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.

248 lines
11 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1997 - 1999
  6. //
  7. // File: update.h
  8. //
  9. //--------------------------------------------------------------------------
  10. #ifndef _UPDATE_H_
  11. #define _UPDATE_H_
  12. #include <mobsync.h>
  13. #include "cscentry.h"
  14. #include "util.h" // ENUM_REASON
  15. #include "nopin.h"
  16. //
  17. // Flags used in CscUpdateCache
  18. //
  19. #define CSC_UPDATE_STARTNOW 0x00000002 // Don't wait for user confirmation to start update
  20. #define CSC_UPDATE_SELECTION 0x00000004 // Update current selection (CSC_NAMELIST_HDR buffer)
  21. #define CSC_UPDATE_PINFILES 0x00000008 // Pin files while updating them
  22. #define CSC_UPDATE_PIN_RECURSE 0x00000010 // Recurse into subfolders when pinning
  23. #define CSC_UPDATE_REINT 0x00000020 // Perform outward reintegration
  24. #define CSC_UPDATE_FILL_QUICK 0x00000040 // Perform quick inward sync (fill sparse files)
  25. #define CSC_UPDATE_FILL_ALL 0x00000080 // Perform full inward sync (overrides CSC_UPDATE_FILL_QUICK)
  26. #define CSC_UPDATE_NOTIFY_DONE 0x00000100 // Send CSCWM_DONESYNCING to notify window when done.
  27. #define CSC_UPDATE_SHOWUI_ALWAYS 0x00000200 // Nothing to sync but show SyncMgr UI anyway.
  28. #define CSC_UPDATE_IGNORE_ACCESS 0x00000400 // Default is to sync files with USER and/or GUEST access.
  29. #define CSC_UPDATE_RECONNECT 0x00000800 // Transition all servers online after syncing
  30. #define CSC_UPDATE_UNATTENDED 0x00001000 // Run sync unattended. Can't prompt user.
  31. HRESULT CscUpdateCache(DWORD dwUpdateFlags, CscFilenameList *pfnl=NULL);
  32. void BuildSilentFolderList(CscFilenameList *pfnlSilentFolders,
  33. CscFilenameList *pfnlSpecialFolders);
  34. class CCscUpdate;
  35. typedef CCscUpdate *PCSCUPDATE;
  36. typedef struct
  37. {
  38. PCSCUPDATE pThis;
  39. SYNCMGRITEMID ItemID;
  40. HANDLE hThread;
  41. LPTSTR pszShareName;
  42. TCHAR szDrive[4];
  43. DWORD dwSyncStatus;
  44. LONG cFilesToSync;
  45. LONG cFilesDone;
  46. CscFilenameList *pUndoExclusionList;
  47. DWORD dwCscContext;
  48. DWORD dwPinHints;
  49. } SYNCTHREADDATA, *PSYNCTHREADDATA;
  50. class CCscUpdate : ISyncMgrSynchronize
  51. {
  52. private:
  53. LONG m_cRef;
  54. CscFilenameList *m_pFileList;
  55. DWORD m_dwSyncFlags;
  56. HDSA m_hSyncItems;
  57. CSCEntryLog m_ShareLog;
  58. LPSYNCMGRSYNCHRONIZECALLBACK m_pSyncMgrCB;
  59. HDPA m_hSyncThreads;
  60. CRITICAL_SECTION m_csThreadList;
  61. BOOL m_bCSInited;
  62. HWND m_hwndDlgParent;
  63. HANDLE m_hSyncMutex;
  64. HANDLE m_hgcSyncInProgress;
  65. BOOL m_bCacheIsEncrypted;
  66. CscFilenameList *m_pConflictPinList;
  67. CscFilenameList *m_pSilentFolderList;
  68. CscFilenameList *m_pSpecialFolderList;
  69. CscFilenameList m_ReconnectList;
  70. CNoPinList m_NoPinList;
  71. private:
  72. CCscUpdate();
  73. ~CCscUpdate();
  74. HRESULT _Init();
  75. public:
  76. static HRESULT WINAPI CreateInstance(REFIID riid, LPVOID *ppv);
  77. // IUnknown methods
  78. STDMETHODIMP QueryInterface(REFIID riid, LPVOID *ppv);
  79. STDMETHODIMP_(ULONG) AddRef();
  80. STDMETHODIMP_(ULONG) Release();
  81. // ISyncMgrSynchronize methods
  82. STDMETHODIMP Initialize(DWORD dwReserved,
  83. DWORD dwSyncFlags,
  84. DWORD cbCookie,
  85. const BYTE *lpCookie);
  86. STDMETHODIMP GetHandlerInfo(LPSYNCMGRHANDLERINFO *ppSyncMgrHandlerInfo);
  87. STDMETHODIMP EnumSyncMgrItems(LPSYNCMGRENUMITEMS *ppenum);
  88. STDMETHODIMP GetItemObject(REFSYNCMGRITEMID rItemID, REFIID riid, LPVOID *ppv);
  89. STDMETHODIMP ShowProperties(HWND hWndParent, REFSYNCMGRITEMID rItemID);
  90. STDMETHODIMP SetProgressCallback(LPSYNCMGRSYNCHRONIZECALLBACK pCallback);
  91. STDMETHODIMP PrepareForSync(ULONG cbNumItems,
  92. SYNCMGRITEMID *pItemIDs,
  93. HWND hWndParent,
  94. DWORD dwReserved);
  95. STDMETHODIMP Synchronize(HWND hWndParent);
  96. STDMETHODIMP SetItemStatus(REFSYNCMGRITEMID pItemID,
  97. DWORD dwSyncMgrStatus);
  98. STDMETHODIMP ShowError(HWND hWndParent,
  99. REFSYNCMGRERRORID ErrorID);
  100. private:
  101. HRESULT LogError(REFSYNCMGRITEMID rItemID,
  102. LPCTSTR pszText,
  103. DWORD dwLogLevel = SYNCMGRLOGLEVEL_ERROR,
  104. REFSYNCMGRERRORID ErrorID = GUID_NULL);
  105. DWORD LogError(REFSYNCMGRITEMID rItemID,
  106. DWORD dwLogLevel,
  107. UINT nFormatID,
  108. ...);
  109. DWORD LogError(REFSYNCMGRITEMID rItemID,
  110. UINT nFormatID,
  111. LPCTSTR pszName,
  112. DWORD dwErr,
  113. DWORD dwLogLevel = SYNCMGRLOGLEVEL_ERROR);
  114. HRESULT SynchronizeShare(SYNCMGRITEMID *pItemID,
  115. LPCTSTR pszShareName,
  116. BOOL bRasConnected);
  117. void SetLastSyncTime(LPCTSTR pszShareName);
  118. DWORD GetLastSyncTime(LPCTSTR pszShareName, LPFILETIME pft);
  119. void SyncThreadCompleted(PSYNCTHREADDATA pSyncData);
  120. void SyncCompleted(void);
  121. DWORD CopyLocalFileWithDriveMapping(LPCTSTR pszSrc,
  122. LPCTSTR pszDst,
  123. LPCTSTR pszShare,
  124. LPCTSTR pszDrive,
  125. BOOL bDirectory = FALSE);
  126. DWORD HandleFileConflict(PSYNCTHREADDATA pSyncData,
  127. LPCTSTR pszName,
  128. DWORD dwStatus,
  129. DWORD dwHintFlags,
  130. LPWIN32_FIND_DATA pFind32);
  131. DWORD HandleDeleteConflict(PSYNCTHREADDATA pSyncData,
  132. LPCTSTR pszName,
  133. DWORD dwStatus,
  134. DWORD dwHintFlags,
  135. LPWIN32_FIND_DATA pFind32);
  136. DWORD CscCallback(PSYNCTHREADDATA pSyncData,
  137. LPCTSTR pszName,
  138. DWORD dwStatus,
  139. DWORD dwHintFlags,
  140. DWORD dwPinCount,
  141. LPWIN32_FIND_DATA pFind32,
  142. DWORD dwReason,
  143. DWORD dwParam1,
  144. DWORD dwParam2);
  145. static void NotifySyncMgr(PSYNCTHREADDATA pSyncData,
  146. LPSYNCMGRPROGRESSITEM pspi);
  147. static DWORD WINAPI _CscCallback(LPCTSTR pszName,
  148. DWORD dwStatus,
  149. DWORD dwHintFlags,
  150. DWORD dwPinCount,
  151. LPWIN32_FIND_DATA pFind32,
  152. DWORD dwReason,
  153. DWORD dwParam1,
  154. DWORD dwParam2,
  155. DWORD_PTR dwContext);
  156. BOOL PinLinkTarget(LPCTSTR pszName, PSYNCTHREADDATA pSyncData);
  157. static DWORD WINAPI _PinNewFilesW32Callback(LPCTSTR pszName,
  158. ENUM_REASON eReason,
  159. LPWIN32_FIND_DATA pFind32,
  160. LPARAM lpContext);
  161. static DWORD WINAPI _PinNewFilesCSCCallback(LPCTSTR pszName,
  162. ENUM_REASON eReason,
  163. DWORD dwStatus,
  164. DWORD dwHintFlags,
  165. DWORD dwPinCount,
  166. LPWIN32_FIND_DATA pFind32,
  167. LPARAM lpContext);
  168. static DWORD WINAPI _SyncThread(LPVOID pThreadData);
  169. DWORD MergeShare(PSYNCTHREADDATA pSyncData);
  170. DWORD FillShare(PSYNCTHREADDATA pSyncData, int cPinned, DWORD dwConnectionSpeed);
  171. void PinFiles(PSYNCTHREADDATA pSyncData, BOOL bConflictPinList=FALSE);
  172. void NotifyUndo(PSYNCTHREADDATA pSyncData, LPCTSTR pszName);
  173. void UndoPinFiles(PSYNCTHREADDATA pSyncData);
  174. static DWORD WINAPI _UndoProgress(LPCTSTR pszItem, LPARAM lpContext);
  175. BOOL SkipEFSPin(PSYNCTHREADDATA pSyncData, LPCTSTR pszItem);
  176. typedef enum
  177. {
  178. SyncStop = 0,
  179. SyncPause,
  180. SyncResume
  181. } eSetSyncStatus;
  182. HRESULT SetSyncThreadStatus(eSetSyncStatus status, REFGUID rItemID);
  183. HRESULT GetSilentFolderList(void);
  184. BOOL IsSilentFolder(LPCTSTR pszName)
  185. { return (m_pSilentFolderList && m_pSilentFolderList->FileExists(pszName, false)); }
  186. BOOL IsSilentShare(LPCTSTR pszShare)
  187. { return (m_pSilentFolderList && m_pSilentFolderList->ShareExists(pszShare)); }
  188. BOOL IsSpecialFolder(LPCTSTR pszName)
  189. { return ((m_pSpecialFolderList && m_pSpecialFolderList->FileExists(pszName, false)) || IsSilentFolder(pszName)); }
  190. BOOL IsSpecialFolderShare(LPCTSTR pszShare)
  191. { return ((m_pSpecialFolderList && m_pSpecialFolderList->ShareExists(pszShare)) || IsSilentShare(pszShare)); }
  192. BOOL ShouldPinRecurse(LPCTSTR pszName);
  193. void _BuildOfflineShareList(CscFilenameList *pfnl);
  194. friend class CUpdateEnumerator;
  195. };
  196. class CUpdateEnumerator : ISyncMgrEnumItems
  197. {
  198. private:
  199. LONG m_cRef;
  200. PCSCUPDATE m_pUpdate;
  201. HANDLE m_hFind;
  202. BOOL m_bEnumFileSelection;
  203. INT m_cCheckedItemsEnumerated;
  204. CscFilenameList::ShareIter m_SelectionIterator;
  205. public:
  206. CUpdateEnumerator(PCSCUPDATE pUpdate);
  207. ~CUpdateEnumerator();
  208. // IUnknown methods
  209. STDMETHODIMP QueryInterface(REFIID, LPVOID*);
  210. STDMETHODIMP_(ULONG) AddRef();
  211. STDMETHODIMP_(ULONG) Release();
  212. // ISyncMgrEnumItems methods
  213. STDMETHODIMP Next(ULONG celt, LPSYNCMGRITEM rgelt, PULONG pceltFetched);
  214. STDMETHODIMP Skip(ULONG celt);
  215. STDMETHODIMP Reset(void);
  216. STDMETHODIMP Clone(LPSYNCMGRENUMITEMS *ppenum);
  217. };
  218. typedef CUpdateEnumerator *PUPDATEENUM;
  219. #endif // _UPDATE_H_