Skip to content

Commit

Permalink
[timed] Expose alarm_present and alarm_triggers via dbus instead of s…
Browse files Browse the repository at this point in the history
…tatefs/contextkit. Contributes to JB#47493

Add these to com.nokia.time dbus API:
- get_alarm_present() function and alarm_present_changed() notifier
- get_alarm_triggers() function (notifiers already exist in API)

Remove dependencies on statefs/contextkit.
  • Loading branch information
Bea Lam committed Jan 13, 2020
1 parent 337a0af commit ba40824
Show file tree
Hide file tree
Showing 9 changed files with 74 additions and 197 deletions.
18 changes: 1 addition & 17 deletions rpm/timed-qt5.spec
Expand Up @@ -12,7 +12,6 @@ Requires: tzdata
Requires: tzdata-timed
Requires: systemd
Requires: oneshot
Requires: statefs
Requires: sailfish-setup >= 0.1.10
%{_oneshot_requires_post}
Requires(post): /sbin/ldconfig
Expand All @@ -23,12 +22,9 @@ BuildRequires: pkgconfig(Qt5DBus)
BuildRequires: pkgconfig(Qt5Test)
BuildRequires: pkgconfig(dsme_dbus_if)
BuildRequires: pkgconfig(systemd)
BuildRequires: pkgconfig(statefs)
BuildRequires: libiodata-qt5-devel >= 0.19
BuildRequires: libxslt
BuildRequires: oneshot
BuildRequires: pkgconfig(statefs-qt5)
BuildRequires: statefs-devel >= 0.3.21
BuildRequires: pkgconfig(sailfishaccesscontrol) >= 0.0.1

%description
Expand Down Expand Up @@ -97,10 +93,6 @@ install -d %{buildroot}/var/lib/timed/shared_settings
# Make /etc/localtime a link to /var/lib/timed/localtime to make system time zone follow timed.
install -d %{buildroot}%{_sysconfdir}
ln -sf /var/lib/timed/localtime %{buildroot}%{_sysconfdir}/localtime
%statefs_provider_install inout timed %{_sysconfdir}/timed-statefs.conf

%pre
%statefs_pre

%post
# Remove existing link so that copying the UTC file will not overwrite anything during reinstall.
Expand All @@ -115,8 +107,6 @@ systemctl-user restart %{name}.service || :
fi

%preun
%statefs_preun
%statefs_provider_unregister inout timed
if [ "$1" -eq 0 ]; then
systemctl-user stop %{name}.service || :
fi
Expand All @@ -127,13 +117,8 @@ if [ "$1" -eq 0 ]; then
systemctl-user stop {%name}.service || :
systemctl-user daemon-reload || :
fi
%statefs_postun

%posttrans
%statefs_provider_register inout timed
%statefs_posttrans

%files -f timed.files
%files
%defattr(-,root,root,-)
%license COPYING copyright
%{_sysconfdir}/dbus-1/system.d/%{name}.conf
Expand All @@ -142,7 +127,6 @@ fi
%{_bindir}/%{name}
%{_libdir}/lib%{name}.so.*
%{_libdir}/libtimed-voland-qt5.so.*
%{_datadir}/contextkit/providers/com.nokia.time.context
%{_datadir}/mapplauncherd/privileges.d/*
%{_libdir}/systemd/user/%{name}.service
%{_libdir}/systemd/user/pre-user-session.target.wants/%{name}.service
Expand Down
24 changes: 24 additions & 0 deletions src/lib/interface.cpp
@@ -1,6 +1,8 @@
/***************************************************************************
** **
** Copyright (C) 2009-2011 Nokia Corporation. **
** Copyright (C) 2013-2019 Jolla Ltd. **
** Copyright (c) 2019 Open Mobile Platform LLC. **
** **
** Author: Ilya Dogolazky <ilya.dogolazky@nokia.com> **
** Author: Simo Piiroinen <simo.piiroinen@nokia.com> **
Expand Down Expand Up @@ -46,8 +48,30 @@ bool Maemo::Timed::Interface::settings_changed_disconnect(QObject *object, const
return Maemo::Timed::bus().disconnect(s,o,i,"settings_changed",object,slot) ;
}

bool Maemo::Timed::Interface::alarm_present_changed_connect(QObject *object, const char *slot)
{
const char *s = Maemo::Timed::service();
const char *o = Maemo::Timed::objpath();
const char *i = Maemo::Timed::interface();
const char *alarm_present_changed_signal = SIGNAL(alarm_present_changed(bool));
if (QObject::connect(this, alarm_present_changed_signal, object, slot)) {
QObject::disconnect(this, alarm_present_changed_signal, object, slot);
return Maemo::Timed::bus().connect(s, o, i, "alarm_present_changed", object, slot);
}
return false;
}

bool Maemo::Timed::Interface::alarm_present_changed_disconnect(QObject *object, const char *slot)
{
const char *s = Maemo::Timed::service();
const char *o = Maemo::Timed::objpath();
const char *i = Maemo::Timed::interface();
return Maemo::Timed::bus().disconnect(s, o, i, "alarm_present_changed", object, slot);
}

bool Maemo::Timed::Interface::alarm_triggers_changed_connect(QObject *object, const char *slot)
{

const char *s = Maemo::Timed::service();
const char *o = Maemo::Timed::objpath();
const char *i = Maemo::Timed::interface();
Expand Down
9 changes: 8 additions & 1 deletion src/lib/interface.h
@@ -1,6 +1,8 @@
/***************************************************************************
** **
** Copyright (C) 2009-2011 Nokia Corporation. **
** Copyright (c) 2009-2011 Nokia Corporation. **
** Copyright (C) 2013-2019 Jolla Ltd. **
** Copyright (c) 2019 Open Mobile Platform LLC. **
** **
** Author: Ilya Dogolazky <ilya.dogolazky@nokia.com> **
** Author: Simo Piiroinen <simo.piiroinen@nokia.com> **
Expand Down Expand Up @@ -77,13 +79,16 @@ namespace Maemo
// void xxx(bool yyy) { /* emit settings_changed_1(yyy) ; */ }
signals:
void settings_changed(const Maemo::Timed::WallClock::Info &info, bool time_changed) ;
void alarm_present_changed(bool present);
void alarm_triggers_changed(Maemo::Timed::Event::Triggers);
// void settings_changed_1(bool time_changed) ;
public:
Interface(QObject *parent=NULL) ;
// -- dbus signals -- //
bool settings_changed_connect(QObject *object, const char *slot) ;
bool settings_changed_disconnect(QObject *object, const char *slot) ;
bool alarm_present_changed_connect(QObject *object, const char *slot);
bool alarm_present_changed_disconnect(QObject *object, const char *slot);
bool alarm_triggers_changed_connect(QObject *object, const char *slot);
bool alarm_triggers_changed_disconnect(QObject *object, const char *slot);
// -- application methods -- //
Expand All @@ -108,6 +113,8 @@ namespace Maemo
qtdbus_method(set_app_snooze, (const QString &name, int value), name, value) ;
qtdbus_method(get_app_snooze, (const QString &name), name) ;
qtdbus_method(remove_app_snooze, (const QString &name), name) ;
qtdbus_method(get_alarm_present, (void));
qtdbus_method(get_alarm_triggers, (void));
// -- to be called by voland -- //
qtdbus_method(dialog_response, (uint32_t cookie, int button), cookie, button) ;
// -- not documented stuff -- //
Expand Down
15 changes: 15 additions & 0 deletions src/server/adaptor.h
Expand Up @@ -80,6 +80,7 @@ class com_nokia_time : public QDBusAbstractAdaptor
void settings_changed(const Maemo::Timed::WallClock::Info &, bool) ;
void settings_changed_1(bool) ;
void next_bootup_event(int next_boot_event, int next_non_boot_event);
void alarm_present_changed(bool present);
void alarm_triggers_changed(Maemo::Timed::Event::Triggers);

public slots:
Expand Down Expand Up @@ -295,6 +296,20 @@ public slots:
timed->settings->remove_app_snooze(name.toStdString()) ;
}

bool get_alarm_present(const QDBusMessage &message)
{
Q_UNUSED(message);
log_notice("DBUS::com.nokia.time.get_alarm_present() by %s", PEER) ;
return timed->get_alarm_present() ;
}

Maemo::Timed::Event::Triggers get_alarm_triggers(const QDBusMessage &message)
{
Q_UNUSED(message);
log_notice("DBUS::com.nokia.time.get_alarm_triggers() by %s", PEER) ;
return timed->get_alarm_triggers() ;
}

void halt(const QString &what, const QDBusMessage &message)
{
Q_UNUSED(message);
Expand Down
123 changes: 0 additions & 123 deletions src/server/com.nokia.time.context

This file was deleted.

9 changes: 0 additions & 9 deletions src/server/server.pro
Expand Up @@ -91,12 +91,9 @@ PKGCONFIG += libpcrecpp libsystemd-daemon
PKGCONFIG += sailfishaccesscontrol
equals(QT_MAJOR_VERSION, 4) {
CONFIG += iodata
PKGCONFIG += contextprovider-1.0
}
equals(QT_MAJOR_VERSION, 5) {
QMAKE_CXXFLAGS += -std=c++0x # required by statefs-qt5
CONFIG += iodata-qt5
PKGCONFIG += statefs-qt5
}


Expand All @@ -106,9 +103,6 @@ CONFIG(dsme_dbus_if) {

target.path = $$(DESTDIR)/usr/bin

xml.files = com.nokia.time.context
xml.path = $$(DESTDIR)/usr/share/contextkit/providers

equals(QT_MAJOR_VERSION, 4) {
timedrc.files = timed.rc
dbusconf.files = timed.conf
Expand All @@ -120,9 +114,6 @@ equals(QT_MAJOR_VERSION, 5) {
dbusconf.files = timed-qt5.conf
systemd.files = timed-qt5.service
oneshot.files = setcaps-timed-qt5.sh
statefs.files = timed-statefs.conf
statefs.path = /etc
INSTALLS += statefs
}
timedrc.path = $$(DESTDIR)/etc
dbusconf.path = $$(DESTDIR)/etc/dbus-1/system.d
Expand Down
4 changes: 0 additions & 4 deletions src/server/timed-statefs.conf

This file was deleted.

0 comments on commit ba40824

Please sign in to comment.