mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-28 00:49:28 -05:00
Merge pull request #297 from PhenomRetroShare/Add_AllowOnlyOneIntanceAndPassArg
Allow only one instance. If exists, pass to it arguments.
This commit is contained in:
commit
c8cae4c33c
@ -2,8 +2,10 @@
|
|||||||
Version=1.0
|
Version=1.0
|
||||||
Name=RetroShare06
|
Name=RetroShare06
|
||||||
Comment=Securely share files with your friends
|
Comment=Securely share files with your friends
|
||||||
Exec=/usr/bin/RetroShare06
|
Exec=/usr/bin/RetroShare06 %U
|
||||||
Icon=/usr/share/pixmaps/retroshare06.xpm
|
Icon=/usr/share/pixmaps/retroshare06.xpm
|
||||||
Terminal=false
|
Terminal=false
|
||||||
Type=Application
|
Type=Application
|
||||||
Categories=Network;P2P;
|
Categories=Network;P2P;
|
||||||
|
MimeType=x-scheme-handler/retroshare
|
||||||
|
|
||||||
|
@ -3,9 +3,10 @@ Encoding=UTF-8
|
|||||||
Version=1.0
|
Version=1.0
|
||||||
Name=RetroShare06
|
Name=RetroShare06
|
||||||
Comment=Securely share files with your friends
|
Comment=Securely share files with your friends
|
||||||
Exec=/usr/bin/RetroShare06
|
Exec=/usr/bin/RetroShare06 %U
|
||||||
Icon=/usr/share/pixmaps/retroshare06.xpm
|
Icon=/usr/share/pixmaps/retroshare06.xpm
|
||||||
Terminal=false
|
Terminal=false
|
||||||
Type=Application
|
Type=Application
|
||||||
Categories=Application;Network;
|
Categories=Application;Network;
|
||||||
|
MimeType=x-scheme-handler/retroshare
|
||||||
|
|
||||||
|
@ -98,8 +98,7 @@ class RsInit
|
|||||||
* Post Login Options
|
* Post Login Options
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static bool getStartMinimised() ;
|
static bool getStartMinimised();
|
||||||
static std::string getRetroShareLink();
|
|
||||||
|
|
||||||
static int getSslPwdLen();
|
static int getSslPwdLen();
|
||||||
static bool getAutoLogin();
|
static bool getAutoLogin();
|
||||||
|
@ -128,8 +128,6 @@ class RsInitConfig
|
|||||||
std::string load_trustedpeer_file;
|
std::string load_trustedpeer_file;
|
||||||
|
|
||||||
bool udpListenerOnly;
|
bool udpListenerOnly;
|
||||||
|
|
||||||
std::string RetroShareLink;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static RsInitConfig *rsInitConfig = NULL;
|
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('p',"port" ,rsInitConfig->port ,"port", "Set listenning port to use." ,false)
|
||||||
>> parameter('c',"base-dir" ,opt_base_dir ,"directory", "Set base directory." ,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('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
|
#ifdef LOCALNET_TESTING
|
||||||
>> parameter('R',"restrict-port" ,portRestrictions ,"port1-port2","Apply port restriction" ,false)
|
>> parameter('R',"restrict-port" ,portRestrictions ,"port1-port2","Apply port restriction" ,false)
|
||||||
#endif
|
#endif
|
||||||
@ -774,11 +773,6 @@ 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;
|
||||||
}
|
}
|
||||||
|
48
retroshare-gui/src/Info.plist
Executable file
48
retroshare-gui/src/Info.plist
Executable file
@ -0,0 +1,48 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
|
<plist version="1.0">
|
||||||
|
<dict>
|
||||||
|
<key>NSPrincipalClass</key>
|
||||||
|
<string>NSApplication</string>
|
||||||
|
<key>CFBundleIconFile</key>
|
||||||
|
<string>rsMacIcon</string>
|
||||||
|
<key>CFBundlePackageType</key>
|
||||||
|
<string>APPL</string>
|
||||||
|
<key>CFBundleGetInfoString</key>
|
||||||
|
<string>RetroShare is a Free and Open Source cross-platform, Friend-2-Friends ans secure decentralised communication platform.</string>
|
||||||
|
<key>CFBundleSignature</key>
|
||||||
|
<string>????</string>
|
||||||
|
<key>CFBundleExecutable</key>
|
||||||
|
<string>RetroShare06</string>
|
||||||
|
<key>CFBundleIdentifier</key>
|
||||||
|
<string>com.RetroShare06</string>
|
||||||
|
<key>NSHighResolutionCapable</key>
|
||||||
|
<true/>
|
||||||
|
<key>CFBundleDocumentTypes</key>
|
||||||
|
<array>
|
||||||
|
<dict>
|
||||||
|
<key>CFBundleTypeName</key>
|
||||||
|
<string>RetroShare Collection</string>
|
||||||
|
<key>CFBundleTypeExtensions</key>
|
||||||
|
<array>
|
||||||
|
<string>rscollection</string>
|
||||||
|
</array>
|
||||||
|
<key>CFBundleTypeRole</key>
|
||||||
|
<string>Viewer</string>
|
||||||
|
</dict>
|
||||||
|
</array>
|
||||||
|
<key>NOTE</key>
|
||||||
|
<string>This file was generated by Qt/QMake.</string>
|
||||||
|
<key>CFBundleURLTypes</key>
|
||||||
|
<array>
|
||||||
|
<dict>
|
||||||
|
<key>CFBundleURLName</key>
|
||||||
|
<string>RetroShare URL</string>
|
||||||
|
<key>CFBundleURLSchemes</key>
|
||||||
|
<array>
|
||||||
|
<string>retroshare</string>
|
||||||
|
</array>
|
||||||
|
</dict>
|
||||||
|
</array>
|
||||||
|
</dict>
|
||||||
|
</plist>
|
@ -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);
|
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 */
|
/* add url handler for RetroShare links */
|
||||||
QDesktopServices::setUrlHandler(RSLINK_SCHEME, this, "retroshareLinkActivated");
|
QDesktopServices::setUrlHandler(RSLINK_SCHEME, this, "retroshareLinkActivated");
|
||||||
@ -1095,6 +1096,12 @@ void MainWindow::doQuit()
|
|||||||
rApp->quit();
|
rApp->quit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::receiveNewArgs(QStringList args)
|
||||||
|
{
|
||||||
|
Rshare::parseArguments(args, false);
|
||||||
|
processLastArgs();
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindow::displayErrorMessage(int /*a*/,int /*b*/,const QString& error_msg)
|
void MainWindow::displayErrorMessage(int /*a*/,int /*b*/,const QString& error_msg)
|
||||||
{
|
{
|
||||||
QMessageBox::critical(NULL, tr("Internal Error"),error_msg) ;
|
QMessageBox::critical(NULL, tr("Internal Error"),error_msg) ;
|
||||||
@ -1433,6 +1440,33 @@ void MainWindow::retroshareLinkActivated(const QUrl &url)
|
|||||||
RetroShareLink::process(links);
|
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()
|
//void MainWindow::servicePermission()
|
||||||
//{
|
//{
|
||||||
// ServicePermissionDialog::showYourself();
|
// ServicePermissionDialog::showYourself();
|
||||||
|
@ -173,13 +173,16 @@ public:
|
|||||||
SysTrayStatus *sysTrayStatusInstance();
|
SysTrayStatus *sysTrayStatusInstance();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
void receiveNewArgs(QStringList args);
|
||||||
void displayErrorMessage(int,int,const QString&) ;
|
void displayErrorMessage(int,int,const QString&) ;
|
||||||
void postModDirectories(bool update_local);
|
void postModDirectories(bool update_local);
|
||||||
void displayDiskSpaceWarning(int loc,int size_limit_mb) ;
|
void displayDiskSpaceWarning(int loc,int size_limit_mb) ;
|
||||||
void checkAndSetIdle(int idleTime);
|
void checkAndSetIdle(int idleTime);
|
||||||
|
|
||||||
void retroshareLinkActivated(const QUrl &url);
|
|
||||||
void externalLinkActivated(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.
|
//! Go to a specific part of the control panel.
|
||||||
void setNewPage(int page);
|
void setNewPage(int page);
|
||||||
void setCompactStatusMode(bool compact);
|
void setCompactStatusMode(bool compact);
|
||||||
|
@ -49,18 +49,31 @@ GeneralPage::GeneralPage(QWidget * parent, Qt::WindowFlags flags)
|
|||||||
ui.chkRunRetroshareAtSystemStartupMinimized->setEnabled(false);
|
ui.chkRunRetroshareAtSystemStartupMinimized->setEnabled(false);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (Settings->canSetRetroShareProtocol() == false) {
|
|
||||||
ui.enableRetroShareProtocol->setEnabled(false);
|
|
||||||
} else {
|
|
||||||
ui.adminLabel->setEnabled(false);
|
|
||||||
ui.adminLabel->setToolTip("");
|
|
||||||
}
|
|
||||||
#else
|
#else
|
||||||
ui.chkRunRetroshareAtSystemStartup->setVisible(false);
|
ui.chkRunRetroshareAtSystemStartup->setVisible(false);
|
||||||
ui.chkRunRetroshareAtSystemStartupMinimized->setVisible(false);
|
ui.chkRunRetroshareAtSystemStartupMinimized->setVisible(false);
|
||||||
ui.enableRetroShareProtocol->setVisible(false);
|
ui.registerRetroShareProtocol->setVisible(false);
|
||||||
ui.adminLabel->setVisible(false);
|
ui.adminLabel->setVisible(false);
|
||||||
#endif
|
#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 */
|
/** Destructor */
|
||||||
@ -75,42 +88,44 @@ void GeneralPage::runStartWizard()
|
|||||||
/** Saves the changes on this page */
|
/** Saves the changes on this page */
|
||||||
bool GeneralPage::save(QString &/*errmsg*/)
|
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
|
#ifdef Q_OS_WIN
|
||||||
|
|
||||||
#ifndef QT_DEBUG
|
#ifndef QT_DEBUG
|
||||||
Settings->setRunRetroshareOnBoot(ui.chkRunRetroshareAtSystemStartup->isChecked(), ui.chkRunRetroshareAtSystemStartupMinimized->isChecked());
|
Settings->setRunRetroshareOnBoot(ui.chkRunRetroshareAtSystemStartup->isChecked(), ui.chkRunRetroshareAtSystemStartupMinimized->isChecked());
|
||||||
#endif
|
#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
|
#endif
|
||||||
|
|
||||||
Settings->setMaxTimeBeforeIdle(ui.spinBox->value());
|
Settings->setStartMinimized(ui.checkStartMinimized->isChecked());
|
||||||
|
|
||||||
RsInit::setAutoLogin(ui.autoLogin->isChecked());
|
|
||||||
|
|
||||||
if (ui.checkAdvanced->isChecked())
|
if (ui.checkAdvanced->isChecked())
|
||||||
{
|
{
|
||||||
std::string opt("YES");
|
std::string opt("YES");
|
||||||
rsConfig->setConfigurationOption(RS_CONFIG_ADVANCED, opt);
|
rsConfig->setConfigurationOption(RS_CONFIG_ADVANCED, opt);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::string opt("NO");
|
std::string opt("NO");
|
||||||
rsConfig->setConfigurationOption(RS_CONFIG_ADVANCED, opt);
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -121,25 +136,23 @@ 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());
|
||||||
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;
|
bool advancedmode = false;
|
||||||
std::string advsetting;
|
std::string advsetting;
|
||||||
if (rsConfig->getConfigurationOption(RS_CONFIG_ADVANCED, advsetting) && (advsetting == "YES"))
|
if (rsConfig->getConfigurationOption(RS_CONFIG_ADVANCED, advsetting) && (advsetting == "YES"))
|
||||||
{
|
{
|
||||||
advancedmode = true;
|
advancedmode = true;
|
||||||
}
|
}
|
||||||
ui.checkAdvanced->setChecked(advancedmode);
|
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());
|
||||||
}
|
}
|
||||||
|
@ -10,13 +10,13 @@
|
|||||||
<height>465</height>
|
<height>465</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QVBoxLayout">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QGroupBox" name="groupBox_2">
|
<widget class="QGroupBox" name="startupGBox">
|
||||||
<property name="title">
|
<property name="title">
|
||||||
<string>Startup</string>
|
<string>Startup</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout_3">
|
<layout class="QGridLayout" name="startupGBoxGLayout">
|
||||||
<property name="verticalSpacing">
|
<property name="verticalSpacing">
|
||||||
<number>2</number>
|
<number>2</number>
|
||||||
</property>
|
</property>
|
||||||
@ -35,9 +35,9 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="0">
|
<item row="3" column="0">
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
<layout class="QHBoxLayout" name="runRetroshareAtSystemStartupMinimizedHLayout">
|
||||||
<item>
|
<item>
|
||||||
<spacer name="horizontalSpacer">
|
<spacer name="runRetroshareAtSystemStartupMinimizedHSpacer">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Horizontal</enum>
|
<enum>Qt::Horizontal</enum>
|
||||||
</property>
|
</property>
|
||||||
@ -65,11 +65,11 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QGroupBox" name="groupBox_4">
|
<widget class="QGroupBox" name="advGBox">
|
||||||
<property name="title">
|
<property name="title">
|
||||||
<string>For Advanced Users </string>
|
<string>For Advanced Users </string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
<layout class="QVBoxLayout" name="advGBoxVLayout">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QCheckBox" name="checkAdvanced">
|
<widget class="QCheckBox" name="checkAdvanced">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
@ -81,11 +81,11 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QGroupBox" name="groupBox">
|
<widget class="QGroupBox" name="miscGBox">
|
||||||
<property name="title">
|
<property name="title">
|
||||||
<string>Misc</string>
|
<string>Misc</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
<layout class="QGridLayout" name="miscGBoxGLayout">
|
||||||
<property name="verticalSpacing">
|
<property name="verticalSpacing">
|
||||||
<number>2</number>
|
<number>2</number>
|
||||||
</property>
|
</property>
|
||||||
@ -111,9 +111,9 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="0">
|
<item row="3" column="0">
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
<layout class="QHBoxLayout" name="retroshareProtocolHLayout">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QCheckBox" name="enableRetroShareProtocol">
|
<widget class="QCheckBox" name="registerRetroShareProtocol">
|
||||||
<property name="minimumSize">
|
<property name="minimumSize">
|
||||||
<size>
|
<size>
|
||||||
<width>0</width>
|
<width>0</width>
|
||||||
@ -121,7 +121,7 @@
|
|||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Register retroshare:// as URL protocol (Restart required)</string>
|
<string>Register retroshare:// as URL protocol</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@ -143,24 +143,53 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="5" column="0">
|
||||||
|
<widget class="QCheckBox" name="useLocalServer">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>When checked, this instance receives new parameters (like RsLink or RsFile) and avoid new one.</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Use Local Server to get new arguments.</string>
|
||||||
|
</property>
|
||||||
|
<property name="checked">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="4" column="0">
|
||||||
|
<widget class="QLabel" name="desktopFileMissingLabel">
|
||||||
|
<property name="font">
|
||||||
|
<font>
|
||||||
|
<weight>75</weight>
|
||||||
|
<bold>true</bold>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string><html><head/><body><p>Install RetroShare with a package installer to get</p><p>/usr/share/applications/retroshare06.desktop</p></body></html></string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>!!!The RetroShare's desktop file is missing or wrong!!!</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QGroupBox" name="groupBox_3">
|
<widget class="QGroupBox" name="idleGBox">
|
||||||
<property name="title">
|
<property name="title">
|
||||||
<string>Idle</string>
|
<string>Idle</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
<layout class="QHBoxLayout" name="idleGBoxHLayout">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="label">
|
<widget class="QLabel" name="idleLabel">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Idle Time</string>
|
<string>Idle Time</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QSpinBox" name="spinBox">
|
<widget class="QSpinBox" name="idleSpinBox">
|
||||||
<property name="suffix">
|
<property name="suffix">
|
||||||
<string> seconds</string>
|
<string> seconds</string>
|
||||||
</property>
|
</property>
|
||||||
@ -176,7 +205,7 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<spacer name="verticalSpacer_2">
|
<spacer name="mainVSpacer">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Vertical</enum>
|
<enum>Qt::Vertical</enum>
|
||||||
</property>
|
</property>
|
||||||
|
@ -741,31 +741,47 @@ RshareSettings::setRunRetroshareOnBoot(bool run, bool minimized)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(Q_OS_WIN)
|
|
||||||
static QString getAppPathForProtocol()
|
static QString getAppPathForProtocol()
|
||||||
{
|
{
|
||||||
|
#if defined(Q_OS_WIN)
|
||||||
return "\"" + QDir::toNativeSeparators(QCoreApplication::applicationFilePath()) + "\" -r \"%1\"";
|
return "\"" + QDir::toNativeSeparators(QCoreApplication::applicationFilePath()) + "\" -r \"%1\"";
|
||||||
}
|
#elif defined(Q_OS_LINUX)
|
||||||
|
return QDir::toNativeSeparators(QCoreApplication::applicationFilePath()) + " %U";
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
/** Returns true if retroshare:// is registered as protocol */
|
/** Returns true if retroshare:// is registered as protocol */
|
||||||
bool RshareSettings::getRetroShareProtocol()
|
bool RshareSettings::getRetroShareProtocol()
|
||||||
{
|
{
|
||||||
#if defined(Q_OS_WIN)
|
#if defined(Q_OS_WIN)
|
||||||
/* Check key */
|
/* Check key */
|
||||||
QSettings retroshare("HKEY_CLASSES_ROOT\\retroshare", QSettings::NativeFormat);
|
QSettings retroshare("HKEY_CURRENT_USER\\Software\\Classes\\retroshare", QSettings::NativeFormat);
|
||||||
if (retroshare.contains("Default")) {
|
if (retroshare.contains("Default")) {
|
||||||
/* Check profile */
|
/* URL Protocol */
|
||||||
if (retroshare.value("Profile").toString().toStdString() == rsPeers->getOwnId().toStdString()) {
|
if (retroshare.contains("URL Protocol")) {
|
||||||
/* Check app path */
|
/* 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()) {
|
if (command.value("Default").toString() == getAppPathForProtocol()) {
|
||||||
return true;
|
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
|
#else
|
||||||
/* Platforms other than windows aren't supported yet */
|
/* Platforms not supported yet */
|
||||||
#endif
|
#endif
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -774,50 +790,72 @@ bool RshareSettings::getRetroShareProtocol()
|
|||||||
bool RshareSettings::canSetRetroShareProtocol()
|
bool RshareSettings::canSetRetroShareProtocol()
|
||||||
{
|
{
|
||||||
#if defined(Q_OS_WIN)
|
#if defined(Q_OS_WIN)
|
||||||
QSettings retroshare("HKEY_CLASSES_ROOT\\retroshare", QSettings::NativeFormat);
|
QSettings classRoot("HKEY_CURRENT_USER\\Software\\Classes", QSettings::NativeFormat);
|
||||||
return retroshare.isWritable();
|
return classRoot.isWritable();
|
||||||
|
#elif defined(Q_OS_LINUX)
|
||||||
|
return RshareSettings::getRetroShareProtocol();
|
||||||
#else
|
#else
|
||||||
return false;
|
return false;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Register retroshare:// as protocol */
|
/** Register retroshare:// as protocol */
|
||||||
bool RshareSettings::setRetroShareProtocol(bool value)
|
bool RshareSettings::setRetroShareProtocol(bool value, QString &error)
|
||||||
{
|
{
|
||||||
|
error = "";
|
||||||
#if defined(Q_OS_WIN)
|
#if defined(Q_OS_WIN)
|
||||||
if (value) {
|
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");
|
retroshare.setValue("Default", "URL: RetroShare protocol");
|
||||||
|
|
||||||
QSettings::Status state = retroshare.status();
|
QSettings::Status state = retroshare.status();
|
||||||
if (state == QSettings::AccessError) {
|
if (state == QSettings::AccessError) {
|
||||||
|
error = tr("Registry Access Error. Maybe you need Administrator right.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
retroshare.setValue("URL Protocol", "");
|
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());
|
command.setValue("Default", getAppPathForProtocol());
|
||||||
state = command.status();
|
state = command.status();
|
||||||
} else {
|
} else {
|
||||||
QSettings retroshare("HKEY_CLASSES_ROOT", QSettings::NativeFormat);
|
QSettings classRoot("HKEY_CURRENT_USER\\Software\\Classes", QSettings::NativeFormat);
|
||||||
retroshare.remove("retroshare");
|
classRoot.remove("retroshare");
|
||||||
|
|
||||||
QSettings::Status state = retroshare.status();
|
QSettings::Status state = classRoot.status();
|
||||||
if (state == QSettings::AccessError) {
|
if (state == QSettings::AccessError) {
|
||||||
|
error = tr("Registry Access Error. Maybe you need Administrator right.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
#else
|
#elif defined(Q_OS_LINUX)
|
||||||
/* Platforms other than windows aren't supported yet */
|
/* RetroShare protocol is always activated for Linux */
|
||||||
|
Q_UNUSED(value);
|
||||||
|
return true;
|
||||||
|
#else
|
||||||
|
/* Platforms not supported yet */
|
||||||
Q_UNUSED(value);
|
Q_UNUSED(value);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
#endif
|
#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 */
|
/** Saving Generic Widget Size / Location */
|
||||||
|
|
||||||
void RshareSettings::saveWidgetInformation(QWidget *widget)
|
void RshareSettings::saveWidgetInformation(QWidget *widget)
|
||||||
|
@ -155,8 +155,13 @@ public:
|
|||||||
bool canSetRetroShareProtocol();
|
bool canSetRetroShareProtocol();
|
||||||
/** Returns true if retroshare:// is registered as protocol */
|
/** Returns true if retroshare:// is registered as protocol */
|
||||||
bool getRetroShareProtocol();
|
bool getRetroShareProtocol();
|
||||||
/** Register retroshare:// as protocl */
|
/** Register retroshare:// as protocol */
|
||||||
bool setRetroShareProtocol(bool value);
|
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. */
|
/* Get the destination log file. */
|
||||||
QString getLogFile();
|
QString getLogFile();
|
||||||
|
@ -39,7 +39,6 @@
|
|||||||
#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"
|
|
||||||
#include "gui/RetroShareLink.h"
|
#include "gui/RetroShareLink.h"
|
||||||
#include "gui/SoundManager.h"
|
#include "gui/SoundManager.h"
|
||||||
#include "gui/NetworkView.h"
|
#include "gui/NetworkView.h"
|
||||||
@ -239,19 +238,9 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
/* Setup The GUI Stuff */
|
/* Setup The GUI Stuff */
|
||||||
Rshare rshare(args, argc, argv,
|
Rshare rshare(args, argc, argv,
|
||||||
QString::fromUtf8(RsAccounts::ConfigDirectory().c_str()));
|
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 */
|
|
||||||
}
|
|
||||||
|
|
||||||
|
/* Start RetroShare */
|
||||||
QSplashScreen splashScreen(QPixmap(":/images/logo/logo_splash.png")/* , Qt::WindowStaysOnTopHint*/);
|
QSplashScreen splashScreen(QPixmap(":/images/logo/logo_splash.png")/* , Qt::WindowStaysOnTopHint*/);
|
||||||
|
|
||||||
switch (initResult) {
|
switch (initResult) {
|
||||||
@ -358,22 +347,7 @@ int main(int argc, char *argv[])
|
|||||||
MainWindow *w = MainWindow::Create ();
|
MainWindow *w = MainWindow::Create ();
|
||||||
splashScreen.finish(w);
|
splashScreen.finish(w);
|
||||||
|
|
||||||
EventReceiver *eventReceiver = NULL;
|
w->processLastArgs();
|
||||||
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());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 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.
|
||||||
@ -422,13 +396,7 @@ int main(int argc, char *argv[])
|
|||||||
int ti = rshare.exec();
|
int ti = rshare.exec();
|
||||||
delete w ;
|
delete w ;
|
||||||
|
|
||||||
WebuiPage::checkShutdownWebui();
|
WebuiPage::checkShutdownWebui();
|
||||||
|
|
||||||
if (eventReceiver) {
|
|
||||||
/* Destroy event receiver */
|
|
||||||
delete eventReceiver;
|
|
||||||
eventReceiver = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* cleanup */
|
/* cleanup */
|
||||||
ChatDialog::cleanupChat();
|
ChatDialog::cleanupChat();
|
||||||
|
@ -5,6 +5,7 @@ QT += network xml
|
|||||||
CONFIG += qt gui uic qrc resources idle bitdht
|
CONFIG += qt gui uic qrc resources idle bitdht
|
||||||
CONFIG += link_prl
|
CONFIG += link_prl
|
||||||
TARGET = RetroShare06
|
TARGET = RetroShare06
|
||||||
|
DEFINES += TARGET=\\\"$TARGET\\\"
|
||||||
|
|
||||||
# Plz never commit the .pro with these flags enabled.
|
# Plz never commit the .pro with these flags enabled.
|
||||||
# Use this flag when developping new features only.
|
# Use this flag when developping new features only.
|
||||||
@ -214,9 +215,13 @@ win32 {
|
|||||||
##################################### MacOS ######################################
|
##################################### MacOS ######################################
|
||||||
|
|
||||||
macx {
|
macx {
|
||||||
# ENABLE THIS OPTION FOR Univeral Binary BUILD.
|
# ENABLE THIS OPTION FOR Univeral Binary BUILD.
|
||||||
#CONFIG += ppc x86
|
#CONFIG += ppc x86
|
||||||
#QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.4
|
#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
|
CONFIG += version_detail_bash_script
|
||||||
LIBS += -lssl -lcrypto -lz
|
LIBS += -lssl -lcrypto -lz
|
||||||
@ -377,7 +382,6 @@ 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/RsAction.h \
|
util/RsAction.h \
|
||||||
util/RsUserdata.h \
|
util/RsUserdata.h \
|
||||||
@ -727,7 +731,6 @@ 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/printpreview.cpp \
|
util/printpreview.cpp \
|
||||||
|
BIN
retroshare-gui/src/rsMacIcon.icns
Executable file
BIN
retroshare-gui/src/rsMacIcon.icns
Executable file
Binary file not shown.
@ -20,51 +20,67 @@
|
|||||||
* Boston, MA 02110-1301, USA.
|
* Boston, MA 02110-1301, USA.
|
||||||
****************************************************************/
|
****************************************************************/
|
||||||
|
|
||||||
#include <QDir>
|
#include <QBuffer>
|
||||||
#include <QTimer>
|
|
||||||
#include <QTextStream>
|
|
||||||
#include <QShortcut>
|
|
||||||
#include <QStyleFactory>
|
|
||||||
#include <QStyle>
|
|
||||||
#include <QString>
|
|
||||||
#include <QLocale>
|
|
||||||
#include <QRegExp>
|
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
#include <gui/common/vmessagebox.h>
|
#include <QDir>
|
||||||
#include <gui/common/html.h>
|
#include <QFileOpenEvent>
|
||||||
#include <util/stringutil.h>
|
#include <QLocale>
|
||||||
#include <stdlib.h>
|
#include <QLocalSocket>
|
||||||
|
#include <QRegExp>
|
||||||
|
#include <QSharedMemory>
|
||||||
|
#include <QShortcut>
|
||||||
|
#include <QString>
|
||||||
|
#include <QStyle>
|
||||||
|
#include <QStyleFactory>
|
||||||
|
#include <QTextStream>
|
||||||
|
#include <QTimer>
|
||||||
|
#ifdef __APPLE__
|
||||||
|
#include <QUrl>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include <gui/common/html.h>
|
||||||
|
#include <gui/common/vmessagebox.h>
|
||||||
|
#include <gui/gxs/GxsIdDetails.h>
|
||||||
|
#include <gui/settings/rsharesettings.h>
|
||||||
|
#include <lang/languagesupport.h>
|
||||||
|
#include <util/stringutil.h>
|
||||||
|
|
||||||
#include <retroshare/rsinit.h>
|
#include <retroshare/rsinit.h>
|
||||||
#include <retroshare/rsversion.h>
|
#include <retroshare/rsversion.h>
|
||||||
#include <retroshare/rsplugin.h>
|
#include <retroshare/rsplugin.h>
|
||||||
#include <lang/languagesupport.h>
|
|
||||||
#include "gui/settings/rsharesettings.h"
|
|
||||||
#include "gui/gxs/GxsIdDetails.h"
|
|
||||||
|
|
||||||
#include "rshare.h"
|
#include "rshare.h"
|
||||||
|
|
||||||
/* Available command-line arguments. */
|
/* Available command-line arguments. */
|
||||||
#define ARG_LANGUAGE "lang" /**< Argument specifying language. */
|
#define ARG_LANGUAGE "lang" /**< Argument specifying language. */
|
||||||
#define ARG_GUISTYLE "style" /**< Argument specfying GUI style. */
|
#define ARG_GUISTYLE "style" /**< Argument specfying GUI style. */
|
||||||
#define ARG_GUISTYLESHEET "stylesheet" /**< Argument specfying GUI style. */
|
#define ARG_GUISTYLESHEET "stylesheet" /**< Argument specfying GUI style. */
|
||||||
#define ARG_RESET "reset" /**< Reset Rshare's saved settings. */
|
#define ARG_RESET "reset" /**< Reset Rshare's saved settings. */
|
||||||
#define ARG_DATADIR "datadir" /**< Directory to use for data files. */
|
#define ARG_DATADIR "datadir" /**< Directory to use for data files. */
|
||||||
#define ARG_LOGFILE "logfile" /**< Location of our logfile. */
|
#define ARG_LOGFILE "logfile" /**< Location of our logfile. */
|
||||||
#define ARG_LOGLEVEL "loglevel" /**< Log verbosity. */
|
#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 */
|
/* Static member variables */
|
||||||
QMap<QString, QString> Rshare::_args; /**< List of command-line arguments. */
|
QMap<QString, QString> Rshare::_args; /**< List of command-line arguments. */
|
||||||
QString Rshare::_style; /**< The current GUI style. */
|
QString Rshare::_style; /**< The current GUI style. */
|
||||||
QString Rshare::_language; /**< The current language. */
|
|
||||||
QString Rshare::_stylesheet; /**< The current GUI stylesheet. */
|
QString Rshare::_stylesheet; /**< The current GUI stylesheet. */
|
||||||
|
QString Rshare::_language; /**< The current language. */
|
||||||
QString Rshare::_dateformat; /**< The format of dates in feed items etc. */
|
QString Rshare::_dateformat; /**< The format of dates in feed items etc. */
|
||||||
Log Rshare::_log;
|
Log Rshare::_log; /**< Logs debugging messages to file or stdout. */
|
||||||
bool Rshare::useConfigDir;
|
QStringList Rshare::_links; /**< List of links passed by arguments. */
|
||||||
QString Rshare::configDir;
|
QStringList Rshare::_files; /**< List of files passed by arguments. */
|
||||||
QDateTime Rshare::mStartupTime;
|
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
|
/** 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().
|
* 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:
|
case QtFatalMsg:
|
||||||
rError(QString("QtFatalMsg: %1").arg(msg));
|
rError(QString("QtFatalMsg: %1").arg(msg));
|
||||||
break;
|
break;
|
||||||
|
#if QT_VERSION >= QT_VERSION_CHECK (5, 5, 0)
|
||||||
|
case QtInfoMsg:
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
if (type == QtFatalMsg) {
|
if (type == QtFatalMsg) {
|
||||||
rError("Fatal Qt error. Aborting.");
|
rError("Fatal Qt error. Aborting.");
|
||||||
@ -102,6 +122,61 @@ Rshare::Rshare(QStringList args, int &argc, char **argv, const QString &dir)
|
|||||||
: QApplication(argc, argv)
|
: QApplication(argc, argv)
|
||||||
{
|
{
|
||||||
mStartupTime = QDateTime::currentDateTime();
|
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)
|
#if QT_VERSION >= QT_VERSION_CHECK (5, 0, 0)
|
||||||
qInstallMessageHandler(qt_msg_handler);
|
qInstallMessageHandler(qt_msg_handler);
|
||||||
@ -172,6 +247,48 @@ Rshare::~Rshare()
|
|||||||
{
|
{
|
||||||
/* Cleanup GxsIdDetails */
|
/* Cleanup GxsIdDetails */
|
||||||
GxsIdDetails::cleanup();
|
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)
|
QString Rshare::retroshareVersion(bool withRevision)
|
||||||
@ -271,39 +388,62 @@ Rshare::showUsageMessageBox()
|
|||||||
bool
|
bool
|
||||||
Rshare::argNeedsValue(QString argName)
|
Rshare::argNeedsValue(QString argName)
|
||||||
{
|
{
|
||||||
return (argName == ARG_GUISTYLE ||
|
return (argName == ARG_GUISTYLE ||
|
||||||
argName == ARG_GUISTYLESHEET ||
|
argName == ARG_GUISTYLESHEET ||
|
||||||
argName == ARG_LANGUAGE ||
|
argName == ARG_LANGUAGE ||
|
||||||
argName == ARG_DATADIR ||
|
argName == ARG_DATADIR ||
|
||||||
argName == ARG_LOGFILE ||
|
argName == ARG_LOGFILE ||
|
||||||
argName == ARG_LOGLEVEL);
|
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
|
/** Parses the list of command-line arguments for their argument names and
|
||||||
* values. */
|
* values. */
|
||||||
void
|
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 */
|
/* Loop through all command-line args/values and put them in a map */
|
||||||
for (int i = 0; i < args.size(); ++i) {
|
for (int i = 0; i < args.size(); ++i) {
|
||||||
/* Get the argument name and set a blank value */
|
/* Get the argument name and set a blank value */
|
||||||
arg = args.at(i).toLower();
|
arg = args.at(i);//.toLower(); Need Upper case for file name.
|
||||||
value = "";
|
if (arg.toLower() == "empty") continue;
|
||||||
|
value = "";
|
||||||
|
|
||||||
/* Check if it starts with a - or -- */
|
/* Check if it starts with a - or -- */
|
||||||
if (arg.startsWith("-")) {
|
if (arg.startsWith("-")) {
|
||||||
arg = arg.mid((arg.startsWith("--") ? 2 : 1));
|
arg = arg.mid((arg.startsWith("--") ? 2 : 1));
|
||||||
}
|
/* Check if it takes a value and there is one on the command-line */
|
||||||
/* Check if it takes a value and there is one on the command-line */
|
if (i < args.size()-1 && argNeedsValue(arg.toLower())) {
|
||||||
if (i < args.size()-1 && argNeedsValue(arg)) {
|
value = args.at(++i);
|
||||||
value = args.at(++i);
|
}
|
||||||
}
|
} else {
|
||||||
/* Place this arg/value in the map */
|
/* Check if links or files without arg */
|
||||||
_args.insert(arg, value);
|
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. */
|
/** Verifies that all specified arguments were valid. */
|
||||||
@ -660,6 +800,29 @@ Rshare::createShortcut(const QKeySequence &key, QWidget *sender,
|
|||||||
connect(s, SIGNAL(activated()), receiver, slot);
|
connect(s, SIGNAL(activated()), receiver, slot);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef __APPLE__
|
||||||
|
bool Rshare::event(QEvent *event)
|
||||||
|
{
|
||||||
|
switch (event->type()) {
|
||||||
|
case QEvent::FileOpen:{
|
||||||
|
QFileOpenEvent* fileOE = static_cast<QFileOpenEvent *>(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()
|
void Rshare::blinkTimer()
|
||||||
{
|
{
|
||||||
mBlink = !mBlink;
|
mBlink = !mBlink;
|
||||||
@ -706,3 +869,17 @@ bool Rshare::loadCertificate(const RsPeerId &accountId, bool autoLogin)
|
|||||||
|
|
||||||
return true;
|
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;
|
||||||
|
}
|
||||||
|
@ -31,11 +31,13 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
|
#include <QKeySequence>
|
||||||
|
#include <QLocalServer>
|
||||||
#include <QMap>
|
#include <QMap>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QKeySequence>
|
|
||||||
|
|
||||||
#include "util/log.h"
|
#include "util/log.h"
|
||||||
|
|
||||||
#include "retroshare/rstypes.h"
|
#include "retroshare/rstypes.h"
|
||||||
|
|
||||||
/** Pointer to this RetroShare application instance. */
|
/** Pointer to this RetroShare application instance. */
|
||||||
@ -63,6 +65,8 @@ public:
|
|||||||
|
|
||||||
/** Return the map of command-line arguments and values. */
|
/** Return the map of command-line arguments and values. */
|
||||||
static QMap<QString, QString> arguments() { return _args; }
|
static QMap<QString, QString> 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. */
|
/** Validates that all arguments were well-formed. */
|
||||||
bool validateArguments(QString &errmsg);
|
bool validateArguments(QString &errmsg);
|
||||||
/** Prints usage information to the given text stream. */
|
/** Prints usage information to the given text stream. */
|
||||||
@ -89,8 +93,10 @@ public:
|
|||||||
static void getAvailableStyleSheets(QMap<QString, QString> &styleSheets);
|
static void getAvailableStyleSheets(QMap<QString, QString> &styleSheets);
|
||||||
/** Recalculates matching stylesheet for widget **/
|
/** Recalculates matching stylesheet for widget **/
|
||||||
static void refreshStyleSheet(QWidget *widget, bool processChildren);
|
static void refreshStyleSheet(QWidget *widget, bool processChildren);
|
||||||
|
/** Load certificate */
|
||||||
static bool loadCertificate(const RsPeerId &accountId, bool autoLogin);
|
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.
|
* Update Language, Style and StyleSheet.
|
||||||
@ -107,6 +113,10 @@ public:
|
|||||||
static QString style() { return _style; }
|
static QString style() { return _style; }
|
||||||
/** Returns the current GUI stylesheet. */
|
/** Returns the current GUI stylesheet. */
|
||||||
static QString stylesheet() { return _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. */
|
/** Returns Rshare's application startup time. */
|
||||||
static QDateTime startupTime();
|
static QDateTime startupTime();
|
||||||
|
|
||||||
@ -131,7 +141,12 @@ public:
|
|||||||
* <b>sender</b>'s context, <b>receiver</b>'s <b>slot</b> will be called. */
|
* <b>sender</b>'s context, <b>receiver</b>'s <b>slot</b> will be called. */
|
||||||
static void createShortcut(const QKeySequence &key, QWidget *sender,
|
static void createShortcut(const QKeySequence &key, QWidget *sender,
|
||||||
QWidget *receiver, const char *slot);
|
QWidget *receiver, const char *slot);
|
||||||
|
|
||||||
|
#ifdef __APPLE__
|
||||||
|
/**To process event from Mac system */
|
||||||
|
bool event(QEvent *);
|
||||||
|
#endif
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
/** Emitted when the application is running and the main event loop has
|
/** Emitted when the application is running and the main event loop has
|
||||||
* started. */
|
* started. */
|
||||||
@ -144,6 +159,8 @@ signals:
|
|||||||
void secondTick();
|
void secondTick();
|
||||||
/** Global timer every minute */
|
/** Global timer every minute */
|
||||||
void minuteTick();
|
void minuteTick();
|
||||||
|
/** Emitted when other process is connected */
|
||||||
|
void newArgsReceived(QStringList args);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
/** Called when the application's main event loop has started. This method
|
/** Called when the application's main event loop has started. This method
|
||||||
@ -151,27 +168,32 @@ private slots:
|
|||||||
* loop is running. */
|
* loop is running. */
|
||||||
void onEventLoopStarted();
|
void onEventLoopStarted();
|
||||||
void blinkTimer();
|
void blinkTimer();
|
||||||
|
/**
|
||||||
|
* @brief Called when accept new connection from new instance.
|
||||||
|
*/
|
||||||
|
void slotConnectionEstablished();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/** customize the date format (defaultlongformat) */
|
/** customize the date format (defaultlongformat) */
|
||||||
static void customizeDateFormat();
|
static void customizeDateFormat();
|
||||||
|
|
||||||
/** Parse the list of command-line arguments. */
|
|
||||||
void parseArguments(QStringList args);
|
|
||||||
/** Returns true if the specified arguments wants a value. */
|
/** Returns true if the specified arguments wants a value. */
|
||||||
bool argNeedsValue(QString argName);
|
static bool argNeedsValue(QString argName);
|
||||||
|
|
||||||
static QMap<QString, QString> _args; /**< List of command-line arguments. */
|
static QMap<QString, QString> _args; /**< List of command-line arguments. */
|
||||||
static QString _style; /**< The current GUI style. */
|
static QString _style; /**< The current GUI style. */
|
||||||
static QString _stylesheet; /**< The current GUI stylesheet. */
|
static QString _stylesheet; /**< The current GUI stylesheet. */
|
||||||
static QString _language; /**< The current language. */
|
static QString _language; /**< The current language. */
|
||||||
static QString _dateformat; /**< The format for dates in feed items etc. */
|
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 QDateTime mStartupTime; // startup time
|
||||||
|
|
||||||
static bool useConfigDir;
|
static bool useConfigDir;
|
||||||
static QString configDir;
|
static QString configDir;
|
||||||
bool mBlink;
|
bool mBlink;
|
||||||
|
static QLocalServer* localServer;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -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 <QCoreApplication>
|
|
||||||
#include <QMessageBox>
|
|
||||||
#include <QIcon>
|
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
#include <retroshare/rsinit.h>
|
|
||||||
|
|
||||||
#include "EventReceiver.h"
|
|
||||||
#include "gui/MainWindow.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());
|
|
||||||
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());
|
|
||||||
}
|
|
||||||
}
|
|
@ -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 <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 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
|
|
@ -1,7 +1,7 @@
|
|||||||
/****************************************************************
|
/****************************************************************
|
||||||
* This file is distributed under the following license:
|
* This file is distributed under the following license:
|
||||||
*
|
*
|
||||||
* Copyright (c) 2008, crypton
|
* Copyright (c) 2008, crypton
|
||||||
* Copyright (c) 2008, Matt Edman, Justin Hipple
|
* Copyright (c) 2008, Matt Edman, Justin Hipple
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or
|
* This program is free software; you can redistribute it and/or
|
||||||
@ -28,6 +28,11 @@
|
|||||||
|
|
||||||
#include "stringutil.h"
|
#include "stringutil.h"
|
||||||
|
|
||||||
|
//#define CHAR_ARRAY_TO_STRINGLIST_DEBUG
|
||||||
|
#ifdef CHAR_ARRAY_TO_STRINGLIST_DEBUG
|
||||||
|
#include <iostream>
|
||||||
|
#include <QFile>
|
||||||
|
#endif
|
||||||
|
|
||||||
/** Create a QStringList from the array of C-style strings. */
|
/** Create a QStringList from the array of C-style strings. */
|
||||||
QStringList
|
QStringList
|
||||||
@ -35,7 +40,20 @@ char_array_to_stringlist(char **arr, int len)
|
|||||||
{
|
{
|
||||||
QStringList list;
|
QStringList list;
|
||||||
for (int i = 0; i < len; i++) {
|
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;
|
return list;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user