Diff

Differences From Artifact [02273309f5]:

To Artifact [cf6e270a5f]:


    33     33   		virtual void HandleMessageThread(pp::VarDictionary *message, pp::Var *messagePlain) {
    34     34   			cackey_chrome_returnType signRet;
    35     35   			char *pinPrompt = NULL;
    36     36   			const char *pin;
    37     37   			const char *smartcardManagerAppId = NULL;
    38     38   			unsigned char buffer[8192];
    39     39   			struct cackey_certificate *certificates, incomingCertificateCACKey;
    40         -			pp::VarDictionary *reply;
    41         -			pp::VarArray certificatesPPArray;
           40  +			struct cackey_reader *readers;
           41  +			pp::VarDictionary *reply, *readerInfo;
           42  +			pp::VarArray certificatesPPArray, readersPPArray;
    42     43   			pp::VarArrayBuffer *certificateContents, *incomingCertificateContents, *incomingData, *outgoingData;
    43     44   			pp::Var command;
    44         -			int numCertificates, i;
           45  +			int numCertificates, numReaders, i;
    45     46   			unsigned long outgoingDataLength;
    46     47   
    47     48   			/*
    48     49   			 * Extract the command
    49     50   			 */
    50     51   			command = message->Get("command");
    51     52   
................................................................................
    83     84   					delete certificateContents;
    84     85   				}
    85     86   
    86     87   				cackey_chrome_freeCertificates(certificates, numCertificates);
    87     88   
    88     89   				reply->Set("status", "success");
    89     90   				reply->Set("certificates", certificatesPPArray);
           91  +			} else if (command.AsString() == "listreaders") {
           92  +				numReaders = cackey_chrome_listReaders(&readers);
           93  +
           94  +				readersPPArray.SetLength(numReaders);
           95  +
           96  +				for (i = 0; i < numReaders; i++) {
           97  +					readerInfo = new pp::VarDictionary;
           98  +
           99  +					readerInfo->Set("readerName", readers[i].reader);
          100  +					readerInfo->Set("cardInserted", readers[i].cardInserted);
          101  +
          102  +					readersPPArray.Set(i, *readerInfo);
          103  +
          104  +					delete readerInfo;
          105  +				}
          106  +
          107  +				cackey_chrome_freeReaders(readers, numReaders);
          108  +
          109  +				reply->Set("status", "success");
          110  +				reply->Set("readers", readersPPArray);
    90    111   			} else if (command.AsString() == "sign") {
    91    112   				if (!message->HasKey("certificate")) {
    92    113   					reply->Set("status", "error");
    93    114   					reply->Set("error", "Certificate not supplied");
    94    115   				} else if (!message->HasKey("data")) {
    95    116   					reply->Set("status", "error");
    96    117   					reply->Set("error", "Data not supplied");