mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-01-13 00:19:30 -05:00
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:
parent
f1e23599da
commit
ae130674ba
@ -205,7 +205,9 @@ MainWindow::MainWindow(QWidget* parent, Qt::WFlags flags)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* add url handler for RetroShare links */
|
/* 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
|
// Setting icons
|
||||||
this->setWindowIcon(QIcon(QString::fromUtf8(":/images/rstray3.png")));
|
this->setWindowIcon(QIcon(QString::fromUtf8(":/images/rstray3.png")));
|
||||||
@ -1278,8 +1280,29 @@ void MainWindow::statusChangedComboBox(int index)
|
|||||||
/* no object known */
|
/* no object known */
|
||||||
setStatus(NULL, statusComboBox->itemData(index, Qt::UserRole).toInt());
|
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);
|
RetroShareLink link(url);
|
||||||
|
|
||||||
|
@ -161,7 +161,8 @@ public slots:
|
|||||||
void displayDiskSpaceWarning(int loc,int size_limit_mb) ;
|
void displayDiskSpaceWarning(int loc,int size_limit_mb) ;
|
||||||
void checkAndSetIdle(int idleTime);
|
void checkAndSetIdle(int idleTime);
|
||||||
|
|
||||||
void linkActivated(const QUrl &url);
|
void retroshareLinkActivated(const QUrl &url);
|
||||||
|
void externalLinkActivated(const QUrl &url);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/** Default Constructor */
|
/** Default Constructor */
|
||||||
|
@ -304,7 +304,7 @@ int main(int argc, char *argv[])
|
|||||||
/* Create event receiver */
|
/* Create event receiver */
|
||||||
eventReceiver = new EventReceiver;
|
eventReceiver = new EventReceiver;
|
||||||
if (eventReceiver->start()) {
|
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 */
|
/* Now use link from the command line, because no RetroShare was running */
|
||||||
RetroShareLink link(QString::fromStdString(url));
|
RetroShareLink link(QString::fromStdString(url));
|
||||||
if (link.valid()) {
|
if (link.valid()) {
|
||||||
w->linkActivated(link.toUrl());
|
w->retroshareLinkActivated(link.toUrl());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user