first working version of snappy

pull/135/head
Simon Stürz 2015-07-09 14:13:40 +02:00 committed by Michael Zanetti
parent edb0ca45ce
commit e553439b63
6 changed files with 58 additions and 16 deletions

View File

@ -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)

24
guh.pro
View File

@ -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
}

View File

@ -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;
}

View File

@ -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

View File

@ -3,6 +3,8 @@ version: 0.1.0
vendor: Simon Stürz <simon.stuerz@guh.guru>
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

View File

@ -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;