2015-04-16 11:50:07 -05:00
|
|
|
/*
|
|
|
|
Copyright (C) 2010 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 "mainwindow.h"
|
|
|
|
#include "../common/ostprotolib.h"
|
|
|
|
#include "../common/protocolmanager.h"
|
|
|
|
#include "../common/protocolwidgetfactory.h"
|
2016-10-13 08:20:33 -05:00
|
|
|
#include "params.h"
|
2015-04-16 11:50:07 -05:00
|
|
|
#include "preferences.h"
|
|
|
|
#include "settings.h"
|
2021-12-24 10:06:14 -06:00
|
|
|
#include "thememanager.h"
|
2015-04-16 11:50:07 -05:00
|
|
|
|
|
|
|
#include <QApplication>
|
2016-03-07 10:10:48 -06:00
|
|
|
#include <QDateTime>
|
2015-04-16 11:50:07 -05:00
|
|
|
#include <QFile>
|
|
|
|
#include <QSettings>
|
2016-03-07 10:10:48 -06:00
|
|
|
#include <QtGlobal>
|
2015-04-16 11:50:07 -05:00
|
|
|
|
|
|
|
#include <google/protobuf/stubs/common.h>
|
|
|
|
|
|
|
|
extern const char* version;
|
|
|
|
extern const char* revision;
|
|
|
|
extern ProtocolManager *OstProtocolManager;
|
|
|
|
extern ProtocolWidgetFactory *OstProtocolWidgetFactory;
|
|
|
|
|
2016-10-13 08:20:33 -05:00
|
|
|
Params appParams;
|
2015-04-16 11:50:07 -05:00
|
|
|
QSettings *appSettings;
|
|
|
|
QMainWindow *mainWindow;
|
|
|
|
|
2019-07-02 07:45:26 -05:00
|
|
|
void NoMsgHandler(QtMsgType type, const QMessageLogContext &context,
|
|
|
|
const QString &msg);
|
|
|
|
|
2015-04-16 11:50:07 -05:00
|
|
|
int main(int argc, char* argv[])
|
|
|
|
{
|
|
|
|
QApplication app(argc, argv);
|
|
|
|
int exitCode;
|
|
|
|
|
|
|
|
app.setApplicationName("Ostinato");
|
|
|
|
app.setOrganizationName("Ostinato");
|
|
|
|
app.setProperty("version", version);
|
|
|
|
app.setProperty("revision", revision);
|
|
|
|
|
2016-10-13 08:20:33 -05:00
|
|
|
appParams.parseCommandLine(argc, argv);
|
|
|
|
|
2019-07-02 07:45:26 -05:00
|
|
|
#ifndef QT_DEBUG // Release mode
|
|
|
|
if (appParams.optLogsDisabled())
|
|
|
|
qInstallMessageHandler(NoMsgHandler);
|
|
|
|
#endif
|
|
|
|
|
2015-04-16 11:50:07 -05:00
|
|
|
OstProtocolManager = new ProtocolManager();
|
|
|
|
OstProtocolWidgetFactory = new ProtocolWidgetFactory();
|
|
|
|
|
2020-04-09 08:13:00 -05:00
|
|
|
Preferences::initDefaults();
|
|
|
|
|
2015-04-16 11:50:07 -05:00
|
|
|
/* (Portable Mode) If we have a .ini file in the same directory as the
|
|
|
|
executable, we use that instead of the platform specific location
|
|
|
|
and format for the settings */
|
|
|
|
QString portableIni = QCoreApplication::applicationDirPath()
|
|
|
|
+ "/ostinato.ini";
|
|
|
|
if (QFile::exists(portableIni))
|
|
|
|
appSettings = new QSettings(portableIni, QSettings::IniFormat);
|
|
|
|
else
|
|
|
|
appSettings = new QSettings();
|
2020-05-06 07:22:18 -05:00
|
|
|
qDebug("Settings: %s", qPrintable(appSettings->fileName()));
|
2015-04-16 11:50:07 -05:00
|
|
|
|
|
|
|
OstProtoLib::setExternalApplicationPaths(
|
|
|
|
appSettings->value(kTsharkPathKey, kTsharkPathDefaultValue).toString(),
|
|
|
|
appSettings->value(kGzipPathKey, kGzipPathDefaultValue).toString(),
|
|
|
|
appSettings->value(kDiffPathKey, kDiffPathDefaultValue).toString(),
|
|
|
|
appSettings->value(kAwkPathKey, kAwkPathDefaultValue).toString());
|
|
|
|
|
2021-12-24 10:06:14 -06:00
|
|
|
ThemeManager::instance()->setTheme(appSettings->value(kThemeKey).toString());
|
|
|
|
|
2016-03-07 10:10:48 -06:00
|
|
|
qsrand(QDateTime::currentDateTime().toTime_t());
|
2015-04-16 11:50:07 -05:00
|
|
|
|
|
|
|
mainWindow = new MainWindow;
|
|
|
|
mainWindow->show();
|
|
|
|
exitCode = app.exec();
|
|
|
|
|
|
|
|
delete mainWindow;
|
|
|
|
delete appSettings;
|
|
|
|
delete OstProtocolManager;
|
|
|
|
google::protobuf::ShutdownProtobufLibrary();
|
|
|
|
|
|
|
|
return exitCode;
|
|
|
|
}
|
2019-07-02 07:45:26 -05:00
|
|
|
|
|
|
|
void NoMsgHandler(QtMsgType type, const QMessageLogContext &/*context*/,
|
|
|
|
const QString &msg)
|
|
|
|
{
|
|
|
|
if (type == QtFatalMsg) {
|
2019-07-02 08:44:38 -05:00
|
|
|
fprintf(stderr, "%s\n", qPrintable(msg));
|
2019-07-02 07:45:26 -05:00
|
|
|
fflush(stderr);
|
|
|
|
abort();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|