3 // This file is part of the aMule Project.
5 // Copyright (c) 2003-2008 aMule Team ( admin@amule.org / http://www.amule.org )
6 // Copyright (c) 2002-2008 Merkur ( devs@emule-project.net / http://www.emule-project.net )
8 // Any parts of this program derived from the xMule, lMule or eMule project,
9 // or contributed by third-party developers are copyrighted by their
10 // respective authors.
12 // This program is free software; you can redistribute it and/or modify
13 // it under the terms of the GNU General Public License as published by
14 // the Free Software Foundation; either version 2 of the License, or
15 // (at your option) any later version.
17 // This program is distributed in the hope that it will be useful,
18 // but WITHOUT ANY WARRANTY; without even the implied warranty of
19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 // GNU General Public License for more details.
22 // You should have received a copy of the GNU General Public License
23 // along with this program; if not, write to the Free Software
24 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
29 #include <wx/archive.h>
30 #include <wx/config.h> // Do_not_auto_remove (MacOS 10.3, wx 2.7)
31 #include <wx/confbase.h> // Do_not_auto_remove (MacOS 10.3, wx 2.7)
32 #include <wx/html/htmlwin.h>
33 #include <wx/mimetype.h> // Do_not_auto_remove (win32)
34 #include <wx/stattext.h>
35 #include <wx/stdpaths.h>
36 #include <wx/textfile.h> // Do_not_auto_remove (win32)
37 #include <wx/tokenzr.h>
38 #include <wx/wfstream.h>
39 #include <wx/zipstrm.h>
40 #include <wx/sysopt.h>
41 #include <wx/wupdlock.h> // Needed for wxWindowUpdateLocker
43 #include <common/EventIDs.h>
46 #include "config.h" // Needed for SVNDATE, PACKAGE, VERSION
48 #include <common/ClientVersion.h>
49 #endif // HAVE_CONFIG_H
51 #include "amuleDlg.h" // Interface declarations.
53 #include <common/Format.h> // Needed for CFormat
54 #include "amule.h" // Needed for theApp
55 #include "ChatWnd.h" // Needed for CChatWnd
56 #include "SourceListCtrl.h" // Needed for CSourceListCtrl
57 #include "DownloadListCtrl.h" // Needed for CDownloadListCtrl
58 #include "DownloadQueue.h" // Needed for CDownloadQueue
59 #include "KadDlg.h" // Needed for CKadDlg
61 #include "MuleTrayIcon.h"
62 #include "muuli_wdr.h" // Needed for ID_BUTTON*
63 #include "Preferences.h" // Needed for CPreferences
64 #include "PrefsUnifiedDlg.h"
65 #include "SearchDlg.h" // Needed for CSearchDlg
66 #include "Server.h" // Needed for CServer
67 #include "ServerConnect.h" // Needed for CServerConnect
68 #include "ServerWnd.h" // Needed for CServerWnd
69 #include "SharedFilesWnd.h" // Needed for CSharedFilesWnd
70 #include "SharedFilePeersListCtrl.h" // Needed for CSharedFilePeersListCtrl
71 #include "Statistics.h" // Needed for theStats
72 #include "StatisticsDlg.h" // Needed for CStatisticsDlg
73 #include "TerminationProcess.h" // Needed for CTerminationProcess
74 #include "TransferWnd.h" // Needed for CTransferWnd
76 #include "PartFileConvertDlg.h"
84 #include "kademlia/kademlia/Kademlia.h"
86 #ifdef ENABLE_IP2COUNTRY
87 #include "IP2Country.h" // Needed for IP2Country
90 #ifdef ENABLE_IP2COUNTRY // That's no bug. MSVC has ENABLE_IP2COUNTRY always on,
91 // but dummy GeoIP.h turns ENABLE_IP2COUNTRY off again.
92 void CamuleDlg::IP2CountryDownloadFinished(uint32 result
)
94 m_IP2Country
->DownloadFinished(result
);
97 void CamuleDlg::EnableIP2Country()
99 if (thePrefs::IsGeoIPEnabled()) {
100 m_IP2Country
->Enable();
106 void CamuleDlg::IP2CountryDownloadFinished(uint32
){}
107 void CamuleDlg::EnableIP2Country(){}
111 BEGIN_EVENT_TABLE(CamuleDlg
, wxFrame
)
113 EVT_TOOL(ID_BUTTONNETWORKS
, CamuleDlg::OnToolBarButton
)
114 EVT_TOOL(ID_BUTTONSEARCH
, CamuleDlg::OnToolBarButton
)
115 EVT_TOOL(ID_BUTTONDOWNLOADS
, CamuleDlg::OnToolBarButton
)
116 EVT_TOOL(ID_BUTTONSHARED
, CamuleDlg::OnToolBarButton
)
117 EVT_TOOL(ID_BUTTONMESSAGES
, CamuleDlg::OnToolBarButton
)
118 EVT_TOOL(ID_BUTTONSTATISTICS
, CamuleDlg::OnToolBarButton
)
119 EVT_TOOL(ID_ABOUT
, CamuleDlg::OnAboutButton
)
121 EVT_TOOL(ID_BUTTONNEWPREFERENCES
, CamuleDlg::OnPrefButton
)
122 EVT_TOOL(ID_BUTTONIMPORT
, CamuleDlg::OnImportButton
)
124 EVT_TOOL(ID_BUTTONCONNECT
, CamuleDlg::OnBnConnect
)
126 EVT_CLOSE(CamuleDlg::OnClose
)
127 EVT_ICONIZE(CamuleDlg::OnMinimize
)
129 EVT_BUTTON(ID_BUTTON_FAST
, CamuleDlg::OnBnClickedFast
)
131 EVT_TIMER(ID_GUI_TIMER_EVENT
, CamuleDlg::OnGUITimer
)
133 EVT_SIZE(CamuleDlg::OnMainGUISizeChange
)
135 EVT_KEY_UP(CamuleDlg::OnKeyPressed
)
137 EVT_MENU(wxID_EXIT
, CamuleDlg::OnExit
)
142 #define wxCLOSE_BOX 0
145 CamuleDlg::CamuleDlg(
147 const wxString
&title
,
152 pParent
, -1, title
, where
, dlg_size
,
153 wxCAPTION
|wxRESIZE_BORDER
|wxSYSTEM_MENU
|wxDIALOG_NO_PARENT
|
154 wxRESIZE_BORDER
|wxMINIMIZE_BOX
|wxMAXIMIZE_BOX
|wxCLOSE_BOX
,
159 m_sharedfileswnd(NULL
),
162 m_statisticswnd(NULL
),
168 m_prefsVisible(false),
170 m_wndTaskbarNotifier(NULL
),
171 m_nActiveDialog(DT_NETWORKS_WND
),
172 m_is_safe_state(false),
173 m_BlinkMessages(false),
174 m_CurrentBlinkBitmap(24),
177 m_clientSkinNames(CLIENT_SKIN_SIZE
)
179 // Initialize skin names
180 m_clientSkinNames
[Client_Green_Smiley
] = wxT("Transfer");
181 m_clientSkinNames
[Client_Red_Smiley
] = wxT("Connecting");
182 m_clientSkinNames
[Client_Yellow_Smiley
] = wxT("OnQueue");
183 m_clientSkinNames
[Client_Grey_Smiley
] = wxT("A4AFNoNeededPartsQueueFull");
184 m_clientSkinNames
[Client_White_Smiley
] = wxT("StatusUnknown");
185 m_clientSkinNames
[Client_ExtendedProtocol_Smiley
] = wxT("ExtendedProtocol");
186 m_clientSkinNames
[Client_SecIdent_Smiley
] = wxT("SecIdent");
187 m_clientSkinNames
[Client_BadGuy_Smiley
] = wxT("BadGuy");
188 m_clientSkinNames
[Client_CreditsGrey_Smiley
] = wxT("CreditsGrey");
189 m_clientSkinNames
[Client_CreditsYellow_Smiley
] = wxT("CreditsYellow");
190 m_clientSkinNames
[Client_Upload_Smiley
] = wxT("Upload");
191 m_clientSkinNames
[Client_Friend_Smiley
] = wxT("Friend");
192 m_clientSkinNames
[Client_eMule_Smiley
] = wxT("eMule");
193 m_clientSkinNames
[Client_mlDonkey_Smiley
] = wxT("mlDonkey");
194 m_clientSkinNames
[Client_eDonkeyHybrid_Smiley
] = wxT("eDonkeyHybrid");
195 m_clientSkinNames
[Client_aMule_Smiley
] = wxT("aMule");
196 m_clientSkinNames
[Client_lphant_Smiley
] = wxT("lphant");
197 m_clientSkinNames
[Client_Shareaza_Smiley
] = wxT("Shareaza");
198 m_clientSkinNames
[Client_xMule_Smiley
] = wxT("xMule");
199 m_clientSkinNames
[Client_Unknown
] = wxT("Unknown");
200 m_clientSkinNames
[Client_InvalidRating_Smiley
] = wxT("InvalidRatingOnFile");
201 m_clientSkinNames
[Client_PoorRating_Smiley
] = wxT("PoorRatingOnFile");
202 m_clientSkinNames
[Client_GoodRating_Smiley
] = wxT("GoodRatingOnFile");
203 m_clientSkinNames
[Client_FairRating_Smiley
] = wxT("FairRatingOnFile");
204 m_clientSkinNames
[Client_ExcellentRating_Smiley
] = wxT("ExcellentRatingOnFile");
205 m_clientSkinNames
[Client_CommentOnly_Smiley
] = wxT("CommentOnly");
206 m_clientSkinNames
[Client_Encryption_Smiley
] = wxT("Encrypted");
208 // wxWidgets send idle events to ALL WINDOWS by default... *SIGH*
209 wxIdleEvent::SetMode(wxIDLE_PROCESS_SPECIFIED
);
210 wxUpdateUIEvent::SetMode(wxUPDATE_UI_PROCESS_SPECIFIED
);
211 wxInitAllImageHandlers();
212 Apply_Clients_Skin();
215 wxSystemOptions::SetOption(wxT("msw.remap"), 0);
218 #if !(wxCHECK_VERSION(2, 9, 0) && defined(__WXMAC__))
219 // this crashes on Mac with wx 2.9
220 SetIcon(wxICON(aMule
));
225 // Create new sizer and stuff a wxPanel in there.
226 wxFlexGridSizer
*s_main
= new wxFlexGridSizer(1);
227 s_main
->AddGrowableCol(0);
228 s_main
->AddGrowableRow(0);
230 wxPanel
* p_cnt
= new wxPanel(this, -1, wxDefaultPosition
, wxDefaultSize
);
231 s_main
->Add(p_cnt
, 0, wxGROW
|wxEXPAND
, 0);
232 muleDlg(p_cnt
, false, true);
233 SetSizer(s_main
, true);
235 m_serverwnd
= new CServerWnd(p_cnt
, m_srv_split_pos
);
236 AddLogLineN(wxEmptyString
);
237 AddLogLineN(wxT(" - ") +
238 CFormat(_("This is aMule %s based on eMule.")) % GetMuleVersion());
239 AddLogLineN(wxT(" ") +
240 CFormat(_("Running on %s")) % wxGetOsDescription());
241 AddLogLineN(wxT(" - ") +
242 wxString(_("Visit http://www.amule.org to check if a new version is available.")));
243 AddLogLineN(wxEmptyString
);
245 #ifdef ENABLE_IP2COUNTRY
246 m_GeoIPavailable
= true;
247 m_IP2Country
= new CIP2Country(theApp
->ConfigDir
);
249 m_GeoIPavailable
= false;
251 m_searchwnd
= new CSearchDlg(p_cnt
);
252 m_transferwnd
= new CTransferWnd(p_cnt
);
253 m_sharedfileswnd
= new CSharedFilesWnd(p_cnt
);
254 m_statisticswnd
= new CStatisticsDlg(p_cnt
, theApp
->m_statistics
);
255 m_chatwnd
= new CChatWnd(p_cnt
);
256 m_kademliawnd
= CastChild(wxT("kadWnd"), CKadDlg
);
258 m_serverwnd
->Show(false);
259 m_searchwnd
->Show(false);
260 m_transferwnd
->Show(false);
261 m_sharedfileswnd
->Show(false);
262 m_statisticswnd
->Show(false);
263 m_chatwnd
->Show(false);
265 // Create the GUI timer
266 gui_timer
=new wxTimer(this,ID_GUI_TIMER_EVENT
);
268 AddLogLineN(_("FATAL ERROR: Failed to create Timer"));
272 // Set transfers as active window
273 Create_Toolbar(thePrefs::VerticalToolbar());
274 SetActiveDialog(DT_TRANSFER_WND
, m_transferwnd
);
275 m_wndToolbar
->ToggleTool(ID_BUTTONDOWNLOADS
, true );
277 bool override_where
= (where
!= wxDefaultPosition
);
278 bool override_size
= (
279 (dlg_size
.x
!= DEFAULT_SIZE_X
) ||
280 (dlg_size
.y
!= DEFAULT_SIZE_Y
) );
281 if (!LoadGUIPrefs(override_where
, override_size
)) {
282 // Prefs not loaded for some reason, exit
283 AddLogLineC(wxT("Error! Unable to load Preferences") );
287 // Prepare the dialog, sets the splitter-position (AFTER window size is set)
288 m_transferwnd
->Prepare();
290 m_is_safe_state
= true;
292 // Init statistics stuff, better do it asap
293 m_statisticswnd
->Init();
294 m_kademliawnd
->Init();
295 m_searchwnd
->UpdateCatChoice();
296 if (thePrefs::UseTrayIcon()) {
301 // Must we start minimized?
302 if (thePrefs::GetStartMinimized()) {
307 wxAcceleratorEntry entries
[] = {
308 wxAcceleratorEntry(wxACCEL_CTRL
, wxT('Q'), wxID_EXIT
)
311 SetAcceleratorTable(wxAcceleratorTable(itemsof(entries
), entries
));
312 ShowED2KLinksHandler( thePrefs::GetFED2KLH() );
314 wxNotebook
* logs_notebook
= CastChild( ID_SRVLOG_NOTEBOOK
, wxNotebook
);
315 wxNotebook
* networks_notebook
= CastChild( ID_NETNOTEBOOK
, wxNotebook
);
317 wxASSERT(logs_notebook
->GetPageCount() == 4);
318 wxASSERT(networks_notebook
->GetPageCount() == 2);
320 for (uint32 i
= 0; i
< logs_notebook
->GetPageCount(); ++i
) {
321 m_logpages
[i
].page
= logs_notebook
->GetPage(i
);
322 m_logpages
[i
].name
= logs_notebook
->GetPageText(i
);
325 for (uint32 i
= 0; i
< networks_notebook
->GetPageCount(); ++i
) {
326 m_networkpages
[i
].page
= networks_notebook
->GetPage(i
);
327 m_networkpages
[i
].name
= networks_notebook
->GetPageText(i
);
330 DoNetworkRearrange();
334 // Madcat - Sets Fast ED2K Links Handler on/off.
335 void CamuleDlg::ShowED2KLinksHandler( bool show
)
337 // Errorchecking in case the pointer becomes invalid ...
338 if (s_fed2klh
== NULL
) {
339 wxLogWarning(wxT("Unable to find Fast ED2K Links handler sizer! Hiding FED2KLH aborted."));
343 s_dlgcnt
->Show( s_fed2klh
, show
);
347 // Toogles ed2k link handler.
348 void CamuleDlg::ToogleED2KLinksHandler()
350 // Errorchecking in case the pointer becomes invalid ...
351 if (s_fed2klh
== NULL
) {
352 wxLogWarning(wxT("Unable to find Fast ED2K Links handler sizer! Toogling FED2KLH aborted."));
355 ShowED2KLinksHandler(!s_dlgcnt
->IsShown(s_fed2klh
));
358 void CamuleDlg::SetActiveDialog(DialogType type
, wxWindow
* dlg
)
360 m_nActiveDialog
= type
;
362 if ( type
== DT_TRANSFER_WND
) {
363 if (thePrefs::ShowCatTabInfos()) {
364 m_transferwnd
->UpdateCatTabTitles();
369 m_activewnd
->Show(false);
370 contentSizer
->Detach(m_activewnd
);
373 contentSizer
->Add(dlg
, 1, wxALIGN_LEFT
|wxEXPAND
);
378 // Since we might be suspending redrawing while hiding the dialog
379 // we have to refresh it once it is visible again
380 dlg
->Refresh( true );
383 if ( type
== DT_SHARED_WND
) {
384 // set up splitter now that window sizes are defined
385 m_sharedfileswnd
->Prepare();
390 void CamuleDlg::UpdateTrayIcon(int percent
)
393 if(!theApp
->IsConnected()) {
394 m_wndTaskbarNotifier
->SetTrayIcon(TRAY_ICON_DISCONNECTED
, percent
);
396 if(theApp
->IsConnectedED2K() && theApp
->serverconnect
->IsLowID()) {
397 m_wndTaskbarNotifier
->SetTrayIcon(TRAY_ICON_LOWID
, percent
);
399 m_wndTaskbarNotifier
->SetTrayIcon(TRAY_ICON_HIGHID
, percent
);
405 void CamuleDlg::CreateSystray()
407 wxCHECK_RET(m_wndTaskbarNotifier
== NULL
,
408 wxT("Systray already created"));
410 m_wndTaskbarNotifier
= new CMuleTrayIcon();
411 // This will effectively show the Tray Icon.
416 void CamuleDlg::RemoveSystray()
418 delete m_wndTaskbarNotifier
;
419 m_wndTaskbarNotifier
= NULL
;
423 void CamuleDlg::OnToolBarButton(wxCommandEvent
& ev
)
425 static int lastbutton
= ID_BUTTONDOWNLOADS
;
427 // Kry - just if the GUI is ready for it
428 if ( m_is_safe_state
) {
430 // Rehide the handler if needed
431 if ( lastbutton
== ID_BUTTONSEARCH
&& !thePrefs::GetFED2KLH() ) {
432 if (ev
.GetId() != ID_BUTTONSEARCH
) {
433 ShowED2KLinksHandler( false );
435 // Toogle ED2K handler.
436 ToogleED2KLinksHandler();
440 if ( lastbutton
!= ev
.GetId() ) {
441 switch ( ev
.GetId() ) {
442 case ID_BUTTONNETWORKS
:
443 SetActiveDialog(DT_NETWORKS_WND
, m_serverwnd
);
444 // Set serverlist splitter position
445 CastChild( wxT("SrvSplitterWnd"), wxSplitterWindow
)->SetSashPosition(m_srv_split_pos
, true);
448 case ID_BUTTONSEARCH
:
449 // The search dialog should always display the handler
450 if ( !thePrefs::GetFED2KLH() )
451 ShowED2KLinksHandler( true );
453 SetActiveDialog(DT_SEARCH_WND
, m_searchwnd
);
456 case ID_BUTTONDOWNLOADS
:
457 SetActiveDialog(DT_TRANSFER_WND
, m_transferwnd
);
458 // Prepare the dialog, sets the splitter-position
459 m_transferwnd
->Prepare();
462 case ID_BUTTONSHARED
:
463 SetActiveDialog(DT_SHARED_WND
, m_sharedfileswnd
);
466 case ID_BUTTONMESSAGES
:
467 m_BlinkMessages
= false;
468 SetActiveDialog(DT_CHAT_WND
, m_chatwnd
);
471 case ID_BUTTONSTATISTICS
:
472 SetActiveDialog(DT_STATS_WND
, m_statisticswnd
);
475 // This shouldn't happen, but just in case
477 AddLogLineC(wxT("Unknown button triggered CamuleApp::OnToolBarButton().") );
482 m_wndToolbar
->ToggleTool(lastbutton
, lastbutton
== ev
.GetId() );
483 lastbutton
= ev
.GetId();
488 void CamuleDlg::OnAboutButton(wxCommandEvent
& WXUNUSED(ev
))
490 wxString msg
= wxT(" ");
492 msg
<< _("aMule remote control ") << wxT(VERSION
);
494 msg
<< wxT("aMule ") << wxT(VERSION
);
498 msg
<< _("Snapshot:") << wxT("\n ") << wxT(SVNDATE
);
500 msg
<< wxT("\n\n") << _("'All-Platform' p2p client based on eMule \n\n") <<
501 _("Website: http://www.amule.org \n") <<
502 _("Forum: http://forum.amule.org \n") <<
503 _("FAQ: http://wiki.amule.org \n\n") <<
504 _("Contact: admin@amule.org (administrative issues) \n") <<
505 _("Copyright (c) 2003-2008 aMule Team \n\n") <<
506 _("Part of aMule is based on \n") <<
507 _("Kademlia: Peer-to-peer routing based on the XOR metric.\n") <<
508 _(" Copyright (c) 2002-2008 Petar Maymounkov ( petar@post.harvard.edu )\n") <<
509 _("http://kademlia.scs.cs.nyu.edu\n");
511 if (m_is_safe_state
) {
512 wxMessageBox(msg
, _("Message"), wxOK
| wxICON_INFORMATION
, this);
517 void CamuleDlg::OnPrefButton(wxCommandEvent
& WXUNUSED(ev
))
519 if (m_is_safe_state
) {
520 if (m_prefsDialog
== NULL
) {
521 m_prefsDialog
= new PrefsUnifiedDlg(this);
524 m_prefsDialog
->TransferToWindow();
525 m_prefsDialog
->Show(true);
526 m_prefsDialog
->Raise();
531 void CamuleDlg::OnImportButton(wxCommandEvent
& WXUNUSED(ev
))
534 if (m_is_safe_state
) {
535 CPartFileConvertDlg::ShowGUI(NULL
);
541 CamuleDlg::~CamuleDlg()
543 theApp
->amuledlg
= NULL
;
545 #ifdef ENABLE_IP2COUNTRY
549 AddLogLineN(_("aMule dialog destroyed"));
553 void CamuleDlg::OnBnConnect(wxCommandEvent
& WXUNUSED(evt
))
556 bool disconnect
= (theApp
->IsConnectedED2K() || theApp
->serverconnect
->IsConnecting())
558 || theApp
->IsConnectedKad() // there's no Kad running state atm
560 || (Kademlia::CKademlia::IsRunning())
563 if (thePrefs::GetNetworkED2K()) {
565 //disconnect if currently connected
566 if (theApp
->serverconnect
->IsConnecting()) {
567 theApp
->serverconnect
->StopConnectionTry();
569 theApp
->serverconnect
->Disconnect();
572 //connect if not currently connected
573 AddLogLineC(_("Connecting"));
574 theApp
->serverconnect
->ConnectToAnyServer();
577 wxASSERT(!theApp
->IsConnectedED2K());
581 if (thePrefs::GetNetworkKademlia()) {
589 wxASSERT(!Kademlia::CKademlia::IsRunning());
593 ShowConnectionState();
597 void CamuleDlg::ResetLog(int id
)
599 wxTextCtrl
* ct
= CastByID(id
, m_serverwnd
, wxTextCtrl
);
600 wxCHECK_RET(ct
, wxT("Resetting unknown log"));
604 if (id
== ID_LOGVIEW
) {
605 // Also clear the log line
606 wxStaticText
* text
= CastChild(wxT("infoLabel"), wxStaticText
);
607 text
->SetLabel(wxEmptyString
);
608 text
->GetParent()->Layout();
613 void CamuleDlg::AddLogLine(const wxString
& line
)
615 bool addtostatusbar
= line
[0] == '!';
616 wxString bufferline
= line
.Mid(1);
618 // Add the message to the log-view
619 wxTextCtrl
* ct
= CastByID( ID_LOGVIEW
, m_serverwnd
, wxTextCtrl
);
621 // Bold critical log-lines
622 // Works in Windows too thanks to wxTE_RICH2 style in muuli
623 wxTextAttr style
= ct
->GetDefaultStyle();
624 wxFont font
= style
.GetFont();
625 font
.SetWeight(addtostatusbar
? wxFONTWEIGHT_BOLD
: wxFONTWEIGHT_NORMAL
);
627 #if wxCHECK_VERSION(2, 9, 0)
628 style
.SetFontSize(8);
630 ct
->SetDefaultStyle(style
);
631 ct
->AppendText(bufferline
);
632 ct
->ShowPosition( ct
->GetLastPosition() - 1 );
636 // Set the status-bar if the event warrents it
637 if ( addtostatusbar
) {
638 // Escape "&"s, which would otherwise not show up
639 bufferline
.Replace( wxT("&"), wxT("&&") );
640 wxStaticText
* text
= CastChild( wxT("infoLabel"), wxStaticText
);
641 // Only show the first line if multiple lines
642 text
->SetLabel( bufferline
.BeforeFirst( wxT('\n') ) );
643 text
->SetToolTip( bufferline
);
644 text
->GetParent()->Layout();
650 void CamuleDlg::AddServerMessageLine(wxString
& message
)
652 wxTextCtrl
* cv
= CastByID( ID_SERVERINFO
, m_serverwnd
, wxTextCtrl
);
654 if (message
.Length() > 500) {
655 cv
->AppendText(message
.Left(500) + wxT("\n"));
657 cv
->AppendText(message
+ wxT("\n"));
659 cv
->ShowPosition(cv
->GetLastPosition()-1);
664 void CamuleDlg::ShowConnectionState(bool skinChanged
)
666 static wxImageList
status_arrows(16,16,true,0);
667 if (!status_arrows
.GetImageCount()) {
668 // Generate the image list (This is only done once)
669 for (int t
= 0; t
< 7; ++t
) {
670 status_arrows
.Add(connImages(t
));
674 m_serverwnd
->UpdateED2KInfo();
675 m_serverwnd
->UpdateKadInfo();
678 ////////////////////////////////////////////////////////////
679 // Determine the status of the networks
681 enum ED2KState
{ ED2KOff
= 0, ED2KLowID
= 1, ED2KConnecting
= 2, ED2KHighID
= 3, ED2KUndef
= -1 };
682 enum EKadState
{ EKadOff
= 4, EKadFW
= 5, EKadConnecting
= 5, EKadOK
= 6, EKadUndef
= -1 };
684 ED2KState ed2kState
= ED2KOff
;
685 EKadState kadState
= EKadOff
;
687 ////////////////////////////////////////////////////////////
688 // Update the label on the status-bar and determine
689 // the states of the two networks.
692 if (theApp
->IsConnectedED2K()) {
693 CServer
* server
= theApp
->serverconnect
->GetCurrentServer();
695 msgED2K
= CFormat(wxT("eD2k: %s")) % server
->GetListName();
698 if (theApp
->serverconnect
->IsLowID()) {
699 ed2kState
= ED2KLowID
;
701 ed2kState
= ED2KHighID
;
703 } else if (theApp
->serverconnect
->IsConnecting()) {
704 msgED2K
= _("eD2k: Connecting");
706 ed2kState
= ED2KConnecting
;
707 } else if (thePrefs::GetNetworkED2K()) {
708 msgED2K
= _("eD2k: Disconnected");
712 if (theApp
->IsConnectedKad()) {
713 if (theApp
->IsFirewalledKad()) {
714 msgKad
= _("Kad: Firewalled");
718 msgKad
= _("Kad: Connected");
722 } else if (theApp
->IsKadRunning()) {
723 msgKad
= _("Kad: Connecting");
725 kadState
= EKadConnecting
;
726 } else if (thePrefs::GetNetworkKademlia()) {
727 msgKad
= _("Kad: Off");
730 wxStaticText
* connLabel
= CastChild( wxT("connLabel"), wxStaticText
);
731 wxCHECK_RET(connLabel
, wxT("'connLabel' widget not found"));
734 if (msgED2K
.Length() && msgKad
.Length()) {
735 labelMsg
= msgED2K
+ wxT(" | ") + msgKad
;
737 labelMsg
= msgED2K
+ msgKad
;
740 connLabel
->SetLabel(labelMsg
);
741 connLabel
->GetParent()->Layout();
744 ////////////////////////////////////////////////////////////
745 // Update the connect/disconnect/cancel button.
754 static EConnState s_oldState
= ECS_Unknown
;
755 EConnState currentState
= ECS_Disconnected
;
757 if (theApp
->serverconnect
->IsConnecting() ||
758 (theApp
->IsKadRunning() && !theApp
->IsConnectedKad())) {
759 currentState
= ECS_Connecting
;
760 } else if (theApp
->IsConnected()) {
761 currentState
= ECS_Connected
;
763 currentState
= ECS_Disconnected
;
766 if ( (true == skinChanged
) || (currentState
!= s_oldState
) ) {
767 wxWindowUpdateLocker
freezer(m_wndToolbar
);
769 wxToolBarToolBase
* toolbarTool
= m_wndToolbar
->RemoveTool(ID_BUTTONCONNECT
);
771 switch (currentState
) {
773 toolbarTool
->SetLabel(_("Cancel"));
774 toolbarTool
->SetShortHelp(_("Stop the current connection attempts"));
775 toolbarTool
->SetNormalBitmap(m_tblist
.GetBitmap(2));
779 toolbarTool
->SetLabel(_("Disconnect"));
780 toolbarTool
->SetShortHelp(_("Disconnect from the currently connected networks"));
781 toolbarTool
->SetNormalBitmap(m_tblist
.GetBitmap(1));
785 toolbarTool
->SetLabel(_("Connect"));
786 toolbarTool
->SetShortHelp(_("Connect to the currently enabled networks"));
787 toolbarTool
->SetNormalBitmap(m_tblist
.GetBitmap(0));
790 m_wndToolbar
->InsertTool(0, toolbarTool
);
791 m_wndToolbar
->Realize();
792 m_wndToolbar
->EnableTool(ID_BUTTONCONNECT
, (thePrefs::GetNetworkED2K() || thePrefs::GetNetworkKademlia()) && theApp
->ipfilter
->IsReady());
794 s_oldState
= currentState
;
798 ////////////////////////////////////////////////////////////
799 // Update the globe-icon in the lower-right corner.
800 // (only if connection state has changed)
802 static ED2KState s_ED2KOldState
= ED2KUndef
;
803 static EKadState s_EKadOldState
= EKadUndef
;
804 if (ed2kState
!= s_ED2KOldState
|| kadState
!= s_EKadOldState
) {
805 s_ED2KOldState
= ed2kState
;
806 s_EKadOldState
= kadState
;
807 wxStaticBitmap
* connBitmap
= CastChild( wxT("connImage"), wxStaticBitmap
);
808 wxCHECK_RET(connBitmap
, wxT("'connImage' widget not found"));
810 wxBitmap statusIcon
= connBitmap
->GetBitmap();
811 // Sanity check - otherwise there's a crash here if aMule runs out of resources
812 if (statusIcon
.GetRefData() == NULL
) {
816 wxMemoryDC
bitmapDC(statusIcon
);
818 status_arrows
.Draw(kadState
, bitmapDC
, 0, 0, wxIMAGELIST_DRAW_TRANSPARENT
);
819 status_arrows
.Draw(ed2kState
, bitmapDC
, 0, 0, wxIMAGELIST_DRAW_TRANSPARENT
);
821 connBitmap
->SetBitmap(statusIcon
);
826 void CamuleDlg::ShowUserCount(const wxString
& info
)
828 wxStaticText
* label
= CastChild( wxT("userLabel"), wxStaticText
);
831 m_serverwnd
->UpdateKadInfo();
833 label
->SetLabel(info
);
834 label
->GetParent()->Layout();
838 void CamuleDlg::ShowTransferRate()
840 float kBpsUp
= theStats::GetUploadRate() / 1024.0;
841 float kBpsDown
= theStats::GetDownloadRate() / 1024.0;
843 if( thePrefs::ShowOverhead() )
845 buffer
= CFormat(_("Up: %.1f(%.1f) | Down: %.1f(%.1f)")) % kBpsUp
% (theStats::GetUpOverheadRate() / 1024.0) % kBpsDown
% (theStats::GetDownOverheadRate() / 1024.0);
847 buffer
= CFormat(_("Up: %.1f | Down: %.1f")) % kBpsUp
% kBpsDown
;
849 buffer
.Truncate(50); // Max size 50
851 wxStaticText
* label
= CastChild( wxT("speedLabel"), wxStaticText
);
852 label
->SetLabel(buffer
);
853 label
->GetParent()->Layout();
855 // Show upload/download speed in title
856 if (thePrefs::GetShowRatesOnTitle()) {
857 wxString UpDownSpeed
= CFormat(wxT("Up: %.1f | Down: %.1f")) % kBpsUp
% kBpsDown
;
858 if (thePrefs::GetShowRatesOnTitle() == 1) {
859 SetTitle(theApp
->m_FrameTitle
+ wxT(" -- ") + UpDownSpeed
);
861 SetTitle(UpDownSpeed
+ wxT(" -- ") + theApp
->m_FrameTitle
);
865 wxASSERT((m_wndTaskbarNotifier
!= NULL
) == thePrefs::UseTrayIcon());
866 if (m_wndTaskbarNotifier
) {
868 int percentDown
= (int)ceil((kBpsDown
*100) / thePrefs::GetMaxGraphDownloadRate());
869 UpdateTrayIcon( ( percentDown
> 100 ) ? 100 : percentDown
);
872 if ( theApp
->IsConnected() ) {
873 buffer2
= CFormat(_("aMule (%s | Connected)")) % buffer
;
875 buffer2
= CFormat(_("aMule (%s | Disconnected)")) % buffer
;
877 m_wndTaskbarNotifier
->SetTrayToolTip(buffer2
);
880 wxStaticBitmap
* bmp
= CastChild( wxT("transferImg"), wxStaticBitmap
);
881 bmp
->SetBitmap(dlStatusImages((kBpsUp
>0.01 ? 2 : 0) + (kBpsDown
>0.01 ? 1 : 0)));
884 void CamuleDlg::DlgShutDown()
886 // Are we already shutting down or still on init?
887 if ( m_is_safe_state
== false ) {
892 m_is_safe_state
= false;
894 // Stop the GUI Timer
896 m_transferwnd
->downloadlistctrl
->DeleteAllItems();
898 // We want to delete the systray too!
902 void CamuleDlg::OnClose(wxCloseEvent
& evt
)
904 // This will be here till the core close is != app close
905 if (evt
.CanVeto() && thePrefs::IsConfirmExitEnabled() ) {
906 if (wxNO
== wxMessageBox(wxString(CFormat(_("Do you really want to exit %s?")) % theApp
->GetMuleAppName()),
907 wxString(_("Exit confirmation")), wxYES_NO
, this)) {
918 theApp
->ShutDown(evt
);
922 void CamuleDlg::OnBnClickedFast(wxCommandEvent
& WXUNUSED(evt
))
924 wxTextCtrl
* ctl
= CastChild( wxT("FastEd2kLinks"), wxTextCtrl
);
926 for ( int i
= 0; i
< ctl
->GetNumberOfLines(); i
++ ) {
927 wxString strlink
= ctl
->GetLineText(i
);
930 if ( !strlink
.IsEmpty() ) {
931 theApp
->downloadqueue
->AddLink( strlink
, m_transferwnd
->downloadlistctrl
->GetCategory() );
935 ctl
->SetValue(wxEmptyString
);
939 // Formerly known as LoadRazorPrefs()
940 bool CamuleDlg::LoadGUIPrefs(bool override_pos
, bool override_size
)
942 // Create a config base for loading razor preferences
943 wxConfigBase
*config
= wxConfigBase::Get();
944 // If config haven't been created exit without loading
945 if (config
== NULL
) {
949 // The section where to save in in file
950 wxString section
= wxT("/Razor_Preferences/");
952 // Get window size and position
953 int x1
= config
->Read(section
+ wxT("MAIN_X_POS"), -1);
954 int y1
= config
->Read(section
+ wxT("MAIN_Y_POS"), -1);
955 int x2
= config
->Read(section
+ wxT("MAIN_X_SIZE"), -1);
956 int y2
= config
->Read(section
+ wxT("MAIN_Y_SIZE"), -1);
958 int maximized
= config
->Read(section
+ wxT("Maximized"), 01);
960 // Kry - Random usable pos for m_srv_split_pos
961 m_srv_split_pos
= config
->Read(section
+ wxT("SRV_SPLITTER_POS"), 463l);
962 if (!override_size
) {
963 if (x2
> 0 && y2
> 0) {
967 // Probably first run.
974 // If x1 and y1 != -1 Redefine location
975 if(x1
!= -1 && y1
!= -1) {
976 wxRect display
= wxGetClientDisplayRect();
977 if (x1
<= display
.GetRightTop().x
&& y1
<= display
.GetRightBottom().y
) {
980 // It's offscreen... so let's not.
985 if (!override_size
&& !override_pos
&& maximized
) {
993 bool CamuleDlg::SaveGUIPrefs()
995 /* Razor 1a - Modif by MikaelB
996 Save client size and position */
998 // Create a config base for saving razor preferences
999 wxConfigBase
*config
= wxConfigBase::Get();
1000 // If config haven't been created exit without saving
1001 if (config
== NULL
) {
1004 // The section where to save in in file
1005 wxString section
= wxT("/Razor_Preferences/");
1007 if (!IsIconized()) {
1008 // Main window location and size
1010 GetPosition(&x1
, &y1
);
1013 // Saving window size and position
1014 config
->Write(section
+wxT("MAIN_X_POS"), (long) x1
);
1015 config
->Write(section
+wxT("MAIN_Y_POS"), (long) y1
);
1017 config
->Write(section
+wxT("MAIN_X_SIZE"), (long) x2
);
1018 config
->Write(section
+wxT("MAIN_Y_SIZE"), (long) y2
);
1020 config
->Write(section
+wxT("Maximized"), (long) (IsMaximized() ? 1 : 0));
1023 // Saving sash position of splitter in server window
1024 config
->Write(section
+wxT("SRV_SPLITTER_POS"), (long) m_srv_split_pos
);
1026 config
->Flush(true);
1034 void CamuleDlg::DoIconize(bool iconize
)
1036 if (m_wndTaskbarNotifier
&& thePrefs::DoMinToTray()) {
1038 // Skip() will do it.
1048 // Will be done by Skip();
1053 void CamuleDlg::OnMinimize(wxIconizeEvent
& evt
)
1055 // Evil Hack: check if the mouse is inside the window
1057 if (GetScreenRect().Contains(wxGetMousePosition()))
1060 if (m_prefsDialog
&& m_prefsDialog
->IsShown()) {
1063 if (m_wndTaskbarNotifier
) {
1064 #if wxCHECK_VERSION(2, 9, 0)
1065 DoIconize(evt
.IsIconized());
1067 DoIconize(evt
.Iconized());
1075 void CamuleDlg::OnGUITimer(wxTimerEvent
& WXUNUSED(evt
))
1077 // Former TimerProc section
1079 static uint32 msPrev1
, msPrev5
;
1081 uint32 msCur
= theStats::GetUptimeMillis();
1083 // can this actually happen under wxwin ?
1089 static uint32 msPrevGraph
, msPrevStats
;
1090 int msGraphUpdate
= thePrefs::GetTrafficOMeterInterval() * 1000;
1091 if ((msGraphUpdate
> 0) && ((msCur
/ msGraphUpdate
) > (msPrevGraph
/ msGraphUpdate
))) {
1092 // trying to get the graph shifts evenly spaced after a change in the update period
1093 msPrevGraph
= msCur
;
1095 GraphUpdateInfo update
= theApp
->m_statistics
->GetPointsForUpdate();
1097 m_statisticswnd
->UpdateStatGraphs(theStats::GetPeakConnections(), update
);
1098 m_kademliawnd
->UpdateGraph(update
);
1101 int sStatsUpdate
= thePrefs::GetStatsInterval();
1102 if ((sStatsUpdate
> 0) && ((int)(msCur
- msPrevStats
) > sStatsUpdate
*1000)) {
1103 if (m_statisticswnd
->IsShownOnScreen()) {
1104 msPrevStats
= msCur
;
1105 m_statisticswnd
->ShowStatistics();
1110 if (msCur
-msPrev5
> 5000) { // every 5 seconds
1113 if (thePrefs::ShowCatTabInfos() && theApp
->amuledlg
->m_activewnd
== theApp
->amuledlg
->m_transferwnd
) {
1114 m_transferwnd
->UpdateCatTabTitles();
1116 if (thePrefs::AutoSortDownload()) {
1117 m_transferwnd
->downloadlistctrl
->SortList();
1118 m_transferwnd
->clientlistctrl
->SortList();
1119 m_sharedfileswnd
->peerslistctrl
->SortList();
1123 if (msCur
-msPrev1
> 1000) { // every second
1125 if (m_CurrentBlinkBitmap
== 12) {
1126 m_CurrentBlinkBitmap
= 7;
1129 if (m_BlinkMessages
) {
1130 m_CurrentBlinkBitmap
= 12;
1139 void CamuleDlg::SetMessagesTool()
1141 wxWindowUpdateLocker
freezer(m_wndToolbar
);
1143 m_wndToolbar
->FindById(ID_BUTTONMESSAGES
)->SetNormalBitmap(m_tblist
.GetBitmap(m_CurrentBlinkBitmap
));
1145 m_wndToolbar
->SetToolNormalBitmap(ID_BUTTONMESSAGES
, m_tblist
.GetBitmap(m_CurrentBlinkBitmap
));
1149 void CamuleDlg::LaunchUrl( const wxString
& url
)
1153 cmd
= thePrefs::GetBrowser();
1155 // Pipes cause problems, so escape them
1156 tmp
.Replace( wxT("|"), wxT("%7C") );
1158 if ( !cmd
.IsEmpty() ) {
1159 if (!cmd
.Replace(wxT("%s"), tmp
)) {
1160 // No %s found, just append the url
1161 cmd
+= wxT(" ") + tmp
;
1164 CTerminationProcess
*p
= new CTerminationProcess(cmd
);
1165 if (wxExecute(cmd
, wxEXEC_ASYNC
, p
)) {
1166 AddLogLineN(_("Launch Command: ") + cmd
);
1172 wxLaunchDefaultBrowser(tmp
);
1175 // Unable to execute browser. But this error message doesn't make sense,
1176 // cosidering that you _can't_ set the browser executable path... =/
1177 wxLogError(wxT("Unable to launch browser. Please set correct browser executable path in Preferences."));
1181 wxString
CamuleDlg::GenWebSearchUrl(const wxString
&filename
, WebSearch wsProvider
)
1184 switch (wsProvider
) {
1186 URL
= wxT("http://www.filehash.com/search.html?pattern=FILENAME&submit=Find");
1191 URL
.Replace(wxT("FILENAME"), filename
);
1197 bool CamuleDlg::Check_and_Init_Skin()
1200 wxString
skinFileName(thePrefs::GetSkin());
1202 if (skinFileName
.IsEmpty() || skinFileName
.IsSameAs(_("- default -"))) {
1206 wxString
userDir(JoinPaths(GetConfigDir(), wxT("skins")) + wxFileName::GetPathSeparator());
1208 wxStandardPathsBase
&spb(wxStandardPaths::Get());
1210 wxString
dataDir(spb
.GetPluginsDir());
1211 #elif defined(__WXMAC__)
1212 wxString
dataDir(spb
.GetDataDir());
1214 wxString
dataDir(spb
.GetDataDir().BeforeLast(wxT('/')) + wxT("/amule"));
1216 wxString
systemDir(JoinPaths(dataDir
,wxT("skins")) + wxFileName::GetPathSeparator());
1219 skinFileName
.Replace(wxT("User:"), userDir
);
1220 skinFileName
.Replace(wxT("System:"), systemDir
);
1222 m_skinFileName
.Assign(skinFileName
);
1223 if (!m_skinFileName
.FileExists()) {
1224 AddLogLineC(CFormat(
1225 _("Skin directory '%s' does not exist")) %
1228 } else if (!m_skinFileName
.IsFileReadable()) {
1229 AddLogLineC(CFormat(
1230 _("WARNING: Unable to open skin file '%s' for read")) %
1235 wxFFileInputStream
in(m_skinFileName
.GetFullPath());
1236 wxZipInputStream
zip(in
);
1238 while ((entry
= zip
.GetNextEntry()) != NULL
) {
1239 wxZipEntry
*& current
= cat
[entry
->GetInternalName()];
1248 void CamuleDlg::Add_Skin_Icon(
1249 const wxString
&iconName
,
1250 const wxBitmap
&stdIcon
,
1255 wxFFileInputStream
in(m_skinFileName
.GetFullPath());
1256 wxZipInputStream
zip(in
);
1258 it
= cat
.find(wxZipEntry::GetInternalName(iconName
+ wxT(".png")));
1259 if ( it
!= cat
.end() ) {
1260 zip
.OpenEntry(*it
->second
);
1261 if ( !new_image
.LoadFile(zip
,wxBITMAP_TYPE_PNG
) ) {
1262 AddLogLineN(wxT("Warning: Error loading icon for ") +
1267 AddLogLineN(wxT("Warning: Can't load icon for ") +
1274 wxBitmap
bmp(useSkins
? new_image
: stdIcon
);
1275 if (iconName
.StartsWith(wxT("Client_"))) {
1276 m_imagelist
.Add(bmp
);
1277 } else if (iconName
.StartsWith(wxT("Toolbar_"))) {
1283 void CamuleDlg::Apply_Clients_Skin()
1285 bool useSkins
= Check_and_Init_Skin();
1287 // Clear the client image list
1288 m_imagelist
.RemoveAll();
1290 // Add the images to the image list
1291 for (int i
= 0; i
< CLIENT_SKIN_SIZE
; ++i
) {
1292 Add_Skin_Icon(wxT("Client_") + m_clientSkinNames
[i
],
1293 clientImages(i
), useSkins
);
1298 void CamuleDlg::Apply_Toolbar_Skin(wxToolBar
*wndToolbar
)
1300 bool useSkins
= Check_and_Init_Skin();
1303 // Clear the toolbar image list
1304 m_tblist
.RemoveAll();
1306 // Add the images to the image list
1307 Add_Skin_Icon(wxT("Toolbar_Connect"), connButImg(0), useSkins
);
1308 Add_Skin_Icon(wxT("Toolbar_Disconnect"), connButImg(1), useSkins
);
1309 Add_Skin_Icon(wxT("Toolbar_Connecting"), connButImg(2), useSkins
);
1310 Add_Skin_Icon(wxT("Toolbar_Network"), amuleDlgImages(20), useSkins
);
1311 Add_Skin_Icon(wxT("Toolbar_Transfers"), amuleDlgImages(21), useSkins
);
1312 Add_Skin_Icon(wxT("Toolbar_Search"), amuleDlgImages(22), useSkins
);
1313 Add_Skin_Icon(wxT("Toolbar_Shared"), amuleDlgImages(23), useSkins
);
1314 Add_Skin_Icon(wxT("Toolbar_Messages"), amuleDlgImages(24), useSkins
);
1315 Add_Skin_Icon(wxT("Toolbar_Stats"), amuleDlgImages(25), useSkins
);
1316 Add_Skin_Icon(wxT("Toolbar_Prefs"), amuleDlgImages(26), useSkins
);
1317 Add_Skin_Icon(wxT("Toolbar_Import"), amuleDlgImages(32), useSkins
);
1318 Add_Skin_Icon(wxT("Toolbar_About"), amuleDlgImages(29), useSkins
);
1319 Add_Skin_Icon(wxT("Toolbar_Blink"), amuleDlgImages(33), useSkins
);
1321 // Build aMule toolbar
1322 wndToolbar
->SetMargins(0, 0);
1324 // Placeholder. Gets updated by ShowConnectionState
1325 wndToolbar
->AddTool(ID_BUTTONCONNECT
, wxT("..."), m_tblist
.GetBitmap(0));
1327 wndToolbar
->AddSeparator();
1328 wndToolbar
->AddTool(ID_BUTTONNETWORKS
, _("Networks"), m_tblist
.GetBitmap(3), wxNullBitmap
, wxITEM_CHECK
, _("Networks Window"));
1329 wndToolbar
->AddTool(ID_BUTTONSEARCH
, _("Searches"), m_tblist
.GetBitmap(5), wxNullBitmap
, wxITEM_CHECK
, _("Searches Window"));
1330 wndToolbar
->AddTool(ID_BUTTONDOWNLOADS
, _("Downloads"), m_tblist
.GetBitmap(4), wxNullBitmap
, wxITEM_CHECK
, _("Downloads Window"));
1331 wndToolbar
->AddTool(ID_BUTTONSHARED
, _("Shared files"), m_tblist
.GetBitmap(6), wxNullBitmap
, wxITEM_CHECK
, _("Shared Files Window"));
1332 wndToolbar
->AddTool(ID_BUTTONMESSAGES
, _("Messages"), m_tblist
.GetBitmap(7), wxNullBitmap
, wxITEM_CHECK
, _("Messages Window"));
1333 wndToolbar
->AddTool(ID_BUTTONSTATISTICS
, _("Statistics"), m_tblist
.GetBitmap(8), wxNullBitmap
, wxITEM_CHECK
, _("Statistics Graph Window"));
1334 wndToolbar
->AddSeparator();
1335 wndToolbar
->AddTool(ID_BUTTONNEWPREFERENCES
, _("Preferences"), m_tblist
.GetBitmap(9), wxNullBitmap
, wxITEM_NORMAL
, _("Preferences Settings Window"));
1337 wndToolbar
->AddTool(ID_BUTTONIMPORT
, _("Import"), m_tblist
.GetBitmap(10), wxNullBitmap
, wxITEM_NORMAL
, _("The partfile importer tool"));
1339 wndToolbar
->AddTool(ID_ABOUT
, _("About"), m_tblist
.GetBitmap(11), wxNullBitmap
, wxITEM_NORMAL
, _("About/Help"));
1341 wndToolbar
->ToggleTool(ID_BUTTONDOWNLOADS
, true);
1343 // Needed for non-GTK platforms, where the
1344 // items don't get added immediatly.
1345 wndToolbar
->Realize();
1347 // Updates the "Connect" button, and so on.
1348 ShowConnectionState(true);
1352 void CamuleDlg::Create_Toolbar(bool orientation
)
1355 // Create ToolBar from the one designed by wxDesigner (BigBob)
1356 wxToolBar
*current
= GetToolBar();
1358 wxASSERT(current
== m_wndToolbar
);
1361 bool oldorientation
= ((current
->GetWindowStyle() & wxTB_VERTICAL
) == wxTB_VERTICAL
);
1362 if (oldorientation
!= orientation
) {
1364 SetToolBar(NULL
); // Remove old one if present
1365 m_wndToolbar
= NULL
;
1367 current
->ClearTools();
1371 if (!m_wndToolbar
) {
1372 m_wndToolbar
= CreateToolBar(
1373 (orientation
? wxTB_VERTICAL
: wxTB_HORIZONTAL
) |
1374 wxNO_BORDER
| wxTB_TEXT
| wxTB_3DBUTTONS
|
1375 wxTB_FLAT
| wxCLIP_CHILDREN
| wxTB_NODIVIDER
);
1378 m_wndToolbar
->SetToolBitmapSize(wxSize(32, 32));
1381 Apply_Toolbar_Skin(m_wndToolbar
);
1387 void CamuleDlg::OnMainGUISizeChange(wxSizeEvent
& evt
)
1389 wxFrame::OnSize(evt
);
1390 if (m_transferwnd
&& m_transferwnd
->clientlistctrl
) {
1391 // Transfer window's splitter set again if it's hidden.
1392 if (!m_transferwnd
->clientlistctrl
->GetShowing()) {
1393 int height
= m_transferwnd
->clientlistctrl
->GetSize().GetHeight();
1394 wxSplitterWindow
* splitter
=
1395 CastChild(wxT("splitterWnd"), wxSplitterWindow
);
1396 height
+= splitter
->GetWindow1()->GetSize().GetHeight();
1397 splitter
->SetSashPosition( height
);
1404 void CamuleDlg::OnKeyPressed(wxKeyEvent
& event
)
1406 if (event
.GetKeyCode() == WXK_F1
) {
1407 // Ctrl/Alt/Shift must not be pressed, to avoid
1408 // conflicts with other (global) shortcuts.
1409 if (!event
.HasModifiers() && !event
.ShiftDown()) {
1410 LaunchUrl(wxT("http://wiki.amule.org"));
1419 void CamuleDlg::OnExit(wxCommandEvent
& WXUNUSED(evt
))
1424 void CamuleDlg::DoNetworkRearrange()
1427 wxWindowUpdateLocker
freezer(this);
1429 wxToolBarToolBase
* toolbarTool
= m_wndToolbar
->RemoveTool(ID_BUTTONNETWORKS
);
1431 wxNotebook
* logs_notebook
= CastChild( ID_SRVLOG_NOTEBOOK
, wxNotebook
);
1432 wxNotebook
* networks_notebook
= CastChild( ID_NETNOTEBOOK
, wxNotebook
);
1434 while (logs_notebook
->GetPageCount() > 1) {
1435 logs_notebook
->RemovePage(logs_notebook
->GetPageCount() - 1);
1438 while (networks_notebook
->GetPageCount() > 0) {
1439 networks_notebook
->RemovePage(networks_notebook
->GetPageCount() - 1);
1442 if (thePrefs::GetNetworkED2K()) {
1444 logs_notebook
->AddPage(m_logpages
[1].page
, m_logpages
[1].name
);
1446 logs_notebook
->AddPage(m_logpages
[2].page
, m_logpages
[2].name
);
1449 m_networkpages
[0].page
->Show(thePrefs::GetNetworkED2K());
1451 if (thePrefs::GetNetworkKademlia()) {
1452 logs_notebook
->AddPage(m_logpages
[3].page
, m_logpages
[3].name
);
1455 m_networkpages
[1].page
->Show(thePrefs::GetNetworkKademlia());
1457 networks_notebook
->Show(thePrefs::GetNetworkED2K() && thePrefs::GetNetworkKademlia());
1459 wxWindow
* replacement
= NULL
;
1461 m_networknotebooksizer
->Clear();
1463 if (thePrefs::GetNetworkED2K() && thePrefs::GetNetworkKademlia()) {
1464 toolbarTool
->SetLabel(_("Networks"));
1466 m_networkpages
[0].page
->Reparent(networks_notebook
);
1467 m_networkpages
[1].page
->Reparent(networks_notebook
);
1469 networks_notebook
->AddPage(m_networkpages
[0].page
, m_networkpages
[0].name
);
1470 networks_notebook
->AddPage(m_networkpages
[1].page
, m_networkpages
[1].name
);
1472 replacement
= networks_notebook
;
1474 } else if (thePrefs::GetNetworkED2K()) {
1475 toolbarTool
->SetLabel(_("eD2k network"));
1476 replacement
= m_networkpages
[0].page
;
1477 m_networkpages
[1].page
->Reparent(m_networknotebooksizer
->GetContainingWindow());
1478 } else if (thePrefs::GetNetworkKademlia()) {
1479 toolbarTool
->SetLabel(_("Kad network"));
1480 m_networkpages
[0].page
->Reparent(m_networknotebooksizer
->GetContainingWindow());
1481 replacement
= m_networkpages
[1].page
;
1484 toolbarTool
->SetLabel(_("No network"));
1488 replacement
->Reparent(m_networknotebooksizer
->GetContainingWindow());
1489 m_networknotebooksizer
->Add( replacement
, 1, wxGROW
|wxALIGN_CENTER_VERTICAL
|wxTOP
, 5 );
1490 m_networknotebooksizer
->Layout();
1493 m_wndToolbar
->InsertTool(2, toolbarTool
);
1495 m_wndToolbar
->EnableTool(ID_BUTTONNETWORKS
, (thePrefs::GetNetworkED2K() || thePrefs::GetNetworkKademlia()));
1496 m_wndToolbar
->EnableTool(ID_BUTTONCONNECT
, (thePrefs::GetNetworkED2K() || thePrefs::GetNetworkKademlia()) && theApp
->ipfilter
->IsReady());
1498 m_wndToolbar
->Realize();
1500 m_searchwnd
->FixSearchTypes();
1503 // File_checked_for_headers