Merged branch v0.5-OpenPGP into trunk:

User-level changes:
==================
- libgpgme is not used anymore; it is replaced by a built-in piece of code called OpenPGP-SDK 
  (http://openpgp.nominet.org.uk/cgi-bin/trac.cgi) that was improved to be used by RetroShare
  for handling PGP keys.

- the gnupg keyring is not used anymore. Now, RetroShare has it's own gpg keyring, shared by all instances.
  On linux it's located in ~/.retroshare/pgp/. A lock system prevents multiple locations to read/write keyrings
  simultaneously.

- the trust database from gnupg is not documented, so RetroShare cannot import it. This comes from the fact that
  the GPG standard (RFC4880) asks explicitly not to export trust information. So RetroShare has it's own 
  trust DB shared by locations. This means you need to re-trust people. Sorry for that!

- at start, if no keyring is found, RS will propose to copy the gnupg keyring to use your existing keys. Clicking on 
  "OK" will do the copy, and you should find back all existing locations, except for DSA keys.

- locations for which the suitable keypair is not in the keyring will not be displayed in the login window
- locations for which the suitable keypair is not a RSA/RSA key will not be displayed. RetroShare does not
  support DSA/Elgamal keypairs yet.

- a key import/export exchange function has been added in the certificate creation window (you go there from the login
  window by clicking on "manage keys/locations". This allows to easily create a new location with the same pgp key on
  another computer. To obtain a suitable keypair using gnupg, you need to concatenate the encrypted private key and the 
  public key into an ascii file. This can be done using:
  		gpg -a --export-secret-keys [your ID] > mykey.asc
		gpg -a --export [your ID] >> mykey.asc

- importing a key with subkeys in not yet possible. Please remove subkeys before importing.

- The code has been tested for a reasonnable amount of time, but it's not possible to prevent some new bugs 
  to appear. Please report them asap supplying: call-stacks if possible, and terminal output. In particular,
  openpgp has some assert()'s that should not be triggered unless RetroShare is calling it in an improper way.

Internal changes
================
- a specific component, PGPHandler, takes care of the interface between openpgp-sdk and RetroShare
  openpgp-sdk is c-code, with it's own memory management, which has been kept well separated from 
  RetroShare.

- GPG Ids are now a specific class (not a std::string anymore) for code consistency reasons. As strings are
  still used in many places, this requires a few conversions. In particular, AuthGPG takes strings as
  function params and calls GPGHandler with the proper PGPIdType class. In the future, RetroShare should
  only use PGPIdType. The same will be done for SSL ids.

- signature cleaning is still handled by the Retroshare built-in function, not by openpgp, but we will 
  do this later.

Still to do
===========
- DSA needs subkey handling, since the encryption is performed by a Elgamal subkey. Not sure this will be done.
- GPGIds/SSLIds cleaning (meaning replace strings by appropriate types). Lots of confusion throughout the code in retroshare-gui in particular.
- key removal from keyring. This is a challenge to keep locations synchronised.



git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@5293 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
csoler 2012-07-13 21:53:39 +00:00
commit fc8dfcf65b
109 changed files with 26549 additions and 2997 deletions

View file

@ -26,16 +26,12 @@ linux-* {
#CONFIG += version_detail_bash_script
QMAKE_CXXFLAGS *= -D_FILE_OFFSET_BITS=64
system(which gpgme-config >/dev/null 2>&1) {
INCLUDEPATH += $$system(gpgme-config --cflags | sed -e "s/-I//g")
} else {
message(Could not find gpgme-config on your system, assuming gpgme.h is in /usr/include)
}
PRE_TARGETDEPS *= ../../libretroshare/src/lib/libretroshare.a
PRE_TARGETDEPS *= ../../openpgpsdk/src/lib/libops.a
LIBS += ../../libretroshare/src/lib/libretroshare.a
LIBS += -lssl -lgpgme -lupnp -lixml -lXss -lgnome-keyring
LIBS += ../../openpgpsdk/src/lib/libops.a -lbz2
LIBS += -lssl -lupnp -lixml -lXss -lgnome-keyring
LIBS *= -rdynamic
DEFINES *= HAVE_XSS # for idle time, libx screensaver extensions
DEFINES *= UBUNTU
@ -110,6 +106,7 @@ win32 {
PRE_TARGETDEPS += ../../libretroshare/src/lib/libretroshare.a
LIBS += ../../libretroshare/src/lib/libretroshare.a
LIBS += ../../openpgpsdk/src/lib/libops.a -lbz2
LIBS += -L"../../../lib"
LIBS += -lssl -lcrypto -lgpgme -lpthreadGC2d -lminiupnpc -lz
# added after bitdht

View file

@ -22,6 +22,7 @@
#include <rshare.h>
#include <util/rsrandom.h>
#include <retroshare/rsinit.h>
#include <retroshare/rspeers.h>
#include "GenCertDialog.h"
#include "InfoDialog.h"
#include <QAbstractEventDispatcher>
@ -45,6 +46,8 @@ GenCertDialog::GenCertDialog(QWidget *parent, Qt::WFlags flags)
connect(ui.new_gpg_key_checkbox, SIGNAL(clicked()), this, SLOT(newGPGKeyGenUiSetup()));
connect(ui.genButton, SIGNAL(clicked()), this, SLOT(genPerson()));
connect(ui.importIdentity_PB, SIGNAL(clicked()), this, SLOT(importIdentity()));
connect(ui.exportIdentity_PB, SIGNAL(clicked()), this, SLOT(exportIdentity()));
connect(ui.infopushButton,SIGNAL(clicked()), this, SLOT(infodlg()));
//connect(ui.selectButton, SIGNAL(clicked()), this, SLOT(selectFriend()));
//connect(ui.friendBox, SIGNAL(stateChanged(int)), this, SLOT(checkChanged(int)));
@ -71,7 +74,7 @@ GenCertDialog::GenCertDialog(QWidget *parent, Qt::WFlags flags)
if (RsInit::GetPGPLogins(pgpIds)) {
for(it = pgpIds.begin(); it != pgpIds.end(); it++)
{
const QVariant & userData = QVariant(QString::fromStdString(*it));
QVariant userData(QString::fromStdString(*it));
std::string name, email;
RsInit::GetPGPLoginDetails(*it, name, email);
std::cerr << "Adding PGPUser: " << name << " id: " << *it << std::endl;
@ -94,9 +97,9 @@ GenCertDialog::GenCertDialog(QWidget *parent, Qt::WFlags flags)
ui.new_gpg_key_checkbox->setChecked(true);
ui.new_gpg_key_checkbox->hide();
ui.progressBar->hide();
setWindowTitle(tr("Create new Profile"));
ui.genButton->setText(tr("Generate new Profile"));
ui.label_3->setText( titleString.arg( tr("Create a new Profile") ) ) ;
setWindowTitle(tr("Create new Identity"));
ui.genButton->setText(tr("Generate new Identity"));
ui.label_3->setText( titleString.arg( tr("Create a new Identity") ) ) ;
genNewGPGKey = true;
}
newGPGKeyGenUiSetup();
@ -117,9 +120,11 @@ void GenCertDialog::newGPGKeyGenUiSetup() {
ui.password_input->show();
ui.genPGPuserlabel->hide();
ui.genPGPuser->hide();
setWindowTitle(tr("Create new Profile"));
ui.genButton->setText(tr("Generate new Profile"));
ui.label_3->setText( titleStr.arg( tr("Create a new Profile") ) ) ;
ui.exportIdentity_PB->hide() ;
ui.importIdentity_PB->hide() ;
setWindowTitle(tr("Create new Identity"));
ui.genButton->setText(tr("Generate new Identity"));
ui.label_3->setText( titleStr.arg( tr("Create a new Identity") ) ) ;
} else {
genNewGPGKey = false;
ui.name_label->hide();
@ -130,12 +135,55 @@ void GenCertDialog::newGPGKeyGenUiSetup() {
ui.password_input->hide();
ui.genPGPuserlabel->show();
ui.genPGPuser->show();
ui.exportIdentity_PB->show() ;
ui.importIdentity_PB->show() ;
setWindowTitle(tr("Create new Location"));
ui.genButton->setText(tr("Generate new Location"));
ui.label_3->setText( titleStr.arg( tr("Create a new Location") ) ) ;
}
}
void GenCertDialog::exportIdentity()
{
QString fname = QFileDialog::getSaveFileName(this,tr("Export Identity"), "",tr("Retroshare Identity files (*.asc)")) ;
if(fname.isNull())
return ;
QVariant data = ui.genPGPuser->itemData(ui.genPGPuser->currentIndex());
std::string gpg_id = data.toString().toStdString() ;
if(RsInit::exportIdentity(fname.toStdString(),gpg_id))
QMessageBox::information(this,tr("Identity saved"),tr("Your identity was successfully saved\nIt is encrypted\n\nYou can now copy it to another computer\nand use the import button to load it")) ;
else
QMessageBox::information(this,tr("Identity not saved"),tr("Your identity was not saved. An error occured.")) ;
}
void GenCertDialog::importIdentity()
{
QString fname = QFileDialog::getOpenFileName(this,tr("Export Identity"), "",tr("Retroshare Identity files (*.asc)")) ;
if(fname.isNull())
return ;
std::string gpg_id ;
std::string err_string ;
if(!RsInit::importIdentity(fname.toStdString(),gpg_id,err_string))
{
QMessageBox::information(this,tr("Identity not loaded"),tr("Your identity was not loaded properly:")+" \n "+QString::fromStdString(err_string)) ;
return ;
}
std::string name,email ;
RsInit::GetPGPLoginDetails(gpg_id, name, email);
std::cerr << "Adding PGPUser: " << name << " id: " << gpg_id << std::endl;
QVariant userData(QString::fromStdString(gpg_id));
QString gid = QString::fromStdString(gpg_id).right(8) ;
ui.genPGPuser->addItem(QString::fromUtf8(name.c_str()) + " <" + QString::fromUtf8(email.c_str()) + "> (" + gid + ")", userData);
}
void GenCertDialog::genPerson()
{
/* Check the data from the GUI. */

View file

@ -42,6 +42,8 @@ private slots:
void genPerson();
//void loadPerson();
void selectFriend();
void importIdentity();
void exportIdentity();
void checkChanged(int i);
void infodlg();
void newGPGKeyGenUiSetup();

View file

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>600</width>
<height>480</height>
<width>684</width>
<height>517</height>
</rect>
</property>
<property name="sizePolicy">
@ -593,8 +593,8 @@ border: 1px solid #CCCCCC;}</string>
<property name="title">
<string/>
</property>
<layout class="QGridLayout" name="gridLayout_5">
<item row="0" column="0" colspan="2">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="no_gpg_key_label">
<property name="text">
<string>It looks like you don't own any Profile (GPG keys). Please fill in the form below to generate one, or use your favorite gnupg key manager.</string>
@ -604,36 +604,67 @@ border: 1px solid #CCCCCC;}</string>
</property>
</widget>
</item>
<item row="2" column="0" colspan="2">
<widget class="QCheckBox" name="new_gpg_key_checkbox">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>32</height>
</size>
<item>
<widget class="QProgressBar" name="progressBar">
<property name="maximum">
<number>0</number>
</property>
<property name="toolTip">
<string>Your profile is associated to a GPG key</string>
<property name="value">
<number>-1</number>
</property>
<property name="text">
<string>Generate a new Profile</string>
</property>
<property name="icon">
<iconset resource="images.qrc">
<normaloff>:/images/contact_new128.png</normaloff>:/images/contact_new128.png</iconset>
</property>
<property name="iconSize">
<size>
<width>32</width>
<height>32</height>
</size>
</property>
<property name="tristate">
<property name="textVisible">
<bool>false</bool>
</property>
</widget>
</item>
<item row="3" column="0">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QCheckBox" name="new_gpg_key_checkbox">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>32</height>
</size>
</property>
<property name="toolTip">
<string>Your profile is associated to a GPG key</string>
</property>
<property name="text">
<string>Generate a new identity</string>
</property>
<property name="icon">
<iconset resource="images.qrc">
<normaloff>:/images/contact_new128.png</normaloff>:/images/contact_new128.png</iconset>
</property>
<property name="iconSize">
<size>
<width>32</width>
<height>32</height>
</size>
</property>
<property name="tristate">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="importIdentity_PB">
<property name="text">
<string>Import new identity</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="exportIdentity_PB">
<property name="text">
<string>Export selected identity</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QLabel" name="progress_label">
<property name="maximumSize">
<size>
@ -646,19 +677,19 @@ border: 1px solid #CCCCCC;}</string>
</property>
</widget>
</item>
<item row="4" column="0" colspan="2">
<item>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QLabel" name="genPGPuserlabel">
<property name="text">
<string>Use Profile</string>
<string>Use identity</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="genPGPuser">
<property name="toolTip">
<string>Your profile is associated to a GPG key</string>
<string>Your profile is associated to a GPG key. RetroShare currently ignores DSA keys.</string>
</property>
</widget>
</item>
@ -737,7 +768,7 @@ anonymous, you can use a fake email.</string>
<number>1</number>
</property>
<property name="text">
<string>Put a meaningfull location. ex : home, laptop, etc. This field will be used to differentiate different installations with the same profile (gpg key).</string>
<string>Put a meaningfull location. ex : home, laptop, etc. This field will be used to differentiate different installations with the same identity (gpg key).</string>
</property>
<property name="scaledContents">
<bool>false</bool>
@ -749,32 +780,6 @@ anonymous, you can use a fake email.</string>
</item>
</layout>
</item>
<item row="6" column="0" colspan="2">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="0">
<widget class="QProgressBar" name="progressBar">
<property name="maximum">
<number>0</number>
</property>
<property name="value">
<number>-1</number>
</property>
<property name="textVisible">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
@ -789,7 +794,7 @@ anonymous, you can use a fake email.</string>
</size>
</property>
<property name="text">
<string>Generate New Profile</string>
<string>Generate New Identity</string>
</property>
<property name="icon">
<iconset resource="images.qrc">
@ -850,8 +855,8 @@ anonymous, you can use a fake email.</string>
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<layout class="QGridLayout" name="gridLayout_4">
<item row="0" column="0" rowspan="2">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLabel" name="label">
<property name="maximumSize">
<size>
@ -870,30 +875,37 @@ anonymous, you can use a fake email.</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="label_3">
<property name="text">
<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;
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QLabel" name="label_3">
<property name="text">
<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:'MS Shell Dlg 2'; font-size:8.25pt; 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-family:'Arial'; font-size:16pt; color:#ffffff;&quot;&gt;Create a new Profile&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLabel" name="label_2">
<property name="text">
<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;/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-family:'Arial'; font-size:16pt; color:#ffffff;&quot;&gt;Create a new Identity&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<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:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;&quot;&gt;
&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-family:'Arial'; font-size:8pt; font-weight:600;&quot;&gt;RetroShare uses gpg keys for identity management. &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; font-family:'Arial'; font-size:8pt; font-weight:600;&quot;&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;&lt;span style=&quot; font-family:'Arial'; font-size:8pt; font-weight:600;&quot;&gt;You can use an existing profile (gpg key), or create a new one with this form.&lt;/span&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;&lt;span style=&quot; font-family:'Arial'; font-size:8pt; font-weight:600;&quot;&gt;You can install retroshare on different locations using the same profile (gpg key).&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
&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-family:'Arial'; font-size:8pt; font-weight:600;&quot;&gt;You can use an existing identity (i.e. a gpg key pair), from the list below, or create a new &lt;/span&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;&lt;span style=&quot; font-family:'Arial'; font-size:8pt; font-weight:600;&quot;&gt;one with this form.&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; font-family:'MS Shell Dlg 2'; font-size:8pt;&quot;&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;&lt;span style=&quot; font-family:'Arial'; font-size:8pt; font-weight:600;&quot;&gt;You can install retroshare on different locations using the same identity. For this, just export the&lt;/span&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;&lt;span style=&quot; font-family:'Arial'; font-size:8pt; font-weight:600;&quot;&gt; selected identity, and import it on the new computer, then create a new location with it.&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>

View file

@ -18,7 +18,6 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
****************************************************************/
#include <gpgme.h>
#include <QTreeWidget>
#include <QDebug>
@ -308,50 +307,6 @@ void NetworkDialog::copyLink()
RSLinkClipboard::copyLinks(urls);
}
/** Open a QFileDialog to browse for a pem/pqi file. */
//void NetworkDialog::loadcert()
//{
// use misc::getOpenFileName
// /* Create a new input dialog, which allows users to create files, too */
// QFileDialog dialog (this, tr("Select a pem/pqi File"));
// //dialog.setDirectory(QFileInfo(ui.lineTorConfig->text()).absoluteDir());
// //dialog.selectFile(QFileInfo(ui.lineTorConfig->text()).fileName());
// dialog.setFileMode(QFileDialog::AnyFile);
// dialog.setReadOnly(false);
//
// /* Prompt the user to select a file or create a new one */
// if (!dialog.exec() || dialog.selectedFiles().isEmpty()) {
// return;
// }
// QString filename = QDir::convertSeparators(dialog.selectedFiles().at(0));
//
// /* Check if the file exists */
// QFile torrcFile(filename);
// if (!QFileInfo(filename).exists()) {
// /* The given file does not exist. Should we create it? */
// int response = VMessageBox::question(this,
// tr("File Not Found"),
// tr("%1 does not exist. Would you like to create it?")
// .arg(filename),
// VMessageBox::Yes, VMessageBox::No);
//
// if (response == VMessageBox::No) {
// /* Don't create it. Just bail. */
// return;
// }
// /* Attempt to create the specified file */
// if (!torrcFile.open(QIODevice::WriteOnly)) {
// VMessageBox::warning(this,
// tr("Failed to Create File"),
// tr("Unable to create %1 [%2]").arg(filename)
// .arg(torrcFile.errorString()),
// VMessageBox::Ok);
// return;
// }
// }
// //ui.lineTorConfig->setText(filename);
//}
void NetworkDialog::updateDisplay()
{
insertConnect() ;
@ -390,7 +345,7 @@ void NetworkDialog::insertConnect()
while (index < connectWidget->topLevelItemCount()) {
std::string gpg_widget_id = (connectWidget->topLevelItem(index))->text(COLUMN_PEERID).toStdString();
RsPeerDetails detail;
if (!rsPeers->getGPGDetails(gpg_widget_id, detail) || (detail.validLvl < GPGME_VALIDITY_MARGINAL && !detail.accept_connection)) {
if (!rsPeers->getGPGDetails(gpg_widget_id, detail) || (detail.validLvl < RS_TRUST_LVL_MARGINAL && !detail.accept_connection)) {
delete (connectWidget->takeTopLevelItem(index));
} else {
index++;
@ -400,7 +355,7 @@ void NetworkDialog::insertConnect()
while (index < ui.unvalidGPGkeyWidget->topLevelItemCount()) {
std::string gpg_widget_id = (ui.unvalidGPGkeyWidget->topLevelItem(index))->text(COLUMN_PEERID).toStdString();
RsPeerDetails detail;
if (!rsPeers->getGPGDetails(gpg_widget_id, detail) || detail.validLvl >= GPGME_VALIDITY_MARGINAL || detail.accept_connection) {
if (!rsPeers->getGPGDetails(gpg_widget_id, detail) || detail.validLvl >= RS_TRUST_LVL_MARGINAL || detail.accept_connection) {
delete (ui.unvalidGPGkeyWidget->takeTopLevelItem(index));
} else {
index++;
@ -461,12 +416,12 @@ void NetworkDialog::insertConnect()
else
switch(detail.trustLvl)
{
case GPGME_VALIDITY_MARGINAL: item->setText(2,tr("Marginally trusted peer")) ; break;
case GPGME_VALIDITY_FULL:
case GPGME_VALIDITY_ULTIMATE: item->setText(2,tr("Fully trusted peer")) ; break ;
case GPGME_VALIDITY_UNKNOWN:
case GPGME_VALIDITY_UNDEFINED:
case GPGME_VALIDITY_NEVER:
case RS_TRUST_LVL_MARGINAL: item->setText(2,tr("Marginally trusted peer")) ; break;
case RS_TRUST_LVL_FULL:
case RS_TRUST_LVL_ULTIMATE: item->setText(2,tr("Fully trusted peer")) ; break ;
case RS_TRUST_LVL_UNKNOWN:
case RS_TRUST_LVL_UNDEFINED:
case RS_TRUST_LVL_NEVER:
default: item->setText(2,tr("Untrusted peer")) ; break ;
}
@ -521,7 +476,7 @@ void NetworkDialog::insertConnect()
item -> setBackground(i,QBrush(backgrndcolor));
/* add to the list */
if (detail.accept_connection || detail.validLvl >= GPGME_VALIDITY_MARGINAL)
if (detail.accept_connection || detail.validLvl >= RS_TRUST_LVL_MARGINAL)
{
/* add gpg item to the list. If item is already in the list, it won't be duplicated thanks to Qt */
connectWidget->addTopLevelItem(item);

View file

@ -23,8 +23,6 @@
#include <retroshare/rspeers.h>
#include <retroshare/rsdisc.h>
#include <gpgme.h>
#include <deque>
#include <set>
#include <iostream>
@ -160,12 +158,12 @@ void NetworkView::updateDisplay()
switch(detail.trustLvl)
{
case GPGME_VALIDITY_MARGINAL: auth = GraphWidget::ELASTIC_NODE_AUTH_MARGINAL ; break;
case GPGME_VALIDITY_FULL:
case GPGME_VALIDITY_ULTIMATE: auth = GraphWidget::ELASTIC_NODE_AUTH_FULL ; break;
case GPGME_VALIDITY_UNKNOWN:
case GPGME_VALIDITY_UNDEFINED:
case GPGME_VALIDITY_NEVER:
case RS_TRUST_LVL_MARGINAL: auth = GraphWidget::ELASTIC_NODE_AUTH_MARGINAL ; break;
case RS_TRUST_LVL_FULL:
case RS_TRUST_LVL_ULTIMATE: auth = GraphWidget::ELASTIC_NODE_AUTH_FULL ; break;
case RS_TRUST_LVL_UNKNOWN:
case RS_TRUST_LVL_UNDEFINED:
case RS_TRUST_LVL_NEVER:
default: auth = GraphWidget::ELASTIC_NODE_AUTH_UNKNOWN ; break ;
}

View file

@ -18,7 +18,6 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
****************************************************************/
#include <gpgme.h>
#include "ConfCertDialog.h"
@ -135,6 +134,17 @@ void ConfCertDialog::load()
return;
}
if(detail.isOnlyGPGdetail && !rsPeers->isKeySupported(mId))
{
ui.make_friend_button->setEnabled(false) ;
ui.make_friend_button->setToolTip(tr("The supplied key algorithm is not supported by RetroShare\n(Only RSA keys are supported at the moment)")) ;
}
else
{
ui.make_friend_button->setEnabled(true) ;
ui.make_friend_button->setToolTip("") ;
}
ui.name->setText(QString::fromUtf8(detail.name.c_str()));
ui.peerid->setText(QString::fromStdString(detail.id));
@ -252,7 +262,7 @@ void ConfCertDialog::load()
}
//web of trust
if (detail.trustLvl == GPGME_VALIDITY_ULTIMATE) {
if (detail.trustLvl == RS_TRUST_LVL_ULTIMATE) {
//trust is ultimate, it means it's one of our own keys
ui.web_of_trust_label->setText(tr("Your trust in this peer is ultimate, it's probably a key you own."));
ui.radioButton_trust_fully->hide();
@ -262,19 +272,19 @@ void ConfCertDialog::load()
ui.radioButton_trust_fully->show();
ui.radioButton_trust_marginnaly->show();
ui.radioButton_trust_never->show();
if (detail.trustLvl == GPGME_VALIDITY_FULL) {
if (detail.trustLvl == RS_TRUST_LVL_FULL) {
ui.web_of_trust_label->setText(tr("Your trust in this peer is full."));
ui.radioButton_trust_fully->setChecked(true);
ui.radioButton_trust_fully->setIcon(QIcon(":/images/security-high-48.png"));
ui.radioButton_trust_marginnaly->setIcon(QIcon(":/images/security-medium-off-48.png"));
ui.radioButton_trust_never->setIcon(QIcon(":/images/security-low-off-48.png"));
} else if (detail.trustLvl == GPGME_VALIDITY_MARGINAL) {
} else if (detail.trustLvl == RS_TRUST_LVL_MARGINAL) {
ui.web_of_trust_label->setText(tr("Your trust in this peer is marginal."));
ui.radioButton_trust_marginnaly->setChecked(true);
ui.radioButton_trust_marginnaly->setIcon(QIcon(":/images/security-medium-48.png"));
ui.radioButton_trust_never->setIcon(QIcon(":/images/security-low-off-48.png"));
ui.radioButton_trust_fully->setIcon(QIcon(":/images/security-high-off-48.png"));
} else if (detail.trustLvl == GPGME_VALIDITY_NEVER) {
} else if (detail.trustLvl == RS_TRUST_LVL_NEVER) {
ui.web_of_trust_label->setText(tr("Your trust in this peer is none."));
ui.radioButton_trust_never->setChecked(true);
ui.radioButton_trust_never->setIcon(QIcon(":/images/security-low-48.png"));
@ -363,13 +373,13 @@ void ConfCertDialog::applyDialog()
}
//check the GPG trustlvl
if (ui.radioButton_trust_fully->isChecked() && detail.trustLvl != GPGME_VALIDITY_FULL) {
if (ui.radioButton_trust_fully->isChecked() && detail.trustLvl != RS_TRUST_LVL_FULL) {
//trust has changed to fully
rsPeers->trustGPGCertificate(detail.id, GPGME_VALIDITY_FULL);
} else if (ui.radioButton_trust_marginnaly->isChecked() && detail.trustLvl != GPGME_VALIDITY_MARGINAL) {
rsPeers->trustGPGCertificate(detail.id, GPGME_VALIDITY_MARGINAL);
} else if (ui.radioButton_trust_never->isChecked() && detail.trustLvl != GPGME_VALIDITY_NEVER) {
rsPeers->trustGPGCertificate(detail.id, GPGME_VALIDITY_NEVER);
rsPeers->trustGPGCertificate(detail.id, RS_TRUST_LVL_FULL);
} else if (ui.radioButton_trust_marginnaly->isChecked() && detail.trustLvl != RS_TRUST_LVL_MARGINAL) {
rsPeers->trustGPGCertificate(detail.id, RS_TRUST_LVL_MARGINAL);
} else if (ui.radioButton_trust_never->isChecked() && detail.trustLvl != RS_TRUST_LVL_NEVER) {
rsPeers->trustGPGCertificate(detail.id, RS_TRUST_LVL_NEVER);
}
if (!detail.isOnlyGPGdetail) {

View file

@ -222,7 +222,7 @@ void ConnectFriendWizard::initializePage(int id)
case RS_TRUST_LVL_MARGINAL:
trustString = tr("Marginal");
break;
case RS_TRUST_LVL_NONE:
case RS_TRUST_LVL_NEVER:
trustString = tr("None");
break;
default:
@ -595,10 +595,6 @@ void ConnectFriendWizard::updatePeersList(int index)
_id_boxes.clear();
#ifdef FRIEND_WIZARD_DEBUG
std::cerr << "FofPage::updatePeersList() updating peers list with index=" << index << std::endl;
#endif
// We have to use this trick because signers are given by their names instead of their ids. That's a cause
// for some confusion when two peers have the same name.
//

View file

@ -79,22 +79,49 @@ int main(int argc, char *argv[])
RsInit::InitRsConfig();
int initResult = RsInit::InitRetroShare(argc, argv);
if(initResult == RS_INIT_NO_KEYRING) // happens when we already have accounts, but no pgp key. This is when switching to the openpgp-sdk version.
{
QApplication dummyApp (argc, argv); // needed for QMessageBox
QMessageBox msgBox;
msgBox.setText(QObject::tr("This version of RetroShare is using OpenPGP-SDK. As a side effect, it's not using the system shared PGP keyring, but has it's own keyring shared by all RetroShare instances. <br><br>You do not appear to have such a keyring, although GPG keys are mentionned by existing RetroShare accounts, probably because you just changed to this new version of the software."));
msgBox.setInformativeText(QObject::tr("Choose between:<br><ul><li><b>Ok</b> to copy the existing keyring from gnupg (safest bet), or </li><li><b>Close without saving</b> to start fresh with an empty keyring (you will be asked to create a new PGP key to work with RetroShare, or import a previously saved pgp keypair). </li><li><b>Cancel</b> to quit and forge a keyring by yourself (needs some PGP skills)</li></ul>"));
msgBox.setStandardButtons(QMessageBox::Ok | QMessageBox::Discard | QMessageBox::Cancel);
msgBox.setDefaultButton(QMessageBox::Ok);
msgBox.setWindowIcon(QIcon(":/images/rstray3.png"));
int ret = msgBox.exec();
if(ret == QMessageBox::Cancel)
return 0 ;
if(ret == QMessageBox::Ok)
{
if(!RsInit::copyGnuPGKeyrings())
return 0 ;
initResult = RsInit::InitRetroShare(argc, argv);
}
else
initResult = RS_INIT_OK ;
}
if (initResult < 0) {
/* Error occured */
QApplication dummyApp (argc, argv); // needed for QMessageBox
QMessageBox mb(QMessageBox::Critical, QObject::tr("RetroShare"), "", QMessageBox::Ok);
mb.setWindowIcon(QIcon(":/images/rstray3.png"));
switch (initResult) {
case RS_INIT_AUTH_FAILED:
std::cerr << "RsInit::InitRetroShare AuthGPG::InitAuth failed" << std::endl;
mb.setText(QObject::tr("Inititialize failed. Wrong or missing installation of gpg."));
break;
default:
/* Unexpected return code */
std::cerr << "RsInit::InitRetroShare unexpected return code " << initResult << std::endl;
mb.setText(QObject::tr("An unexpected error occured. Please report 'RsInit::InitRetroShare unexpected return code %1'.").arg(initResult));
break;
switch (initResult)
{
case RS_INIT_AUTH_FAILED:
std::cerr << "RsInit::InitRetroShare AuthGPG::InitAuth failed" << std::endl;
mb.setText(QObject::tr("Inititialize failed. Wrong or missing installation of gpg."));
break;
default:
/* Unexpected return code */
std::cerr << "RsInit::InitRetroShare unexpected return code " << initResult << std::endl;
mb.setText(QObject::tr("An unexpected error occured. Please report 'RsInit::InitRetroShare unexpected return code %1'.").arg(initResult));
break;
}
mb.exec();
return 1;