diff --git a/libretroshare/src/retroshare/rsmsgs.h b/libretroshare/src/retroshare/rsmsgs.h index 4c226c3fd..d3cec07ad 100644 --- a/libretroshare/src/retroshare/rsmsgs.h +++ b/libretroshare/src/retroshare/rsmsgs.h @@ -233,6 +233,7 @@ virtual void invitePeerToLobby(const ChatLobbyId& lobby_id,const std::string& pe virtual void unsubscribeChatLobby(const ChatLobbyId& lobby_id) = 0; virtual bool setNickNameForChatLobby(const ChatLobbyId& lobby_id,const std::string& nick) = 0; virtual bool getNickNameForChatLobby(const ChatLobbyId& lobby_id,std::string& nick) = 0 ; +virtual ChatLobbyId createChatLobby(const std::string& lobby_name,const std::list& invited_friends) = 0 ; /****************************************/ diff --git a/libretroshare/src/rsserver/p3msgs.cc b/libretroshare/src/rsserver/p3msgs.cc index 9db4d4519..663cbf6aa 100644 --- a/libretroshare/src/rsserver/p3msgs.cc +++ b/libretroshare/src/rsserver/p3msgs.cc @@ -285,4 +285,9 @@ bool p3Msgs::getNickNameForChatLobby(const ChatLobbyId& lobby_id,std::string& ni return mChatSrv->getNickNameForChatLobby(lobby_id,nick_name) ; } +ChatLobbyId p3Msgs::createChatLobby(const std::string& lobby_name,const std::list& invited_friends) +{ + return mChatSrv->createChatLobby(lobby_name,invited_friends) ; +} + diff --git a/libretroshare/src/rsserver/p3msgs.h b/libretroshare/src/rsserver/p3msgs.h index 3fbc4b27c..7f9a33569 100644 --- a/libretroshare/src/rsserver/p3msgs.h +++ b/libretroshare/src/rsserver/p3msgs.h @@ -173,7 +173,7 @@ class p3Msgs: public RsMsgs virtual void unsubscribeChatLobby(const ChatLobbyId& lobby_id) ; virtual bool setNickNameForChatLobby(const ChatLobbyId& lobby_id,const std::string&) ; virtual bool getNickNameForChatLobby(const ChatLobbyId&,std::string& nick) ; - + virtual ChatLobbyId createChatLobby(const std::string& lobby_name,const std::list& invited_friends) ; private: diff --git a/libretroshare/src/services/p3chatservice.cc b/libretroshare/src/services/p3chatservice.cc index 53d4735b3..d6429c2f4 100644 --- a/libretroshare/src/services/p3chatservice.cc +++ b/libretroshare/src/services/p3chatservice.cc @@ -1352,7 +1352,7 @@ void p3ChatService::denyLobbyInvite(const ChatLobbyId& lobby_id) _lobby_invites_queue.erase(it) ; } -void p3ChatService::createChatLobby(const std::string& lobby_name,const std::list& invited_friends) +ChatLobbyId p3ChatService::createChatLobby(const std::string& lobby_name,const std::list& invited_friends) { std::cerr << "Creating a new Chat lobby !!" << std::endl; ChatLobbyId lobby_id ; @@ -1376,6 +1376,8 @@ void p3ChatService::createChatLobby(const std::string& lobby_name,const std::lis for(std::list::const_iterator it(invited_friends.begin());it!=invited_friends.end();++it) invitePeerToLobby(lobby_id,*it) ; + + return lobby_id ; } void p3ChatService::unsubscribeChatLobby(const ChatLobbyId& id) diff --git a/libretroshare/src/services/p3chatservice.h b/libretroshare/src/services/p3chatservice.h index a165abb9d..7df4fd905 100644 --- a/libretroshare/src/services/p3chatservice.h +++ b/libretroshare/src/services/p3chatservice.h @@ -159,6 +159,7 @@ class p3ChatService: public p3Service, public p3Config, public pqiMonitor bool setNickNameForChatLobby(const ChatLobbyId& lobby_id,const std::string& nick) ; void unsubscribeChatLobby(const ChatLobbyId& lobby_id) ; bool getNickNameForChatLobby(const ChatLobbyId& lobby_id,std::string& nick) ; + ChatLobbyId createChatLobby(const std::string& lobby_name,const std::list& invited_friends) ; protected: /************* from p3Config *******************/ @@ -210,7 +211,6 @@ class p3ChatService: public p3Service, public p3Config, public pqiMonitor void handleRecvLobbyInvite(RsChatLobbyInviteItem*) ; bool acceptLobbyInvite(const ChatLobbyId&) ; void denyLobbyInvite(const ChatLobbyId&) ; - void createChatLobby(const std::string& lobby_name,const std::list& invited_friends) ; RsChatAvatarItem *makeOwnAvatarItem() ; RsChatStatusItem *makeOwnCustomStateStringItem() ; diff --git a/retroshare-gui/src/gui/common/FriendList.cpp b/retroshare-gui/src/gui/common/FriendList.cpp index b441326e2..5ecd786f0 100644 --- a/retroshare-gui/src/gui/common/FriendList.cpp +++ b/retroshare-gui/src/gui/common/FriendList.cpp @@ -349,7 +349,7 @@ void FriendList::peerTreeWidgetCostumPopupMenu() mnu->addAction(inviteToLobbyAction); } - mnu->addAction(QIcon(IMAGE_CHAT),tr("create new")) ; + mnu->addAction(QIcon(IMAGE_CHAT),tr("create new"),this,SLOT(createchatlobby())) ; contextMnu.addAction(QIcon(IMAGE_MSG), tr("Message Friend"), this, SLOT(msgfriend())); @@ -1414,6 +1414,26 @@ void FriendList::inviteToLobby() rsMsgs->invitePeerToLobby(ChatLobbyId(QString::fromStdString(lobby_id).toULongLong()), peer_id); } +void FriendList::createchatlobby() +{ + QTreeWidgetItem *c = getCurrentPeer(); + + if (c == NULL) + return; + + std::list friend_list ; + + std::string peer_id = getRsId(c) ; + friend_list.push_back(peer_id) ; + + std::string lobby_name = "New lobby (Plz add the code to select this name at creation time)" ; + + // add to group + ChatLobbyId id = rsMsgs->createChatLobby(lobby_name, friend_list); + + std::cerr << "gui: Created chat lobby " << std::hex << id << std::endl ; +} + void FriendList::addToGroup() { QTreeWidgetItem *c = getCurrentPeer(); diff --git a/retroshare-gui/src/gui/common/FriendList.h b/retroshare-gui/src/gui/common/FriendList.h index 51396b139..14e72046b 100644 --- a/retroshare-gui/src/gui/common/FriendList.h +++ b/retroshare-gui/src/gui/common/FriendList.h @@ -124,6 +124,7 @@ private slots: void removeGroup(); void inviteToLobby(); + void createchatlobby(); }; #endif // FRIENDLIST_H