forked from DoubangoTelecom/webrtc2sip
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mp_mail.h
executable file
·107 lines (93 loc) · 3.43 KB
/
mp_mail.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
/* Copyright (C) 2012-2013 Doubango Telecom <http://www.doubango.org>
*
* This file is part of Open Source 'webrtc2sip' project
* <http://code.google.com/p/webrtc2sip/>
*
* 'webrtc2sip' is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* 'webrtc2sip' is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with 'webrtc2sip'.
*/
#if !defined(_MEDIAPROXY_MAIL_H_)
#define _MEDIAPROXY_MAIL_H_
#include "mp_config.h"
#include "mp_net_transport.h"
#include <list>
namespace webrtc2sip {
class MPMailTransport;
//
// MPMail
//
class MPMail : public MPObject
{
public:
MPMail(const char* pcSrcMailAddr, const char* pcDstMailAddr, const char* pcSubject, const void* pcDataPtr, size_t nDataSize);
virtual ~MPMail();
virtual MP_INLINE const char* getObjectId() { return "MPMail"; }
virtual MP_INLINE const char* getSrcMailAddr() { return m_pSrcMailAddr; }
virtual MP_INLINE const char* getDstMailAddr() { return m_pDstMailAddr; }
virtual MP_INLINE const char* getSubject() { return m_pSubject; }
virtual MP_INLINE const void* getDataPtr() { return m_pDataPtr; }
virtual MP_INLINE size_t getDataSize() { return m_nDataSize; }
private:
char* m_pSrcMailAddr;
char* m_pDstMailAddr;
char* m_pSubject;
void* m_pDataPtr;
size_t m_nDataSize;
};
//
// MPMailTransportCallback
//
class MPMailTransportCallback : public MPNetTransportCallback
{
public:
MPMailTransportCallback(const MPMailTransport* pcTransport);
virtual ~MPMailTransportCallback();
virtual MP_INLINE const char* getObjectId() { return "MPMailTransportCallback"; }
virtual bool onData(MPObjectWrapper<MPNetPeer*> oPeer, size_t &nConsumedBytes);
virtual bool onConnectionStateChanged(MPObjectWrapper<MPNetPeer*> oPeer);
private:
const MPMailTransport* m_pcTransport;
};
//
// MPMailTransport
//
class MPMailTransport : public MPNetTransport
{
friend class MPMailTransportCallback;
public:
MPMailTransport(bool isSecure, const char* pcLocalIP, unsigned short nLocalPort, const char* pcSmtpHost, unsigned short nSmtpPort, const char* pcEmail, const char* pcAuthName, const char* pcAuthPwd);
virtual ~MPMailTransport();
virtual MP_INLINE const char* getObjectId() { return "MPMailTransport"; }
virtual bool setHttpDomain(const char* pcHttpDomain);
virtual bool sendMail(const char* pcDstMailAddr, const char* pcSubject, const void* pcDataPr, size_t nDataSize, const char* pcSrcMailAddr = NULL);
virtual MP_INLINE const char* getHttpDomain() { return m_pHttpDomain; }
private:
bool sendMail(MPObjectWrapper<MPMail*> oMail);
bool sendPendingMails();
private:
MPObjectWrapper<MPMailTransportCallback*> m_oCallback;
bool m_bConnectToPending;
char* m_pSmtpHost;
char* m_pHttpDomain;
unsigned short m_nSmtpPort;
char* m_pEmail;
char* m_pAuthName64;
char* m_pAuthPwd64;
MPNetFd m_nConnectedFd;
std::list<MPObjectWrapper<MPMail*> > m_oPendingMails;
uint8_t* m_pTempBuffPtr;
size_t m_nTempBuffSize;
bool m_bNeedToAuthenticate;
};
}// namespace
#endif /* _MEDIAPROXY_MAIL_H_ */