Merge lp:~unity-api-team/indicator-network/hotspot-cellular-enabled-properties into lp:indicator-network/15.10

Proposed by Pete Woods
Status: Merged
Approved by: Pete Woods
Approved revision: 518
Merged at revision: 525
Proposed branch: lp:~unity-api-team/indicator-network/hotspot-cellular-enabled-properties
Merge into: lp:indicator-network/15.10
Diff against target: 453 lines (+192/-12)
13 files modified
data/com.ubuntu.connectivity1.NetworkingStatus.xml (+3/-0)
debian/changelog (+7/-0)
debian/control (+1/-3)
src/connectivity-api/connectivity-qt/connectivityqt/connectivity.cpp (+18/-0)
src/connectivity-api/connectivity-qt/connectivityqt/connectivity.h (+10/-0)
src/indicator/connectivity-service/connectivity-service.cpp (+29/-0)
src/indicator/connectivity-service/connectivity-service.h (+6/-0)
src/indicator/nmofono/hotspot-manager.cpp (+27/-0)
src/indicator/nmofono/hotspot-manager.h (+8/-0)
src/indicator/nmofono/manager-impl.cpp (+54/-9)
src/indicator/nmofono/manager-impl.h (+4/-0)
src/indicator/nmofono/manager.h (+10/-0)
tests/integration/test-connectivity-api.cpp (+15/-0)
To merge this branch: bzr merge lp:~unity-api-team/indicator-network/hotspot-cellular-enabled-properties
Reviewer Review Type Date Requested Status
Jonas G. Drange (community) Needs Resubmitting
Indicator Applet Developers Pending
Review via email: mp+268775@code.launchpad.net

Commit message

Add properties to determine if modems and hotspot functionality are available.

Description of the change

Add properties to determine if modems and hotspot functionality are available.

To post a comment you must log in.
Revision history for this message
Jonas G. Drange (jonas-drange) wrote :

Does this scale at all? We should be making determinations about what device can have hotspot based on its capabilities—not the device name (are there no flo devices with modems, e.g.?)

I think this also makes the API ambiguous: we now have hotspotEnabled, hotspotSwitchEnabled, hotspotAvailable and hotspotStored. To be blunt, we'd need a logical matrix to determine what to show as enabled/disabled/populated/N/A in the UI.

For mako, we should try to fix the actual bugs that are causing the hotspot to fail, and for flo wee need enumerated capabilities from somewhere (SDK) in order to hide the hotspot (and cellular, phone) entry.

review: Disapprove
Revision history for this message
Jonas G. Drange (jonas-drange) wrote :

After some discussions with Ken, I'd be happy with a resubmit with modemsAvailable only. We can use this property in System Settings to show/hide panels that require a modem (Cellular and Hotspot) when one is present.

hotspotAvailable would then be unnecessary due to the fact that the indicator would just have to know whether or not a hotspot is stored—not if it is able to be created (which is always done in System Settings). And you can't create a hotspot in System Settings if there are no modems.

This will also hide the Hotspot and Cellular entries on flo. For mako, we'll just have to support it.

Hope that makes more sense.

review: Needs Resubmitting

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'data/com.ubuntu.connectivity1.NetworkingStatus.xml'
--- data/com.ubuntu.connectivity1.NetworkingStatus.xml 2015-08-12 15:56:35 +0000
+++ data/com.ubuntu.connectivity1.NetworkingStatus.xml 2015-08-21 15:55:11 +0000
@@ -9,6 +9,9 @@
9 <property name="FlightMode" type="b" access="read"/>9 <property name="FlightMode" type="b" access="read"/>
10 <property name="WifiEnabled" type="b" access="read"/>10 <property name="WifiEnabled" type="b" access="read"/>
1111
12 <property name="ModemAvailable" type="b" access="read"/>
13 <property name="HotspotAvailable" type="b" access="read"/>
14
12 <property name="HotspotSsid" type="ay" access="read"/>15 <property name="HotspotSsid" type="ay" access="read"/>
13 <property name="HotspotEnabled" type="b" access="read"/>16 <property name="HotspotEnabled" type="b" access="read"/>
14 <property name="HotspotMode" type="s" access="read"/>17 <property name="HotspotMode" type="s" access="read"/>
1518
=== modified file 'debian/changelog'
--- debian/changelog 2015-08-18 08:46:30 +0000
+++ debian/changelog 2015-08-21 15:55:11 +0000
@@ -1,3 +1,10 @@
1indicator-network (0.5.4-0ubuntu0) UNRELEASED; urgency=medium
2
3 * Add properties to determine if modems and hotspot functionality are
4 available. (LP: #1487158) (LP: #1487157)
5
6 -- Pete Woods <pete.woods@canonical.com> Fri, 21 Aug 2015 16:51:14 +0100
7
1indicator-network (0.5.3+15.10.20150818-0ubuntu1) wily; urgency=medium8indicator-network (0.5.3+15.10.20150818-0ubuntu1) wily; urgency=medium
29
3 [ Pete Woods ]10 [ Pete Woods ]
411
=== modified file 'debian/control'
--- debian/control 2015-08-03 13:27:40 +0000
+++ debian/control 2015-08-21 15:55:11 +0000
@@ -32,7 +32,7 @@
32 qtdeclarative5-dev,32 qtdeclarative5-dev,
33 qtdeclarative5-dev-tools,33 qtdeclarative5-dev-tools,
34 valgrind [amd64 armhf i386 powerpc],34 valgrind [amd64 armhf i386 powerpc],
35Standards-Version: 3.9.335Standards-Version: 3.9.5
36# If you aren't a member of ~indicator-applet-developers but need to upload36# If you aren't a member of ~indicator-applet-developers but need to upload
37# packaging changes, just go ahead. ~indicator-applet-developers will notice37# packaging changes, just go ahead. ~indicator-applet-developers will notice
38# and sync up the code again.38# and sync up the code again.
@@ -89,8 +89,6 @@
89Depends: ${misc:Depends},89Depends: ${misc:Depends},
90 ${shlibs:Depends},90 ${shlibs:Depends},
91 indicator-network (>= ${source:Version}),91 indicator-network (>= ${source:Version}),
92Recommends:
93 indicator-network (>= 0.5.1+14.10.20140819),
94Description: Ubuntu Connectivity Qt API92Description: Ubuntu Connectivity Qt API
95 Ubuntu Connectivity API - Qt bindings93 Ubuntu Connectivity API - Qt bindings
9694
9795
=== modified file 'src/connectivity-api/connectivity-qt/connectivityqt/connectivity.cpp'
--- src/connectivity-api/connectivity-qt/connectivityqt/connectivity.cpp 2015-08-16 16:43:16 +0000
+++ src/connectivity-api/connectivity-qt/connectivityqt/connectivity.cpp 2015-08-21 15:55:11 +0000
@@ -130,6 +130,14 @@
130 Q_EMIT p.statusUpdated(status);130 Q_EMIT p.statusUpdated(status);
131 Q_EMIT p.onlineUpdated(status == Status::Online);131 Q_EMIT p.onlineUpdated(status == Status::Online);
132 }132 }
133 else if (name == "ModemAvailable")
134 {
135 Q_EMIT p.modemAvailableUpdated(value.toBool());
136 }
137 else if (name == "HotspotAvailable")
138 {
139 Q_EMIT p.hotspotAvailableUpdated(value.toBool());
140 }
133 else if (name == "HotspotEnabled")141 else if (name == "HotspotEnabled")
134 {142 {
135 Q_EMIT p.hotspotEnabledUpdated(value.toBool());143 Q_EMIT p.hotspotEnabledUpdated(value.toBool());
@@ -285,6 +293,16 @@
285 return d->m_writePropertyCache->get("HotspotPassword").toString();293 return d->m_writePropertyCache->get("HotspotPassword").toString();
286}294}
287295
296bool Connectivity::hotspotAvailable() const
297{
298 return d->m_propertyCache->get("HotspotAvailable").toBool();
299}
300
301bool Connectivity::modemAvailable() const
302{
303 return d->m_propertyCache->get("ModemAvailable").toBool();
304}
305
288bool Connectivity::hotspotEnabled() const306bool Connectivity::hotspotEnabled() const
289{307{
290 return d->m_propertyCache->get("HotspotEnabled").toBool();308 return d->m_propertyCache->get("HotspotEnabled").toBool();
291309
=== modified file 'src/connectivity-api/connectivity-qt/connectivityqt/connectivity.h'
--- src/connectivity-api/connectivity-qt/connectivityqt/connectivity.h 2015-08-14 16:03:42 +0000
+++ src/connectivity-api/connectivity-qt/connectivityqt/connectivity.h 2015-08-21 15:55:11 +0000
@@ -108,6 +108,12 @@
108 Q_PROPERTY(bool hotspotSwitchEnabled READ hotspotSwitchEnabled NOTIFY hotspotSwitchEnabledUpdated)108 Q_PROPERTY(bool hotspotSwitchEnabled READ hotspotSwitchEnabled NOTIFY hotspotSwitchEnabledUpdated)
109 bool hotspotSwitchEnabled() const;109 bool hotspotSwitchEnabled() const;
110110
111 Q_PROPERTY(bool modemAvailable READ modemAvailable NOTIFY modemAvailableUpdated)
112 bool modemAvailable() const;
113
114 Q_PROPERTY(bool hotspotAvailable READ hotspotAvailable NOTIFY hotspotAvailableUpdated)
115 bool hotspotAvailable() const;
116
111 Q_PROPERTY(QByteArray hotspotSsid READ hotspotSsid WRITE setHotspotSsid NOTIFY hotspotSsidUpdated)117 Q_PROPERTY(QByteArray hotspotSsid READ hotspotSsid WRITE setHotspotSsid NOTIFY hotspotSsidUpdated)
112 QByteArray hotspotSsid() const;118 QByteArray hotspotSsid() const;
113119
@@ -164,6 +170,10 @@
164170
165 void hotspotPasswordUpdated(const QString& password);171 void hotspotPasswordUpdated(const QString& password);
166172
173 void modemAvailableUpdated(bool);
174
175 void hotspotAvailableUpdated(bool);
176
167 void hotspotEnabledUpdated(bool);177 void hotspotEnabledUpdated(bool);
168178
169 void hotspotModeUpdated(const QString& mode);179 void hotspotModeUpdated(const QString& mode);
170180
=== modified file 'src/indicator/connectivity-service/connectivity-service.cpp'
--- src/indicator/connectivity-service/connectivity-service.cpp 2015-08-17 15:38:34 +0000
+++ src/indicator/connectivity-service/connectivity-service.cpp 2015-08-21 15:55:11 +0000
@@ -112,6 +112,22 @@
112 { "HotspotSsid" });112 { "HotspotSsid" });
113 }113 }
114114
115 void modemAvailableUpdated()
116 {
117 notifyPropertyChanged(p,
118 DBusTypes::SERVICE_PATH,
119 DBusTypes::SERVICE_INTERFACE,
120 { "ModemAvailable" });
121 }
122
123 void hotspotAvailableUpdated()
124 {
125 notifyPropertyChanged(p,
126 DBusTypes::SERVICE_PATH,
127 DBusTypes::SERVICE_INTERFACE,
128 { "HotspotAvailable" });
129 }
130
115 void hotspotEnabledUpdated()131 void hotspotEnabledUpdated()
116 {132 {
117 notifyPropertyChanged(p,133 notifyPropertyChanged(p,
@@ -207,6 +223,9 @@
207 connect(d->m_manager.get(), &Manager::wifiEnabledUpdated, d.get(), &Private::wifiEnabledUpdated);223 connect(d->m_manager.get(), &Manager::wifiEnabledUpdated, d.get(), &Private::wifiEnabledUpdated);
208 connect(d->m_manager.get(), &Manager::unstoppableOperationHappeningUpdated, d.get(), &Private::unstoppableOperationHappeningUpdated);224 connect(d->m_manager.get(), &Manager::unstoppableOperationHappeningUpdated, d.get(), &Private::unstoppableOperationHappeningUpdated);
209225
226 connect(d->m_manager.get(), &Manager::modemAvailableChanged, d.get(), &Private::modemAvailableUpdated);
227 connect(d->m_manager.get(), &Manager::hotspotAvailableChanged, d.get(), &Private::hotspotAvailableUpdated);
228
210 connect(d->m_manager.get(), &Manager::hotspotEnabledChanged, d.get(), &Private::hotspotEnabledUpdated);229 connect(d->m_manager.get(), &Manager::hotspotEnabledChanged, d.get(), &Private::hotspotEnabledUpdated);
211 connect(d->m_manager.get(), &Manager::hotspotSsidChanged, d.get(), &Private::hotspotSsidUpdated);230 connect(d->m_manager.get(), &Manager::hotspotSsidChanged, d.get(), &Private::hotspotSsidUpdated);
212 connect(d->m_manager.get(), &Manager::hotspotPasswordChanged, d.get(), &Private::hotspotPasswordUpdated);231 connect(d->m_manager.get(), &Manager::hotspotPasswordChanged, d.get(), &Private::hotspotPasswordUpdated);
@@ -275,6 +294,16 @@
275 && !d->m_manager->flightMode();294 && !d->m_manager->flightMode();
276}295}
277296
297bool ConnectivityService::modemAvailable() const
298{
299 return d->m_manager->modemAvailable();
300}
301
302bool ConnectivityService::hotspotAvailable() const
303{
304 return d->m_manager->hotspotAvailable();
305}
306
278bool ConnectivityService::hotspotEnabled() const307bool ConnectivityService::hotspotEnabled() const
279{308{
280 return d->m_manager->hotspotEnabled();309 return d->m_manager->hotspotEnabled();
281310
=== modified file 'src/indicator/connectivity-service/connectivity-service.h'
--- src/indicator/connectivity-service/connectivity-service.h 2015-08-14 10:29:55 +0000
+++ src/indicator/connectivity-service/connectivity-service.h 2015-08-21 15:55:11 +0000
@@ -65,6 +65,12 @@
65 Q_PROPERTY(bool HotspotSwitchEnabled READ hotspotSwitchEnabled)65 Q_PROPERTY(bool HotspotSwitchEnabled READ hotspotSwitchEnabled)
66 bool hotspotSwitchEnabled() const;66 bool hotspotSwitchEnabled() const;
6767
68 Q_PROPERTY(bool ModemAvailable READ modemAvailable)
69 bool modemAvailable() const;
70
71 Q_PROPERTY(bool HotspotAvailable READ hotspotAvailable)
72 bool hotspotAvailable() const;
73
68 Q_PROPERTY(bool HotspotEnabled READ hotspotEnabled)74 Q_PROPERTY(bool HotspotEnabled READ hotspotEnabled)
69 bool hotspotEnabled() const;75 bool hotspotEnabled() const;
7076
7177
=== modified file 'src/indicator/nmofono/hotspot-manager.cpp'
--- src/indicator/nmofono/hotspot-manager.cpp 2015-08-17 11:01:23 +0000
+++ src/indicator/nmofono/hotspot-manager.cpp 2015-08-21 15:55:11 +0000
@@ -216,6 +216,27 @@
216 return index >= 0;216 return index >= 0;
217 }217 }
218218
219 bool isKnownBadHardware()
220 {
221 const static QSet<QString> KNOWN_BAD_HARDWARE {"mako", "flo"};
222
223 QString program("getprop");
224 QStringList arguments;
225 arguments << "ro.hardware";
226
227 QProcess getprop;
228 getprop.start(program, arguments);
229
230 if (!getprop.waitForFinished())
231 {
232 qCritical() << "getprop process failed:" << getprop.errorString();
233 return false;
234 }
235
236 QString hardware = QString::fromUtf8(getprop.readAllStandardOutput()).trimmed();
237 return KNOWN_BAD_HARDWARE.contains(hardware);
238 }
239
219 /**240 /**
220 * True if changed successfully, or there was no need. Otherwise false.241 * True if changed successfully, or there was no need. Otherwise false.
221 * Supported modes are 'p2p', 'sta' and 'ap'.242 * Supported modes are 'p2p', 'sta' and 'ap'.
@@ -636,6 +657,7 @@
636 QPowerd::RequestSPtr m_wakelock;657 QPowerd::RequestSPtr m_wakelock;
637658
638 bool m_isHybrisWlan = false;659 bool m_isHybrisWlan = false;
660 bool m_isKnownBadHardware = false;
639 bool m_disconnectWifi = false;661 bool m_disconnectWifi = false;
640662
641 /**663 /**
@@ -661,6 +683,7 @@
661 QObject(parent), d(new Priv(*this))683 QObject(parent), d(new Priv(*this))
662{684{
663 d->m_isHybrisWlan = d->isHybrisWlan();685 d->m_isHybrisWlan = d->isHybrisWlan();
686 d->m_isKnownBadHardware = d->isKnownBadHardware();
664687
665 d->m_manager = make_unique<OrgFreedesktopNetworkManagerInterface>(688 d->m_manager = make_unique<OrgFreedesktopNetworkManagerInterface>(
666 NM_DBUS_SERVICE, NM_DBUS_PATH, connection);689 NM_DBUS_SERVICE, NM_DBUS_PATH, connection);
@@ -780,6 +803,10 @@
780803
781}804}
782805
806bool HotspotManager::knownBadHardware() const {
807 return d->m_isKnownBadHardware;
808}
809
783bool HotspotManager::enabled() const {810bool HotspotManager::enabled() const {
784 return d->m_enabled;811 return d->m_enabled;
785}812}
786813
=== modified file 'src/indicator/nmofono/hotspot-manager.h'
--- src/indicator/nmofono/hotspot-manager.h 2015-08-17 11:01:23 +0000
+++ src/indicator/nmofono/hotspot-manager.h 2015-08-21 15:55:11 +0000
@@ -118,6 +118,10 @@
118 READ disconnectWifi118 READ disconnectWifi
119 NOTIFY disconnectWifiChanged)119 NOTIFY disconnectWifiChanged)
120120
121 Q_PROPERTY( bool knownBadHardware
122 READ knownBadHardware
123 NOTIFY knownBadHardwareChanged)
124
121public:125public:
122 typedef std::shared_ptr<HotspotManager> SPtr;126 typedef std::shared_ptr<HotspotManager> SPtr;
123127
@@ -137,6 +141,8 @@
137141
138 bool disconnectWifi() const;142 bool disconnectWifi() const;
139143
144 bool knownBadHardware() const;
145
140Q_SIGNALS:146Q_SIGNALS:
141 void enabledChanged(bool enabled);147 void enabledChanged(bool enabled);
142148
@@ -150,6 +156,8 @@
150156
151 void disconnectWifiChanged(bool disconnect);157 void disconnectWifiChanged(bool disconnect);
152158
159 void knownBadHardwareChanged(bool knownBadHardware);
160
153 /*161 /*
154 * The mapping of code to string is taken from162 * The mapping of code to string is taken from
155 * http://bazaar.launchpad.net/~vcs-imports/163 * http://bazaar.launchpad.net/~vcs-imports/
156164
=== modified file 'src/indicator/nmofono/manager-impl.cpp'
--- src/indicator/nmofono/manager-impl.cpp 2015-08-18 08:39:29 +0000
+++ src/indicator/nmofono/manager-impl.cpp 2015-08-21 15:55:11 +0000
@@ -69,6 +69,9 @@
69 bool m_wifiEnabled = false;69 bool m_wifiEnabled = false;
70 KillSwitch::Ptr m_killSwitch;70 KillSwitch::Ptr m_killSwitch;
7171
72 bool m_modemAvailable = false;
73 bool m_hotspotAvailable = false;
74
72 QSet<Link::Ptr> m_nmLinks;75 QSet<Link::Ptr> m_nmLinks;
73 QMap<QString, wwan::Modem::Ptr> m_ofonoLinks;76 QMap<QString, wwan::Modem::Ptr> m_ofonoLinks;
7477
@@ -144,6 +147,32 @@
144 Q_EMIT p.wifiEnabledUpdated(m_wifiEnabled);147 Q_EMIT p.wifiEnabledUpdated(m_wifiEnabled);
145 }148 }
146149
150 void updateModemAvailable()
151 {
152 bool modemAvailable = !m_ofonoLinks.empty();
153
154 if (m_modemAvailable == modemAvailable)
155 {
156 return;
157 }
158
159 m_modemAvailable = modemAvailable;
160 Q_EMIT p.modemAvailableChanged(m_modemAvailable);
161 }
162
163 void updateHotspotAvailable()
164 {
165 bool hotspotAvailable = !m_ofonoLinks.empty() && !m_hotspotManager->knownBadHardware();
166
167 if (m_hotspotAvailable == hotspotAvailable)
168 {
169 return;
170 }
171
172 m_hotspotAvailable = hotspotAvailable;
173 Q_EMIT p.hotspotAvailableChanged(m_hotspotAvailable);
174 }
175
147 void setFlightMode(bool newStatus)176 void setFlightMode(bool newStatus)
148 {177 {
149 if (m_flightMode == newStatus)178 if (m_flightMode == newStatus)
@@ -211,6 +240,9 @@
211240
212 Q_EMIT p.linksUpdated();241 Q_EMIT p.linksUpdated();
213 m_unlockDialog->setShowSimIdentifiers(m_ofonoLinks.size() > 1);242 m_unlockDialog->setShowSimIdentifiers(m_ofonoLinks.size() > 1);
243
244 updateModemAvailable();
245 updateHotspotAvailable();
214 }246 }
215};247};
216248
@@ -250,6 +282,16 @@
250 d->m_unlockDialog = make_shared<SimUnlockDialog>(notificationManager);282 d->m_unlockDialog = make_shared<SimUnlockDialog>(notificationManager);
251 connect(d->m_unlockDialog.get(), &SimUnlockDialog::ready, d.get(), &Private::sim_unlock_ready);283 connect(d->m_unlockDialog.get(), &SimUnlockDialog::ready, d.get(), &Private::sim_unlock_ready);
252284
285 d->m_hotspotManager = make_shared<HotspotManager>(systemConnection);
286 connect(d->m_hotspotManager.get(), &HotspotManager::enabledChanged, this, &Manager::hotspotEnabledChanged);
287 connect(d->m_hotspotManager.get(), &HotspotManager::ssidChanged, this, &Manager::hotspotSsidChanged);
288 connect(d->m_hotspotManager.get(), &HotspotManager::passwordChanged, this, &Manager::hotspotPasswordChanged);
289 connect(d->m_hotspotManager.get(), &HotspotManager::modeChanged, this, &Manager::hotspotModeChanged);
290 connect(d->m_hotspotManager.get(), &HotspotManager::storedChanged, this, &Manager::hotspotStoredChanged);
291 connect(d->m_hotspotManager.get(), &HotspotManager::knownBadHardwareChanged, d.get(), &Private::updateHotspotAvailable);
292
293 connect(d->m_hotspotManager.get(), &HotspotManager::reportError, this, &Manager::reportError);
294
253 d->m_ofono = make_shared<QOfonoManager>();295 d->m_ofono = make_shared<QOfonoManager>();
254 connect(d->m_ofono.get(), &QOfonoManager::modemsChanged, d.get(), &Private::modems_changed);296 connect(d->m_ofono.get(), &QOfonoManager::modemsChanged, d.get(), &Private::modems_changed);
255 d->modems_changed(d->m_ofono->modems());297 d->modems_changed(d->m_ofono->modems());
@@ -262,15 +304,6 @@
262 d->m_killSwitch = make_shared<KillSwitch>(systemConnection);304 d->m_killSwitch = make_shared<KillSwitch>(systemConnection);
263 connect(d->m_killSwitch.get(), &KillSwitch::stateChanged, d.get(), &Private::updateHasWifi);305 connect(d->m_killSwitch.get(), &KillSwitch::stateChanged, d.get(), &Private::updateHasWifi);
264306
265 d->m_hotspotManager = make_shared<HotspotManager>(systemConnection);
266 connect(d->m_hotspotManager.get(), &HotspotManager::enabledChanged, this, &Manager::hotspotEnabledChanged);
267 connect(d->m_hotspotManager.get(), &HotspotManager::ssidChanged, this, &Manager::hotspotSsidChanged);
268 connect(d->m_hotspotManager.get(), &HotspotManager::passwordChanged, this, &Manager::hotspotPasswordChanged);
269 connect(d->m_hotspotManager.get(), &HotspotManager::modeChanged, this, &Manager::hotspotModeChanged);
270 connect(d->m_hotspotManager.get(), &HotspotManager::storedChanged, this, &Manager::hotspotStoredChanged);
271
272 connect(d->m_hotspotManager.get(), &HotspotManager::reportError, this, &Manager::reportError);
273
274 connect(d->nm.get(), &OrgFreedesktopNetworkManagerInterface::DeviceAdded, this, &ManagerImpl::device_added);307 connect(d->nm.get(), &OrgFreedesktopNetworkManagerInterface::DeviceAdded, this, &ManagerImpl::device_added);
275 QList<QDBusObjectPath> devices(d->nm->GetDevices());308 QList<QDBusObjectPath> devices(d->nm->GetDevices());
276 for(const auto &path : devices) {309 for(const auto &path : devices) {
@@ -324,6 +357,18 @@
324}357}
325358
326bool359bool
360ManagerImpl::modemAvailable() const
361{
362 return !d->m_ofonoLinks.empty();
363}
364
365bool
366ManagerImpl::hotspotAvailable() const
367{
368 return !d->m_hotspotManager->knownBadHardware();
369}
370
371bool
327ManagerImpl::hotspotEnabled() const372ManagerImpl::hotspotEnabled() const
328{373{
329 return d->m_hotspotManager->enabled();374 return d->m_hotspotManager->enabled();
330375
=== modified file 'src/indicator/nmofono/manager-impl.h'
--- src/indicator/nmofono/manager-impl.h 2015-08-14 15:52:39 +0000
+++ src/indicator/nmofono/manager-impl.h 2015-08-21 15:55:11 +0000
@@ -71,6 +71,10 @@
71 void unlockAllModems() override;71 void unlockAllModems() override;
72 void unlockModemByName(const QString &name) override;72 void unlockModemByName(const QString &name) override;
7373
74 bool modemAvailable() const override;
75
76 bool hotspotAvailable() const override;
77
74 bool hotspotEnabled() const override;78 bool hotspotEnabled() const override;
7579
76 bool hotspotStored() const override;80 bool hotspotStored() const override;
7781
=== modified file 'src/indicator/nmofono/manager.h'
--- src/indicator/nmofono/manager.h 2015-08-14 15:52:39 +0000
+++ src/indicator/nmofono/manager.h 2015-08-21 15:55:11 +0000
@@ -122,6 +122,12 @@
122122
123 virtual void unlockModemByName(const QString &name) = 0;123 virtual void unlockModemByName(const QString &name) = 0;
124124
125 Q_PROPERTY(bool modemAvailable READ modemAvailable NOTIFY modemAvailableChanged)
126 virtual bool modemAvailable() const = 0;
127
128 Q_PROPERTY(bool hotspotAvailable READ hotspotAvailable NOTIFY hotspotAvailableChanged)
129 virtual bool hotspotAvailable() const = 0;
130
125 Q_PROPERTY(bool hotspotEnabled READ hotspotEnabled WRITE setHotspotEnabled NOTIFY hotspotEnabledChanged)131 Q_PROPERTY(bool hotspotEnabled READ hotspotEnabled WRITE setHotspotEnabled NOTIFY hotspotEnabledChanged)
126 virtual bool hotspotEnabled() const = 0;132 virtual bool hotspotEnabled() const = 0;
127133
@@ -150,6 +156,10 @@
150156
151 void wifiEnabledUpdated(bool);157 void wifiEnabledUpdated(bool);
152158
159 void modemAvailableChanged(bool);
160
161 void hotspotAvailableChanged(bool);
162
153 void hotspotEnabledChanged(bool enabled);163 void hotspotEnabledChanged(bool enabled);
154164
155 void hotspotStoredChanged(bool stored);165 void hotspotStoredChanged(bool stored);
156166
=== modified file 'tests/integration/test-connectivity-api.cpp'
--- tests/integration/test-connectivity-api.cpp 2015-08-17 15:38:34 +0000
+++ tests/integration/test-connectivity-api.cpp 2015-08-21 15:55:11 +0000
@@ -630,4 +630,19 @@
630 }630 }
631}631}
632632
633TEST_F(TestConnectivityApi, HotspotModemAvailable)
634{
635 setGlobalConnectedState(NM_STATE_DISCONNECTED);
636 auto device = createWiFiDevice(NM_DEVICE_STATE_DISCONNECTED);
637
638 // Start the indicator
639 ASSERT_NO_THROW(startIndicator());
640
641 // Connect the the service
642 auto connectivity(newConnectivity());
643
644 EXPECT_TRUE(connectivity->hotspotAvailable());
645 EXPECT_TRUE(connectivity->modemAvailable());
646}
647
633}648}

Subscribers

People subscribed via source and target branches