Merge lp:~phablet-team/indicator-network/store-hotspot-device into lp:indicator-network

Proposed by Pete Woods
Status: Merged
Approved by: Pete Woods
Approved revision: 589
Merged at revision: 591
Proposed branch: lp:~phablet-team/indicator-network/store-hotspot-device
Merge into: lp:indicator-network
Prerequisite: lp:~phablet-team/indicator-network/fix-nm1.2-hotspot
Diff against target: 140 lines (+35/-27)
1 file modified
src/indicator/nmofono/hotspot-manager.cpp (+35/-27)
To merge this branch: bzr merge lp:~phablet-team/indicator-network/store-hotspot-device
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Needs Fixing
Indicator Applet Developers Pending
Review via email: mp+294226@code.launchpad.net

Commit message

Store information about which device we are using in a member variable

* Explicitly name methods and remove return types to make it clear they are altering the state of the hotspot manager

Description of the change

Store information about which device we are using in a member variable

* Explicitly name methods and remove return types to make it clear they are altering the state of the hotspot manager

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (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/hotspot-manager.cpp'
2--- src/indicator/nmofono/hotspot-manager.cpp 2016-05-10 11:21:08 +0000
3+++ src/indicator/nmofono/hotspot-manager.cpp 2016-05-10 11:21:08 +0000
4@@ -40,6 +40,17 @@
5 namespace nmofono
6 {
7
8+struct ApDevice
9+{
10+ ApDevice (const QDBusObjectPath& path, const QString& interface) :
11+ m_path (path), m_interface (interface)
12+ {
13+ }
14+
15+ QDBusObjectPath m_path;
16+ QString m_interface;
17+};
18+
19 class HotspotManager::Priv: public QObject
20 {
21
22@@ -271,10 +282,9 @@
23 return true;
24 }
25
26-
27- QDBusObjectPath getApDevice()
28+ void findApDevice()
29 {
30- QDBusObjectPath result("/");
31+ m_device.release();
32 QString tetherIface = getTetheringInterface();
33
34 auto devices = QList<QDBusObjectPath>(m_manager->GetDevices()).toStdList();
35@@ -293,35 +303,32 @@
36 }
37 }
38
39- if (device.deviceType() == NM_DEVICE_TYPE_WIFI)
40+ if (device.deviceType() != NM_DEVICE_TYPE_WIFI)
41 {
42- qDebug() << "Using AP interface " << interface;
43- m_interface = interface;
44- result = *path;
45- break;
46+ continue;
47 }
48+
49+ qDebug() << __PRETTY_FUNCTION__ << "Using AP interface " << interface;
50+ m_device = make_unique<ApDevice>(*path, interface);
51+ break;
52 }
53-
54- return result;
55 }
56
57- QDBusObjectPath createApDevice()
58+ void createApDevice()
59 {
60 setInterfaceFirmware("/", m_mode);
61
62- QDBusObjectPath result("/");
63+ m_device.release();
64
65 int count = 0;
66 // Wait for AP device to appear
67- while (count < 20 && result.path() == "/")
68+ while (count < 20 && !m_device)
69 {
70 QThread::msleep(100);
71- result = getApDevice();
72- qDebug() << __PRETTY_FUNCTION__ << "Searching for AP device" << result.path();
73+ findApDevice();
74+ qDebug() << __PRETTY_FUNCTION__ << "Searching for AP device";
75 ++count;
76 }
77-
78- return result;
79 }
80
81 // wpa_supplicant interaction
82@@ -521,12 +528,12 @@
83 }
84
85
86- auto device = getApDevice();
87+ findApDevice();
88
89- if (device.path() != "/")
90+ if (m_device)
91 {
92- qDebug() << __PRETTY_FUNCTION__ << "Reactivating hotspot connection on device" << device.path();
93- activateConnection(device);
94+ qDebug() << __PRETTY_FUNCTION__ << "Reactivating hotspot connection on device" << m_device->m_path.path();
95+ activateConnection(m_device->m_path);
96 }
97 else
98 {
99@@ -543,7 +550,8 @@
100 bool m_stored = false;
101 QString m_password;
102 QByteArray m_ssid = "Ubuntu";
103- QString m_interface;
104+
105+ unique_ptr<ApDevice> m_device;
106
107 QPowerd::UPtr m_powerd;
108 QPowerd::RequestSPtr m_wakelock;
109@@ -619,9 +627,9 @@
110 d->setDisconnectWifi(true);
111
112 // We use Hybris to load the new device firmware
113- auto device = d->createApDevice();
114+ d->createApDevice();
115
116- if (device.path() == "/")
117+ if (!d->m_device)
118 {
119 qWarning() << __PRETTY_FUNCTION__ << "Failed to create AP device";
120 Q_EMIT reportError(1);
121@@ -637,7 +645,7 @@
122 {
123 d->addConnection();
124 }
125- d->enable(device);
126+ d->enable(d->m_device->m_path);
127 }
128 else
129 {
130@@ -691,8 +699,8 @@
131
132 QString HotspotManager::interface() const
133 {
134- if (enabled())
135- return d->m_interface;
136+ if (enabled() && d->m_device)
137+ return d->m_device->m_interface;
138 else
139 return QString();
140 }

Subscribers

People subscribed via source and target branches