mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-01-14 08:59:50 -05:00
Merge pull request #1640 from G10h4ck/rsmsg_jsonapi
Provide usable API to send RS mails
This commit is contained in:
commit
d46e3eb2b7
@ -165,6 +165,8 @@ public:
|
||||
virtual bool getKey(const RsGxsId &id, RsTlvPublicRSAKey& key) = 0;
|
||||
virtual bool getPrivateKey(const RsGxsId &id, RsTlvPrivateRSAKey& key) = 0; // For signing outgoing messages.
|
||||
virtual bool getIdDetails(const RsGxsId& id, RsIdentityDetails& details) = 0 ; // Proxy function so that we get p3Identity info from Gxs
|
||||
|
||||
virtual ~RsGixs();
|
||||
};
|
||||
|
||||
class GixsReputation
|
||||
|
@ -66,6 +66,9 @@ enum class RsEventType : uint32_t
|
||||
/// Emitted when a peer state changes, @see RsPeers
|
||||
PEER_STATE_CHANGED = 6,
|
||||
|
||||
/// @see RsMailStatusEvent
|
||||
MAIL_STATUS_CHANGE = 7,
|
||||
|
||||
MAX /// Used to detect invalid event type passed
|
||||
};
|
||||
|
||||
|
@ -47,7 +47,7 @@ extern RsGxsChannels* rsGxsChannels;
|
||||
|
||||
struct RsGxsChannelGroup : RsSerializable
|
||||
{
|
||||
RsGxsChannelGroup() : mAutoDownload(false) {}
|
||||
RsGxsChannelGroup() : mAutoDownload(false) {}
|
||||
|
||||
RsGroupMetaData mMeta;
|
||||
std::string mDescription;
|
||||
@ -56,14 +56,17 @@ struct RsGxsChannelGroup : RsSerializable
|
||||
bool mAutoDownload;
|
||||
|
||||
/// @see RsSerializable
|
||||
virtual void serial_process( RsGenericSerializer::SerializeJob j,
|
||||
RsGenericSerializer::SerializeContext& ctx )
|
||||
virtual void serial_process(
|
||||
RsGenericSerializer::SerializeJob j,
|
||||
RsGenericSerializer::SerializeContext& ctx ) override
|
||||
{
|
||||
RS_SERIAL_PROCESS(mMeta);
|
||||
RS_SERIAL_PROCESS(mDescription);
|
||||
RS_SERIAL_PROCESS(mImage);
|
||||
RS_SERIAL_PROCESS(mAutoDownload);
|
||||
}
|
||||
|
||||
~RsGxsChannelGroup() override;
|
||||
};
|
||||
|
||||
struct RsGxsChannelPost : RsSerializable
|
||||
@ -82,8 +85,9 @@ struct RsGxsChannelPost : RsSerializable
|
||||
RsGxsImage mThumbnail;
|
||||
|
||||
/// @see RsSerializable
|
||||
virtual void serial_process( RsGenericSerializer::SerializeJob j,
|
||||
RsGenericSerializer::SerializeContext& ctx )
|
||||
virtual void serial_process(
|
||||
RsGenericSerializer::SerializeJob j,
|
||||
RsGenericSerializer::SerializeContext& ctx ) override
|
||||
{
|
||||
RS_SERIAL_PROCESS(mMeta);
|
||||
RS_SERIAL_PROCESS(mOlderVersions);
|
||||
@ -94,6 +98,8 @@ struct RsGxsChannelPost : RsSerializable
|
||||
RS_SERIAL_PROCESS(mSize);
|
||||
RS_SERIAL_PROCESS(mThumbnail);
|
||||
}
|
||||
|
||||
~RsGxsChannelPost() override;
|
||||
};
|
||||
|
||||
|
||||
@ -544,5 +550,5 @@ public:
|
||||
virtual bool retrieveDistantGroup(const RsGxsGroupId& group_id,RsGxsChannelGroup& distant_group)=0;
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
virtual ~RsGxsChannels();
|
||||
~RsGxsChannels() override;
|
||||
};
|
||||
|
@ -338,7 +338,7 @@ struct RsIdentityDetails : RsSerializable
|
||||
RS_SERIAL_PROCESS(mNickname);
|
||||
RS_SERIAL_PROCESS(mFlags);
|
||||
RS_SERIAL_PROCESS(mPgpId);
|
||||
//RS_SERIAL_PROCESS(mReputation);
|
||||
RS_SERIAL_PROCESS(mReputation);
|
||||
RS_SERIAL_PROCESS(mAvatar);
|
||||
RS_SERIAL_PROCESS(mPublishTS);
|
||||
RS_SERIAL_PROCESS(mLastUsageTS);
|
||||
@ -352,7 +352,6 @@ struct RsIdentityDetails : RsSerializable
|
||||
struct RsIdentity : RsGxsIfaceHelper
|
||||
{
|
||||
explicit RsIdentity(RsGxsIface& gxs) : RsGxsIfaceHelper(gxs) {}
|
||||
virtual ~RsIdentity() {}
|
||||
|
||||
/**
|
||||
* @brief Create a new identity
|
||||
@ -419,6 +418,14 @@ struct RsIdentity : RsGxsIfaceHelper
|
||||
*/
|
||||
virtual bool getOwnPseudonimousIds(std::vector<RsGxsId>& ids) = 0;
|
||||
|
||||
/**
|
||||
* @brief Check if an id is known
|
||||
* @jsonapi{development}
|
||||
* @param[in] id Id to check
|
||||
* @return true if the id is known, false otherwise
|
||||
*/
|
||||
virtual bool isKnownId(const RsGxsId& id) = 0;
|
||||
|
||||
/**
|
||||
* @brief Check if an id is own
|
||||
* @jsonapi{development}
|
||||
@ -568,4 +575,6 @@ struct RsIdentity : RsGxsIfaceHelper
|
||||
RS_DEPRECATED_FOR("getIdentitiesSummaries getIdentitiesInfo")
|
||||
virtual bool getGroupData( const uint32_t& token,
|
||||
std::vector<RsGxsIdGroup>& groups) = 0;
|
||||
|
||||
virtual ~RsIdentity();
|
||||
};
|
||||
|
@ -3,7 +3,8 @@
|
||||
* *
|
||||
* libretroshare: retroshare core library *
|
||||
* *
|
||||
* Copyright 2007-2008 by Robert Fernie <retroshare@lunamutt.com> *
|
||||
* Copyright (C) 2007-2008 Robert Fernie <retroshare@lunamutt.com> *
|
||||
* Copyright (C) 2016-2019 Gioacchino Mazzurco <gio@eigenlab.org> *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
@ -19,8 +20,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
*******************************************************************************/
|
||||
#ifndef RS_MSG_GUI_INTERFACE_H
|
||||
#define RS_MSG_GUI_INTERFACE_H
|
||||
#pragma once
|
||||
|
||||
#include <list>
|
||||
#include <iostream>
|
||||
@ -28,8 +28,11 @@
|
||||
#include <set>
|
||||
#include <assert.h>
|
||||
|
||||
#include "rstypes.h"
|
||||
#include "rsgxsifacetypes.h"
|
||||
#include "retroshare/rstypes.h"
|
||||
#include "retroshare/rsgxsifacetypes.h"
|
||||
#include "retroshare/rsevents.h"
|
||||
#include "util/rsdeprecate.h"
|
||||
#include "util/rsmemory.h"
|
||||
|
||||
/********************** For Messages and Channels *****************/
|
||||
|
||||
@ -93,9 +96,31 @@ const ChatLobbyFlags RS_CHAT_LOBBY_FLAGS_PGP_SIGNED ( 0x00000010 ) ; // requi
|
||||
typedef uint64_t ChatLobbyId ;
|
||||
typedef uint64_t ChatLobbyMsgId ;
|
||||
typedef std::string ChatLobbyNickName ;
|
||||
typedef std::string RsMailMessageId; // should be uint32_t !!
|
||||
typedef uint64_t MessageId ;
|
||||
typedef std::string RsMailMessageId; // TODO: rebase on t_RsGenericIdType
|
||||
|
||||
/**
|
||||
* Used to return a tracker id so the API user can keep track of sent mail
|
||||
* status, it contains mail id, and recipient id
|
||||
*/
|
||||
struct RsMailIdRecipientIdPair : RsSerializable
|
||||
{
|
||||
RsMailIdRecipientIdPair(RsMailMessageId mailId, RsGxsId recipientId):
|
||||
mMailId(mailId), mRecipientId(recipientId) {}
|
||||
|
||||
RsMailMessageId mMailId;
|
||||
RsGxsId mRecipientId;
|
||||
|
||||
/// @see RsSerializable
|
||||
void serial_process(
|
||||
RsGenericSerializer::SerializeJob j,
|
||||
RsGenericSerializer::SerializeContext &ctx ) override;
|
||||
|
||||
bool operator<(const RsMailIdRecipientIdPair& other) const;
|
||||
bool operator==(const RsMailIdRecipientIdPair& other) const;
|
||||
|
||||
RsMailIdRecipientIdPair() = default;
|
||||
~RsMailIdRecipientIdPair() override = default;
|
||||
};
|
||||
|
||||
namespace Rs
|
||||
{
|
||||
@ -137,38 +162,9 @@ class MsgAddress
|
||||
std::string _addr_string ;
|
||||
};
|
||||
|
||||
class MessageInfo_v2
|
||||
{
|
||||
public:
|
||||
//MessageInfo_v2() {}
|
||||
|
||||
unsigned int msgflags;
|
||||
|
||||
//RsMessageId msgId;
|
||||
MsgAddress from ;
|
||||
|
||||
std::list<MsgAddress> rcpt ;
|
||||
|
||||
// Headers
|
||||
//
|
||||
std::string subject;
|
||||
std::string msg;
|
||||
rstime_t time_stamp ;
|
||||
|
||||
//std::list<MessageHeader> headers ;
|
||||
|
||||
std::string attach_title;
|
||||
std::string attach_comment;
|
||||
std::list<FileInfo> files;
|
||||
|
||||
int size; /* total of files */
|
||||
int count; /* file count */
|
||||
};
|
||||
|
||||
struct MessageInfo : RsSerializable
|
||||
{
|
||||
MessageInfo(): msgflags(0), size(0), count(0), ts(0) {}
|
||||
virtual ~MessageInfo() = default;
|
||||
|
||||
std::string msgId;
|
||||
|
||||
@ -202,7 +198,10 @@ struct MessageInfo : RsSerializable
|
||||
int ts;
|
||||
|
||||
// RsSerializable interface
|
||||
void serial_process(RsGenericSerializer::SerializeJob j, RsGenericSerializer::SerializeContext &ctx) {
|
||||
void serial_process(
|
||||
RsGenericSerializer::SerializeJob j,
|
||||
RsGenericSerializer::SerializeContext &ctx ) override
|
||||
{
|
||||
RS_SERIAL_PROCESS(msgId);
|
||||
|
||||
RS_SERIAL_PROCESS(rspeerid_srcId);
|
||||
@ -230,26 +229,30 @@ struct MessageInfo : RsSerializable
|
||||
|
||||
RS_SERIAL_PROCESS(ts);
|
||||
}
|
||||
|
||||
~MessageInfo() override;
|
||||
};
|
||||
|
||||
struct MsgInfoSummary : RsSerializable
|
||||
{
|
||||
MsgInfoSummary() : msgflags(0), count(0), ts(0) {}
|
||||
virtual ~MsgInfoSummary() = default;
|
||||
|
||||
RsMailMessageId msgId;
|
||||
RsMailMessageId msgId;
|
||||
RsPeerId srcId;
|
||||
|
||||
uint32_t msgflags;
|
||||
std::list<uint32_t> msgtags; // that leaves 25 bits for user-defined tags.
|
||||
std::list<uint32_t> msgtags; /// that leaves 25 bits for user-defined tags.
|
||||
|
||||
std::string title;
|
||||
int count; /* file count */
|
||||
int count; /** file count */
|
||||
rstime_t ts;
|
||||
|
||||
|
||||
// RsSerializable interface
|
||||
void serial_process(RsGenericSerializer::SerializeJob j, RsGenericSerializer::SerializeContext &ctx) {
|
||||
/// @see RsSerializable
|
||||
void serial_process(
|
||||
RsGenericSerializer::SerializeJob j,
|
||||
RsGenericSerializer::SerializeContext &ctx) override
|
||||
{
|
||||
RS_SERIAL_PROCESS(msgId);
|
||||
RS_SERIAL_PROCESS(srcId);
|
||||
|
||||
@ -260,6 +263,8 @@ struct MsgInfoSummary : RsSerializable
|
||||
RS_SERIAL_PROCESS(count);
|
||||
RS_SERIAL_PROCESS(ts);
|
||||
}
|
||||
|
||||
~MsgInfoSummary() override;
|
||||
};
|
||||
|
||||
struct MsgTagInfo : RsSerializable
|
||||
@ -291,6 +296,22 @@ struct MsgTagType : RsSerializable
|
||||
} //namespace Rs
|
||||
} //namespace Msgs
|
||||
|
||||
struct RsMailStatusEvent : RsEvent
|
||||
{
|
||||
RsMailStatusEvent() : RsEvent(RsEventType::MAIL_STATUS_CHANGE) {}
|
||||
|
||||
std::set<RsMailMessageId> mChangedMsgIds;
|
||||
|
||||
/// @see RsEvent
|
||||
void serial_process( RsGenericSerializer::SerializeJob j,
|
||||
RsGenericSerializer::SerializeContext& ctx) override
|
||||
{
|
||||
RsEvent::serial_process(j, ctx);
|
||||
RS_SERIAL_PROCESS(mChangedMsgIds);
|
||||
}
|
||||
|
||||
~RsMailStatusEvent() override;
|
||||
};
|
||||
|
||||
#define RS_CHAT_PUBLIC 0x0001
|
||||
#define RS_CHAT_PRIVATE 0x0002
|
||||
@ -426,11 +447,10 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
class VisibleChatLobbyRecord : RsSerializable
|
||||
struct VisibleChatLobbyRecord : RsSerializable
|
||||
{
|
||||
public:
|
||||
VisibleChatLobbyRecord(): lobby_id(0), total_number_of_peers(0), last_report_time(0){}
|
||||
virtual ~VisibleChatLobbyRecord() = default;
|
||||
VisibleChatLobbyRecord():
|
||||
lobby_id(0), total_number_of_peers(0), last_report_time(0) {}
|
||||
|
||||
ChatLobbyId lobby_id ; // unique id of the lobby
|
||||
std::string lobby_name ; // name to use for this lobby
|
||||
@ -441,9 +461,11 @@ public:
|
||||
rstime_t last_report_time ; // last time the lobby was reported.
|
||||
ChatLobbyFlags lobby_flags ; // see RS_CHAT_LOBBY_PRIVACY_LEVEL_PUBLIC / RS_CHAT_LOBBY_PRIVACY_LEVEL_PRIVATE
|
||||
|
||||
// RsSerializable interface
|
||||
public:
|
||||
void serial_process(RsGenericSerializer::SerializeJob j, RsGenericSerializer::SerializeContext &ctx) {
|
||||
/// @see RsSerializable
|
||||
void serial_process(
|
||||
RsGenericSerializer::SerializeJob j,
|
||||
RsGenericSerializer::SerializeContext &ctx) override
|
||||
{
|
||||
RS_SERIAL_PROCESS(lobby_id);
|
||||
RS_SERIAL_PROCESS(lobby_name);
|
||||
RS_SERIAL_PROCESS(lobby_topic);
|
||||
@ -453,6 +475,8 @@ public:
|
||||
RS_SERIAL_PROCESS(last_report_time);
|
||||
RS_SERIAL_PROCESS(lobby_flags);
|
||||
}
|
||||
|
||||
~VisibleChatLobbyRecord() override;
|
||||
};
|
||||
|
||||
class ChatLobbyInfo : RsSerializable
|
||||
@ -499,13 +523,6 @@ class RsMsgs
|
||||
{
|
||||
public:
|
||||
|
||||
RsMsgs() {}
|
||||
virtual ~RsMsgs() = default;
|
||||
|
||||
/****************************************/
|
||||
/* Message Items */
|
||||
/****************************************/
|
||||
|
||||
/**
|
||||
* @brief getMessageSummaries
|
||||
* @jsonapi{development}
|
||||
@ -523,6 +540,33 @@ public:
|
||||
*/
|
||||
virtual bool getMessage(const std::string &msgId, Rs::Msgs::MessageInfo &msg) = 0;
|
||||
|
||||
/**
|
||||
* @brief sendMail
|
||||
* @jsonapi{development}
|
||||
* @param[in] from GXS id of the author
|
||||
* @param[in] subject Mail subject
|
||||
* @param[in] mailBody Mail body
|
||||
* @param[in] to list of To: recipients
|
||||
* @param[in] cc list of CC: recipients
|
||||
* @param[in] bcc list of BCC: recipients
|
||||
* @param[in] attachments list of suggested files
|
||||
* @param[out] trackingIds storage for tracking ids for each sent mail
|
||||
* @param[out] errorMsg error message if errors occurred, empty otherwise
|
||||
* @return number of successfully sent mails
|
||||
*/
|
||||
virtual uint32_t sendMail(
|
||||
const RsGxsId from,
|
||||
const std::string& subject,
|
||||
const std::string& mailBody,
|
||||
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<RsMailIdRecipientIdPair>& trackingIds =
|
||||
RS_DEFAULT_STORAGE_PARAM(std::set<RsMailIdRecipientIdPair>),
|
||||
std::string& errorMsg =
|
||||
RS_DEFAULT_STORAGE_PARAM(std::string) ) = 0;
|
||||
|
||||
/**
|
||||
* @brief getMessageCount
|
||||
* @jsonapi{development}
|
||||
@ -535,14 +579,6 @@ public:
|
||||
*/
|
||||
virtual void getMessageCount(uint32_t &nInbox, uint32_t &nInboxNew, uint32_t &nOutbox, uint32_t &nDraftbox, uint32_t &nSentbox, uint32_t &nTrashbox) = 0;
|
||||
|
||||
/**
|
||||
* @brief MessageSend
|
||||
* @jsonapi{development}
|
||||
* @param[in] info
|
||||
* @return always true
|
||||
*/
|
||||
virtual bool MessageSend(Rs::Msgs::MessageInfo &info) = 0;
|
||||
|
||||
/**
|
||||
* @brief SystemMessage
|
||||
* @jsonapi{development}
|
||||
@ -916,7 +952,14 @@ virtual bool initiateDistantChatConnexion(
|
||||
virtual bool getDistantChatStatus(const DistantChatPeerId& pid,DistantChatPeerInfo& info)=0;
|
||||
virtual bool closeDistantChatConnexion(const DistantChatPeerId& pid)=0;
|
||||
|
||||
/**
|
||||
* @brief MessageSend
|
||||
* @jsonapi{development}
|
||||
* @param[in] info
|
||||
* @return always true
|
||||
*/
|
||||
RS_DEPRECATED_FOR(sendMail)
|
||||
virtual bool MessageSend(Rs::Msgs::MessageInfo &info) = 0;
|
||||
|
||||
virtual ~RsMsgs();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -72,7 +72,6 @@ struct RsReputationInfo : RsSerializable
|
||||
mFriendsNegativeVotes(0),
|
||||
mFriendAverageScore(RS_REPUTATION_THRESHOLD_DEFAULT),
|
||||
mOverallReputationLevel(RsReputationLevel::NEUTRAL) {}
|
||||
virtual ~RsReputationInfo() {}
|
||||
|
||||
RsOpinion mOwnOpinion;
|
||||
|
||||
@ -94,6 +93,8 @@ struct RsReputationInfo : RsSerializable
|
||||
RS_SERIAL_PROCESS(mFriendAverageScore);
|
||||
RS_SERIAL_PROCESS(mOverallReputationLevel);
|
||||
}
|
||||
|
||||
virtual ~RsReputationInfo();
|
||||
};
|
||||
|
||||
|
||||
|
@ -399,11 +399,20 @@ struct FileChunksInfo : RsSerializable
|
||||
CHUNK_STRATEGY_PROGRESSIVE
|
||||
};
|
||||
|
||||
struct SliceInfo
|
||||
struct SliceInfo : RsSerializable
|
||||
{
|
||||
uint32_t start;
|
||||
uint32_t size;
|
||||
RsPeerId peer_id;
|
||||
|
||||
/// @see RsSerializable
|
||||
void serial_process(RsGenericSerializer::SerializeJob j,
|
||||
RsGenericSerializer::SerializeContext& ctx) override
|
||||
{
|
||||
RS_SERIAL_PROCESS(start);
|
||||
RS_SERIAL_PROCESS(size);
|
||||
RS_SERIAL_PROCESS(peer_id);
|
||||
}
|
||||
};
|
||||
|
||||
uint64_t file_size; /// real size of the file
|
||||
@ -432,7 +441,7 @@ struct FileChunksInfo : RsSerializable
|
||||
RS_SERIAL_PROCESS(chunks);
|
||||
RS_SERIAL_PROCESS(compressed_peer_availability_maps);
|
||||
RS_SERIAL_PROCESS(active_chunks);
|
||||
//RS_SERIAL_PROCESS(pending_slices);
|
||||
RS_SERIAL_PROCESS(pending_slices);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -3,7 +3,8 @@
|
||||
* *
|
||||
* libretroshare: retroshare core library *
|
||||
* *
|
||||
* Copyright 2004-2006 by Robert Fernie <retroshare@lunamutt.com> *
|
||||
* Copyright (C) 2004-2006 Robert Fernie <retroshare@lunamutt.com> *
|
||||
* Copyright (C) 2016-2019 Gioacchino Mazzurco <gio@eigenlab.org> *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
@ -20,6 +21,7 @@
|
||||
* *
|
||||
*******************************************************************************/
|
||||
#include <iostream>
|
||||
#include <tuple>
|
||||
|
||||
#include "util/rsdir.h"
|
||||
#include "util/rsdebug.h"
|
||||
@ -38,8 +40,7 @@
|
||||
|
||||
using namespace Rs::Msgs;
|
||||
|
||||
/* external reference point */
|
||||
RsMsgs *rsMsgs = NULL;
|
||||
/*extern*/ RsMsgs* rsMsgs = nullptr;
|
||||
|
||||
/****************************************/
|
||||
/****************************************/
|
||||
@ -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<RsMailIdRecipientIdPair>& 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 RsMailIdRecipientIdPair::serial_process(
|
||||
RsGenericSerializer::SerializeJob j,
|
||||
RsGenericSerializer::SerializeContext& ctx )
|
||||
{
|
||||
RS_SERIAL_PROCESS(mMailId);
|
||||
RS_SERIAL_PROCESS(mRecipientId);
|
||||
}
|
||||
|
||||
bool RsMailIdRecipientIdPair::operator<(const RsMailIdRecipientIdPair& o) const
|
||||
{
|
||||
return std::tie( mMailId, mRecipientId) <
|
||||
std::tie(o.mMailId, o.mRecipientId);
|
||||
}
|
||||
|
||||
bool RsMailIdRecipientIdPair::operator==(const RsMailIdRecipientIdPair& o) const
|
||||
{
|
||||
return std::tie( mMailId, mRecipientId) ==
|
||||
std::tie(o.mMailId, o.mRecipientId);
|
||||
}
|
||||
|
@ -3,7 +3,8 @@
|
||||
* *
|
||||
* libretroshare: retroshare core library *
|
||||
* *
|
||||
* Copyright 2007-2008 by Robert Fernie <retroshare@lunamutt.com> *
|
||||
* Copyright (C) 2007-2008 Robert Fernie <retroshare@lunamutt.com> *
|
||||
* Copyright (C) 2016-2019 Gioacchino Mazzurco <gio@eigenlab.org> *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
@ -19,8 +20,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 +38,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<RsMailIdRecipientIdPair>& trackingIds =
|
||||
RS_DEFAULT_STORAGE_PARAM(std::set<RsMailIdRecipientIdPair>),
|
||||
std::string& errorMsg =
|
||||
RS_DEFAULT_STORAGE_PARAM(std::string) ) override;
|
||||
|
||||
/****************************************/
|
||||
/* Message Items */
|
||||
@ -54,6 +68,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 +187,3 @@ class p3Msgs: public RsMsgs
|
||||
p3MsgService *mMsgSrv;
|
||||
p3ChatService *mChatSrv;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -2466,4 +2466,6 @@ void p3GxsChannels::cleanTimedOutCallbacks()
|
||||
} // RS_STACK_MUTEX(mDistantChannelsCallbacksMapMutex)
|
||||
}
|
||||
|
||||
RsGxsChannelGroup::~RsGxsChannelGroup() = default;
|
||||
RsGxsChannelPost::~RsGxsChannelPost() = default;
|
||||
RsGxsChannels::~RsGxsChannels() = default;
|
||||
|
@ -810,9 +810,15 @@ bool p3IdService::getOwnIds(std::list<RsGxsId> &ownIds,bool signed_only)
|
||||
return true ;
|
||||
}
|
||||
|
||||
bool p3IdService::isKnownId(const RsGxsId& id)
|
||||
{
|
||||
RS_STACK_MUTEX(mIdMtx);
|
||||
return mKeyCache.is_cached(id) ||
|
||||
std::find(mOwnIds.begin(), mOwnIds.end(),id) != mOwnIds.end();
|
||||
}
|
||||
|
||||
bool p3IdService::identityToBase64( const RsGxsId& id,
|
||||
std::string& base64String )
|
||||
std::string& base64String )
|
||||
{ return serialiseIdentityToMemory(id, base64String); }
|
||||
|
||||
bool p3IdService::serialiseIdentityToMemory( const RsGxsId& id,
|
||||
@ -4788,3 +4794,7 @@ RsIdentityUsage::RsIdentityUsage(
|
||||
RsIdentityUsage::RsIdentityUsage() :
|
||||
mServiceId(RsServiceType::NONE), mUsageCode(UNKNOWN_USAGE), mAdditionalId(0)
|
||||
{}
|
||||
|
||||
RsIdentity::~RsIdentity() = default;
|
||||
RsReputationInfo::~RsReputationInfo() = default;
|
||||
RsGixs::~RsGixs() = default;
|
||||
|
@ -293,12 +293,12 @@ public:
|
||||
/// @see RsIdentity
|
||||
bool getOwnPseudonimousIds(std::vector<RsGxsId>& ids) override;
|
||||
|
||||
virtual bool getOwnIds(std::list<RsGxsId> &ownIds, bool signed_only = false);
|
||||
bool getOwnIds(
|
||||
std::list<RsGxsId> &ownIds, bool signed_only = false ) override;
|
||||
|
||||
//virtual bool getPublicKey(const RsGxsId &id, RsTlvSecurityKey &key) ;
|
||||
//virtual void networkRequestPublicKey(const RsGxsId& key_id,const std::list<RsPeerId>& peer_ids) ;
|
||||
bool isKnownId(const RsGxsId& id) override;
|
||||
|
||||
virtual bool isOwnId(const RsGxsId& key_id) ;
|
||||
bool isOwnId(const RsGxsId& key_id) override;
|
||||
|
||||
virtual bool signData( const uint8_t* data,
|
||||
uint32_t data_size,
|
||||
@ -619,7 +619,7 @@ private:
|
||||
bool ownIdsAreLoaded() { RS_STACK_MUTEX(mIdMtx); return mOwnIdsLoaded; }
|
||||
|
||||
bool mAutoAddFriendsIdentitiesAsContacts;
|
||||
uint32_t mMaxKeepKeysBanned ;
|
||||
uint32_t mMaxKeepKeysBanned;
|
||||
|
||||
RS_SET_CONTEXT_DEBUG_LEVEL(1)
|
||||
};
|
||||
|
@ -3,7 +3,8 @@
|
||||
* *
|
||||
* libretroshare: retroshare core library *
|
||||
* *
|
||||
* Copyright 2004-2008 Robert Fernie <retroshare@lunamutt.com> *
|
||||
* Copyright (C) 2004-2008 Robert Fernie <retroshare@lunamutt.com> *
|
||||
* Copyright (C) 2016-2019 Gioacchino Mazzurco <gio@eigenlab.org> *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
@ -55,19 +56,10 @@
|
||||
#include <map>
|
||||
#include <sstream>
|
||||
|
||||
//#define MSG_DEBUG 1
|
||||
//#define DEBUG_DISTANT_MSG
|
||||
//#define DISABLE_DISTANT_MESSAGES
|
||||
//#define DEBUG_DISTANT_MSG
|
||||
|
||||
typedef unsigned int uint;
|
||||
|
||||
using namespace Rs::Msgs;
|
||||
|
||||
static struct RsLog::logInfo msgservicezoneInfo = {RsLog::Default, "msgservice"};
|
||||
#define msgservicezone &msgservicezoneInfo
|
||||
|
||||
static const uint32_t RS_MSG_DISTANT_MESSAGE_HASH_KEEP_TIME = 2*30*86400 ; // keep msg hashes for 2 months to avoid re-sent msgs
|
||||
/// keep msg hashes for 2 months to avoid re-sent msgs
|
||||
static constexpr uint32_t RS_MSG_DISTANT_MESSAGE_HASH_KEEP_TIME = 2*30*86400;
|
||||
|
||||
/* Another little hack ..... unique message Ids
|
||||
* will be handled in this class.....
|
||||
@ -128,11 +120,8 @@ uint32_t p3MsgService::getNewUniqueMsgId()
|
||||
return mMsgUniqueId++;
|
||||
}
|
||||
|
||||
int p3MsgService::tick()
|
||||
int p3MsgService::tick()
|
||||
{
|
||||
pqioutput(PQL_DEBUG_BASIC, msgservicezone,
|
||||
"p3MsgService::tick()");
|
||||
|
||||
/* don't worry about increasing tick rate!
|
||||
* (handled by p3service)
|
||||
*/
|
||||
@ -158,7 +147,7 @@ void p3MsgService::cleanListOfReceivedMessageHashes()
|
||||
{
|
||||
RS_STACK_MUTEX(recentlyReceivedMutex);
|
||||
|
||||
rstime_t now = time(NULL);
|
||||
rstime_t now = time(nullptr);
|
||||
|
||||
for( auto it = mRecentlyReceivedMessageHashes.begin();
|
||||
it != mRecentlyReceivedMessageHashes.end(); )
|
||||
@ -173,21 +162,13 @@ void p3MsgService::cleanListOfReceivedMessageHashes()
|
||||
else ++it;
|
||||
}
|
||||
|
||||
int p3MsgService::status()
|
||||
{
|
||||
pqioutput(PQL_DEBUG_BASIC, msgservicezone,
|
||||
"p3MsgService::status()");
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
void p3MsgService::processIncomingMsg(RsMsgItem *mi)
|
||||
{
|
||||
mi -> recvTime = time(NULL);
|
||||
mi -> recvTime = static_cast<uint32_t>(time(nullptr));
|
||||
mi -> msgId = getNewUniqueMsgId();
|
||||
|
||||
{
|
||||
RsStackMutex stack(mMsgMtx); /*** STACK LOCKED MTX ***/
|
||||
RS_STACK_MUTEX(mMsgMtx);
|
||||
|
||||
/* from a peer */
|
||||
|
||||
@ -226,6 +207,13 @@ void p3MsgService::processIncomingMsg(RsMsgItem *mi)
|
||||
}
|
||||
|
||||
RsServer::notify()->notifyListChange(NOTIFY_LIST_MESSAGELIST,NOTIFY_TYPE_ADD);
|
||||
|
||||
if(rsEvents)
|
||||
{
|
||||
std::shared_ptr<RsMailStatusEvent> pEvent(new RsMailStatusEvent());
|
||||
pEvent->mChangedMsgIds.insert(std::to_string(mi->msgId));
|
||||
rsEvents->postEvent(pEvent);
|
||||
}
|
||||
}
|
||||
|
||||
bool p3MsgService::checkAndRebuildPartialMessage(RsMsgItem *ci)
|
||||
@ -289,7 +277,8 @@ void p3MsgService::handleIncomingItem(RsMsgItem *mi)
|
||||
{
|
||||
bool changed = false ;
|
||||
|
||||
if(checkAndRebuildPartialMessage(mi)) // only returns true when a msg is complete.
|
||||
// only returns true when a msg is complete.
|
||||
if(checkAndRebuildPartialMessage(mi))
|
||||
{
|
||||
processIncomingMsg(mi);
|
||||
changed = true ;
|
||||
@ -356,6 +345,9 @@ int p3MsgService::checkOutgoingMessages()
|
||||
bool changed = false;
|
||||
std::list<RsMsgItem*> output_queue;
|
||||
|
||||
using Evt_t = RsMailStatusEvent;
|
||||
std::shared_ptr<Evt_t> pEvent(new Evt_t());
|
||||
|
||||
{
|
||||
RS_STACK_MUTEX(mMsgMtx); /********** STACK LOCKED MTX ******/
|
||||
|
||||
@ -386,12 +378,12 @@ int p3MsgService::checkOutgoingMessages()
|
||||
|
||||
if(should_send)
|
||||
{
|
||||
/* send msg */
|
||||
pqioutput( PQL_DEBUG_BASIC, msgservicezone,
|
||||
"p3MsgService::checkOutGoingMessages() Sending out message");
|
||||
Dbg3() << __PRETTY_FUNCTION__ << " Sending out message"
|
||||
<< std::endl;
|
||||
/* remove the pending flag */
|
||||
|
||||
output_queue.push_back(mit->second) ;
|
||||
output_queue.push_back(mit->second);
|
||||
pEvent->mChangedMsgIds.insert(std::to_string(mit->first));
|
||||
|
||||
/* When the message is a distant msg, dont remove it yet from
|
||||
* the list. Only mark it as being sent, so that we don't send
|
||||
@ -414,8 +406,8 @@ int p3MsgService::checkOutgoingMessages()
|
||||
}
|
||||
else
|
||||
{
|
||||
pqioutput( PQL_DEBUG_BASIC, msgservicezone,
|
||||
"p3MsgService::checkOutGoingMessages() Delaying until available...");
|
||||
Dbg3() << __PRETTY_FUNCTION__ << " Delaying until available..."
|
||||
<< std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
@ -446,6 +438,9 @@ int p3MsgService::checkOutgoingMessages()
|
||||
if(changed)
|
||||
RsServer::notify()->notifyListChange(NOTIFY_LIST_MESSAGELIST,NOTIFY_TYPE_MOD);
|
||||
|
||||
if(rsEvents && !pEvent->mChangedMsgIds.empty())
|
||||
rsEvents->postEvent(pEvent);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -911,6 +906,8 @@ bool p3MsgService::removeMsgId(const std::string &mid)
|
||||
}
|
||||
|
||||
bool changed = false;
|
||||
using Evt_t = RsMailStatusEvent;
|
||||
std::shared_ptr<Evt_t> pEvent(new Evt_t());
|
||||
|
||||
{
|
||||
RsStackMutex stack(mMsgMtx); /********** STACK LOCKED MTX ******/
|
||||
@ -922,6 +919,7 @@ bool p3MsgService::removeMsgId(const std::string &mid)
|
||||
RsMsgItem *mi = mit->second;
|
||||
imsg.erase(mit);
|
||||
delete mi;
|
||||
pEvent->mChangedMsgIds.insert(mid);
|
||||
}
|
||||
|
||||
mit = msgOutgoing.find(msgId);
|
||||
@ -931,6 +929,7 @@ bool p3MsgService::removeMsgId(const std::string &mid)
|
||||
RsMsgItem *mi = mit->second;
|
||||
msgOutgoing.erase(mit);
|
||||
delete mi;
|
||||
pEvent->mChangedMsgIds.insert(mid);
|
||||
}
|
||||
|
||||
std::map<uint32_t, RsMsgSrcId*>::iterator srcIt = mSrcIds.find(msgId);
|
||||
@ -938,6 +937,7 @@ bool p3MsgService::removeMsgId(const std::string &mid)
|
||||
changed = true;
|
||||
delete (srcIt->second);
|
||||
mSrcIds.erase(srcIt);
|
||||
pEvent->mChangedMsgIds.insert(mid);
|
||||
}
|
||||
}
|
||||
|
||||
@ -950,6 +950,9 @@ bool p3MsgService::removeMsgId(const std::string &mid)
|
||||
RsServer::notify()->notifyListChange(NOTIFY_LIST_MESSAGELIST,NOTIFY_TYPE_MOD);
|
||||
}
|
||||
|
||||
if(rsEvents && !pEvent->mChangedMsgIds.empty())
|
||||
rsEvents->postEvent(pEvent);
|
||||
|
||||
return changed;
|
||||
}
|
||||
|
||||
@ -1095,12 +1098,14 @@ bool p3MsgService::setMsgParentId(uint32_t msgId, uint32_t msgParentId)
|
||||
/****************************************/
|
||||
/****************************************/
|
||||
/* Message Items */
|
||||
uint32_t p3MsgService::sendMessage(RsMsgItem *item) // no from field because it's implicitly our own PeerId
|
||||
// no from field because it's implicitly our own PeerId
|
||||
uint32_t p3MsgService::sendMessage(RsMsgItem* item)
|
||||
{
|
||||
if(!item)
|
||||
return 0 ;
|
||||
|
||||
pqioutput(PQL_DEBUG_BASIC, msgservicezone, "p3MsgService::sendMessage()");
|
||||
if(!item)
|
||||
{
|
||||
RsErr() << __PRETTY_FUNCTION__ << " item can't be null" << std::endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
item->msgId = getNewUniqueMsgId(); /* grabs Mtx as well */
|
||||
item->msgFlags |= (RS_MSG_FLAGS_OUTGOING | RS_MSG_FLAGS_PENDING); /* add pending flag */
|
||||
@ -1131,7 +1136,12 @@ uint32_t p3MsgService::sendMessage(RsMsgItem *item) // no from field because
|
||||
|
||||
uint32_t p3MsgService::sendDistantMessage(RsMsgItem *item, const RsGxsId& from)
|
||||
{
|
||||
if(!item) return 0;
|
||||
if(!item)
|
||||
{
|
||||
RsErr() << __PRETTY_FUNCTION__ << " item can't be null" << std::endl;
|
||||
print_stacktrace();
|
||||
return 0;
|
||||
}
|
||||
|
||||
item->msgId = getNewUniqueMsgId(); /* grabs Mtx as well */
|
||||
item->msgFlags |= ( RS_MSG_FLAGS_DISTANT | RS_MSG_FLAGS_OUTGOING |
|
||||
@ -1178,8 +1188,6 @@ bool p3MsgService::MessageSend(MessageInfo &info)
|
||||
|
||||
if (msg)
|
||||
{
|
||||
std::list<RsPgpId>::iterator it ;
|
||||
|
||||
if (msg->msgFlags & RS_MSG_FLAGS_SIGNED)
|
||||
msg->msgFlags |= RS_MSG_FLAGS_SIGNATURE_CHECKS; // this is always true, since we are sending the message
|
||||
|
||||
@ -1192,14 +1200,125 @@ bool p3MsgService::MessageSend(MessageInfo &info)
|
||||
imsg[msg->msgId] = msg;
|
||||
|
||||
RsServer::notify()->notifyListChange(NOTIFY_LIST_MESSAGELIST,NOTIFY_TYPE_ADD);
|
||||
//
|
||||
// // return new message id
|
||||
// rs_sprintf(info.msgId, "%lu", msg->msgId);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
uint32_t p3MsgService::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<RsMailIdRecipientIdPair>& trackingIds,
|
||||
std::string& errorMsg )
|
||||
{
|
||||
errorMsg.clear();
|
||||
const std::string fname = __PRETTY_FUNCTION__;
|
||||
auto pCheck = [&](bool test, const std::string& errMsg)
|
||||
{
|
||||
if(!test)
|
||||
{
|
||||
errorMsg = errMsg;
|
||||
RsErr() << fname << " " << errMsg << std::endl;
|
||||
}
|
||||
return test;
|
||||
};
|
||||
|
||||
if(!pCheck(!from.isNull(), "from can't be null")) return false;
|
||||
if(!pCheck( rsIdentity->isOwnId(from),
|
||||
"from must be own identity") ) return false;
|
||||
if(!pCheck(!(to.empty() && cc.empty() && bcc.empty()),
|
||||
"You must specify at least one recipient" )) return false;
|
||||
|
||||
auto dstCheck =
|
||||
[&](const std::set<RsGxsId>& dstSet, const std::string& setName)
|
||||
{
|
||||
for(const RsGxsId& dst: dstSet)
|
||||
{
|
||||
if(dst.isNull())
|
||||
{
|
||||
errorMsg = setName + " contains a null recipient";
|
||||
RsErr() << fname << " " << errorMsg << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!rsIdentity->isKnownId(dst))
|
||||
{
|
||||
rsIdentity->requestIdentity(dst);
|
||||
errorMsg = setName + " contains an unknown recipient: " +
|
||||
dst.toStdString();
|
||||
RsErr() << fname << " " << errorMsg << std::endl;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
if(!dstCheck(to, "to")) return false;
|
||||
if(!dstCheck(cc, "cc")) return false;
|
||||
if(!dstCheck(bcc, "bcc")) return false;
|
||||
|
||||
MessageInfo msgInfo;
|
||||
|
||||
msgInfo.rsgxsid_srcId = from;
|
||||
msgInfo.title = subject;
|
||||
msgInfo.msg = body;
|
||||
msgInfo.rsgxsid_msgto = to;
|
||||
msgInfo.rsgxsid_msgcc = cc;
|
||||
msgInfo.rsgxsid_msgbcc = bcc;
|
||||
std::copy( attachments.begin(), attachments.end(),
|
||||
std::back_inserter(msgInfo.files) );
|
||||
|
||||
uint32_t ret = 0;
|
||||
using Evt_t = RsMailStatusEvent;
|
||||
std::shared_ptr<Evt_t> pEvent(new Evt_t());
|
||||
|
||||
auto pSend = [&](const std::set<RsGxsId>& sDest)
|
||||
{
|
||||
for(const RsGxsId& dst : sDest)
|
||||
{
|
||||
RsMsgItem* msgItem = initMIRsMsg(msgInfo, dst);
|
||||
if(!msgItem)
|
||||
{
|
||||
errorMsg += " initMIRsMsg from: " + from.toStdString()
|
||||
+ " dst: " + dst.toStdString() + " subject: " + subject
|
||||
+ " returned nullptr!\n";
|
||||
RsErr() << fname << errorMsg;
|
||||
continue;
|
||||
}
|
||||
|
||||
uint32_t msgId = sendDistantMessage(msgItem, from);
|
||||
// ensure we don't use that ptr again without noticing
|
||||
msgItem = nullptr;
|
||||
|
||||
if(!msgId)
|
||||
{
|
||||
errorMsg += " sendDistantMessage from: " + from.toStdString()
|
||||
+ " dst: " + dst.toStdString() + " subject: " + subject
|
||||
+ " returned 0!\n";
|
||||
RsErr() << fname << errorMsg;
|
||||
continue;
|
||||
}
|
||||
|
||||
const RsMailMessageId mailId = std::to_string(msgId);
|
||||
pEvent->mChangedMsgIds.insert(mailId);
|
||||
trackingIds.insert(RsMailIdRecipientIdPair(mailId, dst));
|
||||
++ret;
|
||||
}
|
||||
};
|
||||
|
||||
pSend(to);
|
||||
pSend(cc);
|
||||
pSend(bcc);
|
||||
|
||||
if(rsEvents) rsEvents->postEvent(pEvent);
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool p3MsgService::SystemMessage(const std::string &title, const std::string &message, uint32_t systemFlag)
|
||||
{
|
||||
if ((systemFlag & RS_MSG_SYSTEM) == 0) {
|
||||
@ -1890,20 +2009,21 @@ void p3MsgService::notifyDataStatus( const GRouterMsgPropagationId& id,
|
||||
{
|
||||
RS_STACK_MUTEX(mMsgMtx);
|
||||
|
||||
std::cerr << "(WW) p3MsgService::notifyDataStatus: Global router tells "
|
||||
<< "us that item ID " << id
|
||||
<< " could not be delivered on time.";
|
||||
|
||||
auto it = _ongoing_messages.find(id);
|
||||
if(it == _ongoing_messages.end())
|
||||
{
|
||||
std::cerr << " (EE) cannot find pending message to acknowledge. "
|
||||
<< "Weird. grouter id = " << id << std::endl;
|
||||
RsErr() << __PRETTY_FUNCTION__
|
||||
<< " cannot find pending message to acknowledge. "
|
||||
<< "Weird. grouter id: " << id << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
uint32_t msg_id = it->second;
|
||||
std::cerr << " message id = " << msg_id << std::endl;
|
||||
|
||||
RsWarn() << __PRETTY_FUNCTION__ << " Global router tells "
|
||||
<< "us that item ID " << id
|
||||
<< " could not be delivered on time. Message id: "
|
||||
<< msg_id << std::endl;
|
||||
|
||||
/* this is needed because it's not saved in config, but we should
|
||||
* probably include it in _ongoing_messages */
|
||||
@ -1912,10 +2032,10 @@ void p3MsgService::notifyDataStatus( const GRouterMsgPropagationId& id,
|
||||
std::map<uint32_t,RsMsgItem*>::iterator mit = msgOutgoing.find(msg_id);
|
||||
if(mit == msgOutgoing.end())
|
||||
{
|
||||
std::cerr << " (II) message has been notified as not delivered, "
|
||||
<< "but it's not in outgoing list. Probably it has been "
|
||||
<< "delivered successfully by other means."
|
||||
<< std::endl;
|
||||
RsInfo() << __PRETTY_FUNCTION__
|
||||
<< " message has been notified as not delivered, "
|
||||
<< "but it's not in outgoing list. Probably it has been "
|
||||
<< "delivered successfully by other means." << std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1925,6 +2045,7 @@ void p3MsgService::notifyDataStatus( const GRouterMsgPropagationId& id,
|
||||
// clear the routed flag so that the message is requested again
|
||||
mit->second->msgFlags &= ~RS_MSG_FLAGS_ROUTED;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1954,17 +2075,31 @@ void p3MsgService::notifyDataStatus( const GRouterMsgPropagationId& id,
|
||||
return;
|
||||
}
|
||||
|
||||
#if 0
|
||||
delete it2->second;
|
||||
msgOutgoing.erase(it2);
|
||||
#else
|
||||
// Do not delete it move to sent folder instead!
|
||||
it2->second->msgFlags &= ~RS_MSG_FLAGS_PENDING;
|
||||
imsg[msg_id] = it2->second;
|
||||
msgOutgoing.erase(it2);
|
||||
#endif
|
||||
|
||||
RsServer::notify()->notifyListChange( NOTIFY_LIST_MESSAGELIST,
|
||||
NOTIFY_TYPE_ADD );
|
||||
IndicateConfigChanged();
|
||||
|
||||
using Evt_t = RsMailStatusEvent;
|
||||
std::shared_ptr<Evt_t> pEvent(new Evt_t());
|
||||
pEvent->mChangedMsgIds.insert(std::to_string(msg_id));
|
||||
if(rsEvents) rsEvents->postEvent(pEvent);
|
||||
|
||||
return;
|
||||
}
|
||||
std::cerr << "p3MsgService: unhandled data status info from global router"
|
||||
<< " for msg ID " << id << ": this is a bug." << std::endl;
|
||||
|
||||
RsErr() << __PRETTY_FUNCTION__
|
||||
<< " unhandled data status info from global router"
|
||||
<< " for msg ID " << id << ": this is a bug." << std::endl;
|
||||
}
|
||||
|
||||
bool p3MsgService::acceptDataFromPeer(const RsGxsId& to_gxs_id)
|
||||
@ -1997,8 +2132,8 @@ bool p3MsgService::receiveGxsTransMail( const RsGxsId& authorId,
|
||||
const RsGxsId& recipientId,
|
||||
const uint8_t* data, uint32_t dataSize )
|
||||
{
|
||||
std::cout << __PRETTY_FUNCTION__ << " " << authorId << ", " << recipientId
|
||||
<< ",, " << dataSize << std::endl;
|
||||
Dbg2() << __PRETTY_FUNCTION__ << " " << authorId << ", " << recipientId
|
||||
<< ",, " << dataSize << std::endl;
|
||||
|
||||
Sha1CheckSum hash = RsDirUtil::sha1sum(data, dataSize);
|
||||
|
||||
@ -2007,29 +2142,31 @@ bool p3MsgService::receiveGxsTransMail( const RsGxsId& authorId,
|
||||
if( mRecentlyReceivedMessageHashes.find(hash) !=
|
||||
mRecentlyReceivedMessageHashes.end() )
|
||||
{
|
||||
std::cerr << __PRETTY_FUNCTION__ << " (II) receiving "
|
||||
RsInfo() << __PRETTY_FUNCTION__ << " (II) receiving "
|
||||
<< "message of hash " << hash << " more than once. "
|
||||
<< "Probably it has arrived before by other means."
|
||||
<< std::endl;
|
||||
return true;
|
||||
}
|
||||
mRecentlyReceivedMessageHashes[hash] = time(NULL);
|
||||
mRecentlyReceivedMessageHashes[hash] =
|
||||
static_cast<uint32_t>(time(nullptr));
|
||||
}
|
||||
|
||||
IndicateConfigChanged();
|
||||
|
||||
RsItem *item = _serialiser->deserialise(const_cast<uint8_t*>(data), &dataSize);
|
||||
RsItem *item = _serialiser->deserialise(
|
||||
const_cast<uint8_t*>(data), &dataSize );
|
||||
RsMsgItem *msg_item = dynamic_cast<RsMsgItem*>(item);
|
||||
|
||||
if(msg_item)
|
||||
{
|
||||
std::cerr << __PRETTY_FUNCTION__ << " Encrypted item correctly "
|
||||
<< "deserialised. Passing on to incoming list."
|
||||
<< std::endl;
|
||||
Dbg3() << __PRETTY_FUNCTION__ << " Encrypted item correctly "
|
||||
<< "deserialised. Passing on to incoming list."
|
||||
<< std::endl;
|
||||
|
||||
msg_item->msgFlags |= RS_MSG_FLAGS_DISTANT;
|
||||
/* we expect complete msgs - remove partial flag just in case
|
||||
* someone has funny ideas */
|
||||
* someone has funny ideas */
|
||||
msg_item->msgFlags &= ~RS_MSG_FLAGS_PARTIAL;
|
||||
|
||||
// hack to pass on GXS id.
|
||||
@ -2038,8 +2175,8 @@ bool p3MsgService::receiveGxsTransMail( const RsGxsId& authorId,
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << __PRETTY_FUNCTION__ << " Item could not be "
|
||||
<< "deserialised. Format error??" << std::endl;
|
||||
RsWarn() << __PRETTY_FUNCTION__ << " Item could not be "
|
||||
<< "deserialised. Format error?" << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -2049,8 +2186,11 @@ bool p3MsgService::receiveGxsTransMail( const RsGxsId& authorId,
|
||||
bool p3MsgService::notifyGxsTransSendStatus( RsGxsTransId mailId,
|
||||
GxsTransSendStatus status )
|
||||
{
|
||||
std::cout << __PRETTY_FUNCTION__ << " " << mailId << ", "
|
||||
<< static_cast<uint>(status) << std::endl;
|
||||
Dbg2() << __PRETTY_FUNCTION__ << " " << mailId << ", "
|
||||
<< static_cast<uint32_t>(status) << std::endl;
|
||||
|
||||
using Evt_t = RsMailStatusEvent;
|
||||
std::shared_ptr<Evt_t> pEvent(new Evt_t());
|
||||
|
||||
if( status == GxsTransSendStatus::RECEIPT_RECEIVED )
|
||||
{
|
||||
@ -2062,11 +2202,10 @@ bool p3MsgService::notifyGxsTransSendStatus( RsGxsTransId mailId,
|
||||
auto it = gxsOngoingMessages.find(mailId);
|
||||
if(it == gxsOngoingMessages.end())
|
||||
{
|
||||
std::cerr << __PRETTY_FUNCTION__<< " "
|
||||
<< mailId
|
||||
<< ", " << static_cast<uint>(status)
|
||||
<< " (EE) cannot find pending message to acknowledge!"
|
||||
<< std::endl;
|
||||
RsErr() << __PRETTY_FUNCTION__<< " " << mailId << ", "
|
||||
<< static_cast<uint32_t>(status)
|
||||
<< " cannot find pending message to acknowledge!"
|
||||
<< std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -2081,26 +2220,32 @@ bool p3MsgService::notifyGxsTransSendStatus( RsGxsTransId mailId,
|
||||
auto it2 = msgOutgoing.find(msg_id);
|
||||
if(it2 == msgOutgoing.end())
|
||||
{
|
||||
std::cerr << __PRETTY_FUNCTION__ << " " << mailId
|
||||
<< ", " << static_cast<uint>(status) << " (II) "
|
||||
<< "received receipt for message that is not in "
|
||||
<< "outgoing list, probably it has been acknoweldged "
|
||||
<< "before by other means." << std::endl;
|
||||
return true;
|
||||
RsInfo() << __PRETTY_FUNCTION__ << " " << mailId
|
||||
<< ", " << static_cast<uint32_t>(status)
|
||||
<< " received receipt for message that is not in "
|
||||
<< "outgoing list, probably it has been acknoweldged "
|
||||
<< "before by other means." << std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
#if 0
|
||||
delete it2->second;
|
||||
msgOutgoing.erase(it2);
|
||||
#else
|
||||
// Do not delete it move to sent folder instead!
|
||||
it2->second->msgFlags &= ~RS_MSG_FLAGS_PENDING;
|
||||
imsg[msg_id] = it2->second;
|
||||
msgOutgoing.erase(it2);
|
||||
#endif
|
||||
pEvent->mChangedMsgIds.insert(std::to_string(msg_id));
|
||||
}
|
||||
|
||||
delete it2->second;
|
||||
msgOutgoing.erase(it2);
|
||||
}
|
||||
|
||||
RsServer::notify()->notifyListChange( NOTIFY_LIST_MESSAGELIST,
|
||||
NOTIFY_TYPE_ADD );
|
||||
IndicateConfigChanged();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if( status >= GxsTransSendStatus::FAILED_RECEIPT_SIGNATURE )
|
||||
else if( status >= GxsTransSendStatus::FAILED_RECEIPT_SIGNATURE )
|
||||
{
|
||||
uint32_t msg_id;
|
||||
|
||||
@ -2132,17 +2277,22 @@ bool p3MsgService::notifyGxsTransSendStatus( RsGxsTransId mailId,
|
||||
std::cerr << " message has been notified as not delivered, "
|
||||
<< "but it not on outgoing list."
|
||||
<< std::endl;
|
||||
return true;
|
||||
}
|
||||
std::cerr << " reseting the ROUTED flag so that the message is "
|
||||
<< "requested again" << std::endl;
|
||||
else
|
||||
{
|
||||
std::cerr << " reseting the ROUTED flag so that the message is "
|
||||
<< "requested again" << std::endl;
|
||||
// clear the routed flag so that the message is requested again
|
||||
mit->second->msgFlags &= ~RS_MSG_FLAGS_ROUTED;
|
||||
|
||||
// clear the routed flag so that the message is requested again
|
||||
mit->second->msgFlags &= ~RS_MSG_FLAGS_ROUTED;
|
||||
return true;
|
||||
pEvent->mChangedMsgIds.insert(std::to_string(msg_id));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(rsEvents && !pEvent->mChangedMsgIds.empty())
|
||||
rsEvents->postEvent(pEvent);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -37,7 +37,7 @@
|
||||
#include "services/p3service.h"
|
||||
#include "rsitems/rsmsgitems.h"
|
||||
#include "util/rsthreads.h"
|
||||
|
||||
#include "util/rsdebug.h"
|
||||
#include "retroshare/rsgxsifacetypes.h"
|
||||
|
||||
#include "grouter/p3grouter.h"
|
||||
@ -59,6 +59,19 @@ public:
|
||||
|
||||
virtual RsServiceInfo getServiceInfo();
|
||||
|
||||
/// @see RsMsgs::sendMail
|
||||
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<RsMailIdRecipientIdPair>& trackingIds =
|
||||
RS_DEFAULT_STORAGE_PARAM(std::set<RsMailIdRecipientIdPair>),
|
||||
std::string& errorMsg =
|
||||
RS_DEFAULT_STORAGE_PARAM(std::string) );
|
||||
|
||||
/* External Interface */
|
||||
bool getMessageSummaries(std::list<Rs::Msgs::MsgInfoSummary> &msgList);
|
||||
bool getMessage(const std::string &mid, Rs::Msgs::MessageInfo &msg);
|
||||
@ -72,6 +85,7 @@ public:
|
||||
// msgParentId == 0 --> remove
|
||||
bool setMsgParentId(uint32_t msgId, uint32_t msgParentId);
|
||||
|
||||
RS_DEPRECATED_FOR(sendMail)
|
||||
bool MessageSend(Rs::Msgs::MessageInfo &info);
|
||||
bool SystemMessage(const std::string &title, const std::string &message, uint32_t systemFlag);
|
||||
bool MessageToDraft(Rs::Msgs::MessageInfo &info, const std::string &msgParentId);
|
||||
@ -94,7 +108,6 @@ public:
|
||||
//std::list<RsMsgItem *> &getMsgOutList();
|
||||
|
||||
int tick();
|
||||
int status();
|
||||
|
||||
/*** Overloaded from p3Config ****/
|
||||
virtual RsSerialiser *setupSerialiser();
|
||||
@ -227,6 +240,8 @@ private:
|
||||
bool mShouldEnableDistantMessaging ;
|
||||
|
||||
p3GxsTrans& mGxsTransServ;
|
||||
|
||||
RS_SET_CONTEXT_DEBUG_LEVEL(3)
|
||||
};
|
||||
|
||||
#endif // MESSAGE_SERVICE_HEADER
|
||||
|
Loading…
Reference in New Issue
Block a user