Provide usable API to send RS mails

Return trackid to sendmail caller
Post RsEvents when sent mail change status
Deprecate old MessageSend
This commit is contained in:
Gioacchino Mazzurco 2019-09-16 18:40:07 +02:00
parent 584918388c
commit 04d3325fbd
No known key found for this signature in database
GPG key ID: A1FBCA3872E87051
6 changed files with 368 additions and 90 deletions

View file

@ -20,6 +20,7 @@
* *
*******************************************************************************/
#include <iostream>
#include <tuple>
#include "util/rsdir.h"
#include "util/rsdebug.h"
@ -300,6 +301,22 @@ bool p3Msgs::MessageSend(MessageInfo &info)
return mMsgSrv->MessageSend(info);
}
uint32_t p3Msgs::sendMail(
const RsGxsId from,
const std::string& subject,
const std::string& body,
const std::set<RsGxsId>& to,
const std::set<RsGxsId>& cc,
const std::set<RsGxsId>& bcc,
const std::vector<FileInfo>& attachments,
std::set<RsMailTrackId>& trackingIds,
std::string& errorMsg )
{
return mMsgSrv->sendMail(
from, subject, body, to, cc, bcc, attachments,
trackingIds, errorMsg );
}
bool p3Msgs::SystemMessage(const std::string &title, const std::string &message, uint32_t systemFlag)
{
return mMsgSrv->SystemMessage(title, message, systemFlag);
@ -541,3 +558,28 @@ uint32_t p3Msgs::getDistantChatPermissionFlags()
return mChatSrv->getDistantChatPermissionFlags() ;
}
RsMsgs::~RsMsgs() = default;
RsMailStatusEvent::~RsMailStatusEvent() = default;
Rs::Msgs::MessageInfo::~MessageInfo() = default;
MsgInfoSummary::~MsgInfoSummary() = default;
VisibleChatLobbyRecord::~VisibleChatLobbyRecord() = default;
void RsMailTrackId::serial_process(
RsGenericSerializer::SerializeJob j,
RsGenericSerializer::SerializeContext& ctx )
{
RS_SERIAL_PROCESS(mMailId);
RS_SERIAL_PROCESS(mRecipientId);
}
bool RsMailTrackId::operator<(const RsMailTrackId& o) const
{
return std::tie( mMailId, mRecipientId) <
std::tie(o.mMailId, o.mRecipientId);
}
bool RsMailTrackId::operator==(const RsMailTrackId& o) const
{
return std::tie( mMailId, mRecipientId) ==
std::tie(o.mMailId, o.mRecipientId);
}

View file

@ -19,8 +19,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. *
* *
*******************************************************************************/
#ifndef RS_P3MSG_INTERFACE_H
#define RS_P3MSG_INTERFACE_H
#pragma once
#include "retroshare/rsmsgs.h"
#include "retroshare/rsgxsifacetypes.h"
@ -38,11 +37,25 @@ class RsChatMsgItem;
*/
class p3Msgs: public RsMsgs
{
public:
public:
p3Msgs(p3MsgService *p3m, p3ChatService *p3c)
:mMsgSrv(p3m), mChatSrv(p3c) { return; }
virtual ~p3Msgs() { return; }
p3Msgs(p3MsgService *p3m, p3ChatService *p3c) :
mMsgSrv(p3m), mChatSrv(p3c) {}
~p3Msgs() override = default;
/// @see RsMsgs
uint32_t sendMail(
const RsGxsId from,
const std::string& subject,
const std::string& body,
const std::set<RsGxsId>& to = std::set<RsGxsId>(),
const std::set<RsGxsId>& cc = std::set<RsGxsId>(),
const std::set<RsGxsId>& bcc = std::set<RsGxsId>(),
const std::vector<FileInfo>& attachments = std::vector<FileInfo>(),
std::set<RsMailTrackId>& trackingIds =
RS_DEFAULT_STORAGE_PARAM(std::set<RsMailTrackId>),
std::string& errorMsg =
RS_DEFAULT_STORAGE_PARAM(std::string) ) override;
/****************************************/
/* Message Items */
@ -54,6 +67,7 @@ class p3Msgs: public RsMsgs
virtual bool getMessage(const std::string &mId, Rs::Msgs::MessageInfo &msg);
virtual void getMessageCount(uint32_t &nInbox, uint32_t &nInboxNew, uint32_t &nOutbox, uint32_t &nDraftbox, uint32_t &nSentbox, uint32_t &nTrashbox);
RS_DEPRECATED_FOR(sendMail)
virtual bool MessageSend(Rs::Msgs::MessageInfo &info);
virtual bool SystemMessage(const std::string &title, const std::string &message, uint32_t systemFlag);
virtual bool MessageToDraft(Rs::Msgs::MessageInfo &info, const std::string &msgParentId);
@ -172,6 +186,3 @@ class p3Msgs: public RsMsgs
p3MsgService *mMsgSrv;
p3ChatService *mChatSrv;
};
#endif