Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Protected Member Functions | Private Member Functions
nsAddressBook Class Reference

#include <nsAddressBook.h>

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

List of all members.

Public Member Functions

 nsAddressBook ()
virtual ~nsAddressBook ()
void newAddressBook (in nsIAbDirectoryProperties aProperties)
void modifyAddressBook (in nsIRDFDataSource aDS, in nsIAbDirectory aParentDir, in nsIAbDirectory aDirectory, in nsIAbDirectoryProperties aProperties)
void deleteAddressBooks (in nsIRDFDataSource aDS, in nsISupportsArray aParentDir, in nsISupportsArray aResourceArray)
void exportAddressBook (in nsIDOMWindow aParentWin, in nsIAbDirectory aDirectory)
void migrate4xAb (in nsIFileSpec aFileSpec, in boolean aMigrating, in boolean aStoreLocAsHome)
 Migrates a 4x ldif address book to our format.
void convertNA2toLDIF (in nsIFileSpec srcFileSpec, in nsIFileSpec dstFileSpec)
 Converts a Netscape NA2 file to an LDIF file.
nsIAddrDatabase getAbDatabaseFromURI (in string URI)
boolean mailListNameExists (in wstring name)
nsIAbCard escapedVCardToAbCard (in string escapedVCardStr)
string abCardToEscapedVCard (in nsIAbCard aCard)
void convert4xVCardPrefs (in string prefRoot, out string escapedVCardStr)
void handleContent (in string aContentType, in nsIInterfaceRequestor aWindowContext, in nsIRequest aRequest)
 Tells the content handler to take over handling the content.
void onStreamComplete (in nsIStreamLoader loader, in nsISupports ctxt, in nsresult status, in unsigned long resultLength,[const, array, size_is(resultLength)] in octet result)

Protected Member Functions

nsresult DoCommand (nsIRDFDataSource *db, const nsACString &command, nsISupportsArray *srcArray, nsISupportsArray *arguments)
nsresult GetAbDatabaseFromFile (char *pDbFile, nsIAddrDatabase **db)

Private Member Functions

nsresult ExportDirectoryToDelimitedText (nsIAbDirectory *aDirectory, const char *aDelim, PRUint32 aDelimLen, nsILocalFile *aLocalFile)
nsresult ExportDirectoryToLDIF (nsIAbDirectory *aDirectory, nsILocalFile *aLocalFile)
nsresult AppendLDIFForMailList (nsIAbCard *aCard, nsACString &aResult)
nsresult AppendDNForCard (const char *aProperty, nsIAbCard *aCard, nsACString &aResult)
nsresult AppendBasicLDIFForCard (nsIAbCard *aCard, nsACString &aResult)
nsresult AppendProperty (const char *aProperty, const PRUnichar *aValue, nsACString &aResult)
PRBool IsSafeLDIFString (const PRUnichar *aStr)

Detailed Description

Definition at line 93 of file nsAddressBook.h.


Constructor & Destructor Documentation

Definition at line 174 of file nsAddressBook.cpp.

{
}

Definition at line 178 of file nsAddressBook.cpp.

{
}

Member Function Documentation

nsresult nsAddressBook::AppendBasicLDIFForCard ( nsIAbCard aCard,
nsACString &  aResult 
) [private]

Definition at line 1040 of file nsAddressBook.cpp.

{
  nsresult rv = AppendDNForCard("dn", aCard, aResult);
  NS_ENSURE_SUCCESS(rv,rv);
  aResult += LDIF_LINEBREAK \
    "objectclass: top" LDIF_LINEBREAK \
    "objectclass: person" LDIF_LINEBREAK \
    "objectclass: organizationalPerson" LDIF_LINEBREAK \
    "objectclass: inetOrgPerson" LDIF_LINEBREAK \
    "objectclass: " MOZ_AB_OBJECTCLASS LDIF_LINEBREAK;  


  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsAddressBook::AppendDNForCard ( const char *  aProperty,
nsIAbCard aCard,
nsACString &  aResult 
) [private]

Definition at line 1011 of file nsAddressBook.cpp.

{
  nsXPIDLString email;
  nsXPIDLString displayName;

  nsresult rv = aCard->GetCardValue(kPriEmailColumn, getter_Copies(email));
  NS_ENSURE_SUCCESS(rv,rv);

  rv = aCard->GetCardValue(kDisplayNameColumn, getter_Copies(displayName));
  NS_ENSURE_SUCCESS(rv,rv);

  nsString cnStr;

  if (!displayName.IsEmpty()) {
    cnStr += NS_LITERAL_STRING("cn=") + displayName;
    if (!email.IsEmpty()) {
      cnStr.AppendLiteral(",");
    }
  }

  if (!email.IsEmpty()) {
    cnStr += NS_LITERAL_STRING("mail=") + email;
  }

  rv = AppendProperty(aProperty, cnStr.get(), aResult);
  NS_ENSURE_SUCCESS(rv,rv);
  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsAddressBook::AppendLDIFForMailList ( nsIAbCard aCard,
nsACString &  aResult 
) [private]

Definition at line 937 of file nsAddressBook.cpp.

{
  nsresult rv;
  nsXPIDLString attrValue;
  
  rv = aCard->GetCardValue(kDisplayNameColumn, getter_Copies(attrValue));
  NS_ENSURE_SUCCESS(rv,rv);

  rv = AppendDNForCard("dn", aCard, aResult);
  NS_ENSURE_SUCCESS(rv,rv);

  aResult += LDIF_LINEBREAK \
             "objectclass: top" LDIF_LINEBREAK \
             "objectclass: groupOfNames" LDIF_LINEBREAK;

  rv = AppendProperty("cn", attrValue.get(), aResult);
  NS_ENSURE_SUCCESS(rv,rv);
  aResult += LDIF_LINEBREAK;

  rv = aCard->GetCardValue(kNicknameColumn, getter_Copies(attrValue));
  NS_ENSURE_SUCCESS(rv,rv);

  if (!attrValue.IsEmpty()) {
    rv = AppendProperty("mozillaNickname", attrValue.get(), aResult);
    NS_ENSURE_SUCCESS(rv,rv);
    aResult += LDIF_LINEBREAK;
  }

  rv = aCard->GetCardValue(kNotesColumn, getter_Copies(attrValue));
  NS_ENSURE_SUCCESS(rv,rv);

  if (!attrValue.IsEmpty()) {
    rv = AppendProperty("description", attrValue.get(), aResult);
    NS_ENSURE_SUCCESS(rv,rv);
    aResult += LDIF_LINEBREAK;
  }

  nsCOMPtr<nsIRDFService> rdfService = do_GetService("@mozilla.org/rdf/rdf-service;1", &rv);
  NS_ENSURE_SUCCESS(rv,rv);
  
  nsXPIDLCString mailListURI;
  rv = aCard->GetMailListURI(getter_Copies(mailListURI));
  NS_ENSURE_SUCCESS(rv,rv);
  
  nsCOMPtr <nsIRDFResource> resource;
  rv = rdfService->GetResource(mailListURI, getter_AddRefs(resource));
  NS_ENSURE_SUCCESS(rv,rv);
    
  nsCOMPtr <nsIAbDirectory> mailList = do_QueryInterface(resource, &rv);
  NS_ENSURE_SUCCESS(rv,rv);
    
  nsCOMPtr<nsISupportsArray> addresses;
  rv = mailList->GetAddressLists(getter_AddRefs(addresses));
  if (addresses) {
    PRUint32 total = 0;
    addresses->Count(&total);
    if (total) {
      PRUint32 i;
      for (i = 0; i < total; i++) {
        nsCOMPtr <nsIAbCard> listCard = do_QueryElementAt(addresses, i, &rv);
        NS_ENSURE_SUCCESS(rv,rv);

        rv = AppendDNForCard("member", listCard, aResult);
        NS_ENSURE_SUCCESS(rv,rv);

        aResult += LDIF_LINEBREAK;
      }
    }
  }
  
  aResult += LDIF_LINEBREAK;
  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsAddressBook::AppendProperty ( const char *  aProperty,
const PRUnichar aValue,
nsACString &  aResult 
) [private]

Definition at line 1076 of file nsAddressBook.cpp.

{
  NS_ENSURE_ARG_POINTER(aValue);

  aResult += aProperty;
 
  // if the string is not safe "as is", base64 encode it
  if (IsSafeLDIFString(aValue)) {
    aResult.AppendLiteral(": ");
    LossyAppendUTF16toASCII(aValue, aResult);
  }
  else {
    char *base64Str = PL_Base64Encode(NS_ConvertUCS2toUTF8(aValue).get(), 0, nsnull);
    if (!base64Str)
      return NS_ERROR_OUT_OF_MEMORY;

    aResult += NS_LITERAL_CSTRING(":: ") + nsDependentCString(base64Str);
    PR_Free(base64Str);
  }

  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsIAddressBook::convert4xVCardPrefs ( in string  prefRoot,
out string  escapedVCardStr 
) [inherited]
void nsIAddressBook::convertNA2toLDIF ( in nsIFileSpec  srcFileSpec,
in nsIFileSpec  dstFileSpec 
) [inherited]

Converts a Netscape NA2 file to an LDIF file.

Will only work on Commercial builds.

Parameters:
srcFileSpecThe source file to convert
dstFileSpecThe destination file for the conversion
void nsIAddressBook::deleteAddressBooks ( in nsIRDFDataSource  aDS,
in nsISupportsArray  aParentDir,
in nsISupportsArray  aResourceArray 
) [inherited]
nsresult nsAddressBook::DoCommand ( nsIRDFDataSource db,
const nsACString &  command,
nsISupportsArray srcArray,
nsISupportsArray arguments 
) [protected]

Definition at line 253 of file nsAddressBook.cpp.

{
  nsresult rv = NS_OK;

  nsCOMPtr<nsIRDFService> rdfService = do_GetService (NS_RDF_CONTRACTID "/rdf-service;1", &rv);
  NS_ENSURE_SUCCESS(rv, rv);

  nsCOMPtr<nsIRDFResource> commandResource;
  rv = rdfService->GetResource(command, getter_AddRefs(commandResource));
  if(NS_SUCCEEDED(rv))
  {
    rv = db->DoCommand(srcArray, commandResource, argumentArray);
  }

  return rv;
}

Here is the call graph for this function:

nsIAbCard nsIAddressBook::escapedVCardToAbCard ( in string  escapedVCardStr) [inherited]
void nsIAddressBook::exportAddressBook ( in nsIDOMWindow  aParentWin,
in nsIAbDirectory  aDirectory 
) [inherited]
nsresult nsAddressBook::ExportDirectoryToDelimitedText ( nsIAbDirectory aDirectory,
const char *  aDelim,
PRUint32  aDelimLen,
nsILocalFile aLocalFile 
) [private]

Definition at line 639 of file nsAddressBook.cpp.

{
  nsCOMPtr <nsIEnumerator> cardsEnumerator;
  nsCOMPtr <nsIAbCard> card;

  nsresult rv;

  nsCOMPtr <nsIImportService> importService = do_GetService(NS_IMPORTSERVICE_CONTRACTID, &rv);
  NS_ENSURE_SUCCESS(rv,rv);

  nsCOMPtr <nsIOutputStream> outputStream;
  rv = NS_NewLocalFileOutputStream(getter_AddRefs(outputStream),
                                   aLocalFile,
                                   PR_CREATE_FILE | PR_WRONLY | PR_TRUNCATE,
                                   0664);

  // the desired file may be read only
  if (NS_FAILED(rv))
    return rv;

  PRUint32 i;
  PRUint32 writeCount;
  PRUint32 length;

  nsCOMPtr<nsIStringBundleService> bundleService = do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv);
  NS_ENSURE_SUCCESS(rv, rv);

  nsCOMPtr<nsIStringBundle> bundle;
  rv = bundleService->CreateBundle("chrome://messenger/locale/importMsgs.properties", getter_AddRefs(bundle));
  NS_ENSURE_SUCCESS(rv, rv);

  nsXPIDLCString revisedName;
  nsXPIDLString columnName;

  for (i = 0; i < EXPORT_ATTRIBUTES_TABLE_COUNT; i++) {
    if (EXPORT_ATTRIBUTES_TABLE[i].plainTextStringID != 0) {

      // We don't need to truncate the string here as getter_Copies will
      // do that for us.
      if (NS_FAILED(bundle->GetStringFromID(EXPORT_ATTRIBUTES_TABLE[i].plainTextStringID, getter_Copies(columnName))))
        columnName.AppendInt(EXPORT_ATTRIBUTES_TABLE[i].plainTextStringID);

      importService->SystemStringFromUnicode(columnName.get(), revisedName);

      rv = outputStream->Write(revisedName.get(),
                               revisedName.Length(),
                               &writeCount);
      NS_ENSURE_SUCCESS(rv,rv);

      if (revisedName.Length() != writeCount)
        return NS_ERROR_FAILURE;
      
      if (i < EXPORT_ATTRIBUTES_TABLE_COUNT - 1) {
        rv = outputStream->Write(aDelim, aDelimLen, &writeCount);
        NS_ENSURE_SUCCESS(rv,rv);

        if (aDelimLen != writeCount)
          return NS_ERROR_FAILURE;
      }
    }
  }
  rv = outputStream->Write(MSG_LINEBREAK, MSG_LINEBREAK_LEN, &writeCount);
  NS_ENSURE_SUCCESS(rv,rv);
  if (MSG_LINEBREAK_LEN != writeCount)
    return NS_ERROR_FAILURE;

  rv = aDirectory->GetChildCards(getter_AddRefs(cardsEnumerator));
  if (NS_SUCCEEDED(rv) && cardsEnumerator) {
    nsCOMPtr<nsISupports> item;
    for (rv = cardsEnumerator->First(); NS_SUCCEEDED(rv); rv = cardsEnumerator->Next()) {
      rv = cardsEnumerator->CurrentItem(getter_AddRefs(item));
      if (NS_SUCCEEDED(rv)) {
        nsCOMPtr <nsIAbCard> card = do_QueryInterface(item, &rv);
        NS_ENSURE_SUCCESS(rv,rv);
         
        PRBool isMailList;
        rv = card->GetIsMailList(&isMailList);
        NS_ENSURE_SUCCESS(rv,rv);
       
         
        if (isMailList) {
          // .tab, .txt and .csv aren't able to export mailing lists
          // use LDIF for that.
        }
        else {
          nsXPIDLString value;          
          nsCString valueCStr;

          for (i = 0; i < EXPORT_ATTRIBUTES_TABLE_COUNT; i++) {
            if (EXPORT_ATTRIBUTES_TABLE[i].plainTextStringID != 0) {
              rv = card->GetCardValue(EXPORT_ATTRIBUTES_TABLE[i].abColName, getter_Copies(value));
              NS_ENSURE_SUCCESS(rv,rv);

              // If a string contains at least one comma, tab or double quote then
              // we need to quote the entire string. Also if double quote is part
              // of the string we need to quote the double quote(s) as well.  
              nsAutoString newValue(value);
              PRBool needsQuotes = PR_FALSE;
              if(newValue.FindChar('"') != kNotFound)
              {
                needsQuotes = PR_TRUE;
                newValue.ReplaceSubstring(NS_LITERAL_STRING("\"").get(), NS_LITERAL_STRING("\"\"").get());
              }
              if (!needsQuotes && (newValue.FindChar(',') != kNotFound || newValue.FindChar('\x09') != kNotFound))
                needsQuotes = PR_TRUE;

              if (needsQuotes)
              {
                newValue.Insert(NS_LITERAL_STRING("\""), 0);
                newValue.AppendLiteral("\"");
              }

              // For notes, make sure CR/LF is converted to spaces 
              // to avoid creating multiple lines for a single card.
              //
              // the import code expects .txt, .tab, .csv files to
              // have non-ASCII data in the system charset
              //
              // note, this means if you machine is set to US-ASCII
              // but you have cards with Japanese characters
              // you will lose data when exporting.
              //
              // the solution is to export / import as LDIF.
              // non-ASCII data is treated as base64 encoded UTF-8 in LDIF
              if (!strcmp(EXPORT_ATTRIBUTES_TABLE[i].abColName, kNotesColumn))
              {
                if (!newValue.IsEmpty())
                {
                  newValue.ReplaceChar(nsCRT::CR, ' ');
                  newValue.ReplaceChar(nsCRT::LF, ' ');
                }
              }
              rv = importService->SystemStringFromUnicode(newValue.get(), valueCStr);

              if (NS_FAILED(rv)) {
                NS_ASSERTION(0, "failed to convert string to system charset.  use LDIF");
                valueCStr = "?";
              }
              
              length = valueCStr.Length();
              if (length) {
                rv = outputStream->Write(valueCStr.get(), length, &writeCount);
                NS_ENSURE_SUCCESS(rv,rv);
                if (length != writeCount)
                  return NS_ERROR_FAILURE;
              }
              valueCStr = "";
            }
            else {
              // something we don't support for the current export
              // for example, .tab doesn't export preferred html format
              continue; // go to next field
            }

            if (i < EXPORT_ATTRIBUTES_TABLE_COUNT - 1) {
              rv = outputStream->Write(aDelim, aDelimLen, &writeCount);
              NS_ENSURE_SUCCESS(rv,rv);
              if (aDelimLen != writeCount)
                return NS_ERROR_FAILURE;
            }
          }

          // write out the linebreak that separates the cards
          rv = outputStream->Write(MSG_LINEBREAK, MSG_LINEBREAK_LEN, &writeCount);
          NS_ENSURE_SUCCESS(rv,rv);
          if (MSG_LINEBREAK_LEN != writeCount)
            return NS_ERROR_FAILURE;
        }
      }
    }
  }

  rv = outputStream->Flush();
  NS_ENSURE_SUCCESS(rv,rv);

  rv = outputStream->Close();
  NS_ENSURE_SUCCESS(rv,rv);
  return NS_OK;
}

Here is the call graph for this function:

nsresult nsAddressBook::ExportDirectoryToLDIF ( nsIAbDirectory aDirectory,
nsILocalFile aLocalFile 
) [private]

Definition at line 820 of file nsAddressBook.cpp.

{
  nsCOMPtr <nsIEnumerator> cardsEnumerator;
  nsCOMPtr <nsIAbCard> card;

  nsresult rv;

  nsCOMPtr <nsIOutputStream> outputStream;
  rv = NS_NewLocalFileOutputStream(getter_AddRefs(outputStream),
                                   aLocalFile,
                                   PR_CREATE_FILE | PR_WRONLY | PR_TRUNCATE,
                                   0664);

  // the desired file may be read only
  if (NS_FAILED(rv))
    return rv;

  PRUint32 i;
  PRUint32 writeCount;
  PRUint32 length;
   
  rv = aDirectory->GetChildCards(getter_AddRefs(cardsEnumerator));
  if (NS_SUCCEEDED(rv) && cardsEnumerator) {
    nsCOMPtr<nsISupports> item;
    for (rv = cardsEnumerator->First(); NS_SUCCEEDED(rv); rv = cardsEnumerator->Next()) {
      rv = cardsEnumerator->CurrentItem(getter_AddRefs(item));
      if (NS_SUCCEEDED(rv)) {
        nsCOMPtr <nsIAbCard> card = do_QueryInterface(item, &rv);
        NS_ENSURE_SUCCESS(rv,rv);
         
        PRBool isMailList;
        rv = card->GetIsMailList(&isMailList);
        NS_ENSURE_SUCCESS(rv,rv);
       
        if (isMailList) {
          nsCString mailListCStr;

          rv = AppendLDIFForMailList(card, mailListCStr);
          NS_ENSURE_SUCCESS(rv,rv);

          length = mailListCStr.Length();
          rv = outputStream->Write(mailListCStr.get(), length, &writeCount);
          NS_ENSURE_SUCCESS(rv,rv);
          if (length != writeCount)
            return NS_ERROR_FAILURE;
        }
        else {
          nsXPIDLString value;          
          nsCString valueCStr;
    
          rv = AppendBasicLDIFForCard(card, valueCStr);
          NS_ENSURE_SUCCESS(rv,rv);
          
          length = valueCStr.Length();
          rv = outputStream->Write(valueCStr.get(), length, &writeCount);
          NS_ENSURE_SUCCESS(rv,rv);
          if (length != writeCount)
            return NS_ERROR_FAILURE;
          
          valueCStr.Truncate();

          for (i = 0; i < EXPORT_ATTRIBUTES_TABLE_COUNT; i++) {
            if (EXPORT_ATTRIBUTES_TABLE[i].ldapPropertyName) {
              rv = card->GetCardValue(EXPORT_ATTRIBUTES_TABLE[i].abColName, getter_Copies(value));
              NS_ENSURE_SUCCESS(rv,rv);
 
              if (!PL_strcmp(EXPORT_ATTRIBUTES_TABLE[i].abColName, kPreferMailFormatColumn)) {
                if (value.Equals(NS_LITERAL_STRING("html").get()))
                  value.AssignLiteral("true");
                else if (value.Equals(NS_LITERAL_STRING("plaintext").get()))
                  value.AssignLiteral("false");
                else
                  value.Truncate(); // unknown.
              }

              if (!value.IsEmpty()) {
                rv = AppendProperty(EXPORT_ATTRIBUTES_TABLE[i].ldapPropertyName, value.get(), valueCStr);
                NS_ENSURE_SUCCESS(rv,rv);
                
                valueCStr += LDIF_LINEBREAK;
              }
              else
                valueCStr.Truncate();
              
              length = valueCStr.Length();
              if (length) {
                rv = outputStream->Write(valueCStr.get(), length, &writeCount);
                NS_ENSURE_SUCCESS(rv,rv);
                if (length != writeCount)
                  return NS_ERROR_FAILURE;
              }
              valueCStr.Truncate();
            }
            else {
              // something we don't support yet
              // ldif doesn't export mutliple addresses
            }
          }
        
          // write out the linebreak that separates the cards
          rv = outputStream->Write(LDIF_LINEBREAK, LDIF_LINEBREAK_LEN, &writeCount);
          NS_ENSURE_SUCCESS(rv,rv);
          if (LDIF_LINEBREAK_LEN != writeCount)
            return NS_ERROR_FAILURE;
        }
      }
    }
  }

  rv = outputStream->Flush();
  NS_ENSURE_SUCCESS(rv,rv);

  rv = outputStream->Close();
  NS_ENSURE_SUCCESS(rv,rv);
  return NS_OK;
}

Here is the call graph for this function:

nsresult nsAddressBook::GetAbDatabaseFromFile ( char *  pDbFile,
nsIAddrDatabase **  db 
) [protected]

Definition at line 316 of file nsAddressBook.cpp.

{
    nsresult rv = NS_OK;
    nsCOMPtr<nsIAddrDatabase> database;
    if (pDbFile)
    {
        nsCOMPtr<nsILocalFile> dbPath;

        nsCOMPtr<nsIAddrBookSession> abSession = 
                 do_GetService(NS_ADDRBOOKSESSION_CONTRACTID, &rv); 
        if(NS_SUCCEEDED(rv))
        {
          rv = abSession->GetUserProfileDirectory(getter_AddRefs(dbPath));
          NS_ENSURE_SUCCESS(rv, rv);
        }
        
        nsCAutoString file(pDbFile);
        rv = dbPath->AppendNative(file);
        NS_ENSURE_SUCCESS(rv,rv);

        nsCOMPtr<nsIAddrDatabase> addrDBFactory = 
                 do_GetService(NS_ADDRDATABASE_CONTRACTID, &rv);
        if (NS_SUCCEEDED(rv) && addrDBFactory)
            rv = addrDBFactory->Open(dbPath, PR_TRUE, PR_TRUE, getter_AddRefs(database));

        if (NS_SUCCEEDED(rv) && database)
        {
            NS_IF_ADDREF(*db = database);
        }
        else
            rv = NS_ERROR_NULL_POINTER;

    }
    return NS_OK;
}

Here is the call graph for this function:

void nsIContentHandler::handleContent ( in string  aContentType,
in nsIInterfaceRequestor  aWindowContext,
in nsIRequest  aRequest 
) [inherited]

Tells the content handler to take over handling the content.

If this function succeeds, the URI Loader will leave this request alone, ignoring progress notifications. Failure of this method will cause the request to be cancelled, unless the error code is NS_ERROR_WONT_HANDLE_CONTENT (see below).

Parameters:
aWindowContextWindow context, used to get things like the current nsIDOMWindow for this request. May be null.
aContentTypeThe content type of aRequest
aRequestA request whose content type is already known.
Exceptions:
NS_ERROR_WONT_HANDLE_CONTENTIndicates that this handler does not want to handle this content. A different way for handling this content should be tried.

Definition at line 1055 of file nsAddressBook.cpp.

{
  // follow RFC 2849 to determine if something is safe "as is" for LDIF
  if (aStr[0] == PRUnichar(' ') ||
      aStr[0] == PRUnichar(':') ||
      aStr[0] == PRUnichar('<')) 
    return PR_FALSE;

  PRUint32 i;
  PRUint32 len = nsCRT::strlen(aStr);
  for (i=0; i<len; i++) {
    // If string contains CR or LF, it is not safe for LDIF
    // and MUST be base64 encoded
    if ((aStr[i] == PRUnichar('\n')) ||
        (aStr[i] == PRUnichar('\r')) ||
        (!nsCRT::IsAscii(aStr[i])))
      return PR_FALSE;
  }
  return PR_TRUE;
}

Here is the caller graph for this function:

boolean nsIAddressBook::mailListNameExists ( in wstring  name) [inherited]
void nsIAddressBook::migrate4xAb ( in nsIFileSpec  aFileSpec,
in boolean  aMigrating,
in boolean  aStoreLocAsHome 
) [inherited]

Migrates a 4x ldif address book to our format.

Parameters:
aFileSpecThe source file to import
aMigratingIf PR_TRUE then the preferences are not created for the address book. If PR_FALSE, then the preferences will be created for the address book.
aStoreLocAsHomeIf PR_TRUE then the location will be stored as the home address, otherwise it will be stored as the company address.
void nsIAddressBook::modifyAddressBook ( in nsIRDFDataSource  aDS,
in nsIAbDirectory  aParentDir,
in nsIAbDirectory  aDirectory,
in nsIAbDirectoryProperties  aProperties 
) [inherited]
void nsIStreamLoaderObserver::onStreamComplete ( in nsIStreamLoader  loader,
in nsISupports  ctxt,
in nsresult  status,
in unsigned long  resultLength,
[const, array, size_is(resultLength)] in octet  result 
) [inherited]

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