Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Private Attributes
nsP12Runnable Class Reference
Inheritance diagram for nsP12Runnable:
Inheritance graph
[legend]
Collaboration diagram for nsP12Runnable:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 nsP12Runnable (nsIX509Cert **certArr, PRInt32 numCerts, nsIPK11Token *token)
virtual ~nsP12Runnable ()
NS_IMETHOD Run ()
 Defines an entry point for a newly created thread.
void run ()

Private Attributes

nsCOMPtr< nsIPK11TokenmToken
nsIX509Cert ** mCertArr
PRInt32 mNumCerts

Detailed Description

Definition at line 183 of file nsCrypto.cpp.


Constructor & Destructor Documentation

nsP12Runnable::nsP12Runnable ( nsIX509Cert **  certArr,
PRInt32  numCerts,
nsIPK11Token token 
)

Definition at line 1649 of file nsCrypto.cpp.

{
  mCertArr  = certArr;
  mNumCerts = numCerts;
  mToken = token;
}

Definition at line 1657 of file nsCrypto.cpp.

{
  PRInt32 i;
  for (i=0; i<mNumCerts; i++) {
      NS_IF_RELEASE(mCertArr[i]);
  }
  delete []mCertArr;
}

Member Function Documentation

void nsIRunnable::run ( ) [inherited]

Defines an entry point for a newly created thread.

Implements nsIRunnable.

Definition at line 1686 of file nsCrypto.cpp.

{
  nsNSSShutDownPreventionLock locker;
  NS_ASSERTION(mCertArr, "certArr is NULL while trying to back up");

  nsString final;
  nsString temp;
  nsresult rv;

  nsCOMPtr<nsINSSComponent> nssComponent(do_GetService(kNSSComponentCID, &rv));
  if (NS_FAILED(rv))
    return rv;

  //Build up the message that let's the user know we're trying to 
  //make PKCS12 backups of the new certs.
  nssComponent->GetPIPNSSBundleString("ForcedBackup1", final);
  final.Append(NS_LITERAL_STRING("\n\n").get());
  nssComponent->GetPIPNSSBundleString("ForcedBackup2", temp);
  final.Append(temp.get());
  final.Append(NS_LITERAL_STRING("\n\n").get());

  nssComponent->GetPIPNSSBundleString("ForcedBackup3", temp);

  final.Append(temp.get());
  alertUser(final.get());

  nsCOMPtr<nsIFilePicker> filePicker = 
                        do_CreateInstance("@mozilla.org/filepicker;1", &rv);
  if (!filePicker) {
    NS_ASSERTION(0, "Could not create a file picker when backing up certs.");
    return rv;
  }

  nsCOMPtr<nsIWindowWatcher> wwatch =
    (do_GetService(NS_WINDOWWATCHER_CONTRACTID, &rv));
  NS_ENSURE_SUCCESS(rv, rv);

  nsCOMPtr<nsIDOMWindow> window;
  wwatch->GetActiveWindow(getter_AddRefs(window));

  nsString filePickMessage;
  nssComponent->GetPIPNSSBundleString("chooseP12BackupFileDialog",
                                      filePickMessage);
  rv = filePicker->Init(window, filePickMessage, nsIFilePicker::modeSave);
  NS_ENSURE_SUCCESS(rv, rv);

  filePicker->AppendFilter(NS_LITERAL_STRING("PKCS12"),
                           NS_LITERAL_STRING("*.p12"));
  filePicker->AppendFilters(nsIFilePicker::filterAll);

  PRInt16 dialogReturn;
  filePicker->Show(&dialogReturn);
  if (dialogReturn == nsIFilePicker::returnCancel)
    return NS_OK;  //User canceled.  It'd be nice if they couldn't, 
                   //but oh well.

  nsCOMPtr<nsILocalFile> localFile;
  rv = filePicker->GetFile(getter_AddRefs(localFile));
  if (NS_FAILED(rv))
    return NS_ERROR_FAILURE;

  nsPKCS12Blob p12Cxt;
  
  p12Cxt.SetToken(mToken);
  p12Cxt.ExportToFile(localFile, mCertArr, mNumCerts);
  return NS_OK;
}

Here is the call graph for this function:


Member Data Documentation

Definition at line 192 of file nsCrypto.cpp.

Definition at line 193 of file nsCrypto.cpp.

Definition at line 191 of file nsCrypto.cpp.


The documentation for this class was generated from the following file: