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
=== modified file 'configure.ac'
--- configure.ac 2013-01-17 21:17:40 +0000
+++ configure.ac 2013-03-07 17:33:21 +0000
@@ -112,6 +112,18 @@
112AM_CONDITIONAL(BUILD_CCPANEL, test x${have_ccpanel} = xyes)112AM_CONDITIONAL(BUILD_CCPANEL, test x${have_ccpanel} = xyes)
113113
114###########################114###########################
115# systemd support
116###########################
117AC_ARG_ENABLE([systemd],
118 AC_HELP_STRING([--enable-systemd], [enable systemd support]),,
119 [enable_systemd=no])
120AM_CONDITIONAL([BUILD_SYSTEMD], [test "x$enable_systemd" != "xno"])
121
122if test "x$enable_systemd" != "xno"; then
123 AC_DEFINE(HAVE_SYSTEMD, 1, [Define to 1 to enable systemd support])
124fi
125
126###########################
115# Grab the GSettings Macros127# Grab the GSettings Macros
116###########################128###########################
117129
@@ -253,6 +265,7 @@
253 Indicator Dir: $INDICATORDIR265 Indicator Dir: $INDICATORDIR
254 CC Panel: $have_ccpanel266 CC Panel: $have_ccpanel
255 CC Panel Dir: $CCPANELDIR267 CC Panel Dir: $CCPANELDIR
268 systemd: $enable_systemd
256 Unit Tests: $enable_tests269 Unit Tests: $enable_tests
257 gcov: $use_gcov270 gcov: $use_gcov
258])271])
259272
=== modified file 'src/Makefile.am'
--- src/Makefile.am 2012-02-17 22:15:25 +0000
+++ src/Makefile.am 2013-03-07 17:33:21 +0000
@@ -4,6 +4,26 @@
4ccpanel_LTLIBRARIES = libindicator-datetime.la4ccpanel_LTLIBRARIES = libindicator-datetime.la
5endif5endif
66
7if BUILD_SYSTEMD
8# This requires running d-bus session and accessible timedate1 daemon
9# FIXME: need to find a way how to filter out unnecessary d-bus stuff (introspectable, properties)
10#timedated1-interface.xml:
11# gdbus introspect \
12# --xml \
13# --system \
14# --dest org.freedesktop.timedate1 \
15# --object-path /org/freedesktop/timedate1 \
16# > timedated1-interface.xml
17
18dbus_built_sources = timedated.c timedated.h
19timedated.c: timedated.h
20timedated.h: Makefile.am timedated1-interface.xml
21 gdbus-codegen \
22 --interface-prefix org.freedesktop. \
23 --generate-c-code timedated \
24 $(srcdir)/timedated1-interface.xml
25endif
26
7libexec_PROGRAMS = indicator-datetime-service27libexec_PROGRAMS = indicator-datetime-service
828
9indicator_datetime_service_SOURCES = \29indicator_datetime_service_SOURCES = \
@@ -91,3 +111,13 @@
91111
92EXTRA_DIST = \112EXTRA_DIST = \
93 datetime-service.xml113 datetime-service.xml
114
115if BUILD_SYSTEMD
116indicator_datetime_service_SOURCES += $(dbus_built_sources)
117libdatetime_la_SOURCES += $(dbus_built_sources)
118if BUILD_CCPANEL
119libindicator_datetime_la_SOURCES += $(dbus_built_sources)
120endif
121CLEANFILES += $(dbus_built_sources)
122EXTRA_DIST += timedated1-interface.xml
123endif
94124
=== modified file 'src/datetime-service.c'
--- src/datetime-service.c 2013-02-04 15:13:42 +0000
+++ src/datetime-service.c 2013-03-07 17:33:21 +0000
@@ -50,6 +50,9 @@
50#include "dbus-shared.h"50#include "dbus-shared.h"
51#include "settings-shared.h"51#include "settings-shared.h"
52#include "utils.h"52#include "utils.h"
53#ifdef HAVE_SYSTEMD
54#include "timedated.h"
55#endif
5356
54/* how often to check for clock skew */57/* how often to check for clock skew */
55#define SKEW_CHECK_INTERVAL_SEC 1058#define SKEW_CHECK_INTERVAL_SEC 10
@@ -1085,6 +1088,23 @@
1085static void1088static void
1086build_timezone (DatetimeInterface * dbus)1089build_timezone (DatetimeInterface * dbus)
1087{1090{
1091#ifdef HAVE_SYSTEMD
1092 GCancellable * cancellable = g_cancellable_new ();
1093 GError * error = NULL;
1094 Timedate1 * dtm = timedate1_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
1095 G_DBUS_PROXY_FLAGS_NONE,
1096 "org.freedesktop.timedate1",
1097 "/org/freedesktop/timedate1",
1098 cancellable,
1099 &error);
1100 if (dtm != NULL) {
1101 g_signal_connect_swapped (dtm, "notify::timezone",
1102 G_CALLBACK (timezone_changed), dbus);
1103 } else {
1104 g_warning ("could not get proxy for DateTimeMechanism: %s", error->message);
1105 g_error_free (error);
1106 }
1107#else
1088 GFile * timezonefile = g_file_new_for_path(TIMEZONE_FILE);1108 GFile * timezonefile = g_file_new_for_path(TIMEZONE_FILE);
1089 GFileMonitor * monitor = g_file_monitor_file(timezonefile, G_FILE_MONITOR_NONE, NULL, NULL);1109 GFileMonitor * monitor = g_file_monitor_file(timezonefile, G_FILE_MONITOR_NONE, NULL, NULL);
1090 if (monitor != NULL) {1110 if (monitor != NULL) {
@@ -1094,6 +1114,9 @@
1094 g_warning("Unable to monitor timezone file: '" TIMEZONE_FILE "'");1114 g_warning("Unable to monitor timezone file: '" TIMEZONE_FILE "'");
1095 }1115 }
1096 g_object_unref(timezonefile);1116 g_object_unref(timezonefile);
1117
1118#endif /* HAVE_SYSTEMD */
1119
1097 return;1120 return;
1098}1121}
10991122
11001123
=== added file 'src/timedated1-interface.xml'
--- src/timedated1-interface.xml 1970-01-01 00:00:00 +0000
+++ src/timedated1-interface.xml 2013-03-07 17:33:21 +0000
@@ -0,0 +1,59 @@
1<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
2"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
3<node>
4 <interface name="org.freedesktop.timedate1">
5 <property name="Timezone" type="s" access="read"/>
6 <property name="LocalRTC" type="b" access="read"/>
7 <property name="NTP" type="b" access="read"/>
8 <method name="SetTime">
9 <arg name="usec_utc" type="x" direction="in"/>
10 <arg name="relative" type="b" direction="in"/>
11 <arg name="user_interaction" type="b" direction="in"/>
12 </method>
13 <method name="SetTimezone">
14 <arg name="timezone" type="s" direction="in"/>
15 <arg name="user_interaction" type="b" direction="in"/>
16 </method>
17 <method name="SetLocalRTC">
18 <arg name="local_rtc" type="b" direction="in"/>
19 <arg name="fix_system" type="b" direction="in"/>
20 <arg name="user_interaction" type="b" direction="in"/>
21 </method>
22 <method name="SetNTP">
23 <arg name="use_ntp" type="b" direction="in"/>
24 <arg name="user_interaction" type="b" direction="in"/>
25 </method>
26 </interface>
27 <interface name="org.freedesktop.DBus.Properties">
28 <method name="Get">
29 <arg name="interface" direction="in" type="s"/>
30 <arg name="property" direction="in" type="s"/>
31 <arg name="value" direction="out" type="v"/>
32 </method>
33 <method name="GetAll">
34 <arg name="interface" direction="in" type="s"/>
35 <arg name="properties" direction="out" type="a{sv}"/>
36 </method>
37 <method name="Set">
38 <arg name="interface" direction="in" type="s"/>
39 <arg name="property" direction="in" type="s"/>
40 <arg name="value" direction="in" type="v"/>
41 </method>
42 <signal name="PropertiesChanged">
43 <arg type="s" name="interface"/>
44 <arg type="a{sv}" name="changed_properties"/>
45 <arg type="as" name="invalidated_properties"/>
46 </signal>
47 </interface>
48 <interface name="org.freedesktop.DBus.Introspectable">
49 <method name="Introspect">
50 <arg name="data" type="s" direction="out"/>
51 </method>
52 </interface>
53<interface name="org.freedesktop.DBus.Peer">
54 <method name="Ping"/>
55 <method name="GetMachineId">
56 <arg type="s" name="machine_uuid" direction="out"/>
57 </method>
58</interface>
59</node>
060
=== modified file 'src/utils.c'
--- src/utils.c 2012-05-25 20:42:25 +0000
+++ src/utils.c 2013-03-07 17:33:21 +0000
@@ -31,6 +31,9 @@
31#include <string.h>31#include <string.h>
32#include "utils.h"32#include "utils.h"
33#include "settings-shared.h"33#include "settings-shared.h"
34#ifdef HAVE_SYSTEMD
35#include "timedated.h"
36#endif
3437
35/* Check the system locale setting to see if the format is 24-hour38/* Check the system locale setting to see if the format is 24-hour
36 time or 12-hour time */39 time or 12-hour time */
@@ -121,6 +124,37 @@
121read_timezone ()124read_timezone ()
122{125{
123 GError * error = NULL;126 GError * error = NULL;
127
128#ifdef HAVE_SYSTEMD
129 const gchar * timezone;
130 GCancellable * cancellable = g_cancellable_new ();
131 Timedate1 * dtm = timedate1_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
132 G_DBUS_PROXY_FLAGS_NONE,
133 "org.freedesktop.timedate1",
134 "/org/freedesktop/timedate1",
135 cancellable,
136 &error);
137 if (dtm) {
138 timezone = timedate1_get_timezone(dtm);
139 } else {
140 g_warning ("could not get proxy for DateTimeMechanism: %s", error->message);
141 g_error_free (error);
142 return NULL;
143 }
144
145 gchar * rv = g_strdup(timezone);
146
147 if (cancellable) {
148 g_cancellable_cancel (cancellable);
149 g_object_unref (cancellable);
150 cancellable = NULL;
151 }
152
153 if (dtm) {
154 g_object_unref (dtm);
155 dtm = NULL;
156 }
157#else
124 gchar * tempzone = NULL;158 gchar * tempzone = NULL;
125 if (!g_file_get_contents(TIMEZONE_FILE, &tempzone, NULL, &error)) {159 if (!g_file_get_contents(TIMEZONE_FILE, &tempzone, NULL, &error)) {
126 g_warning("Unable to read timezone file '" TIMEZONE_FILE "': %s", error->message);160 g_warning("Unable to read timezone file '" TIMEZONE_FILE "': %s", error->message);
@@ -137,6 +171,7 @@
137 for everyone else. */171 for everyone else. */
138 gchar * rv = g_strdup(g_strstrip(tempzone));172 gchar * rv = g_strdup(g_strstrip(tempzone));
139 g_free(tempzone);173 g_free(tempzone);
174#endif /* HAVE_SYSTEMD */
140175
141 return rv;176 return rv;
142}177}

Subscribers

People subscribed via source and target branches