add key generation at startup if no gpg key found

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@2068 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
joss17 2010-01-18 12:30:54 +00:00
parent 28882efe03
commit af68fa36ce
7 changed files with 189 additions and 197 deletions

View file

@ -50,20 +50,15 @@ GenCertDialog::GenCertDialog(QWidget *parent, Qt::WFlags flags)
//ui.genName->setFocus(Qt::OtherFocusReason);
ui.genCountry->hide();
ui.label_6->hide();
ui.genOrg->hide();
ui.label_8->hide();
/* get all available pgp private certificates....
* mark last one as default.
*/
std::cerr << "Finding PGPUsers" << std::endl;
foundGPGKeys = false;
std::list<std::string> pgpIds;
std::list<std::string>::iterator it;
if (RsInit::GetPGPLogins(pgpIds))
{
if (RsInit::GetPGPLogins(pgpIds)) {
for(it = pgpIds.begin(); it != pgpIds.end(); it++)
{
const QVariant & userData = QVariant(QString::fromStdString(*it));
@ -71,10 +66,22 @@ GenCertDialog::GenCertDialog(QWidget *parent, Qt::WFlags flags)
RsInit::GetPGPLoginDetails(*it, name, email);
std::cerr << "Adding PGPUser: " << name << " id: " << *it << std::endl;
ui.genPGPuser->addItem(QString::fromStdString(name), userData);
foundGPGKeys = true;
}
}
if (foundGPGKeys) {
ui.no_gpg_key_label->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();
} else {
ui.genPGPuserlabel->hide();
ui.genPGPuser->hide();
}
}
/** Destructor. */
@ -111,24 +118,47 @@ void GenCertDialog::genPerson()
{
/* Check the data from the GUI. */
std::string genOrg = ui.genOrg->text().toStdString();
std::string genLoc = ui.genLoc->text().toStdString();
std::string genCountry = ui.genCountry->text().toStdString();
std::string err;
std::string PGPId;
int pgpidx = ui.genPGPuser->currentIndex();
if (pgpidx < 0)
{
/* Message Dialog */
QMessageBox::StandardButton sb = QMessageBox::warning ( NULL,
"Generate ID Failure",
"Missing PGP Certificate",
QMessageBox::Ok);
return;
}
if (foundGPGKeys) {
int pgpidx = ui.genPGPuser->currentIndex();
if (pgpidx < 0)
{
/* Message Dialog */
QMessageBox::StandardButton sb = QMessageBox::warning ( NULL,
"Generate ID Failure",
"Missing PGP Certificate",
QMessageBox::Ok);
return;
}
QVariant data = ui.genPGPuser->itemData(pgpidx);
PGPId = (data.toString()).toStdString();
} else {
//generate a new gpg key
std::string err_string;
ui.no_gpg_key_label->setText(tr("Generating new GPG key, please be patient. Fill in your GPG password when asked."));
ui.no_gpg_key_label->show();
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.genLoc->hide();
ui.infopushButton->hide();
ui.genButton->hide();
QMessageBox::StandardButton info = QMessageBox::information( NULL,
"Generating GPG key",
"This process can take some time, please be patient after pressing the OK button",
QMessageBox::Ok);
//info->
RsInit::GeneratePGPCertificate(ui.name_input->text().toStdString(), ui.email_input->text().toStdString(), ui.password_input->text().toStdString(), PGPId, err_string);
}
QVariant data = ui.genPGPuser->itemData(pgpidx);
std::string PGPId = (data.toString()).toStdString();
//generate a random ssl password
std::cerr << " generating sslPasswd." << std::endl;
@ -146,8 +176,9 @@ void GenCertDialog::genPerson()
//RsInit::LoadGPGPassword(PGPpasswd);
std::string sslId;
std::cerr << "Generating SSL cert with name : " << ui.genPGPuser->itemText(pgpidx).toStdString() << std::endl;
bool okGen = RsInit::GenerateSSLCertificate(ui.genPGPuser->itemText(pgpidx).toStdString(), genOrg, genLoc, genCountry, sslPasswd, sslId, err);
std::cerr << "Generating SSL cert with gpg id : " << PGPId << std::endl;
std::string err;
bool okGen = RsInit::GenerateSSLCertificate(PGPId, "", genLoc, "", sslPasswd, sslId, err);
if (okGen)
{

View file

@ -64,6 +64,8 @@ private:
/** Qt Designer generated object */
Ui::GenCertDialog ui;
bool foundGPGKeys;
};
#endif

View file

@ -1010,12 +1010,14 @@
&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:'Arial'; font-size:8pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-size:16pt;&quot;&gt;Create a new RetroShare profile&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot; font-size:9pt;&quot;&gt;Please fill in the information which will&lt;br /&gt;allow your RetroShare to connect to&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-size:9pt;&quot;&gt;Friends.&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-size:16pt;&quot;&gt;Create a new RetroShare profile&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Retroshare uses gpg keys. Please fill in the location field, it will be permanently attached to this retroshare installation. You can generate a new retroshare location profile with the same gpg key on another computer.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
<property name="indent">
<number>100</number>
</property>
@ -1028,65 +1030,69 @@ p, li { white-space: pre-wrap; }
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<layout class="QGridLayout">
<property name="margin">
<number>9</number>
<widget class="QLabel" name="no_gpg_key_label">
<property name="text">
<string>It looks like you don't own any GPG keys. Please fill in the form below to generate one, or use your favorite gnupg keys manager.</string>
</property>
<property name="spacing">
<number>6</number>
<property name="wordWrap">
<bool>true</bool>
</property>
<item row="2" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Organisation:</string>
</property>
</widget>
</item>
<item row="2" column="1" colspan="2">
<widget class="QLineEdit" name="genOrg"/>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_7">
<property name="text">
<string>Location:</string>
</property>
</widget>
</item>
<item row="3" column="1" colspan="2">
<widget class="QLineEdit" name="genLoc"/>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_8">
<property name="text">
<string>Country:</string>
</property>
</widget>
</item>
<item row="4" column="1" colspan="2">
<widget class="QLineEdit" name="genCountry"/>
</item>
<item row="0" column="1" colspan="2">
<widget class="QComboBox" name="genPGPuser"/>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label">
</widget>
</item>
<item row="2" column="0">
<layout class="QFormLayout" name="formLayout">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
</property>
<item row="1" column="0">
<widget class="QLabel" name="genPGPuserlabel">
<property name="text">
<string>OpenPGP User</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="genPGPuser"/>
</item>
<item row="2" column="0">
<widget class="QLabel" name="name_label">
<property name="text">
<string>Name</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="name_input"/>
</item>
<item row="5" column="0">
<widget class="QLabel" name="location_label">
<property name="text">
<string>Location:</string>
</property>
</widget>
</item>
<item row="5" column="1">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
<widget class="QLineEdit" name="genLoc"/>
</item>
<item row="3" column="0">
<widget class="QLabel" name="email_label">
<property name="text">
<string>Email</string>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</widget>
</item>
<item row="3" column="1">
<widget class="QLineEdit" name="email_input"/>
</item>
<item row="4" column="0">
<widget class="QLabel" name="password_label">
<property name="text">
<string>GPG Password</string>
</property>
</spacer>
</widget>
</item>
<item row="4" column="1">
<widget class="QLineEdit" name="password_input"/>
</item>
</layout>
</item>
@ -1124,9 +1130,12 @@ p, li { white-space: pre-wrap; }
</widget>
<tabstops>
<tabstop>genPGPuser</tabstop>
<tabstop>genOrg</tabstop>
<tabstop>name_input</tabstop>
<tabstop>email_input</tabstop>
<tabstop>password_input</tabstop>
<tabstop>genLoc</tabstop>
<tabstop>genCountry</tabstop>
<tabstop>genButton</tabstop>
<tabstop>infopushButton</tabstop>
</tabstops>
<resources>
<include location="images.qrc"/>