5 #include "DownloadQueue.h"
6 #include "updownclient.h"
7 #include "ServerList.h"
8 #include "Preferences.h"
9 #include "ExternalConn.h"
10 #include "SearchFile.h"
14 # include "amuleDlg.h"
15 # include "ServerWnd.h"
16 # include "SearchDlg.h"
17 # include "TransferWnd.h"
18 # include "SharedFilesWnd.h"
19 # include "ServerListCtrl.h"
20 # include "ClientListCtrl.h"
21 # include "SharedFilesCtrl.h"
22 # include "DownloadListCtrl.h"
23 # include "muuli_wdr.h"
24 # include "PartFileConvertDlg.h"
28 # include "PartFileConvert.h"
32 DEFINE_LOCAL_EVENT_TYPE(MULE_EVT_NOTIFY
)
38 void HandleNotification(const CMuleNotiferBase
& ntf
)
40 if (wxThread::IsMain()) {
41 #if defined(AMULE_DAEMON)
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
);
110 void ConvertUpdateProgress(float NOT_ON_DAEMON(percent
), wxString
NOT_ON_DAEMON(text
), wxString
NOT_ON_DAEMON(header
))
113 CPartFileConvertDlg::UpdateProgress(percent
, text
, header
);
117 void ConvertUpdateJobInfo(ConvertInfo
NOT_ON_DAEMON(info
))
120 CPartFileConvertDlg::UpdateJobInfo(info
);
124 void ConvertRemoveJobInfo(unsigned NOT_ON_DAEMON(id
))
127 CPartFileConvertDlg::RemoveJobInfo(id
);
131 void ConvertClearInfos()
134 CPartFileConvertDlg::ClearInfo();
138 void ConvertRemoveJob(unsigned NOT_ON_REMOTEGUI(id
))
141 CPartFileConvert::RemoveJob(id
);
145 void ConvertRetryJob(unsigned NOT_ON_REMOTEGUI(id
))
148 CPartFileConvert::RetryJob(id
);
152 void ConvertReaddAllJobs()
155 CPartFileConvert::ReaddAllJobs();
162 theApp
->amuledlg
->Iconize(false);
168 void PartFile_Swap_A4AF(CPartFile
* file
)
170 theApp
->downloadqueue
->SendFileCommand(file
, EC_OP_PARTFILE_SWAP_A4AF_THIS
);
173 void PartFile_Swap_A4AF_Auto(CPartFile
* file
)
175 theApp
->downloadqueue
->SendFileCommand(file
, EC_OP_PARTFILE_SWAP_A4AF_THIS_AUTO
);
178 void PartFile_Swap_A4AF_Others(CPartFile
* file
)
180 theApp
->downloadqueue
->SendFileCommand(file
, EC_OP_PARTFILE_SWAP_A4AF_OTHERS
);
183 void PartFile_Pause(CPartFile
* file
)
185 theApp
->downloadqueue
->SendFileCommand(file
, EC_OP_PARTFILE_PAUSE
);
188 void PartFile_Resume(CPartFile
* file
)
190 theApp
->downloadqueue
->SendFileCommand(file
, EC_OP_PARTFILE_RESUME
);
193 void PartFile_Stop(CPartFile
* file
)
195 theApp
->downloadqueue
->SendFileCommand(file
, EC_OP_PARTFILE_STOP
);
198 void PartFile_PrioAuto(CPartFile
* file
, bool val
)
200 theApp
->downloadqueue
->AutoPrio(file
, val
);
203 void PartFile_PrioSet(CPartFile
* file
, uint8 newDownPriority
, bool)
205 theApp
->downloadqueue
->Prio(file
, newDownPriority
);
208 void PartFile_Delete(CPartFile
* file
)
210 theApp
->downloadqueue
->SendFileCommand(file
, EC_OP_PARTFILE_DELETE
);
213 void PartFile_SetCat(CPartFile
* file
, uint32 val
)
215 theApp
->downloadqueue
->Category(file
, val
);
218 void KnownFile_Up_Prio_Set(CKnownFile
* file
, uint8 val
)
220 theApp
->sharedfiles
->SetFilePrio(file
, val
);
223 void KnownFile_Up_Prio_Auto(CKnownFile
* file
)
225 theApp
->sharedfiles
->SetFilePrio(file
, PR_AUTO
);
228 void Download_Set_Cat_Prio(uint8
, uint8
)
232 void Download_Set_Cat_Status(uint8
, int)
238 void SharedFilesShowFile(CKnownFile
* NOT_ON_DAEMON(file
))
241 if (theApp
->amuledlg
->m_sharedfileswnd
&& theApp
->amuledlg
->m_sharedfileswnd
->sharedfilesctrl
) {
242 theApp
->amuledlg
->m_sharedfileswnd
->sharedfilesctrl
->ShowFile(file
);
247 void SharedFilesRemoveFile(CKnownFile
* NOT_ON_DAEMON(file
))
250 if (theApp
->amuledlg
->m_sharedfileswnd
&& theApp
->amuledlg
->m_sharedfileswnd
->sharedfilesctrl
) {
251 theApp
->amuledlg
->m_sharedfileswnd
->sharedfilesctrl
->RemoveFile(file
);
256 void SharedFilesRemoveAllFiles()
259 if (theApp
->amuledlg
->m_sharedfileswnd
) {
260 theApp
->amuledlg
->m_sharedfileswnd
->RemoveAllSharedFiles();
266 void SharedFilesShowFileList()
269 if (theApp
->amuledlg
->m_sharedfileswnd
&& theApp
->amuledlg
->m_sharedfileswnd
->sharedfilesctrl
) {
270 theApp
->amuledlg
->m_sharedfileswnd
->sharedfilesctrl
->ShowFileList();
276 void SharedFilesUpdateItem(CKnownFile
* NOT_ON_DAEMON(file
))
279 if (theApp
->amuledlg
->m_sharedfileswnd
&& theApp
->amuledlg
->m_sharedfileswnd
->sharedfilesctrl
) {
280 theApp
->amuledlg
->m_sharedfileswnd
->sharedfilesctrl
->UpdateItem(file
);
286 void DownloadCtrlAddFile(CPartFile
* file
)
288 theApp
->ECServerHandler
->m_ec_notifier
->DownloadFile_AddFile(file
);
290 if (theApp
->amuledlg
->m_transferwnd
&& theApp
->amuledlg
->m_transferwnd
->downloadlistctrl
) {
291 theApp
->amuledlg
->m_transferwnd
->downloadlistctrl
->AddFile(file
);
296 void DownloadCtrlAddSource(CPartFile
* NOT_ON_DAEMON(owner
), CUpDownClient
* NOT_ON_DAEMON(source
), DownloadItemType
NOT_ON_DAEMON(type
))
299 if (theApp
->amuledlg
->m_transferwnd
&& theApp
->amuledlg
->m_transferwnd
->downloadlistctrl
) {
300 if (owner
->ShowSources()) {
301 theApp
->amuledlg
->m_transferwnd
->downloadlistctrl
->AddSource(owner
, source
, type
);
307 void DownloadCtrlRemoveFile(CPartFile
* file
)
309 theApp
->ECServerHandler
->m_ec_notifier
->DownloadFile_RemoveFile(file
);
311 if (theApp
->amuledlg
->m_transferwnd
&& theApp
->amuledlg
->m_transferwnd
->downloadlistctrl
) {
312 theApp
->amuledlg
->m_transferwnd
->downloadlistctrl
->RemoveFile(file
);
317 void DownloadCtrlRemoveSource(const CUpDownClient
* NOT_ON_DAEMON(source
), const CPartFile
* NOT_ON_DAEMON(owner
))
320 if (theApp
->amuledlg
->m_transferwnd
&& theApp
->amuledlg
->m_transferwnd
->downloadlistctrl
) {
321 if ((owner
== NULL
) || owner
->ShowSources()) {
322 theApp
->amuledlg
->m_transferwnd
->downloadlistctrl
->RemoveSource(source
, owner
);
328 void DownloadCtrlHideSource(CPartFile
* NOT_ON_DAEMON(file
))
331 if (theApp
->amuledlg
->m_transferwnd
&& theApp
->amuledlg
->m_transferwnd
->downloadlistctrl
) {
332 theApp
->amuledlg
->m_transferwnd
->downloadlistctrl
->ShowSources(file
, false);
337 void DownloadCtrlSort()
340 if (theApp
->amuledlg
->m_transferwnd
&& theApp
->amuledlg
->m_transferwnd
->downloadlistctrl
) {
341 theApp
->amuledlg
->m_transferwnd
->downloadlistctrl
->SortList();
347 void ClientCtrlAddClient(CUpDownClient
* NOT_ON_DAEMON(client
), ViewType
NOT_ON_DAEMON(type
))
350 if (theApp
->amuledlg
->m_transferwnd
&& theApp
->amuledlg
->m_transferwnd
->clientlistctrl
) {
351 theApp
->amuledlg
->m_transferwnd
->clientlistctrl
->InsertClient(client
, type
);
356 void ClientCtrlRefreshClient(CUpDownClient
* NOT_ON_DAEMON(client
), ViewType
NOT_ON_DAEMON(type
))
359 if (theApp
->amuledlg
->m_transferwnd
&& theApp
->amuledlg
->m_transferwnd
->clientlistctrl
) {
360 theApp
->amuledlg
->m_transferwnd
->clientlistctrl
->UpdateClient(client
, type
);
365 void ClientCtrlRemoveClient(CUpDownClient
* NOT_ON_DAEMON(client
), ViewType
NOT_ON_DAEMON(type
))
368 if (theApp
->amuledlg
->m_transferwnd
&& theApp
->amuledlg
->m_transferwnd
->clientlistctrl
) {
369 theApp
->amuledlg
->m_transferwnd
->clientlistctrl
->RemoveClient(client
, type
);
375 void ServerAdd(CServer
* NOT_ON_DAEMON(server
))
378 if (theApp
->amuledlg
->m_serverwnd
&& theApp
->amuledlg
->m_serverwnd
->serverlistctrl
) {
379 theApp
->amuledlg
->m_serverwnd
->serverlistctrl
->AddServer(server
);
384 void ServerRemove(CServer
* NOT_ON_DAEMON(server
))
387 if (theApp
->amuledlg
->m_serverwnd
&& theApp
->amuledlg
->m_serverwnd
->serverlistctrl
) {
388 theApp
->amuledlg
->m_serverwnd
->serverlistctrl
->RemoveServer(server
);
393 void ServerRemoveDead()
395 if (theApp
->serverlist
) {
396 theApp
->serverlist
->RemoveDeadServers();
400 void ServerRemoveAll()
403 if (theApp
->amuledlg
->m_serverwnd
&& theApp
->amuledlg
->m_serverwnd
->serverlistctrl
) {
404 theApp
->amuledlg
->m_serverwnd
->serverlistctrl
->DeleteAllItems();
409 void ServerHighlight(CServer
* NOT_ON_DAEMON(server
), bool NOT_ON_DAEMON(highlight
))
412 if (theApp
->amuledlg
->m_serverwnd
&& theApp
->amuledlg
->m_serverwnd
->serverlistctrl
) {
413 theApp
->amuledlg
->m_serverwnd
->serverlistctrl
->HighlightServer(server
, highlight
);
418 void ServerRefresh(CServer
* NOT_ON_DAEMON(server
))
421 if (theApp
->amuledlg
->m_serverwnd
&& theApp
->amuledlg
->m_serverwnd
->serverlistctrl
) {
422 theApp
->amuledlg
->m_serverwnd
->serverlistctrl
->RefreshServer(server
);
430 if (theApp
->amuledlg
->m_serverwnd
&& theApp
->amuledlg
->m_serverwnd
->serverlistctrl
) {
431 theApp
->amuledlg
->m_serverwnd
->serverlistctrl
->Freeze();
439 if (theApp
->amuledlg
->m_serverwnd
&& theApp
->amuledlg
->m_serverwnd
->serverlistctrl
) {
440 theApp
->amuledlg
->m_serverwnd
->serverlistctrl
->Thaw();
445 void ServerUpdateED2KInfo()
448 if (theApp
->amuledlg
->m_serverwnd
) {
449 theApp
->amuledlg
->m_serverwnd
->UpdateED2KInfo();
454 void ServerUpdateKadKInfo()
457 if (theApp
->amuledlg
->m_serverwnd
) {
458 theApp
->amuledlg
->m_serverwnd
->UpdateKadInfo();
467 if (theApp
->amuledlg
->m_searchwnd
) {
468 theApp
->amuledlg
->m_searchwnd
->ResetControls();
473 void SearchLocalEnd()
476 if (theApp
->amuledlg
->m_searchwnd
) {
477 theApp
->amuledlg
->m_searchwnd
->LocalSearchEnd();
482 void KadSearchEnd(uint32
NOT_ON_DAEMON(id
))
485 if (theApp
->amuledlg
->m_searchwnd
) {
486 theApp
->amuledlg
->m_searchwnd
->KadSearchEnd(id
);
491 void Search_Update_Sources(CSearchFile
* result
)
493 result
->SetDownloadStatus();
495 if (theApp
->amuledlg
&& theApp
->amuledlg
->m_searchwnd
) {
496 theApp
->amuledlg
->m_searchwnd
->UpdateResult(result
);
501 void Search_Add_Result(CSearchFile
* NOT_ON_DAEMON(result
))
504 if (theApp
->amuledlg
&& theApp
->amuledlg
->m_searchwnd
) {
505 theApp
->amuledlg
->m_searchwnd
->AddResult(result
);
511 void ChatRefreshFriend(CFriend
* NOT_ON_DAEMON(Friend
), bool NOT_ON_DAEMON(connected
))
514 if (theApp
->amuledlg
->m_chatwnd
) {
515 theApp
->amuledlg
->m_chatwnd
->RefreshFriend(Friend
, connected
);
520 void ChatConnResult(bool NOT_ON_DAEMON(success
), uint64
NOT_ON_DAEMON(id
), wxString
NOT_ON_DAEMON(message
))
523 if (theApp
->amuledlg
->m_chatwnd
) {
524 theApp
->amuledlg
->m_chatwnd
->ConnectionResult(success
, message
, id
);
529 void ChatProcessMsg(uint64
NOT_ON_DAEMON(sender
), wxString
NOT_ON_DAEMON(message
))
532 if (theApp
->amuledlg
->m_chatwnd
) {
533 theApp
->amuledlg
->m_chatwnd
->ProcessMessage(sender
, message
);
539 void ChatSendCaptcha(wxString
NOT_ON_DAEMON(captcha
), uint64
NOT_ON_DAEMON(to_id
))
542 if (theApp
->amuledlg
->m_chatwnd
) {
543 theApp
->amuledlg
->m_chatwnd
->SendMessage(captcha
, wxEmptyString
, to_id
);
549 void ShowConnState(long WXUNUSED(state
))
552 theApp
->amuledlg
->ShowConnectionState();
556 void ShowQueueCount(uint32
NOT_ON_DAEMON(count
))
559 if (theApp
->amuledlg
->m_transferwnd
) {
560 theApp
->amuledlg
->m_transferwnd
->ShowQueueCount(count
);
565 void ShowUpdateCatTabTitles()
568 if (theApp
->amuledlg
->m_transferwnd
) {
569 theApp
->amuledlg
->m_transferwnd
->UpdateCatTabTitles();
577 if (theApp
->amuledlg
->m_transferwnd
) {
578 theApp
->amuledlg
->m_transferwnd
->
579 AddCategory(theApp
->glob_prefs
->GetCategory(
580 theApp
->glob_prefs
->GetCatCount()-1));
585 void CategoryUpdate(uint32
NOT_ON_DAEMON(cat
))
588 if (theApp
->amuledlg
->m_transferwnd
) {
589 theApp
->amuledlg
->m_transferwnd
->UpdateCategory(cat
);
590 theApp
->amuledlg
->m_transferwnd
->downloadlistctrl
->Refresh();
591 theApp
->amuledlg
->m_searchwnd
->UpdateCatChoice();
596 void CategoryDelete(uint32 cat
)
599 theApp
->glob_prefs
->RemoveCat(cat
);
601 if (theApp
->amuledlg
->m_transferwnd
) {
602 theApp
->amuledlg
->m_transferwnd
->RemoveCategory(cat
);
608 void PartFile_Swap_A4AF(CPartFile
* file
)
610 if ((file
->GetStatus(false) == PS_READY
|| file
->GetStatus(false) == PS_EMPTY
)) {
611 CPartFile::SourceSet::const_iterator it
= file
->GetA4AFList().begin();
612 for ( ; it
!= file
->GetA4AFList().end(); ) {
613 CUpDownClient
*cur_source
= *it
++;
615 cur_source
->SwapToAnotherFile(true, false, false, file
);
620 void PartFile_Swap_A4AF_Auto(CPartFile
* file
)
622 file
->SetA4AFAuto(!file
->IsA4AFAuto());
625 void PartFile_Swap_A4AF_Others(CPartFile
* file
)
627 if ((file
->GetStatus(false) == PS_READY
) || (file
->GetStatus(false) == PS_EMPTY
)) {
628 CPartFile::SourceSet::const_iterator it
= file
->GetSourceList().begin();
629 for( ; it
!= file
->GetSourceList().end(); ) {
630 CUpDownClient
* cur_source
= *it
++;
632 cur_source
->SwapToAnotherFile(false, false, false, NULL
);
637 void PartFile_Pause(CPartFile
* file
)
642 void PartFile_Resume(CPartFile
* file
)
645 file
->SavePartFile();
648 void PartFile_Stop(CPartFile
* file
)
653 void PartFile_PrioAuto(CPartFile
* file
, bool val
)
655 file
->SetAutoDownPriority(val
);
658 void PartFile_PrioSet(CPartFile
* file
, uint8 newDownPriority
, bool bSave
)
660 file
->SetDownPriority(newDownPriority
, bSave
);
663 void PartFile_Delete(CPartFile
* file
)
668 void PartFile_SetCat(CPartFile
* file
, uint32 val
)
670 file
->SetCategory(val
);
674 void KnownFile_Up_Prio_Set(CKnownFile
* file
, uint8 val
)
676 file
->SetAutoUpPriority(false);
677 file
->SetUpPriority(val
);
680 void KnownFile_Up_Prio_Auto(CKnownFile
* file
)
682 file
->SetAutoUpPriority(true);
683 file
->UpdateAutoUpPriority();
686 void KnownFile_Comment_Set(CKnownFile
* file
, wxString comment
)
688 file
->SetFileComment(comment
);
692 void Download_Set_Cat_Prio(uint8 cat
, uint8 newprio
)
694 theApp
->downloadqueue
->SetCatPrio(cat
, newprio
);
697 void Download_Set_Cat_Status(uint8 cat
, int newstatus
)
699 theApp
->downloadqueue
->SetCatStatus(cat
, newstatus
);
702 #endif // #ifdef CLIENT_GUI
704 // File_checked_for_headers