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.

177 lines
4.7 KiB

  1. /*++
  2. Copyright (c) 1999 Microsoft Corporation
  3. Module Name:
  4. RouteRule.h
  5. Abstract:
  6. This file provides declaration of the service
  7. outbound routing rules.
  8. Author:
  9. Oded Sacher (OdedS) Dec, 1999
  10. Revision History:
  11. --*/
  12. #ifndef _OUT_ROUTE_RULE_H
  13. #define _OUT_ROUTE_RULE_H
  14. #include <map>
  15. #include <list>
  16. #include <string>
  17. #include <algorithm>
  18. using namespace std;
  19. #pragma hdrstop
  20. #pragma warning (disable : 4786) // identifier was truncated to '255' characters in the debug information
  21. // This pragma does not work KB ID: Q167355
  22. /************************************
  23. * *
  24. * CDialingLocation *
  25. * *
  26. ************************************/
  27. class CDialingLocation
  28. {
  29. public:
  30. CDialingLocation () {}
  31. CDialingLocation (DWORD dwCountryCode, DWORD dwAreaCode)
  32. : m_dwCountryCode(dwCountryCode), m_dwAreaCode(dwAreaCode) {}
  33. ~CDialingLocation () {}
  34. BOOL IsValid () const;
  35. bool operator < ( const CDialingLocation &other ) const;
  36. DWORD GetCountryCode () const {return m_dwCountryCode;}
  37. DWORD GetAreaCode () const {return m_dwAreaCode;}
  38. LPCWSTR GetCountryName () const;
  39. private:
  40. DWORD m_dwCountryCode;
  41. DWORD m_dwAreaCode;
  42. }; // CDialingLocation
  43. /************************************
  44. * *
  45. * COutboundRoutingRule *
  46. * *
  47. ************************************/
  48. class COutboundRoutingRule
  49. {
  50. public:
  51. COutboundRoutingRule () {}
  52. ~COutboundRoutingRule () {}
  53. void Init (CDialingLocation DialingLocation, DWORD dwDevice)
  54. {
  55. m_dwDevice = dwDevice;
  56. m_bUseGroup = FALSE;
  57. m_DialingLocation = DialingLocation;
  58. return;
  59. }
  60. DWORD Init (CDialingLocation DialingLocation, wstring wstrGroupName);
  61. COutboundRoutingRule& operator= (const COutboundRoutingRule& rhs)
  62. {
  63. if (this == &rhs)
  64. {
  65. return *this;
  66. }
  67. m_wstrGroupName = rhs.m_wstrGroupName;
  68. m_dwDevice = rhs.m_dwDevice;
  69. m_bUseGroup = rhs.m_bUseGroup;
  70. m_DialingLocation = rhs.m_DialingLocation;
  71. return *this;
  72. }
  73. DWORD GetStatus (FAX_ENUM_RULE_STATUS* lpdwStatus) const;
  74. DWORD GetDeviceList (LPDWORD* lppdwDevices, LPDWORD lpdwNumDevices) const;
  75. DWORD Save(HKEY hRuleKey) const;
  76. DWORD Load(HKEY hRuleKey);
  77. const CDialingLocation GetDialingLocation () const { return m_DialingLocation; }
  78. DWORD Serialize (LPBYTE lpBuffer,
  79. PFAX_OUTBOUND_ROUTING_RULEW pFaxRule,
  80. PULONG_PTR pupOffset,
  81. DWORD dwBufferSize) const;
  82. LPCWSTR GetGroupName () const;
  83. #if DBG
  84. void Dump () const;
  85. #endif
  86. private:
  87. wstring m_wstrGroupName;
  88. DWORD m_dwDevice;
  89. BOOL m_bUseGroup; // Flag that indicates whether to use m_dwDevice or m_wstrGroupName
  90. CDialingLocation m_DialingLocation;
  91. }; // COutboundRoutingRule
  92. typedef COutboundRoutingRule *PCRULE;
  93. /************************************
  94. * *
  95. * COutboundRulesMap *
  96. * *
  97. ************************************/
  98. typedef map<CDialingLocation, COutboundRoutingRule> RULES_MAP, *PRULES_MAP;
  99. //
  100. // The COutboundRulesMap class maps between group name and a list of device ID's
  101. //
  102. class COutboundRulesMap
  103. {
  104. public:
  105. COutboundRulesMap () {}
  106. ~COutboundRulesMap () {}
  107. DWORD Load ();
  108. DWORD AddRule (COutboundRoutingRule& Rule);
  109. DWORD DelRule (CDialingLocation& DialingLocation);
  110. DWORD SerializeRules (PFAX_OUTBOUND_ROUTING_RULEW* ppRules,
  111. LPDWORD lpdwNumRules,
  112. LPDWORD lpdwBufferSize) const;
  113. PCRULE FindRule (CDialingLocation& DialingLocation) const;
  114. BOOL CreateDefaultRule (void);
  115. DWORD IsGroupInRuleDest (LPCWSTR lpcwstrGroupName, BOOL* lpbGroupInRule) const;
  116. #if DBG
  117. void Dump () const;
  118. #endif
  119. private:
  120. RULES_MAP m_RulesMap;
  121. }; // COutboundRulesMap
  122. /************************************
  123. * *
  124. * Externes *
  125. * *
  126. ************************************/
  127. extern COutboundRulesMap* g_pRulesMap; // Map of dialing location to list of device IDs
  128. //
  129. // IMPORTANT - No locking mechanism - USE g_CsConfig to serialize calls to g_pRulesMap
  130. //
  131. /************************************
  132. * *
  133. * Functions *
  134. * *
  135. ************************************/
  136. BOOL CheckDefaultRule (void);
  137. #endif