Merge lp:~unity-api-team/indicator-network/hotspot-cellular-enabled-properties into lp:indicator-network/15.10
- hotspot-cellular-enabled-properties
- Merge into trunk.15.10
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 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Jonas G. Drange (community) | Needs Resubmitting | ||
Indicator Applet Developers | Pending | ||
Review via email:
|
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.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
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.
Preview Diff
1 | === modified file 'data/com.ubuntu.connectivity1.NetworkingStatus.xml' | |||
2 | --- data/com.ubuntu.connectivity1.NetworkingStatus.xml 2015-08-12 15:56:35 +0000 | |||
3 | +++ data/com.ubuntu.connectivity1.NetworkingStatus.xml 2015-08-21 15:55:11 +0000 | |||
4 | @@ -9,6 +9,9 @@ | |||
5 | 9 | <property name="FlightMode" type="b" access="read"/> | 9 | <property name="FlightMode" type="b" access="read"/> |
6 | 10 | <property name="WifiEnabled" type="b" access="read"/> | 10 | <property name="WifiEnabled" type="b" access="read"/> |
7 | 11 | 11 | ||
8 | 12 | <property name="ModemAvailable" type="b" access="read"/> | ||
9 | 13 | <property name="HotspotAvailable" type="b" access="read"/> | ||
10 | 14 | |||
11 | 12 | <property name="HotspotSsid" type="ay" access="read"/> | 15 | <property name="HotspotSsid" type="ay" access="read"/> |
12 | 13 | <property name="HotspotEnabled" type="b" access="read"/> | 16 | <property name="HotspotEnabled" type="b" access="read"/> |
13 | 14 | <property name="HotspotMode" type="s" access="read"/> | 17 | <property name="HotspotMode" type="s" access="read"/> |
14 | 15 | 18 | ||
15 | === modified file 'debian/changelog' | |||
16 | --- debian/changelog 2015-08-18 08:46:30 +0000 | |||
17 | +++ debian/changelog 2015-08-21 15:55:11 +0000 | |||
18 | @@ -1,3 +1,10 @@ | |||
19 | 1 | indicator-network (0.5.4-0ubuntu0) UNRELEASED; urgency=medium | ||
20 | 2 | |||
21 | 3 | * Add properties to determine if modems and hotspot functionality are | ||
22 | 4 | available. (LP: #1487158) (LP: #1487157) | ||
23 | 5 | |||
24 | 6 | -- Pete Woods <pete.woods@canonical.com> Fri, 21 Aug 2015 16:51:14 +0100 | ||
25 | 7 | |||
26 | 1 | indicator-network (0.5.3+15.10.20150818-0ubuntu1) wily; urgency=medium | 8 | indicator-network (0.5.3+15.10.20150818-0ubuntu1) wily; urgency=medium |
27 | 2 | 9 | ||
28 | 3 | [ Pete Woods ] | 10 | [ Pete Woods ] |
29 | 4 | 11 | ||
30 | === modified file 'debian/control' | |||
31 | --- debian/control 2015-08-03 13:27:40 +0000 | |||
32 | +++ debian/control 2015-08-21 15:55:11 +0000 | |||
33 | @@ -32,7 +32,7 @@ | |||
34 | 32 | qtdeclarative5-dev, | 32 | qtdeclarative5-dev, |
35 | 33 | qtdeclarative5-dev-tools, | 33 | qtdeclarative5-dev-tools, |
36 | 34 | valgrind [amd64 armhf i386 powerpc], | 34 | valgrind [amd64 armhf i386 powerpc], |
38 | 35 | Standards-Version: 3.9.3 | 35 | Standards-Version: 3.9.5 |
39 | 36 | # If you aren't a member of ~indicator-applet-developers but need to upload | 36 | # If you aren't a member of ~indicator-applet-developers but need to upload |
40 | 37 | # packaging changes, just go ahead. ~indicator-applet-developers will notice | 37 | # packaging changes, just go ahead. ~indicator-applet-developers will notice |
41 | 38 | # and sync up the code again. | 38 | # and sync up the code again. |
42 | @@ -89,8 +89,6 @@ | |||
43 | 89 | Depends: ${misc:Depends}, | 89 | Depends: ${misc:Depends}, |
44 | 90 | ${shlibs:Depends}, | 90 | ${shlibs:Depends}, |
45 | 91 | indicator-network (>= ${source:Version}), | 91 | indicator-network (>= ${source:Version}), |
46 | 92 | Recommends: | ||
47 | 93 | indicator-network (>= 0.5.1+14.10.20140819), | ||
48 | 94 | Description: Ubuntu Connectivity Qt API | 92 | Description: Ubuntu Connectivity Qt API |
49 | 95 | Ubuntu Connectivity API - Qt bindings | 93 | Ubuntu Connectivity API - Qt bindings |
50 | 96 | 94 | ||
51 | 97 | 95 | ||
52 | === modified file 'src/connectivity-api/connectivity-qt/connectivityqt/connectivity.cpp' | |||
53 | --- src/connectivity-api/connectivity-qt/connectivityqt/connectivity.cpp 2015-08-16 16:43:16 +0000 | |||
54 | +++ src/connectivity-api/connectivity-qt/connectivityqt/connectivity.cpp 2015-08-21 15:55:11 +0000 | |||
55 | @@ -130,6 +130,14 @@ | |||
56 | 130 | Q_EMIT p.statusUpdated(status); | 130 | Q_EMIT p.statusUpdated(status); |
57 | 131 | Q_EMIT p.onlineUpdated(status == Status::Online); | 131 | Q_EMIT p.onlineUpdated(status == Status::Online); |
58 | 132 | } | 132 | } |
59 | 133 | else if (name == "ModemAvailable") | ||
60 | 134 | { | ||
61 | 135 | Q_EMIT p.modemAvailableUpdated(value.toBool()); | ||
62 | 136 | } | ||
63 | 137 | else if (name == "HotspotAvailable") | ||
64 | 138 | { | ||
65 | 139 | Q_EMIT p.hotspotAvailableUpdated(value.toBool()); | ||
66 | 140 | } | ||
67 | 133 | else if (name == "HotspotEnabled") | 141 | else if (name == "HotspotEnabled") |
68 | 134 | { | 142 | { |
69 | 135 | Q_EMIT p.hotspotEnabledUpdated(value.toBool()); | 143 | Q_EMIT p.hotspotEnabledUpdated(value.toBool()); |
70 | @@ -285,6 +293,16 @@ | |||
71 | 285 | return d->m_writePropertyCache->get("HotspotPassword").toString(); | 293 | return d->m_writePropertyCache->get("HotspotPassword").toString(); |
72 | 286 | } | 294 | } |
73 | 287 | 295 | ||
74 | 296 | bool Connectivity::hotspotAvailable() const | ||
75 | 297 | { | ||
76 | 298 | return d->m_propertyCache->get("HotspotAvailable").toBool(); | ||
77 | 299 | } | ||
78 | 300 | |||
79 | 301 | bool Connectivity::modemAvailable() const | ||
80 | 302 | { | ||
81 | 303 | return d->m_propertyCache->get("ModemAvailable").toBool(); | ||
82 | 304 | } | ||
83 | 305 | |||
84 | 288 | bool Connectivity::hotspotEnabled() const | 306 | bool Connectivity::hotspotEnabled() const |
85 | 289 | { | 307 | { |
86 | 290 | return d->m_propertyCache->get("HotspotEnabled").toBool(); | 308 | return d->m_propertyCache->get("HotspotEnabled").toBool(); |
87 | 291 | 309 | ||
88 | === modified file 'src/connectivity-api/connectivity-qt/connectivityqt/connectivity.h' | |||
89 | --- src/connectivity-api/connectivity-qt/connectivityqt/connectivity.h 2015-08-14 16:03:42 +0000 | |||
90 | +++ src/connectivity-api/connectivity-qt/connectivityqt/connectivity.h 2015-08-21 15:55:11 +0000 | |||
91 | @@ -108,6 +108,12 @@ | |||
92 | 108 | Q_PROPERTY(bool hotspotSwitchEnabled READ hotspotSwitchEnabled NOTIFY hotspotSwitchEnabledUpdated) | 108 | Q_PROPERTY(bool hotspotSwitchEnabled READ hotspotSwitchEnabled NOTIFY hotspotSwitchEnabledUpdated) |
93 | 109 | bool hotspotSwitchEnabled() const; | 109 | bool hotspotSwitchEnabled() const; |
94 | 110 | 110 | ||
95 | 111 | Q_PROPERTY(bool modemAvailable READ modemAvailable NOTIFY modemAvailableUpdated) | ||
96 | 112 | bool modemAvailable() const; | ||
97 | 113 | |||
98 | 114 | Q_PROPERTY(bool hotspotAvailable READ hotspotAvailable NOTIFY hotspotAvailableUpdated) | ||
99 | 115 | bool hotspotAvailable() const; | ||
100 | 116 | |||
101 | 111 | Q_PROPERTY(QByteArray hotspotSsid READ hotspotSsid WRITE setHotspotSsid NOTIFY hotspotSsidUpdated) | 117 | Q_PROPERTY(QByteArray hotspotSsid READ hotspotSsid WRITE setHotspotSsid NOTIFY hotspotSsidUpdated) |
102 | 112 | QByteArray hotspotSsid() const; | 118 | QByteArray hotspotSsid() const; |
103 | 113 | 119 | ||
104 | @@ -164,6 +170,10 @@ | |||
105 | 164 | 170 | ||
106 | 165 | void hotspotPasswordUpdated(const QString& password); | 171 | void hotspotPasswordUpdated(const QString& password); |
107 | 166 | 172 | ||
108 | 173 | void modemAvailableUpdated(bool); | ||
109 | 174 | |||
110 | 175 | void hotspotAvailableUpdated(bool); | ||
111 | 176 | |||
112 | 167 | void hotspotEnabledUpdated(bool); | 177 | void hotspotEnabledUpdated(bool); |
113 | 168 | 178 | ||
114 | 169 | void hotspotModeUpdated(const QString& mode); | 179 | void hotspotModeUpdated(const QString& mode); |
115 | 170 | 180 | ||
116 | === modified file 'src/indicator/connectivity-service/connectivity-service.cpp' | |||
117 | --- src/indicator/connectivity-service/connectivity-service.cpp 2015-08-17 15:38:34 +0000 | |||
118 | +++ src/indicator/connectivity-service/connectivity-service.cpp 2015-08-21 15:55:11 +0000 | |||
119 | @@ -112,6 +112,22 @@ | |||
120 | 112 | { "HotspotSsid" }); | 112 | { "HotspotSsid" }); |
121 | 113 | } | 113 | } |
122 | 114 | 114 | ||
123 | 115 | void modemAvailableUpdated() | ||
124 | 116 | { | ||
125 | 117 | notifyPropertyChanged(p, | ||
126 | 118 | DBusTypes::SERVICE_PATH, | ||
127 | 119 | DBusTypes::SERVICE_INTERFACE, | ||
128 | 120 | { "ModemAvailable" }); | ||
129 | 121 | } | ||
130 | 122 | |||
131 | 123 | void hotspotAvailableUpdated() | ||
132 | 124 | { | ||
133 | 125 | notifyPropertyChanged(p, | ||
134 | 126 | DBusTypes::SERVICE_PATH, | ||
135 | 127 | DBusTypes::SERVICE_INTERFACE, | ||
136 | 128 | { "HotspotAvailable" }); | ||
137 | 129 | } | ||
138 | 130 | |||
139 | 115 | void hotspotEnabledUpdated() | 131 | void hotspotEnabledUpdated() |
140 | 116 | { | 132 | { |
141 | 117 | notifyPropertyChanged(p, | 133 | notifyPropertyChanged(p, |
142 | @@ -207,6 +223,9 @@ | |||
143 | 207 | connect(d->m_manager.get(), &Manager::wifiEnabledUpdated, d.get(), &Private::wifiEnabledUpdated); | 223 | connect(d->m_manager.get(), &Manager::wifiEnabledUpdated, d.get(), &Private::wifiEnabledUpdated); |
144 | 208 | connect(d->m_manager.get(), &Manager::unstoppableOperationHappeningUpdated, d.get(), &Private::unstoppableOperationHappeningUpdated); | 224 | connect(d->m_manager.get(), &Manager::unstoppableOperationHappeningUpdated, d.get(), &Private::unstoppableOperationHappeningUpdated); |
145 | 209 | 225 | ||
146 | 226 | connect(d->m_manager.get(), &Manager::modemAvailableChanged, d.get(), &Private::modemAvailableUpdated); | ||
147 | 227 | connect(d->m_manager.get(), &Manager::hotspotAvailableChanged, d.get(), &Private::hotspotAvailableUpdated); | ||
148 | 228 | |||
149 | 210 | connect(d->m_manager.get(), &Manager::hotspotEnabledChanged, d.get(), &Private::hotspotEnabledUpdated); | 229 | connect(d->m_manager.get(), &Manager::hotspotEnabledChanged, d.get(), &Private::hotspotEnabledUpdated); |
150 | 211 | connect(d->m_manager.get(), &Manager::hotspotSsidChanged, d.get(), &Private::hotspotSsidUpdated); | 230 | connect(d->m_manager.get(), &Manager::hotspotSsidChanged, d.get(), &Private::hotspotSsidUpdated); |
151 | 212 | connect(d->m_manager.get(), &Manager::hotspotPasswordChanged, d.get(), &Private::hotspotPasswordUpdated); | 231 | connect(d->m_manager.get(), &Manager::hotspotPasswordChanged, d.get(), &Private::hotspotPasswordUpdated); |
152 | @@ -275,6 +294,16 @@ | |||
153 | 275 | && !d->m_manager->flightMode(); | 294 | && !d->m_manager->flightMode(); |
154 | 276 | } | 295 | } |
155 | 277 | 296 | ||
156 | 297 | bool ConnectivityService::modemAvailable() const | ||
157 | 298 | { | ||
158 | 299 | return d->m_manager->modemAvailable(); | ||
159 | 300 | } | ||
160 | 301 | |||
161 | 302 | bool ConnectivityService::hotspotAvailable() const | ||
162 | 303 | { | ||
163 | 304 | return d->m_manager->hotspotAvailable(); | ||
164 | 305 | } | ||
165 | 306 | |||
166 | 278 | bool ConnectivityService::hotspotEnabled() const | 307 | bool ConnectivityService::hotspotEnabled() const |
167 | 279 | { | 308 | { |
168 | 280 | return d->m_manager->hotspotEnabled(); | 309 | return d->m_manager->hotspotEnabled(); |
169 | 281 | 310 | ||
170 | === modified file 'src/indicator/connectivity-service/connectivity-service.h' | |||
171 | --- src/indicator/connectivity-service/connectivity-service.h 2015-08-14 10:29:55 +0000 | |||
172 | +++ src/indicator/connectivity-service/connectivity-service.h 2015-08-21 15:55:11 +0000 | |||
173 | @@ -65,6 +65,12 @@ | |||
174 | 65 | Q_PROPERTY(bool HotspotSwitchEnabled READ hotspotSwitchEnabled) | 65 | Q_PROPERTY(bool HotspotSwitchEnabled READ hotspotSwitchEnabled) |
175 | 66 | bool hotspotSwitchEnabled() const; | 66 | bool hotspotSwitchEnabled() const; |
176 | 67 | 67 | ||
177 | 68 | Q_PROPERTY(bool ModemAvailable READ modemAvailable) | ||
178 | 69 | bool modemAvailable() const; | ||
179 | 70 | |||
180 | 71 | Q_PROPERTY(bool HotspotAvailable READ hotspotAvailable) | ||
181 | 72 | bool hotspotAvailable() const; | ||
182 | 73 | |||
183 | 68 | Q_PROPERTY(bool HotspotEnabled READ hotspotEnabled) | 74 | Q_PROPERTY(bool HotspotEnabled READ hotspotEnabled) |
184 | 69 | bool hotspotEnabled() const; | 75 | bool hotspotEnabled() const; |
185 | 70 | 76 | ||
186 | 71 | 77 | ||
187 | === modified file 'src/indicator/nmofono/hotspot-manager.cpp' | |||
188 | --- src/indicator/nmofono/hotspot-manager.cpp 2015-08-17 11:01:23 +0000 | |||
189 | +++ src/indicator/nmofono/hotspot-manager.cpp 2015-08-21 15:55:11 +0000 | |||
190 | @@ -216,6 +216,27 @@ | |||
191 | 216 | return index >= 0; | 216 | return index >= 0; |
192 | 217 | } | 217 | } |
193 | 218 | 218 | ||
194 | 219 | bool isKnownBadHardware() | ||
195 | 220 | { | ||
196 | 221 | const static QSet<QString> KNOWN_BAD_HARDWARE {"mako", "flo"}; | ||
197 | 222 | |||
198 | 223 | QString program("getprop"); | ||
199 | 224 | QStringList arguments; | ||
200 | 225 | arguments << "ro.hardware"; | ||
201 | 226 | |||
202 | 227 | QProcess getprop; | ||
203 | 228 | getprop.start(program, arguments); | ||
204 | 229 | |||
205 | 230 | if (!getprop.waitForFinished()) | ||
206 | 231 | { | ||
207 | 232 | qCritical() << "getprop process failed:" << getprop.errorString(); | ||
208 | 233 | return false; | ||
209 | 234 | } | ||
210 | 235 | |||
211 | 236 | QString hardware = QString::fromUtf8(getprop.readAllStandardOutput()).trimmed(); | ||
212 | 237 | return KNOWN_BAD_HARDWARE.contains(hardware); | ||
213 | 238 | } | ||
214 | 239 | |||
215 | 219 | /** | 240 | /** |
216 | 220 | * True if changed successfully, or there was no need. Otherwise false. | 241 | * True if changed successfully, or there was no need. Otherwise false. |
217 | 221 | * Supported modes are 'p2p', 'sta' and 'ap'. | 242 | * Supported modes are 'p2p', 'sta' and 'ap'. |
218 | @@ -636,6 +657,7 @@ | |||
219 | 636 | QPowerd::RequestSPtr m_wakelock; | 657 | QPowerd::RequestSPtr m_wakelock; |
220 | 637 | 658 | ||
221 | 638 | bool m_isHybrisWlan = false; | 659 | bool m_isHybrisWlan = false; |
222 | 660 | bool m_isKnownBadHardware = false; | ||
223 | 639 | bool m_disconnectWifi = false; | 661 | bool m_disconnectWifi = false; |
224 | 640 | 662 | ||
225 | 641 | /** | 663 | /** |
226 | @@ -661,6 +683,7 @@ | |||
227 | 661 | QObject(parent), d(new Priv(*this)) | 683 | QObject(parent), d(new Priv(*this)) |
228 | 662 | { | 684 | { |
229 | 663 | d->m_isHybrisWlan = d->isHybrisWlan(); | 685 | d->m_isHybrisWlan = d->isHybrisWlan(); |
230 | 686 | d->m_isKnownBadHardware = d->isKnownBadHardware(); | ||
231 | 664 | 687 | ||
232 | 665 | d->m_manager = make_unique<OrgFreedesktopNetworkManagerInterface>( | 688 | d->m_manager = make_unique<OrgFreedesktopNetworkManagerInterface>( |
233 | 666 | NM_DBUS_SERVICE, NM_DBUS_PATH, connection); | 689 | NM_DBUS_SERVICE, NM_DBUS_PATH, connection); |
234 | @@ -780,6 +803,10 @@ | |||
235 | 780 | 803 | ||
236 | 781 | } | 804 | } |
237 | 782 | 805 | ||
238 | 806 | bool HotspotManager::knownBadHardware() const { | ||
239 | 807 | return d->m_isKnownBadHardware; | ||
240 | 808 | } | ||
241 | 809 | |||
242 | 783 | bool HotspotManager::enabled() const { | 810 | bool HotspotManager::enabled() const { |
243 | 784 | return d->m_enabled; | 811 | return d->m_enabled; |
244 | 785 | } | 812 | } |
245 | 786 | 813 | ||
246 | === modified file 'src/indicator/nmofono/hotspot-manager.h' | |||
247 | --- src/indicator/nmofono/hotspot-manager.h 2015-08-17 11:01:23 +0000 | |||
248 | +++ src/indicator/nmofono/hotspot-manager.h 2015-08-21 15:55:11 +0000 | |||
249 | @@ -118,6 +118,10 @@ | |||
250 | 118 | READ disconnectWifi | 118 | READ disconnectWifi |
251 | 119 | NOTIFY disconnectWifiChanged) | 119 | NOTIFY disconnectWifiChanged) |
252 | 120 | 120 | ||
253 | 121 | Q_PROPERTY( bool knownBadHardware | ||
254 | 122 | READ knownBadHardware | ||
255 | 123 | NOTIFY knownBadHardwareChanged) | ||
256 | 124 | |||
257 | 121 | public: | 125 | public: |
258 | 122 | typedef std::shared_ptr<HotspotManager> SPtr; | 126 | typedef std::shared_ptr<HotspotManager> SPtr; |
259 | 123 | 127 | ||
260 | @@ -137,6 +141,8 @@ | |||
261 | 137 | 141 | ||
262 | 138 | bool disconnectWifi() const; | 142 | bool disconnectWifi() const; |
263 | 139 | 143 | ||
264 | 144 | bool knownBadHardware() const; | ||
265 | 145 | |||
266 | 140 | Q_SIGNALS: | 146 | Q_SIGNALS: |
267 | 141 | void enabledChanged(bool enabled); | 147 | void enabledChanged(bool enabled); |
268 | 142 | 148 | ||
269 | @@ -150,6 +156,8 @@ | |||
270 | 150 | 156 | ||
271 | 151 | void disconnectWifiChanged(bool disconnect); | 157 | void disconnectWifiChanged(bool disconnect); |
272 | 152 | 158 | ||
273 | 159 | void knownBadHardwareChanged(bool knownBadHardware); | ||
274 | 160 | |||
275 | 153 | /* | 161 | /* |
276 | 154 | * The mapping of code to string is taken from | 162 | * The mapping of code to string is taken from |
277 | 155 | * http://bazaar.launchpad.net/~vcs-imports/ | 163 | * http://bazaar.launchpad.net/~vcs-imports/ |
278 | 156 | 164 | ||
279 | === modified file 'src/indicator/nmofono/manager-impl.cpp' | |||
280 | --- src/indicator/nmofono/manager-impl.cpp 2015-08-18 08:39:29 +0000 | |||
281 | +++ src/indicator/nmofono/manager-impl.cpp 2015-08-21 15:55:11 +0000 | |||
282 | @@ -69,6 +69,9 @@ | |||
283 | 69 | bool m_wifiEnabled = false; | 69 | bool m_wifiEnabled = false; |
284 | 70 | KillSwitch::Ptr m_killSwitch; | 70 | KillSwitch::Ptr m_killSwitch; |
285 | 71 | 71 | ||
286 | 72 | bool m_modemAvailable = false; | ||
287 | 73 | bool m_hotspotAvailable = false; | ||
288 | 74 | |||
289 | 72 | QSet<Link::Ptr> m_nmLinks; | 75 | QSet<Link::Ptr> m_nmLinks; |
290 | 73 | QMap<QString, wwan::Modem::Ptr> m_ofonoLinks; | 76 | QMap<QString, wwan::Modem::Ptr> m_ofonoLinks; |
291 | 74 | 77 | ||
292 | @@ -144,6 +147,32 @@ | |||
293 | 144 | Q_EMIT p.wifiEnabledUpdated(m_wifiEnabled); | 147 | Q_EMIT p.wifiEnabledUpdated(m_wifiEnabled); |
294 | 145 | } | 148 | } |
295 | 146 | 149 | ||
296 | 150 | void updateModemAvailable() | ||
297 | 151 | { | ||
298 | 152 | bool modemAvailable = !m_ofonoLinks.empty(); | ||
299 | 153 | |||
300 | 154 | if (m_modemAvailable == modemAvailable) | ||
301 | 155 | { | ||
302 | 156 | return; | ||
303 | 157 | } | ||
304 | 158 | |||
305 | 159 | m_modemAvailable = modemAvailable; | ||
306 | 160 | Q_EMIT p.modemAvailableChanged(m_modemAvailable); | ||
307 | 161 | } | ||
308 | 162 | |||
309 | 163 | void updateHotspotAvailable() | ||
310 | 164 | { | ||
311 | 165 | bool hotspotAvailable = !m_ofonoLinks.empty() && !m_hotspotManager->knownBadHardware(); | ||
312 | 166 | |||
313 | 167 | if (m_hotspotAvailable == hotspotAvailable) | ||
314 | 168 | { | ||
315 | 169 | return; | ||
316 | 170 | } | ||
317 | 171 | |||
318 | 172 | m_hotspotAvailable = hotspotAvailable; | ||
319 | 173 | Q_EMIT p.hotspotAvailableChanged(m_hotspotAvailable); | ||
320 | 174 | } | ||
321 | 175 | |||
322 | 147 | void setFlightMode(bool newStatus) | 176 | void setFlightMode(bool newStatus) |
323 | 148 | { | 177 | { |
324 | 149 | if (m_flightMode == newStatus) | 178 | if (m_flightMode == newStatus) |
325 | @@ -211,6 +240,9 @@ | |||
326 | 211 | 240 | ||
327 | 212 | Q_EMIT p.linksUpdated(); | 241 | Q_EMIT p.linksUpdated(); |
328 | 213 | m_unlockDialog->setShowSimIdentifiers(m_ofonoLinks.size() > 1); | 242 | m_unlockDialog->setShowSimIdentifiers(m_ofonoLinks.size() > 1); |
329 | 243 | |||
330 | 244 | updateModemAvailable(); | ||
331 | 245 | updateHotspotAvailable(); | ||
332 | 214 | } | 246 | } |
333 | 215 | }; | 247 | }; |
334 | 216 | 248 | ||
335 | @@ -250,6 +282,16 @@ | |||
336 | 250 | d->m_unlockDialog = make_shared<SimUnlockDialog>(notificationManager); | 282 | d->m_unlockDialog = make_shared<SimUnlockDialog>(notificationManager); |
337 | 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); |
338 | 252 | 284 | ||
339 | 285 | d->m_hotspotManager = make_shared<HotspotManager>(systemConnection); | ||
340 | 286 | connect(d->m_hotspotManager.get(), &HotspotManager::enabledChanged, this, &Manager::hotspotEnabledChanged); | ||
341 | 287 | connect(d->m_hotspotManager.get(), &HotspotManager::ssidChanged, this, &Manager::hotspotSsidChanged); | ||
342 | 288 | connect(d->m_hotspotManager.get(), &HotspotManager::passwordChanged, this, &Manager::hotspotPasswordChanged); | ||
343 | 289 | connect(d->m_hotspotManager.get(), &HotspotManager::modeChanged, this, &Manager::hotspotModeChanged); | ||
344 | 290 | connect(d->m_hotspotManager.get(), &HotspotManager::storedChanged, this, &Manager::hotspotStoredChanged); | ||
345 | 291 | connect(d->m_hotspotManager.get(), &HotspotManager::knownBadHardwareChanged, d.get(), &Private::updateHotspotAvailable); | ||
346 | 292 | |||
347 | 293 | connect(d->m_hotspotManager.get(), &HotspotManager::reportError, this, &Manager::reportError); | ||
348 | 294 | |||
349 | 253 | d->m_ofono = make_shared<QOfonoManager>(); | 295 | d->m_ofono = make_shared<QOfonoManager>(); |
350 | 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); |
351 | 255 | d->modems_changed(d->m_ofono->modems()); | 297 | d->modems_changed(d->m_ofono->modems()); |
352 | @@ -262,15 +304,6 @@ | |||
353 | 262 | d->m_killSwitch = make_shared<KillSwitch>(systemConnection); | 304 | d->m_killSwitch = make_shared<KillSwitch>(systemConnection); |
354 | 263 | connect(d->m_killSwitch.get(), &KillSwitch::stateChanged, d.get(), &Private::updateHasWifi); | 305 | connect(d->m_killSwitch.get(), &KillSwitch::stateChanged, d.get(), &Private::updateHasWifi); |
355 | 264 | 306 | ||
356 | 265 | d->m_hotspotManager = make_shared<HotspotManager>(systemConnection); | ||
357 | 266 | connect(d->m_hotspotManager.get(), &HotspotManager::enabledChanged, this, &Manager::hotspotEnabledChanged); | ||
358 | 267 | connect(d->m_hotspotManager.get(), &HotspotManager::ssidChanged, this, &Manager::hotspotSsidChanged); | ||
359 | 268 | connect(d->m_hotspotManager.get(), &HotspotManager::passwordChanged, this, &Manager::hotspotPasswordChanged); | ||
360 | 269 | connect(d->m_hotspotManager.get(), &HotspotManager::modeChanged, this, &Manager::hotspotModeChanged); | ||
361 | 270 | connect(d->m_hotspotManager.get(), &HotspotManager::storedChanged, this, &Manager::hotspotStoredChanged); | ||
362 | 271 | |||
363 | 272 | connect(d->m_hotspotManager.get(), &HotspotManager::reportError, this, &Manager::reportError); | ||
364 | 273 | |||
365 | 274 | connect(d->nm.get(), &OrgFreedesktopNetworkManagerInterface::DeviceAdded, this, &ManagerImpl::device_added); | 307 | connect(d->nm.get(), &OrgFreedesktopNetworkManagerInterface::DeviceAdded, this, &ManagerImpl::device_added); |
366 | 275 | QList<QDBusObjectPath> devices(d->nm->GetDevices()); | 308 | QList<QDBusObjectPath> devices(d->nm->GetDevices()); |
367 | 276 | for(const auto &path : devices) { | 309 | for(const auto &path : devices) { |
368 | @@ -324,6 +357,18 @@ | |||
369 | 324 | } | 357 | } |
370 | 325 | 358 | ||
371 | 326 | bool | 359 | bool |
372 | 360 | ManagerImpl::modemAvailable() const | ||
373 | 361 | { | ||
374 | 362 | return !d->m_ofonoLinks.empty(); | ||
375 | 363 | } | ||
376 | 364 | |||
377 | 365 | bool | ||
378 | 366 | ManagerImpl::hotspotAvailable() const | ||
379 | 367 | { | ||
380 | 368 | return !d->m_hotspotManager->knownBadHardware(); | ||
381 | 369 | } | ||
382 | 370 | |||
383 | 371 | bool | ||
384 | 327 | ManagerImpl::hotspotEnabled() const | 372 | ManagerImpl::hotspotEnabled() const |
385 | 328 | { | 373 | { |
386 | 329 | return d->m_hotspotManager->enabled(); | 374 | return d->m_hotspotManager->enabled(); |
387 | 330 | 375 | ||
388 | === modified file 'src/indicator/nmofono/manager-impl.h' | |||
389 | --- src/indicator/nmofono/manager-impl.h 2015-08-14 15:52:39 +0000 | |||
390 | +++ src/indicator/nmofono/manager-impl.h 2015-08-21 15:55:11 +0000 | |||
391 | @@ -71,6 +71,10 @@ | |||
392 | 71 | void unlockAllModems() override; | 71 | void unlockAllModems() override; |
393 | 72 | void unlockModemByName(const QString &name) override; | 72 | void unlockModemByName(const QString &name) override; |
394 | 73 | 73 | ||
395 | 74 | bool modemAvailable() const override; | ||
396 | 75 | |||
397 | 76 | bool hotspotAvailable() const override; | ||
398 | 77 | |||
399 | 74 | bool hotspotEnabled() const override; | 78 | bool hotspotEnabled() const override; |
400 | 75 | 79 | ||
401 | 76 | bool hotspotStored() const override; | 80 | bool hotspotStored() const override; |
402 | 77 | 81 | ||
403 | === modified file 'src/indicator/nmofono/manager.h' | |||
404 | --- src/indicator/nmofono/manager.h 2015-08-14 15:52:39 +0000 | |||
405 | +++ src/indicator/nmofono/manager.h 2015-08-21 15:55:11 +0000 | |||
406 | @@ -122,6 +122,12 @@ | |||
407 | 122 | 122 | ||
408 | 123 | virtual void unlockModemByName(const QString &name) = 0; | 123 | virtual void unlockModemByName(const QString &name) = 0; |
409 | 124 | 124 | ||
410 | 125 | Q_PROPERTY(bool modemAvailable READ modemAvailable NOTIFY modemAvailableChanged) | ||
411 | 126 | virtual bool modemAvailable() const = 0; | ||
412 | 127 | |||
413 | 128 | Q_PROPERTY(bool hotspotAvailable READ hotspotAvailable NOTIFY hotspotAvailableChanged) | ||
414 | 129 | virtual bool hotspotAvailable() const = 0; | ||
415 | 130 | |||
416 | 125 | Q_PROPERTY(bool hotspotEnabled READ hotspotEnabled WRITE setHotspotEnabled NOTIFY hotspotEnabledChanged) | 131 | Q_PROPERTY(bool hotspotEnabled READ hotspotEnabled WRITE setHotspotEnabled NOTIFY hotspotEnabledChanged) |
417 | 126 | virtual bool hotspotEnabled() const = 0; | 132 | virtual bool hotspotEnabled() const = 0; |
418 | 127 | 133 | ||
419 | @@ -150,6 +156,10 @@ | |||
420 | 150 | 156 | ||
421 | 151 | void wifiEnabledUpdated(bool); | 157 | void wifiEnabledUpdated(bool); |
422 | 152 | 158 | ||
423 | 159 | void modemAvailableChanged(bool); | ||
424 | 160 | |||
425 | 161 | void hotspotAvailableChanged(bool); | ||
426 | 162 | |||
427 | 153 | void hotspotEnabledChanged(bool enabled); | 163 | void hotspotEnabledChanged(bool enabled); |
428 | 154 | 164 | ||
429 | 155 | void hotspotStoredChanged(bool stored); | 165 | void hotspotStoredChanged(bool stored); |
430 | 156 | 166 | ||
431 | === modified file 'tests/integration/test-connectivity-api.cpp' | |||
432 | --- tests/integration/test-connectivity-api.cpp 2015-08-17 15:38:34 +0000 | |||
433 | +++ tests/integration/test-connectivity-api.cpp 2015-08-21 15:55:11 +0000 | |||
434 | @@ -630,4 +630,19 @@ | |||
435 | 630 | } | 630 | } |
436 | 631 | } | 631 | } |
437 | 632 | 632 | ||
438 | 633 | TEST_F(TestConnectivityApi, HotspotModemAvailable) | ||
439 | 634 | { | ||
440 | 635 | setGlobalConnectedState(NM_STATE_DISCONNECTED); | ||
441 | 636 | auto device = createWiFiDevice(NM_DEVICE_STATE_DISCONNECTED); | ||
442 | 637 | |||
443 | 638 | // Start the indicator | ||
444 | 639 | ASSERT_NO_THROW(startIndicator()); | ||
445 | 640 | |||
446 | 641 | // Connect the the service | ||
447 | 642 | auto connectivity(newConnectivity()); | ||
448 | 643 | |||
449 | 644 | EXPECT_TRUE(connectivity->hotspotAvailable()); | ||
450 | 645 | EXPECT_TRUE(connectivity->modemAvailable()); | ||
451 | 646 | } | ||
452 | 647 | |||
453 | 633 | } | 648 | } |
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, hotspotSwitchEn abled, 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.