mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-06-06 21:58:57 -04:00
merged remaining of v0.6-IdCleaning branch (7180->7213) to incorporate global router stuff in trunk
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7214 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
0e6302ac6a
commit
1042744685
53 changed files with 2387 additions and 1904 deletions
|
@ -43,79 +43,74 @@
|
|||
#include "serialiser/rsmsgitems.h"
|
||||
#include "util/rsthreads.h"
|
||||
|
||||
#ifdef GROUTER
|
||||
#include "retroshare/rsgxsifacetypes.h"
|
||||
|
||||
#include "grouter/p3grouter.h"
|
||||
#include "grouter/grouterclientservice.h"
|
||||
#endif
|
||||
#include "turtle/p3turtle.h"
|
||||
#include "turtle/turtleclientservice.h"
|
||||
|
||||
class p3LinkMgr;
|
||||
class p3IdService;
|
||||
|
||||
// Temp tweak to test grouter
|
||||
class p3MsgService: public p3Service, public p3Config, public pqiServiceMonitor, public RsTurtleClientService
|
||||
#ifdef GROUTER
|
||||
, public GRouterClientService
|
||||
#endif
|
||||
class p3MsgService: public p3Service, public p3Config, public pqiServiceMonitor, public GRouterClientService
|
||||
{
|
||||
public:
|
||||
p3MsgService(p3ServiceControl *sc);
|
||||
virtual RsServiceInfo getServiceInfo();
|
||||
p3MsgService(p3ServiceControl *sc, p3IdService *id_service);
|
||||
virtual RsServiceInfo getServiceInfo();
|
||||
|
||||
/* External Interface */
|
||||
bool getMessageSummaries(std::list<MsgInfoSummary> &msgList);
|
||||
bool getMessage(const std::string &mid, MessageInfo &msg);
|
||||
void getMessageCount(unsigned int *pnInbox, unsigned int *pnInboxNew, unsigned int *pnOutbox, unsigned int *pnDraftbox, unsigned int *pnSentbox, unsigned int *pnTrashbox);
|
||||
/* External Interface */
|
||||
bool getMessageSummaries(std::list<MsgInfoSummary> &msgList);
|
||||
bool getMessage(const std::string &mid, MessageInfo &msg);
|
||||
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 removeMsgId(const std::string &mid);
|
||||
bool markMsgIdRead(const std::string &mid, bool bUnreadByUser);
|
||||
bool setMsgFlag(const std::string &mid, uint32_t flag, uint32_t mask);
|
||||
bool getMsgParentId(const std::string &msgId, std::string &msgParentId);
|
||||
// msgParentId == 0 --> remove
|
||||
bool setMsgParentId(uint32_t msgId, uint32_t msgParentId);
|
||||
bool decryptMessage(const std::string& mid) ;
|
||||
bool removeMsgId(const std::string &mid);
|
||||
bool markMsgIdRead(const std::string &mid, bool bUnreadByUser);
|
||||
bool setMsgFlag(const std::string &mid, uint32_t flag, uint32_t mask);
|
||||
bool getMsgParentId(const std::string &msgId, std::string &msgParentId);
|
||||
// msgParentId == 0 --> remove
|
||||
bool setMsgParentId(uint32_t msgId, uint32_t msgParentId);
|
||||
|
||||
bool MessageSend(MessageInfo &info);
|
||||
bool SystemMessage(const std::string &title, const std::string &message, uint32_t systemFlag);
|
||||
bool MessageToDraft(MessageInfo &info, const std::string &msgParentId);
|
||||
bool MessageToTrash(const std::string &mid, bool bTrash);
|
||||
bool MessageSend(MessageInfo &info);
|
||||
bool SystemMessage(const std::string &title, const std::string &message, uint32_t systemFlag);
|
||||
bool MessageToDraft(MessageInfo &info, const std::string &msgParentId);
|
||||
bool MessageToTrash(const std::string &mid, bool bTrash);
|
||||
|
||||
bool getMessageTagTypes(MsgTagType& tags);
|
||||
bool setMessageTagType(uint32_t tagId, std::string& text, uint32_t rgb_color);
|
||||
bool removeMessageTagType(uint32_t tagId);
|
||||
bool getMessageTagTypes(MsgTagType& tags);
|
||||
bool setMessageTagType(uint32_t tagId, std::string& text, uint32_t rgb_color);
|
||||
bool removeMessageTagType(uint32_t tagId);
|
||||
|
||||
bool getMessageTag(const std::string &msgId, MsgTagInfo& info);
|
||||
/* set == false && tagId == 0 --> remove all */
|
||||
bool setMessageTag(const std::string &msgId, uint32_t tagId, bool set);
|
||||
bool getMessageTag(const std::string &msgId, MsgTagInfo& info);
|
||||
/* set == false && tagId == 0 --> remove all */
|
||||
bool setMessageTag(const std::string &msgId, uint32_t tagId, bool set);
|
||||
|
||||
bool resetMessageStandardTagTypes(MsgTagType& tags);
|
||||
bool resetMessageStandardTagTypes(MsgTagType& tags);
|
||||
|
||||
void loadWelcomeMsg(); /* startup message */
|
||||
void loadWelcomeMsg(); /* startup message */
|
||||
|
||||
//std::list<RsMsgItem *> &getMsgList();
|
||||
//std::list<RsMsgItem *> &getMsgOutList();
|
||||
//std::list<RsMsgItem *> &getMsgList();
|
||||
//std::list<RsMsgItem *> &getMsgOutList();
|
||||
|
||||
int tick();
|
||||
int status();
|
||||
int tick();
|
||||
int status();
|
||||
|
||||
/*** Overloaded from p3Config ****/
|
||||
virtual RsSerialiser *setupSerialiser();
|
||||
virtual bool saveList(bool& cleanup, std::list<RsItem*>&);
|
||||
virtual bool loadList(std::list<RsItem*>& load);
|
||||
virtual void saveDone();
|
||||
/*** Overloaded from p3Config ****/
|
||||
/*** Overloaded from p3Config ****/
|
||||
virtual RsSerialiser *setupSerialiser();
|
||||
virtual bool saveList(bool& cleanup, std::list<RsItem*>&);
|
||||
virtual bool loadList(std::list<RsItem*>& load);
|
||||
virtual void saveDone();
|
||||
/*** Overloaded from p3Config ****/
|
||||
|
||||
/*** Overloaded from pqiMonitor ***/
|
||||
virtual void statusChange(const std::list<pqiServicePeer> &plist);
|
||||
int checkOutgoingMessages();
|
||||
/*** Overloaded from pqiMonitor ***/
|
||||
/*** Overloaded from pqiMonitor ***/
|
||||
virtual void statusChange(const std::list<pqiServicePeer> &plist);
|
||||
int checkOutgoingMessages();
|
||||
/*** Overloaded from pqiMonitor ***/
|
||||
|
||||
/*** overloaded from p3turtle ***/
|
||||
/*** overloaded from p3turtle ***/
|
||||
|
||||
#ifdef GROUTER
|
||||
virtual void connectToGlobalRouter(p3GRouter *) ;
|
||||
#endif
|
||||
virtual void connectToTurtleRouter(p3turtle *) ;
|
||||
|
||||
struct DistantMessengingInvite
|
||||
{
|
||||
|
@ -128,96 +123,80 @@ int checkOutgoingMessages();
|
|||
uint32_t status ;
|
||||
bool pending_messages ;
|
||||
};
|
||||
bool createDistantOfflineMessengingInvite(time_t time_of_validity,DistantMsgPeerId &peer_id) ;
|
||||
bool getDistantOfflineMessengingInvites(std::vector<DistantOfflineMessengingInvite>& invites) ;
|
||||
|
||||
void enableDistantMessaging(bool b) ;
|
||||
bool distantMessagingEnabled() ;
|
||||
bool getDistantMessagePeerId(const RsPgpId& pgp_id,DistantMsgPeerId &peer_id) ;
|
||||
|
||||
private:
|
||||
bool getDistantMessageHash(const RsPgpId& pgp_id,Sha1CheckSum &hash) ;
|
||||
void sendPrivateMsgItem(const Sha1CheckSum& hash,RsMsgItem *) ;
|
||||
|
||||
// This maps contains the current invitations to respond to.
|
||||
// The map is indexed by the hash
|
||||
std::map<Sha1CheckSum,DistantMessengingInvite> _messenging_invites ;
|
||||
void sendPrivateMsgItem(RsMsgItem *msgitem) ;
|
||||
|
||||
// This contains the ongoing tunnel handling contacts.
|
||||
// The map is indexed by the hash
|
||||
std::map<Sha1CheckSum,DistantMessengingContact> _messenging_contacts ;
|
||||
//
|
||||
std::map<GRouterKeyId,DistantMessengingContact> _messenging_contacts ;
|
||||
|
||||
// Overloaded from RsTurtleClientService
|
||||
// Overloaded from GRouterClientService
|
||||
|
||||
#ifdef GROUTER
|
||||
virtual void receiveGRouterData(RsGRouterGenericDataItem *item, const GRouterKeyId& key) ;
|
||||
#endif
|
||||
virtual bool handleTunnelRequest(const Sha1CheckSum& hash,const RsPeerId& peer_id) ;
|
||||
// virtual void receiveTurtleData(RsTurtleGenericTunnelItem *item,const Sha1CheckSum& hash,const RsPeerId& virtual_peer_id,RsTurtleGenericTunnelItem::Direction direction) ;
|
||||
void addVirtualPeer(const TurtleFileHash&, const TurtleVirtualPeerId&,RsTurtleGenericTunnelItem::Direction /* dir */) {}
|
||||
void removeVirtualPeer(const TurtleFileHash&, const TurtleVirtualPeerId&) {}
|
||||
virtual void receiveGRouterData(const GRouterKeyId& key,const RsGRouterGenericDataItem *item) ;
|
||||
|
||||
// Utility functions
|
||||
|
||||
bool encryptMessage(const RsPgpId& pgp_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) ;
|
||||
void sendGRouterData(const GRouterKeyId &key_id,RsMsgItem *) ;
|
||||
|
||||
void manageDistantPeers() ;
|
||||
void sendTurtleData(const Sha1CheckSum& hash,RsMsgItem *) ;
|
||||
#ifdef GROUTER
|
||||
void sendGRouterData(const Sha1CheckSum& hash,RsMsgItem *) ;
|
||||
#endif
|
||||
|
||||
void handleIncomingItem(RsMsgItem *) ;
|
||||
|
||||
#ifdef GROUTER
|
||||
uint32_t getNewUniqueMsgId();
|
||||
int sendMessage(RsMsgItem *item);
|
||||
void checkSizeAndSendMessage(RsMsgItem *msg);
|
||||
|
||||
int incomingMsgs();
|
||||
void processMsg(RsMsgItem *mi, bool incoming);
|
||||
bool checkAndRebuildPartialMessage(RsMsgItem*) ;
|
||||
|
||||
void initRsMI(RsMsgItem *msg, MessageInfo &mi);
|
||||
void initRsMIS(RsMsgItem *msg, MsgInfoSummary &mis);
|
||||
|
||||
RsMsgItem *initMIRsMsg(const MessageInfo &info, const RsPeerId& to);
|
||||
RsMsgItem *initMIRsMsg(const MessageInfo &info, const RsGxsId& to);
|
||||
void initMIRsMsg(RsMsgItem *item,const MessageInfo &info) ;
|
||||
|
||||
void initStandardTagTypes();
|
||||
|
||||
p3ServiceControl *mServiceCtrl;
|
||||
p3IdService *mIdService ;
|
||||
p3GRouter *mGRouter ;
|
||||
#endif
|
||||
p3turtle *mTurtle ;
|
||||
|
||||
uint32_t getNewUniqueMsgId();
|
||||
int sendMessage(RsMsgItem *item);
|
||||
void checkSizeAndSendMessage(RsMsgItem *msg);
|
||||
/* Mutex Required for stuff below */
|
||||
|
||||
int incomingMsgs();
|
||||
void processMsg(RsMsgItem *mi, bool incoming);
|
||||
bool checkAndRebuildPartialMessage(RsMsgItem*) ;
|
||||
|
||||
void initRsMI(RsMsgItem *msg, MessageInfo &mi);
|
||||
void initRsMIS(RsMsgItem *msg, MsgInfoSummary &mis);
|
||||
RsMsgItem *initMIRsMsg(MessageInfo &info, const RsPeerId &to);
|
||||
|
||||
void initStandardTagTypes();
|
||||
|
||||
p3ServiceControl *mServiceCtrl;
|
||||
|
||||
/* Mutex Required for stuff below */
|
||||
|
||||
RsMutex mMsgMtx;
|
||||
RsMsgSerialiser *_serialiser ;
|
||||
RsMutex mMsgMtx;
|
||||
RsMsgSerialiser *_serialiser ;
|
||||
|
||||
/* stored list of messages */
|
||||
std::map<uint32_t, RsMsgItem *> imsg;
|
||||
std::map<uint32_t, RsMsgItem *> imsg;
|
||||
/* 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, RsMsgTags*> mMsgTags;
|
||||
std::map<uint32_t, RsMsgTagType*> mTags;
|
||||
std::map<uint32_t, RsMsgTags*> mMsgTags;
|
||||
|
||||
uint32_t mMsgUniqueId;
|
||||
uint32_t mMsgUniqueId;
|
||||
|
||||
// used delete msgSrcIds after config save
|
||||
std::map<uint32_t, RsMsgSrcId*> mSrcIds;
|
||||
// used delete msgSrcIds after config save
|
||||
std::map<uint32_t, RsMsgSrcId*> mSrcIds;
|
||||
|
||||
// save the parent of the messages in draft for replied and forwarded
|
||||
std::map<uint32_t, RsMsgParentId*> mParentId;
|
||||
// save the parent of the messages in draft for replied and forwarded
|
||||
std::map<uint32_t, RsMsgParentId*> mParentId;
|
||||
|
||||
std::string config_dir;
|
||||
std::string config_dir;
|
||||
|
||||
bool mDistantMessagingEnabled ;
|
||||
bool mDistantMessagingEnabled ;
|
||||
};
|
||||
|
||||
#endif // MESSAGE_SERVICE_HEADER
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue