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.

142 lines
3.7 KiB

  1. /*++
  2. Copyright (C) Microsoft Corporation, 1996 - 1999
  3. Module Name:
  4. RdrState
  5. Abstract:
  6. This file contains the definition of the Smartcard Common
  7. dialog CSCardReaderState class. This class encapsulates Smartcard
  8. Reader information.
  9. Author:
  10. Chris Dudley 3/3/1997
  11. Environment:
  12. Win32, C++ w/Exceptions, MFC
  13. Revision History:
  14. Chris Dudley 5/13/1997
  15. Amanda Matlosz 1/30/98 unicode support, code cleanup
  16. Notes:
  17. --*/
  18. #ifndef __RDRSTATE_H__
  19. #define __RDRSTATE_H__
  20. /////////////////////////////////////////////////////////////////////////////
  21. //
  22. // Includes
  23. //
  24. #include "cmnui.h"
  25. /////////////////////////////////////////////////////////////////////////////
  26. //
  27. // CSCardReaderState Class - encapsulates reader state
  28. //
  29. class CSCardReaderState
  30. {
  31. // members
  32. private:
  33. SCARDCONTEXT m_hContext; // Context handle w/Calais
  34. SCARDHANDLE m_hCard; // Handle to smartcard in Reader
  35. CTextString m_sReaderName; // Reader name
  36. CTextString m_sCardName; // Card name actually inserted into Reader
  37. BOOL m_fCardInReader; // Flag for card currently in reader
  38. BOOL m_fCardLookup; // Indicates card is being looked for.
  39. BOOL m_fConnected; // Flag connected to card in reader
  40. BOOL m_fChecked; // Flag that this card has been user verified
  41. SCARD_READERSTATE m_ReaderState; // Handle to ANSI reader status
  42. LPOCNCONNPROCA m_lpfnConnectA; // User call back functions
  43. LPOCNCONNPROCW m_lpfnConnectW; // User call back functions
  44. LPOCNCHKPROC m_lpfnCheck;
  45. LPOCNDSCPROC m_lpfnDisconnect;
  46. LPVOID m_lpUserData;
  47. // RFU AS INDICATED!!!
  48. BOOL m_fUpdated; // RFU!!! Flag for change in name, group, etc.
  49. CTextMultistring m_sGroupName; // RFU!!! Groups this reader belongs to.
  50. public:
  51. // Construction/Destruction
  52. public:
  53. CSCardReaderState()
  54. {
  55. ::ZeroMemory( (LPVOID)&m_ReaderState,
  56. (DWORD)sizeof(SCARD_READERSTATE) );
  57. m_hContext = NULL;
  58. m_hCard = NULL;
  59. m_fCardInReader = FALSE;
  60. m_fCardLookup = FALSE;
  61. m_fChecked = FALSE;
  62. m_fConnected = FALSE;
  63. m_fUpdated = FALSE;
  64. m_lpfnConnectA = NULL; // User call back functions
  65. m_lpfnConnectW = NULL;
  66. m_lpfnCheck = NULL;
  67. m_lpfnDisconnect = NULL;
  68. m_lpUserData = NULL;
  69. }
  70. ~CSCardReaderState()
  71. {
  72. m_sReaderName.Clear();
  73. m_sCardName.Clear();
  74. }
  75. // Implementation
  76. private:
  77. public:
  78. // initialization
  79. void SetContext(SCARDCONTEXT hContext);
  80. void StoreName(LPCTSTR szReaderName);
  81. LONG SetReaderState(LPOCNCONNPROCA lpfnConnectA = NULL,
  82. LPOCNCHKPROC lpfnCheck = NULL,
  83. LPOCNDSCPROC lpfnDisconnect = NULL,
  84. LPVOID lpUserData = NULL);
  85. LONG SetReaderState(LPOCNCONNPROCW lpfnConnectW = NULL,
  86. LPOCNCHKPROC lpfnCheck = NULL,
  87. LPOCNDSCPROC lpfnDisconnect = NULL,
  88. LPVOID lpUserData = NULL);
  89. // attributes
  90. LONG GetReaderInfo(LPSCARD_READERINFO pReaderInfo);
  91. LONG GetReaderState(LPSCARD_READERSTATE pReaderState);
  92. BOOL IsCallbackValid(void);
  93. BOOL IsCardConnected() { return (m_fConnected); }
  94. BOOL IsCardInserted(void);
  95. BOOL IsContextValid() { return (NULL != m_hContext); }
  96. BOOL IsStateValid(void);
  97. // methods
  98. LONG CheckCard(LPCTSTR szCardName);
  99. LONG Connect( SCARDHANDLE *pHandle,
  100. DWORD dwShareMode,
  101. DWORD dwProtocols,
  102. DWORD* pdwActiveProtocols,
  103. CTextString* pszReaderName = NULL,
  104. CTextString* pszCardName = NULL);
  105. LONG UserCheck(void);
  106. LONG UserConnect( LPSCARDHANDLE pCard,
  107. CTextString* pszReaderName = NULL,
  108. CTextString* pszCardName = NULL);
  109. LONG UserDisconnect(void);
  110. LONG GetReaderCardInfo( CTextString* pszReaderName = NULL,
  111. CTextString* pszCardName = NULL);
  112. };
  113. /////////////////////////////////////////////////////////////////////////////
  114. #endif // __RDRSTATE_H__