|
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 |
|
5 /* |
|
6 * JARNAV.C |
|
7 * |
|
8 * JAR stuff needed for client only. |
|
9 * |
|
10 */ |
|
11 |
|
12 #include "jar.h" |
|
13 #include "jarint.h" |
|
14 |
|
15 /* from proto.h */ |
|
16 extern MWContext *FE_GetInitContext(void); |
|
17 |
|
18 /* To return an MWContext for Java */ |
|
19 static MWContext *(*jar_fn_FindSomeContext) (void) = NULL; |
|
20 |
|
21 /* To fabricate an MWContext for FE_GetPassword */ |
|
22 static MWContext *(*jar_fn_GetInitContext) (void) = NULL; |
|
23 |
|
24 /* |
|
25 * J A R _ i n i t |
|
26 * |
|
27 * Initialize the JAR functions. |
|
28 * |
|
29 */ |
|
30 |
|
31 void JAR_init (void) |
|
32 { |
|
33 JAR_init_callbacks (XP_GetString, NULL, NULL); |
|
34 } |
|
35 |
|
36 /* |
|
37 * J A R _ s e t _ c o n t e x t |
|
38 * |
|
39 * Set the jar window context for use by PKCS11, since |
|
40 * it may be needed to prompt the user for a password. |
|
41 * |
|
42 */ |
|
43 int |
|
44 JAR_set_context(JAR *jar, MWContext *mw) |
|
45 { |
|
46 if (mw) { |
|
47 jar->mw = mw; |
|
48 } else { |
|
49 /* jar->mw = XP_FindSomeContext(); */ |
|
50 jar->mw = NULL; |
|
51 /* |
|
52 * We can't find a context because we're in startup state and none |
|
53 * exist yet. go get an FE_InitContext that only works at |
|
54 * initialization time. |
|
55 */ |
|
56 /* Turn on the mac when we get the FE_ function */ |
|
57 if (jar->mw == NULL) { |
|
58 jar->mw = jar_fn_GetInitContext(); |
|
59 } |
|
60 } |
|
61 return 0; |
|
62 } |