diff --git a/retroshare-gui/src/gui/connect/AddFriendDialog.cpp b/retroshare-gui/src/gui/connect/AddFriendDialog.cpp index a99e7fee4..4f627e0ee 100644 --- a/retroshare-gui/src/gui/connect/AddFriendDialog.cpp +++ b/retroshare-gui/src/gui/connect/AddFriendDialog.cpp @@ -28,6 +28,7 @@ #include +//============================================================================ /** Default constructor */ AddFriendDialog::AddFriendDialog(NetworkDialog *cd, QWidget *parent, Qt::WFlags flags) : QDialog(parent, flags), cDialog(cd) @@ -42,68 +43,101 @@ AddFriendDialog::AddFriendDialog(NetworkDialog *cd, QWidget *parent, Qt::WFlags connect(ui.fileButton, SIGNAL(clicked()), this, SLOT(filebutton())); connect(ui.doneButton, SIGNAL(clicked()), this, SLOT(donebutton())); + //maybe, it was already set somewere, but just in case. This settings should + //prevent some bugs... + ui.emailText->setLineWrapMode(QTextEdit::NoWrap); + ui.emailText->setAcceptRichText(false); + //setFixedSize(QSize(434, 462)); } +//============================================================================ + void AddFriendDialog::donebutton() { - /* something complicated ;) */ - std::string id; + std::string id; + std::string certstr; - /* get the text from the window */ - /* load into string */ - std::string certstr = ui.emailText->toPlainText().toStdString(); + QString fn = ui.fileSelectEdit->text() ; + if (fn.isEmpty()) + { + //load certificate from text box + certstr = ui.emailText->toPlainText().toStdString(); - /* ask retroshare to load */ - if ((cDialog) && (rsPeers->LoadCertificateFromString(certstr, id))) - { - close(); - cDialog->showpeerdetails(id); - } - else - { - /* error message */ - int ret = QMessageBox::warning(this, tr("RetroShare"), - tr("Certificate Load Failed"), - QMessageBox::Ok, QMessageBox::Ok); - } + if ((cDialog) && (rsPeers->LoadCertificateFromString(certstr, id))) + { + close(); + cDialog->showpeerdetails(id); + } + else + { + /* error message */ + QMessageBox::warning(this, tr("RetroShare"), + tr("Certificate Load Failed"), + QMessageBox::Ok, QMessageBox::Ok); + + close(); + return; + } + } + else + { + //=== try to load selected certificate file + if (QFile::exists(fn)) + { + std::string fnstr = fn.toStdString(); + if ( (cDialog) && (rsPeers->LoadCertificateFromFile(fnstr, id)) ) + { + close(); + cDialog->showpeerdetails(id); + } + else + { + QString mbxmess = + QString(tr("Certificate Load Failed:something is wrong with %1 ")) + .arg(fn); + + QMessageBox::warning(this, tr("RetroShare"), + mbxmess, QMessageBox::Ok, QMessageBox::Ok); + close(); + return; + } + } + else + { + QString mbxmess = + QString(tr("Certificate Load Failed:file %1 not found")) + .arg(fn); + + QMessageBox::warning(this, tr("RetroShare"), + mbxmess, QMessageBox::Ok, QMessageBox::Ok); + + close(); + return; + } + } } +//============================================================================ void AddFriendDialog::afcancelbutton() { close(); } +//============================================================================ void AddFriendDialog::filebutton() { + QString fileName = + QFileDialog::getOpenFileName(this, tr("Select Certificate"), + "", tr("Certificates (*.pqi *.pem)")); - /* show file dialog, - * load file into screen, - * push done button! - */ - std::string id; - if (cDialog) - { - id = cDialog->loadneighbour(); - } - - /* call make Friend */ - if (id != "") - { - close(); - cDialog->showpeerdetails(id); - } - else - { - /* error message */ - int ret = QMessageBox::warning(this, tr("RetroShare"), - tr("Certificate Load Failed"), - QMessageBox::Ok, QMessageBox::Ok); - } + if (!fileName.isNull()) + ui.fileSelectEdit->setText(fileName); } +//============================================================================ void AddFriendDialog::setInfo(std::string invite) { diff --git a/retroshare-gui/src/gui/connect/AddFriendDialog.ui b/retroshare-gui/src/gui/connect/AddFriendDialog.ui index 7c0c23efc..fee93a0c9 100644 --- a/retroshare-gui/src/gui/connect/AddFriendDialog.ui +++ b/retroshare-gui/src/gui/connect/AddFriendDialog.ui @@ -5,111 +5,28 @@ 0 0 - 539 - 402 + 510 + 350 Add a Friend - - - 9 - - - 6 - - - - - - Courier New - 10 - false - - - - false - - - <!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:'Courier New'; font-size:10pt; font-weight:400; font-style:normal;"> -<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans Serif'; font-size:9pt;"></p></body></html> - - - false - - - - - - - - 77 - 0 - - - - Load From File - - - - - - - - 77 - 0 - - - - Cancel - - - - - - - - 77 - 0 - - - - Done - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - + + + + + 0 + 0 + + + + + 0 + 74 + + 16777215 @@ -535,13 +452,13 @@ p, li { white-space: pre-wrap; } background-image: url(:/images/addfriendlabel.png) - <html><head><meta name="qrichtext" content="1" /><style type="text/css"> + <!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 Serif'; font-size:9pt; 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;"><span style=" font-size:16pt; font-weight:600; color:#32cd32;">Add a new Friend</span></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">To add a new Friend, cut and paste their email </p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">invitation into the box below, and click done.</p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"> </p></body></html> +</style></head><body style=" font-family:'Sans Serif'; 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; font-size:9pt;"><span style=" font-size:16pt; font-weight:600; color:#32cd32;">Add a new Friend</span> </p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:9pt;"> </p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:9pt;"> </p></body></html> Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter @@ -551,13 +468,143 @@ p, li { white-space: pre-wrap; } + + + + + + <!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 Serif'; 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;"><span style=" font-size:12pt;">To add a new friend, specify path to their sertificate file in the box below and click "Done".</span></p></body></html> + + + true + + + + + + + + + + 12 + + + + + + + + + 77 + 0 + + + + Load... + + + + + + + + + + + + + <!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 Serif'; 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;"><span style=" font-size:12pt;">Alternative way, you can copy </span><span style=" font-size:12pt;">and paste your friend's XPGP certificate into the box below. </span></p></body></html> + + + true + + + + + + + + Liberation Mono + + + + false + + + <!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:'Liberation Mono'; 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; font-family:'Courier New';"><span style=" font-family:'Sans Serif'; font-size:11pt;">-----BEGIN XPGP CERTIFICATE-----</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans Serif'; font-size:11pt;">MIICxQIBADCCAUkCAQAwHhcNMDkwMjI4MTgzODIyWhcNMTQwMjI3MTgzODIyWjCC</p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans Serif'; font-size:11pt;">ASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBANuLs8PuMBipmcrNK/Xd8u/Y</p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans Serif'; font-size:11pt;">9/gY5+F/M3OZ7O+UtNI72WpY61XX2P8M/0wyC0oDAzHv/wPH/lXphysBsF13ItC4</p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans Serif'; font-size:11pt;"></p></body></html> + + + false + + + + + + + + + + + + 77 + 0 + + + + Cancel + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 77 + 0 + + + + Done + + + + + fileButton doneButton afcancelButton - emailText diff --git a/retroshare-gui/src/gui/connect/InviteDialog.cpp b/retroshare-gui/src/gui/connect/InviteDialog.cpp index ad8c15733..7c78cdd12 100644 --- a/retroshare-gui/src/gui/connect/InviteDialog.cpp +++ b/retroshare-gui/src/gui/connect/InviteDialog.cpp @@ -23,7 +23,9 @@ #include "rsiface/rsiface.h" #include "rsiface/rspeers.h" -#include +//#include + +#include /** Default constructor */ InviteDialog::InviteDialog(QWidget *parent, Qt::WFlags flags) @@ -35,71 +37,11 @@ InviteDialog::InviteDialog(QWidget *parent, Qt::WFlags flags) /* add a Background image for Invite a Friend Label */ //WidgetBackgroundImage::setBackgroundImage(ui.invitefriendLabel, ":images/new-contact.png", WidgetBackgroundImage::AdjustHeight); - connect(ui.cancelButton, SIGNAL(clicked()), this, SLOT(cancelbutton())); - connect(ui.emailButton, SIGNAL(clicked()), this, SLOT(emailbutton())); - connect(ui.doneButton, SIGNAL(clicked()), this, SLOT(closebutton())); connect(ui.sCertButton, SIGNAL(clicked()), this, SLOT(savecertbutton())); //setFixedSize(QSize(434, 462)); } -void InviteDialog::closebutton() -{ - close(); -} - - -void InviteDialog::cancelbutton() -{ - close(); -} - - /* for Win32 only */ -#if defined(Q_OS_WIN) -#include - -#endif - -void InviteDialog::emailbutton() -{ - /* for Win32 only */ -#if defined(Q_OS_WIN) - - std::string mailstr = "mailto:"; - - mailstr += "?subject=RetroShare Invite"; - mailstr += "&body="; - mailstr += ui.emailText->toPlainText().toStdString(); - - /* search and replace the end of lines with: "%0D%0A" */ - - std::cerr << "MAIL STRING:" << mailstr.c_str() << std::endl; - - size_t loc; - while((loc = mailstr.find("\n")) != mailstr.npos) - { - /* sdfkasdflkjh */ - mailstr.replace(loc, 1, "%0D%0A"); - } - - HINSTANCE hInst = ShellExecuteA(0, - "open", - mailstr.c_str(), - NULL, - NULL, - SW_SHOW); - - if(reinterpret_cast(hInst) <= 32) - { - /* error */ - std::cerr << "ShellExecute Error: " << reinterpret_cast(hInst); - std::cerr << std::endl; - } - -#endif -} - - void InviteDialog::setInfo(std::string invite) { // ui.emailText->setCurrentFont(QFont("TypeWriter",10)) ; @@ -110,8 +52,24 @@ void InviteDialog::setInfo(std::string invite) void InviteDialog::savecertbutton(void) { - - QString qdir = QFileDialog::getSaveFileName(this, "Please choose a filename", QDir::homePath(), "RetroShare Certificate (*.pqi)"); - rsPeers->SaveCertificateToFile(rsPeers->getOwnId(), qdir.toStdString()); // save to file + QString qdir = QFileDialog::getSaveFileName(this, + "Please choose a filename", + QDir::homePath(), + "RetroShare Certificate (*.pqi)"); + + if ( rsPeers->SaveCertificateToFile(rsPeers->getOwnId(), qdir.toStdString()) ) + { + QMessageBox::information(this, tr("RetroShare"), + tr("Certificate file successfully created"), + QMessageBox::Ok, QMessageBox::Ok); + //close the window after messagebox finished + close(); + } + else + { + QMessageBox::information(this, tr("RetroShare"), + tr("Sorry, certificate file creation failed"), + QMessageBox::Ok, QMessageBox::Ok); + } } diff --git a/retroshare-gui/src/gui/connect/InviteDialog.h b/retroshare-gui/src/gui/connect/InviteDialog.h index 2629442c0..f11b68fae 100644 --- a/retroshare-gui/src/gui/connect/InviteDialog.h +++ b/retroshare-gui/src/gui/connect/InviteDialog.h @@ -43,9 +43,6 @@ public slots: protected: private slots: - void closebutton(); - void cancelbutton(); - void emailbutton(); /// saves your certificate to file to send to friends void savecertbutton(); diff --git a/retroshare-gui/src/gui/connect/InviteDialog.ui b/retroshare-gui/src/gui/connect/InviteDialog.ui index 8c277b539..e0b048a6f 100644 --- a/retroshare-gui/src/gui/connect/InviteDialog.ui +++ b/retroshare-gui/src/gui/connect/InviteDialog.ui @@ -6,57 +6,14 @@ 0 0 577 - 554 + 273 Invite a Friend - - - 9 - - - 6 - - - - - - 77 - 0 - - - - Launch Email - - - - - - - - Courier New - 10 - false - - - - true - - - <!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:'Courier New'; font-size:10pt; font-weight:400; font-style:normal;"> -<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Arial'; font-size:8pt;"></p></body></html> - - - false - - - - + + @@ -483,99 +440,78 @@ p, li { white-space: pre-wrap; } background-image: url(:/images/invitefriendlabel.png); - <html><head><meta name="qrichtext" content="1" /><style type="text/css"> + <!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 Serif'; font-size:9pt; 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; font-family:'Arial'; font-size:8pt;"><span style=" font-size:16pt; font-weight:600; color:#32cd32;">Invite a Friend</span><br /><span style=" font-size:10pt;">To Invite your friends to join you with Retroshare: </span></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Arial'; font-size:10pt;">Cut and paste the text below into an email.</p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Arial'; font-size:10pt;">and send it to all your friends!</p></body></html> +</style></head><body style=" font-family:'Sans Serif'; 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; font-family:'Arial'; font-size:8pt;"><span style=" font-size:16pt; font-weight:600; color:#32cd32;">Invite a Friend</span><br /><span style=" font-size:10pt;">To invite your friends to your retsoshare network you have to provide them your key. Just send them the text below</span></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Arial';"></p></body></html> Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + true + 100 - - - - - 77 - 0 - + + + + + Courier New + 10 + false + - - Cancel + + true + + + <!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:'Courier New'; font-size:10pt; font-weight:400; font-style:normal;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Arial'; font-size:8pt;"></p></body></html> + + + false - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - 77 - 0 - - - - Done - - - - - - - Save Cert To File - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - + + + + + + Alternatively, you can save the certificate information to a file. Please, press button to do this. + + + true + + + + + + + + 0 + 0 + + + + Save Cert To File + + + + - emailButton - doneButton - cancelButton emailText