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.

1097 lines
30 KiB

  1. /*++
  2. Copyright (c) 1999 Microsoft Corporation
  3. Module Name:
  4. provider.cpp
  5. Abstract:
  6. TAPI Service Provider functions related to provider info.
  7. TSPI_providerConfig
  8. TSPI_providerEnumDevices
  9. TSPI_providerFreeDialogInstance
  10. TSPI_providerGenericDialogData
  11. TSPI_providerInit
  12. TSPI_providerInstall
  13. TSPI_providerRemove
  14. TSPI_providerShutdown
  15. TSPI_providerUIIdentify
  16. TUISPI_providerConfig
  17. TUISPI_providerInstall
  18. TUISPI_providerRemove
  19. Author:
  20. Nikhil Bobde (NikhilB)
  21. Revision History:
  22. --*/
  23. //
  24. // Include files
  25. //
  26. #include "globals.h"
  27. #include "line.h"
  28. #include "config.h"
  29. #include "q931obj.h"
  30. #include "ras.h"
  31. //
  32. // Global variables
  33. //
  34. DWORD g_dwLineDeviceIDBase = -1;
  35. DWORD g_dwPermanentProviderID = -1;
  36. LINEEVENT g_pfnLineEventProc = NULL;
  37. HANDLE g_hCanUnloadDll = NULL;
  38. HANDLE g_hEventLogSource = NULL;
  39. static HPROVIDER g_hProvider = NULL;
  40. ASYNC_COMPLETION g_pfnCompletionProc = NULL;
  41. // //
  42. // Public procedures //
  43. // //
  44. BOOL
  45. H323IsTSPAlreadyInstalled(void)
  46. /*++
  47. Routine Description:
  48. Searchs registry for previous instance of H323.TSP.
  49. Arguments:
  50. None.
  51. Return Values:
  52. Returns true if TSP already installed.
  53. --*/
  54. {
  55. DWORD i;
  56. HKEY hKey;
  57. LONG lStatus;
  58. DWORD dwNumProviders = 0;
  59. DWORD dwDataSize = sizeof(DWORD);
  60. DWORD dwDataType = REG_DWORD;
  61. LPTSTR pszProvidersKey = TAPI_REGKEY_PROVIDERS;
  62. LPTSTR pszNumProvidersValue = TAPI_REGVAL_NUMPROVIDERS;
  63. TCHAR szName[H323_MAXPATHNAMELEN+1];
  64. TCHAR szPath[H323_MAXPATHNAMELEN+1];
  65. // attempt to open key
  66. lStatus = RegOpenKeyEx(
  67. HKEY_LOCAL_MACHINE,
  68. pszProvidersKey,
  69. 0,
  70. KEY_READ,
  71. &hKey
  72. );
  73. // validate status
  74. if (lStatus != NOERROR)
  75. {
  76. H323DBG(( DEBUG_LEVEL_WARNING,
  77. "error 0x%08lx opening tapi providers key.", lStatus ));
  78. // done
  79. return FALSE;
  80. }
  81. // see if installed bit set
  82. lStatus = RegQueryValueEx(
  83. hKey,
  84. pszNumProvidersValue,
  85. 0,
  86. &dwDataType,
  87. (LPBYTE) &dwNumProviders,
  88. &dwDataSize
  89. );
  90. // validate status
  91. if( lStatus != NOERROR )
  92. {
  93. H323DBG(( DEBUG_LEVEL_WARNING,
  94. "error 0x%08lx determining number of providers.", lStatus ));
  95. // release handle
  96. RegCloseKey(hKey);
  97. // done
  98. return FALSE;
  99. }
  100. // loop through each provider
  101. for (i = 0; i < dwNumProviders; i++)
  102. {
  103. // construct path to provider name
  104. wsprintf(szName, _T("ProviderFileName%d"), i);
  105. // reinitialize size
  106. dwDataSize = sizeof(szPath);
  107. // query the next name
  108. lStatus = RegQueryValueEx(
  109. hKey,
  110. szName,
  111. 0,
  112. &dwDataType,
  113. (unsigned char*)szPath,
  114. &dwDataSize
  115. );
  116. // validate status
  117. if (lStatus == NOERROR)
  118. {
  119. // upper case
  120. _tcsupr(szPath);
  121. // compare path string to h323 provider
  122. if (_tcsstr(szPath, H323_TSPDLL) != NULL)
  123. {
  124. // release handle
  125. RegCloseKey(hKey);
  126. // done
  127. return TRUE;
  128. }
  129. } else {
  130. H323DBG((
  131. DEBUG_LEVEL_WARNING,
  132. "error 0x%08lx loading %s.",
  133. lStatus,
  134. szName
  135. ));
  136. }
  137. }
  138. // release handle
  139. RegCloseKey(hKey);
  140. // done
  141. return FALSE;
  142. }
  143. //
  144. // TSPI procedures
  145. //
  146. /*++
  147. Routine Description:
  148. This function is called by TAPI in response to receipt of a LINE_CREATE
  149. message from the service provider, which allows the dynamic creation of
  150. a new line device.
  151. Arguments:
  152. dwTempID - The temporary device identifier that the service provider
  153. passed to TAPI in the LINE_CREATE message.
  154. dwDeviceID - The device identifier that TAPI assigns to this device if
  155. this function succeeds.
  156. Return Values:
  157. Returns zero if the request is successful or a negative error number if
  158. an error has occurred. Possible return values are:
  159. LINEERR_BADDEVICEID - The specified line device ID is out of range.
  160. LINEERR_NOMEM - Unable to allocate or lock memory.
  161. LINEERR_OPERATIONFAILED - The specified operation failed for unknown
  162. reasons.
  163. --*/
  164. LONG
  165. TSPIAPI
  166. TSPI_providerCreateLineDevice(
  167. DWORD_PTR dwTempID,
  168. DWORD dwDeviceID
  169. )
  170. {
  171. //in the new TSP we don't support creating multiple H323 lines.
  172. //So return success silently but assert in the debug version
  173. _ASSERTE(0);
  174. /*H323DBG(( DEBUG_LEVEL_TRACE,
  175. "creating new device %d (hdLine=0x%08lx).",
  176. dwDeviceID, dwTempID ));
  177. // lock line device using temporary device id
  178. if (!H323GetLineFromIDAndLock(&pLine, (DWORD)dwTempID))
  179. {
  180. H323DBG(( DEBUG_LEVEL_ERROR,
  181. "invalid temp device id 0x%08lx.", dwTempID ));
  182. // failure
  183. return LINEERR_BADDEVICEID;
  184. }
  185. // initialize new line device
  186. H323InitializeLine(pLine, dwDeviceID);
  187. // unlock line
  188. H323UnlockLine(pLine);*/
  189. // success
  190. return NOERROR;
  191. }
  192. /*++
  193. Routine Description:
  194. TAPI.DLL calls this function before TSPI_providerInit to determine the
  195. number of line and phone devices supported by the service provider.
  196. Arguments:
  197. dwPermanentProviderID - Specifies the permanent ID, unique within the
  198. service providers on this system, of the service provider being
  199. initialized.
  200. pdwNumLines - Specifies a far pointer to a DWORD-sized memory location
  201. into which the service provider must write the number of line devices
  202. it is configured to support. TAPI.DLL initializes the value to zero,
  203. so if the service provider fails to write a different value, the
  204. value 0 is assumed.
  205. pdwNumPhones - Specifies a far pointer to a DWORD-sized memory location
  206. into which the service provider must write the number of phone devices
  207. it is configured to support. TAPI.DLL initializes the value to zero,
  208. so if the service provider fails to write a different value, the
  209. value 0 is assumed.
  210. hProvider - Specifies an opaque DWORD-sized value which uniquely identifies
  211. this instance of this service provider during this execution of the
  212. Windows Telephony environment.
  213. pfnLineCreateProc - Specifies a far pointer to the LINEEVENT callback
  214. procedure supplied by TAPI.DLL. The service provider will use this
  215. function to send LINE_CREATE messages when a new line device needs to
  216. be created. This function should not be called to send a LINE_CREATE
  217. message until after the service provider has returned from the
  218. TSPI_providerInit procedure.
  219. pfnPhoneCreateProc - Specifies a far pointer to the PHONEEVENT callback
  220. procedure supplied by TAPI.DLL. The service provider will use this
  221. function to send PHONE_CREATE messages when a new phone device needs
  222. to be created. This function should not be called to send a
  223. PHONE_CREATE message until after the service provider has returned
  224. from the TSPI_providerInit procedure.
  225. Return Values:
  226. Returns zero if the request is successful or a negative error number if
  227. an error has occurred. Possible return values are:
  228. LINEERR_NOMEM - Unable to allocate or lock memory.
  229. LINEERR_OPERATIONFAILED - The specified operation failed for unknown
  230. reasons.
  231. --*/
  232. LONG
  233. TSPIAPI
  234. TSPI_providerEnumDevices(
  235. DWORD dwPermanentProviderID,
  236. PDWORD pdwNumLines,
  237. PDWORD pdwNumPhones,
  238. HPROVIDER hProvider,
  239. LINEEVENT pfnLineCreateProc,
  240. PHONEEVENT pfnPhoneCreateProc
  241. )
  242. {
  243. UNREFERENCED_PARAMETER(pdwNumPhones); // no phone support
  244. UNREFERENCED_PARAMETER(pfnPhoneCreateProc); // no dynamic phones
  245. UNREFERENCED_PARAMETER(dwPermanentProviderID); // legacy parameter
  246. H323DBG(( DEBUG_LEVEL_TRACE, "TSPI_providerEnumDevices - Entered." ));
  247. // save provider handle
  248. g_hProvider = hProvider;
  249. // save line create tapi callback
  250. g_pfnLineEventProc = pfnLineCreateProc;
  251. _ASSERTE(g_pfnLineEventProc);
  252. H323DBG(( DEBUG_LEVEL_VERBOSE, "service provider supports 1 line."));
  253. // report number of interfaces
  254. *pdwNumLines = 1;
  255. H323DBG(( DEBUG_LEVEL_TRACE, "TSPI_providerEnumdevices - Exited." ));
  256. // success
  257. return NOERROR;
  258. }
  259. static LONG H323Initialize (
  260. IN DWORD LineDeviceIDBase)
  261. {
  262. WSADATA wsaData;
  263. WORD wVersionRequested = H323_WINSOCKVERSION;
  264. HRESULT hr;
  265. H323DBG(( DEBUG_LEVEL_TRACE, "H323Initialize - Entered." ));
  266. // initialize winsock stack
  267. WSAStartup(wVersionRequested, &wsaData);
  268. if (!g_pH323Line -> Initialize (LineDeviceIDBase))
  269. {
  270. H323DBG(( DEBUG_LEVEL_ERROR, "init failed for h323 line." ));
  271. return ERROR_GEN_FAILURE;
  272. }
  273. RegistryStart();
  274. g_hCanUnloadDll = H323CreateEvent( NULL, TRUE, TRUE,
  275. _T( "H323TSP_DLLUnloadEvent" ) );
  276. if( g_hCanUnloadDll == NULL )
  277. {
  278. H323DBG(( DEBUG_LEVEL_ERROR, "could not create unloadDLL handle." ));
  279. return ERROR_GEN_FAILURE;
  280. }
  281. #if H323_USE_PRIVATE_IO_THREAD
  282. hr = H323IoThreadStart();
  283. if (hr != S_OK)
  284. return ERROR_GEN_FAILURE;
  285. #endif
  286. H323DBG(( DEBUG_LEVEL_TRACE, "H323Initialize - Exited." ));
  287. return ERROR_SUCCESS;
  288. }
  289. void ReportTSPEvent(
  290. LPCTSTR wszErrorMessage )
  291. {
  292. if( g_hEventLogSource )
  293. {
  294. ReportEvent(
  295. g_hEventLogSource, // handle of event source
  296. EVENTLOG_ERROR_TYPE,// event type
  297. 0, // event category
  298. 0x80000001, // event ID
  299. NULL, // user SID
  300. 1, // string count
  301. 0, // no bytes of raw data
  302. &wszErrorMessage, // array of error strings
  303. NULL); // no raw data
  304. }
  305. }
  306. static
  307. VOID H323Shutdown (void)
  308. {
  309. H323DBG(( DEBUG_LEVEL_TRACE, "H323Shutdown entered" ));
  310. g_pH323Line -> Shutdown();
  311. RegistryStop();
  312. if( g_hCanUnloadDll != NULL )
  313. {
  314. H323DBG(( DEBUG_LEVEL_WARNING, "waiting for i/o refcount to get 0..." ));
  315. //wait until all the calls have been deleted
  316. WaitForSingleObject(
  317. g_hCanUnloadDll,
  318. 300 * 1000 // Wait for 5 minutes to let everything shutdown.
  319. );
  320. H323DBG ((DEBUG_LEVEL_WARNING, "i/o refcount is 0..."));
  321. CloseHandle( g_hCanUnloadDll );
  322. g_hCanUnloadDll = NULL;
  323. //sleep for 500 ms
  324. Sleep( 500 );
  325. }
  326. #if H323_USE_PRIVATE_IO_THREAD
  327. H323IoThreadStop();
  328. #endif
  329. if( g_hEventLogSource )
  330. {
  331. DeregisterEventSource( g_hEventLogSource );
  332. g_hEventLogSource = NULL;
  333. }
  334. // shutdown
  335. WSACleanup();
  336. H323DBG(( DEBUG_LEVEL_TRACE, "H323Shutdown exited" ));
  337. }
  338. /*++
  339. Routine Description:
  340. Initializes the service provider, also giving it parameters required for
  341. subsequent operation.
  342. This function is guaranteed to be called before any of the other functions
  343. prefixed with TSPI_line or TSPI_phone except TSPI_lineNegotiateTSPIVersion.
  344. It is strictly paired with a subsequent call to TSPI_providerShutdown. It
  345. is the caller's reponsibility to ensure proper pairing.
  346. Note that a service provider should perform as many consistency checks as
  347. is practical at the time TSPI_providerInit is called to ensure that it is
  348. ready to run. Some consistency or installation errors, however, may not be
  349. detectable until the operation is attempted. The error LINEERR_NODRIVER can
  350. be used to report such non-specific errors at the time they are detected.
  351. There is no directly corresponding function at the TAPI level. At that
  352. level, multiple different usage instances can be outstanding, with an
  353. "application handle" returned to identify the instance in subsequent
  354. operations. At the TSPI level, the interface architecture supports only a
  355. single usage instance for each distinct service provider.
  356. A new parameter, lpdwTSPIOptions, is added to this function. This parameter
  357. allows the service provider to return bits indicating optional behaviors
  358. desired of TAPI. TAPI sets the options DWORD to 0 before calling
  359. TSPI_providerInit, so if the service provider doesn't want any of these
  360. options, it can just leave the DWORD set to 0.
  361. At this time, only one bit is defined to be returned through this pointer:
  362. LINETSPIOPTION_NONREENTRANT. The service provider sets this bit if it is
  363. not designed for fully pre-emptive, multithreaded, multitasking,
  364. multiprocessor operation (e.g., updating of global data protected by
  365. mutexes). When this bit is set, TAPI will only make one call at a time to
  366. the service provider; it will not call any other entry point, nor that
  367. entry point again, until the service provider returns from the original
  368. function call. Without this bit set, TAPI may call into multiple service
  369. provider entry points, including multiple times to the same entry point,
  370. simultaneously (actually simultaneously in a multiprocessor system). Note:
  371. TAPI will not serialize access to TSPI functions that display a dialog
  372. (TUISPI_lineConfigDialog, TUISPI_lineConfigDialogEdit,
  373. TUISPI_phoneConfigDialog, TUISPI_providerConfig, TUISPI_providerInstall,
  374. TUISPI_providerRemove) so that they do not block other TSPI functions
  375. from being called; the service provider must include internal protection
  376. on these functions.
  377. Arguments:
  378. dwTSPIVersion - Specifies the version of the TSPI definition under which
  379. this function must operate. The caller may use
  380. TSPI_lineNegotiateTSPIVersion with the special dwDeviceID
  381. INITIALIZE_NEGOTIATION to negotiate a version that is guaranteed to be
  382. acceptible to the service provider.
  383. dwPermanentProviderID - Specifies the permanent ID, unique within the
  384. service providers on this system, of the service provider being
  385. initialized.
  386. dwLineDeviceIDBase - Specifies the lowest device ID for the line devices
  387. supported by this service provider.
  388. dwPhoneDeviceIDBase - Specifies the lowest device ID for the phone devices
  389. supported by this service provider.
  390. dwNumLines - Specifies how many line devices this service provider
  391. supports.
  392. dwNumPhones - Specifies how many line devices this service provider
  393. supports.
  394. pfnCompletionProc - Specifies the procedure the service provider calls to
  395. report completion of all asynchronously operating procedures on line
  396. and phone devices.
  397. pdwTSPIOptions - A pointer to a DWORD-sized memory location, into which
  398. the service provider may write a value specifying LINETSPIOPTIONS_
  399. values.
  400. Return Values:
  401. Returns zero if the function is successful, or a negative error number if
  402. an error has occurred. Possible return values are as follows:
  403. LINEERR_INCOMPATIBLEAPIVERSION - The application requested an API
  404. version or version range that is either incompatible or cannot be
  405. supported by the Telephony API implementation and/or corresponding
  406. service provider.
  407. LINEERR_NOMEM - Unable to allocate or lock memory.
  408. LINEERR_OPERATIONFAILED - The specified operation failed for unknown
  409. reasons.
  410. LINEERR_RESOURCEUNAVAIL - Insufficient resources to complete the
  411. operation.
  412. --*/
  413. LONG
  414. TSPIAPI
  415. TSPI_providerInit(
  416. DWORD dwTSPIVersion,
  417. DWORD dwPermanentProviderID,
  418. DWORD dwLineDeviceIDBase,
  419. DWORD dwPhoneDeviceIDBase,
  420. DWORD_PTR dwNumLines,
  421. DWORD_PTR dwNumPhones,
  422. ASYNC_COMPLETION pfnCompletionProc,
  423. LPDWORD pdwTSPIOptions
  424. )
  425. {
  426. LONG dwStatus;
  427. UNREFERENCED_PARAMETER (dwNumLines); // legacy parameter
  428. UNREFERENCED_PARAMETER (dwNumPhones); // legacy parameter
  429. UNREFERENCED_PARAMETER (dwPhoneDeviceIDBase); // no phone support
  430. UNREFERENCED_PARAMETER (pdwTSPIOptions); // already thread-safe
  431. #if DBG
  432. // Register for trace output.
  433. TRACELogRegister(_T("h323tsp"));
  434. #else
  435. OpenLogFile();
  436. #endif
  437. // make sure this is a version we support
  438. if (!H323ValidateTSPIVersion(dwTSPIVersion))
  439. {
  440. H323DBG(( DEBUG_LEVEL_ERROR,
  441. "provider init::incompatible tspi version." ));
  442. // incompatible api version
  443. return LINEERR_INCOMPATIBLEAPIVERSION;
  444. }
  445. dwStatus = H323Initialize (dwLineDeviceIDBase);
  446. if (dwStatus == ERROR_SUCCESS)
  447. {
  448. // save global service provider info
  449. // we don't store dwTSPIVersion, because our behavior does not change based
  450. // on any negotiated version.
  451. // if this changes in the future, then we will record the negotiated version.
  452. g_pfnCompletionProc = pfnCompletionProc;
  453. _ASSERTE( g_pfnCompletionProc );
  454. g_dwLineDeviceIDBase = dwLineDeviceIDBase;
  455. g_dwPermanentProviderID = dwPermanentProviderID;
  456. }
  457. else
  458. {
  459. H323Shutdown();
  460. }
  461. return dwStatus;
  462. }
  463. LONG
  464. TSPIAPI
  465. TSPI_providerShutdown(
  466. DWORD dwTSPIVersion,
  467. DWORD dwPermanentProviderID
  468. )
  469. /*++
  470. Routine Description:
  471. Shuts down the service provider. The service provider should terminate
  472. any activities it has in progress and release any resources it has
  473. allocated.
  474. Arguments:
  475. dwTSPIVersion - Specifies the version of the TSPI definition under which
  476. this function must operate. The caller may use
  477. TSPI_lineNegotiateTSPIVersion or TSPI_phoneNegotiateTSPIVersion with
  478. the special dwDeviceID INITIALIZE_NEGOTIATION to negotiate a version
  479. that is guaranteed to be acceptible to the service provider.
  480. dwPermanentProviderID - Specifies the permanent ID, unique within the
  481. service providers on this system, of the service provider being
  482. shut down.
  483. Return Values:
  484. Returns zero if the function is successful, or a negative error number
  485. if an error has occurred. Possible return values are as follows:
  486. LINEERR_INCOMPATIBLEAPIVERSION - The application requested an API
  487. version or version range that is either incompatible or cannot be
  488. supported by the Telephony API implementation and/or corresponding
  489. service provider.
  490. LINEERR_NOMEM - Unable to allocate or lock memory.
  491. LINEERR_OPERATIONFAILED - The specified operation failed for unknown
  492. reasons.
  493. --*/
  494. {
  495. UNREFERENCED_PARAMETER(dwPermanentProviderID); // legacy parameter
  496. H323DBG(( DEBUG_LEVEL_TRACE, "TSPI_providerShutdown - Entered." ));
  497. // make sure this is a version we support
  498. if (!H323ValidateTSPIVersion(dwTSPIVersion))
  499. {
  500. H323DBG(( DEBUG_LEVEL_ERROR, "invalid tspi version." ));
  501. // failure
  502. return LINEERR_INCOMPATIBLEAPIVERSION;
  503. }
  504. H323Shutdown();
  505. H323DBG(( DEBUG_LEVEL_TRACE, "TSPI_providerShutdown - Exited." ));
  506. return ERROR_SUCCESS;
  507. }
  508. LONG
  509. TSPIAPI
  510. TSPI_providerInstall(
  511. HWND hwndOwner,
  512. DWORD dwPermanentProviderID
  513. )
  514. /*++
  515. Routine Description:
  516. The TSPI_providerInstall function is obsolete. TAPI version 1.4
  517. or earlier service providers can implement this TSPI function.
  518. TAPI version 2.0 or later TSPs implement TUISPI_providerInstall.
  519. Arguments:
  520. hwndOwner - The handle of the parent window in which the function
  521. can create any dialog box windows that are required during
  522. installation.
  523. dwPermanentProviderID - The service provider's permanent provider
  524. identifier.
  525. Return Values:
  526. Always returns NOERROR.
  527. --*/
  528. {
  529. UNREFERENCED_PARAMETER(hwndOwner);
  530. UNREFERENCED_PARAMETER(dwPermanentProviderID);
  531. // success
  532. return NOERROR;
  533. }
  534. LONG
  535. TSPIAPI
  536. TSPI_providerRemove(
  537. HWND hwndOwner,
  538. DWORD dwPermanentProviderID
  539. )
  540. /*++
  541. Routine Description:
  542. The TSPI_providerRemove function is obsolete. TAPI version 1.4 or
  543. earlier service providers can implement this TSPI function. TAPI
  544. version 2.0 or later TSPs implement TUISPI_providerRemove.
  545. Arguments:
  546. hwndOwner - The handle of the parent window in which the function
  547. can create any dialog box windows that are required during
  548. installation.
  549. dwPermanentProviderID - The service provider's permanent provider
  550. identifier.
  551. Return Values:
  552. Always returns NOERROR.
  553. --*/
  554. {
  555. UNREFERENCED_PARAMETER(hwndOwner);
  556. UNREFERENCED_PARAMETER(dwPermanentProviderID);
  557. H323DBG(( DEBUG_LEVEL_TRACE, "TSPI_lineTSPIProviderRemove - Entered." ));
  558. H323DBG(( DEBUG_LEVEL_TRACE, "TSPI_lineTSPIProviderRemove - Exited." ));
  559. // success
  560. return NOERROR;
  561. }
  562. LONG
  563. TSPIAPI
  564. TSPI_providerUIIdentify(
  565. LPWSTR pwszUIDLLName
  566. )
  567. /*++
  568. Routine Description:
  569. The TSPI_providerUIIdentify function extracts from the service
  570. provider the fully qualified path to load the service provider's
  571. UI DLL component.
  572. Implementation is mandatory if the service provider implements
  573. any UI DLL functions.
  574. Arguments:
  575. pwszUIDLLName - Pointer to a block of memory at least MAX_PATH
  576. in length, into which the service provider must copy a NULL-
  577. terminated string specifying the fully-qualified path for the
  578. DLL containing the service provider functions which must execute
  579. in the process of the calling application.
  580. Return Values:
  581. Always returns NOERROR.
  582. --*/
  583. {
  584. H323DBG(( DEBUG_LEVEL_TRACE, "TSPI_ProviderUIIdentify - Entered." ));
  585. // copy name of our dll as ui dll
  586. lstrcpyW(pwszUIDLLName,H323_UIDLL);
  587. H323DBG(( DEBUG_LEVEL_TRACE, "TSPI_ProviderUIIdentify - Exited." ));
  588. // success
  589. return NOERROR;
  590. }
  591. /*++
  592. Routine Description:
  593. Implementation of the TUISPI_providerInstall function is the
  594. service provider's opportunity to install any additional
  595. "pieces" of the provider into the right directories (or at
  596. least verifying that they're there) and set up registry entries
  597. the provider needs.
  598. Arguments:
  599. pfnUIDLLCallback - Pointer to a function the UI DLL can call to
  600. communicate with the service provider DLL to obtain information
  601. needed to display the dialog box.
  602. hwndOwner - The handle of the parent window in which the function
  603. can create any dialog box windows that are required during
  604. installation.
  605. dwPermanentProviderID - The service provider's permanent provider
  606. identifier.
  607. Return Values:
  608. Returns zero if the function is successful, or a negative error number
  609. if an error has occurred. Possible return values are as follows:
  610. LINEERR_NOMEM - Unable to allocate or lock memory.
  611. LINEERR_NOMULTIPLEINSTANCE - A telephony service provider which
  612. does not support multiple instances is listed more than once
  613. in the [Providers] section in the registry. The application
  614. LINEERR_OPERATIONFAILED - The specified operation failed for unknown
  615. reasons.
  616. --*/
  617. LONG
  618. TSPIAPI
  619. TUISPI_providerInstall(
  620. TUISPIDLLCALLBACK pfnUIDLLCallback,
  621. HWND hwndOwner,
  622. DWORD dwPermanentProviderID
  623. )
  624. {
  625. HKEY hKey;
  626. HKEY hKeyTSP;
  627. LONG lStatus;
  628. LPTSTR pszKey;
  629. UNREFERENCED_PARAMETER(pfnUIDLLCallback);
  630. UNREFERENCED_PARAMETER(hwndOwner);
  631. UNREFERENCED_PARAMETER(dwPermanentProviderID);
  632. H323DBG(( DEBUG_LEVEL_TRACE, "TUISPI_providerInstall - Entered." ));
  633. // check for previous instance
  634. if (H323IsTSPAlreadyInstalled())
  635. {
  636. // cannot be installed twice
  637. return LINEERR_NOMULTIPLEINSTANCE;
  638. }
  639. // set key to h323
  640. pszKey = H323_REGKEY_ROOT;
  641. // attempt to open key
  642. lStatus = RegOpenKeyEx(
  643. HKEY_LOCAL_MACHINE,
  644. pszKey,
  645. 0,
  646. KEY_READ,
  647. &hKey
  648. );
  649. // validate status
  650. if( lStatus == NOERROR )
  651. {
  652. H323DBG((DEBUG_LEVEL_TRACE,
  653. "successfully installed H.323 provider." ));
  654. // release handle
  655. RegCloseKey(hKey);
  656. H323DBG(( DEBUG_LEVEL_TRACE, "TUISPI_providerInstall - Exited." ));
  657. // success
  658. return NOERROR;
  659. }
  660. // set key to windows
  661. pszKey = REGSTR_PATH_WINDOWS_CURRENTVERSION;
  662. // attempt to open key
  663. lStatus = RegOpenKeyEx(
  664. HKEY_LOCAL_MACHINE,
  665. pszKey,
  666. 0,
  667. KEY_WRITE,
  668. &hKey
  669. );
  670. // validate status
  671. if( lStatus != NOERROR )
  672. {
  673. H323DBG(( DEBUG_LEVEL_ERROR,
  674. "error 0x%08lx opening windows registry key.", lStatus ));
  675. // operation failed
  676. return LINEERR_OPERATIONFAILED;
  677. }
  678. // attempt to create key
  679. lStatus = RegCreateKey(
  680. hKey,
  681. H323_SUBKEY,
  682. &hKeyTSP
  683. );
  684. // validate status
  685. if (lStatus != NOERROR)
  686. {
  687. H323DBG(( DEBUG_LEVEL_ERROR,
  688. "error 0x%08lx creating tsp registry key.", lStatus ));
  689. // release handle
  690. RegCloseKey(hKey);
  691. // operation failed
  692. return LINEERR_OPERATIONFAILED;
  693. }
  694. H323DBG(( DEBUG_LEVEL_TRACE, "successfully installed H.323 provider." ));
  695. // release handle
  696. RegCloseKey(hKeyTSP);
  697. // release handle
  698. RegCloseKey(hKey);
  699. H323DBG(( DEBUG_LEVEL_TRACE, "TUISPI_providerInstall - Exited." ));
  700. // success
  701. return NOERROR;
  702. }
  703. LONG
  704. TSPIAPI
  705. TUISPI_providerRemove(
  706. TUISPIDLLCALLBACK pfnUIDLLCallback,
  707. HWND hwndOwner,
  708. DWORD dwPermanentProviderID
  709. )
  710. /*++
  711. Routine Description:
  712. The TUISPI_providerRemove function asks the user to confirm
  713. elimination of the service provider.
  714. It is the responsibility of the service provider to remove any
  715. registry entries that the service provider added at addProvider
  716. time, as well as any other modules and files that are no longer
  717. needed.
  718. Arguments:
  719. pfnUIDLLCallback - Pointer to a function the UI DLL can call to
  720. communicate with the service provider DLL to obtain information
  721. needed to display the dialog box.
  722. hwndOwner - The handle of the parent window in which the function
  723. can create any dialog box windows that are required during
  724. removal.
  725. dwPermanentProviderID - The service provider's permanent provider
  726. identifier.
  727. Return Values:
  728. Returns zero if the function is successful, or a negative error number
  729. if an error has occurred. Possible return values are as follows:
  730. LINEERR_NOMEM - Unable to allocate or lock memory.
  731. LINEERR_OPERATIONFAILED - The specified operation failed for unknown
  732. reasons.
  733. --*/
  734. {
  735. HKEY hKey;
  736. LONG lStatus;
  737. LPTSTR pszKey;
  738. UNREFERENCED_PARAMETER(pfnUIDLLCallback);
  739. UNREFERENCED_PARAMETER(hwndOwner);
  740. UNREFERENCED_PARAMETER(dwPermanentProviderID);
  741. // set key to h323
  742. pszKey = H323_REGKEY_ROOT;
  743. H323DBG(( DEBUG_LEVEL_FORCE, "TUISPI_providerRemove - Entered." ));
  744. // attempt to open key
  745. lStatus = RegOpenKeyEx(
  746. HKEY_LOCAL_MACHINE,
  747. pszKey,
  748. 0,
  749. KEY_READ,
  750. &hKey
  751. );
  752. // validate status
  753. if (lStatus != NOERROR)
  754. {
  755. H323DBG ((DEBUG_LEVEL_TRACE, "successfully removed H.323 provider."));
  756. H323DBG ((DEBUG_LEVEL_TRACE, "TUISPI_providerRemove - Exited."));
  757. // success
  758. return NOERROR;
  759. }
  760. // release handle
  761. RegCloseKey(hKey);
  762. // set key to windows
  763. pszKey = REGSTR_PATH_WINDOWS_CURRENTVERSION;
  764. // attempt to open key
  765. lStatus = RegOpenKeyEx(
  766. HKEY_LOCAL_MACHINE,
  767. pszKey,
  768. 0,
  769. KEY_WRITE,
  770. &hKey
  771. );
  772. // validate status
  773. if (lStatus != NOERROR)
  774. {
  775. H323DBG(( DEBUG_LEVEL_ERROR,
  776. "error 0x%08lx opening windows registry key.", lStatus ));
  777. // operation failed
  778. return LINEERR_OPERATIONFAILED;
  779. }
  780. // attempt to delete key
  781. lStatus = RegDeleteKey(
  782. hKey,
  783. H323_SUBKEY
  784. );
  785. // validate status
  786. if (lStatus != NOERROR)
  787. {
  788. H323DBG(( DEBUG_LEVEL_ERROR,
  789. "error 0x%08lx deleting tsp registry key.", lStatus ));
  790. // release handle
  791. RegCloseKey(hKey);
  792. // operation failed
  793. return LINEERR_OPERATIONFAILED;
  794. }
  795. H323DBG(( DEBUG_LEVEL_FORCE, "successfully removed H.323 provider." ));
  796. // release handle
  797. RegCloseKey(hKey);
  798. H323DBG(( DEBUG_LEVEL_TRACE, "TUISPI_providerRemove - Exited." ));
  799. // success
  800. return NOERROR;
  801. }