5 #include "DownloadQueue.h"
6 #include "updownclient.h"
7 #include "ServerList.h"
8 #include "Preferences.h"
9 #include "ExternalConn.h"
10 #include "SearchFile.h"
11 #include "SearchList.h"
15 # include "amuleDlg.h"
16 # include "ServerWnd.h"
17 # include "SearchDlg.h"
18 # include "TransferWnd.h"
19 # include "SharedFilesWnd.h"
20 # include "ServerListCtrl.h"
21 # include "ClientListCtrl.h"
22 # include "SharedFilesCtrl.h"
23 # include "DownloadListCtrl.h"
24 # include "muuli_wdr.h"
25 # include "PartFileConvertDlg.h"
29 # include "PartFileConvert.h"
33 DEFINE_LOCAL_EVENT_TYPE(MULE_EVT_NOTIFY
)
39 void HandleNotification(const CMuleNotiferBase
& ntf
)
41 if (wxThread::IsMain()) {
42 #if defined(AMULE_DAEMON)
45 if (theApp
->amuledlg
) {
50 CMuleGUIEvent
evt(ntf
.Clone());
51 wxPostEvent(wxTheApp
, evt
);
55 void Search_Add_Download(CSearchFile
* file
, uint8 category
)
57 theApp
->downloadqueue
->AddSearchToDownload(file
, category
);
61 void ShowUserCount(wxString
NOT_ON_DAEMON(str
))
64 theApp
->amuledlg
->ShowUserCount(str
);
69 void Search_Update_Progress(uint32
NOT_ON_DAEMON(val
))
72 if (theApp
->amuledlg
->m_searchwnd
) {
74 // Global search ended
75 theApp
->amuledlg
->m_searchwnd
->ResetControls();
76 } else if (val
== 0xfffe) {
78 theApp
->amuledlg
->m_searchwnd
->KadSearchEnd(0);
80 theApp
->amuledlg
->m_searchwnd
->UpdateProgress(val
);
87 void DownloadCtrlUpdateItem(const void* item
)
90 theApp
->ECServerHandler
->m_ec_notifier
->DownloadFile_SetDirty((CPartFile
*)item
);
93 if (theApp
->amuledlg
->m_transferwnd
&& theApp
->amuledlg
->m_transferwnd
->downloadlistctrl
) {
94 theApp
->amuledlg
->m_transferwnd
->downloadlistctrl
->UpdateItem(item
);
100 void NodesURLChanged(wxString
NOT_ON_DAEMON(url
))
103 CastByID(IDC_NODESLISTURL
, NULL
, wxTextCtrl
)->SetValue(url
);
107 void ServersURLChanged(wxString
NOT_ON_DAEMON(url
))
110 CastByID(IDC_SERVERLISTURL
, NULL
, wxTextCtrl
)->SetValue(url
);
114 void ConvertUpdateProgress(float NOT_ON_DAEMON(percent
), wxString
NOT_ON_DAEMON(text
), wxString
NOT_ON_DAEMON(header
))
117 CPartFileConvertDlg::UpdateProgress(percent
, text
, header
);
121 void ConvertUpdateJobInfo(ConvertInfo
NOT_ON_DAEMON(info
))
124 CPartFileConvertDlg::UpdateJobInfo(info
);
128 void ConvertRemoveJobInfo(unsigned NOT_ON_DAEMON(id
))
131 CPartFileConvertDlg::RemoveJobInfo(id
);
135 void ConvertClearInfos()
138 CPartFileConvertDlg::ClearInfo();
142 void ConvertRemoveJob(unsigned NOT_ON_REMOTEGUI(id
))
145 CPartFileConvert::RemoveJob(id
);
149 void ConvertRetryJob(unsigned NOT_ON_REMOTEGUI(id
))
152 CPartFileConvert::RetryJob(id
);
156 void ConvertReaddAllJobs()
159 CPartFileConvert::ReaddAllJobs();
166 theApp
->amuledlg
->Iconize(false);
172 void PartFile_Swap_A4AF(CPartFile
* file
)
174 theApp
->downloadqueue
->SendFileCommand(file
, EC_OP_PARTFILE_SWAP_A4AF_THIS
);
177 void PartFile_Swap_A4AF_Auto(CPartFile
* file
)
179 theApp
->downloadqueue
->SendFileCommand(file
, EC_OP_PARTFILE_SWAP_A4AF_THIS_AUTO
);
182 void PartFile_Swap_A4AF_Others(CPartFile
* file
)
184 theApp
->downloadqueue
->SendFileCommand(file
, EC_OP_PARTFILE_SWAP_A4AF_OTHERS
);
187 void PartFile_Pause(CPartFile
* file
)
189 theApp
->downloadqueue
->SendFileCommand(file
, EC_OP_PARTFILE_PAUSE
);
192 void PartFile_Resume(CPartFile
* file
)
194 theApp
->downloadqueue
->SendFileCommand(file
, EC_OP_PARTFILE_RESUME
);
197 void PartFile_Stop(CPartFile
* file
)
199 theApp
->downloadqueue
->SendFileCommand(file
, EC_OP_PARTFILE_STOP
);
202 void PartFile_PrioAuto(CPartFile
* file
, bool val
)
204 theApp
->downloadqueue
->AutoPrio(file
, val
);
207 void PartFile_PrioSet(CPartFile
* file
, uint8 newDownPriority
, bool)
209 theApp
->downloadqueue
->Prio(file
, newDownPriority
);
212 void PartFile_Delete(CPartFile
* file
)
214 theApp
->downloadqueue
->SendFileCommand(file
, EC_OP_PARTFILE_DELETE
);
217 void PartFile_SetCat(CPartFile
* file
, uint32 val
)
219 theApp
->downloadqueue
->Category(file
, val
);
222 void KnownFile_Up_Prio_Set(CKnownFile
* file
, uint8 val
)
224 theApp
->sharedfiles
->SetFilePrio(file
, val
);
227 void KnownFile_Up_Prio_Auto(CKnownFile
* file
)
229 theApp
->sharedfiles
->SetFilePrio(file
, PR_AUTO
);
232 void Download_Set_Cat_Prio(uint8
, uint8
)
236 void Download_Set_Cat_Status(uint8
, int)
242 void SharedFilesShowFile(CKnownFile
* NOT_ON_DAEMON(file
))
245 if (theApp
->amuledlg
->m_sharedfileswnd
&& theApp
->amuledlg
->m_sharedfileswnd
->sharedfilesctrl
) {
246 theApp
->amuledlg
->m_sharedfileswnd
->sharedfilesctrl
->ShowFile(file
);
251 void SharedFilesRemoveFile(CKnownFile
* NOT_ON_DAEMON(file
))
254 if (theApp
->amuledlg
->m_sharedfileswnd
&& theApp
->amuledlg
->m_sharedfileswnd
->sharedfilesctrl
) {
255 theApp
->amuledlg
->m_sharedfileswnd
->sharedfilesctrl
->RemoveFile(file
);
260 void SharedFilesRemoveAllFiles()
263 if (theApp
->amuledlg
->m_sharedfileswnd
) {
264 theApp
->amuledlg
->m_sharedfileswnd
->RemoveAllSharedFiles();
270 void SharedFilesShowFileList()
273 if (theApp
->amuledlg
->m_sharedfileswnd
&& theApp
->amuledlg
->m_sharedfileswnd
->sharedfilesctrl
) {
274 theApp
->amuledlg
->m_sharedfileswnd
->sharedfilesctrl
->ShowFileList();
280 void SharedFilesUpdateItem(CKnownFile
* NOT_ON_DAEMON(file
))
283 if (theApp
->amuledlg
->m_sharedfileswnd
&& theApp
->amuledlg
->m_sharedfileswnd
->sharedfilesctrl
) {
284 theApp
->amuledlg
->m_sharedfileswnd
->sharedfilesctrl
->UpdateItem(file
);
290 void DownloadCtrlAddFile(CPartFile
* file
)
292 theApp
->ECServerHandler
->m_ec_notifier
->DownloadFile_AddFile(file
);
294 if (theApp
->amuledlg
->m_transferwnd
&& theApp
->amuledlg
->m_transferwnd
->downloadlistctrl
) {
295 theApp
->amuledlg
->m_transferwnd
->downloadlistctrl
->AddFile(file
);
300 void DownloadCtrlAddSource(CPartFile
* NOT_ON_DAEMON(owner
), CUpDownClient
* NOT_ON_DAEMON(source
), DownloadItemType
NOT_ON_DAEMON(type
))
303 if (theApp
->amuledlg
->m_transferwnd
&& theApp
->amuledlg
->m_transferwnd
->downloadlistctrl
) {
304 if (owner
->ShowSources()) {
305 theApp
->amuledlg
->m_transferwnd
->downloadlistctrl
->AddSource(owner
, source
, type
);
311 void DownloadCtrlRemoveFile(CPartFile
* file
)
313 theApp
->ECServerHandler
->m_ec_notifier
->DownloadFile_RemoveFile(file
);
315 if (theApp
->amuledlg
->m_transferwnd
&& theApp
->amuledlg
->m_transferwnd
->downloadlistctrl
) {
316 theApp
->amuledlg
->m_transferwnd
->downloadlistctrl
->RemoveFile(file
);
321 void DownloadCtrlRemoveSource(const CUpDownClient
* NOT_ON_DAEMON(source
), const CPartFile
* NOT_ON_DAEMON(owner
))
324 if (theApp
->amuledlg
->m_transferwnd
&& theApp
->amuledlg
->m_transferwnd
->downloadlistctrl
) {
325 if ((owner
== NULL
) || owner
->ShowSources()) {
326 theApp
->amuledlg
->m_transferwnd
->downloadlistctrl
->RemoveSource(source
, owner
);
332 void DownloadCtrlHideSource(CPartFile
* NOT_ON_DAEMON(file
))
335 if (theApp
->amuledlg
->m_transferwnd
&& theApp
->amuledlg
->m_transferwnd
->downloadlistctrl
) {
336 theApp
->amuledlg
->m_transferwnd
->downloadlistctrl
->ShowSources(file
, false);
341 void DownloadCtrlSort()
344 if (theApp
->amuledlg
->m_transferwnd
&& theApp
->amuledlg
->m_transferwnd
->downloadlistctrl
) {
345 theApp
->amuledlg
->m_transferwnd
->downloadlistctrl
->SortList();
351 void ClientCtrlAddClient(CUpDownClient
* NOT_ON_DAEMON(client
), ViewType
NOT_ON_DAEMON(type
))
354 if (theApp
->amuledlg
->m_transferwnd
&& theApp
->amuledlg
->m_transferwnd
->clientlistctrl
) {
355 theApp
->amuledlg
->m_transferwnd
->clientlistctrl
->InsertClient(client
, type
);
360 void ClientCtrlRefreshClient(CUpDownClient
* NOT_ON_DAEMON(client
), ViewType
NOT_ON_DAEMON(type
))
363 if (theApp
->amuledlg
->m_transferwnd
&& theApp
->amuledlg
->m_transferwnd
->clientlistctrl
) {
364 theApp
->amuledlg
->m_transferwnd
->clientlistctrl
->UpdateClient(client
, type
);
369 void ClientCtrlRemoveClient(CUpDownClient
* NOT_ON_DAEMON(client
), ViewType
NOT_ON_DAEMON(type
))
372 if (theApp
->amuledlg
->m_transferwnd
&& theApp
->amuledlg
->m_transferwnd
->clientlistctrl
) {
373 theApp
->amuledlg
->m_transferwnd
->clientlistctrl
->RemoveClient(client
, type
);
379 void ServerAdd(CServer
* NOT_ON_DAEMON(server
))
382 if (theApp
->amuledlg
->m_serverwnd
&& theApp
->amuledlg
->m_serverwnd
->serverlistctrl
) {
383 theApp
->amuledlg
->m_serverwnd
->serverlistctrl
->AddServer(server
);
388 void ServerRemove(CServer
* NOT_ON_DAEMON(server
))
391 if (theApp
->amuledlg
->m_serverwnd
&& theApp
->amuledlg
->m_serverwnd
->serverlistctrl
) {
392 theApp
->amuledlg
->m_serverwnd
->serverlistctrl
->RemoveServer(server
);
397 void ServerRemoveDead()
399 if (theApp
->serverlist
) {
400 theApp
->serverlist
->RemoveDeadServers();
404 void ServerRemoveAll()
407 if (theApp
->amuledlg
->m_serverwnd
&& theApp
->amuledlg
->m_serverwnd
->serverlistctrl
) {
408 theApp
->amuledlg
->m_serverwnd
->serverlistctrl
->DeleteAllItems();
413 void ServerHighlight(CServer
* NOT_ON_DAEMON(server
), bool NOT_ON_DAEMON(highlight
))
416 if (theApp
->amuledlg
->m_serverwnd
&& theApp
->amuledlg
->m_serverwnd
->serverlistctrl
) {
417 theApp
->amuledlg
->m_serverwnd
->serverlistctrl
->HighlightServer(server
, highlight
);
422 void ServerRefresh(CServer
* NOT_ON_DAEMON(server
))
425 if (theApp
->amuledlg
->m_serverwnd
&& theApp
->amuledlg
->m_serverwnd
->serverlistctrl
) {
426 theApp
->amuledlg
->m_serverwnd
->serverlistctrl
->RefreshServer(server
);
434 if (theApp
->amuledlg
->m_serverwnd
&& theApp
->amuledlg
->m_serverwnd
->serverlistctrl
) {
435 theApp
->amuledlg
->m_serverwnd
->serverlistctrl
->Freeze();
443 if (theApp
->amuledlg
->m_serverwnd
&& theApp
->amuledlg
->m_serverwnd
->serverlistctrl
) {
444 theApp
->amuledlg
->m_serverwnd
->serverlistctrl
->Thaw();
449 void ServerUpdateED2KInfo()
452 if (theApp
->amuledlg
->m_serverwnd
) {
453 theApp
->amuledlg
->m_serverwnd
->UpdateED2KInfo();
458 void ServerUpdateKadKInfo()
461 if (theApp
->amuledlg
->m_serverwnd
) {
462 theApp
->amuledlg
->m_serverwnd
->UpdateKadInfo();
471 if (theApp
->amuledlg
->m_searchwnd
) {
472 theApp
->amuledlg
->m_searchwnd
->ResetControls();
477 void SearchLocalEnd()
480 if (theApp
->amuledlg
->m_searchwnd
) {
481 theApp
->amuledlg
->m_searchwnd
->LocalSearchEnd();
486 void KadSearchEnd(uint32
NOT_ON_DAEMON(id
))
489 if (theApp
->amuledlg
->m_searchwnd
) {
490 theApp
->amuledlg
->m_searchwnd
->KadSearchEnd(id
);
493 theApp
->searchlist
->SetKadSearchFinished();
496 void Search_Update_Sources(CSearchFile
* result
)
498 result
->SetDownloadStatus();
500 if (theApp
->amuledlg
&& theApp
->amuledlg
->m_searchwnd
) {
501 theApp
->amuledlg
->m_searchwnd
->UpdateResult(result
);
506 void Search_Add_Result(CSearchFile
* NOT_ON_DAEMON(result
))
509 if (theApp
->amuledlg
&& theApp
->amuledlg
->m_searchwnd
) {
510 theApp
->amuledlg
->m_searchwnd
->AddResult(result
);
516 void ChatRefreshFriend(CFriend
* NOT_ON_DAEMON(Friend
), bool NOT_ON_DAEMON(connected
))
519 if (theApp
->amuledlg
->m_chatwnd
) {
520 theApp
->amuledlg
->m_chatwnd
->RefreshFriend(Friend
, connected
);
525 void ChatConnResult(bool NOT_ON_DAEMON(success
), uint64
NOT_ON_DAEMON(id
), wxString
NOT_ON_DAEMON(message
))
528 if (theApp
->amuledlg
->m_chatwnd
) {
529 theApp
->amuledlg
->m_chatwnd
->ConnectionResult(success
, message
, id
);
534 void ChatProcessMsg(uint64
NOT_ON_DAEMON(sender
), wxString
NOT_ON_DAEMON(message
))
537 if (theApp
->amuledlg
->m_chatwnd
) {
538 theApp
->amuledlg
->m_chatwnd
->ProcessMessage(sender
, message
);
544 void ChatSendCaptcha(wxString
NOT_ON_DAEMON(captcha
), uint64
NOT_ON_DAEMON(to_id
))
547 if (theApp
->amuledlg
->m_chatwnd
) {
548 theApp
->amuledlg
->m_chatwnd
->SendMessage(captcha
, wxEmptyString
, to_id
);
554 void ShowConnState(long WXUNUSED(state
))
557 theApp
->amuledlg
->ShowConnectionState();
561 void ShowQueueCount(uint32
NOT_ON_DAEMON(count
))
564 if (theApp
->amuledlg
->m_transferwnd
) {
565 theApp
->amuledlg
->m_transferwnd
->ShowQueueCount(count
);
570 void ShowUpdateCatTabTitles()
573 if (theApp
->amuledlg
->m_transferwnd
) {
574 theApp
->amuledlg
->m_transferwnd
->UpdateCatTabTitles();
582 if (theApp
->amuledlg
->m_transferwnd
) {
583 theApp
->amuledlg
->m_transferwnd
->
584 AddCategory(theApp
->glob_prefs
->GetCategory(
585 theApp
->glob_prefs
->GetCatCount()-1));
590 void CategoryUpdate(uint32
NOT_ON_DAEMON(cat
))
593 if (theApp
->amuledlg
->m_transferwnd
) {
594 theApp
->amuledlg
->m_transferwnd
->UpdateCategory(cat
);
595 theApp
->amuledlg
->m_transferwnd
->downloadlistctrl
->Refresh();
596 theApp
->amuledlg
->m_searchwnd
->UpdateCatChoice();
601 void CategoryDelete(uint32 cat
)
605 theApp
->downloadqueue
->ResetCatParts(cat
);
606 theApp
->glob_prefs
->RemoveCat(cat
);
607 if ( theApp
->glob_prefs
->GetCatCount() == 1 ) {
608 thePrefs::SetAllcatType(0);
610 theApp
->glob_prefs
->SaveCats();
613 if (theApp
->amuledlg
->m_transferwnd
) {
614 theApp
->amuledlg
->m_transferwnd
->RemoveCategory(cat
);
620 void PartFile_Swap_A4AF(CPartFile
* file
)
622 if ((file
->GetStatus(false) == PS_READY
|| file
->GetStatus(false) == PS_EMPTY
)) {
623 CPartFile::SourceSet::const_iterator it
= file
->GetA4AFList().begin();
624 for ( ; it
!= file
->GetA4AFList().end(); ) {
625 CUpDownClient
*cur_source
= *it
++;
627 cur_source
->SwapToAnotherFile(true, false, false, file
);
632 void PartFile_Swap_A4AF_Auto(CPartFile
* file
)
634 file
->SetA4AFAuto(!file
->IsA4AFAuto());
637 void PartFile_Swap_A4AF_Others(CPartFile
* file
)
639 if ((file
->GetStatus(false) == PS_READY
) || (file
->GetStatus(false) == PS_EMPTY
)) {
640 CPartFile::SourceSet::const_iterator it
= file
->GetSourceList().begin();
641 for( ; it
!= file
->GetSourceList().end(); ) {
642 CUpDownClient
* cur_source
= *it
++;
644 cur_source
->SwapToAnotherFile(false, false, false, NULL
);
649 void PartFile_Pause(CPartFile
* file
)
654 void PartFile_Resume(CPartFile
* file
)
657 file
->SavePartFile();
660 void PartFile_Stop(CPartFile
* file
)
665 void PartFile_PrioAuto(CPartFile
* file
, bool val
)
667 file
->SetAutoDownPriority(val
);
670 void PartFile_PrioSet(CPartFile
* file
, uint8 newDownPriority
, bool bSave
)
672 file
->SetDownPriority(newDownPriority
, bSave
);
675 void PartFile_Delete(CPartFile
* file
)
680 void PartFile_SetCat(CPartFile
* file
, uint32 val
)
682 file
->SetCategory(val
);
686 void KnownFile_Up_Prio_Set(CKnownFile
* file
, uint8 val
)
688 file
->SetAutoUpPriority(false);
689 file
->SetUpPriority(val
);
692 void KnownFile_Up_Prio_Auto(CKnownFile
* file
)
694 file
->SetAutoUpPriority(true);
695 file
->UpdateAutoUpPriority();
698 void KnownFile_Comment_Set(CKnownFile
* file
, wxString comment
)
700 file
->SetFileComment(comment
);
704 void Download_Set_Cat_Prio(uint8 cat
, uint8 newprio
)
706 theApp
->downloadqueue
->SetCatPrio(cat
, newprio
);
709 void Download_Set_Cat_Status(uint8 cat
, int newstatus
)
711 theApp
->downloadqueue
->SetCatStatus(cat
, newstatus
);
714 #endif // #ifdef CLIENT_GUI
716 // File_checked_for_headers