00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #pragma once
00023
00024 #include "Resource.h"
00025 #include "ComObject.h"
00026 #include "ShareazaOM.h"
00027
00028 class CMainWnd;
00029
00030
00031 class CShareazaApp : public CWinApp
00032 {
00033
00034 public:
00035 CShareazaApp();
00036
00037
00038 public:
00039 CMutex m_pMutex;
00040 CMutex m_pSection;
00041 WORD m_nVersion[4];
00042 CString m_sVersion;
00043 CFont m_gdiFont;
00044 CFont m_gdiFontBold;
00045 CFont m_gdiFontLine;
00046 CWnd* m_pSafeWnd;
00047 BOOL m_bLive;
00048 BOOL m_bNT;
00049 BOOL m_bLimitedConnections;
00050 DWORD m_dwWindowsVersion;
00051 DWORD m_dwWindowsVersionMinor;
00052 QWORD m_nPhysicalMemory;
00053 BOOL m_bRTL;
00054 BOOL m_bMenuWasVisible;
00055
00056 int m_nDefaultFontSize;
00057 CString m_sDefaultFont;
00058 CString m_sPacketDumpFont;
00059 CString m_sSystemLogFont;
00060
00061 HINSTANCE m_hUser32;
00062 BOOL (WINAPI *m_pfnSetLayeredWindowAttributes)(HWND, COLORREF, BYTE, DWORD);
00063 BOOL (WINAPI *m_pfnGetMonitorInfoA)(HMONITOR, LPMONITORINFO);
00064 HMONITOR (WINAPI *m_pfnMonitorFromRect)(LPCRECT, DWORD);
00065 HMONITOR (WINAPI *m_pfnMonitorFromWindow)(HWND, DWORD);
00066 HINSTANCE m_hGDI32;
00067 DWORD (WINAPI *m_pfnSetLayout)(HDC, DWORD);
00068
00069 protected:
00070 CCriticalSection m_csMessage;
00071 static TCHAR szMessageBuffer[16384];
00072
00073
00074 public:
00075 static CMainWnd* SafeMainWnd();
00076 void Message(int nType, UINT nID, ...);
00077 void Message(int nType, LPCTSTR pszFormat, ...);
00078 CString GetErrorString();
00079 BOOL InternalURI(LPCTSTR pszURI);
00080 protected:
00081 void GetVersionNumber();
00082 void InitResources();
00083 public:
00084 void PrintMessage(int nType, LPCTSTR pszLog);
00085 void LogMessage(LPCTSTR pszLog);
00086 void DebugState(BOOL bState);
00087
00088
00089 public:
00090 virtual BOOL InitInstance();
00091 virtual int ExitInstance();
00092 virtual void WinHelp(DWORD dwData, UINT nCmd = HELP_CONTEXT);
00093
00094
00095 public:
00096 DECLARE_MESSAGE_MAP()
00097 };
00098
00099 extern CShareazaApp theApp;
00100
00101
00102
00103
00104
00105 CRuntimeClass* AfxClassForName(LPCTSTR pszClass);
00106
00107 BOOL LoadString(CString& str, UINT nID);
00108 LPCTSTR _tcsistr(LPCTSTR pszString, LPCTSTR pszPattern);
00109 LPCTSTR _tcsnistr(LPCTSTR pszString, LPCTSTR pszPattern, DWORD plen);
00110 void ToLower(CString& strSource);
00111 void Replace(CString& strBuffer, LPCTSTR pszFind, LPCTSTR pszReplace);
00112 void Split(CString strSource, LPCTSTR strDelimiter, CStringArray& pAddIt, BOOL bAddFirstEmpty);
00113 BOOL LoadSourcesString(CString& str, DWORD num);
00114
00115 DWORD TimeFromString(LPCTSTR psz);
00116 CString TimeToString(DWORD tVal);
00117 BOOL TimeFromString(LPCTSTR psz, FILETIME* pTime);
00118 CString TimeToString(FILETIME* pTime);
00119
00120 void RecalcDropWidth(CComboBox* pWnd);
00121 HICON CreateMirroredIcon(HICON hIconOrig);
00122 HBITMAP CreateMirroredBitmap(HBITMAP hbmOrig);
00123
00124 #ifdef _DEBUG
00125 #define MLOG(x) theApp.Message( MSG_DEBUG, x )
00126 #else
00127 #define MLOG(x)
00128 #endif
00129
00130 static inline bool IsCharacter(TCHAR nChar)
00131 {
00132 if ( nChar >= 0 && nChar <= 255 )
00133 {
00134 return ( _istalnum( nChar ) ) != 0;
00135 }
00136 else
00137 {
00138 return ( _istspace( nChar ) ) == 0;
00139 }
00140 }
00141
00142 static inline bool IsWord(LPCTSTR pszString, int nStart, int nLength)
00143 {
00144 for ( pszString += nStart ; *pszString && nLength ; pszString++, nLength-- )
00145 {
00146 if ( ! _istdigit( *pszString ) ) return true;
00147 }
00148 return false;
00149 }
00150
00151 #define MSG_DEFAULT 0
00152 #define MSG_SYSTEM 1
00153 #define MSG_ERROR 2
00154 #define MSG_DEBUG 3
00155 #define MSG_TEMP 4
00156 #define MSG_DOWNLOAD 1
00157
00158 #define WM_WINSOCK (WM_USER+101)
00159 #define WM_VERSIONCHECK (WM_USER+102)
00160 #define WM_OPENCHAT (WM_USER+103)
00161 #define WM_TRAY (WM_USER+104)
00162 #define WM_URL (WM_USER+105)
00163 #define WM_SKINCHANGED (WM_USER+106)
00164 #define WM_COLLECTION (WM_USER+107)
00165 #define WM_OPENSEARCH (WM_USER+108)
00166 #define WM_LOG (WM_USER+109)
00167
00168 #define WM_AFX_SETMESSAGESTRING 0x0362
00169 #define WM_AFX_POPMESSAGESTRING 0x0375
00170 #define WM_IDLEUPDATECMDUI 0x0363
00171
00172 #define ID_PLUGIN_FIRST 27000
00173 #define ID_PLUGIN_LAST 27999
00174
00175 #undef ON_NOTIFY
00176 #define ON_NOTIFY(wNotifyCode, id, memberFxn) \
00177 { WM_NOTIFY, (WORD)(int)wNotifyCode, (WORD)id, (WORD)id, AfxSigNotify_v, \
00178 (AFX_PMSG) \
00179 (reinterpret_cast< void (AFX_MSG_CALL CCmdTarget::*)(NMHDR*, LRESULT*) > \
00180 (memberFxn)) },
00181
00182 #undef ON_NOTIFY_RANGE
00183 #define ON_NOTIFY_RANGE(wNotifyCode, id, idLast, memberFxn) \
00184 { WM_NOTIFY, (WORD)(int)wNotifyCode, (WORD)id, (WORD)idLast, AfxSigNotify_RANGE, \
00185 (AFX_PMSG) \
00186 (reinterpret_cast< void (AFX_MSG_CALL CCmdTarget::*)(UINT, NMHDR*, LRESULT*) > \
00187 (memberFxn)) },
00188
00189 #undef ON_NOTIFY_EX
00190 #define ON_NOTIFY_EX(wNotifyCode, id, memberFxn) \
00191 { WM_NOTIFY, (WORD)(int)wNotifyCode, (WORD)id, (WORD)id, AfxSigNotify_EX, \
00192 (AFX_PMSG) \
00193 (reinterpret_cast< BOOL (AFX_MSG_CALL CCmdTarget::*)(UINT, NMHDR*, LRESULT*) > \
00194 (memberFxn)) },
00195
00196 #undef ON_NOTIFY_EX_RANGE
00197 #define ON_NOTIFY_EX_RANGE(wNotifyCode, id, idLast, memberFxn) \
00198 { WM_NOTIFY, (WORD)(int)wNotifyCode, (WORD)id, (WORD)idLast, AfxSigNotify_EX, \
00199 (AFX_PMSG) \
00200 (reinterpret_cast< BOOL (AFX_MSG_CALL CCmdTarget::*)(UINT, NMHDR*, LRESULT*) > \
00201 (memberFxn)) },
00202
00203 #undef ON_NOTIFY_REFLECT
00204 #define ON_NOTIFY_REFLECT(wNotifyCode, memberFxn) \
00205 { WM_NOTIFY+WM_REFLECT_BASE, (WORD)(int)wNotifyCode, 0, 0, AfxSigNotify_v, \
00206 (AFX_PMSG) \
00207 (reinterpret_cast<void (AFX_MSG_CALL CCmdTarget::*)(NMHDR*, LRESULT*) > \
00208 (memberFxn)) },
00209
00210 #undef ON_NOTIFY_REFLECT_EX
00211 #define ON_NOTIFY_REFLECT_EX(wNotifyCode, memberFxn) \
00212 { WM_NOTIFY+WM_REFLECT_BASE, (WORD)(int)wNotifyCode, 0, 0, AfxSigNotify_b, \
00213 (AFX_PMSG) \
00214 (reinterpret_cast<BOOL (AFX_MSG_CALL CCmdTarget::*)(NMHDR*, LRESULT*) > \
00215 (memberFxn)) },
00216
00217
00218
00219 #define CLIENT_NAME "Shareaza"
00220
00221
00222
00223
00224
00225
00226 #define VENDOR_CODE "RAZB"
00227
00228
00229
00230 #define ED2K_CLIENT_ID 4
00231
00232
00233
00234 #define BT_ID1 'S'
00235 #define BT_ID2 '~'
00236