Merge lp:~marcustomlinson/indicator-network/lp-1427064 into lp:indicator-network/15.04

Proposed by Marcus Tomlinson
Status: Merged
Merged at revision: 478
Proposed branch: lp:~marcustomlinson/indicator-network/lp-1427064
Merge into: lp:indicator-network/15.04
Diff against target: 51 lines (+31/-3)
1 file modified
src/indicator/root-state.cpp (+31/-3)
To merge this branch: bzr merge lp:~marcustomlinson/indicator-network/lp-1427064
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Indicator Applet Developers Pending
Review via email: mp+251403@code.launchpad.net

Commit message

Connect RootState::Private::updateNetworkingIcon() to changes in connected AP strength.

To post a comment you must log in.
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
1=== modified file 'src/indicator/root-state.cpp'
2--- src/indicator/root-state.cpp 2015-02-16 18:33:02 +0000
3+++ src/indicator/root-state.cpp 2015-03-02 06:41:24 +0000
4@@ -34,6 +34,8 @@
5 std::shared_ptr<networking::Manager> m_manager;
6 ModemManager::Ptr m_modemManager;
7 core::Property<Variant> m_state;
8+ networking::wifi::AccessPoint::Ptr m_activeAP;
9+ std::shared_ptr<core::ScopedConnection> m_activeAP_conn;
10
11 std::string m_label;
12
13@@ -224,9 +226,35 @@
14
15 int strength = -1;
16 bool secured = false;
17- if (wifiLink->activeAccessPoint().get()) {
18- strength = wifiLink->activeAccessPoint().get()->strength().get();
19- secured = wifiLink->activeAccessPoint().get()->secured();
20+
21+ // check if the currently active AP has changed
22+ if (m_activeAP != wifiLink->activeAccessPoint().get())
23+ {
24+ // locally store the active AP
25+ m_activeAP = wifiLink->activeAccessPoint().get();
26+ if (m_activeAP)
27+ {
28+ // connect updateNetworkingIcon() to changes in AP strength
29+ auto that = shared_from_this();
30+ m_activeAP_conn = std::make_shared<core::ScopedConnection>(
31+ m_activeAP->strength().changed().connect([that](double)
32+ {
33+ GMainLoopDispatch([that](){
34+ that->updateNetworkingIcon();
35+ });
36+ })
37+ );
38+ }
39+ else
40+ {
41+ // there is no active AP, so we disconnect from strength updates
42+ m_activeAP_conn = nullptr;
43+ }
44+ }
45+
46+ if (m_activeAP) {
47+ strength = m_activeAP->strength().get();
48+ secured = m_activeAP->secured();
49 }
50
51 /// @todo deal with a11ydesc

Subscribers

People subscribed via source and target branches