Adding a link from the browser now starts RetroShare when it is not running.

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@4157 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
thunder2 2011-04-14 23:58:30 +00:00
parent 20fa00c40e
commit 099cc6c11c
5 changed files with 19 additions and 17 deletions

View File

@ -150,6 +150,8 @@ public slots:
void updateTransfers(int count); void updateTransfers(int count);
void privateChatChanged(int list, int type); void privateChatChanged(int list, int type);
void linkActivated(const QUrl &url);
protected: protected:
/** Default Constructor */ /** Default Constructor */
MainWindow(QWidget *parent = 0, Qt::WFlags flags = 0); MainWindow(QWidget *parent = 0, Qt::WFlags flags = 0);
@ -202,8 +204,6 @@ private slots:
void on_actionQuick_Start_Wizard_activated(); void on_actionQuick_Start_Wizard_activated();
void linkActivated(const QUrl &url);
private: private:
/** Create the actions on the tray menu or menubar */ /** Create the actions on the tray menu or menubar */

View File

@ -500,8 +500,8 @@ bool RshareSettings::getRetroShareProtocol()
} }
#else #else
/* Platforms other than windows aren't supported yet */ /* Platforms other than windows aren't supported yet */
return false;
#endif #endif
return false;
} }
/** Register retroshare:// as protocl */ /** Register retroshare:// as protocl */

View File

@ -43,6 +43,7 @@
#include "idle/idle.h" #include "idle/idle.h"
#include "gui/common/Emoticons.h" #include "gui/common/Emoticons.h"
#include "util/EventReceiver.h" #include "util/EventReceiver.h"
#include "gui/RetroShareLink.h"
/*** WINDOWS DON'T LIKE THIS - REDEFINES VER numbers. /*** WINDOWS DON'T LIKE THIS - REDEFINES VER numbers.
#include <gui/qskinobject/qskinobject.h> #include <gui/qskinobject/qskinobject.h>
@ -108,14 +109,17 @@ int main(int argc, char *argv[])
Rshare rshare(args, argc, argv, Rshare rshare(args, argc, argv,
QString::fromStdString(RsInit::RsConfigDirectory())); QString::fromStdString(RsInit::RsConfigDirectory()));
std::string link = RsInit::getRetroShareLink(); std::string url = RsInit::getRetroShareLink();
if (!link.empty()) { if (!url.empty()) {
/* start with RetroShare link */ /* start with RetroShare link */
EventReceiver eventReceiver; EventReceiver eventReceiver;
eventReceiver.sendRetroShareLink(QString::fromStdString(link)); if (eventReceiver.sendRetroShareLink(QString::fromStdString(url))) {
return 0; return 0;
} }
/* Start RetroShare */
}
QSplashScreen splashScreen(QPixmap(":/images/splash.png")/* , Qt::WindowStaysOnTopHint*/); QSplashScreen splashScreen(QPixmap(":/images/splash.png")/* , Qt::WindowStaysOnTopHint*/);
switch (initResult) { switch (initResult) {
@ -247,6 +251,14 @@ int main(int argc, char *argv[])
} }
} }
if (!url.empty()) {
/* Now use link from the command line, because no RetroShare was running */
RetroShareLink link(QString::fromStdString(url));
if (link.valid()) {
w->linkActivated(link.toUrl());
}
}
// I'm using a signal to transfer the hashing info to the mainwindow, because Qt schedules signals properly to // I'm using a signal to transfer the hashing info to the mainwindow, because Qt schedules signals properly to
// avoid clashes between infos from threads. // avoid clashes between infos from threads.
// //

View File

@ -91,18 +91,10 @@ bool EventReceiver::start()
return result; return result;
} }
void EventReceiver::showNoRunningInstanceFound()
{
QMessageBox mb(QMessageBox::Critical, "RetroShare", QObject::tr("No running instance of RetroShare found."), QMessageBox::Ok);
mb.setWindowIcon(QIcon(":/images/rstray3.png"));
mb.exec();
}
bool EventReceiver::sendRetroShareLink(const QString& link) bool EventReceiver::sendRetroShareLink(const QString& link)
{ {
if (!sharedMMemory.attach()) { if (!sharedMMemory.attach()) {
/* No running instance found */ /* No running instance found */
showNoRunningInstanceFound();
return false; return false;
} }
@ -122,7 +114,6 @@ bool EventReceiver::sendRetroShareLink(const QString& link)
SendMessage((HWND) info->wid, WM_COPYDATA, (WPARAM) 0, (LPARAM) (PCOPYDATASTRUCT) &send); SendMessage((HWND) info->wid, WM_COPYDATA, (WPARAM) 0, (LPARAM) (PCOPYDATASTRUCT) &send);
} else { } else {
showNoRunningInstanceFound();
result = false; result = false;
} }
#else #else

View File

@ -47,7 +47,6 @@ signals:
void linkReceived(const QUrl& url); void linkReceived(const QUrl& url);
private: private:
void showNoRunningInstanceFound();
void received(const QString& url); void received(const QString& url);
#ifdef WINDOWS_SYS #ifdef WINDOWS_SYS