mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-02 14:16:16 -04:00
merged in new lobbies with GXS ids. Old peers and new peers cannot see each others lobby lists. Invitations still work and can be used to transfer a lobby ID between versions. Messages of old and new peers will not be visible to each other
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7986 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
2044575067
commit
f9c78ebd61
22 changed files with 1430 additions and 980 deletions
|
@ -13,11 +13,13 @@
|
|||
#include "chat/ChatLobbyUserNotify.h"
|
||||
#include "util/HandleRichText.h"
|
||||
#include "util/QtVersion.h"
|
||||
#include <gui/settings/rsharesettings.h>
|
||||
#include "gui/settings/rsharesettings.h"
|
||||
#include "gui/gxs/GxsIdDetails.h"
|
||||
|
||||
#include "retroshare/rsmsgs.h"
|
||||
#include "retroshare/rspeers.h"
|
||||
#include "retroshare/rsnotify.h"
|
||||
#include "retroshare/rsidentity.h"
|
||||
|
||||
#define COLUMN_NAME 0
|
||||
#define COLUMN_USER_COUNT 1
|
||||
|
@ -94,28 +96,28 @@ ChatLobbyWidget::ChatLobbyWidget(QWidget *parent, Qt::WindowFlags flags)
|
|||
privateSubLobbyItem->setText(COLUMN_NAME, tr("Private Subscribed Lobbies"));
|
||||
privateSubLobbyItem->setData(COLUMN_NAME, ROLE_SORT, "1");
|
||||
// privateLobbyItem->setIcon(COLUMN_NAME, QIcon(IMAGE_PRIVATE));
|
||||
privateSubLobbyItem->setData(COLUMN_DATA, ROLE_PRIVACYLEVEL, RS_CHAT_LOBBY_PRIVACY_LEVEL_PRIVATE);
|
||||
privateSubLobbyItem->setData(COLUMN_DATA, ROLE_PRIVACYLEVEL, CHAT_LOBBY_PRIVACY_LEVEL_PRIVATE);
|
||||
ui.lobbyTreeWidget->insertTopLevelItem(0, privateSubLobbyItem);
|
||||
|
||||
publicSubLobbyItem = new RSTreeWidgetItem(compareRole, TYPE_FOLDER);
|
||||
publicSubLobbyItem->setText(COLUMN_NAME, tr("Public Subscribed Lobbies"));
|
||||
publicSubLobbyItem->setData(COLUMN_NAME, ROLE_SORT, "2");
|
||||
// publicLobbyItem->setIcon(COLUMN_NAME, QIcon(IMAGE_PUBLIC));
|
||||
publicSubLobbyItem->setData(COLUMN_DATA, ROLE_PRIVACYLEVEL, RS_CHAT_LOBBY_PRIVACY_LEVEL_PUBLIC);
|
||||
publicSubLobbyItem->setData(COLUMN_DATA, ROLE_PRIVACYLEVEL, CHAT_LOBBY_PRIVACY_LEVEL_PUBLIC);
|
||||
ui.lobbyTreeWidget->insertTopLevelItem(1, publicSubLobbyItem);
|
||||
|
||||
privateLobbyItem = new RSTreeWidgetItem(compareRole, TYPE_FOLDER);
|
||||
privateLobbyItem->setText(COLUMN_NAME, tr("Private Lobbies"));
|
||||
privateLobbyItem->setData(COLUMN_NAME, ROLE_SORT, "3");
|
||||
// privateLobbyItem->setIcon(COLUMN_NAME, QIcon(IMAGE_PRIVATE));
|
||||
privateLobbyItem->setData(COLUMN_DATA, ROLE_PRIVACYLEVEL, RS_CHAT_LOBBY_PRIVACY_LEVEL_PRIVATE);
|
||||
privateLobbyItem->setData(COLUMN_DATA, ROLE_PRIVACYLEVEL, CHAT_LOBBY_PRIVACY_LEVEL_PRIVATE);
|
||||
ui.lobbyTreeWidget->insertTopLevelItem(2, privateLobbyItem);
|
||||
|
||||
publicLobbyItem = new RSTreeWidgetItem(compareRole, TYPE_FOLDER);
|
||||
publicLobbyItem->setText(COLUMN_NAME, tr("Public Lobbies"));
|
||||
publicLobbyItem->setData(COLUMN_NAME, ROLE_SORT, "4");
|
||||
// publicLobbyItem->setIcon(COLUMN_NAME, QIcon(IMAGE_PUBLIC));
|
||||
publicLobbyItem->setData(COLUMN_DATA, ROLE_PRIVACYLEVEL, RS_CHAT_LOBBY_PRIVACY_LEVEL_PUBLIC);
|
||||
publicLobbyItem->setData(COLUMN_DATA, ROLE_PRIVACYLEVEL, CHAT_LOBBY_PRIVACY_LEVEL_PUBLIC);
|
||||
ui.lobbyTreeWidget->insertTopLevelItem(3, publicLobbyItem);
|
||||
|
||||
ui.lobbyTreeWidget->expandAll();
|
||||
|
@ -212,31 +214,66 @@ void ChatLobbyWidget::lobbyTreeWidgetCustomPopupMenu(QPoint)
|
|||
action->setData(item->data(COLUMN_DATA, ROLE_PRIVACYLEVEL).toInt());
|
||||
}
|
||||
|
||||
if (item && item->type() == TYPE_LOBBY) {
|
||||
if (item->data(COLUMN_DATA, ROLE_SUBSCRIBED).toBool()) {
|
||||
contextMnu.addAction(QIcon(IMAGE_UNSUBSCRIBE), tr("Unsubscribe"), this, SLOT(unsubscribeItem()));
|
||||
} else {
|
||||
contextMnu.addAction(QIcon(IMAGE_SUBSCRIBE), tr("Subscribe"), this, SLOT(subscribeItem()));
|
||||
}
|
||||
if (item->data(COLUMN_DATA, ROLE_AUTOSUBSCRIBE).toBool()) {
|
||||
contextMnu.addAction(QIcon(IMAGE_AUTOSUBSCRIBE), tr("Remove Auto Subscribe"), this, SLOT(autoSubscribeItem()));
|
||||
} else {
|
||||
contextMnu.addAction(QIcon(IMAGE_SUBSCRIBE), tr("Add Auto Subscribe"), this, SLOT(autoSubscribeItem()));
|
||||
if (item && item->type() == TYPE_LOBBY)
|
||||
{
|
||||
if (item->data(COLUMN_DATA, ROLE_SUBSCRIBED).toBool())
|
||||
contextMnu.addAction(QIcon(IMAGE_UNSUBSCRIBE), tr("Leave this lobby"), this, SLOT(unsubscribeItem()));
|
||||
else
|
||||
{
|
||||
std::list<RsGxsId> own_identities ;
|
||||
rsIdentity->getOwnIds(own_identities) ;
|
||||
|
||||
QTreeWidgetItem *item = ui.lobbyTreeWidget->currentItem();
|
||||
uint32_t item_flags = item->data(COLUMN_DATA,ROLE_ID).toUInt() ;
|
||||
|
||||
if(own_identities.size() <= 1)
|
||||
{
|
||||
QAction *action = contextMnu.addAction(QIcon(IMAGE_SUBSCRIBE), tr("Enter this lobby"), this, SLOT(subscribeChatLobbyAs()));
|
||||
|
||||
if(own_identities.empty())
|
||||
action->setEnabled(false) ;
|
||||
else
|
||||
action->setData(QString::fromStdString((own_identities.front()).toStdString())) ;
|
||||
}
|
||||
else
|
||||
{
|
||||
QMenu *mnu = contextMnu.addMenu(QIcon(IMAGE_SUBSCRIBE),tr("Enter this lobby as...")) ;
|
||||
|
||||
for(std::list<RsGxsId>::const_iterator it=own_identities.begin();it!=own_identities.end();++it)
|
||||
{
|
||||
RsIdentityDetails idd ;
|
||||
rsIdentity->getIdDetails(*it,idd) ;
|
||||
|
||||
QPixmap pixmap ;
|
||||
|
||||
if(idd.mAvatar.mSize == 0 || !pixmap.loadFromData(idd.mAvatar.mData, idd.mAvatar.mSize, "PNG"))
|
||||
pixmap = QPixmap::fromImage(GxsIdDetails::makeDefaultIcon(*it)) ;
|
||||
|
||||
QAction *action = mnu->addAction(QIcon(pixmap), QString("%1 (%2)").arg(QString::fromUtf8(idd.mNickname.c_str()), QString::fromStdString((*it).toStdString())), this, SLOT(subscribeChatLobbyAs()));
|
||||
action->setData(QString::fromStdString((*it).toStdString())) ;
|
||||
}
|
||||
}
|
||||
|
||||
if (item->data(COLUMN_DATA, ROLE_AUTOSUBSCRIBE).toBool())
|
||||
contextMnu.addAction(QIcon(IMAGE_AUTOSUBSCRIBE), tr("Remove Auto Subscribe"), this, SLOT(autoSubscribeItem()));
|
||||
else
|
||||
contextMnu.addAction(QIcon(IMAGE_SUBSCRIBE), tr("Add Auto Subscribe"), this, SLOT(autoSubscribeItem()));
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
contextMnu.addSeparator();//-------------------------------------------------------------------
|
||||
contextMnu.addSeparator();//-------------------------------------------------------------------
|
||||
|
||||
showUserCountAct->setChecked(!ui.lobbyTreeWidget->isColumnHidden(COLUMN_USER_COUNT));
|
||||
showTopicAct->setChecked(!ui.lobbyTreeWidget->isColumnHidden(COLUMN_TOPIC));
|
||||
showSubscribeAct->setChecked(!ui.lobbyTreeWidget->isColumnHidden(COLUMN_SUBSCRIBED));
|
||||
showUserCountAct->setChecked(!ui.lobbyTreeWidget->isColumnHidden(COLUMN_USER_COUNT));
|
||||
showTopicAct->setChecked(!ui.lobbyTreeWidget->isColumnHidden(COLUMN_TOPIC));
|
||||
showSubscribeAct->setChecked(!ui.lobbyTreeWidget->isColumnHidden(COLUMN_SUBSCRIBED));
|
||||
|
||||
QMenu *menu = contextMnu.addMenu(tr("Columns"));
|
||||
menu->addAction(showUserCountAct);
|
||||
menu->addAction(showTopicAct);
|
||||
menu->addAction(showSubscribeAct);
|
||||
QMenu *menu = contextMnu.addMenu(tr("Columns"));
|
||||
menu->addAction(showUserCountAct);
|
||||
menu->addAction(showTopicAct);
|
||||
menu->addAction(showSubscribeAct);
|
||||
|
||||
contextMnu.exec(QCursor::pos());
|
||||
contextMnu.exec(QCursor::pos());
|
||||
}
|
||||
|
||||
void ChatLobbyWidget::lobbyChanged()
|
||||
|
@ -302,14 +339,11 @@ void ChatLobbyWidget::addChatPage(ChatLobbyDialog *d)
|
|||
_lobby_infos[id].last_typing_event = time(NULL) ;
|
||||
_lobby_infos[id].unread_count = 0;
|
||||
|
||||
std::list<ChatLobbyInfo> lobbies;
|
||||
rsMsgs->getChatLobbyList(lobbies);
|
||||
|
||||
for (std::list<ChatLobbyInfo>::const_iterator it = lobbies.begin(); it != lobbies.end();++it) {
|
||||
if (it->lobby_id == id) {
|
||||
_lobby_infos[id].default_icon = (it->lobby_privacy_level == RS_CHAT_LOBBY_PRIVACY_LEVEL_PRIVATE) ? QIcon(IMAGE_PRIVATE) : QIcon(IMAGE_PUBLIC);
|
||||
}
|
||||
}
|
||||
ChatLobbyInfo linfo ;
|
||||
if(rsMsgs->getChatLobbyInfo(id,linfo))
|
||||
_lobby_infos[id].default_icon = (linfo.lobby_flags & RS_CHAT_LOBBY_FLAGS_PUBLIC) ? QIcon(IMAGE_PUBLIC):QIcon(IMAGE_PRIVATE) ;
|
||||
else
|
||||
std::cerr << "(EE) cannot find info for lobby " << std::hex << id << std::dec << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -334,7 +368,7 @@ void ChatLobbyWidget::updateDisplay()
|
|||
std::vector<VisibleChatLobbyRecord> visibleLobbies;
|
||||
rsMsgs->getListOfNearbyChatLobbies(visibleLobbies);
|
||||
|
||||
std::list<ChatLobbyInfo> lobbies;
|
||||
std::list<ChatLobbyId> lobbies;
|
||||
rsMsgs->getChatLobbyList(lobbies);
|
||||
|
||||
#ifdef CHAT_LOBBY_GUI_DEBUG
|
||||
|
@ -344,7 +378,7 @@ void ChatLobbyWidget::updateDisplay()
|
|||
// now, do a nice display of lobbies
|
||||
|
||||
RsPeerId vpid;
|
||||
std::list<ChatLobbyInfo>::const_iterator lobbyIt;
|
||||
std::list<ChatLobbyId>::const_iterator lobbyIt;
|
||||
|
||||
// remove not existing public lobbies
|
||||
|
||||
|
@ -381,7 +415,7 @@ void ChatLobbyWidget::updateDisplay()
|
|||
// Check for participating lobby with public level
|
||||
//
|
||||
for (lobbyIt = lobbies.begin(); lobbyIt != lobbies.end(); ++lobbyIt)
|
||||
if(itemLoop->data(COLUMN_DATA, ROLE_ID).toULongLong() == lobbyIt->lobby_id)
|
||||
if(itemLoop->data(COLUMN_DATA, ROLE_ID).toULongLong() == *lobbyIt)
|
||||
break;
|
||||
|
||||
if (lobbyIt == lobbies.end())
|
||||
|
@ -414,33 +448,34 @@ void ChatLobbyWidget::updateDisplay()
|
|||
|
||||
QTreeWidgetItem *item = NULL;
|
||||
QTreeWidgetItem *lobby_item =NULL;
|
||||
QTreeWidgetItem *lobby_other_item =NULL;
|
||||
if (lobby.lobby_privacy_level == RS_CHAT_LOBBY_PRIVACY_LEVEL_PUBLIC)
|
||||
{
|
||||
if (subscribed)
|
||||
{
|
||||
lobby_item = publicSubLobbyItem;
|
||||
lobby_other_item = publicLobbyItem;
|
||||
}
|
||||
else
|
||||
{
|
||||
lobby_item = publicLobbyItem;
|
||||
lobby_other_item = publicSubLobbyItem;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (subscribed)
|
||||
{
|
||||
lobby_item = privateSubLobbyItem;
|
||||
lobby_other_item = privateLobbyItem;
|
||||
}
|
||||
else
|
||||
{
|
||||
lobby_item = privateLobbyItem;
|
||||
lobby_other_item = privateSubLobbyItem;
|
||||
}
|
||||
}
|
||||
QTreeWidgetItem *lobby_other_item =NULL;
|
||||
|
||||
if (lobby.lobby_flags & RS_CHAT_LOBBY_FLAGS_PUBLIC)
|
||||
{
|
||||
if (subscribed)
|
||||
{
|
||||
lobby_item = publicSubLobbyItem;
|
||||
lobby_other_item = publicLobbyItem;
|
||||
}
|
||||
else
|
||||
{
|
||||
lobby_item = publicLobbyItem;
|
||||
lobby_other_item = publicSubLobbyItem;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (subscribed)
|
||||
{
|
||||
lobby_item = privateSubLobbyItem;
|
||||
lobby_other_item = privateLobbyItem;
|
||||
}
|
||||
else
|
||||
{
|
||||
lobby_item = privateLobbyItem;
|
||||
lobby_other_item = privateSubLobbyItem;
|
||||
}
|
||||
}
|
||||
//QTreeWidgetItem *lobby_item = (lobby.lobby_privacy_level == RS_CHAT_LOBBY_PRIVACY_LEVEL_PUBLIC)?publicLobbyItem:privateLobbyItem ;
|
||||
|
||||
// Search existing item
|
||||
|
@ -469,14 +504,14 @@ void ChatLobbyWidget::updateDisplay()
|
|||
if (item == NULL)
|
||||
{
|
||||
item = new RSTreeWidgetItem(compareRole, TYPE_LOBBY);
|
||||
icon = (lobby.lobby_privacy_level == RS_CHAT_LOBBY_PRIVACY_LEVEL_PUBLIC) ? QIcon(IMAGE_PUBLIC) : QIcon(IMAGE_PRIVATE);
|
||||
icon = (lobby.lobby_flags & RS_CHAT_LOBBY_FLAGS_PUBLIC) ? QIcon(IMAGE_PUBLIC) : QIcon(IMAGE_PRIVATE);
|
||||
lobby_item->addChild(item);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (item->data(COLUMN_DATA, ROLE_SUBSCRIBED).toBool() != subscribed) {
|
||||
// Replace icon
|
||||
icon = (lobby.lobby_privacy_level == RS_CHAT_LOBBY_PRIVACY_LEVEL_PUBLIC) ? QIcon(IMAGE_PUBLIC) : QIcon(IMAGE_PRIVATE);
|
||||
icon = (lobby.lobby_flags & RS_CHAT_LOBBY_FLAGS_PUBLIC) ? QIcon(IMAGE_PUBLIC) : QIcon(IMAGE_PRIVATE);
|
||||
}
|
||||
}
|
||||
if (!icon.isNull()) {
|
||||
|
@ -506,19 +541,19 @@ void ChatLobbyWidget::updateDisplay()
|
|||
// Now add participating lobbies.
|
||||
//
|
||||
for (lobbyIt = lobbies.begin(); lobbyIt != lobbies.end(); ++lobbyIt)
|
||||
{
|
||||
const ChatLobbyInfo &lobby = *lobbyIt;
|
||||
{
|
||||
ChatLobbyInfo lobby ;
|
||||
rsMsgs->getChatLobbyInfo(*lobbyIt,lobby) ;
|
||||
|
||||
#ifdef CHAT_LOBBY_GUI_DEBUG
|
||||
std::cerr << "adding " << lobby.lobby_name << "topic " << lobby.lobby_topic << " #" << std::hex << lobby.lobby_id << std::dec << " private " << lobby.nick_names.size() << " peers." << std::endl;
|
||||
#endif
|
||||
|
||||
QTreeWidgetItem *itemParent;
|
||||
if (lobby.lobby_privacy_level == RS_CHAT_LOBBY_PRIVACY_LEVEL_PUBLIC) {
|
||||
if (lobby.lobby_flags & RS_CHAT_LOBBY_FLAGS_PUBLIC)
|
||||
itemParent = publicSubLobbyItem;
|
||||
} else {
|
||||
else
|
||||
itemParent = privateSubLobbyItem;
|
||||
}
|
||||
|
||||
QTreeWidgetItem *item = NULL;
|
||||
|
||||
|
@ -533,23 +568,23 @@ void ChatLobbyWidget::updateDisplay()
|
|||
}
|
||||
|
||||
QIcon icon;
|
||||
if (item == NULL) {
|
||||
item = new RSTreeWidgetItem(compareRole, TYPE_LOBBY);
|
||||
icon = (lobby.lobby_privacy_level == RS_CHAT_LOBBY_PRIVACY_LEVEL_PUBLIC) ? QIcon(IMAGE_PUBLIC) : QIcon(IMAGE_PRIVATE);
|
||||
itemParent->addChild(item);
|
||||
} else {
|
||||
if (!item->data(COLUMN_DATA, ROLE_SUBSCRIBED).toBool()) {
|
||||
// Replace icon
|
||||
icon = (lobby.lobby_privacy_level == RS_CHAT_LOBBY_PRIVACY_LEVEL_PUBLIC) ? QIcon(IMAGE_PUBLIC) : QIcon(IMAGE_PRIVATE);
|
||||
}
|
||||
}
|
||||
if (item == NULL) {
|
||||
item = new RSTreeWidgetItem(compareRole, TYPE_LOBBY);
|
||||
icon = (lobby.lobby_flags & RS_CHAT_LOBBY_FLAGS_PUBLIC) ? QIcon(IMAGE_PUBLIC) : QIcon(IMAGE_PRIVATE);
|
||||
itemParent->addChild(item);
|
||||
} else {
|
||||
if (!item->data(COLUMN_DATA, ROLE_SUBSCRIBED).toBool()) {
|
||||
// Replace icon
|
||||
icon = (lobby.lobby_flags & RS_CHAT_LOBBY_FLAGS_PUBLIC) ? QIcon(IMAGE_PUBLIC) : QIcon(IMAGE_PRIVATE);
|
||||
}
|
||||
}
|
||||
if (!icon.isNull()) {
|
||||
item->setIcon(COLUMN_NAME, icon);
|
||||
}
|
||||
|
||||
bool autoSubscribe = rsMsgs->getLobbyAutoSubscribe(lobby.lobby_id);
|
||||
|
||||
updateItem(ui.lobbyTreeWidget, item, lobby.lobby_id, lobby.lobby_name,lobby.lobby_topic, lobby.nick_names.size(), true, autoSubscribe);
|
||||
updateItem(ui.lobbyTreeWidget, item, lobby.lobby_id, lobby.lobby_name,lobby.lobby_topic, lobby.gxs_ids.size(), true, autoSubscribe);
|
||||
}
|
||||
publicSubLobbyItem->setHidden(publicSubLobbyItem->childCount()==0);
|
||||
privateSubLobbyItem->setHidden(privateSubLobbyItem->childCount()==0);
|
||||
|
@ -581,17 +616,36 @@ void ChatLobbyWidget::showLobby(QTreeWidgetItem *item)
|
|||
else
|
||||
ui.stackedWidget->setCurrentWidget(_lobby_infos[id].dialog) ;
|
||||
}
|
||||
|
||||
static void subscribeLobby(QTreeWidgetItem *item)
|
||||
void ChatLobbyWidget::subscribeChatLobbyAs()
|
||||
{
|
||||
if (item == NULL || item->type() != TYPE_LOBBY) {
|
||||
return;
|
||||
}
|
||||
QTreeWidgetItem *item = ui.lobbyTreeWidget->currentItem();
|
||||
|
||||
ChatLobbyId id = item->data(COLUMN_DATA, ROLE_ID).toULongLong();
|
||||
if (rsMsgs->joinVisibleChatLobby(id)) {
|
||||
if(!item)
|
||||
return ;
|
||||
|
||||
ChatLobbyId id = item->data(COLUMN_DATA, ROLE_ID).toULongLong();
|
||||
|
||||
QAction *action = qobject_cast<QAction *>(QObject::sender());
|
||||
if (!action)
|
||||
return ;
|
||||
|
||||
RsGxsId gxs_id(action->data().toString().toStdString());
|
||||
uint32_t error_code ;
|
||||
|
||||
if(rsMsgs->joinVisibleChatLobby(id,gxs_id))
|
||||
ChatDialog::chatFriend(ChatId(id),true) ;
|
||||
}
|
||||
void ChatLobbyWidget::subscribeChatLobbyAtItem(QTreeWidgetItem *item)
|
||||
{
|
||||
if (item == NULL || item->type() != TYPE_LOBBY) {
|
||||
return;
|
||||
}
|
||||
|
||||
ChatLobbyId id = item->data(COLUMN_DATA, ROLE_ID).toULongLong();
|
||||
RsGxsId gxs_id ;
|
||||
|
||||
if(rsMsgs->getDefaultIdentityForChatLobby(gxs_id) && !gxs_id.isNull() && rsMsgs->joinVisibleChatLobby(id,gxs_id))
|
||||
ChatDialog::chatFriend(ChatId(id),true) ;
|
||||
}
|
||||
}
|
||||
|
||||
void ChatLobbyWidget::autoSubscribeLobby(QTreeWidgetItem *item)
|
||||
|
@ -603,7 +657,7 @@ void ChatLobbyWidget::autoSubscribeLobby(QTreeWidgetItem *item)
|
|||
ChatLobbyId id = item->data(COLUMN_DATA, ROLE_ID).toULongLong();
|
||||
bool isAutoSubscribe = rsMsgs->getLobbyAutoSubscribe(id);
|
||||
rsMsgs->setLobbyAutoSubscribe(id, !isAutoSubscribe);
|
||||
if (!isAutoSubscribe) subscribeLobby(item);
|
||||
if (!isAutoSubscribe) subscribeChatLobbyAtItem(item);
|
||||
}
|
||||
|
||||
void ChatLobbyWidget::showBlankPage(ChatLobbyId id)
|
||||
|
@ -621,7 +675,7 @@ void ChatLobbyWidget::showBlankPage(ChatLobbyId id)
|
|||
ui.lobbyname_lineEdit->setText( RsHtml::plainText(it->lobby_name) );
|
||||
ui.lobbyid_lineEdit->setText( QString::number((*it).lobby_id,16) );
|
||||
ui.lobbytopic_lineEdit->setText( RsHtml::plainText(it->lobby_topic) );
|
||||
ui.lobbytype_lineEdit->setText( (( (*it).lobby_privacy_level == RS_CHAT_LOBBY_PRIVACY_LEVEL_PRIVATE)?tr("Private"):tr("Public")) );
|
||||
ui.lobbytype_lineEdit->setText( (( (*it).lobby_flags & RS_CHAT_LOBBY_FLAGS_PUBLIC)?tr("Public"):tr("Private")) );
|
||||
ui.lobbypeers_lineEdit->setText( QString::number((*it).total_number_of_peers) );
|
||||
|
||||
ui.lobbyInfoLabel->setText(tr("You're not subscribed to this lobby; Double click-it to enter and chat.") );
|
||||
|
@ -640,12 +694,12 @@ void ChatLobbyWidget::showBlankPage(ChatLobbyId id)
|
|||
|
||||
void ChatLobbyWidget::subscribeItem()
|
||||
{
|
||||
subscribeLobby(ui.lobbyTreeWidget->currentItem());
|
||||
subscribeChatLobbyAtItem(ui.lobbyTreeWidget->currentItem());
|
||||
}
|
||||
|
||||
void ChatLobbyWidget::autoSubscribeItem()
|
||||
{
|
||||
autoSubscribeLobby(ui.lobbyTreeWidget->currentItem());
|
||||
autoSubscribeLobby(ui.lobbyTreeWidget->currentItem());
|
||||
}
|
||||
|
||||
QTreeWidgetItem *ChatLobbyWidget::getTreeWidgetItem(ChatLobbyId id)
|
||||
|
@ -786,7 +840,7 @@ void ChatLobbyWidget::updateCurrentLobby()
|
|||
|
||||
if(_lobby_infos.find(id) != _lobby_infos.end()) {
|
||||
int iPrivacyLevel= item->parent()->data(COLUMN_DATA, ROLE_PRIVACYLEVEL).toInt();
|
||||
QIcon icon = (iPrivacyLevel==RS_CHAT_LOBBY_PRIVACY_LEVEL_PUBLIC) ? QIcon(IMAGE_PUBLIC) : QIcon(IMAGE_PRIVATE);
|
||||
QIcon icon = (iPrivacyLevel==CHAT_LOBBY_PRIVACY_LEVEL_PUBLIC) ? QIcon(IMAGE_PUBLIC) : QIcon(IMAGE_PRIVATE);
|
||||
_lobby_infos[id].default_icon = icon ;
|
||||
_lobby_infos[id].unread_count = 0;
|
||||
item->setIcon(COLUMN_NAME, icon) ;
|
||||
|
@ -823,37 +877,62 @@ void ChatLobbyWidget::updateMessageChanged(ChatLobbyId id)
|
|||
|
||||
void ChatLobbyWidget::itemDoubleClicked(QTreeWidgetItem *item, int /*column*/)
|
||||
{
|
||||
subscribeLobby(item);
|
||||
subscribeChatLobbyAtItem(item);
|
||||
}
|
||||
|
||||
void ChatLobbyWidget::displayChatLobbyEvent(qulonglong lobby_id, int event_type, const QString& nickname, const QString& str)
|
||||
void ChatLobbyWidget::displayChatLobbyEvent(qulonglong lobby_id, int event_type, const QString& gxs_id, const QString& str)
|
||||
{
|
||||
if (ChatLobbyDialog *cld = dynamic_cast<ChatLobbyDialog*>(ChatDialog::getExistingChat(ChatId(lobby_id)))) {
|
||||
cld->displayLobbyEvent(event_type, nickname, str);
|
||||
cld->displayLobbyEvent(event_type, RsGxsId(gxs_id.toStdString()), str);
|
||||
}
|
||||
}
|
||||
|
||||
void ChatLobbyWidget::readChatLobbyInvites()
|
||||
{
|
||||
std::list<ChatLobbyInvite> invites;
|
||||
rsMsgs->getPendingChatLobbyInvites(invites);
|
||||
std::list<ChatLobbyInvite> invites;
|
||||
rsMsgs->getPendingChatLobbyInvites(invites);
|
||||
|
||||
for(std::list<ChatLobbyInvite>::const_iterator it(invites.begin());it!=invites.end();++it) {
|
||||
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;
|
||||
RsGxsId default_id ;
|
||||
rsMsgs->getDefaultIdentityForChatLobby(default_id) ;
|
||||
|
||||
rsMsgs->acceptLobbyInvite((*it).lobby_id);
|
||||
for(std::list<ChatLobbyInvite>::const_iterator it(invites.begin());it!=invites.end();++it)
|
||||
{
|
||||
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);
|
||||
|
||||
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 {
|
||||
rsMsgs->denyLobbyInvite((*it).lobby_id);
|
||||
}
|
||||
}
|
||||
GxsIdChooser *idchooser = new GxsIdChooser ;
|
||||
idchooser->loadIds(IDCHOOSER_ID_REQUIRED,default_id) ;
|
||||
|
||||
mb.layout()->addWidget(new QLabel(tr("Choose an identity for this lobby:"))) ;
|
||||
mb.layout()->addWidget(idchooser) ;
|
||||
|
||||
int res = mb.exec() ;
|
||||
|
||||
if (res == QMessageBox::No)
|
||||
{
|
||||
rsMsgs->denyLobbyInvite((*it).lobby_id);
|
||||
continue ;
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void ChatLobbyWidget::filterColumnChanged(int)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue