Back to index

lightning-sunbird  0.9+nobinonly
Classes | Defines | Typedefs | Functions
nsAbView.cpp File Reference
#include "nsAbView.h"
#include "nsISupports.h"
#include "nsIRDFService.h"
#include "nsCOMPtr.h"
#include "nsIServiceManager.h"
#include "nsIAbCard.h"
#include "nsILocale.h"
#include "nsILocaleService.h"
#include "prmem.h"
#include "nsCollationCID.h"
#include "nsIAddrBookSession.h"
#include "nsAbBaseCID.h"
#include "nsXPCOM.h"
#include "nsISupportsPrimitives.h"
#include "nsITreeColumns.h"
#include "nsIPrefService.h"
#include "nsIPrefBranch2.h"
#include "nsIStringBundle.h"
#include "nsIPrefLocalizedString.h"
#include "nsIAddrDatabase.h"
#include "rdf.h"

Go to the source code of this file.


struct  SortClosure


#define CARD_NOT_FOUND   -1
#define ALL_ROWS   -1
#define PREF_MAIL_ADDR_BOOK_LASTNAMEFIRST   "mail.addr_book.lastnamefirst"
#define PREF_MAIL_ADDR_BOOK_DISPLAYNAME_AUTOGENERATION   "mail.addr_book.displayName.autoGeneration"
#define PREF_MAIL_ADDR_BOOK_DISPLAYNAME_LASTNAMEFIRST   "mail.addr_book.displayName.lastnamefirst"
#define GENERATED_NAME_COLUMN_ID   "GeneratedName"


typedef struct SortClosure SortClosure


static int PR_CALLBACK inplaceSortCallback (const void *data1, const void *data2, void *privateData)
static void SetSortClosure (const PRUnichar *sortColumn, const PRUnichar *sortDirection, nsAbView *abView, SortClosure *closure)

Class Documentation

struct SortClosure

Definition at line 612 of file nsAbView.cpp.

Collaboration diagram for SortClosure:
Class Members
nsAbView * abView
const PRUnichar * colID
PRInt32 factor

Define Documentation

#define ALL_ROWS   -1

Definition at line 65 of file nsAbView.cpp.

Definition at line 610 of file nsAbView.cpp.

Definition at line 64 of file nsAbView.cpp.

Definition at line 609 of file nsAbView.cpp.

#define GENERATED_NAME_COLUMN_ID   "GeneratedName"

Definition at line 72 of file nsAbView.cpp.

#define PREF_MAIL_ADDR_BOOK_DISPLAYNAME_AUTOGENERATION   "mail.addr_book.displayName.autoGeneration"

Definition at line 68 of file nsAbView.cpp.

#define PREF_MAIL_ADDR_BOOK_DISPLAYNAME_LASTNAMEFIRST   "mail.addr_book.displayName.lastnamefirst"

Definition at line 69 of file nsAbView.cpp.

#define PREF_MAIL_ADDR_BOOK_LASTNAMEFIRST   "mail.addr_book.lastnamefirst"

Definition at line 67 of file nsAbView.cpp.

Typedef Documentation

typedef struct SortClosure SortClosure

Function Documentation

static int PR_CALLBACK inplaceSortCallback ( const void data1,
const void data2,
void privateData 
) [static]

Definition at line 620 of file nsAbView.cpp.

  AbCard *card1 = (AbCard *)data1;
  AbCard *card2 = (AbCard *)data2;
  SortClosure *closure = (SortClosure *) privateData;
  PRInt32 sortValue;
  // if we are sorting the "PrimaryEmail", swap the collation keys, as the secondary is always the 
  // PrimaryEmail.  use the last primary key as the secondary key.
  // "Pr" to distinguish "PrimaryEmail" from "PagerNumber"
  if (closure->colID[0] == PRUnichar('P') && closure->colID[1] == PRUnichar('r')) {
    sortValue = closure->abView->CompareCollationKeys(card1->secondaryCollationKey,card1->secondaryCollationKeyLen,card2->secondaryCollationKey,card2->secondaryCollationKeyLen);
    if (sortValue)
      return sortValue * closure->factor;
      return closure->abView->CompareCollationKeys(card1->primaryCollationKey,card1->primaryCollationKeyLen,card2->primaryCollationKey,card2->primaryCollationKeyLen) * (closure->factor);
  else {
    sortValue = closure->abView->CompareCollationKeys(card1->primaryCollationKey,card1->primaryCollationKeyLen,card2->primaryCollationKey,card2->primaryCollationKeyLen);
    if (sortValue)
      return sortValue * (closure->factor);
      return closure->abView->CompareCollationKeys(card1->secondaryCollationKey,card1->secondaryCollationKeyLen,card2->secondaryCollationKey,card2->secondaryCollationKeyLen) * (closure->factor);

Here is the call graph for this function:

static NS_DEFINE_CID ( kCollationFactoryCID  ,
) [static]
static void SetSortClosure ( const PRUnichar sortColumn,
const PRUnichar sortDirection,
nsAbView abView,
SortClosure closure 
) [static]

Definition at line 649 of file nsAbView.cpp.

  closure->colID = sortColumn;
  if (sortDirection && !nsCRT::strcmp(sortDirection, NS_LITERAL_STRING("descending").get()))
    closure->factor = DESCENDING_SORT_FACTOR;
    closure->factor = ASCENDING_SORT_FACTOR;

  closure->abView = abView;

Here is the caller graph for this function: