Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members

Shareaza.h

Go to the documentation of this file.
00001 //
00002 // Shareaza.h
00003 //
00004 // Copyright (c) Shareaza Development Team, 2002-2005.
00005 // This file is part of SHAREAZA (www.shareaza.com)
00006 //
00007 // Shareaza is free software; you can redistribute it
00008 // and/or modify it under the terms of the GNU General Public License
00009 // as published by the Free Software Foundation; either version 2 of
00010 // the License, or (at your option) any later version.
00011 //
00012 // Shareaza is distributed in the hope that it will be useful,
00013 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015 // GNU General Public License for more details.
00016 //
00017 // You should have received a copy of the GNU General Public License
00018 // along with Shareaza; if not, write to the Free Software
00019 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
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 // Construction
00034 public:
00035         CShareazaApp();
00036 
00037 // Attributes
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;                                          // NT based core. (NT, 2000, XP, etc)
00049         BOOL                            m_bLimitedConnections;          // Networking is limited (XP SP2)
00050         DWORD                           m_dwWindowsVersion;                     // Windows version
00051         DWORD                           m_dwWindowsVersionMinor;        // Windows minor version
00052         QWORD                           m_nPhysicalMemory;                      // Physical RAM installed
00053         BOOL                            m_bRTL;                                         // Right-to-Left GUI (2000, XP only)
00054         BOOL                m_bMenuWasVisible;          // For the menus in media player window
00055 
00056         int                                     m_nDefaultFontSize;                     // The basic font size. (11)
00057         CString                         m_sDefaultFont;                         // Main font. (Tahoma)
00058         CString                         m_sPacketDumpFont;                      // Packet Window. (Lucida Console)
00059         CString                         m_sSystemLogFont;                       // System Window. (Courier New)
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 // Operations
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 // Overrides
00089 public:
00090         virtual BOOL InitInstance();
00091         virtual int ExitInstance();
00092         virtual void WinHelp(DWORD dwData, UINT nCmd = HELP_CONTEXT);
00093 
00094 // Implementation
00095 public:
00096         DECLARE_MESSAGE_MAP()
00097 };
00098 
00099 extern CShareazaApp theApp;
00100 
00101 //
00102 // Utility Functions
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 // Client's name
00219 #define CLIENT_NAME                     "Shareaza"
00220 
00221 
00222 // Network ID stuff
00223 
00224 // 4 Character vendor code (used on G1, G2)
00225 // BEAR, LIME, RAZA, etc
00226 #define VENDOR_CODE                     "RAZB"
00227 
00228 // ed2k client ID number.
00229 // 0 = eMule, 1 - cDonkey, 4 = Shareaza mod/fork/etc, 28 = Raza.
00230 #define ED2K_CLIENT_ID          4
00231 
00232 // 2 Character BT peer-id code
00233 // SZ = Raza, AZ = Azerus, etc
00234 #define BT_ID1                          'S'
00235 #define BT_ID2                          '~'
00236 

Generated on Thu Dec 15 10:39:48 2005 for Shareaza 2.2.1.0 by  doxygen 1.4.2