Moved loadCertificate from main, StartDialog and GenCertDialog to Rshare.

Switched StartDialog from QMainWindow to QDialog.
Updated english translation file.

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@5752 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
thunder2 2012-11-01 01:07:36 +00:00
parent aadb408533
commit afa3248429
11 changed files with 551 additions and 694 deletions

View File

@ -78,7 +78,7 @@ class RsInit
static bool getPreferedAccountId(std::string &id);
static bool getPGPEngineFileName(std::string &fileName);
static bool getAccountIds(std::list<std::string> &ids);
static bool getAccountDetails(std::string id, std::string &gpgId, std::string &gpgName, std::string &gpgEmail, std::string &sslName);
static bool getAccountDetails(const std::string &id, std::string &gpgId, std::string &gpgName, std::string &gpgEmail, std::string &sslName);
static bool ValidateCertificate(std::string &userName) ;

View File

@ -822,7 +822,7 @@ bool RsInit::getAccountIds(std::list<std::string> &ids)
}
bool RsInit::getAccountDetails(std::string id,
bool RsInit::getAccountDetails(const std::string &id,
std::string &gpgId, std::string &gpgName,
std::string &gpgEmail, std::string &location)
{

View File

@ -22,139 +22,134 @@
#include <rshare.h>
#include <util/rsrandom.h>
#include <retroshare/rsinit.h>
#include <retroshare/rspeers.h>
#include "GenCertDialog.h"
#include <QAbstractEventDispatcher>
#include <QFileDialog>
#include <QMessageBox>
#include <QMovie>
#include <time.h>
#include <iostream>
/* Define the format used for displaying the date and time */
#define DATETIME_FMT "MMM dd hh:mm:ss"
/** Default constructor */
GenCertDialog::GenCertDialog(bool onlyGenerateIdentity, QWidget *parent, Qt::WFlags flags)
: QDialog(parent, flags), mOnlyGenerateIdentity(onlyGenerateIdentity)
: QDialog(parent, flags), mOnlyGenerateIdentity(onlyGenerateIdentity)
{
/* Invoke Qt Designer generated QObject setup routine */
ui.setupUi(this);
/* Invoke Qt Designer generated QObject setup routine */
ui.setupUi(this);
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.selectButton, SIGNAL(clicked()), this, SLOT(selectFriend()));
//connect(ui.friendBox, SIGNAL(stateChanged(int)), this, SLOT(checkChanged(int)));
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()));
//ui.genName->setFocus(Qt::OtherFocusReason);
//ui.genName->setFocus(Qt::OtherFocusReason);
#if QT_VERSION >= 0x040700
ui.email_input->setPlaceholderText(tr("[Optional] Visible to your friends, and friends of friends.")) ;
ui.location_input->setPlaceholderText(tr("[Required] Examples: Home, Laptop,...")) ;
ui.name_input->setPlaceholderText(tr("[Required] Visible to your friends, and friends of friends."));
ui.password_input->setPlaceholderText(tr("[Required] This password protects your PGP key."));
ui.email_input->setPlaceholderText(tr("[Optional] Visible to your friends, and friends of friends.")) ;
ui.location_input->setPlaceholderText(tr("[Required] Examples: Home, Laptop,...")) ;
ui.name_input->setPlaceholderText(tr("[Required] Visible to your friends, and friends of friends."));
ui.password_input->setPlaceholderText(tr("[Required] This password protects your PGP key."));
#endif
/* get all available pgp private certificates....
* mark last one as default.
*/
/* get all available pgp private certificates....
* mark last one as default.
*/
init() ;
init();
}
void GenCertDialog::init()
{
std::cerr << "Finding PGPUsers" << std::endl;
std::cerr << "Finding PGPUsers" << std::endl;
ui.genPGPuser->clear() ;
ui.genPGPuser->clear() ;
std::list<std::string> pgpIds;
std::list<std::string>::iterator it;
bool foundGPGKeys = false;
if (!mOnlyGenerateIdentity) {
if (RsInit::GetPGPLogins(pgpIds)) {
for(it = pgpIds.begin(); it != pgpIds.end(); it++)
{
QVariant userData(QString::fromStdString(*it));
std::string name, email;
RsInit::GetPGPLoginDetails(*it, name, email);
std::cerr << "Adding PGPUser: " << name << " id: " << *it << std::endl;
QString gid = QString::fromStdString(*it).right(8) ;
ui.genPGPuser->addItem(QString::fromUtf8(name.c_str()) + " <" + QString::fromUtf8(email.c_str()) + "> (" + gid + ")", userData);
foundGPGKeys = true;
}
}
}
std::list<std::string> pgpIds;
std::list<std::string>::iterator it;
bool foundGPGKeys = false;
if (!mOnlyGenerateIdentity) {
if (RsInit::GetPGPLogins(pgpIds)) {
for(it = pgpIds.begin(); it != pgpIds.end(); it++)
{
QVariant userData(QString::fromStdString(*it));
std::string name, email;
RsInit::GetPGPLoginDetails(*it, name, email);
std::cerr << "Adding PGPUser: " << name << " id: " << *it << std::endl;
QString gid = QString::fromStdString(*it).right(8) ;
ui.genPGPuser->addItem(QString::fromUtf8(name.c_str()) + " <" + QString::fromUtf8(email.c_str()) + "> (" + gid + ")", userData);
foundGPGKeys = true;
}
}
}
if (foundGPGKeys) {
ui.no_gpg_key_label->hide();
ui.new_gpg_key_checkbox->setChecked(false);
setWindowTitle(tr("Create new Location"));
ui.genButton->setText(tr("Generate new Location"));
ui.headerLabel->setText(tr("Create a new Location"));
genNewGPGKey = false;
} else {
ui.no_gpg_key_label->setVisible(!mOnlyGenerateIdentity);
ui.new_gpg_key_checkbox->setChecked(true);
ui.new_gpg_key_checkbox->setEnabled(false);
setWindowTitle(tr("Create new Identity"));
ui.genButton->setText(tr("Generate new Identity"));
ui.headerLabel->setText(tr("Create a new Identity"));
genNewGPGKey = true;
}
if (foundGPGKeys) {
ui.no_gpg_key_label->hide();
ui.new_gpg_key_checkbox->setChecked(false);
setWindowTitle(tr("Create new Location"));
ui.genButton->setText(tr("Generate new Location"));
ui.headerLabel->setText(tr("Create a new Location"));
genNewGPGKey = false;
} else {
ui.no_gpg_key_label->setVisible(!mOnlyGenerateIdentity);
ui.new_gpg_key_checkbox->setChecked(true);
ui.new_gpg_key_checkbox->setEnabled(false);
setWindowTitle(tr("Create new Identity"));
ui.genButton->setText(tr("Generate new Identity"));
ui.headerLabel->setText(tr("Create a new Identity"));
genNewGPGKey = true;
}
QString text = ui.headerLabel2->text() + "\n";
QString text = ui.headerLabel2->text() + "\n";
if (mOnlyGenerateIdentity) {
ui.new_gpg_key_checkbox->setChecked(true);
ui.new_gpg_key_checkbox->hide();
ui.label->hide();
text += tr("You can create a new identity with this form.");
} else {
text += tr("You can use an existing identity (i.e. a gpg key pair), from the list below, or create a new one with this form.");
}
ui.headerLabel2->setText(text);
if (mOnlyGenerateIdentity) {
ui.new_gpg_key_checkbox->setChecked(true);
ui.new_gpg_key_checkbox->hide();
ui.label->hide();
text += tr("You can create a new identity with this form.");
} else {
text += tr("You can use an existing identity (i.e. a gpg key pair), from the list below, or create a new one with this form.");
}
ui.headerLabel2->setText(text);
newGPGKeyGenUiSetup();
newGPGKeyGenUiSetup();
}
void GenCertDialog::newGPGKeyGenUiSetup() {
if (ui.new_gpg_key_checkbox->isChecked()) {
genNewGPGKey = true;
ui.name_label->show();
ui.name_input->show();
ui.email_label->show();
ui.email_input->show();
ui.password_label->show();
ui.password_input->show();
ui.genPGPuserlabel->hide();
ui.genPGPuser->hide();
ui.importIdentity_PB->hide() ;
ui.exportIdentity_PB->hide();
setWindowTitle(tr("Create new Identity"));
ui.genButton->setText(tr("Generate new Identity"));
ui.headerLabel->setText(tr("Create a new Identity"));
} else {
genNewGPGKey = false;
ui.name_label->hide();
ui.name_input->hide();
ui.email_label->hide();
ui.email_input->hide();
ui.password_label->hide();
ui.password_input->hide();
ui.genPGPuserlabel->show();
ui.genPGPuser->show();
ui.importIdentity_PB->setVisible(!mOnlyGenerateIdentity);
ui.exportIdentity_PB->setVisible(!mOnlyGenerateIdentity);
ui.exportIdentity_PB->setEnabled(ui.genPGPuser->count() != 0);
setWindowTitle(tr("Create new Location"));
ui.genButton->setText(tr("Generate new Location"));
ui.headerLabel->setText(tr("Create a new Location"));
}
if (ui.new_gpg_key_checkbox->isChecked()) {
genNewGPGKey = true;
ui.name_label->show();
ui.name_input->show();
ui.email_label->show();
ui.email_input->show();
ui.password_label->show();
ui.password_input->show();
ui.genPGPuserlabel->hide();
ui.genPGPuser->hide();
ui.importIdentity_PB->hide() ;
ui.exportIdentity_PB->hide();
setWindowTitle(tr("Create new Identity"));
ui.genButton->setText(tr("Generate new Identity"));
ui.headerLabel->setText(tr("Create a new Identity"));
} else {
genNewGPGKey = false;
ui.name_label->hide();
ui.name_input->hide();
ui.email_label->hide();
ui.email_input->hide();
ui.password_label->hide();
ui.password_input->hide();
ui.genPGPuserlabel->show();
ui.genPGPuser->show();
ui.importIdentity_PB->setVisible(!mOnlyGenerateIdentity);
ui.exportIdentity_PB->setVisible(!mOnlyGenerateIdentity);
ui.exportIdentity_PB->setEnabled(ui.genPGPuser->count() != 0);
setWindowTitle(tr("Create new Location"));
ui.genButton->setText(tr("Generate new Location"));
ui.headerLabel->setText(tr("Create a new Location"));
}
}
void GenCertDialog::exportIdentity()
@ -172,6 +167,7 @@ void GenCertDialog::exportIdentity()
else
QMessageBox::information(this,tr("Identity not saved"),tr("Your identity was not saved. An error occurred.")) ;
}
void GenCertDialog::importIdentity()
{
QString fname = QFileDialog::getOpenFileName(this,tr("Export Identity"), "",tr("RetroShare Identity files (*.asc)")) ;
@ -198,102 +194,79 @@ void GenCertDialog::importIdentity()
}
init() ;
// 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. */
std::string genLoc = ui.location_input->text().toUtf8().constData();
std::string PGPId;
std::string genLoc = ui.location_input->text().toUtf8().constData();
std::string PGPId;
if (!genNewGPGKey) {
if (genLoc.length() < 3) {
/* Message Dialog */
QMessageBox::warning(this,
tr("Generate GPG key Failure"),
tr("Location field is required with a minimum of 3 characters"),
QMessageBox::Ok);
return;
}
int pgpidx = ui.genPGPuser->currentIndex();
if (pgpidx < 0)
{
/* Message Dialog */
QMessageBox::warning(this,
"Generate ID Failure",
"Missing PGP Certificate",
QMessageBox::Ok);
return;
}
QVariant data = ui.genPGPuser->itemData(pgpidx);
PGPId = (data.toString()).toStdString();
} else {
if (ui.password_input->text().length() < 3 || ui.name_input->text().length() < 3
|| ui.email_input->text().length() < 3 || ui.location_label->text().length() < 3 ||
genLoc.length() < 3) {
/* Message Dialog */
QMessageBox::warning(this,
tr("Generate GPG key Failure"),
tr("All fields are required with a minimum of 3 characters"),
QMessageBox::Ok);
return;
}
//generate a new gpg key
std::string err_string;
ui.no_gpg_key_label->setText(tr("Generating new GPG key, please be patient: this process needs generating large prime numbers, and can take some minutes on slow computers. \n\nFill in your GPG password when asked, to sign your new key."));
ui.no_gpg_key_label->show();
ui.new_gpg_key_checkbox->hide();
ui.name_label->hide();
ui.name_input->hide();
ui.email_label->hide();
ui.email_input->hide();
ui.password_label->hide();
ui.password_input->hide();
ui.genPGPuserlabel->hide();
ui.genPGPuser->hide();
ui.location_label->hide();
ui.location_input->hide();
ui.genButton->hide();
ui.label_location2->hide();
ui.importIdentity_PB->hide();
// QMessageBox::StandardButton info = QMessageBox::information(this,
// "Generating GPG key",
// "This process can take some time (approximately one minute), please be patient after pressing the OK button",
// QMessageBox::Ok);
//info->
setCursor(Qt::WaitCursor) ;
if (!genNewGPGKey) {
if (genLoc.length() < 3) {
/* Message Dialog */
QMessageBox::warning(this,
tr("Generate GPG key Failure"),
tr("Location field is required with a minimum of 3 characters"),
QMessageBox::Ok);
return;
}
int pgpidx = ui.genPGPuser->currentIndex();
if (pgpidx < 0)
{
/* Message Dialog */
QMessageBox::warning(this,
"Generate ID Failure",
"Missing PGP Certificate",
QMessageBox::Ok);
return;
}
QVariant data = ui.genPGPuser->itemData(pgpidx);
PGPId = (data.toString()).toStdString();
} else {
if (ui.password_input->text().length() < 3 || ui.name_input->text().length() < 3 ||
ui.email_input->text().length() < 3 || genLoc.length() < 3) {
/* Message Dialog */
QMessageBox::warning(this,
tr("Generate GPG key Failure"),
tr("All fields are required with a minimum of 3 characters"),
QMessageBox::Ok);
return;
}
//generate a new gpg key
std::string err_string;
ui.no_gpg_key_label->setText(tr("Generating new GPG key, please be patient: this process needs generating large prime numbers, and can take some minutes on slow computers. \n\nFill in your GPG password when asked, to sign your new key."));
ui.no_gpg_key_label->show();
ui.new_gpg_key_checkbox->hide();
ui.name_label->hide();
ui.name_input->hide();
ui.email_label->hide();
ui.email_input->hide();
ui.password_label->hide();
ui.password_input->hide();
ui.genPGPuserlabel->hide();
ui.genPGPuser->hide();
ui.location_label->hide();
ui.location_input->hide();
ui.genButton->hide();
ui.label_location2->hide();
ui.importIdentity_PB->hide();
QCoreApplication::processEvents();
while(QAbstractEventDispatcher::instance()->processEvents(QEventLoop::AllEvents)) ;
setCursor(Qt::WaitCursor) ;
RsInit::GeneratePGPCertificate(ui.name_input->text().toUtf8().constData(), ui.email_input->text().toUtf8().constData(), ui.password_input->text().toUtf8().constData(), PGPId, err_string);
QCoreApplication::processEvents();
while(QAbstractEventDispatcher::instance()->processEvents(QEventLoop::AllEvents)) ;
setCursor(Qt::ArrowCursor) ;
}
RsInit::GeneratePGPCertificate(ui.name_input->text().toUtf8().constData(), ui.email_input->text().toUtf8().constData(), ui.password_input->text().toUtf8().constData(), PGPId, err_string);
setCursor(Qt::ArrowCursor) ;
}
//generate a random ssl password
std::string sslPasswd = RSRandom::random_alphaNumericString(RsInit::getSslPwdLen()) ;
// std::cerr << "Generated sslPasswd: " << sslPasswd << std::endl;
// const int PWD_LEN = RsInit::getSslPwdLen();
//
// for( int i = 0 ; i < PWD_LEN ; ++i )
// {
// int iNumber;
// iNumber = qrand()%(127-33) + 33;
// sslPasswd += (char)iNumber;
// }
/* Initialise the PGP user first */
RsInit::SelectGPGAccount(PGPId);
//RsInit::LoadGPGPassword(PGPpasswd);
std::string sslId;
std::cerr << "GenCertDialog::genPerson() Generating SSL cert with gpg id : " << PGPId << std::endl;
@ -304,80 +277,16 @@ void GenCertDialog::genPerson()
{
/* complete the process */
RsInit::LoadPassword(sslId, sslPasswd);
loadCertificates();
if (Rshare::loadCertificate(sslId, false, PGPId)) {
accept();
}
}
else
{
/* Message Dialog */
QMessageBox::warning(this,
"Generate ID Failure",
"Failed to Generate your new Certificate, maybe PGP password is wrong !",
tr("Generate ID Failure"),
tr("Failed to Generate your new Certificate, maybe PGP password is wrong!"),
QMessageBox::Ok);
}
}
void GenCertDialog::selectFriend()
{
#if 0
/* still need to find home (first) */
QString fileName = QFileDialog::getOpenFileName(this, tr("Select Trusted Friend"), "",
tr("Certificates (*.pqi *.pem)"));
std::string fname, userName;
fname = fileName.toStdString();
if (RsInit::ValidateTrustedUser(fname, userName))
{
ui.genFriend -> setText(QString::fromStdString(userName));
}
else
{
ui.genFriend -> setText("<Invalid Selected>");
}
#endif
}
void GenCertDialog::checkChanged(int /*i*/)
{
#if 0
if (i)
{
selectFriend();
}
else
{
/* invalidate selection */
std::string fname = "";
std::string userName = "";
RsInit::ValidateTrustedUser(fname, userName);
ui.genFriend -> setText("<None Selected>");
}
#endif
}
void GenCertDialog::loadCertificates()
{
std::string lockFile;
int retVal = RsInit::LockAndLoadCertificates(false, lockFile);
switch(retVal)
{
case 0: close();
break;
case 1: QMessageBox::warning( this,
tr("Multiple instances"),
tr("Another RetroShare using the same profile is "
"already running on your system. Please close "
"that instance first") );
break;
case 2: QMessageBox::warning( this,
tr("Multiple instances"),
tr("An unexpected error occurred when Retroshare "
"tried to acquire the single instance lock") );
break;
case 3: QMessageBox::warning( this,
tr("Generate ID Failure"),
tr("Failed to Load your new Certificate!") );
break;
default: std::cerr << "StartDialog::loadCertificates() unexpected switch value " << retVal << std::endl;
}
}

View File

@ -19,51 +19,33 @@
* Boston, MA 02110-1301, USA.
****************************************************************/
#ifndef _GENCERTDIALOG_H
#define _GENCERTDIALOG_H
#include <retroshare/rstypes.h>
#include "ui_GenCertDialog.h"
class GenCertDialog : public QDialog
{
Q_OBJECT
Q_OBJECT
public:
/** Default constructor */
GenCertDialog(bool onlyGenerateIdentity, QWidget *parent = 0, Qt::WFlags flags = 0);
/** Default destructor */
/** Default constructor */
GenCertDialog(bool onlyGenerateIdentity, QWidget *parent = 0, Qt::WFlags flags = 0);
private slots:
void genPerson();
//void loadPerson();
void selectFriend();
void importIdentity();
void exportIdentity();
void checkChanged(int i);
void newGPGKeyGenUiSetup();
void newGPGKeyGenUiSetup();
private:
void init();
void init() ;
/** Qt Designer generated object */
Ui::GenCertDialog ui;
/** Loads the saved connectidialog settings */
// void loadSettings();
void loadCertificates();
QMovie *movie;
/** Qt Designer generated object */
Ui::GenCertDialog ui;
bool genNewGPGKey;
bool mOnlyGenerateIdentity;
bool genNewGPGKey;
bool mOnlyGenerateIdentity;
};
#endif

View File

@ -29,8 +29,8 @@
#include <iostream>
/** Default constructor */
StartDialog::StartDialog(QWidget *parent, Qt::WFlags flags)
: QMainWindow(parent, flags), reqNewCert(false)
StartDialog::StartDialog(QWidget *parent)
: QDialog(parent, Qt::WindowSystemMenuHint | Qt::WindowTitleHint), reqNewCert(false)
{
/* Invoke Qt Designer generated QObject setup routine */
ui.setupUi(this);
@ -97,43 +97,10 @@ void StartDialog::loadPerson()
QVariant data = ui.loadName->itemData(pgpidx);
accountId = (data.toString()).toStdString();
std::string gpgId, gpgName, gpgEmail, sslName;
if (RsInit::getAccountDetails(accountId, gpgId, gpgName, gpgEmail, sslName))
{
RsInit::SelectGPGAccount(gpgId);
}
RsInit::LoadPassword(accountId, "");
loadCertificates();
}
void StartDialog::loadCertificates()
{
/* Final stage of loading */
std::string lockFile;
int retVal = RsInit::LockAndLoadCertificates(ui.autologin_checkbox->isChecked(), lockFile);
switch(retVal)
{
case 0: close();
break;
case 1: QMessageBox::warning(this,
tr("Multiple instances"),
tr("Another RetroShare using the same profile is "
"already running on your system. Please close "
"that instance first, or choose another profile\n"
"lock file:\n")+ QString::fromStdString(lockFile));
break;
case 2: QMessageBox::warning(this,
tr("Multiple instances"),
tr("An unexpected error occurred when Retroshare "
"tried to acquire the single instance lock\n"
"lock file:\n")+ QString::fromStdString(lockFile));
break;
case 3: QMessageBox::warning(this,
tr("Login Failure"),
tr("Maybe password is wrong") );
break;
default: std::cerr << "StartDialog::loadCertificates() unexpected switch value " << retVal << std::endl;
if (Rshare::loadCertificate(accountId, ui.autologin_checkbox->isChecked())) {
accept();
}
}
@ -142,7 +109,7 @@ void StartDialog::on_labelProfile_linkActivated(QString /*link*/)
// if ((QMessageBox::question(this, tr("Create a New Profile"),tr("This will generate a new Profile\n Are you sure you want to continue?"),QMessageBox::Yes|QMessageBox::No, QMessageBox::Yes))== QMessageBox::Yes)
// {
reqNewCert = true;
close();
accept();
// }
}

View File

@ -24,13 +24,13 @@
#include "ui_StartDialog.h"
class StartDialog : public QMainWindow
class StartDialog : public QDialog
{
Q_OBJECT
public:
/** Default constructor */
StartDialog(QWidget *parent = 0, Qt::WFlags flags = 0);
StartDialog(QWidget *parent = 0);
bool requestedNewCert();
@ -48,9 +48,6 @@ private slots:
void on_labelProfile_linkActivated(QString link);
private:
/** Loads the saved connectidialog settings */
void loadCertificates();
/** Qt Designer generated object */
Ui::StartDialog ui;

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>StartDialog</class>
<widget class="QMainWindow" name="StartDialog">
<widget class="QDialog" name="StartDialog">
<property name="geometry">
<rect>
<x>0</x>
@ -17,293 +17,298 @@
<iconset resource="images.qrc">
<normaloff>:/images/rstray3.png</normaloff>:/images/rstray3.png</iconset>
</property>
<widget class="QWidget" name="centralwidget">
<layout class="QGridLayout" name="gridLayout_4">
<property name="leftMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item row="0" column="0" colspan="4">
<layout class="QGridLayout">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>6</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>6</number>
</property>
<property name="spacing">
<number>6</number>
</property>
<item row="0" column="0">
<spacer>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="1">
<widget class="QToolButton" name="toolButton">
<property name="styleSheet">
<string notr="true">QToolButton {
<layout class="QVBoxLayout" name="verticalLayout_2">
<property name="margin">
<number>0</number>
</property>
<item>
<layout class="QGridLayout" name="gridLayout_4">
<property name="leftMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item row="0" column="0" colspan="4">
<layout class="QGridLayout">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>6</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>6</number>
</property>
<property name="spacing">
<number>6</number>
</property>
<item row="0" column="0">
<spacer>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="1">
<widget class="QToolButton" name="toolButton">
<property name="styleSheet">
<string notr="true">QToolButton {
border-image: url(:/images/avatar_background.png);
}</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="images.qrc">
<normaloff>:/images/user/personal64.png</normaloff>:/images/user/personal64.png</iconset>
</property>
<property name="iconSize">
<size>
<width>96</width>
<height>96</height>
</size>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="2">
<spacer>
<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>
</item>
<item row="1" column="0" colspan="4">
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<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>
<item row="0" column="1">
<widget class="QLabel" name="label">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>32</height>
</size>
</property>
<property name="palette">
<palette>
<active>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>85</red>
<green>170</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
</active>
<inactive>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>85</red>
<green>170</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
</inactive>
<disabled>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>118</red>
<green>116</green>
<blue>108</blue>
</color>
</brush>
</colorrole>
</disabled>
</palette>
</property>
<property name="font">
<font>
<pointsize>18</pointsize>
</font>
</property>
<property name="text">
<string>Login</string>
</property>
</widget>
</item>
<item row="0" column="2">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>48</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="7" column="0" colspan="4">
<widget class="LogoBar" name="callBarFrame">
<property name="minimumSize">
<size>
<width>16</width>
<height>65</height>
</size>
</property>
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
</widget>
</item>
<item row="6" column="1" colspan="2">
<widget class="QLabel" name="labelProfile">
<property name="toolTip">
<string>Opens a dialog for creating a new profile or
adding locations to an existing profile.
The current identities/locations will not be affected.</string>
</property>
<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:'Sans'; font-size:10pt; 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;a href=&quot;Create new Profile...&quot;&gt;&lt;span style=&quot; font-family:'MS Shell Dlg 2'; font-size:8pt; text-decoration: underline; color:#0000ff;&quot;&gt;Manage profiles and locations...&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item row="5" column="0" colspan="4">
<layout class="QGridLayout" name="gridLayout_3">
<property name="topMargin">
<number>9</number>
</property>
<property name="bottomMargin">
<number>9</number>
</property>
<item row="0" column="1">
<widget class="QPushButton" name="loadButton">
<property name="text">
<string>Log In</string>
</property>
<property name="default">
<bool>true</bool>
</property>
<property name="flat">
<bool>false</bool>
</property>
</widget>
</item>
<item row="0" column="0">
<spacer>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>61</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="2">
<spacer>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>71</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="3" column="1" rowspan="2" colspan="2">
<widget class="QGroupBox" name="groupBox">
<property name="enabled">
<bool>true</bool>
</property>
<property name="title">
<string/>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="label_3">
</property>
<property name="text">
<string>Name (GPG Id) - location:</string>
<string/>
</property>
<property name="icon">
<iconset resource="images.qrc">
<normaloff>:/images/user/personal64.png</normaloff>:/images/user/personal64.png</iconset>
</property>
<property name="iconSize">
<size>
<width>96</width>
<height>96</height>
</size>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="loadName"/>
</item>
<item>
<widget class="QCheckBox" name="autologin_checkbox">
<property name="text">
<string>Remember Password</string>
<item row="0" column="2">
<spacer>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="tristate">
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="1" column="0" colspan="4">
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<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>
<item row="0" column="1">
<widget class="QLabel" name="label">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>32</height>
</size>
</property>
<property name="palette">
<palette>
<active>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>85</red>
<green>170</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
</active>
<inactive>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>85</red>
<green>170</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
</inactive>
<disabled>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>118</red>
<green>116</green>
<blue>108</blue>
</color>
</brush>
</colorrole>
</disabled>
</palette>
</property>
<property name="font">
<font>
<pointsize>18</pointsize>
</font>
</property>
<property name="text">
<string>Login</string>
</property>
</widget>
</item>
<item row="0" column="2">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>48</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="3" column="1" rowspan="2" colspan="2">
<widget class="QGroupBox" name="groupBox">
<property name="enabled">
<bool>true</bool>
</property>
<property name="title">
<string/>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="label_3">
<property name="text">
<string>Name (GPG Id) - location:</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="loadName"/>
</item>
<item>
<widget class="QCheckBox" name="autologin_checkbox">
<property name="text">
<string>Remember Password</string>
</property>
<property name="tristate">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="5" column="0" colspan="4">
<layout class="QGridLayout" name="gridLayout_3">
<property name="topMargin">
<number>9</number>
</property>
<property name="bottomMargin">
<number>9</number>
</property>
<item row="0" column="1">
<widget class="QPushButton" name="loadButton">
<property name="text">
<string>Log In</string>
</property>
<property name="default">
<bool>true</bool>
</property>
<property name="flat">
<bool>false</bool>
</property>
</widget>
</item>
<item row="0" column="0">
<spacer>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>61</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="2">
<spacer>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>71</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
<item row="6" column="1" colspan="2">
<widget class="QLabel" name="labelProfile">
<property name="toolTip">
<string>Opens a dialog for creating a new profile or
adding locations to an existing profile.
The current identities/locations will not be affected.</string>
</property>
<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:'Sans'; font-size:10pt; 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;a href=&quot;Create new Profile...&quot;&gt;&lt;span style=&quot; font-family:'MS Shell Dlg 2'; font-size:8pt; text-decoration: underline; color:#0000ff;&quot;&gt;Manage profiles and locations...&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item row="7" column="0" colspan="4">
<widget class="LogoBar" name="callBarFrame">
<property name="minimumSize">
<size>
<width>16</width>
<height>65</height>
</size>
</property>
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>

View File

@ -5025,30 +5025,10 @@ anonymous, you can use a fake email.</source>
Fill in your GPG password when asked, to sign your new key.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Select Trusted Friend</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Certificates (*.pqi *.pem)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Multiple instances</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Another RetroShare using the same profile is already running on your system. Please close that instance first</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Generate ID Failure</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Failed to Load your new Certificate!</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>[Optional] Visible to your friends, and friends of friends.</source>
<translation type="unfinished"></translation>
@ -5161,10 +5141,6 @@ and use the import button to load it</source>
<source>Your identity was imported successfully:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>An unexpected error occurred when Retroshare tried to acquire the single instance lock</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>RetroShare uses gpg keys for identity management.</source>
<translation type="unfinished"></translation>
@ -5177,6 +5153,10 @@ and use the import button to load it</source>
<source>You can use an existing identity (i.e. a gpg key pair), from the list below, or create a new one with this form.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Failed to Generate your new Certificate, maybe PGP password is wrong!</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>GeneralPage</name>
@ -5530,6 +5510,14 @@ p, li { white-space: pre-wrap; }
<source>Private Key Available</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Search Title</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Search Description</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>GuiExprElement</name>
@ -7222,6 +7210,34 @@ Do you want to save message ?</source>
<source>No starred messages available. Stars let you give messages a special status to make them easier to find. To star a message, click on the light gray star beside any message.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Search Subject</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Search From</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Search Date</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Search Content</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Search Tags</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Search Attachments</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Search...</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>MessengerWindow</name>
@ -10504,34 +10520,10 @@ p, li { white-space: pre-wrap; }
<source>Remember Password</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Multiple instances</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Login Failure</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Maybe password is wrong</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Warning</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Another RetroShare using the same profile is already running on your system. Please close that instance first, or choose another profile
lock file:
</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>An unexpected error occurred when Retroshare tried to acquire the single instance lock
lock file:
</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Login</source>
<translation type="unfinished"></translation>

View File

@ -201,27 +201,17 @@ int main(int argc, char *argv[])
{
/* Login Dialog */
/* check for existing Certificate */
StartDialog *sd = NULL;
bool genCert = false;
std::list<std::string> accountIds;
if (RsInit::getAccountIds(accountIds) && (accountIds.size() > 0))
{
sd = new StartDialog();
sd->show();
while(sd -> isVisible())
{
rshare.processEvents();
#ifdef WIN32
Sleep(10);
#else // __LINUX__
usleep(10000);
#endif
StartDialog sd;
if (sd.exec() == QDialog::Rejected) {
return 1;
}
/* if we're logged in */
genCert = sd->requestedNewCert();
delete (sd);
genCert = sd.requestedNewCert();
}
else
{
@ -231,7 +221,9 @@ int main(int argc, char *argv[])
if (genCert)
{
GenCertDialog gd(false);
gd.exec ();
if (gd.exec () == QDialog::Rejected) {
return 1;
}
}
splashScreen.show();
@ -242,39 +234,11 @@ int main(int argc, char *argv[])
splashScreen.show();
splashScreen.showMessage(rshare.translate("SplashScreen", "Load profile"), Qt::AlignHCenter | Qt::AlignBottom);
std::string preferredId, gpgId, gpgName, gpgEmail, sslName;
std::string preferredId;
RsInit::getPreferedAccountId(preferredId);
if (RsInit::getAccountDetails(preferredId, gpgId, gpgName, gpgEmail, sslName))
{
RsInit::SelectGPGAccount(gpgId);
}
// true: note auto-login is active
std::string lockFile;
int retVal = RsInit::LockAndLoadCertificates(true, lockFile);
switch(retVal)
{
case 0: break;
case 1: QMessageBox::warning( 0,
QObject::tr("Multiple instances"),
QObject::tr("Another RetroShare using the same profile is "
"already running on your system. Please close "
"that instance first\n Lock file:\n") +
QString::fromStdString(lockFile));
return 1;
case 2: QMessageBox::critical( 0,
QObject::tr("Multiple instances"),
QObject::tr("An unexpected error occurred when Retroshare "
"tried to acquire the single instance lock\n Lock file:\n") +
QString::fromStdString(lockFile));
return 1;
case 3: QMessageBox::critical( 0,
QObject::tr("Login Failure"),
QObject::tr("Maybe password is wrong") );
return 1;
default: std::cerr << "StartDialog::loadCertificates() unexpected switch value " << retVal << std::endl;
}
Rshare::loadCertificate(preferredId, true);
}
break;
default:

View File

@ -20,8 +20,6 @@
* Boston, MA 02110-1301, USA.
****************************************************************/
#include <QDir>
#include <QTimer>
#include <QTextStream>
@ -32,6 +30,7 @@
#include <gui/common/html.h>
#include <util/stringutil.h>
#include <stdlib.h>
#include <iostream>
#include <retroshare/rsinit.h>
#include <lang/languagesupport.h>
@ -538,3 +537,43 @@ void Rshare::blinkTimer()
mBlink = !mBlink;
emit blink(mBlink);
}
bool Rshare::loadCertificate(const std::string &accountId, bool autoLogin, std::string gpgId)
{
if (gpgId.empty()) {
std::string gpgName, gpgEmail, sslName;
if (!RsInit::getAccountDetails(accountId, gpgId, gpgName, gpgEmail, sslName)) {
return false;
}
}
if (!RsInit::SelectGPGAccount(gpgId)) {
return false;
}
std::string lockFile;
int retVal = RsInit::LockAndLoadCertificates(autoLogin, lockFile);
switch (retVal) {
case 0: break;
case 1: QMessageBox::warning( 0,
QObject::tr("Multiple instances"),
QObject::tr("Another RetroShare using the same profile is "
"already running on your system. Please close "
"that instance first\n Lock file:\n") +
QString::fromUtf8(lockFile.c_str()));
return false;
case 2: QMessageBox::critical( 0,
QObject::tr("Multiple instances"),
QObject::tr("An unexpected error occurred when Retroshare "
"tried to acquire the single instance lock\n Lock file:\n") +
QString::fromUtf8(lockFile.c_str()));
return false;
case 3: QMessageBox::critical( 0,
QObject::tr("Login Failure"),
QObject::tr("Maybe password is wrong") );
return false;
default: std::cerr << "Rshare::loadCertificate() unexpected switch value " << retVal << std::endl;
return false;
}
return true;
}

View File

@ -84,6 +84,8 @@ public:
/** Recalculates matching stylesheet for widget **/
static void refreshStyleSheet(QWidget *widget, bool processChildren);
static bool loadCertificate(const std::string &accountId, bool autoLogin, std::string gpgId = "");
/**
* Update Language, Style and StyleSheet.
* First args are cheked for a style then the settings.