logic: Fixed cli message handling and Mac build
This commit is contained in:
+8
-19
@@ -13,7 +13,6 @@
|
|||||||
#include "project/SourceGroupFactoryModuleCpp.h"
|
#include "project/SourceGroupFactoryModuleCpp.h"
|
||||||
#include "project/SourceGroupFactoryModuleJava.h"
|
#include "project/SourceGroupFactoryModuleJava.h"
|
||||||
#include "qt/network/QtNetworkFactory.h"
|
#include "qt/network/QtNetworkFactory.h"
|
||||||
#include <QCoreApplication>
|
|
||||||
#include "qt/QtApplication.h"
|
#include "qt/QtApplication.h"
|
||||||
#include "qt/QtCoreApplication.h"
|
#include "qt/QtCoreApplication.h"
|
||||||
#include "qt/utility/utilityQt.h"
|
#include "qt/utility/utilityQt.h"
|
||||||
@@ -26,6 +25,7 @@
|
|||||||
#include "utility/logging/logging.h"
|
#include "utility/logging/logging.h"
|
||||||
#include "utility/logging/LogManager.h"
|
#include "utility/logging/LogManager.h"
|
||||||
#include "utility/messaging/type/MessageEnteredLicense.h"
|
#include "utility/messaging/type/MessageEnteredLicense.h"
|
||||||
|
#include "utility/messaging/type/MessageInterruptTasks.h"
|
||||||
#include "utility/messaging/type/MessageLoadProject.h"
|
#include "utility/messaging/type/MessageLoadProject.h"
|
||||||
#include "utility/messaging/type/MessageStatus.h"
|
#include "utility/messaging/type/MessageStatus.h"
|
||||||
#include "utility/ResourcePaths.h"
|
#include "utility/ResourcePaths.h"
|
||||||
@@ -36,17 +36,10 @@
|
|||||||
#include "utility/Version.h"
|
#include "utility/Version.h"
|
||||||
#include "version.h"
|
#include "version.h"
|
||||||
|
|
||||||
void signalHandler( int signum )
|
void signalHandler(int signum)
|
||||||
{
|
{
|
||||||
std::string s;
|
std::cout << "interrupt running tasks" << std::endl;
|
||||||
std::cout << "interrupt are you sure(Y/n):" << std::flush;
|
MessageInterruptTasks().dispatch();
|
||||||
std::cin >> s;
|
|
||||||
std::cout << "\n*******\n" << s << "\n*******\n" << std::endl;
|
|
||||||
if (s == "Y" || s == "y")
|
|
||||||
{
|
|
||||||
std::cout << "quit()" << std::endl;
|
|
||||||
QCoreApplication::quit();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void setupLogging()
|
void setupLogging()
|
||||||
@@ -232,11 +225,10 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
if (commandLineParser.runWithoutGUI())
|
if (commandLineParser.runWithoutGUI())
|
||||||
{
|
{
|
||||||
|
|
||||||
commandLineParser.parse();
|
commandLineParser.parse();
|
||||||
if (commandLineParser.startedWithLicense())
|
if (commandLineParser.startedWithLicense())
|
||||||
{
|
{
|
||||||
qobject_cast<QtCoreApplication*>(qtApp.data())->saveLicense(commandLineParser.getLicense());
|
utility::saveLicense(commandLineParser.getLicensePtr());
|
||||||
}
|
}
|
||||||
if (commandLineParser.exitApplication())
|
if (commandLineParser.exitApplication())
|
||||||
{
|
{
|
||||||
@@ -285,14 +277,13 @@ int main(int argc, char *argv[])
|
|||||||
#else
|
#else
|
||||||
struct sigaction sa;
|
struct sigaction sa;
|
||||||
sa.sa_handler = signalHandler;
|
sa.sa_handler = signalHandler;
|
||||||
sa.sa_flags = 0;
|
sigemptyset(&sa.sa_mask);
|
||||||
::sigemptyset(&sa.sa_mask);
|
|
||||||
sa.sa_flags = SA_RESTART;
|
sa.sa_flags = SA_RESTART;
|
||||||
if(::sigaction(SIGINT, &sa, NULL))
|
if (sigaction(SIGINT, &sa, NULL))
|
||||||
{
|
{
|
||||||
std::cout << "Cant install SIGINT handler" << std::endl;
|
std::cout << "Cant install SIGINT handler" << std::endl;
|
||||||
}
|
}
|
||||||
if(::sigaction(SIGHUP, &sa, NULL))
|
if (sigaction(SIGHUP, &sa, NULL))
|
||||||
{
|
{
|
||||||
std::cout << "Cant install SIGHUP handler" << std::endl;
|
std::cout << "Cant install SIGHUP handler" << std::endl;
|
||||||
}
|
}
|
||||||
@@ -318,9 +309,7 @@ int main(int argc, char *argv[])
|
|||||||
).dispatch();
|
).dispatch();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int exitcode = qtApp->exec();
|
int exitcode = qtApp->exec();
|
||||||
|
|
||||||
return exitcode;
|
return exitcode;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+18
-8
@@ -231,10 +231,6 @@ void Application::refreshProject(bool force)
|
|||||||
m_componentManager->refreshViews();
|
m_componentManager->refreshViews();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (!m_hasGUI)
|
|
||||||
{
|
|
||||||
MessageQuitApplication().dispatch();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -263,6 +259,10 @@ void Application::handleMessage(MessageFinishedParsing* message)
|
|||||||
{
|
{
|
||||||
MessageRefresh().refreshUiOnly().dispatch();
|
MessageRefresh().refreshUiOnly().dispatch();
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MessageQuitApplication().dispatch();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::handleMessage(MessageLoadProject* message)
|
void Application::handleMessage(MessageLoadProject* message)
|
||||||
@@ -275,17 +275,27 @@ void Application::handleMessage(MessageLoadProject* message)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!m_project || projectSettingsFilePath != m_project->getProjectSettingsFilePath())
|
if (m_project && projectSettingsFilePath == m_project->getProjectSettingsFilePath())
|
||||||
{
|
{
|
||||||
createAndLoadProject(projectSettingsFilePath);
|
if (message->forceRefresh && m_hasGUI)
|
||||||
|
{
|
||||||
|
m_project->setStateSettingsUpdated();
|
||||||
|
refreshProject(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
createAndLoadProject(projectSettingsFilePath);
|
||||||
|
|
||||||
if (message->forceRefresh)
|
if (message->forceRefresh)
|
||||||
{
|
{
|
||||||
m_project->setStateSettingsUpdated();
|
refreshProject(true);
|
||||||
|
}
|
||||||
|
else if (!m_hasGUI)
|
||||||
|
{
|
||||||
refreshProject(false);
|
refreshProject(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::handleMessage(MessageRefresh* message)
|
void Application::handleMessage(MessageRefresh* message)
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
#include "component/view/DialogView.h"
|
#include "component/view/DialogView.h"
|
||||||
#include "data/storage/PersistentStorage.h"
|
#include "data/storage/PersistentStorage.h"
|
||||||
#include "utility/messaging/type/MessageFinishedParsing.h"
|
#include "utility/messaging/type/MessageFinishedParsing.h"
|
||||||
#include "utility/messaging/type/MessageQuitApplication.h"
|
|
||||||
#include "utility/messaging/type/MessageStatus.h"
|
#include "utility/messaging/type/MessageStatus.h"
|
||||||
#include "utility/scheduling/Blackboard.h"
|
#include "utility/scheduling/Blackboard.h"
|
||||||
#include "utility/utility.h"
|
#include "utility/utility.h"
|
||||||
@@ -42,11 +41,6 @@ Task::TaskState TaskFinishParsing::doUpdate(std::shared_ptr<Blackboard> blackboa
|
|||||||
dialogView->hideUnknownProgressDialog();
|
dialogView->hideUnknownProgressDialog();
|
||||||
MessageFinishedParsing().dispatch();
|
MessageFinishedParsing().dispatch();
|
||||||
|
|
||||||
if (!Application::getInstance()->hasGUI())
|
|
||||||
{
|
|
||||||
MessageQuitApplication().dispatch();
|
|
||||||
}
|
|
||||||
|
|
||||||
float time = utility::duration(start);
|
float time = utility::duration(start);
|
||||||
|
|
||||||
if (blackboard->exists("clear_time"))
|
if (blackboard->exists("clear_time"))
|
||||||
@@ -104,9 +98,4 @@ void TaskFinishParsing::terminate()
|
|||||||
|
|
||||||
MessageStatus("An unknown exception was thrown during indexing.", true, false).dispatch();
|
MessageStatus("An unknown exception was thrown during indexing.", true, false).dispatch();
|
||||||
MessageFinishedParsing().dispatch();
|
MessageFinishedParsing().dispatch();
|
||||||
|
|
||||||
if (!Application::getInstance()->hasGUI())
|
|
||||||
{
|
|
||||||
MessageQuitApplication().dispatch();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -260,20 +260,16 @@ void Project::load()
|
|||||||
m_storage->buildCaches();
|
m_storage->buildCaches();
|
||||||
m_storageAccessProxy->setSubject(m_storage.get());
|
m_storageAccessProxy->setSubject(m_storage.get());
|
||||||
|
|
||||||
MessageFinishedParsing().dispatch();
|
if (Application::getInstance()->hasGUI())
|
||||||
|
{
|
||||||
|
MessageFinishedParsing().dispatch();
|
||||||
|
}
|
||||||
MessageStatus("Finished Loading", false, false).dispatch();
|
MessageStatus("Finished Loading", false, false).dispatch();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
MessageStatus("Project not loaded", false, false).dispatch();
|
MessageStatus("Project not loaded", false, false).dispatch();
|
||||||
}
|
}
|
||||||
|
|
||||||
// refresh always on headless
|
|
||||||
// since just opening a project in headless does not make sense
|
|
||||||
if (m_state != PROJECT_STATE_LOADED || !Application::getInstance()->hasGUI())
|
|
||||||
{
|
|
||||||
MessageRefresh().dispatch();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Project::requestIndex(bool forceRefresh, bool needsFullRefresh)
|
bool Project::requestIndex(bool forceRefresh, bool needsFullRefresh)
|
||||||
@@ -396,6 +392,11 @@ bool Project::requestIndex(bool forceRefresh, bool needsFullRefresh)
|
|||||||
|
|
||||||
if (!filesToClean.size() && !filesToIndex.size())
|
if (!filesToClean.size() && !filesToIndex.size())
|
||||||
{
|
{
|
||||||
|
if (!Application::getInstance()->hasGUI())
|
||||||
|
{
|
||||||
|
MessageFinishedParsing().dispatch();
|
||||||
|
}
|
||||||
|
|
||||||
MessageStatus("Nothing to refresh, all files are up-to-date.").dispatch();
|
MessageStatus("Nothing to refresh, all files are up-to-date.").dispatch();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,19 +2,9 @@
|
|||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
#include "settings/ApplicationSettings.h"
|
|
||||||
#include "utility/file/FilePath.h"
|
|
||||||
#include "utility/logging/logging.h"
|
|
||||||
#include "utility/AppPath.h"
|
|
||||||
#include "utility/UserPaths.h"
|
|
||||||
#include "utility/utilityApp.h"
|
|
||||||
#include "License.h"
|
|
||||||
|
|
||||||
QtCoreApplication::QtCoreApplication(int argc, char **argv )
|
QtCoreApplication::QtCoreApplication(int argc, char **argv )
|
||||||
: QCoreApplication(argc, argv)
|
: QCoreApplication(argc, argv)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QtCoreApplication::~QtCoreApplication()
|
QtCoreApplication::~QtCoreApplication()
|
||||||
@@ -23,6 +13,7 @@ QtCoreApplication::~QtCoreApplication()
|
|||||||
|
|
||||||
void QtCoreApplication::handleMessage(MessageQuitApplication* message)
|
void QtCoreApplication::handleMessage(MessageQuitApplication* message)
|
||||||
{
|
{
|
||||||
|
std::cout << "quit" << std::endl;
|
||||||
emit quit();
|
emit quit();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -30,8 +21,3 @@ void QtCoreApplication::handleMessage(MessageStatus* message)
|
|||||||
{
|
{
|
||||||
std::cout << message->status << std::endl;
|
std::cout << message->status << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QtCoreApplication::saveLicense(License license)
|
|
||||||
{
|
|
||||||
return utility::saveLicense(&license);
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -2,30 +2,25 @@
|
|||||||
#define QT_COREAPPLICTION_H
|
#define QT_COREAPPLICTION_H
|
||||||
|
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
|
|
||||||
#include "utility/messaging/MessageListener.h"
|
#include "utility/messaging/MessageListener.h"
|
||||||
#include "utility/messaging/type/MessageQuitApplication.h"
|
#include "utility/messaging/type/MessageQuitApplication.h"
|
||||||
#include "utility/messaging/type/MessageStatus.h"
|
#include "utility/messaging/type/MessageStatus.h"
|
||||||
|
|
||||||
class License;
|
|
||||||
class UnixSignalWatcher;
|
|
||||||
|
|
||||||
class QtCoreApplication
|
class QtCoreApplication
|
||||||
: public QCoreApplication
|
: public QCoreApplication
|
||||||
, public MessageListener<MessageQuitApplication>
|
, public MessageListener<MessageQuitApplication>
|
||||||
, public MessageListener<MessageStatus>
|
, public MessageListener<MessageStatus>
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QtCoreApplication(int argc, char **argv);
|
QtCoreApplication(int argc, char **argv);
|
||||||
virtual ~QtCoreApplication();
|
virtual ~QtCoreApplication();
|
||||||
bool saveLicense(License license);
|
|
||||||
signals:
|
|
||||||
void quitSignal();
|
|
||||||
private:
|
private:
|
||||||
virtual void handleMessage(MessageQuitApplication* message);
|
virtual void handleMessage(MessageQuitApplication* message);
|
||||||
virtual void handleMessage(MessageStatus* message);
|
virtual void handleMessage(MessageStatus* message);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif // QT_COREAPPLICATION
|
#endif // QT_COREAPPLICATION
|
||||||
|
|
||||||
|
|||||||
@@ -104,16 +104,17 @@ int utility::getIdealThreadCount()
|
|||||||
return QThread::idealThreadCount();
|
return QThread::idealThreadCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool utility::saveLicense(License* license)
|
bool utility::saveLicense(const License* license)
|
||||||
{
|
{
|
||||||
if (license == nullptr)
|
if (license == nullptr)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (license->isValid())
|
if (license->isValid())
|
||||||
{
|
{
|
||||||
ApplicationSettings* appSettings = ApplicationSettings::getInstance().get();
|
ApplicationSettings* appSettings = ApplicationSettings::getInstance().get();
|
||||||
if (appSettings == NULL)
|
if (appSettings == nullptr)
|
||||||
{
|
{
|
||||||
LOG_ERROR_STREAM(<< "Unable to retrieve app settings");
|
LOG_ERROR_STREAM(<< "Unable to retrieve app settings");
|
||||||
return false;
|
return false;
|
||||||
@@ -121,10 +122,8 @@ bool utility::saveLicense(License* license)
|
|||||||
|
|
||||||
std::string appLocation = AppPath::getAppPath();
|
std::string appLocation = AppPath::getAppPath();
|
||||||
appSettings->setLicenseString(license->getLicenseEncodedString(appLocation));
|
appSettings->setLicenseString(license->getLicenseEncodedString(appLocation));
|
||||||
FilePath p(appLocation);
|
appSettings->setLicenseCheck(license->hashLocation(FilePath(appLocation).absolute().str()));
|
||||||
appSettings->setLicenseCheck(license->hashLocation(p.absolute().str()));
|
appSettings->save();
|
||||||
appSettings->save(UserPaths::getAppSettingsPath());
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -19,7 +19,8 @@ namespace utility
|
|||||||
int getIdealThreadCount();
|
int getIdealThreadCount();
|
||||||
|
|
||||||
OsType getOsType();
|
OsType getOsType();
|
||||||
bool saveLicense(License* license);
|
|
||||||
|
bool saveLicense(const License* license);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // UTILITY_APP_H
|
#endif // UTILITY_APP_H
|
||||||
|
|||||||
@@ -491,7 +491,7 @@ std::string License::getLicenseString() const
|
|||||||
return license;
|
return license;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string License::hashLocation(const std::string& location)
|
std::string License::hashLocation(const std::string& location) const
|
||||||
{
|
{
|
||||||
if (m_rng == NULL || location.size() <= 0)
|
if (m_rng == NULL || location.size() <= 0)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -100,7 +100,7 @@ public:
|
|||||||
|
|
||||||
void print();
|
void print();
|
||||||
|
|
||||||
std::string hashLocation(const std::string&);
|
std::string hashLocation(const std::string&) const;
|
||||||
static bool checkLocation(const std::string&, const std::string&);
|
static bool checkLocation(const std::string&, const std::string&);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
Reference in New Issue
Block a user