//  Beta release only.
//
//  Copyright(c) Ivyware Pty Ltd 2013  (all rights reserved)
//               MELBOURNE, VICTORIA, AUSTRALIA, 3130
//
//  Provided no fee is charged (either by the distributer or user)
//  permission to use, copy, modify, and distribute this software and
//  its documentation for any purpose and without fee is hereby granted,
//  provided that the above copyright notice appear in all copies and
//  that both that copyright notice and this permission notice appear
//  in supporting documentation.
//
//  No waranty or suitablity for purpose is implied.
//
//
//  IMAPISession interface wrapper class
//  NOTES: Manages all subordinate IMAPISession resources
//      
#pragma  once

#include "P2PTL.h"

#include "MAPIEx.h"
#include "MsgStore.h"
#include "MAPIProp.h"
#include "MAPIMessage.h"
#include "MAPIFolder.h"

////////////////////////////////////////////////////////////////////////////////////////////////////////////
//  CMAPISession class
//  NOTES: Primarily wraps and manages the IMAPISession interface

class P2PmsgMAPI_EXT CMAPISession 
{
    // Constructors and destructor
    public:
	      CMAPISession ( CMAPIEx *pMAPIEx );
      virtual
	     ~CMAPISession ( );

    // Attributes
    protected:
      CMAPIEx       *m_pMAPIex_;
	    IMAPISession  *m_pIMAPISession;
      CMsgStore     *m_pCMsgStore;

    // Operations
    public:
	    HRESULT
        LogonEx ( ULONG ulUIParam
                , LPCTSTR szProfileName, LPCTSTR lpszPassword
                , FLAGS ulFlags );
	    void
        LogoffEx ( );
      HRESULT
        OpenMsgStore ( LPCTSTR lpszMsgStorename=NULL, ULONG ulFlags = MAPI_MODIFY | MAPI_NO_CACHE );
      HRESULT
        CloseMsgStore ( );
      BOOL
        GetEmail   ( ADRENTRY& adrEntry, CString& strEmail );
      BOOL
        GetExEmail ( SBinary entryID, CString& strEmail );

    // Property exposure
    public:
      IMAPISession*
        GetIMAPISession ( );
      CMsgStore*
        GetMsgStore ( );
};
typedef P2PSafePtr<CMAPISession> CMAPISessionSP;
