cryptoservices/filebasedcertificateandkeystores/test/certtool/certtool_import.cpp
changeset 29 ece3df019add
parent 8 35751d3474b7
--- a/cryptoservices/filebasedcertificateandkeystores/test/certtool/certtool_import.cpp	Fri Nov 06 13:21:00 2009 +0200
+++ b/cryptoservices/filebasedcertificateandkeystores/test/certtool/certtool_import.cpp	Tue Nov 24 09:06:03 2009 +0200
@@ -54,7 +54,8 @@
 
 void CCertToolAdd::ConstructL()
 	{
-
+	//The Certificate added is deletable by default.
+	iIsDeletable = ETrue;
 	}
 
 
@@ -152,10 +153,35 @@
 		TCertificateFormat format = DoRecognizeL(*iCertData);
 						
 		iState = EIntermediate;
+		
+		/**
+		 * If the iIsDeletable variable of iParams is set, parse its value
+		 * and set the iIsDeletable flag appropriately.
+		 */
+		if(iParams->iIsDeletable)
+		    {
+		    HBufC* lowerCaseString = HBufC::NewLC(iParams->iIsDeletable->Length());
+		    TPtr ptr(lowerCaseString->Des());
+		    
+		    //Convert to lower case.
+		    ptr.CopyLC(*iParams->iIsDeletable);
+		    
+		    if(ptr.CompareF(_L("n")) == 0 || ptr.CompareF(_L("no")) == 0 )
+		        {
+		        iIsDeletable = EFalse;
+		        }
+            else if (ptr.CompareF(_L("y")) != 0  && ptr.CompareF(_L("yes")) != 0)
+                {
+                //Wrong value passed.
+                User::Leave(KErrArgument);     
+                }
+
+		    CleanupStack::PopAndDestroy(lowerCaseString);            
+		    }
 
 		SetActive();
 		//wCertStore.Add(*iParams->iLabel, format, ECACertificate, NULL, NULL, *iCertData, iStatus);
-		wCertStore.Add(*iParams->iLabel, format, EUserCertificate, NULL, NULL, *iCertData, iStatus);
+		wCertStore.Add(*iParams->iLabel, format, EUserCertificate, NULL, NULL, *iCertData, iIsDeletable, iStatus);
 		CleanupStack::PopAndDestroy(2, &fs);
 	}
 
@@ -178,7 +204,7 @@
 				MCTWritableCertStore& wCertStore = iCertStore->WritableCertStore(iParams->iCertstoreIndex);
 				TCertificateFormat format = DoRecognizeL(*iCertData);
 				SetActive();				
-				wCertStore.Add(*iParams->iLabel, format, ECACertificate, NULL, NULL, *iCertData, iStatus);				
+				wCertStore.Add(*iParams->iLabel, format, ECACertificate, NULL, NULL, *iCertData, iIsDeletable, iStatus);				
 				}
 			else 
 				{