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.

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