Back to index

lightning-sunbird  0.9+nobinonly
Classes | Defines | Enumerations | Functions | Variables
nsAbWinHelper.cpp File Reference
#include "nsAbWinHelper.h"
#include "nsMapiAddressBook.h"
#include "nsWabAddressBook.h"
#include "nsCRT.h"
#include <mapiguid.h>
#include "prlog.h"

Go to the source code of this file.

Classes

struct  nsMapiInterfaceWrapper< tInterface >

Defines

#define INITGUID
#define USES_IID_IMAPIProp
#define USES_IID_IMAPIContainer
#define USES_IID_IABContainer
#define USES_IID_IMAPITable
#define USES_IID_IDistList
#define PRINTF(args)   PR_LOG(gAbWinHelperLog, PR_LOG_DEBUG, args)

Enumerations

enum  { ContentsColumnEntryId = 0, ContentsColumnObjectType, ContentsColumnsSize }

Functions

static void assignEntryID (LPENTRYID &aTarget, LPENTRYID aSource, ULONG aByteCount)
static char UnsignedToChar (unsigned char aUnsigned)
static void UnsignedToBase64 (unsigned char *&aUnsigned, ULONG aNbUnsigned, nsCString &aString)
static unsigned char CharToUnsigned (char aChar)
static unsigned char Base64To6Bits (char aBase64)
static void Base64ToUnsigned (const char *&aBase64, PRUint32 aNbBase64, unsigned char *&aUnsigned)
static const SizedSPropTagArray (ContentsColumnsSize, ContentsColumns)
nsAbWinType getAbWinType (const char *aScheme, const char *aUri, nsCString &aStub, nsCString &aEntry)
void buildAbWinUri (const char *aScheme, PRUint32 aType, nsCString &aUri)

Variables

static char kBase64Encoding [] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-."
static const int kARank = 0
static const int kaRank = 26
static const int k0Rank = 52
static const unsigned char kMinusRank = 62
static const unsigned char kDotRank = 63
const char * kOutlookDirectoryScheme = "moz-aboutlookdirectory://"
const int kOutlookDirSchemeLength = 21
const char * kOutlookStub = "op/"
const int kOutlookStubLength = 3
const char * kOutlookExpStub = "oe/"
const int kOutlookExpStubLength = 3
const char * kOutlookCardScheme = "moz-aboutlookcard://"
const int kOutlookCardSchemeLength = 16

Define Documentation

Definition at line 39 of file nsAbWinHelper.cpp.

#define PRINTF (   args)    PR_LOG(gAbWinHelperLog, PR_LOG_DEBUG, args)

Definition at line 60 of file nsAbWinHelper.cpp.

Definition at line 42 of file nsAbWinHelper.cpp.

Definition at line 44 of file nsAbWinHelper.cpp.

Definition at line 41 of file nsAbWinHelper.cpp.

Definition at line 40 of file nsAbWinHelper.cpp.

Definition at line 43 of file nsAbWinHelper.cpp.


Enumeration Type Documentation

anonymous enum
Enumerator:
ContentsColumnEntryId 
ContentsColumnObjectType 
ContentsColumnsSize 

Definition at line 828 of file nsAbWinHelper.cpp.


Function Documentation

static void assignEntryID ( LPENTRYID &  aTarget,
LPENTRYID  aSource,
ULONG  aByteCount 
) [static]

Definition at line 76 of file nsAbWinHelper.cpp.

{
    if (aTarget != NULL) {
        delete [] (NS_REINTERPRET_CAST (LPBYTE, aTarget)) ;
        aTarget = NULL ;
    }
    if (aSource != NULL) {
        aTarget = NS_REINTERPRET_CAST(LPENTRYID, new BYTE [aByteCount]) ;
        memcpy(aTarget, aSource, aByteCount) ;
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

static unsigned char Base64To6Bits ( char  aBase64) [static]

Definition at line 164 of file nsAbWinHelper.cpp.

{
    if (aBase64 >= 'A' && aBase64 <= 'Z') { 
        return NS_STATIC_CAST(unsigned char, aBase64 - 'A' + kARank) ; 
    }
    if (aBase64 >= 'a' && aBase64 <= 'z') { 
        return NS_STATIC_CAST(unsigned char, aBase64 - 'a' + kaRank) ; 
    }
    if (aBase64 >= '0' && aBase64 <= '9') {
        return NS_STATIC_CAST(unsigned char, aBase64 - '0' + k0Rank) ;
    }
    if (aBase64 == '-') { return kMinusRank ; }
    if (aBase64 == '.') { return kDotRank ; }
    return 0 ;
}

Here is the caller graph for this function:

static void Base64ToUnsigned ( const char *&  aBase64,
PRUint32  aNbBase64,
unsigned char *&  aUnsigned 
) [static]

Definition at line 180 of file nsAbWinHelper.cpp.

{
    // By design of the encoding, we must have at least two characters to use
    if (aNbBase64 > 1) {
        unsigned char first6Bits = Base64To6Bits(*aBase64 ++) ;
        unsigned char second6Bits = Base64To6Bits(*aBase64 ++) ;

        *aUnsigned = first6Bits << 2 ;
        *aUnsigned |= second6Bits >> 4 ;
        ++ aUnsigned ;
        if (aNbBase64 > 2) {
            unsigned char third6Bits = Base64To6Bits(*aBase64 ++) ;

            *aUnsigned = second6Bits << 4 ;
            *aUnsigned |= third6Bits >> 2 ;
            ++ aUnsigned ;
            if (aNbBase64 > 3) {
                unsigned char fourth6Bits = Base64To6Bits(*aBase64 ++) ;

                *aUnsigned = third6Bits << 6 ;
                *aUnsigned |= fourth6Bits ;
                ++ aUnsigned ;
            }
        }
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void buildAbWinUri ( const char *  aScheme,
PRUint32  aType,
nsCString aUri 
)

Definition at line 1033 of file nsAbWinHelper.cpp.

{
    aUri.Assign(aScheme) ;
    switch(aType) {
    case nsAbWinType_Outlook: aUri.Append(kOutlookStub) ; break ; 
    case nsAbWinType_OutlookExp: aUri.Append(kOutlookExpStub) ; break ;
    default: aUri.Assign("") ;
    }
}

Here is the caller graph for this function:

static unsigned char CharToUnsigned ( char  aChar) [static]

Definition at line 156 of file nsAbWinHelper.cpp.

{
    if (aChar >= '0' && aChar <= '9') { return NS_STATIC_CAST(unsigned char, aChar) - '0' ; }
    return NS_STATIC_CAST(unsigned char, aChar) - 'A' + 0xA ;
}
nsAbWinType getAbWinType ( const char *  aScheme,
const char *  aUri,
nsCString aStub,
nsCString aEntry 
)

Definition at line 1012 of file nsAbWinHelper.cpp.

{
    aStub.Truncate() ;
    aEntry.Truncate() ;
    PRUint32 schemeLength = strlen(aScheme) ;

    if (nsCRT::strncmp(aUri, aScheme, schemeLength) == 0) {
        if (nsCRT::strncmp(aUri + schemeLength, kOutlookStub, kOutlookStubLength) == 0) {
            aEntry = aUri + schemeLength + kOutlookStubLength ;
            aStub = kOutlookStub ;
            return nsAbWinType_Outlook ;
        }
        if (nsCRT::strncmp(aUri + schemeLength, kOutlookExpStub, kOutlookExpStubLength) == 0) {
            aEntry = aUri + schemeLength + kOutlookExpStubLength ;
            aStub = kOutlookExpStub ;
            return nsAbWinType_OutlookExp ;
        }
    }
    return nsAbWinType_Unknown ;   
}

Here is the caller graph for this function:

static const SizedSPropTagArray ( ContentsColumnsSize  ,
ContentsColumns   
) [static]
static void UnsignedToBase64 ( unsigned char *&  aUnsigned,
ULONG  aNbUnsigned,
nsCString aString 
) [static]

Definition at line 128 of file nsAbWinHelper.cpp.

{
    if (aNbUnsigned > 0) {
        unsigned char remain0 = (*aUnsigned & 0x03) << 4 ;

        aString.Append(kBase64Encoding [(*aUnsigned >> 2) & 0x3F]) ;
        ++ aUnsigned ;
        if (aNbUnsigned > 1) {
            unsigned char remain1 = (*aUnsigned & 0x0F) << 2 ;

            aString.Append(kBase64Encoding [remain0 | ((*aUnsigned >> 4) & 0x0F)]) ;
            ++ aUnsigned ;
            if (aNbUnsigned > 2) {
                aString.Append(kBase64Encoding [remain1 | ((*aUnsigned >> 6) & 0x03)]) ;
                aString.Append(kBase64Encoding [*aUnsigned & 0x3F]) ;
                ++ aUnsigned ;
            }
            else {
                aString.Append(kBase64Encoding [remain1]) ;
            }
        }
        else {
            aString.Append(kBase64Encoding [remain0]) ;
        }
    }
}

Here is the caller graph for this function:

static char UnsignedToChar ( unsigned char  aUnsigned) [static]

Definition at line 115 of file nsAbWinHelper.cpp.

{
    if (aUnsigned < 0xA) { return '0' + aUnsigned ; }
    return 'A' + aUnsigned - 0xA ;
}

Variable Documentation

const int k0Rank = 52 [static]

Definition at line 124 of file nsAbWinHelper.cpp.

const int kARank = 0 [static]

Definition at line 122 of file nsAbWinHelper.cpp.

const int kaRank = 26 [static]

Definition at line 123 of file nsAbWinHelper.cpp.

char kBase64Encoding[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-." [static]

Definition at line 121 of file nsAbWinHelper.cpp.

const unsigned char kDotRank = 63 [static]

Definition at line 126 of file nsAbWinHelper.cpp.

const unsigned char kMinusRank = 62 [static]

Definition at line 125 of file nsAbWinHelper.cpp.

const char* kOutlookCardScheme = "moz-aboutlookcard://"

Definition at line 1009 of file nsAbWinHelper.cpp.

Definition at line 1010 of file nsAbWinHelper.cpp.

const char* kOutlookDirectoryScheme = "moz-aboutlookdirectory://"

Definition at line 1003 of file nsAbWinHelper.cpp.

Definition at line 1004 of file nsAbWinHelper.cpp.

const char* kOutlookExpStub = "oe/"

Definition at line 1007 of file nsAbWinHelper.cpp.

Definition at line 1008 of file nsAbWinHelper.cpp.

const char* kOutlookStub = "op/"

Definition at line 1005 of file nsAbWinHelper.cpp.

Definition at line 1006 of file nsAbWinHelper.cpp.