Added ostinato cmdline option -s to suppress starting local drone
This commit is contained in:
parent
6a426a7a7e
commit
708aed9135
@ -21,6 +21,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
|||||||
#include "../common/ostprotolib.h"
|
#include "../common/ostprotolib.h"
|
||||||
#include "../common/protocolmanager.h"
|
#include "../common/protocolmanager.h"
|
||||||
#include "../common/protocolwidgetfactory.h"
|
#include "../common/protocolwidgetfactory.h"
|
||||||
|
#include "params.h"
|
||||||
#include "preferences.h"
|
#include "preferences.h"
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
|
|
||||||
@ -37,6 +38,7 @@ extern const char* revision;
|
|||||||
extern ProtocolManager *OstProtocolManager;
|
extern ProtocolManager *OstProtocolManager;
|
||||||
extern ProtocolWidgetFactory *OstProtocolWidgetFactory;
|
extern ProtocolWidgetFactory *OstProtocolWidgetFactory;
|
||||||
|
|
||||||
|
Params appParams;
|
||||||
QSettings *appSettings;
|
QSettings *appSettings;
|
||||||
QMainWindow *mainWindow;
|
QMainWindow *mainWindow;
|
||||||
|
|
||||||
@ -50,6 +52,8 @@ int main(int argc, char* argv[])
|
|||||||
app.setProperty("version", version);
|
app.setProperty("version", version);
|
||||||
app.setProperty("revision", revision);
|
app.setProperty("revision", revision);
|
||||||
|
|
||||||
|
appParams.parseCommandLine(argc, argv);
|
||||||
|
|
||||||
OstProtocolManager = new ProtocolManager();
|
OstProtocolManager = new ProtocolManager();
|
||||||
OstProtocolWidgetFactory = new ProtocolWidgetFactory();
|
OstProtocolWidgetFactory = new ProtocolWidgetFactory();
|
||||||
|
|
||||||
|
@ -23,6 +23,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
|||||||
#include "dbgthread.h"
|
#include "dbgthread.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "params.h"
|
||||||
#include "portgrouplist.h"
|
#include "portgrouplist.h"
|
||||||
#include "portstatswindow.h"
|
#include "portstatswindow.h"
|
||||||
#include "portswindow.h"
|
#include "portswindow.h"
|
||||||
@ -50,23 +51,28 @@ PortGroupList *pgl;
|
|||||||
MainWindow::MainWindow(QWidget *parent)
|
MainWindow::MainWindow(QWidget *parent)
|
||||||
: QMainWindow (parent)
|
: QMainWindow (parent)
|
||||||
{
|
{
|
||||||
QString serverApp = QCoreApplication::applicationDirPath();
|
|
||||||
Updater *updater = new Updater();
|
Updater *updater = new Updater();
|
||||||
|
|
||||||
|
if (appParams.optLocalDrone()) {
|
||||||
|
QString serverApp = QCoreApplication::applicationDirPath();
|
||||||
#ifdef Q_OS_MAC
|
#ifdef Q_OS_MAC
|
||||||
// applicationDirPath() does not return bundle, but executable inside bundle
|
// applicationDirPath() does not return bundle,
|
||||||
serverApp.replace("Ostinato.app", "drone.app");
|
// but executable inside bundle
|
||||||
|
serverApp.replace("Ostinato.app", "drone.app");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef Q_OS_WIN32
|
#ifdef Q_OS_WIN32
|
||||||
serverApp.append("/drone.exe");
|
serverApp.append("/drone.exe");
|
||||||
#else
|
#else
|
||||||
serverApp.append("/drone");
|
serverApp.append("/drone");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
localServer_ = new QProcess(this);
|
qDebug("staring local server - %s", qPrintable(serverApp));
|
||||||
localServer_->setProcessChannelMode(QProcess::ForwardedChannels);
|
localServer_ = new QProcess(this);
|
||||||
localServer_->start(serverApp, QStringList());
|
localServer_->setProcessChannelMode(QProcess::ForwardedChannels);
|
||||||
|
localServer_->start(serverApp, QStringList());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
localServer_ = NULL;
|
||||||
|
|
||||||
pgl = new PortGroupList;
|
pgl = new PortGroupList;
|
||||||
|
|
||||||
@ -124,12 +130,14 @@ MainWindow::MainWindow(QWidget *parent)
|
|||||||
|
|
||||||
MainWindow::~MainWindow()
|
MainWindow::~MainWindow()
|
||||||
{
|
{
|
||||||
|
if (localServer_) {
|
||||||
#ifdef Q_OS_WIN32
|
#ifdef Q_OS_WIN32
|
||||||
//! \todo - find a way to terminate cleanly
|
//! \todo - find a way to terminate cleanly
|
||||||
localServer_->kill();
|
localServer_->kill();
|
||||||
#else
|
#else
|
||||||
localServer_->terminate();
|
localServer_->terminate();
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
delete pgl;
|
delete pgl;
|
||||||
|
|
||||||
@ -137,8 +145,10 @@ MainWindow::~MainWindow()
|
|||||||
appSettings->setValue(kApplicationWindowLayout, layout);
|
appSettings->setValue(kApplicationWindowLayout, layout);
|
||||||
appSettings->setValue(kApplicationWindowGeometryKey, geometry());
|
appSettings->setValue(kApplicationWindowGeometryKey, geometry());
|
||||||
|
|
||||||
localServer_->waitForFinished();
|
if (localServer_) {
|
||||||
delete localServer_;
|
localServer_->waitForFinished();
|
||||||
|
delete localServer_;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_actionOpenSession_triggered()
|
void MainWindow::on_actionOpenSession_triggered()
|
||||||
|
@ -86,6 +86,7 @@ SOURCES += \
|
|||||||
mainwindow.cpp \
|
mainwindow.cpp \
|
||||||
ndpstatusmodel.cpp \
|
ndpstatusmodel.cpp \
|
||||||
packetmodel.cpp \
|
packetmodel.cpp \
|
||||||
|
params.cpp \
|
||||||
port.cpp \
|
port.cpp \
|
||||||
portconfigdialog.cpp \
|
portconfigdialog.cpp \
|
||||||
portgroup.cpp \
|
portgroup.cpp \
|
||||||
|
65
client/params.cpp
Normal file
65
client/params.cpp
Normal file
@ -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 <http://www.gnu.org/licenses/>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "params.h"
|
||||||
|
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
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();
|
||||||
|
}
|
43
client/params.h
Normal file
43
client/params.h
Normal file
@ -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 <http://www.gnu.org/licenses/>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _PARAMS_H
|
||||||
|
#define _PARAMS_H
|
||||||
|
|
||||||
|
#include <QStringList>
|
||||||
|
|
||||||
|
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
|
||||||
|
|
@ -19,6 +19,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
|||||||
|
|
||||||
#include "portgrouplist.h"
|
#include "portgrouplist.h"
|
||||||
|
|
||||||
|
#include "params.h"
|
||||||
|
|
||||||
// TODO(LOW): Remove
|
// TODO(LOW): Remove
|
||||||
#include <modeltest.h>
|
#include <modeltest.h>
|
||||||
|
|
||||||
@ -29,8 +31,6 @@ PortGroupList::PortGroupList()
|
|||||||
mDeviceGroupModel(this),
|
mDeviceGroupModel(this),
|
||||||
mDeviceModel(this)
|
mDeviceModel(this)
|
||||||
{
|
{
|
||||||
PortGroup *pg;
|
|
||||||
|
|
||||||
#ifdef QT_NO_DEBUG
|
#ifdef QT_NO_DEBUG
|
||||||
streamModelTester_ = NULL;
|
streamModelTester_ = NULL;
|
||||||
portModelTester_ = NULL;
|
portModelTester_ = NULL;
|
||||||
@ -46,8 +46,10 @@ PortGroupList::PortGroupList()
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Add the "Local" Port Group
|
// Add the "Local" Port Group
|
||||||
pg = new PortGroup;
|
if (appParams.optLocalDrone()) {
|
||||||
addPortGroup(*pg);
|
PortGroup *pg = new PortGroup;
|
||||||
|
addPortGroup(*pg);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PortGroupList::~PortGroupList()
|
PortGroupList::~PortGroupList()
|
||||||
|
Loading…
Reference in New Issue
Block a user