mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
Added automatic clean of the friend certificate in ConnectFriendWizard.
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@5422 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
5d289b520b
commit
cfe72859bf
@ -136,11 +136,19 @@ void ConnectFriendWizard::initializePage(int id)
|
|||||||
connect(ui->userCertCopyButton, SIGNAL(clicked()), this, SLOT(copyCert()));
|
connect(ui->userCertCopyButton, SIGNAL(clicked()), this, SLOT(copyCert()));
|
||||||
connect(ui->userCertSaveButton, SIGNAL(clicked()), this, SLOT(saveCert()));
|
connect(ui->userCertSaveButton, SIGNAL(clicked()), this, SLOT(saveCert()));
|
||||||
connect(ui->userCertMailButton, SIGNAL(clicked()), this, SLOT(runEmailClient()));
|
connect(ui->userCertMailButton, SIGNAL(clicked()), this, SLOT(runEmailClient()));
|
||||||
connect(ui->friendCertCleanButton, SIGNAL(clicked()), this, SLOT(cleanFriendCert()));
|
connect(ui->friendCertEdit, SIGNAL(textChanged()), this, SLOT(friendCertChanged()));
|
||||||
|
|
||||||
ui->TextPage->registerField("friendCert*", ui->friendCertEdit, "plainText", SIGNAL(textChanged()));
|
cleanfriendCertTimer = new QTimer(this);
|
||||||
|
cleanfriendCertTimer->setSingleShot(true);
|
||||||
|
cleanfriendCertTimer->setInterval(1000); // 1 second
|
||||||
|
connect(cleanfriendCertTimer, SIGNAL(timeout()), this, SLOT(cleanFriendCert()));
|
||||||
|
|
||||||
|
toggleFormatState(false);
|
||||||
|
toggleSignatureState(false);
|
||||||
|
updateOwnCert();
|
||||||
|
|
||||||
|
cleanFriendCert();
|
||||||
|
|
||||||
toggleSignatureState(); // updateOwnCert
|
|
||||||
break;
|
break;
|
||||||
case Page_Cert:
|
case Page_Cert:
|
||||||
connect(ui->userFileCreateButton, SIGNAL(clicked()), this, SLOT(generateCertificateCalled()));
|
connect(ui->userFileCreateButton, SIGNAL(clicked()), this, SLOT(generateCertificateCalled()));
|
||||||
@ -287,8 +295,6 @@ bool ConnectFriendWizard::validateCurrentPage()
|
|||||||
break;
|
break;
|
||||||
case Page_Text:
|
case Page_Text:
|
||||||
{
|
{
|
||||||
cleanFriendCert() ;
|
|
||||||
|
|
||||||
std::string certstr = ui->friendCertEdit->toPlainText().toUtf8().constData();
|
std::string certstr = ui->friendCertEdit->toPlainText().toUtf8().constData();
|
||||||
std::string error_string;
|
std::string error_string;
|
||||||
|
|
||||||
@ -478,7 +484,8 @@ void ConnectFriendWizard::updateOwnCert()
|
|||||||
|
|
||||||
ui->userCertEdit->setPlainText(QString::fromUtf8(invite.c_str()));
|
ui->userCertEdit->setPlainText(QString::fromUtf8(invite.c_str()));
|
||||||
}
|
}
|
||||||
void ConnectFriendWizard::toggleFormatState()
|
|
||||||
|
void ConnectFriendWizard::toggleFormatState(bool doUpdate)
|
||||||
{
|
{
|
||||||
if (ui->userCertOldFormatButton->isChecked())
|
if (ui->userCertOldFormatButton->isChecked())
|
||||||
{
|
{
|
||||||
@ -491,9 +498,12 @@ void ConnectFriendWizard::toggleFormatState()
|
|||||||
ui->userCertOldFormatButton->setIcon(QIcon(":/images/ledon1.png")) ;
|
ui->userCertOldFormatButton->setIcon(QIcon(":/images/ledon1.png")) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (doUpdate) {
|
||||||
updateOwnCert();
|
updateOwnCert();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
void ConnectFriendWizard::toggleSignatureState()
|
|
||||||
|
void ConnectFriendWizard::toggleSignatureState(bool doUpdate)
|
||||||
{
|
{
|
||||||
if (ui->userCertIncludeSignaturesButton->isChecked()) {
|
if (ui->userCertIncludeSignaturesButton->isChecked()) {
|
||||||
ui->userCertIncludeSignaturesButton->setToolTip(tr("Remove signatures"));
|
ui->userCertIncludeSignaturesButton->setToolTip(tr("Remove signatures"));
|
||||||
@ -501,7 +511,9 @@ void ConnectFriendWizard::toggleSignatureState()
|
|||||||
ui->userCertIncludeSignaturesButton->setToolTip(tr("Include signatures"));
|
ui->userCertIncludeSignaturesButton->setToolTip(tr("Include signatures"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (doUpdate) {
|
||||||
updateOwnCert();
|
updateOwnCert();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConnectFriendWizard::runEmailClient()
|
void ConnectFriendWizard::runEmailClient()
|
||||||
@ -509,37 +521,57 @@ void ConnectFriendWizard::runEmailClient()
|
|||||||
sendMail("", tr("RetroShare Invite"), ui->userCertEdit->toPlainText());
|
sendMail("", tr("RetroShare Invite"), ui->userCertEdit->toPlainText());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ConnectFriendWizard::friendCertChanged()
|
||||||
|
{
|
||||||
|
ui->TextPage->setComplete(false);
|
||||||
|
cleanfriendCertTimer->start();
|
||||||
|
}
|
||||||
|
|
||||||
void ConnectFriendWizard::cleanFriendCert()
|
void ConnectFriendWizard::cleanFriendCert()
|
||||||
{
|
{
|
||||||
|
bool certValid = false;
|
||||||
|
QString errorMsg;
|
||||||
std::string cert = ui->friendCertEdit->toPlainText().toUtf8().constData();
|
std::string cert = ui->friendCertEdit->toPlainText().toUtf8().constData();
|
||||||
cert += "\n"; // add an end of line to avoid a bug
|
|
||||||
|
if (cert.empty()) {
|
||||||
|
ui->friendCertCleanLabel->setPixmap(QPixmap(":/images/delete.png"));
|
||||||
|
ui->friendCertCleanLabel->setToolTip("");
|
||||||
|
} else {
|
||||||
std::string cleanCert;
|
std::string cleanCert;
|
||||||
int error_code;
|
int error_code;
|
||||||
|
|
||||||
if (rsPeers->cleanCertificate(cert, cleanCert, error_code)) {
|
if (rsPeers->cleanCertificate(cert, cleanCert, error_code)) {
|
||||||
ui->friendCertEdit->setPlainText(QString::fromStdString(cleanCert));
|
certValid = true;
|
||||||
|
if (cert != cleanCert) {
|
||||||
|
disconnect(ui->friendCertEdit, SIGNAL(textChanged()), this, SLOT(friendCertChanged()));
|
||||||
|
QTextCursor textCursor = ui->friendCertEdit->textCursor();
|
||||||
|
ui->friendCertEdit->setPlainText(QString::fromUtf8(cleanCert.c_str()));
|
||||||
|
ui->friendCertEdit->setTextCursor(textCursor);
|
||||||
|
connect(ui->friendCertEdit, SIGNAL(textChanged()), this, SLOT(friendCertChanged()));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
if (error_code > 0) {
|
if (error_code > 0) {
|
||||||
QString msg;
|
|
||||||
|
|
||||||
switch (error_code) {
|
switch (error_code) {
|
||||||
case RS_PEER_CERT_CLEANING_CODE_NO_BEGIN_TAG:
|
case RS_PEER_CERT_CLEANING_CODE_NO_BEGIN_TAG:
|
||||||
msg = tr("No or misspelled BEGIN tag found") ;
|
errorMsg = tr("No or misspelled BEGIN tag found") ;
|
||||||
break ;
|
break ;
|
||||||
case RS_PEER_CERT_CLEANING_CODE_NO_END_TAG:
|
case RS_PEER_CERT_CLEANING_CODE_NO_END_TAG:
|
||||||
msg = tr("No or misspelled END tag found") ;
|
errorMsg = tr("No or misspelled END tag found") ;
|
||||||
break ;
|
break ;
|
||||||
case RS_PEER_CERT_CLEANING_CODE_NO_CHECKSUM:
|
case RS_PEER_CERT_CLEANING_CODE_NO_CHECKSUM:
|
||||||
msg = tr("No checksum found (the last 5 chars should be separated by a '=' char), or no newline after tag line (e.g. line beginning with Version:)") ;
|
errorMsg = tr("No checksum found (the last 5 chars should be separated by a '=' char), or no newline after tag line (e.g. line beginning with Version:)") ;
|
||||||
break ;
|
break ;
|
||||||
default:
|
default:
|
||||||
msg = tr("Unknown error. Your cert is probably not even a certificate.") ;
|
errorMsg = tr("Unknown error. Your cert is probably not even a certificate.") ;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
QMessageBox::information(NULL, tr("Certificate cleaning error"), msg) ;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ui->friendCertCleanLabel->setPixmap(certValid ? QPixmap(":/images/accepted16.png") : QPixmap(":/images/delete.png"));
|
||||||
|
ui->friendCertCleanLabel->setToolTip(errorMsg);
|
||||||
|
|
||||||
}
|
ui->TextPage->setComplete(certValid);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConnectFriendWizard::showHelpUserCert()
|
void ConnectFriendWizard::showHelpUserCert()
|
||||||
|
@ -44,12 +44,13 @@ protected:
|
|||||||
private slots:
|
private slots:
|
||||||
/* TextPage */
|
/* TextPage */
|
||||||
void updateOwnCert();
|
void updateOwnCert();
|
||||||
void toggleSignatureState();
|
void toggleSignatureState(bool doUpdate = true);
|
||||||
void toggleFormatState();
|
void toggleFormatState(bool doUpdate = true);
|
||||||
void runEmailClient();
|
void runEmailClient();
|
||||||
void showHelpUserCert();
|
void showHelpUserCert();
|
||||||
void copyCert();
|
void copyCert();
|
||||||
void saveCert();
|
void saveCert();
|
||||||
|
void friendCertChanged();
|
||||||
void cleanFriendCert();
|
void cleanFriendCert();
|
||||||
|
|
||||||
/* CertificatePage */
|
/* CertificatePage */
|
||||||
@ -67,6 +68,9 @@ private:
|
|||||||
bool error;
|
bool error;
|
||||||
RsPeerDetails peerDetails;
|
RsPeerDetails peerDetails;
|
||||||
|
|
||||||
|
/* TextPage */
|
||||||
|
QTimer *cleanfriendCertTimer;
|
||||||
|
|
||||||
/* FofPage */
|
/* FofPage */
|
||||||
std::map<QCheckBox*, std::string> _id_boxes;
|
std::map<QCheckBox*, std::string> _id_boxes;
|
||||||
std::map<QCheckBox*, std::string> _gpg_id_boxes;
|
std::map<QCheckBox*, std::string> _gpg_id_boxes;
|
||||||
|
@ -215,9 +215,6 @@
|
|||||||
<verstretch>20</verstretch>
|
<verstretch>20</verstretch>
|
||||||
</sizepolicy>
|
</sizepolicy>
|
||||||
</property>
|
</property>
|
||||||
<property name="toolTip">
|
|
||||||
<string>Run Email program</string>
|
|
||||||
</property>
|
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
<iconset resource="../images.qrc">
|
<iconset resource="../images.qrc">
|
||||||
<normaloff>:/images/ledon1.png</normaloff>:/images/ledon1.png</iconset>
|
<normaloff>:/images/ledon1.png</normaloff>:/images/ledon1.png</iconset>
|
||||||
@ -272,21 +269,30 @@
|
|||||||
<item>
|
<item>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="friendCertCleanButton">
|
<spacer name="verticalSpacer_3">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>40</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="friendCertCleanLabel">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||||
<horstretch>20</horstretch>
|
<horstretch>20</horstretch>
|
||||||
<verstretch>20</verstretch>
|
<verstretch>20</verstretch>
|
||||||
</sizepolicy>
|
</sizepolicy>
|
||||||
</property>
|
</property>
|
||||||
<property name="toolTip">
|
<property name="pixmap">
|
||||||
<string>Clean certificate</string>
|
<pixmap resource="../images.qrc">:/images/accepted16.png</pixmap>
|
||||||
</property>
|
</property>
|
||||||
<property name="icon">
|
<property name="scaledContents">
|
||||||
<iconset resource="../images.qrc">
|
|
||||||
<normaloff>:/images/accepted16.png</normaloff>:/images/accepted16.png</iconset>
|
|
||||||
</property>
|
|
||||||
<property name="flat">
|
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
|
Loading…
Reference in New Issue
Block a user