michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: #ifndef _NSSMARTCARDMONITOR_ michael@0: #define _NSSMARTCARDMONITOR_ michael@0: michael@0: #include "prthread.h" michael@0: #include "secmod.h" michael@0: #include "plhash.h" michael@0: #include "pkcs11t.h" michael@0: michael@0: class SmartCardThreadEntry; michael@0: class SmartCardMonitoringThread; michael@0: michael@0: // michael@0: // manage a group of SmartCardMonitoringThreads michael@0: // michael@0: class SmartCardThreadList { michael@0: public: michael@0: SmartCardThreadList(); michael@0: ~SmartCardThreadList(); michael@0: void Remove(SECMODModule *module); michael@0: nsresult Add(SmartCardMonitoringThread *thread); michael@0: private: michael@0: SmartCardThreadEntry *head; michael@0: }; michael@0: michael@0: // michael@0: // monitor a Module for token insertion and removal michael@0: // michael@0: // NOTE: this provides the application the ability to dynamically add slots michael@0: // on the fly as necessary. michael@0: // michael@0: class SmartCardMonitoringThread michael@0: { michael@0: public: michael@0: SmartCardMonitoringThread(SECMODModule *module); michael@0: ~SmartCardMonitoringThread(); michael@0: michael@0: nsresult Start(); michael@0: void Stop(); michael@0: michael@0: void Execute(); michael@0: void Interrupt(); michael@0: michael@0: const SECMODModule *GetModule(); michael@0: michael@0: private: michael@0: michael@0: static void LaunchExecute(void *arg); michael@0: void SetTokenName(CK_SLOT_ID slotid, const char *tokenName, uint32_t series); michael@0: const char *GetTokenName(CK_SLOT_ID slotid); michael@0: uint32_t GetTokenSeries(CK_SLOT_ID slotid); michael@0: nsresult SendEvent(const nsAString &type,const char *tokenName); michael@0: michael@0: michael@0: SECMODModule *mModule; michael@0: PLHashTable *mHash; michael@0: PRThread* mThread; michael@0: }; michael@0: michael@0: #endif