Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Static Protected Member Functions | Static Private Attributes
CMapiApi Class Reference

#include <MapiApi.h>

List of all members.

Public Member Functions

 CMapiApi ()
 ~CMapiApi ()
BOOL Initialize (void)
BOOL LogOn (void)
void AddMessageStore (CMsgStore *pStore)
void SetCurrentMsgStore (LPMDB lpMdb)
BOOL OpenEntry (ULONG cbEntry, LPENTRYID pEntryId, LPUNKNOWN *ppOpen)
BOOL GetStoreFolders (ULONG cbEid, LPENTRYID lpEid, CMapiFolderList &folders, int startDepth)
BOOL GetStoreAddressFolders (ULONG cbEid, LPENTRYID lpEid, CMapiFolderList &folders)
BOOL OpenStore (ULONG cbEid, LPENTRYID lpEid, LPMDB *ppMdb)
BOOL IterateStores (CMapiFolderList &list)
BOOL IterateContents (CMapiContentIter *pIter, LPMAPIFOLDER pFolder, ULONG flags=0)
BOOL IterateHierarchy (CMapiHierarchyIter *pIter, LPMAPIFOLDER pFolder, ULONG flags=0)

Static Public Member Functions

static BOOL LoadMapi (void)
static BOOL LoadMapiEntryPoints (void)
static void UnloadMapi (void)
static void MAPIUninitialize (void)
static HRESULT MAPIInitialize (LPVOID lpInit)
static SCODE MAPIAllocateBuffer (ULONG cbSize, LPVOID FAR *lppBuffer)
static ULONG MAPIFreeBuffer (LPVOID lpBuff)
static HRESULT MAPILogonEx (ULONG ulUIParam, LPTSTR lpszProfileName, LPTSTR lpszPassword, FLAGS flFlags, LPMAPISESSION FAR *lppSession)
static HRESULT OpenStreamOnFile (LPALLOCATEBUFFER lpAllocateBuffer, LPFREEBUFFER lpFreeBuffer, ULONG ulFlags, LPTSTR lpszFileName, LPTSTR lpszPrefix, LPSTREAM FAR *lppStream)
static void FreeProws (LPSRowSet prows)
static BOOL OpenMdbEntry (LPMDB lpMdb, ULONG cbEntry, LPENTRYID pEntryId, LPUNKNOWN *ppOpen)
static LPSPropValue GetMapiProperty (LPMAPIPROP pProp, ULONG tag)
static BOOL GetEntryIdFromProp (LPSPropValue pVal, ULONG &cbEntryId, LPENTRYID &lpEntryId, BOOL delVal=TRUE)
static BOOL GetStringFromProp (LPSPropValue pVal, nsCString &val, BOOL delVal=TRUE)
static BOOL GetStringFromProp (LPSPropValue pVal, nsString &val, BOOL delVal=TRUE)
static LONG GetLongFromProp (LPSPropValue pVal, BOOL delVal=TRUE)
static BOOL GetLargeStringProperty (LPMAPIPROP pProp, ULONG tag, nsCString &val)
static BOOL GetLargeStringProperty (LPMAPIPROP pProp, ULONG tag, nsString &val)
static BOOL IsLargeProperty (LPSPropValue pVal)
static ULONG GetEmailPropertyTag (LPMAPIPROP lpProp, LONG nameID)
static void ListProperties (LPMAPIPROP lpProp, BOOL getValues=TRUE)
static void ListPropertyValue (LPSPropValue pVal, nsCString &s)

Static Public Attributes

static HINSTANCE m_hMapi32 = NULL

Protected Member Functions

BOOL HandleHierarchyItem (ULONG oType, ULONG cb, LPENTRYID pEntry)
BOOL HandleContentsItem (ULONG oType, ULONG cb, LPENTRYID pEntry)
void GetStoreInfo (CMapiFolder *pFolder, long *pSzContents)
CMsgStoreFindMessageStore (ULONG cbEid, LPENTRYID lpEid)
void ClearMessageStores (void)

Static Protected Member Functions

static void CStrToUnicode (const char *pStr, nsString &result)
static void GetPropTagName (ULONG tag, nsCString &s)
static void ReportStringProp (const char *pTag, LPSPropValue pVal)
static void ReportUIDProp (const char *pTag, LPSPropValue pVal)
static void ReportLongProp (const char *pTag, LPSPropValue pVal)

Static Private Attributes

static int m_clients = 0
static BOOL m_initialized = PR_FALSE
static nsVoidArraym_pStores = NULL
static LPMAPISESSION m_lpSession = NULL
static LPMDB m_lpMdb = NULL
static HRESULT m_lastError
static PRUnicharm_pUniBuff = NULL
static int m_uniBuffLen = 0

Detailed Description

Definition at line 71 of file MapiApi.h.


Constructor & Destructor Documentation

Definition at line 172 of file MapiApi.cpp.

Here is the call graph for this function:

Definition at line 180 of file MapiApi.cpp.

{
       m_clients--;
       if (!m_clients) {
              HRESULT       hr;
              
              ClearMessageStores();
              delete m_pStores;
              m_pStores = NULL;

              m_lpMdb = NULL;

              if (m_lpSession) {
                     hr = m_lpSession->Logoff( NULL, 0, 0);
                     if (FAILED(hr)) {
                            MAPI_TRACE2( "Logoff failed: 0x%lx, %d\n", (long)hr, (int)hr);
                     }
                     m_lpSession->Release();
                     m_lpSession = NULL;
              }

              if (m_initialized) {
                     MAPIUninitialize();
                     m_initialized = FALSE;
              }

              UnloadMapi();
              
              if (m_pUniBuff)
                     delete [] m_pUniBuff;
              m_pUniBuff = NULL;
              m_uniBuffLen = 0;
       }
}

Here is the call graph for this function:


Member Function Documentation

Definition at line 1048 of file MapiApi.cpp.

{
       if (m_pStores)
              m_pStores->AppendElement( pStore);
}

Here is the caller graph for this function:

Definition at line 1036 of file MapiApi.cpp.

{
       if (m_pStores) {
              CMsgStore *   pStore;
              for (int i = 0; i < m_pStores->Count(); i++) {
                     pStore = (CMsgStore *) m_pStores->ElementAt( i);
                     delete pStore;
              }
              m_pStores->Clear();
       }
}

Here is the caller graph for this function:

void CMapiApi::CStrToUnicode ( const char *  pStr,
nsString result 
) [static, protected]

Definition at line 215 of file MapiApi.cpp.

{
       result.Truncate( 0);
       int wLen = MultiByteToWideChar( CP_ACP, 0, pStr, -1, m_pUniBuff, 0);
       if (wLen >= m_uniBuffLen) {
              if (m_pUniBuff)
                     delete [] m_pUniBuff;
              m_pUniBuff = new PRUnichar[wLen + 64];
              m_uniBuffLen = wLen + 64;
       }
       if (wLen) {
              MultiByteToWideChar( CP_ACP, 0, pStr, -1, m_pUniBuff, m_uniBuffLen);
              result = m_pUniBuff;
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

CMsgStore * CMapiApi::FindMessageStore ( ULONG  cbEid,
LPENTRYID  lpEid 
) [protected]

Definition at line 1054 of file MapiApi.cpp.

{
       if (!m_lpSession) {
              MAPI_TRACE0( "FindMessageStore called before session is open\n");
              m_lastError = -1;
              return( NULL);
       }

       ULONG         result;
       HRESULT              hr;
       CMsgStore *   pStore;
       for (int i = 0; i < m_pStores->Count(); i++) {
              pStore = (CMsgStore *) m_pStores->ElementAt( i);
              hr = m_lpSession->CompareEntryIDs( cbEid, lpEid, pStore->GetCBEntryID(), pStore->GetLPEntryID(),
                                                                             0, &result);
              if (HR_FAILED( hr)) {
                     MAPI_TRACE2( "CompareEntryIDs failed: 0x%lx, %d\n", (long)hr, (int)hr);
                     m_lastError = hr;
                     return( NULL);
              }
              if ( result) {
                     return( pStore);
              }
       }
       
       pStore = new CMsgStore( cbEid, lpEid);
       AddMessageStore( pStore);
       return( pStore);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void CMapiApi::FreeProws ( LPSRowSet  prows) [static]

Definition at line 132 of file MapiApi.cpp.

{
       ULONG         irow;
       if (!prows)
              return;
       for (irow = 0; irow < prows->cRows; ++irow)
              MAPIFreeBuffer( prows->aRow[irow].lpProps);
       MAPIFreeBuffer( prows);
}

Here is the call graph for this function:

Here is the caller graph for this function:

ULONG CMapiApi::GetEmailPropertyTag ( LPMAPIPROP  lpProp,
LONG  nameID 
) [static]

Definition at line 669 of file MapiApi.cpp.

{
static GUID emailGUID = {
   0x00062004, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46
};

  MAPINAMEID mapiNameID;
  mapiNameID.lpguid = &emailGUID;
  mapiNameID.ulKind = MNID_ID;
  mapiNameID.Kind.lID = nameID;

  LPMAPINAMEID lpMapiNames = &mapiNameID;
  LPSPropTagArray lpMailTagArray = nsnull;

  HRESULT result = lpProp->GetIDsFromNames(1L, &lpMapiNames, 0, &lpMailTagArray);
  if (result == S_OK)
  {
    ULONG lTag = lpMailTagArray->aulPropTag[0];
    MAPIFreeBuffer(lpMailTagArray);
    return lTag;
  }
  else
    return 0L;
}

Here is the call graph for this function:

Here is the caller graph for this function:

BOOL CMapiApi::GetEntryIdFromProp ( LPSPropValue  pVal,
ULONG cbEntryId,
LPENTRYID &  lpEntryId,
BOOL  delVal = TRUE 
) [static]

Definition at line 1175 of file MapiApi.cpp.

{
       if (!pVal)
              return( FALSE);
       
       BOOL bResult = TRUE;
    switch( PROP_TYPE( pVal->ulPropTag)) {
              case PT_BINARY:
                     cbEntryId = pVal->Value.bin.cb;
                     MAPIAllocateBuffer( cbEntryId, (LPVOID *) &lpEntryId);
                     memcpy( lpEntryId, pVal->Value.bin.lpb, cbEntryId);
              break;

              default:
                     MAPI_TRACE0( "EntryId not in BINARY prop value\n");
                     bResult = FALSE;
        break;
    }

       if (pVal && delVal)
              MAPIFreeBuffer( pVal);

       return( bResult);
}

Here is the call graph for this function:

Here is the caller graph for this function:

BOOL CMapiApi::GetLargeStringProperty ( LPMAPIPROP  pProp,
ULONG  tag,
nsCString val 
) [static]

Definition at line 1126 of file MapiApi.cpp.

{
       LPSTREAM      lpStream;
       HRESULT              hr = pProp->OpenProperty( tag, &IID_IStream, 0, 0, (LPUNKNOWN *)&lpStream);
       if (HR_FAILED( hr))
              return( FALSE);
       STATSTG              st;
       BOOL bResult = TRUE;
       hr = lpStream->Stat( &st, STATFLAG_NONAME);
       if (HR_FAILED( hr))
              bResult = FALSE;
       else {
              if (!st.cbSize.QuadPart)
                     st.cbSize.QuadPart = 1;
              char *pVal = new char[ (int) st.cbSize.QuadPart + 1];
              // val.SetCapacity( (int) st.cbSize.QuadPart);
              if (pVal) {
                     ULONG  sz;
                     hr = lpStream->Read( pVal, (ULONG) st.cbSize.QuadPart, &sz);
                     if (HR_FAILED( hr)) {
                            bResult = FALSE;
                            *pVal = 0;
                            sz = 0;
                     }
                     else
                            pVal[(int) st.cbSize.QuadPart] = 0;
                     val = pVal;
                     delete [] pVal;
              }
              else
                     bResult = FALSE;
       }
       
       lpStream->Release();

       return( bResult);
}

Here is the call graph for this function:

Here is the caller graph for this function:

BOOL CMapiApi::GetLargeStringProperty ( LPMAPIPROP  pProp,
ULONG  tag,
nsString val 
) [static]

Definition at line 1164 of file MapiApi.cpp.

{
       nsCString     result;
       if (GetLargeStringProperty( pProp, tag, result)) {
              CStrToUnicode( result.get(), val);
              return( TRUE);
       }

       return( FALSE);
}

Here is the call graph for this function:

LONG CMapiApi::GetLongFromProp ( LPSPropValue  pVal,
BOOL  delVal = TRUE 
) [static]

Definition at line 1265 of file MapiApi.cpp.

{
       LONG val = 0;
       if ( pVal && (PROP_TYPE( pVal->ulPropTag) == PT_LONG)) {
              val = pVal->Value.l;
       }
       else if (pVal && (PROP_TYPE( pVal->ulPropTag) == PT_NULL)) {
              val = 0;
       }
       else if (pVal && (PROP_TYPE( pVal->ulPropTag) == PT_ERROR)) {
              val = 0;
              MAPI_TRACE0( "GetLongFromProp: Error retrieving property\n");
       }
       else {
              MAPI_TRACE0( "GetLongFromProp: invalid value, expecting long\n");
       }
       if (pVal && delVal)
              MAPIFreeBuffer( pVal);

       return( val);
}

Here is the call graph for this function:

Here is the caller graph for this function:

LPSPropValue CMapiApi::GetMapiProperty ( LPMAPIPROP  pProp,
ULONG  tag 
) [static]

Definition at line 1088 of file MapiApi.cpp.

{
       if (!pProp)
              return( NULL);

       int    sz = CbNewSPropTagArray( 1);
       SPropTagArray *pTag = (SPropTagArray *) new char[sz];
       pTag->cValues = 1;
       pTag->aulPropTag[0] = tag;
       LPSPropValue  lpProp = NULL;
       ULONG  cValues = 0;
       HRESULT hr = pProp->GetProps( pTag, 0, &cValues, &lpProp);
       delete [] pTag;
       if (HR_FAILED( hr) || (cValues != 1)) {
              if (lpProp)
                     MAPIFreeBuffer( lpProp);
              return( NULL);
       }
       else {
              if (PROP_TYPE( lpProp->ulPropTag) == PT_ERROR) {
                     if (lpProp->Value.l == MAPI_E_NOT_FOUND) {
                            MAPIFreeBuffer( lpProp);
                            lpProp = NULL;
                     }
              }
       }

       return( lpProp);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void CMapiApi::GetPropTagName ( ULONG  tag,
nsCString s 
) [static, protected]

Definition at line 1362 of file MapiApi.cpp.

{
       char numStr[256];
       PR_snprintf( numStr, 256, "0x%lx, %ld", tag, tag);
       s = numStr;
       switch( tag) {
#include "mapitagstrs.cpp"
       }
       s += ", data: ";
       switch( PROP_TYPE( tag)) {
              case PT_UNSPECIFIED: s += "PT_UNSPECIFIED"; break;
              case PT_NULL: s += "PT_NULL"; break;
              case PT_I2: s += "PT_I2"; break;
              case PT_LONG: s += "PT_LONG"; break;
              case PT_R4: s += "PT_R4"; break;
              case PT_DOUBLE: s += "PT_DOUBLE"; break;
              case PT_CURRENCY: s += "PT_CURRENCY"; break;
              case PT_APPTIME: s += "PT_APPTIME"; break;
              case PT_ERROR: s += "PT_ERROR"; break;
              case PT_BOOLEAN: s += "PT_BOOLEAN"; break;
              case PT_OBJECT: s += "PT_OBJECT"; break;
              case PT_I8: s += "PT_I8"; break;
              case PT_STRING8: s += "PT_STRING8"; break;
              case PT_UNICODE: s += "PT_UNICODE"; break;
              case PT_SYSTIME: s += "PT_SYSTIME"; break;
              case PT_CLSID: s += "PT_CLSID"; break;
              case PT_BINARY: s += "PT_BINARY"; break;
              case PT_MV_I2: s += "PT_MV_I2"; break;
              case PT_MV_LONG: s += "PT_MV_LONG"; break;
              case PT_MV_R4: s += "PT_MV_R4"; break;
              case PT_MV_DOUBLE: s += "PT_MV_DOUBLE"; break;
              case PT_MV_CURRENCY: s += "PT_MV_CURRENCY"; break;
              case PT_MV_APPTIME: s += "PT_MV_APPTIME"; break;
              case PT_MV_SYSTIME: s += "PT_MV_SYSTIME"; break;
              case PT_MV_STRING8: s += "PT_MV_STRING8"; break;
              case PT_MV_BINARY: s += "PT_MV_BINARY"; break;
              case PT_MV_UNICODE: s += "PT_MV_UNICODE"; break;
              case PT_MV_CLSID: s += "PT_MV_CLSID"; break;
              case PT_MV_I8: s += "PT_MV_I8"; break;
              default:
                     s += "Unknown";
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

BOOL CMapiApi::GetStoreAddressFolders ( ULONG  cbEid,
LPENTRYID  lpEid,
CMapiFolderList folders 
)

Definition at line 428 of file MapiApi.cpp.

{
       // Fill in the array with the folders in the given store
       if (!m_initialized || !m_lpSession) {
              MAPI_TRACE0( "MAPI not initialized for GetStoreAddressFolders\n");
              return( FALSE);
       }
       
       m_lpMdb = NULL;

       CMsgStore *          pStore = FindMessageStore( cbEid, lpEid);
       BOOL                 bResult = FALSE;
       LPSPropValue  pVal;

       if (pStore && pStore->Open( m_lpSession, &m_lpMdb)) {
              // Successful open, do the iteration of the store
              pVal = GetMapiProperty( m_lpMdb, PR_IPM_SUBTREE_ENTRYID);
              if (pVal) {
                     ULONG                cbEntry;
                     LPENTRYID            pEntry;
                     LPMAPIFOLDER  lpSubTree = NULL;

                     if (GetEntryIdFromProp( pVal, cbEntry, pEntry)) {
                            // Open up the folder!
                            bResult = OpenEntry( cbEntry, pEntry, (LPUNKNOWN *)&lpSubTree);
                            MAPIFreeBuffer( pEntry);
                            if (bResult && lpSubTree) {
                                   // Iterate the subtree with the results going into the folder list
                                   CGetStoreFoldersIter iterHandler( this, folders, 1, FALSE);
                                   bResult = IterateHierarchy( &iterHandler, lpSubTree);
                                   lpSubTree->Release();
                            }
                            else {
                                   MAPI_TRACE0( "GetStoreAddressFolders: Error opening sub tree.\n");
                            }
                     }
                     else {
                            MAPI_TRACE0( "GetStoreAddressFolders: Error getting entryID from sub tree property val.\n");
                     }
              }
              else {
                     MAPI_TRACE0( "GetStoreAddressFolders: Error getting sub tree property.\n");
              }
       }
       else {
              MAPI_TRACE0( "GetStoreAddressFolders: Error opening message store.\n");
       }

       return( bResult);
}

Here is the call graph for this function:

Here is the caller graph for this function:

BOOL CMapiApi::GetStoreFolders ( ULONG  cbEid,
LPENTRYID  lpEid,
CMapiFolderList folders,
int  startDepth 
)

Definition at line 377 of file MapiApi.cpp.

{
       // Fill in the array with the folders in the given store
       if (!m_initialized || !m_lpSession) {
              MAPI_TRACE0( "MAPI not initialized for GetStoreFolders\n");
              return( FALSE);
       }
       
       m_lpMdb = NULL;

       CMsgStore *          pStore = FindMessageStore( cbEid, lpEid);
       BOOL                 bResult = FALSE;
       LPSPropValue  pVal;

       if (pStore && pStore->Open( m_lpSession, &m_lpMdb)) {
              // Successful open, do the iteration of the store
              pVal = GetMapiProperty( m_lpMdb, PR_IPM_SUBTREE_ENTRYID);
              if (pVal) {
                     ULONG                cbEntry;
                     LPENTRYID            pEntry;
                     LPMAPIFOLDER  lpSubTree = NULL;

                     if (GetEntryIdFromProp( pVal, cbEntry, pEntry)) {
                            // Open up the folder!
                            bResult = OpenEntry( cbEntry, pEntry, (LPUNKNOWN *)&lpSubTree);
                            MAPIFreeBuffer( pEntry);
                            if (bResult && lpSubTree) {
                                   // Iterate the subtree with the results going into the folder list
                                   CGetStoreFoldersIter iterHandler( this, folders, startDepth);
                                   bResult = IterateHierarchy( &iterHandler, lpSubTree);
                                   lpSubTree->Release();
                            }
                            else {
                                   MAPI_TRACE0( "GetStoreFolders: Error opening sub tree.\n");
                            }
                     }
                     else {
                            MAPI_TRACE0( "GetStoreFolders: Error getting entryID from sub tree property val.\n");
                     }
              }
              else {
                     MAPI_TRACE0( "GetStoreFolders: Error getting sub tree property.\n");
              }
       }
       else {
              MAPI_TRACE0( "GetStoreFolders: Error opening message store.\n");
       }

       return( bResult);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void CMapiApi::GetStoreInfo ( CMapiFolder pFolder,
long pSzContents 
) [protected]

Definition at line 954 of file MapiApi.cpp.

{
       HRESULT       hr;
       LPMDB  lpMdb;

       if (pSzContents)
              *pSzContents = 0;

       if (!OpenStore( pFolder->GetCBEntryID(), pFolder->GetEntryID(), &lpMdb))
              return;
       
       LPSPropValue pVal;
       /*
       pVal = GetMapiProperty( lpMdb, PR_DISPLAY_NAME);
       ReportStringProp( "    Message store name:", pVal);
       pVal = GetMapiProperty( lpMdb, PR_MDB_PROVIDER);
       ReportUIDProp( "    Message store provider:", pVal);
       pVal = GetMapiProperty( lpMdb, PR_COMMENT);
       ReportStringProp( "    Message comment:", pVal);
       pVal = GetMapiProperty( lpMdb, PR_ACCESS_LEVEL);
       ReportLongProp( "    Message store Access Level:", pVal);
       pVal = GetMapiProperty( lpMdb, PR_STORE_SUPPORT_MASK);
       ReportLongProp( "    Message store support mask:", pVal);
       pVal = GetMapiProperty( lpMdb, PR_STORE_STATE);
       ReportLongProp( "    Message store state:", pVal);
       pVal = GetMapiProperty( lpMdb, PR_OBJECT_TYPE);
       ReportLongProp( "    Message store object type:", pVal);
       pVal = GetMapiProperty( lpMdb, PR_VALID_FOLDER_MASK);
       ReportLongProp( "    Message store valid folder mask:", pVal);
       
       pVal = GetMapiProperty( lpMdb, 0x8001001e);
       ReportStringProp( "    Message prop 0x8001001e:", pVal);

       // This key appears to be the OMI Account Manager account that corresponds
       // to this message store.  This is important for IMAP accounts
       // since we may not want to import messages from an IMAP store!
       // Seems silly if you ask me!
       // In order to test this, we'll need the registry key to look under to determine
       // if it contains the "IMAP Server" value, if it does then we are an
       // IMAP store, if not, then we are a non-IMAP store - which may always mean
       // a regular store that should be imported.

       pVal = GetMapiProperty( lpMdb, 0x80000003);
       ReportLongProp( "    Message prop 0x80000003:", pVal);

       // ListProperties( lpMdb);
       */

       pVal = GetMapiProperty( lpMdb, PR_IPM_SUBTREE_ENTRYID);
       if (pVal) {
              ULONG                cbEntry;
              LPENTRYID            pEntry;
              LPMAPIFOLDER  lpSubTree = NULL;

              if (GetEntryIdFromProp( pVal, cbEntry, pEntry)) {
                     // Open up the folder!
                     ULONG         ulObjType;
                     hr = lpMdb->OpenEntry( cbEntry, pEntry, NULL, 0, &ulObjType, (LPUNKNOWN *) &lpSubTree);
                     MAPIFreeBuffer( pEntry);
                     if (SUCCEEDED( hr) && lpSubTree) {
                            // Find out if there are any contents in the 
                            // tree.
                            LPMAPITABLE   lpTable;
                            hr = lpSubTree->GetHierarchyTable( 0, &lpTable);
                            if (HR_FAILED(hr)) {
                                   MAPI_TRACE2( "GetStoreInfo: GetHierarchyTable failed: 0x%lx, %d\n", (long)hr, (int)hr);
                            }
                            else {
                                   ULONG rowCount;
                                   hr = lpTable->GetRowCount( 0, &rowCount);
                                   lpTable->Release();
                                   if (SUCCEEDED( hr) && pSzContents)
                                          *pSzContents = (long) rowCount;
                            }

                            lpSubTree->Release();
                     }
              }
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

BOOL CMapiApi::GetStringFromProp ( LPSPropValue  pVal,
nsCString val,
BOOL  delVal = TRUE 
) [static]

Definition at line 1200 of file MapiApi.cpp.

{
       BOOL bResult = TRUE;
       if ( pVal && (PROP_TYPE( pVal->ulPropTag) == PT_STRING8)) {
              val = pVal->Value.lpszA;
       }
       else if ( pVal && (PROP_TYPE( pVal->ulPropTag) == PT_UNICODE)) {
              val.AssignWithConversion((PRUnichar *) pVal->Value.lpszW);
       }
       else if (pVal && (PROP_TYPE( pVal->ulPropTag) == PT_NULL)) {
              val.Truncate();
       }
       else if (pVal && (PROP_TYPE( pVal->ulPropTag) == PT_ERROR)) {
              val.Truncate();
              bResult = FALSE;
       }
       else {
              if (pVal) {
                     MAPI_TRACE1( "GetStringFromProp: invalid value, expecting string - %d\n", (int) PROP_TYPE( pVal->ulPropTag));
              }
              else {
                     MAPI_TRACE0( "GetStringFromProp: invalid value, expecting string, got null pointer\n");
              }
              val.Truncate();
              bResult = FALSE;
       }
       if (pVal && delVal)
              MAPIFreeBuffer( pVal);

       return( bResult);
}

Here is the call graph for this function:

Here is the caller graph for this function:

BOOL CMapiApi::GetStringFromProp ( LPSPropValue  pVal,
nsString val,
BOOL  delVal = TRUE 
) [static]

Definition at line 1232 of file MapiApi.cpp.

{
       BOOL bResult = TRUE;
       if ( pVal && (PROP_TYPE( pVal->ulPropTag) == PT_STRING8)) {
              CStrToUnicode( (const char *)pVal->Value.lpszA, val);
       }
       else if ( pVal && (PROP_TYPE( pVal->ulPropTag) == PT_UNICODE)) {
              val = (PRUnichar *) pVal->Value.lpszW;
       }
       else if (pVal && (PROP_TYPE( pVal->ulPropTag) == PT_NULL)) {
              val.Truncate();
       }
       else if (pVal && (PROP_TYPE( pVal->ulPropTag) == PT_ERROR)) {
              val.Truncate();
              bResult = FALSE;
       }
       else {
              if (pVal) {
                     MAPI_TRACE1( "GetStringFromProp: invalid value, expecting string - %d\n", (int) PROP_TYPE( pVal->ulPropTag));
              }
              else {
                     MAPI_TRACE0( "GetStringFromProp: invalid value, expecting string, got null pointer\n");
              }
              val.Truncate();
              bResult = FALSE;
       }
       if (pVal && delVal)
              MAPIFreeBuffer( pVal);

       return( bResult);
}

Here is the call graph for this function:

BOOL CMapiApi::HandleContentsItem ( ULONG  oType,
ULONG  cb,
LPENTRYID  pEntry 
) [protected]

Definition at line 605 of file MapiApi.cpp.

{
       if (oType == MAPI_MESSAGE) {
              LPMESSAGE pMsg;
              if (OpenEntry( cb, pEntry, (LPUNKNOWN *) &pMsg)) {
                     LPSPropValue pVal;
                     pVal = GetMapiProperty( pMsg, PR_SUBJECT);
                     ReportStringProp( "PR_SUBJECT:", pVal);
                     pVal = GetMapiProperty( pMsg, PR_DISPLAY_BCC);
                     ReportStringProp( "PR_DISPLAY_BCC:", pVal);
                     pVal = GetMapiProperty( pMsg, PR_DISPLAY_CC);
                     ReportStringProp( "PR_DISPLAY_CC:", pVal);
                     pVal = GetMapiProperty( pMsg, PR_DISPLAY_TO);
                     ReportStringProp( "PR_DISPLAY_TO:", pVal);
                     pVal = GetMapiProperty( pMsg, PR_MESSAGE_CLASS);
                     ReportStringProp( "PR_MESSAGE_CLASS:", pVal);
                     ListProperties( pMsg);
                     pMsg->Release();
              }
              else {
                     MAPI_TRACE0( "    Folder type - error opening\n");
              }
       }
       else
              MAPI_TRACE1( "    ObjectType: %ld\n", oType);

       return( TRUE);
}

Here is the call graph for this function:

Here is the caller graph for this function:

BOOL CMapiApi::HandleHierarchyItem ( ULONG  oType,
ULONG  cb,
LPENTRYID  pEntry 
) [protected]

Definition at line 694 of file MapiApi.cpp.

{
       if (oType == MAPI_FOLDER) {
              LPMAPIFOLDER pFolder;
              if (OpenEntry( cb, pEntry, (LPUNKNOWN *) &pFolder)) {
                     LPSPropValue pVal;
                     pVal = GetMapiProperty( pFolder, PR_DISPLAY_NAME);
                     ReportStringProp( "Folder name:", pVal);
                     IterateContents( NULL, pFolder);
                     IterateHierarchy( NULL, pFolder);
                     pFolder->Release();
              }
              else {
                     MAPI_TRACE0( "    Folder type - error opening\n");
              }
       }
       else
              MAPI_TRACE1( "    ObjectType: %ld\n", oType);

       return( TRUE);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 231 of file MapiApi.cpp.

{
       if (m_initialized)
              return( TRUE);

       HRESULT              hr;

       hr = MAPIInitialize( NULL);

       if (FAILED(hr)) {
              MAPI_TRACE2( "MAPI Initialize failed: 0x%lx, %d\n", (long)hr, (int)hr);
              return( FALSE);
       }
       
       m_initialized = TRUE;
       MAPI_TRACE0( "MAPI Initialized\n");

       return( TRUE);
}

Here is the call graph for this function:

Here is the caller graph for this function:

BOOL CMapiApi::IsLargeProperty ( LPSPropValue  pVal) [static]

Definition at line 1118 of file MapiApi.cpp.

{
       if ((PROP_TYPE( pVal->ulPropTag) == PT_ERROR) && (pVal->Value.l == E_OUTOFMEMORY)) {
              return( TRUE);
       }
       return( FALSE);
}

Here is the caller graph for this function:

BOOL CMapiApi::IterateContents ( CMapiContentIter pIter,
LPMAPIFOLDER  pFolder,
ULONG  flags = 0 
)

Definition at line 536 of file MapiApi.cpp.

{
       // flags can be 0 or MAPI_ASSOCIATED
       // MAPI_ASSOCIATED is usually used for forms and views

       HRESULT              hr;
       LPMAPITABLE   lpTable;
       hr = pFolder->GetContentsTable( flags, &lpTable);
       if (FAILED(hr)) {
              MAPI_TRACE2( "GetContentsTable failed: 0x%lx, %d\n", (long)hr, (int)hr);
              return( FALSE);
       }

       ULONG rowCount;
       hr = lpTable->GetRowCount( 0, &rowCount);
       if (!rowCount) {
              MAPI_TRACE0( "  Empty Table\n");
       }

       hr = lpTable->SetColumns( (LPSPropTagArray)&ptaEid, 0);
       if (FAILED(hr)) {
              lpTable->Release();
              MAPI_TRACE2( "SetColumns failed: 0x%lx, %d\n", (long)hr, (int)hr);
              return( FALSE);
       }

       hr = lpTable->SeekRow( BOOKMARK_BEGINNING, 0, NULL);
       if (FAILED(hr)) {
              lpTable->Release();
              MAPI_TRACE2( "SeekRow failed: 0x%lx, %d\n", (long)hr, (int)hr);
              return( FALSE);
       }

       int                  cNumRows = 0;
       LPSRowSet     lpRow;
       BOOL          keepGoing = TRUE;
       BOOL          bResult = TRUE;
       do {
              
              lpRow = NULL;
              hr = lpTable->QueryRows( 1, 0, &lpRow);

        if(HR_FAILED(hr)) {
                     MAPI_TRACE2( "QueryRows failed: 0x%lx, %d\n", (long)hr, (int)hr);
            bResult = FALSE;
                     break;
              }

        if(lpRow) {
            cNumRows = lpRow->cRows;

                  if (cNumRows) {
                LPENTRYID   lpEID = (LPENTRYID) lpRow->aRow[0].lpProps[ieidPR_ENTRYID].Value.bin.lpb;
                ULONG              cbEID = lpRow->aRow[0].lpProps[ieidPR_ENTRYID].Value.bin.cb;
                            ULONG         oType = lpRow->aRow[0].lpProps[ieidPR_OBJECT_TYPE].Value.ul;

                keepGoing = HandleContentsItem( oType, cbEID, lpEID);
                            MAPI_TRACE1( "    ObjectType: %ld\n", oType);
                  }
                     FreeProws( lpRow);          
        }

       } while ( SUCCEEDED(hr) && cNumRows && lpRow && keepGoing);

       lpTable->Release();

       return( bResult);
}

Here is the call graph for this function:

Here is the caller graph for this function:

BOOL CMapiApi::IterateHierarchy ( CMapiHierarchyIter pIter,
LPMAPIFOLDER  pFolder,
ULONG  flags = 0 
)

Definition at line 716 of file MapiApi.cpp.

{
       // flags can be CONVENIENT_DEPTH or 0
       // CONVENIENT_DEPTH will return all depths I believe instead
       // of just children
       HRESULT              hr;
       LPMAPITABLE   lpTable;
       hr = pFolder->GetHierarchyTable( flags, &lpTable);
       if (HR_FAILED(hr)) {
              m_lastError = hr;
              MAPI_TRACE2( "IterateHierarchy: GetContentsTable failed: 0x%lx, %d\n", (long)hr, (int)hr);
              return( FALSE);
       }

       ULONG rowCount;
       hr = lpTable->GetRowCount( 0, &rowCount);
       if (!rowCount) {
              lpTable->Release();
              return( TRUE);
       }

       hr = lpTable->SetColumns( (LPSPropTagArray)&ptaEid, 0);
       if (HR_FAILED(hr)) {
              m_lastError = hr;
              lpTable->Release();
              MAPI_TRACE2( "IterateHierarchy: SetColumns failed: 0x%lx, %d\n", (long)hr, (int)hr);
              return( FALSE);
       }

       hr = lpTable->SeekRow( BOOKMARK_BEGINNING, 0, NULL);
       if (HR_FAILED(hr)) {
              m_lastError = hr;
              lpTable->Release();
              MAPI_TRACE2( "IterateHierarchy: SeekRow failed: 0x%lx, %d\n", (long)hr, (int)hr);
              return( FALSE);
       }

       int                  cNumRows = 0;
       LPSRowSet     lpRow;
       BOOL          keepGoing = TRUE;
       BOOL          bResult = TRUE;
       do {
              
              lpRow = NULL;
              hr = lpTable->QueryRows( 1, 0, &lpRow);

        if(HR_FAILED(hr)) {
                     MAPI_TRACE2( "QueryRows failed: 0x%lx, %d\n", (long)hr, (int)hr);
                     m_lastError = hr;
            bResult = FALSE;
                     break;
              }

        if(lpRow) {
            cNumRows = lpRow->cRows;

                  if (cNumRows) {
                LPENTRYID   lpEntry = (LPENTRYID) lpRow->aRow[0].lpProps[ieidPR_ENTRYID].Value.bin.lpb;
                ULONG              cb = lpRow->aRow[0].lpProps[ieidPR_ENTRYID].Value.bin.cb;
                            ULONG         oType = lpRow->aRow[0].lpProps[ieidPR_OBJECT_TYPE].Value.ul;
                            
                            if (pIter)
                                   keepGoing = pIter->HandleHierarchyItem( oType, cb, lpEntry);
                            else
                                   keepGoing = HandleHierarchyItem( oType, cb, lpEntry);

                  }
                     FreeProws( lpRow);          
        }

       } while ( SUCCEEDED(hr) && cNumRows && lpRow && keepGoing);

       lpTable->Release();
       
       if (bResult && !keepGoing)
              bResult = FALSE;

       return( bResult);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 812 of file MapiApi.cpp.

{
       stores.ClearAll();

       if (!m_lpSession) {
              MAPI_TRACE0( "IterateStores called before session is open\n");
              m_lastError = -1;
              return( FALSE);
       }


       HRESULT              hr;
       
       /* -- Some Microsoft sample code just to see if things are working --- *//*

       ULONG         cbEIDStore;
       LPENTRYID     lpEIDStore;

    hr = HrMAPIFindDefaultMsgStore( m_lpSession, &cbEIDStore, &lpEIDStore);
    if (HR_FAILED(hr)) {
        MAPI_TRACE0( "Default message store not found\n");
              // MessageBox(NULL,"Message Store Not Found",NULL,MB_OK);
    }
       else {
              LPMDB  lpStore;
              MAPI_TRACE0( "Default Message store FOUND\n");
              hr = m_lpSession->OpenMsgStore( NULL, cbEIDStore,
                                  lpEIDStore, NULL,
                                  MDB_NO_MAIL | MDB_NO_DIALOG, &lpStore);
              if (HR_FAILED(hr)) {
                     MAPI_TRACE1( "Unable to open default message store: 0x%lx\n", hr);
              }
              else {
                     MAPI_TRACE0( "Default message store OPENED\n");
                     lpStore->Release();
              }
        }
     */



       LPMAPITABLE   lpTable;

       hr = m_lpSession->GetMsgStoresTable( 0, &lpTable);
       if (FAILED(hr)) {
              MAPI_TRACE0( "GetMsgStoresTable failed\n");
              m_lastError = hr;
              return( FALSE);
       }


       ULONG rowCount;
       hr = lpTable->GetRowCount( 0, &rowCount);
       MAPI_TRACE1( "MsgStores Table rowCount: %ld\n", rowCount);

       hr = lpTable->SetColumns( (LPSPropTagArray)&ptaTbl, 0);
       if (FAILED(hr)) {
              lpTable->Release();
              MAPI_TRACE2( "SetColumns failed: 0x%lx, %d\n", (long)hr, (int)hr);
              m_lastError = hr;
              return( FALSE);
       }

       hr = lpTable->SeekRow( BOOKMARK_BEGINNING, 0, NULL);
       if (FAILED(hr)) {
              lpTable->Release();
              MAPI_TRACE2( "SeekRow failed: 0x%lx, %d\n", (long)hr, (int)hr);
              m_lastError = hr;
              return( FALSE);
       }

       int                  cNumRows = 0;
       LPSRowSet     lpRow;
       BOOL          keepGoing = TRUE;
       BOOL          bResult = TRUE;
       do {
              
              lpRow = NULL;
              hr = lpTable->QueryRows( 1, 0, &lpRow);

        if(HR_FAILED(hr)) {
                     MAPI_TRACE2( "QueryRows failed: 0x%lx, %d\n", (long)hr, (int)hr);
            bResult = FALSE;
                     m_lastError = hr;
                     break;
              }

        if(lpRow) {
            cNumRows = lpRow->cRows;

                  if (cNumRows) {
                            LPCTSTR              lpStr = (LPCTSTR) lpRow->aRow[0].lpProps[itblPR_DISPLAY_NAME].Value.LPSZ;
                LPENTRYID   lpEID = (LPENTRYID) lpRow->aRow[0].lpProps[itblPR_ENTRYID].Value.bin.lpb;
                ULONG              cbEID = lpRow->aRow[0].lpProps[itblPR_ENTRYID].Value.bin.cb;

                            // In the future, GetStoreInfo needs to somehow return
                            // whether or not the store is from an IMAP server.
                            // Currently, GetStoreInfo opens the store and attempts
                            // to get the hierarchy tree.  If the tree is empty or
                            // does not exist, then szContents will be zero.  We'll
                            // assume that any store that doesn't have anything in
                            // it's hierarchy tree is not a store we want to import - 
                            // there would be nothing to import from anyway!
                            // Currently, this does exclude IMAP server accounts
                            // which is the desired behaviour.

                int         strLen = strlen(lpStr);
                PRUnichar * pwszStr = (PRUnichar *) nsMemory::Alloc((strLen + 1) * sizeof(WCHAR));
                if (!pwszStr) {
                    // out of memory
                    FreeProws( lpRow);
                    lpTable->Release();
                    return FALSE;
                }
                ::MultiByteToWideChar(CP_ACP, 0, lpStr, strlen(lpStr) + 1, pwszStr, (strLen + 1) * sizeof(WCHAR));
                            CMapiFolder *pFolder = new CMapiFolder( pwszStr, cbEID, lpEID, 0, MAPI_STORE);
                nsMemory::Free(pwszStr);

                            long szContents = 1;
                            GetStoreInfo( pFolder, &szContents);

                            MAPI_TRACE1( "    DisplayName: %s\n", lpStr);
                            if (szContents) {
                                   stores.AddItem( pFolder);
                            }
                            else {
                                   delete pFolder;
                                   MAPI_TRACE0( "    ^^^^^ Not added to store list\n");
                            }

                            keepGoing = TRUE;
                  }
                     FreeProws( lpRow);          
        }

       } while ( SUCCEEDED(hr) && cNumRows && lpRow && keepGoing);

       lpTable->Release();

       return( bResult);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void CMapiApi::ListProperties ( LPMAPIPROP  lpProp,
BOOL  getValues = TRUE 
) [static]

Definition at line 634 of file MapiApi.cpp.

{
       LPSPropTagArray             pArray;
       HRESULT                            hr = lpProp->GetPropList( 0, &pArray);
       if (FAILED(hr)) {
              MAPI_TRACE0( "    Unable to retrieve property list\n");
              return;
       }
  ULONG count = 0;
  LPMAPINAMEID FAR * lppPropNames;
  SPropTagArray             tagArray;
  LPSPropTagArray lpTagArray = &tagArray;
  tagArray.cValues = (ULONG)1;
       nsCString     desc;
       for (ULONG i = 0; i < pArray->cValues; i++) {
              GetPropTagName( pArray->aulPropTag[i], desc);
              if (getValues) {
      tagArray.aulPropTag[0] = pArray->aulPropTag[i];
      hr = lpProp->GetNamesFromIDs(&lpTagArray, nsnull, 0, &count, &lppPropNames); 
      if (hr == S_OK)
        MAPIFreeBuffer(lppPropNames);

                     LPSPropValue pVal = GetMapiProperty( lpProp, pArray->aulPropTag[i]);
                     if (pVal) {
                            desc += ", ";
                            ListPropertyValue( pVal, desc);
                            MAPIFreeBuffer( pVal);
                     }
              }
              MAPI_TRACE2( "    Tag #%d: %s\n", (int)i, (const char *)desc);
       }

  MAPIFreeBuffer( pArray);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void CMapiApi::ListPropertyValue ( LPSPropValue  pVal,
nsCString s 
) [static]

Definition at line 1428 of file MapiApi.cpp.

{
       nsCString            strVal;
       char                 nBuff[64];
       nsCString            t;

       s += "value: ";
       switch (PROP_TYPE( pVal->ulPropTag)) {
              case PT_STRING8:
                     GetStringFromProp( pVal, strVal, FALSE);
                     if (strVal.Length() > 60) {
                            strVal.Left( t, 60);
                            strVal = t;
                            strVal += "...";
                     }
                     ReplaceEolChars( strVal);
                     s += strVal;
              break;
              case PT_LONG:
                     s.AppendInt( (PRInt32) pVal->Value.l);
                     s += ", 0x";
                     s.AppendInt( (PRInt32) pVal->Value.l, 16);
                     s += nBuff;
              break;
              case PT_BOOLEAN:
                     if (pVal->Value.b)
                            s += "True";
                     else
                            s += "False";
              break;
              case PT_NULL:
                     s += "--NULL--";
              break;
              case PT_SYSTIME: {
                     /*
                     COleDateTime  tm( pVal->Value.ft);
                     s += tm.Format();
                     */
                     s += "-- Figure out how to format time in mozilla, PT_SYSTIME --";
              }
              break;
              default:
               s += "?";
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

BOOL CMapiApi::LoadMapi ( void  ) [static]

Definition at line 145 of file MapiApi.cpp.

{
       if (m_hMapi32)
              return( TRUE);
       
       HINSTANCE     hInst = ::LoadLibrary( "MAPI32.DLL");
       if (!hInst)
              return( FALSE);
       FARPROC pProc = GetProcAddress( hInst, "MAPIGetNetscapeVersion");
       if (pProc) {
              ::FreeLibrary( hInst);
              hInst = ::LoadLibrary( "MAPI32BAK.DLL");
              if (!hInst)
                     return( FALSE);
       }

       m_hMapi32 = hInst;
       return( LoadMapiEntryPoints());
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 73 of file MapiApi.cpp.

{
       if (!(gpMapiUninitialize = (LPMAPIUNINITIALIZE) GetProcAddress( m_hMapi32, "MAPIUninitialize")))
              return( FALSE);
       if (!(gpMapiInitialize = (LPMAPIINITIALIZE) GetProcAddress( m_hMapi32, "MAPIInitialize")))
              return( FALSE);
       if (!(gpMapiAllocateBuffer = (LPMAPIALLOCATEBUFFER) GetProcAddress( m_hMapi32, "MAPIAllocateBuffer")))
              return( FALSE);
       if (!(gpMapiFreeBuffer = (LPMAPIFREEBUFFER) GetProcAddress( m_hMapi32, "MAPIFreeBuffer")))
              return( FALSE);
       if (!(gpMapiLogonEx = (LPMAPILOGONEX) GetProcAddress( m_hMapi32, "MAPILogonEx")))
              return( FALSE);
       if (!(gpMapiOpenStreamOnFile = (LPOPENSTREAMONFILE) GetProcAddress( m_hMapi32, "OpenStreamOnFile")))
              return( FALSE);

       return( TRUE);
}

Here is the caller graph for this function:

Definition at line 251 of file MapiApi.cpp.

{
       if (!m_initialized) {
              MAPI_TRACE0( "Tried to LogOn before initializing MAPI\n");
              return( FALSE);
       }
       
       if (m_lpSession)
              return( TRUE);

       HRESULT hr;

       hr = MAPILogonEx(    0, // might need to be passed in HWND
                                          NULL, // profile name, 64 char max (LPTSTR)
                                          NULL, // profile password, 64 char max (LPTSTR)
                                          // MAPI_NEW_SESSION | MAPI_NO_MAIL | MAPI_LOGON_UI | MAPI_EXPLICIT_PROFILE,
                                          // MAPI_NEW_SESSION | MAPI_NO_MAIL | MAPI_LOGON_UI,
                                          // MAPI_NO_MAIL | MAPI_LOGON_UI,
                                          MAPI_NO_MAIL | MAPI_USE_DEFAULT | MAPI_EXTENDED | MAPI_NEW_SESSION,
                                          &m_lpSession);

       if (FAILED(hr)) {
              m_lpSession = NULL;
              MAPI_TRACE2( "LogOn failed: 0x%lx, %d\n", (long)hr, (int)hr);
              return( FALSE);
       }

       MAPI_TRACE0( "MAPI Logged on\n");


       return( TRUE);
}

Here is the call graph for this function:

Here is the caller graph for this function:

SCODE CMapiApi::MAPIAllocateBuffer ( ULONG  cbSize,
LPVOID FAR lppBuffer 
) [static]

Definition at line 104 of file MapiApi.cpp.

{
       if (m_hMapi32 && gpMapiAllocateBuffer)
              return( (*gpMapiAllocateBuffer)( cbSize, lppBuffer));
       return( MAPI_E_NOT_INITIALIZED);
}

Here is the caller graph for this function:

ULONG CMapiApi::MAPIFreeBuffer ( LPVOID  lpBuff) [static]

Definition at line 111 of file MapiApi.cpp.

{
       if (m_hMapi32 && gpMapiFreeBuffer)
              return( (*gpMapiFreeBuffer)( lpBuff));
       return( MAPI_E_NOT_INITIALIZED);
}

Here is the caller graph for this function:

HRESULT CMapiApi::MAPIInitialize ( LPVOID  lpInit) [static]

Definition at line 97 of file MapiApi.cpp.

{
       if (m_hMapi32 && gpMapiInitialize)
              return( (*gpMapiInitialize)( lpInit));
       return( MAPI_E_NOT_INITIALIZED);
}

Here is the caller graph for this function:

HRESULT CMapiApi::MAPILogonEx ( ULONG  ulUIParam,
LPTSTR  lpszProfileName,
LPTSTR  lpszPassword,
FLAGS  flFlags,
LPMAPISESSION FAR lppSession 
) [static]

Definition at line 118 of file MapiApi.cpp.

{
       if (m_hMapi32 && gpMapiLogonEx)
              return( (*gpMapiLogonEx)( ulUIParam, lpszProfileName, lpszPassword, flFlags, lppSession));
       return( MAPI_E_NOT_INITIALIZED);
}

Here is the caller graph for this function:

Definition at line 91 of file MapiApi.cpp.

{
       if (m_hMapi32 && gpMapiUninitialize)
              (*gpMapiUninitialize)();
}

Here is the caller graph for this function:

BOOL CMapiApi::OpenEntry ( ULONG  cbEntry,
LPENTRYID  pEntryId,
LPUNKNOWN *  ppOpen 
)

Definition at line 494 of file MapiApi.cpp.

{
       if (!m_lpMdb) {
              MAPI_TRACE0( "OpenEntry called before the message store is open\n");
              return( FALSE);
       }
       
       return( OpenMdbEntry( m_lpMdb, cbEntry, pEntryId, ppOpen));
}

Here is the call graph for this function:

Here is the caller graph for this function:

BOOL CMapiApi::OpenMdbEntry ( LPMDB  lpMdb,
ULONG  cbEntry,
LPENTRYID  pEntryId,
LPUNKNOWN *  ppOpen 
) [static]

Definition at line 504 of file MapiApi.cpp.

{      
       ULONG         ulObjType;
       HRESULT              hr;
    hr = m_lpSession->OpenEntry(cbEntry,
                                                        pEntryId,
                                                        NULL,
                                                        0,
                                                        &ulObjType,
                                                        (LPUNKNOWN *) ppOpen);
       if (FAILED(hr)) {
              MAPI_TRACE2( "OpenMdbEntry failed: 0x%lx, %d\n", (long)hr, (int)hr);
              return( FALSE);
       }
       return( TRUE);
}

Here is the caller graph for this function:

BOOL CMapiApi::OpenStore ( ULONG  cbEid,
LPENTRYID  lpEid,
LPMDB *  ppMdb 
)

Definition at line 480 of file MapiApi.cpp.

{
       if (!m_lpSession) {
              MAPI_TRACE0( "OpenStore called before a session was opened\n");
              return( FALSE);
       }

       CMsgStore *          pStore = FindMessageStore( cbEid, lpEid);
       if (pStore && pStore->Open( m_lpSession, ppMdb))
              return( TRUE);
       return( FALSE);
}

Here is the call graph for this function:

Here is the caller graph for this function:

HRESULT CMapiApi::OpenStreamOnFile ( LPALLOCATEBUFFER  lpAllocateBuffer,
LPFREEBUFFER  lpFreeBuffer,
ULONG  ulFlags,
LPTSTR  lpszFileName,
LPTSTR  lpszPrefix,
LPSTREAM FAR lppStream 
) [static]

Definition at line 125 of file MapiApi.cpp.

{
       if (m_hMapi32 && gpMapiOpenStreamOnFile)
              return( (*gpMapiOpenStreamOnFile)( lpAllocateBuffer, lpFreeBuffer, ulFlags, lpszFileName, lpszPrefix, lppStream));
       return( MAPI_E_NOT_INITIALIZED);
}

Here is the caller graph for this function:

void CMapiApi::ReportLongProp ( const char *  pTag,
LPSPropValue  pVal 
) [static, protected]

Definition at line 1317 of file MapiApi.cpp.

{
       if ( pVal && (PROP_TYPE( pVal->ulPropTag) == PT_LONG)) {
              nsCString     num;
              nsCString     num2;

              num.AppendInt( (PRInt32) pVal->Value.l);
              num2.AppendInt( (PRInt32) pVal->Value.l, 16);
              MAPI_TRACE3( "%s %s, 0x%s\n", pTag, num, num2);
       }
       else if (pVal && (PROP_TYPE( pVal->ulPropTag) == PT_NULL)) {
              MAPI_TRACE1( "%s {NULL}\n", pTag);
       }
       else if (pVal && (PROP_TYPE( pVal->ulPropTag) == PT_ERROR)) {
              MAPI_TRACE1( "%s {Error retrieving property}\n", pTag);
       }
       else if (pVal && (PROP_TYPE( pVal->ulPropTag) == PT_ERROR)) {
              MAPI_TRACE1( "%s {Error retrieving property}\n", pTag);
       }
       else {
              MAPI_TRACE1( "%s invalid value, expecting long\n", pTag);
       }
       if (pVal)
              MAPIFreeBuffer( pVal);
}

Here is the call graph for this function:

void CMapiApi::ReportStringProp ( const char *  pTag,
LPSPropValue  pVal 
) [static, protected]

Definition at line 1343 of file MapiApi.cpp.

{
       if ( pVal && (PROP_TYPE( pVal->ulPropTag) == PT_TSTRING)) {
              nsCString val((LPCTSTR) (pVal->Value.LPSZ));
              MAPI_TRACE2( "%s %s\n", pTag, (const char *)val);
       }
       else if (pVal && (PROP_TYPE( pVal->ulPropTag) == PT_NULL)) {
              MAPI_TRACE1( "%s {NULL}\n", pTag);
       }
       else if (pVal && (PROP_TYPE( pVal->ulPropTag) == PT_ERROR)) {
              MAPI_TRACE1( "%s {Error retrieving property}\n", pTag);
       }
       else {
              MAPI_TRACE1( "%s invalid value, expecting string\n", pTag);
       }
       if (pVal)
              MAPIFreeBuffer( pVal);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void CMapiApi::ReportUIDProp ( const char *  pTag,
LPSPropValue  pVal 
) [static, protected]

Definition at line 1288 of file MapiApi.cpp.

{
       if ( pVal && (PROP_TYPE( pVal->ulPropTag) == PT_BINARY)) {
              if (pVal->Value.bin.cb != 16) {
                     MAPI_TRACE1( "%s - INVALID, expecting 16 bytes of binary data for UID\n", pTag);
              }
              else {
                     nsIID  uid;
                     memcpy( &uid, pVal->Value.bin.lpb, 16);
                     char * pStr = uid.ToString();
                     if (pStr) {
                            MAPI_TRACE2( "%s %s\n", pTag, (const char *)pStr);
                            nsCRT::free( pStr);
                     }
              }
       }
       else if (pVal && (PROP_TYPE( pVal->ulPropTag) == PT_NULL)) {
              MAPI_TRACE1( "%s {NULL}\n", pTag);
       }
       else if (pVal && (PROP_TYPE( pVal->ulPropTag) == PT_ERROR)) {
              MAPI_TRACE1( "%s {Error retrieving property}\n", pTag);
       }
       else {
              MAPI_TRACE1( "%s invalid value, expecting binary\n", pTag);
       }
       if (pVal)
              MAPIFreeBuffer( pVal);
}

Here is the call graph for this function:

void CMapiApi::SetCurrentMsgStore ( LPMDB  lpMdb) [inline]

Definition at line 95 of file MapiApi.h.

{ m_lpMdb = lpMdb;}
void CMapiApi::UnloadMapi ( void  ) [static]

Definition at line 165 of file MapiApi.cpp.

Here is the caller graph for this function:


Member Data Documentation

int CMapiApi::m_clients = 0 [static, private]

Definition at line 148 of file MapiApi.h.

Definition at line 80 of file MapiApi.h.

BOOL CMapiApi::m_initialized = PR_FALSE [static, private]

Definition at line 149 of file MapiApi.h.

HRESULT CMapiApi::m_lastError [static, private]

Definition at line 153 of file MapiApi.h.

LPMDB CMapiApi::m_lpMdb = NULL [static, private]

Definition at line 152 of file MapiApi.h.

LPMAPISESSION CMapiApi::m_lpSession = NULL [static, private]

Definition at line 151 of file MapiApi.h.

nsVoidArray * CMapiApi::m_pStores = NULL [static, private]

Definition at line 150 of file MapiApi.h.

PRUnichar * CMapiApi::m_pUniBuff = NULL [static, private]

Definition at line 154 of file MapiApi.h.

int CMapiApi::m_uniBuffLen = 0 [static, private]

Definition at line 155 of file MapiApi.h.


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