diff --git a/build_scripts/RedHat+Fedora/data/retroshare.desktop b/build_scripts/RedHat+Fedora/data/retroshare.desktop
index 504ca9048..d5534f4d3 100644
--- a/build_scripts/RedHat+Fedora/data/retroshare.desktop
+++ b/build_scripts/RedHat+Fedora/data/retroshare.desktop
@@ -2,8 +2,10 @@
Version=1.0
Name=RetroShare06
Comment=Securely share files with your friends
-Exec=/usr/bin/RetroShare06
+Exec=/usr/bin/RetroShare06 %U
Icon=/usr/share/pixmaps/retroshare06.xpm
Terminal=false
Type=Application
Categories=Network;P2P;
+MimeType=x-scheme-handler/retroshare
+
diff --git a/data/retroshare06.desktop b/data/retroshare06.desktop
index 2019a83c7..1df9783b2 100644
--- a/data/retroshare06.desktop
+++ b/data/retroshare06.desktop
@@ -3,9 +3,10 @@ Encoding=UTF-8
Version=1.0
Name=RetroShare06
Comment=Securely share files with your friends
-Exec=/usr/bin/RetroShare06
+Exec=/usr/bin/RetroShare06 %U
Icon=/usr/share/pixmaps/retroshare06.xpm
Terminal=false
Type=Application
Categories=Application;Network;
+MimeType=x-scheme-handler/retroshare
diff --git a/libretroshare/src/retroshare/rsinit.h b/libretroshare/src/retroshare/rsinit.h
index 9e5cd4bfc..1555be893 100644
--- a/libretroshare/src/retroshare/rsinit.h
+++ b/libretroshare/src/retroshare/rsinit.h
@@ -98,8 +98,7 @@ class RsInit
* Post Login Options
*/
- static bool getStartMinimised() ;
- static std::string getRetroShareLink();
+ static bool getStartMinimised();
static int getSslPwdLen();
static bool getAutoLogin();
diff --git a/libretroshare/src/rsserver/rsinit.cc b/libretroshare/src/rsserver/rsinit.cc
index 1b4b393ab..d064dabf9 100644
--- a/libretroshare/src/rsserver/rsinit.cc
+++ b/libretroshare/src/rsserver/rsinit.cc
@@ -128,8 +128,6 @@ class RsInitConfig
std::string load_trustedpeer_file;
bool udpListenerOnly;
-
- std::string RetroShareLink;
};
static RsInitConfig *rsInitConfig = NULL;
@@ -363,7 +361,8 @@ int RsInit::InitRetroShare(int argcIgnored, char **argvIgnored, bool strictCheck
>> parameter('p',"port" ,rsInitConfig->port ,"port", "Set listenning port to use." ,false)
>> parameter('c',"base-dir" ,opt_base_dir ,"directory", "Set base directory." ,false)
>> parameter('U',"user-id" ,prefUserString ,"ID", "[User Name/GPG id/SSL id] Sets Account to Use, Useful when Autologin is enabled",false)
- >> parameter('r',"link" ,rsInitConfig->RetroShareLink ,"retroshare://...", "Use a given Retroshare Link" ,false)
+ // by rshare 'r' "link" "Link" "Open RsLink with protocol retroshare://"
+ // by rshare 'f' "rsfile" "RsFile" "Open RsFile like RsCollection"
#ifdef LOCALNET_TESTING
>> parameter('R',"restrict-port" ,portRestrictions ,"port1-port2","Apply port restriction" ,false)
#endif
@@ -774,11 +773,6 @@ bool RsInit::getStartMinimised()
return rsInitConfig->startMinimised;
}
-std::string RsInit::getRetroShareLink()
-{
- return rsInitConfig->RetroShareLink;
-}
-
int RsInit::getSslPwdLen(){
return SSLPWD_LEN;
}
diff --git a/retroshare-gui/src/Info.plist b/retroshare-gui/src/Info.plist
new file mode 100755
index 000000000..72df6d774
--- /dev/null
+++ b/retroshare-gui/src/Info.plist
@@ -0,0 +1,48 @@
+
+
+
+
+ NSPrincipalClass
+ NSApplication
+ CFBundleIconFile
+ rsMacIcon
+ CFBundlePackageType
+ APPL
+ CFBundleGetInfoString
+ RetroShare is a Free and Open Source cross-platform, Friend-2-Friends ans secure decentralised communication platform.
+ CFBundleSignature
+ ????
+ CFBundleExecutable
+ RetroShare06
+ CFBundleIdentifier
+ com.RetroShare06
+ NSHighResolutionCapable
+
+ CFBundleDocumentTypes
+
+
+ CFBundleTypeName
+ RetroShare Collection
+ CFBundleTypeExtensions
+
+ rscollection
+
+ CFBundleTypeRole
+ Viewer
+
+
+ NOTE
+ This file was generated by Qt/QMake.
+ CFBundleURLTypes
+
+
+ CFBundleURLName
+ RetroShare URL
+ CFBundleURLSchemes
+
+ retroshare
+
+
+
+
+
diff --git a/retroshare-gui/src/gui/MainWindow.cpp b/retroshare-gui/src/gui/MainWindow.cpp
index 4a2a9d448..4fd1bebab 100644
--- a/retroshare-gui/src/gui/MainWindow.cpp
+++ b/retroshare-gui/src/gui/MainWindow.cpp
@@ -203,6 +203,7 @@ MainWindow::MainWindow(QWidget* parent, Qt::WindowFlags flags)
}
setWindowTitle(tr("RetroShare %1 a secure decentralized communication platform").arg(Rshare::retroshareVersion(true)) + " - " + nameAndLocation);
+ connect(rApp, SIGNAL(newArgsReceived(QStringList)), this, SLOT(receiveNewArgs(QStringList)));
/* add url handler for RetroShare links */
QDesktopServices::setUrlHandler(RSLINK_SCHEME, this, "retroshareLinkActivated");
@@ -1095,6 +1096,12 @@ void MainWindow::doQuit()
rApp->quit();
}
+void MainWindow::receiveNewArgs(QStringList args)
+{
+ Rshare::parseArguments(args, false);
+ processLastArgs();
+}
+
void MainWindow::displayErrorMessage(int /*a*/,int /*b*/,const QString& error_msg)
{
QMessageBox::critical(NULL, tr("Internal Error"),error_msg) ;
@@ -1433,6 +1440,33 @@ void MainWindow::retroshareLinkActivated(const QUrl &url)
RetroShareLink::process(links);
}
+void MainWindow::openRsCollection(const QString &filename)
+{
+ QFileInfo qinfo(filename);
+ if (qinfo.exists()) {
+ if (qinfo.absoluteFilePath().endsWith(RsCollectionFile::ExtensionString)) {
+ RsCollectionFile collection;
+ collection.openColl(qinfo.absoluteFilePath());
+ }
+ }
+}
+
+void MainWindow::processLastArgs()
+{
+ while (!Rshare::links()->isEmpty()) {
+ std::cerr << "MainWindow::processLastArgs() : " << Rshare::links()->count() << std::endl;
+ /* Now use links from the command line, because no RetroShare was running */
+ RetroShareLink link(Rshare::links()->takeFirst());
+ if (link.valid()) {
+ retroshareLinkActivated(link.toUrl());
+ }
+ }
+ while (!Rshare::files()->isEmpty()) {
+ /* Now use files from the command line, because no RetroShare was running */
+ openRsCollection(Rshare::files()->takeFirst());
+ }
+}
+
//void MainWindow::servicePermission()
//{
// ServicePermissionDialog::showYourself();
diff --git a/retroshare-gui/src/gui/MainWindow.h b/retroshare-gui/src/gui/MainWindow.h
index 897740123..b65d5992b 100644
--- a/retroshare-gui/src/gui/MainWindow.h
+++ b/retroshare-gui/src/gui/MainWindow.h
@@ -173,13 +173,16 @@ public:
SysTrayStatus *sysTrayStatusInstance();
public slots:
+ void receiveNewArgs(QStringList args);
void displayErrorMessage(int,int,const QString&) ;
void postModDirectories(bool update_local);
void displayDiskSpaceWarning(int loc,int size_limit_mb) ;
void checkAndSetIdle(int idleTime);
- void retroshareLinkActivated(const QUrl &url);
void externalLinkActivated(const QUrl &url);
+ void retroshareLinkActivated(const QUrl &url);
+ void openRsCollection(const QString &filename);
+ void processLastArgs();
//! Go to a specific part of the control panel.
void setNewPage(int page);
void setCompactStatusMode(bool compact);
diff --git a/retroshare-gui/src/gui/settings/GeneralPage.cpp b/retroshare-gui/src/gui/settings/GeneralPage.cpp
index 3eea9c701..e3608e65c 100755
--- a/retroshare-gui/src/gui/settings/GeneralPage.cpp
+++ b/retroshare-gui/src/gui/settings/GeneralPage.cpp
@@ -49,18 +49,31 @@ GeneralPage::GeneralPage(QWidget * parent, Qt::WindowFlags flags)
ui.chkRunRetroshareAtSystemStartupMinimized->setEnabled(false);
#endif
- if (Settings->canSetRetroShareProtocol() == false) {
- ui.enableRetroShareProtocol->setEnabled(false);
- } else {
- ui.adminLabel->setEnabled(false);
- ui.adminLabel->setToolTip("");
- }
#else
ui.chkRunRetroshareAtSystemStartup->setVisible(false);
ui.chkRunRetroshareAtSystemStartupMinimized->setVisible(false);
- ui.enableRetroShareProtocol->setVisible(false);
+ ui.registerRetroShareProtocol->setVisible(false);
ui.adminLabel->setVisible(false);
#endif
+
+ if (Settings->canSetRetroShareProtocol()) {
+ ui.registerRetroShareProtocol->setEnabled(true);
+#ifdef Q_OS_WIN
+ ui.adminLabel->setEnabled(true);
+ ui.adminLabel->setToolTip(tr("You have enough right."));
+#else
+ ui.desktopFileMissingLabel->setVisible(false);
+#endif
+ } else {
+ ui.registerRetroShareProtocol->setEnabled(false);
+#ifdef Q_OS_WIN
+ ui.adminLabel->setEnabled(false);
+ ui.adminLabel->setToolTip(tr("You don't have enough right. Run RetroShare as Admin to change this setting."));
+#else
+ ui.desktopFileMissingLabel->setVisible(true);
+#endif
+ }
+ ui.useLocalServer->setEnabled(true);
}
/** Destructor */
@@ -75,42 +88,44 @@ void GeneralPage::runStartWizard()
/** Saves the changes on this page */
bool GeneralPage::save(QString &/*errmsg*/)
{
- Settings->setStartMinimized(ui.checkStartMinimized->isChecked());
- Settings->setValue("doQuit", ui.checkQuit->isChecked());
- Settings->setCloseToTray(ui.checkCloseToTray->isChecked());
-
#ifdef Q_OS_WIN
-
#ifndef QT_DEBUG
Settings->setRunRetroshareOnBoot(ui.chkRunRetroshareAtSystemStartup->isChecked(), ui.chkRunRetroshareAtSystemStartupMinimized->isChecked());
#endif
-
- if (ui.enableRetroShareProtocol->isChecked() != Settings->getRetroShareProtocol()) {
- if (Settings->setRetroShareProtocol(ui.enableRetroShareProtocol->isChecked()) == false) {
- if (ui.enableRetroShareProtocol->isChecked()) {
- QMessageBox::critical(this, tr("Error"), tr("Could not add retroshare:// as protocol."));
- } else {
- QMessageBox::critical(this, tr("Error"), tr("Could not remove retroshare:// protocol."));
- }
- }
- }
#endif
- Settings->setMaxTimeBeforeIdle(ui.spinBox->value());
-
- RsInit::setAutoLogin(ui.autoLogin->isChecked());
+ Settings->setStartMinimized(ui.checkStartMinimized->isChecked());
if (ui.checkAdvanced->isChecked())
{
- std::string opt("YES");
- rsConfig->setConfigurationOption(RS_CONFIG_ADVANCED, opt);
+ std::string opt("YES");
+ rsConfig->setConfigurationOption(RS_CONFIG_ADVANCED, opt);
}
else
{
- std::string opt("NO");
- rsConfig->setConfigurationOption(RS_CONFIG_ADVANCED, opt);
+ std::string opt("NO");
+ rsConfig->setConfigurationOption(RS_CONFIG_ADVANCED, opt);
}
+ Settings->setValue("doQuit", ui.checkQuit->isChecked());
+ Settings->setCloseToTray(ui.checkCloseToTray->isChecked());
+ RsInit::setAutoLogin(ui.autoLogin->isChecked());
+
+ if (ui.registerRetroShareProtocol->isChecked() != Settings->getRetroShareProtocol()) {
+ QString error ="";
+ if (Settings->setRetroShareProtocol(ui.registerRetroShareProtocol->isChecked(), error) == false) {
+ if (ui.registerRetroShareProtocol->isChecked()) {
+ QMessageBox::critical(this, tr("Error"), tr("Could not add retroshare:// as protocol.").append("\n").append(error));
+ } else {
+ QMessageBox::critical(this, tr("Error"), tr("Could not remove retroshare:// protocol.").append("\n").append(error));
+ }
+ }
+ }
+
+ Settings->setUseLocalServer(ui.useLocalServer->isChecked());
+
+ Settings->setMaxTimeBeforeIdle(ui.idleSpinBox->value());
+
return true;
}
@@ -121,25 +136,23 @@ void GeneralPage::load()
bool minimized;
ui.chkRunRetroshareAtSystemStartup->setChecked(Settings->runRetroshareOnBoot(minimized));
ui.chkRunRetroshareAtSystemStartupMinimized->setChecked(minimized);
-
- ui.enableRetroShareProtocol->setChecked(Settings->getRetroShareProtocol());
#endif
ui.checkStartMinimized->setChecked(Settings->getStartMinimized());
- ui.checkQuit->setChecked(Settings->value("doQuit", false).toBool());
-
- ui.checkCloseToTray->setChecked(Settings->getCloseToTray());
-
- ui.spinBox->setValue(Settings->getMaxTimeBeforeIdle());
-
- ui.autoLogin->setChecked(RsInit::getAutoLogin());
bool advancedmode = false;
std::string advsetting;
if (rsConfig->getConfigurationOption(RS_CONFIG_ADVANCED, advsetting) && (advsetting == "YES"))
{
- advancedmode = true;
+ advancedmode = true;
}
ui.checkAdvanced->setChecked(advancedmode);
+ ui.checkQuit->setChecked(Settings->value("doQuit", false).toBool());
+ ui.checkCloseToTray->setChecked(Settings->getCloseToTray());
+ ui.autoLogin->setChecked(RsInit::getAutoLogin());
+ ui.registerRetroShareProtocol->setChecked(Settings->getRetroShareProtocol());
+ ui.useLocalServer->setChecked(Settings->getUseLocalServer());
+
+ ui.idleSpinBox->setValue(Settings->getMaxTimeBeforeIdle());
}
diff --git a/retroshare-gui/src/gui/settings/GeneralPage.ui b/retroshare-gui/src/gui/settings/GeneralPage.ui
index 11ce75905..c7f6aebff 100755
--- a/retroshare-gui/src/gui/settings/GeneralPage.ui
+++ b/retroshare-gui/src/gui/settings/GeneralPage.ui
@@ -10,13 +10,13 @@
465
-
+
-
-
+
Startup
-
+
2
@@ -35,9 +35,9 @@
-
-
+
-
-
+
Qt::Horizontal
@@ -65,11 +65,11 @@
-
-
+
For Advanced Users
-
+
-
@@ -81,11 +81,11 @@
-
-
+
Misc
-
+
2
@@ -111,9 +111,9 @@
-
-
+
-
-
+
0
@@ -121,7 +121,7 @@
- Register retroshare:// as URL protocol (Restart required)
+ Register retroshare:// as URL protocol
@@ -143,24 +143,53 @@
+ -
+
+
+ When checked, this instance receives new parameters (like RsLink or RsFile) and avoid new one.
+
+
+ Use Local Server to get new arguments.
+
+
+ true
+
+
+
+ -
+
+
+
+ 75
+ true
+
+
+
+ <html><head/><body><p>Install RetroShare with a package installer to get</p><p>/usr/share/applications/retroshare06.desktop</p></body></html>
+
+
+ !!!The RetroShare's desktop file is missing or wrong!!!
+
+
+
-
-
+
Idle
-
+
-
-
+
Idle Time
-
-
+
seconds
@@ -176,7 +205,7 @@
-
-
+
Qt::Vertical
diff --git a/retroshare-gui/src/gui/settings/rsharesettings.cpp b/retroshare-gui/src/gui/settings/rsharesettings.cpp
index b7cf16f01..0dfc713f9 100644
--- a/retroshare-gui/src/gui/settings/rsharesettings.cpp
+++ b/retroshare-gui/src/gui/settings/rsharesettings.cpp
@@ -741,31 +741,47 @@ RshareSettings::setRunRetroshareOnBoot(bool run, bool minimized)
#endif
}
-#if defined(Q_OS_WIN)
static QString getAppPathForProtocol()
{
+#if defined(Q_OS_WIN)
return "\"" + QDir::toNativeSeparators(QCoreApplication::applicationFilePath()) + "\" -r \"%1\"";
-}
+#elif defined(Q_OS_LINUX)
+ return QDir::toNativeSeparators(QCoreApplication::applicationFilePath()) + " %U";
#endif
+}
/** Returns true if retroshare:// is registered as protocol */
bool RshareSettings::getRetroShareProtocol()
{
#if defined(Q_OS_WIN)
/* Check key */
- QSettings retroshare("HKEY_CLASSES_ROOT\\retroshare", QSettings::NativeFormat);
+ QSettings retroshare("HKEY_CURRENT_USER\\Software\\Classes\\retroshare", QSettings::NativeFormat);
if (retroshare.contains("Default")) {
- /* Check profile */
- if (retroshare.value("Profile").toString().toStdString() == rsPeers->getOwnId().toStdString()) {
+ /* URL Protocol */
+ if (retroshare.contains("URL Protocol")) {
/* Check app path */
- QSettings command("HKEY_CLASSES_ROOT\\retroshare\\shell\\open\\command", QSettings::NativeFormat);
+ QSettings command("HKEY_CURRENT_USER\\Software\\Classes\\retroshare\\shell\\open\\command", QSettings::NativeFormat);
if (command.value("Default").toString() == getAppPathForProtocol()) {
return true;
}
}
}
+#elif defined(Q_OS_LINUX)
+ QFile desktop("/usr/share/applications/retroshare06.desktop");
+ if (desktop.exists()) {
+ desktop.open(QIODevice::ReadOnly | QIODevice::Text);
+ QTextStream in(&desktop);
+ QStringList lines;
+ while(!in.atEnd()) {
+ lines << in.readLine();
+ }
+ desktop.close();
+ if (lines.contains("Exec=" + getAppPathForProtocol()))
+ if (lines.contains("MimeType=x-scheme-handler/retroshare"))
+ return true;
+ }
#else
- /* Platforms other than windows aren't supported yet */
+ /* Platforms not supported yet */
#endif
return false;
}
@@ -774,50 +790,72 @@ bool RshareSettings::getRetroShareProtocol()
bool RshareSettings::canSetRetroShareProtocol()
{
#if defined(Q_OS_WIN)
- QSettings retroshare("HKEY_CLASSES_ROOT\\retroshare", QSettings::NativeFormat);
- return retroshare.isWritable();
+ QSettings classRoot("HKEY_CURRENT_USER\\Software\\Classes", QSettings::NativeFormat);
+ return classRoot.isWritable();
+#elif defined(Q_OS_LINUX)
+ return RshareSettings::getRetroShareProtocol();
#else
return false;
#endif
}
/** Register retroshare:// as protocol */
-bool RshareSettings::setRetroShareProtocol(bool value)
+bool RshareSettings::setRetroShareProtocol(bool value, QString &error)
{
+ error = "";
#if defined(Q_OS_WIN)
if (value) {
- QSettings retroshare("HKEY_CLASSES_ROOT\\retroshare", QSettings::NativeFormat);
+ QSettings retroshare("HKEY_CURRENT_USER\\Software\\Classes\\retroshare", QSettings::NativeFormat);
retroshare.setValue("Default", "URL: RetroShare protocol");
QSettings::Status state = retroshare.status();
if (state == QSettings::AccessError) {
+ error = tr("Registry Access Error. Maybe you need Administrator right.");
return false;
}
retroshare.setValue("URL Protocol", "");
- retroshare.setValue("Profile", QString::fromStdString(rsPeers->getOwnId().toStdString()));
- QSettings command("HKEY_CLASSES_ROOT\\retroshare\\shell\\open\\command", QSettings::NativeFormat);
+ QSettings command("HKEY_CURRENT_USER\\Software\\Classes\\retroshare\\shell\\open\\command", QSettings::NativeFormat);
command.setValue("Default", getAppPathForProtocol());
state = command.status();
} else {
- QSettings retroshare("HKEY_CLASSES_ROOT", QSettings::NativeFormat);
- retroshare.remove("retroshare");
+ QSettings classRoot("HKEY_CURRENT_USER\\Software\\Classes", QSettings::NativeFormat);
+ classRoot.remove("retroshare");
- QSettings::Status state = retroshare.status();
+ QSettings::Status state = classRoot.status();
if (state == QSettings::AccessError) {
+ error = tr("Registry Access Error. Maybe you need Administrator right.");
return false;
}
}
return true;
-#else
- /* Platforms other than windows aren't supported yet */
+#elif defined(Q_OS_LINUX)
+ /* RetroShare protocol is always activated for Linux */
+ Q_UNUSED(value);
+ return true;
+#else
+ /* Platforms not supported yet */
Q_UNUSED(value);
-
return false;
#endif
}
+/** Returns true if this instance have to run Local Server*/
+bool RshareSettings::getUseLocalServer()
+{
+ return value("UseLocalServer", true).toBool();
+}
+
+/** Sets whether to run Local Server */
+void RshareSettings::setUseLocalServer(bool value)
+{
+ if (value != getUseLocalServer()) {
+ setValue("UseLocalServer", value);
+ Rshare::updateLocalServer();
+ }
+}
+
/** Saving Generic Widget Size / Location */
void RshareSettings::saveWidgetInformation(QWidget *widget)
diff --git a/retroshare-gui/src/gui/settings/rsharesettings.h b/retroshare-gui/src/gui/settings/rsharesettings.h
index f22e89afd..52963ce92 100644
--- a/retroshare-gui/src/gui/settings/rsharesettings.h
+++ b/retroshare-gui/src/gui/settings/rsharesettings.h
@@ -155,8 +155,13 @@ public:
bool canSetRetroShareProtocol();
/** Returns true if retroshare:// is registered as protocol */
bool getRetroShareProtocol();
- /** Register retroshare:// as protocl */
- bool setRetroShareProtocol(bool value);
+ /** Register retroshare:// as protocol */
+ bool setRetroShareProtocol(bool value, QString &error);
+
+ /** Returns true if this instance have to run Local Server*/
+ bool getUseLocalServer();
+ /** Sets whether to run Local Server */
+ void setUseLocalServer(bool value);
/* Get the destination log file. */
QString getLogFile();
diff --git a/retroshare-gui/src/main.cpp b/retroshare-gui/src/main.cpp
index 20ee39561..2bb78ac5b 100644
--- a/retroshare-gui/src/main.cpp
+++ b/retroshare-gui/src/main.cpp
@@ -39,7 +39,6 @@
#include "gui/connect/ConfCertDialog.h"
#include "idle/idle.h"
#include "gui/common/Emoticons.h"
-#include "util/EventReceiver.h"
#include "gui/RetroShareLink.h"
#include "gui/SoundManager.h"
#include "gui/NetworkView.h"
@@ -239,19 +238,9 @@ int main(int argc, char *argv[])
/* Setup The GUI Stuff */
Rshare rshare(args, argc, argv,
- QString::fromUtf8(RsAccounts::ConfigDirectory().c_str()));
-
- std::string url = RsInit::getRetroShareLink();
- if (!url.empty()) {
- /* start with RetroShare link */
- EventReceiver eventReceiver;
- if (eventReceiver.sendRetroShareLink(QString::fromStdString(url))) {
- return 0;
- }
-
- /* Start RetroShare */
- }
+ QString::fromUtf8(RsAccounts::ConfigDirectory().c_str()));
+ /* Start RetroShare */
QSplashScreen splashScreen(QPixmap(":/images/logo/logo_splash.png")/* , Qt::WindowStaysOnTopHint*/);
switch (initResult) {
@@ -358,22 +347,7 @@ int main(int argc, char *argv[])
MainWindow *w = MainWindow::Create ();
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(retroshareLinkActivated(const QUrl&)));
- }
- }
-
- if (!url.empty()) {
- /* Now use link from the command line, because no RetroShare was running */
- RetroShareLink link(QString::fromStdString(url));
- if (link.valid()) {
- w->retroshareLinkActivated(link.toUrl());
- }
- }
+ w->processLastArgs();
// 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.
@@ -422,13 +396,7 @@ int main(int argc, char *argv[])
int ti = rshare.exec();
delete w ;
- WebuiPage::checkShutdownWebui();
-
- if (eventReceiver) {
- /* Destroy event receiver */
- delete eventReceiver;
- eventReceiver = NULL;
- }
+ WebuiPage::checkShutdownWebui();
/* cleanup */
ChatDialog::cleanupChat();
diff --git a/retroshare-gui/src/retroshare-gui.pro b/retroshare-gui/src/retroshare-gui.pro
index 7d436eea4..f0df5b4e7 100644
--- a/retroshare-gui/src/retroshare-gui.pro
+++ b/retroshare-gui/src/retroshare-gui.pro
@@ -5,6 +5,7 @@ QT += network xml
CONFIG += qt gui uic qrc resources idle bitdht
CONFIG += link_prl
TARGET = RetroShare06
+DEFINES += TARGET=\\\"$TARGET\\\"
# Plz never commit the .pro with these flags enabled.
# Use this flag when developping new features only.
@@ -214,9 +215,13 @@ win32 {
##################################### MacOS ######################################
macx {
- # ENABLE THIS OPTION FOR Univeral Binary BUILD.
- #CONFIG += ppc x86
+ # ENABLE THIS OPTION FOR Univeral Binary BUILD.
+ #CONFIG += ppc x86
#QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.4
+ QMAKE_INFO_PLIST = Info.plist
+ mac_icon.files = $$files($$PWD/rsMacIcon.icns)
+ mac_icon.path = Contents/Resources
+ QMAKE_BUNDLE_DATA += mac_icon
CONFIG += version_detail_bash_script
LIBS += -lssl -lcrypto -lz
@@ -377,7 +382,6 @@ HEADERS += rshare.h \
util/PixmapMerging.h \
util/MouseEventFilter.h \
util/EventFilter.h \
- util/EventReceiver.h \
util/Widget.h \
util/RsAction.h \
util/RsUserdata.h \
@@ -727,7 +731,6 @@ SOURCES += main.cpp \
util/PixmapMerging.cpp \
util/MouseEventFilter.cpp \
util/EventFilter.cpp \
- util/EventReceiver.cpp \
util/Widget.cpp \
util/RsAction.cpp \
util/printpreview.cpp \
diff --git a/retroshare-gui/src/rsMacIcon.icns b/retroshare-gui/src/rsMacIcon.icns
new file mode 100755
index 000000000..df7a9aafd
Binary files /dev/null and b/retroshare-gui/src/rsMacIcon.icns differ
diff --git a/retroshare-gui/src/rshare.cpp b/retroshare-gui/src/rshare.cpp
index 4528215d4..bbb816f1c 100644
--- a/retroshare-gui/src/rshare.cpp
+++ b/retroshare-gui/src/rshare.cpp
@@ -20,51 +20,67 @@
* Boston, MA 02110-1301, USA.
****************************************************************/
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
+#include
#include
-#include
-#include
-#include
-#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#ifdef __APPLE__
+#include
+#endif
+
#include
+#include
+
+#include
+#include
+#include
+#include
+#include
+#include
#include
#include
#include
-#include
-#include "gui/settings/rsharesettings.h"
-#include "gui/gxs/GxsIdDetails.h"
#include "rshare.h"
/* Available command-line arguments. */
-#define ARG_LANGUAGE "lang" /**< Argument specifying language. */
-#define ARG_GUISTYLE "style" /**< Argument specfying GUI style. */
+#define ARG_LANGUAGE "lang" /**< Argument specifying language. */
+#define ARG_GUISTYLE "style" /**< Argument specfying GUI style. */
#define ARG_GUISTYLESHEET "stylesheet" /**< Argument specfying GUI style. */
-#define ARG_RESET "reset" /**< Reset Rshare's saved settings. */
-#define ARG_DATADIR "datadir" /**< Directory to use for data files. */
-#define ARG_LOGFILE "logfile" /**< Location of our logfile. */
-#define ARG_LOGLEVEL "loglevel" /**< Log verbosity. */
-
+#define ARG_RESET "reset" /**< Reset Rshare's saved settings. */
+#define ARG_DATADIR "datadir" /**< Directory to use for data files. */
+#define ARG_LOGFILE "logfile" /**< Location of our logfile. */
+#define ARG_LOGLEVEL "loglevel" /**< Log verbosity. */
+#define ARG_RSLINK_S "r" /**< Open RsLink with protocol retroshare:// */
+#define ARG_RSLINK_L "link" /**< Open RsLink with protocol retroshare:// */
+#define ARG_RSFILE_S "f" /**< Open RsFile with or without arg */
+#define ARG_RSFILE_L "rsfile" /**< Open RsFile with or without arg */
+//Other defined for server in /libretroshare/src/rsserver/rsinit.cc:351
/* Static member variables */
QMap Rshare::_args; /**< List of command-line arguments. */
QString Rshare::_style; /**< The current GUI style. */
-QString Rshare::_language; /**< The current language. */
QString Rshare::_stylesheet; /**< The current GUI stylesheet. */
+QString Rshare::_language; /**< The current language. */
QString Rshare::_dateformat; /**< The format of dates in feed items etc. */
-Log Rshare::_log;
-bool Rshare::useConfigDir;
-QString Rshare::configDir;
+Log Rshare::_log; /**< Logs debugging messages to file or stdout. */
+QStringList Rshare::_links; /**< List of links passed by arguments. */
+QStringList Rshare::_files; /**< List of files passed by arguments. */
QDateTime Rshare::mStartupTime;
+bool Rshare::useConfigDir;
+QString Rshare::configDir;
+QLocalServer* Rshare::localServer;
/** Catches debugging messages from Qt and sends them to RetroShare's logs. If Qt
* emits a QtFatalMsg, we will write the message to the log and then abort().
@@ -88,6 +104,10 @@ void qt_msg_handler(QtMsgType type, const char *msg)
case QtFatalMsg:
rError(QString("QtFatalMsg: %1").arg(msg));
break;
+#if QT_VERSION >= QT_VERSION_CHECK (5, 5, 0)
+ case QtInfoMsg:
+ break;
+#endif
}
if (type == QtFatalMsg) {
rError("Fatal Qt error. Aborting.");
@@ -102,6 +122,61 @@ Rshare::Rshare(QStringList args, int &argc, char **argv, const QString &dir)
: QApplication(argc, argv)
{
mStartupTime = QDateTime::currentDateTime();
+ localServer = NULL;
+
+ //Initialize connection to LocalServer to know if other process runs.
+ {
+ QString serverName = QString(TARGET);
+
+ if (args.isEmpty()) args.append("Empty");
+ // load into shared memory
+ QBuffer buffer;
+ buffer.open(QBuffer::ReadWrite);
+ QDataStream out(&buffer);
+ out << args;
+ int size = buffer.size();
+
+ QSharedMemory newArgs;
+ newArgs.setKey(serverName + "_newArgs");
+ if (newArgs.isAttached()) newArgs.detach();
+
+ if (!newArgs.create(size)) {
+ std::cerr << "(EE) Rshare::Rshare Unable to create shared memory segment of size:"
+ << size << " error:" << newArgs.errorString().toStdString() << "." << std::endl;
+#ifdef Q_OS_UNIX
+ std::cerr << "Look with `ipcs -m` for nattch==0 segment. And remove it with `ipcrm -m 'shmid'`." << std::endl;
+ //No need for windows, as it removes shared segment directly even when crash.
+#endif
+ newArgs.detach();
+ ::exit(EXIT_FAILURE);
+ }
+ newArgs.lock();
+ char *to = (char*)newArgs.data();
+ const char *from = buffer.data().data();
+ memcpy(to, from, qMin(newArgs.size(), size));
+ newArgs.unlock();
+
+ // Connect to the Local Server of the main process to notify it
+ // that a new process had been started
+ QLocalSocket localSocket;
+ localSocket.connectToServer(QString(TARGET));
+
+ std::cerr << "Rshare::Rshare waitForConnected to other instance." << std::endl;
+ if( localSocket.waitForConnected(100) )
+ {
+ std::cerr << "Rshare::Rshare Connection etablished. Waiting for disconnection." << std::endl;
+ localSocket.waitForDisconnected(1000);
+ newArgs.detach();
+ ::exit(EXIT_SUCCESS); // Terminate the program using STDLib's exit function
+ } else {
+ newArgs.detach();
+ // No main process exists
+ // So we start a Local Server to listen for connections from new process
+ localServer= new QLocalServer();
+ QObject::connect(localServer, SIGNAL(newConnection()), this, SLOT(slotConnectionEstablished()));
+ updateLocalServer();
+ }
+ }
#if QT_VERSION >= QT_VERSION_CHECK (5, 0, 0)
qInstallMessageHandler(qt_msg_handler);
@@ -172,6 +247,48 @@ Rshare::~Rshare()
{
/* Cleanup GxsIdDetails */
GxsIdDetails::cleanup();
+ if (localServer)
+ {
+ localServer->close();
+ delete localServer;
+ }
+}
+
+/**
+ * @brief Executed when new instance connect command is sent to LocalServer
+ */
+void Rshare::slotConnectionEstablished()
+{
+ QLocalSocket *socket = localServer->nextPendingConnection();
+ socket->close();
+ delete socket;
+
+ QSharedMemory newArgs;
+ newArgs.setKey(QString(TARGET) + "_newArgs");
+
+ if (!newArgs.attach())
+ {
+ std::cerr << "(EE) Rshare::slotConnectionEstablished() Unable to attach to shared memory segment."
+ << newArgs.errorString().toStdString() << std::endl;
+ return;
+ }
+
+ QBuffer buffer;
+ QDataStream in(&buffer);
+ QStringList args;
+
+ newArgs.lock();
+ buffer.setData((char*)newArgs.constData(), newArgs.size());
+ buffer.open(QBuffer::ReadOnly);
+ in >> args;
+ newArgs.unlock();
+ newArgs.detach();
+
+ emit newArgsReceived(args);
+ while (!args.empty())
+ {
+ std::cerr << "Rshare::slotConnectionEstablished args:" << QString(args.takeFirst()).toStdString() << std::endl;
+ }
}
QString Rshare::retroshareVersion(bool withRevision)
@@ -271,39 +388,62 @@ Rshare::showUsageMessageBox()
bool
Rshare::argNeedsValue(QString argName)
{
- return (argName == ARG_GUISTYLE ||
- argName == ARG_GUISTYLESHEET ||
- argName == ARG_LANGUAGE ||
- argName == ARG_DATADIR ||
- argName == ARG_LOGFILE ||
- argName == ARG_LOGLEVEL);
-
+ return (argName == ARG_GUISTYLE ||
+ argName == ARG_GUISTYLESHEET ||
+ argName == ARG_LANGUAGE ||
+ argName == ARG_DATADIR ||
+ argName == ARG_LOGFILE ||
+ argName == ARG_LOGLEVEL ||
+ argName == ARG_RSLINK_S ||
+ argName == ARG_RSLINK_L ||
+ argName == ARG_RSFILE_S ||
+ argName == ARG_RSFILE_L );
}
/** Parses the list of command-line arguments for their argument names and
* values. */
void
-Rshare::parseArguments(QStringList args)
+Rshare::parseArguments(QStringList args, bool firstRun)
{
- QString arg, value;
+ QString arg, value;
- /* Loop through all command-line args/values and put them in a map */
- for (int i = 0; i < args.size(); ++i) {
- /* Get the argument name and set a blank value */
- arg = args.at(i).toLower();
- value = "";
+ /* Loop through all command-line args/values and put them in a map */
+ for (int i = 0; i < args.size(); ++i) {
+ /* Get the argument name and set a blank value */
+ arg = args.at(i);//.toLower(); Need Upper case for file name.
+ if (arg.toLower() == "empty") continue;
+ value = "";
- /* Check if it starts with a - or -- */
- if (arg.startsWith("-")) {
- arg = arg.mid((arg.startsWith("--") ? 2 : 1));
- }
- /* Check if it takes a value and there is one on the command-line */
- if (i < args.size()-1 && argNeedsValue(arg)) {
- value = args.at(++i);
- }
- /* Place this arg/value in the map */
- _args.insert(arg, value);
- }
+ /* Check if it starts with a - or -- */
+ if (arg.startsWith("-")) {
+ arg = arg.mid((arg.startsWith("--") ? 2 : 1));
+ /* Check if it takes a value and there is one on the command-line */
+ if (i < args.size()-1 && argNeedsValue(arg.toLower())) {
+ value = args.at(++i);
+ }
+ } else {
+ /* Check if links or files without arg */
+ if (arg.toLower().startsWith("retroshare://")) {
+ value = arg;
+ arg = ARG_RSLINK_L;
+ } else {
+ if (QFile(arg).exists()) {
+ value = arg;
+ arg = ARG_RSFILE_L;
+ }
+ }
+ }
+
+ /* Don't send theses argument to _args map to allow multiple. */
+ if (arg == ARG_RSLINK_S || arg == ARG_RSLINK_L) {
+ _links.append(value);
+ } else if (arg == ARG_RSFILE_S || arg == ARG_RSFILE_L) {
+ _files.append(value);
+ } else if (firstRun) {
+ /* Place this arg/value in the map only first time*/
+ _args.insert(arg, value);
+ }
+ }
}
/** Verifies that all specified arguments were valid. */
@@ -660,6 +800,29 @@ Rshare::createShortcut(const QKeySequence &key, QWidget *sender,
connect(s, SIGNAL(activated()), receiver, slot);
}
+#ifdef __APPLE__
+bool Rshare::event(QEvent *event)
+{
+ switch (event->type()) {
+ case QEvent::FileOpen:{
+ QFileOpenEvent* fileOE = static_cast(event);
+ QStringList args;
+ if (! fileOE->file().isEmpty()) {
+ _files.append(fileOE->file());
+ emit newArgsReceived(QStringList());
+ return true;
+ } else if (! fileOE->url().isEmpty()) {
+ _links.append(fileOE->url().toString());
+ emit newArgsReceived(QStringList());
+ return true;
+ }
+ }
+ default:
+ return QApplication::event(event);
+ }
+}
+#endif
+
void Rshare::blinkTimer()
{
mBlink = !mBlink;
@@ -706,3 +869,17 @@ bool Rshare::loadCertificate(const RsPeerId &accountId, bool autoLogin)
return true;
}
+
+bool Rshare::updateLocalServer()
+{
+ if (localServer) {
+ QString serverName = QString(TARGET);
+ if (Settings->getUseLocalServer()) {
+ localServer->removeServer(serverName);
+ localServer->listen(serverName);
+ return true;
+ }
+ localServer->close();
+ }
+ return false;
+}
diff --git a/retroshare-gui/src/rshare.h b/retroshare-gui/src/rshare.h
index 4e83b2299..cc982ba93 100644
--- a/retroshare-gui/src/rshare.h
+++ b/retroshare-gui/src/rshare.h
@@ -31,11 +31,13 @@
#endif
#include
+#include
+#include
#include
#include
-#include
#include "util/log.h"
+
#include "retroshare/rstypes.h"
/** Pointer to this RetroShare application instance. */
@@ -63,6 +65,8 @@ public:
/** Return the map of command-line arguments and values. */
static QMap arguments() { return _args; }
+ /** Parse the list of command-line arguments. */
+ static void parseArguments(QStringList args, bool firstRun = true);
/** Validates that all arguments were well-formed. */
bool validateArguments(QString &errmsg);
/** Prints usage information to the given text stream. */
@@ -89,8 +93,10 @@ public:
static void getAvailableStyleSheets(QMap &styleSheets);
/** Recalculates matching stylesheet for widget **/
static void refreshStyleSheet(QWidget *widget, bool processChildren);
-
+ /** Load certificate */
static bool loadCertificate(const RsPeerId &accountId, bool autoLogin);
+ /** Start or Stop Local server to get new arguments depends setting */
+ static bool updateLocalServer();
/**
* Update Language, Style and StyleSheet.
@@ -107,6 +113,10 @@ public:
static QString style() { return _style; }
/** Returns the current GUI stylesheet. */
static QString stylesheet() { return _stylesheet; }
+ /** Returns links passed by arguments. */
+ static QStringList* links() { return &_links; }
+ /** Returns files passed by arguments. */
+ static QStringList* files() {return &_files; }
/** Returns Rshare's application startup time. */
static QDateTime startupTime();
@@ -131,7 +141,12 @@ public:
* sender's context, receiver's slot will be called. */
static void createShortcut(const QKeySequence &key, QWidget *sender,
QWidget *receiver, const char *slot);
-
+
+#ifdef __APPLE__
+ /**To process event from Mac system */
+ bool event(QEvent *);
+#endif
+
signals:
/** Emitted when the application is running and the main event loop has
* started. */
@@ -144,6 +159,8 @@ signals:
void secondTick();
/** Global timer every minute */
void minuteTick();
+ /** Emitted when other process is connected */
+ void newArgsReceived(QStringList args);
private slots:
/** Called when the application's main event loop has started. This method
@@ -151,27 +168,32 @@ private slots:
* loop is running. */
void onEventLoopStarted();
void blinkTimer();
+ /**
+ * @brief Called when accept new connection from new instance.
+ */
+ void slotConnectionEstablished();
private:
/** customize the date format (defaultlongformat) */
static void customizeDateFormat();
- /** Parse the list of command-line arguments. */
- void parseArguments(QStringList args);
/** Returns true if the specified arguments wants a value. */
- bool argNeedsValue(QString argName);
+ static bool argNeedsValue(QString argName);
static QMap _args; /**< List of command-line arguments. */
static QString _style; /**< The current GUI style. */
static QString _stylesheet; /**< The current GUI stylesheet. */
static QString _language; /**< The current language. */
static QString _dateformat; /**< The format for dates in feed items etc. */
- static Log _log; /**< Logs debugging messages to file or stdout. */
+ static Log _log; /**< Logs debugging messages to file or stdout. */
+ static QStringList _links; /**< List of links passed by arguments. */
+ static QStringList _files; /**< List of files passed by arguments. */
static QDateTime mStartupTime; // startup time
static bool useConfigDir;
static QString configDir;
bool mBlink;
+ static QLocalServer* localServer;
};
#endif
diff --git a/retroshare-gui/src/util/EventReceiver.cpp b/retroshare-gui/src/util/EventReceiver.cpp
deleted file mode 100644
index 312610f35..000000000
--- a/retroshare-gui/src/util/EventReceiver.cpp
+++ /dev/null
@@ -1,173 +0,0 @@
-/****************************************************************
- * 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
-#include
-#include
-#include
-
-#include
-
-#include "EventReceiver.h"
-#include "gui/MainWindow.h"
-#include "gui/RetroShareLink.h"
-
-#ifdef WINDOWS_SYS
-#include
-#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());
- sharedMemory.setKey(name);
-}
-
-EventReceiver::~EventReceiver()
-{
- sharedMemory.detach();
-}
-
-bool EventReceiver::start()
-{
- if (!sharedMemory.create(sizeof(SharedMemoryInfo))) {
- std::cerr << "EventReceiver::start() Cannot create shared memory !" << sharedMemory.errorString().toStdString() << std::endl;
- return false;
- }
-
- bool result = true;
-
- if (sharedMemory.lock()) {
- SharedMemoryInfo *info = (SharedMemoryInfo*) sharedMemory.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;
- }
-
- sharedMemory.unlock();
- } else {
- result = false;
- std::cerr << "EventReceiver::start() Cannot lock shared memory !" << std::endl;
- }
-
- return result;
-}
-
-bool EventReceiver::sendRetroShareLink(const QString& link)
-{
- if (!sharedMemory.attach()) {
- /* No running instance found */
- return false;
- }
-
- bool result = true;
-
- if (sharedMemory.lock()) {
- SharedMemoryInfo *info = (SharedMemoryInfo*) sharedMemory.data();
- if (info) {
-#ifdef WINDOWS_SYS
- if (info->wid) {
- QByteArray linkData(link.toUtf8());
-
- COPYDATASTRUCT send;
- send.dwData = OP_RETROSHARELINK;
- send.cbData = link.length() * sizeof(char);
- send.lpData = (void*) linkData.constData();
-
- SendMessage((HWND) info->wid, WM_COPYDATA, (WPARAM) 0, (LPARAM) (PCOPYDATASTRUCT) &send);
- } else {
- result = false;
- }
-#else
- Q_UNUSED(link);
-
- QMessageBox mb(QMessageBox::Critical, "RetroShare", QObject::tr("Start with a RetroShare link is only supported for Windows."), QMessageBox::Ok);
- mb.exec();
-
- result = false;
-#endif
- } else {
- result = false;
- std::cerr << "EventReceiver::sendRetroShareLink() Cannot lock shared memory !" << std::endl;
- }
-
- sharedMemory.unlock();
- } else {
- result = false;
- std::cerr << "EventReceiver::start() Cannot lock shared memory !" << std::endl;
- }
-
- sharedMemory.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::fromUtf8((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()) {
- MainWindow::raiseWindow();
-
- emit linkReceived(link.toUrl());
- }
-}
diff --git a/retroshare-gui/src/util/EventReceiver.h b/retroshare-gui/src/util/EventReceiver.h
deleted file mode 100644
index adf1b5d7b..000000000
--- a/retroshare-gui/src/util/EventReceiver.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/****************************************************************
- * 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
-#include
-
-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 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 sharedMemory;
-};
-
-#endif
diff --git a/retroshare-gui/src/util/stringutil.cpp b/retroshare-gui/src/util/stringutil.cpp
index 5f14236ea..84df81bfa 100644
--- a/retroshare-gui/src/util/stringutil.cpp
+++ b/retroshare-gui/src/util/stringutil.cpp
@@ -1,7 +1,7 @@
/****************************************************************
- * This file is distributed under the following license:
- *
- * Copyright (c) 2008, crypton
+ * This file is distributed under the following license:
+ *
+ * Copyright (c) 2008, crypton
* Copyright (c) 2008, Matt Edman, Justin Hipple
*
* This program is free software; you can redistribute it and/or
@@ -28,6 +28,11 @@
#include "stringutil.h"
+//#define CHAR_ARRAY_TO_STRINGLIST_DEBUG
+#ifdef CHAR_ARRAY_TO_STRINGLIST_DEBUG
+#include
+#include
+#endif
/** Create a QStringList from the array of C-style strings. */
QStringList
@@ -35,7 +40,20 @@ char_array_to_stringlist(char **arr, int len)
{
QStringList list;
for (int i = 0; i < len; i++) {
- list << QString(arr[i]);
+#ifdef WINDOWS_SYS
+ list << QString::fromLatin1(arr[i]);
+#else
+ list << QString::fromUtf8(arr[i]);
+#endif
+
+#ifdef CHAR_ARRAY_TO_STRINGLIST_DEBUG
+ std::cerr << "arr[" << i << "]==" << arr[i] << std::endl;
+ if (QFile(arr[i]).exists()) std::cerr << "arr[i] File exists" << std::endl;
+ std::cerr << "QString UTF8==" << QString::fromUtf8(arr[i]).toStdString() << std::endl;
+ if (QFile(QString::fromUtf8(arr[i])).exists()) std::cerr << "QString UTF8 File exists" << std::endl;
+ std::cerr << "QString Latin1==" << QString::fromLatin1(arr[i]).toStdString() << std::endl;
+ if (QFile(QString::fromLatin1(arr[i])).exists()) std::cerr << "QString Latin1 File exists" << std::endl;
+#endif
}
return list;
}