Source code of Windows XP (NT5)
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.

145 lines
4.3 KiB

  1. //
  2. // The class ID of this OneStop Handler class.
  3. //
  4. //
  5. #define ODS(sz) OutputDebugString(sz)
  6. #ifndef _SYNCHNDLR_H
  7. #define _SYNCHNDLR_H
  8. #include <objbase.h>
  9. #include <mobsync.h>
  10. #include "reg.h" // include so Handlers can call the reg helper routines.
  11. // base structure for OfflineHandler item.
  12. // specific implementations allocate extra space on the end for their specific data.
  13. typedef struct _SYNCMGRHANDLERITEM
  14. {
  15. _SYNCMGRHANDLERITEM *pNextOfflineItem;
  16. SYNCMGRITEM offlineItem; // array of OfflineItems
  17. } SYNCMGRHANDLERITEM;
  18. typedef SYNCMGRHANDLERITEM *LPSYNCMGRHANDLERITEM;
  19. // structure for keeping track of items as a whole
  20. typedef struct _tagSYNCMGRHANDLERITEMS
  21. {
  22. DWORD _cRefs; // reference count on this structure
  23. DWORD dwNumOfflineItems; // number of items in OffItems array.
  24. LPSYNCMGRHANDLERITEM pFirstOfflineItem; // ptr to first OfflineItem in linked list
  25. } SYNCMGRHANDLERITEMS;
  26. typedef SYNCMGRHANDLERITEMS *LPSYNCMGRHANDLERITEMS;
  27. class CClassFactory : public IClassFactory
  28. {
  29. protected:
  30. ULONG m_cRef;
  31. public:
  32. CClassFactory();
  33. ~CClassFactory();
  34. //IUnknown members
  35. STDMETHODIMP QueryInterface(REFIID, LPVOID FAR *);
  36. STDMETHODIMP_(ULONG) AddRef();
  37. STDMETHODIMP_(ULONG) Release();
  38. //IClassFactory members
  39. STDMETHODIMP CreateInstance(LPUNKNOWN, REFIID, LPVOID FAR *);
  40. STDMETHODIMP LockServer(BOOL);
  41. };
  42. typedef CClassFactory *LPCClassFactory;
  43. // todo: need helper functions for creating and releasing
  44. // structure so each function doesn't have to call it.
  45. class COneStopHandler : public ISyncMgrSynchronize
  46. {
  47. private: // should be private
  48. DWORD m_cRef;
  49. LPSYNCMGRHANDLERITEMS m_pOfflineHandlerItems;
  50. LPSYNCMGRSYNCHRONIZECALLBACK m_pOfflineSynchronizeCallback;
  51. public:
  52. COneStopHandler();
  53. ~COneStopHandler();
  54. //IUnknown members
  55. STDMETHODIMP QueryInterface(REFIID, LPVOID FAR *);
  56. STDMETHODIMP_(ULONG) AddRef();
  57. STDMETHODIMP_(ULONG) Release();
  58. virtual inline STDMETHODIMP DestroyHandler() { return NOERROR; };
  59. // IOfflineSynchroinze methods
  60. STDMETHODIMP Initialize(DWORD dwReserved,DWORD dwSyncFlags,
  61. DWORD cbCookie,const BYTE *lpCooke);
  62. STDMETHODIMP GetHandlerInfo(LPSYNCMGRHANDLERINFO *ppSyncMgrHandlerInfo);
  63. STDMETHODIMP EnumSyncMgrItems(ISyncMgrEnumItems **ppenumOffineItems);
  64. STDMETHODIMP GetItemObject(REFSYNCMGRITEMID ItemID,REFIID riid,void** ppv);
  65. STDMETHODIMP ShowProperties(HWND hwnd,REFSYNCMGRITEMID ItemID);
  66. STDMETHODIMP SetProgressCallback(ISyncMgrSynchronizeCallback *lpCallBack);
  67. STDMETHODIMP PrepareForSync(ULONG cbNumItems,SYNCMGRITEMID* pItemIDs,HWND hWndParent,
  68. DWORD dwReserved);
  69. STDMETHODIMP Synchronize(HWND hwnd);
  70. STDMETHODIMP SetItemStatus(REFSYNCMGRITEMID ItemID,DWORD dwSyncMgrStatus);
  71. STDMETHODIMP ShowError(HWND hWndParent,REFSYNCMGRERRORID ErrorID);
  72. // functions for get/set of private variables.
  73. inline LPSYNCMGRHANDLERITEMS GetOfflineItemsHolder() { return m_pOfflineHandlerItems; };
  74. inline void SetOfflineItemsHolder(LPSYNCMGRHANDLERITEMS pOfflineHandlerItems)
  75. { m_pOfflineHandlerItems = pOfflineHandlerItems; };
  76. inline LPSYNCMGRSYNCHRONIZECALLBACK GetOfflineSynchronizeCallback()
  77. { return m_pOfflineSynchronizeCallback; };
  78. };
  79. typedef COneStopHandler *LPCOneStopHandler;
  80. class CEnumOfflineItems : public ISyncMgrEnumItems
  81. {
  82. private:
  83. DWORD m_cRef;
  84. DWORD m_cOffset;
  85. LPSYNCMGRHANDLERITEMS m_pOfflineItems; // array of offline items, same format as give to OneStop
  86. LPSYNCMGRHANDLERITEM m_pNextItem;
  87. public:
  88. CEnumOfflineItems(LPSYNCMGRHANDLERITEMS pOfflineItems,DWORD cOffset);
  89. ~CEnumOfflineItems();
  90. //IUnknown members
  91. STDMETHODIMP QueryInterface(REFIID, LPVOID FAR *);
  92. STDMETHODIMP_(ULONG) AddRef();
  93. STDMETHODIMP_(ULONG) Release();
  94. //IEnumOfflineItems members
  95. STDMETHODIMP Next(ULONG celt, LPSYNCMGRITEM rgelt,ULONG *pceltFetched);
  96. STDMETHODIMP Skip(ULONG celt);
  97. STDMETHODIMP Reset();
  98. STDMETHODIMP Clone(ISyncMgrEnumItems **ppenum);
  99. };
  100. typedef CEnumOfflineItems *LPCEnumOfflineItems;
  101. STDAPI DllRegisterServer(void);
  102. // helper function declarations.
  103. // TODO: MOVE TO OWN FILE
  104. DWORD AddRef_OfflineHandlerItemsList(LPSYNCMGRHANDLERITEMS lpOfflineItem);
  105. DWORD Release_OfflineHandlerItemsList(LPSYNCMGRHANDLERITEMS lpOfflineItem);
  106. LPSYNCMGRHANDLERITEMS CreateOfflineHandlerItemsList();
  107. LPSYNCMGRHANDLERITEM AddOfflineItemToList(LPSYNCMGRHANDLERITEMS pOfflineItemsList,ULONG cbSize);
  108. #endif // _SYNCHNDLR_H