Changed the RetroShare link format to an internet conform style.

retroshare://file?name=&size=&hash=
retroshare://person?name=&hash=
We can extend this very easy. QUrl can build and parse it.
The paste of the old RetroShare links is still working.

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@3818 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
thunder2 2010-11-18 16:31:44 +00:00
parent d8da5082a1
commit e82fab4ba4
5 changed files with 289 additions and 214 deletions

View file

@ -159,7 +159,7 @@ MainWindow::MainWindow(QWidget* parent, Qt::WFlags flags)
setWindowTitle(tr("RetroShare %1 a secure decentralised communication platform").arg(retroshareVersion()));
/* add url handler for RetroShare links */
QDesktopServices::setUrlHandler("retroshare", this, "linkActivated");
QDesktopServices::setUrlHandler(RSLINK_SCHEME, this, "linkActivated");
// Setting icons
this->setWindowIcon(QIcon(QString::fromUtf8(":/images/rstray3.png")));
@ -1190,5 +1190,22 @@ void MainWindow::statusChangedComboBox(int index)
void MainWindow::linkActivated(const QUrl &url)
{
RetroShareLink::processUrl(url, RSLINK_PROCESS_NOTIFY_ALL);
RetroShareLink link(url);
if (link.valid() == false) {
// QUrl can't handle the old RetroShare link format properly
if (url.host().isEmpty()) {
QMessageBox mb("RetroShare", tr("It seems to be an old RetroShare link. Please use copy instead."), QMessageBox::Critical, QMessageBox::Ok, 0, 0);
mb.setWindowIcon(QIcon(":/images/rstray3.png"));
mb.exec();
return;
}
QMessageBox mb("RetroShare", tr("The file link is malformed."), QMessageBox::Critical, QMessageBox::Ok, 0, 0);
mb.setWindowIcon(QIcon(":/images/rstray3.png"));
mb.exec();
return;
}
link.process(RSLINK_PROCESS_NOTIFY_ERROR | RSLINK_PROCESS_NOTIFY_SUCCESS);
}