Merge lp:~charlesk/indicator-datetime/timezone-class-privacy into lp:indicator-datetime/13.10

Proposed by Charles Kerr
Status: Merged
Approved by: Ted Gould
Approved revision: 378
Merged at revision: 379
Proposed branch: lp:~charlesk/indicator-datetime/timezone-class-privacy
Merge into: lp:indicator-datetime/13.10
Diff against target: 798 lines (+368/-319)
6 files modified
include/datetime/clock.h (+0/-2)
include/datetime/timezone-file.h (+5/-14)
include/datetime/timezone-geoclue.h (+4/-20)
src/timezone-file.cpp (+110/-77)
src/timezone-geoclue.cpp (+247/-206)
src/wakeup-timer-powerd.cpp (+2/-0)
To merge this branch: bzr merge lp:~charlesk/indicator-datetime/timezone-class-privacy
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Ted Gould (community) Approve
Review via email: mp+234896@code.launchpad.net

Commit message

Move timezone code behind a private Impl class

Description of the change

Simple cleanup done while working on other bugfixes.

This doesn't change the behavior of any code; just moves the implementation details of GeoclueTimezone and FileTimezone into private Impl classes.

To post a comment you must log in.
Revision history for this message
Ted Gould (ted) :
review: Approve
Revision history for this message
Ted Gould (ted) wrote :

The camelcase to underscores I think were the final straw for meld. It didn't do as good of a job as I would have expected.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'include/datetime/clock.h'
--- include/datetime/clock.h 2014-09-13 18:12:04 +0000
+++ include/datetime/clock.h 2014-09-16 22:48:45 +0000
@@ -25,8 +25,6 @@
25#include <core/property.h>25#include <core/property.h>
26#include <core/signal.h>26#include <core/signal.h>
2727
28#include <gio/gio.h> // GDBusConnection
29
30#include <memory> // std::shared_ptr, std::unique_ptr28#include <memory> // std::shared_ptr, std::unique_ptr
3129
32namespace unity {30namespace unity {
3331
=== modified file 'include/datetime/timezone-file.h'
--- include/datetime/timezone-file.h 2014-02-02 21:28:52 +0000
+++ include/datetime/timezone-file.h 2014-09-16 22:48:45 +0000
@@ -24,9 +24,6 @@
2424
25#include <string> // std::string25#include <string> // std::string
2626
27#include <glib.h>
28#include <gio/gio.h>
29
30namespace unity {27namespace unity {
31namespace indicator {28namespace indicator {
32namespace datetime {29namespace datetime {
@@ -37,21 +34,15 @@
37class FileTimezone: public Timezone34class FileTimezone: public Timezone
38{35{
39public:36public:
40 FileTimezone();
41 FileTimezone(const std::string& filename);37 FileTimezone(const std::string& filename);
42 ~FileTimezone();38 ~FileTimezone();
4339
44private:40private:
45 void set_filename(const std::string& filename);41 class Impl;
46 static void on_file_changed(gpointer gself);42 friend Impl;
47 void clear();43 std::unique_ptr<Impl> impl;
48 void reload();44
4945 // we have pointers in here, so disable copying
50 std::string m_filename;
51 GFileMonitor * m_monitor = nullptr;
52 unsigned long m_monitor_handler_id = 0;
53
54 // we have raw pointers and glib tags in here, so disable copying
55 FileTimezone(const FileTimezone&) =delete;46 FileTimezone(const FileTimezone&) =delete;
56 FileTimezone& operator=(const FileTimezone&) =delete;47 FileTimezone& operator=(const FileTimezone&) =delete;
57};48};
5849
=== modified file 'include/datetime/timezone-geoclue.h'
--- include/datetime/timezone-geoclue.h 2014-01-15 05:07:10 +0000
+++ include/datetime/timezone-geoclue.h 2014-09-16 22:48:45 +0000
@@ -22,11 +22,6 @@
2222
23#include <datetime/timezone.h> // base class23#include <datetime/timezone.h> // base class
2424
25#include <string>
26
27#include <glib.h>
28#include <gio/gio.h>
29
30namespace unity {25namespace unity {
31namespace indicator {26namespace indicator {
32namespace datetime {27namespace datetime {
@@ -41,21 +36,10 @@
41 ~GeoclueTimezone();36 ~GeoclueTimezone();
4237
43private:38private:
44 static void on_bus_got (GObject*, GAsyncResult*, gpointer);39 struct Impl;
45 static void on_client_created (GObject*, GAsyncResult*, gpointer);40 std::unique_ptr<Impl> impl;
46 static void on_address_changed (GDBusConnection*, const gchar*, const gchar*, const gchar*, const gchar*, GVariant*, gpointer);41
47 static void on_requirements_set (GObject*, GAsyncResult*, gpointer);42 // we've got pointers in here, so don't allow copying
48 static void on_address_started (GObject*, GAsyncResult*, gpointer);
49 static void on_address_got (GObject*, GAsyncResult*, gpointer);
50 void setTimezoneFromAddressVariant (GVariant*);
51 static GVariant * call_finish (GObject*, GAsyncResult*);
52
53 GCancellable * m_cancellable = nullptr;
54 GDBusConnection * m_connection = nullptr;
55 std::string m_client_object_path;
56 guint m_signal_subscription = 0;
57
58 // we've got pointers and gsignal tags in here, so don't allow copying
59 GeoclueTimezone(const GeoclueTimezone&) =delete;43 GeoclueTimezone(const GeoclueTimezone&) =delete;
60 GeoclueTimezone& operator=(const GeoclueTimezone&) =delete;44 GeoclueTimezone& operator=(const GeoclueTimezone&) =delete;
61};45};
6246
=== modified file 'src/timezone-file.cpp'
--- src/timezone-file.cpp 2014-05-05 15:06:34 +0000
+++ src/timezone-file.cpp 2014-09-16 22:48:45 +0000
@@ -19,11 +19,97 @@
1919
20#include <datetime/timezone-file.h>20#include <datetime/timezone-file.h>
2121
22#include <gio/gio.h>
23
22#include <cerrno>24#include <cerrno>
23#include <cstdlib>25#include <cstdlib>
2426
25namespace27namespace unity {
28namespace indicator {
29namespace datetime {
30
31/***
32****
33***/
34
35class FileTimezone::Impl
26{36{
37public:
38
39 Impl(FileTimezone& owner, const std::string& filename):
40 m_owner(owner)
41 {
42 set_filename(filename);
43 }
44
45 ~Impl()
46 {
47 clear();
48 }
49
50private:
51
52 void clear()
53 {
54 if (m_monitor_handler_id)
55 g_signal_handler_disconnect(m_monitor, m_monitor_handler_id);
56
57 g_clear_object (&m_monitor);
58
59 m_filename.clear();
60 }
61
62 void set_filename(const std::string& filename)
63 {
64 clear();
65
66 auto tmp = realpath(filename.c_str(), nullptr);
67 if(tmp != nullptr)
68 {
69 m_filename = tmp;
70 free(tmp);
71 }
72 else
73 {
74 g_warning("Unable to resolve path '%s': %s", filename.c_str(), g_strerror(errno));
75 m_filename = filename; // better than nothing?
76 }
77
78 auto file = g_file_new_for_path(m_filename.c_str());
79 GError * err = nullptr;
80 m_monitor = g_file_monitor_file(file, G_FILE_MONITOR_NONE, nullptr, &err);
81 g_object_unref(file);
82 if (err)
83 {
84 g_warning("%s Unable to monitor timezone file '%s': %s", G_STRLOC, TIMEZONE_FILE, err->message);
85 g_error_free(err);
86 }
87 else
88 {
89 m_monitor_handler_id = g_signal_connect_swapped(m_monitor, "changed", G_CALLBACK(on_file_changed), this);
90 g_debug("%s Monitoring timezone file '%s'", G_STRLOC, m_filename.c_str());
91 }
92
93 reload();
94 }
95
96 static void on_file_changed(gpointer gself)
97 {
98 static_cast<Impl*>(gself)->reload();
99 }
100
101 void reload()
102 {
103 const auto new_timezone = get_timezone_from_file(m_filename);
104
105 if (!new_timezone.empty())
106 m_owner.timezone.set(new_timezone);
107 }
108
109 /***
110 ****
111 ***/
112
27 std::string get_timezone_from_file(const std::string& filename)113 std::string get_timezone_from_file(const std::string& filename)
28 {114 {
29 GError * error;115 GError * error;
@@ -73,86 +159,33 @@
73159
74 return ret;160 return ret;
75 }161 }
76}162
77163 /***
78namespace unity {164 ****
79namespace indicator {165 ***/
80namespace datetime {166
81167 FileTimezone & m_owner;
82FileTimezone::FileTimezone()168 std::string m_filename;
83{169 GFileMonitor * m_monitor = nullptr;
84}170 unsigned long m_monitor_handler_id = 0;
85171};
86FileTimezone::FileTimezone(const std::string& filename)172
87{173/***
88 set_filename(filename);174****
175***/
176
177FileTimezone::FileTimezone(const std::string& filename):
178 impl(new Impl{*this, filename})
179{
89}180}
90181
91FileTimezone::~FileTimezone()182FileTimezone::~FileTimezone()
92{183{
93 clear();184}
94}185
95186/***
96void187****
97FileTimezone::clear()188***/
98{
99 if (m_monitor_handler_id)
100 g_signal_handler_disconnect(m_monitor, m_monitor_handler_id);
101
102 g_clear_object (&m_monitor);
103
104 m_filename.clear();
105}
106
107void
108FileTimezone::set_filename(const std::string& filename)
109{
110 clear();
111
112 auto tmp = realpath(filename.c_str(), nullptr);
113 if(tmp != nullptr)
114 {
115 m_filename = tmp;
116 free(tmp);
117 }
118 else
119 {
120 g_warning("Unable to resolve path '%s': %s", filename.c_str(), g_strerror(errno));
121 m_filename = filename; // better than nothing?
122 }
123
124 auto file = g_file_new_for_path(m_filename.c_str());
125 GError * err = nullptr;
126 m_monitor = g_file_monitor_file(file, G_FILE_MONITOR_NONE, nullptr, &err);
127 g_object_unref(file);
128 if (err)
129 {
130 g_warning("%s Unable to monitor timezone file '%s': %s", G_STRLOC, TIMEZONE_FILE, err->message);
131 g_error_free(err);
132 }
133 else
134 {
135 m_monitor_handler_id = g_signal_connect_swapped(m_monitor, "changed", G_CALLBACK(on_file_changed), this);
136 g_debug("%s Monitoring timezone file '%s'", G_STRLOC, m_filename.c_str());
137 }
138
139 reload();
140}
141
142void
143FileTimezone::on_file_changed(gpointer gself)
144{
145 static_cast<FileTimezone*>(gself)->reload();
146}
147
148void
149FileTimezone::reload()
150{
151 const auto new_timezone = get_timezone_from_file(m_filename);
152
153 if (!new_timezone.empty())
154 timezone.set(new_timezone);
155}
156189
157} // namespace datetime190} // namespace datetime
158} // namespace indicator191} // namespace indicator
159192
=== modified file 'src/timezone-geoclue.cpp'
--- src/timezone-geoclue.cpp 2014-01-15 05:07:10 +0000
+++ src/timezone-geoclue.cpp 2014-09-16 22:48:45 +0000
@@ -19,225 +19,266 @@
1919
20#include <datetime/timezone-geoclue.h>20#include <datetime/timezone-geoclue.h>
2121
22#include <gio/gio.h>
23
24#include <memory>
25#include <string>
26#include <vector>
27
22#define GEOCLUE_BUS_NAME "org.freedesktop.Geoclue.Master"28#define GEOCLUE_BUS_NAME "org.freedesktop.Geoclue.Master"
2329
24namespace unity {30namespace unity {
25namespace indicator {31namespace indicator {
26namespace datetime {32namespace datetime {
2733
34class GeoclueTimezone::Impl
35{
36
37public:
38
39 Impl(GeoclueTimezone& owner):
40 m_owner(owner),
41 m_cancellable(g_cancellable_new())
42 {
43 g_bus_get(G_BUS_TYPE_SESSION, m_cancellable, on_bus_got, this);
44 }
45
46 ~Impl()
47 {
48 g_cancellable_cancel(m_cancellable);
49 g_object_unref(m_cancellable);
50 g_object_unref(m_bus);
51 }
52
53private:
54
55 void remember_subscription(GDBusConnection * bus,
56 guint tag)
57 {
58 g_object_ref(bus);
59
60 auto deleter = [tag](GDBusConnection* bus){
61 g_dbus_connection_signal_unsubscribe(bus, tag);
62 g_object_unref(G_OBJECT(bus));
63 };
64
65 m_subscriptions.push_back(std::shared_ptr<GDBusConnection>(bus, deleter));
66 }
67
68 static void on_bus_got(GObject * /*source*/,
69 GAsyncResult * res,
70 gpointer gself)
71 {
72 GError * error;
73 GDBusConnection * connection;
74
75 error = nullptr;
76 connection = g_bus_get_finish(res, &error);
77 if (error)
78 {
79 if (!g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
80 g_warning("Couldn't get bus: %s", error->message);
81
82 g_error_free(error);
83 }
84 else
85 {
86 auto self = static_cast<Impl*>(gself);
87
88 self->m_bus = connection;
89
90 g_dbus_connection_call(self->m_bus,
91 GEOCLUE_BUS_NAME,
92 "/org/freedesktop/Geoclue/Master",
93 "org.freedesktop.Geoclue.Master",
94 "Create",
95 nullptr, // parameters
96 G_VARIANT_TYPE("(o)"),
97 G_DBUS_CALL_FLAGS_NONE,
98 -1,
99 self->m_cancellable,
100 on_client_created,
101 self);
102 }
103 }
104
105 static void on_client_created(GObject* source, GAsyncResult* res, gpointer gself)
106 {
107 GVariant * result;
108
109 if ((result = call_finish(G_STRFUNC, source, res)))
110 {
111 auto self = static_cast<Impl*>(gself);
112
113 GVariant * child = g_variant_get_child_value(result, 0);
114 self->m_client_object_path = g_variant_get_string(child, nullptr);
115 g_variant_unref(child);
116 g_variant_unref(result);
117
118 auto tag = g_dbus_connection_signal_subscribe(self->m_bus,
119 GEOCLUE_BUS_NAME,
120 "org.freedesktop.Geoclue.Address", // interface
121 "AddressChanged", // signal name
122 self->m_client_object_path.c_str(), // object path
123 nullptr, // arg0
124 G_DBUS_SIGNAL_FLAGS_NONE,
125 on_address_changed,
126 self,
127 nullptr);
128 self->remember_subscription(self->m_bus, tag);
129
130 g_dbus_connection_call(self->m_bus,
131 GEOCLUE_BUS_NAME,
132 self->m_client_object_path.c_str(),
133 "org.freedesktop.Geoclue.MasterClient",
134 "SetRequirements",
135 g_variant_new("(iibi)", 2, 0, FALSE, 1023),
136 nullptr,
137 G_DBUS_CALL_FLAGS_NONE,
138 -1,
139 self->m_cancellable,
140 on_requirements_set,
141 self);
142 }
143 }
144
145 static void on_address_changed(GDBusConnection* /*connection*/,
146 const gchar* /*sender_name*/,
147 const gchar* /*object_path*/,
148 const gchar* /*interface_name*/,
149 const gchar* /*signal_name*/,
150 GVariant* parameters,
151 gpointer gself)
152 {
153 static_cast<Impl*>(gself)->set_timezone_from_address_variant(parameters);
154 }
155
156 static void on_requirements_set(GObject* source, GAsyncResult* res, gpointer gself)
157 {
158 GVariant * result;
159
160 if ((result = call_finish(G_STRFUNC, source, res)))
161 {
162 auto self = static_cast<Impl*>(gself);
163
164 g_dbus_connection_call(self->m_bus,
165 GEOCLUE_BUS_NAME,
166 self->m_client_object_path.c_str(),
167 "org.freedesktop.Geoclue.MasterClient",
168 "AddressStart",
169 nullptr,
170 nullptr,
171 G_DBUS_CALL_FLAGS_NONE,
172 -1,
173 self->m_cancellable,
174 on_address_started,
175 self);
176
177 g_variant_unref(result);
178 }
179 }
180
181 static void on_address_started(GObject* source, GAsyncResult* res, gpointer gself)
182 {
183 GVariant * result;
184
185 if ((result = call_finish(G_STRFUNC, source, res)))
186 {
187 auto self = static_cast<Impl*>(gself);
188
189 g_dbus_connection_call(self->m_bus,
190 GEOCLUE_BUS_NAME,
191 self->m_client_object_path.c_str(),
192 "org.freedesktop.Geoclue.Address",
193 "GetAddress",
194 nullptr,
195 G_VARIANT_TYPE("(ia{ss}(idd))"),
196 G_DBUS_CALL_FLAGS_NONE,
197 -1,
198 self->m_cancellable,
199 on_address_got,
200 self);
201
202 g_variant_unref(result);
203 }
204 }
205
206 static void on_address_got(GObject* source, GAsyncResult* res, gpointer gself)
207 {
208 GVariant * result;
209
210 if ((result = call_finish(G_STRFUNC, source, res)))
211 {
212 static_cast<Impl*>(gself)->set_timezone_from_address_variant(result);
213 g_variant_unref(result);
214 }
215 }
216
217 /***
218 ****
219 ***/
220
221 void set_timezone_from_address_variant(GVariant * variant)
222 {
223 g_return_if_fail(g_variant_is_of_type(variant, G_VARIANT_TYPE("(ia{ss}(idd))")));
224
225 const gchar * timezone_string = nullptr;
226 GVariant * dict = g_variant_get_child_value(variant, 1);
227 if (dict)
228 {
229 if (g_variant_lookup(dict, "timezone", "&s", &timezone_string))
230 {
231 g_debug("from geoclue, setting timezone to '%s'", timezone_string);
232 m_owner.timezone.set(timezone_string);
233 }
234
235 g_variant_unref(dict);
236 }
237 }
238
239 static GVariant* call_finish(const char * funcname, GObject * source, GAsyncResult * res)
240 {
241 GError * error;
242 GVariant * result;
243
244 error = nullptr;
245 result = g_dbus_connection_call_finish(G_DBUS_CONNECTION(source), res, &error);
246
247 if (error)
248 {
249 if (!g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
250 g_warning("%s failed: %s", funcname, error->message);
251
252 g_error_free(error);
253
254 g_clear_pointer(&result, g_variant_unref);
255 }
256
257 return result;
258 }
259
260 /***
261 ****
262 ***/
263
264 GeoclueTimezone & m_owner;
265 GDBusConnection * m_bus = nullptr;
266 GCancellable * m_cancellable = nullptr;
267 std::string m_client_object_path;
268 std::vector<std::shared_ptr<GDBusConnection>> m_subscriptions;
269};
270
271/****
272*****
273****/
28274
29GeoclueTimezone::GeoclueTimezone():275GeoclueTimezone::GeoclueTimezone():
30 m_cancellable(g_cancellable_new())276 impl(new Impl{*this})
31{277{
32 g_bus_get(G_BUS_TYPE_SESSION, m_cancellable, on_bus_got, this);
33}278}
34279
35GeoclueTimezone::~GeoclueTimezone()280GeoclueTimezone::~GeoclueTimezone()
36{281{
37 g_cancellable_cancel(m_cancellable);
38 g_object_unref(m_cancellable);
39
40 if (m_signal_subscription)
41 g_dbus_connection_signal_unsubscribe(m_connection, m_signal_subscription);
42
43 g_object_unref(m_connection);
44}
45
46/***
47****
48***/
49
50void
51GeoclueTimezone::on_bus_got(GObject* /*source*/,
52 GAsyncResult* res,
53 gpointer gself)
54{
55 GError * error;
56 GDBusConnection * connection;
57
58 error = nullptr;
59 connection = g_bus_get_finish(res, &error);
60 if (error)
61 {
62 if (!g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
63 g_warning("Couldn't get bus: %s", error->message);
64
65 g_error_free(error);
66 }
67 else
68 {
69 auto self = static_cast<GeoclueTimezone*>(gself);
70
71 self->m_connection = connection;
72
73 g_dbus_connection_call(self->m_connection,
74 GEOCLUE_BUS_NAME,
75 "/org/freedesktop/Geoclue/Master",
76 "org.freedesktop.Geoclue.Master",
77 "Create",
78 nullptr, // parameters
79 G_VARIANT_TYPE("(o)"),
80 G_DBUS_CALL_FLAGS_NONE,
81 -1,
82 self->m_cancellable,
83 on_client_created,
84 self);
85 }
86}
87
88void
89GeoclueTimezone::on_client_created(GObject * source, GAsyncResult * res, gpointer gself)
90{
91 GVariant * result;
92
93 if ((result = call_finish(source, res)))
94 {
95 auto self = static_cast<GeoclueTimezone*>(gself);
96
97 GVariant * child = g_variant_get_child_value(result, 0);
98 self->m_client_object_path = g_variant_get_string(child, nullptr);
99 g_variant_unref(child);
100 g_variant_unref(result);
101
102 self->m_signal_subscription = g_dbus_connection_signal_subscribe(
103 self->m_connection,
104 GEOCLUE_BUS_NAME,
105 "org.freedesktop.Geoclue.Address", // inteface
106 "AddressChanged", // signal name
107 self->m_client_object_path.c_str(), // object path
108 nullptr, // arg0
109 G_DBUS_SIGNAL_FLAGS_NONE,
110 on_address_changed,
111 self,
112 nullptr);
113
114 g_dbus_connection_call(self->m_connection,
115 GEOCLUE_BUS_NAME,
116 self->m_client_object_path.c_str(),
117 "org.freedesktop.Geoclue.MasterClient",
118 "SetRequirements",
119 g_variant_new("(iibi)", 2, 0, FALSE, 1023),
120 nullptr,
121 G_DBUS_CALL_FLAGS_NONE,
122 -1,
123 self->m_cancellable,
124 on_requirements_set,
125 self);
126 }
127}
128
129void
130GeoclueTimezone::on_address_changed(GDBusConnection* /*connection*/,
131 const gchar* /*sender_name*/,
132 const gchar* /*object_path*/,
133 const gchar* /*interface_name*/,
134 const gchar* /*signal_name*/,
135 GVariant* parameters,
136 gpointer gself)
137{
138 static_cast<GeoclueTimezone*>(gself)->setTimezoneFromAddressVariant(parameters);
139}
140
141void
142GeoclueTimezone::on_requirements_set(GObject* source, GAsyncResult* res, gpointer gself)
143{
144 GVariant * result;
145
146 if ((result = call_finish(source, res)))
147 {
148 auto self = static_cast<GeoclueTimezone*>(gself);
149
150 g_dbus_connection_call(self->m_connection,
151 GEOCLUE_BUS_NAME,
152 self->m_client_object_path.c_str(),
153 "org.freedesktop.Geoclue.MasterClient",
154 "AddressStart",
155 nullptr,
156 nullptr,
157 G_DBUS_CALL_FLAGS_NONE,
158 -1,
159 self->m_cancellable,
160 on_address_started,
161 self);
162
163 g_variant_unref(result);
164 }
165}
166
167void
168GeoclueTimezone::on_address_started(GObject * source, GAsyncResult * res, gpointer gself)
169{
170 GVariant * result;
171
172 if ((result = call_finish(source, res)))
173 {
174 auto self = static_cast<GeoclueTimezone*>(gself);
175
176 g_dbus_connection_call(self->m_connection,
177 GEOCLUE_BUS_NAME,
178 self->m_client_object_path.c_str(),
179 "org.freedesktop.Geoclue.Address",
180 "GetAddress",
181 nullptr,
182 G_VARIANT_TYPE("(ia{ss}(idd))"),
183 G_DBUS_CALL_FLAGS_NONE,
184 -1,
185 self->m_cancellable,
186 on_address_got,
187 self);
188
189 g_variant_unref(result);
190 }
191}
192
193void
194GeoclueTimezone::on_address_got(GObject * source, GAsyncResult * res, gpointer gself)
195{
196 GVariant * result;
197
198 if ((result = call_finish(source, res)))
199 {
200 static_cast<GeoclueTimezone*>(gself)->setTimezoneFromAddressVariant(result);
201 g_variant_unref(result);
202 }
203}
204
205void
206GeoclueTimezone::setTimezoneFromAddressVariant(GVariant * variant)
207{
208 g_return_if_fail(g_variant_is_of_type(variant, G_VARIANT_TYPE("(ia{ss}(idd))")));
209
210 const gchar * timezone_string = nullptr;
211 GVariant * dict = g_variant_get_child_value(variant, 1);
212 if (dict)
213 {
214 if (g_variant_lookup(dict, "timezone", "&s", &timezone_string))
215 timezone.set(timezone_string);
216
217 g_variant_unref(dict);
218 }
219}
220
221GVariant*
222GeoclueTimezone::call_finish(GObject * source, GAsyncResult * res)
223{
224 GError * error;
225 GVariant * result;
226
227 error = nullptr;
228 result = g_dbus_connection_call_finish(G_DBUS_CONNECTION(source), res, &error);
229
230 if (error)
231 {
232 if (!g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
233 g_warning("AddressStart() failed: %s", error->message);
234
235 g_error_free(error);
236
237 g_clear_pointer(&result, g_variant_unref);
238 }
239
240 return result;
241}282}
242283
243/****284/****
244285
=== modified file 'src/wakeup-timer-powerd.cpp'
--- src/wakeup-timer-powerd.cpp 2014-08-19 04:08:38 +0000
+++ src/wakeup-timer-powerd.cpp 2014-09-16 22:48:45 +0000
@@ -22,6 +22,8 @@
2222
23#include <notifications/dbus-shared.h> // BUS_POWERD_NAME23#include <notifications/dbus-shared.h> // BUS_POWERD_NAME
2424
25#include <gio/gio.h>
26
25#include <memory> // std::shared_ptr27#include <memory> // std::shared_ptr
2628
27namespace unity {29namespace unity {

Subscribers

People subscribed via source and target branches