5 #include "DownloadQueue.h"
6 #include "updownclient.h"
7 #include "ServerList.h"
8 #include "Preferences.h"
12 # include "amuleDlg.h"
13 # include "ServerWnd.h"
14 # include "SearchDlg.h"
15 # include "TransferWnd.h"
16 # include "SharedFilesWnd.h"
17 # include "ServerListCtrl.h"
18 # include "ClientListCtrl.h"
19 # include "SharedFilesCtrl.h"
20 # include "DownloadListCtrl.h"
21 # include "muuli_wdr.h"
25 # define NOT_ON_DAEMON(x) WXUNUSED(x)
27 # define NOT_ON_DAEMON(x) x
31 DEFINE_LOCAL_EVENT_TYPE(MULE_EVT_NOTIFY
)
37 void HandleNotification(const CMuleNotiferBase
& ntf
)
39 if (wxThread::IsMain()) {
40 #if defined(AMULE_DAEMON) || defined(REMOTE_GUI)
43 if (theApp
->amuledlg
) {
48 CMuleGUIEvent
evt(ntf
.Clone());
49 wxPostEvent(wxTheApp
, evt
);
53 void Search_Add_Download(CSearchFile
* file
, uint8 category
)
55 theApp
->downloadqueue
->AddSearchToDownload(file
, category
);
59 void ShowUserCount(wxString
NOT_ON_DAEMON(str
))
62 theApp
->amuledlg
->ShowUserCount(str
);
67 void Search_Update_Progress(uint32
NOT_ON_DAEMON(val
))
70 if (theApp
->amuledlg
->m_searchwnd
) {
72 // Global search ended
73 theApp
->amuledlg
->m_searchwnd
->ResetControls();
75 theApp
->amuledlg
->m_searchwnd
->UpdateProgress(val
);
82 void DownloadCtrlUpdateItem(const void* NOT_ON_DAEMON(item
))
85 if (theApp
->amuledlg
->m_transferwnd
&& theApp
->amuledlg
->m_transferwnd
->downloadlistctrl
) {
86 theApp
->amuledlg
->m_transferwnd
->downloadlistctrl
->UpdateItem(item
);
92 void NodesURLChanged(wxString
NOT_ON_DAEMON(url
))
95 CastByID(IDC_NODESLISTURL
, NULL
, wxTextCtrl
)->SetValue(url
);
99 void ServersURLChanged(wxString
NOT_ON_DAEMON(url
))
102 CastByID(IDC_SERVERLISTURL
, NULL
, wxTextCtrl
)->SetValue(url
);
109 void PartFile_Swap_A4AF(CPartFile
* file
)
111 theApp
->downloadqueue
->SendFileCommand(file
, EC_OP_PARTFILE_SWAP_A4AF_THIS
);
114 void PartFile_Swap_A4AF_Auto(CPartFile
* file
)
116 theApp
->downloadqueue
->SendFileCommand(file
, EC_OP_PARTFILE_SWAP_A4AF_THIS_AUTO
);
119 void PartFile_Swap_A4AF_Others(CPartFile
* file
)
121 theApp
->downloadqueue
->SendFileCommand(file
, EC_OP_PARTFILE_SWAP_A4AF_OTHERS
);
124 void PartFile_Pause(CPartFile
* file
)
126 theApp
->downloadqueue
->SendFileCommand(file
, EC_OP_PARTFILE_PAUSE
);
129 void PartFile_Resume(CPartFile
* file
)
131 theApp
->downloadqueue
->SendFileCommand(file
, EC_OP_PARTFILE_RESUME
);
134 void PartFile_Stop(CPartFile
* file
)
136 theApp
->downloadqueue
->SendFileCommand(file
, EC_OP_PARTFILE_STOP
);
139 void PartFile_PrioAuto(CPartFile
* file
, bool val
)
141 theApp
->downloadqueue
->AutoPrio(file
, val
);
144 void PartFile_PrioSet(CPartFile
* file
, uint8 newDownPriority
, bool)
146 theApp
->downloadqueue
->Prio(file
, newDownPriority
);
149 void PartFile_Delete(CPartFile
* file
)
151 theApp
->downloadqueue
->SendFileCommand(file
, EC_OP_PARTFILE_DELETE
);
154 void PartFile_SetCat(CPartFile
* file
, uint32 val
)
156 theApp
->downloadqueue
->Category(file
, val
);
159 void KnownFile_Up_Prio_Set(CKnownFile
* file
, uint8 val
)
161 theApp
->sharedfiles
->SetFilePrio(file
, val
);
164 void KnownFile_Up_Prio_Auto(CKnownFile
* file
)
166 theApp
->sharedfiles
->SetFilePrio(file
, PR_AUTO
);
169 void Download_Set_Cat_Prio(uint8
, uint8
)
173 void Download_Set_Cat_Status(uint8
, int)
179 void SharedFilesShowFile(CKnownFile
* NOT_ON_DAEMON(file
))
182 if (theApp
->amuledlg
->m_sharedfileswnd
&& theApp
->amuledlg
->m_sharedfileswnd
->sharedfilesctrl
) {
183 theApp
->amuledlg
->m_sharedfileswnd
->sharedfilesctrl
->ShowFile(file
);
188 void SharedFilesRemoveFile(CKnownFile
* NOT_ON_DAEMON(file
))
191 if (theApp
->amuledlg
->m_sharedfileswnd
&& theApp
->amuledlg
->m_sharedfileswnd
->sharedfilesctrl
) {
192 theApp
->amuledlg
->m_sharedfileswnd
->sharedfilesctrl
->RemoveFile(file
);
197 void SharedFilesRemoveAllFiles()
200 if (theApp
->amuledlg
->m_sharedfileswnd
) {
201 theApp
->amuledlg
->m_sharedfileswnd
->RemoveAllSharedFiles();
207 void SharedFilesShowFileList()
210 if (theApp
->amuledlg
->m_sharedfileswnd
&& theApp
->amuledlg
->m_sharedfileswnd
->sharedfilesctrl
) {
211 theApp
->amuledlg
->m_sharedfileswnd
->sharedfilesctrl
->ShowFileList();
217 void SharedFilesUpdateItem(CKnownFile
* NOT_ON_DAEMON(file
))
220 if (theApp
->amuledlg
->m_sharedfileswnd
&& theApp
->amuledlg
->m_sharedfileswnd
->sharedfilesctrl
) {
221 theApp
->amuledlg
->m_sharedfileswnd
->sharedfilesctrl
->UpdateItem(file
);
227 void DownloadCtrlAddFile(CPartFile
* NOT_ON_DAEMON(file
))
230 if (theApp
->amuledlg
->m_transferwnd
&& theApp
->amuledlg
->m_transferwnd
->downloadlistctrl
) {
231 theApp
->amuledlg
->m_transferwnd
->downloadlistctrl
->AddFile(file
);
236 void DownloadCtrlAddSource(CPartFile
* NOT_ON_DAEMON(owner
), CUpDownClient
* NOT_ON_DAEMON(source
), DownloadItemType
NOT_ON_DAEMON(type
))
239 if (theApp
->amuledlg
->m_transferwnd
&& theApp
->amuledlg
->m_transferwnd
->downloadlistctrl
) {
240 if (owner
->ShowSources()) {
241 theApp
->amuledlg
->m_transferwnd
->downloadlistctrl
->AddSource(owner
, source
, type
);
247 void DownloadCtrlRemoveFile(CPartFile
* NOT_ON_DAEMON(file
))
250 if (theApp
->amuledlg
->m_transferwnd
&& theApp
->amuledlg
->m_transferwnd
->downloadlistctrl
) {
251 theApp
->amuledlg
->m_transferwnd
->downloadlistctrl
->RemoveFile(file
);
256 void DownloadCtrlRemoveSource(const CUpDownClient
* NOT_ON_DAEMON(source
), const CPartFile
* NOT_ON_DAEMON(owner
))
259 if (theApp
->amuledlg
->m_transferwnd
&& theApp
->amuledlg
->m_transferwnd
->downloadlistctrl
) {
260 if ((owner
== NULL
) || owner
->ShowSources()) {
261 theApp
->amuledlg
->m_transferwnd
->downloadlistctrl
->RemoveSource(source
, owner
);
267 void DownloadCtrlHideSource(CPartFile
* NOT_ON_DAEMON(file
))
270 if (theApp
->amuledlg
->m_transferwnd
&& theApp
->amuledlg
->m_transferwnd
->downloadlistctrl
) {
271 theApp
->amuledlg
->m_transferwnd
->downloadlistctrl
->ShowSources(file
, false);
276 void DownloadCtrlSort()
279 if (theApp
->amuledlg
->m_transferwnd
&& theApp
->amuledlg
->m_transferwnd
->downloadlistctrl
) {
280 theApp
->amuledlg
->m_transferwnd
->downloadlistctrl
->SortList();
286 void ClientCtrlAddClient(CUpDownClient
* NOT_ON_DAEMON(client
), ViewType
NOT_ON_DAEMON(type
))
289 if (theApp
->amuledlg
->m_transferwnd
&& theApp
->amuledlg
->m_transferwnd
->clientlistctrl
) {
290 theApp
->amuledlg
->m_transferwnd
->clientlistctrl
->InsertClient(client
, type
);
295 void ClientCtrlRefreshClient(CUpDownClient
* NOT_ON_DAEMON(client
), ViewType
NOT_ON_DAEMON(type
))
298 if (theApp
->amuledlg
->m_transferwnd
&& theApp
->amuledlg
->m_transferwnd
->clientlistctrl
) {
299 theApp
->amuledlg
->m_transferwnd
->clientlistctrl
->UpdateClient(client
, type
);
304 void ClientCtrlRemoveClient(CUpDownClient
* NOT_ON_DAEMON(client
), ViewType
NOT_ON_DAEMON(type
))
307 if (theApp
->amuledlg
->m_transferwnd
&& theApp
->amuledlg
->m_transferwnd
->clientlistctrl
) {
308 theApp
->amuledlg
->m_transferwnd
->clientlistctrl
->RemoveClient(client
, type
);
314 void ServerAdd(CServer
* NOT_ON_DAEMON(server
))
317 if (theApp
->amuledlg
->m_serverwnd
&& theApp
->amuledlg
->m_serverwnd
->serverlistctrl
) {
318 theApp
->amuledlg
->m_serverwnd
->serverlistctrl
->AddServer(server
);
323 void ServerRemove(CServer
* NOT_ON_DAEMON(server
))
326 if (theApp
->amuledlg
->m_serverwnd
&& theApp
->amuledlg
->m_serverwnd
->serverlistctrl
) {
327 theApp
->amuledlg
->m_serverwnd
->serverlistctrl
->RemoveServer(server
);
332 void ServerRemoveDead()
334 if (theApp
->serverlist
) {
335 theApp
->serverlist
->RemoveDeadServers();
339 void ServerRemoveAll()
342 if (theApp
->amuledlg
->m_serverwnd
&& theApp
->amuledlg
->m_serverwnd
->serverlistctrl
) {
343 theApp
->amuledlg
->m_serverwnd
->serverlistctrl
->DeleteAllItems();
348 void ServerHighlight(CServer
* NOT_ON_DAEMON(server
), bool NOT_ON_DAEMON(highlight
))
351 if (theApp
->amuledlg
->m_serverwnd
&& theApp
->amuledlg
->m_serverwnd
->serverlistctrl
) {
352 theApp
->amuledlg
->m_serverwnd
->serverlistctrl
->HighlightServer(server
, highlight
);
357 void ServerRefresh(CServer
* NOT_ON_DAEMON(server
))
360 if (theApp
->amuledlg
->m_serverwnd
&& theApp
->amuledlg
->m_serverwnd
->serverlistctrl
) {
361 theApp
->amuledlg
->m_serverwnd
->serverlistctrl
->RefreshServer(server
);
369 if (theApp
->amuledlg
->m_serverwnd
&& theApp
->amuledlg
->m_serverwnd
->serverlistctrl
) {
370 theApp
->amuledlg
->m_serverwnd
->serverlistctrl
->Freeze();
378 if (theApp
->amuledlg
->m_serverwnd
&& theApp
->amuledlg
->m_serverwnd
->serverlistctrl
) {
379 theApp
->amuledlg
->m_serverwnd
->serverlistctrl
->Thaw();
384 void ServerUpdateED2KInfo()
387 if (theApp
->amuledlg
->m_serverwnd
) {
388 theApp
->amuledlg
->m_serverwnd
->UpdateED2KInfo();
393 void ServerUpdateKadKInfo()
396 if (theApp
->amuledlg
->m_serverwnd
) {
397 theApp
->amuledlg
->m_serverwnd
->UpdateKadInfo();
406 if (theApp
->amuledlg
->m_searchwnd
) {
407 theApp
->amuledlg
->m_searchwnd
->ResetControls();
412 void SearchLocalEnd()
415 if (theApp
->amuledlg
->m_searchwnd
) {
416 theApp
->amuledlg
->m_searchwnd
->LocalSearchEnd();
421 void KadSearchEnd(uint32
NOT_ON_DAEMON(id
))
424 if (theApp
->amuledlg
->m_searchwnd
) {
425 theApp
->amuledlg
->m_searchwnd
->KadSearchEnd(id
);
430 void Search_Update_Sources(CSearchFile
* NOT_ON_DAEMON(result
))
433 if (theApp
->amuledlg
&& theApp
->amuledlg
->m_searchwnd
) {
434 theApp
->amuledlg
->m_searchwnd
->UpdateResult(result
);
439 void Search_Add_Result(CSearchFile
* NOT_ON_DAEMON(result
))
442 if (theApp
->amuledlg
&& theApp
->amuledlg
->m_searchwnd
) {
443 theApp
->amuledlg
->m_searchwnd
->AddResult(result
);
449 void ChatRefreshFriend(uint32
NOT_ON_DAEMON(lastUsedIP
), uint32
NOT_ON_DAEMON(lastUsedPort
), wxString
NOT_ON_DAEMON(name
))
452 if (theApp
->amuledlg
->m_chatwnd
) {
453 theApp
->amuledlg
->m_chatwnd
->RefreshFriend(CMD4Hash(), name
, lastUsedIP
, lastUsedPort
);
458 void ChatConnResult(bool NOT_ON_DAEMON(success
), uint64
NOT_ON_DAEMON(id
), wxString
NOT_ON_DAEMON(message
))
461 if (theApp
->amuledlg
->m_chatwnd
) {
462 theApp
->amuledlg
->m_chatwnd
->ConnectionResult(success
, message
, id
);
467 void ChatProcessMsg(uint64
NOT_ON_DAEMON(sender
), wxString
NOT_ON_DAEMON(message
))
470 if (theApp
->amuledlg
->m_chatwnd
) {
471 theApp
->amuledlg
->m_chatwnd
->ProcessMessage(sender
, message
);
477 void ShowConnState(long NOT_ON_DAEMON(state
))
481 theApp
->m_ConnState
= state
;
484 theApp
->amuledlg
->ShowConnectionState();
488 void ShowQueueCount(uint32
NOT_ON_DAEMON(count
))
491 if (theApp
->amuledlg
->m_transferwnd
) {
492 theApp
->amuledlg
->m_transferwnd
->ShowQueueCount(count
);
497 void ShowUpdateCatTabTitles()
500 if (theApp
->amuledlg
->m_transferwnd
) {
501 theApp
->amuledlg
->m_transferwnd
->UpdateCatTabTitles();
509 theApp
->amuledlg
->Iconize(false);
517 if (theApp
->amuledlg
->m_transferwnd
) {
518 theApp
->amuledlg
->m_transferwnd
->
519 AddCategory(theApp
->glob_prefs
->GetCategory(
520 theApp
->glob_prefs
->GetCatCount()-1));
525 void CategoryUpdate(uint32
NOT_ON_DAEMON(cat
))
528 if (theApp
->amuledlg
->m_transferwnd
) {
529 theApp
->amuledlg
->m_transferwnd
->UpdateCategory(cat
);
530 theApp
->amuledlg
->m_transferwnd
->downloadlistctrl
->Refresh();
531 theApp
->amuledlg
->m_searchwnd
->UpdateCatChoice();
536 void CategoryDelete(uint32
NOT_ON_DAEMON(cat
))
539 if (theApp
->amuledlg
->m_transferwnd
) {
540 theApp
->amuledlg
->m_transferwnd
->RemoveCategory(cat
);
546 void PartFile_Swap_A4AF(CPartFile
* file
)
548 if ((file
->GetStatus(false) == PS_READY
|| file
->GetStatus(false) == PS_EMPTY
)) {
549 CPartFile::SourceSet::const_iterator it
= file
->GetA4AFList().begin();
550 for ( ; it
!= file
->GetA4AFList().end(); ) {
551 CUpDownClient
*cur_source
= *it
++;
553 cur_source
->SwapToAnotherFile(true, false, false, file
);
558 void PartFile_Swap_A4AF_Auto(CPartFile
* file
)
560 file
->SetA4AFAuto(!file
->IsA4AFAuto());
563 void PartFile_Swap_A4AF_Others(CPartFile
* file
)
565 if ((file
->GetStatus(false) == PS_READY
) || (file
->GetStatus(false) == PS_EMPTY
)) {
566 CPartFile::SourceSet::const_iterator it
= file
->GetSourceList().begin();
567 for( ; it
!= file
->GetSourceList().end(); ) {
568 CUpDownClient
* cur_source
= *it
++;
570 cur_source
->SwapToAnotherFile(false, false, false, NULL
);
575 void PartFile_Pause(CPartFile
* file
)
580 void PartFile_Resume(CPartFile
* file
)
583 file
->SavePartFile();
586 void PartFile_Stop(CPartFile
* file
)
591 void PartFile_PrioAuto(CPartFile
* file
, bool val
)
593 file
->SetAutoDownPriority(val
);
596 void PartFile_PrioSet(CPartFile
* file
, uint8 newDownPriority
, bool bSave
)
598 file
->SetDownPriority(newDownPriority
, bSave
);
601 void PartFile_Delete(CPartFile
* file
)
606 void PartFile_SetCat(CPartFile
* file
, uint32 val
)
608 file
->SetCategory(val
);
612 void KnownFile_Up_Prio_Set(CKnownFile
* file
, uint8 val
)
614 file
->SetAutoUpPriority(false);
615 file
->SetUpPriority(val
);
618 void KnownFile_Up_Prio_Auto(CKnownFile
* file
)
620 file
->SetAutoUpPriority(true);
621 file
->UpdateAutoUpPriority();
624 void KnownFile_Comment_Set(CKnownFile
* file
, wxString comment
)
626 file
->SetFileComment(comment
);
630 void Download_Set_Cat_Prio(uint8 cat
, uint8 newprio
)
632 theApp
->downloadqueue
->SetCatPrio(cat
, newprio
);
635 void Download_Set_Cat_Status(uint8 cat
, int newstatus
)
637 theApp
->downloadqueue
->SetCatStatus(cat
, newstatus
);
640 #endif // #ifdef CLIENT_GUI
642 // File_checked_for_headers