nsSmartCardMonitor.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /* This Source Code Form is subject to the terms of the Mozilla Public
  2. * License, v. 2.0. If a copy of the MPL was not distributed with this
  3. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  4. #ifndef nsSmartCardMonitor_h
  5. #define nsSmartCardMonitor_h
  6. #include "prthread.h"
  7. #include "secmod.h"
  8. #include "plhash.h"
  9. #include "pkcs11t.h"
  10. class SmartCardThreadEntry;
  11. class SmartCardMonitoringThread;
  12. //
  13. // manage a group of SmartCardMonitoringThreads
  14. //
  15. class SmartCardThreadList {
  16. public:
  17. SmartCardThreadList();
  18. ~SmartCardThreadList();
  19. void Remove(SECMODModule* module);
  20. nsresult Add(SmartCardMonitoringThread* thread);
  21. private:
  22. SmartCardThreadEntry* head;
  23. };
  24. //
  25. // monitor a Module for token insertion and removal
  26. //
  27. // NOTE: this provides the application the ability to dynamically add slots
  28. // on the fly as necessary.
  29. //
  30. class SmartCardMonitoringThread
  31. {
  32. public:
  33. explicit SmartCardMonitoringThread(SECMODModule* module);
  34. ~SmartCardMonitoringThread();
  35. nsresult Start();
  36. void Stop();
  37. void Execute();
  38. void Interrupt();
  39. const SECMODModule* GetModule();
  40. private:
  41. static void LaunchExecute(void* arg);
  42. void SetTokenName(CK_SLOT_ID slotid, const char* tokenName, uint32_t series);
  43. const char* GetTokenName(CK_SLOT_ID slotid);
  44. uint32_t GetTokenSeries(CK_SLOT_ID slotid);
  45. void SendEvent(const nsAString& type, const char* tokenName);
  46. SECMODModule* mModule;
  47. PLHashTable* mHash;
  48. PRThread* mThread;
  49. };
  50. #endif // nsSmartCardMonitor_h