removed all permission system. Kept the use-as-direct-source option.

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7904 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
csoler 2015-02-02 22:32:30 +00:00
parent a018f17af7
commit 64f8b4c539
8 changed files with 55 additions and 221 deletions

View File

@ -73,26 +73,21 @@ const uint32_t RS_PEER_STATE_ONLINE = 0x0002;
const uint32_t RS_PEER_STATE_CONNECTED = 0x0004;
const uint32_t RS_PEER_STATE_UNREACHABLE= 0x0008;
// Service permission flags.
// Service option flags.
//
const ServicePermissionFlags RS_SERVICE_PERM_NONE ( 0x00000000 ) ;
const ServicePermissionFlags RS_SERVICE_PERM_TURTLE ( 0x00000001 ) ;
const ServicePermissionFlags RS_SERVICE_PERM_DISCOVERY ( 0x00000002 ) ;
const ServicePermissionFlags RS_SERVICE_PERM_DISTRIB ( 0x00000004 ) ;
const ServicePermissionFlags RS_SERVICE_PERM_DIRECT_DL ( 0x00000008 ) ;
const ServicePermissionFlags RS_SERVICE_PERM_ALL = RS_SERVICE_PERM_TURTLE | RS_SERVICE_PERM_DISCOVERY
| RS_SERVICE_PERM_DISTRIB | RS_SERVICE_PERM_DIRECT_DL;
const ServicePermissionFlags RS_SERVICE_PERM_ALL = RS_SERVICE_PERM_DIRECT_DL ;
// ...
/* Connect state */
const uint32_t RS_PEER_CONNECTSTATE_OFFLINE = 0;
const uint32_t RS_PEER_CONNECTSTATE_TRYING_TCP = 2;
const uint32_t RS_PEER_CONNECTSTATE_TRYING_UDP = 3;
const uint32_t RS_PEER_CONNECTSTATE_CONNECTED_TCP = 4;
const uint32_t RS_PEER_CONNECTSTATE_CONNECTED_UDP = 5;
const uint32_t RS_PEER_CONNECTSTATE_CONNECTED_TOR = 6;
const uint32_t RS_PEER_CONNECTSTATE_CONNECTED_UNKNOWN = 7;
/* Error codes for certificate cleaning and cert parsing. Numbers should not overlap. */
@ -215,10 +210,10 @@ class RsPeerDetails
bool accept_connection;
/* Peer permission flags. What services the peer can use (Only valid if friend).*/
ServicePermissionFlags service_perm_flags ;
/* Peer permission flags. What services the peer can use (Only valid if friend).*/
ServicePermissionFlags service_perm_flags ;
/* Network details (only valid if friend) */
/* Network details (only valid if friend) */
uint32_t state;
std::string connectAddr ; // current address if connected.
@ -326,7 +321,7 @@ class RsPeers
virtual bool gpgSignData(const void *data, const uint32_t len, unsigned char *sign, unsigned int *signlen) = 0;
/* Add/Remove Friends */
virtual bool addFriend(const RsPeerId &ssl_id, const RsPgpId &gpg_id,ServicePermissionFlags flags = RS_SERVICE_PERM_ALL) = 0;
virtual bool addFriend(const RsPeerId &ssl_id, const RsPgpId &gpg_id,ServicePermissionFlags flags = RS_SERVICE_PERM_ALL) = 0;
virtual bool removeFriend(const RsPgpId& pgp_id) = 0;
virtual bool removeFriendLocation(const RsPeerId& sslId) = 0;
@ -397,11 +392,11 @@ class RsPeers
//
virtual FileSearchFlags computePeerPermissionFlags(const RsPeerId& peer_id,FileStorageFlags file_sharing_flags,const std::list<std::string>& file_parent_groups) = 0;
/* Service permission flags */
/* Service permission flags */
virtual ServicePermissionFlags servicePermissionFlags(const RsPgpId& gpg_id) = 0;
virtual ServicePermissionFlags servicePermissionFlags(const RsPeerId& ssl_id) = 0;
virtual void setServicePermissionFlags(const RsPgpId& gpg_id,const ServicePermissionFlags& flags) = 0;
virtual ServicePermissionFlags servicePermissionFlags(const RsPgpId& gpg_id) = 0;
virtual ServicePermissionFlags servicePermissionFlags(const RsPeerId& ssl_id) = 0;
virtual void setServicePermissionFlags(const RsPgpId& gpg_id,const ServicePermissionFlags& flags) = 0;
};
#endif

View File

@ -274,25 +274,10 @@ int p3discovery2::handleIncoming()
if (NULL != (contact = dynamic_cast<RsDiscContactItem *> (item)))
{
if (item->PeerId() == contact->sslId) /* self describing */
{
recvOwnContactInfo(item->PeerId(), contact);
}
else if (rsPeers->servicePermissionFlags(item->PeerId()) & RS_SERVICE_PERM_DISCOVERY)
{
processContactInfo(item->PeerId(), contact);
}
else
{
/* not allowed */
delete item;
}
continue;
}
else
processContactInfo(item->PeerId(), contact);
/* any other packets should be dropped if they don't have permission */
if(!(rsPeers->servicePermissionFlags(item->PeerId()) & RS_SERVICE_PERM_DISCOVERY))
{
delete item;
continue;
}
@ -795,15 +780,6 @@ void p3discovery2::sendContactInfo_locked(const PGPID &aboutId, const SSLID &toI
std::cerr << "p3discovery2::sendContactInfo_locked() aboutPGPId: " << aboutId << " toId: " << toId;
std::cerr << std::endl;
#endif
if (!(rsPeers->servicePermissionFlags(toId) & RS_SERVICE_PERM_DISCOVERY))
{
#ifdef P3DISC_DEBUG
std::cerr << "p3discovery2::sendContactInfo_locked() discovery disabled for SSLID: " << toId;
std::cerr << std::endl;
#endif
return;
}
std::map<PGPID, DiscPgpInfo>::const_iterator it;
it = mFriendList.find(aboutId);
if (it == mFriendList.end())

View File

@ -50,13 +50,7 @@ ServicePermissionDialog::ServicePermissionDialog() :
ui->servicePermissionList->setShowType(FriendSelectionWidget::SHOW_GROUP | FriendSelectionWidget::SHOW_GPG);
/* add columns */
int column = ui->servicePermissionList->addColumn(tr("Anonymous routing"));
mColumns[column] = RS_SERVICE_PERM_TURTLE;
column = ui->servicePermissionList->addColumn(tr("Discovery"));
mColumns[column] = RS_SERVICE_PERM_DISCOVERY;
column = ui->servicePermissionList->addColumn(tr("Forums/Channels"));
mColumns[column] = RS_SERVICE_PERM_DISTRIB;
column = ui->servicePermissionList->addColumn(tr("Use as direct source, when available"));
int column = ui->servicePermissionList->addColumn(tr("Use as direct source, when available"));
mColumns[column] = RS_SERVICE_PERM_DIRECT_DL;
ui->servicePermissionList->start();

View File

@ -95,7 +95,7 @@ ConfCertDialog::ConfCertDialog(const RsPeerId& id, const RsPgpId &pgp_id, QWidge
ui.headerFrame->setHeaderImage(QPixmap(":/images/user/identityinfo64.png"));
ui.headerFrame->setHeaderText(tr("Friend Details"));
ui._chat_CB->hide() ;
//ui._chat_CB->hide() ;
setAttribute(Qt::WA_DeleteOnClose, true);
@ -135,19 +135,6 @@ ConfCertDialog::~ConfCertDialog()
}
}
void ConfCertDialog::setServiceFlags()
{
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 ;
if( ui._direct_transfer_CB->isChecked()) flags = flags | RS_SERVICE_PERM_DIRECT_DL ;
rsPeers->setServicePermissionFlags(pgpId,flags) ;
}
void ConfCertDialog::loadAll()
{
for(QMap<RsPeerId, ConfCertDialog*>::iterator it = instances_ssl.begin(); it != instances_ssl.end(); ++it) it.value()->load();
@ -178,11 +165,6 @@ 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._direct_transfer_CB->setChecked( detail.service_perm_flags & RS_SERVICE_PERM_DIRECT_DL ) ;
ui.name->setText(QString::fromUtf8(detail.name.c_str()));
ui.peerid->setText(QString::fromStdString(detail.id.toStdString()));
@ -496,8 +478,6 @@ void ConfCertDialog::applyDialog()
emit configChanged();
}
setServiceFlags() ;
loadAll();
close();
}
@ -509,7 +489,6 @@ void ConfCertDialog::makeFriend()
}
rsPeers->addFriend(peerId, pgpId);
setServiceFlags() ;
loadAll();
emit configChanged();

View File

@ -80,7 +80,6 @@ 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>643</height>
<height>669</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">
@ -810,107 +810,10 @@ p, li { white-space: pre-wrap; }
<normaloff>:/images/admin-16.png</normaloff>:/images/admin-16.png</iconset>
</attribute>
<attribute name="title">
<string>Services</string>
<string>Options</string>
</attribute>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="label_7">
<property name="maximumSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="../images.qrc">:/images/admin-24.png</pixmap>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="StyledLabel" name="servicePermissionsLabel">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>User service permissions</string>
</property>
</widget>
</item>
<item row="1" column="0" colspan="2">
<widget class="QPlainTextEdit" name="servicePermissionsInfoLabel">
<property name="readOnly">
<bool>true</bool>
</property>
<property name="plainText">
<string>This tab allows you to finely tune which services each of your contacts is allowed to use with you.
Some services (Discovery, anonymous routing) can be switched off globally, which always overrides the settings per-user.</string>
</property>
<property name="overwriteMode">
<bool>false</bool>
</property>
</widget>
</item>
<item row="2" column="0" colspan="2">
<widget class="QCheckBox" name="_anonymous_routing_CB">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p align=&quot;justify&quot;&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 align=&quot;justify&quot;&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 row="3" column="0" colspan="2">
<widget class="QCheckBox" name="_discovery_CB">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p align=&quot;justify&quot;&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 align=&quot;justify&quot;&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 row="4" column="0" colspan="2">
<widget class="QCheckBox" name="_forums_channels_CB">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p align=&quot;justify&quot;&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 row="5" column="0" colspan="2">
<widget class="QCheckBox" name="_direct_transfer_CB">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p align=&quot;justify&quot;&gt;Retroshare periodically checks your friend lists for browsable files matching your transfers, to establish a direct transfer. In this case, your friend knows you're downloading the file.&lt;/p&gt;&lt;p align=&quot;justify&quot;&gt;To prevent this behavior for this friend only, uncheck this box. You can still perform a direct transfer if you explicitly ask for it, by e.g. downloading from your friend's file list. &lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Use as direct source, when available</string>
</property>
</widget>
</item>
<item row="6" column="0" colspan="2">
<widget class="QCheckBox" name="_chat_CB">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Chat</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="7" column="0" colspan="2">
<spacer name="verticalSpacer_4">
<property name="orientation">
<enum>Qt::Vertical</enum>
@ -923,6 +826,16 @@ Some services (Discovery, anonymous routing) can be switched off globally, which
</property>
</spacer>
</item>
<item row="0" column="0" colspan="2">
<widget class="QCheckBox" name="_direct_transfer_CB">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p align=&quot;justify&quot;&gt;Retroshare periodically checks your friend lists for browsable files matching your transfers, to establish a direct transfer. In this case, your friend knows you're downloading the file.&lt;/p&gt;&lt;p align=&quot;justify&quot;&gt;To prevent this behavior for this friend only, uncheck this box. You can still perform a direct transfer if you explicitly ask for it, by e.g. downloading from your friend's file list. &lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Use as direct source, when available</string>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
@ -939,11 +852,6 @@ Some services (Discovery, anonymous routing) can be switched off globally, which
<header>gui/common/AvatarWidget.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>StyledLabel</class>
<extends>QLabel</extends>
<header>gui/common/StyledLabel.h</header>
</customwidget>
<customwidget>
<class>HeaderFrame</class>
<extends>QFrame</extends>

View File

@ -256,10 +256,7 @@ 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) ;
ui->_direct_transfer_CB_2 ->setChecked(peerDetails.service_perm_flags & RS_SERVICE_PERM_DIRECT_DL) ;
ui->_direct_transfer_CB_2 ->setChecked(peerDetails.service_perm_flags & RS_SERVICE_PERM_DIRECT_DL) ;
RsPeerDetails tmp_det ;
bool already_in_keyring = rsPeers->getGPGDetails(peerDetails.gpg_id, tmp_det) ;
@ -277,7 +274,7 @@ void ConnectFriendWizard::initializePage(int id)
//gpg key connection is already accepted, don't propose to accept it again
ui->signGPGCheckBox->setChecked(false);
ui->acceptNoSignGPGCheckBox->hide();
ui->acceptNoSignGPGCheckBox->setChecked(false);
ui->acceptNoSignGPGCheckBox->setChecked(false);
}
if (!peerDetails.accept_connection && peerDetails.ownsign) {
//gpg key is already signed, don't propose to sign it again
@ -619,21 +616,15 @@ int ConnectFriendWizard::nextId() const
ServicePermissionFlags ConnectFriendWizard::serviceFlags() const
{
ServicePermissionFlags flags(0) ;
ServicePermissionFlags flags(0) ;
if (hasVisitedPage(Page_FriendRequest))
{
if(ui->_anonymous_routing_CB->isChecked()) flags |= RS_SERVICE_PERM_TURTLE ;
if( ui->_discovery_CB->isChecked()) flags |= RS_SERVICE_PERM_DISCOVERY ;
if( ui->_forums_channels_CB->isChecked()) flags |= RS_SERVICE_PERM_DISTRIB ;
if( ui->_direct_transfer_CB->isChecked()) flags |= RS_SERVICE_PERM_DIRECT_DL ;
} else if (hasVisitedPage(Page_Conclusion)) {
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 ;
if( ui->_direct_transfer_CB_2->isChecked()) flags |= RS_SERVICE_PERM_DIRECT_DL ;
}
return flags ;
if (hasVisitedPage(Page_FriendRequest))
{
if( ui->_direct_transfer_CB->isChecked()) flags |= RS_SERVICE_PERM_DIRECT_DL ;
} else if (hasVisitedPage(Page_Conclusion)) {
if( ui->_direct_transfer_CB_2->isChecked()) flags |= RS_SERVICE_PERM_DIRECT_DL ;
}
return flags ;
}
void ConnectFriendWizard::accept()
{
@ -675,8 +666,8 @@ void ConnectFriendWizard::accept()
if(accept_connection && !peerDetails.gpg_id.isNull())
{
std::cerr << "ConclusionPage::validatePage() accepting GPG key for connection." << std::endl;
rsPeers->addFriend(peerDetails.id, peerDetails.gpg_id,serviceFlags()) ;
rsPeers->setServicePermissionFlags(peerDetails.gpg_id,serviceFlags()) ;
rsPeers->addFriend(peerDetails.id, peerDetails.gpg_id,serviceFlags()) ;
rsPeers->setServicePermissionFlags(peerDetails.gpg_id,serviceFlags()) ;
if(sign)
{

View File

@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>604</width>
<width>662</width>
<height>623</height>
</rect>
</property>
@ -677,30 +677,9 @@
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Service permissions</string>
<string>Options</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>
<item>
<widget class="QCheckBox" name="_direct_transfer_CB">
<property name="text">
@ -708,6 +687,19 @@
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer_5">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>