2 // This file is part of the aMule Project.
4 // Copyright (c) 2003-2008 aMule Team ( admin@amule.org / http://www.amule.org )
5 // Copyright (c) 2002 Merkur ( devs@emule-project.net / http://www.emule-project.net )
7 // Any parts of this program derived from the xMule, lMule or eMule project,
8 // or contributed by third-party developers are copyrighted by their
11 // This program is free software; you can redistribute it and/or modify
12 // it under the terms of the GNU General Public License as published by
13 // the Free Software Foundation; either version 2 of the License, or
14 // (at your option) any later version.
16 // This program is distributed in the hope that it will be useful,
17 // but WITHOUT ANY WARRANTY; without even the implied warranty of
18 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 // GNU General Public License for more details.
21 // You should have received a copy of the GNU General Public License
22 // along with this program; if not, write to the Free Software
23 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
28 #include <wx/archive.h>
29 #include <wx/config.h> // Do_not_auto_remove (MacOS 10.3, wx 2.7)
30 #include <wx/confbase.h> // Do_not_auto_remove (MacOS 10.3, wx 2.7)
31 #include <wx/html/htmlwin.h>
32 #include <wx/mimetype.h> // Do_not_auto_remove (win32)
33 #include <wx/stattext.h>
34 #include <wx/stdpaths.h>
35 #include <wx/textfile.h> // Do_not_auto_remove (win32)
36 #include <wx/tokenzr.h>
37 #include <wx/wfstream.h>
38 #include <wx/zipstrm.h>
39 #include <wx/wupdlock.h> // Needed for wxWindowUpdateLocker
41 #include <common/EventIDs.h>
44 #include "config.h" // Needed for SVNDATE, PACKAGE, VERSION
46 #include <common/ClientVersion.h>
47 #endif // HAVE_CONFIG_H
49 #include "amuleDlg.h" // Interface declarations.
51 #include <common/Format.h> // Needed for CFormat
52 #include "amule.h" // Needed for theApp
53 #include "ChatWnd.h" // Needed for CChatWnd
54 #include "ClientListCtrl.h" // Needed for CClientListCtrl
55 #include "DownloadListCtrl.h" // Needed for CDownloadListCtrl
56 #include "DownloadQueue.h" // Needed for CDownloadQueue
57 #include "KadDlg.h" // Needed for CKadDlg
59 #include "MuleTrayIcon.h"
60 #include "muuli_wdr.h" // Needed for ID_BUTTON*
61 #include "Preferences.h" // Needed for CPreferences
62 #include "PrefsUnifiedDlg.h"
63 #include "SearchDlg.h" // Needed for CSearchDlg
64 #include "Server.h" // Needed for CServer
65 #include "ServerConnect.h" // Needed for CServerConnect
66 #include "ServerWnd.h" // Needed for CServerWnd
67 #include "SharedFilesWnd.h" // Needed for CSharedFilesWnd
68 #include "Statistics.h" // Needed for theStats
69 #include "StatisticsDlg.h" // Needed for CStatisticsDlg
70 #include "TerminationProcess.h" // Needed for CTerminationProcess
71 #include "TransferWnd.h" // Needed for CTransferWnd
73 #include "PartFileConvert.h"
80 #include "kademlia/kademlia/Kademlia.h"
82 #ifdef ENABLE_IP2COUNTRY
83 #include "IP2Country.h" // Needed for IP2Country
86 BEGIN_EVENT_TABLE(CamuleDlg
, wxFrame
)
88 EVT_TOOL(ID_BUTTONNETWORKS
, CamuleDlg::OnToolBarButton
)
89 EVT_TOOL(ID_BUTTONSEARCH
, CamuleDlg::OnToolBarButton
)
90 EVT_TOOL(ID_BUTTONTRANSFER
, CamuleDlg::OnToolBarButton
)
91 EVT_TOOL(ID_BUTTONSHARED
, CamuleDlg::OnToolBarButton
)
92 EVT_TOOL(ID_BUTTONMESSAGES
, CamuleDlg::OnToolBarButton
)
93 EVT_TOOL(ID_BUTTONSTATISTICS
, CamuleDlg::OnToolBarButton
)
94 EVT_TOOL(ID_ABOUT
, CamuleDlg::OnAboutButton
)
96 EVT_TOOL(ID_BUTTONNEWPREFERENCES
, CamuleDlg::OnPrefButton
)
98 EVT_TOOL(ID_BUTTONIMPORT
, CamuleDlg::OnImportButton
)
101 EVT_TOOL(ID_BUTTONCONNECT
, CamuleDlg::OnBnConnect
)
103 EVT_CLOSE(CamuleDlg::OnClose
)
104 EVT_ICONIZE(CamuleDlg::OnMinimize
)
106 EVT_BUTTON(ID_BUTTON_FAST
, CamuleDlg::OnBnClickedFast
)
107 EVT_BUTTON(IDC_SHOWSTATUSTEXT
, CamuleDlg::OnBnStatusText
)
109 EVT_TIMER(ID_GUI_TIMER_EVENT
, CamuleDlg::OnGUITimer
)
111 EVT_SIZE(CamuleDlg::OnMainGUISizeChange
)
113 EVT_KEY_UP(CamuleDlg::OnKeyPressed
)
115 EVT_MENU(wxID_EXIT
, CamuleDlg::OnExit
)
120 #define wxCLOSE_BOX 0
123 CamuleDlg::CamuleDlg(
125 const wxString
&title
,
130 pParent
, -1, title
, where
, dlg_size
,
131 wxCAPTION
|wxRESIZE_BORDER
|wxSYSTEM_MENU
|wxDIALOG_NO_PARENT
|
132 wxRESIZE_BORDER
|wxMINIMIZE_BOX
|wxMAXIMIZE_BOX
|wxCLOSE_BOX
,
137 m_sharedfileswnd(NULL
),
140 m_statisticswnd(NULL
),
146 m_prefsVisible(false),
148 m_wndTaskbarNotifier(NULL
),
149 m_nActiveDialog(DT_NETWORKS_WND
),
150 m_is_safe_state(false),
151 m_BlinkMessages(false),
152 m_CurrentBlinkBitmap(24),
155 m_clientSkinNames(CLIENT_SKIN_SIZE
)
157 // Initialize skin names
158 m_clientSkinNames
[Client_Green_Smiley
] = wxT("Transfer");
159 m_clientSkinNames
[Client_Red_Smiley
] = wxT("Connecting");
160 m_clientSkinNames
[Client_Yellow_Smiley
] = wxT("OnQueue");
161 m_clientSkinNames
[Client_Grey_Smiley
] = wxT("A4AFNoNeededPartsQueueFull");
162 m_clientSkinNames
[Client_White_Smiley
] = wxT("StatusUnknown");
163 m_clientSkinNames
[Client_ExtendedProtocol_Smiley
] = wxT("ExtendedProtocol");
164 m_clientSkinNames
[Client_SecIdent_Smiley
] = wxT("SecIdent");
165 m_clientSkinNames
[Client_BadGuy_Smiley
] = wxT("BadGuy");
166 m_clientSkinNames
[Client_CreditsGrey_Smiley
] = wxT("CreditsGrey");
167 m_clientSkinNames
[Client_CreditsYellow_Smiley
] = wxT("CreditsYellow");
168 m_clientSkinNames
[Client_Upload_Smiley
] = wxT("Upload");
169 m_clientSkinNames
[Client_Friend_Smiley
] = wxT("Friend");
170 m_clientSkinNames
[Client_eMule_Smiley
] = wxT("eMule");
171 m_clientSkinNames
[Client_mlDonkey_Smiley
] = wxT("mlDonkey");
172 m_clientSkinNames
[Client_eDonkeyHybrid_Smiley
] = wxT("eDonkeyHybrid");
173 m_clientSkinNames
[Client_aMule_Smiley
] = wxT("aMule");
174 m_clientSkinNames
[Client_lphant_Smiley
] = wxT("lphant");
175 m_clientSkinNames
[Client_Shareaza_Smiley
] = wxT("Shareaza");
176 m_clientSkinNames
[Client_xMule_Smiley
] = wxT("xMule");
177 m_clientSkinNames
[Client_Unknown
] = wxT("Unknown");
178 m_clientSkinNames
[Client_InvalidRating_Smiley
] = wxT("InvalidRatingOnFile");
179 m_clientSkinNames
[Client_PoorRating_Smiley
] = wxT("PoorRatingOnFile");
180 m_clientSkinNames
[Client_GoodRating_Smiley
] = wxT("GoodRatingOnFile");
181 m_clientSkinNames
[Client_FairRating_Smiley
] = wxT("FairRatingOnFile");
182 m_clientSkinNames
[Client_ExcellentRating_Smiley
] = wxT("ExcellentRatingOnFile");
183 m_clientSkinNames
[Client_CommentOnly_Smiley
] = wxT("CommentOnly");
184 m_clientSkinNames
[Client_Encryption_Smiley
] = wxT("Encrypted");
186 // wxWidgets send idle events to ALL WINDOWS by default... *SIGH*
187 wxIdleEvent::SetMode(wxIDLE_PROCESS_SPECIFIED
);
188 wxUpdateUIEvent::SetMode(wxUPDATE_UI_PROCESS_SPECIFIED
);
189 wxInitAllImageHandlers();
190 Apply_Clients_Skin();
192 bool override_where
= where
!= wxDefaultPosition
;
194 dlg_size
.x
!= DEFAULT_SIZE_X
||
195 dlg_size
.y
!= DEFAULT_SIZE_Y
;
196 if (!LoadGUIPrefs(override_where
, override_size
)) {
197 // Prefs not loaded for some reason, exit
198 AddLogLineM( true, wxT("Error! Unable to load Preferences") );
202 SetIcon(wxICON(aMule
));
206 // Create new sizer and stuff a wxPanel in there.
207 wxFlexGridSizer
*s_main
= new wxFlexGridSizer(1);
208 s_main
->AddGrowableCol(0);
209 s_main
->AddGrowableRow(0);
211 wxPanel
* p_cnt
= new wxPanel(this, -1, wxDefaultPosition
, wxDefaultSize
);
212 s_main
->Add(p_cnt
, 0, wxGROW
|wxEXPAND
, 0);
213 muleDlg(p_cnt
, false, true);
214 SetSizer(s_main
, true);
216 m_serverwnd
= new CServerWnd(p_cnt
, m_srv_split_pos
);
217 AddLogLineM(false, wxEmptyString
);
218 AddLogLineM(false, wxT(" - ") +
219 CFormat(_("This is aMule %s based on eMule.")) % GetMuleVersion());
220 AddLogLineM(false, wxT(" ") +
221 CFormat(_("Running on %s")) % wxGetOsDescription());
222 AddLogLineM(false, wxT(" - ") +
223 wxString(_("Visit http://www.amule.org to check if a new version is available.")));
224 AddLogLineM(false, wxEmptyString
);
226 #ifdef ENABLE_IP2COUNTRY
227 m_IP2Country
= new CIP2Country();
229 m_searchwnd
= new CSearchDlg(p_cnt
);
230 m_transferwnd
= new CTransferWnd(p_cnt
);
231 m_sharedfileswnd
= new CSharedFilesWnd(p_cnt
);
232 m_statisticswnd
= new CStatisticsDlg(p_cnt
, theApp
->m_statistics
);
233 m_chatwnd
= new CChatWnd(p_cnt
);
234 m_kademliawnd
= CastChild(wxT("kadWnd"), CKadDlg
);
236 m_serverwnd
->Show(false);
237 m_searchwnd
->Show(false);
238 m_transferwnd
->Show(false);
239 m_sharedfileswnd
->Show(false);
240 m_statisticswnd
->Show(false);
241 m_chatwnd
->Show(false);
243 // Create the GUI timer
244 gui_timer
=new wxTimer(this,ID_GUI_TIMER_EVENT
);
246 AddLogLine(false, _("Fatal Error: Failed to create Timer"));
250 // Set transfers as active window
251 Create_Toolbar(thePrefs::VerticalToolbar());
252 SetActiveDialog(DT_TRANSFER_WND
, m_transferwnd
);
253 m_wndToolbar
->ToggleTool(ID_BUTTONTRANSFER
, true );
255 m_is_safe_state
= true;
257 // Init statistics stuff, better do it asap
258 m_statisticswnd
->Init();
259 m_kademliawnd
->Init();
260 m_searchwnd
->UpdateCatChoice();
261 if (thePrefs::UseTrayIcon()) {
266 // Must we start minimized?
267 if (thePrefs::GetStartMinimized()) {
272 wxAcceleratorEntry entries
[] = {
273 wxAcceleratorEntry(wxACCEL_CTRL
, wxT('Q'), wxID_EXIT
)
276 SetAcceleratorTable(wxAcceleratorTable(itemsof(entries
), entries
));
277 ShowED2KLinksHandler( thePrefs::GetFED2KLH() );
279 wxNotebook
* logs_notebook
= CastChild( ID_SRVLOG_NOTEBOOK
, wxNotebook
);
280 wxNotebook
* networks_notebook
= CastChild( ID_NETNOTEBOOK
, wxNotebook
);
282 wxASSERT(logs_notebook
->GetPageCount() == 4);
283 wxASSERT(networks_notebook
->GetPageCount() == 2);
285 for (int i
= 0; i
< logs_notebook
->GetPageCount(); ++i
) {
286 m_logpages
[i
].page
= logs_notebook
->GetPage(i
);
287 m_logpages
[i
].name
= logs_notebook
->GetPageText(i
);
290 for (int i
= 0; i
< networks_notebook
->GetPageCount(); ++i
) {
291 m_networkpages
[i
].page
= networks_notebook
->GetPage(i
);
292 m_networkpages
[i
].name
= networks_notebook
->GetPageText(i
);
295 DoNetworkRearrange();
299 // Madcat - Sets Fast ED2K Links Handler on/off.
300 void CamuleDlg::ShowED2KLinksHandler( bool show
)
302 // Errorchecking in case the pointer becomes invalid ...
303 if (s_fed2klh
== NULL
) {
304 wxLogWarning(wxT("Unable to find Fast ED2K Links handler sizer! Hiding FED2KLH aborted."));
308 s_dlgcnt
->Show( s_fed2klh
, show
);
312 // Toogles ed2k link handler.
313 void CamuleDlg::ToogleED2KLinksHandler()
315 // Errorchecking in case the pointer becomes invalid ...
316 if (s_fed2klh
== NULL
) {
317 wxLogWarning(wxT("Unable to find Fast ED2K Links handler sizer! Toogling FED2KLH aborted."));
320 ShowED2KLinksHandler(!s_dlgcnt
->IsShown(s_fed2klh
));
323 void CamuleDlg::SetActiveDialog(DialogType type
, wxWindow
* dlg
)
325 m_nActiveDialog
= type
;
327 if ( type
== DT_TRANSFER_WND
) {
328 if (thePrefs::ShowCatTabInfos()) {
329 m_transferwnd
->UpdateCatTabTitles();
334 m_activewnd
->Show(false);
335 contentSizer
->Detach(m_activewnd
);
338 contentSizer
->Add(dlg
, 1, wxALIGN_LEFT
|wxEXPAND
);
343 // Since we might be suspending redrawing while hiding the dialog
344 // we have to refresh it once it is visible again
345 dlg
->Refresh( true );
350 void CamuleDlg::UpdateTrayIcon(int percent
)
353 if(!theApp
->IsConnected()) {
354 m_wndTaskbarNotifier
->SetTrayIcon(TRAY_ICON_DISCONNECTED
, percent
);
356 if(theApp
->IsConnectedED2K() && theApp
->serverconnect
->IsLowID()) {
357 m_wndTaskbarNotifier
->SetTrayIcon(TRAY_ICON_LOWID
, percent
);
359 m_wndTaskbarNotifier
->SetTrayIcon(TRAY_ICON_HIGHID
, percent
);
365 void CamuleDlg::CreateSystray()
367 wxCHECK_RET(m_wndTaskbarNotifier
== NULL
,
368 wxT("Systray already created"));
370 m_wndTaskbarNotifier
= new CMuleTrayIcon();
371 // This will effectively show the Tray Icon.
376 void CamuleDlg::RemoveSystray()
378 delete m_wndTaskbarNotifier
;
379 m_wndTaskbarNotifier
= NULL
;
383 void CamuleDlg::OnToolBarButton(wxCommandEvent
& ev
)
385 static int lastbutton
= ID_BUTTONTRANSFER
;
387 // Kry - just if the GUI is ready for it
388 if ( m_is_safe_state
) {
390 // Rehide the handler if needed
391 if ( lastbutton
== ID_BUTTONSEARCH
&& !thePrefs::GetFED2KLH() ) {
392 if (ev
.GetId() != ID_BUTTONSEARCH
) {
393 ShowED2KLinksHandler( false );
395 // Toogle ED2K handler.
396 ToogleED2KLinksHandler();
400 if ( lastbutton
!= ev
.GetId() ) {
401 switch ( ev
.GetId() ) {
402 case ID_BUTTONNETWORKS
:
403 SetActiveDialog(DT_NETWORKS_WND
, m_serverwnd
);
404 // Set serverlist splitter position
405 CastChild( wxT("SrvSplitterWnd"), wxSplitterWindow
)->SetSashPosition(m_srv_split_pos
, true);
408 case ID_BUTTONSEARCH
:
409 // The search dialog should always display the handler
410 if ( !thePrefs::GetFED2KLH() )
411 ShowED2KLinksHandler( true );
413 SetActiveDialog(DT_SEARCH_WND
, m_searchwnd
);
416 case ID_BUTTONTRANSFER
:
417 SetActiveDialog(DT_TRANSFER_WND
, m_transferwnd
);
418 // Prepare the dialog, sets the splitter-position
419 m_transferwnd
->Prepare();
422 case ID_BUTTONSHARED
:
423 SetActiveDialog(DT_SHARED_WND
, m_sharedfileswnd
);
426 case ID_BUTTONMESSAGES
:
427 m_BlinkMessages
= false;
428 SetActiveDialog(DT_CHAT_WND
, m_chatwnd
);
431 case ID_BUTTONSTATISTICS
:
432 SetActiveDialog(DT_STATS_WND
, m_statisticswnd
);
435 // This shouldn't happen, but just in case
437 AddLogLineM( true, wxT("Unknown button triggered CamuleApp::OnToolBarButton().") );
442 m_wndToolbar
->ToggleTool(lastbutton
, lastbutton
== ev
.GetId() );
443 lastbutton
= ev
.GetId();
448 void CamuleDlg::OnAboutButton(wxCommandEvent
& WXUNUSED(ev
))
450 wxString msg
= wxT(" ");
452 msg
<< _("aMule remote control ") << wxT(VERSION
);
454 msg
<< wxT("aMule ") << wxT(VERSION
);
458 msg
<< _("Snapshot:") << wxT("\n ") << wxT(SVNDATE
);
460 msg
<< wxT("\n\n") << _(" 'All-Platform' p2p client based on eMule \n\n") <<
461 _(" Website: http://www.amule.org \n") <<
462 _(" Forum: http://forum.amule.org \n") <<
463 _(" FAQ: http://wiki.amule.org \n\n") <<
464 _(" Contact: admin@amule.org (administrative issues) \n") <<
465 _(" Copyright (C) 2003-2008 aMule Team \n\n") <<
466 _(" Part of aMule is based on \n") <<
467 _("Kademlia: Peer-to-peer routing based on the XOR metric.\n") <<
468 _(" Copyright (C) 2002 Petar Maymounkov\n") <<
469 _(" http://kademlia.scs.cs.nyu.edu\n");
471 if (m_is_safe_state
) {
472 wxMessageBox(msg
, _("Message"), wxOK
| wxICON_INFORMATION
, this);
477 void CamuleDlg::OnPrefButton(wxCommandEvent
& WXUNUSED(ev
))
479 if (m_is_safe_state
) {
480 if (m_prefsDialog
== NULL
) {
481 m_prefsDialog
= new PrefsUnifiedDlg(this);
484 m_prefsDialog
->TransferToWindow();
485 m_prefsDialog
->Show(true);
486 m_prefsDialog
->Raise();
492 void CamuleDlg::OnImportButton(wxCommandEvent
& WXUNUSED(ev
))
494 if ( m_is_safe_state
) {
495 CPartFileConvert::ShowGUI(NULL
);
500 CamuleDlg::~CamuleDlg()
502 printf("Shutting down aMule...\n");
506 theApp
->amuledlg
= NULL
;
508 #ifdef ENABLE_IP2COUNTRY
512 printf("aMule dialog destroyed\n");
516 void CamuleDlg::OnBnConnect(wxCommandEvent
& WXUNUSED(evt
))
519 bool disconnect
= (theApp
->IsConnectedED2K() || theApp
->serverconnect
->IsConnecting())
521 || (Kademlia::CKademlia::IsRunning())
524 if (thePrefs::GetNetworkED2K()) {
526 //disconnect if currently connected
527 if (theApp
->serverconnect
->IsConnecting()) {
528 theApp
->serverconnect
->StopConnectionTry();
530 theApp
->serverconnect
->Disconnect();
533 //connect if not currently connected
534 AddLogLine(true, _("Connecting"));
535 theApp
->serverconnect
->ConnectToAnyServer();
538 wxASSERT(!theApp
->IsConnectedED2K());
542 if (thePrefs::GetNetworkKademlia()) {
550 wxASSERT(!Kademlia::CKademlia::IsRunning());
554 ShowConnectionState();
558 void CamuleDlg::OnBnStatusText(wxCommandEvent
& WXUNUSED(evt
))
560 wxString line
= CastChild(wxT("infoLabel"), wxStaticText
)->GetLabel();
562 if (!line
.IsEmpty()) {
563 wxMessageBox(line
, wxString(_("Status text")), wxOK
|wxICON_INFORMATION
, this);
568 void CamuleDlg::ResetLog(int id
)
570 wxTextCtrl
* ct
= CastByID(id
, m_serverwnd
, wxTextCtrl
);
571 wxCHECK_RET(ct
, wxT("Resetting unknown log"));
575 if (id
== ID_LOGVIEW
) {
576 // Also clear the log line
577 wxStaticText
* text
= CastChild(wxT("infoLabel"), wxStaticText
);
578 text
->SetLabel(wxEmptyString
);
579 text
->GetParent()->Layout();
584 void CamuleDlg::AddLogLine(bool addtostatusbar
, const wxString
& line
)
586 // Remove newspace at end, it causes problems with the layout...
587 wxString bufferline
= line
.Strip(wxString::trailing
);
589 // Create the timestamp
590 wxString stamp
= wxDateTime::Now().FormatISODate() + wxT(" ") + wxDateTime::Now().FormatISOTime() + wxT(": ");
592 // Add the message to the log-view
593 wxTextCtrl
* ct
= CastByID( ID_LOGVIEW
, m_serverwnd
, wxTextCtrl
);
595 if ( bufferline
.IsEmpty() ) {
596 // If it's empty we just write a blank line with no timestamp.
597 ct
->AppendText( wxT("\n") );
599 // Bold critical log-lines
600 wxTextAttr style
= ct
->GetDefaultStyle();
601 wxFont font
= style
.GetFont();
602 font
.SetWeight(addtostatusbar
? wxFONTWEIGHT_BOLD
: wxFONTWEIGHT_NORMAL
);
604 ct
->SetDefaultStyle(style
);
606 // Split multi-line messages into individual lines
607 wxStringTokenizer
tokens( bufferline
, wxT("\n") );
608 while ( tokens
.HasMoreTokens() ) {
609 ct
->AppendText( stamp
+ tokens
.GetNextToken() + wxT("\n") );
613 ct
->ShowPosition( ct
->GetLastPosition() - 1 );
617 // Set the status-bar if the event warrents it
618 if ( addtostatusbar
) {
619 // Escape "&"s, which would otherwise not show up
620 bufferline
.Replace( wxT("&"), wxT("&&") );
621 wxStaticText
* text
= CastChild( wxT("infoLabel"), wxStaticText
);
622 // Only show the first line if multiple lines
623 text
->SetLabel( bufferline
.BeforeFirst( wxT('\n') ) );
624 text
->GetParent()->Layout();
630 void CamuleDlg::AddServerMessageLine(wxString
& message
)
632 wxTextCtrl
* cv
= CastByID( ID_SERVERINFO
, m_serverwnd
, wxTextCtrl
);
634 if (message
.Length() > 500) {
635 cv
->AppendText(message
.Left(500) + wxT("\n"));
637 cv
->AppendText(message
+ wxT("\n"));
639 cv
->ShowPosition(cv
->GetLastPosition()-1);
644 void CamuleDlg::ShowConnectionState()
646 static wxImageList
status_arrows(16,16,true,0);
647 if (!status_arrows
.GetImageCount()) {
648 // Generate the image list (This is only done once)
649 for (int t
= 0; t
< 7; ++t
) {
650 status_arrows
.Add(connImages(t
));
654 m_serverwnd
->UpdateED2KInfo();
655 m_serverwnd
->UpdateKadInfo();
658 ////////////////////////////////////////////////////////////
659 // Determine the status of the networks
661 enum ED2KState
{ ED2KOff
= 0, ED2KLowID
= 1, ED2KConnecting
= 2, ED2KHighID
= 3 };
662 enum EKadState
{ EKadOff
= 4, EKadFW
= 5, EKadConnecting
= 5, EKadOK
= 6 };
664 ED2KState ed2kState
= ED2KOff
;
665 EKadState kadState
= EKadOff
;
667 ////////////////////////////////////////////////////////////
668 // Update the label on the status-bar and determine
669 // the states of the two networks.
672 if (theApp
->IsConnectedED2K()) {
673 CServer
* server
= theApp
->serverconnect
->GetCurrentServer();
675 msgED2K
= CFormat(wxT("ED2K: %s")) % server
->GetListName();
678 if (theApp
->serverconnect
->IsLowID()) {
679 ed2kState
= ED2KLowID
;
681 ed2kState
= ED2KHighID
;
683 } else if (theApp
->serverconnect
->IsConnecting()) {
684 msgED2K
= _("ED2K: Connecting");
686 ed2kState
= ED2KConnecting
;
687 } else if (thePrefs::GetNetworkED2K()) {
688 msgED2K
= _("ED2K: Disconnected");
692 if (theApp
->IsConnectedKad()) {
693 if (theApp
->IsFirewalledKad()) {
694 msgKad
= _("Kad: Firewalled");
698 msgKad
= _("Kad: Connected");
702 } else if (theApp
->IsKadRunning()) {
703 msgKad
= _("Kad: Connecting");
705 kadState
= EKadConnecting
;
706 } else if (thePrefs::GetNetworkKademlia()) {
707 msgKad
= _("Kad: Off");
710 wxStaticText
* connLabel
= CastChild( wxT("connLabel"), wxStaticText
);
711 wxCHECK_RET(connLabel
, wxT("'connLabel' widget not found"));
714 if (msgED2K
.Length() && msgKad
.Length()) {
715 labelMsg
= msgED2K
+ wxT(" | ") + msgKad
;
717 labelMsg
= msgED2K
+ msgKad
;
720 connLabel
->SetLabel(labelMsg
);
721 connLabel
->GetParent()->Layout();
724 ////////////////////////////////////////////////////////////
725 // Update the connect/disconnect/cancel button.
734 static EConnState s_oldState
= ECS_Unknown
;
735 EConnState currentState
= ECS_Disconnected
;
737 if (theApp
->serverconnect
->IsConnecting() ||
738 (theApp
->IsKadRunning() && !theApp
->IsConnectedKad())) {
739 currentState
= ECS_Connecting
;
740 } else if (theApp
->IsConnected()) {
741 currentState
= ECS_Connected
;
743 currentState
= ECS_Disconnected
;
746 if (currentState
!= s_oldState
) {
747 wxWindowUpdateLocker
freezer(m_wndToolbar
);
749 wxToolBarToolBase
* toolbarTool
= m_wndToolbar
->RemoveTool(ID_BUTTONCONNECT
);
751 switch (currentState
) {
753 toolbarTool
->SetLabel(_("Cancel"));
754 toolbarTool
->SetShortHelp(_("Stop the current connection attempts"));
755 toolbarTool
->SetNormalBitmap(m_tblist
.GetBitmap(2));
759 toolbarTool
->SetLabel(_("Disconnect"));
760 toolbarTool
->SetShortHelp(_("Disconnect from the currently connected networks"));
761 toolbarTool
->SetNormalBitmap(m_tblist
.GetBitmap(1));
765 toolbarTool
->SetLabel(_("Connect"));
766 toolbarTool
->SetShortHelp(_("Connect to the currently enabled networks"));
767 toolbarTool
->SetNormalBitmap(m_tblist
.GetBitmap(0));
770 m_wndToolbar
->InsertTool(0, toolbarTool
);
771 m_wndToolbar
->Realize();
773 s_oldState
= currentState
;
777 ////////////////////////////////////////////////////////////
778 // Update the globe-icon in the lower-right corner.
780 wxStaticBitmap
* connBitmap
= CastChild( wxT("connImage"), wxStaticBitmap
);
781 wxCHECK_RET(connBitmap
, wxT("'connImage' widget not found"));
783 wxBitmap statusIcon
= connBitmap
->GetBitmap();
784 wxMemoryDC
bitmapDC(statusIcon
);
786 status_arrows
.Draw(kadState
, bitmapDC
, 0, 0, wxIMAGELIST_DRAW_TRANSPARENT
);
787 status_arrows
.Draw(ed2kState
, bitmapDC
, 0, 0, wxIMAGELIST_DRAW_TRANSPARENT
);
789 connBitmap
->SetBitmap(statusIcon
);
793 void CamuleDlg::ShowUserCount(const wxString
& info
)
795 wxStaticText
* label
= CastChild( wxT("userLabel"), wxStaticText
);
798 m_serverwnd
->UpdateKadInfo();
800 label
->SetLabel(info
);
801 label
->GetParent()->Layout();
805 void CamuleDlg::ShowTransferRate()
807 float kBpsUp
= theStats::GetUploadRate() / 1024.0;
808 float kBpsDown
= theStats::GetDownloadRate() / 1024.0;
810 if( thePrefs::ShowOverhead() )
812 buffer
= wxString::Format(_("Up: %.1f(%.1f) | Down: %.1f(%.1f)"), kBpsUp
, theStats::GetUpOverheadRate() / 1024.0, kBpsDown
, theStats::GetDownOverheadRate() / 1024.0);
814 buffer
= wxString::Format(_("Up: %.1f | Down: %.1f"), kBpsUp
, kBpsDown
);
816 buffer
.Truncate(50); // Max size 50
818 wxStaticText
* label
= CastChild( wxT("speedLabel"), wxStaticText
);
819 label
->SetLabel(buffer
);
820 label
->GetParent()->Layout();
822 // Show upload/download speed in title
823 if (thePrefs::GetShowRatesOnTitle()) {
824 wxString UpDownSpeed
= wxString::Format(wxT(" -- Up: %.1f | Down: %.1f"), kBpsUp
, kBpsDown
);
825 SetTitle(theApp
->m_FrameTitle
+ UpDownSpeed
);
828 wxASSERT((m_wndTaskbarNotifier
!= NULL
) == thePrefs::UseTrayIcon());
829 if (m_wndTaskbarNotifier
) {
831 int percentDown
= (int)ceil((kBpsDown
*100) / thePrefs::GetMaxGraphDownloadRate());
832 UpdateTrayIcon( ( percentDown
> 100 ) ? 100 : percentDown
);
835 if ( theApp
->IsConnected() ) {
836 buffer2
= CFormat(_("aMule (%s | Connected)")) % buffer
;
838 buffer2
= CFormat(_("aMule (%s | Disconnected)")) % buffer
;
840 m_wndTaskbarNotifier
->SetTrayToolTip(buffer2
);
843 wxStaticBitmap
* bmp
= CastChild( wxT("transferImg"), wxStaticBitmap
);
844 bmp
->SetBitmap(dlStatusImages((kBpsUp
>0.01 ? 2 : 0) + (kBpsDown
>0.01 ? 1 : 0)));
847 void CamuleDlg::DlgShutDown()
849 // Are we already shutting down or still on init?
850 if ( m_is_safe_state
== false ) {
855 m_is_safe_state
= false;
857 // Stop the GUI Timer
859 m_transferwnd
->downloadlistctrl
->DeleteAllItems();
861 // We want to delete the systray too!
865 void CamuleDlg::OnClose(wxCloseEvent
& evt
)
867 // This will be here till the core close is != app close
868 if (evt
.CanVeto() && thePrefs::IsConfirmExitEnabled() ) {
869 if (wxNO
== wxMessageBox(wxString(_("Do you really want to exit aMule?")),
870 wxString(_("Exit confirmation")), wxYES_NO
, this)) {
879 theApp
->ShutDown(evt
);
883 void CamuleDlg::OnBnClickedFast(wxCommandEvent
& WXUNUSED(evt
))
885 wxTextCtrl
* ctl
= CastChild( wxT("FastEd2kLinks"), wxTextCtrl
);
887 for ( int i
= 0; i
< ctl
->GetNumberOfLines(); i
++ ) {
888 wxString strlink
= ctl
->GetLineText(i
);
891 if ( !strlink
.IsEmpty() ) {
892 theApp
->downloadqueue
->AddLink( strlink
, m_transferwnd
->downloadlistctrl
->GetCategory() );
896 ctl
->SetValue(wxEmptyString
);
900 // Formerly known as LoadRazorPrefs()
901 bool CamuleDlg::LoadGUIPrefs(bool override_pos
, bool override_size
)
903 // Create a config base for loading razor preferences
904 wxConfigBase
*config
= wxConfigBase::Get();
905 // If config haven't been created exit without loading
906 if (config
== NULL
) {
910 // The section where to save in in file
911 wxString section
= wxT("/Razor_Preferences/");
913 // Get window size and position
914 int x1
= config
->Read(section
+ wxT("MAIN_X_POS"), -1);
915 int y1
= config
->Read(section
+ wxT("MAIN_Y_POS"), -1);
916 int x2
= config
->Read(section
+ wxT("MAIN_X_SIZE"), -1);
917 int y2
= config
->Read(section
+ wxT("MAIN_Y_SIZE"), -1);
919 int maximized
= config
->Read(section
+ wxT("Maximized"), 01);
921 // Kry - Random usable pos for m_srv_split_pos
922 m_srv_split_pos
= config
->Read(section
+ wxT("SRV_SPLITTER_POS"), 463l);
923 if (!override_size
) {
924 if (x2
> 0 && y2
> 0) {
928 // Probably first run.
935 // If x1 and y1 != -1 Redefine location
936 if(x1
!= -1 && y1
!= -1) {
937 wxRect display
= wxGetClientDisplayRect();
938 if (x1
<= display
.GetRightTop().x
&& y1
<= display
.GetRightBottom().y
) {
941 // It's offscreen... so let's not.
946 if (!override_size
&& !override_pos
&& maximized
) {
954 bool CamuleDlg::SaveGUIPrefs()
956 /* Razor 1a - Modif by MikaelB
957 Save client size and position */
959 // Create a config base for saving razor preferences
960 wxConfigBase
*config
= wxConfigBase::Get();
961 // If config haven't been created exit without saving
962 if (config
== NULL
) {
965 // The section where to save in in file
966 wxString section
= wxT("/Razor_Preferences/");
968 // Main window location and size
970 GetPosition(&x1
, &y1
);
973 // Saving window size and position
974 config
->Write(section
+wxT("MAIN_X_POS"), (long) x1
);
975 config
->Write(section
+wxT("MAIN_Y_POS"), (long) y1
);
977 config
->Write(section
+wxT("MAIN_X_SIZE"), (long) x2
);
978 config
->Write(section
+wxT("MAIN_Y_SIZE"), (long) y2
);
980 config
->Write(section
+wxT("Maximized"), (long) (IsMaximized() ? 1 : 0));
982 // Saving sash position of splitter in server window
983 config
->Write(section
+wxT("SRV_SPLITTER_POS"), (long) m_srv_split_pos
);
993 void CamuleDlg::DoIconize(bool iconize
)
995 // Evil Hack: check if the mouse is inside the window
997 if (GetScreenRect().Contains(wxGetMousePosition()))
1000 if (m_wndTaskbarNotifier
&& thePrefs::DoMinToTray()) {
1002 // Skip() will do it.
1012 // Will be done by Skip();
1018 void CamuleDlg::OnMinimize(wxIconizeEvent
& evt
)
1020 if (m_prefsDialog
&& m_prefsDialog
->IsShown()) {
1023 if (m_wndTaskbarNotifier
) {
1024 DoIconize(evt
.Iconized());
1030 void CamuleDlg::OnGUITimer(wxTimerEvent
& WXUNUSED(evt
))
1032 // Former TimerProc section
1034 static uint32 msPrev1
, msPrev5
, msPrevStats
;
1036 uint32 msCur
= theStats::GetUptimeMillis();
1038 // can this actually happen under wxwin ?
1044 static uint32 msPrevGraph
;
1045 int msGraphUpdate
= thePrefs::GetTrafficOMeterInterval() * 1000;
1046 if ((msGraphUpdate
> 0) && ((msCur
/ msGraphUpdate
) > (msPrevGraph
/ msGraphUpdate
))) {
1047 // trying to get the graph shifts evenly spaced after a change in the update period
1048 msPrevGraph
= msCur
;
1050 GraphUpdateInfo update
= theApp
->m_statistics
->GetPointsForUpdate();
1052 m_statisticswnd
->UpdateStatGraphs(theStats::GetPeakConnections(), update
);
1053 m_kademliawnd
->UpdateGraph(update
);
1056 //#warning TODO: CORE/GUI -- EC needed
1059 int sStatsUpdate
= thePrefs::GetStatsInterval();
1060 if ((sStatsUpdate
> 0) && ((int)(msCur
- msPrevStats
) > sStatsUpdate
*1000)) {
1061 if (m_statisticswnd
->IsShownOnScreen()) {
1062 msPrevStats
= msCur
;
1063 m_statisticswnd
->ShowStatistics();
1067 if (msCur
-msPrev5
> 5000) { // every 5 seconds
1070 if (thePrefs::ShowCatTabInfos() && theApp
->amuledlg
->m_activewnd
== theApp
->amuledlg
->m_transferwnd
) {
1071 m_transferwnd
->UpdateCatTabTitles();
1073 if (thePrefs::AutoSortDownload()) {
1074 m_transferwnd
->downloadlistctrl
->SortList();
1078 if (msCur
-msPrev1
> 1000) { // every second
1080 if (m_CurrentBlinkBitmap
== 12) {
1081 m_CurrentBlinkBitmap
= 7;
1084 if (m_BlinkMessages
) {
1085 m_CurrentBlinkBitmap
= 12;
1094 void CamuleDlg::SetMessagesTool()
1096 int pos
= m_wndToolbar
->GetToolPos(ID_BUTTONMESSAGES
);
1097 wxASSERT(pos
== 6); // so we don't miss a change on wx2.4
1099 wxWindowUpdateLocker
freezer(m_wndToolbar
);
1100 m_wndToolbar
->SetToolNormalBitmap(ID_BUTTONMESSAGES
, m_tblist
.GetBitmap(m_CurrentBlinkBitmap
));
1105 Try to launch the specified url:
1106 - Windows: Default or custom browser will be used.
1107 - Mac: Currently not implemented
1108 - Anything else: Try a number of hardcoded browsers. Should be made configurable...
1110 void CamuleDlg::LaunchUrl( const wxString
& url
)
1114 cmd
= thePrefs::GetBrowser();
1115 if ( !cmd
.IsEmpty() ) {
1117 // Pipes cause problems, so escape them
1118 tmp
.Replace( wxT("|"), wxT("%7C") );
1120 if (!cmd
.Replace(wxT("%s"), tmp
)) {
1121 // No %s found, just append the url
1122 cmd
+= wxT(" ") + tmp
;
1125 CTerminationProcess
*p
= new CTerminationProcess(cmd
);
1126 if (wxExecute(cmd
, wxEXEC_ASYNC
, p
)) {
1127 printf( "Launch Command: %s\n", (const char *)unicode2char(cmd
));
1135 wxTheMimeTypesManager
->GetFileTypeFromExtension(wxT("html"));
1137 wxLogError(wxT("Impossible to determine the file type for extension html. Please edit your MIME types."));
1141 bool ok
= ft
->GetOpenCommand(
1142 &cmd
, wxFileType::MessageParameters(url
, wxT("")));
1147 _("Could not determine the command for running the browser."),
1148 wxT("Browsing problem"), wxOK
|wxICON_EXCLAMATION
, this);
1152 wxPuts(wxT("Launch Command: ") + cmd
);
1153 CTerminationProcess
*p
= new CTerminationProcess(cmd
);
1154 if (wxExecute(cmd
, wxEXEC_ASYNC
, p
)) {
1161 // Unable to execute browser. But this error message doesn't make sense,
1162 // cosidering that you _can't_ set the browser executable path... =/
1163 wxLogError(wxT("Unable to launch browser. Please set correct browser executable path in Preferences."));
1167 wxString
CamuleDlg::GenWebSearchUrl(const wxString
&filename
, WebSearch wsProvider
)
1170 switch (wsProvider
) {
1172 URL
= wxT("http://www.filehash.com/search.html?pattern=FILENAME&submit=Find");
1177 URL
.Replace(wxT("FILENAME"), filename
);
1183 bool CamuleDlg::Check_and_Init_Skin()
1186 wxString
skinFileName(thePrefs::GetSkin());
1188 wxString
userDir(JoinPaths(GetConfigDir(), wxT("skins")) + wxFileName::GetPathSeparator());
1190 wxStandardPathsBase
&spb(wxStandardPaths::Get());
1192 wxString
dataDir(spb
.GetPluginsDir());
1193 #elif defined(__WXMAC__)
1194 wxString
dataDir(spb
.GetDataDir());
1196 wxString
dataDir(spb
.GetDataDir().BeforeLast(wxT('/')) + wxT("/amule"));
1198 wxString
systemDir(JoinPaths(dataDir
,wxT("skins")) + wxFileName::GetPathSeparator());
1201 skinFileName
.Replace(wxT("User:"), userDir
);
1202 skinFileName
.Replace(wxT("System:"), systemDir
);
1204 m_skinFileName
.Assign(skinFileName
);
1205 if (!m_skinFileName
.FileExists()) {
1206 AddLogLineM(true, CFormat(
1207 _("Skin directory '%s' does not exist")) %
1210 } else if (!m_skinFileName
.IsFileReadable()) {
1211 AddLogLineM(true, CFormat(
1212 _("Warning: Unable to open skin file '%s' for read")) %
1217 wxFFileInputStream
in(m_skinFileName
.GetFullPath());
1218 wxZipInputStream
zip(in
);
1220 while ((entry
= zip
.GetNextEntry()) != NULL
) {
1221 wxZipEntry
*& current
= cat
[entry
->GetInternalName()];
1230 void CamuleDlg::Add_Skin_Icon(
1231 const wxString
&iconName
,
1232 const wxBitmap
&stdIcon
,
1237 wxFFileInputStream
in(m_skinFileName
.GetFullPath());
1238 wxZipInputStream
zip(in
);
1240 it
= cat
.find(wxZipEntry::GetInternalName(iconName
+ wxT(".png")));
1241 if ( it
!= cat
.end() ) {
1242 zip
.OpenEntry(*it
->second
);
1243 if ( !new_image
.LoadFile(zip
,wxBITMAP_TYPE_PNG
) ) {
1245 wxT("Warning: Error loading icon for ") +
1251 wxT("Warning: Can't load icon for ") +
1258 wxBitmap
bmp(useSkins
? new_image
: stdIcon
);
1259 if (iconName
.StartsWith(wxT("Client_"))) {
1260 m_imagelist
.Add(bmp
);
1261 } else if (iconName
.StartsWith(wxT("Toolbar_"))) {
1267 void CamuleDlg::Apply_Clients_Skin()
1269 bool useSkins
= thePrefs::UseSkins() && Check_and_Init_Skin();
1271 // Clear the client image list
1272 m_imagelist
.RemoveAll();
1274 // Add the images to the image list
1275 for (int i
= 0; i
< CLIENT_SKIN_SIZE
; ++i
) {
1276 Add_Skin_Icon(wxT("Client_") + m_clientSkinNames
[i
],
1277 clientImages(i
), useSkins
);
1282 void CamuleDlg::Apply_Toolbar_Skin(wxToolBar
*wndToolbar
)
1284 bool useSkins
= thePrefs::UseSkins() && Check_and_Init_Skin();
1286 // Clear the toolbar image list
1287 m_tblist
.RemoveAll();
1289 // Add the images to the image list
1290 Add_Skin_Icon(wxT("Toolbar_Connect"), connButImg(0), useSkins
);
1291 Add_Skin_Icon(wxT("Toolbar_Disconnect"), connButImg(1), useSkins
);
1292 Add_Skin_Icon(wxT("Toolbar_Connecting"), connButImg(2), useSkins
);
1293 Add_Skin_Icon(wxT("Toolbar_Network"), amuleDlgImages(20), useSkins
);
1294 Add_Skin_Icon(wxT("Toolbar_Transfers"), amuleDlgImages(21), useSkins
);
1295 Add_Skin_Icon(wxT("Toolbar_Search"), amuleDlgImages(22), useSkins
);
1296 Add_Skin_Icon(wxT("Toolbar_Shared"), amuleDlgImages(23), useSkins
);
1297 Add_Skin_Icon(wxT("Toolbar_Messages"), amuleDlgImages(24), useSkins
);
1298 Add_Skin_Icon(wxT("Toolbar_Stats"), amuleDlgImages(25), useSkins
);
1299 Add_Skin_Icon(wxT("Toolbar_Prefs"), amuleDlgImages(26), useSkins
);
1300 Add_Skin_Icon(wxT("Toolbar_Import"), amuleDlgImages(32), useSkins
);
1301 Add_Skin_Icon(wxT("Toolbar_About"), amuleDlgImages(29), useSkins
);
1302 Add_Skin_Icon(wxT("Toolbar_Blink"), amuleDlgImages(33), useSkins
);
1304 // Build aMule toolbar
1305 wndToolbar
->SetMargins(0, 0);
1307 // Placeholder. Gets updated by ShowConnectionState
1308 wndToolbar
->AddTool(ID_BUTTONCONNECT
, wxT("..."), m_tblist
.GetBitmap(0));
1310 wndToolbar
->AddSeparator();
1311 wndToolbar
->AddTool(ID_BUTTONNETWORKS
,
1312 _("Networks"), m_tblist
.GetBitmap(3),
1313 wxNullBitmap
, wxITEM_CHECK
,
1314 _("Networks Window"));
1315 wndToolbar
->AddTool(ID_BUTTONSEARCH
,
1316 _("Searches"), m_tblist
.GetBitmap(5),
1317 wxNullBitmap
, wxITEM_CHECK
,
1318 _("Searches Window"));
1319 wndToolbar
->AddTool(ID_BUTTONTRANSFER
,
1320 _("Transfers"), m_tblist
.GetBitmap(4),
1321 wxNullBitmap
, wxITEM_CHECK
,
1322 _("Files Transfers Window"));
1323 wndToolbar
->AddTool(ID_BUTTONSHARED
,
1324 _("Shared Files"), m_tblist
.GetBitmap(6),
1325 wxNullBitmap
, wxITEM_CHECK
,
1326 _("Shared Files Window"));
1327 wndToolbar
->AddTool(ID_BUTTONMESSAGES
,
1328 _("Messages"), m_tblist
.GetBitmap(7),
1329 wxNullBitmap
, wxITEM_CHECK
,
1330 _("Messages Window"));
1331 wndToolbar
->AddTool(ID_BUTTONSTATISTICS
,
1332 _("Statistics"), m_tblist
.GetBitmap(8),
1333 wxNullBitmap
, wxITEM_CHECK
,
1334 _("Statistics Graph Window"));
1335 wndToolbar
->AddSeparator();
1336 wndToolbar
->AddTool(ID_BUTTONNEWPREFERENCES
,
1337 _("Preferences"), m_tblist
.GetBitmap(9),
1338 wxNullBitmap
, wxITEM_NORMAL
,
1339 _("Preferences Settings Window"));
1340 wndToolbar
->AddTool(ID_BUTTONIMPORT
,
1341 _("Import"), m_tblist
.GetBitmap(10),
1342 wxNullBitmap
, wxITEM_NORMAL
,
1343 _("The partfile importer tool"));
1344 wndToolbar
->AddTool(ID_ABOUT
,
1345 _("About"), m_tblist
.GetBitmap(11),
1346 wxNullBitmap
, wxITEM_NORMAL
,
1349 wndToolbar
->ToggleTool(ID_BUTTONTRANSFER
, true);
1351 // Needed for non-GTK platforms, where the
1352 // items don't get added immediatly.
1353 wndToolbar
->Realize();
1355 // Updates the "Connect" button, and so on.
1356 ShowConnectionState();
1360 void CamuleDlg::Create_Toolbar(bool orientation
)
1363 // Create ToolBar from the one designed by wxDesigner (BigBob)
1364 wxToolBar
*current
= GetToolBar();
1366 wxASSERT(current
== m_wndToolbar
);
1369 bool oldorientation
= ((current
->GetWindowStyle() & wxTB_VERTICAL
) == wxTB_VERTICAL
);
1370 if (oldorientation
!= orientation
) {
1372 SetToolBar(NULL
); // Remove old one if present
1373 m_wndToolbar
= NULL
;
1375 current
->ClearTools();
1379 if (!m_wndToolbar
) {
1380 m_wndToolbar
= CreateToolBar(
1381 (orientation
? wxTB_VERTICAL
: wxTB_HORIZONTAL
) |
1382 wxNO_BORDER
| wxTB_TEXT
| wxTB_3DBUTTONS
|
1383 wxTB_FLAT
| wxCLIP_CHILDREN
| wxTB_NODIVIDER
);
1386 m_wndToolbar
->SetToolBitmapSize(wxSize(32, 32));
1389 Apply_Toolbar_Skin(m_wndToolbar
);
1391 m_wndToolbar
->DeleteTool(ID_BUTTONIMPORT
);
1398 void CamuleDlg::OnMainGUISizeChange(wxSizeEvent
& evt
)
1400 wxFrame::OnSize(evt
);
1401 if (m_transferwnd
&& m_transferwnd
->clientlistctrl
) {
1402 // Transfer window's splitter set again if it's hidden.
1403 if (m_transferwnd
->clientlistctrl
->GetListView() == vtNone
) {
1404 int height
= m_transferwnd
->clientlistctrl
->GetSize().GetHeight();
1405 wxSplitterWindow
* splitter
=
1406 CastChild(wxT("splitterWnd"), wxSplitterWindow
);
1407 height
+= splitter
->GetWindow1()->GetSize().GetHeight();
1408 splitter
->SetSashPosition( height
);
1415 void CamuleDlg::OnKeyPressed(wxKeyEvent
& event
)
1417 if (event
.GetKeyCode() == WXK_F1
) {
1418 // Ctrl/Alt/Shift must not be pressed, to avoid
1419 // conflicts with other (global) shortcuts.
1420 if (!event
.HasModifiers() && !event
.ShiftDown()) {
1421 LaunchUrl(wxT("http://wiki.amule.org"));
1430 void CamuleDlg::OnExit(wxCommandEvent
& WXUNUSED(evt
))
1435 void CamuleDlg::DoNetworkRearrange()
1438 wxWindowUpdateLocker
freezer(this);
1440 wxToolBarToolBase
* toolbarTool
= m_wndToolbar
->RemoveTool(ID_BUTTONNETWORKS
);
1442 wxNotebook
* logs_notebook
= CastChild( ID_SRVLOG_NOTEBOOK
, wxNotebook
);
1443 wxNotebook
* networks_notebook
= CastChild( ID_NETNOTEBOOK
, wxNotebook
);
1445 while (logs_notebook
->GetPageCount() > 1) {
1446 logs_notebook
->RemovePage(logs_notebook
->GetPageCount() - 1);
1449 while (networks_notebook
->GetPageCount() > 0) {
1450 networks_notebook
->RemovePage(networks_notebook
->GetPageCount() - 1);
1453 if (thePrefs::GetNetworkED2K()) {
1454 logs_notebook
->AddPage(m_logpages
[1].page
, m_logpages
[1].name
);
1455 logs_notebook
->AddPage(m_logpages
[2].page
, m_logpages
[2].name
);
1458 m_networkpages
[0].page
->Show(thePrefs::GetNetworkED2K());
1460 if (thePrefs::GetNetworkKademlia()) {
1461 logs_notebook
->AddPage(m_logpages
[3].page
, m_logpages
[3].name
);
1464 m_networkpages
[1].page
->Show(thePrefs::GetNetworkKademlia());
1466 networks_notebook
->Show(thePrefs::GetNetworkED2K() && thePrefs::GetNetworkKademlia());
1468 wxWindow
* replacement
= NULL
;
1470 m_networknotebooksizer
->Clear();
1472 if (thePrefs::GetNetworkED2K() && thePrefs::GetNetworkKademlia()) {
1473 toolbarTool
->SetLabel(_("Networks"));
1475 m_networkpages
[0].page
->Reparent(networks_notebook
);
1476 m_networkpages
[1].page
->Reparent(networks_notebook
);
1478 networks_notebook
->AddPage(m_networkpages
[0].page
, m_networkpages
[0].name
);
1479 networks_notebook
->AddPage(m_networkpages
[1].page
, m_networkpages
[1].name
);
1481 replacement
= networks_notebook
;
1483 } else if (thePrefs::GetNetworkED2K()) {
1484 toolbarTool
->SetLabel(_("ed2k network"));
1485 replacement
= m_networkpages
[0].page
;
1486 m_networkpages
[1].page
->Reparent(m_networknotebooksizer
->GetContainingWindow());
1487 } else if (thePrefs::GetNetworkKademlia()) {
1488 toolbarTool
->SetLabel(_("Kad network"));
1489 m_networkpages
[0].page
->Reparent(m_networknotebooksizer
->GetContainingWindow());
1490 replacement
= m_networkpages
[1].page
;
1493 toolbarTool
->SetLabel(_("No network"));
1497 replacement
->Reparent(m_networknotebooksizer
->GetContainingWindow());
1498 m_networknotebooksizer
->Add( replacement
, 1, wxGROW
|wxALIGN_CENTER_VERTICAL
|wxTOP
, 5 );
1499 m_networknotebooksizer
->Layout();
1502 m_wndToolbar
->InsertTool(2, toolbarTool
);
1504 m_wndToolbar
->EnableTool(ID_BUTTONNETWORKS
, (thePrefs::GetNetworkED2K() || thePrefs::GetNetworkKademlia()));
1505 m_wndToolbar
->EnableTool(ID_BUTTONCONNECT
, (thePrefs::GetNetworkED2K() || thePrefs::GetNetworkKademlia()));
1507 m_wndToolbar
->Realize();
1509 m_searchwnd
->FixSearchTypes();
1512 // File_checked_for_headers