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.

333 lines
15 KiB

  1. // HotSync.h
  2. //
  3. // Definitions for WAB <-> HotMail synchronization
  4. //
  5. #ifndef __hotsync_h__
  6. #define __hotsync_h__
  7. #include "imnxport.h"
  8. #include <wab.h>
  9. #include "ui_cflct.h"
  10. #define CBIHTTPCALLBACK sizeof(IHTTPCALLBACK)
  11. #define WAB_IHTTPCALLBACK_METHODS(IPURE) \
  12. MAPIMETHOD(OnTimeout)( \
  13. THIS_ \
  14. /* [out][in] */ DWORD FAR *pdwTimeout, \
  15. /* [in] */ IInternetTransport FAR *pTransport) IPURE; \
  16. MAPIMETHOD(OnLogonPrompt)( \
  17. THIS_ \
  18. /* [out][in] */ LPINETSERVER pInetServer, \
  19. /* [in] */ IInternetTransport FAR *pTransport) IPURE; \
  20. MAPIMETHOD(OnPrompt)( \
  21. THIS_ \
  22. /* [in] */ HRESULT hrError, \
  23. /* [in] */ LPCTSTR pszText, \
  24. /* [in] */ LPCTSTR pszCaption, \
  25. /* [in] */ UINT uType, \
  26. /* [in] */ IInternetTransport FAR *pTransport) IPURE; \
  27. MAPIMETHOD(OnStatus)( \
  28. THIS_ \
  29. /* [in] */ IXPSTATUS ixpstatus, \
  30. /* [in] */ IInternetTransport FAR *pTransport) IPURE; \
  31. MAPIMETHOD(OnError)( \
  32. THIS_ \
  33. /* [in] */ IXPSTATUS ixpstatus, \
  34. /* [in] */ LPIXPRESULT pResult, \
  35. /* [in] */ IInternetTransport FAR *pTransport) IPURE; \
  36. MAPIMETHOD(OnCommand)( \
  37. THIS_ \
  38. /* [in] */ CMDTYPE cmdtype, \
  39. /* [in] */ LPSTR pszLine, \
  40. /* [in] */ HRESULT hrResponse, \
  41. /* [in] */ IInternetTransport FAR *pTransport) IPURE; \
  42. MAPIMETHOD(OnResponse)( \
  43. THIS_ \
  44. /* [in] */ LPHTTPMAILRESPONSE pResponse) IPURE; \
  45. #undef INTERFACE
  46. #define INTERFACE IHTTPCallback
  47. DECLARE_MAPI_INTERFACE_(IHTTPCallback, IUnknown)
  48. {
  49. BEGIN_INTERFACE
  50. MAPI_IUNKNOWN_METHODS(PURE)
  51. WAB_IHTTPCALLBACK_METHODS(PURE)
  52. };
  53. DECLARE_MAPI_INTERFACE_PTR(IHTTPCallback, LPHTTPCALLBACK);
  54. #undef INTERFACE
  55. #define INTERFACE struct _IHTTPCALLBACK
  56. #undef METHOD_PREFIX
  57. #define METHOD_PREFIX IHTTPCALLBACK_
  58. #undef LPVTBL_ELEM
  59. #define LPVTBL_ELEM lpvtbl
  60. #undef MAPIMETHOD_
  61. #define MAPIMETHOD_(type, method) MAPIMETHOD_DECLARE(type, method, IHTTPCALLBACK_)
  62. MAPI_IUNKNOWN_METHODS(IMPL)
  63. WAB_IHTTPCALLBACK_METHODS(IMPL)
  64. #undef MAPIMETHOD_
  65. #define MAPIMETHOD_(type, method) MAPIMETHOD_TYPEDEF(type, method, IHTTPCALLBACK_)
  66. MAPI_IUNKNOWN_METHODS(IMPL)
  67. WAB_IHTTPCALLBACK_METHODS(IMPL)
  68. #undef MAPIMETHOD_
  69. #define MAPIMETHOD_(type, method) STDMETHOD_(type, method)
  70. DECLARE_MAPI_INTERFACE(IHTTPCALLBACK_)
  71. {
  72. BEGIN_INTERFACE
  73. MAPI_IUNKNOWN_METHODS(IMPL)
  74. WAB_IHTTPCALLBACK_METHODS(IMPL)
  75. };
  76. typedef struct tagSyncOp HOTSYNCOP, *LPHOTSYNCOP; // forward declaration
  77. enum tagSYNCHSTATE
  78. { SYNC_STATE_INITIALIZING = 0,
  79. SYNC_STATE_SERVER_CONTACT_DISCOVERY = SYNC_STATE_INITIALIZING + 1,
  80. SYNC_STATE_PROCESS_OPS = SYNC_STATE_SERVER_CONTACT_DISCOVERY + 1,
  81. SYNC_STATE_PROCESS_CONFLICTS = SYNC_STATE_PROCESS_OPS + 1,
  82. SYNC_STATE_PROCESS_MERGED_CONFLICTS = SYNC_STATE_PROCESS_CONFLICTS + 1,
  83. SYNC_STATE_DONE = SYNC_STATE_PROCESS_MERGED_CONFLICTS + 1
  84. } SYNCSTATE;
  85. enum tagOPSTATE
  86. { OP_STATE_INITIALIZING = 0,
  87. OP_STATE_SERVER_GET = OP_STATE_INITIALIZING + 1,
  88. OP_STATE_LOADED = OP_STATE_SERVER_GET + 1,
  89. OP_STATE_MERGED = OP_STATE_LOADED + 1,
  90. OP_STATE_SERVER_PUT = OP_STATE_MERGED + 1,
  91. OP_STATE_DONE = OP_STATE_SERVER_PUT + 1
  92. } OPSTATE;
  93. typedef int (__cdecl*FnCompareFunc)(const void*lpvA, const void *lpvB);
  94. typedef struct tagVector
  95. {
  96. DWORD m_cItems;
  97. DWORD m_cSpaces;
  98. DWORD m_dwGrowBy;
  99. LPVOID *m_pItems;
  100. } VECTOR, *LPVECTOR;
  101. HRESULT Vector_Create(LPVECTOR *ppVector);
  102. void Vector_Delete(LPVECTOR pVector);
  103. DWORD Vector_GetLength(LPVECTOR pVector);
  104. HRESULT Vector_AddItem(LPVECTOR pVector, LPVOID lpvItem);
  105. void Vector_Remove(LPVECTOR pVector, LPVOID lpvItem);
  106. void Vector_RemoveItem(LPVECTOR pVector, DWORD dwIndex);
  107. LPVOID Vector_GetItem(LPVECTOR pVector, DWORD dwIndex);
  108. void Vector_Sort(LPVECTOR pVector, FnCompareFunc lpfnCompare);
  109. HRESULT CopyMultiValueString(
  110. SWStringArray *pInArray,
  111. SLPSTRArray **ppOutArray);
  112. HRESULT FreeMultiValueString(SLPSTRArray *pInArray);
  113. HRESULT SetMultiValueStringValue(SLPSTRArray *pInArray, LPSTR szStr, DWORD dwIndex);
  114. HRESULT AppendToMultiValueString(SLPSTRArray *pInArray, LPSTR szStr);
  115. typedef struct tagWabSync
  116. {
  117. IHTTPMailCallbackVtbl FAR *vtbl;
  118. LONG m_cRef; // Reference Counting
  119. DWORD m_state;
  120. HWND m_hWnd;
  121. HWND m_hParentWnd;
  122. IAddrBook *m_pAB;
  123. IHTTPMailTransport *m_pTransport;
  124. IXPSTATUS m_ixpStatus;
  125. INETSERVER m_rInetServerInfo;
  126. BOOL m_fAborted;
  127. BOOL m_fSkipped;
  128. #ifdef HM_GROUP_SYNCING
  129. BOOL m_fSyncGroups;
  130. #endif
  131. DWORD m_cTotalOps;
  132. LPVECTOR m_pOps;
  133. LPVECTOR m_pWabItems;
  134. char m_szLoginName[256];
  135. DWORD m_cAborts;
  136. DWORD m_dwServerID;
  137. FILETIME m_ftLastSync;
  138. LPSTR m_pszRootUrl;
  139. LPSTR m_pszAccountId;
  140. } WABSYNC, *LPWABSYNC;
  141. typedef HRESULT (*FnHandleResponse)(LPHOTSYNCOP pSyncOp, LPHTTPMAILRESPONSE pResponse);
  142. typedef HRESULT (*FnBeginOp)(LPHOTSYNCOP pSyncOp);
  143. typedef struct
  144. {
  145. LPSTR pszHotmailHref;
  146. LPSTR pszHotmailId;
  147. LPSTR pszModHotmail;
  148. SLPSTRArray *pszaContactIds;
  149. SLPSTRArray *pszaServerIds;
  150. SLPSTRArray *pszaModtimes;
  151. SLPSTRArray *pszaEmails;
  152. DWORD dwEmailIndex;
  153. LPENTRYID lpEID;
  154. ULONG cbEID;
  155. FILETIME ftModWab;
  156. #ifdef HM_GROUP_SYNCING
  157. ULONG ulContactType;
  158. #endif
  159. BOOL fDelete;
  160. } WABCONTACTINFO, *LPWABCONTACTINFO;
  161. void WABContact_Delete(LPWABCONTACTINFO pContact);
  162. struct tagSyncOp
  163. {
  164. BYTE m_bOpType;
  165. BYTE m_bState;
  166. DWORD m_dwRetries;
  167. BOOL m_fPartialSkip;
  168. IHTTPMailCallback *m_pHotSync;
  169. IHTTPMailTransport *m_pTransport;
  170. FnHandleResponse m_pfnHandleResponse;
  171. FnBeginOp m_pfnBegin;
  172. LPWABCONTACTINFO m_pContactInfo;
  173. LPHTTPCONTACTINFO m_pServerContact;
  174. LPHTTPCONTACTINFO m_pClientContact;
  175. };
  176. #ifdef HM_GROUP_SYNCING
  177. HRESULT HrSynchronize(HWND hWnd, LPADRBOOK lpIAB, LPCTSTR pszAccountID, BOOL bSyncGroups);
  178. #else
  179. HRESULT HrSynchronize(HWND hWnd, LPADRBOOK lpIAB, LPCTSTR pszAccountID);
  180. #endif
  181. HRESULT WABSync_Create(LPWABSYNC *ppWabSync);
  182. void WABSync_Delete(LPWABSYNC pWabSync);
  183. //----------------------------------------------------------------------
  184. // IUnknown Members
  185. //----------------------------------------------------------------------
  186. STDMETHODIMP WABSync_QueryInterface(IHTTPMailCallback __RPC_FAR * This, REFIID riid, LPVOID *ppv);
  187. STDMETHODIMP_(ULONG) WABSync_AddRef(IHTTPMailCallback __RPC_FAR * This);
  188. STDMETHODIMP_(ULONG) WABSync_Release(IHTTPMailCallback __RPC_FAR * This);
  189. //----------------------------------------------------------------------
  190. // IHTTPMailCallback Members
  191. //----------------------------------------------------------------------
  192. STDMETHODIMP WABSync_OnTimeout (IHTTPMailCallback __RPC_FAR * This, DWORD *pdwTimeout, IInternetTransport *pTransport);
  193. STDMETHODIMP WABSync_OnLogonPrompt (IHTTPMailCallback __RPC_FAR * This, LPINETSERVER pInetServer, IInternetTransport *pTransport);
  194. STDMETHODIMP_(INT) WABSync_OnPrompt (IHTTPMailCallback __RPC_FAR * This, HRESULT hrError, LPCTSTR pszText, LPCTSTR pszCaption, UINT uType, IInternetTransport *pTransport);
  195. STDMETHODIMP WABSync_OnStatus (IHTTPMailCallback __RPC_FAR * This, IXPSTATUS ixpstatus, IInternetTransport *pTransport);
  196. STDMETHODIMP WABSync_OnError (IHTTPMailCallback __RPC_FAR * This, IXPSTATUS ixpstatus, LPIXPRESULT pResult, IInternetTransport *pTransport);
  197. STDMETHODIMP WABSync_OnCommand (IHTTPMailCallback __RPC_FAR * This, CMDTYPE cmdtype, LPSTR pszLine, HRESULT hrResponse, IInternetTransport *pTransport);
  198. STDMETHODIMP WABSync_OnResponse (IHTTPMailCallback __RPC_FAR * This, LPHTTPMAILRESPONSE pResponse);
  199. STDMETHODIMP WABSync_GetParentWindow (IHTTPMailCallback __RPC_FAR *This, HWND *pHwndParent);
  200. //----------------------------------------------------------------------
  201. // Public Members
  202. //----------------------------------------------------------------------
  203. #ifdef HM_GROUP_SYNCING
  204. STDMETHODIMP WABSync_Initialize(LPWABSYNC pWabSync, HWND hWnd, IAddrBook *pAB, LPCTSTR pszAccountID, BOOL bSyncGroups);
  205. #else
  206. STDMETHODIMP WABSync_Initialize(LPWABSYNC pWabSync, HWND hWnd, IAddrBook *pAB, LPCTSTR pszAccountID);
  207. #endif
  208. STDMETHODIMP WABSync_BeginSynchronize(LPWABSYNC pWabSync);
  209. STDMETHODIMP WABSync_Abort(LPWABSYNC pWabSync, HRESULT hr);
  210. STDMETHODIMP WABSync_OperationCompleted(LPWABSYNC pWabSync, LPHOTSYNCOP pOp);
  211. //----------------------------------------------------------------------
  212. // Private Members
  213. //----------------------------------------------------------------------
  214. STDMETHODIMP WABSync_FinishSynchronize(LPWABSYNC pWabSync, HRESULT hr);
  215. STDMETHODIMP WABSync_RequestServerIDList(LPWABSYNC pWabSync);
  216. STDMETHODIMP WABSync_RequestContactsRootProperty(LPWABSYNC pWabSync);
  217. STDMETHODIMP WABSync_HandleContactsRootResponse(LPWABSYNC pWabSync, LPHTTPMAILRESPONSE pResponse);
  218. STDMETHODIMP WABSync_HandleIDListResponse(LPWABSYNC pWabSync, LPHTTPMAILRESPONSE pResponse);
  219. STDMETHODIMP_ (void) WABSync_NextState(LPWABSYNC pWabSync);
  220. STDMETHODIMP_ (BOOL) WABSync_NextOp(LPWABSYNC pWabSync, BOOL fPopFirst);
  221. STDMETHODIMP WABSync_BuildWabContactList(LPWABSYNC pWabSync);
  222. STDMETHODIMP WABSync_LoadLastModInfo(LPWABSYNC pWabSync);
  223. STDMETHODIMP WABSync_SaveCurrentModInfo(LPWABSYNC pWabSync);
  224. STDMETHODIMP_ (void) WABSync_FreeItems(LPWABSYNC pWabSync);
  225. STDMETHODIMP_ (void) WABSync_FreeOps(LPWABSYNC pWabSync);
  226. STDMETHODIMP WABSync_FindContactByServerId(LPWABSYNC pWabSync, LPSTR pszServerId, LPWABCONTACTINFO *ppContact, DWORD *pdwIndex);
  227. STDMETHODIMP WABSync_DoConflicts(LPWABSYNC pWabSync);
  228. STDMETHODIMP WABSync_AbortOp(LPWABSYNC pWabSync, HRESULT hr);
  229. STDMETHODIMP_ (void) WABSync_Progress(LPWABSYNC pWabSync, DWORD dwResId, DWORD dwCount);
  230. STDMETHODIMP_ (void) WABSync_MergeAddsToConflicts(LPWABSYNC pWabSync);
  231. enum tagSYNCOPTYPE
  232. { SYNCOP_SERVER_INVALID = 0,
  233. SYNCOP_SERVER_DELETE,
  234. SYNCOP_CLIENT_DELETE,
  235. SYNCOP_SERVER_ADD,
  236. SYNCOP_SERVER_CHANGE,
  237. SYNCOP_CLIENT_ADD,
  238. SYNCOP_CLIENT_CHANGE,
  239. SYNCOP_CONFLICT
  240. } SYNCOPTYPE;
  241. LPHOTSYNCOP Syncop_CreateServerAdd(LPWABCONTACTINFO pContactInfo);
  242. HRESULT Syncop_ServerAddResponse(LPHOTSYNCOP pSyncOp, LPHTTPMAILRESPONSE pResponse);
  243. HRESULT Syncop_ServerAddBegin(LPHOTSYNCOP pSyncOp);
  244. LPHOTSYNCOP Syncop_CreateServerDelete(LPWABCONTACTINFO pContactInfo);
  245. HRESULT Syncop_ServerDeleteResponse(LPHOTSYNCOP pSyncOp, LPHTTPMAILRESPONSE pResponse);
  246. HRESULT Syncop_ServerDeleteBegin(LPHOTSYNCOP pSyncOp);
  247. LPHOTSYNCOP Syncop_CreateServerChange(LPWABCONTACTINFO pContactInfo);
  248. HRESULT Syncop_ServerChangeResponse(LPHOTSYNCOP pSyncOp, LPHTTPMAILRESPONSE pResponse);
  249. HRESULT Syncop_ServerChangeBegin(LPHOTSYNCOP pSyncOp);
  250. LPHOTSYNCOP Syncop_CreateClientAdd(LPWABCONTACTINFO pContactInfo);
  251. HRESULT Syncop_ClientAddResponse(LPHOTSYNCOP pSyncOp, LPHTTPMAILRESPONSE pResponse);
  252. HRESULT Syncop_ClientAddBegin(LPHOTSYNCOP pSyncOp);
  253. LPHOTSYNCOP Syncop_CreateClientDelete(LPWABCONTACTINFO pContactInfo);
  254. HRESULT Syncop_ClientDeleteResponse(LPHOTSYNCOP pSyncOp, LPHTTPMAILRESPONSE pResponse);
  255. HRESULT Syncop_ClientDeleteBegin(LPHOTSYNCOP pSyncOp);
  256. LPHOTSYNCOP Syncop_CreateClientChange(LPWABCONTACTINFO pContactInfo);
  257. HRESULT Syncop_ClientChangeResponse(LPHOTSYNCOP pSyncOp, LPHTTPMAILRESPONSE pResponse);
  258. HRESULT Syncop_ClientChangeBegin(LPHOTSYNCOP pSyncOp);
  259. LPHOTSYNCOP Syncop_CreateConflict(LPWABCONTACTINFO pContactInfo);
  260. HRESULT Syncop_ConflictResponse(LPHOTSYNCOP pSyncOp, LPHTTPMAILRESPONSE pResponse);
  261. HRESULT Syncop_ConflictBegin(LPHOTSYNCOP pSyncOp);
  262. HRESULT Syncop_Init(LPHOTSYNCOP pSyncOp, IHTTPMailCallback *pHotSync, IHTTPMailTransport *pTransport);
  263. HRESULT Syncop_Delete(LPHOTSYNCOP pSyncOp);
  264. HRESULT Syncop_HandleResponse(LPHOTSYNCOP pSyncOp, LPHTTPMAILRESPONSE pResponse);
  265. HRESULT Syncop_Begin(LPHOTSYNCOP pSyncOp);
  266. HRESULT Syncop_Abort(LPHOTSYNCOP pSyncOp);
  267. void Syncop_SetServerContactInfo(LPHOTSYNCOP pSyncOp, LPWABCONTACTINFO pWabContactInfo, LPHTTPCONTACTINFO pContactInfo);
  268. void ContactInfo_Free(LPHTTPCONTACTINFO pContactInfo);
  269. void ContactInfo_Clear(LPHTTPCONTACTINFO pContactInfo);
  270. HRESULT ContactInfo_SaveToWAB(LPWABSYNC pWabSync, LPHTTPCONTACTINFO pContactInfo, LPWABCONTACTINFO pWabContact, LPENTRYID lpEntryID, ULONG cbEntryID, BOOL fDeleteProps);
  271. HRESULT ContactInfo_LoadFromWAB(LPWABSYNC pWabSync, LPHTTPCONTACTINFO pContactInfo, LPWABCONTACTINFO pWabContact, LPENTRYID lpEntryID, ULONG cbEntryID);
  272. HRESULT ContactInfo_GenerateNickname(LPHTTPCONTACTINFO pContactInfo);
  273. BOOL ContactInfo_Match(LPHTTPCONTACTINFO pci1, LPHTTPCONTACTINFO pci2);
  274. HRESULT ContactInfo_PreparePatch(LPHTTPCONTACTINFO pciFrom, LPHTTPCONTACTINFO pciTo);
  275. HRESULT ContactInfo_EmptyNullItems(LPHTTPCONTACTINFO pci);
  276. HRESULT ContactInfo_BlendResults(LPHTTPCONTACTINFO pciServer, LPHTTPCONTACTINFO pciClient, CONFLICT_DECISION *prgDecisions);
  277. HRESULT ContactInfo_BlendNewContact(LPWABSYNC pWabSync, LPHTTPCONTACTINFO pContactInfo);
  278. void UpdateSynchronizeMenus(HMENU hMenu, LPIAB lpIAB);
  279. DWORD CountHTTPMailAccounts(LPIAB lpIAB);
  280. INT_PTR CALLBACK SyncProgressDlgProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
  281. #endif __hotsync_h__