|
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_ |
|
5 #define _NSSMARTCARDMONITOR_ |
|
6 |
|
7 #include "prthread.h" |
|
8 #include "secmod.h" |
|
9 #include "plhash.h" |
|
10 #include "pkcs11t.h" |
|
11 |
|
12 class SmartCardThreadEntry; |
|
13 class SmartCardMonitoringThread; |
|
14 |
|
15 // |
|
16 // manage a group of SmartCardMonitoringThreads |
|
17 // |
|
18 class SmartCardThreadList { |
|
19 public: |
|
20 SmartCardThreadList(); |
|
21 ~SmartCardThreadList(); |
|
22 void Remove(SECMODModule *module); |
|
23 nsresult Add(SmartCardMonitoringThread *thread); |
|
24 private: |
|
25 SmartCardThreadEntry *head; |
|
26 }; |
|
27 |
|
28 // |
|
29 // monitor a Module for token insertion and removal |
|
30 // |
|
31 // NOTE: this provides the application the ability to dynamically add slots |
|
32 // on the fly as necessary. |
|
33 // |
|
34 class SmartCardMonitoringThread |
|
35 { |
|
36 public: |
|
37 SmartCardMonitoringThread(SECMODModule *module); |
|
38 ~SmartCardMonitoringThread(); |
|
39 |
|
40 nsresult Start(); |
|
41 void Stop(); |
|
42 |
|
43 void Execute(); |
|
44 void Interrupt(); |
|
45 |
|
46 const SECMODModule *GetModule(); |
|
47 |
|
48 private: |
|
49 |
|
50 static void LaunchExecute(void *arg); |
|
51 void SetTokenName(CK_SLOT_ID slotid, const char *tokenName, uint32_t series); |
|
52 const char *GetTokenName(CK_SLOT_ID slotid); |
|
53 uint32_t GetTokenSeries(CK_SLOT_ID slotid); |
|
54 nsresult SendEvent(const nsAString &type,const char *tokenName); |
|
55 |
|
56 |
|
57 SECMODModule *mModule; |
|
58 PLHashTable *mHash; |
|
59 PRThread* mThread; |
|
60 }; |
|
61 |
|
62 #endif |