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.

109 lines
3.2 KiB

  1. /*
  2. File: offsync.cpp
  3. Miscellaneous code not in the handler or the enumerator
  4. Based on sample code from OneStop
  5. */
  6. #include "pch.hxx"
  7. #include "onestop.h"
  8. #include "multiusr.h"
  9. #include "demand.h"
  10. LPSYNCMGRHANDLERITEMS OHIL_Create()
  11. {
  12. LPSYNCMGRHANDLERITEMS lpOffline;
  13. if (MemAlloc((LPVOID *)&lpOffline, sizeof(SYNCMGRHANDLERITEMS)))
  14. {
  15. lpOffline->cRefs = 0;
  16. lpOffline->dwNumOfflineItems=NULL;
  17. lpOffline->pFirstOfflineItem=NULL;
  18. OHIL_AddRef(lpOffline);
  19. // do any specific itemlist initialization here.
  20. }
  21. return lpOffline;
  22. }
  23. DWORD OHIL_AddRef(LPSYNCMGRHANDLERITEMS lpOfflineItem)
  24. {
  25. return ++(lpOfflineItem->cRefs);
  26. }
  27. DWORD OHIL_Release(LPSYNCMGRHANDLERITEMS lpOfflineItem)
  28. {
  29. DWORD cRefs = --lpOfflineItem->cRefs;
  30. LPSYNCMGRHANDLERITEM lpCurrent, lpDelete;
  31. if (0 == cRefs)
  32. {
  33. lpCurrent = lpOfflineItem->pFirstOfflineItem;
  34. while (lpCurrent)
  35. {
  36. lpDelete = lpCurrent;
  37. lpCurrent = lpCurrent->pNextOfflineItem;
  38. MemFree(lpDelete);
  39. }
  40. MemFree(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 OHIL_AddItem(LPSYNCMGRHANDLERITEMS pOfflineItemsList)
  47. {
  48. LPSYNCMGRHANDLERITEM pOfflineItem;
  49. if (MemAlloc((LPVOID *)&pOfflineItem, sizeof(SYNCMGRHANDLERITEM)))
  50. {
  51. // Add new node to the front
  52. pOfflineItem->pNextOfflineItem = pOfflineItemsList->pFirstOfflineItem;
  53. pOfflineItemsList->pFirstOfflineItem = pOfflineItem;
  54. ++pOfflineItemsList->dwNumOfflineItems;
  55. }
  56. return pOfflineItem;
  57. }
  58. // Only called from OE, so assumes OE init of dll vars has occurred
  59. void InvokeSyncMgr(HWND hwnd, ISyncMgrSynchronizeInvoke ** ppSyncMgr, BOOL bPrompt)
  60. {
  61. HRESULT hr;
  62. uCLSSPEC ucs;
  63. static s_fSyncAvail = FALSE;
  64. DWORD dwDummy=1;
  65. ucs.tyspec = TYSPEC_CLSID;
  66. ucs.tagged_union.clsid = CLSID_MobilityFeature;
  67. // Try to fault in the Mobility pack if it is not around
  68. if (!s_fSyncAvail && FAILED(hr = FaultInIEFeature(hwnd, &ucs, NULL, FIEF_FLAG_FORCE_JITUI)))
  69. {
  70. if (HRESULT_FROM_WIN32(ERROR_ACCESS_DENIED) == hr)
  71. AthMessageBoxW(hwnd, MAKEINTRESOURCEW(idsAthena), MAKEINTRESOURCEW(idsJITErrDenied), NULL, MB_OK);
  72. return;
  73. }
  74. AssertSz(S_FALSE != hr, "InvokeSyncMgr: URLMON Thinks that the Offline pack is not an IE feature!");
  75. // Avoid expensive URLMON call next time
  76. s_fSyncAvail = TRUE;
  77. if (!*ppSyncMgr)
  78. {
  79. // We've never grabbed the sync mgr invoker before
  80. if (FAILED(CoCreateInstance(CLSID_SyncMgr, NULL, CLSCTX_INPROC_SERVER, IID_ISyncMgrSynchronizeInvoke, (LPVOID *)ppSyncMgr)))
  81. {
  82. AthMessageBoxW(hwnd, MAKEINTRESOURCEW(idsAthena), MAKEINTRESOURCEW(idsSYNCMGRErr), NULL, MB_OK);
  83. return;
  84. }
  85. }
  86. // Against all odds, the following call will create a new PROCESS!
  87. (*ppSyncMgr)->UpdateItems(bPrompt ? 0 : SYNCMGRINVOKE_STARTSYNC, CLSID_OEOneStopHandler, sizeof(dwDummy), (LPCBYTE)&dwDummy);
  88. }