Back to index

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

#include <msgMapiMain.h>

Collaboration diagram for nsMAPIConfiguration:
Collaboration graph
[legend]

List of all members.

Public Member Functions

void OpenConfiguration ()
PRInt16 RegisterSession (PRUint32 aHwnd, const PRUnichar *aUserName, const PRUnichar *aPassword, PRBool aForceDownLoad, PRBool aNewSession, PRUint32 *aSession, char *aIdKey)
PRBool IsSessionValid (PRUint32 aSessionID)
PRBool UnRegisterSession (PRUint32 aSessionID)
PRUnicharGetPassword (PRUint32 aSessionID)
char * GetIdKey (PRUint32 aSessionID)
voidGetMapiListContext (PRUint32 aSessionID)
void SetMapiListContext (PRUint32 aSessionID, void *mapiListContext)
 ~nsMAPIConfiguration ()

Static Public Member Functions

static nsMAPIConfigurationGetMAPIConfiguration ()
static HRESULT GetMAPIErrorFromNSError (nsresult res)

Private Member Functions

 nsMAPIConfiguration ()

Private Attributes

PRLockm_Lock
PRUint32 m_nMaxSessions
nsHashtable m_ProfileMap
nsHashtable m_SessionMap

Static Private Attributes

static PRUint32 session_generator = 0
static PRUint32 sessionCount = 0
static nsMAPIConfigurationm_pSelfRef = nsnull

Detailed Description

Definition at line 54 of file msgMapiMain.h.


Constructor & Destructor Documentation

Definition at line 80 of file msgMapiMain.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 99 of file msgMapiMain.cpp.

Here is the call graph for this function:


Member Function Documentation

char * nsMAPIConfiguration::GetIdKey ( PRUint32  aSessionID)

Definition at line 292 of file msgMapiMain.cpp.

{
    char *pResult = nsnull;

    PR_Lock(m_Lock);

    if (aSessionID != 0)
    {
        nsPRUintKey sessionKey(aSessionID);
        nsMAPISession *pTemp = (nsMAPISession *)m_SessionMap.Get(&sessionKey);
        if (pTemp)
           pResult = pTemp->GetIdKey();
    }

    PR_Unlock(m_Lock);
    return pResult;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 72 of file msgMapiMain.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 311 of file msgMapiMain.cpp.

{
    HRESULT hr = SUCCESS_SUCCESS ;

    if (NS_SUCCEEDED (res)) return hr ;

    // if failure return the related MAPI failure code
    switch (res)
    {
        case NS_MSG_NO_RECIPIENTS :
            hr = MAPI_E_BAD_RECIPTYPE ;
            break ;
        case NS_ERROR_COULD_NOT_GET_USERS_MAIL_ADDRESS :
            hr = MAPI_E_INVALID_RECIPS ; 
            break ;
        case NS_ERROR_COULD_NOT_LOGIN_TO_SMTP_SERVER :
            hr = MAPI_E_LOGIN_FAILURE ;
            break ;
        case NS_MSG_UNABLE_TO_OPEN_FILE :                 
        case NS_MSG_UNABLE_TO_OPEN_TMP_FILE :
        case NS_MSG_COULDNT_OPEN_FCC_FOLDER :
        case NS_ERROR_FILE_INVALID_PATH :
            hr = MAPI_E_ATTACHMENT_OPEN_FAILURE ;
            break ;
        case NS_ERROR_FILE_TARGET_DOES_NOT_EXIST :
            hr = MAPI_E_ATTACHMENT_NOT_FOUND ;
            break ;
        case NS_MSG_CANCELLING :
            hr = MAPI_E_USER_ABORT ;
            break ;
        case NS_MSG_ERROR_WRITING_FILE :
        case NS_MSG_UNABLE_TO_SAVE_TEMPLATE :
        case NS_MSG_UNABLE_TO_SAVE_DRAFT :
            hr = MAPI_E_ATTACHMENT_WRITE_FAILURE ;
            break ;
        default :
            hr = MAPI_E_FAILURE ;
            break ;
    }

    return hr ;
}

Here is the caller graph for this function:

Definition at line 259 of file msgMapiMain.cpp.

{
    void *pResult = nsnull;

    PR_Lock(m_Lock);

    if (aSessionID != 0)
    {
        nsPRUintKey sessionKey(aSessionID);
        nsMAPISession *pTemp = (nsMAPISession *)m_SessionMap.Get(&sessionKey);
        if (pTemp)
           pResult = pTemp->GetMapiListContext();
    }

    PR_Unlock(m_Lock);
    return pResult;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 239 of file msgMapiMain.cpp.

{
    PRUnichar *pResult = nsnull;

    PR_Lock(m_Lock);

    if (aSessionID != 0)
    {
        nsPRUintKey sessionKey(aSessionID);
        nsMAPISession *pTemp = (nsMAPISession *)m_SessionMap.Get(&sessionKey);

        if (pTemp)
            pResult = pTemp->GetPassword();
    }

    PR_Unlock(m_Lock);

    return pResult;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 221 of file msgMapiMain.cpp.

{
    if (aSessionID == 0)
        return PR_FALSE;

    PRBool retValue = PR_FALSE;
    nsPRUintKey sessionKey(aSessionID);

    PR_Lock(m_Lock);

    retValue = m_SessionMap.Exists(&sessionKey);
        
    PR_Unlock(m_Lock);

    return retValue;
}

Here is the caller graph for this function:

Definition at line 108 of file msgMapiMain.cpp.

{
    // No. of max. sessions is set to MAX_SESSIONS.  In future
    // if it is decided to have configuration (registry)
    // parameter, this function can be used to set the
    // max sessions;

    return;
}
PRInt16 nsMAPIConfiguration::RegisterSession ( PRUint32  aHwnd,
const PRUnichar aUserName,
const PRUnichar aPassword,
PRBool  aForceDownLoad,
PRBool  aNewSession,
PRUint32 aSession,
char *  aIdKey 
)

Definition at line 118 of file msgMapiMain.cpp.

{
    PRInt16 nResult = 0;
    PRUint32 n_SessionId = 0;

    PR_Lock(m_Lock);

    // Check whether max sessions is exceeded

    if (sessionCount >= m_nMaxSessions)
    {
        PR_Unlock(m_Lock);
        return -1;
    }

    if (aUserName != nsnull && aUserName[0] != '\0')
    {
      nsStringKey usernameKey(aUserName);
      n_SessionId = (PRUint32) m_ProfileMap.Get(&usernameKey);
    }

    // try to share a session; if not create a session

    if (n_SessionId > 0)
    {
        nsPRUintKey sessionKey(n_SessionId);
        nsMAPISession *pTemp = (nsMAPISession *)m_SessionMap.Get(&sessionKey);
        if (pTemp != nsnull)
        {
            pTemp->IncrementSession();
            *aSession = n_SessionId;
            nResult = 1;
        }
    }
    else if (aNewSession || n_SessionId == 0) // checking for n_SessionId is a concession
    {
        // create a new session ; if new session is specified OR there is no session
        nsMAPISession *pTemp = nsnull;
        pTemp = new nsMAPISession(aHwnd, aUserName,
                               aPassword, aForceDownLoad, aIdKey);

        if (pTemp != nsnull)
        {
            session_generator++;

            // I don't think there will be (2 power 32) sessions alive
            // in a cycle.  This is an assumption

            if (session_generator == 0)
                session_generator++;

            nsPRUintKey sessionKey(session_generator);
            m_SessionMap.Put(&sessionKey, pTemp);
            if (aUserName != nsnull && aUserName[0] != '\0')
            {
                nsStringKey usernameKey(aUserName);
                m_ProfileMap.Put(&usernameKey, (void*)session_generator);
            }

            *aSession = session_generator;
            sessionCount++;
            nResult = 1;
        }
    }

    PR_Unlock(m_Lock);
    return nResult;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsMAPIConfiguration::SetMapiListContext ( PRUint32  aSessionID,
void mapiListContext 
)

Definition at line 277 of file msgMapiMain.cpp.

{
    PR_Lock(m_Lock);

    if (aSessionID != 0)
    {
        nsPRUintKey sessionKey(aSessionID);
        nsMAPISession *pTemp = (nsMAPISession *)m_SessionMap.Get(&sessionKey);
        if (pTemp)
           pTemp->SetMapiListContext(mapiListContext);
    }

    PR_Unlock(m_Lock);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 190 of file msgMapiMain.cpp.

{
    PRBool bResult = PR_FALSE;

    PR_Lock(m_Lock);

    if (aSessionID != 0)
    {
        nsPRUintKey sessionKey(aSessionID);
        nsMAPISession *pTemp = (nsMAPISession *)m_SessionMap.Get(&sessionKey);

        if (pTemp != nsnull)
        {
            if (pTemp->DecrementSession() == 0)
            {
                if (pTemp->m_pProfileName.get() != nsnull)
                {
                  nsStringKey stringKey(pTemp->m_pProfileName.get());
                  m_ProfileMap.Remove(&stringKey);
                }
                m_SessionMap.Remove(&sessionKey);
                sessionCount--;
                bResult = PR_TRUE;
            }
        }
    }

    PR_Unlock(m_Lock);
    return bResult;
}

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 61 of file msgMapiMain.h.

Definition at line 62 of file msgMapiMain.h.

nsHashtable nsMAPIConfiguration::m_ProfileMap [private]

Definition at line 65 of file msgMapiMain.h.

Definition at line 60 of file msgMapiMain.h.

nsHashtable nsMAPIConfiguration::m_SessionMap [private]

Definition at line 66 of file msgMapiMain.h.

Definition at line 58 of file msgMapiMain.h.

Definition at line 59 of file msgMapiMain.h.


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