5 #include "DownloadQueue.h"
6 #include "updownclient.h"
7 #include "ServerList.h"
8 #include "Preferences.h"
9 #include "ExternalConn.h"
13 # include "amuleDlg.h"
14 # include "ServerWnd.h"
15 # include "SearchDlg.h"
16 # include "TransferWnd.h"
17 # include "SharedFilesWnd.h"
18 # include "ServerListCtrl.h"
19 # include "ClientListCtrl.h"
20 # include "SharedFilesCtrl.h"
21 # include "DownloadListCtrl.h"
22 # include "muuli_wdr.h"
26 # define NOT_ON_DAEMON(x) WXUNUSED(x)
28 # define NOT_ON_DAEMON(x) x
32 DEFINE_LOCAL_EVENT_TYPE(MULE_EVT_NOTIFY
)
38 void HandleNotification(const CMuleNotiferBase
& ntf
)
40 if (wxThread::IsMain()) {
41 #if defined(AMULE_DAEMON) || defined(REMOTE_GUI)
44 if (theApp
->amuledlg
) {
49 CMuleGUIEvent
evt(ntf
.Clone());
50 wxPostEvent(wxTheApp
, evt
);
54 void Search_Add_Download(CSearchFile
* file
, uint8 category
)
56 theApp
->downloadqueue
->AddSearchToDownload(file
, category
);
60 void ShowUserCount(wxString
NOT_ON_DAEMON(str
))
63 theApp
->amuledlg
->ShowUserCount(str
);
68 void Search_Update_Progress(uint32
NOT_ON_DAEMON(val
))
71 if (theApp
->amuledlg
->m_searchwnd
) {
73 // Global search ended
74 theApp
->amuledlg
->m_searchwnd
->ResetControls();
76 theApp
->amuledlg
->m_searchwnd
->UpdateProgress(val
);
83 void DownloadCtrlUpdateItem(const void* item
)
86 theApp
->ECServerHandler
->m_ec_notifier
->DownloadFile_SetDirty((CPartFile
*)item
);
89 if (theApp
->amuledlg
->m_transferwnd
&& theApp
->amuledlg
->m_transferwnd
->downloadlistctrl
) {
90 theApp
->amuledlg
->m_transferwnd
->downloadlistctrl
->UpdateItem(item
);
96 void NodesURLChanged(wxString
NOT_ON_DAEMON(url
))
99 CastByID(IDC_NODESLISTURL
, NULL
, wxTextCtrl
)->SetValue(url
);
103 void ServersURLChanged(wxString
NOT_ON_DAEMON(url
))
106 CastByID(IDC_SERVERLISTURL
, NULL
, wxTextCtrl
)->SetValue(url
);
113 void PartFile_Swap_A4AF(CPartFile
* file
)
115 theApp
->downloadqueue
->SendFileCommand(file
, EC_OP_PARTFILE_SWAP_A4AF_THIS
);
118 void PartFile_Swap_A4AF_Auto(CPartFile
* file
)
120 theApp
->downloadqueue
->SendFileCommand(file
, EC_OP_PARTFILE_SWAP_A4AF_THIS_AUTO
);
123 void PartFile_Swap_A4AF_Others(CPartFile
* file
)
125 theApp
->downloadqueue
->SendFileCommand(file
, EC_OP_PARTFILE_SWAP_A4AF_OTHERS
);
128 void PartFile_Pause(CPartFile
* file
)
130 theApp
->downloadqueue
->SendFileCommand(file
, EC_OP_PARTFILE_PAUSE
);
133 void PartFile_Resume(CPartFile
* file
)
135 theApp
->downloadqueue
->SendFileCommand(file
, EC_OP_PARTFILE_RESUME
);
138 void PartFile_Stop(CPartFile
* file
)
140 theApp
->downloadqueue
->SendFileCommand(file
, EC_OP_PARTFILE_STOP
);
143 void PartFile_PrioAuto(CPartFile
* file
, bool val
)
145 theApp
->downloadqueue
->AutoPrio(file
, val
);
148 void PartFile_PrioSet(CPartFile
* file
, uint8 newDownPriority
, bool)
150 theApp
->downloadqueue
->Prio(file
, newDownPriority
);
153 void PartFile_Delete(CPartFile
* file
)
155 theApp
->downloadqueue
->SendFileCommand(file
, EC_OP_PARTFILE_DELETE
);
158 void PartFile_SetCat(CPartFile
* file
, uint32 val
)
160 theApp
->downloadqueue
->Category(file
, val
);
163 void KnownFile_Up_Prio_Set(CKnownFile
* file
, uint8 val
)
165 theApp
->sharedfiles
->SetFilePrio(file
, val
);
168 void KnownFile_Up_Prio_Auto(CKnownFile
* file
)
170 theApp
->sharedfiles
->SetFilePrio(file
, PR_AUTO
);
173 void Download_Set_Cat_Prio(uint8
, uint8
)
177 void Download_Set_Cat_Status(uint8
, int)
183 void SharedFilesShowFile(CKnownFile
* NOT_ON_DAEMON(file
))
186 if (theApp
->amuledlg
->m_sharedfileswnd
&& theApp
->amuledlg
->m_sharedfileswnd
->sharedfilesctrl
) {
187 theApp
->amuledlg
->m_sharedfileswnd
->sharedfilesctrl
->ShowFile(file
);
192 void SharedFilesRemoveFile(CKnownFile
* NOT_ON_DAEMON(file
))
195 if (theApp
->amuledlg
->m_sharedfileswnd
&& theApp
->amuledlg
->m_sharedfileswnd
->sharedfilesctrl
) {
196 theApp
->amuledlg
->m_sharedfileswnd
->sharedfilesctrl
->RemoveFile(file
);
201 void SharedFilesRemoveAllFiles()
204 if (theApp
->amuledlg
->m_sharedfileswnd
) {
205 theApp
->amuledlg
->m_sharedfileswnd
->RemoveAllSharedFiles();
211 void SharedFilesShowFileList()
214 if (theApp
->amuledlg
->m_sharedfileswnd
&& theApp
->amuledlg
->m_sharedfileswnd
->sharedfilesctrl
) {
215 theApp
->amuledlg
->m_sharedfileswnd
->sharedfilesctrl
->ShowFileList();
221 void SharedFilesUpdateItem(CKnownFile
* NOT_ON_DAEMON(file
))
224 if (theApp
->amuledlg
->m_sharedfileswnd
&& theApp
->amuledlg
->m_sharedfileswnd
->sharedfilesctrl
) {
225 theApp
->amuledlg
->m_sharedfileswnd
->sharedfilesctrl
->UpdateItem(file
);
231 void DownloadCtrlAddFile(CPartFile
* file
)
234 theApp
->ECServerHandler
->m_ec_notifier
->DownloadFile_AddFile(file
);
237 if (theApp
->amuledlg
->m_transferwnd
&& theApp
->amuledlg
->m_transferwnd
->downloadlistctrl
) {
238 theApp
->amuledlg
->m_transferwnd
->downloadlistctrl
->AddFile(file
);
243 void DownloadCtrlAddSource(CPartFile
* NOT_ON_DAEMON(owner
), CUpDownClient
* NOT_ON_DAEMON(source
), DownloadItemType
NOT_ON_DAEMON(type
))
246 if (theApp
->amuledlg
->m_transferwnd
&& theApp
->amuledlg
->m_transferwnd
->downloadlistctrl
) {
247 if (owner
->ShowSources()) {
248 theApp
->amuledlg
->m_transferwnd
->downloadlistctrl
->AddSource(owner
, source
, type
);
254 void DownloadCtrlRemoveFile(CPartFile
* file
)
257 theApp
->ECServerHandler
->m_ec_notifier
->DownloadFile_RemoveFile(file
);
260 if (theApp
->amuledlg
->m_transferwnd
&& theApp
->amuledlg
->m_transferwnd
->downloadlistctrl
) {
261 theApp
->amuledlg
->m_transferwnd
->downloadlistctrl
->RemoveFile(file
);
266 void DownloadCtrlRemoveSource(const CUpDownClient
* NOT_ON_DAEMON(source
), const CPartFile
* NOT_ON_DAEMON(owner
))
269 if (theApp
->amuledlg
->m_transferwnd
&& theApp
->amuledlg
->m_transferwnd
->downloadlistctrl
) {
270 if ((owner
== NULL
) || owner
->ShowSources()) {
271 theApp
->amuledlg
->m_transferwnd
->downloadlistctrl
->RemoveSource(source
, owner
);
277 void DownloadCtrlHideSource(CPartFile
* NOT_ON_DAEMON(file
))
280 if (theApp
->amuledlg
->m_transferwnd
&& theApp
->amuledlg
->m_transferwnd
->downloadlistctrl
) {
281 theApp
->amuledlg
->m_transferwnd
->downloadlistctrl
->ShowSources(file
, false);
286 void DownloadCtrlSort()
289 if (theApp
->amuledlg
->m_transferwnd
&& theApp
->amuledlg
->m_transferwnd
->downloadlistctrl
) {
290 theApp
->amuledlg
->m_transferwnd
->downloadlistctrl
->SortList();
296 void ClientCtrlAddClient(CUpDownClient
* NOT_ON_DAEMON(client
), ViewType
NOT_ON_DAEMON(type
))
299 if (theApp
->amuledlg
->m_transferwnd
&& theApp
->amuledlg
->m_transferwnd
->clientlistctrl
) {
300 theApp
->amuledlg
->m_transferwnd
->clientlistctrl
->InsertClient(client
, type
);
305 void ClientCtrlRefreshClient(CUpDownClient
* NOT_ON_DAEMON(client
), ViewType
NOT_ON_DAEMON(type
))
308 if (theApp
->amuledlg
->m_transferwnd
&& theApp
->amuledlg
->m_transferwnd
->clientlistctrl
) {
309 theApp
->amuledlg
->m_transferwnd
->clientlistctrl
->UpdateClient(client
, type
);
314 void ClientCtrlRemoveClient(CUpDownClient
* NOT_ON_DAEMON(client
), ViewType
NOT_ON_DAEMON(type
))
317 if (theApp
->amuledlg
->m_transferwnd
&& theApp
->amuledlg
->m_transferwnd
->clientlistctrl
) {
318 theApp
->amuledlg
->m_transferwnd
->clientlistctrl
->RemoveClient(client
, type
);
324 void ServerAdd(CServer
* NOT_ON_DAEMON(server
))
327 if (theApp
->amuledlg
->m_serverwnd
&& theApp
->amuledlg
->m_serverwnd
->serverlistctrl
) {
328 theApp
->amuledlg
->m_serverwnd
->serverlistctrl
->AddServer(server
);
333 void ServerRemove(CServer
* NOT_ON_DAEMON(server
))
336 if (theApp
->amuledlg
->m_serverwnd
&& theApp
->amuledlg
->m_serverwnd
->serverlistctrl
) {
337 theApp
->amuledlg
->m_serverwnd
->serverlistctrl
->RemoveServer(server
);
342 void ServerRemoveDead()
344 if (theApp
->serverlist
) {
345 theApp
->serverlist
->RemoveDeadServers();
349 void ServerRemoveAll()
352 if (theApp
->amuledlg
->m_serverwnd
&& theApp
->amuledlg
->m_serverwnd
->serverlistctrl
) {
353 theApp
->amuledlg
->m_serverwnd
->serverlistctrl
->DeleteAllItems();
358 void ServerHighlight(CServer
* NOT_ON_DAEMON(server
), bool NOT_ON_DAEMON(highlight
))
361 if (theApp
->amuledlg
->m_serverwnd
&& theApp
->amuledlg
->m_serverwnd
->serverlistctrl
) {
362 theApp
->amuledlg
->m_serverwnd
->serverlistctrl
->HighlightServer(server
, highlight
);
367 void ServerRefresh(CServer
* NOT_ON_DAEMON(server
))
370 if (theApp
->amuledlg
->m_serverwnd
&& theApp
->amuledlg
->m_serverwnd
->serverlistctrl
) {
371 theApp
->amuledlg
->m_serverwnd
->serverlistctrl
->RefreshServer(server
);
379 if (theApp
->amuledlg
->m_serverwnd
&& theApp
->amuledlg
->m_serverwnd
->serverlistctrl
) {
380 theApp
->amuledlg
->m_serverwnd
->serverlistctrl
->Freeze();
388 if (theApp
->amuledlg
->m_serverwnd
&& theApp
->amuledlg
->m_serverwnd
->serverlistctrl
) {
389 theApp
->amuledlg
->m_serverwnd
->serverlistctrl
->Thaw();
394 void ServerUpdateED2KInfo()
397 if (theApp
->amuledlg
->m_serverwnd
) {
398 theApp
->amuledlg
->m_serverwnd
->UpdateED2KInfo();
403 void ServerUpdateKadKInfo()
406 if (theApp
->amuledlg
->m_serverwnd
) {
407 theApp
->amuledlg
->m_serverwnd
->UpdateKadInfo();
416 if (theApp
->amuledlg
->m_searchwnd
) {
417 theApp
->amuledlg
->m_searchwnd
->ResetControls();
422 void SearchLocalEnd()
425 if (theApp
->amuledlg
->m_searchwnd
) {
426 theApp
->amuledlg
->m_searchwnd
->LocalSearchEnd();
431 void KadSearchEnd(uint32
NOT_ON_DAEMON(id
))
434 if (theApp
->amuledlg
->m_searchwnd
) {
435 theApp
->amuledlg
->m_searchwnd
->KadSearchEnd(id
);
440 void Search_Update_Sources(CSearchFile
* NOT_ON_DAEMON(result
))
443 if (theApp
->amuledlg
&& theApp
->amuledlg
->m_searchwnd
) {
444 theApp
->amuledlg
->m_searchwnd
->UpdateResult(result
);
449 void Search_Add_Result(CSearchFile
* NOT_ON_DAEMON(result
))
452 if (theApp
->amuledlg
&& theApp
->amuledlg
->m_searchwnd
) {
453 theApp
->amuledlg
->m_searchwnd
->AddResult(result
);
459 void ChatRefreshFriend(uint32
NOT_ON_DAEMON(lastUsedIP
), uint32
NOT_ON_DAEMON(lastUsedPort
), wxString
NOT_ON_DAEMON(name
))
462 if (theApp
->amuledlg
->m_chatwnd
) {
463 theApp
->amuledlg
->m_chatwnd
->RefreshFriend(CMD4Hash(), name
, lastUsedIP
, lastUsedPort
);
468 void ChatConnResult(bool NOT_ON_DAEMON(success
), uint64
NOT_ON_DAEMON(id
), wxString
NOT_ON_DAEMON(message
))
471 if (theApp
->amuledlg
->m_chatwnd
) {
472 theApp
->amuledlg
->m_chatwnd
->ConnectionResult(success
, message
, id
);
477 void ChatProcessMsg(uint64
NOT_ON_DAEMON(sender
), wxString
NOT_ON_DAEMON(message
))
480 if (theApp
->amuledlg
->m_chatwnd
) {
481 theApp
->amuledlg
->m_chatwnd
->ProcessMessage(sender
, message
);
487 void ChatSendCaptcha(wxString
NOT_ON_DAEMON(captcha
), uint64
NOT_ON_DAEMON(to_id
))
490 if (theApp
->amuledlg
->m_chatwnd
) {
491 theApp
->amuledlg
->m_chatwnd
->SendMessage(captcha
, wxEmptyString
, to_id
);
497 void ShowConnState(long WXUNUSED(state
))
500 theApp
->amuledlg
->ShowConnectionState();
504 void ShowQueueCount(uint32
NOT_ON_DAEMON(count
))
507 if (theApp
->amuledlg
->m_transferwnd
) {
508 theApp
->amuledlg
->m_transferwnd
->ShowQueueCount(count
);
513 void ShowUpdateCatTabTitles()
516 if (theApp
->amuledlg
->m_transferwnd
) {
517 theApp
->amuledlg
->m_transferwnd
->UpdateCatTabTitles();
525 theApp
->amuledlg
->Iconize(false);
533 if (theApp
->amuledlg
->m_transferwnd
) {
534 theApp
->amuledlg
->m_transferwnd
->
535 AddCategory(theApp
->glob_prefs
->GetCategory(
536 theApp
->glob_prefs
->GetCatCount()-1));
541 void CategoryUpdate(uint32
NOT_ON_DAEMON(cat
))
544 if (theApp
->amuledlg
->m_transferwnd
) {
545 theApp
->amuledlg
->m_transferwnd
->UpdateCategory(cat
);
546 theApp
->amuledlg
->m_transferwnd
->downloadlistctrl
->Refresh();
547 theApp
->amuledlg
->m_searchwnd
->UpdateCatChoice();
552 void CategoryDelete(uint32
NOT_ON_DAEMON(cat
))
555 if (theApp
->amuledlg
->m_transferwnd
) {
556 theApp
->amuledlg
->m_transferwnd
->RemoveCategory(cat
);
562 void PartFile_Swap_A4AF(CPartFile
* file
)
564 if ((file
->GetStatus(false) == PS_READY
|| file
->GetStatus(false) == PS_EMPTY
)) {
565 CPartFile::SourceSet::const_iterator it
= file
->GetA4AFList().begin();
566 for ( ; it
!= file
->GetA4AFList().end(); ) {
567 CUpDownClient
*cur_source
= *it
++;
569 cur_source
->SwapToAnotherFile(true, false, false, file
);
574 void PartFile_Swap_A4AF_Auto(CPartFile
* file
)
576 file
->SetA4AFAuto(!file
->IsA4AFAuto());
579 void PartFile_Swap_A4AF_Others(CPartFile
* file
)
581 if ((file
->GetStatus(false) == PS_READY
) || (file
->GetStatus(false) == PS_EMPTY
)) {
582 CPartFile::SourceSet::const_iterator it
= file
->GetSourceList().begin();
583 for( ; it
!= file
->GetSourceList().end(); ) {
584 CUpDownClient
* cur_source
= *it
++;
586 cur_source
->SwapToAnotherFile(false, false, false, NULL
);
591 void PartFile_Pause(CPartFile
* file
)
596 void PartFile_Resume(CPartFile
* file
)
599 file
->SavePartFile();
602 void PartFile_Stop(CPartFile
* file
)
607 void PartFile_PrioAuto(CPartFile
* file
, bool val
)
609 file
->SetAutoDownPriority(val
);
612 void PartFile_PrioSet(CPartFile
* file
, uint8 newDownPriority
, bool bSave
)
614 file
->SetDownPriority(newDownPriority
, bSave
);
617 void PartFile_Delete(CPartFile
* file
)
622 void PartFile_SetCat(CPartFile
* file
, uint32 val
)
624 file
->SetCategory(val
);
628 void KnownFile_Up_Prio_Set(CKnownFile
* file
, uint8 val
)
630 file
->SetAutoUpPriority(false);
631 file
->SetUpPriority(val
);
634 void KnownFile_Up_Prio_Auto(CKnownFile
* file
)
636 file
->SetAutoUpPriority(true);
637 file
->UpdateAutoUpPriority();
640 void KnownFile_Comment_Set(CKnownFile
* file
, wxString comment
)
642 file
->SetFileComment(comment
);
646 void Download_Set_Cat_Prio(uint8 cat
, uint8 newprio
)
648 theApp
->downloadqueue
->SetCatPrio(cat
, newprio
);
651 void Download_Set_Cat_Status(uint8 cat
, int newstatus
)
653 theApp
->downloadqueue
->SetCatStatus(cat
, newstatus
);
656 #endif // #ifdef CLIENT_GUI
658 // File_checked_for_headers