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.

171 lines
7.6 KiB

  1. #ifndef __FLDRSYNC_H
  2. #define __FLDRSYNC_H
  3. #include <conman.h>
  4. class CFolderSync;
  5. enum
  6. {
  7. COPY_STATE_OPEN = 0,
  8. COPY_STATE_SAVE,
  9. COPY_STATE_SAVE2,
  10. COPY_STATE_DELETE,
  11. COPY_STATE_DELETE2,
  12. COPY_STATE_DONE
  13. };
  14. enum
  15. {
  16. CONN_STATE_CONNECTED = 0,
  17. CONN_STATE_NOT_CONNECTED,
  18. CONN_STATE_OFFLINE
  19. };
  20. typedef HRESULT (CFolderSync::*PFNCOPYFUNC)(THIS_ void);
  21. typedef struct tagCOPYINFO
  22. {
  23. DWORD state;
  24. HRESULT hr;
  25. CANCELTYPE tyCancel;
  26. STOREOPERATIONTYPE type;
  27. BOOL fDownloadFail;
  28. IMessageFolder *pDest;
  29. IMessageFolder *pDestLocal;
  30. LPMESSAGEIDLIST pList;
  31. ADJUSTFLAGS AdjustFlags;
  32. IStoreCallback *pCallback;
  33. STOREERROR *pErrorInfo;
  34. BOOL fAsync;
  35. BOOL fBegin;
  36. BOOL fMove;
  37. DWORD iMsg;
  38. BOOL fSrcOffline;
  39. BOOL fDestOffline;
  40. IStream *pStream;
  41. BOOL fSrcRequested;
  42. } COPYINFO;
  43. //--------------------------------------------------------------------------
  44. // CFolderSync
  45. //--------------------------------------------------------------------------
  46. class CFolderSync :
  47. public IMessageFolder,
  48. public IServiceProvider,
  49. public IStoreCallback,
  50. public IOperationCancel,
  51. public IConnectionNotify
  52. {
  53. public:
  54. //----------------------------------------------------------------------
  55. // Construction
  56. //----------------------------------------------------------------------
  57. CFolderSync(void);
  58. ~CFolderSync(void);
  59. //----------------------------------------------------------------------
  60. // IUnknown Members
  61. //----------------------------------------------------------------------
  62. STDMETHODIMP QueryInterface(REFIID riid, LPVOID *ppv);
  63. STDMETHODIMP_(ULONG) AddRef(void);
  64. STDMETHODIMP_(ULONG) Release(void);
  65. //----------------------------------------------------------------------
  66. // IMessageFolder Members
  67. //----------------------------------------------------------------------
  68. STDMETHODIMP Initialize(IMessageStore *pStore, IMessageServer *pServer, OPENFOLDERFLAGS dwFlags, FOLDERID idFolder);
  69. STDMETHODIMP SetOwner(IStoreCallback *pDefaultCallback);
  70. STDMETHODIMP Close();
  71. STDMETHODIMP GetFolderId(LPFOLDERID pidFolder);
  72. STDMETHODIMP GetMessageFolderId(MESSAGEID idMessage, LPFOLDERID pidFolder);
  73. STDMETHODIMP Synchronize(SYNCFOLDERFLAGS dwFlags, DWORD cHeaders, IStoreCallback *pCallback);
  74. STDMETHODIMP OpenMessage(MESSAGEID idMessage, OPENMESSAGEFLAGS dwFlags, IMimeMessage **ppMessage, IStoreCallback *pCallback);
  75. STDMETHODIMP SaveMessage(LPMESSAGEID pidMessage, SAVEMESSAGEFLAGS dwOptions, MESSAGEFLAGS dwFlags, IStream *pStream, IMimeMessage *pMessage, IStoreCallback *pCallback);
  76. STDMETHODIMP SetMessageStream(MESSAGEID idMessage, IStream *pStream);
  77. STDMETHODIMP SetMessageFlags(LPMESSAGEIDLIST pList, LPADJUSTFLAGS pFlags, LPRESULTLIST pResults, IStoreCallback *pCallback);
  78. STDMETHODIMP CopyMessages(IMessageFolder *pDest, COPYMESSAGEFLAGS dwFlags, LPMESSAGEIDLIST pList, LPADJUSTFLAGS pFlags, LPRESULTLIST pResults, IStoreCallback *pCallback);
  79. STDMETHODIMP DeleteMessages(DELETEMESSAGEFLAGS dwFlags, LPMESSAGEIDLIST pList, LPRESULTLIST pResults, IStoreCallback *pCallback);
  80. STDMETHODIMP DoFolderCounts(BOOL fDoCounts);
  81. STDMETHODIMP ConnectionAddRef();
  82. STDMETHODIMP ConnectionRelease();
  83. STDMETHODIMP GetDatabase(IDatabase **ppDB) { return m_pFldr->GetDatabase(ppDB); }
  84. STDMETHODIMP ResetFolderCounts(DWORD cMessages, DWORD cUnread, DWORD cWatchedUnread, DWORD cWatched) { return m_pFldr->ResetFolderCounts(cMessages, cUnread, cWatchedUnread, cWatched); }
  85. STDMETHODIMP IsWatched(LPCSTR pszReferences, LPCSTR pszSubject) { return m_pFldr->IsWatched(pszReferences, pszSubject); }
  86. STDMETHODIMP GetAdBarUrl(IStoreCallback *pCallback);
  87. //----------------------------------------------------------------------
  88. // IDatabase Members
  89. //----------------------------------------------------------------------
  90. IMPLEMENT_IDATABASE(TRUE, m_pFldr);
  91. //----------------------------------------------------------------------
  92. // IServiceProvider
  93. //----------------------------------------------------------------------
  94. STDMETHODIMP QueryService(REFGUID guidService, REFIID riid, LPVOID *ppvObject);
  95. //----------------------------------------------------------------------
  96. // IStoreCallback
  97. //----------------------------------------------------------------------
  98. HRESULT STDMETHODCALLTYPE OnBegin(STOREOPERATIONTYPE tyOperation, STOREOPERATIONINFO *pOpInfo, IOperationCancel *pCancel);
  99. HRESULT STDMETHODCALLTYPE OnProgress(STOREOPERATIONTYPE tyOperation, DWORD dwCurrent, DWORD dwMax, LPCSTR pszStatus);
  100. HRESULT STDMETHODCALLTYPE OnTimeout(LPINETSERVER pServer, LPDWORD pdwTimeout, IXPTYPE ixpServerType);
  101. HRESULT STDMETHODCALLTYPE CanConnect(LPCSTR pszAccountId, DWORD dwFlags);
  102. HRESULT STDMETHODCALLTYPE OnLogonPrompt(LPINETSERVER pServer, IXPTYPE ixpServerType);
  103. HRESULT STDMETHODCALLTYPE OnComplete(STOREOPERATIONTYPE tyOperation, HRESULT hrComplete, LPSTOREOPERATIONINFO pOpInfo, LPSTOREERROR pErrorInfo);
  104. HRESULT STDMETHODCALLTYPE OnPrompt(HRESULT hrError, LPCTSTR pszText, LPCTSTR pszCaption, UINT uType, INT *piUserResponse);
  105. HRESULT STDMETHODCALLTYPE GetParentWindow(DWORD dwReserved, HWND *phwndParent);
  106. //----------------------------------------------------------------------
  107. // IOperationCancel
  108. //----------------------------------------------------------------------
  109. HRESULT STDMETHODCALLTYPE Cancel(CANCELTYPE tyCancel);
  110. //----------------------------------------------------------------------
  111. // IConnectionNotify
  112. //----------------------------------------------------------------------
  113. STDMETHODIMP OnConnectionNotify(CONNNOTIFY nCode, LPVOID pvData, CConnectionManager *pConMan);
  114. // CFolderSync
  115. HRESULT Initialize(IMessageStore *pStore, IMessageFolder *pLocalFolder, IMessageServer *pServer, OPENFOLDERFLAGS dwFlags, FOLDERTYPE tyFolder, FOLDERID idFolder, FOLDERID idServer);
  116. HRESULT CopyOpen(void);
  117. HRESULT CopySave(void);
  118. HRESULT CopySave2(void);
  119. HRESULT CopyDelete(void);
  120. HRESULT CopyDelete2(void);
  121. static LRESULT CALLBACK FolderSyncWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
  122. private:
  123. //----------------------------------------------------------------------
  124. // Private Methods
  125. //----------------------------------------------------------------------
  126. HRESULT _Offline(DWORD *pdwState);
  127. HRESULT _OfflineServer(FOLDERID idServer, DWORD *pdwState);
  128. HRESULT _CopyMessageState(void);
  129. void _FreeCopyInfo(void);
  130. private:
  131. //----------------------------------------------------------------------
  132. // Private Data
  133. //----------------------------------------------------------------------
  134. LONG m_cRef; // Ref Count
  135. FOLDERTYPE m_tyFolder; // Type of folder I'm In
  136. FOLDERID m_idFolder; // Folder Id
  137. FOLDERID m_idServer;
  138. char m_szAcctId[CCHMAX_ACCOUNT_NAME];
  139. IMessageFolder *m_pFldr; // local message folder
  140. IMessageStore *m_pLocalStore; // Store Object
  141. IMessageServer *m_pServer;
  142. BOOL m_fConManAdvise;
  143. HWND m_hwnd;
  144. COPYINFO *m_pCopy;
  145. BOOL m_fImap; // IMAP special-casing lives!
  146. };
  147. #endif // __FLDRSYNC_H