- Added flags for services and service permissions for peers

Flags are identity-related, meaning that all locations of the same peers have the same flags.
- It's now possible to tweak which services each peer can use. Service that can be disabled are
  forums/channels, discovery, anonymous routing.
- by default, peers have all flags on.
- fixed missing error msg in p3cfgmgr when serialisation fails.
- fixed bug in RemoteDirModel causing infinite loop to happen when group name is unknown




git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@5924 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
csoler 2012-12-01 19:22:22 +00:00
parent 099a3ad33e
commit e3da77612a
24 changed files with 887 additions and 242 deletions

View file

@ -218,6 +218,9 @@ QString RetroshareDirModel::getGroupsString(const std::list<std::string>& group_
if(++it != group_ids.end())
groups_str += ", " ;
}
else
++it ;
return groups_str ;
}

View file

@ -79,6 +79,9 @@ ConfCertDialog::ConfCertDialog(const std::string& id, QWidget *parent, Qt::WFlag
connect(ui.trusthelpButton, SIGNAL(clicked()), this, SLOT(showHelpDialog()));
connect(ui._shouldAddSignatures_CB, SIGNAL(toggled(bool)), this, SLOT(loadInvitePage()));
connect(ui._useOldFormat_CB, SIGNAL(toggled(bool)), this, SLOT(loadInvitePage()));
// connect(ui._anonymous_routing_CB, SIGNAL(toggled(bool)), this, SLOT(setServiceFlags()));
// connect(ui._discovery_CB, SIGNAL(toggled(bool)), this, SLOT(setServiceFlags()));
// connect(ui._forums_channels_CB, SIGNAL(toggled(bool)), this, SLOT(setServiceFlags()));
ui.avatar->setFrameType(AvatarWidget::NORMAL_FRAME);
@ -120,6 +123,21 @@ void ConfCertDialog::showIt(const std::string& peer_id, enumPage page)
/* window will destroy itself! */
}
void ConfCertDialog::setServiceFlags()
{
RsPeerDetails detail;
if (!rsPeers->getPeerDetails(mId, detail))
return ;
ServicePermissionFlags flags(0) ;
if(ui._anonymous_routing_CB->isChecked()) flags = flags | RS_SERVICE_PERM_TURTLE ;
if( ui._discovery_CB->isChecked()) flags = flags | RS_SERVICE_PERM_DISCOVERY ;
if( ui._forums_channels_CB->isChecked()) flags = flags | RS_SERVICE_PERM_DISTRIB ;
rsPeers->setServicePermissionFlags(detail.gpg_id,flags) ;
}
void ConfCertDialog::loadAll()
{
QMap<std::string, ConfCertDialog*>::iterator it;
@ -151,6 +169,10 @@ void ConfCertDialog::load()
ui.make_friend_button->setToolTip("") ;
}
ui._anonymous_routing_CB->setChecked(detail.service_perm_flags & RS_SERVICE_PERM_TURTLE ) ;
ui._discovery_CB->setChecked( detail.service_perm_flags & RS_SERVICE_PERM_DISCOVERY ) ;
ui._forums_channels_CB->setChecked( detail.service_perm_flags & RS_SERVICE_PERM_DISTRIB ) ;
ui.name->setText(QString::fromUtf8(detail.name.c_str()));
ui.peerid->setText(QString::fromStdString(detail.id));
@ -417,6 +439,8 @@ void ConfCertDialog::applyDialog()
emit configChanged();
}
setServiceFlags() ;
loadAll();
close();
}
@ -429,6 +453,7 @@ void ConfCertDialog::makeFriend()
}
rsPeers->addFriend(mId, gpg_id);
setServiceFlags() ;
loadAll();
emit configChanged();

View file

@ -56,6 +56,7 @@ private slots:
void denyFriend();
void signGPGKey();
void loadInvitePage();
void setServiceFlags();
void showHelpDialog();
/** Called when a child window requests the given help <b>topic</b>. */

View file

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>635</width>
<height>629</height>
<height>665</height>
</rect>
</property>
<property name="windowTitle">
@ -60,7 +60,7 @@
<item row="0" column="0">
<widget class="QTabWidget" name="stabWidget">
<property name="currentIndex">
<number>0</number>
<number>3</number>
</property>
<widget class="QWidget" name="tab">
<attribute name="icon">
@ -738,6 +738,91 @@ p, li { white-space: pre-wrap; }
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_4">
<attribute name="title">
<string>Services</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QTextBrowser" name="textBrowser">
<property name="html">
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Ubuntu'; font-size:11pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;User service permissions&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;This tab allows you to finely tune which services each of your contacts is allowed to use with you.&lt;/p&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Some services (Discovery, anonymous routing) can be switched off globally, which always overrides the settings per-user.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="_anonymous_routing_CB">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Disabling anonymous routing will suppress all sending/retrieval of tunnel and anonymous search requests from/to this user. This user will not be able to transfer anonymously through you.&lt;/p&gt;&lt;p&gt;For a global switch, go to the server configuration panel.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Anonymous routing</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="_discovery_CB">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Disabling discovery removes the sending of public keys of your own friends to this user. Discovery information from this friend will be dropped as well.&lt;/p&gt;&lt;p&gt;For a global switch, go to the server configuration panel.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Discovery</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="_forums_channels_CB">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Disabling this means that forums and channels posts will not be passed from you to this friend, and items coming from this friend will be dropped.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Forums/Channels</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBox_3">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Chat</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton">
<property name="text">
<string>PushButton</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer_4">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>196</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</widget>
</item>
</layout>

View file

@ -222,6 +222,10 @@ void ConnectFriendWizard::initializePage(int id)
{
std::cerr << "Conclusion page id : " << peerDetails.id << "; gpg_id : " << peerDetails.gpg_id << std::endl;
ui->_anonymous_routing_CB_2->setChecked(peerDetails.service_perm_flags & RS_SERVICE_PERM_TURTLE) ;
ui->_discovery_CB_2 ->setChecked(peerDetails.service_perm_flags & RS_SERVICE_PERM_DISCOVERY) ;
ui->_forums_channels_CB_2 ->setChecked(peerDetails.service_perm_flags & RS_SERVICE_PERM_DISTRIB) ;
//set the radio button to sign the GPG key
if (peerDetails.accept_connection && !peerDetails.ownsign) {
//gpg key connection is already accepted, don't propose to accept it again
@ -489,6 +493,17 @@ int ConnectFriendWizard::nextId() const
return -1;
}
ServicePermissionFlags ConnectFriendWizard::serviceFlags() const
{
ServicePermissionFlags flags(0) ;
if(ui->_anonymous_routing_CB_2->isChecked()) flags |= RS_SERVICE_PERM_TURTLE ;
if( ui->_discovery_CB_2->isChecked()) flags |= RS_SERVICE_PERM_DISCOVERY ;
if( ui->_forums_channels_CB_2->isChecked()) flags |= RS_SERVICE_PERM_DISTRIB ;
return flags ;
}
void ConnectFriendWizard::accept()
{
bool sign = false;
@ -526,7 +541,7 @@ void ConnectFriendWizard::accept()
rsPeers->signGPGCertificate(peerDetails.gpg_id); //bye default sign set accept_connection to true;
} else if (accept_connection) {
std::cerr << "ConclusionPage::validatePage() accepting GPG key for connection." << std::endl;
rsPeers->addFriend("", peerDetails.gpg_id);
rsPeers->addFriend("", peerDetails.gpg_id,serviceFlags()) ;
}
if (!groupId.isEmpty()) {
@ -535,7 +550,8 @@ void ConnectFriendWizard::accept()
}
if (peerDetails.id != "") {
rsPeers->addFriend(peerDetails.id, peerDetails.gpg_id);
rsPeers->addFriend(peerDetails.id, peerDetails.gpg_id,serviceFlags()) ;
//let's check if there is ip adresses in the wizard.
if (!peerDetails.extAddr.empty() && peerDetails.extPort) {
std::cerr << "ConnectFriendWizard::accept() : setting ip ext address." << std::endl;

View file

@ -54,6 +54,8 @@ private slots:
void friendCertChanged();
void cleanFriendCert();
ServicePermissionFlags serviceFlags() const ;
/* CertificatePage */
void loadFriendCert();
void generateCertificateCalled();

View file

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>572</width>
<height>517</height>
<width>603</width>
<height>561</height>
</rect>
</property>
<property name="windowTitle">
@ -535,138 +535,193 @@
</property>
<item row="0" column="0">
<widget class="QFrame" name="frame">
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0" colspan="2">
<widget class="QLabel" name="fr_label">
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string notr="true">You have a friend request from</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="AvatarWidget" name="fr_avatar">
<property name="minimumSize">
<size>
<width>96</width>
<height>96</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>96</width>
<height>96</height>
</size>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QGroupBox" name="fr_peerDetailsFrame">
<property name="title">
<string>Peer details</string>
</property>
<layout class="QFormLayout" name="formLayout_3">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
<widget class="QLabel" name="fr_label">
<property name="geometry">
<rect>
<x>9</x>
<y>9</y>
<width>220</width>
<height>19</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string notr="true">You have a friend request from</string>
</property>
</widget>
<widget class="AvatarWidget" name="fr_avatar">
<property name="geometry">
<rect>
<x>9</x>
<y>38</y>
<width>96</width>
<height>96</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>96</width>
<height>96</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>96</width>
<height>96</height>
</size>
</property>
</widget>
<widget class="QGroupBox" name="fr_peerDetailsFrame">
<property name="geometry">
<rect>
<x>111</x>
<y>34</y>
<width>156</width>
<height>105</height>
</rect>
</property>
<property name="title">
<string>Peer details</string>
</property>
<layout class="QFormLayout" name="formLayout_3">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
</property>
<item row="0" column="0">
<widget class="QLabel" name="fr_nameLabel">
<property name="text">
<string>Name:</string>
</property>
<item row="0" column="0">
<widget class="QLabel" name="fr_nameLabel">
<property name="text">
<string>Name:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="fr_nameEdit">
<property name="text">
<string notr="true">Name</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="fr_emailLabel">
<property name="text">
<string>Email:</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="fr_locationLabel">
<property name="text">
<string>Location:</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLabel" name="fr_locationEdit">
<property name="text">
<string notr="true">Location</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLabel" name="fr_emailEdit">
<property name="text">
<string notr="true">Email</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="2" column="0" colspan="2">
<widget class="QGroupBox" name="fr_optionsFrame">
<property name="title">
<string>Options</string>
</property>
<layout class="QFormLayout" name="formLayout_4">
<item row="0" column="0">
<widget class="QLabel" name="fr_groupLabel">
<property name="text">
<string>Add friend to group:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="fr_groupComboBox"/>
</item>
<item row="1" column="0">
<widget class="QCheckBox" name="fr_signGPGCheckBox">
<property name="text">
<string>Authenticate friend (Sign GPG Key)</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QCheckBox" name="fr_acceptNoSignGPGCheckBox">
<property name="text">
<string>Add as friend to connect with</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="3" column="0" colspan="2">
<spacer name="fr_verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>488</width>
<height>118</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="fr_nameEdit">
<property name="text">
<string notr="true">Name</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="fr_emailLabel">
<property name="text">
<string>Email:</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="fr_locationLabel">
<property name="text">
<string>Location:</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLabel" name="fr_locationEdit">
<property name="text">
<string notr="true">Location</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLabel" name="fr_emailEdit">
<property name="text">
<string notr="true">Email</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QGroupBox" name="fr_optionsFrame">
<property name="geometry">
<rect>
<x>9</x>
<y>145</y>
<width>385</width>
<height>239</height>
</rect>
</property>
<property name="title">
<string>Options</string>
</property>
<layout class="QFormLayout" name="formLayout_4">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
</property>
<item row="0" column="0">
<widget class="QLabel" name="fr_groupLabel">
<property name="text">
<string>Add friend to group:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="fr_groupComboBox"/>
</item>
<item row="1" column="0">
<widget class="QCheckBox" name="fr_signGPGCheckBox">
<property name="text">
<string>Authenticate friend (Sign GPG Key)</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QCheckBox" name="fr_acceptNoSignGPGCheckBox">
<property name="text">
<string>Add as friend to connect with</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Service permissions</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_12">
<item>
<widget class="QCheckBox" name="_anonymous_routing_CB">
<property name="text">
<string>Anonymous routing</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="_discovery_CB">
<property name="text">
<string>Discovery</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="_forums_channels_CB">
<property name="text">
<string>Forums/channels</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
<item row="1" column="0">
<spacer name="fr_verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>488</width>
<height>118</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<widget class="ConnectFriendPage" name="ErrorMessagePage">
@ -825,6 +880,49 @@
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>Service permissions</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_7">
<item>
<widget class="QCheckBox" name="_anonymous_routing_CB_2">
<property name="text">
<string>Anonymous routing</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="_forums_channels_CB_2">
<property name="text">
<string>Forums/channels</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="_discovery_CB_2">
<property name="text">
<string>Discovery</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</widget>