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/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();
|
||||
|
||||
|
@ -23,6 +23,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
#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()
|
||||
|
@ -86,6 +86,7 @@ SOURCES += \
|
||||
mainwindow.cpp \
|
||||
ndpstatusmodel.cpp \
|
||||
packetmodel.cpp \
|
||||
params.cpp \
|
||||
port.cpp \
|
||||
portconfigdialog.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 "params.h"
|
||||
|
||||
// TODO(LOW): Remove
|
||||
#include <modeltest.h>
|
||||
|
||||
@ -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()
|
||||
|
Loading…
Reference in New Issue
Block a user