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"
16 # include "amuleDlg.h"
17 # include "ServerWnd.h"
18 # include "SearchDlg.h"
19 # include "TransferWnd.h"
20 # include "SharedFilesWnd.h"
21 # include "ServerListCtrl.h"
22 # include "SourceListCtrl.h"
23 # include "SharedFilesCtrl.h"
24 # include "DownloadListCtrl.h"
25 # include "muuli_wdr.h"
26 # include "SharedFilePeersListCtrl.h"
27 # include "PartFileConvertDlg.h"
31 # include "PartFileConvert.h"
34 #include <common/MacrosProgramSpecific.h>
36 DEFINE_LOCAL_EVENT_TYPE(MULE_EVT_NOTIFY
)
42 void HandleNotification(const CMuleNotiferBase
& ntf
)
44 if (wxThread::IsMain()) {
48 if (theApp
->amuledlg
) {
53 CMuleGUIEvent
evt(ntf
.Clone());
54 wxPostEvent(wxTheApp
, evt
);
59 void HandleNotificationAlways(const CMuleNotiferBase
& ntf
)
61 CMuleGUIEvent
evt(ntf
.Clone());
62 wxPostEvent(wxTheApp
, evt
);
66 void Search_Add_Download(CSearchFile
* file
, uint8 category
)
68 theApp
->downloadqueue
->AddSearchToDownload(file
, category
);
72 void ShowUserCount(wxString
NOT_ON_DAEMON(str
))
75 theApp
->amuledlg
->ShowUserCount(str
);
80 void Search_Update_Progress(uint32
NOT_ON_DAEMON(val
))
83 if (theApp
->amuledlg
->m_searchwnd
) {
85 // Global search ended
86 theApp
->amuledlg
->m_searchwnd
->ResetControls();
87 } else if (val
== 0xfffe) {
89 theApp
->amuledlg
->m_searchwnd
->KadSearchEnd(0);
91 theApp
->amuledlg
->m_searchwnd
->UpdateProgress(val
);
98 void DownloadCtrlUpdateItem(const void* item
)
101 theApp
->ECServerHandler
->m_ec_notifier
->DownloadFile_SetDirty((CPartFile
*)item
);
104 if (theApp
->amuledlg
->m_transferwnd
&& theApp
->amuledlg
->m_transferwnd
->downloadlistctrl
) {
105 theApp
->amuledlg
->m_transferwnd
->downloadlistctrl
->UpdateItem(item
);
111 void NodesURLChanged(wxString
NOT_ON_DAEMON(url
))
114 CastByID(IDC_NODESLISTURL
, NULL
, wxTextCtrl
)->SetValue(url
);
118 void ServersURLChanged(wxString
NOT_ON_DAEMON(url
))
121 CastByID(IDC_SERVERLISTURL
, NULL
, wxTextCtrl
)->SetValue(url
);
125 void ConvertUpdateProgress(float NOT_ON_DAEMON(percent
), wxString
NOT_ON_DAEMON(text
), wxString
NOT_ON_DAEMON(header
))
128 CPartFileConvertDlg::UpdateProgress(percent
, text
, header
);
132 void ConvertUpdateJobInfo(ConvertInfo
NOT_ON_DAEMON(info
))
135 CPartFileConvertDlg::UpdateJobInfo(info
);
139 void ConvertRemoveJobInfo(unsigned NOT_ON_DAEMON(id
))
142 CPartFileConvertDlg::RemoveJobInfo(id
);
146 void ConvertClearInfos()
149 CPartFileConvertDlg::ClearInfo();
153 void ConvertRemoveJob(unsigned NOT_ON_REMOTEGUI(id
))
156 CPartFileConvert::RemoveJob(id
);
160 void ConvertRetryJob(unsigned NOT_ON_REMOTEGUI(id
))
163 CPartFileConvert::RetryJob(id
);
167 void ConvertReaddAllJobs()
170 CPartFileConvert::ReaddAllJobs();
177 theApp
->amuledlg
->Iconize(false);
181 void SourceCtrlUpdateSource(CUpDownClient
* NOT_ON_DAEMON(source
), SourceItemType
NOT_ON_DAEMON(type
))
184 if (theApp
->amuledlg
->m_transferwnd
&& theApp
->amuledlg
->m_transferwnd
->clientlistctrl
) {
185 theApp
->amuledlg
->m_transferwnd
->clientlistctrl
->UpdateItem(source
, type
);
190 void SourceCtrlAddSource(CPartFile
* NOT_ON_DAEMON(owner
), CUpDownClient
* NOT_ON_DAEMON(source
), SourceItemType
NOT_ON_DAEMON(type
))
193 if (theApp
->amuledlg
->m_transferwnd
&& theApp
->amuledlg
->m_transferwnd
->clientlistctrl
) {
194 theApp
->amuledlg
->m_transferwnd
->clientlistctrl
->AddSource(owner
, source
, type
);
199 void SourceCtrlRemoveSource(const CUpDownClient
* NOT_ON_DAEMON(source
), const CPartFile
* NOT_ON_DAEMON(owner
))
202 if (theApp
->amuledlg
->m_transferwnd
&& theApp
->amuledlg
->m_transferwnd
->clientlistctrl
) {
203 theApp
->amuledlg
->m_transferwnd
->clientlistctrl
->RemoveSource(source
, owner
);
208 void SharedCtrlAddClient(CKnownFile
* NOT_ON_DAEMON(owner
), CUpDownClient
* NOT_ON_DAEMON(source
), SourceItemType
NOT_ON_DAEMON(type
))
211 if (theApp
->amuledlg
->m_sharedfileswnd
&& theApp
->amuledlg
->m_sharedfileswnd
->peerslistctrl
) {
212 theApp
->amuledlg
->m_sharedfileswnd
->peerslistctrl
->AddSource(owner
, source
, type
);
217 void SharedCtrlRefreshClient(CUpDownClient
* NOT_ON_DAEMON(client
), SourceItemType
NOT_ON_DAEMON(type
))
220 if (theApp
->amuledlg
->m_sharedfileswnd
&& theApp
->amuledlg
->m_sharedfileswnd
->peerslistctrl
) {
221 theApp
->amuledlg
->m_sharedfileswnd
->peerslistctrl
->UpdateItem(client
, type
);
226 void SharedCtrlRemoveClient(const CKnownFile
* NOT_ON_DAEMON(owner
), const CUpDownClient
* NOT_ON_DAEMON(source
))
229 if (theApp
->amuledlg
->m_sharedfileswnd
&& theApp
->amuledlg
->m_sharedfileswnd
->peerslistctrl
) {
230 theApp
->amuledlg
->m_sharedfileswnd
->peerslistctrl
->RemoveSource(source
, owner
);
235 void ServerRefresh(CServer
* NOT_ON_DAEMON(server
))
238 if (theApp
->amuledlg
->m_serverwnd
&& theApp
->amuledlg
->m_serverwnd
->serverlistctrl
) {
239 theApp
->amuledlg
->m_serverwnd
->serverlistctrl
->RefreshServer(server
);
247 void PartFile_Swap_A4AF(CPartFile
* file
)
249 theApp
->downloadqueue
->SendFileCommand(file
, EC_OP_PARTFILE_SWAP_A4AF_THIS
);
252 void PartFile_Swap_A4AF_Auto(CPartFile
* file
)
254 theApp
->downloadqueue
->SendFileCommand(file
, EC_OP_PARTFILE_SWAP_A4AF_THIS_AUTO
);
257 void PartFile_Swap_A4AF_Others(CPartFile
* file
)
259 theApp
->downloadqueue
->SendFileCommand(file
, EC_OP_PARTFILE_SWAP_A4AF_OTHERS
);
262 void PartFile_Pause(CPartFile
* file
)
264 theApp
->downloadqueue
->SendFileCommand(file
, EC_OP_PARTFILE_PAUSE
);
267 void PartFile_Resume(CPartFile
* file
)
269 theApp
->downloadqueue
->SendFileCommand(file
, EC_OP_PARTFILE_RESUME
);
272 void PartFile_Stop(CPartFile
* file
)
274 theApp
->downloadqueue
->SendFileCommand(file
, EC_OP_PARTFILE_STOP
);
277 void PartFile_PrioAuto(CPartFile
* file
, bool val
)
279 theApp
->downloadqueue
->AutoPrio(file
, val
);
282 void PartFile_PrioSet(CPartFile
* file
, uint8 newDownPriority
, bool)
284 theApp
->downloadqueue
->Prio(file
, newDownPriority
);
287 void PartFile_Delete(CPartFile
* file
)
289 theApp
->downloadqueue
->SendFileCommand(file
, EC_OP_PARTFILE_DELETE
);
292 void PartFile_SetCat(CPartFile
* file
, uint32 val
)
294 theApp
->downloadqueue
->Category(file
, val
);
297 void KnownFile_Up_Prio_Set(CKnownFile
* file
, uint8 val
)
299 theApp
->sharedfiles
->SetFilePrio(file
, val
);
302 void KnownFile_Up_Prio_Auto(CKnownFile
* file
)
304 theApp
->sharedfiles
->SetFilePrio(file
, PR_AUTO
);
307 void KnownFile_Comment_Set(CKnownFile
* file
, wxString comment
, int8 rating
)
309 theApp
->sharedfiles
->SetFileCommentRating(file
, comment
, rating
);
312 void Download_Set_Cat_Prio(uint8
, uint8
)
316 void Download_Set_Cat_Status(uint8
, int)
322 void SharedFilesShowFile(CKnownFile
* NOT_ON_DAEMON(file
))
325 if (theApp
->amuledlg
->m_sharedfileswnd
&& theApp
->amuledlg
->m_sharedfileswnd
->sharedfilesctrl
) {
326 theApp
->amuledlg
->m_sharedfileswnd
->sharedfilesctrl
->ShowFile(file
);
331 void SharedFilesRemoveFile(CKnownFile
* NOT_ON_DAEMON(file
))
334 if (theApp
->amuledlg
->m_sharedfileswnd
&& theApp
->amuledlg
->m_sharedfileswnd
->sharedfilesctrl
) {
335 theApp
->amuledlg
->m_sharedfileswnd
->sharedfilesctrl
->RemoveFile(file
);
340 void SharedFilesRemoveAllFiles()
343 if (theApp
->amuledlg
->m_sharedfileswnd
) {
344 theApp
->amuledlg
->m_sharedfileswnd
->RemoveAllSharedFiles();
350 void SharedFilesShowFileList()
353 if (theApp
->amuledlg
->m_sharedfileswnd
&& theApp
->amuledlg
->m_sharedfileswnd
->sharedfilesctrl
) {
354 theApp
->amuledlg
->m_sharedfileswnd
->sharedfilesctrl
->ShowFileList();
360 void SharedFilesUpdateItem(CKnownFile
* NOT_ON_DAEMON(file
))
363 if (theApp
->amuledlg
->m_sharedfileswnd
&& theApp
->amuledlg
->m_sharedfileswnd
->sharedfilesctrl
) {
364 theApp
->amuledlg
->m_sharedfileswnd
->sharedfilesctrl
->UpdateItem(file
);
370 void DownloadCtrlAddFile(CPartFile
* file
)
372 theApp
->ECServerHandler
->m_ec_notifier
->DownloadFile_AddFile(file
);
374 if (theApp
->amuledlg
->m_transferwnd
&& theApp
->amuledlg
->m_transferwnd
->downloadlistctrl
) {
375 theApp
->amuledlg
->m_transferwnd
->downloadlistctrl
->AddFile(file
);
380 void DownloadCtrlRemoveFile(CPartFile
* file
)
382 theApp
->ECServerHandler
->m_ec_notifier
->DownloadFile_RemoveFile(file
);
384 if (theApp
->amuledlg
->m_transferwnd
&& theApp
->amuledlg
->m_transferwnd
->downloadlistctrl
) {
385 theApp
->amuledlg
->m_transferwnd
->downloadlistctrl
->RemoveFile(file
);
390 void DownloadCtrlSort()
393 if (theApp
->amuledlg
->m_transferwnd
&& theApp
->amuledlg
->m_transferwnd
->downloadlistctrl
) {
394 theApp
->amuledlg
->m_transferwnd
->downloadlistctrl
->SortList();
399 void ServerAdd(CServer
* NOT_ON_DAEMON(server
))
402 if (theApp
->amuledlg
->m_serverwnd
&& theApp
->amuledlg
->m_serverwnd
->serverlistctrl
) {
403 theApp
->amuledlg
->m_serverwnd
->serverlistctrl
->AddServer(server
);
408 void ServerRemove(CServer
* NOT_ON_DAEMON(server
))
411 if (theApp
->amuledlg
->m_serverwnd
&& theApp
->amuledlg
->m_serverwnd
->serverlistctrl
) {
412 theApp
->amuledlg
->m_serverwnd
->serverlistctrl
->RemoveServer(server
);
417 void ServerRemoveDead()
419 if (theApp
->serverlist
) {
420 theApp
->serverlist
->RemoveDeadServers();
424 void ServerRemoveAll()
427 if (theApp
->amuledlg
->m_serverwnd
&& theApp
->amuledlg
->m_serverwnd
->serverlistctrl
) {
428 theApp
->amuledlg
->m_serverwnd
->serverlistctrl
->DeleteAllItems();
433 void ServerHighlight(CServer
* NOT_ON_DAEMON(server
), bool NOT_ON_DAEMON(highlight
))
436 if (theApp
->amuledlg
->m_serverwnd
&& theApp
->amuledlg
->m_serverwnd
->serverlistctrl
) {
437 theApp
->amuledlg
->m_serverwnd
->serverlistctrl
->HighlightServer(server
, highlight
);
445 if (theApp
->amuledlg
->m_serverwnd
&& theApp
->amuledlg
->m_serverwnd
->serverlistctrl
) {
446 theApp
->amuledlg
->m_serverwnd
->serverlistctrl
->Freeze();
454 if (theApp
->amuledlg
->m_serverwnd
&& theApp
->amuledlg
->m_serverwnd
->serverlistctrl
) {
455 theApp
->amuledlg
->m_serverwnd
->serverlistctrl
->Thaw();
460 void ServerUpdateED2KInfo()
463 if (theApp
->amuledlg
->m_serverwnd
) {
464 theApp
->amuledlg
->m_serverwnd
->UpdateED2KInfo();
469 void ServerUpdateKadKInfo()
472 if (theApp
->amuledlg
->m_serverwnd
) {
473 theApp
->amuledlg
->m_serverwnd
->UpdateKadInfo();
482 if (theApp
->amuledlg
->m_searchwnd
) {
483 theApp
->amuledlg
->m_searchwnd
->ResetControls();
488 void SearchLocalEnd()
491 if (theApp
->amuledlg
->m_searchwnd
) {
492 theApp
->amuledlg
->m_searchwnd
->LocalSearchEnd();
497 void KadSearchEnd(uint32
NOT_ON_DAEMON(id
))
500 if (theApp
->amuledlg
->m_searchwnd
) {
501 theApp
->amuledlg
->m_searchwnd
->KadSearchEnd(id
);
504 theApp
->searchlist
->SetKadSearchFinished();
507 void Search_Update_Sources(CSearchFile
* result
)
509 result
->SetDownloadStatus();
511 if (theApp
->amuledlg
&& theApp
->amuledlg
->m_searchwnd
) {
512 theApp
->amuledlg
->m_searchwnd
->UpdateResult(result
);
517 void Search_Add_Result(CSearchFile
* NOT_ON_DAEMON(result
))
520 if (theApp
->amuledlg
&& theApp
->amuledlg
->m_searchwnd
) {
521 theApp
->amuledlg
->m_searchwnd
->AddResult(result
);
527 void ChatRefreshFriend(CFriend
* NOT_ON_DAEMON(Friend
), bool NOT_ON_DAEMON(connected
))
530 if (theApp
->amuledlg
->m_chatwnd
) {
531 theApp
->amuledlg
->m_chatwnd
->RefreshFriend(Friend
, connected
);
536 void ChatConnResult(bool NOT_ON_DAEMON(success
), uint64
NOT_ON_DAEMON(id
), wxString
NOT_ON_DAEMON(message
))
539 if (theApp
->amuledlg
->m_chatwnd
) {
540 theApp
->amuledlg
->m_chatwnd
->ConnectionResult(success
, message
, id
);
545 void ChatProcessMsg(uint64
NOT_ON_DAEMON(sender
), wxString
NOT_ON_DAEMON(message
))
548 if (theApp
->amuledlg
->m_chatwnd
) {
549 theApp
->amuledlg
->m_chatwnd
->ProcessMessage(sender
, message
);
555 void ChatSendCaptcha(wxString
NOT_ON_DAEMON(captcha
), uint64
NOT_ON_DAEMON(to_id
))
558 if (theApp
->amuledlg
->m_chatwnd
) {
559 theApp
->amuledlg
->m_chatwnd
->SendMessage(captcha
, wxEmptyString
, to_id
);
565 void ShowConnState(long NOT_ON_DAEMON(forceUpdate
))
568 theApp
->amuledlg
->ShowConnectionState(forceUpdate
!= 0);
572 void ShowQueueCount(uint32
NOT_ON_DAEMON(count
))
575 if (theApp
->amuledlg
->m_transferwnd
) {
576 theApp
->amuledlg
->m_transferwnd
->ShowQueueCount(count
);
581 void ShowUpdateCatTabTitles()
584 if (theApp
->amuledlg
->m_transferwnd
) {
585 theApp
->amuledlg
->m_transferwnd
->UpdateCatTabTitles();
593 if (theApp
->amuledlg
->m_transferwnd
) {
594 theApp
->amuledlg
->m_transferwnd
->
595 AddCategory(theApp
->glob_prefs
->GetCategory(
596 theApp
->glob_prefs
->GetCatCount()-1));
601 void CategoryUpdate(uint32
NOT_ON_DAEMON(cat
))
604 if (theApp
->amuledlg
->m_transferwnd
) {
605 theApp
->amuledlg
->m_transferwnd
->UpdateCategory(cat
);
606 theApp
->amuledlg
->m_transferwnd
->downloadlistctrl
->Refresh();
607 theApp
->amuledlg
->m_searchwnd
->UpdateCatChoice();
612 void CategoryDelete(uint32 cat
)
616 theApp
->downloadqueue
->ResetCatParts(cat
);
617 theApp
->glob_prefs
->RemoveCat(cat
);
618 if ( theApp
->glob_prefs
->GetCatCount() == 1 ) {
619 thePrefs::SetAllcatFilter( acfAll
);
621 theApp
->glob_prefs
->SaveCats();
624 if (theApp
->amuledlg
->m_transferwnd
) {
625 theApp
->amuledlg
->m_transferwnd
->RemoveCategory(cat
);
631 void PartFile_Swap_A4AF(CPartFile
* file
)
633 if ((file
->GetStatus(false) == PS_READY
|| file
->GetStatus(false) == PS_EMPTY
)) {
634 CPartFile::SourceSet::const_iterator it
= file
->GetA4AFList().begin();
635 for ( ; it
!= file
->GetA4AFList().end(); ) {
636 CUpDownClient
*cur_source
= *it
++;
638 cur_source
->SwapToAnotherFile(true, false, false, file
);
643 void PartFile_Swap_A4AF_Auto(CPartFile
* file
)
645 file
->SetA4AFAuto(!file
->IsA4AFAuto());
648 void PartFile_Swap_A4AF_Others(CPartFile
* file
)
650 if ((file
->GetStatus(false) == PS_READY
) || (file
->GetStatus(false) == PS_EMPTY
)) {
651 CPartFile::SourceSet::const_iterator it
= file
->GetSourceList().begin();
652 for( ; it
!= file
->GetSourceList().end(); ) {
653 CUpDownClient
* cur_source
= *it
++;
655 cur_source
->SwapToAnotherFile(false, false, false, NULL
);
660 void PartFile_Pause(CPartFile
* file
)
665 void PartFile_Resume(CPartFile
* file
)
668 file
->SavePartFile();
671 void PartFile_Stop(CPartFile
* file
)
676 void PartFile_PrioAuto(CPartFile
* file
, bool val
)
678 file
->SetAutoDownPriority(val
);
681 void PartFile_PrioSet(CPartFile
* file
, uint8 newDownPriority
, bool bSave
)
683 file
->SetDownPriority(newDownPriority
, bSave
);
686 void PartFile_Delete(CPartFile
* file
)
691 void PartFile_SetCat(CPartFile
* file
, uint32 val
)
693 file
->SetCategory(val
);
697 void KnownFile_Up_Prio_Set(CKnownFile
* file
, uint8 val
)
699 file
->SetAutoUpPriority(false);
700 file
->SetUpPriority(val
);
703 void KnownFile_Up_Prio_Auto(CKnownFile
* file
)
705 file
->SetAutoUpPriority(true);
706 file
->UpdateAutoUpPriority();
709 void KnownFile_Comment_Set(CKnownFile
* file
, wxString comment
, int8 rating
)
711 file
->SetFileCommentRating(comment
, rating
);
712 SharedFilesUpdateItem(file
);
716 void Download_Set_Cat_Prio(uint8 cat
, uint8 newprio
)
718 theApp
->downloadqueue
->SetCatPrio(cat
, newprio
);
721 void Download_Set_Cat_Status(uint8 cat
, int newstatus
)
723 theApp
->downloadqueue
->SetCatStatus(cat
, newstatus
);
726 void IPFilter_Reload()
728 theApp
->ipfilter
->Reload();
731 void IPFilter_Update(wxString url
)
733 theApp
->ipfilter
->Update(url
);
737 #endif // #ifdef CLIENT_GUI
739 // File_checked_for_headers