Diff

Differences From Artifact [7e38a33c28]:

To Artifact [7c0a1742a0]:


    15     15   #include <ppapi/cpp/var_array_buffer.h>
    16     16   
    17     17   #include "pcsc-nacl.h"
    18     18   #include "cackey-chrome.h"
    19     19   
    20     20   class CACKeyInstance : public pp::Instance {
    21     21   	private:
    22         -		void pcscNaClInitWrapper(pp::Core *core) {
    23         -			pcscNaClInit(this, core);
    24         -		}
           22  +		pp::Core *corePointer;
    25     23   	public:
    26     24   		explicit CACKeyInstance(PP_Instance instance, pp::Core *core) : pp::Instance(instance) {
    27         -			std::thread(&CACKeyInstance::pcscNaClInitWrapper, this, core).detach();
           25  +			corePointer = core;
    28     26   		}
    29     27   
    30     28   		virtual ~CACKeyInstance() {}
    31     29   
    32     30   		virtual void HandleMessageThread(pp::VarDictionary *message) {
    33     31   			cackey_chrome_returnType signRet;
    34     32   			char *pinPrompt;
    35     33   			const char *pin;
           34  +			const char *smartcardManagerAppId = NULL;
    36     35   			unsigned char buffer[8192];
    37     36   			struct cackey_certificate *certificates, incomingCertificateCACKey;
    38     37   			pp::VarDictionary *reply;
    39     38   			pp::VarArray certificatesPPArray;
    40     39   			pp::VarArrayBuffer *certificateContents, *incomingCertificateContents, *incomingData, *outgoingData;
    41     40   			pp::Var command;
    42     41   			const pp::Var *messageAsVar = NULL, *outgoingDataAsVar = NULL;
................................................................................
    49     48   			command = message->Get("command");
    50     49   
    51     50   			/*
    52     51   			 * Do the thing we are being asked to do
    53     52   			 */
    54     53   			reply = new pp::VarDictionary();
    55     54   
    56         -			if (command.AsString() == "listcertificates") {
           55  +			if (command.AsString() == "init") {
           56  +				if (message->HasKey("smartcardManagerAppId")) {
           57  +					smartcardManagerAppId = message->Get("smartcardManagerAppId").AsString().c_str();
           58  +				}
           59  +
           60  +				pcscNaClInit(this, corePointer, smartcardManagerAppId, "CACKey");
           61  +
           62  +				reply->Set("status", "success");
           63  +			} else if (command.AsString() == "listcertificates") {
    57     64   				numCertificates = cackey_chrome_listCertificates(&certificates);
    58     65   
    59     66   				certificatesPPArray.SetLength(numCertificates);
    60     67   
    61     68   				for (i = 0; i < numCertificates; i++) {
    62     69   					certificateContents = new pp::VarArrayBuffer(certificates[i].certificate_len);
    63     70