diff --git a/client/main.cpp b/client/main.cpp
index 34f689e..1507eef 100644
--- a/client/main.cpp
+++ b/client/main.cpp
@@ -21,6 +21,7 @@ along with this program. If not, see
#include "../common/ostprotolib.h"
#include "../common/protocolmanager.h"
#include "../common/protocolwidgetfactory.h"
+#include "params.h"
#include "preferences.h"
#include "settings.h"
@@ -37,6 +38,7 @@ extern const char* revision;
extern ProtocolManager *OstProtocolManager;
extern ProtocolWidgetFactory *OstProtocolWidgetFactory;
+Params appParams;
QSettings *appSettings;
QMainWindow *mainWindow;
@@ -50,6 +52,8 @@ int main(int argc, char* argv[])
app.setProperty("version", version);
app.setProperty("revision", revision);
+ appParams.parseCommandLine(argc, argv);
+
OstProtocolManager = new ProtocolManager();
OstProtocolWidgetFactory = new ProtocolWidgetFactory();
diff --git a/client/mainwindow.cpp b/client/mainwindow.cpp
index 212fdcf..8c881d7 100644
--- a/client/mainwindow.cpp
+++ b/client/mainwindow.cpp
@@ -23,6 +23,7 @@ along with this program. If not, see
#include "dbgthread.h"
#endif
+#include "params.h"
#include "portgrouplist.h"
#include "portstatswindow.h"
#include "portswindow.h"
@@ -50,23 +51,28 @@ PortGroupList *pgl;
MainWindow::MainWindow(QWidget *parent)
: QMainWindow (parent)
{
- QString serverApp = QCoreApplication::applicationDirPath();
Updater *updater = new Updater();
+ if (appParams.optLocalDrone()) {
+ QString serverApp = QCoreApplication::applicationDirPath();
#ifdef Q_OS_MAC
- // applicationDirPath() does not return bundle, but executable inside bundle
- serverApp.replace("Ostinato.app", "drone.app");
+ // applicationDirPath() does not return bundle,
+ // but executable inside bundle
+ serverApp.replace("Ostinato.app", "drone.app");
#endif
-
#ifdef Q_OS_WIN32
- serverApp.append("/drone.exe");
+ serverApp.append("/drone.exe");
#else
- serverApp.append("/drone");
+ serverApp.append("/drone");
#endif
- localServer_ = new QProcess(this);
- localServer_->setProcessChannelMode(QProcess::ForwardedChannels);
- localServer_->start(serverApp, QStringList());
+ qDebug("staring local server - %s", qPrintable(serverApp));
+ localServer_ = new QProcess(this);
+ localServer_->setProcessChannelMode(QProcess::ForwardedChannels);
+ localServer_->start(serverApp, QStringList());
+ }
+ else
+ localServer_ = NULL;
pgl = new PortGroupList;
@@ -124,12 +130,14 @@ MainWindow::MainWindow(QWidget *parent)
MainWindow::~MainWindow()
{
+ if (localServer_) {
#ifdef Q_OS_WIN32
- //! \todo - find a way to terminate cleanly
- localServer_->kill();
+ //! \todo - find a way to terminate cleanly
+ localServer_->kill();
#else
- localServer_->terminate();
+ localServer_->terminate();
#endif
+ }
delete pgl;
@@ -137,8 +145,10 @@ MainWindow::~MainWindow()
appSettings->setValue(kApplicationWindowLayout, layout);
appSettings->setValue(kApplicationWindowGeometryKey, geometry());
- localServer_->waitForFinished();
- delete localServer_;
+ if (localServer_) {
+ localServer_->waitForFinished();
+ delete localServer_;
+ }
}
void MainWindow::on_actionOpenSession_triggered()
diff --git a/client/ostinato.pro b/client/ostinato.pro
index e4773ea..aca28e4 100644
--- a/client/ostinato.pro
+++ b/client/ostinato.pro
@@ -86,6 +86,7 @@ SOURCES += \
mainwindow.cpp \
ndpstatusmodel.cpp \
packetmodel.cpp \
+ params.cpp \
port.cpp \
portconfigdialog.cpp \
portgroup.cpp \
diff --git a/client/params.cpp b/client/params.cpp
new file mode 100644
index 0000000..8af44f2
--- /dev/null
+++ b/client/params.cpp
@@ -0,0 +1,65 @@
+/*
+Copyright (C) 2016 Srivats P.
+
+This file is part of "Ostinato"
+
+This 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 3 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, see
+*/
+
+#include "params.h"
+
+#include
+
+Params::Params()
+{
+ localDrone_ = true;
+}
+
+int Params::parseCommandLine(int argc, char* argv[])
+{
+ int c, n = 0;
+
+ opterr = 0;
+ while ((c = getopt (argc, argv, "s")) != -1) {
+ switch (c)
+ {
+ case 's':
+ localDrone_ = false;
+ break;
+ default:
+ qDebug("ignoring unrecognized option (%c)", c);
+ }
+ n++;
+ }
+
+ for (int i = optind; i < argc; i++, n++)
+ args_ << argv[i];
+
+ return n;
+}
+
+bool Params::optLocalDrone()
+{
+ return localDrone_;
+}
+
+int Params::argumentCount()
+{
+ return args_.size();
+}
+
+QString Params::argument(int index)
+{
+ return index < args_.size() ? args_.at(index) : QString();
+}
diff --git a/client/params.h b/client/params.h
new file mode 100644
index 0000000..a5ebc2f
--- /dev/null
+++ b/client/params.h
@@ -0,0 +1,43 @@
+/*
+Copyright (C) 2016 Srivats P.
+
+This file is part of "Ostinato"
+
+This 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 3 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, see
+*/
+
+#ifndef _PARAMS_H
+#define _PARAMS_H
+
+#include
+
+class Params {
+public:
+ Params();
+ int parseCommandLine(int argc, char* argv[]);
+
+ bool optLocalDrone();
+
+ int argumentCount();
+ QString argument(int index);
+
+private:
+ bool localDrone_;
+ QStringList args_;
+};
+
+extern Params appParams;
+
+#endif
+
diff --git a/client/portgrouplist.cpp b/client/portgrouplist.cpp
index 6e380a0..79f500d 100644
--- a/client/portgrouplist.cpp
+++ b/client/portgrouplist.cpp
@@ -19,6 +19,8 @@ along with this program. If not, see
#include "portgrouplist.h"
+#include "params.h"
+
// TODO(LOW): Remove
#include
@@ -29,8 +31,6 @@ PortGroupList::PortGroupList()
mDeviceGroupModel(this),
mDeviceModel(this)
{
- PortGroup *pg;
-
#ifdef QT_NO_DEBUG
streamModelTester_ = NULL;
portModelTester_ = NULL;
@@ -46,8 +46,10 @@ PortGroupList::PortGroupList()
#endif
// Add the "Local" Port Group
- pg = new PortGroup;
- addPortGroup(*pg);
+ if (appParams.optLocalDrone()) {
+ PortGroup *pg = new PortGroup;
+ addPortGroup(*pg);
+ }
}
PortGroupList::~PortGroupList()