Merge lp:~unity-api-team/indicator-network/modeminfo into lp:indicator-network/14.10

Proposed by Antti Kaijanmäki
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
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://code.launchpad.net/~unity-api-team/unity8/modeminfo/+merge/225159
https://code.launchpad.net/~unity-api-team/unity8/default-indicator-page-loader-visible-fix/+merge/228943

silo: https://launchpad.net/~ci-train-ppa-service/+archive/ubuntu/landing-001

New indicator item that displays modem information and allows unlocking of a cellular modems.

Example of the different variations:
http://imgur.com/W52T6nV

Actual result when combined with the indicator:
http://imgur.com/XK0fEWt

To post a comment you must log in.
Revision history for this message
Pete Woods (pete-woods) wrote :

LGTM.

review: Approve
Revision history for this message
Charles Kerr (charlesk) wrote :

Tested on N4, seems to be working as advertised. :-)

review: Approve
Revision history for this message
Nick Dedekind (nick-dedekind) wrote :

On Mako

https://dl.dropboxusercontent.com/u/85539674/locked_sim/locked_sim1.png
https://dl.dropboxusercontent.com/u/85539674/locked_sim/locked_sim2.png
https://dl.dropboxusercontent.com/u/85539674/locked_sim/locked_sim3.png
https://dl.dropboxusercontent.com/u/85539674/locked_sim/locked_sim4.png
https://dl.dropboxusercontent.com/u/85539674/locked_sim/locked_sim5.png
https://dl.dropboxusercontent.com/u/85539674/locked_sim/locked_sim6.png
https://dl.dropboxusercontent.com/u/85539674/locked_sim/locked_sim7.png

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/ofono/scripts/list-modems output for each state.
1) http://paste.ubuntu.com/7969273/
2) http://paste.ubuntu.com/7969275/
3) http://paste.ubuntu.com/7969276/
4) http://paste.ubuntu.com/7969279/
5) http://paste.ubuntu.com/7969280/
6) can't reproduce
7) http://paste.ubuntu.com/7969282/

review: Needs Fixing
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
360. By Antti Kaijanmäki

Forgot to bind to the modem online property in the panel icon side.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
361. By Antti Kaijanmäki

add default sim identifiers and make sure modems are ordered correctly in the menu.

Revision history for this message
Antti Kaijanmäki (kaijanmaki) wrote :

> On Mako
>
> https://dl.dropboxusercontent.com/u/85539674/locked_sim/locked_sim1.png
> https://dl.dropboxusercontent.com/u/85539674/locked_sim/locked_sim2.png
> https://dl.dropboxusercontent.com/u/85539674/locked_sim/locked_sim3.png
> https://dl.dropboxusercontent.com/u/85539674/locked_sim/locked_sim4.png
> https://dl.dropboxusercontent.com/u/85539674/locked_sim/locked_sim5.png
> https://dl.dropboxusercontent.com/u/85539674/locked_sim/locked_sim6.png
> https://dl.dropboxusercontent.com/u/85539674/locked_sim/locked_sim7.png
>
> 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.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
363. By Antti Kaijanmäki

make sure cellular icons are ordered correctly in the panel.

Revision history for this message
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 :)

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
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://dl.dropboxusercontent.com/u/85539674/locked_sim/locked_sim8.png

After restarting indicator-network.
https://dl.dropboxusercontent.com/u/85539674/locked_sim/locked_sim9.png

The state text should never be empty. If it's in an unknown state, it should say "Unknown".

review: Needs Fixing
364. By Antti Kaijanmäki

Improve the panel modemTechIcon handling a bit on dual sim.

365. By Antti Kaijanmäki

Handle NetworkRegistration::Status::unknown better.

Revision history for this message
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://dl.dropboxusercontent.com/u/85539674/locked_sim/locked_sim8.png

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://dl.dropboxusercontent.com/u/85539674/locked_sim/locked_sim9.png
>
> The state text should never be empty. If it's in an unknown state, it should
> say "Unknown".

Agreed and fixed.

Revision history for this message
Pete Woods (pete-woods) wrote :

The last two changes look sensible to me.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'debian/control'
--- debian/control 2014-07-22 20:21:50 +0000
+++ debian/control 2014-08-07 11:23:41 +0000
@@ -41,7 +41,7 @@
41 ubuntu-mobile-icons (>= 13.04+13.10.20131014),41 ubuntu-mobile-icons (>= 13.04+13.10.20131014),
42# For apport hook42# For apport hook
43 python3-xdg,43 python3-xdg,
44 unity8 (>= 7.82),44 unity8 (>= 8.00+14.10.20140806),
45Conflicts: chewie,45Conflicts: chewie,
46 indicators-client-plugin-network,46 indicators-client-plugin-network,
47Description: Systems settings menu service - Network indicator47Description: Systems settings menu service - Network indicator
4848
=== modified file 'network/CMakeLists.txt'
--- network/CMakeLists.txt 2014-05-22 08:32:45 +0000
+++ network/CMakeLists.txt 2014-08-07 11:23:41 +0000
@@ -28,6 +28,7 @@
2828
29 menuitems/access-point-item.h29 menuitems/access-point-item.h
30 menuitems/item.h30 menuitems/item.h
31 menuitems/modem-info-item.cpp
31 menuitems/section.h32 menuitems/section.h
32 menuitems/switch-item.h33 menuitems/switch-item.h
33 menuitems/text-item.h34 menuitems/text-item.h
3435
=== added file 'network/menuitems/modem-info-item.cpp'
--- network/menuitems/modem-info-item.cpp 1970-01-01 00:00:00 +0000
+++ network/menuitems/modem-info-item.cpp 2014-08-07 11:23:41 +0000
@@ -0,0 +1,148 @@
1/*
2 * Copyright (C) 2014 Canonical, Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3, as published
6 * by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranties of
10 * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
11 * PURPOSE. See the GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License along
14 * with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authors:
17 * Antti Kaijanmäki <antti.kaijanmaki@canonical.com>
18 */
19
20#include "modem-info-item.h"
21
22class ModemInfoItem::Private
23{
24public:
25 core::Signal<void> m_unlock;
26
27 std::vector<core::Connection> m_connections;
28
29 Action::Ptr m_actionStatusLabel;
30 Action::Ptr m_actionStatusIcon;
31 Action::Ptr m_actionConnectivityIcon;
32 Action::Ptr m_actionSimIdentifier;
33 Action::Ptr m_actionRoaming;
34 Action::Ptr m_actionLocked;
35
36 MenuItem::Ptr m_item;
37};
38
39ModemInfoItem::ModemInfoItem()
40{
41 d.reset(new Private);
42
43 static int id = 0;
44 ++id; /// @todo guard me.
45
46 std::string actionIdBase = "modem." + std::to_string(id);
47
48 std::string statusLabelActionId = actionIdBase + "::status-label";
49 std::string statusIconActionId = actionIdBase + "::status-icon";
50 std::string connectivityIconActionId = actionIdBase + "::connectivity-icon";
51 std::string simIdentifierActionId = actionIdBase + "::sim-identifier-label";
52 std::string roamingActionId = actionIdBase + "::roaming";
53 std::string lockedActionId = actionIdBase + "::locked";
54
55 d->m_item = std::make_shared<MenuItem>();
56
57 d->m_item->setAttribute("x-canonical-type", TypedVariant<std::string>("com.canonical.indicator.network.modeminfoitem"));
58 d->m_item->setAttribute("x-canonical-modem-status-label-action", TypedVariant<std::string>("indicator." + statusLabelActionId));
59 d->m_item->setAttribute("x-canonical-modem-status-icon-action", TypedVariant<std::string>("indicator." + statusIconActionId));
60 d->m_item->setAttribute("x-canonical-modem-connectivity-icon-action", TypedVariant<std::string>("indicator." + connectivityIconActionId));
61 d->m_item->setAttribute("x-canonical-modem-sim-identifier-label-action", TypedVariant<std::string>("indicator." + simIdentifierActionId));
62 d->m_item->setAttribute("x-canonical-modem-roaming-action", TypedVariant<std::string>("indicator." + roamingActionId));
63 d->m_item->setAttribute("x-canonical-modem-locked-action", TypedVariant<std::string>("indicator." + lockedActionId));
64
65
66
67 d->m_actionStatusLabel = std::make_shared<Action>(statusLabelActionId,
68 nullptr,
69 TypedVariant<std::string>());
70 d->m_actionStatusIcon = std::make_shared<Action>(statusIconActionId,
71 nullptr,
72 TypedVariant<std::string>());
73 d->m_actionConnectivityIcon = std::make_shared<Action>(connectivityIconActionId,
74 nullptr,
75 TypedVariant<std::string>());
76 d->m_actionSimIdentifier = std::make_shared<Action>(simIdentifierActionId,
77 nullptr,
78 TypedVariant<std::string>());
79 d->m_actionRoaming = std::make_shared<Action>(roamingActionId,
80 nullptr,
81 TypedVariant<bool>(false));
82 d->m_actionLocked = std::make_shared<Action>(lockedActionId,
83 nullptr,
84 TypedVariant<bool>(false));
85 m_actionGroup->add(d->m_actionStatusLabel);
86 m_actionGroup->add(d->m_actionStatusIcon);
87 m_actionGroup->add(d->m_actionConnectivityIcon);
88 m_actionGroup->add(d->m_actionSimIdentifier);
89 m_actionGroup->add(d->m_actionRoaming);
90 m_actionGroup->add(d->m_actionLocked);
91
92 d->m_actionLocked->activated().connect([this](Variant){ d->m_unlock(); });
93}
94
95ModemInfoItem::~ModemInfoItem()
96{
97
98}
99
100void
101ModemInfoItem::setStatusIcon(const std::string &name)
102{
103 d->m_actionStatusIcon->setState(TypedVariant<std::string>(name));
104}
105
106void
107ModemInfoItem::setStatusText(const std::string &value)
108{
109 d->m_actionStatusLabel->setState(TypedVariant<std::string>(value));
110}
111
112void
113ModemInfoItem::setConnectivityIcon(const std::string &name)
114{
115 d->m_actionConnectivityIcon->setState(TypedVariant<std::string>(name));
116}
117
118void
119ModemInfoItem::setSimIdentifierText(const std::string &value)
120
121{
122 d->m_actionSimIdentifier->setState(TypedVariant<std::string>(value));
123}
124
125void
126ModemInfoItem::setLocked(bool value)
127{
128 d->m_actionLocked->setState(TypedVariant<bool>(value));
129}
130
131void
132ModemInfoItem::setRoaming(bool value)
133{
134 d->m_actionRoaming->setState(TypedVariant<bool>(value));
135}
136
137MenuItem::Ptr
138ModemInfoItem::menuItem()
139{
140 return d->m_item;
141}
142
143core::Signal<void> &
144ModemInfoItem::unlock()
145{
146 return d->m_unlock;
147}
148
0149
=== added file 'network/menuitems/modem-info-item.h'
--- network/menuitems/modem-info-item.h 1970-01-01 00:00:00 +0000
+++ network/menuitems/modem-info-item.h 2014-08-07 11:23:41 +0000
@@ -0,0 +1,56 @@
1/*
2 * Copyright (C) 2014 Canonical, Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3, as published
6 * by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranties of
10 * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
11 * PURPOSE. See the GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License along
14 * with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authors:
17 * Antti Kaijanmäki <antti.kaijanmaki@canonical.com>
18 */
19
20#ifndef MODEM_INFO_ITEM_H
21#define MODEM_INFO_ITEM_H
22
23#include "item.h"
24#include "menumodel-cpp/action.h"
25#include "menumodel-cpp/menu-item.h"
26#include "menumodel-cpp/gio-helpers/variant.h"
27
28#include <core/signal.h>
29
30#include <functional>
31#include <vector>
32
33class ModemInfoItem : public Item
34{
35 class Private;
36 std::unique_ptr<Private> d;
37
38public:
39 typedef std::shared_ptr<ModemInfoItem> Ptr;
40
41 ModemInfoItem();
42 virtual ~ModemInfoItem();
43
44 void setStatusIcon(const std::string &name);
45 void setStatusText(const std::string &value);
46 void setConnectivityIcon(const std::string &name);
47 void setSimIdentifierText(const std::string &value);
48 void setLocked(bool value);
49 void setRoaming(bool value);
50
51 virtual MenuItem::Ptr menuItem();
52
53 core::Signal<void> &unlock();
54};
55
56#endif // MODEM_INFO_ITEM_H
057
=== modified file 'network/menumodel-cpp/menu-merger.h'
--- network/menumodel-cpp/menu-merger.h 2014-04-23 13:18:25 +0000
+++ network/menumodel-cpp/menu-merger.h 2014-08-07 11:23:41 +0000
@@ -127,7 +127,14 @@
127 m_startPositions.erase(*menu);127 m_startPositions.erase(*menu);
128 m_gmodelToMenu.erase(*menu);128 m_gmodelToMenu.erase(*menu);
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());
130 }130 }
131
132 void clear()
133 {
134 std::vector<MenuModel::Ptr> tmp = m_menus;
135 for (auto menu : tmp)
136 remove(menu);
137 }
131138
132 operator GMenuModel*() { return G_MENU_MODEL(m_gmenu.get()); }139 operator GMenuModel*() { return G_MENU_MODEL(m_gmenu.get()); }
133};140};
134141
=== modified file 'network/modem.cpp'
--- network/modem.cpp 2014-05-02 14:05:12 +0000
+++ network/modem.cpp 2014-08-07 11:23:41 +0000
@@ -22,49 +22,91 @@
22class Modem::Private22class Modem::Private
23{23{
24public:24public:
25 core::Property<bool> m_online;
26
25 org::ofono::Interface::Modem::Ptr m_ofonoModem;27 org::ofono::Interface::Modem::Ptr m_ofonoModem;
26 core::Property<Modem::SimStatus> m_simStatus;28 core::Property<Modem::SimStatus> m_simStatus;
27 core::Property<Modem::PinType> m_requiredPin;29 core::Property<Modem::PinType> m_requiredPin;
28 core::Property<std::map<Modem::PinType, std::uint8_t>> m_retries;30 core::Property<std::map<Modem::PinType, std::uint8_t>> m_retries;
29 core::Property<std::string> m_subscriberIdentity;
3031
31 core::Property<std::string> m_operatorName;32 core::Property<std::string> m_operatorName;
32 core::Property<org::ofono::Interface::NetworkRegistration::Status> m_status;33 core::Property<org::ofono::Interface::NetworkRegistration::Status> m_status;
33 core::Property<std::int8_t> m_strength;34 core::Property<std::int8_t> m_strength;
34 core::Property<org::ofono::Interface::NetworkRegistration::Technology> m_technology;35 core::Property<org::ofono::Interface::NetworkRegistration::Technology> m_technology;
3536
37 core::Property<std::string> m_simIdentifier;
38 int m_index = -1;
39
36 void networkRegistrationChanged(org::ofono::Interface::NetworkRegistration::Ptr netreg);40 void networkRegistrationChanged(org::ofono::Interface::NetworkRegistration::Ptr netreg);
37 void simManagerChanged(org::ofono::Interface::SimManager::Ptr simmgr);41 void simManagerChanged(org::ofono::Interface::SimManager::Ptr simmgr);
3842
39 void simPresentChanged(bool value);43 void update();
40 void pinRequiredChanged(org::ofono::Interface::SimManager::PinType pin);
41 void retriesChanged(std::map<org::ofono::Interface::SimManager::PinType, std::uint8_t> retries) ;
42};44};
4345
44void46void
45Modem::Private::networkRegistrationChanged(org::ofono::Interface::NetworkRegistration::Ptr netreg)47Modem::Private::update()
46{48{
49 auto simmgr = m_ofonoModem->simManager.get();
50 if (simmgr) {
51 // update requiredPin
52 switch(simmgr->pinRequired.get())
53 {
54 case org::ofono::Interface::SimManager::PinType::none:
55 m_requiredPin.set(PinType::none);
56 break;
57 case org::ofono::Interface::SimManager::PinType::pin:
58 m_requiredPin.set(PinType::pin);
59 break;
60 case org::ofono::Interface::SimManager::PinType::puk:
61 m_requiredPin.set(PinType::puk);
62 break;
63 default:
64 throw std::runtime_error("Ofono requires a PIN we have not been prepared to handle (" +
65 org::ofono::Interface::SimManager::pin2str(simmgr->pinRequired.get()) +
66 "). Bailing out.");
67 }
68
69 // update retries
70 std::map<Modem::PinType, std::uint8_t> tmp;
71 for (auto element : simmgr->retries.get()) {
72 switch(element.first) {
73 case org::ofono::Interface::SimManager::PinType::pin:
74 tmp[Modem::PinType::pin] = element.second;
75 break;
76 case org::ofono::Interface::SimManager::PinType::puk:
77 tmp[Modem::PinType::puk] = element.second;
78 break;
79 default:
80 // don't care
81 break;
82 }
83 }
84 m_retries.set(tmp);
85
86 // update simStatus
87 if (!simmgr->present.get()) {
88 m_simStatus.set(SimStatus::missing);
89 } else if (m_requiredPin == PinType::none){
90 m_simStatus.set(SimStatus::ready);
91 } else {
92 if (m_retries->count(PinType::puk) != 0 && m_retries->at(PinType::puk) == 0)
93 m_simStatus.set(SimStatus::permanentlyLocked);
94 else
95 m_simStatus.set(SimStatus::locked);
96 }
97
98 } else {
99 m_requiredPin.set(PinType::none);
100 m_retries.set({});
101 m_simStatus.set(SimStatus::missing);
102 }
103
104 auto netreg = m_ofonoModem->networkRegistration.get();
47 if (netreg) {105 if (netreg) {
48 netreg->operatorName.changed().connect([this](std::string value){
49 m_operatorName.set(value);
50 });
51 m_operatorName.set(netreg->operatorName.get());106 m_operatorName.set(netreg->operatorName.get());
52
53 netreg->status.changed().connect([this](org::ofono::Interface::NetworkRegistration::Status value){
54 m_status.set(value);
55 });
56 m_status.set(netreg->status.get());107 m_status.set(netreg->status.get());
57
58 netreg->strength.changed().connect([this](std::int8_t value){
59 m_strength.set(value);
60 });
61 m_strength.set(netreg->strength.get());108 m_strength.set(netreg->strength.get());
62
63 netreg->technology.changed().connect([this](org::ofono::Interface::NetworkRegistration::Technology value){
64 m_technology.set(value);
65 });
66 m_technology.set(netreg->technology.get());109 m_technology.set(netreg->technology.get());
67
68 } else {110 } else {
69 m_operatorName.set("");111 m_operatorName.set("");
70 m_status.set(org::ofono::Interface::NetworkRegistration::Status::unknown);112 m_status.set(org::ofono::Interface::NetworkRegistration::Status::unknown);
@@ -73,96 +115,58 @@
73 }115 }
74}116}
75117
118void
119Modem::Private::networkRegistrationChanged(org::ofono::Interface::NetworkRegistration::Ptr netreg)
120{
121 if (netreg) {
122 netreg->operatorName.changed().connect(std::bind(&Private::update, this));
123 netreg->status.changed().connect(std::bind(&Private::update, this));
124 netreg->strength.changed().connect(std::bind(&Private::update, this));
125 netreg->technology.changed().connect(std::bind(&Private::update, this));
126 }
127 update();
128}
129
76130
77void131void
78Modem::Private::simManagerChanged(org::ofono::Interface::SimManager::Ptr simmgr)132Modem::Private::simManagerChanged(org::ofono::Interface::SimManager::Ptr simmgr)
79{133{
80 if (simmgr) {134 if (simmgr) {
81 simmgr->present.changed().connect(std::bind(&Private::simPresentChanged, this, std::placeholders::_1));135 simmgr->present.changed().connect(std::bind(&Private::update, this));
82 simPresentChanged(simmgr->present.get());136 simmgr->pinRequired.changed().connect(std::bind(&Private::update, this));
83137 simmgr->retries.changed().connect(std::bind(&Private::update, this));
84 simmgr->pinRequired.changed().connect(std::bind(&Private::pinRequiredChanged, this, std::placeholders::_1));138 }
85 pinRequiredChanged(simmgr->pinRequired.get());139 update();
86140}
87 simmgr->retries.changed().connect(std::bind(&Private::retriesChanged, this, std::placeholders::_1));
88 retriesChanged(simmgr->retries.get());
89
90 /// @todo subscriberIdentity
91
92 } else {
93 m_simStatus.set(SimStatus::offline);
94 m_requiredPin.set(PinType::none);
95 m_retries.set({});
96 }
97}
98
99void
100Modem::Private::pinRequiredChanged(org::ofono::Interface::SimManager::PinType pin)
101{
102 switch(pin)
103 {
104 case org::ofono::Interface::SimManager::PinType::none:
105 m_requiredPin.set(PinType::none);
106 m_simStatus.set(SimStatus::ready);
107 break;
108 case org::ofono::Interface::SimManager::PinType::pin:
109 m_requiredPin.set(PinType::pin);
110 m_simStatus.set(SimStatus::locked);
111 break;
112 case org::ofono::Interface::SimManager::PinType::puk:
113 m_requiredPin.set(PinType::puk);
114 m_simStatus.set(SimStatus::locked);
115 break;
116 default:
117 throw std::runtime_error("Ofono requires a PIN we have not been prepared to handle (" +
118 org::ofono::Interface::SimManager::pin2str(pin) +
119 "). Bailing out.");
120 }
121}
122
123void
124Modem::Private::retriesChanged(std::map<org::ofono::Interface::SimManager::PinType, std::uint8_t> retries)
125{
126 std::map<Modem::PinType, std::uint8_t> tmp;
127 for (auto element : retries) {
128 switch(element.first) {
129 case org::ofono::Interface::SimManager::PinType::pin:
130 tmp[Modem::PinType::pin] = element.second;
131 break;
132 case org::ofono::Interface::SimManager::PinType::puk:
133 tmp[Modem::PinType::puk] = element.second;
134 break;
135 default:
136 // don't care
137 break;
138 }
139 }
140 m_retries.set(tmp);
141}
142
143void
144Modem::Private::simPresentChanged(bool value)
145{
146 if (!value) {
147 m_simStatus.set(SimStatus::missing);
148 }
149}
150
151141
152Modem::Modem(org::ofono::Interface::Modem::Ptr ofonoModem)142Modem::Modem(org::ofono::Interface::Modem::Ptr ofonoModem)
153{143{
154 d.reset(new Private);144 d.reset(new Private);
155 d->m_ofonoModem = ofonoModem;145 d->m_ofonoModem = ofonoModem;
156146
147 d->m_online.set(d->m_ofonoModem->online.get());
148 d->m_ofonoModem->online.changed().connect([this](bool value){
149 d->m_online.set(value);
150 });
151
157 d->simManagerChanged(d->m_ofonoModem->simManager.get());152 d->simManagerChanged(d->m_ofonoModem->simManager.get());
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));
159 d->simManagerChanged(value);
160 });
161154
162 d->networkRegistrationChanged(d->m_ofonoModem->networkRegistration.get());155 d->networkRegistrationChanged(d->m_ofonoModem->networkRegistration.get());
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));
164 d->networkRegistrationChanged(value);157
165 });158 /// @todo hook up with system-settings to allow changing the identifier.
159 /// for now just provide the defaults
160 const auto path = ofonoModem->object->path().as_string();
161 if (path == "/ril_0") {
162 d->m_simIdentifier.set("SIM 1");
163 d->m_index = 1;
164 } else if (path == "/ril_1") {
165 d->m_simIdentifier.set("SIM 2");
166 d->m_index = 2;
167 } else {
168 d->m_simIdentifier.set(path);
169 }
166}170}
167171
168Modem::~Modem()172Modem::~Modem()
@@ -240,6 +244,12 @@
240 throw std::logic_error("code should not be reached.");244 throw std::logic_error("code should not be reached.");
241}245}
242246
247const core::Property<bool> &
248Modem::online()
249{
250 return d->m_online;
251}
252
243const core::Property<Modem::SimStatus> &253const core::Property<Modem::SimStatus> &
244Modem::simStatus()254Modem::simStatus()
245{255{
@@ -259,12 +269,6 @@
259}269}
260270
261const core::Property<std::string> &271const core::Property<std::string> &
262Modem::subscriberIdentity()
263{
264 return d->m_subscriberIdentity;
265}
266
267const core::Property<std::string> &
268Modem::operatorName()272Modem::operatorName()
269{273{
270 return d->m_operatorName;274 return d->m_operatorName;
@@ -287,3 +291,15 @@
287{291{
288 return d->m_technology;292 return d->m_technology;
289}293}
294const core::Property<std::string> &
295Modem::simIdentifier()
296{
297 return d->m_simIdentifier;
298}
299
300int
301Modem::index()
302{
303 return d->m_index;
304}
305
290306
=== modified file 'network/modem.h'
--- network/modem.h 2014-04-23 13:18:25 +0000
+++ network/modem.h 2014-08-07 11:23:41 +0000
@@ -42,7 +42,6 @@
4242
43 enum class SimStatus43 enum class SimStatus
44 {44 {
45 offline,
46 missing,45 missing,
47 error,46 error,
48 locked,47 locked,
@@ -70,17 +69,56 @@
70 const std::string &oldPin,69 const std::string &oldPin,
71 const std::string &newPin);70 const std::string &newPin);
7271
72 const core::Property<bool> &online();
7373
74 const core::Property<SimStatus> &simStatus();74 const core::Property<SimStatus> &simStatus();
75 const core::Property<PinType> &requiredPin();75 const core::Property<PinType> &requiredPin();
76 const core::Property<std::map<PinType, std::uint8_t>> &retries();76 const core::Property<std::map<PinType, std::uint8_t>> &retries();
77 const core::Property<std::string> &subscriberIdentity();
7877
79 const core::Property<std::string> &operatorName();78 const core::Property<std::string> &operatorName();
80 const core::Property<org::ofono::Interface::NetworkRegistration::Status> &status();79 const core::Property<org::ofono::Interface::NetworkRegistration::Status> &status();
81 const core::Property<std::int8_t> &strength();80 const core::Property<std::int8_t> &strength();
82 const core::Property<org::ofono::Interface::NetworkRegistration::Technology> &technology();81 const core::Property<org::ofono::Interface::NetworkRegistration::Technology> &technology();
8382
83 const core::Property<std::string> &simIdentifier();
84 int index();
85
86 static const std::string strengthIcon(int8_t strength)
87 {
88 /* Using same values as used by Android, not linear (LP: #1329945)*/
89 if (strength >= 39)
90 return "gsm-3g-full";
91 else if (strength >= 26)
92 return "gsm-3g-high";
93 else if (strength >= 16)
94 return "gsm-3g-medium";
95 else if (strength >= 6)
96 return "gsm-3g-low";
97 else
98 return "gsm-3g-none";
99 }
100
101 static const std::string technologyIcon(org::ofono::Interface::NetworkRegistration::Technology tech)
102 {
103 switch (tech){
104 case org::ofono::Interface::NetworkRegistration::Technology::notAvailable:
105 case org::ofono::Interface::NetworkRegistration::Technology::gsm:
106 return "network-cellular-pre-edge";
107 case org::ofono::Interface::NetworkRegistration::Technology::edge:
108 return "network-cellular-edge";
109 case org::ofono::Interface::NetworkRegistration::Technology::umts:
110 return "network-cellular-3g";
111 case org::ofono::Interface::NetworkRegistration::Technology::hspa:
112 return "network-cellular-hspa";
113 /// @todo oFono can't tell us about hspa+ yet
114 //case org::ofono::Interface::NetworkRegistration::Technology::hspaplus:
115 // break;
116 case org::ofono::Interface::NetworkRegistration::Technology::lte:
117 return "network-cellular-lte";
118 }
119 // shouldn't be reached
120 return "";
121 }
84};122};
85123
86#endif124#endif
87125
=== modified file 'network/root-state.cpp'
--- network/root-state.cpp 2014-06-17 12:27:05 +0000
+++ network/root-state.cpp 2014-08-07 11:23:41 +0000
@@ -33,7 +33,6 @@
33 ModemManager::Ptr m_modemManager;33 ModemManager::Ptr m_modemManager;
34 core::Property<Variant> m_state;34 core::Property<Variant> m_state;
3535
36 std::string m_preLabel;
37 std::string m_label;36 std::string m_label;
3837
39 /// @todo multiple adapters etc..38 /// @todo multiple adapters etc..
@@ -41,15 +40,11 @@
4140
42 std::string m_modemTechIcon;41 std::string m_modemTechIcon;
4342
44 bool m_inFlightMode;
45 bool m_roaming;
46
47 std::map<Modem::Ptr, std::string> m_cellularIcons;43 std::map<Modem::Ptr, std::string> m_cellularIcons;
4844
49 Private() = delete;45 Private() = delete;
50 Private(std::shared_ptr<networking::Manager> manager, ModemManager::Ptr modemManager);46 Private(std::shared_ptr<networking::Manager> manager, ModemManager::Ptr modemManager);
5147
52 void flightModeChanged(networking::Manager::FlightModeStatus status);
53 void modemsChanged(const std::set<Modem::Ptr> &modems);48 void modemsChanged(const std::set<Modem::Ptr> &modems);
5449
55 void updateModem(Modem::WeakPtr weakModem);50 void updateModem(Modem::WeakPtr weakModem);
@@ -62,39 +57,23 @@
6257
63RootState::Private::Private(std::shared_ptr<networking::Manager> manager, ModemManager::Ptr modemManager)58RootState::Private::Private(std::shared_ptr<networking::Manager> manager, ModemManager::Ptr modemManager)
64 : m_manager{manager},59 : m_manager{manager},
65 m_modemManager{modemManager},60 m_modemManager{modemManager}
66 m_roaming{false}
67{ 61{
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));
69 flightModeChanged(m_manager->flightMode().get());
7063
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));
72 modemsChanged(m_modemManager->modems().get());65 modemsChanged(m_modemManager->modems().get());
7366
74 m_manager->status().changed().connect(std::bind(&Private::updateNetworkingIcon, this));67 m_manager->status().changed().connect(std::bind(&Private::updateNetworkingIcon, this));
75 m_manager->links().changed().connect(std::bind(&Private::updateNetworkingIcon, this));68 m_manager->links().changed().connect(std::bind(&Private::updateNetworkingIcon, this));
69
70 // will also call updateRootState()
76 updateNetworkingIcon();71 updateNetworkingIcon();
77}72}
7873
79void74void
80RootState::Private::flightModeChanged(networking::Manager::FlightModeStatus status)
81{
82 switch(status) {
83 case networking::Manager::FlightModeStatus::off:
84 m_inFlightMode = false;
85 break;
86 case networking::Manager::FlightModeStatus::on:
87 m_inFlightMode = true;
88 break;
89 }
90 updateRootState();
91}
92
93void
94RootState::Private::modemsChanged(const std::set<Modem::Ptr> &modems)75RootState::Private::modemsChanged(const std::set<Modem::Ptr> &modems)
95{76{
96 /// @todo we have to address the correct ordering of the modems
97
98 std::set<Modem::Ptr> current;77 std::set<Modem::Ptr> current;
99 for (auto element : m_cellularIcons)78 for (auto element : m_cellularIcons)
100 current.insert(element.first);79 current.insert(element.first);
@@ -112,6 +91,7 @@
112 m_cellularIcons.erase(modem);91 m_cellularIcons.erase(modem);
11392
114 for (auto modem : added) {93 for (auto modem : added) {
94 modem->online().changed().connect(std::bind(&Private::updateModem, this, Modem::WeakPtr(modem)));
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)));
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)));
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)));
@@ -129,90 +109,56 @@
129 return;109 return;
130 }110 }
131111
132 /// @todo multisim for all of these
133 m_preLabel.clear();
134 m_roaming = false;
135 m_modemTechIcon.clear();112 m_modemTechIcon.clear();
136
137 m_cellularIcons[modem] = "";113 m_cellularIcons[modem] = "";
138114
115 if (!modem->online().get()) {
116 // modem offline, nothing to show
117 updateRootState();
118 return;
119 }
139120
140 switch(modem->simStatus().get()) {121 switch(modem->simStatus().get()) {
141 case Modem::SimStatus::offline:
142 /// @todo show something.
143 break;
144 case Modem::SimStatus::missing:122 case Modem::SimStatus::missing:
145 m_preLabel = _("No SIM");123 // no need to show anything in the panel
146 break;124 break;
147 case Modem::SimStatus::error:125 case Modem::SimStatus::error:
148 m_preLabel = _("SIM Error");126 m_cellularIcons[modem] = "simcard-error";
149 break;127 break;
150 case Modem::SimStatus::locked:128 case Modem::SimStatus::locked:
151 case Modem::SimStatus::permanentlyLocked:129 case Modem::SimStatus::permanentlyLocked:
152 /// @todo handle perm blocked somehow130 m_cellularIcons[modem] = "simcard-locked";
153 m_preLabel = _("SIM Locked");
154 break;131 break;
155 case Modem::SimStatus::ready:132 case Modem::SimStatus::ready:
156 {133 {
157 switch (modem->status().get()) {134 switch (modem->status().get()) {
158 case org::ofono::Interface::NetworkRegistration::Status::unregistered:135 case org::ofono::Interface::NetworkRegistration::Status::unregistered:
159 /// @todo show something?
160 break;
161 case org::ofono::Interface::NetworkRegistration::Status::denied:
162 /// @todo maybe show something like "Denied" ?
163 m_preLabel = _("No Signal");
164 break;
165 case org::ofono::Interface::NetworkRegistration::Status::unknown:136 case org::ofono::Interface::NetworkRegistration::Status::unknown:
166 case org::ofono::Interface::NetworkRegistration::Status::searching:137 case org::ofono::Interface::NetworkRegistration::Status::searching:
138 m_cellularIcons[modem] = "gsm-3g-disabled";
139 break;
140 case org::ofono::Interface::NetworkRegistration::Status::denied:
141 /// @todo we might need network-error for this
142 m_cellularIcons[modem] = "gsm-3g-disabled";
143 break;
167 case org::ofono::Interface::NetworkRegistration::Status::registered:144 case org::ofono::Interface::NetworkRegistration::Status::registered:
168 /// @todo show something?
169 break;
170 case org::ofono::Interface::NetworkRegistration::Status::roaming:145 case org::ofono::Interface::NetworkRegistration::Status::roaming:
171 /// @todo multisim146 if (modem->strength().get() != 0) {
172 m_roaming = true;147 m_cellularIcons[modem] = Modem::strengthIcon(modem->strength().get());
173 break;148 /// @todo need to revise this once the modems are part of the connectivity-api
174 }149 /// this might get us wrong results on dual-sim
175150 if (modem->index() == 1) {
176 auto strength = modem->strength().get();151 m_modemTechIcon = Modem::technologyIcon(modem->technology().get());
177 /* Using same values as used by Android, not linear (LP: #1329945)*/152 }
178 if (strength >= 39)153 } else {
179 m_cellularIcons[modem] = "gsm-3g-full";154 m_cellularIcons[modem] = "gsm-3g-no-service";
180 else if (strength >= 26)155
181 m_cellularIcons[modem] = "gsm-3g-high";156 }
182 else if (strength >= 16)157
183 m_cellularIcons[modem] = "gsm-3g-medium";158 // we might have changed the modem tech icon which affects the networkingIcon.
184 else if (strength >= 6)159 updateNetworkingIcon();
185 m_cellularIcons[modem] = "gsm-3g-low";160 break;
186 else161 }
187 m_cellularIcons[modem] = "gsm-3g-none";
188
189 switch (modem->technology().get()){
190 case org::ofono::Interface::NetworkRegistration::Technology::notAvailable:
191 /// @todo check this..
192 // "network-cellular-pre-edge"
193 // a11ydesc = _("Network (cellular, %s)").printf(current_protocol)
194 break;
195 case org::ofono::Interface::NetworkRegistration::Technology::gsm:
196 m_modemTechIcon = "network-cellular-pre-edge";
197 break;
198 case org::ofono::Interface::NetworkRegistration::Technology::edge:
199 m_modemTechIcon = "network-cellular-edge";
200 break;
201 case org::ofono::Interface::NetworkRegistration::Technology::umts:
202 m_modemTechIcon = "network-cellular-3g";
203 break;
204 case org::ofono::Interface::NetworkRegistration::Technology::hspa:
205 m_modemTechIcon = "network-cellular-hspa";
206 break;
207 /// @todo oFono can't tell us about hspa+ yet
208 //case org::ofono::Interface::NetworkRegistration::Technology::hspaplus:
209 // break;
210 case org::ofono::Interface::NetworkRegistration::Technology::lte:
211 m_modemTechIcon = "network-cellular-lte";
212 break;
213 }
214 // we might have changed the modem tech icon which affects the networkingIcon.
215 updateNetworkingIcon();
216 break;162 break;
217 }}163 }}
218164
@@ -241,8 +187,12 @@
241187
242 auto wifiLink = std::dynamic_pointer_cast<networking::wifi::Link>(link);188 auto wifiLink = std::dynamic_pointer_cast<networking::wifi::Link>(link);
243189
244 int strength = wifiLink->activeAccessPoint().get()->strength().get();190 int strength = -1;
245 bool secured = wifiLink->activeAccessPoint().get()->secured();191 bool secured = false;
192 if (wifiLink->activeAccessPoint().get()) {
193 strength = wifiLink->activeAccessPoint().get()->strength().get();
194 secured = wifiLink->activeAccessPoint().get()->secured();
195 }
246196
247 /// @todo deal with a11ydesc197 /// @todo deal with a11ydesc
248// gchar *a11ydesc = nullptr;198// gchar *a11ydesc = nullptr;
@@ -305,15 +255,41 @@
305 std::vector<std::string> icons;255 std::vector<std::string> icons;
306 std::map<std::string, Variant> state;256 std::map<std::string, Variant> state;
307257
308 if (m_inFlightMode)258 switch(m_manager->flightMode().get()) {
259 case networking::Manager::FlightModeStatus::off:
260 break;
261 case networking::Manager::FlightModeStatus::on:
309 icons.push_back("airplane-mode");262 icons.push_back("airplane-mode");
310263 break;
311 for (auto icon : m_cellularIcons)264 }
312 if (!icon.second.empty())265
313 icons.push_back(icon.second);266 auto compare = [](int lhs, int rhs ){
314267 // make sure index() == -1 goes as leftmost cellular icon
315 if (m_roaming)268 if (lhs == -1 && rhs == -1)
316 icons.push_back("network-cellular-roaming");269 return false;
270 if (lhs == -1)
271 return false;
272 if (rhs == -1)
273 return true;
274 return lhs < rhs;
275 };
276 std::multimap<int, std::string, decltype(compare)> sorted(compare);
277
278 for (auto pair : m_cellularIcons) {
279 sorted.insert(std::make_pair(pair.first->index(), pair.second));
280 }
281 for (auto pair : sorted) {
282 if (!pair.second.empty())
283 icons.push_back(pair.second);
284 }
285
286 // if any of the modems is roaming, show the roaming icon
287 for (auto modem : m_modemManager->modems().get()) {
288 if (modem->status().get() == org::ofono::Interface::NetworkRegistration::Status::roaming) {
289 icons.push_back("network-cellular-roaming");
290 break;
291 }
292 }
317293
318 if (!m_networkingIcon.empty()) {294 if (!m_networkingIcon.empty()) {
319295
@@ -328,9 +304,6 @@
328 icons.push_back(m_networkingIcon);304 icons.push_back(m_networkingIcon);
329 }305 }
330306
331 if (!m_preLabel.empty())
332 state["pre-label"] = TypedVariant<std::string>(m_preLabel);
333
334 if (!m_label.empty())307 if (!m_label.empty())
335 state["label"] = TypedVariant<std::string>(m_label);308 state["label"] = TypedVariant<std::string>(m_label);
336309
337310
=== modified file 'network/service.h'
--- network/service.h 2014-05-16 19:39:19 +0000
+++ network/service.h 2014-08-07 11:23:41 +0000
@@ -112,18 +112,18 @@
112 m_phoneMenu->addSection(m_quickAccessSection);112 m_phoneMenu->addSection(m_quickAccessSection);
113 m_phoneGreeterMenu->addSection(m_quickAccessSection);113 m_phoneGreeterMenu->addSection(m_quickAccessSection);
114114
115 m_wwanSection = std::make_shared<WwanSection>(m_modemManager);
116 m_desktopMenu->addSection(m_wwanSection);
117 m_desktopGreeterMenu->addSection(m_wwanSection);
118 m_phoneMenu->addSection(m_wwanSection);
119 m_phoneGreeterMenu->addSection(m_wwanSection);
120
115 m_wifiSection = std::make_shared<WifiSection>(m_manager);121 m_wifiSection = std::make_shared<WifiSection>(m_manager);
116 m_desktopMenu->addSection(m_wifiSection);122 m_desktopMenu->addSection(m_wifiSection);
117 m_desktopGreeterMenu->addSection(m_wifiSection);123 m_desktopGreeterMenu->addSection(m_wifiSection);
118 m_phoneMenu->addSection(m_wifiSection);124 m_phoneMenu->addSection(m_wifiSection);
119 m_phoneGreeterMenu->addSection(m_wifiSection);125 m_phoneGreeterMenu->addSection(m_wifiSection);
120126
121 m_wwanSection = std::make_shared<WwanSection>(m_modemManager);
122 m_desktopMenu->addSection(m_wwanSection);
123 m_desktopGreeterMenu->addSection(m_wwanSection);
124 m_phoneMenu->addSection(m_wwanSection);
125 m_phoneGreeterMenu->addSection(m_wwanSection);
126
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()));
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()));
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()));
130130
=== modified file 'network/wwan-link-item.cpp'
--- network/wwan-link-item.cpp 2014-05-21 17:56:25 +0000
+++ network/wwan-link-item.cpp 2014-08-07 11:23:41 +0000
@@ -19,7 +19,7 @@
1919
20#include "wwan-link-item.h"20#include "wwan-link-item.h"
2121
22#include "menuitems/text-item.h"22#include "menuitems/modem-info-item.h"
2323
24#include "menumodel-cpp/menu.h"24#include "menumodel-cpp/menu.h"
2525
@@ -33,13 +33,14 @@
33 Modem::Ptr m_modem;33 Modem::Ptr m_modem;
34 ModemManager::Ptr m_modemManager;34 ModemManager::Ptr m_modemManager;
3535
36 TextItem::Ptr m_unlockSim;36 ModemInfoItem::Ptr m_infoItem;
37 bool m_wasLocked;37
38 core::Property<bool> m_showIdentifier;
3839
39 Private() = delete;40 Private() = delete;
40 Private(Modem::Ptr modem, ModemManager::Ptr modemManager);41 Private(Modem::Ptr modem, ModemManager::Ptr modemManager);
4142
42 void simStatusChanged(Modem::SimStatus status);43 void update();
43 void unlockSim();44 void unlockSim();
44};45};
4546
@@ -50,33 +51,97 @@
50 m_actionGroupMerger = std::make_shared<ActionGroupMerger>();51 m_actionGroupMerger = std::make_shared<ActionGroupMerger>();
51 m_menu = std::make_shared<Menu>();52 m_menu = std::make_shared<Menu>();
5253
53 /// @todo add stuff to control the link54 m_infoItem = std::make_shared<ModemInfoItem>();
5455 m_infoItem->unlock().connect(std::bind(&ModemManager::unlockModem, m_modemManager.get(), m_modem));
55 m_unlockSim = std::make_shared<TextItem>(_("Unlock SIM…"), "sim", "unlock");56
56 m_unlockSim->activated().connect(std::bind(&ModemManager::unlockModem, m_modemManager.get(), m_modem));57 m_actionGroupMerger->add(*m_infoItem);
5758 m_menu->append(*m_infoItem);
58 m_actionGroupMerger->add(*m_unlockSim);59
5960 m_showIdentifier.set(false);
60 m_wasLocked = false;61 m_showIdentifier.changed().connect(std::bind(&Private::update, this));
61 m_modem->simStatus().changed().connect(std::bind(&Private::simStatusChanged, this, std::placeholders::_1));62
62 simStatusChanged(m_modem->simStatus().get());63 m_modem->online().changed().connect(std::bind(&Private::update, this));
64 m_modem->simStatus().changed().connect(std::bind(&Private::update, this));
65 m_modem->operatorName().changed().connect(std::bind(&Private::update, this));
66 m_modem->status().changed().connect(std::bind(&Private::update, this));
67 m_modem->strength().changed().connect(std::bind(&Private::update, this));
68 m_modem->technology().changed().connect(std::bind(&Private::update, this));
69 m_modem->simIdentifier().changed().connect(std::bind(&Private::update, this));
70 update();
63}71}
6472
65void73void
66WwanLinkItem::Private::simStatusChanged(Modem::SimStatus status)74WwanLinkItem::Private::update()
67{75{
68 if (status == Modem::SimStatus::locked) {76 if (m_showIdentifier.get()) {
69 if (!m_wasLocked) {77 m_infoItem->setSimIdentifierText(m_modem->simIdentifier().get());
70 //m_actionGroupMerger->add(*m_unlockSim);
71 m_menu->append(*m_unlockSim);
72 m_wasLocked = true;
73 }
74 } else {78 } else {
75 if (m_wasLocked) {79 m_infoItem->setSimIdentifierText("");
76 //m_actionGroupMerger->remove(*m_unlockSim);80 }
77 m_menu->remove(m_menu->find(*m_unlockSim));81 /// @todo implement me.
78 m_wasLocked = false;82 m_infoItem->setConnectivityIcon("");
83
84 switch(m_modem->simStatus().get()) {
85 case Modem::SimStatus::missing:
86 m_infoItem->setStatusIcon("no-simcard");
87 m_infoItem->setStatusText(_("No SIM"));
88 m_infoItem->setLocked(false);
89 m_infoItem->setRoaming(false);
90 break;
91 case Modem::SimStatus::error:
92 m_infoItem->setStatusIcon("simcard-error");
93 m_infoItem->setStatusText(_("SIM Error"));
94 m_infoItem->setLocked(false);
95 m_infoItem->setRoaming(false);
96 break;
97 case Modem::SimStatus::locked:
98 case Modem::SimStatus::permanentlyLocked:
99 m_infoItem->setStatusIcon("simcard-locked");
100 m_infoItem->setStatusText(_("SIM Locked"));
101 m_infoItem->setLocked(true);
102 m_infoItem->setRoaming(false);
103 break;
104 case Modem::SimStatus::ready:
105 m_infoItem->setLocked(false);
106 m_infoItem->setRoaming(false);
107
108 if (m_modem->online().get()) {
109 switch (m_modem->status().get()) {
110 case org::ofono::Interface::NetworkRegistration::Status::unregistered:
111 m_infoItem->setStatusIcon("gsm-3g-disabled");
112 m_infoItem->setStatusText(_("Unregistered"));
113 break;
114 case org::ofono::Interface::NetworkRegistration::Status::unknown:
115 m_infoItem->setStatusIcon("gsm-3g-disabled");
116 m_infoItem->setStatusText(_("Unknown"));
117 break;
118 case org::ofono::Interface::NetworkRegistration::Status::denied:
119 m_infoItem->setStatusIcon("gsm-3g-disabled");
120 m_infoItem->setStatusText(_("Denied"));
121 break;
122 case org::ofono::Interface::NetworkRegistration::Status::searching:
123 m_infoItem->setStatusIcon("gsm-3g-disabled");
124 m_infoItem->setStatusText(_("Searching"));
125 break;
126 case org::ofono::Interface::NetworkRegistration::Status::roaming:
127 m_infoItem->setRoaming(true);
128 /* fallthrough */
129 case org::ofono::Interface::NetworkRegistration::Status::registered:
130 if (m_modem->strength().get() != 0) {
131 m_infoItem->setStatusIcon(Modem::strengthIcon(m_modem->strength().get()));
132 m_infoItem->setStatusText(m_modem->operatorName());
133 } else {
134 m_infoItem->setStatusIcon("gsm-3g-no-service");
135 m_infoItem->setStatusText(_("No Signal"));
136 }
137 break;
138 }
139 } else {
140 m_infoItem->setStatusIcon("gsm-3g-disabled");
141 m_infoItem->setStatusText(_("Offline"));
79 }142 }
143
144 break;
80 }145 }
81}146}
82147
@@ -99,3 +164,9 @@
99{164{
100 return d->m_menu;165 return d->m_menu;
101}166}
167
168void
169WwanLinkItem::showSimIdentifier(bool value)
170{
171 d->m_showIdentifier.set(value);
172}
102173
=== modified file 'network/wwan-link-item.h'
--- network/wwan-link-item.h 2014-04-23 13:18:25 +0000
+++ network/wwan-link-item.h 2014-08-07 11:23:41 +0000
@@ -37,6 +37,8 @@
37 // from Section37 // from Section
38 virtual ActionGroup::Ptr actionGroup();38 virtual ActionGroup::Ptr actionGroup();
39 virtual MenuModel::Ptr menuModel();39 virtual MenuModel::Ptr menuModel();
40
41 void showSimIdentifier(bool value);
40};42};
4143
42#endif // WWAN_LINK_ITEM_H44#endif // WWAN_LINK_ITEM_H
4345
=== modified file 'network/wwan-section.cpp'
--- network/wwan-section.cpp 2014-05-16 12:38:53 +0000
+++ network/wwan-section.cpp 2014-08-07 11:23:41 +0000
@@ -92,8 +92,6 @@
92void92void
93WwanSection::Private::modemsChanged(const std::set<Modem::Ptr> &modems)93WwanSection::Private::modemsChanged(const std::set<Modem::Ptr> &modems)
94{94{
95 /// @todo we have to address the correct ordering of the modems
96
97 std::set<Modem::Ptr> current;95 std::set<Modem::Ptr> current;
98 for (auto element : m_items)96 for (auto element : m_items)
99 current.insert(element.first);97 current.insert(element.first);
@@ -118,9 +116,31 @@
118116
119 for (auto modem : added) {117 for (auto modem : added) {
120 auto item = std::make_shared<WwanLinkItem>(modem, m_modemManager);118 auto item = std::make_shared<WwanLinkItem>(modem, m_modemManager);
121 m_linkMenuMerger->append(*item);119
120 m_items.push_back(std::make_pair(modem, item));
122 m_actionGroupMerger->add(*item);121 m_actionGroupMerger->add(*item);
123 m_items.push_back(std::make_pair(modem, item));122
123 // for now just throw everything away and rebuild
124 /// @todo add MenuMerger::insert() and ::find()
125 m_linkMenuMerger->clear();
126
127 auto compare = [](int lhs, int rhs ){
128 // make sure index() == -1 goes to the bottom of the menu
129 if (lhs == -1 && rhs == -1)
130 return false;
131 if (lhs == -1)
132 return false;
133 if (rhs == -1)
134 return true;
135 return lhs < rhs;
136 };
137 std::multimap<int, WwanLinkItem::Ptr, decltype(compare)> sorted(compare);
138
139 for (auto pair : m_items) {
140 sorted.insert(std::make_pair(pair.first->index(), pair.second));
141 }
142 for (auto pair : sorted)
143 m_linkMenuMerger->append(*(pair.second));
124 }144 }
125145
126 if (modems.size() == 0) {146 if (modems.size() == 0) {
@@ -129,6 +149,14 @@
129 if (m_bottomMenu->find(*m_openCellularSettings) == m_bottomMenu->end())149 if (m_bottomMenu->find(*m_openCellularSettings) == m_bottomMenu->end())
130 m_bottomMenu->append(*m_openCellularSettings);150 m_bottomMenu->append(*m_openCellularSettings);
131 }151 }
152
153 if (m_items.size() > 1) {
154 for(auto i : m_items)
155 i.second->showSimIdentifier(true);
156 } else {
157 for(auto i : m_items)
158 i.second->showSimIdentifier(false);
159 }
132}160}
133161
134WwanSection::WwanSection(ModemManager::Ptr modemManager)162WwanSection::WwanSection(ModemManager::Ptr modemManager)

Subscribers

People subscribed via source and target branches