diff --git a/retroshare-gui/src/gui/HomePage.cpp b/retroshare-gui/src/gui/HomePage.cpp index f5d7a5719..3268b4e79 100644 --- a/retroshare-gui/src/gui/HomePage.cpp +++ b/retroshare-gui/src/gui/HomePage.cpp @@ -80,25 +80,37 @@ HomePage::HomePage(QWidget *parent) : if(!RsAccounts::isHiddenNode()) { + mIncludeLocIPact = new QAction(QIcon(), tr("Include current local IP"),this); + connect(mIncludeLocIPact, SIGNAL(triggered()), this, SLOT(updateOwnCert())); + mIncludeLocIPact->setCheckable(true); + mIncludeLocIPact->setChecked(true); + menu->addAction(mIncludeLocIPact); + + mIncludeExtIPact = new QAction(QIcon(), tr("Include current external IP"),this); + connect(mIncludeExtIPact, SIGNAL(triggered()), this, SLOT(updateOwnCert())); + mIncludeExtIPact->setCheckable(true); + mIncludeExtIPact->setChecked(true); + menu->addAction(mIncludeExtIPact); + mIncludeDNSact = new QAction(QIcon(), tr("Include my DNS"),this); connect(mIncludeDNSact, SIGNAL(triggered()), this, SLOT(updateOwnCert())); mIncludeDNSact->setCheckable(true); mIncludeDNSact->setChecked(true); menu->addAction(mIncludeDNSact); - mIncludeIPsAct = new QAction(QIcon(), tr("Include all your known IPs"),this); - connect(mIncludeIPsAct, SIGNAL(triggered()), this, SLOT(updateOwnCert())); - mIncludeIPsAct->setCheckable(true); - mIncludeIPsAct->setChecked(false); - menu->addAction(mIncludeIPsAct); + mIncludeIPHistoryact = new QAction(QIcon(), tr("Include all IPs history"),this); + connect(mIncludeIPHistoryact, SIGNAL(triggered()), this, SLOT(updateOwnCert())); + mIncludeIPHistoryact->setCheckable(true); + mIncludeIPHistoryact->setChecked(false); + menu->addAction(mIncludeIPHistoryact); } - mUseOldFormatAct = new QAction(QIcon(), tr("Use old certificate format"),this); - mUseOldFormatAct->setToolTip(tr("Displays the certificate format used up to version 0.6.5\nOld Retroshare nodes will not understand the\nnew short format")); - connect(mUseOldFormatAct, SIGNAL(triggered()), this, SLOT(updateOwnCert())); - mUseOldFormatAct->setCheckable(true); - mUseOldFormatAct->setChecked(false); - menu->addAction(mUseOldFormatAct); + mUseOldFormatact = new QAction(QIcon(), tr("Use old certificate format"),this); + mUseOldFormatact->setToolTip(tr("Displays the certificate format used up to version 0.6.5\nOld Retroshare nodes will not understand the\nnew short format")); + connect(mUseOldFormatact, SIGNAL(triggered()), this, SLOT(updateOwnCert())); + mUseOldFormatact->setCheckable(true); + mUseOldFormatact->setChecked(false); + menu->addAction(mUseOldFormatact); ui->shareButton->setMenu(menu); @@ -193,9 +205,8 @@ HomePage::~HomePage() delete ui; } -void HomePage::updateOwnCert() +void HomePage::getOwnCert(QString& invite,QString& description) const { - bool include_extra_locators = mIncludeIPsAct->isChecked(); RsPeerDetails detail; @@ -205,23 +216,47 @@ void HomePage::updateOwnCert() return ; } - QString invite ; - RetroshareInviteFlags invite_flags = RsPeers::defaultCertificateFlags; + RetroshareInviteFlags invite_flags = RetroshareInviteFlags::NOTHING; - if(mIncludeIPsAct->isChecked()) + if(mIncludeLocIPact->isChecked()) + invite_flags |= RetroshareInviteFlags::CURRENT_LOCAL_IP; + + if(mIncludeExtIPact->isChecked()) + invite_flags |= RetroshareInviteFlags::CURRENT_EXTERNAL_IP; + + if(mIncludeDNSact->isChecked()) + invite_flags |= RetroshareInviteFlags::DNS; + + if(mIncludeIPHistoryact->isChecked()) invite_flags |= RetroshareInviteFlags::FULL_IP_HISTORY; - if(!mUseOldFormatAct->isChecked()) + if(!mUseOldFormatact->isChecked()) { std::string short_invite; rsPeers->getShortInvite(short_invite,rsPeers->getOwnId(),invite_flags | RetroshareInviteFlags::RADIX_FORMAT); + invite = QString::fromStdString(short_invite); + } + else + invite = QString::fromStdString(rsPeers->GetRetroshareInvite(detail.id,invite_flags)); + bool include_extra_locators = mIncludeIPHistoryact->isChecked(); + description = ConfCertDialog::getCertificateDescription(detail,false,!mUseOldFormatact->isChecked(),include_extra_locators); +} + +void HomePage::updateOwnCert() +{ + QString certificate, description; + + getOwnCert(certificate,description); + + if(!mUseOldFormatact->isChecked()) // in this case we have to split the cert for a bettr display + { QString S; QString txt; - for(uint32_t i=0;iGetRetroshareInvite(detail.id,invite_flags)); - - ui->retroshareid->setText("\n"+invite+"\n"); - - QString description = ConfCertDialog::getCertificateDescription(detail,false,!mUseOldFormatAct->isChecked(),include_extra_locators); + ui->retroshareid->setText("\n"+certificate+"\n"); ui->retroshareid->setToolTip(description); } diff --git a/retroshare-gui/src/gui/HomePage.h b/retroshare-gui/src/gui/HomePage.h index c5f06f33b..a20f07863 100644 --- a/retroshare-gui/src/gui/HomePage.h +++ b/retroshare-gui/src/gui/HomePage.h @@ -46,6 +46,10 @@ public: virtual QString pageName() const { return tr("Home") ; } //MainPage virtual QString helpText() const { return ""; } //MainPage + // Returns the certificate along with its description using current options. + + void getOwnCert(QString& invite,QString& description) const; + private slots: #ifdef DEAD_CODE void certContextMenu(QPoint); @@ -64,8 +68,10 @@ private: Ui::HomePage *ui; QAction *mIncludeDNSact; - QAction *mIncludeIPsAct; - QAction *mUseOldFormatAct; + QAction *mIncludeIPHistoryact; + QAction *mIncludeExtIPact; + QAction *mIncludeLocIPact; + QAction *mUseOldFormatact; RsEventsHandlerId_t mEventHandlerId; diff --git a/retroshare-gui/src/gui/MainWindow.cpp b/retroshare-gui/src/gui/MainWindow.cpp index 207fc5130..16af6710a 100644 --- a/retroshare-gui/src/gui/MainWindow.cpp +++ b/retroshare-gui/src/gui/MainWindow.cpp @@ -1083,7 +1083,9 @@ void SetForegroundWindowInternal(HWND hWnd) return _instance->gxsforumDialog; case Posted: return _instance->postedDialog; - } + case Home: + return _instance->homePage; + } return NULL; } diff --git a/retroshare-gui/src/gui/MainWindow.h b/retroshare-gui/src/gui/MainWindow.h index b4f3cccd5..23b70e66f 100644 --- a/retroshare-gui/src/gui/MainWindow.h +++ b/retroshare-gui/src/gui/MainWindow.h @@ -100,9 +100,10 @@ public: Channels = 6, /** Channels page. */ Forums = 7, /** Forums page. */ Search = 8, /** Search page. */ - Posted = 11, /** Posted links */ - People = 12, /** People page. */ - Options = 13 /** People page. */ + Posted = 11, /** Posted links */ + People = 12, /** People page. */ + Options = 13, /** People page. */ + Home = 14 /** Home page. */ }; diff --git a/retroshare-gui/src/gui/RetroShareLink.cpp b/retroshare-gui/src/gui/RetroShareLink.cpp index d34871104..524f3c757 100644 --- a/retroshare-gui/src/gui/RetroShareLink.cpp +++ b/retroshare-gui/src/gui/RetroShareLink.cpp @@ -22,6 +22,7 @@ #include "ChatLobbyWidget.h" #include "MainWindow.h" +#include "HomePage.h" #include "chat/ChatDialog.h" #include "common/PeerDefs.h" #include "common/RsCollection.h" @@ -551,32 +552,41 @@ RetroShareLink RetroShareLink::createMessage(const RsGxsId& peerId, const QStrin RetroShareLink RetroShareLink::createCertificate(const RsPeerId& ssl_id) { - RetroShareLink link; - link.clear(); + RetroShareLink link; + link.clear(); #ifndef RS_NO_WARN_CPP #pragma message("csoler 2012-08-14: This is baaaaaad code") #endif - // - we should not need to parse and re-read a cert in old format. - // - RsPeerDetails detail; - if (rsPeers->getPeerDetails(ssl_id, detail) == false) { - std::cerr << "RetroShareLink::createPerson() Couldn't find peer id " << ssl_id << std::endl; - } else { + // - we should not need to parse and re-read a cert in old format. + // + RsPeerDetails detail; + if (rsPeers->getPeerDetails(ssl_id, detail) == false) + std::cerr << "RetroShareLink::createPerson() Couldn't find peer id " << ssl_id << std::endl; + else + { + link._type = TYPE_CERTIFICATE; - link._type = TYPE_CERTIFICATE; - link._radix = QString::fromUtf8(rsPeers->GetRetroshareInvite(ssl_id).c_str()); - link._name = QString::fromUtf8(detail.name.c_str()); - link._location = QString::fromUtf8(detail.location.c_str()); - link._radix.replace("\n",""); + if(rsPeers->getOwnId() == ssl_id) // in this case, use application-wide parameters set in HomePage + { + QString invite,description; + static_cast(MainWindow::getPage(MainWindow::Home))->getOwnCert(invite,description); + link._radix = invite; + } + else + link._radix = QString::fromUtf8(rsPeers->GetRetroshareInvite(ssl_id).c_str()); - std::cerr << "Found radix = " << link._radix.toStdString() << std::endl; - } + link._name = QString::fromUtf8(detail.name.c_str()); + link._location = QString::fromUtf8(detail.location.c_str()); + link._radix.replace("\n",""); - link.check(); + std::cerr << "Found radix = " << link._radix.toStdString() << std::endl; + } - return link; + link.check(); + + return link; } RetroShareLink RetroShareLink::createUnknownSslCertificate(const RsPeerId& sslId, const RsPgpId& gpgId) {