Added a Security Page for Options to View, Copy and Export own Public Key.

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@1380 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
defnax 2009-07-14 23:11:37 +00:00
parent 1c729b93fc
commit 9c65c694c5
5 changed files with 422 additions and 678 deletions

View File

@ -1,7 +1,7 @@
/**************************************************************** /****************************************************************
* RShare is distributed under the following license: * RetroShare is distributed under the following license:
* *
* Copyright (C) 2006, crypton * Copyright (C) 2006 - 2009 RetroShare Team
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -17,40 +17,120 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, * Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA. * Boston, MA 02110-1301, USA.
****************************************************************/ ****************************************************************/
#include "rsiface/rspeers.h" //for rsPeers variable
#include <rshare.h> #include "rsiface/rsiface.h"
#include "CryptographyDialog.h"
#include <QtGui>
#include <QClipboard>
/** Constructor */
CryptographyDialog::CryptographyDialog(QWidget *parent) #include <rshare.h>
: ConfigPage(parent) #include "CryptographyDialog.h"
{
/* Invoke the Qt Designer generated object setup routine */ #include <sstream>
ui.setupUi(this); #include <iostream>
#include <set>
/* Create RshareSettings object */
_settings = new RshareSettings(); /** Constructor */
CryptographyDialog::CryptographyDialog(QWidget *parent)
/* Hide platform specific features */ : ConfigPage(parent)
#ifdef Q_WS_WIN {
/* Invoke the Qt Designer generated object setup routine */
#endif ui.setupUi(this);
}
/* Create RshareSettings object */
/** Saves the changes on this page */ _settings = new RshareSettings();
bool
CryptographyDialog::save(QString &errmsg) connect(ui.copykeyButton, SIGNAL(clicked()), this, SLOT(copyPublicKey()));
{ connect(ui.exportkeyButton, SIGNAL(clicked()), this, SLOT(exportPublicKey()));
}
loadPublicKey();
/** Loads the settings for this page */
void
CryptographyDialog::load() /* Hide platform specific features */
{ #ifdef Q_WS_WIN
} #endif
}
/** Saves the changes on this page */
bool
CryptographyDialog::save(QString &errmsg)
{
return true;
}
/** Loads the settings for this page */
void
CryptographyDialog::load()
{
}
/** Loads ouer default Puplickey */
void
CryptographyDialog::loadPublicKey()
{
//std::cerr << "CryptoPage() getting Invite" << std::endl;
std::string invite = rsPeers->GetRetroshareInvite();
RsPeerDetails ownDetail;
rsPeers->getPeerDetails(rsPeers->getOwnId(), ownDetail);
invite += LOCAL_IP;
invite += ownDetail.localAddr + ":";
std::ostringstream out;
out << ownDetail.localPort;
invite += out.str() + ";";
invite += "\n";
invite += EXT_IP;
invite += ownDetail.extAddr + ":";
std::ostringstream out2;
out2 << ownDetail.extPort;
invite += out2.str() + ";";
ui.certtextEdit->setText(QString::fromStdString(invite));
ui.certtextEdit->setReadOnly(true);
ui.certtextEdit->setMinimumHeight(200);
//std::cerr << "CryptoPage() getting Invite: " << invite << std::endl;
}
void
CryptographyDialog::copyPublicKey()
{
QMessageBox::information(this,
tr("RetroShare"),
tr("Your Public Key is copied to Clipbard, paste and send it to your"
"friend via email or some other way"));
QClipboard *clipboard = QApplication::clipboard();
clipboard->setText(ui.certtextEdit->toPlainText());
}
void
CryptographyDialog::exportPublicKey()
{
qDebug() << " exportPulicKey";
QString qdir = QFileDialog::getSaveFileName(this,
"Please choose a filename",
QDir::homePath(),
"RetroShare Certificate (*.pqi)");
if ( rsPeers->SaveCertificateToFile(rsPeers->getOwnId(), qdir.toStdString()) )
{
QMessageBox::information(this, tr("RetroShare"),
tr("Certificate file successfully created"),
QMessageBox::Ok, QMessageBox::Ok);
}
else
{
QMessageBox::information(this, tr("RetroShare"),
tr("Sorry, certificate file creation failed"),
QMessageBox::Ok, QMessageBox::Ok);
}
}

View File

@ -1,7 +1,7 @@
/**************************************************************** /****************************************************************
* RShare is distributed under the following license: * RetroShare is distributed under the following license:
* *
* Copyright (C) 2006, crypton * Copyright (C) 2006 - 2009 RetroShare Team
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -17,42 +17,50 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, * Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA. * Boston, MA 02110-1301, USA.
****************************************************************/ ****************************************************************/
#ifndef _CRYPTOGRAPHYDIALOG_H #ifndef _CRYPTOGRAPHYDIALOG_H
#define _CRYPTOGRAPHYDIALOG_H #define _CRYPTOGRAPHYDIALOG_H
#include <QFileDialog> #include <QFileDialog>
#include <gui/Preferences/rsharesettings.h> #include <gui/Preferences/rsharesettings.h>
#include "gui/connect/ConnectFriendWizard.h"
#include "configpage.h"
#include "ui_CryptographyDialog.h" #include "configpage.h"
#include "ui_CryptographyDialog.h"
class CryptographyDialog : public ConfigPage
{
Q_OBJECT class CryptographyDialog : public ConfigPage
{
public: Q_OBJECT
/** Default Constructor */
CryptographyDialog(QWidget *parent = 0); public:
/** Default Destructor */ /** Default Constructor */
CryptographyDialog(QWidget *parent = 0);
/** Saves the changes on this page */ /** Default Destructor */
bool save(QString &errmsg);
/** Loads the settings for this page */ /** Saves the changes on this page */
void load(); bool save(QString &errmsg);
/** Loads the settings for this page */
private slots: void load();
private slots:
private:
/** A RshareSettings object used for saving/loading settings */ void loadPublicKey();
void copyPublicKey();
void exportPublicKey();
private:
/** A RshareSettings object used for saving/loading settings */
RshareSettings* _settings; RshareSettings* _settings;
/** Qt Designer generated object */ /** Qt Designer generated object */
Ui::CryptographyDialog ui; Ui::CryptographyDialog ui;
}; };
#endif #endif

File diff suppressed because it is too large Load Diff

View File

@ -32,12 +32,12 @@
/* Images for toolbar icons */ /* Images for toolbar icons */
#define IMAGE_PREFERENCES ":/images/kcmsystem24.png" #define IMAGE_PREFERENCES ":/images/kcmsystem24.png"
#define IMAGE_SERVER ":/images/server_24x24.png" #define IMAGE_SERVER ":/images/server_24x24.png"
#define IMAGE_DIRECTORIES ":/images/folder_doments.png" #define IMAGE_DIRECTORIES ":/images/folder_doments.png"
#define IMAGE_CRYPTOGRAPHY ":/images/cryptography_24x24.png" #define IMAGE_CRYPTOGRAPHY ":/images/encrypted32.png"
#define IMAGE_LOG ":/images/log_24x24.png" #define IMAGE_LOG ":/images/log_24x24.png"
#define IMAGE_ABOUT ":/images/informations_24x24.png" #define IMAGE_ABOUT ":/images/informations_24x24.png"
#define IMAGE_SAVE ":/images/media-floppy.png" #define IMAGE_SAVE ":/images/media-floppy.png"
#define IMAGE_HELP ":/images/help24.png" #define IMAGE_HELP ":/images/help24.png"
#define IMAGE_APPEARRANCE ":/images/looknfeel.png" #define IMAGE_APPEARRANCE ":/images/looknfeel.png"
#define IMAGE_FILE_ASSOTIATIONS ":/images/folder-draft24.png" #define IMAGE_FILE_ASSOTIATIONS ":/images/folder-draft24.png"
@ -69,6 +69,9 @@ PreferencesWindow::PreferencesWindow(QWidget *parent, Qt::WFlags flags)
ui.stackPages->add(new NotifyDialog(ui.stackPages), ui.stackPages->add(new NotifyDialog(ui.stackPages),
createPageAction(QIcon(IMAGE_NOTIFY), tr("Notify"), grp)); createPageAction(QIcon(IMAGE_NOTIFY), tr("Notify"), grp));
ui.stackPages->add(new CryptographyDialog(ui.stackPages),
createPageAction(QIcon(IMAGE_CRYPTOGRAPHY), tr("Security"), grp));
ui.stackPages->add(new FileAssotiationsDialog(ui.stackPages), ui.stackPages->add(new FileAssotiationsDialog(ui.stackPages),
createPageAction(QIcon(IMAGE_FILE_ASSOTIATIONS), createPageAction(QIcon(IMAGE_FILE_ASSOTIATIONS),
tr("File assotiations"), grp)); tr("File assotiations"), grp));

View File

@ -50,6 +50,7 @@ public:
Directories, /** Directories page. */ Directories, /** Directories page. */
Appearance, /** Appearance page. */ Appearance, /** Appearance page. */
Notify, /** Notify page. */ Notify, /** Notify page. */
Security, /** Security page. */
FileAssotiations /** File assotiations page. */ FileAssotiations /** File assotiations page. */
}; };