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.

287 lines
8.0 KiB

  1. /*++
  2. Copyright (c) 1999 Microsoft Corporation
  3. Module Name:
  4. ExtensionData.h
  5. Abstract:
  6. This file provides declarations of the named
  7. extension data functions (get / set / notify)
  8. Author:
  9. Eran Yariv (EranY) Dec, 1999
  10. Revision History:
  11. --*/
  12. #ifndef _EXTENSION_DATA_H_
  13. #define _EXTENSION_DATA_H_
  14. #include <map>
  15. #include <list>
  16. #include <string>
  17. using namespace std;
  18. class CExtNotifyCallbackPacket
  19. {
  20. public:
  21. CExtNotifyCallbackPacket();
  22. ~CExtNotifyCallbackPacket();
  23. BOOL Init(
  24. PFAX_EXT_CONFIG_CHANGE pCallback,
  25. DWORD dwDeviceId,
  26. LPCWSTR lpcwstrDataGuid,
  27. LPBYTE lpbData,
  28. DWORD dwDataSize);
  29. public:
  30. DWORD m_dwDeviceId;
  31. LPWSTR m_lpwstrGUID;
  32. LPBYTE m_lpbData;
  33. DWORD m_dwDataSize;
  34. PFAX_EXT_CONFIG_CHANGE m_pCallback ;
  35. };
  36. /************************************
  37. * *
  38. * CMapDeviceId *
  39. * *
  40. ************************************/
  41. class CMapDeviceId
  42. {
  43. public:
  44. CMapDeviceId () {}
  45. ~CMapDeviceId () {}
  46. DWORD AddDevice (DWORD dwTAPIid, DWORD dwFaxId);
  47. DWORD RemoveDevice (DWORD dwTAPIid);
  48. DWORD LookupUniqueId (DWORD dwOtherId, LPDWORD lpdwFaxId) const;
  49. private:
  50. typedef map<DWORD, DWORD> DEVICE_IDS_MAP, *PDEVICE_IDS_MAP;
  51. DEVICE_IDS_MAP m_Map;
  52. }; // CMapDeviceId
  53. /************************************
  54. * *
  55. * CDeviceAndGUID *
  56. * *
  57. ************************************/
  58. //
  59. // CDeviceAndGUID class
  60. //
  61. // This class represents the key in the notification map
  62. //
  63. class CDeviceAndGUID
  64. {
  65. public:
  66. CDeviceAndGUID (DWORD dwDeviceId, LPCWSTR lpcwstrGUID) :
  67. m_dwDeviceId (dwDeviceId),
  68. m_strGUID (lpcwstrGUID)
  69. {}
  70. virtual ~CDeviceAndGUID () {}
  71. bool operator < ( const CDeviceAndGUID &other ) const;
  72. private:
  73. wstring m_strGUID;
  74. DWORD m_dwDeviceId;
  75. }; // CDeviceAndGUID
  76. /************************************
  77. * *
  78. * CNotificationSink *
  79. * *
  80. ************************************/
  81. //
  82. // CNotificationSink class
  83. //
  84. // This generic abstract class represents a notification sink.
  85. // The value in the map is a list of pointer to instances derived from this class.
  86. //
  87. class CNotificationSink
  88. {
  89. public:
  90. CNotificationSink () : m_type (SINK_TYPE_UNKNOWN) {}
  91. virtual ~CNotificationSink() {}
  92. virtual HRESULT Notify (DWORD dwDeviceId,
  93. LPCWSTR lpcwstrNameGUID,
  94. LPCWSTR lpcwstrComputerName,
  95. HANDLE hModule,
  96. LPBYTE lpData,
  97. DWORD dwDataSize,
  98. LPBOOL lpbRemove) = 0;
  99. virtual bool operator == (const CNotificationSink &rhs) const = 0;
  100. virtual bool operator != (const CNotificationSink &rhs) const
  101. {
  102. return !(*this == rhs);
  103. }
  104. virtual HRESULT Disconnect () = 0;
  105. typedef enum {
  106. SINK_TYPE_UNKNOWN, // Unspecified sink type
  107. SINK_TYPE_LOCAL, // Local sink (callback)
  108. SINK_TYPE_REMOTE // Remote sink (RPC)
  109. } SinkType;
  110. SinkType Type() const { return m_type; }
  111. protected:
  112. SinkType m_type;
  113. }; // CNotificationSink
  114. /************************************
  115. * *
  116. * CLocalNotificationSink *
  117. * *
  118. ************************************/
  119. //
  120. // CLocalNotificationSink class
  121. //
  122. // This is a concrete class derived from CNotificationSink.
  123. // It implementes a notification local sink in a Fax extension (via a callback).
  124. //
  125. class CLocalNotificationSink : public CNotificationSink
  126. {
  127. public:
  128. CLocalNotificationSink (
  129. PFAX_EXT_CONFIG_CHANGE lpConfigChangeCallback,
  130. DWORD dwNotifyDeviceId,
  131. HINSTANCE hInst);
  132. virtual ~CLocalNotificationSink() {}
  133. virtual bool operator == (const CNotificationSink &rhs) const;
  134. virtual HRESULT Disconnect () { return NOERROR; }
  135. virtual HRESULT Notify (DWORD dwDeviceId,
  136. LPCWSTR lpcwstrNameGUID,
  137. LPCWSTR lpcwstrComputerName,
  138. HANDLE hModule,
  139. LPBYTE lpData,
  140. DWORD dwDataSize,
  141. LPBOOL lpbRemove);
  142. private:
  143. PFAX_EXT_CONFIG_CHANGE m_lpConfigChangeCallback;
  144. DWORD m_dwNotifyDeviceId;
  145. HINSTANCE m_hInst; // Instance of extension that asks for this sink
  146. }; // CLocalNotificationSink
  147. /************************************
  148. * *
  149. * CSinksList *
  150. * *
  151. ************************************/
  152. typedef list<CNotificationSink *> SINKS_LIST, *PSINKS_LIST;
  153. class CSinksList
  154. {
  155. public:
  156. CSinksList () : m_bNotifying (FALSE) {}
  157. ~CSinksList ();
  158. BOOL m_bNotifying; // Are we now already notifying to this device id + GUID?
  159. SINKS_LIST m_List; // List of notification sinks
  160. }; // CSinksList
  161. #define NUM_EXT_DATA_SET_THREADS 1 /* The number of extension
  162. notification completion port
  163. dequeueing threads created
  164. */
  165. #define MAX_CONCURRENT_EXT_DATA_SET_THREADS 1 /* The maximal number of extension
  166. notification completion
  167. port dequeueing threads allowed
  168. (by the system) to run concurrently.
  169. */
  170. /************************************
  171. * *
  172. * CNotificationMap *
  173. * *
  174. ************************************/
  175. typedef map<CDeviceAndGUID, CSinksList*> NOTIFY_MAP, *PNOTIFY_MAP;
  176. //
  177. // The CNotificationMap class is the global notification mechanism
  178. //
  179. class CNotificationMap
  180. {
  181. public:
  182. CNotificationMap () :
  183. m_bNotifying (FALSE),
  184. m_hCompletionPort(NULL)
  185. {}
  186. virtual ~CNotificationMap ();
  187. void Notify (DWORD dwDeviceId,
  188. LPCWSTR lpcwstrNameGUID,
  189. LPCWSTR lpcwstrComputerName,
  190. HANDLE hModule,
  191. LPBYTE lpData,
  192. DWORD dwDataSize);
  193. CNotificationSink * AddLocalSink (
  194. HINSTANCE hInst,
  195. DWORD dwDeviceId,
  196. DWORD dwNotifyDeviceId,
  197. LPCWSTR lpcwstrNameGUID,
  198. PFAX_EXT_CONFIG_CHANGE lpConfigChangeCallback);
  199. DWORD RemoveSink (CNotificationSink *pSinkToRemove);
  200. DWORD Init ();
  201. HANDLE m_hCompletionPort;
  202. CFaxCriticalSection m_CsExtensionData; // Protects all extension data use
  203. private:
  204. NOTIFY_MAP m_Map;
  205. BOOL m_bNotifying; // Are we notifying someone now?
  206. static DWORD ExtNotificationThread(LPVOID UnUsed); // Extension Notification Thread function
  207. }; // CNotificationMap
  208. /************************************
  209. * *
  210. * Externs *
  211. * *
  212. ************************************/
  213. extern CNotificationMap* g_pNotificationMap; // Map of DeviceId+GUID to list of notification sinks
  214. extern CMapDeviceId* g_pTAPIDevicesIdsMap; // Map between TAPI permanent line id and fax unique device id.
  215. #endif // _EXTENSION_DATA_H_