add some validators for gpg key gen

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@2313 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
joss17 2010-02-14 12:04:44 +00:00
parent 48a25578c0
commit bb3696597a
2 changed files with 24 additions and 8 deletions

View File

@ -140,10 +140,18 @@ void GenCertDialog::genPerson()
{ {
/* Check the data from the GUI. */ /* Check the data from the GUI. */
std::string genLoc = ui.genLoc->text().toStdString(); std::string genLoc = ui.location_input->text().toStdString();
std::string PGPId; std::string PGPId;
if (!genNewGPGKey) { if (!genNewGPGKey) {
if (ui.location_input->text().length() < 3) {
/* Message Dialog */
QMessageBox::StandardButton sb = QMessageBox::warning ( NULL,
tr("Generate GPG key Failure"),
tr("Location field is required with a minimum of 3 characters"),
QMessageBox::Ok);
return;
}
int pgpidx = ui.genPGPuser->currentIndex(); int pgpidx = ui.genPGPuser->currentIndex();
if (pgpidx < 0) if (pgpidx < 0)
{ {
@ -157,11 +165,12 @@ 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) {
/* Message Dialog */ /* Message Dialog */
QMessageBox::StandardButton sb = QMessageBox::warning ( NULL, QMessageBox::StandardButton sb = QMessageBox::warning ( NULL,
tr("Generate GPG key Failure"), tr("Generate GPG key Failure"),
tr("Your Name or password is too short (3+ characters)"), tr("All fields are required with a minimum of 3 characters"),
QMessageBox::Ok); QMessageBox::Ok);
return; return;
} }
@ -183,7 +192,7 @@ void GenCertDialog::genPerson()
ui.genPGPuserlabel->hide(); ui.genPGPuserlabel->hide();
ui.genPGPuser->hide(); ui.genPGPuser->hide();
ui.location_label->hide(); ui.location_label->hide();
ui.genLoc->hide(); ui.location_input->hide();
ui.infopushButton->hide(); ui.infopushButton->hide();
ui.genButton->hide(); ui.genButton->hide();
QMessageBox::StandardButton info = QMessageBox::information( NULL, QMessageBox::StandardButton info = QMessageBox::information( NULL,

View File

@ -7,7 +7,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>569</width> <width>569</width>
<height>437</height> <height>469</height>
</rect> </rect>
</property> </property>
<property name="sizePolicy"> <property name="sizePolicy">
@ -715,7 +715,14 @@ border: 1px solid #CCCCCC;}</string>
</widget> </widget>
</item> </item>
<item row="5" column="1"> <item row="5" column="1">
<widget class="QLineEdit" name="genLoc"/> <widget class="QLineEdit" name="location_input"/>
</item>
<item row="6" column="1">
<widget class="QLabel" name="label_location2">
<property name="text">
<string>Put a meaningfull location. ex : home, laptop, etc.</string>
</property>
</widget>
</item> </item>
</layout> </layout>
</item> </item>
@ -741,7 +748,7 @@ border: 1px solid #CCCCCC;}</string>
</size> </size>
</property> </property>
<property name="text"> <property name="text">
<string>Generate a new a new gpg key</string> <string>Generate a new gpg key</string>
</property> </property>
<property name="icon"> <property name="icon">
<iconset resource="images.qrc"> <iconset resource="images.qrc">
@ -835,7 +842,7 @@ border: 1px solid #CCCCCC;}</string>
<tabstop>name_input</tabstop> <tabstop>name_input</tabstop>
<tabstop>email_input</tabstop> <tabstop>email_input</tabstop>
<tabstop>password_input</tabstop> <tabstop>password_input</tabstop>
<tabstop>genLoc</tabstop> <tabstop>location_input</tabstop>
</tabstops> </tabstops>
<resources> <resources>
<include location="images.qrc"/> <include location="images.qrc"/>