|
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- |
|
2 * |
|
3 * This Source Code Form is subject to the terms of the Mozilla Public |
|
4 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
6 |
|
7 #ifndef _NSKEYGENTHREAD_H_ |
|
8 #define _NSKEYGENTHREAD_H_ |
|
9 |
|
10 #include "keyhi.h" |
|
11 #include "nspr.h" |
|
12 |
|
13 #include "mozilla/Mutex.h" |
|
14 #include "nsIKeygenThread.h" |
|
15 #include "nsCOMPtr.h" |
|
16 |
|
17 class nsIRunnable; |
|
18 |
|
19 class nsKeygenThread : public nsIKeygenThread |
|
20 { |
|
21 private: |
|
22 mozilla::Mutex mutex; |
|
23 |
|
24 nsCOMPtr<nsIRunnable> mNotifyObserver; |
|
25 |
|
26 bool iAmRunning; |
|
27 bool keygenReady; |
|
28 bool statusDialogClosed; |
|
29 bool alreadyReceivedParams; |
|
30 |
|
31 SECKEYPrivateKey *privateKey; |
|
32 SECKEYPublicKey *publicKey; |
|
33 PK11SlotInfo *slot; |
|
34 PK11AttrFlags flags; |
|
35 PK11SlotInfo *altSlot; |
|
36 PK11AttrFlags altFlags; |
|
37 PK11SlotInfo *usedSlot; |
|
38 uint32_t keyGenMechanism; |
|
39 void *params; |
|
40 void *wincx; |
|
41 |
|
42 PRThread *threadHandle; |
|
43 |
|
44 public: |
|
45 nsKeygenThread(); |
|
46 virtual ~nsKeygenThread(); |
|
47 |
|
48 NS_DECL_NSIKEYGENTHREAD |
|
49 NS_DECL_THREADSAFE_ISUPPORTS |
|
50 |
|
51 void SetParams( |
|
52 PK11SlotInfo *a_slot, |
|
53 PK11AttrFlags a_flags, |
|
54 PK11SlotInfo *a_alternative_slot, |
|
55 PK11AttrFlags a_alternative_flags, |
|
56 uint32_t a_keyGenMechanism, |
|
57 void *a_params, |
|
58 void *a_wincx ); |
|
59 |
|
60 nsresult ConsumeResult( |
|
61 PK11SlotInfo **a_used_slot, |
|
62 SECKEYPrivateKey **a_privateKey, |
|
63 SECKEYPublicKey **a_publicKey); |
|
64 |
|
65 void Join(void); |
|
66 |
|
67 void Run(void); |
|
68 }; |
|
69 |
|
70 #endif //_NSKEYGENTHREAD_H_ |