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"
23 # include "PartFileConvertDlg.h"
27 # include "PartFileConvert.h"
31 DEFINE_LOCAL_EVENT_TYPE(MULE_EVT_NOTIFY
)
37 void HandleNotification(const CMuleNotiferBase
& ntf
)
39 if (wxThread::IsMain()) {
40 #if defined(AMULE_DAEMON)
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* item
)
85 theApp
->ECServerHandler
->m_ec_notifier
->DownloadFile_SetDirty((CPartFile
*)item
);
88 if (theApp
->amuledlg
->m_transferwnd
&& theApp
->amuledlg
->m_transferwnd
->downloadlistctrl
) {
89 theApp
->amuledlg
->m_transferwnd
->downloadlistctrl
->UpdateItem(item
);
95 void NodesURLChanged(wxString
NOT_ON_DAEMON(url
))
98 CastByID(IDC_NODESLISTURL
, NULL
, wxTextCtrl
)->SetValue(url
);
102 void ServersURLChanged(wxString
NOT_ON_DAEMON(url
))
105 CastByID(IDC_SERVERLISTURL
, NULL
, wxTextCtrl
)->SetValue(url
);
109 void ConvertUpdateProgress(float NOT_ON_DAEMON(percent
), wxString
NOT_ON_DAEMON(text
), wxString
NOT_ON_DAEMON(header
))
112 CPartFileConvertDlg::UpdateProgress(percent
, text
, header
);
116 void ConvertUpdateJobInfo(ConvertInfo
NOT_ON_DAEMON(info
))
119 CPartFileConvertDlg::UpdateJobInfo(info
);
123 void ConvertRemoveJobInfo(unsigned NOT_ON_DAEMON(id
))
126 CPartFileConvertDlg::RemoveJobInfo(id
);
130 void ConvertClearInfos()
133 CPartFileConvertDlg::ClearInfo();
137 void ConvertRemoveJob(unsigned NOT_ON_REMOTEGUI(id
))
140 CPartFileConvert::RemoveJob(id
);
144 void ConvertRetryJob(unsigned NOT_ON_REMOTEGUI(id
))
147 CPartFileConvert::RetryJob(id
);
151 void ConvertReaddAllJobs()
154 CPartFileConvert::ReaddAllJobs();
161 theApp
->amuledlg
->Iconize(false);
167 void PartFile_Swap_A4AF(CPartFile
* file
)
169 theApp
->downloadqueue
->SendFileCommand(file
, EC_OP_PARTFILE_SWAP_A4AF_THIS
);
172 void PartFile_Swap_A4AF_Auto(CPartFile
* file
)
174 theApp
->downloadqueue
->SendFileCommand(file
, EC_OP_PARTFILE_SWAP_A4AF_THIS_AUTO
);
177 void PartFile_Swap_A4AF_Others(CPartFile
* file
)
179 theApp
->downloadqueue
->SendFileCommand(file
, EC_OP_PARTFILE_SWAP_A4AF_OTHERS
);
182 void PartFile_Pause(CPartFile
* file
)
184 theApp
->downloadqueue
->SendFileCommand(file
, EC_OP_PARTFILE_PAUSE
);
187 void PartFile_Resume(CPartFile
* file
)
189 theApp
->downloadqueue
->SendFileCommand(file
, EC_OP_PARTFILE_RESUME
);
192 void PartFile_Stop(CPartFile
* file
)
194 theApp
->downloadqueue
->SendFileCommand(file
, EC_OP_PARTFILE_STOP
);
197 void PartFile_PrioAuto(CPartFile
* file
, bool val
)
199 theApp
->downloadqueue
->AutoPrio(file
, val
);
202 void PartFile_PrioSet(CPartFile
* file
, uint8 newDownPriority
, bool)
204 theApp
->downloadqueue
->Prio(file
, newDownPriority
);
207 void PartFile_Delete(CPartFile
* file
)
209 theApp
->downloadqueue
->SendFileCommand(file
, EC_OP_PARTFILE_DELETE
);
212 void PartFile_SetCat(CPartFile
* file
, uint32 val
)
214 theApp
->downloadqueue
->Category(file
, val
);
217 void KnownFile_Up_Prio_Set(CKnownFile
* file
, uint8 val
)
219 theApp
->sharedfiles
->SetFilePrio(file
, val
);
222 void KnownFile_Up_Prio_Auto(CKnownFile
* file
)
224 theApp
->sharedfiles
->SetFilePrio(file
, PR_AUTO
);
227 void Download_Set_Cat_Prio(uint8
, uint8
)
231 void Download_Set_Cat_Status(uint8
, int)
237 void SharedFilesShowFile(CKnownFile
* NOT_ON_DAEMON(file
))
240 if (theApp
->amuledlg
->m_sharedfileswnd
&& theApp
->amuledlg
->m_sharedfileswnd
->sharedfilesctrl
) {
241 theApp
->amuledlg
->m_sharedfileswnd
->sharedfilesctrl
->ShowFile(file
);
246 void SharedFilesRemoveFile(CKnownFile
* NOT_ON_DAEMON(file
))
249 if (theApp
->amuledlg
->m_sharedfileswnd
&& theApp
->amuledlg
->m_sharedfileswnd
->sharedfilesctrl
) {
250 theApp
->amuledlg
->m_sharedfileswnd
->sharedfilesctrl
->RemoveFile(file
);
255 void SharedFilesRemoveAllFiles()
258 if (theApp
->amuledlg
->m_sharedfileswnd
) {
259 theApp
->amuledlg
->m_sharedfileswnd
->RemoveAllSharedFiles();
265 void SharedFilesShowFileList()
268 if (theApp
->amuledlg
->m_sharedfileswnd
&& theApp
->amuledlg
->m_sharedfileswnd
->sharedfilesctrl
) {
269 theApp
->amuledlg
->m_sharedfileswnd
->sharedfilesctrl
->ShowFileList();
275 void SharedFilesUpdateItem(CKnownFile
* NOT_ON_DAEMON(file
))
278 if (theApp
->amuledlg
->m_sharedfileswnd
&& theApp
->amuledlg
->m_sharedfileswnd
->sharedfilesctrl
) {
279 theApp
->amuledlg
->m_sharedfileswnd
->sharedfilesctrl
->UpdateItem(file
);
285 void DownloadCtrlAddFile(CPartFile
* file
)
287 theApp
->ECServerHandler
->m_ec_notifier
->DownloadFile_AddFile(file
);
289 if (theApp
->amuledlg
->m_transferwnd
&& theApp
->amuledlg
->m_transferwnd
->downloadlistctrl
) {
290 theApp
->amuledlg
->m_transferwnd
->downloadlistctrl
->AddFile(file
);
295 void DownloadCtrlAddSource(CPartFile
* NOT_ON_DAEMON(owner
), CUpDownClient
* NOT_ON_DAEMON(source
), DownloadItemType
NOT_ON_DAEMON(type
))
298 if (theApp
->amuledlg
->m_transferwnd
&& theApp
->amuledlg
->m_transferwnd
->downloadlistctrl
) {
299 if (owner
->ShowSources()) {
300 theApp
->amuledlg
->m_transferwnd
->downloadlistctrl
->AddSource(owner
, source
, type
);
306 void DownloadCtrlRemoveFile(CPartFile
* file
)
308 theApp
->ECServerHandler
->m_ec_notifier
->DownloadFile_RemoveFile(file
);
310 if (theApp
->amuledlg
->m_transferwnd
&& theApp
->amuledlg
->m_transferwnd
->downloadlistctrl
) {
311 theApp
->amuledlg
->m_transferwnd
->downloadlistctrl
->RemoveFile(file
);
316 void DownloadCtrlRemoveSource(const CUpDownClient
* NOT_ON_DAEMON(source
), const CPartFile
* NOT_ON_DAEMON(owner
))
319 if (theApp
->amuledlg
->m_transferwnd
&& theApp
->amuledlg
->m_transferwnd
->downloadlistctrl
) {
320 if ((owner
== NULL
) || owner
->ShowSources()) {
321 theApp
->amuledlg
->m_transferwnd
->downloadlistctrl
->RemoveSource(source
, owner
);
327 void DownloadCtrlHideSource(CPartFile
* NOT_ON_DAEMON(file
))
330 if (theApp
->amuledlg
->m_transferwnd
&& theApp
->amuledlg
->m_transferwnd
->downloadlistctrl
) {
331 theApp
->amuledlg
->m_transferwnd
->downloadlistctrl
->ShowSources(file
, false);
336 void DownloadCtrlSort()
339 if (theApp
->amuledlg
->m_transferwnd
&& theApp
->amuledlg
->m_transferwnd
->downloadlistctrl
) {
340 theApp
->amuledlg
->m_transferwnd
->downloadlistctrl
->SortList();
346 void ClientCtrlAddClient(CUpDownClient
* NOT_ON_DAEMON(client
), ViewType
NOT_ON_DAEMON(type
))
349 if (theApp
->amuledlg
->m_transferwnd
&& theApp
->amuledlg
->m_transferwnd
->clientlistctrl
) {
350 theApp
->amuledlg
->m_transferwnd
->clientlistctrl
->InsertClient(client
, type
);
355 void ClientCtrlRefreshClient(CUpDownClient
* NOT_ON_DAEMON(client
), ViewType
NOT_ON_DAEMON(type
))
358 if (theApp
->amuledlg
->m_transferwnd
&& theApp
->amuledlg
->m_transferwnd
->clientlistctrl
) {
359 theApp
->amuledlg
->m_transferwnd
->clientlistctrl
->UpdateClient(client
, type
);
364 void ClientCtrlRemoveClient(CUpDownClient
* NOT_ON_DAEMON(client
), ViewType
NOT_ON_DAEMON(type
))
367 if (theApp
->amuledlg
->m_transferwnd
&& theApp
->amuledlg
->m_transferwnd
->clientlistctrl
) {
368 theApp
->amuledlg
->m_transferwnd
->clientlistctrl
->RemoveClient(client
, type
);
374 void ServerAdd(CServer
* NOT_ON_DAEMON(server
))
377 if (theApp
->amuledlg
->m_serverwnd
&& theApp
->amuledlg
->m_serverwnd
->serverlistctrl
) {
378 theApp
->amuledlg
->m_serverwnd
->serverlistctrl
->AddServer(server
);
383 void ServerRemove(CServer
* NOT_ON_DAEMON(server
))
386 if (theApp
->amuledlg
->m_serverwnd
&& theApp
->amuledlg
->m_serverwnd
->serverlistctrl
) {
387 theApp
->amuledlg
->m_serverwnd
->serverlistctrl
->RemoveServer(server
);
392 void ServerRemoveDead()
394 if (theApp
->serverlist
) {
395 theApp
->serverlist
->RemoveDeadServers();
399 void ServerRemoveAll()
402 if (theApp
->amuledlg
->m_serverwnd
&& theApp
->amuledlg
->m_serverwnd
->serverlistctrl
) {
403 theApp
->amuledlg
->m_serverwnd
->serverlistctrl
->DeleteAllItems();
408 void ServerHighlight(CServer
* NOT_ON_DAEMON(server
), bool NOT_ON_DAEMON(highlight
))
411 if (theApp
->amuledlg
->m_serverwnd
&& theApp
->amuledlg
->m_serverwnd
->serverlistctrl
) {
412 theApp
->amuledlg
->m_serverwnd
->serverlistctrl
->HighlightServer(server
, highlight
);
417 void ServerRefresh(CServer
* NOT_ON_DAEMON(server
))
420 if (theApp
->amuledlg
->m_serverwnd
&& theApp
->amuledlg
->m_serverwnd
->serverlistctrl
) {
421 theApp
->amuledlg
->m_serverwnd
->serverlistctrl
->RefreshServer(server
);
429 if (theApp
->amuledlg
->m_serverwnd
&& theApp
->amuledlg
->m_serverwnd
->serverlistctrl
) {
430 theApp
->amuledlg
->m_serverwnd
->serverlistctrl
->Freeze();
438 if (theApp
->amuledlg
->m_serverwnd
&& theApp
->amuledlg
->m_serverwnd
->serverlistctrl
) {
439 theApp
->amuledlg
->m_serverwnd
->serverlistctrl
->Thaw();
444 void ServerUpdateED2KInfo()
447 if (theApp
->amuledlg
->m_serverwnd
) {
448 theApp
->amuledlg
->m_serverwnd
->UpdateED2KInfo();
453 void ServerUpdateKadKInfo()
456 if (theApp
->amuledlg
->m_serverwnd
) {
457 theApp
->amuledlg
->m_serverwnd
->UpdateKadInfo();
466 if (theApp
->amuledlg
->m_searchwnd
) {
467 theApp
->amuledlg
->m_searchwnd
->ResetControls();
472 void SearchLocalEnd()
475 if (theApp
->amuledlg
->m_searchwnd
) {
476 theApp
->amuledlg
->m_searchwnd
->LocalSearchEnd();
481 void KadSearchEnd(uint32
NOT_ON_DAEMON(id
))
484 if (theApp
->amuledlg
->m_searchwnd
) {
485 theApp
->amuledlg
->m_searchwnd
->KadSearchEnd(id
);
490 void Search_Update_Sources(CSearchFile
* NOT_ON_DAEMON(result
))
493 if (theApp
->amuledlg
&& theApp
->amuledlg
->m_searchwnd
) {
494 theApp
->amuledlg
->m_searchwnd
->UpdateResult(result
);
499 void Search_Add_Result(CSearchFile
* NOT_ON_DAEMON(result
))
502 if (theApp
->amuledlg
&& theApp
->amuledlg
->m_searchwnd
) {
503 theApp
->amuledlg
->m_searchwnd
->AddResult(result
);
509 void ChatRefreshFriend(CFriend
* NOT_ON_DAEMON(Friend
), bool NOT_ON_DAEMON(connected
))
512 if (theApp
->amuledlg
->m_chatwnd
) {
513 theApp
->amuledlg
->m_chatwnd
->RefreshFriend(Friend
, connected
);
518 void ChatConnResult(bool NOT_ON_DAEMON(success
), uint64
NOT_ON_DAEMON(id
), wxString
NOT_ON_DAEMON(message
))
521 if (theApp
->amuledlg
->m_chatwnd
) {
522 theApp
->amuledlg
->m_chatwnd
->ConnectionResult(success
, message
, id
);
527 void ChatProcessMsg(uint64
NOT_ON_DAEMON(sender
), wxString
NOT_ON_DAEMON(message
))
530 if (theApp
->amuledlg
->m_chatwnd
) {
531 theApp
->amuledlg
->m_chatwnd
->ProcessMessage(sender
, message
);
537 void ChatSendCaptcha(wxString
NOT_ON_DAEMON(captcha
), uint64
NOT_ON_DAEMON(to_id
))
540 if (theApp
->amuledlg
->m_chatwnd
) {
541 theApp
->amuledlg
->m_chatwnd
->SendMessage(captcha
, wxEmptyString
, to_id
);
547 void ShowConnState(long WXUNUSED(state
))
550 theApp
->amuledlg
->ShowConnectionState();
554 void ShowQueueCount(uint32
NOT_ON_DAEMON(count
))
557 if (theApp
->amuledlg
->m_transferwnd
) {
558 theApp
->amuledlg
->m_transferwnd
->ShowQueueCount(count
);
563 void ShowUpdateCatTabTitles()
566 if (theApp
->amuledlg
->m_transferwnd
) {
567 theApp
->amuledlg
->m_transferwnd
->UpdateCatTabTitles();
575 if (theApp
->amuledlg
->m_transferwnd
) {
576 theApp
->amuledlg
->m_transferwnd
->
577 AddCategory(theApp
->glob_prefs
->GetCategory(
578 theApp
->glob_prefs
->GetCatCount()-1));
583 void CategoryUpdate(uint32
NOT_ON_DAEMON(cat
))
586 if (theApp
->amuledlg
->m_transferwnd
) {
587 theApp
->amuledlg
->m_transferwnd
->UpdateCategory(cat
);
588 theApp
->amuledlg
->m_transferwnd
->downloadlistctrl
->Refresh();
589 theApp
->amuledlg
->m_searchwnd
->UpdateCatChoice();
594 void CategoryDelete(uint32 cat
)
597 theApp
->glob_prefs
->RemoveCat(cat
);
599 if (theApp
->amuledlg
->m_transferwnd
) {
600 theApp
->amuledlg
->m_transferwnd
->RemoveCategory(cat
);
606 void PartFile_Swap_A4AF(CPartFile
* file
)
608 if ((file
->GetStatus(false) == PS_READY
|| file
->GetStatus(false) == PS_EMPTY
)) {
609 CPartFile::SourceSet::const_iterator it
= file
->GetA4AFList().begin();
610 for ( ; it
!= file
->GetA4AFList().end(); ) {
611 CUpDownClient
*cur_source
= *it
++;
613 cur_source
->SwapToAnotherFile(true, false, false, file
);
618 void PartFile_Swap_A4AF_Auto(CPartFile
* file
)
620 file
->SetA4AFAuto(!file
->IsA4AFAuto());
623 void PartFile_Swap_A4AF_Others(CPartFile
* file
)
625 if ((file
->GetStatus(false) == PS_READY
) || (file
->GetStatus(false) == PS_EMPTY
)) {
626 CPartFile::SourceSet::const_iterator it
= file
->GetSourceList().begin();
627 for( ; it
!= file
->GetSourceList().end(); ) {
628 CUpDownClient
* cur_source
= *it
++;
630 cur_source
->SwapToAnotherFile(false, false, false, NULL
);
635 void PartFile_Pause(CPartFile
* file
)
640 void PartFile_Resume(CPartFile
* file
)
643 file
->SavePartFile();
646 void PartFile_Stop(CPartFile
* file
)
651 void PartFile_PrioAuto(CPartFile
* file
, bool val
)
653 file
->SetAutoDownPriority(val
);
656 void PartFile_PrioSet(CPartFile
* file
, uint8 newDownPriority
, bool bSave
)
658 file
->SetDownPriority(newDownPriority
, bSave
);
661 void PartFile_Delete(CPartFile
* file
)
666 void PartFile_SetCat(CPartFile
* file
, uint32 val
)
668 file
->SetCategory(val
);
672 void KnownFile_Up_Prio_Set(CKnownFile
* file
, uint8 val
)
674 file
->SetAutoUpPriority(false);
675 file
->SetUpPriority(val
);
678 void KnownFile_Up_Prio_Auto(CKnownFile
* file
)
680 file
->SetAutoUpPriority(true);
681 file
->UpdateAutoUpPriority();
684 void KnownFile_Comment_Set(CKnownFile
* file
, wxString comment
)
686 file
->SetFileComment(comment
);
690 void Download_Set_Cat_Prio(uint8 cat
, uint8 newprio
)
692 theApp
->downloadqueue
->SetCatPrio(cat
, newprio
);
695 void Download_Set_Cat_Status(uint8 cat
, int newstatus
)
697 theApp
->downloadqueue
->SetCatStatus(cat
, newstatus
);
700 #endif // #ifdef CLIENT_GUI
702 // File_checked_for_headers