Merge lp:~pete-woods/indicator-network/no-aps-when-hotspot-enabled into lp:indicator-network/15.10

Proposed by Pete Woods
Status: Merged
Approved by: Pete Woods
Approved revision: 522
Merged at revision: 506
Proposed branch: lp:~pete-woods/indicator-network/no-aps-when-hotspot-enabled
Merge into: lp:indicator-network/15.10
Prerequisite: lp:~pete-woods/indicator-network/simplify-toggles
Diff against target: 472 lines (+166/-113) (has conflicts)
6 files modified
src/indicator/nmofono/kill-switch.cpp (+49/-27)
src/indicator/nmofono/kill-switch.h (+1/-3)
src/indicator/nmofono/manager-impl.cpp (+71/-70)
src/indicator/nmofono/wifi/wifi-link-impl.cpp (+38/-11)
src/indicator/nmofono/wifi/wifi-link-impl.h (+3/-1)
src/indicator/nmofono/wifi/wifi-link.h (+4/-1)
Text conflict in debian/changelog
To merge this branch: bzr merge lp:~pete-woods/indicator-network/no-aps-when-hotspot-enabled
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Indicator Applet Developers Pending
Review via email: mp+267314@code.launchpad.net

Commit message

Don't show access points when hotspot is enabled

Description of the change

Don't show access points when hotspot is enabled

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/nmofono/kill-switch.cpp'
2--- src/indicator/nmofono/kill-switch.cpp 2015-08-07 09:39:56 +0000
3+++ src/indicator/nmofono/kill-switch.cpp 2015-08-07 09:39:56 +0000
4@@ -25,11 +25,15 @@
5 #include <URfkillInterface.h>
6 #include <URfkillKillswitchInterface.h>
7
8+using namespace std;
9+
10 namespace nmofono
11 {
12
13-class KillSwitch::Private
14+class KillSwitch::Private: public QObject
15 {
16+ Q_OBJECT
17+
18 public:
19 enum class DeviceType
20 {
21@@ -43,15 +47,48 @@
22 nfc = 8
23 };
24
25+ KillSwitch& p;
26+
27 std::shared_ptr<OrgFreedesktopURfkillInterface> urfkill;
28 std::shared_ptr<OrgFreedesktopURfkillKillswitchInterface> killSwitch;
29
30 bool m_flightMode = false;
31+ State m_state = State::not_available;
32
33- Private(std::shared_ptr<OrgFreedesktopURfkillInterface> urfkill,
34+ Private(KillSwitch& parent,
35+ std::shared_ptr<OrgFreedesktopURfkillInterface> urfkill,
36 std::shared_ptr<OrgFreedesktopURfkillKillswitchInterface> killSwitch)
37- : urfkill(urfkill),
38+ : p(parent),
39+ urfkill(urfkill),
40 killSwitch(killSwitch) {}
41+
42+public Q_SLOTS:
43+ void setFlightMode(bool flightMode)
44+ {
45+ if (flightMode == m_flightMode)
46+ {
47+ return;
48+ }
49+
50+ m_flightMode = flightMode;
51+ Q_EMIT p.flightModeChanged(flightMode);
52+ }
53+
54+ void stateChanged()
55+ {
56+ int stateIndex = killSwitch->state();
57+ if (stateIndex >= static_cast<int>(State::first_) &&
58+ stateIndex <= static_cast<int>(State::last_))
59+ {
60+ m_state = static_cast<KillSwitch::State>(stateIndex);
61+ }
62+ else
63+ {
64+ m_state = KillSwitch::State::not_available;
65+ }
66+
67+ Q_EMIT p.stateChanged(m_state);
68+ }
69 };
70
71
72@@ -65,28 +102,17 @@
73 DBusTypes::URFKILL_WIFI_OBJ_PATH,
74 systemBus);
75
76- connect(urfkill.get(), SIGNAL(FlightModeChanged(bool)), this, SLOT(setFlightMode(bool)));
77- connect(killSwitch.get(), SIGNAL(StateChanged()), this, SIGNAL(stateChanged()));
78-
79- d.reset(new Private(urfkill, killSwitch));
80-
81- setFlightMode(urfkill->IsFlightMode());
82+ d = make_unique<Private>(*this, urfkill, killSwitch);
83+ d->setFlightMode(urfkill->IsFlightMode());
84+ d->stateChanged();
85+
86+ connect(urfkill.get(), &OrgFreedesktopURfkillInterface::FlightModeChanged, d.get(), &Private::setFlightMode);
87+ connect(killSwitch.get(), &OrgFreedesktopURfkillKillswitchInterface::StateChanged, d.get(), &Private::stateChanged);
88 }
89
90 KillSwitch::~KillSwitch()
91 {}
92
93-void KillSwitch::setFlightMode(bool flightMode)
94-{
95- if (flightMode == d->m_flightMode)
96- {
97- return;
98- }
99-
100- d->m_flightMode = flightMode;
101- Q_EMIT flightModeChanged(flightMode);
102-}
103-
104 void
105 KillSwitch::setBlock(bool block)
106 {
107@@ -121,13 +147,7 @@
108
109 KillSwitch::State KillSwitch::state() const
110 {
111- int stateIndex = d->killSwitch->state();
112- if (stateIndex >= static_cast<int>(State::first_) &&
113- stateIndex <= static_cast<int>(State::last_))
114- {
115- return static_cast<KillSwitch::State>(stateIndex);
116- }
117- return KillSwitch::State::not_available;
118+ return d->m_state;
119 }
120
121 bool KillSwitch::flightMode(bool enable)
122@@ -154,3 +174,5 @@
123 }
124
125 }
126+
127+#include "kill-switch.moc"
128
129=== modified file 'src/indicator/nmofono/kill-switch.h'
130--- src/indicator/nmofono/kill-switch.h 2015-08-07 09:39:56 +0000
131+++ src/indicator/nmofono/kill-switch.h 2015-08-07 09:39:56 +0000
132@@ -57,11 +57,9 @@
133 bool isFlightMode();
134
135 Q_SIGNALS:
136- void stateChanged();
137+ void stateChanged(State);
138 void flightModeChanged(bool);
139
140-private Q_SLOTS:
141- void setFlightMode(bool);
142 };
143
144 }
145
146=== modified file 'src/indicator/nmofono/manager-impl.cpp'
147--- src/indicator/nmofono/manager-impl.cpp 2015-08-07 09:39:56 +0000
148+++ src/indicator/nmofono/manager-impl.cpp 2015-08-07 09:39:56 +0000
149@@ -271,6 +271,69 @@
150 d->updateHasWifi();
151 }
152
153+bool
154+ManagerImpl::wifiEnabled() const
155+{
156+ return d->m_wifiEnabled;
157+}
158+
159+
160+void
161+ManagerImpl::setWifiEnabled(bool enabled)
162+{
163+ if (!d->m_hasWifi)
164+ {
165+ return;
166+ }
167+
168+ if (d->m_wifiEnabled == enabled)
169+ {
170+ return;
171+ }
172+
173+ d->setUnstoppableOperationHappening(true);
174+ d->m_killSwitch->setBlock(!enabled);
175+ d->nm->setWirelessEnabled(enabled);
176+ d->setUnstoppableOperationHappening(false);
177+}
178+
179+bool
180+ManagerImpl::hotspotEnabled() const
181+{
182+ return d->m_hotspotManager->enabled();
183+}
184+
185+void
186+ManagerImpl::setHotspotEnabled(bool enabled)
187+{
188+ d->setUnstoppableOperationHappening(true);
189+ d->m_hotspotManager->setEnabled(enabled);
190+ d->setUnstoppableOperationHappening(false);
191+}
192+
193+void
194+ManagerImpl::setFlightMode(bool enabled)
195+{
196+ if (enabled == d->m_killSwitch->isFlightMode())
197+ {
198+ return;
199+ }
200+
201+ d->setUnstoppableOperationHappening(true);
202+
203+ if (!d->m_killSwitch->flightMode(enabled))
204+ {
205+ qWarning() << "Failed to change flightmode.";
206+ }
207+ d->setUnstoppableOperationHappening(false);
208+}
209+
210+Manager::FlightModeStatus
211+ManagerImpl::flightMode() const
212+{
213+ return d->m_flightMode;
214+}
215+
216 void
217 ManagerImpl::nm_properties_changed(const QVariantMap &properties)
218 {
219@@ -325,9 +388,16 @@
220 auto dev = make_shared<OrgFreedesktopNetworkManagerDeviceInterface>(
221 NM_DBUS_SERVICE, path.path(), d->nm->connection());
222 if (dev->deviceType() == NM_DEVICE_TYPE_WIFI) {
223- link = make_shared<wifi::WifiLinkImpl>(dev,
224+ wifi::WifiLink::Ptr tmp = make_shared<wifi::WifiLinkImpl>(dev,
225 d->nm,
226 d->m_killSwitch);
227+
228+ // Wire up enabling / disabling AP visibility to the hotspot enabled state
229+ tmp->setHideAccessPoints(d->m_hotspotManager->enabled());
230+ QObject::connect(d->m_hotspotManager.get(), &HotspotManager::enabledChanged,
231+ tmp.get(), &wifi::WifiLink::setHideAccessPoints);
232+
233+ link = tmp;
234 }
235 } catch (const exception &e) {
236 qDebug() << __PRETTY_FUNCTION__ << ": failed to create Device proxy for "<< path.path() << ": ";
237@@ -345,35 +415,6 @@
238 }
239
240
241-void
242-ManagerImpl::setFlightMode(bool enabled)
243-{
244-#ifdef INDICATOR_NETWORK_TRACE_MESSAGES
245- qDebug() << __PRETTY_FUNCTION__ << enabled;
246-#endif
247- if (enabled == d->m_killSwitch->isFlightMode())
248- {
249- return;
250- }
251-
252- d->setUnstoppableOperationHappening(true);
253-
254- if (!d->m_killSwitch->flightMode(enabled))
255- {
256- qWarning() << "Failed to change flightmode.";
257- }
258- d->setUnstoppableOperationHappening(false);
259-}
260-
261-Manager::FlightModeStatus
262-ManagerImpl::flightMode() const
263-{
264- // - connect to each individual URfkill.Killswitch interface
265- // - make this property to reflect their combined state
266- /// @todo implement flightmode status properly when URfkill gets the flightmode API
267- return d->m_flightMode;
268-}
269-
270 bool
271 ManagerImpl::unstoppableOperationHappening() const
272 {
273@@ -410,32 +451,6 @@
274 }
275
276 bool
277-ManagerImpl::wifiEnabled() const
278-{
279- return d->m_wifiEnabled;
280-}
281-
282-
283-void
284-ManagerImpl::setWifiEnabled(bool enabled)
285-{
286- if (!d->m_hasWifi)
287- {
288- return;
289- }
290-
291- if (d->m_wifiEnabled == enabled)
292- {
293- return;
294- }
295-
296- d->setUnstoppableOperationHappening(true);
297- d->m_killSwitch->setBlock(!enabled);
298- d->nm->setWirelessEnabled(enabled);
299- d->setUnstoppableOperationHappening(false);
300-}
301-
302-bool
303 ManagerImpl::roaming() const
304 {
305 for (auto modem : d->m_ofonoLinks) {
306@@ -531,12 +546,6 @@
307 }
308
309 bool
310-ManagerImpl::hotspotEnabled() const
311-{
312- return d->m_hotspotManager->enabled();
313-}
314-
315-bool
316 ManagerImpl::hotspotStored() const
317 {
318 return d->m_hotspotManager->stored();
319@@ -561,14 +570,6 @@
320 }
321
322 void
323-ManagerImpl::setHotspotEnabled(bool enabled)
324-{
325- d->setUnstoppableOperationHappening(true);
326- d->m_hotspotManager->setEnabled(enabled);
327- d->setUnstoppableOperationHappening(false);
328-}
329-
330-void
331 ManagerImpl::setHotspotSsid(const QByteArray& ssid)
332 {
333 d->m_hotspotManager->setSsid(ssid);
334
335=== modified file 'src/indicator/nmofono/wifi/wifi-link-impl.cpp'
336--- src/indicator/nmofono/wifi/wifi-link-impl.cpp 2015-08-07 09:39:56 +0000
337+++ src/indicator/nmofono/wifi/wifi-link-impl.cpp 2015-08-07 09:39:56 +0000
338@@ -76,6 +76,7 @@
339 QString m_name;
340 shared_ptr<OrgFreedesktopNetworkManagerConnectionActiveInterface> m_activeConnection;
341 bool m_connecting = false;
342+ bool m_hideAccessPoints = false;
343
344 void setStatus(Status status)
345 {
346@@ -234,7 +235,7 @@
347 } else {
348 m_grouper[k] = make_shared<GroupedAccessPoint>(shap);
349 }
350- update_grouped();
351+ update_grouped_access_points();
352 } catch(const exception &e) {
353 /// @bug dbus-cpp internal logic exploded
354 // If this happens, indicator-network is in an unknown state with no clear way of
355@@ -271,16 +272,25 @@
356 m_grouper.erase(it);
357 }
358 }
359- update_grouped();
360+ update_grouped_access_points();
361 }
362
363- void update_grouped() {
364- QSet<AccessPoint::Ptr> new_grouped;
365- for(auto &i : m_grouper) {
366- new_grouped.insert(i.second);
367- }
368- m_groupedAccessPoints = new_grouped;
369- Q_EMIT p.accessPointsUpdated(new_grouped);
370+ void update_grouped_access_points()
371+ {
372+ m_groupedAccessPoints.clear();
373+ for (auto &i : m_grouper)
374+ {
375+ m_groupedAccessPoints.insert(i.second);
376+ }
377+
378+ if (m_hideAccessPoints)
379+ {
380+ Q_EMIT p.accessPointsUpdated(QSet<AccessPoint::Ptr>());
381+ }
382+ else
383+ {
384+ Q_EMIT p.accessPointsUpdated(m_groupedAccessPoints);
385+ }
386 }
387
388 void state_changed(uint new_state, uint, uint)
389@@ -288,7 +298,7 @@
390 updateDeviceState(new_state);
391 }
392
393- void kill_switch_updated()
394+ void kill_switch_updated(KillSwitch::State)
395 {
396 updateDeviceState(m_lastState);
397 }
398@@ -346,8 +356,13 @@
399 return d->m_name;
400 }
401
402-const QSet<AccessPoint::Ptr>&
403+QSet<AccessPoint::Ptr>
404 WifiLinkImpl::accessPoints() const {
405+ if (d->m_hideAccessPoints)
406+ {
407+ return QSet<AccessPoint::Ptr>();
408+ }
409+
410 return d->m_groupedAccessPoints;
411 }
412
413@@ -438,6 +453,18 @@
414 return QDBusObjectPath(d->m_dev->path());
415 }
416
417+void
418+WifiLinkImpl::setHideAccessPoints(bool hide)
419+{
420+ if (hide == d->m_hideAccessPoints)
421+ {
422+ return;
423+ }
424+
425+ d->m_hideAccessPoints = hide;
426+ d->update_grouped_access_points();
427+}
428+
429 }
430 }
431
432
433=== modified file 'src/indicator/nmofono/wifi/wifi-link-impl.h'
434--- src/indicator/nmofono/wifi/wifi-link-impl.h 2015-08-07 09:39:56 +0000
435+++ src/indicator/nmofono/wifi/wifi-link-impl.h 2015-08-07 09:39:56 +0000
436@@ -50,12 +50,14 @@
437 std::uint32_t characteristics() const override;
438 Status status() const override;
439
440- const QSet<AccessPoint::Ptr>& accessPoints() const override;
441+ QSet<AccessPoint::Ptr> accessPoints() const override;
442 void connect_to(AccessPoint::Ptr accessPoint) override;
443 AccessPoint::Ptr activeAccessPoint() override;
444
445 QDBusObjectPath device_path() const;
446
447+ void setHideAccessPoints(bool) override;
448+
449 private:
450 struct Private;
451 std::unique_ptr<Private> d;
452
453=== modified file 'src/indicator/nmofono/wifi/wifi-link.h'
454--- src/indicator/nmofono/wifi/wifi-link.h 2015-04-14 11:20:17 +0000
455+++ src/indicator/nmofono/wifi/wifi-link.h 2015-08-07 09:39:56 +0000
456@@ -46,13 +46,16 @@
457 virtual ~WifiLink() = default;
458
459 Q_PROPERTY(QSet<nmofono::wifi::AccessPoint::Ptr> accessPoints READ accessPoints NOTIFY accessPointsUpdated)
460- virtual const QSet<AccessPoint::Ptr>& accessPoints() const = 0;
461+ virtual QSet<AccessPoint::Ptr> accessPoints() const = 0;
462
463 virtual void connect_to(AccessPoint::Ptr accessPoint) = 0;
464
465 Q_PROPERTY(nmofono::wifi::AccessPoint::Ptr activeAccessPoint READ activeAccessPoint NOTIFY activeAccessPointUpdated)
466 virtual AccessPoint::Ptr activeAccessPoint() = 0;
467
468+public Q_SLOTS:
469+ virtual void setHideAccessPoints(bool) = 0;
470+
471 Q_SIGNALS:
472 void accessPointsUpdated(const QSet<AccessPoint::Ptr>&);
473

Subscribers

People subscribed via source and target branches