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.

769 lines
25 KiB

  1. /*++
  2. Copyright (c) 1999 Microsoft Corporation
  3. Module Name:
  4. hidphone.h
  5. Abstract:
  6. This module contains the definitions of all the data structures being used
  7. in hidphone.c
  8. Author: Shivani Aggarwal
  9. --*/
  10. #ifndef _HIDPHONE_H_
  11. #define _HIDPHONE_H_
  12. #include <windows.h>
  13. #include <tspi.h>
  14. #include <tapi.h>
  15. #include <winbase.h>
  16. #include <setupapi.h>
  17. #include <TCHAR.h>
  18. #include <mmsystem.h>
  19. // * NOTE - initguid.h must always be defined before devguid.h
  20. #include <initguid.h>
  21. #include <hidclass.h>
  22. #include <dbt.h>
  23. #include "hidsdi.h"
  24. #include "hid.h"
  25. #include "resource.h"
  26. #include "audio.h"
  27. #include "mymem.h"
  28. #define LOW_VERSION 0x00020000
  29. #define HIGH_VERSION 0x00030001
  30. //
  31. // MAX_CHARS is used as an upper limit on the number of chars required
  32. // to store the phone id as a string. The phone ids begin from 0
  33. // to gdwNumPhones which a DWORD, hence 32-bit. Therefore the largest number
  34. // possible is 4294967296. Hence 20 chars are enough to store the largest string
  35. //
  36. #define MAX_CHARS 20
  37. // In order to distinguish between value and button usages
  38. #define PHONESP_BUTTON 1
  39. #define PHONESP_VALUE 0
  40. // Registry strings
  41. #define REGSTR_PATH_WINDOWS_CURRENTVERSION TEXT("Software\\Microsoft\\Windows\\CurrentVersion")
  42. #define TAPI_REGKEY_ROOT REGSTR_PATH_WINDOWS_CURRENTVERSION TEXT("\\Telephony")
  43. #define TAPI_REGKEY_PROVIDERS TAPI_REGKEY_ROOT TEXT("\\Providers")
  44. #define TAPI_REGVAL_NUMPROVIDERS TEXT("NumProviders")
  45. #define HIDPHONE_TSPDLL TEXT("HIDPHONE.TSP")
  46. /////////////////////////////////////////////////////////////////////////////
  47. /////////////////////////////////////////////////////////////////////////////
  48. //
  49. // Telephony HID definitions
  50. // These are usages already defined in the Hid Telephony page.
  51. // Just defining the usages with User-friendly names
  52. //
  53. // Definitions of relevant usages on the telephony page.
  54. #define HID_USAGE_TELEPHONY_HANDSET ((USAGE) 0x04)
  55. #define HID_USAGE_TELEPHONY_HEADSET ((USAGE) 0x05)
  56. #define HID_USAGE_TELEPHONY_HOOKSWITCH ((USAGE) 0x20)
  57. #define HID_USAGE_TELEPHONY_FLASH ((USAGE) 0x21)
  58. #define HID_USAGE_TELEPHONY_HOLD ((USAGE) 0x23)
  59. #define HID_USAGE_TELEPHONY_REDIAL ((USAGE) 0x24)
  60. #define HID_USAGE_TELEPHONY_TRANSFER ((USAGE) 0x25)
  61. #define HID_USAGE_TELEPHONY_DROP ((USAGE) 0x26)
  62. #define HID_USAGE_TELEPHONY_PARK ((USAGE) 0x27)
  63. #define HID_USAGE_TELEPHONY_FORWARD_CALLS ((USAGE) 0x28)
  64. #define HID_USAGE_TELEPHONY_LINE ((USAGE) 0x2A)
  65. #define HID_USAGE_TELEPHONY_SPEAKER_PHONE ((USAGE) 0x2B)
  66. #define HID_USAGE_TELEPHONY_CONFERENCE ((USAGE) 0x2C)
  67. #define HID_USAGE_TELEPHONY_RING_SELECT ((USAGE) 0x2E)
  68. #define HID_USAGE_TELEPHONY_PHONE_MUTE ((USAGE) 0x2F)
  69. #define HID_USAGE_TELEPHONY_CALLERID ((USAGE) 0x30)
  70. #define HID_USAGE_TELEPHONY_SEND ((USAGE) 0x31)
  71. #define HID_USAGE_TELEPHONY_DONOTDISTURB ((USAGE) 0x72)
  72. #define HID_USAGE_TELEPHONY_RINGER ((USAGE) 0x9E)
  73. #define HID_USAGE_TELEPHONY_PHONE_KEY_0 ((USAGE) 0xB0)
  74. #define HID_USAGE_TELEPHONY_PHONE_KEY_1 ((USAGE) 0xB1)
  75. #define HID_USAGE_TELEPHONY_PHONE_KEY_2 ((USAGE) 0xB2)
  76. #define HID_USAGE_TELEPHONY_PHONE_KEY_3 ((USAGE) 0xB3)
  77. #define HID_USAGE_TELEPHONY_PHONE_KEY_4 ((USAGE) 0xB4)
  78. #define HID_USAGE_TELEPHONY_PHONE_KEY_5 ((USAGE) 0xB5)
  79. #define HID_USAGE_TELEPHONY_PHONE_KEY_6 ((USAGE) 0xB6)
  80. #define HID_USAGE_TELEPHONY_PHONE_KEY_7 ((USAGE) 0xB7)
  81. #define HID_USAGE_TELEPHONY_PHONE_KEY_8 ((USAGE) 0xB8)
  82. #define HID_USAGE_TELEPHONY_PHONE_KEY_9 ((USAGE) 0xB9)
  83. #define HID_USAGE_TELEPHONY_PHONE_KEY_STAR ((USAGE) 0xBA)
  84. #define HID_USAGE_TELEPHONY_PHONE_KEY_POUND ((USAGE) 0xBB)
  85. #define HID_USAGE_TELEPHONY_PHONE_KEY_A ((USAGE) 0xBC)
  86. #define HID_USAGE_TELEPHONY_PHONE_KEY_B ((USAGE) 0xBD)
  87. #define HID_USAGE_TELEPHONY_PHONE_KEY_C ((USAGE) 0xBE)
  88. #define HID_USAGE_TELEPHONY_PHONE_KEY_D ((USAGE) 0xBF)
  89. #define HID_USAGE_CONSUMER_VOLUME ((USAGE) 0xE0)
  90. #define PHONESP_ALLBUTTONMODES \
  91. ( PHONEBUTTONMODE_CALL | \
  92. PHONEBUTTONMODE_FEATURE | \
  93. PHONEBUTTONMODE_KEYPAD | \
  94. PHONEBUTTONMODE_LOCAL | \
  95. PHONEBUTTONMODE_DISPLAY )
  96. #define PHONESP_ALLBUTTONSTATES \
  97. (PHONEBUTTONSTATE_UP | \
  98. PHONEBUTTONSTATE_DOWN)
  99. // These act like bit masks which specify which reports are valid for a usage
  100. #define INPUT_REPORT 1
  101. #define OUTPUT_REPORT 2
  102. #define FEATURE_REPORT 4
  103. /*****************************************************************************/
  104. //
  105. // This structure holds the information for the button
  106. //
  107. typedef struct _PHONESP_BUTTON_INFO
  108. {
  109. // The ID for this button
  110. DWORD dwButtonID;
  111. // The ButtonMode (whether it is a PHONEBUTTONMODE_FEATURE or _KEYPAD, etc)
  112. DWORD dwButtonMode;
  113. // the Function (PHONEBUTTONFUNCTION_NONE or _FLASH, etc),
  114. DWORD dwButtonFunction;
  115. //
  116. // This data is relevant for only on-off control buttons. The current state
  117. // of the button is stored here
  118. //
  119. DWORD dwButtonState;
  120. // the Button Text associated for the button - these are present in the
  121. // string table
  122. LPWSTR szButtonText;
  123. } PHONESP_BUTTONINFO, *PPHONESP_BUTTONINFO;
  124. /*****************************************************************************/
  125. //
  126. //
  127. // User friendly names for the indexes into the capabilities of the phone structure
  128. //
  129. #define PHONESP_PHONE_KEY_0 0
  130. #define PHONESP_PHONE_KEY_1 1
  131. #define PHONESP_PHONE_KEY_2 2
  132. #define PHONESP_PHONE_KEY_3 3
  133. #define PHONESP_PHONE_KEY_4 4
  134. #define PHONESP_PHONE_KEY_5 5
  135. #define PHONESP_PHONE_KEY_6 6
  136. #define PHONESP_PHONE_KEY_7 7
  137. #define PHONESP_PHONE_KEY_8 8
  138. #define PHONESP_PHONE_KEY_9 9
  139. #define PHONESP_PHONE_KEY_STAR 10
  140. #define PHONESP_PHONE_KEY_POUND 11
  141. #define PHONESP_PHONE_KEY_A 12
  142. #define PHONESP_PHONE_KEY_B 13
  143. #define PHONESP_PHONE_KEY_C 14
  144. #define PHONESP_PHONE_KEY_D 15
  145. // The number of dial buttons supported by this tsp
  146. #define PHONESP_NUMBER_PHONE_KEYS 16
  147. // Feature Button indices
  148. #define PHONESP_FEATURE_FLASH 16
  149. #define PHONESP_FEATURE_HOLD 17
  150. #define PHONESP_FEATURE_REDIAL 18
  151. #define PHONESP_FEATURE_TRANSFER 19
  152. #define PHONESP_FEATURE_DROP 20
  153. #define PHONESP_FEATURE_PARK 21
  154. #define PHONESP_FEATURE_FORWARD 22
  155. #define PHONESP_FEATURE_LINE 23
  156. #define PHONESP_FEATURE_CONFERENCE 24
  157. #define PHONESP_FEATURE_RING_SELECT 25
  158. #define PHONESP_FEATURE_PHONE_MUTE 26
  159. #define PHONESP_FEATURE_CALLERID 27
  160. #define PHONESP_FEATURE_DONOTDISTURB 28
  161. #define PHONESP_FEATURE_SEND 29
  162. #define PHONESP_FEATURE_VOLUMEUP 30
  163. #define PHONESP_FEATURE_VOLUMEDOWN 31
  164. // The number of Feature buttons supported by this tsp
  165. #define PHONESP_NUMBER_FEATURE_BUTTONS 16
  166. #define PHONESP_NUMBER_BUTTONS ( PHONESP_NUMBER_PHONE_KEYS + \
  167. PHONESP_NUMBER_FEATURE_BUTTONS )
  168. //
  169. // The functions associated with the feature buttons
  170. //
  171. DWORD gdwButtonFunction[] =
  172. {
  173. PHONEBUTTONFUNCTION_FLASH,
  174. PHONEBUTTONFUNCTION_HOLD,
  175. PHONEBUTTONFUNCTION_LASTNUM,
  176. PHONEBUTTONFUNCTION_TRANSFER,
  177. PHONEBUTTONFUNCTION_DROP,
  178. PHONEBUTTONFUNCTION_PARK,
  179. PHONEBUTTONFUNCTION_FORWARD,
  180. PHONEBUTTONFUNCTION_CALLAPP,
  181. PHONEBUTTONFUNCTION_CONFERENCE,
  182. PHONEBUTTONFUNCTION_SELECTRING,
  183. PHONEBUTTONFUNCTION_MUTE,
  184. PHONEBUTTONFUNCTION_CALLID,
  185. PHONEBUTTONFUNCTION_DONOTDISTURB,
  186. PHONEBUTTONFUNCTION_SEND,
  187. PHONEBUTTONFUNCTION_VOLUMEUP,
  188. PHONEBUTTONFUNCTION_VOLUMEDOWN
  189. };
  190. //
  191. // The associated string table ID for the text of the phone buttons
  192. //
  193. DWORD gdwButtonText[] =
  194. {
  195. IDS_PHONE_KEY_0,
  196. IDS_PHONE_KEY_1,
  197. IDS_PHONE_KEY_2,
  198. IDS_PHONE_KEY_3,
  199. IDS_PHONE_KEY_4,
  200. IDS_PHONE_KEY_5,
  201. IDS_PHONE_KEY_6,
  202. IDS_PHONE_KEY_7,
  203. IDS_PHONE_KEY_8,
  204. IDS_PHONE_KEY_9,
  205. IDS_PHONE_KEY_STAR,
  206. IDS_PHONE_KEY_POUND,
  207. IDS_PHONE_KEY_A,
  208. IDS_PHONE_KEY_B,
  209. IDS_PHONE_KEY_C,
  210. IDS_PHONE_KEY_D,
  211. IDS_BUTTON_FLASH,
  212. IDS_BUTTON_HOLD,
  213. IDS_BUTTON_REDIAL,
  214. IDS_BUTTON_TRANSFER,
  215. IDS_BUTTON_DROP,
  216. IDS_BUTTON_PARK,
  217. IDS_BUTTON_FORWARD,
  218. IDS_BUTTON_LINE,
  219. IDS_BUTTON_CONFERENCE,
  220. IDS_BUTTON_RING_SELECT,
  221. IDS_BUTTON_MUTE,
  222. IDS_BUTTON_CALLERID,
  223. IDS_BUTTON_DONOTDISTURB,
  224. IDS_BUTTON_SEND,
  225. IDS_BUTTON_VOLUMEUP,
  226. IDS_BUTTON_VOLUMEDOWN
  227. };
  228. typedef struct _PHONESP_LOOKUP_USAGEINDEX
  229. {
  230. USAGE Usage;
  231. DWORD Index;
  232. }PHONESP_LOOKUPUSAGEINDEX, *PPHONESP_LOOKUPUSAGEINDEX;
  233. // inorder to look up the index for the feature button usages
  234. // The 1st value in this 2-D array are the feature usages supported
  235. // The 2nd value is the respective index
  236. PHONESP_LOOKUPUSAGEINDEX gdwLookupFeatureIndex [] =
  237. {
  238. { HID_USAGE_TELEPHONY_FLASH, PHONESP_FEATURE_FLASH },
  239. { HID_USAGE_TELEPHONY_HOLD, PHONESP_FEATURE_HOLD },
  240. { HID_USAGE_TELEPHONY_REDIAL, PHONESP_FEATURE_REDIAL },
  241. { HID_USAGE_TELEPHONY_TRANSFER, PHONESP_FEATURE_TRANSFER },
  242. { HID_USAGE_TELEPHONY_DROP, PHONESP_FEATURE_DROP },
  243. { HID_USAGE_TELEPHONY_PARK, PHONESP_FEATURE_PARK },
  244. { HID_USAGE_TELEPHONY_FORWARD_CALLS, PHONESP_FEATURE_FORWARD },
  245. { HID_USAGE_TELEPHONY_LINE, PHONESP_FEATURE_LINE },
  246. { HID_USAGE_TELEPHONY_CONFERENCE, PHONESP_FEATURE_CONFERENCE },
  247. { HID_USAGE_TELEPHONY_RING_SELECT, PHONESP_FEATURE_RING_SELECT },
  248. { HID_USAGE_TELEPHONY_PHONE_MUTE, PHONESP_FEATURE_PHONE_MUTE },
  249. { HID_USAGE_TELEPHONY_CALLERID, PHONESP_FEATURE_CALLERID },
  250. { HID_USAGE_TELEPHONY_DONOTDISTURB, PHONESP_FEATURE_DONOTDISTURB },
  251. { HID_USAGE_TELEPHONY_SEND, PHONESP_FEATURE_SEND }
  252. };
  253. /****************************************************************************/
  254. //
  255. // This structure maintains the information available about the phone. Every
  256. // phone that has been enumerated has this structure associated with it
  257. //
  258. typedef struct _PHONESP_PHONE_INFO
  259. {
  260. // The deviceID for the phone. The Device ID for the phone is initialized
  261. // in TSPI_providerInit
  262. DWORD dwDeviceID;
  263. //
  264. // The version negotiated with TAPI using TSPI_phoneNegotiateTSPIVersion
  265. // function that returns the highest SPI version the TSP can operate under
  266. // for this device.
  267. //
  268. DWORD dwVersion;
  269. //
  270. // if this is true then it means that the
  271. // phone is open and phone close on the device hasn't been called yet
  272. //
  273. BOOL bPhoneOpen;
  274. //
  275. // if this is false it means that this entry in the phone array is
  276. // unused and can be filled in with a new phone
  277. //
  278. BOOL bAllocated;
  279. //
  280. // if this is true it means that a PHONE_CREATE message was sent for this
  281. // phone, but we are waiting for a TSPI_providerCreatePhoneDevice
  282. //
  283. BOOL bCreatePending;
  284. //
  285. // if this is true it means that a PHONE_REMOVE message was sent for this
  286. // phone, but we are waiting for a TSPI_phoneClose
  287. //
  288. BOOL bRemovePending;
  289. //
  290. // This variable keeps a count of the number of requests queued for this
  291. // phone in the async queue
  292. //
  293. DWORD dwNumPendingReqInQueue;
  294. //
  295. // A handle to an event object which is set when there are no requests
  296. // pending in the queue for this phone. Phone Close waits on this event
  297. // to ensure that all asynchronous operations on the phone has been
  298. // completed
  299. //
  300. HANDLE hNoPendingReqInQueueEvent;
  301. //
  302. // The handle for the phone received from TAPI and used by the phone
  303. // to notify TAPI about the events occuring on this phone
  304. //
  305. HTAPIPHONE htPhone;
  306. //
  307. //Pointer to the Hid Device structure associated with this device
  308. //
  309. PHID_DEVICE pHidDevice;
  310. //
  311. // Whether the phone device has a render device associated with it
  312. //
  313. BOOL bRender;
  314. //
  315. // if the render device exists for this phone, this data contains the
  316. // render device id
  317. //
  318. DWORD dwRenderWaveId;
  319. //
  320. // Whether the phone device has a capture device associated with it
  321. //
  322. BOOL bCapture;
  323. //
  324. // if the capture device exists for this phone, this data contains the
  325. // capture device id
  326. //
  327. DWORD dwCaptureWaveId;
  328. // This event is signalled when a input report is recieved from the device
  329. HANDLE hInputReportEvent;
  330. // This event is signalled when the phone is closed
  331. HANDLE hCloseEvent;
  332. // A handle to the read thread
  333. HANDLE hReadThread;
  334. // The structure to be passed to the ReadFile function - This struct will
  335. // pass the hInputReportEvent which will be triggered when ReadFile returns
  336. LPOVERLAPPED lpOverlapped;
  337. // The Critical Section for this phone
  338. CRITICAL_SECTION csThisPhone;
  339. // lpfnPhoneEventProc is a callback function implemented by TAPI and
  340. // supplied to the TSP as a parameter to TSPI_phoneOpen The TSP calls this
  341. // function to report events that occur on the phone.
  342. //
  343. PHONEEVENT lpfnPhoneEventProc;
  344. // The phone states messages for which TAPI can receive notification
  345. DWORD dwPhoneStates;
  346. //
  347. // The phone state messages TAPI is interested in receiving
  348. //
  349. DWORD dwPhoneStateMsgs;
  350. //
  351. // The last three bits of this data signify which reports are valid for the
  352. // handset/speaker. If zero, the handset does not exist, if bit 0 is set -
  353. // input report can be received, if bit 1 is set - output report can be
  354. // sent, if bit 2 is set - feature report supported
  355. //
  356. DWORD dwHandset;
  357. DWORD dwSpeaker;
  358. //
  359. // The mode of the handset/ speaker at the moment whether _ONHOOK, _MIC,
  360. // _SPEAKER, _MICSPEAKER. These modes are defined by TAPI
  361. //
  362. DWORD dwHandsetHookSwitchMode;
  363. DWORD dwSpeakerHookSwitchMode;
  364. BOOL bSpeakerHookSwitchButton;
  365. //
  366. // The hookswitch supported on this phone - handset and/or speaker
  367. //
  368. DWORD dwHookSwitchDevs;
  369. // To determine whether the phone has a keypad
  370. BOOL bKeyPad;
  371. //
  372. // The last three bits of this data signify which reports are valid for the
  373. // ringer. If zero, the handset does not exist, if bit 0 is set - input
  374. // report can be received, if bit 1 is set - output report can be sent, if
  375. // bit 2 is set - feature report supported
  376. //
  377. DWORD dwRing;
  378. //
  379. // The last three bits of this data signify which reports are valid for the
  380. // volume control. If zero, the handset does not exist, if bit 0 is set - input
  381. // report can be received, if bit 1 is set - output report can be sent, if
  382. // bit 2 is set - feature report supported
  383. //
  384. DWORD dwVolume;
  385. //
  386. // The mode of the handset/ speaker at the moment whether ringing or not
  387. // if zero the phone is not ringing
  388. //
  389. DWORD dwRingMode;
  390. // The buttonmodes for which the phone will send phone events
  391. DWORD dwButtonModesMsgs;
  392. // The button states for which the phone will send phone events
  393. DWORD dwButtonStateMsgs;
  394. // Number of usable buttons on this phone
  395. DWORD dwNumButtons;
  396. PPHONESP_BUTTONINFO pButtonInfo;
  397. //
  398. // The Phone Name and other Info on this Phone which will be displayed
  399. //
  400. LPWSTR wszPhoneName, wszPhoneInfo;
  401. //
  402. // The buttons valid for this phone - the entry for the
  403. // corresponding button contains 0 if the button associated with the index
  404. // does not exist else it specifies the report types valid for this button
  405. // using the last 3 bits.
  406. //
  407. DWORD dwReportTypes[PHONESP_NUMBER_BUTTONS];
  408. //
  409. // After the button is created this contains the
  410. // report Id assigned to the button
  411. //
  412. DWORD dwButtonIds[PHONESP_NUMBER_BUTTONS];
  413. } PHONESP_PHONE_INFO, *PPHONESP_PHONE_INFO;
  414. /*****************************************************************************/
  415. typedef void (CALLBACK *ASYNCPROC)(PPHONESP_ASYNCREQINFO, BOOL);
  416. /*****************************************************************************/
  417. typedef struct _PHONESP_FUNC_INFO
  418. {
  419. // number of parameters in this array - don't actually use it, can be removed
  420. DWORD dwNumParams;
  421. // The pointer to the phone
  422. ULONG_PTR dwParam1;
  423. //
  424. // The rest of the parameters are dependent on the function
  425. // to which this parameter list is passed
  426. //
  427. ULONG_PTR dwParam2;
  428. ULONG_PTR dwParam3;
  429. ULONG_PTR dwParam4;
  430. ULONG_PTR dwParam5;
  431. ULONG_PTR dwParam6;
  432. ULONG_PTR dwParam7;
  433. ULONG_PTR dwParam8;
  434. } PHONESP_FUNC_INFO, far *PPHONESP_FUNC_INFO;
  435. /*****************************************************************************/
  436. typedef struct _PHONESP_ASYNC_REQUEST_INFO
  437. {
  438. // The function to be executed
  439. ASYNCPROC pfnAsyncProc;
  440. // Parameters to be passed to the async function
  441. PPHONESP_FUNC_INFO pFuncInfo;
  442. } PHONESP_ASYNC_REQ_INFO, *PPHONESP_ASYNC_REQ_INFO;
  443. /*****************************************************************************/
  444. typedef struct _PHONESP_ASYNC_QUEUE
  445. {
  446. //
  447. //The handle to the thread which services the queue
  448. //
  449. HANDLE hAsyncEventQueueServiceThread;
  450. //
  451. // The event if set signifies pending entries in the queue
  452. // else the thread waits on this thread
  453. //
  454. HANDLE hAsyncEventsPendingEvent;
  455. CRITICAL_SECTION AsyncEventQueueCritSec;
  456. DWORD dwNumTotalQueueEntries;
  457. DWORD dwNumUsedQueueEntries;
  458. //Pointer to the queue
  459. PPHONESP_ASYNC_REQ_INFO *pAsyncRequestQueue;
  460. //Pointer to the next entry in the queue where the request can be added
  461. PPHONESP_ASYNC_REQ_INFO *pAsyncRequestQueueIn;
  462. //Pointer to the next request to be serviced in the queue
  463. PPHONESP_ASYNC_REQ_INFO *pAsyncRequestQueueOut;
  464. } PHONESP_ASYNCQUEUE, *PPHONESP_ASYNCQUEUE;
  465. /*****************************************************************************/
  466. //
  467. // All these might be combined in a global structure
  468. //
  469. DWORD gdwNumPhones;
  470. HINSTANCE ghInst;
  471. DWORD gdwPermanentProviderID;
  472. DWORD gdwPhoneDeviceIDBase;
  473. HPROVIDER ghProvider;
  474. // The memory for this queue is allocated in providerInit and will be used to
  475. // store requests on the phone. These requests will be processed asynchronously
  476. // by a separate Thread created on this queue
  477. PHONESP_ASYNCQUEUE gAsyncQueue, gInputReportQueue;
  478. // 256 is just a random number taken for the initial number of entries that the
  479. // can have.. the queue can be expanded later as required
  480. #define MAX_QUEUE_ENTRIES 256
  481. //
  482. // glpfnCompletionProc is a callback function implemented by TAPI and supplied
  483. // to the TSP as a parameter to TSPI_providerInit.The TSP calls this function
  484. // to report the completion of a line or phone procedure that it executes
  485. // asynchronously.
  486. //
  487. ASYNC_COMPLETION glpfnCompletionProc;
  488. //
  489. // glpfnPhoneCreateProc is a callback function implemented by TAPI and supplied
  490. // to the TSP as a parameter to TSPI_providerInit The TSP calls this function
  491. // to report the creation of a new device.
  492. //
  493. PHONEEVENT glpfnPhoneCreateProc;
  494. // gpPhone maintains an array of the phones enumerated - each of these phones
  495. // have a corresponding HidDevice value in the gpHidDevices.
  496. PPHONESP_PHONE_INFO *gpPhone;
  497. // This the global heap from which all the memory allocations are carried out
  498. HANDLE ghHeap;
  499. // This two handles are required for registering for PNP events
  500. HANDLE ghDevNotify;
  501. HWND ghWndNotify;
  502. const LPCWSTR gpcstrServiceName = _T("TapiSrv");
  503. LPCWSTR gszProviderInfo;
  504. // This is to notify the thread that services the queue to exit
  505. // maybe this could be changed to an event based termination of thread
  506. BOOL gbProviderShutdown = FALSE;
  507. CRITICAL_SECTION csAllPhones;
  508. CRITICAL_SECTION csHidList;
  509. PPHONESP_MEMINFO gpMemFirst = NULL, gpMemLast = NULL;
  510. CRITICAL_SECTION csMemoryList;
  511. BOOL gbBreakOnLeak = FALSE;
  512. /**********************PRIVATE FUNCTIONS**************************************/
  513. BOOL
  514. AsyncRequestQueueIn (
  515. PPHONESP_ASYNC_REQ_INFO pAsyncReqInfo
  516. );
  517. LONG
  518. CreateButtonsAndAssignID(
  519. PPHONESP_PHONE_INFO pPhone
  520. );
  521. PPHONESP_BUTTONINFO
  522. GetButtonFromID (
  523. PPHONESP_PHONE_INFO pPhone,
  524. DWORD dwButtonID
  525. );
  526. VOID
  527. GetButtonUsages(
  528. PPHONESP_PHONE_INFO pPhone,
  529. PHIDP_BUTTON_CAPS pButtonCaps,
  530. DWORD dwNumberButtonCaps,
  531. DWORD ReportType
  532. );
  533. PPHONESP_PHONE_INFO
  534. GetPhoneFromID(
  535. DWORD dwDeviceID,
  536. DWORD * pdwPhoneID
  537. );
  538. PPHONESP_PHONE_INFO
  539. GetPhoneFromHid (
  540. PHID_DEVICE HidDevice
  541. );
  542. VOID
  543. GetValueUsages(
  544. PPHONESP_PHONE_INFO pPhone,
  545. PHIDP_VALUE_CAPS pValueCaps,
  546. DWORD dwNumberCaps,
  547. DWORD ReportType
  548. );
  549. VOID
  550. InitPhoneAttribFromUsage (
  551. DWORD ReportType,
  552. USAGE UsagePage,
  553. USAGE Usage,
  554. PPHONESP_PHONE_INFO pPhone,
  555. LONG Min,
  556. LONG Max
  557. );
  558. LONG
  559. LookupIndexForUsage(
  560. IN DWORD Usage,
  561. OUT DWORD *Index
  562. );
  563. DWORD
  564. WINAPI
  565. PNPServiceHandler(
  566. DWORD dwControl,
  567. DWORD dwEventType,
  568. LPVOID lpEventData,
  569. LPVOID lpContext
  570. );
  571. VOID
  572. ReportUsage (
  573. PPHONESP_PHONE_INFO pPhone,
  574. USAGE UsagePage,
  575. USAGE Usage,
  576. ULONG Value
  577. );
  578. VOID
  579. SendPhoneEvent(
  580. PPHONESP_PHONE_INFO pPhone,
  581. DWORD dwMsg,
  582. ULONG_PTR Param1,
  583. ULONG_PTR Param2,
  584. ULONG_PTR Param3
  585. );
  586. LONG
  587. SendOutputReport(
  588. PHID_DEVICE pHidDevice,
  589. USAGE Usage,
  590. BOOL bSet
  591. );
  592. VOID
  593. CALLBACK
  594. ShowData(
  595. PPHONESP_FUNC_INFO pAsyncFuncInfo
  596. );
  597. LPWSTR
  598. PHONESP_LoadString(
  599. IN UINT ResourceID,
  600. PLONG lResult
  601. );
  602. BOOL
  603. ReadInputReport (
  604. PPHONESP_PHONE_INFO pPhone
  605. );
  606. VOID
  607. InitUsage (
  608. PPHONESP_PHONE_INFO pPhone,
  609. USAGE Usage,
  610. BOOL bON
  611. );
  612. VOID
  613. ReenumDevices ();
  614. VOID
  615. FreePhone (
  616. PPHONESP_PHONE_INFO pPhone
  617. );
  618. LONG
  619. CreatePhone (
  620. PPHONESP_PHONE_INFO pPhone,
  621. PHID_DEVICE pHidDevice,
  622. DWORD dwPhoneCnt
  623. );
  624. #endif