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.

208 lines
6.0 KiB

  1. /****************************************************************************
  2. Copyright (c) 1998 Microsoft Corporation
  3. Module Name: card.h
  4. Abstract: Calling Card Object definitions
  5. Author: noela - 09/11/98
  6. Notes:
  7. Rev History:
  8. ****************************************************************************/
  9. #ifndef __CARD_H_
  10. #define __CARD_H_
  11. #include "utils.h"
  12. #include "rules.h"
  13. #define MAXLEN_CARDNAME 96
  14. #define MAXLEN_PIN 128
  15. #define MAXLEN_RULE 128
  16. #define CARD_BUILTIN 1
  17. #define CARD_HIDE 2
  18. // Calling Card Validation Flags
  19. #define CCVF_NOCARDNAME 0x01
  20. #define CCVF_NOCARDRULES 0x02
  21. #define CCVF_NOCARDNUMBER 0x04
  22. #define CCVF_NOPINNUMBER 0x08
  23. #define CCVF_NOINTERNATIONALACCESSNUMBER 0x10
  24. #define CCVF_NOLOCALACCESSNUMBER 0x20
  25. #define CCVF_NOLONGDISTANCEACCESSNUMBER 0x40
  26. //***************************************************************************
  27. //
  28. // Class Definition - CCallingCard
  29. //
  30. //***************************************************************************
  31. class CCallingCard
  32. {
  33. private:
  34. DWORD m_dwCardID;
  35. PWSTR m_pszCardName;
  36. DWORD m_dwFlags;
  37. PWSTR m_pszPIN;
  38. PWSTR m_pszEncryptedPIN;
  39. PWSTR m_pszAccountNumber;
  40. PWSTR m_pszLocalAccessNumber;
  41. PWSTR m_pszLongDistanceAccessNumber;
  42. PWSTR m_pszInternationalAccessNumber;
  43. CRuleSet m_Rules;
  44. HKEY m_hCard;
  45. PTSTR m_pszCardPath;
  46. BOOL m_bDirty;
  47. BOOL m_bDeleted;
  48. DWORD m_dwCryptInitResult;
  49. private:
  50. void CleanUp(void);
  51. DWORD OpenCardKey(BOOL bWrite);
  52. DWORD CloseCardKey();
  53. DWORD ReadOneStringValue(PWSTR *pMember, const TCHAR *pszName);
  54. DWORD EncryptPIN(void);
  55. DWORD DecryptPIN(void);
  56. public:
  57. CCallingCard();
  58. ~CCallingCard();
  59. DECLARE_TRACELOG_CLASS(CCallingCard)
  60. HRESULT Initialize (
  61. DWORD dwCardID,
  62. PWSTR pszCardName,
  63. DWORD dwFlags,
  64. PWSTR pszPIN,
  65. PWSTR pszAccountNumber,
  66. PWSTR pszInternationalRule,
  67. PWSTR pszLongDistanceRule,
  68. PWSTR pszLocalRule,
  69. PWSTR pszInternationalAccessNumber,
  70. PWSTR pszLongDistanceAccessNumber,
  71. PWSTR pszLocalAccessNumber
  72. );
  73. HRESULT Initialize ( DWORD dwCardID);
  74. HRESULT SaveToRegistry(void);
  75. HRESULT MarkDeleted(void);
  76. DWORD IsMarkedDeleted(void) const {return m_bDeleted || (m_dwFlags & CARD_HIDE);};
  77. DWORD IsMarkedHidden(void) const {return (m_dwFlags & CARD_HIDE) != 0;};
  78. DWORD IsMarkedPermanent(void) const {return (m_dwFlags & CARD_BUILTIN) != 0;};
  79. DWORD Validate(void);
  80. #define GET_SET_METHOD(Member) \
  81. PWSTR Get##Member(void) const { return m_psz##Member; }; \
  82. HRESULT Set##Member(PWSTR) ;
  83. GET_SET_METHOD(CardName)
  84. GET_SET_METHOD(PIN);
  85. GET_SET_METHOD(AccountNumber);
  86. GET_SET_METHOD(InternationalAccessNumber);
  87. GET_SET_METHOD(LongDistanceAccessNumber);
  88. GET_SET_METHOD(LocalAccessNumber);
  89. #define m_pszInternationalRule m_Rules.m_pszInternationalRule
  90. #define m_pszLongDistanceRule m_Rules.m_pszLongDistanceRule
  91. #define m_pszLocalRule m_Rules.m_pszLocalRule
  92. GET_SET_METHOD(InternationalRule);
  93. GET_SET_METHOD(LongDistanceRule);
  94. GET_SET_METHOD(LocalRule);
  95. #undef m_pszInternationalRule
  96. #undef m_pszLongDistanceRule
  97. #undef m_pszLocalRule
  98. #undef GET_SET_METHOD
  99. CRuleSet * GetRuleSet(){return &m_Rules;}
  100. DWORD GetCardID(void) const {return m_dwCardID;}
  101. HRESULT SetCardID(DWORD dwCardID) {m_dwCardID=dwCardID; return S_OK;}
  102. };
  103. //***************************************************************************
  104. // Fill out the list template
  105. typedef LinkedList<CCallingCard *> CCallingCardList;
  106. typedef ListNode<CCallingCard *> CCallingCardNode;
  107. //***************************************************************************
  108. //
  109. // Class Definition - CCallingCards
  110. //
  111. //***************************************************************************
  112. class CCallingCards
  113. {
  114. private:
  115. DWORD m_dwNumEntries;
  116. DWORD m_dwNextID;
  117. CCallingCardList m_CallingCardList;
  118. CCallingCardList m_DeletedCallingCardList;
  119. HKEY m_hCards;
  120. CCallingCardNode *m_hEnumNode;
  121. BOOL m_bEnumInclHidden;
  122. private:
  123. DWORD CreateFreshCards(void);
  124. void InternalDeleteCard(CCallingCardNode *);
  125. public:
  126. CCallingCards();
  127. ~CCallingCards();
  128. #ifdef TRACELOG
  129. DECLARE_TRACELOG_CLASS(CCallingCards)
  130. #endif
  131. HRESULT Initialize(void);
  132. HRESULT SaveToRegistry(void);
  133. void AddCard(CCallingCard *pNewCard) {m_CallingCardList.tail()->insert_after(pNewCard); m_dwNumEntries++;};
  134. void RemoveCard(CCallingCard *pCard);
  135. void RemoveCard(DWORD dwID);
  136. DWORD AllocNewCardID(void) { return m_dwNextID++; };
  137. DWORD GetNumCards(void) const { return m_dwNumEntries; } ;
  138. CCallingCard *GetCallingCard(DWORD dwID);
  139. // a sort of enumerator
  140. HRESULT Reset(BOOL bInclHidden);
  141. HRESULT Next(DWORD NrElem, CCallingCard **, DWORD *pNrElemFetched);
  142. HRESULT Skip(DWORD NrElem);
  143. };
  144. #endif //__CARD_H_