Merge lp:~unity-api-team/indicator-network/modeminfo into lp:indicator-network/14.10
- modeminfo
- Merge into trunk.14.10
Status: | Merged | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Approved by: | Charles Kerr | ||||||||||||||||
Approved revision: | 363 | ||||||||||||||||
Merge reported by: | Antti Kaijanmäki | ||||||||||||||||
Merged at revision: | not available | ||||||||||||||||
Proposed branch: | lp:~unity-api-team/indicator-network/modeminfo | ||||||||||||||||
Merge into: | lp:indicator-network/14.10 | ||||||||||||||||
Diff against target: |
1162 lines (+584/-244) 12 files modified
debian/control (+1/-1) network/CMakeLists.txt (+1/-0) network/menuitems/modem-info-item.cpp (+148/-0) network/menuitems/modem-info-item.h (+56/-0) network/menumodel-cpp/menu-merger.h (+8/-1) network/modem.cpp (+119/-103) network/modem.h (+40/-2) network/root-state.cpp (+75/-102) network/service.h (+6/-6) network/wwan-link-item.cpp (+96/-25) network/wwan-link-item.h (+2/-0) network/wwan-section.cpp (+32/-4) |
||||||||||||||||
To merge this branch: | bzr merge lp:~unity-api-team/indicator-network/modeminfo | ||||||||||||||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Pete Woods (community) | Approve | ||
Nick Dedekind (community) | Needs Fixing | ||
PS Jenkins bot (community) | continuous-integration | Approve | |
Charles Kerr (community) | Approve | ||
Review via email: mp+225160@code.launchpad.net |
Commit message
Add ModemInfoItem.
Description of the change
ModemInfoItem.
also requires:
https:/
https:/
silo: https:/
New indicator item that displays modem information and allows unlocking of a cellular modems.
Example of the different variations:
http://
Actual result when combined with the indicator:
http://
Charles Kerr (charlesk) wrote : | # |
Tested on N4, seems to be working as advertised. :-)
Nick Dedekind (nick-dedekind) wrote : | # |
On Mako
https:/
https:/
https:/
https:/
https:/
https:/
https:/
locked_sim1.png) this is how it comes up on boot. looks ok
locked_sim2.png) after unlocking phone. Note it still says "SIM Locked"
locked_sim3.png) restart indicator-network
locked_sim4.png) called the phone when it was in state 3. rejected
locked_sim5.png) restart indicator-network. called phone again. Can see the notification for accepting call, but see is still "Offline" & no strength icon
locked_sim6.png) restarted phone. came up without a locked sim icon in panel as in 1
locked_sim7.png) resarted again and unlocked. finally went into searching, then picked up a network. But it doesn't match with the designs you provided where there is the phone number above the carrier. There is no way to tell the sims apart if connected on same network.
/usr/share/
1) http://
2) http://
3) http://
4) http://
5) http://
6) can't reproduce
7) http://
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:359
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
Click here to trigger a rebuild:
http://
- 360. By Antti Kaijanmäki
-
Forgot to bind to the modem online property in the panel icon side.
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:360
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
Click here to trigger a rebuild:
http://
- 361. By Antti Kaijanmäki
-
add default sim identifiers and make sure modems are ordered correctly in the menu.
Antti Kaijanmäki (kaijanmaki) wrote : | # |
> On Mako
>
> https:/
> https:/
> https:/
> https:/
> https:/
> https:/
> https:/
>
> locked_sim1.png) this is how it comes up on boot. looks ok
> locked_sim2.png) after unlocking phone. Note it still says "SIM Locked"
> locked_sim3.png) restart indicator-network
> locked_sim4.png) called the phone when it was in state 3. rejected
> locked_sim5.png) restart indicator-network. called phone again. Can see the
> notification for accepting call, but see is still "Offline" & no strength icon
> locked_sim6.png) restarted phone. came up without a locked sim icon in panel
> as in 1
> locked_sim7.png) resarted again and unlocked. finally went into searching,
> then picked up a network.
Thank you for in-depth testing!
I nailed a couple of bugs and hopefully all of the above problems are now solved.
> But it doesn't match with the designs you provided
> where there is the phone number above the carrier.
The phone number is not always available. We need to investigate a bit more to figure out what additional information to have in there.
> There is no way to tell the
> sims apart if connected on same network.
Agreed.
I added default SIM identifiers (SIM 1, SIM 2) which are visible when using a dual sim device.
on a single sim device there is no reason to show the identifier as there is only one sim.
- 362. By Antti Kaijanmäki
-
review adjustments.
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:361
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:362
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
Click here to trigger a rebuild:
http://
- 363. By Antti Kaijanmäki
-
make sure cellular icons are ordered correctly in the panel.
Charles Kerr (charlesk) wrote : | # |
Code inspection LGTM after r362 + r363, thanks for the fixes.
I do not have dual sim so I have /not/ done Real World testing on this -- DO NOT merge this based on my approval until Nick's had another pass at it :)
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:363
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
Click here to trigger a rebuild:
http://
Nick Dedekind (nick-dedekind) wrote : | # |
Seems to be a little better now, but after a few tries of rebooting phone and unlocking I got this:
This is after unlocking. Note missing text & disabled signal icon in panel.
https:/
After restarting indicator-network.
https:/
The state text should never be empty. If it's in an unknown state, it should say "Unknown".
- 364. By Antti Kaijanmäki
-
Improve the panel modemTechIcon handling a bit on dual sim.
- 365. By Antti Kaijanmäki
-
Handle NetworkRegistra
tion::Status: :unknown better.
Antti Kaijanmäki (kaijanmaki) wrote : | # |
> Seems to be a little better now, but after a few tries of rebooting phone and
> unlocking I got this:
>
> This is after unlocking. Note missing text & disabled signal icon in panel.
> https:/
OK. seems your phone gets an unknown state from networkregistration and unfortunately the unknown case was accidentally clearing the connectivity-icon instead of status icon. Fixed now.
> After restarting indicator-network.
> https:/
>
> The state text should never be empty. If it's in an unknown state, it should
> say "Unknown".
Agreed and fixed.
Pete Woods (pete-woods) wrote : | # |
The last two changes look sensible to me.
Preview Diff
1 | === modified file 'debian/control' | |||
2 | --- debian/control 2014-07-22 20:21:50 +0000 | |||
3 | +++ debian/control 2014-08-07 11:23:41 +0000 | |||
4 | @@ -41,7 +41,7 @@ | |||
5 | 41 | ubuntu-mobile-icons (>= 13.04+13.10.20131014), | 41 | ubuntu-mobile-icons (>= 13.04+13.10.20131014), |
6 | 42 | # For apport hook | 42 | # For apport hook |
7 | 43 | python3-xdg, | 43 | python3-xdg, |
9 | 44 | unity8 (>= 7.82), | 44 | unity8 (>= 8.00+14.10.20140806), |
10 | 45 | Conflicts: chewie, | 45 | Conflicts: chewie, |
11 | 46 | indicators-client-plugin-network, | 46 | indicators-client-plugin-network, |
12 | 47 | Description: Systems settings menu service - Network indicator | 47 | Description: Systems settings menu service - Network indicator |
13 | 48 | 48 | ||
14 | === modified file 'network/CMakeLists.txt' | |||
15 | --- network/CMakeLists.txt 2014-05-22 08:32:45 +0000 | |||
16 | +++ network/CMakeLists.txt 2014-08-07 11:23:41 +0000 | |||
17 | @@ -28,6 +28,7 @@ | |||
18 | 28 | 28 | ||
19 | 29 | menuitems/access-point-item.h | 29 | menuitems/access-point-item.h |
20 | 30 | menuitems/item.h | 30 | menuitems/item.h |
21 | 31 | menuitems/modem-info-item.cpp | ||
22 | 31 | menuitems/section.h | 32 | menuitems/section.h |
23 | 32 | menuitems/switch-item.h | 33 | menuitems/switch-item.h |
24 | 33 | menuitems/text-item.h | 34 | menuitems/text-item.h |
25 | 34 | 35 | ||
26 | === added file 'network/menuitems/modem-info-item.cpp' | |||
27 | --- network/menuitems/modem-info-item.cpp 1970-01-01 00:00:00 +0000 | |||
28 | +++ network/menuitems/modem-info-item.cpp 2014-08-07 11:23:41 +0000 | |||
29 | @@ -0,0 +1,148 @@ | |||
30 | 1 | /* | ||
31 | 2 | * Copyright (C) 2014 Canonical, Ltd. | ||
32 | 3 | * | ||
33 | 4 | * This program is free software: you can redistribute it and/or modify it | ||
34 | 5 | * under the terms of the GNU General Public License version 3, as published | ||
35 | 6 | * by the Free Software Foundation. | ||
36 | 7 | * | ||
37 | 8 | * This program is distributed in the hope that it will be useful, but | ||
38 | 9 | * WITHOUT ANY WARRANTY; without even the implied warranties of | ||
39 | 10 | * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR | ||
40 | 11 | * PURPOSE. See the GNU General Public License for more details. | ||
41 | 12 | * | ||
42 | 13 | * You should have received a copy of the GNU General Public License along | ||
43 | 14 | * with this program. If not, see <http://www.gnu.org/licenses/>. | ||
44 | 15 | * | ||
45 | 16 | * Authors: | ||
46 | 17 | * Antti Kaijanmäki <antti.kaijanmaki@canonical.com> | ||
47 | 18 | */ | ||
48 | 19 | |||
49 | 20 | #include "modem-info-item.h" | ||
50 | 21 | |||
51 | 22 | class ModemInfoItem::Private | ||
52 | 23 | { | ||
53 | 24 | public: | ||
54 | 25 | core::Signal<void> m_unlock; | ||
55 | 26 | |||
56 | 27 | std::vector<core::Connection> m_connections; | ||
57 | 28 | |||
58 | 29 | Action::Ptr m_actionStatusLabel; | ||
59 | 30 | Action::Ptr m_actionStatusIcon; | ||
60 | 31 | Action::Ptr m_actionConnectivityIcon; | ||
61 | 32 | Action::Ptr m_actionSimIdentifier; | ||
62 | 33 | Action::Ptr m_actionRoaming; | ||
63 | 34 | Action::Ptr m_actionLocked; | ||
64 | 35 | |||
65 | 36 | MenuItem::Ptr m_item; | ||
66 | 37 | }; | ||
67 | 38 | |||
68 | 39 | ModemInfoItem::ModemInfoItem() | ||
69 | 40 | { | ||
70 | 41 | d.reset(new Private); | ||
71 | 42 | |||
72 | 43 | static int id = 0; | ||
73 | 44 | ++id; /// @todo guard me. | ||
74 | 45 | |||
75 | 46 | std::string actionIdBase = "modem." + std::to_string(id); | ||
76 | 47 | |||
77 | 48 | std::string statusLabelActionId = actionIdBase + "::status-label"; | ||
78 | 49 | std::string statusIconActionId = actionIdBase + "::status-icon"; | ||
79 | 50 | std::string connectivityIconActionId = actionIdBase + "::connectivity-icon"; | ||
80 | 51 | std::string simIdentifierActionId = actionIdBase + "::sim-identifier-label"; | ||
81 | 52 | std::string roamingActionId = actionIdBase + "::roaming"; | ||
82 | 53 | std::string lockedActionId = actionIdBase + "::locked"; | ||
83 | 54 | |||
84 | 55 | d->m_item = std::make_shared<MenuItem>(); | ||
85 | 56 | |||
86 | 57 | d->m_item->setAttribute("x-canonical-type", TypedVariant<std::string>("com.canonical.indicator.network.modeminfoitem")); | ||
87 | 58 | d->m_item->setAttribute("x-canonical-modem-status-label-action", TypedVariant<std::string>("indicator." + statusLabelActionId)); | ||
88 | 59 | d->m_item->setAttribute("x-canonical-modem-status-icon-action", TypedVariant<std::string>("indicator." + statusIconActionId)); | ||
89 | 60 | d->m_item->setAttribute("x-canonical-modem-connectivity-icon-action", TypedVariant<std::string>("indicator." + connectivityIconActionId)); | ||
90 | 61 | d->m_item->setAttribute("x-canonical-modem-sim-identifier-label-action", TypedVariant<std::string>("indicator." + simIdentifierActionId)); | ||
91 | 62 | d->m_item->setAttribute("x-canonical-modem-roaming-action", TypedVariant<std::string>("indicator." + roamingActionId)); | ||
92 | 63 | d->m_item->setAttribute("x-canonical-modem-locked-action", TypedVariant<std::string>("indicator." + lockedActionId)); | ||
93 | 64 | |||
94 | 65 | |||
95 | 66 | |||
96 | 67 | d->m_actionStatusLabel = std::make_shared<Action>(statusLabelActionId, | ||
97 | 68 | nullptr, | ||
98 | 69 | TypedVariant<std::string>()); | ||
99 | 70 | d->m_actionStatusIcon = std::make_shared<Action>(statusIconActionId, | ||
100 | 71 | nullptr, | ||
101 | 72 | TypedVariant<std::string>()); | ||
102 | 73 | d->m_actionConnectivityIcon = std::make_shared<Action>(connectivityIconActionId, | ||
103 | 74 | nullptr, | ||
104 | 75 | TypedVariant<std::string>()); | ||
105 | 76 | d->m_actionSimIdentifier = std::make_shared<Action>(simIdentifierActionId, | ||
106 | 77 | nullptr, | ||
107 | 78 | TypedVariant<std::string>()); | ||
108 | 79 | d->m_actionRoaming = std::make_shared<Action>(roamingActionId, | ||
109 | 80 | nullptr, | ||
110 | 81 | TypedVariant<bool>(false)); | ||
111 | 82 | d->m_actionLocked = std::make_shared<Action>(lockedActionId, | ||
112 | 83 | nullptr, | ||
113 | 84 | TypedVariant<bool>(false)); | ||
114 | 85 | m_actionGroup->add(d->m_actionStatusLabel); | ||
115 | 86 | m_actionGroup->add(d->m_actionStatusIcon); | ||
116 | 87 | m_actionGroup->add(d->m_actionConnectivityIcon); | ||
117 | 88 | m_actionGroup->add(d->m_actionSimIdentifier); | ||
118 | 89 | m_actionGroup->add(d->m_actionRoaming); | ||
119 | 90 | m_actionGroup->add(d->m_actionLocked); | ||
120 | 91 | |||
121 | 92 | d->m_actionLocked->activated().connect([this](Variant){ d->m_unlock(); }); | ||
122 | 93 | } | ||
123 | 94 | |||
124 | 95 | ModemInfoItem::~ModemInfoItem() | ||
125 | 96 | { | ||
126 | 97 | |||
127 | 98 | } | ||
128 | 99 | |||
129 | 100 | void | ||
130 | 101 | ModemInfoItem::setStatusIcon(const std::string &name) | ||
131 | 102 | { | ||
132 | 103 | d->m_actionStatusIcon->setState(TypedVariant<std::string>(name)); | ||
133 | 104 | } | ||
134 | 105 | |||
135 | 106 | void | ||
136 | 107 | ModemInfoItem::setStatusText(const std::string &value) | ||
137 | 108 | { | ||
138 | 109 | d->m_actionStatusLabel->setState(TypedVariant<std::string>(value)); | ||
139 | 110 | } | ||
140 | 111 | |||
141 | 112 | void | ||
142 | 113 | ModemInfoItem::setConnectivityIcon(const std::string &name) | ||
143 | 114 | { | ||
144 | 115 | d->m_actionConnectivityIcon->setState(TypedVariant<std::string>(name)); | ||
145 | 116 | } | ||
146 | 117 | |||
147 | 118 | void | ||
148 | 119 | ModemInfoItem::setSimIdentifierText(const std::string &value) | ||
149 | 120 | |||
150 | 121 | { | ||
151 | 122 | d->m_actionSimIdentifier->setState(TypedVariant<std::string>(value)); | ||
152 | 123 | } | ||
153 | 124 | |||
154 | 125 | void | ||
155 | 126 | ModemInfoItem::setLocked(bool value) | ||
156 | 127 | { | ||
157 | 128 | d->m_actionLocked->setState(TypedVariant<bool>(value)); | ||
158 | 129 | } | ||
159 | 130 | |||
160 | 131 | void | ||
161 | 132 | ModemInfoItem::setRoaming(bool value) | ||
162 | 133 | { | ||
163 | 134 | d->m_actionRoaming->setState(TypedVariant<bool>(value)); | ||
164 | 135 | } | ||
165 | 136 | |||
166 | 137 | MenuItem::Ptr | ||
167 | 138 | ModemInfoItem::menuItem() | ||
168 | 139 | { | ||
169 | 140 | return d->m_item; | ||
170 | 141 | } | ||
171 | 142 | |||
172 | 143 | core::Signal<void> & | ||
173 | 144 | ModemInfoItem::unlock() | ||
174 | 145 | { | ||
175 | 146 | return d->m_unlock; | ||
176 | 147 | } | ||
177 | 148 | |||
178 | 0 | 149 | ||
179 | === added file 'network/menuitems/modem-info-item.h' | |||
180 | --- network/menuitems/modem-info-item.h 1970-01-01 00:00:00 +0000 | |||
181 | +++ network/menuitems/modem-info-item.h 2014-08-07 11:23:41 +0000 | |||
182 | @@ -0,0 +1,56 @@ | |||
183 | 1 | /* | ||
184 | 2 | * Copyright (C) 2014 Canonical, Ltd. | ||
185 | 3 | * | ||
186 | 4 | * This program is free software: you can redistribute it and/or modify it | ||
187 | 5 | * under the terms of the GNU General Public License version 3, as published | ||
188 | 6 | * by the Free Software Foundation. | ||
189 | 7 | * | ||
190 | 8 | * This program is distributed in the hope that it will be useful, but | ||
191 | 9 | * WITHOUT ANY WARRANTY; without even the implied warranties of | ||
192 | 10 | * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR | ||
193 | 11 | * PURPOSE. See the GNU General Public License for more details. | ||
194 | 12 | * | ||
195 | 13 | * You should have received a copy of the GNU General Public License along | ||
196 | 14 | * with this program. If not, see <http://www.gnu.org/licenses/>. | ||
197 | 15 | * | ||
198 | 16 | * Authors: | ||
199 | 17 | * Antti Kaijanmäki <antti.kaijanmaki@canonical.com> | ||
200 | 18 | */ | ||
201 | 19 | |||
202 | 20 | #ifndef MODEM_INFO_ITEM_H | ||
203 | 21 | #define MODEM_INFO_ITEM_H | ||
204 | 22 | |||
205 | 23 | #include "item.h" | ||
206 | 24 | #include "menumodel-cpp/action.h" | ||
207 | 25 | #include "menumodel-cpp/menu-item.h" | ||
208 | 26 | #include "menumodel-cpp/gio-helpers/variant.h" | ||
209 | 27 | |||
210 | 28 | #include <core/signal.h> | ||
211 | 29 | |||
212 | 30 | #include <functional> | ||
213 | 31 | #include <vector> | ||
214 | 32 | |||
215 | 33 | class ModemInfoItem : public Item | ||
216 | 34 | { | ||
217 | 35 | class Private; | ||
218 | 36 | std::unique_ptr<Private> d; | ||
219 | 37 | |||
220 | 38 | public: | ||
221 | 39 | typedef std::shared_ptr<ModemInfoItem> Ptr; | ||
222 | 40 | |||
223 | 41 | ModemInfoItem(); | ||
224 | 42 | virtual ~ModemInfoItem(); | ||
225 | 43 | |||
226 | 44 | void setStatusIcon(const std::string &name); | ||
227 | 45 | void setStatusText(const std::string &value); | ||
228 | 46 | void setConnectivityIcon(const std::string &name); | ||
229 | 47 | void setSimIdentifierText(const std::string &value); | ||
230 | 48 | void setLocked(bool value); | ||
231 | 49 | void setRoaming(bool value); | ||
232 | 50 | |||
233 | 51 | virtual MenuItem::Ptr menuItem(); | ||
234 | 52 | |||
235 | 53 | core::Signal<void> &unlock(); | ||
236 | 54 | }; | ||
237 | 55 | |||
238 | 56 | #endif // MODEM_INFO_ITEM_H | ||
239 | 0 | 57 | ||
240 | === modified file 'network/menumodel-cpp/menu-merger.h' | |||
241 | --- network/menumodel-cpp/menu-merger.h 2014-04-23 13:18:25 +0000 | |||
242 | +++ network/menumodel-cpp/menu-merger.h 2014-08-07 11:23:41 +0000 | |||
243 | @@ -127,7 +127,14 @@ | |||
244 | 127 | m_startPositions.erase(*menu); | 127 | m_startPositions.erase(*menu); |
245 | 128 | m_gmodelToMenu.erase(*menu); | 128 | m_gmodelToMenu.erase(*menu); |
246 | 129 | m_menus.erase(std::remove(m_menus.begin(), m_menus.end(), menu), m_menus.end()); | 129 | m_menus.erase(std::remove(m_menus.begin(), m_menus.end(), menu), m_menus.end()); |
248 | 130 | } | 130 | } |
249 | 131 | |||
250 | 132 | void clear() | ||
251 | 133 | { | ||
252 | 134 | std::vector<MenuModel::Ptr> tmp = m_menus; | ||
253 | 135 | for (auto menu : tmp) | ||
254 | 136 | remove(menu); | ||
255 | 137 | } | ||
256 | 131 | 138 | ||
257 | 132 | operator GMenuModel*() { return G_MENU_MODEL(m_gmenu.get()); } | 139 | operator GMenuModel*() { return G_MENU_MODEL(m_gmenu.get()); } |
258 | 133 | }; | 140 | }; |
259 | 134 | 141 | ||
260 | === modified file 'network/modem.cpp' | |||
261 | --- network/modem.cpp 2014-05-02 14:05:12 +0000 | |||
262 | +++ network/modem.cpp 2014-08-07 11:23:41 +0000 | |||
263 | @@ -22,49 +22,91 @@ | |||
264 | 22 | class Modem::Private | 22 | class Modem::Private |
265 | 23 | { | 23 | { |
266 | 24 | public: | 24 | public: |
267 | 25 | core::Property<bool> m_online; | ||
268 | 26 | |||
269 | 25 | org::ofono::Interface::Modem::Ptr m_ofonoModem; | 27 | org::ofono::Interface::Modem::Ptr m_ofonoModem; |
270 | 26 | core::Property<Modem::SimStatus> m_simStatus; | 28 | core::Property<Modem::SimStatus> m_simStatus; |
271 | 27 | core::Property<Modem::PinType> m_requiredPin; | 29 | core::Property<Modem::PinType> m_requiredPin; |
272 | 28 | core::Property<std::map<Modem::PinType, std::uint8_t>> m_retries; | 30 | core::Property<std::map<Modem::PinType, std::uint8_t>> m_retries; |
273 | 29 | core::Property<std::string> m_subscriberIdentity; | ||
274 | 30 | 31 | ||
275 | 31 | core::Property<std::string> m_operatorName; | 32 | core::Property<std::string> m_operatorName; |
276 | 32 | core::Property<org::ofono::Interface::NetworkRegistration::Status> m_status; | 33 | core::Property<org::ofono::Interface::NetworkRegistration::Status> m_status; |
277 | 33 | core::Property<std::int8_t> m_strength; | 34 | core::Property<std::int8_t> m_strength; |
278 | 34 | core::Property<org::ofono::Interface::NetworkRegistration::Technology> m_technology; | 35 | core::Property<org::ofono::Interface::NetworkRegistration::Technology> m_technology; |
279 | 35 | 36 | ||
280 | 37 | core::Property<std::string> m_simIdentifier; | ||
281 | 38 | int m_index = -1; | ||
282 | 39 | |||
283 | 36 | void networkRegistrationChanged(org::ofono::Interface::NetworkRegistration::Ptr netreg); | 40 | void networkRegistrationChanged(org::ofono::Interface::NetworkRegistration::Ptr netreg); |
284 | 37 | void simManagerChanged(org::ofono::Interface::SimManager::Ptr simmgr); | 41 | void simManagerChanged(org::ofono::Interface::SimManager::Ptr simmgr); |
285 | 38 | 42 | ||
289 | 39 | void simPresentChanged(bool value); | 43 | void update(); |
287 | 40 | void pinRequiredChanged(org::ofono::Interface::SimManager::PinType pin); | ||
288 | 41 | void retriesChanged(std::map<org::ofono::Interface::SimManager::PinType, std::uint8_t> retries) ; | ||
290 | 42 | }; | 44 | }; |
291 | 43 | 45 | ||
292 | 44 | void | 46 | void |
294 | 45 | Modem::Private::networkRegistrationChanged(org::ofono::Interface::NetworkRegistration::Ptr netreg) | 47 | Modem::Private::update() |
295 | 46 | { | 48 | { |
296 | 49 | auto simmgr = m_ofonoModem->simManager.get(); | ||
297 | 50 | if (simmgr) { | ||
298 | 51 | // update requiredPin | ||
299 | 52 | switch(simmgr->pinRequired.get()) | ||
300 | 53 | { | ||
301 | 54 | case org::ofono::Interface::SimManager::PinType::none: | ||
302 | 55 | m_requiredPin.set(PinType::none); | ||
303 | 56 | break; | ||
304 | 57 | case org::ofono::Interface::SimManager::PinType::pin: | ||
305 | 58 | m_requiredPin.set(PinType::pin); | ||
306 | 59 | break; | ||
307 | 60 | case org::ofono::Interface::SimManager::PinType::puk: | ||
308 | 61 | m_requiredPin.set(PinType::puk); | ||
309 | 62 | break; | ||
310 | 63 | default: | ||
311 | 64 | throw std::runtime_error("Ofono requires a PIN we have not been prepared to handle (" + | ||
312 | 65 | org::ofono::Interface::SimManager::pin2str(simmgr->pinRequired.get()) + | ||
313 | 66 | "). Bailing out."); | ||
314 | 67 | } | ||
315 | 68 | |||
316 | 69 | // update retries | ||
317 | 70 | std::map<Modem::PinType, std::uint8_t> tmp; | ||
318 | 71 | for (auto element : simmgr->retries.get()) { | ||
319 | 72 | switch(element.first) { | ||
320 | 73 | case org::ofono::Interface::SimManager::PinType::pin: | ||
321 | 74 | tmp[Modem::PinType::pin] = element.second; | ||
322 | 75 | break; | ||
323 | 76 | case org::ofono::Interface::SimManager::PinType::puk: | ||
324 | 77 | tmp[Modem::PinType::puk] = element.second; | ||
325 | 78 | break; | ||
326 | 79 | default: | ||
327 | 80 | // don't care | ||
328 | 81 | break; | ||
329 | 82 | } | ||
330 | 83 | } | ||
331 | 84 | m_retries.set(tmp); | ||
332 | 85 | |||
333 | 86 | // update simStatus | ||
334 | 87 | if (!simmgr->present.get()) { | ||
335 | 88 | m_simStatus.set(SimStatus::missing); | ||
336 | 89 | } else if (m_requiredPin == PinType::none){ | ||
337 | 90 | m_simStatus.set(SimStatus::ready); | ||
338 | 91 | } else { | ||
339 | 92 | if (m_retries->count(PinType::puk) != 0 && m_retries->at(PinType::puk) == 0) | ||
340 | 93 | m_simStatus.set(SimStatus::permanentlyLocked); | ||
341 | 94 | else | ||
342 | 95 | m_simStatus.set(SimStatus::locked); | ||
343 | 96 | } | ||
344 | 97 | |||
345 | 98 | } else { | ||
346 | 99 | m_requiredPin.set(PinType::none); | ||
347 | 100 | m_retries.set({}); | ||
348 | 101 | m_simStatus.set(SimStatus::missing); | ||
349 | 102 | } | ||
350 | 103 | |||
351 | 104 | auto netreg = m_ofonoModem->networkRegistration.get(); | ||
352 | 47 | if (netreg) { | 105 | if (netreg) { |
353 | 48 | netreg->operatorName.changed().connect([this](std::string value){ | ||
354 | 49 | m_operatorName.set(value); | ||
355 | 50 | }); | ||
356 | 51 | m_operatorName.set(netreg->operatorName.get()); | 106 | m_operatorName.set(netreg->operatorName.get()); |
357 | 52 | |||
358 | 53 | netreg->status.changed().connect([this](org::ofono::Interface::NetworkRegistration::Status value){ | ||
359 | 54 | m_status.set(value); | ||
360 | 55 | }); | ||
361 | 56 | m_status.set(netreg->status.get()); | 107 | m_status.set(netreg->status.get()); |
362 | 57 | |||
363 | 58 | netreg->strength.changed().connect([this](std::int8_t value){ | ||
364 | 59 | m_strength.set(value); | ||
365 | 60 | }); | ||
366 | 61 | m_strength.set(netreg->strength.get()); | 108 | m_strength.set(netreg->strength.get()); |
367 | 62 | |||
368 | 63 | netreg->technology.changed().connect([this](org::ofono::Interface::NetworkRegistration::Technology value){ | ||
369 | 64 | m_technology.set(value); | ||
370 | 65 | }); | ||
371 | 66 | m_technology.set(netreg->technology.get()); | 109 | m_technology.set(netreg->technology.get()); |
372 | 67 | |||
373 | 68 | } else { | 110 | } else { |
374 | 69 | m_operatorName.set(""); | 111 | m_operatorName.set(""); |
375 | 70 | m_status.set(org::ofono::Interface::NetworkRegistration::Status::unknown); | 112 | m_status.set(org::ofono::Interface::NetworkRegistration::Status::unknown); |
376 | @@ -73,96 +115,58 @@ | |||
377 | 73 | } | 115 | } |
378 | 74 | } | 116 | } |
379 | 75 | 117 | ||
380 | 118 | void | ||
381 | 119 | Modem::Private::networkRegistrationChanged(org::ofono::Interface::NetworkRegistration::Ptr netreg) | ||
382 | 120 | { | ||
383 | 121 | if (netreg) { | ||
384 | 122 | netreg->operatorName.changed().connect(std::bind(&Private::update, this)); | ||
385 | 123 | netreg->status.changed().connect(std::bind(&Private::update, this)); | ||
386 | 124 | netreg->strength.changed().connect(std::bind(&Private::update, this)); | ||
387 | 125 | netreg->technology.changed().connect(std::bind(&Private::update, this)); | ||
388 | 126 | } | ||
389 | 127 | update(); | ||
390 | 128 | } | ||
391 | 129 | |||
392 | 76 | 130 | ||
393 | 77 | void | 131 | void |
394 | 78 | Modem::Private::simManagerChanged(org::ofono::Interface::SimManager::Ptr simmgr) | 132 | Modem::Private::simManagerChanged(org::ofono::Interface::SimManager::Ptr simmgr) |
395 | 79 | { | 133 | { |
396 | 80 | if (simmgr) { | 134 | if (simmgr) { |
467 | 81 | simmgr->present.changed().connect(std::bind(&Private::simPresentChanged, this, std::placeholders::_1)); | 135 | simmgr->present.changed().connect(std::bind(&Private::update, this)); |
468 | 82 | simPresentChanged(simmgr->present.get()); | 136 | simmgr->pinRequired.changed().connect(std::bind(&Private::update, this)); |
469 | 83 | 137 | simmgr->retries.changed().connect(std::bind(&Private::update, this)); | |
470 | 84 | simmgr->pinRequired.changed().connect(std::bind(&Private::pinRequiredChanged, this, std::placeholders::_1)); | 138 | } |
471 | 85 | pinRequiredChanged(simmgr->pinRequired.get()); | 139 | update(); |
472 | 86 | 140 | } | |
403 | 87 | simmgr->retries.changed().connect(std::bind(&Private::retriesChanged, this, std::placeholders::_1)); | ||
404 | 88 | retriesChanged(simmgr->retries.get()); | ||
405 | 89 | |||
406 | 90 | /// @todo subscriberIdentity | ||
407 | 91 | |||
408 | 92 | } else { | ||
409 | 93 | m_simStatus.set(SimStatus::offline); | ||
410 | 94 | m_requiredPin.set(PinType::none); | ||
411 | 95 | m_retries.set({}); | ||
412 | 96 | } | ||
413 | 97 | } | ||
414 | 98 | |||
415 | 99 | void | ||
416 | 100 | Modem::Private::pinRequiredChanged(org::ofono::Interface::SimManager::PinType pin) | ||
417 | 101 | { | ||
418 | 102 | switch(pin) | ||
419 | 103 | { | ||
420 | 104 | case org::ofono::Interface::SimManager::PinType::none: | ||
421 | 105 | m_requiredPin.set(PinType::none); | ||
422 | 106 | m_simStatus.set(SimStatus::ready); | ||
423 | 107 | break; | ||
424 | 108 | case org::ofono::Interface::SimManager::PinType::pin: | ||
425 | 109 | m_requiredPin.set(PinType::pin); | ||
426 | 110 | m_simStatus.set(SimStatus::locked); | ||
427 | 111 | break; | ||
428 | 112 | case org::ofono::Interface::SimManager::PinType::puk: | ||
429 | 113 | m_requiredPin.set(PinType::puk); | ||
430 | 114 | m_simStatus.set(SimStatus::locked); | ||
431 | 115 | break; | ||
432 | 116 | default: | ||
433 | 117 | throw std::runtime_error("Ofono requires a PIN we have not been prepared to handle (" + | ||
434 | 118 | org::ofono::Interface::SimManager::pin2str(pin) + | ||
435 | 119 | "). Bailing out."); | ||
436 | 120 | } | ||
437 | 121 | } | ||
438 | 122 | |||
439 | 123 | void | ||
440 | 124 | Modem::Private::retriesChanged(std::map<org::ofono::Interface::SimManager::PinType, std::uint8_t> retries) | ||
441 | 125 | { | ||
442 | 126 | std::map<Modem::PinType, std::uint8_t> tmp; | ||
443 | 127 | for (auto element : retries) { | ||
444 | 128 | switch(element.first) { | ||
445 | 129 | case org::ofono::Interface::SimManager::PinType::pin: | ||
446 | 130 | tmp[Modem::PinType::pin] = element.second; | ||
447 | 131 | break; | ||
448 | 132 | case org::ofono::Interface::SimManager::PinType::puk: | ||
449 | 133 | tmp[Modem::PinType::puk] = element.second; | ||
450 | 134 | break; | ||
451 | 135 | default: | ||
452 | 136 | // don't care | ||
453 | 137 | break; | ||
454 | 138 | } | ||
455 | 139 | } | ||
456 | 140 | m_retries.set(tmp); | ||
457 | 141 | } | ||
458 | 142 | |||
459 | 143 | void | ||
460 | 144 | Modem::Private::simPresentChanged(bool value) | ||
461 | 145 | { | ||
462 | 146 | if (!value) { | ||
463 | 147 | m_simStatus.set(SimStatus::missing); | ||
464 | 148 | } | ||
465 | 149 | } | ||
466 | 150 | |||
473 | 151 | 141 | ||
474 | 152 | Modem::Modem(org::ofono::Interface::Modem::Ptr ofonoModem) | 142 | Modem::Modem(org::ofono::Interface::Modem::Ptr ofonoModem) |
475 | 153 | { | 143 | { |
476 | 154 | d.reset(new Private); | 144 | d.reset(new Private); |
477 | 155 | d->m_ofonoModem = ofonoModem; | 145 | d->m_ofonoModem = ofonoModem; |
478 | 156 | 146 | ||
479 | 147 | d->m_online.set(d->m_ofonoModem->online.get()); | ||
480 | 148 | d->m_ofonoModem->online.changed().connect([this](bool value){ | ||
481 | 149 | d->m_online.set(value); | ||
482 | 150 | }); | ||
483 | 151 | |||
484 | 157 | d->simManagerChanged(d->m_ofonoModem->simManager.get()); | 152 | d->simManagerChanged(d->m_ofonoModem->simManager.get()); |
488 | 158 | d->m_ofonoModem->simManager.changed().connect([this](org::ofono::Interface::SimManager::Ptr value){ | 153 | d->m_ofonoModem->simManager.changed().connect(std::bind(&Private::simManagerChanged, d.get(), std::placeholders::_1)); |
486 | 159 | d->simManagerChanged(value); | ||
487 | 160 | }); | ||
489 | 161 | 154 | ||
490 | 162 | d->networkRegistrationChanged(d->m_ofonoModem->networkRegistration.get()); | 155 | d->networkRegistrationChanged(d->m_ofonoModem->networkRegistration.get()); |
494 | 163 | d->m_ofonoModem->networkRegistration.changed().connect([this](org::ofono::Interface::NetworkRegistration::Ptr value){ | 156 | d->m_ofonoModem->networkRegistration.changed().connect(std::bind(&Private::networkRegistrationChanged, d.get(), std::placeholders::_1)); |
495 | 164 | d->networkRegistrationChanged(value); | 157 | |
496 | 165 | }); | 158 | /// @todo hook up with system-settings to allow changing the identifier. |
497 | 159 | /// for now just provide the defaults | ||
498 | 160 | const auto path = ofonoModem->object->path().as_string(); | ||
499 | 161 | if (path == "/ril_0") { | ||
500 | 162 | d->m_simIdentifier.set("SIM 1"); | ||
501 | 163 | d->m_index = 1; | ||
502 | 164 | } else if (path == "/ril_1") { | ||
503 | 165 | d->m_simIdentifier.set("SIM 2"); | ||
504 | 166 | d->m_index = 2; | ||
505 | 167 | } else { | ||
506 | 168 | d->m_simIdentifier.set(path); | ||
507 | 169 | } | ||
508 | 166 | } | 170 | } |
509 | 167 | 171 | ||
510 | 168 | Modem::~Modem() | 172 | Modem::~Modem() |
511 | @@ -240,6 +244,12 @@ | |||
512 | 240 | throw std::logic_error("code should not be reached."); | 244 | throw std::logic_error("code should not be reached."); |
513 | 241 | } | 245 | } |
514 | 242 | 246 | ||
515 | 247 | const core::Property<bool> & | ||
516 | 248 | Modem::online() | ||
517 | 249 | { | ||
518 | 250 | return d->m_online; | ||
519 | 251 | } | ||
520 | 252 | |||
521 | 243 | const core::Property<Modem::SimStatus> & | 253 | const core::Property<Modem::SimStatus> & |
522 | 244 | Modem::simStatus() | 254 | Modem::simStatus() |
523 | 245 | { | 255 | { |
524 | @@ -259,12 +269,6 @@ | |||
525 | 259 | } | 269 | } |
526 | 260 | 270 | ||
527 | 261 | const core::Property<std::string> & | 271 | const core::Property<std::string> & |
528 | 262 | Modem::subscriberIdentity() | ||
529 | 263 | { | ||
530 | 264 | return d->m_subscriberIdentity; | ||
531 | 265 | } | ||
532 | 266 | |||
533 | 267 | const core::Property<std::string> & | ||
534 | 268 | Modem::operatorName() | 272 | Modem::operatorName() |
535 | 269 | { | 273 | { |
536 | 270 | return d->m_operatorName; | 274 | return d->m_operatorName; |
537 | @@ -287,3 +291,15 @@ | |||
538 | 287 | { | 291 | { |
539 | 288 | return d->m_technology; | 292 | return d->m_technology; |
540 | 289 | } | 293 | } |
541 | 294 | const core::Property<std::string> & | ||
542 | 295 | Modem::simIdentifier() | ||
543 | 296 | { | ||
544 | 297 | return d->m_simIdentifier; | ||
545 | 298 | } | ||
546 | 299 | |||
547 | 300 | int | ||
548 | 301 | Modem::index() | ||
549 | 302 | { | ||
550 | 303 | return d->m_index; | ||
551 | 304 | } | ||
552 | 305 | |||
553 | 290 | 306 | ||
554 | === modified file 'network/modem.h' | |||
555 | --- network/modem.h 2014-04-23 13:18:25 +0000 | |||
556 | +++ network/modem.h 2014-08-07 11:23:41 +0000 | |||
557 | @@ -42,7 +42,6 @@ | |||
558 | 42 | 42 | ||
559 | 43 | enum class SimStatus | 43 | enum class SimStatus |
560 | 44 | { | 44 | { |
561 | 45 | offline, | ||
562 | 46 | missing, | 45 | missing, |
563 | 47 | error, | 46 | error, |
564 | 48 | locked, | 47 | locked, |
565 | @@ -70,17 +69,56 @@ | |||
566 | 70 | const std::string &oldPin, | 69 | const std::string &oldPin, |
567 | 71 | const std::string &newPin); | 70 | const std::string &newPin); |
568 | 72 | 71 | ||
569 | 72 | const core::Property<bool> &online(); | ||
570 | 73 | 73 | ||
571 | 74 | const core::Property<SimStatus> &simStatus(); | 74 | const core::Property<SimStatus> &simStatus(); |
572 | 75 | const core::Property<PinType> &requiredPin(); | 75 | const core::Property<PinType> &requiredPin(); |
573 | 76 | const core::Property<std::map<PinType, std::uint8_t>> &retries(); | 76 | const core::Property<std::map<PinType, std::uint8_t>> &retries(); |
574 | 77 | const core::Property<std::string> &subscriberIdentity(); | ||
575 | 78 | 77 | ||
576 | 79 | const core::Property<std::string> &operatorName(); | 78 | const core::Property<std::string> &operatorName(); |
577 | 80 | const core::Property<org::ofono::Interface::NetworkRegistration::Status> &status(); | 79 | const core::Property<org::ofono::Interface::NetworkRegistration::Status> &status(); |
578 | 81 | const core::Property<std::int8_t> &strength(); | 80 | const core::Property<std::int8_t> &strength(); |
579 | 82 | const core::Property<org::ofono::Interface::NetworkRegistration::Technology> &technology(); | 81 | const core::Property<org::ofono::Interface::NetworkRegistration::Technology> &technology(); |
580 | 83 | 82 | ||
581 | 83 | const core::Property<std::string> &simIdentifier(); | ||
582 | 84 | int index(); | ||
583 | 85 | |||
584 | 86 | static const std::string strengthIcon(int8_t strength) | ||
585 | 87 | { | ||
586 | 88 | /* Using same values as used by Android, not linear (LP: #1329945)*/ | ||
587 | 89 | if (strength >= 39) | ||
588 | 90 | return "gsm-3g-full"; | ||
589 | 91 | else if (strength >= 26) | ||
590 | 92 | return "gsm-3g-high"; | ||
591 | 93 | else if (strength >= 16) | ||
592 | 94 | return "gsm-3g-medium"; | ||
593 | 95 | else if (strength >= 6) | ||
594 | 96 | return "gsm-3g-low"; | ||
595 | 97 | else | ||
596 | 98 | return "gsm-3g-none"; | ||
597 | 99 | } | ||
598 | 100 | |||
599 | 101 | static const std::string technologyIcon(org::ofono::Interface::NetworkRegistration::Technology tech) | ||
600 | 102 | { | ||
601 | 103 | switch (tech){ | ||
602 | 104 | case org::ofono::Interface::NetworkRegistration::Technology::notAvailable: | ||
603 | 105 | case org::ofono::Interface::NetworkRegistration::Technology::gsm: | ||
604 | 106 | return "network-cellular-pre-edge"; | ||
605 | 107 | case org::ofono::Interface::NetworkRegistration::Technology::edge: | ||
606 | 108 | return "network-cellular-edge"; | ||
607 | 109 | case org::ofono::Interface::NetworkRegistration::Technology::umts: | ||
608 | 110 | return "network-cellular-3g"; | ||
609 | 111 | case org::ofono::Interface::NetworkRegistration::Technology::hspa: | ||
610 | 112 | return "network-cellular-hspa"; | ||
611 | 113 | /// @todo oFono can't tell us about hspa+ yet | ||
612 | 114 | //case org::ofono::Interface::NetworkRegistration::Technology::hspaplus: | ||
613 | 115 | // break; | ||
614 | 116 | case org::ofono::Interface::NetworkRegistration::Technology::lte: | ||
615 | 117 | return "network-cellular-lte"; | ||
616 | 118 | } | ||
617 | 119 | // shouldn't be reached | ||
618 | 120 | return ""; | ||
619 | 121 | } | ||
620 | 84 | }; | 122 | }; |
621 | 85 | 123 | ||
622 | 86 | #endif | 124 | #endif |
623 | 87 | 125 | ||
624 | === modified file 'network/root-state.cpp' | |||
625 | --- network/root-state.cpp 2014-06-17 12:27:05 +0000 | |||
626 | +++ network/root-state.cpp 2014-08-07 11:23:41 +0000 | |||
627 | @@ -33,7 +33,6 @@ | |||
628 | 33 | ModemManager::Ptr m_modemManager; | 33 | ModemManager::Ptr m_modemManager; |
629 | 34 | core::Property<Variant> m_state; | 34 | core::Property<Variant> m_state; |
630 | 35 | 35 | ||
631 | 36 | std::string m_preLabel; | ||
632 | 37 | std::string m_label; | 36 | std::string m_label; |
633 | 38 | 37 | ||
634 | 39 | /// @todo multiple adapters etc.. | 38 | /// @todo multiple adapters etc.. |
635 | @@ -41,15 +40,11 @@ | |||
636 | 41 | 40 | ||
637 | 42 | std::string m_modemTechIcon; | 41 | std::string m_modemTechIcon; |
638 | 43 | 42 | ||
639 | 44 | bool m_inFlightMode; | ||
640 | 45 | bool m_roaming; | ||
641 | 46 | |||
642 | 47 | std::map<Modem::Ptr, std::string> m_cellularIcons; | 43 | std::map<Modem::Ptr, std::string> m_cellularIcons; |
643 | 48 | 44 | ||
644 | 49 | Private() = delete; | 45 | Private() = delete; |
645 | 50 | Private(std::shared_ptr<networking::Manager> manager, ModemManager::Ptr modemManager); | 46 | Private(std::shared_ptr<networking::Manager> manager, ModemManager::Ptr modemManager); |
646 | 51 | 47 | ||
647 | 52 | void flightModeChanged(networking::Manager::FlightModeStatus status); | ||
648 | 53 | void modemsChanged(const std::set<Modem::Ptr> &modems); | 48 | void modemsChanged(const std::set<Modem::Ptr> &modems); |
649 | 54 | 49 | ||
650 | 55 | void updateModem(Modem::WeakPtr weakModem); | 50 | void updateModem(Modem::WeakPtr weakModem); |
651 | @@ -62,39 +57,23 @@ | |||
652 | 62 | 57 | ||
653 | 63 | RootState::Private::Private(std::shared_ptr<networking::Manager> manager, ModemManager::Ptr modemManager) | 58 | RootState::Private::Private(std::shared_ptr<networking::Manager> manager, ModemManager::Ptr modemManager) |
654 | 64 | : m_manager{manager}, | 59 | : m_manager{manager}, |
657 | 65 | m_modemManager{modemManager}, | 60 | m_modemManager{modemManager} |
656 | 66 | m_roaming{false} | ||
658 | 67 | { | 61 | { |
661 | 68 | m_manager->flightMode().changed().connect(std::bind(&Private::flightModeChanged, this, std::placeholders::_1)); | 62 | m_manager->flightMode().changed().connect(std::bind(&Private::updateRootState, this)); |
660 | 69 | flightModeChanged(m_manager->flightMode().get()); | ||
662 | 70 | 63 | ||
663 | 71 | m_modemManager->modems().changed().connect(std::bind(&Private::modemsChanged, this, std::placeholders::_1)); | 64 | m_modemManager->modems().changed().connect(std::bind(&Private::modemsChanged, this, std::placeholders::_1)); |
664 | 72 | modemsChanged(m_modemManager->modems().get()); | 65 | modemsChanged(m_modemManager->modems().get()); |
665 | 73 | 66 | ||
666 | 74 | m_manager->status().changed().connect(std::bind(&Private::updateNetworkingIcon, this)); | 67 | m_manager->status().changed().connect(std::bind(&Private::updateNetworkingIcon, this)); |
667 | 75 | m_manager->links().changed().connect(std::bind(&Private::updateNetworkingIcon, this)); | 68 | m_manager->links().changed().connect(std::bind(&Private::updateNetworkingIcon, this)); |
668 | 69 | |||
669 | 70 | // will also call updateRootState() | ||
670 | 76 | updateNetworkingIcon(); | 71 | updateNetworkingIcon(); |
671 | 77 | } | 72 | } |
672 | 78 | 73 | ||
673 | 79 | void | 74 | void |
674 | 80 | RootState::Private::flightModeChanged(networking::Manager::FlightModeStatus status) | ||
675 | 81 | { | ||
676 | 82 | switch(status) { | ||
677 | 83 | case networking::Manager::FlightModeStatus::off: | ||
678 | 84 | m_inFlightMode = false; | ||
679 | 85 | break; | ||
680 | 86 | case networking::Manager::FlightModeStatus::on: | ||
681 | 87 | m_inFlightMode = true; | ||
682 | 88 | break; | ||
683 | 89 | } | ||
684 | 90 | updateRootState(); | ||
685 | 91 | } | ||
686 | 92 | |||
687 | 93 | void | ||
688 | 94 | RootState::Private::modemsChanged(const std::set<Modem::Ptr> &modems) | 75 | RootState::Private::modemsChanged(const std::set<Modem::Ptr> &modems) |
689 | 95 | { | 76 | { |
690 | 96 | /// @todo we have to address the correct ordering of the modems | ||
691 | 97 | |||
692 | 98 | std::set<Modem::Ptr> current; | 77 | std::set<Modem::Ptr> current; |
693 | 99 | for (auto element : m_cellularIcons) | 78 | for (auto element : m_cellularIcons) |
694 | 100 | current.insert(element.first); | 79 | current.insert(element.first); |
695 | @@ -112,6 +91,7 @@ | |||
696 | 112 | m_cellularIcons.erase(modem); | 91 | m_cellularIcons.erase(modem); |
697 | 113 | 92 | ||
698 | 114 | for (auto modem : added) { | 93 | for (auto modem : added) { |
699 | 94 | modem->online().changed().connect(std::bind(&Private::updateModem, this, Modem::WeakPtr(modem))); | ||
700 | 115 | modem->simStatus().changed().connect(std::bind(&Private::updateModem, this, Modem::WeakPtr(modem))); | 95 | modem->simStatus().changed().connect(std::bind(&Private::updateModem, this, Modem::WeakPtr(modem))); |
701 | 116 | modem->status().changed().connect(std::bind(&Private::updateModem, this, Modem::WeakPtr(modem))); | 96 | modem->status().changed().connect(std::bind(&Private::updateModem, this, Modem::WeakPtr(modem))); |
702 | 117 | modem->technology().changed().connect(std::bind(&Private::updateModem, this, Modem::WeakPtr(modem))); | 97 | modem->technology().changed().connect(std::bind(&Private::updateModem, this, Modem::WeakPtr(modem))); |
703 | @@ -129,90 +109,56 @@ | |||
704 | 129 | return; | 109 | return; |
705 | 130 | } | 110 | } |
706 | 131 | 111 | ||
707 | 132 | /// @todo multisim for all of these | ||
708 | 133 | m_preLabel.clear(); | ||
709 | 134 | m_roaming = false; | ||
710 | 135 | m_modemTechIcon.clear(); | 112 | m_modemTechIcon.clear(); |
711 | 136 | |||
712 | 137 | m_cellularIcons[modem] = ""; | 113 | m_cellularIcons[modem] = ""; |
713 | 138 | 114 | ||
714 | 115 | if (!modem->online().get()) { | ||
715 | 116 | // modem offline, nothing to show | ||
716 | 117 | updateRootState(); | ||
717 | 118 | return; | ||
718 | 119 | } | ||
719 | 139 | 120 | ||
720 | 140 | switch(modem->simStatus().get()) { | 121 | switch(modem->simStatus().get()) { |
721 | 141 | case Modem::SimStatus::offline: | ||
722 | 142 | /// @todo show something. | ||
723 | 143 | break; | ||
724 | 144 | case Modem::SimStatus::missing: | 122 | case Modem::SimStatus::missing: |
726 | 145 | m_preLabel = _("No SIM"); | 123 | // no need to show anything in the panel |
727 | 146 | break; | 124 | break; |
728 | 147 | case Modem::SimStatus::error: | 125 | case Modem::SimStatus::error: |
730 | 148 | m_preLabel = _("SIM Error"); | 126 | m_cellularIcons[modem] = "simcard-error"; |
731 | 149 | break; | 127 | break; |
732 | 150 | case Modem::SimStatus::locked: | 128 | case Modem::SimStatus::locked: |
733 | 151 | case Modem::SimStatus::permanentlyLocked: | 129 | case Modem::SimStatus::permanentlyLocked: |
736 | 152 | /// @todo handle perm blocked somehow | 130 | m_cellularIcons[modem] = "simcard-locked"; |
735 | 153 | m_preLabel = _("SIM Locked"); | ||
737 | 154 | break; | 131 | break; |
738 | 155 | case Modem::SimStatus::ready: | 132 | case Modem::SimStatus::ready: |
739 | 156 | { | 133 | { |
740 | 157 | switch (modem->status().get()) { | 134 | switch (modem->status().get()) { |
741 | 158 | case org::ofono::Interface::NetworkRegistration::Status::unregistered: | 135 | case org::ofono::Interface::NetworkRegistration::Status::unregistered: |
742 | 159 | /// @todo show something? | ||
743 | 160 | break; | ||
744 | 161 | case org::ofono::Interface::NetworkRegistration::Status::denied: | ||
745 | 162 | /// @todo maybe show something like "Denied" ? | ||
746 | 163 | m_preLabel = _("No Signal"); | ||
747 | 164 | break; | ||
748 | 165 | case org::ofono::Interface::NetworkRegistration::Status::unknown: | 136 | case org::ofono::Interface::NetworkRegistration::Status::unknown: |
749 | 166 | case org::ofono::Interface::NetworkRegistration::Status::searching: | 137 | case org::ofono::Interface::NetworkRegistration::Status::searching: |
750 | 138 | m_cellularIcons[modem] = "gsm-3g-disabled"; | ||
751 | 139 | break; | ||
752 | 140 | case org::ofono::Interface::NetworkRegistration::Status::denied: | ||
753 | 141 | /// @todo we might need network-error for this | ||
754 | 142 | m_cellularIcons[modem] = "gsm-3g-disabled"; | ||
755 | 143 | break; | ||
756 | 167 | case org::ofono::Interface::NetworkRegistration::Status::registered: | 144 | case org::ofono::Interface::NetworkRegistration::Status::registered: |
757 | 168 | /// @todo show something? | ||
758 | 169 | break; | ||
759 | 170 | case org::ofono::Interface::NetworkRegistration::Status::roaming: | 145 | case org::ofono::Interface::NetworkRegistration::Status::roaming: |
805 | 171 | /// @todo multisim | 146 | if (modem->strength().get() != 0) { |
806 | 172 | m_roaming = true; | 147 | m_cellularIcons[modem] = Modem::strengthIcon(modem->strength().get()); |
807 | 173 | break; | 148 | /// @todo need to revise this once the modems are part of the connectivity-api |
808 | 174 | } | 149 | /// this might get us wrong results on dual-sim |
809 | 175 | 150 | if (modem->index() == 1) { | |
810 | 176 | auto strength = modem->strength().get(); | 151 | m_modemTechIcon = Modem::technologyIcon(modem->technology().get()); |
811 | 177 | /* Using same values as used by Android, not linear (LP: #1329945)*/ | 152 | } |
812 | 178 | if (strength >= 39) | 153 | } else { |
813 | 179 | m_cellularIcons[modem] = "gsm-3g-full"; | 154 | m_cellularIcons[modem] = "gsm-3g-no-service"; |
814 | 180 | else if (strength >= 26) | 155 | |
815 | 181 | m_cellularIcons[modem] = "gsm-3g-high"; | 156 | } |
816 | 182 | else if (strength >= 16) | 157 | |
817 | 183 | m_cellularIcons[modem] = "gsm-3g-medium"; | 158 | // we might have changed the modem tech icon which affects the networkingIcon. |
818 | 184 | else if (strength >= 6) | 159 | updateNetworkingIcon(); |
819 | 185 | m_cellularIcons[modem] = "gsm-3g-low"; | 160 | break; |
820 | 186 | else | 161 | } |
776 | 187 | m_cellularIcons[modem] = "gsm-3g-none"; | ||
777 | 188 | |||
778 | 189 | switch (modem->technology().get()){ | ||
779 | 190 | case org::ofono::Interface::NetworkRegistration::Technology::notAvailable: | ||
780 | 191 | /// @todo check this.. | ||
781 | 192 | // "network-cellular-pre-edge" | ||
782 | 193 | // a11ydesc = _("Network (cellular, %s)").printf(current_protocol) | ||
783 | 194 | break; | ||
784 | 195 | case org::ofono::Interface::NetworkRegistration::Technology::gsm: | ||
785 | 196 | m_modemTechIcon = "network-cellular-pre-edge"; | ||
786 | 197 | break; | ||
787 | 198 | case org::ofono::Interface::NetworkRegistration::Technology::edge: | ||
788 | 199 | m_modemTechIcon = "network-cellular-edge"; | ||
789 | 200 | break; | ||
790 | 201 | case org::ofono::Interface::NetworkRegistration::Technology::umts: | ||
791 | 202 | m_modemTechIcon = "network-cellular-3g"; | ||
792 | 203 | break; | ||
793 | 204 | case org::ofono::Interface::NetworkRegistration::Technology::hspa: | ||
794 | 205 | m_modemTechIcon = "network-cellular-hspa"; | ||
795 | 206 | break; | ||
796 | 207 | /// @todo oFono can't tell us about hspa+ yet | ||
797 | 208 | //case org::ofono::Interface::NetworkRegistration::Technology::hspaplus: | ||
798 | 209 | // break; | ||
799 | 210 | case org::ofono::Interface::NetworkRegistration::Technology::lte: | ||
800 | 211 | m_modemTechIcon = "network-cellular-lte"; | ||
801 | 212 | break; | ||
802 | 213 | } | ||
803 | 214 | // we might have changed the modem tech icon which affects the networkingIcon. | ||
804 | 215 | updateNetworkingIcon(); | ||
821 | 216 | break; | 162 | break; |
822 | 217 | }} | 163 | }} |
823 | 218 | 164 | ||
824 | @@ -241,8 +187,12 @@ | |||
825 | 241 | 187 | ||
826 | 242 | auto wifiLink = std::dynamic_pointer_cast<networking::wifi::Link>(link); | 188 | auto wifiLink = std::dynamic_pointer_cast<networking::wifi::Link>(link); |
827 | 243 | 189 | ||
830 | 244 | int strength = wifiLink->activeAccessPoint().get()->strength().get(); | 190 | int strength = -1; |
831 | 245 | bool secured = wifiLink->activeAccessPoint().get()->secured(); | 191 | bool secured = false; |
832 | 192 | if (wifiLink->activeAccessPoint().get()) { | ||
833 | 193 | strength = wifiLink->activeAccessPoint().get()->strength().get(); | ||
834 | 194 | secured = wifiLink->activeAccessPoint().get()->secured(); | ||
835 | 195 | } | ||
836 | 246 | 196 | ||
837 | 247 | /// @todo deal with a11ydesc | 197 | /// @todo deal with a11ydesc |
838 | 248 | // gchar *a11ydesc = nullptr; | 198 | // gchar *a11ydesc = nullptr; |
839 | @@ -305,15 +255,41 @@ | |||
840 | 305 | std::vector<std::string> icons; | 255 | std::vector<std::string> icons; |
841 | 306 | std::map<std::string, Variant> state; | 256 | std::map<std::string, Variant> state; |
842 | 307 | 257 | ||
844 | 308 | if (m_inFlightMode) | 258 | switch(m_manager->flightMode().get()) { |
845 | 259 | case networking::Manager::FlightModeStatus::off: | ||
846 | 260 | break; | ||
847 | 261 | case networking::Manager::FlightModeStatus::on: | ||
848 | 309 | icons.push_back("airplane-mode"); | 262 | icons.push_back("airplane-mode"); |
856 | 310 | 263 | break; | |
857 | 311 | for (auto icon : m_cellularIcons) | 264 | } |
858 | 312 | if (!icon.second.empty()) | 265 | |
859 | 313 | icons.push_back(icon.second); | 266 | auto compare = [](int lhs, int rhs ){ |
860 | 314 | 267 | // make sure index() == -1 goes as leftmost cellular icon | |
861 | 315 | if (m_roaming) | 268 | if (lhs == -1 && rhs == -1) |
862 | 316 | icons.push_back("network-cellular-roaming"); | 269 | return false; |
863 | 270 | if (lhs == -1) | ||
864 | 271 | return false; | ||
865 | 272 | if (rhs == -1) | ||
866 | 273 | return true; | ||
867 | 274 | return lhs < rhs; | ||
868 | 275 | }; | ||
869 | 276 | std::multimap<int, std::string, decltype(compare)> sorted(compare); | ||
870 | 277 | |||
871 | 278 | for (auto pair : m_cellularIcons) { | ||
872 | 279 | sorted.insert(std::make_pair(pair.first->index(), pair.second)); | ||
873 | 280 | } | ||
874 | 281 | for (auto pair : sorted) { | ||
875 | 282 | if (!pair.second.empty()) | ||
876 | 283 | icons.push_back(pair.second); | ||
877 | 284 | } | ||
878 | 285 | |||
879 | 286 | // if any of the modems is roaming, show the roaming icon | ||
880 | 287 | for (auto modem : m_modemManager->modems().get()) { | ||
881 | 288 | if (modem->status().get() == org::ofono::Interface::NetworkRegistration::Status::roaming) { | ||
882 | 289 | icons.push_back("network-cellular-roaming"); | ||
883 | 290 | break; | ||
884 | 291 | } | ||
885 | 292 | } | ||
886 | 317 | 293 | ||
887 | 318 | if (!m_networkingIcon.empty()) { | 294 | if (!m_networkingIcon.empty()) { |
888 | 319 | 295 | ||
889 | @@ -328,9 +304,6 @@ | |||
890 | 328 | icons.push_back(m_networkingIcon); | 304 | icons.push_back(m_networkingIcon); |
891 | 329 | } | 305 | } |
892 | 330 | 306 | ||
893 | 331 | if (!m_preLabel.empty()) | ||
894 | 332 | state["pre-label"] = TypedVariant<std::string>(m_preLabel); | ||
895 | 333 | |||
896 | 334 | if (!m_label.empty()) | 307 | if (!m_label.empty()) |
897 | 335 | state["label"] = TypedVariant<std::string>(m_label); | 308 | state["label"] = TypedVariant<std::string>(m_label); |
898 | 336 | 309 | ||
899 | 337 | 310 | ||
900 | === modified file 'network/service.h' | |||
901 | --- network/service.h 2014-05-16 19:39:19 +0000 | |||
902 | +++ network/service.h 2014-08-07 11:23:41 +0000 | |||
903 | @@ -112,18 +112,18 @@ | |||
904 | 112 | m_phoneMenu->addSection(m_quickAccessSection); | 112 | m_phoneMenu->addSection(m_quickAccessSection); |
905 | 113 | m_phoneGreeterMenu->addSection(m_quickAccessSection); | 113 | m_phoneGreeterMenu->addSection(m_quickAccessSection); |
906 | 114 | 114 | ||
907 | 115 | m_wwanSection = std::make_shared<WwanSection>(m_modemManager); | ||
908 | 116 | m_desktopMenu->addSection(m_wwanSection); | ||
909 | 117 | m_desktopGreeterMenu->addSection(m_wwanSection); | ||
910 | 118 | m_phoneMenu->addSection(m_wwanSection); | ||
911 | 119 | m_phoneGreeterMenu->addSection(m_wwanSection); | ||
912 | 120 | |||
913 | 115 | m_wifiSection = std::make_shared<WifiSection>(m_manager); | 121 | m_wifiSection = std::make_shared<WifiSection>(m_manager); |
914 | 116 | m_desktopMenu->addSection(m_wifiSection); | 122 | m_desktopMenu->addSection(m_wifiSection); |
915 | 117 | m_desktopGreeterMenu->addSection(m_wifiSection); | 123 | m_desktopGreeterMenu->addSection(m_wifiSection); |
916 | 118 | m_phoneMenu->addSection(m_wifiSection); | 124 | m_phoneMenu->addSection(m_wifiSection); |
917 | 119 | m_phoneGreeterMenu->addSection(m_wifiSection); | 125 | m_phoneGreeterMenu->addSection(m_wifiSection); |
918 | 120 | 126 | ||
919 | 121 | m_wwanSection = std::make_shared<WwanSection>(m_modemManager); | ||
920 | 122 | m_desktopMenu->addSection(m_wwanSection); | ||
921 | 123 | m_desktopGreeterMenu->addSection(m_wwanSection); | ||
922 | 124 | m_phoneMenu->addSection(m_wwanSection); | ||
923 | 125 | m_phoneGreeterMenu->addSection(m_wwanSection); | ||
924 | 126 | |||
925 | 127 | m_desktopMenuExporter.reset(new MenuExporter(m_sessionBus, "/com/canonical/indicator/network/desktop", m_desktopMenu->menu())); | 127 | m_desktopMenuExporter.reset(new MenuExporter(m_sessionBus, "/com/canonical/indicator/network/desktop", m_desktopMenu->menu())); |
926 | 128 | m_desktopGreeterMenuExporter.reset(new MenuExporter(m_sessionBus, "/com/canonical/indicator/network/desktop_greeter", m_desktopGreeterMenu->menu())); | 128 | m_desktopGreeterMenuExporter.reset(new MenuExporter(m_sessionBus, "/com/canonical/indicator/network/desktop_greeter", m_desktopGreeterMenu->menu())); |
927 | 129 | m_desktopWifiSettingsMenuExporter.reset(new MenuExporter(m_sessionBus, "/com/canonical/indicator/network/desktop_wifi_settings", m_wifiSection->settingsModel())); | 129 | m_desktopWifiSettingsMenuExporter.reset(new MenuExporter(m_sessionBus, "/com/canonical/indicator/network/desktop_wifi_settings", m_wifiSection->settingsModel())); |
928 | 130 | 130 | ||
929 | === modified file 'network/wwan-link-item.cpp' | |||
930 | --- network/wwan-link-item.cpp 2014-05-21 17:56:25 +0000 | |||
931 | +++ network/wwan-link-item.cpp 2014-08-07 11:23:41 +0000 | |||
932 | @@ -19,7 +19,7 @@ | |||
933 | 19 | 19 | ||
934 | 20 | #include "wwan-link-item.h" | 20 | #include "wwan-link-item.h" |
935 | 21 | 21 | ||
937 | 22 | #include "menuitems/text-item.h" | 22 | #include "menuitems/modem-info-item.h" |
938 | 23 | 23 | ||
939 | 24 | #include "menumodel-cpp/menu.h" | 24 | #include "menumodel-cpp/menu.h" |
940 | 25 | 25 | ||
941 | @@ -33,13 +33,14 @@ | |||
942 | 33 | Modem::Ptr m_modem; | 33 | Modem::Ptr m_modem; |
943 | 34 | ModemManager::Ptr m_modemManager; | 34 | ModemManager::Ptr m_modemManager; |
944 | 35 | 35 | ||
947 | 36 | TextItem::Ptr m_unlockSim; | 36 | ModemInfoItem::Ptr m_infoItem; |
948 | 37 | bool m_wasLocked; | 37 | |
949 | 38 | core::Property<bool> m_showIdentifier; | ||
950 | 38 | 39 | ||
951 | 39 | Private() = delete; | 40 | Private() = delete; |
952 | 40 | Private(Modem::Ptr modem, ModemManager::Ptr modemManager); | 41 | Private(Modem::Ptr modem, ModemManager::Ptr modemManager); |
953 | 41 | 42 | ||
955 | 42 | void simStatusChanged(Modem::SimStatus status); | 43 | void update(); |
956 | 43 | void unlockSim(); | 44 | void unlockSim(); |
957 | 44 | }; | 45 | }; |
958 | 45 | 46 | ||
959 | @@ -50,33 +51,97 @@ | |||
960 | 50 | m_actionGroupMerger = std::make_shared<ActionGroupMerger>(); | 51 | m_actionGroupMerger = std::make_shared<ActionGroupMerger>(); |
961 | 51 | m_menu = std::make_shared<Menu>(); | 52 | m_menu = std::make_shared<Menu>(); |
962 | 52 | 53 | ||
973 | 53 | /// @todo add stuff to control the link | 54 | m_infoItem = std::make_shared<ModemInfoItem>(); |
974 | 54 | 55 | m_infoItem->unlock().connect(std::bind(&ModemManager::unlockModem, m_modemManager.get(), m_modem)); | |
975 | 55 | m_unlockSim = std::make_shared<TextItem>(_("Unlock SIM…"), "sim", "unlock"); | 56 | |
976 | 56 | m_unlockSim->activated().connect(std::bind(&ModemManager::unlockModem, m_modemManager.get(), m_modem)); | 57 | m_actionGroupMerger->add(*m_infoItem); |
977 | 57 | 58 | m_menu->append(*m_infoItem); | |
978 | 58 | m_actionGroupMerger->add(*m_unlockSim); | 59 | |
979 | 59 | 60 | m_showIdentifier.set(false); | |
980 | 60 | m_wasLocked = false; | 61 | m_showIdentifier.changed().connect(std::bind(&Private::update, this)); |
981 | 61 | m_modem->simStatus().changed().connect(std::bind(&Private::simStatusChanged, this, std::placeholders::_1)); | 62 | |
982 | 62 | simStatusChanged(m_modem->simStatus().get()); | 63 | m_modem->online().changed().connect(std::bind(&Private::update, this)); |
983 | 64 | m_modem->simStatus().changed().connect(std::bind(&Private::update, this)); | ||
984 | 65 | m_modem->operatorName().changed().connect(std::bind(&Private::update, this)); | ||
985 | 66 | m_modem->status().changed().connect(std::bind(&Private::update, this)); | ||
986 | 67 | m_modem->strength().changed().connect(std::bind(&Private::update, this)); | ||
987 | 68 | m_modem->technology().changed().connect(std::bind(&Private::update, this)); | ||
988 | 69 | m_modem->simIdentifier().changed().connect(std::bind(&Private::update, this)); | ||
989 | 70 | update(); | ||
990 | 63 | } | 71 | } |
991 | 64 | 72 | ||
992 | 65 | void | 73 | void |
994 | 66 | WwanLinkItem::Private::simStatusChanged(Modem::SimStatus status) | 74 | WwanLinkItem::Private::update() |
995 | 67 | { | 75 | { |
1002 | 68 | if (status == Modem::SimStatus::locked) { | 76 | if (m_showIdentifier.get()) { |
1003 | 69 | if (!m_wasLocked) { | 77 | m_infoItem->setSimIdentifierText(m_modem->simIdentifier().get()); |
998 | 70 | //m_actionGroupMerger->add(*m_unlockSim); | ||
999 | 71 | m_menu->append(*m_unlockSim); | ||
1000 | 72 | m_wasLocked = true; | ||
1001 | 73 | } | ||
1004 | 74 | } else { | 78 | } else { |
1009 | 75 | if (m_wasLocked) { | 79 | m_infoItem->setSimIdentifierText(""); |
1010 | 76 | //m_actionGroupMerger->remove(*m_unlockSim); | 80 | } |
1011 | 77 | m_menu->remove(m_menu->find(*m_unlockSim)); | 81 | /// @todo implement me. |
1012 | 78 | m_wasLocked = false; | 82 | m_infoItem->setConnectivityIcon(""); |
1013 | 83 | |||
1014 | 84 | switch(m_modem->simStatus().get()) { | ||
1015 | 85 | case Modem::SimStatus::missing: | ||
1016 | 86 | m_infoItem->setStatusIcon("no-simcard"); | ||
1017 | 87 | m_infoItem->setStatusText(_("No SIM")); | ||
1018 | 88 | m_infoItem->setLocked(false); | ||
1019 | 89 | m_infoItem->setRoaming(false); | ||
1020 | 90 | break; | ||
1021 | 91 | case Modem::SimStatus::error: | ||
1022 | 92 | m_infoItem->setStatusIcon("simcard-error"); | ||
1023 | 93 | m_infoItem->setStatusText(_("SIM Error")); | ||
1024 | 94 | m_infoItem->setLocked(false); | ||
1025 | 95 | m_infoItem->setRoaming(false); | ||
1026 | 96 | break; | ||
1027 | 97 | case Modem::SimStatus::locked: | ||
1028 | 98 | case Modem::SimStatus::permanentlyLocked: | ||
1029 | 99 | m_infoItem->setStatusIcon("simcard-locked"); | ||
1030 | 100 | m_infoItem->setStatusText(_("SIM Locked")); | ||
1031 | 101 | m_infoItem->setLocked(true); | ||
1032 | 102 | m_infoItem->setRoaming(false); | ||
1033 | 103 | break; | ||
1034 | 104 | case Modem::SimStatus::ready: | ||
1035 | 105 | m_infoItem->setLocked(false); | ||
1036 | 106 | m_infoItem->setRoaming(false); | ||
1037 | 107 | |||
1038 | 108 | if (m_modem->online().get()) { | ||
1039 | 109 | switch (m_modem->status().get()) { | ||
1040 | 110 | case org::ofono::Interface::NetworkRegistration::Status::unregistered: | ||
1041 | 111 | m_infoItem->setStatusIcon("gsm-3g-disabled"); | ||
1042 | 112 | m_infoItem->setStatusText(_("Unregistered")); | ||
1043 | 113 | break; | ||
1044 | 114 | case org::ofono::Interface::NetworkRegistration::Status::unknown: | ||
1045 | 115 | m_infoItem->setStatusIcon("gsm-3g-disabled"); | ||
1046 | 116 | m_infoItem->setStatusText(_("Unknown")); | ||
1047 | 117 | break; | ||
1048 | 118 | case org::ofono::Interface::NetworkRegistration::Status::denied: | ||
1049 | 119 | m_infoItem->setStatusIcon("gsm-3g-disabled"); | ||
1050 | 120 | m_infoItem->setStatusText(_("Denied")); | ||
1051 | 121 | break; | ||
1052 | 122 | case org::ofono::Interface::NetworkRegistration::Status::searching: | ||
1053 | 123 | m_infoItem->setStatusIcon("gsm-3g-disabled"); | ||
1054 | 124 | m_infoItem->setStatusText(_("Searching")); | ||
1055 | 125 | break; | ||
1056 | 126 | case org::ofono::Interface::NetworkRegistration::Status::roaming: | ||
1057 | 127 | m_infoItem->setRoaming(true); | ||
1058 | 128 | /* fallthrough */ | ||
1059 | 129 | case org::ofono::Interface::NetworkRegistration::Status::registered: | ||
1060 | 130 | if (m_modem->strength().get() != 0) { | ||
1061 | 131 | m_infoItem->setStatusIcon(Modem::strengthIcon(m_modem->strength().get())); | ||
1062 | 132 | m_infoItem->setStatusText(m_modem->operatorName()); | ||
1063 | 133 | } else { | ||
1064 | 134 | m_infoItem->setStatusIcon("gsm-3g-no-service"); | ||
1065 | 135 | m_infoItem->setStatusText(_("No Signal")); | ||
1066 | 136 | } | ||
1067 | 137 | break; | ||
1068 | 138 | } | ||
1069 | 139 | } else { | ||
1070 | 140 | m_infoItem->setStatusIcon("gsm-3g-disabled"); | ||
1071 | 141 | m_infoItem->setStatusText(_("Offline")); | ||
1072 | 79 | } | 142 | } |
1073 | 143 | |||
1074 | 144 | break; | ||
1075 | 80 | } | 145 | } |
1076 | 81 | } | 146 | } |
1077 | 82 | 147 | ||
1078 | @@ -99,3 +164,9 @@ | |||
1079 | 99 | { | 164 | { |
1080 | 100 | return d->m_menu; | 165 | return d->m_menu; |
1081 | 101 | } | 166 | } |
1082 | 167 | |||
1083 | 168 | void | ||
1084 | 169 | WwanLinkItem::showSimIdentifier(bool value) | ||
1085 | 170 | { | ||
1086 | 171 | d->m_showIdentifier.set(value); | ||
1087 | 172 | } | ||
1088 | 102 | 173 | ||
1089 | === modified file 'network/wwan-link-item.h' | |||
1090 | --- network/wwan-link-item.h 2014-04-23 13:18:25 +0000 | |||
1091 | +++ network/wwan-link-item.h 2014-08-07 11:23:41 +0000 | |||
1092 | @@ -37,6 +37,8 @@ | |||
1093 | 37 | // from Section | 37 | // from Section |
1094 | 38 | virtual ActionGroup::Ptr actionGroup(); | 38 | virtual ActionGroup::Ptr actionGroup(); |
1095 | 39 | virtual MenuModel::Ptr menuModel(); | 39 | virtual MenuModel::Ptr menuModel(); |
1096 | 40 | |||
1097 | 41 | void showSimIdentifier(bool value); | ||
1098 | 40 | }; | 42 | }; |
1099 | 41 | 43 | ||
1100 | 42 | #endif // WWAN_LINK_ITEM_H | 44 | #endif // WWAN_LINK_ITEM_H |
1101 | 43 | 45 | ||
1102 | === modified file 'network/wwan-section.cpp' | |||
1103 | --- network/wwan-section.cpp 2014-05-16 12:38:53 +0000 | |||
1104 | +++ network/wwan-section.cpp 2014-08-07 11:23:41 +0000 | |||
1105 | @@ -92,8 +92,6 @@ | |||
1106 | 92 | void | 92 | void |
1107 | 93 | WwanSection::Private::modemsChanged(const std::set<Modem::Ptr> &modems) | 93 | WwanSection::Private::modemsChanged(const std::set<Modem::Ptr> &modems) |
1108 | 94 | { | 94 | { |
1109 | 95 | /// @todo we have to address the correct ordering of the modems | ||
1110 | 96 | |||
1111 | 97 | std::set<Modem::Ptr> current; | 95 | std::set<Modem::Ptr> current; |
1112 | 98 | for (auto element : m_items) | 96 | for (auto element : m_items) |
1113 | 99 | current.insert(element.first); | 97 | current.insert(element.first); |
1114 | @@ -118,9 +116,31 @@ | |||
1115 | 118 | 116 | ||
1116 | 119 | for (auto modem : added) { | 117 | for (auto modem : added) { |
1117 | 120 | auto item = std::make_shared<WwanLinkItem>(modem, m_modemManager); | 118 | auto item = std::make_shared<WwanLinkItem>(modem, m_modemManager); |
1119 | 121 | m_linkMenuMerger->append(*item); | 119 | |
1120 | 120 | m_items.push_back(std::make_pair(modem, item)); | ||
1121 | 122 | m_actionGroupMerger->add(*item); | 121 | m_actionGroupMerger->add(*item); |
1123 | 123 | m_items.push_back(std::make_pair(modem, item)); | 122 | |
1124 | 123 | // for now just throw everything away and rebuild | ||
1125 | 124 | /// @todo add MenuMerger::insert() and ::find() | ||
1126 | 125 | m_linkMenuMerger->clear(); | ||
1127 | 126 | |||
1128 | 127 | auto compare = [](int lhs, int rhs ){ | ||
1129 | 128 | // make sure index() == -1 goes to the bottom of the menu | ||
1130 | 129 | if (lhs == -1 && rhs == -1) | ||
1131 | 130 | return false; | ||
1132 | 131 | if (lhs == -1) | ||
1133 | 132 | return false; | ||
1134 | 133 | if (rhs == -1) | ||
1135 | 134 | return true; | ||
1136 | 135 | return lhs < rhs; | ||
1137 | 136 | }; | ||
1138 | 137 | std::multimap<int, WwanLinkItem::Ptr, decltype(compare)> sorted(compare); | ||
1139 | 138 | |||
1140 | 139 | for (auto pair : m_items) { | ||
1141 | 140 | sorted.insert(std::make_pair(pair.first->index(), pair.second)); | ||
1142 | 141 | } | ||
1143 | 142 | for (auto pair : sorted) | ||
1144 | 143 | m_linkMenuMerger->append(*(pair.second)); | ||
1145 | 124 | } | 144 | } |
1146 | 125 | 145 | ||
1147 | 126 | if (modems.size() == 0) { | 146 | if (modems.size() == 0) { |
1148 | @@ -129,6 +149,14 @@ | |||
1149 | 129 | if (m_bottomMenu->find(*m_openCellularSettings) == m_bottomMenu->end()) | 149 | if (m_bottomMenu->find(*m_openCellularSettings) == m_bottomMenu->end()) |
1150 | 130 | m_bottomMenu->append(*m_openCellularSettings); | 150 | m_bottomMenu->append(*m_openCellularSettings); |
1151 | 131 | } | 151 | } |
1152 | 152 | |||
1153 | 153 | if (m_items.size() > 1) { | ||
1154 | 154 | for(auto i : m_items) | ||
1155 | 155 | i.second->showSimIdentifier(true); | ||
1156 | 156 | } else { | ||
1157 | 157 | for(auto i : m_items) | ||
1158 | 158 | i.second->showSimIdentifier(false); | ||
1159 | 159 | } | ||
1160 | 132 | } | 160 | } |
1161 | 133 | 161 | ||
1162 | 134 | WwanSection::WwanSection(ModemManager::Ptr modemManager) | 162 | WwanSection::WwanSection(ModemManager::Ptr modemManager) |
LGTM.