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 getPreferedAccountId(std::string &id);
static bool getPGPEngineFileName(std::string &fileName); static bool getPGPEngineFileName(std::string &fileName);
static bool getAccountIds(std::list<std::string> &ids); 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) ; 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 &gpgId, std::string &gpgName,
std::string &gpgEmail, std::string &location) std::string &gpgEmail, std::string &location)
{ {

View file

@ -22,19 +22,16 @@
#include <rshare.h> #include <rshare.h>
#include <util/rsrandom.h> #include <util/rsrandom.h>
#include <retroshare/rsinit.h> #include <retroshare/rsinit.h>
#include <retroshare/rspeers.h>
#include "GenCertDialog.h" #include "GenCertDialog.h"
#include <QAbstractEventDispatcher> #include <QAbstractEventDispatcher>
#include <QFileDialog> #include <QFileDialog>
#include <QMessageBox> #include <QMessageBox>
#include <QMovie>
#include <time.h> #include <time.h>
#include <iostream>
/* Define the format used for displaying the date and time */ /* Define the format used for displaying the date and time */
#define DATETIME_FMT "MMM dd hh:mm:ss" #define DATETIME_FMT "MMM dd hh:mm:ss"
/** Default constructor */ /** Default constructor */
GenCertDialog::GenCertDialog(bool onlyGenerateIdentity, QWidget *parent, Qt::WFlags flags) GenCertDialog::GenCertDialog(bool onlyGenerateIdentity, QWidget *parent, Qt::WFlags flags)
: QDialog(parent, flags), mOnlyGenerateIdentity(onlyGenerateIdentity) : QDialog(parent, flags), mOnlyGenerateIdentity(onlyGenerateIdentity)
@ -47,8 +44,6 @@ GenCertDialog::GenCertDialog(bool onlyGenerateIdentity, QWidget *parent, Qt::WFl
connect(ui.genButton, SIGNAL(clicked()), this, SLOT(genPerson())); connect(ui.genButton, SIGNAL(clicked()), this, SLOT(genPerson()));
connect(ui.importIdentity_PB, SIGNAL(clicked()), this, SLOT(importIdentity())); connect(ui.importIdentity_PB, SIGNAL(clicked()), this, SLOT(importIdentity()));
connect(ui.exportIdentity_PB, SIGNAL(clicked()), this, SLOT(exportIdentity())); 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)));
//ui.genName->setFocus(Qt::OtherFocusReason); //ui.genName->setFocus(Qt::OtherFocusReason);
@ -62,7 +57,7 @@ GenCertDialog::GenCertDialog(bool onlyGenerateIdentity, QWidget *parent, Qt::WFl
* mark last one as default. * mark last one as default.
*/ */
init() ; init();
} }
void GenCertDialog::init() void GenCertDialog::init()
@ -172,6 +167,7 @@ void GenCertDialog::exportIdentity()
else else
QMessageBox::information(this,tr("Identity not saved"),tr("Your identity was not saved. An error occurred.")) ; QMessageBox::information(this,tr("Identity not saved"),tr("Your identity was not saved. An error occurred.")) ;
} }
void GenCertDialog::importIdentity() void GenCertDialog::importIdentity()
{ {
QString fname = QFileDialog::getOpenFileName(this,tr("Export Identity"), "",tr("RetroShare Identity files (*.asc)")) ; QString fname = QFileDialog::getOpenFileName(this,tr("Export Identity"), "",tr("RetroShare Identity files (*.asc)")) ;
@ -198,10 +194,6 @@ void GenCertDialog::importIdentity()
} }
init() ; 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() void GenCertDialog::genPerson()
@ -232,9 +224,8 @@ void GenCertDialog::genPerson()
QVariant data = ui.genPGPuser->itemData(pgpidx); QVariant data = ui.genPGPuser->itemData(pgpidx);
PGPId = (data.toString()).toStdString(); PGPId = (data.toString()).toStdString();
} else { } else {
if (ui.password_input->text().length() < 3 || ui.name_input->text().length() < 3 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 || ui.email_input->text().length() < 3 || genLoc.length() < 3) {
genLoc.length() < 3) {
/* Message Dialog */ /* Message Dialog */
QMessageBox::warning(this, QMessageBox::warning(this,
tr("Generate GPG key Failure"), tr("Generate GPG key Failure"),
@ -261,11 +252,6 @@ void GenCertDialog::genPerson()
ui.label_location2->hide(); ui.label_location2->hide();
ui.importIdentity_PB->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) ; setCursor(Qt::WaitCursor) ;
QCoreApplication::processEvents(); QCoreApplication::processEvents();
@ -276,24 +262,11 @@ void GenCertDialog::genPerson()
setCursor(Qt::ArrowCursor) ; setCursor(Qt::ArrowCursor) ;
} }
//generate a random ssl password //generate a random ssl password
std::string sslPasswd = RSRandom::random_alphaNumericString(RsInit::getSslPwdLen()) ; 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 */ /* Initialise the PGP user first */
RsInit::SelectGPGAccount(PGPId); RsInit::SelectGPGAccount(PGPId);
//RsInit::LoadGPGPassword(PGPpasswd);
std::string sslId; std::string sslId;
std::cerr << "GenCertDialog::genPerson() Generating SSL cert with gpg id : " << PGPId << std::endl; std::cerr << "GenCertDialog::genPerson() Generating SSL cert with gpg id : " << PGPId << std::endl;
@ -304,80 +277,16 @@ void GenCertDialog::genPerson()
{ {
/* complete the process */ /* complete the process */
RsInit::LoadPassword(sslId, sslPasswd); RsInit::LoadPassword(sslId, sslPasswd);
loadCertificates(); if (Rshare::loadCertificate(sslId, false, PGPId)) {
accept();
}
} }
else else
{ {
/* Message Dialog */ /* Message Dialog */
QMessageBox::warning(this, QMessageBox::warning(this,
"Generate ID Failure", tr("Generate ID Failure"),
"Failed to Generate your new Certificate, maybe PGP password is wrong !", tr("Failed to Generate your new Certificate, maybe PGP password is wrong!"),
QMessageBox::Ok); 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,16 +19,11 @@
* Boston, MA 02110-1301, USA. * Boston, MA 02110-1301, USA.
****************************************************************/ ****************************************************************/
#ifndef _GENCERTDIALOG_H #ifndef _GENCERTDIALOG_H
#define _GENCERTDIALOG_H #define _GENCERTDIALOG_H
#include <retroshare/rstypes.h>
#include "ui_GenCertDialog.h" #include "ui_GenCertDialog.h"
class GenCertDialog : public QDialog class GenCertDialog : public QDialog
{ {
Q_OBJECT Q_OBJECT
@ -36,27 +31,15 @@ class GenCertDialog : public QDialog
public: public:
/** Default constructor */ /** Default constructor */
GenCertDialog(bool onlyGenerateIdentity, QWidget *parent = 0, Qt::WFlags flags = 0); GenCertDialog(bool onlyGenerateIdentity, QWidget *parent = 0, Qt::WFlags flags = 0);
/** Default destructor */
private slots: private slots:
void genPerson(); void genPerson();
//void loadPerson();
void selectFriend();
void importIdentity(); void importIdentity();
void exportIdentity(); void exportIdentity();
void checkChanged(int i);
void newGPGKeyGenUiSetup(); void newGPGKeyGenUiSetup();
private: private:
void init();
void init() ;
/** Loads the saved connectidialog settings */
// void loadSettings();
void loadCertificates();
QMovie *movie;
/** Qt Designer generated object */ /** Qt Designer generated object */
Ui::GenCertDialog ui; Ui::GenCertDialog ui;
@ -66,4 +49,3 @@ private:
}; };
#endif #endif

View file

@ -29,8 +29,8 @@
#include <iostream> #include <iostream>
/** Default constructor */ /** Default constructor */
StartDialog::StartDialog(QWidget *parent, Qt::WFlags flags) StartDialog::StartDialog(QWidget *parent)
: QMainWindow(parent, flags), reqNewCert(false) : QDialog(parent, Qt::WindowSystemMenuHint | Qt::WindowTitleHint), reqNewCert(false)
{ {
/* Invoke Qt Designer generated QObject setup routine */ /* Invoke Qt Designer generated QObject setup routine */
ui.setupUi(this); ui.setupUi(this);
@ -97,43 +97,10 @@ void StartDialog::loadPerson()
QVariant data = ui.loadName->itemData(pgpidx); QVariant data = ui.loadName->itemData(pgpidx);
accountId = (data.toString()).toStdString(); accountId = (data.toString()).toStdString();
std::string gpgId, gpgName, gpgEmail, sslName;
if (RsInit::getAccountDetails(accountId, gpgId, gpgName, gpgEmail, sslName))
{
RsInit::SelectGPGAccount(gpgId);
}
RsInit::LoadPassword(accountId, ""); RsInit::LoadPassword(accountId, "");
loadCertificates();
}
void StartDialog::loadCertificates() if (Rshare::loadCertificate(accountId, ui.autologin_checkbox->isChecked())) {
{ accept();
/* 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;
} }
} }
@ -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) // 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; reqNewCert = true;
close(); accept();
// } // }
} }

View file

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

View file

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0"> <ui version="4.0">
<class>StartDialog</class> <class>StartDialog</class>
<widget class="QMainWindow" name="StartDialog"> <widget class="QDialog" name="StartDialog">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>0</x> <x>0</x>
@ -17,7 +17,11 @@
<iconset resource="images.qrc"> <iconset resource="images.qrc">
<normaloff>:/images/rstray3.png</normaloff>:/images/rstray3.png</iconset> <normaloff>:/images/rstray3.png</normaloff>:/images/rstray3.png</iconset>
</property> </property>
<widget class="QWidget" name="centralwidget"> <layout class="QVBoxLayout" name="verticalLayout_2">
<property name="margin">
<number>0</number>
</property>
<item>
<layout class="QGridLayout" name="gridLayout_4"> <layout class="QGridLayout" name="gridLayout_4">
<property name="leftMargin"> <property name="leftMargin">
<number>0</number> <number>0</number>
@ -189,36 +193,36 @@
</item> </item>
</layout> </layout>
</item> </item>
<item row="7" column="0" colspan="4"> <item row="3" column="1" rowspan="2" colspan="2">
<widget class="LogoBar" name="callBarFrame"> <widget class="QGroupBox" name="groupBox">
<property name="minimumSize"> <property name="enabled">
<size> <bool>true</bool>
<width>16</width>
<height>65</height>
</size>
</property> </property>
<property name="frameShape"> <property name="title">
<enum>QFrame::NoFrame</enum> <string/>
</property> </property>
<property name="frameShadow"> <layout class="QVBoxLayout" name="verticalLayout">
<enum>QFrame::Raised</enum> <item>
<widget class="QLabel" name="label_3">
<property name="text">
<string>Name (GPG Id) - location:</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="6" column="1" colspan="2"> <item>
<widget class="QLabel" name="labelProfile"> <widget class="QComboBox" name="loadName"/>
<property name="toolTip"> </item>
<string>Opens a dialog for creating a new profile or <item>
adding locations to an existing profile. <widget class="QCheckBox" name="autologin_checkbox">
The current identities/locations will not be affected.</string>
</property>
<property name="text"> <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; <string>Remember Password</string>
&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> </property>
<property name="tristate">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</widget> </widget>
</item> </item>
<item row="5" column="0" colspan="4"> <item row="5" column="0" colspan="4">
@ -270,41 +274,42 @@ p, li { white-space: pre-wrap; }
</item> </item>
</layout> </layout>
</item> </item>
<item row="3" column="1" rowspan="2" colspan="2"> <item row="6" column="1" colspan="2">
<widget class="QGroupBox" name="groupBox"> <widget class="QLabel" name="labelProfile">
<property name="enabled"> <property name="toolTip">
<bool>true</bool> <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>
<property name="title">
<string/>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="label_3">
<property name="text"> <property name="text">
<string>Name (GPG Id) - location:</string> <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> </property>
</widget> </widget>
</item> </item>
<item> <item row="7" column="0" colspan="4">
<widget class="QComboBox" name="loadName"/> <widget class="LogoBar" name="callBarFrame">
</item> <property name="minimumSize">
<item> <size>
<widget class="QCheckBox" name="autologin_checkbox"> <width>16</width>
<property name="text"> <height>65</height>
<string>Remember Password</string> </size>
</property> </property>
<property name="tristate"> <property name="frameShape">
<bool>false</bool> <enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property> </property>
</widget> </widget>
</item> </item>
</layout> </layout>
</widget>
</item> </item>
</layout> </layout>
</widget> </widget>
</widget>
<customwidgets> <customwidgets>
<customwidget> <customwidget>
<class>LogoBar</class> <class>LogoBar</class>

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> Fill in your GPG password when asked, to sign your new key.</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </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> <message>
<source>Generate ID Failure</source> <source>Generate ID Failure</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<source>Failed to Load your new Certificate!</source>
<translation type="unfinished"></translation>
</message>
<message> <message>
<source>[Optional] Visible to your friends, and friends of friends.</source> <source>[Optional] Visible to your friends, and friends of friends.</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
@ -5161,10 +5141,6 @@ and use the import button to load it</source>
<source>Your identity was imported successfully:</source> <source>Your identity was imported successfully:</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<source>An unexpected error occurred when Retroshare tried to acquire the single instance lock</source>
<translation type="unfinished"></translation>
</message>
<message> <message>
<source>RetroShare uses gpg keys for identity management.</source> <source>RetroShare uses gpg keys for identity management.</source>
<translation type="unfinished"></translation> <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> <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> <translation type="unfinished"></translation>
</message> </message>
<message>
<source>Failed to Generate your new Certificate, maybe PGP password is wrong!</source>
<translation type="unfinished"></translation>
</message>
</context> </context>
<context> <context>
<name>GeneralPage</name> <name>GeneralPage</name>
@ -5530,6 +5510,14 @@ p, li { white-space: pre-wrap; }
<source>Private Key Available</source> <source>Private Key Available</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<source>Search Title</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Search Description</source>
<translation type="unfinished"></translation>
</message>
</context> </context>
<context> <context>
<name>GuiExprElement</name> <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> <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> <translation type="unfinished"></translation>
</message> </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>
<context> <context>
<name>MessengerWindow</name> <name>MessengerWindow</name>
@ -10504,34 +10520,10 @@ p, li { white-space: pre-wrap; }
<source>Remember Password</source> <source>Remember Password</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </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> <message>
<source>Warning</source> <source>Warning</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </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> <message>
<source>Login</source> <source>Login</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>

View file

@ -201,27 +201,17 @@ int main(int argc, char *argv[])
{ {
/* Login Dialog */ /* Login Dialog */
/* check for existing Certificate */ /* check for existing Certificate */
StartDialog *sd = NULL;
bool genCert = false; bool genCert = false;
std::list<std::string> accountIds; std::list<std::string> accountIds;
if (RsInit::getAccountIds(accountIds) && (accountIds.size() > 0)) if (RsInit::getAccountIds(accountIds) && (accountIds.size() > 0))
{ {
sd = new StartDialog(); StartDialog sd;
sd->show(); if (sd.exec() == QDialog::Rejected) {
return 1;
while(sd -> isVisible())
{
rshare.processEvents();
#ifdef WIN32
Sleep(10);
#else // __LINUX__
usleep(10000);
#endif
} }
/* if we're logged in */ /* if we're logged in */
genCert = sd->requestedNewCert(); genCert = sd.requestedNewCert();
delete (sd);
} }
else else
{ {
@ -231,7 +221,9 @@ int main(int argc, char *argv[])
if (genCert) if (genCert)
{ {
GenCertDialog gd(false); GenCertDialog gd(false);
gd.exec (); if (gd.exec () == QDialog::Rejected) {
return 1;
}
} }
splashScreen.show(); splashScreen.show();
@ -242,39 +234,11 @@ int main(int argc, char *argv[])
splashScreen.show(); splashScreen.show();
splashScreen.showMessage(rshare.translate("SplashScreen", "Load profile"), Qt::AlignHCenter | Qt::AlignBottom); splashScreen.showMessage(rshare.translate("SplashScreen", "Load profile"), Qt::AlignHCenter | Qt::AlignBottom);
std::string preferredId, gpgId, gpgName, gpgEmail, sslName; std::string preferredId;
RsInit::getPreferedAccountId(preferredId); RsInit::getPreferedAccountId(preferredId);
if (RsInit::getAccountDetails(preferredId, gpgId, gpgName, gpgEmail, sslName))
{
RsInit::SelectGPGAccount(gpgId);
}
// true: note auto-login is active // true: note auto-login is active
std::string lockFile; Rshare::loadCertificate(preferredId, true);
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;
}
} }
break; break;
default: default:

View file

@ -20,8 +20,6 @@
* Boston, MA 02110-1301, USA. * Boston, MA 02110-1301, USA.
****************************************************************/ ****************************************************************/
#include <QDir> #include <QDir>
#include <QTimer> #include <QTimer>
#include <QTextStream> #include <QTextStream>
@ -32,6 +30,7 @@
#include <gui/common/html.h> #include <gui/common/html.h>
#include <util/stringutil.h> #include <util/stringutil.h>
#include <stdlib.h> #include <stdlib.h>
#include <iostream>
#include <retroshare/rsinit.h> #include <retroshare/rsinit.h>
#include <lang/languagesupport.h> #include <lang/languagesupport.h>
@ -538,3 +537,43 @@ void Rshare::blinkTimer()
mBlink = !mBlink; mBlink = !mBlink;
emit blink(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 **/ /** Recalculates matching stylesheet for widget **/
static void refreshStyleSheet(QWidget *widget, bool processChildren); static void refreshStyleSheet(QWidget *widget, bool processChildren);
static bool loadCertificate(const std::string &accountId, bool autoLogin, std::string gpgId = "");
/** /**
* Update Language, Style and StyleSheet. * Update Language, Style and StyleSheet.
* First args are cheked for a style then the settings. * First args are cheked for a style then the settings.