Basic methods and a bit of interface for chat lobby.

Next:
- chat lobby algorithmics (cache+broadcast system)
- invitation handling
- specification of chat lobby window with list of known/unknown participants


git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-ChatLobby@4685 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
csoler 2011-11-23 22:10:37 +00:00
parent d9244225b7
commit 5cdc36d730
9 changed files with 1137 additions and 116 deletions

View file

@ -61,6 +61,8 @@
#define RS_MSGTAGTYPE_LATER 5
#define RS_MSGTAGTYPE_USER 100
typedef uint64_t ChatLobbyId ;
class MessageInfo
{
public:
@ -135,10 +137,17 @@ class ChatInfo
std::wstring msg;
};
class ChatLobbyInfo
{
public:
ChatLobbyId lobby_id ;
std::string display_name ;
std::list<std::string> participating_friends ; // list of direct friend who participate. Used to broadcast sent messages.
std::list<std::string> additional_peers ; // list of non direct friend who participate. Used to display only.
};
std::ostream &operator<<(std::ostream &out, const MessageInfo &info);
std::ostream &operator<<(std::ostream &out, const ChatInfo &info);
//std::ostream &operator<<(std::ostream &out, const MsgTagInfo);
//std::ostream &operator<<(std::ostream &out, const MsgTagType);
bool operator==(const ChatInfo&, const ChatInfo&);
@ -185,13 +194,15 @@ virtual bool resetMessageStandardTagTypes(MsgTagType& tags) = 0;
/****************************************/
/* Chat */
virtual bool sendPublicChat(const std::wstring& msg) = 0;
virtual bool sendLobbyChat(const std::wstring& msg,const ChatLobbyId& lid) = 0;
virtual bool sendPrivateChat(const std::string& id, const std::wstring& msg) = 0;
virtual int getPublicChatQueueCount() = 0;
virtual int getPublicChatQueueCount() = 0;
virtual bool getPublicChatQueue(std::list<ChatInfo> &chats) = 0;
virtual int getPrivateChatQueueCount(bool incoming) = 0;
virtual int getPrivateChatQueueCount(bool incoming) = 0;
virtual bool getPrivateChatQueueIds(bool incoming, std::list<std::string> &ids) = 0;
virtual bool getPrivateChatQueue(bool incoming, const std::string& id, std::list<ChatInfo> &chats) = 0;
virtual bool clearPrivateChatQueue(bool incoming, const std::string& id) = 0;
virtual void sendStatusString(const std::string& id,const std::string& status_string) = 0 ;
virtual void sendGroupChatStatusString(const std::string& status_string) = 0 ;
@ -205,6 +216,9 @@ virtual void getAvatarData(const std::string& pid,unsigned char *& data,int& siz
virtual void setOwnAvatarData(const unsigned char *data,int size) = 0 ;
virtual void getOwnAvatarData(unsigned char *& data,int& size) = 0 ;
virtual void getChatLobbyList(std::list<ChatLobbyInfo>& cl_info) = 0;
virtual void invitePeerToLobby(const ChatLobbyId& lobby_id,const std::string& peer_id) = 0;
/****************************************/
};

View file

@ -260,3 +260,17 @@ void p3Msgs::setCustomStateString(const std::string& state_string)
mChatSrv->setOwnCustomStateString(state_string) ;
}
bool p3Msgs::sendLobbyChat(const std::wstring& msg, const ChatLobbyId& id)
{
return mChatSrv->sendLobbyChat(msg,id) ;
}
void p3Msgs::getChatLobbyList(std::list<ChatLobbyInfo>& linfos)
{
mChatSrv->getChatLobbyList(linfos) ;
}
void p3Msgs::invitePeerToLobby(const ChatLobbyId& lobby_id, const std::string& peer_id)
{
mChatSrv->invitePeerToLobby(lobby_id,peer_id) ;
}

View file

@ -167,6 +167,9 @@ class p3Msgs: public RsMsgs
/****************************************/
virtual bool sendLobbyChat(const std::wstring&, const ChatLobbyId&) ;
virtual void getChatLobbyList(std::list<ChatLobbyInfo, std::allocator<ChatLobbyInfo> >&) ;
virtual void invitePeerToLobby(const ChatLobbyId&, const std::string&) ;
private:

View file

@ -1135,3 +1135,33 @@ void p3ChatService::statusChange(const std::list<pqipeer> &plist)
}
}
}
//********************** Chat Lobby Stuff ***********************//
bool p3ChatService::sendLobbyChat(const std::wstring& msg, const ChatLobbyId& lobby_id)
{
std::cerr << "Sending chat lobby message to lobby " << lobby_id << std::endl;
std::cerr << "msg:" << std::endl;
std::cerr << msg.c_str() << std::endl;
return true ;
}
void p3ChatService::getChatLobbyList(std::list<ChatLobbyInfo>& linfos)
{
// fill up a dummy list for now.
linfos.clear() ;
ChatLobbyInfo info ;
info.lobby_id = 0x38484fe ;
info.display_name = "lobby 1" ;
info.participating_friends.push_back("friend 1") ;
info.participating_friends.push_back("friend 2") ;
info.additional_peers.push_back("peer 1") ;
linfos.push_back(info) ;
}
void p3ChatService::invitePeerToLobby(const ChatLobbyId& lobby_id, const std::string& peer_id)
{
std::cerr << "Sending invitation to peer " << peer_id << " to lobby "<< lobby_id << std::endl;
}

View file

@ -153,6 +153,11 @@ class p3ChatService: public p3Service, public p3Config, public pqiMonitor
*/
bool clearPrivateChatQueue(bool incoming, const std::string &id);
bool sendLobbyChat(const std::wstring&, const ChatLobbyId&) ;
void getChatLobbyList(std::list<ChatLobbyInfo, std::allocator<ChatLobbyInfo> >&) ;
void invitePeerToLobby(const ChatLobbyId&, const std::string&) ;
protected:
/************* from p3Config *******************/
virtual RsSerialiser *setupSerialiser() ;