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.

346 lines
10 KiB

  1. /****************************************************************************
  2. Copyright (c) 1998 Microsoft Corporation
  3. Module Name: location.h
  4. Abstract: Location Object definitions
  5. Author: noela - 09/11/98
  6. Notes:
  7. Rev History:
  8. ****************************************************************************/
  9. #ifndef __LOCATION_H_
  10. #define __LOCATION_H_
  11. #include "utils.h"
  12. #include "loc_comn.h"
  13. #include "rules.h"
  14. #include "card.h"
  15. #define CITY_MANDATORY (1)
  16. #define CITY_OPTIONAL (-1)
  17. #define CITY_NONE (0)
  18. #define LONG_DISTANCE_CARRIER_MANDATORY (1)
  19. #define LONG_DISTANCE_CARRIER_OPTIONAL (-1)
  20. #define LONG_DISTANCE_CARRIER_NONE (0)
  21. #define INTERNATIONAL_CARRIER_MANDATORY (1)
  22. #define INTERNATIONAL_CARRIER_OPTIONAL (-1)
  23. #define INTERNATIONAL_CARRIER_NONE (0)
  24. //***************************************************************************
  25. //
  26. // Class Definition - CCountry
  27. //
  28. //***************************************************************************
  29. class CCountry
  30. {
  31. private:
  32. DWORD m_dwCountryID;
  33. DWORD m_dwCountryCode;
  34. DWORD m_dwCountryGroup;
  35. PWSTR m_pszCountryName;
  36. CRuleSet m_Rules;
  37. public:
  38. CCountry();
  39. ~CCountry();
  40. #ifdef TRACELOG
  41. DECLARE_TRACELOG_CLASS(CCountry)
  42. #endif
  43. STDMETHOD(Initialize) ( DWORD dwCountryID,
  44. DWORD dwCountryCode,
  45. DWORD dwCountryGroup,
  46. PWSTR pszCountryName,
  47. PWSTR pszInternationalRule,
  48. PWSTR pszLongDistanceRule,
  49. PWSTR pszLocalRule
  50. );
  51. PWSTR GetInternationalRule(){return m_Rules.m_pszInternationalRule;}
  52. PWSTR GetLongDistanceRule(){return m_Rules.m_pszLongDistanceRule;}
  53. PWSTR GetLocalRule(){return m_Rules.m_pszLocalRule;}
  54. CRuleSet * GetRuleSet(){return &m_Rules;}
  55. DWORD GetCountryID(){return m_dwCountryID;}
  56. DWORD GetCountryCode(){return m_dwCountryCode;}
  57. DWORD GetCountryGroup(){return m_dwCountryGroup;}
  58. PWSTR GetCountryName(){return m_pszCountryName;}
  59. };
  60. //***************************************************************************
  61. // Fill out the list template
  62. typedef LinkedList<CCountry *> CCountryList;
  63. typedef ListNode<CCountry *> CCountryNode;
  64. //***************************************************************************
  65. //
  66. // Class Definition - CCountries
  67. //
  68. //***************************************************************************
  69. class CCountries
  70. {
  71. private:
  72. DWORD m_dwNumEntries;
  73. CCountryList m_CountryList;
  74. CCountryNode * m_hEnumNode;
  75. public:
  76. CCountries();
  77. ~CCountries();
  78. #ifdef TRACELOG
  79. DECLARE_TRACELOG_CLASS(CCountries)
  80. #endif
  81. HRESULT Initialize(void);
  82. // a sort of enumerator
  83. HRESULT Reset(void);
  84. HRESULT Next(DWORD NrElem, CCountry ** ppCountry, DWORD *pNrElemFetched);
  85. HRESULT Skip(DWORD NrElem);
  86. };
  87. //***************************************************************************
  88. //
  89. // Class Definition - CLocation
  90. //
  91. //***************************************************************************
  92. class CLocation
  93. {
  94. private:
  95. PWSTR m_pszLocationName;
  96. PWSTR m_pszAreaCode;
  97. PWSTR m_pszLongDistanceCarrierCode;
  98. PWSTR m_pszInternationalCarrierCode;
  99. PWSTR m_pszLongDistanceAccessCode;
  100. PWSTR m_pszLocalAccessCode;
  101. PWSTR m_pszDisableCallWaitingCode;
  102. DWORD m_dwLocationID;
  103. DWORD m_dwCountryID;
  104. DWORD m_dwCountryCode;
  105. DWORD m_dwPreferredCardID;
  106. DWORD m_dwOptions;
  107. BOOL m_bFromRegistry; // Was this read from the registry
  108. // or only existed in memory, i.e
  109. // how do we delete it.
  110. BOOL m_bChanged; // has this entry changed while in
  111. // memory, if not we don't write it
  112. // back to server.
  113. DWORD m_dwNumRules;
  114. PWSTR m_pszTAPIDialingRule; // temp store used when processing rules
  115. AreaCodeRulePtrNode * m_hEnumNode;
  116. public:
  117. AreaCodeRulePtrList m_AreaCodeRuleList;
  118. public:
  119. CLocation();
  120. ~CLocation();
  121. #ifdef TRACELOG
  122. DECLARE_TRACELOG_CLASS(CLocation)
  123. #endif
  124. STDMETHOD(Initialize) ( PWSTR pszLocationName,
  125. PWSTR pszAreaCode,
  126. PWSTR pszLongDistanceCarrierCode,
  127. PWSTR pszInternationalCarrierCode,
  128. PWSTR pszLongDistanceAccessCode,
  129. PWSTR pszLocalAccessCode,
  130. PWSTR pszDisableCallWaitingCode,
  131. DWORD dwLocationID,
  132. DWORD dwCountryID,
  133. DWORD dwPreferredCardID,
  134. DWORD dwOptions,
  135. BOOL bFromRegistry = FALSE
  136. );
  137. BOOL HasCallWaiting() {return m_dwOptions & LOCATION_HASCALLWAITING;}
  138. void UseCallWaiting(BOOL bCw);
  139. BOOL HasCallingCard(){return m_dwOptions & LOCATION_USECALLINGCARD;}
  140. void UseCallingCard(BOOL bCc);
  141. BOOL HasToneDialing(){return m_dwOptions & LOCATION_USETONEDIALING;}
  142. void UseToneDialing(BOOL bCc);
  143. PWSTR GetName(){return m_pszLocationName;}
  144. STDMETHOD (SetName)(PWSTR pszLocationName);
  145. PWSTR GetAreaCode(){return m_pszAreaCode;}
  146. STDMETHOD (SetAreaCode)(PWSTR pszAreaCode);
  147. PWSTR GetLongDistanceCarrierCode(){return m_pszLongDistanceCarrierCode;}
  148. STDMETHOD (SetLongDistanceCarrierCode)(PWSTR pszLongDistanceCarrierCode);
  149. PWSTR GetInternationalCarrierCode(){return m_pszInternationalCarrierCode;}
  150. STDMETHOD (SetInternationalCarrierCode)(PWSTR pszInternationalCarrierCode);
  151. PWSTR GetLongDistanceAccessCode(){return m_pszLongDistanceAccessCode;}
  152. STDMETHOD (SetLongDistanceAccessCode)(PWSTR pszLongDistanceAccessCode);
  153. PWSTR GetLocalAccessCode(){return m_pszLocalAccessCode;}
  154. STDMETHOD (SetLocalAccessCode)(PWSTR pszLocalAccessCode);
  155. PWSTR GetDisableCallWaitingCode(){return m_pszDisableCallWaitingCode;}
  156. STDMETHOD (SetDisableCallWaitingCode)(PWSTR pszDisableCallWaitingCode);
  157. DWORD GetLocationID() {return m_dwLocationID;}
  158. DWORD GetCountryID() {return m_dwCountryID;}
  159. void SetCountryID(DWORD dwID) {m_dwCountryID = dwID;}
  160. DWORD GetCountryCode();
  161. //void SetCountryCode(DWORD dwCode) {m_dwCountryCode = dwCode;}
  162. DWORD GetPreferredCardID() {return m_dwPreferredCardID;}
  163. void SetPreferredCardID(DWORD dwID) {m_dwPreferredCardID = dwID;}
  164. BOOL FromRegistry(){return m_bFromRegistry;}
  165. LONG TranslateAddress(PCWSTR pszAddressIn,
  166. CCallingCard * pCallingCard,
  167. DWORD dwTranslateOptions,
  168. PDWORD pdwTranslateResults,
  169. PDWORD pdwDestCountryCode,
  170. PWSTR * pszDialableString,
  171. PWSTR * pszDisplayableString
  172. );
  173. void CLocation::FindRule(
  174. DWORD dwTranslateResults,
  175. DWORD dwTranslateOptions,
  176. CCallingCard * pCard,
  177. CCountry * pCountry,
  178. PWSTR AreaCodeString,
  179. PWSTR SubscriberString,
  180. PWSTR * ppRule,
  181. PDWORD dwAccess
  182. );
  183. STDMETHOD(WriteToRegistry)();
  184. void AddRule(CAreaCodeRule *pNewRule) {m_AreaCodeRuleList.tail()->insert_after(pNewRule);
  185. m_dwNumRules++;
  186. m_bChanged = TRUE;
  187. }
  188. void RemoveRule(CAreaCodeRule *pRule);
  189. HRESULT ResetRules(void);
  190. HRESULT NextRule(DWORD NrElem, CAreaCodeRule **ppRule, DWORD *pNrElemFetched);
  191. HRESULT SkipRule(DWORD NrElem);
  192. DWORD TapiSize();
  193. DWORD TapiPack(PLOCATION pLocation, DWORD dwTotalSize);
  194. DWORD GetNumRules(){return m_dwNumRules;}
  195. void Changed(){m_bChanged=TRUE;}
  196. HRESULT NewID(); // gets new ID from server
  197. };
  198. typedef LinkedList<CLocation *> CLocationList;
  199. typedef ListNode<CLocation *> CLocationNode;
  200. //***************************************************************************
  201. //
  202. // Class Definition - CLocations
  203. //
  204. //***************************************************************************
  205. class CLocations
  206. {
  207. private:
  208. DWORD m_dwCurrentLocationID;
  209. DWORD m_dwNumEntries;
  210. CLocationList m_LocationList;
  211. CLocationList m_DeletedLocationList; // we need to remember these, so we
  212. // can delete their reistry entry
  213. CLocationNode * m_hEnumNode;
  214. public:
  215. CLocations();
  216. ~CLocations();
  217. #ifdef TRACELOG
  218. DECLARE_TRACELOG_CLASS(CLocations)
  219. #endif
  220. HRESULT Initialize(void);
  221. void Remove(CLocation * pLocation);
  222. void Remove(DWORD dwID);
  223. void Replace(CLocation * pLocOld, CLocation * pLocNew);
  224. void Add(CLocation * pLocation);
  225. HRESULT SaveToRegistry(void);
  226. DWORD GetCurrentLocationID() {return m_dwCurrentLocationID;}
  227. void SetCurrentLocationID(DWORD dwLocationID) {m_dwCurrentLocationID = dwLocationID;}
  228. DWORD GetNumLocations(void) const { return m_dwNumEntries; } ;
  229. HRESULT Reset(void);
  230. HRESULT Next(DWORD NrElem, CLocation **ppLocation, DWORD *pNrElemFetched);
  231. HRESULT Skip(DWORD NrElem);
  232. };
  233. #endif //__LOCATION_H_