mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-06 08:05:18 -04:00
simplification of the chat interface to libretroshare using a single unified class for chat IDs. Used a common chat widget for all chats including broadcast. Opens the way to having plugins send/recv chat messages. Patch from Electron.
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7800 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
535fe875e4
commit
13d7866171
53 changed files with 1180 additions and 2280 deletions
|
@ -27,6 +27,7 @@
|
|||
*/
|
||||
|
||||
class RsHistory;
|
||||
class ChatId;
|
||||
|
||||
extern RsHistory *rsHistory;
|
||||
|
||||
|
@ -72,10 +73,10 @@ public:
|
|||
class RsHistory
|
||||
{
|
||||
public:
|
||||
virtual bool getMessages(const RsPeerId &chatPeerId, std::list<HistoryMsg> &msgs, uint32_t loadCount) = 0;
|
||||
virtual bool getMessages(const ChatId &chatPeerId, std::list<HistoryMsg> &msgs, uint32_t loadCount) = 0;
|
||||
virtual bool getMessage(uint32_t msgId, HistoryMsg &msg) = 0;
|
||||
virtual void removeMessages(const std::list<uint32_t> &msgIds) = 0;
|
||||
virtual void clear(const RsPeerId &chatPeerId) = 0;
|
||||
virtual void clear(const ChatId &chatPeerId) = 0;
|
||||
|
||||
virtual bool getEnable(uint32_t chat_type) = 0;
|
||||
virtual void setEnable(uint32_t chat_type, bool enable) = 0;
|
||||
|
|
|
@ -254,15 +254,64 @@ public:
|
|||
#define RS_DISTANT_CHAT_FLAG_SIGNED 0x0001
|
||||
#define RS_DISTANT_CHAT_FLAG_SIGNATURE_OK 0x0002
|
||||
|
||||
class ChatInfo
|
||||
// Identifier for an chat endpoint like
|
||||
// neighbour peer, distant peer, chatlobby, broadcast
|
||||
class ChatId
|
||||
{
|
||||
public:
|
||||
RsPeerId rsid;
|
||||
std::string peer_nickname;
|
||||
unsigned int chatflags;
|
||||
uint32_t sendTime;
|
||||
uint32_t recvTime;
|
||||
std::string msg;
|
||||
public:
|
||||
ChatId();
|
||||
explicit ChatId(RsPeerId id);
|
||||
explicit ChatId(RsGxsId id);
|
||||
explicit ChatId(ChatLobbyId id);
|
||||
explicit ChatId(std::string str);
|
||||
static ChatId makeBroadcastId();
|
||||
|
||||
std::string toStdString() const;
|
||||
bool operator<(const ChatId& other) const;
|
||||
bool isSameEndpoint(const ChatId& other) const;
|
||||
|
||||
bool isNotSet() const;
|
||||
bool isPeerId() const;
|
||||
bool isGxsId() const;
|
||||
bool isLobbyId() const;
|
||||
bool isBroadcast() const;
|
||||
|
||||
RsPeerId toPeerId() const;
|
||||
RsGxsId toGxsId() const;
|
||||
ChatLobbyId toLobbyId() const;
|
||||
|
||||
// for the very specific case of transfering a status string
|
||||
// from the chatservice to the gui,
|
||||
// this defines from which peer the status string came from
|
||||
RsPeerId broadcast_status_peer_id;
|
||||
private:
|
||||
enum Type { TYPE_NOT_SET,
|
||||
TYPE_PRIVATE, // private chat with directly connected friend, peer_id is valid
|
||||
TYPE_PRIVATE_DISTANT, // private chat with distant peer, gxs_id is valid
|
||||
TYPE_LOBBY, // chat lobby id, lobby_id is valid
|
||||
TYPE_BROADCAST // message to/from all connected peers
|
||||
};
|
||||
|
||||
Type type;
|
||||
RsPeerId peer_id;
|
||||
RsGxsId gxs_id;
|
||||
ChatLobbyId lobby_id;
|
||||
};
|
||||
|
||||
class ChatMessage
|
||||
{
|
||||
public:
|
||||
ChatId chat_id; // id of chat endpoint
|
||||
RsPeerId broadcast_peer_id; // only used for broadcast chat: source peer id
|
||||
std::string lobby_peer_nickname; // only used for lobbys: nickname of message author
|
||||
|
||||
unsigned int chatflags;
|
||||
uint32_t sendTime;
|
||||
uint32_t recvTime;
|
||||
std::string msg;
|
||||
bool incoming;
|
||||
bool online; // for outgoing messages: was this message send?
|
||||
//bool system_message;
|
||||
};
|
||||
|
||||
class ChatLobbyInvite
|
||||
|
@ -315,9 +364,6 @@ struct DistantChatInviteInfo
|
|||
};
|
||||
|
||||
std::ostream &operator<<(std::ostream &out, const MessageInfo &info);
|
||||
std::ostream &operator<<(std::ostream &out, const ChatInfo &info);
|
||||
|
||||
bool operator==(const ChatInfo&, const ChatInfo&);
|
||||
|
||||
class RsMsgs;
|
||||
extern RsMsgs *rsMsgs;
|
||||
|
@ -381,18 +427,13 @@ virtual bool distantMessagingEnabled() = 0;
|
|||
/****************************************/
|
||||
/* Chat */
|
||||
/****************************************/
|
||||
virtual bool sendPublicChat(const std::string& msg) = 0;
|
||||
virtual bool sendPrivateChat(const RsPeerId& id, const std::string& msg) = 0;
|
||||
virtual int getPublicChatQueueCount() = 0;
|
||||
virtual bool getPublicChatQueue(std::list<ChatInfo> &chats) = 0;
|
||||
virtual int getPrivateChatQueueCount(bool incoming) = 0;
|
||||
virtual bool getPrivateChatQueueIds(bool incoming, std::list<RsPeerId> &ids) = 0;
|
||||
virtual bool getPrivateChatQueue(bool incoming, const RsPeerId& id, std::list<ChatInfo> &chats) = 0;
|
||||
virtual bool clearPrivateChatQueue(bool incoming, const RsPeerId& id) = 0;
|
||||
virtual uint32_t getMaxMessageSecuritySize(int type) = 0;
|
||||
// sendChat for broadcast, private, lobby and private distant chat
|
||||
// note: for lobby chat, you first have to subscribe to a lobby
|
||||
// for private distant chat, it is reqired to have an active distant chat session
|
||||
virtual bool sendChat(ChatId id, std::string msg) = 0;
|
||||
virtual uint32_t getMaxMessageSecuritySize(int type) = 0;
|
||||
|
||||
virtual void sendStatusString(const RsPeerId& id,const std::string& status_string) = 0 ;
|
||||
virtual void sendGroupChatStatusString(const std::string& status_string) = 0 ;
|
||||
virtual void sendStatusString(const ChatId& id,const std::string& status_string) = 0 ;
|
||||
|
||||
virtual void setCustomStateString(const std::string& status_string) = 0 ;
|
||||
virtual std::string getCustomStateString() = 0 ;
|
||||
|
|
|
@ -35,6 +35,9 @@
|
|||
|
||||
#include "rsturtle.h"
|
||||
|
||||
class ChatId;
|
||||
class ChatMessage;
|
||||
|
||||
class RsNotify;
|
||||
extern RsNotify *rsNotify;
|
||||
|
||||
|
@ -198,8 +201,8 @@ class NotifyClient
|
|||
virtual void notifyListPreChange (int /* list */, int /* type */) {}
|
||||
virtual void notifyListChange (int /* list */, int /* type */) {}
|
||||
virtual void notifyErrorMsg (int /* list */, int /* sev */, std::string /* msg */) {}
|
||||
virtual void notifyChatStatus (const std::string& /* peer_id */, const std::string& /* status_string */ ,bool /* is_private */) {}
|
||||
virtual void notifyChatShow (const std::string& /* peer_id */) {}
|
||||
virtual void notifyChatMessage (const ChatMessage& /* msg */) {}
|
||||
virtual void notifyChatStatus (const ChatId& /* chat_id */, const std::string& /* status_string */) {}
|
||||
virtual void notifyChatLobbyEvent (uint64_t /* lobby id */, uint32_t /* event type */ ,const std::string& /* nickname */,const std::string& /* any string */) {}
|
||||
virtual void notifyChatLobbyTimeShift (int /* time_shift*/) {}
|
||||
virtual void notifyCustomState (const std::string& /* peer_id */, const std::string& /* status_string */) {}
|
||||
|
@ -214,8 +217,10 @@ class NotifyClient
|
|||
/* one or more peers has changed the states */
|
||||
virtual void notifyPeerStatusChangedSummary () {}
|
||||
virtual void notifyDiscInfoChanged () {}
|
||||
#ifdef REMOVE
|
||||
virtual void notifyForumMsgReadSatusChanged (const std::string& /* channelId */, const std::string& /* msgId */, uint32_t /* status */) {}
|
||||
virtual void notifyChannelMsgReadSatusChanged (const std::string& /* channelId */, const std::string& /* msgId */, uint32_t /* status */) {}
|
||||
#endif
|
||||
virtual bool askForDeferredSelfSignature (const void * /* data */, const uint32_t /* len */, unsigned char * /* sign */, unsigned int * /* signlen */,int& signature_result ) { signature_result = false ;return true; }
|
||||
virtual void notifyDownloadComplete (const std::string& /* fileHash */) {}
|
||||
virtual void notifyDownloadCompleteCount (uint32_t /* count */) {}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue