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.

149 lines
8.6 KiB

  1. //--------------------------------------------------------------------------
  2. // FindFold.h
  3. //--------------------------------------------------------------------------
  4. #pragma once
  5. //--------------------------------------------------------------------------
  6. // Depends
  7. //--------------------------------------------------------------------------
  8. #include "dbimpl.h"
  9. //--------------------------------------------------------------------------
  10. // ACTIVEFINDFOLDER
  11. //--------------------------------------------------------------------------
  12. class CFindFolder;
  13. typedef struct tagACTIVEFINDFOLDER *LPACTIVEFINDFOLDER;
  14. typedef struct tagACTIVEFINDFOLDER {
  15. FOLDERID idFolder;
  16. CFindFolder *pFolder;
  17. LPACTIVEFINDFOLDER pNext;
  18. } ACTIVEFINDFOLDER;
  19. //--------------------------------------------------------------------------
  20. // FOLDERENTRY
  21. //--------------------------------------------------------------------------
  22. typedef struct tagFOLDERENTRY {
  23. LPSTR pszName;
  24. DWORD cRecords;
  25. BOOL fInDeleted;
  26. FOLDERID idFolder;
  27. FOLDERTYPE tyFolder;
  28. IDatabase *pDB;
  29. IMessageFolder *pFolder; // Used only for Opening messages...
  30. } FOLDERENTRY, *LPFOLDERENTRY;
  31. //--------------------------------------------------------------------------
  32. // CFindFolder
  33. //--------------------------------------------------------------------------
  34. class CFindFolder : public IMessageFolder,
  35. public IDatabaseNotify,
  36. public IStoreCallback,
  37. public IServiceProvider,
  38. public IOperationCancel
  39. {
  40. public:
  41. //----------------------------------------------------------------------
  42. // Construction
  43. //----------------------------------------------------------------------
  44. CFindFolder(void);
  45. ~CFindFolder(void);
  46. //----------------------------------------------------------------------
  47. // IUnknown Members
  48. //----------------------------------------------------------------------
  49. STDMETHODIMP QueryInterface(REFIID riid, LPVOID *ppv);
  50. STDMETHODIMP_(ULONG) AddRef(void);
  51. STDMETHODIMP_(ULONG) Release(void);
  52. //----------------------------------------------------------------------
  53. // IMessageFolder Members
  54. //----------------------------------------------------------------------
  55. STDMETHODIMP Initialize(IMessageStore *pStore, IMessageServer *pServer, OPENFOLDERFLAGS dwFlags, FOLDERID idFolder);
  56. STDMETHODIMP SetOwner(IStoreCallback *pDefaultCallback) { return E_NOTIMPL; }
  57. STDMETHODIMP Close() { return S_OK; }
  58. STDMETHODIMP GetFolderId(LPFOLDERID pidFolder) { *pidFolder = m_idFolder; return S_OK; }
  59. STDMETHODIMP GetMessageFolderId(MESSAGEID idMessage, LPFOLDERID pidFolder);
  60. STDMETHODIMP Synchronize(SYNCFOLDERFLAGS dwFlags, DWORD cHeaders, IStoreCallback *pCallback) { return E_NOTIMPL; }
  61. STDMETHODIMP OpenMessage(MESSAGEID idMessage, OPENMESSAGEFLAGS dwFlags, IMimeMessage **ppMessage, IStoreCallback *pCallback);
  62. STDMETHODIMP SaveMessage(LPMESSAGEID pidMessage, SAVEMESSAGEFLAGS dwOptions, MESSAGEFLAGS dwFlags, IStream *pStream, IMimeMessage *pMessage, IStoreCallback *pCallback);
  63. STDMETHODIMP SetMessageStream(MESSAGEID idMessage, IStream *pStream) { return E_NOTIMPL; }
  64. STDMETHODIMP SetMessageFlags(LPMESSAGEIDLIST pList, LPADJUSTFLAGS pFlags, LPRESULTLIST pResults, IStoreCallback *pCallback);
  65. STDMETHODIMP CopyMessages(IMessageFolder *pDest, COPYMESSAGEFLAGS dwFlags, LPMESSAGEIDLIST pList, LPADJUSTFLAGS pFlags, LPRESULTLIST pResults, IStoreCallback *pCallback);
  66. STDMETHODIMP DeleteMessages(DELETEMESSAGEFLAGS dwFlags, LPMESSAGEIDLIST pList, LPRESULTLIST pResults, IStoreCallback *pCallback);
  67. STDMETHODIMP ConnectionAddRef();
  68. STDMETHODIMP ConnectionRelease();
  69. STDMETHODIMP GetDatabase(IDatabase **ppDB) { return m_pSearch->GetDatabase(ppDB); }
  70. STDMETHODIMP ResetFolderCounts(DWORD cMessages, DWORD cUnread, DWORD cWatchedUnread, DWORD cWatched) { return(S_OK); }
  71. STDMETHODIMP IsWatched(LPCSTR pszReferences, LPCSTR pszSubject) { return m_pSearch->IsWatched(pszReferences, pszSubject); }
  72. STDMETHODIMP GetAdBarUrl(IStoreCallback *pCallback) { return E_NOTIMPL; }
  73. //----------------------------------------------------------------------
  74. // IServiceProvider
  75. //----------------------------------------------------------------------
  76. STDMETHODIMP QueryService(REFGUID guidService, REFIID riid, LPVOID *ppvObject);
  77. //----------------------------------------------------------------------
  78. // IStoreCallback Members
  79. //----------------------------------------------------------------------
  80. STDMETHODIMP OnBegin(STOREOPERATIONTYPE tyOperation, STOREOPERATIONINFO *pOpInfo, IOperationCancel *pCancel) { return(E_NOTIMPL); }
  81. STDMETHODIMP OnProgress(STOREOPERATIONTYPE tyOperation, DWORD dwCurrent, DWORD dwMax, LPCSTR pszStatus) { return(E_NOTIMPL); }
  82. STDMETHODIMP OnTimeout(LPINETSERVER pServer, LPDWORD pdwTimeout, IXPTYPE ixpServerType) { return(E_NOTIMPL); }
  83. STDMETHODIMP CanConnect(LPCSTR pszAccountId, DWORD dwFlags) { return(E_NOTIMPL); }
  84. STDMETHODIMP OnLogonPrompt(LPINETSERVER pServer, IXPTYPE ixpServerType) { return(E_NOTIMPL); }
  85. STDMETHODIMP OnComplete(STOREOPERATIONTYPE tyOperation, HRESULT hrComplete, LPSTOREOPERATIONINFO pOpInfo, LPSTOREERROR pErrorInfo) { return(E_NOTIMPL); }
  86. STDMETHODIMP OnPrompt(HRESULT hrError, LPCTSTR pszText, LPCTSTR pszCaption, UINT uType, INT *piUserResponse) { return(E_NOTIMPL); }
  87. STDMETHODIMP GetParentWindow(DWORD dwReserved, HWND *phwndParent) { return(E_NOTIMPL); }
  88. //----------------------------------------------------------------------
  89. // IOperationCancel
  90. //----------------------------------------------------------------------
  91. STDMETHODIMP Cancel(CANCELTYPE tyCancel) { m_fCancel = TRUE; return(S_OK); }
  92. //----------------------------------------------------------------------
  93. // IDatabase Members
  94. //----------------------------------------------------------------------
  95. IMPLEMENT_IDATABASE(FALSE, m_pSearch)
  96. //----------------------------------------------------------------------
  97. // IDatabaseNotify
  98. //----------------------------------------------------------------------
  99. STDMETHODIMP OnTransaction(HTRANSACTION hTransaction, DWORD_PTR dwCookie, IDatabase *pDB);
  100. //----------------------------------------------------------------------
  101. // CFindFolder
  102. //----------------------------------------------------------------------
  103. HRESULT StartFind(LPFINDINFO pCriteria, IStoreCallback *pCallback);
  104. HRESULT GetMessageFolderType(MESSAGEID idMessage, FOLDERTYPE *ptyFolder);
  105. private:
  106. //----------------------------------------------------------------------
  107. // Private Methods
  108. //----------------------------------------------------------------------
  109. HRESULT _StartFind(void);
  110. HRESULT _SearchFolder(DWORD iFolder);
  111. HRESULT _IsMatch(DWORD iFolder, LPMESSAGEINFO pMessage);
  112. HRESULT _OnInsert(DWORD iFolder, LPMESSAGEINFO pMessage, BOOL *pfMatch, LPMESSAGEID pidNew=NULL);
  113. HRESULT _OnDelete(DWORD iFolder, LPMESSAGEINFO pInfo);
  114. HRESULT _OnUpdate(DWORD iFolder, LPMESSAGEINFO pInfo1, LPMESSAGEINFO pInfo2);
  115. HRESULT _FreeIdListArray(LPMESSAGEIDLIST *pprgList);
  116. HRESULT _CollateIdList(LPMESSAGEIDLIST pList, LPMESSAGEIDLIST *pprgCollated, BOOL *pfSomeInDeleted);
  117. private:
  118. //----------------------------------------------------------------------
  119. // Private Data
  120. //----------------------------------------------------------------------
  121. LONG m_cRef; // Reference Counting
  122. FOLDERID m_idRoot; // Root Folder Id to Search
  123. FOLDERID m_idFolder; // Temporary Search Folder Id
  124. DWORD m_cFolders; // Number of Folders we are looking at...
  125. DWORD m_cAllocated; // Number of allocated elements in m_prgFolder
  126. DWORD m_cMax; // Max Number of Records to Query
  127. DWORD m_cCur; // Current number of records queried
  128. BYTE m_fCancel; // Was IOperationCancel Called ?
  129. LPFOLDERENTRY m_prgFolder; // Array of folders to search
  130. LPFINDINFO m_pCriteria; // Criteria To perform Find With
  131. IMessageFolder *m_pSearch; // Search Folder
  132. IMessageStore *m_pStore; // My Store Object
  133. IStoreCallback *m_pCallback; // The Callback (Usually to the Finder Dialog)
  134. IMimeMessage *m_pMessage; // Reusable mime message for searching
  135. };