changed the connect wizard so that we can add someone key to keyring without making friend. Made connection progress dialog only show up when really making friend

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@6801 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
csoler 2013-10-04 20:55:16 +00:00
parent a9290e9dd7
commit f3f7a40ad7
2 changed files with 124 additions and 91 deletions

View File

@ -97,6 +97,9 @@ ConnectFriendWizard::ConnectFriendWizard(QWidget *parent) :
/* disable not used pages */
ui->foffRadioButton->hide();
ui->rsidRadioButton->hide();
connect(ui->acceptNoSignGPGCheckBox,SIGNAL(toggled(bool)), ui->optionsFrame,SLOT(setEnabled(bool))) ;
connect(ui->addKeyToKeyring_CB,SIGNAL(toggled(bool)), ui->acceptNoSignGPGCheckBox,SLOT(setChecked(bool))) ;
}
QString ConnectFriendWizard::getErrorString(uint32_t error_code)
@ -251,6 +254,17 @@ void ConnectFriendWizard::initializePage(int id)
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) ;
RsPeerDetails tmp_det ;
bool already_in_keyring = rsPeers->getPeerDetails(peerDetails.gpg_id, tmp_det) ;
ui->addKeyToKeyring_CB->setChecked(true) ;
ui->addKeyToKeyring_CB->setEnabled(!already_in_keyring) ;
if(already_in_keyring)
ui->addKeyToKeyring_CB->setToolTip(tr("This key is already in your keyring")) ;
else
ui->addKeyToKeyring_CB->setToolTip(tr("Check this to add the key to your keyring\nThis might be useful for sending\ndistant messages to this peer\neven if you don't make friends.")) ;
//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
@ -607,12 +621,14 @@ void ConnectFriendWizard::accept()
{
bool sign = false;
bool accept_connection = false;
bool add_key_to_keyring = false;
if (hasVisitedPage(Page_Conclusion)) {
std::cerr << "ConnectFriendWizard::accept() called with page conclusion visited" << std::endl;
sign = ui->signGPGCheckBox->isChecked();
accept_connection = ui->acceptNoSignGPGCheckBox->isChecked();
add_key_to_keyring = ui->addKeyToKeyring_CB->isChecked() ;
} else if (hasVisitedPage(Page_FriendRequest)) {
std::cerr << "ConnectFriendWizard::accept() called with page friend request visited" << std::endl;
@ -623,7 +639,7 @@ void ConnectFriendWizard::accept()
return;
}
if (!mCertificate.empty() && (accept_connection || sign))
if (!mCertificate.empty() && add_key_to_keyring)
{
std::string pgp_id,ssl_id,error_string ;
@ -635,29 +651,26 @@ void ConnectFriendWizard::accept()
}
bool runProgressDialog = false;
if (!peerDetails.gpg_id.empty()) {
if (sign) {
if(accept_connection && !peerDetails.gpg_id.empty())
{
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()) ;
if(sign)
{
std::cerr << "ConclusionPage::validatePage() signing GPG key." << std::endl;
rsPeers->signGPGCertificate(peerDetails.gpg_id); //bye default sign set accept_connection to true;
rsPeers->setServicePermissionFlags(peerDetails.gpg_id,serviceFlags()) ;
runProgressDialog = true;
}
} else if (accept_connection) {
std::cerr << "ConclusionPage::validatePage() accepting GPG key for connection." << std::endl;
rsPeers->addFriend("", peerDetails.gpg_id,serviceFlags()) ;
rsPeers->setServicePermissionFlags(peerDetails.gpg_id,serviceFlags()) ;
runProgressDialog = true;
}
if (!groupId.isEmpty()) {
if (!groupId.isEmpty())
rsPeers->assignPeerToGroup(groupId.toStdString(), peerDetails.gpg_id, true);
}
}
if (peerDetails.id != "") {
rsPeers->addFriend(peerDetails.id, peerDetails.gpg_id,serviceFlags()) ;
runProgressDialog = true;
if(accept_connection)
{
//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;
@ -675,6 +688,7 @@ void ConnectFriendWizard::accept()
std::cerr << "ConnectFriendWizard::accept() : setting peerLocation." << std::endl;
rsPeers->setLocation(peerDetails.id, peerDetails.location);
}
runProgressDialog = true;
}
if (runProgressDialog)

View File

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>603</width>
<height>624</height>
<height>623</height>
</rect>
</property>
<property name="windowTitle">
@ -780,7 +780,7 @@
<attribute name="pageId">
<string notr="true">ConnectFriendWizard::Page_Conclusion</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_10">
<layout class="QVBoxLayout" name="verticalLayout_18">
<item>
<widget class="QGroupBox" name="peerDetailsFrame">
<property name="title">
@ -874,84 +874,103 @@
</widget>
</item>
<item>
<widget class="QGroupBox" name="optionsFrame">
<property name="title">
<string>Options</string>
<widget class="QCheckBox" name="addKeyToKeyring_CB">
<property name="text">
<string>Add key to keyring</string>
</property>
<layout class="QFormLayout" name="formLayout_2">
<item row="0" column="0">
<widget class="QLabel" name="groupLabel">
<property name="text">
<string>Add friend to group:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="groupComboBox"/>
</item>
<item row="1" column="0">
<widget class="QCheckBox" name="signGPGCheckBox">
<property name="text">
<string>Authenticate friend (Sign PGP Key)</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QCheckBox" name="acceptNoSignGPGCheckBox">
<property name="text">
<string>Add as friend to connect with</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>Service permissions</string>
<widget class="QCheckBox" name="acceptNoSignGPGCheckBox">
<property name="text">
<string>Add as friend to connect with</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_7">
</widget>
</item>
<item>
<widget class="QGroupBox" name="optionsFrame">
<property name="title">
<string/>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_10">
<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>
<widget class="QCheckBox" name="_direct_transfer_CB_2">
<property name="text">
<string>Direct source</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>
<layout class="QHBoxLayout" name="horizontalLayout_7">
<item>
<layout class="QVBoxLayout" name="verticalLayout_17">
<item>
<widget class="QCheckBox" name="signGPGCheckBox">
<property name="text">
<string>Authenticate friend (Sign PGP Key)</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_9">
<item>
<widget class="QLabel" name="groupLabel">
<property name="text">
<string>Add friend to group:</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="groupComboBox"/>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer_4">
<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>
</item>
<item>
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>Service permissions</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_10">
<item>
<widget class="QCheckBox" name="_direct_transfer_CB_2">
<property name="text">
<string>Direct source</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="_discovery_CB_2">
<property name="text">
<string>Discovery</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="_anonymous_routing_CB_2">
<property name="text">
<string>Anonymous routing</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</item>
</layout>
</widget>