Merge lp:~ballogy/indicator-datetime/systemd-support into lp:indicator-datetime/13.04

Proposed by Balló György
Status: Work in progress
Proposed branch: lp:~ballogy/indicator-datetime/systemd-support
Merge into: lp:indicator-datetime/13.04
Diff against target: 247 lines (+160/-0)
5 files modified
configure.ac (+13/-0)
src/Makefile.am (+30/-0)
src/datetime-service.c (+23/-0)
src/timedated1-interface.xml (+59/-0)
src/utils.c (+35/-0)
To merge this branch: bzr merge lp:~ballogy/indicator-datetime/systemd-support
Reviewer Review Type Date Requested Status
Mathieu Trudel-Lapierre Needs Resubmitting
Allison Karlitskaya (community) Disapprove
Review via email: mp+152233@code.launchpad.net

Description of the change

This change adds optional build support for reading current timezone with systemd-timedated[1] D-Bus interface instead of reading the /etc/timezone file. The /etc/timezone file is not available in a pure systemd system (e.g. on Arch Linux), so we need to read it with timedated.

The change is based on chenxiaolong's patch[2] and gnome-control-center's systemd-timedated port[3]:

[1] http://www.freedesktop.org/wiki/Software/systemd/timedated
[2] https://github.com/chenxiaolong/Unity-for-Arch/blob/master/indicator-datetime/0001_Port_to_systemd_timedated.patch
[3] https://git.gnome.org/browse/gnome-control-center/commit/?id=90f78394f60882b95793976c2d113b5f275acad5

To post a comment you must log in.
Revision history for this message
Sebastien Bacher (seb128) wrote :

thanks, that's a duplicate of the work done in https://code.launchpad.net/~desrt/indicator-datetime/timedated/+merge/151560 though...

Revision history for this message
Balló György (ballogy) wrote :

No, it's not for the same purpose. The linked merge request replaces gnome-settings-daemon datetime mechanism with timedated to SET the current timezone. But my merge request replaces reading /etc/timezone with timedated to GET the current timezone. The two changes should work together.

Revision history for this message
Allison Karlitskaya (desrt) wrote :

This patch is way too complicated. Since indicator-datetime will now depend on systemd unconditionally (after my branch merges) all of the extra checking is not needed.

Let's wait until that lands (which will be after systemd gets in main) and then see if we can make a more minimal patch based on that.

review: Disapprove
Revision history for this message
Balló György (ballogy) wrote :

Of course, the patch can be simplified if systemd become a dependency. I just put this patch here that works at the current state coexist with the existing method.

Revision history for this message
Mathieu Trudel-Lapierre (cyphermox) wrote :

Please resubmit against lp:indicator-datetime.

review: Needs Resubmitting

Unmerged revisions

211. By Balló György

Add systemd support

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'configure.ac'
2--- configure.ac 2013-01-17 21:17:40 +0000
3+++ configure.ac 2013-03-07 17:33:21 +0000
4@@ -112,6 +112,18 @@
5 AM_CONDITIONAL(BUILD_CCPANEL, test x${have_ccpanel} = xyes)
6
7 ###########################
8+# systemd support
9+###########################
10+AC_ARG_ENABLE([systemd],
11+ AC_HELP_STRING([--enable-systemd], [enable systemd support]),,
12+ [enable_systemd=no])
13+AM_CONDITIONAL([BUILD_SYSTEMD], [test "x$enable_systemd" != "xno"])
14+
15+if test "x$enable_systemd" != "xno"; then
16+ AC_DEFINE(HAVE_SYSTEMD, 1, [Define to 1 to enable systemd support])
17+fi
18+
19+###########################
20 # Grab the GSettings Macros
21 ###########################
22
23@@ -253,6 +265,7 @@
24 Indicator Dir: $INDICATORDIR
25 CC Panel: $have_ccpanel
26 CC Panel Dir: $CCPANELDIR
27+ systemd: $enable_systemd
28 Unit Tests: $enable_tests
29 gcov: $use_gcov
30 ])
31
32=== modified file 'src/Makefile.am'
33--- src/Makefile.am 2012-02-17 22:15:25 +0000
34+++ src/Makefile.am 2013-03-07 17:33:21 +0000
35@@ -4,6 +4,26 @@
36 ccpanel_LTLIBRARIES = libindicator-datetime.la
37 endif
38
39+if BUILD_SYSTEMD
40+# This requires running d-bus session and accessible timedate1 daemon
41+# FIXME: need to find a way how to filter out unnecessary d-bus stuff (introspectable, properties)
42+#timedated1-interface.xml:
43+# gdbus introspect \
44+# --xml \
45+# --system \
46+# --dest org.freedesktop.timedate1 \
47+# --object-path /org/freedesktop/timedate1 \
48+# > timedated1-interface.xml
49+
50+dbus_built_sources = timedated.c timedated.h
51+timedated.c: timedated.h
52+timedated.h: Makefile.am timedated1-interface.xml
53+ gdbus-codegen \
54+ --interface-prefix org.freedesktop. \
55+ --generate-c-code timedated \
56+ $(srcdir)/timedated1-interface.xml
57+endif
58+
59 libexec_PROGRAMS = indicator-datetime-service
60
61 indicator_datetime_service_SOURCES = \
62@@ -91,3 +111,13 @@
63
64 EXTRA_DIST = \
65 datetime-service.xml
66+
67+if BUILD_SYSTEMD
68+indicator_datetime_service_SOURCES += $(dbus_built_sources)
69+libdatetime_la_SOURCES += $(dbus_built_sources)
70+if BUILD_CCPANEL
71+libindicator_datetime_la_SOURCES += $(dbus_built_sources)
72+endif
73+CLEANFILES += $(dbus_built_sources)
74+EXTRA_DIST += timedated1-interface.xml
75+endif
76
77=== modified file 'src/datetime-service.c'
78--- src/datetime-service.c 2013-02-04 15:13:42 +0000
79+++ src/datetime-service.c 2013-03-07 17:33:21 +0000
80@@ -50,6 +50,9 @@
81 #include "dbus-shared.h"
82 #include "settings-shared.h"
83 #include "utils.h"
84+#ifdef HAVE_SYSTEMD
85+#include "timedated.h"
86+#endif
87
88 /* how often to check for clock skew */
89 #define SKEW_CHECK_INTERVAL_SEC 10
90@@ -1085,6 +1088,23 @@
91 static void
92 build_timezone (DatetimeInterface * dbus)
93 {
94+#ifdef HAVE_SYSTEMD
95+ GCancellable * cancellable = g_cancellable_new ();
96+ GError * error = NULL;
97+ Timedate1 * dtm = timedate1_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
98+ G_DBUS_PROXY_FLAGS_NONE,
99+ "org.freedesktop.timedate1",
100+ "/org/freedesktop/timedate1",
101+ cancellable,
102+ &error);
103+ if (dtm != NULL) {
104+ g_signal_connect_swapped (dtm, "notify::timezone",
105+ G_CALLBACK (timezone_changed), dbus);
106+ } else {
107+ g_warning ("could not get proxy for DateTimeMechanism: %s", error->message);
108+ g_error_free (error);
109+ }
110+#else
111 GFile * timezonefile = g_file_new_for_path(TIMEZONE_FILE);
112 GFileMonitor * monitor = g_file_monitor_file(timezonefile, G_FILE_MONITOR_NONE, NULL, NULL);
113 if (monitor != NULL) {
114@@ -1094,6 +1114,9 @@
115 g_warning("Unable to monitor timezone file: '" TIMEZONE_FILE "'");
116 }
117 g_object_unref(timezonefile);
118+
119+#endif /* HAVE_SYSTEMD */
120+
121 return;
122 }
123
124
125=== added file 'src/timedated1-interface.xml'
126--- src/timedated1-interface.xml 1970-01-01 00:00:00 +0000
127+++ src/timedated1-interface.xml 2013-03-07 17:33:21 +0000
128@@ -0,0 +1,59 @@
129+<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
130+"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
131+<node>
132+ <interface name="org.freedesktop.timedate1">
133+ <property name="Timezone" type="s" access="read"/>
134+ <property name="LocalRTC" type="b" access="read"/>
135+ <property name="NTP" type="b" access="read"/>
136+ <method name="SetTime">
137+ <arg name="usec_utc" type="x" direction="in"/>
138+ <arg name="relative" type="b" direction="in"/>
139+ <arg name="user_interaction" type="b" direction="in"/>
140+ </method>
141+ <method name="SetTimezone">
142+ <arg name="timezone" type="s" direction="in"/>
143+ <arg name="user_interaction" type="b" direction="in"/>
144+ </method>
145+ <method name="SetLocalRTC">
146+ <arg name="local_rtc" type="b" direction="in"/>
147+ <arg name="fix_system" type="b" direction="in"/>
148+ <arg name="user_interaction" type="b" direction="in"/>
149+ </method>
150+ <method name="SetNTP">
151+ <arg name="use_ntp" type="b" direction="in"/>
152+ <arg name="user_interaction" type="b" direction="in"/>
153+ </method>
154+ </interface>
155+ <interface name="org.freedesktop.DBus.Properties">
156+ <method name="Get">
157+ <arg name="interface" direction="in" type="s"/>
158+ <arg name="property" direction="in" type="s"/>
159+ <arg name="value" direction="out" type="v"/>
160+ </method>
161+ <method name="GetAll">
162+ <arg name="interface" direction="in" type="s"/>
163+ <arg name="properties" direction="out" type="a{sv}"/>
164+ </method>
165+ <method name="Set">
166+ <arg name="interface" direction="in" type="s"/>
167+ <arg name="property" direction="in" type="s"/>
168+ <arg name="value" direction="in" type="v"/>
169+ </method>
170+ <signal name="PropertiesChanged">
171+ <arg type="s" name="interface"/>
172+ <arg type="a{sv}" name="changed_properties"/>
173+ <arg type="as" name="invalidated_properties"/>
174+ </signal>
175+ </interface>
176+ <interface name="org.freedesktop.DBus.Introspectable">
177+ <method name="Introspect">
178+ <arg name="data" type="s" direction="out"/>
179+ </method>
180+ </interface>
181+<interface name="org.freedesktop.DBus.Peer">
182+ <method name="Ping"/>
183+ <method name="GetMachineId">
184+ <arg type="s" name="machine_uuid" direction="out"/>
185+ </method>
186+</interface>
187+</node>
188
189=== modified file 'src/utils.c'
190--- src/utils.c 2012-05-25 20:42:25 +0000
191+++ src/utils.c 2013-03-07 17:33:21 +0000
192@@ -31,6 +31,9 @@
193 #include <string.h>
194 #include "utils.h"
195 #include "settings-shared.h"
196+#ifdef HAVE_SYSTEMD
197+#include "timedated.h"
198+#endif
199
200 /* Check the system locale setting to see if the format is 24-hour
201 time or 12-hour time */
202@@ -121,6 +124,37 @@
203 read_timezone ()
204 {
205 GError * error = NULL;
206+
207+#ifdef HAVE_SYSTEMD
208+ const gchar * timezone;
209+ GCancellable * cancellable = g_cancellable_new ();
210+ Timedate1 * dtm = timedate1_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
211+ G_DBUS_PROXY_FLAGS_NONE,
212+ "org.freedesktop.timedate1",
213+ "/org/freedesktop/timedate1",
214+ cancellable,
215+ &error);
216+ if (dtm) {
217+ timezone = timedate1_get_timezone(dtm);
218+ } else {
219+ g_warning ("could not get proxy for DateTimeMechanism: %s", error->message);
220+ g_error_free (error);
221+ return NULL;
222+ }
223+
224+ gchar * rv = g_strdup(timezone);
225+
226+ if (cancellable) {
227+ g_cancellable_cancel (cancellable);
228+ g_object_unref (cancellable);
229+ cancellable = NULL;
230+ }
231+
232+ if (dtm) {
233+ g_object_unref (dtm);
234+ dtm = NULL;
235+ }
236+#else
237 gchar * tempzone = NULL;
238 if (!g_file_get_contents(TIMEZONE_FILE, &tempzone, NULL, &error)) {
239 g_warning("Unable to read timezone file '" TIMEZONE_FILE "': %s", error->message);
240@@ -137,6 +171,7 @@
241 for everyone else. */
242 gchar * rv = g_strdup(g_strstrip(tempzone));
243 g_free(tempzone);
244+#endif /* HAVE_SYSTEMD */
245
246 return rv;
247 }

Subscribers

People subscribed via source and target branches