fixed serialisation error (missing call) for received Distant msg hash map

This commit is contained in:
csoler 2016-01-09 10:58:49 -05:00
parent fe02167ad7
commit ee84ab732d
3 changed files with 167 additions and 161 deletions

View File

@ -1023,12 +1023,14 @@ RsMsgDistantMessagesHashMap* RsMsgSerialiser::deserialiseMsgDistantMessageHashMa
if (offset != rssize) if (offset != rssize)
{ {
/* error */ /* error */
std::cerr << "(EE) size error in packet deserialisation: p3MsgItem, subtype " << getRsItemSubType(rstype) << ". offset=" << offset << " != rssize=" << rssize << std::endl;
delete item; delete item;
return NULL; return NULL;
} }
if (!ok) if (!ok)
{ {
std::cerr << "(EE) size error in packet deserialisation: p3MsgItem, subtype " << getRsItemSubType(rstype) << std::endl;
delete item; delete item;
return NULL; return NULL;
} }
@ -1177,27 +1179,14 @@ RsItem* RsMsgSerialiser::deserialise(void *data, uint32_t *pktsize)
switch(getRsItemSubType(rstype)) switch(getRsItemSubType(rstype))
{ {
case RS_PKT_SUBTYPE_DEFAULT: case RS_PKT_SUBTYPE_DEFAULT: return deserialiseMsgItem(data, pktsize);
return deserialiseMsgItem(data, pktsize); case RS_PKT_SUBTYPE_MSG_SRC_TAG: return deserialiseMsgSrcIdItem(data, pktsize);
break; case RS_PKT_SUBTYPE_MSG_PARENT_TAG: return deserialiseMsgParentIdItem(data, pktsize);
case RS_PKT_SUBTYPE_MSG_SRC_TAG: case RS_PKT_SUBTYPE_MSG_TAG_TYPE: return deserialiseTagItem(data, pktsize);
return deserialiseMsgSrcIdItem(data, pktsize); case RS_PKT_SUBTYPE_MSG_INVITE: return deserialisePublicMsgInviteConfigItem(data, pktsize);
break; case RS_PKT_SUBTYPE_MSG_TAGS: return deserialiseMsgTagItem(data, pktsize);
case RS_PKT_SUBTYPE_MSG_PARENT_TAG: case RS_PKT_SUBTYPE_MSG_GROUTER_MAP: return deserialiseMsgGRouterMap(data, pktsize);
return deserialiseMsgParentIdItem(data, pktsize); case RS_PKT_SUBTYPE_MSG_DISTANT_MSG_MAP: return deserialiseMsgDistantMessageHashMap(data, pktsize);
break;
case RS_PKT_SUBTYPE_MSG_TAG_TYPE:
return deserialiseTagItem(data, pktsize);
break;
case RS_PKT_SUBTYPE_MSG_INVITE:
return deserialisePublicMsgInviteConfigItem(data, pktsize);
break;
case RS_PKT_SUBTYPE_MSG_TAGS:
return deserialiseMsgTagItem(data, pktsize);
break;
case RS_PKT_SUBTYPE_MSG_GROUTER_MAP:
return deserialiseMsgGRouterMap(data, pktsize);
break;
default: default:
return NULL; return NULL;
break; break;

View File

@ -51,7 +51,9 @@
#include "util/rsstring.h" #include "util/rsstring.h"
#include "util/radix64.h" #include "util/radix64.h"
#include "util/rsrandom.h" #include "util/rsrandom.h"
#include "util/rsmemory.h"
#include "util/rsprint.h" #include "util/rsprint.h"
#include "util/rsthreads.h"
#include <unistd.h> #include <unistd.h>
#include <iomanip> #include <iomanip>
@ -67,6 +69,8 @@ using namespace Rs::Msgs;
const int msgservicezone = 54319; const int msgservicezone = 54319;
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
/* Another little hack ..... unique message Ids /* Another little hack ..... unique message Ids
* will be handled in this class..... * will be handled in this class.....
* These are unique within this run of the server, * These are unique within this run of the server,
@ -78,23 +82,22 @@ const int msgservicezone = 54319;
* (3) from storage... * (3) from storage...
*/ */
p3MsgService::p3MsgService(p3ServiceControl *sc, p3IdService *id_serv) p3MsgService::p3MsgService(p3ServiceControl *sc, p3IdService *id_serv)
:p3Service(), p3Config(), mIdService(id_serv), mServiceCtrl(sc), mMsgMtx("p3MsgService"), mMsgUniqueId(0) :p3Service(), p3Config(), mIdService(id_serv), mServiceCtrl(sc), mMsgMtx("p3MsgService"), mMsgUniqueId(0)
{ {
_serialiser = new RsMsgSerialiser(); // this serialiser is used for services. It's not the same than the one returned by setupSerialiser(). We need both!! _serialiser = new RsMsgSerialiser(); // this serialiser is used for services. It's not the same than the one returned by setupSerialiser(). We need both!!
addSerialType(_serialiser); addSerialType(_serialiser);
mMsgUniqueId = RSRandom::random_u32() ; // better than time(NULL). We don't need crypto-safe random here. Just something much likely mMsgUniqueId = 1 ; // MsgIds are not transmitted, but only used locally as a storage index. As such, thay do not need to be different
// different from what friends use. // at friends nodes.
mShouldEnableDistantMessaging = true ; mShouldEnableDistantMessaging = true ;
mDistantMessagingEnabled = false ; mDistantMessagingEnabled = false ;
mDistantMessagePermissions = RS_DISTANT_MESSAGING_CONTACT_PERMISSION_FLAG_FILTER_NONE ; mDistantMessagePermissions = RS_DISTANT_MESSAGING_CONTACT_PERMISSION_FLAG_FILTER_NONE ;
/* Initialize standard tag types */ /* Initialize standard tag types */
if(sc) if(sc)
initStandardTagTypes(); initStandardTagTypes();
} }
@ -117,7 +120,7 @@ RsServiceInfo p3MsgService::getServiceInfo()
uint32_t p3MsgService::getNewUniqueMsgId() uint32_t p3MsgService::getNewUniqueMsgId()
{ {
RsStackMutex stack(mMsgMtx); /********** STACK LOCKED MTX ******/ RS_STACK_MUTEX(mMsgMtx); /********** STACK LOCKED MTX ******/
return mMsgUniqueId++; return mMsgUniqueId++;
} }
@ -139,6 +142,7 @@ int p3MsgService::tick()
{ {
manageDistantPeers() ; manageDistantPeers() ;
checkOutgoingMessages(); checkOutgoingMessages();
cleanListOfReceivedMessageHashes();
last_management_time = now ; last_management_time = now ;
} }
@ -146,6 +150,24 @@ int p3MsgService::tick()
return 0; return 0;
} }
void p3MsgService::cleanListOfReceivedMessageHashes()
{
RS_STACK_MUTEX(mMsgMtx); /********** STACK LOCKED MTX ******/
time_t now = time(NULL) ;
for(std::map<Sha1CheckSum,uint32_t>::iterator it(mRecentlyReceivedDistantMessageHashes.begin());it!=mRecentlyReceivedDistantMessageHashes.end();)
if(now > RS_MSG_DISTANT_MESSAGE_HASH_KEEP_TIME + it->second)
{
std::cerr << "p3MsgService(): cleanListOfReceivedMessageHashes(). Removing old hash " << it->first << ", aged " << now - it->second << " secs ago" << std::endl;
std::map<Sha1CheckSum,uint32_t>::iterator tmp(it) ;
++tmp ;
mRecentlyReceivedDistantMessageHashes.erase(it) ;
it=tmp ;
}
else
++it ;
}
int p3MsgService::status() int p3MsgService::status()
{ {
@ -332,9 +354,6 @@ int p3MsgService::checkOutgoingMessages()
* if online, send * if online, send
*/ */
static const uint32_t OLD_MESSAGE_FLUSHING_DELAY = 86400*7 ; // re-send old messages every week. This mainly ensures that
// messages that where never sent get sent at some point.
time_t now = time(NULL); time_t now = time(NULL);
bool changed = false ; bool changed = false ;
std::list<RsMsgItem*> output_queue ; std::list<RsMsgItem*> output_queue ;
@ -363,18 +382,9 @@ int p3MsgService::checkOutgoingMessages()
if( mServiceCtrl->isPeerConnected(getServiceInfo().mServiceType, pid) ) /* FEEDBACK Msg to Ourselves */ if( mServiceCtrl->isPeerConnected(getServiceInfo().mServiceType, pid) ) /* FEEDBACK Msg to Ourselves */
should_send = true ; should_send = true ;
if (mit->second->msgFlags & RS_MSG_FLAGS_DISTANT) if((mit->second->msgFlags & RS_MSG_FLAGS_DISTANT) && !(mit->second->msgFlags & RS_MSG_FLAGS_ROUTED))
{
if(!(mit->second->msgFlags & RS_MSG_FLAGS_ROUTED))
should_send = true ; should_send = true ;
// if(mit->second->sendTime + OLD_MESSAGE_FLUSHING_DELAY < now)
//{
// should_send = true ;
// mit->second->sendTime = now;
// }
}
if(should_send) if(should_send)
{ {
/* send msg */ /* send msg */
@ -595,6 +605,13 @@ bool p3MsgService::loadList(std::list<RsItem*>& load)
else if(NULL != (ghm = dynamic_cast<RsMsgDistantMessagesHashMap*>(*it))) else if(NULL != (ghm = dynamic_cast<RsMsgDistantMessagesHashMap*>(*it)))
{ {
mRecentlyReceivedDistantMessageHashes = ghm->hash_map ; mRecentlyReceivedDistantMessageHashes = ghm->hash_map ;
#ifdef DEBUG_DISTANT_MSG
std::cerr << " loaded recently received message map: " << std::endl;
for(std::map<Sha1CheckSum,uint32_t>::const_iterator it(mRecentlyReceivedDistantMessageHashes.begin());it!=mRecentlyReceivedDistantMessageHashes.end();++it)
std::cerr << " " << it->first << " received " << time(NULL)-it->second << " secs ago." << std::endl;
#endif
} }
else if(NULL != (mtt = dynamic_cast<RsMsgTagType *>(*it))) else if(NULL != (mtt = dynamic_cast<RsMsgTagType *>(*it)))
{ {
@ -1820,7 +1837,7 @@ void p3MsgService::manageDistantPeers()
{ {
#ifdef DEBUG_DISTANT_MSG #ifdef DEBUG_DISTANT_MSG
for(std::list<RsGxsId>::const_iterator it(own_id_list.begin());it!=own_id_list.end();++it) for(std::list<RsGxsId>::const_iterator it(own_id_list.begin());it!=own_id_list.end();++it)
std::cerr << (b?"Enabling":"Disabling") << " distant messaging, with peer id = " << *it << std::endl; std::cerr << (mShouldEnableDistantMessaging?"Enabling":"Disabling") << " distant messaging, with peer id = " << *it << std::endl;
#endif #endif
for(std::list<RsGxsId>::const_iterator it(own_id_list.begin());it!=own_id_list.end();++it) for(std::list<RsGxsId>::const_iterator it(own_id_list.begin());it!=own_id_list.end();++it)
@ -1943,6 +1960,7 @@ void p3MsgService::receiveGRouterData(const RsGxsId& destination_key, const RsGx
return ; return ;
} }
mRecentlyReceivedDistantMessageHashes[hash] = time(NULL) ; mRecentlyReceivedDistantMessageHashes[hash] = time(NULL) ;
IndicateConfigChanged() ;
RsItem *item = _serialiser->deserialise(data,&data_size) ; RsItem *item = _serialiser->deserialise(data,&data_size) ;
free(data) ; free(data) ;
@ -1969,7 +1987,8 @@ void p3MsgService::sendDistantMsgItem(RsMsgItem *msgitem)
RsGxsId destination_key_id(msgitem->PeerId()) ; RsGxsId destination_key_id(msgitem->PeerId()) ;
RsGxsId signing_key_id ; RsGxsId signing_key_id ;
msgitem->msgFlags |= RS_MSG_FLAGS_DISTANT ; msgitem->msgFlags |= RS_MSG_FLAGS_DISTANT ;// just in case, but normally we should always have this flag set, when ending up here.
{ {
RS_STACK_MUTEX(mMsgMtx) ; RS_STACK_MUTEX(mMsgMtx) ;
@ -1994,12 +2013,11 @@ void p3MsgService::sendDistantMsgItem(RsMsgItem *msgitem)
// The item is serialized and turned into a generic turtle item. Use use the explicit serialiser to make sure that the msgId is not included // The item is serialized and turned into a generic turtle item. Use use the explicit serialiser to make sure that the msgId is not included
uint32_t msg_serialized_rssize = msgitem->serial_size(false) ; uint32_t msg_serialized_rssize = msgitem->serial_size(false) ;
unsigned char *msg_serialized_data = new unsigned char[msg_serialized_rssize] ; RsTemporaryMemory msg_serialized_data(msg_serialized_rssize) ;
if(!msgitem->serialise(msg_serialized_data,msg_serialized_rssize,false)) if(!msgitem->serialise(msg_serialized_data,msg_serialized_rssize,false))
{ {
std::cerr << "(EE) p3MsgService::sendTurtleData(): Serialization error." << std::endl; std::cerr << "(EE) p3MsgService::sendTurtleData(): Serialization error." << std::endl;
delete[] msg_serialized_data ;
return ; return ;
} }
#ifdef DEBUG_DISTANT_MSG #ifdef DEBUG_DISTANT_MSG
@ -2009,8 +2027,6 @@ void p3MsgService::sendDistantMsgItem(RsMsgItem *msgitem)
GRouterMsgPropagationId grouter_message_id ; GRouterMsgPropagationId grouter_message_id ;
mGRouter->sendData(destination_key_id,GROUTER_CLIENT_ID_MESSAGES,msg_serialized_data,msg_serialized_rssize,signing_key_id,grouter_message_id) ; mGRouter->sendData(destination_key_id,GROUTER_CLIENT_ID_MESSAGES,msg_serialized_data,msg_serialized_rssize,signing_key_id,grouter_message_id) ;
delete[] msg_serialized_data ;
// now store the grouter id along with the message id, so that we can keep track of received messages // now store the grouter id along with the message id, so that we can keep track of received messages
{ {

View File

@ -56,160 +56,161 @@ class p3IdService;
// Temp tweak to test grouter // Temp tweak to test grouter
class p3MsgService: public p3Service, public p3Config, public pqiServiceMonitor, public GRouterClientService class p3MsgService: public p3Service, public p3Config, public pqiServiceMonitor, public GRouterClientService
{ {
public: public:
p3MsgService(p3ServiceControl *sc, p3IdService *id_service); p3MsgService(p3ServiceControl *sc, p3IdService *id_service);
virtual RsServiceInfo getServiceInfo(); virtual RsServiceInfo getServiceInfo();
/* External Interface */ /* External Interface */
bool getMessageSummaries(std::list<Rs::Msgs::MsgInfoSummary> &msgList); bool getMessageSummaries(std::list<Rs::Msgs::MsgInfoSummary> &msgList);
bool getMessage(const std::string &mid, Rs::Msgs::MessageInfo &msg); bool getMessage(const std::string &mid, Rs::Msgs::MessageInfo &msg);
void getMessageCount(unsigned int *pnInbox, unsigned int *pnInboxNew, unsigned int *pnOutbox, unsigned int *pnDraftbox, unsigned int *pnSentbox, unsigned int *pnTrashbox); void getMessageCount(unsigned int *pnInbox, unsigned int *pnInboxNew, unsigned int *pnOutbox, unsigned int *pnDraftbox, unsigned int *pnSentbox, unsigned int *pnTrashbox);
bool decryptMessage(const std::string& mid) ; bool decryptMessage(const std::string& mid) ;
bool removeMsgId(const std::string &mid); bool removeMsgId(const std::string &mid);
bool markMsgIdRead(const std::string &mid, bool bUnreadByUser); bool markMsgIdRead(const std::string &mid, bool bUnreadByUser);
bool setMsgFlag(const std::string &mid, uint32_t flag, uint32_t mask); bool setMsgFlag(const std::string &mid, uint32_t flag, uint32_t mask);
bool getMsgParentId(const std::string &msgId, std::string &msgParentId); bool getMsgParentId(const std::string &msgId, std::string &msgParentId);
// msgParentId == 0 --> remove // msgParentId == 0 --> remove
bool setMsgParentId(uint32_t msgId, uint32_t msgParentId); bool setMsgParentId(uint32_t msgId, uint32_t msgParentId);
bool MessageSend(Rs::Msgs::MessageInfo &info); bool MessageSend(Rs::Msgs::MessageInfo &info);
bool SystemMessage(const std::string &title, const std::string &message, uint32_t systemFlag); bool SystemMessage(const std::string &title, const std::string &message, uint32_t systemFlag);
bool MessageToDraft(Rs::Msgs::MessageInfo &info, const std::string &msgParentId); bool MessageToDraft(Rs::Msgs::MessageInfo &info, const std::string &msgParentId);
bool MessageToTrash(const std::string &mid, bool bTrash); bool MessageToTrash(const std::string &mid, bool bTrash);
bool getMessageTagTypes(Rs::Msgs::MsgTagType& tags); bool getMessageTagTypes(Rs::Msgs::MsgTagType& tags);
bool setMessageTagType(uint32_t tagId, std::string& text, uint32_t rgb_color); bool setMessageTagType(uint32_t tagId, std::string& text, uint32_t rgb_color);
bool removeMessageTagType(uint32_t tagId); bool removeMessageTagType(uint32_t tagId);
bool getMessageTag(const std::string &msgId, Rs::Msgs::MsgTagInfo& info); bool getMessageTag(const std::string &msgId, Rs::Msgs::MsgTagInfo& info);
/* set == false && tagId == 0 --> remove all */ /* set == false && tagId == 0 --> remove all */
bool setMessageTag(const std::string &msgId, uint32_t tagId, bool set); bool setMessageTag(const std::string &msgId, uint32_t tagId, bool set);
bool resetMessageStandardTagTypes(Rs::Msgs::MsgTagType& tags); bool resetMessageStandardTagTypes(Rs::Msgs::MsgTagType& tags);
void loadWelcomeMsg(); /* startup message */ void loadWelcomeMsg(); /* startup message */
//std::list<RsMsgItem *> &getMsgList(); //std::list<RsMsgItem *> &getMsgList();
//std::list<RsMsgItem *> &getMsgOutList(); //std::list<RsMsgItem *> &getMsgOutList();
int tick(); int tick();
int status(); int status();
/*** Overloaded from p3Config ****/ /*** Overloaded from p3Config ****/
virtual RsSerialiser *setupSerialiser(); virtual RsSerialiser *setupSerialiser();
virtual bool saveList(bool& cleanup, std::list<RsItem*>&); virtual bool saveList(bool& cleanup, std::list<RsItem*>&);
virtual bool loadList(std::list<RsItem*>& load); virtual bool loadList(std::list<RsItem*>& load);
virtual void saveDone(); virtual void saveDone();
/*** Overloaded from p3Config ****/ /*** Overloaded from p3Config ****/
/*** Overloaded from pqiMonitor ***/ /*** Overloaded from pqiMonitor ***/
virtual void statusChange(const std::list<pqiServicePeer> &plist); virtual void statusChange(const std::list<pqiServicePeer> &plist);
int checkOutgoingMessages(); int checkOutgoingMessages();
/*** Overloaded from pqiMonitor ***/ /*** Overloaded from pqiMonitor ***/
/*** overloaded from p3turtle ***/ /*** overloaded from p3turtle ***/
virtual void connectToGlobalRouter(p3GRouter *) ; virtual void connectToGlobalRouter(p3GRouter *) ;
struct DistantMessengingInvite struct DistantMessengingInvite
{ {
time_t time_of_validity ; time_t time_of_validity ;
}; };
struct DistantMessengingContact struct DistantMessengingContact
{ {
time_t last_hit_time ; time_t last_hit_time ;
RsPeerId virtual_peer_id ; RsPeerId virtual_peer_id ;
uint32_t status ; uint32_t status ;
bool pending_messages ; bool pending_messages ;
}; };
void enableDistantMessaging(bool b) ; void enableDistantMessaging(bool b) ;
bool distantMessagingEnabled() ; bool distantMessagingEnabled() ;
void setDistantMessagingPermissionFlags(uint32_t flags) ; void setDistantMessagingPermissionFlags(uint32_t flags) ;
uint32_t getDistantMessagingPermissionFlags() ; uint32_t getDistantMessagingPermissionFlags() ;
private: private:
void sendDistantMsgItem(RsMsgItem *msgitem) ; void sendDistantMsgItem(RsMsgItem *msgitem) ;
// This contains the ongoing tunnel handling contacts. // This contains the ongoing tunnel handling contacts.
// The map is indexed by the hash // The map is indexed by the hash
// //
std::map<GRouterMsgPropagationId,uint32_t> _ongoing_messages ; std::map<GRouterMsgPropagationId,uint32_t> _ongoing_messages ;
// Overloaded from GRouterClientService // Overloaded from GRouterClientService
virtual bool acceptDataFromPeer(const RsGxsId& gxs_id) ; virtual bool acceptDataFromPeer(const RsGxsId& gxs_id) ;
virtual void receiveGRouterData(const RsGxsId& destination_key,const RsGxsId& signing_key, GRouterServiceId &client_id, uint8_t *data, uint32_t data_size) ; virtual void receiveGRouterData(const RsGxsId& destination_key,const RsGxsId& signing_key, GRouterServiceId &client_id, uint8_t *data, uint32_t data_size) ;
virtual void notifyDataStatus(const GRouterMsgPropagationId& msg_id,uint32_t data_status) ; virtual void notifyDataStatus(const GRouterMsgPropagationId& msg_id,uint32_t data_status) ;
// Utility functions // Utility functions
bool createDistantMessage(const RsGxsId& destination_gxs_id,const RsGxsId& source_gxs_id,RsMsgItem *msg) ; bool createDistantMessage(const RsGxsId& destination_gxs_id,const RsGxsId& source_gxs_id,RsMsgItem *msg) ;
bool locked_findHashForVirtualPeerId(const RsPeerId& pid,Sha1CheckSum& hash) ; bool locked_findHashForVirtualPeerId(const RsPeerId& pid,Sha1CheckSum& hash) ;
void sendGRouterData(const RsGxsId &key_id,RsMsgItem *) ; void sendGRouterData(const RsGxsId &key_id,RsMsgItem *) ;
void manageDistantPeers() ; void manageDistantPeers() ;
void handleIncomingItem(RsMsgItem *) ; void handleIncomingItem(RsMsgItem *) ;
uint32_t getNewUniqueMsgId(); uint32_t getNewUniqueMsgId();
uint32_t sendMessage(RsMsgItem *item); uint32_t sendMessage(RsMsgItem *item);
uint32_t sendDistantMessage(RsMsgItem *item,const RsGxsId& signing_gxs_id); uint32_t sendDistantMessage(RsMsgItem *item,const RsGxsId& signing_gxs_id);
void checkSizeAndSendMessage(RsMsgItem *msg); void checkSizeAndSendMessage(RsMsgItem *msg);
void cleanListOfReceivedMessageHashes();
int incomingMsgs(); int incomingMsgs();
void processIncomingMsg(RsMsgItem *mi) ; void processIncomingMsg(RsMsgItem *mi) ;
bool checkAndRebuildPartialMessage(RsMsgItem*) ; bool checkAndRebuildPartialMessage(RsMsgItem*) ;
void initRsMI(RsMsgItem *msg, Rs::Msgs::MessageInfo &mi); void initRsMI(RsMsgItem *msg, Rs::Msgs::MessageInfo &mi);
void initRsMIS(RsMsgItem *msg, Rs::Msgs::MsgInfoSummary &mis); void initRsMIS(RsMsgItem *msg, Rs::Msgs::MsgInfoSummary &mis);
RsMsgItem *initMIRsMsg(const Rs::Msgs::MessageInfo &info, const RsPeerId& to); RsMsgItem *initMIRsMsg(const Rs::Msgs::MessageInfo &info, const RsPeerId& to);
RsMsgItem *initMIRsMsg(const Rs::Msgs::MessageInfo &info, const RsGxsId& to); RsMsgItem *initMIRsMsg(const Rs::Msgs::MessageInfo &info, const RsGxsId& to);
void initMIRsMsg(RsMsgItem *item,const Rs::Msgs::MessageInfo &info) ; void initMIRsMsg(RsMsgItem *item,const Rs::Msgs::MessageInfo &info) ;
void initStandardTagTypes(); void initStandardTagTypes();
p3IdService *mIdService ; p3IdService *mIdService ;
p3ServiceControl *mServiceCtrl; p3ServiceControl *mServiceCtrl;
p3GRouter *mGRouter ; p3GRouter *mGRouter ;
/* Mutex Required for stuff below */ /* Mutex Required for stuff below */
RsMutex mMsgMtx; RsMutex mMsgMtx;
RsMsgSerialiser *_serialiser ; RsMsgSerialiser *_serialiser ;
/* stored list of messages */ /* stored list of messages */
std::map<uint32_t, RsMsgItem *> imsg; std::map<uint32_t, RsMsgItem *> imsg;
/* ones that haven't made it out yet! */ /* ones that haven't made it out yet! */
std::map<uint32_t, RsMsgItem *> msgOutgoing; std::map<uint32_t, RsMsgItem *> msgOutgoing;
std::map<RsPeerId, RsMsgItem *> _pendingPartialMessages ; std::map<RsPeerId, RsMsgItem *> _pendingPartialMessages ;
/* maps for tags types and msg tags */ /* maps for tags types and msg tags */
std::map<uint32_t, RsMsgTagType*> mTags; std::map<uint32_t, RsMsgTagType*> mTags;
std::map<uint32_t, RsMsgTags*> mMsgTags; std::map<uint32_t, RsMsgTags*> mMsgTags;
uint32_t mMsgUniqueId; uint32_t mMsgUniqueId;
std::map<Sha1CheckSum,uint32_t> mRecentlyReceivedDistantMessageHashes; std::map<Sha1CheckSum,uint32_t> mRecentlyReceivedDistantMessageHashes;
// used delete msgSrcIds after config save // used delete msgSrcIds after config save
std::map<uint32_t, RsMsgSrcId*> mSrcIds; std::map<uint32_t, RsMsgSrcId*> mSrcIds;
// temporary storage. Will not be needed when messages have a proper "from" field. Not saved! // temporary storage. Will not be needed when messages have a proper "from" field. Not saved!
std::map<uint32_t, RsGxsId> mDistantOutgoingMsgSigners; std::map<uint32_t, RsGxsId> mDistantOutgoingMsgSigners;
// save the parent of the messages in draft for replied and forwarded // save the parent of the messages in draft for replied and forwarded
std::map<uint32_t, RsMsgParentId*> mParentId; std::map<uint32_t, RsMsgParentId*> mParentId;
std::string config_dir; std::string config_dir;
bool mDistantMessagingEnabled ; bool mDistantMessagingEnabled ;
uint32_t mDistantMessagePermissions ; uint32_t mDistantMessagePermissions ;
bool mShouldEnableDistantMessaging ; bool mShouldEnableDistantMessaging ;
}; };
#endif // MESSAGE_SERVICE_HEADER #endif // MESSAGE_SERVICE_HEADER