1//
2// This file is part of the aMule Project.
3//
4// Copyright (c) 2003-2011 aMule Team ( admin@amule.org / http://www.amule.org )
5// Copyright (c) 2002-2011 Merkur ( devs@emule-project.net / http://www.emule-project.net )
6//
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
9// respective authors.
10//
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.
15//
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.
20//
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
24//
25
26#ifndef AMULEDLG_H
27#define AMULEDLG_H
28
29
30#include <wx/archive.h>
31#include <wx/filename.h>
32#include <wx/frame.h>			// Needed for wxFrame
33#include <wx/imaglist.h>
34#include <wx/timer.h>
35#include <wx/wfstream.h>
36#include <wx/zipstrm.h>
37
38#include "Types.h"			// Needed for uint32
39
40
41class wxTimerEvent;
42class wxTextCtrl;
43
44class CIP2Country;
45class CTransferWnd;
46class CServerWnd;
47class CSharedFilesWnd;
48class CSearchDlg;
49class CChatWnd;
50class CStatisticsDlg;
51class CKadDlg;
52class PrefsUnifiedDlg;
53
54
55class CMuleTrayIcon;
56
57struct PageType {
58	wxWindow* page;
59	wxString name;
60};
61
62#define MP_RESTORE	4001
63#define MP_CONNECT	4002
64#define MP_DISCONNECT	4003
65#define MP_EXIT		4004
66
67
68#define DEFAULT_SIZE_X  800
69#define DEFAULT_SIZE_Y  600
70
71
72enum ClientSkinEnum {
73	Client_Green_Smiley = 0,
74	Client_Red_Smiley,
75	Client_Yellow_Smiley,
76	Client_Grey_Smiley,
77	Client_White_Smiley,
78	Client_ExtendedProtocol_Smiley,
79	Client_SecIdent_Smiley,
80	Client_BadGuy_Smiley,
81	Client_CreditsGrey_Smiley,
82	Client_CreditsYellow_Smiley,
83	Client_Upload_Smiley,
84	Client_Friend_Smiley,
85	Client_eMule_Smiley,
86	Client_mlDonkey_Smiley,
87	Client_eDonkeyHybrid_Smiley,
88	Client_aMule_Smiley,
89	Client_lphant_Smiley,
90	Client_Shareaza_Smiley,
91	Client_xMule_Smiley,
92	Client_Unknown,
93	Client_InvalidRating_Smiley,
94	Client_PoorRating_Smiley,
95	Client_FairRating_Smiley,
96	Client_GoodRating_Smiley,
97	Client_ExcellentRating_Smiley,
98	Client_CommentOnly_Smiley,
99	Client_Encryption_Smiley,
100	// Add items here.
101	CLIENT_SKIN_SIZE
102};
103
104
105// CamuleDlg Dialogfeld
106class CamuleDlg : public wxFrame
107{
108public:
109	CamuleDlg(
110		wxWindow *pParent = NULL,
111		const wxString &title = wxEmptyString,
112		wxPoint where = wxDefaultPosition,
113		wxSize dlg_size = wxSize(DEFAULT_SIZE_X,DEFAULT_SIZE_Y));
114	~CamuleDlg();
115
116	void AddLogLine(const wxString& line);
117	void AddServerMessageLine(wxString& message);
118	void ResetLog(int id);
119
120	void ShowUserCount(const wxString& info = wxEmptyString);
121	void ShowConnectionState(bool skinChanged = false);
122	void ShowTransferRate();
123
124	bool StatisticsWindowActive()
125		{ return (m_activewnd == (wxWindow*)m_statisticswnd); }
126
127	/* Returns the active dialog. Needed to check what to redraw. */
128	enum DialogType {
129		DT_TRANSFER_WND,
130		DT_NETWORKS_WND,
131		DT_SEARCH_WND,
132		DT_SHARED_WND,
133		DT_CHAT_WND,
134		DT_STATS_WND,
135		DT_KAD_WND	// this one is still unused
136	};
137	DialogType GetActiveDialog()
138		{ return m_nActiveDialog; }
139	void SetActiveDialog(DialogType type, wxWindow* dlg);
140
141	/**
142	 * Helper function for deciding if a certian dlg is visible.
143	 *
144	 * @return True if the dialog is visible to the user, false otherwise.
145	 */
146	bool IsDialogVisible( DialogType dlg )
147	{
148		return m_nActiveDialog == dlg && m_is_safe_state /* && !IsIconized() */;
149	}
150
151	void ShowED2KLinksHandler( bool show );
152
153	void DlgShutDown();
154	void OnClose(wxCloseEvent& evt);
155	void OnBnConnect(wxCommandEvent& evt);
156
157	void DoIconize(bool iconize);
158
159	bool SafeState()	{ return m_is_safe_state; }
160
161	void LaunchUrl(const wxString &url);
162
163	//! These are the currently known web-search providers
164	enum WebSearch {
165		WS_FILEHASH
166	};
167	// websearch function
168	wxString GenWebSearchUrl( const wxString &filename, WebSearch provider );
169
170	void CreateSystray();
171	void RemoveSystray();
172
173	void StartGuiTimer()	{ gui_timer->Start(100); }
174	void StopGuiTimer()	{ gui_timer->Stop(); }
175
176	/**
177	 * This function ensures that _all_ list widgets are properly sorted.
178	 */
179	void InitSort();
180
181	void SetMessageBlink(bool state) { m_BlinkMessages = state; }
182	void Create_Toolbar(bool orientation);
183
184	void DoNetworkRearrange();
185
186	CIP2Country*		m_IP2Country;
187	void IP2CountryDownloadFinished(uint32 result);
188	void EnableIP2Country();
189
190	wxWindow*		m_activewnd;
191	CTransferWnd*		m_transferwnd;
192	CServerWnd*		m_serverwnd;
193	CSharedFilesWnd*	m_sharedfileswnd;
194	CSearchDlg*		m_searchwnd;
195	CChatWnd*		m_chatwnd;
196	CStatisticsDlg*		m_statisticswnd;
197	CKadDlg*		m_kademliawnd;
198	//! Pointer to the current preference dialog, if any.
199	PrefsUnifiedDlg*	m_prefsDialog;
200
201	int			m_srv_split_pos;
202
203	wxImageList m_imagelist;
204	wxImageList m_tblist;
205
206protected:
207	void OnToolBarButton(wxCommandEvent& ev);
208	void OnAboutButton(wxCommandEvent& ev);
209	void OnPrefButton(wxCommandEvent& ev);
210	void OnImportButton(wxCommandEvent& ev);
211	void OnMinimize(wxIconizeEvent& evt);
212	void OnBnClickedFast(wxCommandEvent& evt);
213	void OnGUITimer(wxTimerEvent& evt);
214	void OnMainGUISizeChange(wxSizeEvent& evt);
215	void OnExit(wxCommandEvent& evt);
216
217private:
218	//! Specifies if the prefs-dialog was shown before minimizing.
219	bool m_prefsVisible;
220	wxToolBar *m_wndToolbar;
221	wxTimer *gui_timer;
222	CMuleTrayIcon *m_wndTaskbarNotifier;
223	DialogType m_nActiveDialog;
224	bool m_is_safe_state;
225	bool m_BlinkMessages;
226	int m_CurrentBlinkBitmap;
227	uint32 m_last_iconizing;
228	wxFileName m_skinFileName;
229	std::vector<wxString> m_clientSkinNames;
230	bool m_GeoIPavailable;
231
232	WX_DECLARE_STRING_HASH_MAP(wxZipEntry*, ZipCatalog);
233	ZipCatalog::iterator it;
234	wxZipEntry *entry;
235	ZipCatalog cat;
236
237	PageType m_logpages[4];
238	PageType m_networkpages[2];
239
240	bool LoadGUIPrefs(bool override_pos, bool override_size);
241	bool SaveGUIPrefs();
242
243	void UpdateTrayIcon(int percent);
244
245	void Apply_Clients_Skin();
246	void Apply_Toolbar_Skin(wxToolBar *wndToolbar);
247	bool Check_and_Init_Skin();
248	void Add_Skin_Icon(const wxString &iconName, const wxBitmap &stdIcon, bool useSkins);
249	void ToogleED2KLinksHandler();
250	void SetMessagesTool();
251	void OnKeyPressed(wxKeyEvent& evt);
252
253	DECLARE_EVENT_TABLE()
254};
255
256#endif
257
258// File_checked_for_headers
259