@@ -17,24 +17,23 @@ #include "pcsc-nacl.h" #include "cackey-chrome.h" class CACKeyInstance : public pp::Instance { private: - void pcscNaClInitWrapper(pp::Core *core) { - pcscNaClInit(this, core); - } + pp::Core *corePointer; public: explicit CACKeyInstance(PP_Instance instance, pp::Core *core) : pp::Instance(instance) { - std::thread(&CACKeyInstance::pcscNaClInitWrapper, this, core).detach(); + corePointer = core; } virtual ~CACKeyInstance() {} virtual void HandleMessageThread(pp::VarDictionary *message) { cackey_chrome_returnType signRet; char *pinPrompt; const char *pin; + const char *smartcardManagerAppId = NULL; unsigned char buffer[8192]; struct cackey_certificate *certificates, incomingCertificateCACKey; pp::VarDictionary *reply; pp::VarArray certificatesPPArray; pp::VarArrayBuffer *certificateContents, *incomingCertificateContents, *incomingData, *outgoingData; @@ -51,11 +50,19 @@ /* * Do the thing we are being asked to do */ reply = new pp::VarDictionary(); - if (command.AsString() == "listcertificates") { + if (command.AsString() == "init") { + if (message->HasKey("smartcardManagerAppId")) { + smartcardManagerAppId = message->Get("smartcardManagerAppId").AsString().c_str(); + } + + pcscNaClInit(this, corePointer, smartcardManagerAppId, "CACKey"); + + reply->Set("status", "success"); + } else if (command.AsString() == "listcertificates") { numCertificates = cackey_chrome_listCertificates(&certificates); certificatesPPArray.SetLength(numCertificates); for (i = 0; i < numCertificates; i++) {