Merge pull request #57 from csoler/v0.6-SignedLobbies

V0.6 signed lobbies
This commit is contained in:
Cyril Soler 2015-08-28 00:14:24 -04:00
commit a45de1ddb3
9 changed files with 251 additions and 84 deletions

View File

@ -58,10 +58,10 @@ static const uint32_t MAX_MESSAGES_PER_SECONDS_NUMBER = 5 ; // max number o
static const uint32_t MAX_MESSAGES_PER_SECONDS_PERIOD = 10 ; // duration window for max number of messages before messages get dropped.
#define IS_PUBLIC_LOBBY(flags) (flags & RS_CHAT_LOBBY_FLAGS_PUBLIC )
#define IS_ANONYMOUS_LOBBY(flags) (flags & RS_CHAT_LOBBY_FLAGS_ANONYMOUS)
#define IS_CONNEXION_CHALLENGE(flags) (flags & RS_CHAT_LOBBY_FLAGS_CHALLENGE)
#define IS_PGP_SIGNED_LOBBY(flags) (flags & RS_CHAT_LOBBY_FLAGS_PGP_SIGNED)
#define IS_CONNEXION_CHALLENGE(flags) (flags & RS_CHAT_LOBBY_FLAGS_CHALLENGE )
#define EXTRACT_PRIVACY_FLAGS(flags) (ChatLobbyFlags(flags.toUInt32()) & RS_CHAT_LOBBY_FLAGS_PUBLIC)
#define EXTRACT_PRIVACY_FLAGS(flags) (ChatLobbyFlags(flags.toUInt32()) * (RS_CHAT_LOBBY_FLAGS_PUBLIC | RS_CHAT_LOBBY_FLAGS_PGP_SIGNED))
DistributedChatService::DistributedChatService(uint32_t serv_type,p3ServiceControl *sc,p3HistoryMgr *hm, RsGixs *is)
: mServType(serv_type),mDistributedChatMtx("Distributed Chat"), mServControl(sc), mHistMgr(hm),mGixs(is)
@ -145,6 +145,36 @@ bool DistributedChatService::handleRecvChatLobbyMsgItem(RsChatMsgItem *ci)
return false;
}
ChatLobbyFlags fl ;
// delete items that are not for us, as early as possible.
{
RsStackMutex stack(mDistributedChatMtx); /********** STACK LOCKED MTX ******/
// send upward for display
std::map<ChatLobbyId,ChatLobbyEntry>::const_iterator it = _chat_lobbys.find(cli->lobby_id) ;
if(it == _chat_lobbys.end())
{
#ifdef DEBUG_CHAT_LOBBIES
std::cerr << "Chatlobby for id " << std::hex << item->lobby_id << " has no record. Dropping the msg." << std::dec << std::endl;
#endif
return false;
}
fl = it->second.lobby_flags ;
}
if(IS_PGP_SIGNED_LOBBY(fl))
{
RsIdentityDetails details;
if(!rsIdentity->getIdDetails(cli->signature.keyId,details) || !details.mPgpKnown)
{
std::cerr << "(WW) Received a lobby msg/item that is not PGP-authed (id=" << cli->signature.keyId << "), whereas the lobby flags require it. Rejecting!" << std::endl;
return false ;
}
}
if(!bounceLobbyObject(cli,cli->PeerId())) // forwards the message to friends, keeps track of subscribers, etc.
return false;
@ -209,6 +239,7 @@ bool DistributedChatService::checkSignature(RsChatLobbyBouncingObject *obj,const
return res;
}
#ifdef DEBUG_CHAT_LOBBIES
std::cerr << " signature: CHECKS" << std::endl;
#endif
@ -252,7 +283,7 @@ void DistributedChatService::locked_printDebugInfo() const
std::cerr << " Lobby topic\t\t: " << it->second.lobby_topic << std::endl;
std::cerr << " nick name\t\t: " << it->second.gxs_id << std::endl;
std::cerr << " Lobby type\t\t: " << ((IS_PUBLIC_LOBBY(it->second.lobby_flags))?"Public":"Private") << std::endl;
std::cerr << " Lobby policy\t\t: " << ((IS_ANONYMOUS_LOBBY(it->second.lobby_flags))?"Unsigned":"Signature required") << std::endl;
std::cerr << " Lobby security\t\t: " << ((IS_PGP_SIGNED_LOBBY(it->second.lobby_flags))?"PGP-signed IDs required":"Anon IDs accepted") << std::endl;
std::cerr << " Lobby peer id\t: " << it->second.virtual_peer_id << std::endl;
std::cerr << " Challenge count\t: " << it->second.connexion_challenge_count << std::endl;
std::cerr << " Last activity\t: " << now - it->second.last_activity << " seconds ago." << std::endl;
@ -446,7 +477,7 @@ void DistributedChatService::handleRecvChatLobbyListRequest(RsChatLobbyListReque
info.name = it->second.lobby_name ;
info.topic = it->second.lobby_topic ;
info.count = it->second.gxs_ids.size() ;
info.flags = it->second.lobby_flags ;
info.flags = ChatLobbyFlags(EXTRACT_PRIVACY_FLAGS(it->second.lobby_flags)) ;
item->lobbies.push_back(info) ;
}
@ -496,7 +527,7 @@ void DistributedChatService::handleRecvChatLobbyList(RsChatLobbyListItem *item)
rec.total_number_of_peers = std::max(rec.total_number_of_peers,item->lobbies[i].count) ;
rec.last_report_time = now ;
rec.lobby_flags = item->lobbies[i].flags ;
rec.lobby_flags = EXTRACT_PRIVACY_FLAGS(item->lobbies[i].flags) ;
std::map<ChatLobbyId,ChatLobbyFlags>::const_iterator it(_known_lobbies_flags.find(item->lobbies[i].id)) ;
@ -596,19 +627,24 @@ void DistributedChatService::addTimeShiftStatistics(int D)
void DistributedChatService::handleRecvChatLobbyEventItem(RsChatLobbyEventItem *item)
{
ChatLobbyFlags fl ;
// delete items that are not for us, as early as possible.
{
RsStackMutex stack(mDistributedChatMtx); /********** STACK LOCKED MTX ******/
// send upward for display
if(_chat_lobbys.find(item->lobby_id) == _chat_lobbys.end())
std::map<ChatLobbyId,ChatLobbyEntry>::const_iterator it = _chat_lobbys.find(item->lobby_id) ;
if(it == _chat_lobbys.end())
{
#ifdef DEBUG_CHAT_LOBBIES
std::cerr << "Chatlobby for id " << std::hex << item->lobby_id << " has no record. Dropping the msg." << std::dec << std::endl;
#endif
return ;
}
fl = it->second.lobby_flags ;
}
@ -625,6 +661,17 @@ void DistributedChatService::handleRecvChatLobbyEventItem(RsChatLobbyEventItem *
return ;
}
if(IS_PGP_SIGNED_LOBBY(fl))
{
RsIdentityDetails details;
if(!rsIdentity->getIdDetails(item->signature.keyId,details) || !details.mPgpKnown)
{
std::cerr << "(WW) Received a lobby msg/item that is not PGP-authed (ID=" << item->signature.keyId << "), whereas the lobby flags require it. Rejecting!" << std::endl;
return ;
}
}
addTimeShiftStatistics((int)now - (int)item->sendTime) ;
if(now+100 > (time_t) item->sendTime + MAX_KEEP_MSG_RECORD) // the message is older than the max cache keep minus 100 seconds ! It's too old, and is going to make an echo!
@ -912,10 +959,8 @@ bool DistributedChatService::locked_initLobbyBouncableObject(const ChatLobbyId&
// now sign the object, if the lobby expects it
if(!IS_ANONYMOUS_LOBBY(lobby.lobby_flags))
{
uint32_t size = item.signed_serial_size() ;
unsigned char *memory = (unsigned char *)malloc(size) ;
RsTemporaryMemory memory(size) ;
if(!item.serialise_signed_part(memory,size))
{
@ -934,12 +979,9 @@ bool DistributedChatService::locked_initLobbyBouncableObject(const ChatLobbyId&
default: std::cerr << "(EE) Cannot sign item: unknown error" << std::endl;
break ;
}
free(memory) ;
return false ;
}
#ifdef DEBUG_CHAT_LOBBIES
std::cerr << " signature done." << std::endl;
@ -953,8 +995,6 @@ bool DistributedChatService::locked_initLobbyBouncableObject(const ChatLobbyId&
std::cerr << " Item dump:" << std::endl;
item.print(std::cerr,2) ;
#endif
free(memory) ;
}
return true ;
}

View File

@ -28,6 +28,7 @@ template<int n> class t_RsFlags32
inline t_RsFlags32<n> operator| (const t_RsFlags32<n>& f) const { return t_RsFlags32<n>(_bits | f._bits) ; }
inline t_RsFlags32<n> operator^ (const t_RsFlags32<n>& f) const { return t_RsFlags32<n>(_bits ^ f._bits) ; }
inline t_RsFlags32<n> operator* (const t_RsFlags32<n>& f) const { return t_RsFlags32<n>(_bits & f._bits) ; }
inline bool operator!=(const t_RsFlags32<n>& f) const { return _bits != f._bits ; }
inline bool operator==(const t_RsFlags32<n>& f) const { return _bits == f._bits ; }

View File

@ -90,9 +90,10 @@
#define RS_CHAT_TYPE_DISTANT 4
const ChatLobbyFlags RS_CHAT_LOBBY_FLAGS_AUTO_SUBSCRIBE( 0x00000001 ) ;
const ChatLobbyFlags RS_CHAT_LOBBY_FLAGS_ANONYMOUS ( 0x00000002 ) ;
const ChatLobbyFlags RS_CHAT_LOBBY_FLAGS_deprecated ( 0x00000002 ) ;
const ChatLobbyFlags RS_CHAT_LOBBY_FLAGS_PUBLIC ( 0x00000004 ) ;
const ChatLobbyFlags RS_CHAT_LOBBY_FLAGS_CHALLENGE ( 0x00000008 ) ;
const ChatLobbyFlags RS_CHAT_LOBBY_FLAGS_PGP_SIGNED ( 0x00000010 ) ; // requires the signing ID to be PGP-linked. Avoids anonymous crap.
typedef uint64_t ChatLobbyId ;
typedef uint64_t ChatLobbyMsgId ;

View File

@ -22,18 +22,21 @@
#include "retroshare/rsnotify.h"
#include "retroshare/rsidentity.h"
//#define CHAT_LOBBY_GUI_DEBUG 1
#define COLUMN_NAME 0
#define COLUMN_USER_COUNT 1
#define COLUMN_TOPIC 2
#define COLUMN_SUBSCRIBED 3
#define COLUMN_COUNT 4
#define COLUMN_DATA 0
#define ROLE_SORT Qt::UserRole
#define ROLE_ID Qt::UserRole + 1
#define ROLE_SUBSCRIBED Qt::UserRole + 2
#define ROLE_PRIVACYLEVEL Qt::UserRole + 3
#define ROLE_AUTOSUBSCRIBE Qt::UserRole + 4
#define ROLE_FLAGS Qt::UserRole + 5
#define TYPE_FOLDER 0
@ -129,10 +132,12 @@ ChatLobbyWidget::ChatLobbyWidget(QWidget *parent, Qt::WindowFlags flags)
ui.lobbyTreeWidget->setColumnHidden(COLUMN_SUBSCRIBED,true) ;
ui.lobbyTreeWidget->setSortingEnabled(true) ;
float fact = QFontMetricsF(font()).height()/14.0f;
ui.lobbyTreeWidget->adjustSize();
ui.lobbyTreeWidget->setColumnWidth(COLUMN_NAME,100);
ui.lobbyTreeWidget->setColumnWidth(COLUMN_USER_COUNT, 50);
ui.lobbyTreeWidget->setColumnWidth(COLUMN_TOPIC, 50);
ui.lobbyTreeWidget->setColumnWidth(COLUMN_NAME,100*fact);
ui.lobbyTreeWidget->setColumnWidth(COLUMN_USER_COUNT, 50*fact);
ui.lobbyTreeWidget->setColumnWidth(COLUMN_TOPIC, 50*fact);
/** Setup the actions for the header context menu */
showUserCountAct= new QAction(headerItem->text(COLUMN_USER_COUNT),this);
@ -150,7 +155,7 @@ ChatLobbyWidget::ChatLobbyWidget(QWidget *parent, Qt::WindowFlags flags)
ui.splitter->setStretchFactor(1, 1);
QList<int> sizes;
sizes << 200 << width(); // Qt calculates the right sizes
sizes << 200*fact << width(); // Qt calculates the right sizes
ui.splitter->setSizes(sizes);
lobbyChanged();
@ -222,6 +227,25 @@ void ChatLobbyWidget::updateNotify(ChatLobbyId id, unsigned int count)
}
}
static bool trimAnonIds(std::list<RsGxsId>& lst)
{
// trim down identities that are unsigned, because the lobby requires it.
bool removed = false ;
RsIdentityDetails idd ;
for(std::list<RsGxsId>::iterator it = lst.begin();it!=lst.end();)
if(!rsIdentity->getIdDetails(*it,idd) || !idd.mPgpLinked)
{
it = lst.erase(it) ;
removed= true ;
}
else
++it ;
return removed ;
}
void ChatLobbyWidget::lobbyTreeWidgetCustomPopupMenu(QPoint)
{
std::cerr << "Creating customPopupMennu" << std::endl;
@ -244,10 +268,19 @@ void ChatLobbyWidget::lobbyTreeWidgetCustomPopupMenu(QPoint)
else
{
QTreeWidgetItem *item = ui.lobbyTreeWidget->currentItem();
uint32_t item_flags = item->data(COLUMN_DATA,ROLE_ID).toUInt() ;
ChatLobbyId id = item->data(COLUMN_DATA, ROLE_ID).toULongLong();
ChatLobbyFlags flags(item->data(COLUMN_DATA, ROLE_FLAGS).toUInt());
bool removed = false ;
if(flags & RS_CHAT_LOBBY_FLAGS_PGP_SIGNED)
removed = trimAnonIds(own_identities) ;
if(own_identities.empty())
{
if(removed)
contextMnu.addAction(QIcon(IMAGE_SUBSCRIBE), tr("Create a non anonymous identity and enter this lobby"), this, SLOT(createIdentityAndSubscribe()));
else
contextMnu.addAction(QIcon(IMAGE_SUBSCRIBE), tr("Create an identity and enter this lobby"), this, SLOT(createIdentityAndSubscribe()));
}
else if(own_identities.size() == 1)
@ -300,7 +333,7 @@ void ChatLobbyWidget::lobbyChanged()
updateDisplay();
}
static void updateItem(QTreeWidget *treeWidget, QTreeWidgetItem *item, ChatLobbyId id, const std::string &name, const std::string &topic, int count, bool subscribed, bool autoSubscribe)
static void updateItem(QTreeWidget *treeWidget, QTreeWidgetItem *item, ChatLobbyId id, const std::string &name, const std::string &topic, int count, bool subscribed, bool autoSubscribe,ChatLobbyFlags lobby_flags)
{
item->setText(COLUMN_NAME, QString::fromUtf8(name.c_str()));
item->setData(COLUMN_NAME, ROLE_SORT, QString::fromUtf8(name.c_str()));
@ -323,9 +356,11 @@ static void updateItem(QTreeWidget *treeWidget, QTreeWidgetItem *item, ChatLobby
item->setData(COLUMN_DATA, ROLE_ID, (qulonglong)id);
item->setData(COLUMN_DATA, ROLE_SUBSCRIBED, subscribed);
item->setData(COLUMN_DATA, ROLE_FLAGS, lobby_flags.toUInt32());
item->setData(COLUMN_DATA, ROLE_AUTOSUBSCRIBE, autoSubscribe);
QColor color = treeWidget->palette().color(QPalette::Active, QPalette::Text);
if (!subscribed) {
// Average between Base and Text colors
QColor color2 = treeWidget->palette().color(QPalette::Active, QPalette::Base);
@ -335,10 +370,15 @@ static void updateItem(QTreeWidget *treeWidget, QTreeWidgetItem *item, ChatLobby
for (int column = 0; column < COLUMN_COUNT; ++column) {
item->setTextColor(column, color);
}
item->setToolTip(0,QObject::tr("Subject:")+" "+item->text(COLUMN_TOPIC)+"\n"
QString tooltipstr = QObject::tr("Subject:")+" "+item->text(COLUMN_TOPIC)+"\n"
+QObject::tr("Participants:")+" "+QString::number(count)+"\n"
+QObject::tr("Auto Subscribe:")+" "+(autoSubscribe? QObject::tr("enabled"): QObject::tr("disabled"))+"\n"
+QObject::tr("Id:")+" "+QString::number(id,16)) ;
+QObject::tr("Id:")+" "+QString::number(id,16) ;
if(lobby_flags & RS_CHAT_LOBBY_FLAGS_PGP_SIGNED)
tooltipstr += QObject::tr("\nSecurity: no anonymous ids") ;
item->setToolTip(0,tooltipstr) ;
}
void ChatLobbyWidget::addChatPage(ChatLobbyDialog *d)
@ -380,7 +420,6 @@ void ChatLobbyWidget::setCurrentChatPage(ChatLobbyDialog *d)
}
}
//#define CHAT_LOBBY_GUI_DEBUG
void ChatLobbyWidget::updateDisplay()
{
#ifdef CHAT_LOBBY_GUI_DEBUG
@ -521,12 +560,15 @@ void ChatLobbyWidget::updateDisplay()
}
}
ChatLobbyFlags lobby_flags = lobby.lobby_flags ;
QIcon icon;
if (item == NULL)
{
item = new RSTreeWidgetItem(compareRole, TYPE_LOBBY);
icon = (lobby.lobby_flags & RS_CHAT_LOBBY_FLAGS_PUBLIC) ? QIcon(IMAGE_PUBLIC) : QIcon(IMAGE_PRIVATE);
lobby_item->addChild(item);
}
else
{
@ -554,7 +596,7 @@ void ChatLobbyWidget::updateDisplay()
}
}
updateItem(ui.lobbyTreeWidget, item, lobby.lobby_id, lobby.lobby_name,lobby.lobby_topic, lobby.total_number_of_peers, subscribed, autoSubscribe);
updateItem(ui.lobbyTreeWidget, item, lobby.lobby_id, lobby.lobby_name,lobby.lobby_topic, lobby.total_number_of_peers, subscribed, autoSubscribe,lobby_flags);
}
// time_t now = time(NULL) ;
@ -589,7 +631,11 @@ void ChatLobbyWidget::updateDisplay()
}
QIcon icon;
if (item == NULL) {
ChatLobbyFlags lobby_flags = lobby.lobby_flags ;
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);
@ -605,7 +651,7 @@ void ChatLobbyWidget::updateDisplay()
bool autoSubscribe = rsMsgs->getLobbyAutoSubscribe(lobby.lobby_id);
updateItem(ui.lobbyTreeWidget, item, lobby.lobby_id, lobby.lobby_name,lobby.lobby_topic, lobby.gxs_ids.size(), true, autoSubscribe);
updateItem(ui.lobbyTreeWidget, item, lobby.lobby_id, lobby.lobby_name,lobby.lobby_topic, lobby.gxs_ids.size(), true, autoSubscribe,lobby_flags);
}
publicSubLobbyItem->setHidden(publicSubLobbyItem->childCount()==0);
privateSubLobbyItem->setHidden(privateSubLobbyItem->childCount()==0);
@ -647,9 +693,14 @@ void ChatLobbyWidget::createIdentityAndSubscribe()
return ;
ChatLobbyId id = item->data(COLUMN_DATA, ROLE_ID).toULongLong();
ChatLobbyFlags flags(item->data(COLUMN_DATA, ROLE_FLAGS).toUInt());
IdEditDialog dlg(this);
dlg.setupNewId(false);
if(flags & RS_CHAT_LOBBY_FLAGS_PGP_SIGNED) //
dlg.enforceNoAnonIds() ;
dlg.exec();
// fetch new id
std::list<RsGxsId> own_ids;
@ -711,6 +762,7 @@ void ChatLobbyWidget::subscribeChatLobbyAtItem(QTreeWidgetItem *item)
}
ChatLobbyId id = item->data(COLUMN_DATA, ROLE_ID).toULongLong();
ChatLobbyFlags flags ( item->data(COLUMN_DATA, ROLE_FLAGS).toUInt());
RsGxsId gxs_id ;
std::list<RsGxsId> own_ids;
@ -726,6 +778,9 @@ void ChatLobbyWidget::subscribeChatLobbyAtItem(QTreeWidgetItem *item)
{
IdEditDialog dlg(this);
dlg.setupNewId(false);
if(flags & RS_CHAT_LOBBY_FLAGS_PGP_SIGNED) //
dlg.enforceNoAnonIds() ;
dlg.exec();
// fetch new id
if(!rsIdentity->getOwnIds(own_ids) || own_ids.empty())
@ -733,8 +788,20 @@ void ChatLobbyWidget::subscribeChatLobbyAtItem(QTreeWidgetItem *item)
gxs_id = own_ids.front();
}
else
{
rsMsgs->getDefaultIdentityForChatLobby(gxs_id);
RsIdentityDetails idd ;
if(!rsIdentity->getIdDetails(gxs_id,idd))
return ;
if(flags & RS_CHAT_LOBBY_FLAGS_PGP_SIGNED)
{
QMessageBox::warning(NULL,tr("Default identity is anonymous"),tr("You cannot join this lobby with your default identity, since it is anonymous and the lobby forbids it.")) ;
return ;
}
}
if(rsMsgs->joinVisibleChatLobby(id,gxs_id))
ChatDialog::chatFriend(ChatId(id),true) ;
}
@ -763,6 +830,8 @@ void ChatLobbyWidget::showBlankPage(ChatLobbyId id)
std::list<RsGxsId> my_ids ;
rsIdentity->getOwnIds(my_ids) ;
trimAnonIds(my_ids) ;
for(std::vector<VisibleChatLobbyRecord>::const_iterator it(lobbies.begin());it!=lobbies.end();++it)
if( (*it).lobby_id == id)
{
@ -770,10 +839,15 @@ void ChatLobbyWidget::showBlankPage(ChatLobbyId id)
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_flags & RS_CHAT_LOBBY_FLAGS_PUBLIC)?tr("Public"):tr("Private")) );
ui.lobbysec_lineEdit->setText( (( (*it).lobby_flags & RS_CHAT_LOBBY_FLAGS_PGP_SIGNED)?tr("No anonymous IDs"):tr("Anonymous ids accepted")) );
ui.lobbypeers_lineEdit->setText( QString::number((*it).total_number_of_peers) );
QString text = tr("You're not subscribed to this lobby; Double click-it to enter and chat.") ;
if(my_ids.empty())
if( (*it).lobby_flags & RS_CHAT_LOBBY_FLAGS_PGP_SIGNED)
text += "\n\n"+tr("You will need to create a non anonymous identity in order to join this chat lobby.") ;
else
text += "\n\n"+tr("You will need to create an identity in order to join chat lobbies.") ;
ui.lobbyInfoLabel->setText(text);
@ -785,6 +859,7 @@ void ChatLobbyWidget::showBlankPage(ChatLobbyId id)
ui.lobbytopic_lineEdit->clear();
ui.lobbytype_lineEdit->clear();
ui.lobbypeers_lineEdit->clear();
ui.lobbysec_lineEdit->clear();
QString text = tr("No lobby selected. \nSelect lobbies at left to show details.\nDouble click lobbies to enter and chat.") ;
ui.lobbyInfoLabel->setText(text) ;

View File

@ -6,21 +6,12 @@
<rect>
<x>0</x>
<y>0</y>
<width>643</width>
<height>426</height>
<width>803</width>
<height>517</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_5">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<property name="margin">
<number>0</number>
</property>
<item>
@ -99,7 +90,7 @@
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<widget class="QWidget" name="">
<widget class="QWidget" name="layoutWidget">
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QFrame" name="toolBarFrame">
@ -201,9 +192,6 @@
</property>
<item row="0" column="0">
<widget class="QGroupBox" name="lobbyinfo_groupBox">
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="title">
<string>Selected lobby info</string>
</property>
@ -264,6 +252,19 @@
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_6">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Security:</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_5">
<property name="font">
@ -336,6 +337,13 @@
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="lobbysec_lineEdit">
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="lobbypeers_lineEdit">
<property name="sizePolicy">

View File

@ -210,6 +210,12 @@ void IdEditDialog::setupExistingId(const RsGxsGroupId &keyId)
mIdQueue->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, groupIds, IDEDITDIALOG_LOADID);
}
void IdEditDialog::enforceNoAnonIds()
{
ui->radioButton_GpgId->setChecked(true);
ui->radioButton_GpgId->setEnabled(false);
}
void IdEditDialog::loadExistingId(uint32_t token)
{
mStateHelper->setLoading(IDEDITDIALOG_LOADID, false);

View File

@ -47,6 +47,7 @@ public:
void setupNewId(bool pseudo);
void setupExistingId(const RsGxsGroupId &keyId);
void enforceNoAnonIds() ;
RsGxsGroupId groupId() { return mGroupId; }

View File

@ -57,7 +57,8 @@ CreateLobbyDialog::CreateLobbyDialog(const std::set<RsPeerId>& peer_list, int pr
connect( ui->buttonBox, SIGNAL(rejected()), this, SLOT(close()));
connect( ui->lobbyName_LE, SIGNAL( textChanged ( QString ) ), this, SLOT( checkTextFields( ) ) );
connect( ui->lobbyTopic_LE, SIGNAL( textChanged ( QString ) ), this, SLOT( checkTextFields( ) ) );
connect( ui->idChooser_CB, SIGNAL( currentChanged ( int ) ), this, SLOT( checkTextFields( ) ) );
connect( ui->idChooser_CB, SIGNAL( currentIndexChanged ( int ) ), this, SLOT( checkTextFields( ) ) );
connect( ui->pgp_signed_CB, SIGNAL( toggled ( bool ) ), this, SLOT( checkTextFields( ) ) );
/* initialize key share list */
ui->keyShareList->setHeaderText(tr("Contacts:"));
@ -105,6 +106,13 @@ void CreateLobbyDialog::checkTextFields()
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(true) ;
break ;
}
RsIdentityDetails(idd) ;
rsIdentity->getIdDetails(id,idd) ;
if( (!idd.mPgpKnown) && ui->pgp_signed_CB->isChecked())
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false) ;
}
void CreateLobbyDialog::createLobby()
@ -128,6 +136,7 @@ void CreateLobbyDialog::createLobby()
case GxsIdChooser::NoId:
case GxsIdChooser::None:
return ;
default: break ;
}
// add to group
@ -136,6 +145,9 @@ void CreateLobbyDialog::createLobby()
if(ui->security_CB->currentIndex() == 0)
lobby_flags |= RS_CHAT_LOBBY_FLAGS_PUBLIC ;
if(ui->pgp_signed_CB->isChecked())
lobby_flags |= RS_CHAT_LOBBY_FLAGS_PGP_SIGNED ;
ChatLobbyId id = rsMsgs->createChatLobby(lobby_name,gxs_id, lobby_topic, shareList, lobby_flags);
std::cerr << "gui: Created chat lobby " << std::hex << id << std::dec << std::endl ;

View File

@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>787</width>
<width>1315</width>
<height>486</height>
</rect>
</property>
@ -86,7 +86,7 @@
<item row="3" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Security policy:</string>
<string>Visibility:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
@ -110,6 +110,29 @@
<item row="2" column="2">
<widget class="GxsIdChooser" name="idChooser_CB"/>
</item>
<item row="4" column="2">
<widget class="QCheckBox" name="pgp_signed_CB">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;If you check this, only PGP-signed ids can be used to join and talk in this lobby. This limitation prevents anonymous spamming as it becomes possible for at least some people in the lobby to locate the spammer's node.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>require PGP-signed identities</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label">
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="text">
<string>Security:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
</layout>
</item>
<item>