Merge lp:~charlesk/indicator-location/lp-1348334-ualc-status into lp:indicator-location/14.10

Proposed by Charles Kerr
Status: Merged
Approved by: Thomas Voß
Approved revision: 104
Merged at revision: 104
Proposed branch: lp:~charlesk/indicator-location/lp-1348334-ualc-status
Merge into: lp:indicator-location/14.10
Diff against target: 67 lines (+15/-10)
2 files modified
src/controller-ualc.cc (+14/-9)
src/controller-ualc.h (+1/-1)
To merge this branch: bzr merge lp:~charlesk/indicator-location/lp-1348334-ualc-status
Reviewer Review Type Date Requested Status
Thomas Voß (community) Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+230004@code.launchpad.net

Commit message

Fix bug that let controller-ualc's state get out of sync with the platform-api's ualc state.

Description of the change

Fix bug that let controller-ualc's state get out of sync with the platform-api's ualc state.

when src/controller-ualc.cc gets a state change notification from ualc, get an up-to-date status by calling ua_location_service_controller_query_status().

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Thomas Voß (thomas-voss) wrote :

LGTM.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/controller-ualc.cc'
2--- src/controller-ualc.cc 2014-01-29 00:21:10 +0000
3+++ src/controller-ualc.cc 2014-08-07 19:50:43 +0000
4@@ -32,10 +32,7 @@
5 on_ualc_status_changed,
6 this);
7
8- // query the ualc to bootstrap our initial status
9- UALocationServiceStatusFlags initial_status;
10- if (ua_location_service_controller_query_status (ualc, &initial_status) == U_STATUS_SUCCESS)
11- set_status (initial_status);
12+ update_status();
13 }
14
15 UbuntuAppLocController :: ~UbuntuAppLocController ()
16@@ -45,17 +42,25 @@
17 }
18
19 void
20-UbuntuAppLocController :: on_ualc_status_changed (UALocationServiceStatusFlags flags, void *vself)
21+UbuntuAppLocController :: on_ualc_status_changed (UALocationServiceStatusFlags /*flags*/, void *vself)
22 {
23- static_cast<UbuntuAppLocController*>(vself)->set_status (flags);
24+ static_cast<UbuntuAppLocController*>(vself)->update_status();
25 }
26
27 void
28-UbuntuAppLocController :: set_status (UALocationServiceStatusFlags new_status)
29+UbuntuAppLocController :: update_status ()
30 {
31 const bool loc_was_enabled = is_location_service_enabled();
32 const bool gps_was_enabled = is_gps_enabled();
33- current_status = new_status;
34+
35+ // update this.current_status with a fresh ualc status
36+ UALocationServiceStatusFlags flags;
37+ if (ua_location_service_controller_query_status (ualc, &flags) == U_STATUS_SUCCESS)
38+ {
39+ g_debug("%s %s updating ualc controller status with flags: %d", G_STRLOC, G_STRFUNC, (int)flags);
40+ current_status = flags;
41+ }
42+
43 const bool loc_is_enabled = is_location_service_enabled();
44 const bool gps_is_enabled = is_gps_enabled();
45
46@@ -63,7 +68,7 @@
47 notify_location_service_enabled (loc_is_enabled);
48
49 if (gps_was_enabled != gps_is_enabled)
50- notify_gps_enabled (gps_is_enabled);
51+ notify_gps_enabled (gps_is_enabled);
52 }
53
54 /***
55
56=== modified file 'src/controller-ualc.h'
57--- src/controller-ualc.h 2014-01-26 21:37:12 +0000
58+++ src/controller-ualc.h 2014-08-07 19:50:43 +0000
59@@ -46,7 +46,7 @@
60 UbuntuApplicationLocationServiceController * ualc;
61
62 static void on_ualc_status_changed (UALocationServiceStatusFlags, void *vself);
63- void set_status (UALocationServiceStatusFlags);
64+ void update_status ();
65 };
66
67 #endif // __INDICATOR_LOCATION_CONTROLLER_UALC__H__

Subscribers

People subscribed via source and target branches