//  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.
//
//
//  P2PeerHubMAPI definitions and prototypes
//  NOTES: Integrates Exchange, using MAPI (Messaging API) into a P2Peer virtual
//         network
//       : Supports MAPI Initialize, send email and Uninitialize
//      
#pragma once
#include "P2PmsgMAPI.h"
#include "P2PeerHub.h"
#include "MAPIEx.h"

class P2PmsgMAPI_EXT P2PeerHubMAPI : public P2PeerHub
{
      void
        RenderThisSafe();

    // Constructors and destructor
    public:
        P2PeerHubMAPI ( P2PaddrSTR strP2PaddrThis );
      virtual
       ~P2PeerHubMAPI ( );

    // Attributes
    private:
      P2PumpID            m_nMAPIPumpID;
      CMAPIEx            *m_pMAPIex;
      CMAPISession       *m_pMAPISession;
      CString             m_strProfileName;
      CString             m_strProfilePassword;
      CString             m_strMsgStorename;
      CString             m_strFrom_Email;
      CString             m_strFrom_Name;
      CString             m_strUsernameODBC;
      CString             m_strPasswordODBC;
      CString             m_strServernameODBC;

    // Extractors
    // NOTES: Translate various P2PeerMsg formats into CMAPIMessage
    private:
      void
        TranslateMsg ( CMAPImessage& oMAPImessage, P2PeerMsg *pMsg );
      void
        TranslateMsgSQL ( CMAPImessage& oMAPImessage, P2PeerMsg *pMsg );

    // P2PeerCon_MAP handlers
    // NOTES: Placemarker for map.  Default set of handlers reside
    //        in P2PeerTarget.  Usually this default set is customised
    protected:
    DECLARE_P2PeerCon_MAP()

    // P2PeerMsg_MAP handlers
    // NOTES: Placemarker for map.  Default set of handlers reside
    //        in P2PeerTarget.  Usually this default set is customised
    protected:
	  DECLARE_P2PeerMsg_MAP()
      virtual msgRESULT
        On_MAPIInitialize ( P2PeerMsg *pMsg );
      virtual msgRESULT
        On_MAPILogonEx ( P2PeerMsg *pMsg );
      virtual msgRESULT
        On_MAPILogoffEx ( P2PeerMsg *pMsg );
      virtual msgRESULT
        On_MAPIsendEmail ( P2PeerMsg *pMsg );
      virtual msgRESULT
        On_MAPIUnitialize ( P2PeerMsg *pMsg );
};

