Added handling of RetroShare protocol under Windows.

Added new command line parameter "-r retroshare://..." for adding links to the registered running RetroShare.
Recompile of the GUI needed.

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@4156 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
thunder2 2011-04-14 21:59:51 +00:00
parent a337941555
commit 20fa00c40e
12 changed files with 380 additions and 16 deletions

View File

@ -127,8 +127,9 @@ class RsInit
static std::string RsConfigDirectory(); static std::string RsConfigDirectory();
static std::string RsConfigKeysDirectory(); static std::string RsConfigKeysDirectory();
static std::string RsProfileConfigDirectory(); static std::string RsProfileConfigDirectory();
static bool setStartMinimised() ; static bool getStartMinimised() ;
static std::string getRetroShareLink();
static int getSslPwdLen(); static int getSslPwdLen();
static bool getAutoLogin(); static bool getAutoLogin();

View File

@ -127,6 +127,8 @@ class RsInitConfig
static std::string load_trustedpeer_file; static std::string load_trustedpeer_file;
static bool udpListenerOnly; static bool udpListenerOnly;
static std::string RetroShareLink;
}; };
@ -160,6 +162,7 @@ std::string RsInitConfig::passwd;
bool RsInitConfig::autoLogin; /* autoLogin allowed */ bool RsInitConfig::autoLogin; /* autoLogin allowed */
bool RsInitConfig::startMinimised; /* Icon or Full Window */ bool RsInitConfig::startMinimised; /* Icon or Full Window */
std::string RsInitConfig::RetroShareLink;
/* Win/Unix Differences */ /* Win/Unix Differences */
char RsInitConfig::dirSeperator; char RsInitConfig::dirSeperator;
@ -396,7 +399,7 @@ int RsInit::InitRetroShare(int argcIgnored, char **argvIgnored, bool strictCheck
/* getopt info: every availiable option is listed here. if it is followed by a ':' it /* getopt info: every availiable option is listed here. if it is followed by a ':' it
needs an argument. If it is followed by a '::' the argument is optional. needs an argument. If it is followed by a '::' the argument is optional.
*/ */
while((c = getopt(argc, argv,"hesamui:p:c:w:l:d:U:")) != -1) while((c = getopt(argc, argv,"hesamui:p:c:w:l:d:U:r:")) != -1)
{ {
switch (c) switch (c)
{ {
@ -466,6 +469,11 @@ int RsInit::InitRetroShare(int argcIgnored, char **argvIgnored, bool strictCheck
std::cerr << "Opt for User Id "; std::cerr << "Opt for User Id ";
std::cerr << std::endl; std::cerr << std::endl;
break; break;
case 'r':
RsInitConfig::RetroShareLink = optarg;
std::cerr << "Opt for RetroShare link";
std::cerr << std::endl;
break;
case 'h': case 'h':
std::cerr << "Help: " << std::endl; std::cerr << "Help: " << std::endl;
std::cerr << "The commandline options are for retroshare-nogui, a headless server in a shell, or systems without QT." << std::endl << std::endl; std::cerr << "The commandline options are for retroshare-nogui, a headless server in a shell, or systems without QT." << std::endl << std::endl;
@ -481,14 +489,15 @@ int RsInit::InitRetroShare(int argcIgnored, char **argvIgnored, bool strictCheck
std::cerr << "-u Only listen to UDP" << std::endl; std::cerr << "-u Only listen to UDP" << std::endl;
std::cerr << "-e Use a forwarded external Port" << std::endl ; std::cerr << "-e Use a forwarded external Port" << std::endl ;
std::cerr << "-U [User Name/GPG id/SSL id] Sets Account to Use, Useful when Autologin is enabled." << std::endl; std::cerr << "-U [User Name/GPG id/SSL id] Sets Account to Use, Useful when Autologin is enabled." << std::endl;
std::cerr << "-r link Use RetroShare link." << std::endl;
exit(1); exit(1);
break; break;
default: default:
if (strictCheck) { if (strictCheck) {
std::cerr << "Unknown Option!" << std::endl; std::cerr << "Unknown Option!" << std::endl;
std::cerr << "Use '-h' for help." << std::endl; std::cerr << "Use '-h' for help." << std::endl;
exit(1); exit(1);
} }
} }
} }
@ -1657,11 +1666,16 @@ std::string RsInit::RsProfileConfigDirectory()
return dir; return dir;
} }
bool RsInit::setStartMinimised() bool RsInit::getStartMinimised()
{ {
return RsInitConfig::startMinimised; return RsInitConfig::startMinimised;
} }
std::string RsInit::getRetroShareLink()
{
return RsInitConfig::RetroShareLink;
}
int RsInit::getSslPwdLen(){ int RsInit::getSslPwdLen(){
return SSLPWD_LEN; return SSLPWD_LEN;
} }

View File

@ -246,6 +246,7 @@ HEADERS += rshare.h \
util/PixmapMerging.h \ util/PixmapMerging.h \
util/MouseEventFilter.h \ util/MouseEventFilter.h \
util/EventFilter.h \ util/EventFilter.h \
util/EventReceiver.h \
util/Widget.h \ util/Widget.h \
util/rsversion.h \ util/rsversion.h \
util/RsAction.h \ util/RsAction.h \
@ -475,6 +476,7 @@ SOURCES += main.cpp \
util/PixmapMerging.cpp \ util/PixmapMerging.cpp \
util/MouseEventFilter.cpp \ util/MouseEventFilter.cpp \
util/EventFilter.cpp \ util/EventFilter.cpp \
util/EventReceiver.cpp \
util/Widget.cpp \ util/Widget.cpp \
util/RsAction.cpp \ util/RsAction.cpp \
util/rsversion.cpp \ util/rsversion.cpp \

View File

@ -38,6 +38,7 @@ GeneralPage::GeneralPage(QWidget * parent, Qt::WFlags flags)
#ifndef Q_WS_WIN #ifndef Q_WS_WIN
ui.chkRunRetroshareAtSystemStartup->setVisible(false); ui.chkRunRetroshareAtSystemStartup->setVisible(false);
ui.chkRunRetroshareAtSystemStartupMinimized->setVisible(false); ui.chkRunRetroshareAtSystemStartupMinimized->setVisible(false);
ui.enableRetroShareProtocol->setVisible(false);
#endif #endif
} }
@ -55,6 +56,10 @@ bool GeneralPage::save(QString &errmsg)
#ifdef Q_WS_WIN #ifdef Q_WS_WIN
Settings->setRunRetroshareOnBoot(ui.chkRunRetroshareAtSystemStartup->isChecked(), ui.chkRunRetroshareAtSystemStartupMinimized->isChecked()); Settings->setRunRetroshareOnBoot(ui.chkRunRetroshareAtSystemStartup->isChecked(), ui.chkRunRetroshareAtSystemStartupMinimized->isChecked());
if (ui.enableRetroShareProtocol->isChecked() != Settings->getRetroShareProtocol()) {
Settings->setRetroShareProtocol(ui.enableRetroShareProtocol->isChecked());
}
#endif #endif
Settings->setMaxTimeBeforeIdle(ui.spinBox->value()); Settings->setMaxTimeBeforeIdle(ui.spinBox->value());
@ -71,6 +76,8 @@ void GeneralPage::load()
bool minimized; bool minimized;
ui.chkRunRetroshareAtSystemStartup->setChecked(Settings->runRetroshareOnBoot(minimized)); ui.chkRunRetroshareAtSystemStartup->setChecked(Settings->runRetroshareOnBoot(minimized));
ui.chkRunRetroshareAtSystemStartupMinimized->setChecked(minimized); ui.chkRunRetroshareAtSystemStartupMinimized->setChecked(minimized);
ui.enableRetroShareProtocol->setChecked(Settings->getRetroShareProtocol());
#endif #endif
ui.checkStartMinimized->setChecked(Settings->getStartMinimized()); ui.checkStartMinimized->setChecked(Settings->getStartMinimized());

View File

@ -583,6 +583,13 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="3" column="0">
<widget class="QCheckBox" name="enableRetroShareProtocol">
<property name="text">
<string>Register retroshare:// as url protocol (Restart required)</string>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
</item> </item>

View File

@ -37,6 +37,7 @@
#endif // MINIMAL_RSGUI #endif // MINIMAL_RSGUI
#include <retroshare/rsnotify.h> #include <retroshare/rsnotify.h>
#include <retroshare/rspeers.h>
#if defined(Q_WS_WIN) #if defined(Q_WS_WIN)
#include <util/win32.h> #include <util/win32.h>
@ -472,7 +473,56 @@ RshareSettings::setRunRetroshareOnBoot(bool run, bool minimized)
#else #else
/* Platforms othe rthan windows aren't supported yet */ /* Platforms othe rthan windows aren't supported yet */
Q_UNUSED(run); Q_UNUSED(run);
return; Q_UNUSED(minimized);
#endif
}
static QString getAppPathForProtocol()
{
return "\"" + QDir::convertSeparators(QCoreApplication::applicationFilePath()) + "\" -r \"%1\"";
}
/** Returns true if retroshare:// is registered as protocol */
bool RshareSettings::getRetroShareProtocol()
{
#if defined(Q_WS_WIN)
/* Check key */
QSettings retroshare("HKEY_CLASSES_ROOT\\retroshare", QSettings::NativeFormat);
if (retroshare.contains("Default")) {
/* Check profile */
if (retroshare.value("Profile").toString().toStdString() == rsPeers->getOwnId()) {
/* Check app path */
QSettings command("HKEY_CLASSES_ROOT\\retroshare\\shell\\open\\command", QSettings::NativeFormat);
if (command.value("Default").toString() == getAppPathForProtocol()) {
return true;
}
}
}
#else
/* Platforms other than windows aren't supported yet */
return false;
#endif
}
/** Register retroshare:// as protocl */
void RshareSettings::setRetroShareProtocol(bool value)
{
#if defined(Q_WS_WIN)
if (value) {
QSettings retroshare("HKEY_CLASSES_ROOT\\retroshare", QSettings::NativeFormat);
retroshare.setValue("Default", "URL: RetroShare protocol");
retroshare.setValue("URL Protocol", "");
retroshare.setValue("Profile", QString::fromStdString(rsPeers->getOwnId()));
QSettings command("HKEY_CLASSES_ROOT\\retroshare\\shell\\open\\command", QSettings::NativeFormat);
command.setValue("Default", getAppPathForProtocol());
} else {
QSettings retroshare("HKEY_CLASSES_ROOT", QSettings::NativeFormat);
retroshare.remove("retroshare");
}
#else
/* Platforms othe rthan windows aren't supported yet */
Q_UNUSED(value);
#endif #endif
} }

View File

@ -109,6 +109,11 @@ public:
/** Set whether to run RetroShare on system boot. */ /** Set whether to run RetroShare on system boot. */
void setRunRetroshareOnBoot(bool run, bool minimized); void setRunRetroshareOnBoot(bool run, bool minimized);
/** Returns true if retroshare:// is registered as protocol */
bool getRetroShareProtocol();
/** Register retroshare:// as protocl */
void setRetroShareProtocol(bool value);
/* Get the destination log file. */ /* Get the destination log file. */
QString getLogFile(); QString getLogFile();
/** Set the destination log file. */ /** Set the destination log file. */

View File

@ -4320,12 +4320,12 @@ Gib Dein GPG Passwort wenn Du gefragt wirst ein, um Deinen neuen Schlüssel zu u
<translation>Nicht in den Systemabschnitt minimieren</translation> <translation>Nicht in den Systemabschnitt minimieren</translation>
</message> </message>
<message> <message>
<location line="+46"/> <location line="+53"/>
<source> seconds</source> <source> seconds</source>
<translation>Sekunden</translation> <translation>Sekunden</translation>
</message> </message>
<message> <message>
<location line="-99"/> <location line="-106"/>
<source>Start minimized</source> <source>Start minimized</source>
<translation>Minimiert starten</translation> <translation>Minimiert starten</translation>
</message> </message>
@ -4335,7 +4335,12 @@ Gib Dein GPG Passwort wenn Du gefragt wirst ein, um Deinen neuen Schlüssel zu u
<translation>Starte RetroShare mit dem System</translation> <translation>Starte RetroShare mit dem System</translation>
</message> </message>
<message> <message>
<location line="+93"/> <location line="+77"/>
<source>Register retroshare:// as url protocol (Restart required)</source>
<translation>Registriere retroshare:// als Protokoll (Neustart erforderlich)</translation>
</message>
<message>
<location line="+23"/>
<source>Idle</source> <source>Idle</source>
<translation>Untätig</translation> <translation>Untätig</translation>
</message> </message>
@ -8828,19 +8833,19 @@ p, li { white-space: pre-wrap; }
<context> <context>
<name>QObject</name> <name>QObject</name>
<message> <message>
<location filename="../main.cpp" line="+83"/> <location filename="../main.cpp" line="+84"/>
<location line="+115"/> <location line="+123"/>
<source>RetroShare</source> <source>RetroShare</source>
<translation>RetroShare</translation> <translation>RetroShare</translation>
</message> </message>
<message> <message>
<location line="-109"/> <location line="-117"/>
<source>Inititialize failed. Wrong or missing installation of gpg.</source> <source>Inititialize failed. Wrong or missing installation of gpg.</source>
<translation>Initialisierung fehlgeschlagen. GPG fehlt oder es ist eine falsche Version installiert.</translation> <translation>Initialisierung fehlgeschlagen. GPG fehlt oder es ist eine falsche Version installiert.</translation>
</message> </message>
<message> <message>
<location line="+5"/> <location line="+5"/>
<location line="+104"/> <location line="+112"/>
<source>An unexpected error occured. Please report &apos;RsInit::InitRetroShare unexpected return code %1&apos;.</source> <source>An unexpected error occured. Please report &apos;RsInit::InitRetroShare unexpected return code %1&apos;.</source>
<translation>Ein unerwarteter Fehler ist aufgetreten. Bitte melde &apos;RsInit::InitRetroShare unexpected return code %1&apos;.</translation> <translation>Ein unerwarteter Fehler ist aufgetreten. Bitte melde &apos;RsInit::InitRetroShare unexpected return code %1&apos;.</translation>
</message> </message>
@ -8971,6 +8976,16 @@ Lockdatei:
<source>Peer details</source> <source>Peer details</source>
<translation>Nachbar Details</translation> <translation>Nachbar Details</translation>
</message> </message>
<message>
<location filename="../util/EventReceiver.cpp" line="+91"/>
<source>No running instance of RetroShare found.</source>
<translation>Kein laufendes RetroShare gefunden.</translation>
</message>
<message>
<location line="+33"/>
<source>Start with a RetroShare link is only supported for Windows.</source>
<translation>Der Start mit einem RetroShare Link wird nur unter Windows unterstützt.</translation>
</message>
</context> </context>
<context> <context>
<name>QuickStartWizard</name> <name>QuickStartWizard</name>
@ -11073,7 +11088,7 @@ p, li { white-space: pre-wrap; }
<translation>Definiere Farben</translation> <translation>Definiere Farben</translation>
</message> </message>
<message> <message>
<location line="+78"/> <location line="+82"/>
<source>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt; <source>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt; &lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; } p, li { white-space: pre-wrap; }

View File

@ -42,6 +42,7 @@
#include "gui/connect/ConfCertDialog.h" #include "gui/connect/ConfCertDialog.h"
#include "idle/idle.h" #include "idle/idle.h"
#include "gui/common/Emoticons.h" #include "gui/common/Emoticons.h"
#include "util/EventReceiver.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>
@ -107,6 +108,14 @@ 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();
if (!link.empty()) {
/* start with RetroShare link */
EventReceiver eventReceiver;
eventReceiver.sendRetroShareLink(QString::fromStdString(link));
return 0;
}
QSplashScreen splashScreen(QPixmap(":/images/splash.png")/* , Qt::WindowStaysOnTopHint*/); QSplashScreen splashScreen(QPixmap(":/images/splash.png")/* , Qt::WindowStaysOnTopHint*/);
switch (initResult) { switch (initResult) {
@ -229,6 +238,15 @@ int main(int argc, char *argv[])
MainWindow *w = MainWindow::Create (); MainWindow *w = MainWindow::Create ();
splashScreen.finish(w); splashScreen.finish(w);
EventReceiver *eventReceiver = NULL;
if (Settings->getRetroShareProtocol()) {
/* Create event receiver */
eventReceiver = new EventReceiver;
if (eventReceiver->start()) {
QObject::connect(eventReceiver, SIGNAL(linkReceived(const QUrl&)), w, SLOT(linkActivated(const QUrl&)));
}
}
// 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.
// //
@ -268,7 +286,7 @@ int main(int argc, char *argv[])
w->installGroupChatNotifier(); w->installGroupChatNotifier();
/* only show window, if not startMinimized */ /* only show window, if not startMinimized */
if (RsInit::setStartMinimised() || Settings->getStartMinimized()) if (RsInit::getStartMinimised() || Settings->getStartMinimized())
{ {
splashScreen.close(); splashScreen.close();
} else { } else {
@ -286,6 +304,12 @@ int main(int argc, char *argv[])
#ifndef MINIMAL_RSGUI #ifndef MINIMAL_RSGUI
delete w ; delete w ;
if (eventReceiver) {
/* Destroy event receiver */
delete eventReceiver;
eventReceiver = NULL;
}
/* cleanup */ /* cleanup */
PopupChatDialog::cleanupChat(); PopupChatDialog::cleanupChat();
#endif // MINIMAL_RSGUI #endif // MINIMAL_RSGUI

View File

@ -0,0 +1,178 @@
/****************************************************************
* RetroShare is distributed under the following license:
*
* Copyright (C) 2006, 2007 crypton
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
****************************************************************/
#include <QCoreApplication>
#include <QMessageBox>
#include <QIcon>
#include <iostream>
#include <retroshare/rsinit.h>
#include "EventReceiver.h"
#include "gui/RetroShareLink.h"
#ifdef WINDOWS_SYS
#include <windows.h>
#define OP_RETROSHARELINK 12000
#endif
struct SharedMemoryInfo
{
#ifdef WINDOWS_SYS
/* Store handle of the event window */
WId wid;
#else
long dummy;
#endif
};
EventReceiver::EventReceiver()
{
#ifdef WINDOWS_SYS
setWindowTitle("RetroShare EventReceiver");
#endif
/* Build unique name for the running instance */
QString name = QString("RetroShare-%1::EventReceiver").arg(QCoreApplication::applicationDirPath());
sharedMMemory.setKey(name);
}
EventReceiver::~EventReceiver()
{
sharedMMemory.detach();
}
bool EventReceiver::start()
{
if (!sharedMMemory.create(sizeof(SharedMemoryInfo))) {
std::cerr << "EventReceiver::start() Cannot create shared memory !" << sharedMMemory.errorString().toStdString() << std::endl;
return false;
}
bool result = true;
if (sharedMMemory.lock()) {
SharedMemoryInfo *info = (SharedMemoryInfo*) sharedMMemory.data();
if (info) {
#ifdef WINDOWS_SYS
info->wid = winId();
#else
info->dummy = 0;
#endif
} else {
result = false;
std::cerr << "EventReceiver::start() Shared memory returns a NULL pointer!" << std::endl;
}
sharedMMemory.unlock();
} else {
result = false;
std::cerr << "EventReceiver::start() Cannot lock shared memory !" << std::endl;
}
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;
}
bool result = true;
if (sharedMMemory.lock()) {
SharedMemoryInfo *info = (SharedMemoryInfo*) sharedMMemory.data();
if (info) {
#ifdef WINDOWS_SYS
if (info->wid) {
QByteArray linkData = link.toAscii();
COPYDATASTRUCT send;
send.cbData = (link.length() + 1) * sizeof(char);
send.dwData = OP_RETROSHARELINK;
send.lpData = (void*) linkData.constData();
SendMessage((HWND) info->wid, WM_COPYDATA, (WPARAM) 0, (LPARAM) (PCOPYDATASTRUCT) &send);
} else {
showNoRunningInstanceFound();
result = false;
}
#else
QMessageBox mb(QMessageBox::Critical, "RetroShare", QObject::tr("Start with a RetroShare link is only supported for Windows."), QMessageBox::Ok);
mb.setWindowIcon(QIcon(":/images/rstray3.png"));
mb.exec();
result = false;
#endif
} else {
result = false;
std::cerr << "EventReceiver::sendRetroShareLink() Cannot lock shared memory !" << std::endl;
}
sharedMMemory.unlock();
} else {
result = false;
std::cerr << "EventReceiver::start() Cannot lock shared memory !" << std::endl;
}
sharedMMemory.detach();
return result;
}
#ifdef WINDOWS_SYS
bool EventReceiver::winEvent(MSG* message, long* result)
{
if (message->message == WM_COPYDATA ) {
/* Extract the struct from lParam */
COPYDATASTRUCT *data = (COPYDATASTRUCT*) message->lParam;
if (data && data->dwData == OP_RETROSHARELINK) {
received(QString::fromAscii((const char*) data->lpData, data->cbData));
/* Keep the event from Qt */
*result = 0;
return true;
}
}
/* Give the event to Qt */
return false;
}
#endif
void EventReceiver::received(const QString &url)
{
RetroShareLink link(url);
if (link.valid()) {
emit linkReceived(link.toUrl());
}
}

View File

@ -0,0 +1,61 @@
/****************************************************************
* RetroShare is distributed under the following license:
*
* Copyright (C) 2006,2007 crypton
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
****************************************************************/
#ifndef _EVENTRECEIVER_H
#define _EVENTRECEIVER_H
#include <QWidget>
#include <QSharedMemory>
class QUrl;
class EventReceiver : public
#ifdef WINDOWS_SYS
QWidget
#else
QObject
#endif
{
Q_OBJECT
public:
EventReceiver();
~EventReceiver();
bool start();
bool sendRetroShareLink(const QString& link);
signals:
void linkReceived(const QUrl& url);
private:
void showNoRunningInstanceFound();
void received(const QString& url);
#ifdef WINDOWS_SYS
/* Extend QWidget with a class that will capture the WM_COPYDATA messages */
bool winEvent (MSG* message, long* result);
#endif // WINDOWS_SYS
QSharedMemory sharedMMemory;
};
#endif