diff --git a/libretroshare/src/retroshare/rsinit.h b/libretroshare/src/retroshare/rsinit.h index f0af5e907..1400e2bf2 100644 --- a/libretroshare/src/retroshare/rsinit.h +++ b/libretroshare/src/retroshare/rsinit.h @@ -78,7 +78,7 @@ class RsInit static bool getPreferedAccountId(std::string &id); static bool getPGPEngineFileName(std::string &fileName); static bool getAccountIds(std::list &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) ; diff --git a/libretroshare/src/rsserver/rsinit.cc b/libretroshare/src/rsserver/rsinit.cc index 359c833f2..7dabbe7bf 100644 --- a/libretroshare/src/rsserver/rsinit.cc +++ b/libretroshare/src/rsserver/rsinit.cc @@ -822,7 +822,7 @@ bool RsInit::getAccountIds(std::list &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) { diff --git a/retroshare-gui/src/gui/GenCertDialog.cpp b/retroshare-gui/src/gui/GenCertDialog.cpp index 8166a98f4..3cdfc7318 100644 --- a/retroshare-gui/src/gui/GenCertDialog.cpp +++ b/retroshare-gui/src/gui/GenCertDialog.cpp @@ -22,139 +22,134 @@ #include #include #include -#include #include "GenCertDialog.h" #include #include #include -#include #include - +#include /* 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 pgpIds; - std::list::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 pgpIds; + std::list::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(""); - } -#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(""); - } -#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; - } -} diff --git a/retroshare-gui/src/gui/GenCertDialog.h b/retroshare-gui/src/gui/GenCertDialog.h index 640816ebd..38c53fe3a 100644 --- a/retroshare-gui/src/gui/GenCertDialog.h +++ b/retroshare-gui/src/gui/GenCertDialog.h @@ -19,51 +19,33 @@ * Boston, MA 02110-1301, USA. ****************************************************************/ - #ifndef _GENCERTDIALOG_H #define _GENCERTDIALOG_H -#include - #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 - diff --git a/retroshare-gui/src/gui/StartDialog.cpp b/retroshare-gui/src/gui/StartDialog.cpp index 63e79c348..593bfc25d 100644 --- a/retroshare-gui/src/gui/StartDialog.cpp +++ b/retroshare-gui/src/gui/StartDialog.cpp @@ -29,8 +29,8 @@ #include /** 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(); // } } diff --git a/retroshare-gui/src/gui/StartDialog.h b/retroshare-gui/src/gui/StartDialog.h index fda0a6a23..ed6d6d725 100644 --- a/retroshare-gui/src/gui/StartDialog.h +++ b/retroshare-gui/src/gui/StartDialog.h @@ -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; diff --git a/retroshare-gui/src/gui/StartDialog.ui b/retroshare-gui/src/gui/StartDialog.ui index 0fa020a8d..9ab6c1cb3 100644 --- a/retroshare-gui/src/gui/StartDialog.ui +++ b/retroshare-gui/src/gui/StartDialog.ui @@ -1,7 +1,7 @@ StartDialog - + 0 @@ -17,293 +17,298 @@ :/images/rstray3.png:/images/rstray3.png - - - - 0 - - - 0 - - - 0 - - - - - 0 - - - 6 - - - 0 - - - 6 - - - 6 - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - QToolButton { + + + 0 + + + + + 0 + + + 0 + + + 0 + + + + + 0 + + + 6 + + + 0 + + + 6 + + + 6 + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + QToolButton { border-image: url(:/images/avatar_background.png); } - - - - - - - :/images/user/personal64.png:/images/user/personal64.png - - - - 96 - 96 - - - - true - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - 0 - 0 - - - - - 16777215 - 32 - - - - - - - - - 85 - 170 - 255 - - - - - - - - - 85 - 170 - 255 - - - - - - - - - 118 - 116 - 108 - - - - - - - - - 18 - - - - Login - - - - - - - Qt::Horizontal - - - - 48 - 20 - - - - - - - - - - - 16 - 65 - - - - QFrame::NoFrame - - - QFrame::Raised - - - - - - - Opens a dialog for creating a new profile or -adding locations to an existing profile. -The current identities/locations will not be affected. - - - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> -<html><head><meta name="qrichtext" content="1" /><style type="text/css"> -p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a href="Create new Profile..."><span style=" font-family:'MS Shell Dlg 2'; font-size:8pt; text-decoration: underline; color:#0000ff;">Manage profiles and locations...</span></a></p></body></html> - - - - - - - 9 - - - 9 - - - - - Log In - - - true - - - false - - - - - - - Qt::Horizontal - - - - 61 - 20 - - - - - - - - Qt::Horizontal - - - - 71 - 20 - - - - - - - - - - true - - - - - - - + - Name (GPG Id) - location: + + + + + :/images/user/personal64.png:/images/user/personal64.png + + + + 96 + 96 + + + + true - - - - - - - Remember Password + + + + Qt::Horizontal - + + + 40 + 20 + + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 0 + 0 + + + + + 16777215 + 32 + + + + + + + + + 85 + 170 + 255 + + + + + + + + + 85 + 170 + 255 + + + + + + + + + 118 + 116 + 108 + + + + + + + + + 18 + + + + Login + + + + + + + Qt::Horizontal + + + + 48 + 20 + + + + + + + + + + true + + + + + + + + + Name (GPG Id) - location: + + + + + + + + + + Remember Password + + + false + + + + + + + + + + 9 + + + 9 + + + + + Log In + + + true + + false + + + + Qt::Horizontal + + + + 61 + 20 + + + + + + + + Qt::Horizontal + + + + 71 + 20 + + + + - - - - + + + + + Opens a dialog for creating a new profile or +adding locations to an existing profile. +The current identities/locations will not be affected. + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a href="Create new Profile..."><span style=" font-family:'MS Shell Dlg 2'; font-size:8pt; text-decoration: underline; color:#0000ff;">Manage profiles and locations...</span></a></p></body></html> + + + + + + + + 16 + 65 + + + + QFrame::NoFrame + + + QFrame::Raised + + + + + + diff --git a/retroshare-gui/src/lang/retroshare_en.ts b/retroshare-gui/src/lang/retroshare_en.ts index e3ed38625..673b922e9 100644 --- a/retroshare-gui/src/lang/retroshare_en.ts +++ b/retroshare-gui/src/lang/retroshare_en.ts @@ -5025,30 +5025,10 @@ anonymous, you can use a fake email. Fill in your GPG password when asked, to sign your new key. - - Select Trusted Friend - - - - Certificates (*.pqi *.pem) - - - - Multiple instances - - - - Another RetroShare using the same profile is already running on your system. Please close that instance first - - Generate ID Failure - - Failed to Load your new Certificate! - - [Optional] Visible to your friends, and friends of friends. @@ -5161,10 +5141,6 @@ and use the import button to load it Your identity was imported successfully: - - An unexpected error occurred when Retroshare tried to acquire the single instance lock - - RetroShare uses gpg keys for identity management. @@ -5177,6 +5153,10 @@ and use the import button to load it You can use an existing identity (i.e. a gpg key pair), from the list below, or create a new one with this form. + + Failed to Generate your new Certificate, maybe PGP password is wrong! + + GeneralPage @@ -5530,6 +5510,14 @@ p, li { white-space: pre-wrap; } Private Key Available + + Search Title + + + + Search Description + + GuiExprElement @@ -7222,6 +7210,34 @@ Do you want to save message ? 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. + + Search Subject + + + + Search From + + + + Search Date + + + + Search Content + + + + Search Tags + + + + Search Attachments + + + + Search... + + MessengerWindow @@ -10504,34 +10520,10 @@ p, li { white-space: pre-wrap; } Remember Password - - Multiple instances - - - - Login Failure - - - - Maybe password is wrong - - Warning - - Another RetroShare using the same profile is already running on your system. Please close that instance first, or choose another profile -lock file: - - - - - An unexpected error occurred when Retroshare tried to acquire the single instance lock -lock file: - - - Login diff --git a/retroshare-gui/src/main.cpp b/retroshare-gui/src/main.cpp index 8a0dd9df0..09a404a11 100644 --- a/retroshare-gui/src/main.cpp +++ b/retroshare-gui/src/main.cpp @@ -201,27 +201,17 @@ int main(int argc, char *argv[]) { /* Login Dialog */ /* check for existing Certificate */ - StartDialog *sd = NULL; bool genCert = false; std::list 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: diff --git a/retroshare-gui/src/rshare.cpp b/retroshare-gui/src/rshare.cpp index 7b03dd03f..ed6a01971 100644 --- a/retroshare-gui/src/rshare.cpp +++ b/retroshare-gui/src/rshare.cpp @@ -20,8 +20,6 @@ * Boston, MA 02110-1301, USA. ****************************************************************/ - - #include #include #include @@ -32,6 +30,7 @@ #include #include #include +#include #include #include @@ -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; +} diff --git a/retroshare-gui/src/rshare.h b/retroshare-gui/src/rshare.h index b3a866c76..07ca3be74 100644 --- a/retroshare-gui/src/rshare.h +++ b/retroshare-gui/src/rshare.h @@ -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.