Back to index

lightning-sunbird  0.9+nobinonly
Classes | Defines | Typedefs | Functions | Variables
nsAbCardProperty.cpp File Reference
#include "nsAbCardProperty.h"
#include "nsIServiceManager.h"
#include "nsXPIDLString.h"
#include "nsAbBaseCID.h"
#include "nsCOMPtr.h"
#include "nsReadableUtils.h"
#include "nsUnicharUtils.h"
#include "nsIPrefService.h"
#include "nsIPrefBranch.h"
#include "nsIAbDirectory.h"
#include "plbase64.h"
#include "nsIAddrBookSession.h"
#include "nsIStringBundle.h"
#include "nsIRDFResource.h"
#include "nsIRDFService.h"
#include "nsRDFCID.h"
#include "nsEscape.h"
#include "nsVCardObj.h"
#include "mozITXTToHTMLConv.h"

Go to the source code of this file.

Classes

struct  AppendItem

Defines

#define PREF_MAIL_ADDR_BOOK_LASTNAMEFIRST   "mail.addr_book.lastnamefirst"

Typedefs

typedef nsresultAppendCallback )(nsAbCardProperty *aCard, AppendItem *aItem, mozITXTToHTMLConv *aConv, nsString &aResult)

Functions

nsresult AppendLine (nsAbCardProperty *aCard, AppendItem *aItem, mozITXTToHTMLConv *aConv, nsString &aResult)
nsresult AppendLabel (nsAbCardProperty *aCard, AppendItem *aItem, mozITXTToHTMLConv *aConv, nsString &aResult)
nsresult AppendCityStateZip (nsAbCardProperty *aCard, AppendItem *aItem, mozITXTToHTMLConv *aConv, nsString &aResult)
static VObjectmyAddPropValue (VObject *o, const char *propName, const PRUnichar *propValue, PRBool *aCardHasData)

Variables

const char sAddrbookProperties [] = "chrome://messenger/locale/addressbook/addressBook.properties"
static AppendItem NAME_ATTRS_ARRAY []
static AppendItem PHONE_ATTRS_ARRAY []
static AppendItem HOME_ATTRS_ARRAY []
static AppendItem WORK_ATTRS_ARRAY []
static AppendItem CUSTOM_ATTRS_ARRAY []

Class Documentation

struct AppendItem

Definition at line 71 of file nsAbCardProperty.cpp.

Class Members
AppendCallback * mCallback
const char * mColumn
const char * mLabel

Define Documentation

#define PREF_MAIL_ADDR_BOOK_LASTNAMEFIRST   "mail.addr_book.lastnamefirst"

Definition at line 63 of file nsAbCardProperty.cpp.


Typedef Documentation

Definition at line 69 of file nsAbCardProperty.cpp.


Function Documentation

nsresult AppendCityStateZip ( nsAbCardProperty aCard,
AppendItem aItem,
mozITXTToHTMLConv aConv,
nsString aResult 
)

Definition at line 1905 of file nsAbCardProperty.cpp.

{
  nsresult rv;
  AppendItem item;
  const char *stateCol, *zipCol;

  if (strcmp(aItem->mColumn, kHomeCityColumn) == 0) {
    stateCol = kHomeStateColumn;
    zipCol = kHomeZipCodeColumn;
  }
  else {
    stateCol = kWorkStateColumn;
    zipCol = kWorkZipCodeColumn;
  }

  nsAutoString cityResult, stateResult, zipResult;

  rv = AppendLine(aCard, aItem, aConv, cityResult);
  NS_ENSURE_SUCCESS(rv,rv);
  
  item.mColumn = stateCol;
  item.mLabel = "";

  rv = AppendLine(aCard, &item, aConv, stateResult);
  NS_ENSURE_SUCCESS(rv,rv);

  item.mColumn = zipCol;

  rv = AppendLine(aCard, &item, aConv, zipResult);
  NS_ENSURE_SUCCESS(rv,rv);

  nsXPIDLString formattedString;

  nsCOMPtr<nsIStringBundle> bundle;

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

  rv = stringBundleService->CreateBundle(sAddrbookProperties, getter_AddRefs(bundle));
  NS_ENSURE_SUCCESS(rv,rv); 

  if (!cityResult.IsEmpty() && !stateResult.IsEmpty() && !zipResult.IsEmpty()) {
    const PRUnichar *formatStrings[3] = { cityResult.get(), stateResult.get(), zipResult.get() };
    rv = bundle->FormatStringFromName(NS_LITERAL_STRING("cityAndStateAndZip").get(), formatStrings, 3, getter_Copies(formattedString));
    NS_ENSURE_SUCCESS(rv,rv);
  }
  else if (!cityResult.IsEmpty() && !stateResult.IsEmpty() && zipResult.IsEmpty()) {
    const PRUnichar *formatStrings[2] = { cityResult.get(), stateResult.get() };
    rv = bundle->FormatStringFromName(NS_LITERAL_STRING("cityAndStateNoZip").get(), formatStrings, 2, getter_Copies(formattedString));
    NS_ENSURE_SUCCESS(rv,rv);
  }
  else if ((!cityResult.IsEmpty() && stateResult.IsEmpty() && !zipResult.IsEmpty()) ||
          (cityResult.IsEmpty() && !stateResult.IsEmpty() && !zipResult.IsEmpty())) {
    const PRUnichar *formatStrings[2] = { cityResult.IsEmpty() ? stateResult.get() : cityResult.get(), zipResult.get() };
    rv = bundle->FormatStringFromName(NS_LITERAL_STRING("cityOrStateAndZip").get(), formatStrings, 2, getter_Copies(formattedString));
    NS_ENSURE_SUCCESS(rv,rv);
  }
  else {
    if (!cityResult.IsEmpty()) 
      formattedString = cityResult;
    else if (!stateResult.IsEmpty()) 
      formattedString = stateResult;
    else 
      formattedString = zipResult;
  }

  aResult.Append(formattedString);

  return NS_OK;
}

Here is the call graph for this function:

nsresult AppendLabel ( nsAbCardProperty aCard,
AppendItem aItem,
mozITXTToHTMLConv aConv,
nsString aResult 
)

Definition at line 1867 of file nsAbCardProperty.cpp.

{
  nsresult rv;
  
  nsCOMPtr<nsIStringBundle> bundle;

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

  rv = stringBundleService->CreateBundle(sAddrbookProperties, getter_AddRefs(bundle));
  NS_ENSURE_SUCCESS(rv,rv); 
  
  nsXPIDLString label;
  
  nsXPIDLString attrValue;

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

  if (attrValue.IsEmpty())
    return NS_OK;

  rv = bundle->GetStringFromName(NS_ConvertASCIItoUCS2(aItem->mLabel).get(), getter_Copies(label));
  NS_ENSURE_SUCCESS(rv, rv);

  aResult.AppendLiteral("<labelrow><label>");

  aResult.Append(label);
  aResult.AppendLiteral(": </label>");

  rv = AppendLine(aCard, aItem, aConv, aResult);
  NS_ENSURE_SUCCESS(rv,rv);

  aResult.AppendLiteral("</labelrow>");
  
  return NS_OK;
}

Here is the call graph for this function:

nsresult AppendLine ( nsAbCardProperty aCard,
AppendItem aItem,
mozITXTToHTMLConv aConv,
nsString aResult 
)

Definition at line 1838 of file nsAbCardProperty.cpp.

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

  if (attrValue.IsEmpty())
    return NS_OK; 

  nsAutoString attrNameStr;
  attrNameStr.AssignWithConversion(aItem->mColumn);
  
  aResult.Append(PRUnichar('<'));
  aResult.Append(attrNameStr);
  aResult.Append(PRUnichar('>'));
  
  // use ScanTXT to convert < > & to safe values.
  nsXPIDLString safeText;
  rv = aConv->ScanTXT(attrValue, mozITXTToHTMLConv::kEntities, getter_Copies(safeText));
  NS_ENSURE_SUCCESS(rv,rv);
  aResult.Append(safeText);

  aResult.AppendLiteral("</");
  aResult.Append(attrNameStr);
  aResult.Append(PRUnichar('>'));

  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static VObject* myAddPropValue ( VObject o,
const char *  propName,
const PRUnichar propValue,
PRBool aCardHasData 
) [static]

Definition at line 1370 of file nsAbCardProperty.cpp.

{
    if (aCardHasData)
        *aCardHasData = PR_TRUE;
    return addPropValue(o, propName, NS_ConvertUCS2toUTF8(propValue).get());
}

Here is the call graph for this function:


Variable Documentation

Initial value:
 { 
       {kCustom1Column, "propertyCustom1", AppendLabel},   
       {kCustom2Column, "propertyCustom2", AppendLabel},
       {kCustom3Column, "propertyCustom3", AppendLabel},       
       {kCustom4Column, "propertyCustom4", AppendLabel},
       {kNotesColumn, "", AppendLine}
}

Definition at line 116 of file nsAbCardProperty.cpp.

Initial value:
 { 
       {kDisplayNameColumn, "propertyDisplayName", AppendLabel},   
       {kNicknameColumn, "propertyNickname", AppendLabel},
       {kPriEmailColumn, "", AppendLine},       
       {k2ndEmailColumn, "", AppendLine},
  {kAimScreenNameColumn, "propertyScreenName", AppendLabel},
}

Definition at line 81 of file nsAbCardProperty.cpp.

Initial value:
 { 
       {kWorkPhoneColumn, "propertyWork", AppendLabel},   
       {kHomePhoneColumn, "propertyHome", AppendLabel},
       {kFaxColumn, "propertyFax", AppendLabel},       
       {kPagerColumn, "propertyPager", AppendLabel},
       {kCellularColumn, "propertyCellular", AppendLabel}
}

Definition at line 89 of file nsAbCardProperty.cpp.

const char sAddrbookProperties[] = "chrome://messenger/locale/addressbook/addressBook.properties"

Definition at line 65 of file nsAbCardProperty.cpp.