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.

948 lines
21 KiB

  1. /*++
  2. Copyright (c) 1997 Microsoft Corporation
  3. Module Name:
  4. tapi.c
  5. Abstract:
  6. This file implements WindowsNT side functionality for TAPI migration.
  7. Author:
  8. Marc R. Whitten (marcw) 21-Nov-1997
  9. Revision History:
  10. --*/
  11. #include "pch.h"
  12. typedef struct {
  13. PTSTR Name;
  14. PTSTR AreaCode;
  15. DWORD Country;
  16. PTSTR DisableCallWaiting;
  17. DWORD Flags;
  18. DWORD Id;
  19. PTSTR LongDistanceAccess;
  20. DWORD PulseDial;
  21. PTSTR OutsideAccess;
  22. DWORD CallingCard;
  23. TCHAR EntryName[40];
  24. } LOCATION, * PLOCATION;
  25. typedef struct {
  26. PTSTR Name;
  27. TCHAR EntryName[60];
  28. DWORD Id;
  29. PTSTR Pin;
  30. PTSTR Locale;
  31. PTSTR LongDistance;
  32. PTSTR International;
  33. DWORD Flags;
  34. } CALLINGCARD, * PCALLINGCARD;
  35. #define DBG_TAPI "TAPI"
  36. #define DEFAULT_LOCATION_FLAGS 1
  37. #define NO_CURRENT_LOCATION_FOUND -1
  38. GROWLIST g_LocationsList = GROWLIST_INIT;
  39. GROWLIST g_CallingCardList = GROWLIST_INIT;
  40. BOOL g_LocationsRead = FALSE;
  41. UINT g_CurrentLocation = 0;
  42. POOLHANDLE g_TapiPool;
  43. //
  44. // Location flags to set.
  45. //
  46. #define LOCATION_USETONEDIALING 0x01
  47. #define LOCATION_USECALLINGCARD 0x02
  48. #define LOCATION_HASCALLWAITING 0x04
  49. //
  50. // CallingCard flags to set.
  51. //
  52. #define CALLINGCARD_BUILTIN 0x01
  53. #define CALLINGCARD_HIDE 0x02
  54. //
  55. // Location key field specifiers (in telephon.ini)
  56. //
  57. enum {
  58. FIELD_ID = 1,
  59. FIELD_NAME = 2,
  60. FIELD_OUTSIDEACCESS = 3,
  61. FIELD_LONGDISTANCEACCESS = 4,
  62. FIELD_AREACODE = 5,
  63. FIELD_COUNTRY = 6,
  64. FIELD_CALLINGCARD = 7,
  65. FIELD_PULSEDIAL = 11,
  66. FIELD_DISABLECALLWAITING = 12
  67. };
  68. enum {
  69. FIELD_CC_ID = 1,
  70. FIELD_CC_NAME = 2,
  71. FIELD_CC_PIN = 3,
  72. FIELD_CC_LOCALE = 4,
  73. FIELD_CC_LONGDISTANCE = 5,
  74. FIELD_CC_INTERNATIONAL = 6,
  75. FIELD_CC_FLAGS = 7
  76. };
  77. #define S_USERLOCATIONSKEY TEXT("Software\\Microsoft\\Windows\\CurrentVersion\\Telephony\\Locations")
  78. #define S_USERCALLINGCARDSKEY TEXT("Software\\Microsoft\\Windows\\CurrentVersion\\Telephony\\Cards")
  79. #define S_LOCALRULE TEXT("LocalRule")
  80. #define S_LDRULE TEXT("LDRule")
  81. #define S_INTERNATIONALRULE TEXT("InternationalRule")
  82. #define S_PIN TEXT("Pin")
  83. #define S_CALLINGCARD TEXT("CallingCard")
  84. #define S_CARDS TEXT("Cards")
  85. BOOL
  86. pReadCardFromIniFile (
  87. IN PINFSTRUCT Is,
  88. OUT PCALLINGCARD Card
  89. )
  90. {
  91. BOOL rSuccess = TRUE;
  92. PTSTR p;
  93. MYASSERT(Is);
  94. MYASSERT(Card);
  95. p = InfGetStringField (Is, FIELD_CC_NAME);
  96. if (p) {
  97. Card->Name = PoolMemDuplicateString (g_TapiPool, p);
  98. }
  99. else {
  100. rSuccess = FALSE;
  101. }
  102. if (!InfGetIntField (Is, FIELD_CC_ID, &Card->Id)) {
  103. rSuccess = FALSE;
  104. }
  105. p = InfGetStringField (Is, FIELD_CC_LOCALE);
  106. if (p) {
  107. Card->Locale = PoolMemDuplicateString (g_TapiPool, p);
  108. }
  109. else {
  110. rSuccess = FALSE;
  111. }
  112. p = InfGetStringField (Is, FIELD_CC_LONGDISTANCE);
  113. if (p) {
  114. Card->LongDistance = PoolMemDuplicateString (g_TapiPool, p);
  115. }
  116. else {
  117. rSuccess = FALSE;
  118. }
  119. p = InfGetStringField (Is, FIELD_CC_INTERNATIONAL);
  120. if (p) {
  121. Card->International = PoolMemDuplicateString (g_TapiPool, p);
  122. }
  123. else {
  124. rSuccess = FALSE;
  125. }
  126. p = InfGetStringField (Is, FIELD_CC_PIN);
  127. if (p) {
  128. Card->Pin = PoolMemDuplicateString (g_TapiPool, p);
  129. }
  130. else {
  131. rSuccess = FALSE;
  132. }
  133. if (!InfGetIntField (Is, FIELD_CC_FLAGS, &Card->Flags)) {
  134. rSuccess = FALSE;
  135. }
  136. return rSuccess;
  137. }
  138. /*++
  139. Routine Description:
  140. pReadLocationFromIniFile reads the data located at the line in the ini file
  141. referenced by the InfStruct passed in and parses that information into a
  142. LOCATION structure.
  143. Arguments:
  144. Is - Initialized InfStruct pointing to a location line in an ini
  145. file.
  146. Location - Pointer to a location struct that recieves the parsed data.
  147. Return Value:
  148. TRUE if the line was successfully parsed, FALSE otherwise.
  149. --*/
  150. BOOL
  151. pReadLocationFromIniFile (
  152. IN PINFSTRUCT Is,
  153. OUT PLOCATION Location
  154. )
  155. {
  156. BOOL rSuccess = TRUE;
  157. PTSTR p;
  158. MYASSERT(Is);
  159. MYASSERT(Location);
  160. ZeroMemory(Location,sizeof(LOCATION));
  161. p = InfGetStringField (Is, FIELD_NAME);
  162. if (p) {
  163. Location -> Name = PoolMemDuplicateString (g_TapiPool, p);
  164. }
  165. else {
  166. rSuccess = FALSE;
  167. }
  168. p = InfGetStringField (Is, FIELD_AREACODE);
  169. if (p) {
  170. Location -> AreaCode = PoolMemDuplicateString (g_TapiPool, p);
  171. }
  172. else {
  173. rSuccess = FALSE;
  174. }
  175. if (!InfGetIntField(Is,FIELD_COUNTRY,&(Location -> Country))) {
  176. rSuccess = FALSE;
  177. }
  178. p = InfGetStringField (Is, FIELD_DISABLECALLWAITING);
  179. if (p) {
  180. Location -> DisableCallWaiting = PoolMemDuplicateString (g_TapiPool, p);
  181. }
  182. else {
  183. rSuccess = FALSE;
  184. }
  185. p = InfGetStringField (Is, FIELD_LONGDISTANCEACCESS);
  186. if (p) {
  187. Location -> LongDistanceAccess = PoolMemDuplicateString (g_TapiPool, p);
  188. }
  189. else {
  190. rSuccess = FALSE;
  191. }
  192. p = InfGetStringField (Is, FIELD_OUTSIDEACCESS);
  193. if (p) {
  194. Location -> OutsideAccess = PoolMemDuplicateString (g_TapiPool, p);
  195. }
  196. else {
  197. rSuccess = FALSE;
  198. }
  199. if (!InfGetIntField(Is,FIELD_ID, &(Location -> Id))) {
  200. rSuccess = FALSE;
  201. }
  202. if (!InfGetIntField(Is,FIELD_PULSEDIAL, &(Location -> PulseDial))) {
  203. rSuccess = FALSE;
  204. }
  205. if (!InfGetIntField(Is,FIELD_CALLINGCARD, &(Location -> CallingCard))) {
  206. rSuccess = FALSE;
  207. }
  208. //
  209. // Set TAPI flags for this location.
  210. //
  211. if (Location->CallingCard) {
  212. //
  213. // Non-zero calling card indicates this user calls using a card.
  214. //
  215. Location->Flags |= LOCATION_USECALLINGCARD;
  216. }
  217. if (Location->DisableCallWaiting &&
  218. *Location->DisableCallWaiting &&
  219. *Location->DisableCallWaiting != TEXT(' ')) {
  220. //
  221. // Non-empty disable string means the user has call waiting.
  222. //
  223. Location->Flags |= LOCATION_HASCALLWAITING;
  224. }
  225. if (!Location->PulseDial) {
  226. Location->Flags |= LOCATION_USETONEDIALING;
  227. }
  228. return rSuccess;
  229. }
  230. /*++
  231. Routine Description:
  232. pSetStringRegValue is a simplification wrapper for RegSetValueEx. It is
  233. used to set a string value in a currently opened key.
  234. Arguments:
  235. Key - a valid handle to a registry key.
  236. Name - The name of the value to set
  237. Data - The data to set in the value.
  238. Return Value:
  239. TRUE if the value was set successfully, FALSE otherwise.
  240. --*/
  241. BOOL
  242. pSetStringRegValue (
  243. IN HKEY Key,
  244. IN PTSTR Name,
  245. IN PTSTR Data
  246. )
  247. {
  248. BOOL rSuccess = TRUE;
  249. MYASSERT(Key);
  250. MYASSERT(Name);
  251. MYASSERT(Data);
  252. if (ERROR_SUCCESS != RegSetValueEx(Key,Name,0,REG_SZ,(PBYTE) Data,SizeOfString(Data))) {
  253. rSuccess = FALSE;
  254. LOG ((LOG_ERROR,"SetStringRegValue failed! Value name: %s Value Data: %s",Name,Data));
  255. }
  256. return rSuccess;
  257. }
  258. /*++
  259. Routine Description:
  260. pSetDwordRegValue is a simplification wrapper for RegSetValueEx. It is
  261. used to set a DWORD value in a currently opened key.
  262. Arguments:
  263. Key - a valid handle to a registry key.
  264. Name - The name of the value to set
  265. Data - The data to set in the value.
  266. Return Value:
  267. TRUE if the value was set successfully, FALSE otherwise.
  268. --*/
  269. BOOL
  270. pSetDwordRegValue (
  271. IN HKEY Key,
  272. IN PTSTR Name,
  273. IN DWORD Data
  274. )
  275. {
  276. BOOL rSuccess = TRUE;
  277. MYASSERT(Key);
  278. MYASSERT(Name);
  279. if (ERROR_SUCCESS != RegSetValueEx(Key,Name,0,REG_DWORD,(PBYTE) &Data,sizeof(DWORD))) {
  280. rSuccess = FALSE;
  281. LOG ((LOG_ERROR,"SetDwordRegValue failed! Value name: %s Value Data: %u",Name,Data));
  282. }
  283. return rSuccess;
  284. }
  285. /*++
  286. Routine Description:
  287. pWriteLocationToRegistry is responsible for saving a LOCATION structure
  288. away into the NT 5.0 Registry.
  289. Arguments:
  290. DialingLocation - The name of the dialing location to create in the NT
  291. registry.
  292. LocationData - The LOCATION structure containing the data to write into
  293. the NT 5 registry.
  294. Return Value:
  295. TRUE if the the function successfully saved the Dialing Location Data into
  296. the NT 5 Registry, FALSE otherwise.
  297. --*/
  298. BOOL
  299. pWriteLocationToRegistry (
  300. IN PLOCATION LocationData
  301. )
  302. {
  303. BOOL rSuccess = TRUE;
  304. PTSTR regKeyString = NULL;
  305. HKEY regKey = NULL;
  306. MYASSERT(LocationData);
  307. //
  308. // Create %CURRENTVERSION%\Telephony\Locations\Location<n> Key
  309. //
  310. regKeyString = JoinPaths(S_LOCATIONS_REGKEY, LocationData->EntryName);
  311. regKey = CreateRegKeyStr(regKeyString);
  312. if (regKey) {
  313. //
  314. // Create Name String
  315. //
  316. rSuccess &= pSetStringRegValue(regKey,S_NAME,LocationData -> Name);
  317. //
  318. // Create AreaCode String
  319. //
  320. rSuccess &= pSetStringRegValue(regKey,S_AREACODE,LocationData -> AreaCode);
  321. //
  322. // Create Country Value
  323. //
  324. rSuccess &= pSetDwordRegValue(regKey,S_COUNTRY,LocationData -> Country);
  325. //
  326. // Create DisableCallWating String
  327. //
  328. rSuccess &= pSetStringRegValue(regKey,S_DISABLECALLWAITING,LocationData -> DisableCallWaiting);
  329. //
  330. // Create LongDistanceAccess String
  331. //
  332. rSuccess &= pSetStringRegValue(regKey,S_LONGDISTANCEACCESS,LocationData -> LongDistanceAccess);
  333. //
  334. // Create OutSideAccessString
  335. //
  336. rSuccess &= pSetStringRegValue(regKey,S_OUTSIDEACCESS,LocationData -> OutsideAccess);
  337. //
  338. // Create Flags Value
  339. //
  340. rSuccess &= pSetDwordRegValue(regKey,S_FLAGS,LocationData -> Flags);
  341. //
  342. // Create ID Value
  343. //
  344. rSuccess &= pSetDwordRegValue(regKey,S_ID,LocationData -> Id);
  345. CloseRegKey(regKey);
  346. }
  347. else {
  348. rSuccess = FALSE;
  349. LOG ((LOG_ERROR,"Migrate Location: Error creating registry key %s.",regKeyString));
  350. }
  351. FreePathString(regKeyString);
  352. if (!rSuccess) {
  353. LOG ((
  354. LOG_ERROR,
  355. "Error creating Location registry entries for location %s.",
  356. LocationData->EntryName
  357. ));
  358. }
  359. return rSuccess;
  360. }
  361. /*++
  362. Routine Description:
  363. pMigrateDialingLocations migrates all dialing locations from
  364. %windir%\telephon.ini and into the NT registry.
  365. Arguments:
  366. None.
  367. Return Value:
  368. TRUE if dialing locations were successfully migrated, FALSE otherwise.
  369. --*/
  370. BOOL
  371. pMigrateDialingLocations (
  372. VOID
  373. )
  374. {
  375. BOOL rSuccess = TRUE;
  376. HKEY locationsKey = NULL;
  377. PLOCATION location;
  378. UINT i;
  379. UINT count = GrowListGetSize (&g_LocationsList);
  380. //
  381. // Migrate individual locations.
  382. //
  383. for (i = 0; i < count; i++) {
  384. location = (PLOCATION) GrowListGetItem (&g_LocationsList, i);
  385. if (!pWriteLocationToRegistry (location)) {
  386. rSuccess = FALSE;
  387. DEBUGMSG ((DBG_ERROR, "Error writing TAPI location %s (%s) to the registry.", location->Name, location->EntryName));
  388. }
  389. }
  390. if (count) {
  391. locationsKey = OpenRegKeyStr(S_LOCATIONS_REGKEY);
  392. if (locationsKey) {
  393. //
  394. // Update %CURRENTVERSION%\Telephony\Locations\[CurrentID]
  395. //
  396. if (!pSetDwordRegValue (locationsKey, S_CURRENTID, g_CurrentLocation)) {
  397. rSuccess = FALSE;
  398. }
  399. //
  400. // Update %CURRENTVERSION%\Telephony\Locations\[NextID]
  401. //
  402. if (!pSetDwordRegValue (locationsKey, S_NEXTID, count + 1)) {
  403. rSuccess = FALSE;
  404. }
  405. //
  406. // Update %CURRENTVERSION%\Telephony\Locations\[NumEntries]
  407. //
  408. if (!pSetDwordRegValue (locationsKey, S_NUMENTRIES, count)) {
  409. rSuccess = FALSE;
  410. }
  411. CloseRegKey(locationsKey);
  412. }
  413. else {
  414. rSuccess = FALSE;
  415. LOG ((LOG_ERROR,"Tapi: Error opening %s key.",S_LOCATIONS_REGKEY));
  416. }
  417. }
  418. return rSuccess;
  419. }
  420. VOID
  421. pGatherLocationsData (
  422. VOID
  423. )
  424. {
  425. HINF hTelephonIni = INVALID_HANDLE_VALUE;
  426. INFSTRUCT is = INITINFSTRUCT_POOLHANDLE;
  427. BOOL rSuccess = TRUE;
  428. PCTSTR telephonIniPath = NULL;
  429. PTSTR curKey = NULL;
  430. LOCATION location;
  431. CALLINGCARD card;
  432. HKEY locationsKey = NULL;
  433. PCTSTR tempPath = NULL;
  434. g_LocationsRead = TRUE;
  435. //
  436. // Open %windir%\telephon.ini
  437. //
  438. telephonIniPath = JoinPaths(g_WinDir,S_TELEPHON_INI);
  439. tempPath = GetTemporaryLocationForFile (telephonIniPath);
  440. if (tempPath) {
  441. //
  442. // telephon ini is in a temporary location. Use that.
  443. //
  444. DEBUGMSG ((DBG_TAPI, "Using %s for %s.", tempPath, telephonIniPath));
  445. FreePathString (telephonIniPath);
  446. telephonIniPath = tempPath;
  447. }
  448. hTelephonIni = InfOpenInfFile(telephonIniPath);
  449. if (hTelephonIni) {
  450. //
  451. // For each location in [locations],
  452. //
  453. if (InfFindFirstLine(hTelephonIni,S_LOCATIONS,NULL,&is)) {
  454. do {
  455. curKey = InfGetStringField(&is,0);
  456. if (!curKey) {
  457. continue;
  458. }
  459. if (StringIMatch(curKey,S_LOCATIONS)) {
  460. DEBUGMSG((DBG_TAPI,"From %s: Locations = %s",telephonIniPath,InfGetLineText(&is)));
  461. //
  462. // Nothing to do here right now..
  463. //
  464. }
  465. else if (StringIMatch (curKey, S_CURRENTLOCATION)) {
  466. if (!InfGetIntField (&is, 1, &g_CurrentLocation)) {
  467. rSuccess = FALSE;
  468. LOG((LOG_ERROR,"TAPI: Error retrieving current location information."));
  469. }
  470. }
  471. else if (IsPatternMatch(TEXT("Location*"),curKey)) {
  472. //
  473. // Add this location to the list of locations.
  474. //
  475. if (!pReadLocationFromIniFile (&is, &location)) {
  476. rSuccess = FALSE;
  477. LOG ((LOG_ERROR,"TAPI: Error migrating location %s.",curKey));
  478. }
  479. StringCopy (location.EntryName, curKey);
  480. GrowListAppend (&g_LocationsList, (PBYTE) &location, sizeof (LOCATION));
  481. }
  482. else if (StringIMatch(curKey,TEXT("Inited"))) {
  483. DEBUGMSG((DBG_TAPI,"Inited key unused during migration."));
  484. }
  485. ELSE_DEBUGMSG((DBG_WHOOPS,"TAPI Dialing Location Migration: Ingored or Unknown key: %s",curKey));
  486. InfResetInfStruct (&is);
  487. } while (InfFindNextLine(&is));
  488. //
  489. // Read in all the calling card information.
  490. //
  491. if (InfFindFirstLine(hTelephonIni,S_CARDS,NULL,&is)) {
  492. do {
  493. curKey = InfGetStringField(&is,0);
  494. if (!StringIMatch (curKey, S_CARDS) && IsPatternMatch (TEXT("Card*"),curKey)) {
  495. ZeroMemory (&card, sizeof (CALLINGCARD));
  496. StringCopy (card.EntryName, curKey);
  497. if (!pReadCardFromIniFile (&is, &card)) {
  498. rSuccess = FALSE;
  499. LOG ((LOG_ERROR,"TAPI: Error migrating location %s.",curKey));
  500. }
  501. GrowListAppend (&g_CallingCardList, (PBYTE) &card, sizeof (CALLINGCARD));
  502. }
  503. InfResetInfStruct (&is);
  504. } while (InfFindNextLine(&is));
  505. }
  506. }
  507. DEBUGMSG((DBG_TAPI,"%u dialing locations found in telephon.ini.",GrowListGetSize (&g_LocationsList)));
  508. InfCloseInfFile(hTelephonIni);
  509. }
  510. ELSE_DEBUGMSG((DBG_TAPI,"No telephon.ini file found, or, telephon.ini coudl not be opened."));
  511. FreePathString(telephonIniPath);
  512. InfCleanUpInfStruct(&is);
  513. }
  514. BOOL
  515. Tapi_MigrateUser (
  516. IN PCTSTR UserName,
  517. IN HKEY UserRoot
  518. )
  519. {
  520. BOOL rSuccess = TRUE;
  521. UINT i;
  522. UINT count;
  523. HKEY hKey;
  524. PTSTR keyString;
  525. PLOCATION location;
  526. PCALLINGCARD card;
  527. if (!g_LocationsRead) {
  528. pGatherLocationsData ();
  529. }
  530. //
  531. // First, migrate user specific location information into the user
  532. // registry..
  533. //
  534. count = GrowListGetSize (&g_LocationsList);
  535. for (i = 0; i < count; i++) {
  536. location = (PLOCATION) GrowListGetItem (&g_LocationsList, i);
  537. keyString = JoinPaths (S_USERLOCATIONSKEY, location->EntryName);
  538. hKey = CreateRegKey (UserRoot, keyString);
  539. if (hKey) {
  540. rSuccess &= pSetDwordRegValue (hKey, S_CALLINGCARD, location->CallingCard);
  541. CloseRegKey (hKey);
  542. }
  543. FreePathString (keyString);
  544. }
  545. count = GrowListGetSize (&g_CallingCardList);
  546. for (i = 0; i < count; i++) {
  547. card = (PCALLINGCARD) GrowListGetItem (&g_CallingCardList, i);
  548. keyString = JoinPaths (S_USERCALLINGCARDSKEY, card->EntryName);
  549. hKey = CreateRegKey (UserRoot, keyString);
  550. if (hKey) {
  551. rSuccess &= pSetDwordRegValue (hKey, S_ID, card->Id);
  552. rSuccess &= pSetStringRegValue (hKey, S_NAME, card->Name);
  553. rSuccess &= pSetStringRegValue (hKey, S_LOCALRULE, card->Locale);
  554. rSuccess &= pSetStringRegValue (hKey, S_LDRULE, card->LongDistance);
  555. rSuccess &= pSetStringRegValue (hKey, S_INTERNATIONALRULE, card->International);
  556. rSuccess &= pSetStringRegValue (hKey, S_PIN, card->Pin);
  557. rSuccess &= pSetDwordRegValue (hKey, S_FLAGS, card->Flags);
  558. CloseRegKey (hKey);
  559. }
  560. ELSE_DEBUGMSG ((DBG_ERROR, "TAPI: Could not open key %s for user %s.", card->EntryName, UserName));
  561. FreePathString (keyString);
  562. hKey = CreateRegKey (UserRoot, S_USERCALLINGCARDSKEY);
  563. if (hKey) {
  564. rSuccess &= pSetDwordRegValue (hKey, S_NEXTID, count);
  565. rSuccess &= pSetDwordRegValue (hKey, S_NUMENTRIES, count);
  566. CloseRegKey (hKey);
  567. }
  568. ELSE_DEBUGMSG ((DBG_ERROR, "TAPI: Could not open key %s for user %s.", S_USERCALLINGCARDSKEY, UserName));
  569. }
  570. //
  571. // Next, we need to create calling card entries
  572. //
  573. if (!pMigrateDialingLocations()) {
  574. ERROR_NONCRITICAL;
  575. LOG ((LOG_ERROR, (PCSTR)MSG_UNABLE_TO_MIGRATE_TAPI_DIALING_LOCATIONS));
  576. }
  577. return rSuccess;
  578. }
  579. /*++
  580. Routine Description:
  581. Tapi_MigrateSystem is responsible for migrating all system-wide TAPI
  582. settings from 95 to Windows NT5.
  583. Arguments:
  584. None.
  585. Return Value:
  586. TRUE if TAPI settings were successfully migrated, FALSE otherwise.
  587. --*/
  588. BOOL
  589. Tapi_MigrateSystem (
  590. VOID
  591. )
  592. {
  593. BOOL rSuccess = TRUE;
  594. if (!g_LocationsRead) {
  595. pGatherLocationsData ();
  596. }
  597. if (!pMigrateDialingLocations()) {
  598. ERROR_NONCRITICAL;
  599. LOG ((LOG_ERROR, (PCSTR)MSG_UNABLE_TO_MIGRATE_TAPI_DIALING_LOCATIONS));
  600. }
  601. return rSuccess;
  602. }
  603. BOOL
  604. Tapi_Entry (
  605. IN HINSTANCE Instance,
  606. IN DWORD Reason,
  607. IN PVOID Reserved
  608. )
  609. {
  610. BOOL rSuccess = TRUE;
  611. switch (Reason)
  612. {
  613. case DLL_PROCESS_ATTACH:
  614. //
  615. // Initialize Memory pool.
  616. //
  617. g_TapiPool = PoolMemInitNamedPool ("Tapi");
  618. if (!g_TapiPool) {
  619. DEBUGMSG((DBG_ERROR,"Ras Migration: Pool Memory failed to initialize..."));
  620. rSuccess = FALSE;
  621. }
  622. break;
  623. case DLL_PROCESS_DETACH:
  624. //
  625. // Free memory pool.
  626. //
  627. FreeGrowList (&g_CallingCardList);
  628. FreeGrowList (&g_LocationsList);
  629. if (g_TapiPool) {
  630. PoolMemDestroyPool(g_TapiPool);
  631. }
  632. break;
  633. }
  634. return rSuccess;
  635. }
  636. DWORD
  637. DeleteSysTapiSettings (
  638. IN DWORD Request
  639. )
  640. {
  641. //
  642. // Delete previous TAPI settings (OCM initiated.)
  643. //
  644. if (Request == REQUEST_QUERYTICKS) {
  645. return TICKS_DELETESYSTAPI;
  646. }
  647. pSetupRegistryDelnode (HKEY_LOCAL_MACHINE, TEXT("software\\Microsoft\\Windows\\CurrentVersion\\Telephony\\Locations"));
  648. return ERROR_SUCCESS;
  649. }
  650. DWORD
  651. DeleteUserTapiSettings (
  652. IN DWORD Request,
  653. IN PMIGRATE_USER_ENUM EnumPtr
  654. )
  655. {
  656. if (Request == REQUEST_QUERYTICKS) {
  657. return TICKS_DELETEUSERTAPI;
  658. }
  659. pSetupRegistryDelnode (g_hKeyRootNT, TEXT("software\\Microsoft\\Windows\\CurrentVersion\\Telephony\\Cards"));
  660. pSetupRegistryDelnode (g_hKeyRootNT, TEXT("software\\Microsoft\\Windows\\CurrentVersion\\Telephony\\Locations"));
  661. return ERROR_SUCCESS;
  662. }