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 "SourceListCtrl.h"
22 # include "SharedFilesCtrl.h"
23 # include "DownloadListCtrl.h"
24 # include "muuli_wdr.h"
25 # include "SharedFilePeersListCtrl.h"
26 # include "PartFileConvertDlg.h"
30 # include "PartFileConvert.h"
34 DEFINE_LOCAL_EVENT_TYPE(MULE_EVT_NOTIFY
)
40 void HandleNotification(const CMuleNotiferBase
& ntf
)
42 if (wxThread::IsMain()) {
46 if (theApp
->amuledlg
) {
51 CMuleGUIEvent
evt(ntf
.Clone());
52 wxPostEvent(wxTheApp
, evt
);
56 void Search_Add_Download(CSearchFile
* file
, uint8 category
)
58 theApp
->downloadqueue
->AddSearchToDownload(file
, category
);
62 void ShowUserCount(wxString
NOT_ON_DAEMON(str
))
65 theApp
->amuledlg
->ShowUserCount(str
);
70 void Search_Update_Progress(uint32
NOT_ON_DAEMON(val
))
73 if (theApp
->amuledlg
->m_searchwnd
) {
75 // Global search ended
76 theApp
->amuledlg
->m_searchwnd
->ResetControls();
77 } else if (val
== 0xfffe) {
79 theApp
->amuledlg
->m_searchwnd
->KadSearchEnd(0);
81 theApp
->amuledlg
->m_searchwnd
->UpdateProgress(val
);
88 void DownloadCtrlUpdateItem(const void* item
)
91 theApp
->ECServerHandler
->m_ec_notifier
->DownloadFile_SetDirty((CPartFile
*)item
);
94 if (theApp
->amuledlg
->m_transferwnd
&& theApp
->amuledlg
->m_transferwnd
->downloadlistctrl
) {
95 theApp
->amuledlg
->m_transferwnd
->downloadlistctrl
->UpdateItem(item
);
101 void NodesURLChanged(wxString
NOT_ON_DAEMON(url
))
104 CastByID(IDC_NODESLISTURL
, NULL
, wxTextCtrl
)->SetValue(url
);
108 void ServersURLChanged(wxString
NOT_ON_DAEMON(url
))
111 CastByID(IDC_SERVERLISTURL
, NULL
, wxTextCtrl
)->SetValue(url
);
115 void ConvertUpdateProgress(float NOT_ON_DAEMON(percent
), wxString
NOT_ON_DAEMON(text
), wxString
NOT_ON_DAEMON(header
))
118 CPartFileConvertDlg::UpdateProgress(percent
, text
, header
);
122 void ConvertUpdateJobInfo(ConvertInfo
NOT_ON_DAEMON(info
))
125 CPartFileConvertDlg::UpdateJobInfo(info
);
129 void ConvertRemoveJobInfo(unsigned NOT_ON_DAEMON(id
))
132 CPartFileConvertDlg::RemoveJobInfo(id
);
136 void ConvertClearInfos()
139 CPartFileConvertDlg::ClearInfo();
143 void ConvertRemoveJob(unsigned NOT_ON_REMOTEGUI(id
))
146 CPartFileConvert::RemoveJob(id
);
150 void ConvertRetryJob(unsigned NOT_ON_REMOTEGUI(id
))
153 CPartFileConvert::RetryJob(id
);
157 void ConvertReaddAllJobs()
160 CPartFileConvert::ReaddAllJobs();
167 theApp
->amuledlg
->Iconize(false);
171 void SourceCtrlUpdateSource(CUpDownClient
* NOT_ON_DAEMON(source
), SourceItemType
NOT_ON_DAEMON(type
))
174 if (theApp
->amuledlg
->m_transferwnd
&& theApp
->amuledlg
->m_transferwnd
->clientlistctrl
) {
175 theApp
->amuledlg
->m_transferwnd
->clientlistctrl
->UpdateItem(source
, type
);
180 void SourceCtrlAddSource(CPartFile
* NOT_ON_DAEMON(owner
), CUpDownClient
* NOT_ON_DAEMON(source
), SourceItemType
NOT_ON_DAEMON(type
))
183 if (theApp
->amuledlg
->m_transferwnd
&& theApp
->amuledlg
->m_transferwnd
->clientlistctrl
) {
184 theApp
->amuledlg
->m_transferwnd
->clientlistctrl
->AddSource(owner
, source
, type
);
189 void SourceCtrlRemoveSource(const CUpDownClient
* NOT_ON_DAEMON(source
), const CPartFile
* NOT_ON_DAEMON(owner
))
192 if (theApp
->amuledlg
->m_transferwnd
&& theApp
->amuledlg
->m_transferwnd
->clientlistctrl
) {
193 theApp
->amuledlg
->m_transferwnd
->clientlistctrl
->RemoveSource(source
, owner
);
198 void SharedCtrlAddClient(CKnownFile
* NOT_ON_DAEMON(owner
), CUpDownClient
* NOT_ON_DAEMON(source
), SourceItemType
NOT_ON_DAEMON(type
))
201 if (theApp
->amuledlg
->m_sharedfileswnd
&& theApp
->amuledlg
->m_sharedfileswnd
->peerslistctrl
) {
202 theApp
->amuledlg
->m_sharedfileswnd
->peerslistctrl
->AddSource(owner
, source
, type
);
207 void SharedCtrlRefreshClient(CUpDownClient
* NOT_ON_DAEMON(client
), SourceItemType
NOT_ON_DAEMON(type
))
210 if (theApp
->amuledlg
->m_sharedfileswnd
&& theApp
->amuledlg
->m_sharedfileswnd
->peerslistctrl
) {
211 theApp
->amuledlg
->m_sharedfileswnd
->peerslistctrl
->UpdateItem(client
, type
);
216 void SharedCtrlRemoveClient(const CKnownFile
* NOT_ON_DAEMON(owner
), const CUpDownClient
* NOT_ON_DAEMON(source
))
219 if (theApp
->amuledlg
->m_sharedfileswnd
&& theApp
->amuledlg
->m_sharedfileswnd
->peerslistctrl
) {
220 theApp
->amuledlg
->m_sharedfileswnd
->peerslistctrl
->RemoveSource(source
, owner
);
228 void PartFile_Swap_A4AF(CPartFile
* file
)
230 theApp
->downloadqueue
->SendFileCommand(file
, EC_OP_PARTFILE_SWAP_A4AF_THIS
);
233 void PartFile_Swap_A4AF_Auto(CPartFile
* file
)
235 theApp
->downloadqueue
->SendFileCommand(file
, EC_OP_PARTFILE_SWAP_A4AF_THIS_AUTO
);
238 void PartFile_Swap_A4AF_Others(CPartFile
* file
)
240 theApp
->downloadqueue
->SendFileCommand(file
, EC_OP_PARTFILE_SWAP_A4AF_OTHERS
);
243 void PartFile_Pause(CPartFile
* file
)
245 theApp
->downloadqueue
->SendFileCommand(file
, EC_OP_PARTFILE_PAUSE
);
248 void PartFile_Resume(CPartFile
* file
)
250 theApp
->downloadqueue
->SendFileCommand(file
, EC_OP_PARTFILE_RESUME
);
253 void PartFile_Stop(CPartFile
* file
)
255 theApp
->downloadqueue
->SendFileCommand(file
, EC_OP_PARTFILE_STOP
);
258 void PartFile_PrioAuto(CPartFile
* file
, bool val
)
260 theApp
->downloadqueue
->AutoPrio(file
, val
);
263 void PartFile_PrioSet(CPartFile
* file
, uint8 newDownPriority
, bool)
265 theApp
->downloadqueue
->Prio(file
, newDownPriority
);
268 void PartFile_Delete(CPartFile
* file
)
270 theApp
->downloadqueue
->SendFileCommand(file
, EC_OP_PARTFILE_DELETE
);
273 void PartFile_SetCat(CPartFile
* file
, uint32 val
)
275 theApp
->downloadqueue
->Category(file
, val
);
278 void KnownFile_Up_Prio_Set(CKnownFile
* file
, uint8 val
)
280 theApp
->sharedfiles
->SetFilePrio(file
, val
);
283 void KnownFile_Up_Prio_Auto(CKnownFile
* file
)
285 theApp
->sharedfiles
->SetFilePrio(file
, PR_AUTO
);
288 void Download_Set_Cat_Prio(uint8
, uint8
)
292 void Download_Set_Cat_Status(uint8
, int)
298 void SharedFilesShowFile(CKnownFile
* NOT_ON_DAEMON(file
))
301 if (theApp
->amuledlg
->m_sharedfileswnd
&& theApp
->amuledlg
->m_sharedfileswnd
->sharedfilesctrl
) {
302 theApp
->amuledlg
->m_sharedfileswnd
->sharedfilesctrl
->ShowFile(file
);
307 void SharedFilesRemoveFile(CKnownFile
* NOT_ON_DAEMON(file
))
310 if (theApp
->amuledlg
->m_sharedfileswnd
&& theApp
->amuledlg
->m_sharedfileswnd
->sharedfilesctrl
) {
311 theApp
->amuledlg
->m_sharedfileswnd
->sharedfilesctrl
->RemoveFile(file
);
316 void SharedFilesRemoveAllFiles()
319 if (theApp
->amuledlg
->m_sharedfileswnd
) {
320 theApp
->amuledlg
->m_sharedfileswnd
->RemoveAllSharedFiles();
326 void SharedFilesShowFileList()
329 if (theApp
->amuledlg
->m_sharedfileswnd
&& theApp
->amuledlg
->m_sharedfileswnd
->sharedfilesctrl
) {
330 theApp
->amuledlg
->m_sharedfileswnd
->sharedfilesctrl
->ShowFileList();
336 void SharedFilesUpdateItem(CKnownFile
* NOT_ON_DAEMON(file
))
339 if (theApp
->amuledlg
->m_sharedfileswnd
&& theApp
->amuledlg
->m_sharedfileswnd
->sharedfilesctrl
) {
340 theApp
->amuledlg
->m_sharedfileswnd
->sharedfilesctrl
->UpdateItem(file
);
346 void DownloadCtrlAddFile(CPartFile
* file
)
348 theApp
->ECServerHandler
->m_ec_notifier
->DownloadFile_AddFile(file
);
350 if (theApp
->amuledlg
->m_transferwnd
&& theApp
->amuledlg
->m_transferwnd
->downloadlistctrl
) {
351 theApp
->amuledlg
->m_transferwnd
->downloadlistctrl
->AddFile(file
);
356 void DownloadCtrlRemoveFile(CPartFile
* file
)
358 theApp
->ECServerHandler
->m_ec_notifier
->DownloadFile_RemoveFile(file
);
360 if (theApp
->amuledlg
->m_transferwnd
&& theApp
->amuledlg
->m_transferwnd
->downloadlistctrl
) {
361 theApp
->amuledlg
->m_transferwnd
->downloadlistctrl
->RemoveFile(file
);
366 void DownloadCtrlSort()
369 if (theApp
->amuledlg
->m_transferwnd
&& theApp
->amuledlg
->m_transferwnd
->downloadlistctrl
) {
370 theApp
->amuledlg
->m_transferwnd
->downloadlistctrl
->SortList();
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
);
489 theApp
->searchlist
->SetKadSearchFinished();
492 void Search_Update_Sources(CSearchFile
* result
)
494 result
->SetDownloadStatus();
496 if (theApp
->amuledlg
&& theApp
->amuledlg
->m_searchwnd
) {
497 theApp
->amuledlg
->m_searchwnd
->UpdateResult(result
);
502 void Search_Add_Result(CSearchFile
* NOT_ON_DAEMON(result
))
505 if (theApp
->amuledlg
&& theApp
->amuledlg
->m_searchwnd
) {
506 theApp
->amuledlg
->m_searchwnd
->AddResult(result
);
512 void ChatRefreshFriend(CFriend
* NOT_ON_DAEMON(Friend
), bool NOT_ON_DAEMON(connected
))
515 if (theApp
->amuledlg
->m_chatwnd
) {
516 theApp
->amuledlg
->m_chatwnd
->RefreshFriend(Friend
, connected
);
521 void ChatConnResult(bool NOT_ON_DAEMON(success
), uint64
NOT_ON_DAEMON(id
), wxString
NOT_ON_DAEMON(message
))
524 if (theApp
->amuledlg
->m_chatwnd
) {
525 theApp
->amuledlg
->m_chatwnd
->ConnectionResult(success
, message
, id
);
530 void ChatProcessMsg(uint64
NOT_ON_DAEMON(sender
), wxString
NOT_ON_DAEMON(message
))
533 if (theApp
->amuledlg
->m_chatwnd
) {
534 theApp
->amuledlg
->m_chatwnd
->ProcessMessage(sender
, message
);
540 void ChatSendCaptcha(wxString
NOT_ON_DAEMON(captcha
), uint64
NOT_ON_DAEMON(to_id
))
543 if (theApp
->amuledlg
->m_chatwnd
) {
544 theApp
->amuledlg
->m_chatwnd
->SendMessage(captcha
, wxEmptyString
, to_id
);
550 void ShowConnState(long NOT_ON_DAEMON(forceUpdate
))
553 theApp
->amuledlg
->ShowConnectionState(forceUpdate
!= 0);
557 void ShowQueueCount(uint32
NOT_ON_DAEMON(count
))
560 if (theApp
->amuledlg
->m_transferwnd
) {
561 theApp
->amuledlg
->m_transferwnd
->ShowQueueCount(count
);
566 void ShowUpdateCatTabTitles()
569 if (theApp
->amuledlg
->m_transferwnd
) {
570 theApp
->amuledlg
->m_transferwnd
->UpdateCatTabTitles();
578 if (theApp
->amuledlg
->m_transferwnd
) {
579 theApp
->amuledlg
->m_transferwnd
->
580 AddCategory(theApp
->glob_prefs
->GetCategory(
581 theApp
->glob_prefs
->GetCatCount()-1));
586 void CategoryUpdate(uint32
NOT_ON_DAEMON(cat
))
589 if (theApp
->amuledlg
->m_transferwnd
) {
590 theApp
->amuledlg
->m_transferwnd
->UpdateCategory(cat
);
591 theApp
->amuledlg
->m_transferwnd
->downloadlistctrl
->Refresh();
592 theApp
->amuledlg
->m_searchwnd
->UpdateCatChoice();
597 void CategoryDelete(uint32 cat
)
601 theApp
->downloadqueue
->ResetCatParts(cat
);
602 theApp
->glob_prefs
->RemoveCat(cat
);
603 if ( theApp
->glob_prefs
->GetCatCount() == 1 ) {
604 thePrefs::SetAllcatFilter( acfAll
);
606 theApp
->glob_prefs
->SaveCats();
609 if (theApp
->amuledlg
->m_transferwnd
) {
610 theApp
->amuledlg
->m_transferwnd
->RemoveCategory(cat
);
616 void PartFile_Swap_A4AF(CPartFile
* file
)
618 if ((file
->GetStatus(false) == PS_READY
|| file
->GetStatus(false) == PS_EMPTY
)) {
619 CPartFile::SourceSet::const_iterator it
= file
->GetA4AFList().begin();
620 for ( ; it
!= file
->GetA4AFList().end(); ) {
621 CUpDownClient
*cur_source
= *it
++;
623 cur_source
->SwapToAnotherFile(true, false, false, file
);
628 void PartFile_Swap_A4AF_Auto(CPartFile
* file
)
630 file
->SetA4AFAuto(!file
->IsA4AFAuto());
633 void PartFile_Swap_A4AF_Others(CPartFile
* file
)
635 if ((file
->GetStatus(false) == PS_READY
) || (file
->GetStatus(false) == PS_EMPTY
)) {
636 CPartFile::SourceSet::const_iterator it
= file
->GetSourceList().begin();
637 for( ; it
!= file
->GetSourceList().end(); ) {
638 CUpDownClient
* cur_source
= *it
++;
640 cur_source
->SwapToAnotherFile(false, false, false, NULL
);
645 void PartFile_Pause(CPartFile
* file
)
650 void PartFile_Resume(CPartFile
* file
)
653 file
->SavePartFile();
656 void PartFile_Stop(CPartFile
* file
)
661 void PartFile_PrioAuto(CPartFile
* file
, bool val
)
663 file
->SetAutoDownPriority(val
);
666 void PartFile_PrioSet(CPartFile
* file
, uint8 newDownPriority
, bool bSave
)
668 file
->SetDownPriority(newDownPriority
, bSave
);
671 void PartFile_Delete(CPartFile
* file
)
676 void PartFile_SetCat(CPartFile
* file
, uint32 val
)
678 file
->SetCategory(val
);
682 void KnownFile_Up_Prio_Set(CKnownFile
* file
, uint8 val
)
684 file
->SetAutoUpPriority(false);
685 file
->SetUpPriority(val
);
688 void KnownFile_Up_Prio_Auto(CKnownFile
* file
)
690 file
->SetAutoUpPriority(true);
691 file
->UpdateAutoUpPriority();
694 void KnownFile_Comment_Set(CKnownFile
* file
, wxString comment
)
696 file
->SetFileComment(comment
);
700 void Download_Set_Cat_Prio(uint8 cat
, uint8 newprio
)
702 theApp
->downloadqueue
->SetCatPrio(cat
, newprio
);
705 void Download_Set_Cat_Status(uint8 cat
, int newstatus
)
707 theApp
->downloadqueue
->SetCatStatus(cat
, newstatus
);
710 #endif // #ifdef CLIENT_GUI
712 // File_checked_for_headers