diff --git a/guh.pri b/guh.pri index 23d81e02..5e43e254 100644 --- a/guh.pri +++ b/guh.pri @@ -32,10 +32,10 @@ enable433gpio { DEFINES += GPIO433 } -# check websocket support (sonce Qt 5.3) -equals(QT_MAJOR_VERSION, 5):greaterThan(QT_MINOR_VERSION, 2) { - DEFINES += WEBSOCKET +snappy { + DEFINES += SNAPPY } + top_srcdir=$$PWD top_builddir=$$shadowed($$PWD) diff --git a/guh.pro b/guh.pro index 0fa6f8ac..c5acc823 100644 --- a/guh.pro +++ b/guh.pro @@ -74,7 +74,7 @@ contains(DEFINES, GPIO433){ message("Radio 433 for GPIO's disabled") } -snappy { +contains(DEFINES, SNAPPY){ message("Building Ubuntu snappy package.") meta.files = meta/package.yaml \ meta/readme.md \ @@ -86,15 +86,19 @@ snappy { wrapper.path = /usr/bin/ # We need to bring our own Qt libs, at least for now - qtlibs.files=/usr/lib/arm-linux-gnueabihf/libQt5Network.so.5 \ - /usr/lib/arm-linux-gnueabihf/libQt5Sql.so.5 \ - /usr/lib/arm-linux-gnueabihf/libQt5Core.so.5 \ - /usr/lib/arm-linux-gnueabihf/libicui18n.so.52 \ - /usr/lib/arm-linux-gnueabihf/libicuuc.so.52 \ - /usr/lib/arm-linux-gnueabihf/libicudata.so.52 - qtlibs.path=/usr/lib/ + qtlibs.files = /usr/lib/arm-linux-gnueabihf/libQt5Network.so.5 \ + /usr/lib/arm-linux-gnueabihf/libQt5Sql.so.5 \ + /usr/lib/arm-linux-gnueabihf/libQt5Core.so.5 \ + /usr/lib/arm-linux-gnueabihf/libQt5Test.so.5 \ + /usr/lib/arm-linux-gnueabihf/libQt5Gui.so.5 \ + /usr/lib/arm-linux-gnueabihf/libicui18n.so.52 \ + /usr/lib/arm-linux-gnueabihf/libicuuc.so.52 \ + /usr/lib/arm-linux-gnueabihf/libicudata.so.52 + qtlibs.path = /usr/lib/ - DEFINES += SNAPPY + # install sqlite driver + sqlplugin.files = /usr/lib/arm-linux-gnueabihf/qt5/plugins/sqldrivers/libqsqlite.so + sqlplugin.path = /usr/lib/qt5/plugins/sqldrivers/ - INSTALLS += meta wrapper qtlibs + INSTALLS += meta wrapper qtlibs sqlplugin } diff --git a/libguh/guhsettings.cpp b/libguh/guhsettings.cpp index 0bb98868..c4830f63 100644 --- a/libguh/guhsettings.cpp +++ b/libguh/guhsettings.cpp @@ -61,6 +61,36 @@ GuhSettings::GuhSettings(const SettingsRole &role, QObject *parent): QObject(parent), m_role(role) { + +#ifdef SNAPPY + QString settingsFile; + switch (role) { + case SettingsRoleNone: + break; + case SettingsRoleDevices: + settingsFile = "config/devices.conf"; + m_settings = new QSettings(settingsFile, QSettings::IniFormat, this); + qDebug() << "Created device settings" << m_settings->fileName(); + break; + case SettingsRoleRules: + settingsFile = "config/rules.conf"; + m_settings = new QSettings(settingsFile, QSettings::IniFormat, this); + qDebug() << "Created rule settings" << m_settings->fileName(); + break; + case SettingsRolePlugins: + settingsFile = "config/plugins.conf"; + m_settings = new QSettings(settingsFile, QSettings::IniFormat, this); + qDebug() << "Created plugin settings" << m_settings->fileName(); + break; + case SettingsRoleGlobal: + settingsFile = "config/guhd.conf"; + m_settings = new QSettings(settingsFile, QSettings::IniFormat, this); + qDebug() << "Created guhd settings" << m_settings->fileName(); + break; + default: + break; + } +#else QString settingsFile; QString settingsPrefix = QCoreApplication::instance()->organizationName(); bool rootPrivilege = isRoot(); @@ -115,6 +145,7 @@ GuhSettings::GuhSettings(const SettingsRole &role, QObject *parent): default: break; } +#endif // SNAPPY } /*! Destructor of the GuhSettings.*/ @@ -146,6 +177,9 @@ bool GuhSettings::isRoot() QString GuhSettings::logPath() { QString logPath; +#ifdef SNAPPY + logPath = "/var/log/guhd.log"; +#else QString organisationName = QCoreApplication::instance()->organizationName(); if (organisationName == "guh-test") { @@ -155,7 +189,7 @@ QString GuhSettings::logPath() } else { logPath = QDir::homePath() + "/.config/" + organisationName + "/guhd.sqlite"; } - +#endif // SNAPPY return logPath; } diff --git a/meta/guhd-wrapper.sh b/meta/guhd-wrapper.sh index 8a889523..c25c58c1 100755 --- a/meta/guhd-wrapper.sh +++ b/meta/guhd-wrapper.sh @@ -1,4 +1,5 @@ #!/bin/sh +export QT_PLUGIN_PATH=$SNAPP_APP_PATH/usr/lib/qt5/plugins export LD_LIBRARY_PATH=$SNAPP_APP_PATH/usr/lib:$LD_LIBRARY_PATH -$SNAPP_APP_PATH/usr/bin/guhd -n +$SNAPP_APP_PATH/usr/bin/guhd -n -d LogEngine diff --git a/meta/package.yaml b/meta/package.yaml index 48b02ce9..64f7dba4 100644 --- a/meta/package.yaml +++ b/meta/package.yaml @@ -3,6 +3,8 @@ version: 0.1.0 vendor: Simon Stürz architecture: [armhf] icon: meta/guh-logo.svg +source: https://github.com/guh/guh +license-version: "GPLv2" services: - name: guhd start: usr/bin/guhd-wrapper.sh @@ -11,4 +13,3 @@ services: caps: - networking - network-service - diff --git a/server/logging/logengine.cpp b/server/logging/logengine.cpp index 5dbf65ed..321fb480 100644 --- a/server/logging/logengine.cpp +++ b/server/logging/logengine.cpp @@ -122,6 +122,8 @@ namespace guhserver { LogEngine::LogEngine(QObject *parent): QObject(parent) { + qCDebug(dcLogEngine) << "Using log file" << GuhSettings::logPath(); + m_db = QSqlDatabase::addDatabase("QSQLITE"); m_db.setDatabaseName(GuhSettings::logPath()); m_dbMaxSize = 8000;