Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 2 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 3 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 4 | |
michael@0 | 5 | /* |
michael@0 | 6 | * JARNAV.C |
michael@0 | 7 | * |
michael@0 | 8 | * JAR stuff needed for client only. |
michael@0 | 9 | * |
michael@0 | 10 | */ |
michael@0 | 11 | |
michael@0 | 12 | #include "jar.h" |
michael@0 | 13 | #include "jarint.h" |
michael@0 | 14 | |
michael@0 | 15 | /* from proto.h */ |
michael@0 | 16 | extern MWContext *FE_GetInitContext(void); |
michael@0 | 17 | |
michael@0 | 18 | /* To return an MWContext for Java */ |
michael@0 | 19 | static MWContext *(*jar_fn_FindSomeContext) (void) = NULL; |
michael@0 | 20 | |
michael@0 | 21 | /* To fabricate an MWContext for FE_GetPassword */ |
michael@0 | 22 | static MWContext *(*jar_fn_GetInitContext) (void) = NULL; |
michael@0 | 23 | |
michael@0 | 24 | /* |
michael@0 | 25 | * J A R _ i n i t |
michael@0 | 26 | * |
michael@0 | 27 | * Initialize the JAR functions. |
michael@0 | 28 | * |
michael@0 | 29 | */ |
michael@0 | 30 | |
michael@0 | 31 | void JAR_init (void) |
michael@0 | 32 | { |
michael@0 | 33 | JAR_init_callbacks (XP_GetString, NULL, NULL); |
michael@0 | 34 | } |
michael@0 | 35 | |
michael@0 | 36 | /* |
michael@0 | 37 | * J A R _ s e t _ c o n t e x t |
michael@0 | 38 | * |
michael@0 | 39 | * Set the jar window context for use by PKCS11, since |
michael@0 | 40 | * it may be needed to prompt the user for a password. |
michael@0 | 41 | * |
michael@0 | 42 | */ |
michael@0 | 43 | int |
michael@0 | 44 | JAR_set_context(JAR *jar, MWContext *mw) |
michael@0 | 45 | { |
michael@0 | 46 | if (mw) { |
michael@0 | 47 | jar->mw = mw; |
michael@0 | 48 | } else { |
michael@0 | 49 | /* jar->mw = XP_FindSomeContext(); */ |
michael@0 | 50 | jar->mw = NULL; |
michael@0 | 51 | /* |
michael@0 | 52 | * We can't find a context because we're in startup state and none |
michael@0 | 53 | * exist yet. go get an FE_InitContext that only works at |
michael@0 | 54 | * initialization time. |
michael@0 | 55 | */ |
michael@0 | 56 | /* Turn on the mac when we get the FE_ function */ |
michael@0 | 57 | if (jar->mw == NULL) { |
michael@0 | 58 | jar->mw = jar_fn_GetInitContext(); |
michael@0 | 59 | } |
michael@0 | 60 | } |
michael@0 | 61 | return 0; |
michael@0 | 62 | } |