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