Merge lp:~davidmhewitt/pantheon-agent-geoclue2/fix-tabs into lp:~elementary-pantheon/pantheon-agent-geoclue2/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
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.
Revision history for this message
Danielle Foré (danrabbit) wrote :

Looks good. I can confirm it builds and seems to be the same :)

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/Agent.vala'
--- src/Agent.vala 2017-02-25 16:16:16 +0000
+++ src/Agent.vala 2017-02-25 17:42:29 +0000
@@ -21,189 +21,189 @@
2121
22namespace Ag {22namespace Ag {
23 public class Agent : Gtk.Application, GeoClue2Agent {23 public class Agent : Gtk.Application, GeoClue2Agent {
24 private uint _max_accuracy_level = GeoClue2.AccuracyLevel.EXACT;24 private uint _max_accuracy_level = GeoClue2.AccuracyLevel.EXACT;
25 public uint max_accuracy_level { get { return _max_accuracy_level; } }25 public uint max_accuracy_level { get { return _max_accuracy_level; } }
2626
27 private MainLoop loop;27 private MainLoop loop;
28 private uint object_id;28 private uint object_id;
29 private bool bus_registered = false; 29 private bool bus_registered = false;
3030
31 private GeoClue2Client? client = null;31 private GeoClue2Client? client = null;
32 private Settings settings;32 private Settings settings;
33 private VariantDict remembered_apps;33 private VariantDict remembered_apps;
3434
35 construct {35 construct {
36 application_id = "org.pantheon.agent-geoclue2";36 application_id = "org.pantheon.agent-geoclue2";
37 settings = new Settings (application_id);37 settings = new Settings (application_id);
3838
39 settings.changed.connect ((key) => {39 settings.changed.connect ((key) => {
40 refresh_enabled_state ();40 refresh_enabled_state ();
41 refresh_remembered_apps ();41 refresh_remembered_apps ();
42 });42 });
4343
44 loop = new MainLoop (); 44 loop = new MainLoop ();
45 45
46 refresh_enabled_state (); 46 refresh_enabled_state ();
47 refresh_remembered_apps ();47 refresh_remembered_apps ();
48 }48 }
4949
50 public override void activate () {50 public override void activate () {
51 loop.run ();51 loop.run ();
52 }52 }
53 53
54 private void on_name (DBusConnection conn) {54 private void on_name (DBusConnection conn) {
55 try {55 try {
56 if (bus_registered) {56 if (bus_registered) {
57 conn.unregister_object (object_id);57 conn.unregister_object (object_id);
58 bus_registered = false;58 bus_registered = false;
59 }59 }
60 60
61 debug ("Adding agent...");61 debug ("Adding agent...");
62 object_id = conn.register_object ("/org/freedesktop/GeoClue2/Agent", (GeoClue2Agent)this);62 object_id = conn.register_object ("/org/freedesktop/GeoClue2/Agent", (GeoClue2Agent)this);
63 bus_registered = true;63 bus_registered = true;
64 register_with_geoclue.begin ();64 register_with_geoclue.begin ();
65 } catch (Error e) {65 } catch (Error e) {
66 error ("Error while registering the agent: %s \n", e.message);66 error ("Error while registering the agent: %s \n", e.message);
67 } 67 }
68 }68 }
6969
70 private void watch (DBusConnection connection) {70 private void watch (DBusConnection connection) {
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);
72 }72 }
7373
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 {
75 base.dbus_register (connection, object_path);75 base.dbus_register (connection, object_path);
76 watch (connection);76 watch (connection);
7777
78 return true;78 return true;
79 }79 }
8080
81 public override void dbus_unregister (DBusConnection connection, string object_path) {81 public override void dbus_unregister (DBusConnection connection, string object_path) {
82 if (bus_registered) {82 if (bus_registered) {
83 connection.unregister_object (object_id);83 connection.unregister_object (object_id);
84 }84 }
8585
86 base.dbus_unregister (connection, object_path);86 base.dbus_unregister (connection, object_path);
87 }87 }
88 88
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) {
90 debug ("Request for '%s' at level '%u'", id, req_accuracy);90 debug ("Request for '%s' at level '%u'", id, req_accuracy);
9191
92 DesktopAppInfo app_info = new DesktopAppInfo (id + ".desktop");92 DesktopAppInfo app_info = new DesktopAppInfo (id + ".desktop");
93 if (app_info == null) {93 if (app_info == null) {
94 debug ("Rejecting for invalid desktop file");94 debug ("Rejecting for invalid desktop file");
95 authorized = false;95 authorized = false;
96 allowed_accuracy = req_accuracy;96 allowed_accuracy = req_accuracy;
97 return;97 return;
98 }98 }
9999
100 Variant? remembered_accuracy = get_remembered_accuracy (id);100 Variant? remembered_accuracy = get_remembered_accuracy (id);
101 if (remembered_accuracy != null) {101 if (remembered_accuracy != null) {
102 var stored_auth = remembered_accuracy.get_child_value (0).get_boolean ();102 var stored_auth = remembered_accuracy.get_child_value (0).get_boolean ();
103 var stored_accuracy = remembered_accuracy.get_child_value (1).get_uint32 (); 103 var stored_accuracy = remembered_accuracy.get_child_value (1).get_uint32 ();
104 if (req_accuracy <= stored_accuracy && stored_auth) {104 if (req_accuracy <= stored_accuracy && stored_auth) {
105 authorized = true;105 authorized = true;
106 allowed_accuracy = req_accuracy;106 allowed_accuracy = req_accuracy;
107 return;107 return;
108 }108 }
109 }109 }
110110
111 string app_name = app_info.get_display_name ();111 string app_name = app_info.get_display_name ();
112 string accuracy_string = accuracy_to_string (app_name, req_accuracy);112 string accuracy_string = accuracy_to_string (app_name, req_accuracy);
113113
114 client = yield get_geoclue_client ();114 client = yield get_geoclue_client ();
115 debug ("Starting client...");115 debug ("Starting client...");
116 if (client != null) {116 if (client != null) {
117 try {117 try {
118 client.start ();118 client.start ();
119 } catch (Error e) {119 } catch (Error e) {
120 error ("Could not start client: %s", e.message);120 error ("Could not start client: %s", e.message);
121 }121 }
122 }122 }
123123
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 ());
125 dialog.show_all ();125 dialog.show_all ();
126126
127 var result = dialog.run ();127 var result = dialog.run ();
128128
129 if (result == Gtk.ResponseType.YES) {129 if (result == Gtk.ResponseType.YES) {
130 authorized = true;130 authorized = true;
131 } else {131 } else {
132 authorized = false;132 authorized = false;
133 }133 }
134 134
135 dialog.destroy ();135 dialog.destroy ();
136 allowed_accuracy = req_accuracy;136 allowed_accuracy = req_accuracy;
137 remember_app (id, authorized, req_accuracy);137 remember_app (id, authorized, req_accuracy);
138138
139 debug ("Stopping client...");139 debug ("Stopping client...");
140 if (client != null) {140 if (client != null) {
141 try {141 try {
142 client.stop ();142 client.stop ();
143 } catch (Error e) {143 } catch (Error e) {
144 error ("Could not stop client: %s", e.message);144 error ("Could not stop client: %s", e.message);
145 }145 }
146 } 146 }
147 }147 }
148148
149 private string accuracy_to_string (string app_name, uint accuracy) {149 private string accuracy_to_string (string app_name, uint accuracy) {
150 string message = "";150 string message = "";
151 switch (accuracy) {151 switch (accuracy) {
152 case GeoClue2.AccuracyLevel.COUNTRY:152 case GeoClue2.AccuracyLevel.COUNTRY:
153 message = _("the current country");153 message = _("the current country");
154 break;154 break;
155 case GeoClue2.AccuracyLevel.CITY:155 case GeoClue2.AccuracyLevel.CITY:
156 message = _("the nearest city or town");156 message = _("the nearest city or town");
157 break;157 break;
158 case GeoClue2.AccuracyLevel.NEIGHBORHOOD:158 case GeoClue2.AccuracyLevel.NEIGHBORHOOD:
159 message = _("the nearest neighborhood");159 message = _("the nearest neighborhood");
160 break;160 break;
161 case GeoClue2.AccuracyLevel.STREET:161 case GeoClue2.AccuracyLevel.STREET:
162 message = _("the nearest street");162 message = _("the nearest street");
163 break;163 break;
164 case GeoClue2.AccuracyLevel.EXACT:164 case GeoClue2.AccuracyLevel.EXACT:
165 message = _("your exact location");165 message = _("your exact location");
166 break;166 break;
167 default:167 default:
168 message = _("your location");168 message = _("your location");
169 break;169 break;
170 }170 }
171 171
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);
173 }173 }
174174
175 private async void register_with_geoclue () {175 private async void register_with_geoclue () {
176 yield Utils.register_with_geoclue (application_id);176 yield Utils.register_with_geoclue (application_id);
177 }177 }
178178
179 private async GeoClue2Client? get_geoclue_client () {179 private async GeoClue2Client? get_geoclue_client () {
180 return yield Utils.get_geoclue2_client (application_id);180 return yield Utils.get_geoclue2_client (application_id);
181 }181 }
182182
183 private void refresh_remembered_apps () {183 private void refresh_remembered_apps () {
184 remembered_apps = new VariantDict(settings.get_value("remembered-apps"));184 remembered_apps = new VariantDict(settings.get_value("remembered-apps"));
185 }185 }
186186
187 private void refresh_enabled_state () {187 private void refresh_enabled_state () {
188 bool enabled = settings.get_value ("location-enabled").get_boolean ();188 bool enabled = settings.get_value ("location-enabled").get_boolean ();
189 if (enabled) {189 if (enabled) {
190 _max_accuracy_level = GeoClue2.AccuracyLevel.EXACT;190 _max_accuracy_level = GeoClue2.AccuracyLevel.EXACT;
191 } else {191 } else {
192 _max_accuracy_level = GeoClue2.AccuracyLevel.NONE;192 _max_accuracy_level = GeoClue2.AccuracyLevel.NONE;
193 }193 }
194 }194 }
195195
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) {
197 Variant[2] tuple_vals = new Variant[2];197 Variant[2] tuple_vals = new Variant[2];
198 tuple_vals[0] = new Variant.boolean (authorized);198 tuple_vals[0] = new Variant.boolean (authorized);
199 tuple_vals[1] = new Variant.uint32 (accuracy_level);199 tuple_vals[1] = new Variant.uint32 (accuracy_level);
200 remembered_apps.insert_value (desktop_id, new Variant.tuple (tuple_vals));200 remembered_apps.insert_value (desktop_id, new Variant.tuple (tuple_vals));
201 settings.set_value ("remembered-apps", remembered_apps.end ());201 settings.set_value ("remembered-apps", remembered_apps.end ());
202 }202 }
203203
204 public Variant? get_remembered_accuracy (string desktop_id) {204 public Variant? get_remembered_accuracy (string desktop_id) {
205 return remembered_apps.lookup_value (desktop_id, GLib.VariantType.TUPLE);205 return remembered_apps.lookup_value (desktop_id, GLib.VariantType.TUPLE);
206 }206 }
207 }207 }
208208
209 public static int main (string[] args) {209 public static int main (string[] args) {
210210
=== modified file 'src/Interfaces.vala'
--- src/Interfaces.vala 2017-02-25 15:01:53 +0000
+++ src/Interfaces.vala 2017-02-25 17:42:29 +0000
@@ -27,12 +27,12 @@
27 }27 }
2828
29 [DBus (name = "org.freedesktop.GeoClue2.Agent")]29 [DBus (name = "org.freedesktop.GeoClue2.Agent")]
30 public interface GeoClue2Agent : GLib.Object {30 public interface GeoClue2Agent : GLib.Object {
31 [DBus (name = "AuthorizeApp")]31 [DBus (name = "AuthorizeApp")]
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;
33 [DBus (name ="MaxAccuracyLevel")]33 [DBus (name ="MaxAccuracyLevel")]
34 public abstract uint max_accuracy_level { get; }34 public abstract uint max_accuracy_level { get; }
35 }35 }
3636
37 [DBus (name = "org.freedesktop.GeoClue2.Client")]37 [DBus (name = "org.freedesktop.GeoClue2.Client")]
38 public interface GeoClue2Client : GLib.Object {38 public interface GeoClue2Client : GLib.Object {
3939
=== modified file 'vapi/geoclue2.vapi'
--- vapi/geoclue2.vapi 2017-02-20 18:30:50 +0000
+++ vapi/geoclue2.vapi 2017-02-25 17:42:29 +0000
@@ -20,13 +20,13 @@
20 */20 */
2121
22namespace GeoClue2 {22namespace GeoClue2 {
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" )]
24 public enum AccuracyLevel {24 public enum AccuracyLevel {
25 NONE,25 NONE,
26 COUNTRY,26 COUNTRY,
27 CITY,27 CITY,
28 NEIGHBORHOOD,28 NEIGHBORHOOD,
29 STREET,29 STREET,
30 EXACT30 EXACT
31 }31 }
32}32}

Subscribers

People subscribed via source and target branches

to all changes: