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.

178 lines
8.2 KiB

  1. // =================================================================================
  2. // Common IMailXP macros and stuff
  3. // Written by: Steven J. Bailey on 1/21/96
  4. // =================================================================================
  5. #ifndef __XPCOMM_H
  6. #define __XPCOMM_H
  7. // ------------------------------------------------------------------------------------
  8. // INETMAILERROR
  9. // ------------------------------------------------------------------------------------
  10. typedef struct tagINETMAILERROR {
  11. DWORD dwErrorNumber; // Error Number
  12. HRESULT hrError; // HRESULT of error
  13. LPTSTR pszServer; // Server
  14. LPTSTR pszAccount; // Account
  15. LPTSTR pszMessage; // Actual error message
  16. LPTSTR pszUserName; // User Name
  17. LPTSTR pszProtocol; // protocol smtp or pop3
  18. LPTSTR pszDetails; // Details message
  19. DWORD dwPort; // Port
  20. BOOL fSecure; // Secure ssl conneciton
  21. } INETMAILERROR, *LPINETMAILERROR;
  22. INT_PTR CALLBACK InetMailErrorDlgProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
  23. // =================================================================================
  24. // Defines
  25. // =================================================================================
  26. #define SECONDS_INA_MINUTE (ULONG)60 // Easy
  27. #define SECONDS_INA_HOUR (ULONG)3600 // 60 * 60
  28. #define SECONDS_INA_DAY (ULONG)86400 // 3600 * 24
  29. #define IS_EXTENDED(ch) ((ch > 126 || ch < 32) && ch != '\t' && ch != '\n' && ch != '\r')
  30. // ============================================================================================
  31. // Returns 0 if string is NULL, lstrlen + 1 otherwise
  32. // ============================================================================================
  33. #define SafeStrlen(_psz) (_psz ? lstrlen (_psz) + 1 : 0)
  34. // =================================================================================
  35. // CProgress
  36. // =================================================================================
  37. class CProgress : public IDatabaseProgress, public IStoreCallback
  38. {
  39. public:
  40. //----------------------------------------------------------------------
  41. // Construction
  42. //----------------------------------------------------------------------
  43. CProgress(void);
  44. ~CProgress(void);
  45. //----------------------------------------------------------------------
  46. // IUnknown Members
  47. //----------------------------------------------------------------------
  48. STDMETHODIMP QueryInterface(REFIID riid, LPVOID *ppv) { return E_NOTIMPL; }
  49. STDMETHODIMP_(ULONG) AddRef(void);
  50. STDMETHODIMP_(ULONG) Release(void);
  51. //----------------------------------------------------------------------
  52. // IStoreCallback Members
  53. //----------------------------------------------------------------------
  54. STDMETHODIMP OnBegin(STOREOPERATIONTYPE tyOperation, STOREOPERATIONINFO *pOpInfo, IOperationCancel *pCancel) { return(E_NOTIMPL); }
  55. STDMETHODIMP OnTimeout(LPINETSERVER pServer, LPDWORD pdwTimeout, IXPTYPE ixpServerType) { return(E_NOTIMPL); }
  56. STDMETHODIMP CanConnect(LPCSTR pszAccountId, DWORD dwFlags) { return(E_NOTIMPL); }
  57. STDMETHODIMP OnLogonPrompt(LPINETSERVER pServer, IXPTYPE ixpServerType) { return(E_NOTIMPL); }
  58. STDMETHODIMP OnComplete(STOREOPERATIONTYPE tyOperation, HRESULT hrComplete, LPSTOREOPERATIONINFO pOpInfo, LPSTOREERROR pErrorInfo) { return(E_NOTIMPL); }
  59. STDMETHODIMP OnPrompt(HRESULT hrError, LPCTSTR pszText, LPCTSTR pszCaption, UINT uType, INT *piUserResponse) { return(E_NOTIMPL); }
  60. STDMETHODIMP GetParentWindow(DWORD dwReserved, HWND *phwndParent) { return(E_NOTIMPL); }
  61. STDMETHODIMP OnProgress(STOREOPERATIONTYPE tyOperation, DWORD dwCurrent, DWORD dwMax, LPCSTR pszStatus)
  62. {
  63. if (0 == m_cMax)
  64. AdjustMax(dwMax);
  65. ULONG cIncrement = (dwCurrent - m_cLast);
  66. HRESULT hr = HrUpdate(cIncrement);
  67. m_cLast = dwCurrent;
  68. return(hr);
  69. }
  70. //----------------------------------------------------------------------
  71. // IDatabaseProgress Members
  72. //----------------------------------------------------------------------
  73. STDMETHODIMP Update(DWORD cCount) { return HrUpdate(1); }
  74. //----------------------------------------------------------------------
  75. // CProgress Members
  76. //----------------------------------------------------------------------
  77. void SetMsg(LPTSTR lpszMsg);
  78. void SetTitle(LPTSTR lpszTitle);
  79. void Show(DWORD dwDelaySeconds=0);
  80. void Hide(void);
  81. void Close(void);
  82. void AdjustMax(ULONG cNewMax);
  83. void Reset(void);
  84. HWND GetHwnd(void) { return (m_hwndDlg); }
  85. HRESULT HrUpdate (ULONG cInc);
  86. static INT_PTR CALLBACK ProgressDlgProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
  87. void Init(HWND hwndParent, LPTSTR lpszTitle, LPTSTR lpszMsg, ULONG cMax, UINT idani, BOOL fCanCancel, BOOL fBacktrackParent=TRUE);
  88. private:
  89. //----------------------------------------------------------------------
  90. // Private Data
  91. //----------------------------------------------------------------------
  92. ULONG m_cRef;
  93. ULONG m_cLast;
  94. ULONG m_cMax;
  95. ULONG m_cCur;
  96. ULONG m_cPerCur;
  97. HWND m_hwndProgress;
  98. HWND m_hwndDlg;
  99. HWND m_hwndOwner;
  100. HWND m_hwndDisable;
  101. BOOL m_fCanCancel;
  102. BOOL m_fHasCancel;
  103. };
  104. // =================================================================================
  105. // Max Message String
  106. // =================================================================================
  107. #define MAX_MESSAGE_STRING 255
  108. #define MAX_RESOURCE_STRING 255
  109. #define MAX_REG_VALUE_STR 1024
  110. #define MAX_TEXT_STM_BUFFER_STR 4096
  111. // =================================================================================
  112. // Detailed Error Struct
  113. // =================================================================================
  114. typedef struct tagDETERR {
  115. LPTSTR lpszMessage;
  116. LPTSTR lpszDetails;
  117. UINT idsTitle;
  118. RECT rc;
  119. BOOL fHideDetails;
  120. } DETERR, *LPDETERR;
  121. // Blob parsing
  122. HRESULT HrBlobReadData (LPBYTE lpBlob, ULONG cbBlob, ULONG *pib, LPBYTE lpbData, ULONG cbData);
  123. HRESULT HrBlobWriteData (LPBYTE lpBlob, ULONG cbBlob, ULONG *pib, LPBYTE lpbData, ULONG cbData);
  124. // String Parsing Functions
  125. VOID StripSpaces(LPTSTR psz);
  126. LPTSTR SzGetSearchTokens(LPTSTR pszCriteria);;
  127. HRESULT HrCopyAlloc (LPBYTE *lppbDest, LPBYTE lpbSrc, ULONG cb);
  128. LPTSTR StringDup (LPCTSTR lpcsz);
  129. BOOL FIsStringEmpty (LPTSTR lpszString);
  130. BOOL FIsStringEmptyW(LPWSTR lpwszString);
  131. void SkipWhitespace (LPCTSTR lpcsz, ULONG *pi);
  132. BOOL FStringTok (LPCTSTR lpcszString, ULONG *piString, LPTSTR lpcszTokens, TCHAR *chToken, LPTSTR lpszValue, ULONG cbValueMax, BOOL fStripTrailingWhitespace);
  133. #ifdef DEAD
  134. ULONG UlDBCSStripWhitespace (LPSTR lpsz, BOOL fLeading, BOOL fTrailing, ULONG *pcb);
  135. #endif // DEAD
  136. LPTSTR SzNormalizeSubject (LPTSTR lpszSubject);
  137. LPTSTR SzFindChar (LPCTSTR lpcsz, TCHAR ch);
  138. WORD NFromSz (LPCTSTR lpcsz);
  139. UINT AthUFromSz(LPCTSTR lpcsz);
  140. VOID ProcessNlsError (VOID);
  141. // Networking Functions
  142. LPSTR SzGetLocalHostName (VOID);
  143. LPTSTR SzGetLocalPackedIP (VOID);
  144. LPSTR SzGetLocalHostNameForID (VOID);
  145. HRESULT HrFixupHostString (LPTSTR lpszHost);
  146. HRESULT HrFixupAccountString (LPTSTR lpszAccount);
  147. LPTSTR SzStrAlloc (ULONG cch);
  148. // Whatever
  149. HFONT HGetMenuFont (void);
  150. VOID DetailedError (HWND hwndParent, LPDETERR lpDetErr);
  151. ULONG UlDateDiff (LPFILETIME lpft1, LPFILETIME lpft2);
  152. BOOL FIsLeapYear (INT nYear);
  153. VOID ResizeDialogComboEx (HWND hwndDlg, HWND hwndCombo, UINT idcBase, HIMAGELIST himl);
  154. VOID StripIllegalHostChars(LPSTR pszSrc, LPTSTR pszDst);
  155. #ifdef DEBUG
  156. VOID TestDateDiff (VOID);
  157. #endif
  158. #endif // _COMMON_HPP