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
=== modified file 'src/indicator/nmofono/hotspot-manager.cpp'
--- src/indicator/nmofono/hotspot-manager.cpp 2016-05-10 11:21:08 +0000
+++ src/indicator/nmofono/hotspot-manager.cpp 2016-05-10 11:21:08 +0000
@@ -40,6 +40,17 @@
40namespace nmofono40namespace nmofono
41{41{
4242
43struct ApDevice
44{
45 ApDevice (const QDBusObjectPath& path, const QString& interface) :
46 m_path (path), m_interface (interface)
47 {
48 }
49
50 QDBusObjectPath m_path;
51 QString m_interface;
52};
53
43class HotspotManager::Priv: public QObject54class HotspotManager::Priv: public QObject
44{55{
4556
@@ -271,10 +282,9 @@
271 return true;282 return true;
272 }283 }
273284
274285 void findApDevice()
275 QDBusObjectPath getApDevice()
276 {286 {
277 QDBusObjectPath result("/");287 m_device.release();
278 QString tetherIface = getTetheringInterface();288 QString tetherIface = getTetheringInterface();
279289
280 auto devices = QList<QDBusObjectPath>(m_manager->GetDevices()).toStdList();290 auto devices = QList<QDBusObjectPath>(m_manager->GetDevices()).toStdList();
@@ -293,35 +303,32 @@
293 }303 }
294 }304 }
295305
296 if (device.deviceType() == NM_DEVICE_TYPE_WIFI)306 if (device.deviceType() != NM_DEVICE_TYPE_WIFI)
297 {307 {
298 qDebug() << "Using AP interface " << interface;308 continue;
299 m_interface = interface;
300 result = *path;
301 break;
302 }309 }
310
311 qDebug() << __PRETTY_FUNCTION__ << "Using AP interface " << interface;
312 m_device = make_unique<ApDevice>(*path, interface);
313 break;
303 }314 }
304
305 return result;
306 }315 }
307316
308 QDBusObjectPath createApDevice()317 void createApDevice()
309 {318 {
310 setInterfaceFirmware("/", m_mode);319 setInterfaceFirmware("/", m_mode);
311320
312 QDBusObjectPath result("/");321 m_device.release();
313322
314 int count = 0;323 int count = 0;
315 // Wait for AP device to appear324 // Wait for AP device to appear
316 while (count < 20 && result.path() == "/")325 while (count < 20 && !m_device)
317 {326 {
318 QThread::msleep(100);327 QThread::msleep(100);
319 result = getApDevice();328 findApDevice();
320 qDebug() << __PRETTY_FUNCTION__ << "Searching for AP device" << result.path();329 qDebug() << __PRETTY_FUNCTION__ << "Searching for AP device";
321 ++count;330 ++count;
322 }331 }
323
324 return result;
325 }332 }
326333
327 // wpa_supplicant interaction334 // wpa_supplicant interaction
@@ -521,12 +528,12 @@
521 }528 }
522529
523530
524 auto device = getApDevice();531 findApDevice();
525532
526 if (device.path() != "/")533 if (m_device)
527 {534 {
528 qDebug() << __PRETTY_FUNCTION__ << "Reactivating hotspot connection on device" << device.path();535 qDebug() << __PRETTY_FUNCTION__ << "Reactivating hotspot connection on device" << m_device->m_path.path();
529 activateConnection(device);536 activateConnection(m_device->m_path);
530 }537 }
531 else538 else
532 {539 {
@@ -543,7 +550,8 @@
543 bool m_stored = false;550 bool m_stored = false;
544 QString m_password;551 QString m_password;
545 QByteArray m_ssid = "Ubuntu";552 QByteArray m_ssid = "Ubuntu";
546 QString m_interface;553
554 unique_ptr<ApDevice> m_device;
547555
548 QPowerd::UPtr m_powerd;556 QPowerd::UPtr m_powerd;
549 QPowerd::RequestSPtr m_wakelock;557 QPowerd::RequestSPtr m_wakelock;
@@ -619,9 +627,9 @@
619 d->setDisconnectWifi(true);627 d->setDisconnectWifi(true);
620628
621 // We use Hybris to load the new device firmware629 // We use Hybris to load the new device firmware
622 auto device = d->createApDevice();630 d->createApDevice();
623631
624 if (device.path() == "/")632 if (!d->m_device)
625 {633 {
626 qWarning() << __PRETTY_FUNCTION__ << "Failed to create AP device";634 qWarning() << __PRETTY_FUNCTION__ << "Failed to create AP device";
627 Q_EMIT reportError(1);635 Q_EMIT reportError(1);
@@ -637,7 +645,7 @@
637 {645 {
638 d->addConnection();646 d->addConnection();
639 }647 }
640 d->enable(device);648 d->enable(d->m_device->m_path);
641 }649 }
642 else650 else
643 {651 {
@@ -691,8 +699,8 @@
691699
692QString HotspotManager::interface() const700QString HotspotManager::interface() const
693{701{
694 if (enabled())702 if (enabled() && d->m_device)
695 return d->m_interface;703 return d->m_device->m_interface;
696 else704 else
697 return QString();705 return QString();
698}706}

Subscribers

People subscribed via source and target branches