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.

212 lines
7.5 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1998.
  5. //
  6. // File: Hndlrq.h
  7. //
  8. // Contents: Keeps tracks of Handlers and UI assignments
  9. //
  10. // Classes: CHndlrQueue
  11. //
  12. // Notes:
  13. //
  14. // History: 05-Nov-97 rogerg Created.
  15. // 17-Nov-97 susia Converted to an Autosync Queue
  16. //
  17. //--------------------------------------------------------------------------
  18. #ifndef _HANDLERQUEUE_
  19. #define _HANDLERQUEUE_
  20. typedef enum _tagHANDLERSTATE
  21. {
  22. HANDLERSTATE_CREATE = 0x01, // state is initialized to this.
  23. HANDLERSTATE_INCREATE = 0x02, // state is initialized to this.
  24. HANDLERSTATE_INITIALIZE = 0x03, // set after a successfull creation.
  25. HANDLERSTATE_ININITIALIZE = 0x04, // set during initialization call
  26. HANDLERSTATE_ADDHANDLERTEMS = 0x05, // items need to be enumerated
  27. HANDLERSTATE_INADDHANDLERITEMS = 0x06, // in the items enumerator
  28. HANDLERSTATE_PREPAREFORSYNC = 0x07, // set during queue tranfers
  29. HANDLERSTATE_INPREPAREFORSYNC = 0x08, // handler is currently in a prepfosync call.
  30. HANDLERSTATE_DEAD = 0x0F, // handler has been released. Data Stays around.
  31. } HANDLERSTATE;
  32. typedef enum _tagQUEUETYPE
  33. {
  34. QUEUETYPE_SETTINGS = 0x3, // set during queue tranfers
  35. QUEUETYPE_SCHEDULE = 0x4, // set during queue tranfers
  36. } QUEUETYPE;
  37. // so can share the queue with AutoSync and Idle just define a checkstate struct
  38. // to keep track of items.
  39. typedef struct _tagITEMCHECKSTATE
  40. {
  41. DWORD dwAutoSync;
  42. DWORD dwIdle;
  43. DWORD dwSchedule;
  44. } ITEMCHECKSTATE;
  45. typedef struct _ITEMLIST
  46. {
  47. struct _ITEMLIST *pnextItem;
  48. WORD wItemId; // Id that uniquely identifies Item within a handler.
  49. void *pHandlerInfo; // pointer to the handler that owns this item
  50. INT iItem; // Index of Item in the current ListView.!!!Initialize to -1
  51. SYNCMGRITEM offlineItem; // enumerator structure item returned
  52. ITEMCHECKSTATE *pItemCheckState; // list of check states per connection
  53. } ITEMLIST;
  54. typedef ITEMLIST* LPITEMLIST;
  55. typedef struct _HANDLERINFO {
  56. struct _HANDLERINFO *pNextHandler; // next handler in queue
  57. WORD wHandlerId; // Id that uniquely identifies this instance of the Handler
  58. CLSID clsidHandler; // CLSID of the handler Handler
  59. SYNCMGRHANDLERINFO SyncMgrHandlerInfo; // copy of handler info GetHandlerInfo CallHANDLERSTATE HandlerState; // Current state of the handler
  60. HANDLERSTATE HandlerState;
  61. DWORD dwRegistrationFlags; // flags as item is registered
  62. DWORD dwSyncFlags; // sync flags originally passed in Initialize.
  63. WORD wItemCount; // number of items on this handler
  64. LPITEMLIST pFirstItem; // ptr to first Item of the handler in the list.
  65. LPSYNCMGRSYNCHRONIZE pSyncMgrHandler;
  66. } HANDLERINFO;
  67. typedef HANDLERINFO* LPHANDLERINFO;
  68. class CHndlrQueue {
  69. private:
  70. LPHANDLERINFO m_pFirstHandler; // first handler in queue
  71. WORD m_wHandlerCount; // number of handlers in this queue
  72. QUEUETYPE m_QueueType; // type of queue this is.
  73. CRITICAL_SECTION m_CriticalSection; // critical section for the queue.
  74. LPCONNECTIONSETTINGS m_ConnectionList; // hold the settings per connection
  75. int m_ConnectionCount; // number of connections
  76. BOOL m_fItemsMissing; // set if any handlers have missing items.
  77. public:
  78. CHndlrQueue(QUEUETYPE QueueType);
  79. ~CHndlrQueue();
  80. STDMETHODIMP_(ULONG) AddRef();
  81. STDMETHODIMP_(ULONG) Release();
  82. // main queue routines
  83. STDMETHODIMP AddHandler(REFCLSID clsidHandler, WORD *wHandlerId);
  84. STDMETHODIMP RemoveHandler(WORD wHandlerId);
  85. STDMETHODIMP FreeAllHandlers(void);
  86. // For updating hWnd and ListView Information.
  87. STDMETHODIMP GetHandlerInfo(REFCLSID clsidHandler,LPSYNCMGRHANDLERINFO pSyncMgrHandlerInfo);
  88. STDMETHODIMP FindFirstHandlerInState
  89. (HANDLERSTATE hndlrState,
  90. WORD *wHandlerID);
  91. STDMETHODIMP FindNextHandlerInState
  92. (WORD wLastHandlerID,
  93. HANDLERSTATE hndlrState,
  94. WORD *wHandlerID);
  95. STDMETHODIMP GetHandlerIDFromClsid
  96. (REFCLSID clsidHandlerIn,
  97. WORD *pwHandlerId);
  98. STDMETHODIMP FindFirstItemOnConnection
  99. (TCHAR *pszConnectionName,
  100. CLSID *pclsidHandler,
  101. SYNCMGRITEMID* OfflineItemID,
  102. WORD *pwHandlerId,WORD *pwItemID);
  103. STDMETHODIMP FindNextItemOnConnection
  104. (TCHAR *pszConnectionName,
  105. WORD wLastHandlerId,
  106. WORD wLastItemID,
  107. CLSID *pclsidHandler,
  108. SYNCMGRITEMID* OfflineItemID,
  109. WORD *pwHandlerId,
  110. WORD *pwItemID,
  111. BOOL fAllHandlers,
  112. DWORD *pdwCheckState);
  113. STDMETHODIMP GetSyncItemDataOnConnection
  114. (int iConnectionIndex,
  115. WORD wHandlerId,
  116. WORD wItemID,
  117. CLSID *pclsidHandler,
  118. SYNCMGRITEM* offlineItem,
  119. ITEMCHECKSTATE *pItemCheckState,
  120. BOOL fSchedSync,
  121. BOOL fClear);
  122. STDMETHODIMP SetSyncCheckStateFromListViewItem
  123. (SYNCTYPE SyncType,INT iItem,
  124. BOOL fChecked,
  125. INT iConnectionItem);
  126. //AutoSync specific methods
  127. STDMETHODIMP ReadSyncSettingsPerConnection(SYNCTYPE syncType,WORD wHandlerID);
  128. STDMETHODIMP InitSyncSettings(SYNCTYPE syncType,HWND hwndRasCombo);
  129. STDMETHODIMP CommitSyncChanges(SYNCTYPE syncType,CRasUI *pRas);
  130. // Idle Specific methods.
  131. STDMETHODIMP ReadAdvancedIdleSettings(LPCONNECTIONSETTINGS pConnectionSettings);
  132. STDMETHODIMP WriteAdvancedIdleSettings(LPCONNECTIONSETTINGS pConnectionSettings);
  133. //SchedSync specific methods
  134. STDMETHODIMP ReadSchedSyncSettingsOnConnection(WORD wHandlerID, TCHAR *pszSchedName);
  135. STDMETHODIMP InitSchedSyncSettings(LPCONNECTIONSETTINGS pConnectionSettings);
  136. STDMETHODIMP CommitSchedSyncChanges(TCHAR * pszSchedName,
  137. TCHAR * pszFriendlyName,
  138. TCHAR * pszConnectionName,
  139. DWORD dwConnType,BOOL fCleanReg);
  140. STDMETHODIMP InsertItem(LPHANDLERINFO pCurHandler,
  141. LPSYNC_HANDLER_ITEM_INFO pHandlerItemInfo);
  142. STDMETHODIMP AddHandlerItem(LPSYNC_HANDLER_ITEM_INFO pHandlerItemInfo);
  143. STDMETHODIMP SetItemCheck(REFCLSID pclsidHandler,
  144. SYNCMGRITEMID *OfflineItemID, DWORD dwCheckState);
  145. STDMETHODIMP GetItemCheck(REFCLSID pclsidHandler,
  146. SYNCMGRITEMID *OfflineItemID, DWORD *pdwCheckState);
  147. STDMETHODIMP SetItemListViewID(CLSID clsidHandler,SYNCMGRITEMID OfflineItemID,INT iItem); // assigns list view ID to an Item.
  148. DWORD GetCheck(WORD wParam, INT iItem);
  149. STDMETHODIMP SetConnectionCheck(WORD wParam, DWORD dwState, INT iConnectionItem);
  150. STDMETHODIMP ListViewItemHasProperties(INT iItem); // determines if there are properties associated with this item.
  151. STDMETHODIMP ShowProperties(HWND hwndParent,INT iItem); // show properties for this listView Item.
  152. STDMETHODIMP CreateServer(WORD wHandlerId, const CLSID *pCLSIDServer);
  153. STDMETHODIMP Initialize(WORD wHandlerId,DWORD dwReserved,DWORD dwSyncFlags,
  154. DWORD cbCookie,const BYTE *lpCookie);
  155. STDMETHODIMP SetHandlerInfo(WORD wHandlerId,LPSYNCMGRHANDLERINFO pSyncMgrHandlerInfo);
  156. STDMETHODIMP AddHandlerItemsToQueue(WORD wHandlerId);
  157. STDMETHODIMP AddItemToHandler(WORD wHandlerId,SYNCMGRITEM *pOffineItem);
  158. STDMETHODIMP GetItemName(WORD wHandlerId, WORD wItemID, WCHAR *pwszName);
  159. STDMETHODIMP GetItemIcon(WORD wHandlerId, WORD wItemID, HICON *phIcon);
  160. private:
  161. // private functions for finding proper handlers and items.
  162. STDMETHODIMP LookupHandlerFromId(WORD wHandlerId,LPHANDLERINFO *pHandlerInfo);
  163. ULONG m_cRef;
  164. };
  165. #endif // _HANDLERQUEUE_