diff --git a/retroshare-gui/src/gui/MainWindow.h b/retroshare-gui/src/gui/MainWindow.h index 4ec7838a4..a9d6fa761 100644 --- a/retroshare-gui/src/gui/MainWindow.h +++ b/retroshare-gui/src/gui/MainWindow.h @@ -150,6 +150,8 @@ public slots: void updateTransfers(int count); void privateChatChanged(int list, int type); + void linkActivated(const QUrl &url); + protected: /** Default Constructor */ MainWindow(QWidget *parent = 0, Qt::WFlags flags = 0); @@ -202,8 +204,6 @@ private slots: void on_actionQuick_Start_Wizard_activated(); - void linkActivated(const QUrl &url); - private: /** Create the actions on the tray menu or menubar */ diff --git a/retroshare-gui/src/gui/settings/rsharesettings.cpp b/retroshare-gui/src/gui/settings/rsharesettings.cpp index f13f2a182..b3c291a54 100644 --- a/retroshare-gui/src/gui/settings/rsharesettings.cpp +++ b/retroshare-gui/src/gui/settings/rsharesettings.cpp @@ -500,8 +500,8 @@ bool RshareSettings::getRetroShareProtocol() } #else /* Platforms other than windows aren't supported yet */ - return false; #endif + return false; } /** Register retroshare:// as protocl */ diff --git a/retroshare-gui/src/main.cpp b/retroshare-gui/src/main.cpp index 4d1b6f1c5..705ff56ba 100644 --- a/retroshare-gui/src/main.cpp +++ b/retroshare-gui/src/main.cpp @@ -43,6 +43,7 @@ #include "idle/idle.h" #include "gui/common/Emoticons.h" #include "util/EventReceiver.h" +#include "gui/RetroShareLink.h" /*** WINDOWS DON'T LIKE THIS - REDEFINES VER numbers. #include @@ -108,12 +109,15 @@ int main(int argc, char *argv[]) Rshare rshare(args, argc, argv, QString::fromStdString(RsInit::RsConfigDirectory())); - std::string link = RsInit::getRetroShareLink(); - if (!link.empty()) { + std::string url = RsInit::getRetroShareLink(); + if (!url.empty()) { /* start with RetroShare link */ EventReceiver eventReceiver; - eventReceiver.sendRetroShareLink(QString::fromStdString(link)); - return 0; + if (eventReceiver.sendRetroShareLink(QString::fromStdString(url))) { + return 0; + } + + /* Start RetroShare */ } QSplashScreen splashScreen(QPixmap(":/images/splash.png")/* , Qt::WindowStaysOnTopHint*/); @@ -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 // avoid clashes between infos from threads. // diff --git a/retroshare-gui/src/util/EventReceiver.cpp b/retroshare-gui/src/util/EventReceiver.cpp index 225ca32c5..3c16154ed 100644 --- a/retroshare-gui/src/util/EventReceiver.cpp +++ b/retroshare-gui/src/util/EventReceiver.cpp @@ -91,18 +91,10 @@ bool EventReceiver::start() 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) { if (!sharedMMemory.attach()) { /* No running instance found */ - showNoRunningInstanceFound(); return false; } @@ -122,7 +114,6 @@ bool EventReceiver::sendRetroShareLink(const QString& link) SendMessage((HWND) info->wid, WM_COPYDATA, (WPARAM) 0, (LPARAM) (PCOPYDATASTRUCT) &send); } else { - showNoRunningInstanceFound(); result = false; } #else diff --git a/retroshare-gui/src/util/EventReceiver.h b/retroshare-gui/src/util/EventReceiver.h index 410abba7a..a755b2a92 100644 --- a/retroshare-gui/src/util/EventReceiver.h +++ b/retroshare-gui/src/util/EventReceiver.h @@ -47,7 +47,6 @@ signals: void linkReceived(const QUrl& url); private: - void showNoRunningInstanceFound(); void received(const QString& url); #ifdef WINDOWS_SYS