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: mp+318314@code.launchpad.net |
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 | 21 | 21 | ||
6 | 22 | namespace Ag { | 22 | namespace Ag { |
7 | 23 | public class Agent : Gtk.Application, GeoClue2Agent { | 23 | public class Agent : Gtk.Application, GeoClue2Agent { |
9 | 24 | private uint _max_accuracy_level = GeoClue2.AccuracyLevel.EXACT; | 24 | private uint _max_accuracy_level = GeoClue2.AccuracyLevel.EXACT; |
10 | 25 | public uint max_accuracy_level { get { return _max_accuracy_level; } } | 25 | public uint max_accuracy_level { get { return _max_accuracy_level; } } |
11 | 26 | 26 | ||
12 | 27 | private MainLoop loop; | 27 | private MainLoop loop; |
15 | 28 | private uint object_id; | 28 | private uint object_id; |
16 | 29 | private bool bus_registered = false; | 29 | private bool bus_registered = false; |
17 | 30 | 30 | ||
21 | 31 | private GeoClue2Client? client = null; | 31 | private GeoClue2Client? client = null; |
22 | 32 | private Settings settings; | 32 | private Settings settings; |
23 | 33 | private VariantDict remembered_apps; | 33 | private VariantDict remembered_apps; |
24 | 34 | 34 | ||
25 | 35 | construct { | 35 | construct { |
26 | 36 | application_id = "org.pantheon.agent-geoclue2"; | 36 | application_id = "org.pantheon.agent-geoclue2"; |
27 | 37 | settings = new Settings (application_id); | 37 | settings = new Settings (application_id); |
28 | 38 | 38 | ||
33 | 39 | settings.changed.connect ((key) => { | 39 | settings.changed.connect ((key) => { |
34 | 40 | refresh_enabled_state (); | 40 | refresh_enabled_state (); |
35 | 41 | refresh_remembered_apps (); | 41 | refresh_remembered_apps (); |
36 | 42 | }); | 42 | }); |
37 | 43 | 43 | ||
38 | 44 | loop = new MainLoop (); | 44 | loop = new MainLoop (); |
40 | 45 | 45 | ||
41 | 46 | refresh_enabled_state (); | 46 | refresh_enabled_state (); |
43 | 47 | refresh_remembered_apps (); | 47 | refresh_remembered_apps (); |
44 | 48 | } | 48 | } |
45 | 49 | 49 | ||
46 | 50 | public override void activate () { | 50 | public override void activate () { |
47 | 51 | loop.run (); | 51 | loop.run (); |
48 | 52 | } | 52 | } |
49 | 53 | 53 | ||
84 | 54 | private void on_name (DBusConnection conn) { | 54 | private void on_name (DBusConnection conn) { |
85 | 55 | try { | 55 | try { |
86 | 56 | if (bus_registered) { | 56 | if (bus_registered) { |
87 | 57 | conn.unregister_object (object_id); | 57 | conn.unregister_object (object_id); |
88 | 58 | bus_registered = false; | 58 | bus_registered = false; |
89 | 59 | } | 59 | } |
90 | 60 | 60 | ||
91 | 61 | debug ("Adding agent..."); | 61 | debug ("Adding agent..."); |
92 | 62 | object_id = conn.register_object ("/org/freedesktop/GeoClue2/Agent", (GeoClue2Agent)this); | 62 | object_id = conn.register_object ("/org/freedesktop/GeoClue2/Agent", (GeoClue2Agent)this); |
93 | 63 | bus_registered = true; | 63 | bus_registered = true; |
94 | 64 | register_with_geoclue.begin (); | 64 | register_with_geoclue.begin (); |
95 | 65 | } catch (Error e) { | 65 | } catch (Error e) { |
96 | 66 | error ("Error while registering the agent: %s \n", e.message); | 66 | error ("Error while registering the agent: %s \n", e.message); |
97 | 67 | } | 67 | } |
98 | 68 | } | 68 | } |
99 | 69 | 69 | ||
100 | 70 | private void watch (DBusConnection connection) { | 70 | private void watch (DBusConnection connection) { |
101 | 71 | Bus.watch_name (BusType.SYSTEM, "org.freedesktop.GeoClue2", BusNameWatcherFlags.AUTO_START, on_name); | 71 | Bus.watch_name (BusType.SYSTEM, "org.freedesktop.GeoClue2", BusNameWatcherFlags.AUTO_START, on_name); |
102 | 72 | } | 72 | } |
103 | 73 | 73 | ||
104 | 74 | public override bool dbus_register (DBusConnection connection, string object_path) throws Error { | 74 | public override bool dbus_register (DBusConnection connection, string object_path) throws Error { |
105 | 75 | base.dbus_register (connection, object_path); | 75 | base.dbus_register (connection, object_path); |
106 | 76 | watch (connection); | 76 | watch (connection); |
107 | 77 | 77 | ||
108 | 78 | return true; | 78 | return true; |
109 | 79 | } | 79 | } |
110 | 80 | 80 | ||
111 | 81 | public override void dbus_unregister (DBusConnection connection, string object_path) { | 81 | public override void dbus_unregister (DBusConnection connection, string object_path) { |
112 | 82 | if (bus_registered) { | 82 | if (bus_registered) { |
113 | 83 | connection.unregister_object (object_id); | 83 | connection.unregister_object (object_id); |
114 | 84 | } | 84 | } |
115 | 85 | 85 | ||
116 | 86 | base.dbus_unregister (connection, object_path); | 86 | base.dbus_unregister (connection, object_path); |
117 | 87 | } | 87 | } |
118 | 88 | 88 | ||
119 | 89 | public async void authorize_app (string id, uint req_accuracy, out bool authorized, out uint allowed_accuracy) { | 89 | public async void authorize_app (string id, uint req_accuracy, out bool authorized, out uint allowed_accuracy) { |
161 | 90 | debug ("Request for '%s' at level '%u'", id, req_accuracy); | 90 | debug ("Request for '%s' at level '%u'", id, req_accuracy); |
162 | 91 | 91 | ||
163 | 92 | DesktopAppInfo app_info = new DesktopAppInfo (id + ".desktop"); | 92 | DesktopAppInfo app_info = new DesktopAppInfo (id + ".desktop"); |
164 | 93 | if (app_info == null) { | 93 | if (app_info == null) { |
165 | 94 | debug ("Rejecting for invalid desktop file"); | 94 | debug ("Rejecting for invalid desktop file"); |
166 | 95 | authorized = false; | 95 | authorized = false; |
167 | 96 | allowed_accuracy = req_accuracy; | 96 | allowed_accuracy = req_accuracy; |
168 | 97 | return; | 97 | return; |
169 | 98 | } | 98 | } |
170 | 99 | 99 | ||
171 | 100 | Variant? remembered_accuracy = get_remembered_accuracy (id); | 100 | Variant? remembered_accuracy = get_remembered_accuracy (id); |
172 | 101 | if (remembered_accuracy != null) { | 101 | if (remembered_accuracy != null) { |
173 | 102 | var stored_auth = remembered_accuracy.get_child_value (0).get_boolean (); | 102 | var stored_auth = remembered_accuracy.get_child_value (0).get_boolean (); |
174 | 103 | var stored_accuracy = remembered_accuracy.get_child_value (1).get_uint32 (); | 103 | var stored_accuracy = remembered_accuracy.get_child_value (1).get_uint32 (); |
175 | 104 | if (req_accuracy <= stored_accuracy && stored_auth) { | 104 | if (req_accuracy <= stored_accuracy && stored_auth) { |
176 | 105 | authorized = true; | 105 | authorized = true; |
177 | 106 | allowed_accuracy = req_accuracy; | 106 | allowed_accuracy = req_accuracy; |
178 | 107 | return; | 107 | return; |
179 | 108 | } | 108 | } |
180 | 109 | } | 109 | } |
181 | 110 | 110 | ||
182 | 111 | string app_name = app_info.get_display_name (); | 111 | string app_name = app_info.get_display_name (); |
183 | 112 | string accuracy_string = accuracy_to_string (app_name, req_accuracy); | 112 | string accuracy_string = accuracy_to_string (app_name, req_accuracy); |
184 | 113 | 113 | ||
185 | 114 | client = yield get_geoclue_client (); | 114 | client = yield get_geoclue_client (); |
186 | 115 | debug ("Starting client..."); | 115 | debug ("Starting client..."); |
187 | 116 | if (client != null) { | 116 | if (client != null) { |
188 | 117 | try { | 117 | try { |
189 | 118 | client.start (); | 118 | client.start (); |
190 | 119 | } catch (Error e) { | 119 | } catch (Error e) { |
191 | 120 | error ("Could not start client: %s", e.message); | 120 | error ("Could not start client: %s", e.message); |
192 | 121 | } | 121 | } |
193 | 122 | } | 122 | } |
194 | 123 | 123 | ||
195 | 124 | var dialog = new Widgets.Geoclue2Dialog (accuracy_string, app_name, app_info.get_icon ().to_string ()); | 124 | var dialog = new Widgets.Geoclue2Dialog (accuracy_string, app_name, app_info.get_icon ().to_string ()); |
196 | 125 | dialog.show_all (); | 125 | dialog.show_all (); |
197 | 126 | 126 | ||
198 | 127 | var result = dialog.run (); | 127 | var result = dialog.run (); |
199 | 128 | 128 | ||
200 | 129 | if (result == Gtk.ResponseType.YES) { | 129 | if (result == Gtk.ResponseType.YES) { |
201 | 130 | authorized = true; | 130 | authorized = true; |
202 | 131 | } else { | 131 | } else { |
207 | 132 | authorized = false; | 132 | authorized = false; |
208 | 133 | } | 133 | } |
209 | 134 | 134 | ||
210 | 135 | dialog.destroy (); | 135 | dialog.destroy (); |
211 | 136 | allowed_accuracy = req_accuracy; | 136 | allowed_accuracy = req_accuracy; |
212 | 137 | remember_app (id, authorized, req_accuracy); | 137 | remember_app (id, authorized, req_accuracy); |
213 | 138 | 138 | ||
214 | 139 | debug ("Stopping client..."); | 139 | debug ("Stopping client..."); |
222 | 140 | if (client != null) { | 140 | if (client != null) { |
223 | 141 | try { | 141 | try { |
224 | 142 | client.stop (); | 142 | client.stop (); |
225 | 143 | } catch (Error e) { | 143 | } catch (Error e) { |
226 | 144 | error ("Could not stop client: %s", e.message); | 144 | error ("Could not stop client: %s", e.message); |
227 | 145 | } | 145 | } |
228 | 146 | } | 146 | } |
229 | 147 | } | 147 | } |
230 | 148 | 148 | ||
256 | 149 | private string accuracy_to_string (string app_name, uint accuracy) { | 149 | private string accuracy_to_string (string app_name, uint accuracy) { |
257 | 150 | string message = ""; | 150 | string message = ""; |
258 | 151 | switch (accuracy) { | 151 | switch (accuracy) { |
259 | 152 | case GeoClue2.AccuracyLevel.COUNTRY: | 152 | case GeoClue2.AccuracyLevel.COUNTRY: |
260 | 153 | message = _("the current country"); | 153 | message = _("the current country"); |
261 | 154 | break; | 154 | break; |
262 | 155 | case GeoClue2.AccuracyLevel.CITY: | 155 | case GeoClue2.AccuracyLevel.CITY: |
263 | 156 | message = _("the nearest city or town"); | 156 | message = _("the nearest city or town"); |
264 | 157 | break; | 157 | break; |
265 | 158 | case GeoClue2.AccuracyLevel.NEIGHBORHOOD: | 158 | case GeoClue2.AccuracyLevel.NEIGHBORHOOD: |
266 | 159 | message = _("the nearest neighborhood"); | 159 | message = _("the nearest neighborhood"); |
267 | 160 | break; | 160 | break; |
268 | 161 | case GeoClue2.AccuracyLevel.STREET: | 161 | case GeoClue2.AccuracyLevel.STREET: |
269 | 162 | message = _("the nearest street"); | 162 | message = _("the nearest street"); |
270 | 163 | break; | 163 | break; |
271 | 164 | case GeoClue2.AccuracyLevel.EXACT: | 164 | case GeoClue2.AccuracyLevel.EXACT: |
272 | 165 | message = _("your exact location"); | 165 | message = _("your exact location"); |
273 | 166 | break; | 166 | break; |
274 | 167 | default: | 167 | default: |
275 | 168 | message = _("your location"); | 168 | message = _("your location"); |
276 | 169 | break; | 169 | break; |
277 | 170 | } | 170 | } |
278 | 171 | 171 | ||
279 | 172 | 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); | 172 | 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 | 173 | } | 173 | } |
281 | 174 | 174 | ||
282 | 175 | private async void register_with_geoclue () { | 175 | private async void register_with_geoclue () { |
283 | 176 | yield Utils.register_with_geoclue (application_id); | 176 | yield Utils.register_with_geoclue (application_id); |
284 | 177 | } | 177 | } |
285 | 178 | 178 | ||
314 | 179 | private async GeoClue2Client? get_geoclue_client () { | 179 | private async GeoClue2Client? get_geoclue_client () { |
315 | 180 | return yield Utils.get_geoclue2_client (application_id); | 180 | return yield Utils.get_geoclue2_client (application_id); |
316 | 181 | } | 181 | } |
317 | 182 | 182 | ||
318 | 183 | private void refresh_remembered_apps () { | 183 | private void refresh_remembered_apps () { |
319 | 184 | remembered_apps = new VariantDict(settings.get_value("remembered-apps")); | 184 | remembered_apps = new VariantDict(settings.get_value("remembered-apps")); |
320 | 185 | } | 185 | } |
321 | 186 | 186 | ||
322 | 187 | private void refresh_enabled_state () { | 187 | private void refresh_enabled_state () { |
323 | 188 | bool enabled = settings.get_value ("location-enabled").get_boolean (); | 188 | bool enabled = settings.get_value ("location-enabled").get_boolean (); |
324 | 189 | if (enabled) { | 189 | if (enabled) { |
325 | 190 | _max_accuracy_level = GeoClue2.AccuracyLevel.EXACT; | 190 | _max_accuracy_level = GeoClue2.AccuracyLevel.EXACT; |
326 | 191 | } else { | 191 | } else { |
327 | 192 | _max_accuracy_level = GeoClue2.AccuracyLevel.NONE; | 192 | _max_accuracy_level = GeoClue2.AccuracyLevel.NONE; |
328 | 193 | } | 193 | } |
329 | 194 | } | 194 | } |
330 | 195 | 195 | ||
331 | 196 | public void remember_app (string desktop_id, bool authorized, uint32 accuracy_level) { | 196 | public void remember_app (string desktop_id, bool authorized, uint32 accuracy_level) { |
332 | 197 | Variant[2] tuple_vals = new Variant[2]; | 197 | Variant[2] tuple_vals = new Variant[2]; |
333 | 198 | tuple_vals[0] = new Variant.boolean (authorized); | 198 | tuple_vals[0] = new Variant.boolean (authorized); |
334 | 199 | tuple_vals[1] = new Variant.uint32 (accuracy_level); | 199 | tuple_vals[1] = new Variant.uint32 (accuracy_level); |
335 | 200 | remembered_apps.insert_value (desktop_id, new Variant.tuple (tuple_vals)); | 200 | remembered_apps.insert_value (desktop_id, new Variant.tuple (tuple_vals)); |
336 | 201 | settings.set_value ("remembered-apps", remembered_apps.end ()); | 201 | settings.set_value ("remembered-apps", remembered_apps.end ()); |
337 | 202 | } | 202 | } |
338 | 203 | 203 | ||
339 | 204 | public Variant? get_remembered_accuracy (string desktop_id) { | 204 | public Variant? get_remembered_accuracy (string desktop_id) { |
340 | 205 | return remembered_apps.lookup_value (desktop_id, GLib.VariantType.TUPLE); | 205 | return remembered_apps.lookup_value (desktop_id, GLib.VariantType.TUPLE); |
341 | 206 | } | 206 | } |
342 | 207 | } | 207 | } |
343 | 208 | 208 | ||
344 | 209 | public static int main (string[] args) { | 209 | public static int main (string[] args) { |
345 | 210 | 210 | ||
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 | 27 | } | 27 | } |
351 | 28 | 28 | ||
352 | 29 | [DBus (name = "org.freedesktop.GeoClue2.Agent")] | 29 | [DBus (name = "org.freedesktop.GeoClue2.Agent")] |
354 | 30 | public interface GeoClue2Agent : GLib.Object { | 30 | public interface GeoClue2Agent : GLib.Object { |
355 | 31 | [DBus (name = "AuthorizeApp")] | 31 | [DBus (name = "AuthorizeApp")] |
357 | 32 | public abstract async void authorize_app(string desktop_id, uint req_accuracy_level, out bool authorized, out uint allowed_accuracy_level) throws DBusError, IOError; | 32 | 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 | 33 | [DBus (name ="MaxAccuracyLevel")] | 33 | [DBus (name ="MaxAccuracyLevel")] |
361 | 34 | public abstract uint max_accuracy_level { get; } | 34 | public abstract uint max_accuracy_level { get; } |
362 | 35 | } | 35 | } |
363 | 36 | 36 | ||
364 | 37 | [DBus (name = "org.freedesktop.GeoClue2.Client")] | 37 | [DBus (name = "org.freedesktop.GeoClue2.Client")] |
365 | 38 | public interface GeoClue2Client : GLib.Object { | 38 | public interface GeoClue2Client : GLib.Object { |
366 | 39 | 39 | ||
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 | 20 | */ | 20 | */ |
372 | 21 | 21 | ||
373 | 22 | namespace GeoClue2 { | 22 | namespace GeoClue2 { |
383 | 23 | [CCode (cname = "GClueAccuracyLevel", cprefix = "GCLUE_ACCURACY_LEVEL_", cheader_filename = "gclue-enums.h" )] | 23 | [CCode (cname = "GClueAccuracyLevel", cprefix = "GCLUE_ACCURACY_LEVEL_", cheader_filename = "gclue-enums.h" )] |
384 | 24 | public enum AccuracyLevel { | 24 | public enum AccuracyLevel { |
385 | 25 | NONE, | 25 | NONE, |
386 | 26 | COUNTRY, | 26 | COUNTRY, |
387 | 27 | CITY, | 27 | CITY, |
388 | 28 | NEIGHBORHOOD, | 28 | NEIGHBORHOOD, |
389 | 29 | STREET, | 29 | STREET, |
390 | 30 | EXACT | 30 | EXACT |
391 | 31 | } | 31 | } |
392 | 32 | } | 32 | } |
Looks good. I can confirm it builds and seems to be the same :)