Back to index

lightning-sunbird  0.9+nobinonly
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes
PSMContentDownloader Class Reference

#include <nsNSSComponent.h>

Inheritance diagram for PSMContentDownloader:
Inheritance graph
[legend]
Collaboration diagram for PSMContentDownloader:
Collaboration graph
[legend]

List of all members.

Public Types

enum  { UNKNOWN_TYPE = 0 }
enum  { X509_CA_CERT = 1 }
enum  { X509_USER_CERT = 2 }
enum  { X509_EMAIL_CERT = 3 }
enum  { X509_SERVER_CERT = 4 }
enum  { PKCS7_CRL = 5 }

Public Member Functions

 PSMContentDownloader ()
 PSMContentDownloader (PRUint32 type)
virtual ~PSMContentDownloader ()
void setSilentDownload (PRBool flag)
void setCrlAutodownloadKey (nsAutoString key)
void onDataAvailable (in nsIRequest aRequest, in nsISupports aContext, in nsIInputStream aInputStream, in unsigned long aOffset, in unsigned long aCount)
 Called when the next chunk of data (corresponding to the request) may be read without blocking the calling thread.
void onStartRequest (in nsIRequest aRequest, in nsISupports aContext)
 Called to signify the beginning of an asynchronous request.
void onStopRequest (in nsIRequest aRequest, in nsISupports aContext, in nsresult aStatusCode)
 Called to signify the end of an asynchronous request.

Protected Member Functions

nsresult handleContentDownloadError (nsresult errCode)

Protected Attributes

char * mByteData
PRInt32 mBufferOffset
PRInt32 mBufferSize
PRUint32 mType
PRBool mDoSilentDownload
nsAutoString mCrlAutoDownloadKey
nsCOMPtr< nsIURImURI

Detailed Description

Definition at line 96 of file nsNSSComponent.h.


Member Enumeration Documentation

anonymous enum
Enumerator:
UNKNOWN_TYPE 

Definition at line 109 of file nsNSSComponent.h.

{UNKNOWN_TYPE = 0};
anonymous enum
Enumerator:
X509_CA_CERT 

Definition at line 110 of file nsNSSComponent.h.

{X509_CA_CERT  = 1};
anonymous enum
Enumerator:
X509_USER_CERT 

Definition at line 111 of file nsNSSComponent.h.

anonymous enum
Enumerator:
X509_EMAIL_CERT 

Definition at line 112 of file nsNSSComponent.h.

anonymous enum
Enumerator:
X509_SERVER_CERT 

Definition at line 113 of file nsNSSComponent.h.

anonymous enum
Enumerator:
PKCS7_CRL 

Definition at line 114 of file nsNSSComponent.h.

{PKCS7_CRL = 5};

Constructor & Destructor Documentation

Definition at line 99 of file nsNSSComponent.h.

{NS_ASSERTION(PR_FALSE, "don't use this constructor."); }

Definition at line 2368 of file nsNSSComponent.cpp.

Definition at line 2375 of file nsNSSComponent.cpp.

{
  if (mByteData)
    nsMemory::Free(mByteData);
}

Member Function Documentation

Definition at line 2505 of file nsNSSComponent.cpp.

{
  nsString tmpMessage;
  nsresult rv;
  nsCOMPtr<nsINSSComponent> nssComponent(do_GetService(kNSSComponentCID, &rv));
  if(NS_FAILED(rv)){
    return rv;
  }
      
  //Handling errors for crl download only, for now.
  switch (mType){
  case PSMContentDownloader::PKCS7_CRL:

    //TO DO: Handle network errors in details
    //XXXXXXXXXXXXXXXXXX
    nssComponent->GetPIPNSSBundleString("CrlImportFailureNetworkProblem", tmpMessage);
      
    if(mDoSilentDownload == PR_TRUE){
      //This is the case for automatic download. Update failure history
      nsCAutoString updateErrCntPrefStr(CRL_AUTOUPDATE_ERRCNT_PREF);
      nsCAutoString updateErrDetailPrefStr(CRL_AUTOUPDATE_ERRDETAIL_PREF);
      PRUnichar *nameInDb;
      nsCString errMsg;
      PRInt32 errCnt;

      nsCOMPtr<nsIPrefBranch> pref = do_GetService(NS_PREFSERVICE_CONTRACTID,&rv);
      if(NS_FAILED(rv)){
        return rv;
      }
      
      nameInDb = (PRUnichar *)mCrlAutoDownloadKey.get();
      updateErrCntPrefStr.AppendWithConversion(nameInDb);
      updateErrDetailPrefStr.AppendWithConversion(nameInDb);  
      errMsg.AssignWithConversion(tmpMessage.get());
      
      rv = pref->GetIntPref(updateErrCntPrefStr.get(),&errCnt);
      if( (NS_FAILED(rv)) || (errCnt == 0) ){
        pref->SetIntPref(updateErrCntPrefStr.get(),1);
      }else{
        pref->SetIntPref(updateErrCntPrefStr.get(),errCnt+1);
      }
      pref->SetCharPref(updateErrDetailPrefStr.get(),errMsg.get());
      nsCOMPtr<nsIPrefService> prefSvc(do_QueryInterface(pref));
      prefSvc->SavePrefFile(nsnull);
    }else{
      nsString message;
      nsCOMPtr<nsIWindowWatcher> wwatch(do_GetService(NS_WINDOWWATCHER_CONTRACTID));
      nsCOMPtr<nsIPrompt> prompter;
      if (wwatch){
        wwatch->GetNewPrompter(0, getter_AddRefs(prompter));
        nssComponent->GetPIPNSSBundleString("CrlImportFailure1", message);
        message.Append(NS_LITERAL_STRING("\n").get());
        message.Append(tmpMessage);
        nssComponent->GetPIPNSSBundleString("CrlImportFailure2", tmpMessage);
        message.Append(NS_LITERAL_STRING("\n").get());
        message.Append(tmpMessage);

        if(prompter) {
          nsPSMUITracker tracker;
          if (!tracker.isUIForbidden()) {
            prompter->Alert(0, message.get());
          }
        }
      }
    }
    break;
  default:
    break;
  }

  return NS_OK;

}

Here is the call graph for this function:

void nsIStreamListener::onDataAvailable ( in nsIRequest  aRequest,
in nsISupports  aContext,
in nsIInputStream  aInputStream,
in unsigned long  aOffset,
in unsigned long  aCount 
) [inherited]

Called when the next chunk of data (corresponding to the request) may be read without blocking the calling thread.

The onDataAvailable impl must read exactly |aCount| bytes of data before returning.

Parameters:
aRequestrequest corresponding to the source of the data
aContextuser defined context
aInputStreaminput stream containing the data chunk
aOffsetNumber of bytes that were sent in previous onDataAvailable calls for this request. In other words, the sum of all previous count parameters. If that number is greater than or equal to 2^32, this parameter will be PR_UINT32_MAX (2^32 - 1).
aCountnumber of bytes available in the stream

NOTE: The aInputStream parameter must implement readSegments.

An exception thrown from onDataAvailable has the side-effect of causing the request to be canceled.

void nsIRequestObserver::onStartRequest ( in nsIRequest  aRequest,
in nsISupports  aContext 
) [inherited]

Called to signify the beginning of an asynchronous request.

Parameters:
aRequestrequest being observed
aContextuser defined context

An exception thrown from onStartRequest has the side-effect of causing the request to be canceled.

Here is the caller graph for this function:

void nsIRequestObserver::onStopRequest ( in nsIRequest  aRequest,
in nsISupports  aContext,
in nsresult  aStatusCode 
) [inherited]

Called to signify the end of an asynchronous request.

This call is always preceded by a call to onStartRequest.

Parameters:
aRequestrequest being observed
aContextuser defined context
aStatusCodereason for stopping (NS_OK if completed successfully)

An exception thrown from onStopRequest is generally ignored.

Here is the caller graph for this function:

Definition at line 2586 of file nsNSSComponent.cpp.

Here is the caller graph for this function:

Definition at line 2580 of file nsNSSComponent.cpp.

Here is the caller graph for this function:


Member Data Documentation

Definition at line 118 of file nsNSSComponent.h.

Definition at line 119 of file nsNSSComponent.h.

Definition at line 117 of file nsNSSComponent.h.

Definition at line 122 of file nsNSSComponent.h.

Definition at line 121 of file nsNSSComponent.h.

Definition at line 120 of file nsNSSComponent.h.

Definition at line 123 of file nsNSSComponent.h.


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