added warnign when openning http/https links using system services

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@6226 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
csoler 2013-03-15 23:08:54 +00:00
parent f1e23599da
commit ae130674ba
3 changed files with 29 additions and 5 deletions

View File

@ -205,7 +205,9 @@ MainWindow::MainWindow(QWidget* parent, Qt::WFlags flags)
}
/* add url handler for RetroShare links */
QDesktopServices::setUrlHandler(RSLINK_SCHEME, this, "linkActivated");
QDesktopServices::setUrlHandler(RSLINK_SCHEME, this, "retroshareLinkActivated");
QDesktopServices::setUrlHandler("http", this, "externalLinkActivated");
QDesktopServices::setUrlHandler("https", this, "externalLinkActivated");
// Setting icons
this->setWindowIcon(QIcon(QString::fromUtf8(":/images/rstray3.png")));
@ -1278,8 +1280,29 @@ void MainWindow::statusChangedComboBox(int index)
/* no object known */
setStatus(NULL, statusComboBox->itemData(index, Qt::UserRole).toInt());
}
void MainWindow::externalLinkActivated(const QUrl &url)
{
static bool already_warned = false ;
void MainWindow::linkActivated(const QUrl &url)
if(!already_warned)
{
QMessageBox mb(QObject::tr("Confirmation"), QObject::tr("Do you want this link to be handled by your system?")+"<br/><br/>"+ url.toString()+"<br/><br/>"+tr("Make sure this link has not been forged to drag you to a malicious website."), QMessageBox::Question, QMessageBox::Yes,QMessageBox::No, 0);
mb.setWindowIcon(QIcon(QString::fromUtf8(":/images/rstray3.png")));
QCheckBox *checkbox = new QCheckBox("Don't ask me again") ;
mb.layout()->addWidget(checkbox) ;
int res = mb.exec() ;
if (res == QMessageBox::No)
return ;
else if(checkbox->isChecked())
already_warned = true ;
}
QDesktopServices::openUrl(url) ;
}
void MainWindow::retroshareLinkActivated(const QUrl &url)
{
RetroShareLink link(url);

View File

@ -161,7 +161,8 @@ public slots:
void displayDiskSpaceWarning(int loc,int size_limit_mb) ;
void checkAndSetIdle(int idleTime);
void linkActivated(const QUrl &url);
void retroshareLinkActivated(const QUrl &url);
void externalLinkActivated(const QUrl &url);
protected:
/** Default Constructor */

View File

@ -304,7 +304,7 @@ int main(int argc, char *argv[])
/* Create event receiver */
eventReceiver = new EventReceiver;
if (eventReceiver->start()) {
QObject::connect(eventReceiver, SIGNAL(linkReceived(const QUrl&)), w, SLOT(linkActivated(const QUrl&)));
QObject::connect(eventReceiver, SIGNAL(linkReceived(const QUrl&)), w, SLOT(retroshareLinkActivated(const QUrl&)));
}
}
@ -312,7 +312,7 @@ int main(int argc, char *argv[])
/* Now use link from the command line, because no RetroShare was running */
RetroShareLink link(QString::fromStdString(url));
if (link.valid()) {
w->linkActivated(link.toUrl());
w->retroshareLinkActivated(link.toUrl());
}
}