void GenCertDialog::init() { std::cerr << "Finding PGPUsers" << std::endl; ui.genPGPuser->clear() ; std::list<RsPgpId> pgpIds; std::list<RsPgpId>::iterator it; bool foundGPGKeys = false; if (!mOnlyGenerateIdentity) { if (RsAccounts::GetPGPLogins(pgpIds)) { for(it = pgpIds.begin(); it != pgpIds.end(); ++it) { QVariant userData(QString::fromStdString( (*it).toStdString() )); std::string name, email; RsAccounts::GetPGPLoginDetails(*it, name, email); std::cerr << "Adding PGPUser: "******" id: " << *it << std::endl; QString gid = QString::fromStdString( (*it).toStdString()).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 node")); ui.genButton2->setText(tr("Generate new node")); ui.headerFrame->setHeaderText(tr("Create a new node")); genNewGPGKey = false; } else { ui.no_gpg_key_label->setVisible(!mOnlyGenerateIdentity); ui.new_gpg_key_checkbox->setChecked(true); ui.new_gpg_key_checkbox->setEnabled(true); setWindowTitle(tr("Create new Identity")); ui.genButton2->setText(tr("Generate new Identity")); ui.headerFrame->setHeaderText(tr("Create a new Identity")); genNewGPGKey = true; } QString text; /*= ui.header_label->text() + "\n";*/ text += tr("You can create a new identity with this form."); if (mOnlyGenerateIdentity) { ui.new_gpg_key_checkbox->setChecked(true); ui.new_gpg_key_checkbox->hide(); ui.genprofileinfo_label->hide(); } else { text += "\n"; text += tr("Alternatively you can use an existing identity. Just uncheck \"Create a new identity\""); } ui.header_label->setText(text); newGPGKeyGenUiSetup(); updateUiSetup(); }
/** Default constructor */ GenCertDialog::GenCertDialog(bool onlyGenerateIdentity, QWidget *parent) : QDialog(parent, Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint), mOnlyGenerateIdentity(onlyGenerateIdentity) { /* Invoke Qt Designer generated QObject setup routine */ ui.setupUi(this); ui.headerFrame->setHeaderImage(QPixmap(":/images/contact_new128.png")); ui.headerFrame->setHeaderText(tr("Create a new Identity")); connect(ui.new_gpg_key_checkbox, SIGNAL(clicked()), this, SLOT(newGPGKeyGenUiSetup())); connect(ui.adv_checkbox, SIGNAL(clicked()), this, SLOT(updateUiSetup())); connect(ui.hidden_checkbox, SIGNAL(clicked()), this, SLOT(updateUiSetup())); connect(ui.genButton2, 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); // QObject *obj = QCoreApplication::eventFilter() ; // std::cerr << "Event filter : " << obj << std::endl; // QCoreApplication::instance()->setEventFilter(MyEventFilter) ; entropy_timer = new QTimer ; entropy_timer->start(20) ; QObject::connect(entropy_timer,SIGNAL(timeout()),this,SLOT(grabMouse())) ; // EntropyCollectorWidget *ecw = new EntropyCollectorWidget(ui.entropy_bar,this) ; // ecw->resize(size()) ; // ecw->move(0,0) ; // // QGraphicsOpacityEffect *effect = new QGraphicsOpacityEffect ; // effect->setOpacity(0.2) ; // ecw->setGraphicsEffect(effect) ; //ecw->setBackgroundColor(QColor::fromRGB(1,1,1)) ; // ecw->show() ; ui.entropy_bar->setValue(0) ; // make sure that QVariant always takes an 'int' otherwise the program will crash! ui.keylength_comboBox->addItem("2048 bits", QVariant(2048)); ui.keylength_comboBox->addItem("3072 bits", QVariant(3072)); ui.keylength_comboBox->addItem("4096 bits", QVariant(4096)); #if QT_VERSION >= 0x040700 ui.email_input->setPlaceholderText(tr("[Optional] Visible to your friends, and friends of friends.")) ; ui.node_input->setPlaceholderText(tr("[Required] Examples: Home, Laptop,...")) ; ui.hiddenaddr_input->setPlaceholderText(tr("[Required] Examples: xa76giaf6ifda7ri63i263.onion (obtained by you from TOR)")) ; 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.password_input_2->setPlaceholderText(tr("[Required] Type the same password again here.")); #endif ui.node_input->setToolTip(tr("Enter a meaningful node description. e.g. : home, laptop, etc. \nThis field will be used to differentiate different installations with\nthe same identity (PGP key).")) ; ui.email_input->hide() ; ui.email_label->hide() ; /* get all available pgp private certificates.... * mark last one as default. */ init(); }
void GenCertDialog::newGPGKeyGenUiSetup() { bool adv_state = ui.adv_checkbox->isChecked(); bool hidden_state = ui.hidden_checkbox->isChecked(); ui.no_node_label->setVisible(false); 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_label_2->show(); ui.password_input->show(); ui.password_input_2->show(); ui.genPGPuserlabel->hide(); ui.genPGPuser->hide(); ui.importIdentity_PB->hide() ; ui.exportIdentity_PB->hide(); setWindowTitle(tr("Create new profile")); ui.genButton2->setText(tr("Generate new profile and node")); ui.headerFrame->setHeaderText(tr("Create a new profile and node")); ui.no_gpg_key_label->setText(tr("Welcome to Retroshare. Before you can proceed you need to create a profile and associate a node with it. To do so please fill out this form.\nAlternatively you can import a (previously exported) profile. Just uncheck \"Create a new profile\"")); ui.genButton2->setVisible(true); ui.adv_checkbox->setVisible(true); ui.node_label->setVisible(true); ui.node_input->setVisible(true); ui.entropy_label->setVisible(true); ui.entropy_bar->setVisible(true); ui.genprofileinfo_label->setVisible(false); if (!mOnlyGenerateIdentity) { ui.header_label->setVisible(haveGPGKeys); } //ui.keylength_label->show(); //ui.keylength_comboBox->show(); } else { //haveGPGKeys = (ui.genPGPuser->count() != 0)?true:false; if (haveGPGKeys) { QVariant data = ui.genPGPuser->itemData(ui.genPGPuser->currentIndex()); if (!rsAccounts->selectAccountByString(data.toString().toStdString())) { ui.no_node_label->setText(tr("No node is associated with the profile named") + " " + ui.genPGPuser->currentText() + ". " +tr("Please create a node for it by providing a node name.")); ui.no_node_label->setVisible(true); } else { ui.genprofileinfo_label->show(); } } genNewGPGKey = false; ui.name_label->hide(); ui.name_input->hide(); // ui.email_label->hide(); // ui.email_input->hide(); ui.password_label->hide(); ui.password_label_2->hide(); ui.password_input->hide(); ui.password_input_2->hide(); ui.genPGPuserlabel->show(); ui.genPGPuser->show(); ui.importIdentity_PB->setVisible(!mOnlyGenerateIdentity); ui.exportIdentity_PB->setVisible(haveGPGKeys); ui.exportIdentity_PB->setEnabled(haveGPGKeys); setWindowTitle(tr("Create new node")); ui.genButton2->setText(tr("Generate new node")); ui.headerFrame->setHeaderText(tr("Create a new node")); ui.no_gpg_key_label->setText(tr("Welcome to Retroshare. Before you can proceed you need to import a profile and after that associate a node with it.")); ui.genButton2->setVisible(haveGPGKeys); ui.adv_checkbox->setVisible(haveGPGKeys); ui.adv_checkbox->setChecked(haveGPGKeys && adv_state); ui.genPGPuser->setVisible(haveGPGKeys); ui.genPGPuserlabel->setVisible(haveGPGKeys); ui.node_label->setVisible(haveGPGKeys); ui.node_input->setVisible(haveGPGKeys); ui.entropy_label->setVisible(haveGPGKeys); ui.entropy_bar->setVisible(haveGPGKeys); //ui.genprofileinfo_label->show(); ui.header_label->setVisible(false); ui.keylength_label->hide(); ui.keylength_comboBox->hide(); } updateUiSetup(); ui.adv_checkbox->setChecked(adv_state); ui.hidden_checkbox->setChecked(hidden_state); }