Merge lp:~davidmhewitt/pantheon-agent-geoclue2/fix-tabs into lp:~elementary-pantheon/pantheon-agent-geoclue2/trunk
- fix-tabs
- Merge into trunk
Proposed by
David Hewitt
Status: | Merged |
---|---|
Approved by: | Danielle Foré |
Approved revision: | 18 |
Merged at revision: | 18 |
Proposed branch: | lp:~davidmhewitt/pantheon-agent-geoclue2/fix-tabs |
Merge into: | lp:~elementary-pantheon/pantheon-agent-geoclue2/trunk |
Diff against target: |
392 lines (+164/-164) 3 files modified
src/Agent.vala (+151/-151) src/Interfaces.vala (+4/-4) vapi/geoclue2.vapi (+9/-9) |
To merge this branch: | bzr merge lp:~davidmhewitt/pantheon-agent-geoclue2/fix-tabs |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Danielle Foré | Approve | ||
Review via email:
|
Commit message
Fix mix of tabs and spaces
Description of the change
Convert tabs to spaces. No changes to code were made.
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'src/Agent.vala' |
2 | --- src/Agent.vala 2017-02-25 16:16:16 +0000 |
3 | +++ src/Agent.vala 2017-02-25 17:42:29 +0000 |
4 | @@ -21,189 +21,189 @@ |
5 | |
6 | namespace Ag { |
7 | public class Agent : Gtk.Application, GeoClue2Agent { |
8 | - private uint _max_accuracy_level = GeoClue2.AccuracyLevel.EXACT; |
9 | + private uint _max_accuracy_level = GeoClue2.AccuracyLevel.EXACT; |
10 | public uint max_accuracy_level { get { return _max_accuracy_level; } } |
11 | |
12 | private MainLoop loop; |
13 | - private uint object_id; |
14 | - private bool bus_registered = false; |
15 | + private uint object_id; |
16 | + private bool bus_registered = false; |
17 | |
18 | - private GeoClue2Client? client = null; |
19 | - private Settings settings; |
20 | - private VariantDict remembered_apps; |
21 | + private GeoClue2Client? client = null; |
22 | + private Settings settings; |
23 | + private VariantDict remembered_apps; |
24 | |
25 | construct { |
26 | application_id = "org.pantheon.agent-geoclue2"; |
27 | settings = new Settings (application_id); |
28 | |
29 | - settings.changed.connect ((key) => { |
30 | - refresh_enabled_state (); |
31 | - refresh_remembered_apps (); |
32 | - }); |
33 | + settings.changed.connect ((key) => { |
34 | + refresh_enabled_state (); |
35 | + refresh_remembered_apps (); |
36 | + }); |
37 | |
38 | loop = new MainLoop (); |
39 | - |
40 | + |
41 | refresh_enabled_state (); |
42 | - refresh_remembered_apps (); |
43 | + refresh_remembered_apps (); |
44 | } |
45 | |
46 | public override void activate () { |
47 | loop.run (); |
48 | } |
49 | |
50 | - private void on_name (DBusConnection conn) { |
51 | - try { |
52 | - if (bus_registered) { |
53 | - conn.unregister_object (object_id); |
54 | - bus_registered = false; |
55 | - } |
56 | - |
57 | - debug ("Adding agent..."); |
58 | - object_id = conn.register_object ("/org/freedesktop/GeoClue2/Agent", (GeoClue2Agent)this); |
59 | - bus_registered = true; |
60 | - register_with_geoclue.begin (); |
61 | - } catch (Error e) { |
62 | - error ("Error while registering the agent: %s \n", e.message); |
63 | - } |
64 | - } |
65 | - |
66 | - private void watch (DBusConnection connection) { |
67 | - Bus.watch_name (BusType.SYSTEM, "org.freedesktop.GeoClue2", BusNameWatcherFlags.AUTO_START, on_name); |
68 | - } |
69 | - |
70 | - public override bool dbus_register (DBusConnection connection, string object_path) throws Error { |
71 | - base.dbus_register (connection, object_path); |
72 | - watch (connection); |
73 | - |
74 | - return true; |
75 | - } |
76 | - |
77 | - public override void dbus_unregister (DBusConnection connection, string object_path) { |
78 | - if (bus_registered) { |
79 | - connection.unregister_object (object_id); |
80 | - } |
81 | - |
82 | - base.dbus_unregister (connection, object_path); |
83 | - } |
84 | + private void on_name (DBusConnection conn) { |
85 | + try { |
86 | + if (bus_registered) { |
87 | + conn.unregister_object (object_id); |
88 | + bus_registered = false; |
89 | + } |
90 | + |
91 | + debug ("Adding agent..."); |
92 | + object_id = conn.register_object ("/org/freedesktop/GeoClue2/Agent", (GeoClue2Agent)this); |
93 | + bus_registered = true; |
94 | + register_with_geoclue.begin (); |
95 | + } catch (Error e) { |
96 | + error ("Error while registering the agent: %s \n", e.message); |
97 | + } |
98 | + } |
99 | + |
100 | + private void watch (DBusConnection connection) { |
101 | + Bus.watch_name (BusType.SYSTEM, "org.freedesktop.GeoClue2", BusNameWatcherFlags.AUTO_START, on_name); |
102 | + } |
103 | + |
104 | + public override bool dbus_register (DBusConnection connection, string object_path) throws Error { |
105 | + base.dbus_register (connection, object_path); |
106 | + watch (connection); |
107 | + |
108 | + return true; |
109 | + } |
110 | + |
111 | + public override void dbus_unregister (DBusConnection connection, string object_path) { |
112 | + if (bus_registered) { |
113 | + connection.unregister_object (object_id); |
114 | + } |
115 | + |
116 | + base.dbus_unregister (connection, object_path); |
117 | + } |
118 | |
119 | public async void authorize_app (string id, uint req_accuracy, out bool authorized, out uint allowed_accuracy) { |
120 | - debug ("Request for '%s' at level '%u'", id, req_accuracy); |
121 | - |
122 | - DesktopAppInfo app_info = new DesktopAppInfo (id + ".desktop"); |
123 | - if (app_info == null) { |
124 | - debug ("Rejecting for invalid desktop file"); |
125 | - authorized = false; |
126 | - allowed_accuracy = req_accuracy; |
127 | - return; |
128 | - } |
129 | - |
130 | - Variant? remembered_accuracy = get_remembered_accuracy (id); |
131 | - if (remembered_accuracy != null) { |
132 | - var stored_auth = remembered_accuracy.get_child_value (0).get_boolean (); |
133 | - var stored_accuracy = remembered_accuracy.get_child_value (1).get_uint32 (); |
134 | - if (req_accuracy <= stored_accuracy && stored_auth) { |
135 | - authorized = true; |
136 | - allowed_accuracy = req_accuracy; |
137 | - return; |
138 | - } |
139 | - } |
140 | - |
141 | - string app_name = app_info.get_display_name (); |
142 | - string accuracy_string = accuracy_to_string (app_name, req_accuracy); |
143 | - |
144 | - client = yield get_geoclue_client (); |
145 | - debug ("Starting client..."); |
146 | - if (client != null) { |
147 | - try { |
148 | - client.start (); |
149 | - } catch (Error e) { |
150 | - error ("Could not start client: %s", e.message); |
151 | - } |
152 | - } |
153 | - |
154 | - var dialog = new Widgets.Geoclue2Dialog (accuracy_string, app_name, app_info.get_icon ().to_string ()); |
155 | - dialog.show_all (); |
156 | - |
157 | - var result = dialog.run (); |
158 | - |
159 | - if (result == Gtk.ResponseType.YES) { |
160 | - authorized = true; |
161 | + debug ("Request for '%s' at level '%u'", id, req_accuracy); |
162 | + |
163 | + DesktopAppInfo app_info = new DesktopAppInfo (id + ".desktop"); |
164 | + if (app_info == null) { |
165 | + debug ("Rejecting for invalid desktop file"); |
166 | + authorized = false; |
167 | + allowed_accuracy = req_accuracy; |
168 | + return; |
169 | + } |
170 | + |
171 | + Variant? remembered_accuracy = get_remembered_accuracy (id); |
172 | + if (remembered_accuracy != null) { |
173 | + var stored_auth = remembered_accuracy.get_child_value (0).get_boolean (); |
174 | + var stored_accuracy = remembered_accuracy.get_child_value (1).get_uint32 (); |
175 | + if (req_accuracy <= stored_accuracy && stored_auth) { |
176 | + authorized = true; |
177 | + allowed_accuracy = req_accuracy; |
178 | + return; |
179 | + } |
180 | + } |
181 | + |
182 | + string app_name = app_info.get_display_name (); |
183 | + string accuracy_string = accuracy_to_string (app_name, req_accuracy); |
184 | + |
185 | + client = yield get_geoclue_client (); |
186 | + debug ("Starting client..."); |
187 | + if (client != null) { |
188 | + try { |
189 | + client.start (); |
190 | + } catch (Error e) { |
191 | + error ("Could not start client: %s", e.message); |
192 | + } |
193 | + } |
194 | + |
195 | + var dialog = new Widgets.Geoclue2Dialog (accuracy_string, app_name, app_info.get_icon ().to_string ()); |
196 | + dialog.show_all (); |
197 | + |
198 | + var result = dialog.run (); |
199 | + |
200 | + if (result == Gtk.ResponseType.YES) { |
201 | + authorized = true; |
202 | } else { |
203 | - authorized = false; |
204 | - } |
205 | - |
206 | - dialog.destroy (); |
207 | + authorized = false; |
208 | + } |
209 | + |
210 | + dialog.destroy (); |
211 | allowed_accuracy = req_accuracy; |
212 | remember_app (id, authorized, req_accuracy); |
213 | |
214 | debug ("Stopping client..."); |
215 | - if (client != null) { |
216 | - try { |
217 | - client.stop (); |
218 | - } catch (Error e) { |
219 | - error ("Could not stop client: %s", e.message); |
220 | - } |
221 | - } |
222 | + if (client != null) { |
223 | + try { |
224 | + client.stop (); |
225 | + } catch (Error e) { |
226 | + error ("Could not stop client: %s", e.message); |
227 | + } |
228 | + } |
229 | } |
230 | |
231 | - private string accuracy_to_string (string app_name, uint accuracy) { |
232 | - string message = ""; |
233 | - switch (accuracy) { |
234 | - case GeoClue2.AccuracyLevel.COUNTRY: |
235 | - message = _("the current country"); |
236 | - break; |
237 | - case GeoClue2.AccuracyLevel.CITY: |
238 | - message = _("the nearest city or town"); |
239 | - break; |
240 | - case GeoClue2.AccuracyLevel.NEIGHBORHOOD: |
241 | - message = _("the nearest neighborhood"); |
242 | - break; |
243 | - case GeoClue2.AccuracyLevel.STREET: |
244 | - message = _("the nearest street"); |
245 | - break; |
246 | - case GeoClue2.AccuracyLevel.EXACT: |
247 | - message = _("your exact location"); |
248 | - break; |
249 | - default: |
250 | - message = _("your location"); |
251 | - break; |
252 | - } |
253 | - |
254 | - return _("%s will be able to detect %s. Permissions can be changed in <a href='settings://security/privacy/location'>Location Settings…</a>").printf (app_name, message); |
255 | - } |
256 | + private string accuracy_to_string (string app_name, uint accuracy) { |
257 | + string message = ""; |
258 | + switch (accuracy) { |
259 | + case GeoClue2.AccuracyLevel.COUNTRY: |
260 | + message = _("the current country"); |
261 | + break; |
262 | + case GeoClue2.AccuracyLevel.CITY: |
263 | + message = _("the nearest city or town"); |
264 | + break; |
265 | + case GeoClue2.AccuracyLevel.NEIGHBORHOOD: |
266 | + message = _("the nearest neighborhood"); |
267 | + break; |
268 | + case GeoClue2.AccuracyLevel.STREET: |
269 | + message = _("the nearest street"); |
270 | + break; |
271 | + case GeoClue2.AccuracyLevel.EXACT: |
272 | + message = _("your exact location"); |
273 | + break; |
274 | + default: |
275 | + message = _("your location"); |
276 | + break; |
277 | + } |
278 | + |
279 | + return _("%s will be able to detect %s. Permissions can be changed in <a href='settings://security/privacy/location'>Location Settings…</a>").printf (app_name, message); |
280 | + } |
281 | |
282 | private async void register_with_geoclue () { |
283 | yield Utils.register_with_geoclue (application_id); |
284 | } |
285 | |
286 | - private async GeoClue2Client? get_geoclue_client () { |
287 | - return yield Utils.get_geoclue2_client (application_id); |
288 | - } |
289 | - |
290 | - private void refresh_remembered_apps () { |
291 | - remembered_apps = new VariantDict(settings.get_value("remembered-apps")); |
292 | - } |
293 | - |
294 | - private void refresh_enabled_state () { |
295 | - bool enabled = settings.get_value ("location-enabled").get_boolean (); |
296 | - if (enabled) { |
297 | - _max_accuracy_level = GeoClue2.AccuracyLevel.EXACT; |
298 | - } else { |
299 | - _max_accuracy_level = GeoClue2.AccuracyLevel.NONE; |
300 | - } |
301 | - } |
302 | - |
303 | - public void remember_app (string desktop_id, bool authorized, uint32 accuracy_level) { |
304 | - Variant[2] tuple_vals = new Variant[2]; |
305 | - tuple_vals[0] = new Variant.boolean (authorized); |
306 | - tuple_vals[1] = new Variant.uint32 (accuracy_level); |
307 | - remembered_apps.insert_value (desktop_id, new Variant.tuple (tuple_vals)); |
308 | - settings.set_value ("remembered-apps", remembered_apps.end ()); |
309 | - } |
310 | - |
311 | - public Variant? get_remembered_accuracy (string desktop_id) { |
312 | - return remembered_apps.lookup_value (desktop_id, GLib.VariantType.TUPLE); |
313 | - } |
314 | + private async GeoClue2Client? get_geoclue_client () { |
315 | + return yield Utils.get_geoclue2_client (application_id); |
316 | + } |
317 | + |
318 | + private void refresh_remembered_apps () { |
319 | + remembered_apps = new VariantDict(settings.get_value("remembered-apps")); |
320 | + } |
321 | + |
322 | + private void refresh_enabled_state () { |
323 | + bool enabled = settings.get_value ("location-enabled").get_boolean (); |
324 | + if (enabled) { |
325 | + _max_accuracy_level = GeoClue2.AccuracyLevel.EXACT; |
326 | + } else { |
327 | + _max_accuracy_level = GeoClue2.AccuracyLevel.NONE; |
328 | + } |
329 | + } |
330 | + |
331 | + public void remember_app (string desktop_id, bool authorized, uint32 accuracy_level) { |
332 | + Variant[2] tuple_vals = new Variant[2]; |
333 | + tuple_vals[0] = new Variant.boolean (authorized); |
334 | + tuple_vals[1] = new Variant.uint32 (accuracy_level); |
335 | + remembered_apps.insert_value (desktop_id, new Variant.tuple (tuple_vals)); |
336 | + settings.set_value ("remembered-apps", remembered_apps.end ()); |
337 | + } |
338 | + |
339 | + public Variant? get_remembered_accuracy (string desktop_id) { |
340 | + return remembered_apps.lookup_value (desktop_id, GLib.VariantType.TUPLE); |
341 | + } |
342 | } |
343 | |
344 | public static int main (string[] args) { |
345 | |
346 | === modified file 'src/Interfaces.vala' |
347 | --- src/Interfaces.vala 2017-02-25 15:01:53 +0000 |
348 | +++ src/Interfaces.vala 2017-02-25 17:42:29 +0000 |
349 | @@ -27,12 +27,12 @@ |
350 | } |
351 | |
352 | [DBus (name = "org.freedesktop.GeoClue2.Agent")] |
353 | - public interface GeoClue2Agent : GLib.Object { |
354 | + public interface GeoClue2Agent : GLib.Object { |
355 | [DBus (name = "AuthorizeApp")] |
356 | - public abstract async void authorize_app(string desktop_id, uint req_accuracy_level, out bool authorized, out uint allowed_accuracy_level) throws DBusError, IOError; |
357 | + public abstract async void authorize_app (string desktop_id, uint req_accuracy_level, out bool authorized, out uint allowed_accuracy_level) throws DBusError, IOError; |
358 | [DBus (name ="MaxAccuracyLevel")] |
359 | - public abstract uint max_accuracy_level { get; } |
360 | - } |
361 | + public abstract uint max_accuracy_level { get; } |
362 | + } |
363 | |
364 | [DBus (name = "org.freedesktop.GeoClue2.Client")] |
365 | public interface GeoClue2Client : GLib.Object { |
366 | |
367 | === modified file 'vapi/geoclue2.vapi' |
368 | --- vapi/geoclue2.vapi 2017-02-20 18:30:50 +0000 |
369 | +++ vapi/geoclue2.vapi 2017-02-25 17:42:29 +0000 |
370 | @@ -20,13 +20,13 @@ |
371 | */ |
372 | |
373 | namespace GeoClue2 { |
374 | - [CCode (cname = "GClueAccuracyLevel", cprefix = "GCLUE_ACCURACY_LEVEL_", cheader_filename = "gclue-enums.h" )] |
375 | - public enum AccuracyLevel { |
376 | - NONE, |
377 | - COUNTRY, |
378 | - CITY, |
379 | - NEIGHBORHOOD, |
380 | - STREET, |
381 | - EXACT |
382 | - } |
383 | + [CCode (cname = "GClueAccuracyLevel", cprefix = "GCLUE_ACCURACY_LEVEL_", cheader_filename = "gclue-enums.h" )] |
384 | + public enum AccuracyLevel { |
385 | + NONE, |
386 | + COUNTRY, |
387 | + CITY, |
388 | + NEIGHBORHOOD, |
389 | + STREET, |
390 | + EXACT |
391 | + } |
392 | } |
Looks good. I can confirm it builds and seems to be the same :)