mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-02-22 07:49:56 -05:00
added menu to select identity when entering lobby; removed debug info
git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.6-LobbiesWithGXSIds@7985 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
48b16a068f
commit
2f6a6a14b1
@ -37,7 +37,7 @@
|
|||||||
#include "gxs/gxssecurity.h"
|
#include "gxs/gxssecurity.h"
|
||||||
#include "services/p3idservice.h"
|
#include "services/p3idservice.h"
|
||||||
|
|
||||||
#define DEBUG_CHAT_LOBBIES 1
|
//#define DEBUG_CHAT_LOBBIES 1
|
||||||
|
|
||||||
static const int CONNECTION_CHALLENGE_MAX_COUNT = 20 ; // sends a connection challenge every 20 messages
|
static const int CONNECTION_CHALLENGE_MAX_COUNT = 20 ; // sends a connection challenge every 20 messages
|
||||||
static const time_t CONNECTION_CHALLENGE_MAX_MSG_AGE = 30 ; // maximum age of a message to be used in a connection challenge
|
static const time_t CONNECTION_CHALLENGE_MAX_MSG_AGE = 30 ; // maximum age of a message to be used in a connection challenge
|
||||||
@ -122,7 +122,7 @@ bool DistributedChatService::handleRecvChatLobbyMsgItem(RsChatMsgItem *ci)
|
|||||||
}
|
}
|
||||||
if(!checkSignature(cli,cli->PeerId())) // check the object's signature and possibly request missing keys
|
if(!checkSignature(cli,cli->PeerId())) // check the object's signature and possibly request missing keys
|
||||||
{
|
{
|
||||||
std::cerr << "Signature mismatched for this lobby event item: " << std::endl;
|
std::cerr << "Signature mismatched for this lobby event item. Item will be dropped: " << std::endl;
|
||||||
cli->print(std::cerr) ;
|
cli->print(std::cerr) ;
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
return false;
|
return false;
|
||||||
@ -152,13 +152,17 @@ bool DistributedChatService::checkSignature(RsChatLobbyBouncingObject *obj,const
|
|||||||
std::list<RsPeerId> peer_list ;
|
std::list<RsPeerId> peer_list ;
|
||||||
peer_list.push_back(peer_id) ;
|
peer_list.push_back(peer_id) ;
|
||||||
|
|
||||||
bool key_available = mIdService->requestKey(obj->signature.keyId,peer_list);
|
// network pre-request key to allow message authentication.
|
||||||
|
|
||||||
|
mIdService->requestKey(obj->signature.keyId,peer_list);
|
||||||
|
|
||||||
uint32_t size = obj->signed_serial_size() ;
|
uint32_t size = obj->signed_serial_size() ;
|
||||||
unsigned char *memory = (unsigned char *)malloc(size) ;
|
unsigned char *memory = (unsigned char *)malloc(size) ;
|
||||||
|
|
||||||
|
#ifdef DEBUG_CHAT_LOBBIES
|
||||||
std::cerr << "Checking object signature: " << std::endl;
|
std::cerr << "Checking object signature: " << std::endl;
|
||||||
std::cerr << " signature id: " << obj->signature.keyId << std::endl;
|
std::cerr << " signature id: " << obj->signature.keyId << std::endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
if(!obj->serialise_signed_part(memory,size))
|
if(!obj->serialise_signed_part(memory,size))
|
||||||
{
|
{
|
||||||
@ -178,20 +182,26 @@ bool DistributedChatService::checkSignature(RsChatLobbyBouncingObject *obj,const
|
|||||||
|
|
||||||
return true ;
|
return true ;
|
||||||
}
|
}
|
||||||
|
#ifdef DEBUG_CHAT_LOBBIES
|
||||||
std::cerr << " key available. " << key_available << std::endl;
|
std::cerr << " key available. " << key_available << std::endl;
|
||||||
std::cerr << " data hash: " << RsDirUtil::sha1sum(memory,obj->signed_serial_size()) << std::endl;
|
std::cerr << " data hash: " << RsDirUtil::sha1sum(memory,obj->signed_serial_size()) << std::endl;
|
||||||
std::cerr << " signed data: " << RsUtil::BinToHex((char*)memory,obj->signed_serial_size()) << std::endl;
|
std::cerr << " signed data: " << RsUtil::BinToHex((char*)memory,obj->signed_serial_size()) << std::endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
if(!GxsSecurity::validateSignature((const char *)memory,obj->signed_serial_size(),signature_public_key,obj->signature))
|
if(!GxsSecurity::validateSignature((const char *)memory,obj->signed_serial_size(),signature_public_key,obj->signature))
|
||||||
{
|
{
|
||||||
|
#ifdef DEBUG_CHAT_LOBBIES
|
||||||
std::cerr << " Signature: FAILS." << std::endl;
|
std::cerr << " Signature: FAILS." << std::endl;
|
||||||
|
#endif
|
||||||
free(memory) ;
|
free(memory) ;
|
||||||
|
|
||||||
return false ;
|
return false ;
|
||||||
}
|
}
|
||||||
free(memory) ;
|
free(memory) ;
|
||||||
|
|
||||||
|
#ifdef DEBUG_CHAT_LOBBIES
|
||||||
std::cerr << " signature: CHECKS" << std::endl;
|
std::cerr << " signature: CHECKS" << std::endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
return true ;
|
return true ;
|
||||||
}
|
}
|
||||||
@ -769,8 +779,6 @@ bool DistributedChatService::bounceLobbyObject(RsChatLobbyBouncingObject *item,c
|
|||||||
if(!locked_bouncingObjectCheck(item,peer_id,lobby.participating_friends.size()))
|
if(!locked_bouncingObjectCheck(item,peer_id,lobby.participating_friends.size()))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
bool is_message = (NULL != dynamic_cast<RsChatLobbyMsgItem*>(item)) ;
|
|
||||||
|
|
||||||
// Forward to allparticipating friends, except this peer.
|
// Forward to allparticipating friends, except this peer.
|
||||||
|
|
||||||
for(std::set<RsPeerId>::const_iterator it(lobby.participating_friends.begin());it!=lobby.participating_friends.end();++it)
|
for(std::set<RsPeerId>::const_iterator it(lobby.participating_friends.begin());it!=lobby.participating_friends.end();++it)
|
||||||
|
@ -13,11 +13,13 @@
|
|||||||
#include "chat/ChatLobbyUserNotify.h"
|
#include "chat/ChatLobbyUserNotify.h"
|
||||||
#include "util/HandleRichText.h"
|
#include "util/HandleRichText.h"
|
||||||
#include "util/QtVersion.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/rsmsgs.h"
|
||||||
#include "retroshare/rspeers.h"
|
#include "retroshare/rspeers.h"
|
||||||
#include "retroshare/rsnotify.h"
|
#include "retroshare/rsnotify.h"
|
||||||
|
#include "retroshare/rsidentity.h"
|
||||||
|
|
||||||
#define COLUMN_NAME 0
|
#define COLUMN_NAME 0
|
||||||
#define COLUMN_USER_COUNT 1
|
#define COLUMN_USER_COUNT 1
|
||||||
@ -212,31 +214,66 @@ void ChatLobbyWidget::lobbyTreeWidgetCustomPopupMenu(QPoint)
|
|||||||
action->setData(item->data(COLUMN_DATA, ROLE_PRIVACYLEVEL).toInt());
|
action->setData(item->data(COLUMN_DATA, ROLE_PRIVACYLEVEL).toInt());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item && item->type() == TYPE_LOBBY) {
|
if (item && item->type() == TYPE_LOBBY)
|
||||||
if (item->data(COLUMN_DATA, ROLE_SUBSCRIBED).toBool()) {
|
{
|
||||||
contextMnu.addAction(QIcon(IMAGE_UNSUBSCRIBE), tr("Unsubscribe"), this, SLOT(unsubscribeItem()));
|
if (item->data(COLUMN_DATA, ROLE_SUBSCRIBED).toBool())
|
||||||
} else {
|
contextMnu.addAction(QIcon(IMAGE_UNSUBSCRIBE), tr("Leave this lobby"), this, SLOT(unsubscribeItem()));
|
||||||
contextMnu.addAction(QIcon(IMAGE_SUBSCRIBE), tr("Subscribe"), this, SLOT(subscribeItem()));
|
else
|
||||||
}
|
{
|
||||||
if (item->data(COLUMN_DATA, ROLE_AUTOSUBSCRIBE).toBool()) {
|
std::list<RsGxsId> own_identities ;
|
||||||
contextMnu.addAction(QIcon(IMAGE_AUTOSUBSCRIBE), tr("Remove Auto Subscribe"), this, SLOT(autoSubscribeItem()));
|
rsIdentity->getOwnIds(own_identities) ;
|
||||||
} else {
|
|
||||||
contextMnu.addAction(QIcon(IMAGE_SUBSCRIBE), tr("Add Auto Subscribe"), this, SLOT(autoSubscribeItem()));
|
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));
|
showUserCountAct->setChecked(!ui.lobbyTreeWidget->isColumnHidden(COLUMN_USER_COUNT));
|
||||||
showTopicAct->setChecked(!ui.lobbyTreeWidget->isColumnHidden(COLUMN_TOPIC));
|
showTopicAct->setChecked(!ui.lobbyTreeWidget->isColumnHidden(COLUMN_TOPIC));
|
||||||
showSubscribeAct->setChecked(!ui.lobbyTreeWidget->isColumnHidden(COLUMN_SUBSCRIBED));
|
showSubscribeAct->setChecked(!ui.lobbyTreeWidget->isColumnHidden(COLUMN_SUBSCRIBED));
|
||||||
|
|
||||||
QMenu *menu = contextMnu.addMenu(tr("Columns"));
|
QMenu *menu = contextMnu.addMenu(tr("Columns"));
|
||||||
menu->addAction(showUserCountAct);
|
menu->addAction(showUserCountAct);
|
||||||
menu->addAction(showTopicAct);
|
menu->addAction(showTopicAct);
|
||||||
menu->addAction(showSubscribeAct);
|
menu->addAction(showSubscribeAct);
|
||||||
|
|
||||||
contextMnu.exec(QCursor::pos());
|
contextMnu.exec(QCursor::pos());
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChatLobbyWidget::lobbyChanged()
|
void ChatLobbyWidget::lobbyChanged()
|
||||||
@ -579,12 +616,30 @@ void ChatLobbyWidget::showLobby(QTreeWidgetItem *item)
|
|||||||
else
|
else
|
||||||
ui.stackedWidget->setCurrentWidget(_lobby_infos[id].dialog) ;
|
ui.stackedWidget->setCurrentWidget(_lobby_infos[id].dialog) ;
|
||||||
}
|
}
|
||||||
|
void ChatLobbyWidget::subscribeChatLobbyAs()
|
||||||
static void subscribeLobby(QTreeWidgetItem *item)
|
|
||||||
{
|
{
|
||||||
if (item == NULL || item->type() != TYPE_LOBBY) {
|
QTreeWidgetItem *item = ui.lobbyTreeWidget->currentItem();
|
||||||
return;
|
|
||||||
}
|
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();
|
ChatLobbyId id = item->data(COLUMN_DATA, ROLE_ID).toULongLong();
|
||||||
RsGxsId gxs_id ;
|
RsGxsId gxs_id ;
|
||||||
@ -602,7 +657,7 @@ void ChatLobbyWidget::autoSubscribeLobby(QTreeWidgetItem *item)
|
|||||||
ChatLobbyId id = item->data(COLUMN_DATA, ROLE_ID).toULongLong();
|
ChatLobbyId id = item->data(COLUMN_DATA, ROLE_ID).toULongLong();
|
||||||
bool isAutoSubscribe = rsMsgs->getLobbyAutoSubscribe(id);
|
bool isAutoSubscribe = rsMsgs->getLobbyAutoSubscribe(id);
|
||||||
rsMsgs->setLobbyAutoSubscribe(id, !isAutoSubscribe);
|
rsMsgs->setLobbyAutoSubscribe(id, !isAutoSubscribe);
|
||||||
if (!isAutoSubscribe) subscribeLobby(item);
|
if (!isAutoSubscribe) subscribeChatLobbyAtItem(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChatLobbyWidget::showBlankPage(ChatLobbyId id)
|
void ChatLobbyWidget::showBlankPage(ChatLobbyId id)
|
||||||
@ -639,12 +694,12 @@ void ChatLobbyWidget::showBlankPage(ChatLobbyId id)
|
|||||||
|
|
||||||
void ChatLobbyWidget::subscribeItem()
|
void ChatLobbyWidget::subscribeItem()
|
||||||
{
|
{
|
||||||
subscribeLobby(ui.lobbyTreeWidget->currentItem());
|
subscribeChatLobbyAtItem(ui.lobbyTreeWidget->currentItem());
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChatLobbyWidget::autoSubscribeItem()
|
void ChatLobbyWidget::autoSubscribeItem()
|
||||||
{
|
{
|
||||||
autoSubscribeLobby(ui.lobbyTreeWidget->currentItem());
|
autoSubscribeLobby(ui.lobbyTreeWidget->currentItem());
|
||||||
}
|
}
|
||||||
|
|
||||||
QTreeWidgetItem *ChatLobbyWidget::getTreeWidgetItem(ChatLobbyId id)
|
QTreeWidgetItem *ChatLobbyWidget::getTreeWidgetItem(ChatLobbyId id)
|
||||||
@ -822,7 +877,7 @@ void ChatLobbyWidget::updateMessageChanged(ChatLobbyId id)
|
|||||||
|
|
||||||
void ChatLobbyWidget::itemDoubleClicked(QTreeWidgetItem *item, int /*column*/)
|
void ChatLobbyWidget::itemDoubleClicked(QTreeWidgetItem *item, int /*column*/)
|
||||||
{
|
{
|
||||||
subscribeLobby(item);
|
subscribeChatLobbyAtItem(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChatLobbyWidget::displayChatLobbyEvent(qulonglong lobby_id, int event_type, const QString& gxs_id, const QString& str)
|
void ChatLobbyWidget::displayChatLobbyEvent(qulonglong lobby_id, int event_type, const QString& gxs_id, const QString& str)
|
||||||
|
@ -62,8 +62,9 @@ protected slots:
|
|||||||
void readChatLobbyInvites();
|
void readChatLobbyInvites();
|
||||||
void showLobby(QTreeWidgetItem *lobby_item) ;
|
void showLobby(QTreeWidgetItem *lobby_item) ;
|
||||||
void showBlankPage(ChatLobbyId id) ;
|
void showBlankPage(ChatLobbyId id) ;
|
||||||
void unsubscribeChatLobby(ChatLobbyId id) ;
|
void unsubscribeChatLobby(ChatLobbyId id) ;
|
||||||
void updateTypingStatus(ChatLobbyId id) ;
|
void subscribeChatLobbyAs() ;
|
||||||
|
void updateTypingStatus(ChatLobbyId id) ;
|
||||||
void resetLobbyTreeIcons() ;
|
void resetLobbyTreeIcons() ;
|
||||||
void updateMessageChanged(ChatLobbyId);
|
void updateMessageChanged(ChatLobbyId);
|
||||||
void updatePeerEntering(ChatLobbyId);
|
void updatePeerEntering(ChatLobbyId);
|
||||||
@ -81,6 +82,8 @@ private slots:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
void autoSubscribeLobby(QTreeWidgetItem *item);
|
void autoSubscribeLobby(QTreeWidgetItem *item);
|
||||||
|
void subscribeChatLobby(ChatLobbyId id) ;
|
||||||
|
void subscribeChatLobbyAtItem(QTreeWidgetItem *item) ;
|
||||||
|
|
||||||
bool filterItem(QTreeWidgetItem *item, const QString &text, int filterColumn);
|
bool filterItem(QTreeWidgetItem *item, const QString &text, int filterColumn);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user