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 NOT_ON_DAEMON(state
))
501 theApp
->m_ConnState
= state
;
504 theApp
->amuledlg
->ShowConnectionState();
508 void ShowQueueCount(uint32
NOT_ON_DAEMON(count
))
511 if (theApp
->amuledlg
->m_transferwnd
) {
512 theApp
->amuledlg
->m_transferwnd
->ShowQueueCount(count
);
517 void ShowUpdateCatTabTitles()
520 if (theApp
->amuledlg
->m_transferwnd
) {
521 theApp
->amuledlg
->m_transferwnd
->UpdateCatTabTitles();
529 theApp
->amuledlg
->Iconize(false);
537 if (theApp
->amuledlg
->m_transferwnd
) {
538 theApp
->amuledlg
->m_transferwnd
->
539 AddCategory(theApp
->glob_prefs
->GetCategory(
540 theApp
->glob_prefs
->GetCatCount()-1));
545 void CategoryUpdate(uint32
NOT_ON_DAEMON(cat
))
548 if (theApp
->amuledlg
->m_transferwnd
) {
549 theApp
->amuledlg
->m_transferwnd
->UpdateCategory(cat
);
550 theApp
->amuledlg
->m_transferwnd
->downloadlistctrl
->Refresh();
551 theApp
->amuledlg
->m_searchwnd
->UpdateCatChoice();
556 void CategoryDelete(uint32
NOT_ON_DAEMON(cat
))
559 if (theApp
->amuledlg
->m_transferwnd
) {
560 theApp
->amuledlg
->m_transferwnd
->RemoveCategory(cat
);
566 void PartFile_Swap_A4AF(CPartFile
* file
)
568 if ((file
->GetStatus(false) == PS_READY
|| file
->GetStatus(false) == PS_EMPTY
)) {
569 CPartFile::SourceSet::const_iterator it
= file
->GetA4AFList().begin();
570 for ( ; it
!= file
->GetA4AFList().end(); ) {
571 CUpDownClient
*cur_source
= *it
++;
573 cur_source
->SwapToAnotherFile(true, false, false, file
);
578 void PartFile_Swap_A4AF_Auto(CPartFile
* file
)
580 file
->SetA4AFAuto(!file
->IsA4AFAuto());
583 void PartFile_Swap_A4AF_Others(CPartFile
* file
)
585 if ((file
->GetStatus(false) == PS_READY
) || (file
->GetStatus(false) == PS_EMPTY
)) {
586 CPartFile::SourceSet::const_iterator it
= file
->GetSourceList().begin();
587 for( ; it
!= file
->GetSourceList().end(); ) {
588 CUpDownClient
* cur_source
= *it
++;
590 cur_source
->SwapToAnotherFile(false, false, false, NULL
);
595 void PartFile_Pause(CPartFile
* file
)
600 void PartFile_Resume(CPartFile
* file
)
603 file
->SavePartFile();
606 void PartFile_Stop(CPartFile
* file
)
611 void PartFile_PrioAuto(CPartFile
* file
, bool val
)
613 file
->SetAutoDownPriority(val
);
616 void PartFile_PrioSet(CPartFile
* file
, uint8 newDownPriority
, bool bSave
)
618 file
->SetDownPriority(newDownPriority
, bSave
);
621 void PartFile_Delete(CPartFile
* file
)
626 void PartFile_SetCat(CPartFile
* file
, uint32 val
)
628 file
->SetCategory(val
);
632 void KnownFile_Up_Prio_Set(CKnownFile
* file
, uint8 val
)
634 file
->SetAutoUpPriority(false);
635 file
->SetUpPriority(val
);
638 void KnownFile_Up_Prio_Auto(CKnownFile
* file
)
640 file
->SetAutoUpPriority(true);
641 file
->UpdateAutoUpPriority();
644 void KnownFile_Comment_Set(CKnownFile
* file
, wxString comment
)
646 file
->SetFileComment(comment
);
650 void Download_Set_Cat_Prio(uint8 cat
, uint8 newprio
)
652 theApp
->downloadqueue
->SetCatPrio(cat
, newprio
);
655 void Download_Set_Cat_Status(uint8 cat
, int newstatus
)
657 theApp
->downloadqueue
->SetCatStatus(cat
, newstatus
);
660 #endif // #ifdef CLIENT_GUI
662 // File_checked_for_headers