From 7c3ad32436f2c6a48aca3d9473ef829e152da563 Mon Sep 17 00:00:00 2001 From: csoler Date: Thu, 5 Mar 2015 21:51:12 +0000 Subject: [PATCH] added response to lobby invites git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.6-LobbiesWithGXSIds@7983 b45a01b8-16f6-495d-af2f-9b41ad6348cc --- retroshare-gui/src/gui/ChatLobbyWidget.cpp | 51 +++++++++++++------ .../src/gui/chat/ChatLobbyDialog.cpp | 3 +- 2 files changed, 36 insertions(+), 18 deletions(-) diff --git a/retroshare-gui/src/gui/ChatLobbyWidget.cpp b/retroshare-gui/src/gui/ChatLobbyWidget.cpp index 8b15f55a2..86ec122fb 100644 --- a/retroshare-gui/src/gui/ChatLobbyWidget.cpp +++ b/retroshare-gui/src/gui/ChatLobbyWidget.cpp @@ -834,30 +834,49 @@ void ChatLobbyWidget::displayChatLobbyEvent(qulonglong lobby_id, int event_type, void ChatLobbyWidget::readChatLobbyInvites() { - std::list invites; - rsMsgs->getPendingChatLobbyInvites(invites); + std::list invites; + rsMsgs->getPendingChatLobbyInvites(invites); + + RsGxsId default_id ; + rsMsgs->getDefaultIdentityForChatLobby(default_id) ; for(std::list::const_iterator it(invites.begin());it!=invites.end();++it) { -#warning We need here a QDialog that also asks for the identity to use. -#ifdef REMOVED_CODE - QDialog dialog ; + QMessageBox mb(QObject::tr("Join chat lobby"), + tr("%1 invites you to chat lobby named %2").arg(QString::fromUtf8(rsPeers->getPeerName((*it).peer_id).c_str())).arg(RsHtml::plainText(it->lobby_name)), + QMessageBox::Question, QMessageBox::Yes,QMessageBox::No, 0); - if (QMessageBox::Ok == QMessageBox::question(this, tr("Invitation to chat lobby"), tr("%1 invites you to chat lobby named %2").arg(QString::fromUtf8(rsPeers->getPeerName((*it).peer_id).c_str())).arg(RsHtml::plainText(it->lobby_name)), QMessageBox::Ok, QMessageBox::Ignore)) { - std::cerr << "Accepting invite to lobby " << (*it).lobby_name << std::endl; + GxsIdChooser *idchooser = new GxsIdChooser ; + idchooser->loadIds(IDCHOOSER_ID_REQUIRED,default_id) ; - rsMsgs->acceptLobbyInvite((*it).lobby_id); + mb.layout()->addWidget(new QLabel(tr("Choose an identity for this lobby:"))) ; + mb.layout()->addWidget(idchooser) ; - RsPeerId vpid; - if(rsMsgs->getVirtualPeerId((*it).lobby_id,vpid )) { - ChatDialog::chatFriend(ChatId((*it).lobby_id),true); - } else { - std::cerr << "No lobby known with id 0x" << std::hex << (*it).lobby_id << std::dec << std::endl; - } - } else { + int res = mb.exec() ; + + if (res == QMessageBox::No) + { rsMsgs->denyLobbyInvite((*it).lobby_id); + continue ; } -#endif + + RsGxsId chosen_id ; + idchooser->getChosenId(chosen_id) ; + + if(chosen_id.isNull()) + { + rsMsgs->denyLobbyInvite((*it).lobby_id); + continue ; + } + + rsMsgs->acceptLobbyInvite((*it).lobby_id,chosen_id); + + RsPeerId vpid; + if(rsMsgs->getVirtualPeerId((*it).lobby_id,vpid )) + ChatDialog::chatFriend(ChatId((*it).lobby_id),true); + else + std::cerr << "No lobby known with id 0x" << std::hex << (*it).lobby_id << std::dec << std::endl; + } } diff --git a/retroshare-gui/src/gui/chat/ChatLobbyDialog.cpp b/retroshare-gui/src/gui/chat/ChatLobbyDialog.cpp index 6fb6f657b..fbf7e515c 100644 --- a/retroshare-gui/src/gui/chat/ChatLobbyDialog.cpp +++ b/retroshare-gui/src/gui/chat/ChatLobbyDialog.cpp @@ -322,8 +322,7 @@ void ChatLobbyDialog::addChatMsg(const ChatMessage& msg) QString message = QString::fromUtf8(msg.msg.c_str()); RsGxsId gxs_id = msg.lobby_peer_gxs_id ; - if(!isParticipantMuted(gxs_id)) { -#warning We could change addChatMsg to display the peer's icon, passing a ChatId + if(!isParticipantMuted(gxs_id)) { // We could change addChatMsg to display the peers icon, passing a ChatId RsIdentityDetails details ; QString name ;