diff --git a/libretroshare/src/retroshare/rsmsgs.h b/libretroshare/src/retroshare/rsmsgs.h index b8157c500..f9d939871 100644 --- a/libretroshare/src/retroshare/rsmsgs.h +++ b/libretroshare/src/retroshare/rsmsgs.h @@ -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 participating_friends ; // list of direct friend who participate. Used to broadcast sent messages. + std::list 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 &chats) = 0; -virtual int getPrivateChatQueueCount(bool incoming) = 0; +virtual int getPrivateChatQueueCount(bool incoming) = 0; virtual bool getPrivateChatQueueIds(bool incoming, std::list &ids) = 0; virtual bool getPrivateChatQueue(bool incoming, const std::string& id, std::list &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& cl_info) = 0; +virtual void invitePeerToLobby(const ChatLobbyId& lobby_id,const std::string& peer_id) = 0; + /****************************************/ }; diff --git a/libretroshare/src/rsserver/p3msgs.cc b/libretroshare/src/rsserver/p3msgs.cc index 56fb174a7..31cc6ec1e 100644 --- a/libretroshare/src/rsserver/p3msgs.cc +++ b/libretroshare/src/rsserver/p3msgs.cc @@ -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& linfos) +{ + mChatSrv->getChatLobbyList(linfos) ; +} +void p3Msgs::invitePeerToLobby(const ChatLobbyId& lobby_id, const std::string& peer_id) +{ + mChatSrv->invitePeerToLobby(lobby_id,peer_id) ; +} + + diff --git a/libretroshare/src/rsserver/p3msgs.h b/libretroshare/src/rsserver/p3msgs.h index 39b39e903..57f68c780 100644 --- a/libretroshare/src/rsserver/p3msgs.h +++ b/libretroshare/src/rsserver/p3msgs.h @@ -167,6 +167,9 @@ class p3Msgs: public RsMsgs /****************************************/ + virtual bool sendLobbyChat(const std::wstring&, const ChatLobbyId&) ; + virtual void getChatLobbyList(std::list >&) ; + virtual void invitePeerToLobby(const ChatLobbyId&, const std::string&) ; private: diff --git a/libretroshare/src/services/p3chatservice.cc b/libretroshare/src/services/p3chatservice.cc index 8c7e02040..51e29ea95 100644 --- a/libretroshare/src/services/p3chatservice.cc +++ b/libretroshare/src/services/p3chatservice.cc @@ -1135,3 +1135,33 @@ void p3ChatService::statusChange(const std::list &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& 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; +} + diff --git a/libretroshare/src/services/p3chatservice.h b/libretroshare/src/services/p3chatservice.h index 619e67578..a1d5f8eea 100644 --- a/libretroshare/src/services/p3chatservice.h +++ b/libretroshare/src/services/p3chatservice.h @@ -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 >&) ; + void invitePeerToLobby(const ChatLobbyId&, const std::string&) ; + + protected: /************* from p3Config *******************/ virtual RsSerialiser *setupSerialiser() ; diff --git a/retroshare-gui/src/RetroShare.pro b/retroshare-gui/src/RetroShare.pro index 212417c8e..f56cfe4e3 100644 --- a/retroshare-gui/src/RetroShare.pro +++ b/retroshare-gui/src/RetroShare.pro @@ -270,6 +270,7 @@ HEADERS += rshare.h \ gui/profile/StatusMessage.h \ gui/chat/PopupChatWindow.h \ gui/chat/PopupChatDialog.h \ + gui/chat/ChatLobbyDialog.h \ gui/chat/HandleRichText.h \ gui/chat/ChatStyle.h \ gui/channels/CreateChannel.h \ @@ -405,6 +406,7 @@ FORMS += gui/StartDialog.ui \ gui/channels/ShareKey.ui \ gui/chat/PopupChatWindow.ui \ gui/chat/PopupChatDialog.ui \ + gui/chat/ChatLobbyDialog.ui \ gui/connect/ConfCertDialog.ui \ gui/msgs/MessageComposer.ui \ gui/msgs/MessageWindow.ui\ @@ -527,6 +529,7 @@ SOURCES += main.cpp \ gui/channels/ShareKey.cpp \ gui/chat/PopupChatWindow.cpp \ gui/chat/PopupChatDialog.cpp \ +# gui/chat/ChatLobbyDialog.cpp \ gui/chat/HandleRichText.cpp \ gui/chat/ChatStyle.cpp \ gui/connect/ConfCertDialog.cpp \ diff --git a/retroshare-gui/src/gui/chat/ChatLobbyDialog.ui b/retroshare-gui/src/gui/chat/ChatLobbyDialog.ui new file mode 100644 index 000000000..e4ef50813 --- /dev/null +++ b/retroshare-gui/src/gui/chat/ChatLobbyDialog.ui @@ -0,0 +1,907 @@ + + + PopupChatDialog + + + Qt::NonModal + + + + 0 + 0 + 662 + 499 + + + + MainWindow + + + + + + + 0 + + + + + 0 + + + 1 + + + 0 + + + 0 + + + + + + 0 + 0 + + + + + 14 + 16777215 + + + + QFrame#frame{border: transparent} + + + QFrame::StyledPanel + + + QFrame::Raised + + + + 0 + + + + + + 14 + 31 + + + + + 14 + 31 + + + + + + + + 16 + 31 + + + + true + + + + + + + Qt::Vertical + + + + 12 + 335 + + + + + + + + + + + + 132 + 16777215 + + + + border: transparent; + + + QFrame::StyledPanel + + + QFrame::Raised + + + + 3 + + + 9 + + + 3 + + + 9 + + + + + Qt::Vertical + + + + 61 + 141 + + + + + + + + + 116 + 116 + + + + + 116 + 116 + + + + + + + + + + + + + + QFrame#frame_2{border: transparent} + + + QFrame::StyledPanel + + + QFrame::Raised + + + + 2 + + + 3 + + + 3 + + + 3 + + + + + + 0 + 0 + + + + + Arial + 13 + 75 + true + true + + + + TextLabel + + + + + + + + Arial + 9 + + + + TextLabel + + + + + + + + + + QFrame#infoframe{border: 1px solid #DCDC41; +border-radius: 6px; +background: #FFFFD7; +background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1, +stop:0 #FFFFD7, stop:1 #FFFFB2);} + + + QFrame::StyledPanel + + + QFrame::Raised + + + + 6 + + + + + + 16 + 16 + + + + + + + :/images/info16.png + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + + + + + TextLabel + + + + + + + + 16 + 16 + + + + Qt::NoFocus + + + Close + + + QToolButton +{ + border-image: url(:/images/closenormal.png) +} + +QToolButton:hover +{ +border-image: url(:/images/closehover.png) +} + +QToolButton:pressed { +border-image: url(:/images/closepressed.png) +} + + + + + + true + + + + + + + + + + + 347 + 30 + + + + + 16777215 + 30 + + + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + 1 + + + 6 + + + + + + 28 + 28 + + + + + 28 + 28 + + + + Qt::NoFocus + + + QPushButton::menu-indicator { +subcontrol-origin: padding; +subcontrol-position: bottom right; +} + +QPushButton::menu-indicator:pressed, QPushButton::menu-indicator:open { +position: relative; +top: 1px; left: 1px; /* shift the arrow by 2 px */ +} + +QPushButton:hover { +border: 1px solid #CCCCCC; +} + + + + + + + :/images/configure.png:/images/configure.png + + + + 22 + 22 + + + + true + + + + + + + + 28 + 28 + + + + + 28 + 28 + + + + Qt::NoFocus + + + Attach a Picture + + + + + + + :/images/add_image24.png:/images/add_image24.png + + + + 24 + 24 + + + + true + + + + + + + + 28 + 28 + + + + Qt::NoFocus + + + Add a File for your Friend + + + + + + + :/images/add-share24.png:/images/add-share24.png + + + + 24 + 24 + + + + true + + + + + + + Qt::Horizontal + + + + 190 + 25 + + + + + + + + Send + + + + + + + + 0 + 0 + + + + + 28 + 28 + + + + + 28 + 28 + + + + Qt::NoFocus + + + + + + + 24 + 24 + + + + true + + + + + + + + 28 + 28 + + + + + 28 + 28 + + + + Qt::NoFocus + + + Bold + + + + + + + ../../../../../../../Dokumente und Einstellungen/Linux/.designer/backup../../../../../../../Dokumente und Einstellungen/Linux/.designer/backup + + + false + + + true + + + + + + + + 28 + 28 + + + + + 28 + 28 + + + + Qt::NoFocus + + + Underline + + + + + + + ../../../../../../../Dokumente und Einstellungen/Linux/.designer/backup../../../../../../../Dokumente und Einstellungen/Linux/.designer/backup + + + false + + + true + + + + + + + + 28 + 28 + + + + + 28 + 28 + + + + Qt::NoFocus + + + Italic + + + + + + + ../../../../../../../Dokumente und Einstellungen/Linux/.designer/backup../../../../../../../Dokumente und Einstellungen/Linux/.designer/backup + + + false + + + true + + + + + + + + 28 + 28 + + + + + 28 + 28 + + + + Qt::NoFocus + + + Font + + + + + + + ../../../../../../../Dokumente und Einstellungen/Linux/.designer/backup../../../../../../../Dokumente und Einstellungen/Linux/.designer/backup + + + false + + + true + + + + + + + + 28 + 28 + + + + + 28 + 28 + + + + Qt::NoFocus + + + Text Color + + + + + + true + + + + + + + + + + + + + 1 + + + Qt::Vertical + + + 2 + + + + + + + + 0 + 0 + + + + + 0 + 100 + + + + QTextBrowser{border: 1px solid #B8B6B1; +border-radius: 6px; +background: white;} + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Ubuntu'; font-size:11pt; font-weight:400; font-style:normal;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"></p></body></html> + + + true + + + true + + + + + + + + + 0 + + + + + + + + 0 + + + 3 + + + + + + + + 0 + 0 + + + + + 0 + 30 + + + + Qt::CustomContextMenu + + + QTextEdit{border: 1px solid #B8B6B1; +border-radius: 6px; +background: white;} + + + + + + + + 18 + 18 + + + + + 18 + 18 + + + + T + + + Qt::AlignCenter + + + + + + + + + + + + + Bold + + + + + Italic + + + + + Underline + + + + + Strike + + + + + + :/images/edit-clear-history.png:/images/edit-clear-history.png + + + Clear Chat History + + + + + true + + + Disable Emoticons + + + + + Save Chat History + + + Save Chat History + + + + + Clear offline messages + + + + + Browse Message History + + + Browse History + + + + + + :/images/edit-clear-history.png:/images/edit-clear-history.png + + + Delete Chat History + + + Deletes all stored and displayed chat history + + + + + + AvatarWidget + QWidget +
gui/common/AvatarWidget.h
+ 1 +
+
+ + + + +
diff --git a/retroshare-gui/src/gui/common/FriendList.cpp b/retroshare-gui/src/gui/common/FriendList.cpp index 81c0b380d..3e8488e60 100644 --- a/retroshare-gui/src/gui/common/FriendList.cpp +++ b/retroshare-gui/src/gui/common/FriendList.cpp @@ -292,143 +292,162 @@ void FriendList::peerTreeWidgetCostumPopupMenu() contextMnu.addAction(widgetAction); // create menu entries - if (c) { // if a peer is selected - int type = c->type(); + if (c) + { // if a peer is selected + int type = c->type(); - // define header - switch (type) { - case TYPE_GROUP: - //this is a GPG key - textLabel->setText("" + tr("Group") + ""); - break; - case TYPE_GPG: - //this is a GPG key - textLabel->setText("" + tr("Friend") + ""); - break; - case TYPE_SSL: - //this is a SSL key - textLabel->setText("" + tr("Location") + ""); - break; - } + // define header + switch (type) { + case TYPE_GROUP: + //this is a GPG key + textLabel->setText("" + tr("Group") + ""); + break; + case TYPE_GPG: + //this is a GPG key + textLabel->setText("" + tr("Friend") + ""); + break; + case TYPE_SSL: + //this is a SSL key + textLabel->setText("" + tr("Location") + ""); + break; + } - switch (type) { - case TYPE_GROUP: - { - bool standard = c->data(COLUMN_DATA, ROLE_STANDARD).toBool(); + switch (type) { + case TYPE_GROUP: + { + bool standard = c->data(COLUMN_DATA, ROLE_STANDARD).toBool(); - contextMnu.addAction(QIcon(IMAGE_MSG), tr("Message Group"), this, SLOT(msgfriend())); - contextMnu.addAction(QIcon(IMAGE_ADDFRIEND), tr("Add Friend"), this, SLOT(addFriend())); + contextMnu.addAction(QIcon(IMAGE_MSG), tr("Message Group"), this, SLOT(msgfriend())); + contextMnu.addAction(QIcon(IMAGE_ADDFRIEND), tr("Add Friend"), this, SLOT(addFriend())); - contextMnu.addSeparator(); + contextMnu.addSeparator(); - QAction *action = contextMnu.addAction(QIcon(IMAGE_EDIT), tr("Edit Group"), this, SLOT(editGroup())); - action->setDisabled(standard); + QAction *action = contextMnu.addAction(QIcon(IMAGE_EDIT), tr("Edit Group"), this, SLOT(editGroup())); + action->setDisabled(standard); - action = contextMnu.addAction(QIcon(IMAGE_REMOVE), tr("Remove Group"), this, SLOT(removeGroup())); - action->setDisabled(standard); - } - break; - case TYPE_GPG: - case TYPE_SSL: - { - contextMnu.addAction(QIcon(IMAGE_CHAT), tr("Chat"), this, SLOT(chatfriendproxy())); - contextMnu.addAction(QIcon(IMAGE_MSG), tr("Message Friend"), this, SLOT(msgfriend())); + action = contextMnu.addAction(QIcon(IMAGE_REMOVE), tr("Remove Group"), this, SLOT(removeGroup())); + action->setDisabled(standard); - contextMnu.addSeparator(); + contextMnu.addAction(QIcon(IMAGE_CHAT), tr("Create chat lobby"), this, SLOT(createchatlobby())); + } + break; + case TYPE_GPG: + case TYPE_SSL: + { + contextMnu.addAction(QIcon(IMAGE_CHAT), tr("Chat"), this, SLOT(chatfriendproxy())); + QMenu *mnu = contextMnu.addMenu(QIcon(IMAGE_CHAT), tr("Invite to chat lobby")) ; - contextMnu.addAction(QIcon(IMAGE_FRIENDINFO), tr("Friend Details"), this, SLOT(configurefriend())); -// contextMnu.addAction(QIcon(IMAGE_PEERINFO), tr("Profile View"), this, SLOT(viewprofile())); -// action = contextMnu.addAction(QIcon(IMAGE_EXPORTFRIEND), tr("Export Friend"), this, SLOT(exportfriend())); + std::list cl_infos ; - if (type == TYPE_GPG) { - contextMnu.addAction(QIcon(IMAGE_EXPORTFRIEND), tr("Recommend this Friend to..."), this, SLOT(recommendfriend())); - } + rsMsgs->getChatLobbyList(cl_infos) ; - contextMnu.addAction(QIcon(IMAGE_CONNECT), tr("Connect To Friend"), this, SLOT(connectfriend())); + for(std::list::const_iterator it(cl_infos.begin());it!=cl_infos.end();++it) + { + QAction* inviteToLobbyAction = new QAction(QString::fromUtf8((*it).display_name.c_str()), mnu); + inviteToLobbyAction->setData(QString::fromStdString((*it).lobby_id.c_str())); + connect(inviteToLobbyAction, SIGNAL(triggered()), this, SLOT(inviteToLobby())); + mnu->addAction(inviteToLobbyAction); + } - if (type == TYPE_GPG) { - contextMnu.addAction(QIcon(IMAGE_COPYLINK), tr("Copy RetroShare Link"), this, SLOT(copyLink())); - } + mnu->addAction(QIcon(IMAGE_CHAT),tr("create new")) ; - QAction *action = contextMnu.addAction(QIcon(IMAGE_PASTELINK), tr("Paste Friend Link"), this, SLOT(pastePerson())); - if (RSLinkClipboard::empty(RetroShareLink::TYPE_PERSON)) { - action->setDisabled(true); - } + contextMnu.addAction(QIcon(IMAGE_MSG), tr("Message Friend"), this, SLOT(msgfriend())); - if (type == TYPE_GPG) { - contextMnu.addAction(QIcon(IMAGE_DENYFRIEND), tr("Deny Friend"), this, SLOT(removefriend())); - } else { - //this is a SSL key - contextMnu.addAction(QIcon(IMAGE_REMOVEFRIEND), tr("Remove Friend Location"), this, SLOT(removefriend())); - } + contextMnu.addSeparator(); - if (mShowGroups && type == TYPE_GPG) { - QMenu* addToGroupMenu = NULL; - QMenu* moveToGroupMenu = NULL; + contextMnu.addAction(QIcon(IMAGE_FRIENDINFO), tr("Friend Details"), this, SLOT(configurefriend())); + // contextMnu.addAction(QIcon(IMAGE_PEERINFO), tr("Profile View"), this, SLOT(viewprofile())); + // action = contextMnu.addAction(QIcon(IMAGE_EXPORTFRIEND), tr("Export Friend"), this, SLOT(exportfriend())); - std::list groupInfoList; - rsPeers->getGroupInfoList(groupInfoList); + if (type == TYPE_GPG) { + contextMnu.addAction(QIcon(IMAGE_EXPORTFRIEND), tr("Recommend this Friend to..."), this, SLOT(recommendfriend())); + } - GroupDefs::sortByName(groupInfoList); + contextMnu.addAction(QIcon(IMAGE_CONNECT), tr("Connect To Friend"), this, SLOT(connectfriend())); - std::string gpgId = getRsId(c); + if (type == TYPE_GPG) { + contextMnu.addAction(QIcon(IMAGE_COPYLINK), tr("Copy RetroShare Link"), this, SLOT(copyLink())); + } - QTreeWidgetItem *parent = c->parent(); + QAction *action = contextMnu.addAction(QIcon(IMAGE_PASTELINK), tr("Paste Friend Link"), this, SLOT(pastePerson())); + if (RSLinkClipboard::empty(RetroShareLink::TYPE_PERSON)) { + action->setDisabled(true); + } - bool foundGroup = false; - // add action for all groups, except the own group - for (std::list::iterator groupIt = groupInfoList.begin(); groupIt != groupInfoList.end(); groupIt++) { - if (std::find(groupIt->peerIds.begin(), groupIt->peerIds.end(), gpgId) == groupIt->peerIds.end()) { - if (parent) { - if (addToGroupMenu == NULL) { - addToGroupMenu = new QMenu(tr("Add to group"), &contextMnu); - } - QAction* addToGroupAction = new QAction(GroupDefs::name(*groupIt), addToGroupMenu); - addToGroupAction->setData(QString::fromStdString(groupIt->id)); - connect(addToGroupAction, SIGNAL(triggered()), this, SLOT(addToGroup())); - addToGroupMenu->addAction(addToGroupAction); - } + if (type == TYPE_GPG) { + contextMnu.addAction(QIcon(IMAGE_DENYFRIEND), tr("Deny Friend"), this, SLOT(removefriend())); + } else { + //this is a SSL key + contextMnu.addAction(QIcon(IMAGE_REMOVEFRIEND), tr("Remove Friend Location"), this, SLOT(removefriend())); + } - if (moveToGroupMenu == NULL) { - moveToGroupMenu = new QMenu(tr("Move to group"), &contextMnu); - } - QAction* moveToGroupAction = new QAction(GroupDefs::name(*groupIt), moveToGroupMenu); - moveToGroupAction->setData(QString::fromStdString(groupIt->id)); - connect(moveToGroupAction, SIGNAL(triggered()), this, SLOT(moveToGroup())); - moveToGroupMenu->addAction(moveToGroupAction); - } else { - foundGroup = true; - } - } + if (mShowGroups && type == TYPE_GPG) { + QMenu* addToGroupMenu = NULL; + QMenu* moveToGroupMenu = NULL; - if (addToGroupMenu || moveToGroupMenu || foundGroup) { - QMenu *groupsMenu = contextMnu.addMenu(QIcon(IMAGE_GROUP16), tr("Groups")); + std::list groupInfoList; + rsPeers->getGroupInfoList(groupInfoList); - if (addToGroupMenu) { - groupsMenu->addMenu(addToGroupMenu); - } + GroupDefs::sortByName(groupInfoList); - if (moveToGroupMenu) { - groupsMenu->addMenu(moveToGroupMenu); - } + std::string gpgId = getRsId(c); - if (foundGroup) { - // add remove from group - if (parent && parent->type() == TYPE_GROUP) { - QAction *removeFromGroup = groupsMenu->addAction(tr("Remove from group")); - removeFromGroup->setData(parent->data(COLUMN_DATA, ROLE_ID)); - connect(removeFromGroup, SIGNAL(triggered()), this, SLOT(removeFromGroup())); - } + QTreeWidgetItem *parent = c->parent(); - QAction *removeFromAllGroups = groupsMenu->addAction(tr("Remove from all groups")); - removeFromAllGroups->setData(""); - connect(removeFromAllGroups, SIGNAL(triggered()), this, SLOT(removeFromGroup())); - } - } - } - } - } - } else { + bool foundGroup = false; + // add action for all groups, except the own group + for (std::list::iterator groupIt = groupInfoList.begin(); groupIt != groupInfoList.end(); groupIt++) { + if (std::find(groupIt->peerIds.begin(), groupIt->peerIds.end(), gpgId) == groupIt->peerIds.end()) { + if (parent) { + if (addToGroupMenu == NULL) { + addToGroupMenu = new QMenu(tr("Add to group"), &contextMnu); + } + QAction* addToGroupAction = new QAction(GroupDefs::name(*groupIt), addToGroupMenu); + addToGroupAction->setData(QString::fromStdString(groupIt->id)); + connect(addToGroupAction, SIGNAL(triggered()), this, SLOT(addToGroup())); + addToGroupMenu->addAction(addToGroupAction); + } + + if (moveToGroupMenu == NULL) { + moveToGroupMenu = new QMenu(tr("Move to group"), &contextMnu); + } + QAction* moveToGroupAction = new QAction(GroupDefs::name(*groupIt), moveToGroupMenu); + moveToGroupAction->setData(QString::fromStdString(groupIt->id)); + connect(moveToGroupAction, SIGNAL(triggered()), this, SLOT(moveToGroup())); + moveToGroupMenu->addAction(moveToGroupAction); + } else { + foundGroup = true; + } + } + + if (addToGroupMenu || moveToGroupMenu || foundGroup) { + QMenu *groupsMenu = contextMnu.addMenu(QIcon(IMAGE_GROUP16), tr("Groups")); + + if (addToGroupMenu) { + groupsMenu->addMenu(addToGroupMenu); + } + + if (moveToGroupMenu) { + groupsMenu->addMenu(moveToGroupMenu); + } + + if (foundGroup) { + // add remove from group + if (parent && parent->type() == TYPE_GROUP) { + QAction *removeFromGroup = groupsMenu->addAction(tr("Remove from group")); + removeFromGroup->setData(parent->data(COLUMN_DATA, ROLE_ID)); + connect(removeFromGroup, SIGNAL(triggered()), this, SLOT(removeFromGroup())); + } + + QAction *removeFromAllGroups = groupsMenu->addAction(tr("Remove from all groups")); + removeFromAllGroups->setData(""); + connect(removeFromAllGroups, SIGNAL(triggered()), this, SLOT(removeFromGroup())); + } + } + } + } + } + } else { QAction *action = contextMnu.addAction(QIcon(IMAGE_PASTELINK), tr("Paste Friend Link"), this, SLOT(pastePerson())); if (RSLinkClipboard::empty(RetroShareLink::TYPE_PERSON)) { action->setDisabled(true); @@ -1371,6 +1390,30 @@ void FriendList::configurefriend() ConfCertDialog::showIt(getRsId(getCurrentPeer()), ConfCertDialog::PageDetails); } +void FriendList::inviteToLobby() +{ + QTreeWidgetItem *c = getCurrentPeer(); + + if (c == NULL) { + return; + } + + if (c->type() != TYPE_SSL) { + // wrong type + return; + } + + std::string lobby_id = qobject_cast(sender())->data().toString().toStdString(); + + if(lobby_id.empty()) + return; + + std::string peer_id = getRsId(c) ; + + // add to group + rsMsgs->invitePeerToLobby(ChatLobbyId(lobby_id), peer_id); +} + 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 db633cf3c..51396b139 100644 --- a/retroshare-gui/src/gui/common/FriendList.h +++ b/retroshare-gui/src/gui/common/FriendList.h @@ -122,6 +122,8 @@ private slots: void editGroup(); void removeGroup(); + + void inviteToLobby(); }; #endif // FRIENDLIST_H