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.

184 lines
4.0 KiB

  1. // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
  2. // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
  3. // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
  4. // PARTICULAR PURPOSE.
  5. //
  6. // Copyright (C) 1993-1996 Microsoft Corporation. All Rights Reserved.
  7. //
  8. //
  9. // Purpose: Implements the IOfflineSynchronize Interfaces for the OneStop Handler
  10. //#include "priv.h"
  11. #include "SyncHndl.h"
  12. extern HINSTANCE g_hmodThisDll; // Handle to this DLL itself.
  13. // begin helper apis, move to separate file
  14. #define ALLOC(cb) CoTaskMemAlloc(cb)
  15. #define FREE(cb) CoTaskMemFree(cb)
  16. // create an new offline items list and initialize it to nothing
  17. // and set the refcount to 1.
  18. LPSYNCMGRHANDLERITEMS CreateOfflineHandlerItemsList()
  19. {
  20. LPSYNCMGRHANDLERITEMS lpoffline =
  21. (LPSYNCMGRHANDLERITEMS) ALLOC(sizeof(SYNCMGRHANDLERITEMS));
  22. if (lpoffline)
  23. {
  24. memset(lpoffline,0,sizeof(SYNCMGRHANDLERITEMS));
  25. AddRef_OfflineHandlerItemsList(lpoffline);
  26. // do any specific itemlist initializatoin here.
  27. }
  28. return lpoffline;
  29. }
  30. DWORD AddRef_OfflineHandlerItemsList(LPSYNCMGRHANDLERITEMS lpOfflineItem)
  31. {
  32. return ++lpOfflineItem->_cRefs;
  33. }
  34. DWORD Release_OfflineHandlerItemsList(LPSYNCMGRHANDLERITEMS lpOfflineItem)
  35. {
  36. DWORD cRefs;
  37. cRefs = --lpOfflineItem->_cRefs;
  38. if (0 == lpOfflineItem->_cRefs)
  39. {
  40. FREE(lpOfflineItem);
  41. }
  42. return cRefs;
  43. }
  44. // allocates space for a new offline and adds it to the list,
  45. // if successfull returns pointer to new item so caller can initialize it.
  46. LPSYNCMGRHANDLERITEM AddOfflineItemToList(LPSYNCMGRHANDLERITEMS pOfflineItemsList,ULONG cbSize)
  47. {
  48. LPSYNCMGRHANDLERITEM pOfflineItem;
  49. // size must be at least size of the base offlinehandler item.
  50. if (cbSize < sizeof(SYNCMGRHANDLERITEM))
  51. return NULL;
  52. pOfflineItem = (LPSYNCMGRHANDLERITEM) ALLOC(cbSize);
  53. // todo: Add validation.
  54. if (pOfflineItem)
  55. {
  56. // initialize to zero, and then add it to the list.
  57. memset(pOfflineItem,0,cbSize);
  58. pOfflineItem->pNextOfflineItem = pOfflineItemsList->pFirstOfflineItem;
  59. pOfflineItemsList->pFirstOfflineItem = pOfflineItem;
  60. ++pOfflineItemsList->dwNumOfflineItems;
  61. }
  62. return pOfflineItem;
  63. }
  64. // end of helper APIS
  65. // Implementation must override this.
  66. STDMETHODIMP COneStopHandler::Initialize(DWORD dwReserved,DWORD dwSyncFlags,
  67. DWORD cbCookie,BYTE const*lpCookie)
  68. {
  69. return E_NOTIMPL;
  70. }
  71. STDMETHODIMP COneStopHandler::GetHandlerInfo(LPSYNCMGRHANDLERINFO *ppSyncMgrHandlerInfo)
  72. {
  73. return E_NOTIMPL;
  74. }
  75. STDMETHODIMP COneStopHandler::EnumSyncMgrItems(ISyncMgrEnumItems** ppenumOffineItems)
  76. {
  77. if (m_pOfflineHandlerItems)
  78. {
  79. *ppenumOffineItems = new CEnumOfflineItems(m_pOfflineHandlerItems,0);
  80. }
  81. else
  82. {
  83. *ppenumOffineItems = NULL;
  84. }
  85. return *ppenumOffineItems ? NOERROR: E_OUTOFMEMORY;
  86. }
  87. STDMETHODIMP COneStopHandler::GetItemObject(REFSYNCMGRITEMID ItemID,REFIID riid,void** ppv)
  88. {
  89. return E_NOTIMPL;
  90. }
  91. STDMETHODIMP COneStopHandler::ShowProperties(HWND hwnd,REFSYNCMGRITEMID dwItemID)
  92. {
  93. // if support properties should display it as a standard property dialog.
  94. return E_NOTIMPL;
  95. }
  96. STDMETHODIMP COneStopHandler::SetProgressCallback(ISyncMgrSynchronizeCallback *lpCallBack)
  97. {
  98. LPSYNCMGRSYNCHRONIZECALLBACK pCallbackCurrent = m_pOfflineSynchronizeCallback;
  99. m_pOfflineSynchronizeCallback = lpCallBack;
  100. if (m_pOfflineSynchronizeCallback)
  101. m_pOfflineSynchronizeCallback->AddRef();
  102. if (pCallbackCurrent)
  103. pCallbackCurrent->Release();
  104. return NOERROR;
  105. }
  106. STDMETHODIMP COneStopHandler::PrepareForSync(ULONG cbNumItems,SYNCMGRITEMID* pItemIDs,
  107. HWND hwndParent,DWORD dwReserved)
  108. {
  109. return E_NOTIMPL;
  110. }
  111. STDMETHODIMP COneStopHandler::Synchronize(HWND hwndParent)
  112. {
  113. return E_NOTIMPL;
  114. }
  115. STDMETHODIMP COneStopHandler::SetItemStatus(REFSYNCMGRITEMID ItemID,DWORD dwSyncMgrStatus)
  116. {
  117. return E_NOTIMPL;
  118. }
  119. STDMETHODIMP COneStopHandler::ShowError(HWND hWndParent,REFSYNCMGRERRORID ErrorID)
  120. {
  121. // Can show any synchronization conflicts. Also gives a chance
  122. // to display any errors that occured during synchronization
  123. return E_NOTIMPL;
  124. }