Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

220 lines
11 KiB

  1. // --------------------------------------------------------------------------------
  2. // INSTANCE.H
  3. // Copyright (c)1993-1995 Microsoft Corporation, All Rights Reserved
  4. // --------------------------------------------------------------------------------
  5. #ifndef __INSTANCE_H
  6. #define __INSTANCE_H
  7. // --------------------------------------------------------------------------------
  8. // Depends
  9. // --------------------------------------------------------------------------------
  10. #include <msoeapi.h>
  11. // --------------------------------------------------------------------------------
  12. // Macros
  13. // --------------------------------------------------------------------------------
  14. #ifdef DEBUG
  15. #define CoIncrementInit(_pszSource, _dwFlags, _pszCmdLine, _phInitRef) \
  16. g_pInstance->CoIncrementInitDebug(_pszSource, _dwFlags, _pszCmdLine, _phInitRef)
  17. #define CoDecrementInit(_pszSource, _phInitRef) \
  18. g_pInstance->CoDecrementInitDebug(_pszSource, _phInitRef)
  19. #else
  20. #define CoIncrementInit(_pszSource, _dwFlags, _pszCmdLine, _phInitRef) \
  21. g_pInstance->CoIncrementInitImpl(_dwFlags, _pszCmdLine, _phInitRef)
  22. #define CoDecrementInit(_pszSource, _phInitRef) \
  23. g_pInstance->CoDecrementInitImpl(_phInitRef)
  24. #endif // DEBUG
  25. // --------------------------------------------------------------------------------
  26. // Forward Decls
  27. // --------------------------------------------------------------------------------
  28. extern DWORD g_dwHideMessenger;
  29. #define BL_DISP 0
  30. #define BL_CHECK 1
  31. #define BL_HIDE 2
  32. #define BL_NOTINST 10
  33. #define BL_DISABLE (BL_CHECK | BL_NOTINST)
  34. #define BL_DEFAULT BL_CHECK
  35. // --------------------------------------------------------------------------------
  36. // User Window Messages
  37. // --------------------------------------------------------------------------------
  38. #define ITM_SHUTDOWNTHREAD (WM_USER)
  39. #define ITM_CREATENOTEWINDOW (WM_USER+1)
  40. #define ITM_CREATEWMSUINOTE (WM_USER+2)
  41. #define ITM_CALLGENERICVOIDFN (WM_USER+3)
  42. #define ITM_CALLFINDWINDOW (WM_USER+4) // wparam == OFTYPE - see enumeration above.
  43. #define ITM_CREATEREMINDWINDOW (WM_USER+5)
  44. #define ITM_MAPILOGON (WM_USER+6)
  45. #define ITM_OPENSTORE (WM_USER+7)
  46. #define ITM_OPENAB (WM_USER+8)
  47. #define ITM_REDOCOLUMNS (WM_USER+9)
  48. #define ITM_OPENNEWSSTORE (WM_USER+10)
  49. #define ITM_CLOSENOTES (WM_USER+11) // this note is passed when we need to close a note.
  50. #define ITM_CHECKCONFIG (WM_USER+12)
  51. #define ITM_CREATENEWSNOTEWINDOW (WM_USER+13)
  52. #define ITM_OPTIONADVISE (WM_USER+14) // wparam = PFNOPTNOTIFY, lparam = LPARAM
  53. #define ITM_OPTIONUNADVISE (WM_USER+15) // wparam = PFNOPTNOTIFY
  54. #define ITM_GOPTIONSCHANGED (WM_USER+16)
  55. #define ITM_BROWSETOOBJECT (WM_USER+17)
  56. #define ITM_IDENTITYMSG (WM_USER+18)
  57. #define ITM_POSTCOPYDATA (WM_USER+19)
  58. #define ITM_WAB_CO_DECREMENT (WM_USER+20)
  59. // --------------------------------------------------------------------------------
  60. // Startup Modes
  61. // --------------------------------------------------------------------------------
  62. #define MODE_NEWSONLY 0x00000001
  63. #define MODE_OUTLOOKNEWS (0x00000002 | MODE_NEWSONLY | MODE_NOIDENTITIES)
  64. #define MODE_MAILONLY 0x00000004
  65. #define MODE_NOIDENTITIES 0x00000008
  66. #define MODE_EXAM 0x00000010
  67. #define MODE_PLE 0x00000020
  68. #define MODE_JUNKMAIL 0x00000040
  69. // --------------------------------------------------------------------------------
  70. // TRAYICONACTION
  71. // --------------------------------------------------------------------------------
  72. typedef enum tagTRAYICONACTION {
  73. TRAYICONACTION_ADD,
  74. TRAYICONACTION_REMOVE
  75. } TRAYICONACTION;
  76. // --------------------------------------------------------------------------------
  77. // REPORTERRORINFO
  78. // --------------------------------------------------------------------------------
  79. typedef struct tagREPORTERRORINFO {
  80. UINT nTitleIds; // Title of the messagebox
  81. UINT nPrefixIds; // Prefix string resource id
  82. UINT nErrorIds; // Error string resource id
  83. UINT nReasonIds; // Reason string resource id
  84. BOOL nHelpIds; // Help String Resource Id
  85. LPCSTR pszExtra1; // Extra parameter 1
  86. ULONG ulLastError; // GetLastError() Value
  87. } REPORTERRORINFO, *LPREPORTERRORINFO;
  88. // --------------------------------------------------------------------------------
  89. // COutlookExpress
  90. // --------------------------------------------------------------------------------
  91. class COutlookExpress : public IOutlookExpress
  92. {
  93. public:
  94. // ----------------------------------------------------------------------------
  95. // Construction
  96. // ----------------------------------------------------------------------------
  97. COutlookExpress(void);
  98. ~COutlookExpress(void);
  99. // ----------------------------------------------------------------------------
  100. // IUnknown Methods
  101. // ----------------------------------------------------------------------------
  102. STDMETHODIMP QueryInterface(REFIID riid, LPVOID *ppv);
  103. STDMETHODIMP_(ULONG) AddRef(void);
  104. STDMETHODIMP_(ULONG) Release(void);
  105. // ----------------------------------------------------------------------------
  106. // IOutlookExpress Methods
  107. // ----------------------------------------------------------------------------
  108. STDMETHODIMP Start(DWORD dwFlags, LPCWSTR pwszCmdLine, INT nCmdShow);
  109. // ----------------------------------------------------------------------------
  110. // Initialize / Uninitialize
  111. // ----------------------------------------------------------------------------
  112. #ifdef DEBUG
  113. HRESULT CoIncrementInitDebug(LPCSTR pwszSource, DWORD dwFlags, LPCWSTR pszCmdLine, LPHINITREF phInitRef);
  114. HRESULT CoDecrementInitDebug(LPCSTR pwszSource, LPHINITREF phInitRef);
  115. #endif // DEBUG
  116. HRESULT CoIncrementInitImpl(DWORD dwFlags, LPCWSTR pwszCmdLine, LPHINITREF phInitRef);
  117. HRESULT CoDecrementInitImpl(LPHINITREF phInitRef);
  118. // ----------------------------------------------------------------------------
  119. // DllAddRef / DllRelease
  120. // ----------------------------------------------------------------------------
  121. HRESULT DllAddRef(void);
  122. HRESULT DllRelease(void);
  123. // ----------------------------------------------------------------------------
  124. // LockServer - Called from CClassFactory Implementation
  125. // ----------------------------------------------------------------------------
  126. HRESULT LockServer(BOOL fLock);
  127. // ----------------------------------------------------------------------------
  128. // DllCanUnloadNow
  129. // ----------------------------------------------------------------------------
  130. HRESULT DllCanUnloadNow(void) {
  131. HRESULT hr;
  132. if ((m_cDllInit <= 0) &&
  133. (m_cDllRef <= 0) &&
  134. (m_cDllLock <= 0))
  135. {
  136. hr = S_OK;
  137. }
  138. else
  139. {
  140. hr = S_FALSE;
  141. }
  142. return hr;
  143. }
  144. // ----------------------------------------------------------------------------
  145. // Defered Init/Deinit Methods
  146. // ----------------------------------------------------------------------------
  147. HRESULT ProcessCommandLine(INT nCmdShow, LPWSTR pwszCmdLineIn, BOOL *pfErrorDisplayed);
  148. HRESULT BrowseToObject(UINT nCmdShow, FOLDERID idFolder);
  149. HRESULT ActivateWindow(HWND hwnd);
  150. // ----------------------------------------------------------------------------
  151. // Multi-user startup/shutdown
  152. // ----------------------------------------------------------------------------
  153. HRESULT SetSwitchingUsers(BOOL bSwitching);
  154. BOOL SwitchingUsers(void) {return m_fSwitchingUsers;}
  155. void SetSwitchToUser(TCHAR *lpszUserName);
  156. // ----------------------------------------------------------------------------
  157. // InitWndProc
  158. // ----------------------------------------------------------------------------
  159. static LRESULT EXPORT_16 CALLBACK InitWndProc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp);
  160. // ----------------------------------------------------------------------------
  161. // Tray Notification Icon Stuff
  162. // ----------------------------------------------------------------------------
  163. HRESULT UpdateTrayIcon(TRAYICONACTION type);
  164. void CloseSplashScreen(void);
  165. private:
  166. // ----------------------------------------------------------------------------
  167. // Private Members
  168. // ----------------------------------------------------------------------------
  169. HRESULT _HandleMailURL(LPWSTR pwszCmdLine, BOOL *pfErrorDisplayed);
  170. HRESULT _HandleNewsURL(INT nCmdShow, LPWSTR pwszCmd, BOOL *pfErrorDisplayed);
  171. HRESULT _HandleFile(LPWSTR pwszCmd, BOOL *pfErrorDisplayed, BOOL fNews);
  172. HRESULT _HandleNewsArticleURL(LPSTR pszServerIn, LPSTR pszArticle, UINT uPort, BOOL fSecure, BOOL *pfErrorDisplayed);
  173. void _HandleTrayIconEvent(WPARAM wParam, LPARAM lParam);
  174. HRESULT _ValidateDll(LPCSTR pszDll, BOOL fDemandResult, HMODULE hModule, HRESULT hrLoadError, HRESULT hrVersionError, LPREPORTERRORINFO pError);
  175. BOOL _ReportError(HINSTANCE hInstance, HRESULT hrResult, LONG lResult, LPREPORTERRORINFO pInfo);
  176. HRESULT _CoDecrementInitMain(LPHINITREF phInitRef=NULL);
  177. void _ProcessCommandLineFlags(LPWSTR *ppwszCmdLine, DWORD dwFlags);
  178. private:
  179. // ----------------------------------------------------------------------------
  180. // PrivateData
  181. // ----------------------------------------------------------------------------
  182. LONG m_cRef; // Reference Count
  183. HANDLE m_hInstMutex; // Startup/Shutdown mutex
  184. BOOL m_fPumpingMsgs; // Do we have a message pump running ?
  185. LONG m_cDllRef; // Dll Reference Count
  186. LONG m_cDllLock; // Dll Reference Count
  187. LONG m_cDllInit; // Number of inits
  188. DWORD m_dwThreadId; // Thread that I was created on
  189. CRITICAL_SECTION m_cs; // Thread Safety
  190. BOOL m_fSwitchingUsers; // Multiple user switch is happening
  191. TCHAR * m_szSwitchToUsername; // Switching to a specific user
  192. HWND m_hwndSplash;
  193. ISplashScreen *m_pSplash;
  194. BOOL m_fIncremented;
  195. HICON m_hTrayIcon;
  196. };
  197. #endif // __INSTANCE_H