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/sysopt.h>
40 #include <wx/wupdlock.h> // Needed for wxWindowUpdateLocker
42 #include <common/EventIDs.h>
45 #include "config.h" // Needed for SVNDATE, PACKAGE, VERSION
47 #include <common/ClientVersion.h>
48 #endif // HAVE_CONFIG_H
50 #include "amuleDlg.h" // Interface declarations.
52 #include <common/Format.h> // Needed for CFormat
53 #include "amule.h" // Needed for theApp
54 #include "ChatWnd.h" // Needed for CChatWnd
55 #include "ClientListCtrl.h" // Needed for CClientListCtrl
56 #include "DownloadListCtrl.h" // Needed for CDownloadListCtrl
57 #include "DownloadQueue.h" // Needed for CDownloadQueue
58 #include "KadDlg.h" // Needed for CKadDlg
60 #include "MuleTrayIcon.h"
61 #include "muuli_wdr.h" // Needed for ID_BUTTON*
62 #include "Preferences.h" // Needed for CPreferences
63 #include "PrefsUnifiedDlg.h"
64 #include "SearchDlg.h" // Needed for CSearchDlg
65 #include "Server.h" // Needed for CServer
66 #include "ServerConnect.h" // Needed for CServerConnect
67 #include "ServerWnd.h" // Needed for CServerWnd
68 #include "SharedFilesWnd.h" // Needed for CSharedFilesWnd
69 #include "Statistics.h" // Needed for theStats
70 #include "StatisticsDlg.h" // Needed for CStatisticsDlg
71 #include "TerminationProcess.h" // Needed for CTerminationProcess
72 #include "TransferWnd.h" // Needed for CTransferWnd
74 #include "PartFileConvert.h"
81 #include "kademlia/kademlia/Kademlia.h"
83 #ifdef ENABLE_IP2COUNTRY
84 #include "IP2Country.h" // Needed for IP2Country
87 BEGIN_EVENT_TABLE(CamuleDlg
, wxFrame
)
89 EVT_TOOL(ID_BUTTONNETWORKS
, CamuleDlg::OnToolBarButton
)
90 EVT_TOOL(ID_BUTTONSEARCH
, CamuleDlg::OnToolBarButton
)
91 EVT_TOOL(ID_BUTTONTRANSFER
, CamuleDlg::OnToolBarButton
)
92 EVT_TOOL(ID_BUTTONSHARED
, CamuleDlg::OnToolBarButton
)
93 EVT_TOOL(ID_BUTTONMESSAGES
, CamuleDlg::OnToolBarButton
)
94 EVT_TOOL(ID_BUTTONSTATISTICS
, CamuleDlg::OnToolBarButton
)
95 EVT_TOOL(ID_ABOUT
, CamuleDlg::OnAboutButton
)
97 EVT_TOOL(ID_BUTTONNEWPREFERENCES
, CamuleDlg::OnPrefButton
)
99 EVT_TOOL(ID_BUTTONIMPORT
, CamuleDlg::OnImportButton
)
102 EVT_TOOL(ID_BUTTONCONNECT
, CamuleDlg::OnBnConnect
)
104 EVT_CLOSE(CamuleDlg::OnClose
)
105 EVT_ICONIZE(CamuleDlg::OnMinimize
)
107 EVT_BUTTON(ID_BUTTON_FAST
, CamuleDlg::OnBnClickedFast
)
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();
193 wxSystemOptions::SetOption(wxT("msw.remap"), 0);
196 SetIcon(wxICON(aMule
));
200 // Create new sizer and stuff a wxPanel in there.
201 wxFlexGridSizer
*s_main
= new wxFlexGridSizer(1);
202 s_main
->AddGrowableCol(0);
203 s_main
->AddGrowableRow(0);
205 wxPanel
* p_cnt
= new wxPanel(this, -1, wxDefaultPosition
, wxDefaultSize
);
206 s_main
->Add(p_cnt
, 0, wxGROW
|wxEXPAND
, 0);
207 muleDlg(p_cnt
, false, true);
208 SetSizer(s_main
, true);
210 m_serverwnd
= new CServerWnd(p_cnt
, m_srv_split_pos
);
211 AddLogLineM(false, wxEmptyString
);
212 AddLogLineM(false, wxT(" - ") +
213 CFormat(_("This is aMule %s based on eMule.")) % GetMuleVersion());
214 AddLogLineM(false, wxT(" ") +
215 CFormat(_("Running on %s")) % wxGetOsDescription());
216 AddLogLineM(false, wxT(" - ") +
217 wxString(_("Visit http://www.amule.org to check if a new version is available.")));
218 AddLogLineM(false, wxEmptyString
);
220 #ifdef ENABLE_IP2COUNTRY
221 m_IP2Country
= new CIP2Country();
223 m_searchwnd
= new CSearchDlg(p_cnt
);
224 m_transferwnd
= new CTransferWnd(p_cnt
);
225 m_sharedfileswnd
= new CSharedFilesWnd(p_cnt
);
226 m_statisticswnd
= new CStatisticsDlg(p_cnt
, theApp
->m_statistics
);
227 m_chatwnd
= new CChatWnd(p_cnt
);
228 m_kademliawnd
= CastChild(wxT("kadWnd"), CKadDlg
);
230 m_serverwnd
->Show(false);
231 m_searchwnd
->Show(false);
232 m_transferwnd
->Show(false);
233 m_sharedfileswnd
->Show(false);
234 m_statisticswnd
->Show(false);
235 m_chatwnd
->Show(false);
237 // Create the GUI timer
238 gui_timer
=new wxTimer(this,ID_GUI_TIMER_EVENT
);
240 AddLogLine(false, _("FATAL ERROR: Failed to create Timer"));
244 // Set transfers as active window
245 Create_Toolbar(thePrefs::VerticalToolbar());
246 SetActiveDialog(DT_TRANSFER_WND
, m_transferwnd
);
247 m_wndToolbar
->ToggleTool(ID_BUTTONTRANSFER
, true );
249 bool override_where
= (where
!= wxDefaultPosition
);
250 bool override_size
= (
251 (dlg_size
.x
!= DEFAULT_SIZE_X
) ||
252 (dlg_size
.y
!= DEFAULT_SIZE_Y
) );
253 if (!LoadGUIPrefs(override_where
, override_size
)) {
254 // Prefs not loaded for some reason, exit
255 AddLogLineM( true, wxT("Error! Unable to load Preferences") );
259 m_is_safe_state
= true;
261 // Init statistics stuff, better do it asap
262 m_statisticswnd
->Init();
263 m_kademliawnd
->Init();
264 m_searchwnd
->UpdateCatChoice();
265 if (thePrefs::UseTrayIcon()) {
270 // Must we start minimized?
271 if (thePrefs::GetStartMinimized()) {
276 wxAcceleratorEntry entries
[] = {
277 wxAcceleratorEntry(wxACCEL_CTRL
, wxT('Q'), wxID_EXIT
)
280 SetAcceleratorTable(wxAcceleratorTable(itemsof(entries
), entries
));
281 ShowED2KLinksHandler( thePrefs::GetFED2KLH() );
283 wxNotebook
* logs_notebook
= CastChild( ID_SRVLOG_NOTEBOOK
, wxNotebook
);
284 wxNotebook
* networks_notebook
= CastChild( ID_NETNOTEBOOK
, wxNotebook
);
286 wxASSERT(logs_notebook
->GetPageCount() == 4);
287 wxASSERT(networks_notebook
->GetPageCount() == 2);
289 for (uint32 i
= 0; i
< logs_notebook
->GetPageCount(); ++i
) {
290 m_logpages
[i
].page
= logs_notebook
->GetPage(i
);
291 m_logpages
[i
].name
= logs_notebook
->GetPageText(i
);
294 for (uint32 i
= 0; i
< networks_notebook
->GetPageCount(); ++i
) {
295 m_networkpages
[i
].page
= networks_notebook
->GetPage(i
);
296 m_networkpages
[i
].name
= networks_notebook
->GetPageText(i
);
299 DoNetworkRearrange();
303 // Madcat - Sets Fast ED2K Links Handler on/off.
304 void CamuleDlg::ShowED2KLinksHandler( bool show
)
306 // Errorchecking in case the pointer becomes invalid ...
307 if (s_fed2klh
== NULL
) {
308 wxLogWarning(wxT("Unable to find Fast ED2K Links handler sizer! Hiding FED2KLH aborted."));
312 s_dlgcnt
->Show( s_fed2klh
, show
);
316 // Toogles ed2k link handler.
317 void CamuleDlg::ToogleED2KLinksHandler()
319 // Errorchecking in case the pointer becomes invalid ...
320 if (s_fed2klh
== NULL
) {
321 wxLogWarning(wxT("Unable to find Fast ED2K Links handler sizer! Toogling FED2KLH aborted."));
324 ShowED2KLinksHandler(!s_dlgcnt
->IsShown(s_fed2klh
));
327 void CamuleDlg::SetActiveDialog(DialogType type
, wxWindow
* dlg
)
329 m_nActiveDialog
= type
;
331 if ( type
== DT_TRANSFER_WND
) {
332 if (thePrefs::ShowCatTabInfos()) {
333 m_transferwnd
->UpdateCatTabTitles();
338 m_activewnd
->Show(false);
339 contentSizer
->Detach(m_activewnd
);
342 contentSizer
->Add(dlg
, 1, wxALIGN_LEFT
|wxEXPAND
);
347 // Since we might be suspending redrawing while hiding the dialog
348 // we have to refresh it once it is visible again
349 dlg
->Refresh( true );
354 void CamuleDlg::UpdateTrayIcon(int percent
)
357 if(!theApp
->IsConnected()) {
358 m_wndTaskbarNotifier
->SetTrayIcon(TRAY_ICON_DISCONNECTED
, percent
);
360 if(theApp
->IsConnectedED2K() && theApp
->serverconnect
->IsLowID()) {
361 m_wndTaskbarNotifier
->SetTrayIcon(TRAY_ICON_LOWID
, percent
);
363 m_wndTaskbarNotifier
->SetTrayIcon(TRAY_ICON_HIGHID
, percent
);
369 void CamuleDlg::CreateSystray()
371 wxCHECK_RET(m_wndTaskbarNotifier
== NULL
,
372 wxT("Systray already created"));
374 m_wndTaskbarNotifier
= new CMuleTrayIcon();
375 // This will effectively show the Tray Icon.
380 void CamuleDlg::RemoveSystray()
382 delete m_wndTaskbarNotifier
;
383 m_wndTaskbarNotifier
= NULL
;
387 void CamuleDlg::OnToolBarButton(wxCommandEvent
& ev
)
389 static int lastbutton
= ID_BUTTONTRANSFER
;
391 // Kry - just if the GUI is ready for it
392 if ( m_is_safe_state
) {
394 // Rehide the handler if needed
395 if ( lastbutton
== ID_BUTTONSEARCH
&& !thePrefs::GetFED2KLH() ) {
396 if (ev
.GetId() != ID_BUTTONSEARCH
) {
397 ShowED2KLinksHandler( false );
399 // Toogle ED2K handler.
400 ToogleED2KLinksHandler();
404 if ( lastbutton
!= ev
.GetId() ) {
405 switch ( ev
.GetId() ) {
406 case ID_BUTTONNETWORKS
:
407 SetActiveDialog(DT_NETWORKS_WND
, m_serverwnd
);
408 // Set serverlist splitter position
409 CastChild( wxT("SrvSplitterWnd"), wxSplitterWindow
)->SetSashPosition(m_srv_split_pos
, true);
412 case ID_BUTTONSEARCH
:
413 // The search dialog should always display the handler
414 if ( !thePrefs::GetFED2KLH() )
415 ShowED2KLinksHandler( true );
417 SetActiveDialog(DT_SEARCH_WND
, m_searchwnd
);
420 case ID_BUTTONTRANSFER
:
421 SetActiveDialog(DT_TRANSFER_WND
, m_transferwnd
);
422 // Prepare the dialog, sets the splitter-position
423 m_transferwnd
->Prepare();
426 case ID_BUTTONSHARED
:
427 SetActiveDialog(DT_SHARED_WND
, m_sharedfileswnd
);
430 case ID_BUTTONMESSAGES
:
431 m_BlinkMessages
= false;
432 SetActiveDialog(DT_CHAT_WND
, m_chatwnd
);
435 case ID_BUTTONSTATISTICS
:
436 SetActiveDialog(DT_STATS_WND
, m_statisticswnd
);
439 // This shouldn't happen, but just in case
441 AddLogLineM( true, wxT("Unknown button triggered CamuleApp::OnToolBarButton().") );
446 m_wndToolbar
->ToggleTool(lastbutton
, lastbutton
== ev
.GetId() );
447 lastbutton
= ev
.GetId();
452 void CamuleDlg::OnAboutButton(wxCommandEvent
& WXUNUSED(ev
))
454 wxString msg
= wxT(" ");
456 msg
<< _("aMule remote control ") << wxT(VERSION
);
458 msg
<< wxT("aMule ") << wxT(VERSION
);
462 msg
<< _("Snapshot:") << wxT("\n ") << wxT(SVNDATE
);
464 msg
<< wxT("\n\n") << _("'All-Platform' p2p client based on eMule \n\n") <<
465 _("Website: http://www.amule.org \n") <<
466 _("Forum: http://forum.amule.org \n") <<
467 _("FAQ: http://wiki.amule.org \n\n") <<
468 _("Contact: admin@amule.org (administrative issues) \n") <<
469 _("Copyright (c) 2003-2008 aMule Team \n\n") <<
470 _("Part of aMule is based on \n") <<
471 _("Kademlia: Peer-to-peer routing based on the XOR metric.\n") <<
472 _(" Copyright (C) 2002 Petar Maymounkov <petar@post.harvard.edu>\n") <<
473 _("http://kademlia.scs.cs.nyu.edu\n");
475 if (m_is_safe_state
) {
476 wxMessageBox(msg
, _("Message"), wxOK
| wxICON_INFORMATION
, this);
481 void CamuleDlg::OnPrefButton(wxCommandEvent
& WXUNUSED(ev
))
483 if (m_is_safe_state
) {
484 if (m_prefsDialog
== NULL
) {
485 m_prefsDialog
= new PrefsUnifiedDlg(this);
488 m_prefsDialog
->TransferToWindow();
489 m_prefsDialog
->Show(true);
490 m_prefsDialog
->Raise();
496 void CamuleDlg::OnImportButton(wxCommandEvent
& WXUNUSED(ev
))
498 if ( m_is_safe_state
) {
499 CPartFileConvert::ShowGUI(NULL
);
504 CamuleDlg::~CamuleDlg()
506 printf("Shutting down aMule...\n");
510 theApp
->amuledlg
= NULL
;
512 #ifdef ENABLE_IP2COUNTRY
516 printf("aMule dialog destroyed\n");
520 void CamuleDlg::OnBnConnect(wxCommandEvent
& WXUNUSED(evt
))
523 bool disconnect
= (theApp
->IsConnectedED2K() || theApp
->serverconnect
->IsConnecting())
525 || (Kademlia::CKademlia::IsRunning())
528 if (thePrefs::GetNetworkED2K()) {
530 //disconnect if currently connected
531 if (theApp
->serverconnect
->IsConnecting()) {
532 theApp
->serverconnect
->StopConnectionTry();
534 theApp
->serverconnect
->Disconnect();
537 //connect if not currently connected
538 AddLogLine(true, _("Connecting"));
539 theApp
->serverconnect
->ConnectToAnyServer();
542 wxASSERT(!theApp
->IsConnectedED2K());
546 if (thePrefs::GetNetworkKademlia()) {
554 wxASSERT(!Kademlia::CKademlia::IsRunning());
558 ShowConnectionState();
562 void CamuleDlg::ResetLog(int id
)
564 wxTextCtrl
* ct
= CastByID(id
, m_serverwnd
, wxTextCtrl
);
565 wxCHECK_RET(ct
, wxT("Resetting unknown log"));
569 if (id
== ID_LOGVIEW
) {
570 // Also clear the log line
571 wxStaticText
* text
= CastChild(wxT("infoLabel"), wxStaticText
);
572 text
->SetLabel(wxEmptyString
);
573 text
->GetParent()->Layout();
578 void CamuleDlg::AddLogLine(bool addtostatusbar
, const wxString
& line
)
580 // Remove newspace at end, it causes problems with the layout...
581 wxString bufferline
= line
.Strip(wxString::trailing
);
583 // Create the timestamp
584 wxString stamp
= wxDateTime::Now().FormatISODate() + wxT(" ") + wxDateTime::Now().FormatISOTime() + wxT(": ");
586 // Add the message to the log-view
587 wxTextCtrl
* ct
= CastByID( ID_LOGVIEW
, m_serverwnd
, wxTextCtrl
);
589 if ( bufferline
.IsEmpty() ) {
590 // If it's empty we just write a blank line with no timestamp.
591 ct
->AppendText( wxT("\n") );
593 // Bold critical log-lines
594 wxTextAttr style
= ct
->GetDefaultStyle();
595 wxFont font
= style
.GetFont();
596 font
.SetWeight(addtostatusbar
? wxFONTWEIGHT_BOLD
: wxFONTWEIGHT_NORMAL
);
598 ct
->SetDefaultStyle(style
);
600 // Split multi-line messages into individual lines
601 wxStringTokenizer
tokens( bufferline
, wxT("\n") );
602 while ( tokens
.HasMoreTokens() ) {
603 ct
->AppendText( stamp
+ tokens
.GetNextToken() + wxT("\n") );
607 ct
->ShowPosition( ct
->GetLastPosition() - 1 );
611 // Set the status-bar if the event warrents it
612 if ( addtostatusbar
) {
613 // Escape "&"s, which would otherwise not show up
614 bufferline
.Replace( wxT("&"), wxT("&&") );
615 wxStaticText
* text
= CastChild( wxT("infoLabel"), wxStaticText
);
616 // Only show the first line if multiple lines
617 text
->SetLabel( bufferline
.BeforeFirst( wxT('\n') ) );
618 text
->SetToolTip( bufferline
);
619 text
->GetParent()->Layout();
625 void CamuleDlg::AddServerMessageLine(wxString
& message
)
627 wxTextCtrl
* cv
= CastByID( ID_SERVERINFO
, m_serverwnd
, wxTextCtrl
);
629 if (message
.Length() > 500) {
630 cv
->AppendText(message
.Left(500) + wxT("\n"));
632 cv
->AppendText(message
+ wxT("\n"));
634 cv
->ShowPosition(cv
->GetLastPosition()-1);
639 void CamuleDlg::ShowConnectionState(bool skinChanged
)
641 static wxImageList
status_arrows(16,16,true,0);
642 if (!status_arrows
.GetImageCount()) {
643 // Generate the image list (This is only done once)
644 for (int t
= 0; t
< 7; ++t
) {
645 status_arrows
.Add(connImages(t
));
649 m_serverwnd
->UpdateED2KInfo();
650 m_serverwnd
->UpdateKadInfo();
653 ////////////////////////////////////////////////////////////
654 // Determine the status of the networks
656 enum ED2KState
{ ED2KOff
= 0, ED2KLowID
= 1, ED2KConnecting
= 2, ED2KHighID
= 3 };
657 enum EKadState
{ EKadOff
= 4, EKadFW
= 5, EKadConnecting
= 5, EKadOK
= 6 };
659 ED2KState ed2kState
= ED2KOff
;
660 EKadState kadState
= EKadOff
;
662 ////////////////////////////////////////////////////////////
663 // Update the label on the status-bar and determine
664 // the states of the two networks.
667 if (theApp
->IsConnectedED2K()) {
668 CServer
* server
= theApp
->serverconnect
->GetCurrentServer();
670 msgED2K
= CFormat(wxT("eD2k: %s")) % server
->GetListName();
673 if (theApp
->serverconnect
->IsLowID()) {
674 ed2kState
= ED2KLowID
;
676 ed2kState
= ED2KHighID
;
678 } else if (theApp
->serverconnect
->IsConnecting()) {
679 msgED2K
= _("eD2k: Connecting");
681 ed2kState
= ED2KConnecting
;
682 } else if (thePrefs::GetNetworkED2K()) {
683 msgED2K
= _("eD2k: Disconnected");
687 if (theApp
->IsConnectedKad()) {
688 if (theApp
->IsFirewalledKad()) {
689 msgKad
= _("Kad: Firewalled");
693 msgKad
= _("Kad: Connected");
697 } else if (theApp
->IsKadRunning()) {
698 msgKad
= _("Kad: Connecting");
700 kadState
= EKadConnecting
;
701 } else if (thePrefs::GetNetworkKademlia()) {
702 msgKad
= _("Kad: Off");
705 wxStaticText
* connLabel
= CastChild( wxT("connLabel"), wxStaticText
);
706 wxCHECK_RET(connLabel
, wxT("'connLabel' widget not found"));
709 if (msgED2K
.Length() && msgKad
.Length()) {
710 labelMsg
= msgED2K
+ wxT(" | ") + msgKad
;
712 labelMsg
= msgED2K
+ msgKad
;
715 connLabel
->SetLabel(labelMsg
);
716 connLabel
->GetParent()->Layout();
719 ////////////////////////////////////////////////////////////
720 // Update the connect/disconnect/cancel button.
729 static EConnState s_oldState
= ECS_Unknown
;
730 EConnState currentState
= ECS_Disconnected
;
732 if (theApp
->serverconnect
->IsConnecting() ||
733 (theApp
->IsKadRunning() && !theApp
->IsConnectedKad())) {
734 currentState
= ECS_Connecting
;
735 } else if (theApp
->IsConnected()) {
736 currentState
= ECS_Connected
;
738 currentState
= ECS_Disconnected
;
741 if ( (true == skinChanged
) || (currentState
!= s_oldState
) ) {
742 wxWindowUpdateLocker
freezer(m_wndToolbar
);
744 wxToolBarToolBase
* toolbarTool
= m_wndToolbar
->RemoveTool(ID_BUTTONCONNECT
);
746 switch (currentState
) {
748 toolbarTool
->SetLabel(_("Cancel"));
749 toolbarTool
->SetShortHelp(_("Stop the current connection attempts"));
750 toolbarTool
->SetNormalBitmap(m_tblist
.GetBitmap(2));
754 toolbarTool
->SetLabel(_("Disconnect"));
755 toolbarTool
->SetShortHelp(_("Disconnect from the currently connected networks"));
756 toolbarTool
->SetNormalBitmap(m_tblist
.GetBitmap(1));
760 toolbarTool
->SetLabel(_("Connect"));
761 toolbarTool
->SetShortHelp(_("Connect to the currently enabled networks"));
762 toolbarTool
->SetNormalBitmap(m_tblist
.GetBitmap(0));
765 m_wndToolbar
->InsertTool(0, toolbarTool
);
766 m_wndToolbar
->Realize();
768 s_oldState
= currentState
;
772 ////////////////////////////////////////////////////////////
773 // Update the globe-icon in the lower-right corner.
775 wxStaticBitmap
* connBitmap
= CastChild( wxT("connImage"), wxStaticBitmap
);
776 wxCHECK_RET(connBitmap
, wxT("'connImage' widget not found"));
778 wxBitmap statusIcon
= connBitmap
->GetBitmap();
779 wxMemoryDC
bitmapDC(statusIcon
);
781 status_arrows
.Draw(kadState
, bitmapDC
, 0, 0, wxIMAGELIST_DRAW_TRANSPARENT
);
782 status_arrows
.Draw(ed2kState
, bitmapDC
, 0, 0, wxIMAGELIST_DRAW_TRANSPARENT
);
784 connBitmap
->SetBitmap(statusIcon
);
788 void CamuleDlg::ShowUserCount(const wxString
& info
)
790 wxStaticText
* label
= CastChild( wxT("userLabel"), wxStaticText
);
793 m_serverwnd
->UpdateKadInfo();
795 label
->SetLabel(info
);
796 label
->GetParent()->Layout();
800 void CamuleDlg::ShowTransferRate()
802 float kBpsUp
= theStats::GetUploadRate() / 1024.0;
803 float kBpsDown
= theStats::GetDownloadRate() / 1024.0;
805 if( thePrefs::ShowOverhead() )
807 buffer
= wxString::Format(_("Up: %.1f(%.1f) | Down: %.1f(%.1f)"), kBpsUp
, theStats::GetUpOverheadRate() / 1024.0, kBpsDown
, theStats::GetDownOverheadRate() / 1024.0);
809 buffer
= wxString::Format(_("Up: %.1f | Down: %.1f"), kBpsUp
, kBpsDown
);
811 buffer
.Truncate(50); // Max size 50
813 wxStaticText
* label
= CastChild( wxT("speedLabel"), wxStaticText
);
814 label
->SetLabel(buffer
);
815 label
->GetParent()->Layout();
817 // Show upload/download speed in title
818 if (thePrefs::GetShowRatesOnTitle()) {
819 wxString UpDownSpeed
= wxString::Format(wxT("Up: %.1f | Down: %.1f"), kBpsUp
, kBpsDown
);
820 if (thePrefs::GetShowRatesOnTitle() == 1) {
821 SetTitle(theApp
->m_FrameTitle
+ wxT(" -- ") + UpDownSpeed
);
823 SetTitle(UpDownSpeed
+ wxT(" -- ") + theApp
->m_FrameTitle
);
827 wxASSERT((m_wndTaskbarNotifier
!= NULL
) == thePrefs::UseTrayIcon());
828 if (m_wndTaskbarNotifier
) {
830 int percentDown
= (int)ceil((kBpsDown
*100) / thePrefs::GetMaxGraphDownloadRate());
831 UpdateTrayIcon( ( percentDown
> 100 ) ? 100 : percentDown
);
834 if ( theApp
->IsConnected() ) {
835 buffer2
= CFormat(_("aMule (%s | Connected)")) % buffer
;
837 buffer2
= CFormat(_("aMule (%s | Disconnected)")) % buffer
;
839 m_wndTaskbarNotifier
->SetTrayToolTip(buffer2
);
842 wxStaticBitmap
* bmp
= CastChild( wxT("transferImg"), wxStaticBitmap
);
843 bmp
->SetBitmap(dlStatusImages((kBpsUp
>0.01 ? 2 : 0) + (kBpsDown
>0.01 ? 1 : 0)));
846 void CamuleDlg::DlgShutDown()
848 // Are we already shutting down or still on init?
849 if ( m_is_safe_state
== false ) {
854 m_is_safe_state
= false;
856 // Stop the GUI Timer
858 m_transferwnd
->downloadlistctrl
->DeleteAllItems();
860 // We want to delete the systray too!
864 void CamuleDlg::OnClose(wxCloseEvent
& evt
)
866 // This will be here till the core close is != app close
867 if (evt
.CanVeto() && thePrefs::IsConfirmExitEnabled() ) {
868 if (wxNO
== wxMessageBox(wxString(_("Do you really want to exit aMule?")),
869 wxString(_("Exit confirmation")), wxYES_NO
, this)) {
878 theApp
->ShutDown(evt
);
882 void CamuleDlg::OnBnClickedFast(wxCommandEvent
& WXUNUSED(evt
))
884 wxTextCtrl
* ctl
= CastChild( wxT("FastEd2kLinks"), wxTextCtrl
);
886 for ( int i
= 0; i
< ctl
->GetNumberOfLines(); i
++ ) {
887 wxString strlink
= ctl
->GetLineText(i
);
890 if ( !strlink
.IsEmpty() ) {
891 theApp
->downloadqueue
->AddLink( strlink
, m_transferwnd
->downloadlistctrl
->GetCategory() );
895 ctl
->SetValue(wxEmptyString
);
899 // Formerly known as LoadRazorPrefs()
900 bool CamuleDlg::LoadGUIPrefs(bool override_pos
, bool override_size
)
902 // Create a config base for loading razor preferences
903 wxConfigBase
*config
= wxConfigBase::Get();
904 // If config haven't been created exit without loading
905 if (config
== NULL
) {
909 // The section where to save in in file
910 wxString section
= wxT("/Razor_Preferences/");
912 // Get window size and position
913 int x1
= config
->Read(section
+ wxT("MAIN_X_POS"), -1);
914 int y1
= config
->Read(section
+ wxT("MAIN_Y_POS"), -1);
915 int x2
= config
->Read(section
+ wxT("MAIN_X_SIZE"), -1);
916 int y2
= config
->Read(section
+ wxT("MAIN_Y_SIZE"), -1);
918 int maximized
= config
->Read(section
+ wxT("Maximized"), 01);
920 // Kry - Random usable pos for m_srv_split_pos
921 m_srv_split_pos
= config
->Read(section
+ wxT("SRV_SPLITTER_POS"), 463l);
922 if (!override_size
) {
923 if (x2
> 0 && y2
> 0) {
927 // Probably first run.
934 // If x1 and y1 != -1 Redefine location
935 if(x1
!= -1 && y1
!= -1) {
936 wxRect display
= wxGetClientDisplayRect();
937 if (x1
<= display
.GetRightTop().x
&& y1
<= display
.GetRightBottom().y
) {
940 // It's offscreen... so let's not.
945 if (!override_size
&& !override_pos
&& maximized
) {
953 bool CamuleDlg::SaveGUIPrefs()
955 /* Razor 1a - Modif by MikaelB
956 Save client size and position */
958 // Create a config base for saving razor preferences
959 wxConfigBase
*config
= wxConfigBase::Get();
960 // If config haven't been created exit without saving
961 if (config
== NULL
) {
964 // The section where to save in in file
965 wxString section
= wxT("/Razor_Preferences/");
967 // Main window location and size
969 GetPosition(&x1
, &y1
);
972 // Saving window size and position
973 config
->Write(section
+wxT("MAIN_X_POS"), (long) x1
);
974 config
->Write(section
+wxT("MAIN_Y_POS"), (long) y1
);
976 config
->Write(section
+wxT("MAIN_X_SIZE"), (long) x2
);
977 config
->Write(section
+wxT("MAIN_Y_SIZE"), (long) y2
);
979 config
->Write(section
+wxT("Maximized"), (long) (IsMaximized() ? 1 : 0));
981 // Saving sash position of splitter in server window
982 config
->Write(section
+wxT("SRV_SPLITTER_POS"), (long) m_srv_split_pos
);
992 void CamuleDlg::DoIconize(bool iconize
)
994 if (m_wndTaskbarNotifier
&& thePrefs::DoMinToTray()) {
996 // Skip() will do it.
1006 // Will be done by Skip();
1011 void CamuleDlg::OnMinimize(wxIconizeEvent
& evt
)
1013 // Evil Hack: check if the mouse is inside the window
1015 if (GetScreenRect().Contains(wxGetMousePosition()))
1018 if (m_prefsDialog
&& m_prefsDialog
->IsShown()) {
1021 if (m_wndTaskbarNotifier
) {
1022 DoIconize(evt
.Iconized());
1029 void CamuleDlg::OnGUITimer(wxTimerEvent
& WXUNUSED(evt
))
1031 // Former TimerProc section
1033 static uint32 msPrev1
, msPrev5
, msPrevStats
;
1035 uint32 msCur
= theStats::GetUptimeMillis();
1037 // can this actually happen under wxwin ?
1043 static uint32 msPrevGraph
;
1044 int msGraphUpdate
= thePrefs::GetTrafficOMeterInterval() * 1000;
1045 if ((msGraphUpdate
> 0) && ((msCur
/ msGraphUpdate
) > (msPrevGraph
/ msGraphUpdate
))) {
1046 // trying to get the graph shifts evenly spaced after a change in the update period
1047 msPrevGraph
= msCur
;
1049 GraphUpdateInfo update
= theApp
->m_statistics
->GetPointsForUpdate();
1051 m_statisticswnd
->UpdateStatGraphs(theStats::GetPeakConnections(), update
);
1052 m_kademliawnd
->UpdateGraph(update
);
1055 //#warning TODO: CORE/GUI -- EC needed
1058 int sStatsUpdate
= thePrefs::GetStatsInterval();
1059 if ((sStatsUpdate
> 0) && ((int)(msCur
- msPrevStats
) > sStatsUpdate
*1000)) {
1060 if (m_statisticswnd
->IsShownOnScreen()) {
1061 msPrevStats
= msCur
;
1062 m_statisticswnd
->ShowStatistics();
1066 if (msCur
-msPrev5
> 5000) { // every 5 seconds
1069 if (thePrefs::ShowCatTabInfos() && theApp
->amuledlg
->m_activewnd
== theApp
->amuledlg
->m_transferwnd
) {
1070 m_transferwnd
->UpdateCatTabTitles();
1072 if (thePrefs::AutoSortDownload()) {
1073 m_transferwnd
->downloadlistctrl
->SortList();
1077 if (msCur
-msPrev1
> 1000) { // every second
1079 if (m_CurrentBlinkBitmap
== 12) {
1080 m_CurrentBlinkBitmap
= 7;
1083 if (m_BlinkMessages
) {
1084 m_CurrentBlinkBitmap
= 12;
1093 void CamuleDlg::SetMessagesTool()
1095 int pos
= m_wndToolbar
->GetToolPos(ID_BUTTONMESSAGES
);
1096 wxASSERT(pos
== 6); // so we don't miss a change on wx2.4
1098 wxWindowUpdateLocker
freezer(m_wndToolbar
);
1100 m_wndToolbar
->FindById(ID_BUTTONMESSAGES
)->SetNormalBitmap(m_tblist
.GetBitmap(m_CurrentBlinkBitmap
));
1102 m_wndToolbar
->SetToolNormalBitmap(ID_BUTTONMESSAGES
, m_tblist
.GetBitmap(m_CurrentBlinkBitmap
));
1106 void CamuleDlg::LaunchUrl( const wxString
& url
)
1110 cmd
= thePrefs::GetBrowser();
1112 // Pipes cause problems, so escape them
1113 tmp
.Replace( wxT("|"), wxT("%7C") );
1115 if ( !cmd
.IsEmpty() ) {
1116 if (!cmd
.Replace(wxT("%s"), tmp
)) {
1117 // No %s found, just append the url
1118 cmd
+= wxT(" ") + tmp
;
1121 CTerminationProcess
*p
= new CTerminationProcess(cmd
);
1122 if (wxExecute(cmd
, wxEXEC_ASYNC
, p
)) {
1123 printf( "Launch Command: %s\n", (const char *)unicode2char(cmd
));
1129 wxLaunchDefaultBrowser(tmp
);
1132 // Unable to execute browser. But this error message doesn't make sense,
1133 // cosidering that you _can't_ set the browser executable path... =/
1134 wxLogError(wxT("Unable to launch browser. Please set correct browser executable path in Preferences."));
1138 wxString
CamuleDlg::GenWebSearchUrl(const wxString
&filename
, WebSearch wsProvider
)
1141 switch (wsProvider
) {
1143 URL
= wxT("http://www.filehash.com/search.html?pattern=FILENAME&submit=Find");
1148 URL
.Replace(wxT("FILENAME"), filename
);
1154 bool CamuleDlg::Check_and_Init_Skin()
1157 wxString
skinFileName(thePrefs::GetSkin());
1159 if (skinFileName
.IsEmpty()) {
1163 wxString
userDir(JoinPaths(GetConfigDir(), wxT("skins")) + wxFileName::GetPathSeparator());
1165 wxStandardPathsBase
&spb(wxStandardPaths::Get());
1167 wxString
dataDir(spb
.GetPluginsDir());
1168 #elif defined(__WXMAC__)
1169 wxString
dataDir(spb
.GetDataDir());
1171 wxString
dataDir(spb
.GetDataDir().BeforeLast(wxT('/')) + wxT("/amule"));
1173 wxString
systemDir(JoinPaths(dataDir
,wxT("skins")) + wxFileName::GetPathSeparator());
1176 skinFileName
.Replace(wxT("User:"), userDir
);
1177 skinFileName
.Replace(wxT("System:"), systemDir
);
1179 m_skinFileName
.Assign(skinFileName
);
1180 if (!m_skinFileName
.FileExists()) {
1181 AddLogLineM(true, CFormat(
1182 _("Skin directory '%s' does not exist")) %
1185 } else if (!m_skinFileName
.IsFileReadable()) {
1186 AddLogLineM(true, CFormat(
1187 _("WARNING: Unable to open skin file '%s' for read")) %
1192 wxFFileInputStream
in(m_skinFileName
.GetFullPath());
1193 wxZipInputStream
zip(in
);
1195 while ((entry
= zip
.GetNextEntry()) != NULL
) {
1196 wxZipEntry
*& current
= cat
[entry
->GetInternalName()];
1205 void CamuleDlg::Add_Skin_Icon(
1206 const wxString
&iconName
,
1207 const wxBitmap
&stdIcon
,
1212 wxFFileInputStream
in(m_skinFileName
.GetFullPath());
1213 wxZipInputStream
zip(in
);
1215 it
= cat
.find(wxZipEntry::GetInternalName(iconName
+ wxT(".png")));
1216 if ( it
!= cat
.end() ) {
1217 zip
.OpenEntry(*it
->second
);
1218 if ( !new_image
.LoadFile(zip
,wxBITMAP_TYPE_PNG
) ) {
1220 wxT("Warning: Error loading icon for ") +
1226 wxT("Warning: Can't load icon for ") +
1233 wxBitmap
bmp(useSkins
? new_image
: stdIcon
);
1234 if (iconName
.StartsWith(wxT("Client_"))) {
1235 m_imagelist
.Add(bmp
);
1236 } else if (iconName
.StartsWith(wxT("Toolbar_"))) {
1242 void CamuleDlg::Apply_Clients_Skin()
1244 bool useSkins
= Check_and_Init_Skin();
1246 // Clear the client image list
1247 m_imagelist
.RemoveAll();
1249 // Add the images to the image list
1250 for (int i
= 0; i
< CLIENT_SKIN_SIZE
; ++i
) {
1251 Add_Skin_Icon(wxT("Client_") + m_clientSkinNames
[i
],
1252 clientImages(i
), useSkins
);
1257 void CamuleDlg::Apply_Toolbar_Skin(wxToolBar
*wndToolbar
)
1259 bool useSkins
= Check_and_Init_Skin();
1262 // Clear the toolbar image list
1263 m_tblist
.RemoveAll();
1265 // Add the images to the image list
1266 Add_Skin_Icon(wxT("Toolbar_Connect"), connButImg(0), useSkins
);
1267 Add_Skin_Icon(wxT("Toolbar_Disconnect"), connButImg(1), useSkins
);
1268 Add_Skin_Icon(wxT("Toolbar_Connecting"), connButImg(2), useSkins
);
1269 Add_Skin_Icon(wxT("Toolbar_Network"), amuleDlgImages(20), useSkins
);
1270 Add_Skin_Icon(wxT("Toolbar_Transfers"), amuleDlgImages(21), useSkins
);
1271 Add_Skin_Icon(wxT("Toolbar_Search"), amuleDlgImages(22), useSkins
);
1272 Add_Skin_Icon(wxT("Toolbar_Shared"), amuleDlgImages(23), useSkins
);
1273 Add_Skin_Icon(wxT("Toolbar_Messages"), amuleDlgImages(24), useSkins
);
1274 Add_Skin_Icon(wxT("Toolbar_Stats"), amuleDlgImages(25), useSkins
);
1275 Add_Skin_Icon(wxT("Toolbar_Prefs"), amuleDlgImages(26), useSkins
);
1276 Add_Skin_Icon(wxT("Toolbar_Import"), amuleDlgImages(32), useSkins
);
1277 Add_Skin_Icon(wxT("Toolbar_About"), amuleDlgImages(29), useSkins
);
1278 Add_Skin_Icon(wxT("Toolbar_Blink"), amuleDlgImages(33), useSkins
);
1280 // Build aMule toolbar
1281 wndToolbar
->SetMargins(0, 0);
1283 // Placeholder. Gets updated by ShowConnectionState
1284 wndToolbar
->AddTool(ID_BUTTONCONNECT
, wxT("..."), m_tblist
.GetBitmap(0));
1286 wndToolbar
->AddSeparator();
1287 wndToolbar
->AddTool(ID_BUTTONNETWORKS
,
1288 _("Networks"), m_tblist
.GetBitmap(3),
1289 wxNullBitmap
, wxITEM_CHECK
,
1290 _("Networks window"));
1291 wndToolbar
->AddTool(ID_BUTTONSEARCH
,
1292 _("Searches"), m_tblist
.GetBitmap(5),
1293 wxNullBitmap
, wxITEM_CHECK
,
1294 _("Searches window"));
1295 wndToolbar
->AddTool(ID_BUTTONTRANSFER
,
1296 _("Transfers"), m_tblist
.GetBitmap(4),
1297 wxNullBitmap
, wxITEM_CHECK
,
1298 _("Files transfers window"));
1299 wndToolbar
->AddTool(ID_BUTTONSHARED
,
1300 _("Shared files"), m_tblist
.GetBitmap(6),
1301 wxNullBitmap
, wxITEM_CHECK
,
1302 _("Shared files window"));
1303 wndToolbar
->AddTool(ID_BUTTONMESSAGES
,
1304 _("Messages"), m_tblist
.GetBitmap(7),
1305 wxNullBitmap
, wxITEM_CHECK
,
1306 _("Messages window"));
1307 wndToolbar
->AddTool(ID_BUTTONSTATISTICS
,
1308 _("Statistics"), m_tblist
.GetBitmap(8),
1309 wxNullBitmap
, wxITEM_CHECK
,
1310 _("Statistics graph window"));
1311 wndToolbar
->AddSeparator();
1312 wndToolbar
->AddTool(ID_BUTTONNEWPREFERENCES
,
1313 _("Preferences"), m_tblist
.GetBitmap(9),
1314 wxNullBitmap
, wxITEM_NORMAL
,
1315 _("Preferences settings window"));
1316 wndToolbar
->AddTool(ID_BUTTONIMPORT
,
1317 _("Import"), m_tblist
.GetBitmap(10),
1318 wxNullBitmap
, wxITEM_NORMAL
,
1319 _("The partfile importer tool"));
1320 wndToolbar
->AddTool(ID_ABOUT
,
1321 _("About"), m_tblist
.GetBitmap(11),
1322 wxNullBitmap
, wxITEM_NORMAL
,
1325 wndToolbar
->ToggleTool(ID_BUTTONTRANSFER
, true);
1327 // Needed for non-GTK platforms, where the
1328 // items don't get added immediatly.
1329 wndToolbar
->Realize();
1331 // Updates the "Connect" button, and so on.
1332 ShowConnectionState(true);
1336 void CamuleDlg::Create_Toolbar(bool orientation
)
1339 // Create ToolBar from the one designed by wxDesigner (BigBob)
1340 wxToolBar
*current
= GetToolBar();
1342 wxASSERT(current
== m_wndToolbar
);
1345 bool oldorientation
= ((current
->GetWindowStyle() & wxTB_VERTICAL
) == wxTB_VERTICAL
);
1346 if (oldorientation
!= orientation
) {
1348 SetToolBar(NULL
); // Remove old one if present
1349 m_wndToolbar
= NULL
;
1351 current
->ClearTools();
1355 if (!m_wndToolbar
) {
1356 m_wndToolbar
= CreateToolBar(
1357 (orientation
? wxTB_VERTICAL
: wxTB_HORIZONTAL
) |
1358 wxNO_BORDER
| wxTB_TEXT
| wxTB_3DBUTTONS
|
1359 wxTB_FLAT
| wxCLIP_CHILDREN
| wxTB_NODIVIDER
);
1362 m_wndToolbar
->SetToolBitmapSize(wxSize(32, 32));
1365 Apply_Toolbar_Skin(m_wndToolbar
);
1367 m_wndToolbar
->DeleteTool(ID_BUTTONIMPORT
);
1374 void CamuleDlg::OnMainGUISizeChange(wxSizeEvent
& evt
)
1376 wxFrame::OnSize(evt
);
1377 if (m_transferwnd
&& m_transferwnd
->clientlistctrl
) {
1378 // Transfer window's splitter set again if it's hidden.
1379 if (m_transferwnd
->clientlistctrl
->GetListView() == vtNone
) {
1380 int height
= m_transferwnd
->clientlistctrl
->GetSize().GetHeight();
1381 wxSplitterWindow
* splitter
=
1382 CastChild(wxT("splitterWnd"), wxSplitterWindow
);
1383 height
+= splitter
->GetWindow1()->GetSize().GetHeight();
1384 splitter
->SetSashPosition( height
);
1391 void CamuleDlg::OnKeyPressed(wxKeyEvent
& event
)
1393 if (event
.GetKeyCode() == WXK_F1
) {
1394 // Ctrl/Alt/Shift must not be pressed, to avoid
1395 // conflicts with other (global) shortcuts.
1396 if (!event
.HasModifiers() && !event
.ShiftDown()) {
1397 LaunchUrl(wxT("http://wiki.amule.org"));
1406 void CamuleDlg::OnExit(wxCommandEvent
& WXUNUSED(evt
))
1411 void CamuleDlg::DoNetworkRearrange()
1414 wxWindowUpdateLocker
freezer(this);
1416 wxToolBarToolBase
* toolbarTool
= m_wndToolbar
->RemoveTool(ID_BUTTONNETWORKS
);
1418 wxNotebook
* logs_notebook
= CastChild( ID_SRVLOG_NOTEBOOK
, wxNotebook
);
1419 wxNotebook
* networks_notebook
= CastChild( ID_NETNOTEBOOK
, wxNotebook
);
1421 while (logs_notebook
->GetPageCount() > 1) {
1422 logs_notebook
->RemovePage(logs_notebook
->GetPageCount() - 1);
1425 while (networks_notebook
->GetPageCount() > 0) {
1426 networks_notebook
->RemovePage(networks_notebook
->GetPageCount() - 1);
1429 if (thePrefs::GetNetworkED2K()) {
1430 logs_notebook
->AddPage(m_logpages
[1].page
, m_logpages
[1].name
);
1431 logs_notebook
->AddPage(m_logpages
[2].page
, m_logpages
[2].name
);
1434 m_networkpages
[0].page
->Show(thePrefs::GetNetworkED2K());
1436 if (thePrefs::GetNetworkKademlia()) {
1437 logs_notebook
->AddPage(m_logpages
[3].page
, m_logpages
[3].name
);
1440 m_networkpages
[1].page
->Show(thePrefs::GetNetworkKademlia());
1442 networks_notebook
->Show(thePrefs::GetNetworkED2K() && thePrefs::GetNetworkKademlia());
1444 wxWindow
* replacement
= NULL
;
1446 m_networknotebooksizer
->Clear();
1448 if (thePrefs::GetNetworkED2K() && thePrefs::GetNetworkKademlia()) {
1449 toolbarTool
->SetLabel(_("Networks"));
1451 m_networkpages
[0].page
->Reparent(networks_notebook
);
1452 m_networkpages
[1].page
->Reparent(networks_notebook
);
1454 networks_notebook
->AddPage(m_networkpages
[0].page
, m_networkpages
[0].name
);
1455 networks_notebook
->AddPage(m_networkpages
[1].page
, m_networkpages
[1].name
);
1457 replacement
= networks_notebook
;
1459 } else if (thePrefs::GetNetworkED2K()) {
1460 toolbarTool
->SetLabel(_("eD2k network"));
1461 replacement
= m_networkpages
[0].page
;
1462 m_networkpages
[1].page
->Reparent(m_networknotebooksizer
->GetContainingWindow());
1463 } else if (thePrefs::GetNetworkKademlia()) {
1464 toolbarTool
->SetLabel(_("Kad network"));
1465 m_networkpages
[0].page
->Reparent(m_networknotebooksizer
->GetContainingWindow());
1466 replacement
= m_networkpages
[1].page
;
1469 toolbarTool
->SetLabel(_("No network"));
1473 replacement
->Reparent(m_networknotebooksizer
->GetContainingWindow());
1474 m_networknotebooksizer
->Add( replacement
, 1, wxGROW
|wxALIGN_CENTER_VERTICAL
|wxTOP
, 5 );
1475 m_networknotebooksizer
->Layout();
1478 m_wndToolbar
->InsertTool(2, toolbarTool
);
1480 m_wndToolbar
->EnableTool(ID_BUTTONNETWORKS
, (thePrefs::GetNetworkED2K() || thePrefs::GetNetworkKademlia()));
1481 m_wndToolbar
->EnableTool(ID_BUTTONCONNECT
, (thePrefs::GetNetworkED2K() || thePrefs::GetNetworkKademlia()));
1483 m_wndToolbar
->Realize();
1485 m_searchwnd
->FixSearchTypes();
1488 // File_checked_for_headers