From 64e965f7b2cc99f1f0ddd94169d4c1c166b96ac4 Mon Sep 17 00:00:00 2001 From: Javier Date: Sat, 4 Apr 2015 03:00:21 +0200 Subject: make boostable, add systemd service --- rpm/saltoq.spec | 19 +++++++++++++++++++ rpm/saltoq.yaml | 3 ++- saltoqd/main.cpp | 2 +- saltoqd/saltoqd.pro | 12 +++++++++--- saltoqd/saltoqd.service | 11 +++++++++++ saltoqd/settingsmanager.cpp | 11 +++++++++++ saltoqd/settingsmanager.h | 21 +++++++++++++++++++++ saltoqd/storagemanager.cpp | 4 ++-- saltoqd/toqmanager.cpp | 2 ++ saltoqd/toqmanager.h | 2 ++ 10 files changed, 80 insertions(+), 7 deletions(-) create mode 100644 saltoqd/saltoqd.service create mode 100644 saltoqd/settingsmanager.cpp create mode 100644 saltoqd/settingsmanager.h diff --git a/rpm/saltoq.spec b/rpm/saltoq.spec index 5b8cb72..cb629a6 100644 --- a/rpm/saltoq.spec +++ b/rpm/saltoq.spec @@ -32,6 +32,7 @@ BuildRequires: pkgconfig(Qt5Quick) BuildRequires: pkgconfig(Qt5DBus) BuildRequires: pkgconfig(Qt5Bluetooth) >= 5.2 BuildRequires: pkgconfig(Qt5Contacts) +BuildRequires: pkgconfig(qt5-boostable) BuildRequires: pkgconfig(mlite5) BuildRequires: pkgconfig(libiphb) BuildRequires: pkgconfig(zlib) @@ -72,8 +73,26 @@ rm -rf %{buildroot} # >> install post # << install post +%post +# >> post +if [ "$1" -ge 1 ]; then +grep -q "^/usr/bin/saltoqd" /usr/share/mapplauncherd/privileges || echo "/usr/bin/saltoqd,chmp" >> /usr/share/mapplauncherd/privileges +systemctl-user daemon-reload || : +systemctl-user restart saltoqd.service || : +fi +# << post + +%postun +# >> postun +if [ "$1" -eq 0 ]; then +systemctl-user stop saltoqd.service || : +systemctl-user daemon-reload || : +fi +# << postun + %files %defattr(-,root,root,-) %{_bindir} +%{_libdir}/systemd/user/saltoqd.service # >> files # << files diff --git a/rpm/saltoq.yaml b/rpm/saltoq.yaml index fc205a4..f82b9ef 100644 --- a/rpm/saltoq.yaml +++ b/rpm/saltoq.yaml @@ -20,6 +20,7 @@ PkgConfigBR: - Qt5DBus - Qt5Bluetooth >= 5.2 - Qt5Contacts + - qt5-boostable - mlite5 - libiphb - zlib @@ -45,4 +46,4 @@ Files: # - '%{_datadir}/%{name}' # - '%{_datadir}/applications/%{name}.desktop' # - '%{_datadir}/icons/hicolor/86x86/apps/%{name}.png' -# - '%{_libdir}/systemd/user/salmeta.service' + - '%{_libdir}/systemd/user/saltoqd.service' diff --git a/saltoqd/main.cpp b/saltoqd/main.cpp index 6fa4257..4910dca 100644 --- a/saltoqd/main.cpp +++ b/saltoqd/main.cpp @@ -1,7 +1,7 @@ #include #include "toqmanager.h" -int main(int argc, char **argv) +Q_DECL_EXPORT int main(int argc, char **argv) { QCoreApplication app(argc, argv); diff --git a/saltoqd/saltoqd.pro b/saltoqd/saltoqd.pro index 983475c..d7cb076 100644 --- a/saltoqd/saltoqd.pro +++ b/saltoqd/saltoqd.pro @@ -5,7 +5,7 @@ QT += dbus bluetooth contacts CONFIG += c++11 link_pkgconfig -PKGCONFIG += zlib dbus-1 mlite5 commhistory-qt5 openobex qtcontacts-sqlite-qt5-extensions libmkcal-qt5 libkcalcoren-qt5 +PKGCONFIG += qt5-boostable zlib dbus-1 mlite5 commhistory-qt5 openobex qtcontacts-sqlite-qt5-extensions libmkcal-qt5 libkcalcoren-qt5 INCLUDEPATH += /usr/include/dbus-1.0 /usr/include/mlite5 /usr/include/commhistory-qt5 /usr/include/mkcal-qt5 /usr/include/kcalcoren-qt5 SOURCES += main.cpp \ @@ -24,7 +24,8 @@ SOURCES += main.cpp \ contactsmanager.cpp \ cardmanager.cpp \ agendamanager.cpp \ - settings.cpp + settings.cpp \ + settingsmanager.cpp HEADERS += \ toqconnection.h \ @@ -42,7 +43,8 @@ HEADERS += \ contactsmanager.h \ cardmanager.h \ agendamanager.h \ - settings.h + settings.h \ + settingsmanager.h DBUS_ADAPTORS += org.freedesktop.Notifications.xml @@ -51,3 +53,7 @@ QDBUSXML2CPP_INTERFACE_HEADER_FLAGS = -i voicecallmanager.h target.path = /usr/bin INSTALLS += target + +unit.path = /usr/lib/systemd/user/ +unit.files = saltoqd.service +INSTALLS += unit diff --git a/saltoqd/saltoqd.service b/saltoqd/saltoqd.service new file mode 100644 index 0000000..c1f15b4 --- /dev/null +++ b/saltoqd/saltoqd.service @@ -0,0 +1,11 @@ +[Unit] +Description=Saltoq MetaWatch manager daemon +Requires=dbus.socket bluetooth.target booster-qt5.service +After=lipstick.service dbus.socket bluetooth.target booster-qt5.service + +[Service] +ExecStart=/usr/bin/invoker -o --type=qt5 /usr/bin/salmeta --daemon +Restart=always + +[Install] +WantedBy=user-session.target diff --git a/saltoqd/settingsmanager.cpp b/saltoqd/settingsmanager.cpp new file mode 100644 index 0000000..8ec107b --- /dev/null +++ b/saltoqd/settingsmanager.cpp @@ -0,0 +1,11 @@ +#include "settingsmanager.h" + +SettingsManager::SettingsManager(Settings *settings, FmsManager *fms, ToqManager *toq) : + QObject(toq), _toq(toq), _fms(fms), _settings(settings) +{ +} + +void SettingsManager::sync() +{ + // Understand and upload FMS file "/settings/usersettings.jsn" +} diff --git a/saltoqd/settingsmanager.h b/saltoqd/settingsmanager.h new file mode 100644 index 0000000..857228c --- /dev/null +++ b/saltoqd/settingsmanager.h @@ -0,0 +1,21 @@ +#ifndef SETTINGSMANAGER_H +#define SETTINGSMANAGER_H + +#include "toqmanager.h" + +class SettingsManager : public QObject +{ + Q_OBJECT +public: + explicit SettingsManager(Settings *settings, FmsManager *fms, ToqManager *toq); + +public slots: + void sync(); + +private: + ToqManager *_toq; + FmsManager *_fms; + Settings *_settings; +}; + +#endif // SETTINGSMANAGER_H diff --git a/saltoqd/storagemanager.cpp b/saltoqd/storagemanager.cpp index c88f36c..1d4d325 100644 --- a/saltoqd/storagemanager.cpp +++ b/saltoqd/storagemanager.cpp @@ -2,9 +2,9 @@ #include "obexconnection.h" #include "storagemanager.h" -static QString generate_send_name(const QString &store, int checksum) +static QString generate_send_name(const QString &store, ulong checksum) { - return QString("%1_%2.jsn").arg(store).arg(qint64(checksum)); + return QString("%1_%2.jsn").arg(store).arg(checksum); } StorageManager::StorageManager(ObexConnection *obex, ToqManager *toq) : diff --git a/saltoqd/toqmanager.cpp b/saltoqd/toqmanager.cpp index ea59874..dcc22f4 100644 --- a/saltoqd/toqmanager.cpp +++ b/saltoqd/toqmanager.cpp @@ -6,6 +6,7 @@ #include "systemmanager.h" #include "fmsmanager.h" #include "storagemanager.h" +#include "settingsmanager.h" #include "musicmanager.h" #include "contactsmanager.h" #include "commmanager.h" @@ -25,6 +26,7 @@ ToqManager::ToqManager(Settings *settings, QObject *parent) : _systemManager(new SystemManager(this)), _fmsManager(new FmsManager(_obex, this)), _storageManager(new StorageManager(_obex, this)), + _settingsManager(new SettingsManager(_settings, _fmsManager, this)), _musicManager(new MusicManager(this)), _contactsManager(new ContactsManager(_storageManager, this)), _commManager(new CommManager(_settings, _storageManager, _contactsManager, this)), diff --git a/saltoqd/toqmanager.h b/saltoqd/toqmanager.h index 0333fa7..422884d 100644 --- a/saltoqd/toqmanager.h +++ b/saltoqd/toqmanager.h @@ -11,6 +11,7 @@ class VersionManager; class SystemManager; class FmsManager; class StorageManager; +class SettingsManager; class MusicManager; class ContactsManager; class CommManager; @@ -65,6 +66,7 @@ private: SystemManager *_systemManager; FmsManager *_fmsManager; StorageManager *_storageManager; + SettingsManager *_settingsManager; MusicManager *_musicManager; ContactsManager *_contactsManager; CommManager *_commManager; -- cgit v1.2.3