Merge lp:~unity-api-team/indicator-network/unlock-modem-api-14.09 into lp:indicator-network/14.09

Proposed by Antti Kaijanmäki
Status: Merged
Approved by: Jussi Pakkanen
Approved revision: 465
Merged at revision: 465
Proposed branch: lp:~unity-api-team/indicator-network/unlock-modem-api-14.09
Merge into: lp:indicator-network/14.09
Diff against target: 220 lines (+94/-1)
11 files modified
src/dbus-cpp/services/connectivity.h (+16/-0)
src/indicator/connectivity-service/connectivity-service.cpp (+30/-1)
src/indicator/connectivity-service/connectivity-service.h (+5/-0)
src/indicator/indicator-network-service.cpp (+3/-0)
src/indicator/modem-manager.cpp (+14/-0)
src/indicator/modem-manager.h (+5/-0)
src/indicator/modem.cpp (+7/-0)
src/indicator/modem.h (+2/-0)
src/indicator/service.h (+5/-0)
src/indicator/wwan-section.cpp (+6/-0)
src/indicator/wwan-section.h (+1/-0)
To merge this branch: bzr merge lp:~unity-api-team/indicator-network/unlock-modem-api-14.09
Reviewer Review Type Date Requested Status
Jussi Pakkanen (community) Approve
Review via email: mp+244108@code.launchpad.net

Commit message

add com.ubuntu.connectivity1.Private.UnlockModem

Description of the change

$ dbus-send --session --print-reply --dest=com.ubuntu.connectivity1 /com/ubuntu/connectivity1/Private com.ubuntu.connectivity1.Private.UnlockModem string:/ril_0

Test cases to run:
https://wiki.ubuntu.com/Process/Merges/TestPlan/indicator-network#Test_Case:_indicator-network.2BAC8-unlock-sim-connectivity-service-dbus-api

To post a comment you must log in.
Revision history for this message
Jussi Pakkanen (jpakkane) wrote :

Looks good.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/dbus-cpp/services/connectivity.h'
2--- src/dbus-cpp/services/connectivity.h 2014-10-23 21:46:41 +0000
3+++ src/dbus-cpp/services/connectivity.h 2014-12-09 10:47:58 +0000
4@@ -129,6 +129,22 @@
5 return std::chrono::seconds{30};
6 }
7 };
8+
9+ struct UnlockModem {
10+ static const std::string& name()
11+ {
12+ static const std::string s{"UnlockModem"};
13+ return s;
14+ }
15+
16+ typedef Private Interface;
17+ typedef void ValueType;
18+
19+ static std::chrono::milliseconds default_timeout()
20+ {
21+ return std::chrono::seconds{30};
22+ }
23+ };
24 };
25
26 Private(std::shared_ptr<core::dbus::Service> &service,
27
28=== modified file 'src/indicator/connectivity-service/connectivity-service.cpp'
29--- src/indicator/connectivity-service/connectivity-service.cpp 2014-10-31 14:15:50 +0000
30+++ src/indicator/connectivity-service/connectivity-service.cpp 2014-12-09 10:47:58 +0000
31@@ -101,7 +101,8 @@
32 core::dbus::Object::Ptr m_privateObject;
33 std::shared_ptr<com::ubuntu::connectivity::Interface::Private> m_private;
34
35- core::Signal<> m_unlockAllModems;
36+ core::Signal<> m_unlockAllModems;
37+ core::Signal<std::string> m_unlockModem;
38
39 std::shared_ptr<networking::Manager> m_manager;
40
41@@ -201,6 +202,28 @@
42 auto that = shared_from_this();
43 GMainLoopDispatch([that](){ that->m_unlockAllModems(); });
44 });
45+
46+ m_privateObject->install_method_handler<com::ubuntu::connectivity::Interface::Private::Method::UnlockModem>([this](const core::dbus::Message::Ptr& msg)
47+ {
48+ core::dbus::Message::Reader reader;
49+ try {
50+ reader = msg->reader();
51+ } catch(...) {
52+ m_bus->send(core::dbus::Message::make_error(msg, "org.freedesktop.DBus.Error.InvalidArgs", "no modem name specified"));
53+ return;
54+ }
55+ if (reader.type() != core::dbus::ArgumentType::string) {
56+ m_bus->send(core::dbus::Message::make_error(msg, "org.freedesktop.DBus.Error.InvalidArgs", "modem name must be a string"));
57+ return;
58+ }
59+ std::string name = reader.pop_string();
60+
61+ auto reply = core::dbus::Message::make_method_return(msg);
62+ m_bus->send(reply);
63+
64+ auto that = shared_from_this();
65+ GMainLoopDispatch([that, name](){ that->m_unlockModem(name); });
66+ });
67 }
68
69 ConnectivityService::Private::~Private()
70@@ -333,3 +356,9 @@
71 return d->m_unlockAllModems;
72 }
73
74+core::Signal<std::string> &
75+ConnectivityService::unlockModem()
76+{
77+ return d->m_unlockModem;
78+}
79+
80
81=== modified file 'src/indicator/connectivity-service/connectivity-service.h'
82--- src/indicator/connectivity-service/connectivity-service.h 2014-10-29 18:12:05 +0000
83+++ src/indicator/connectivity-service/connectivity-service.h 2014-12-09 10:47:58 +0000
84@@ -34,6 +34,11 @@
85 */
86 core::Signal<> &unlockAllModems();
87
88+ /**
89+ * synced with GMainLoop
90+ */
91+ core::Signal<std::string> &unlockModem();
92+
93 private:
94 class Private;
95 std::shared_ptr<Private> d;
96
97=== modified file 'src/indicator/indicator-network-service.cpp'
98--- src/indicator/indicator-network-service.cpp 2014-10-29 18:12:05 +0000
99+++ src/indicator/indicator-network-service.cpp 2014-12-09 10:47:58 +0000
100@@ -90,6 +90,9 @@
101 // unlockAllModems is dispatched from GMainLoop
102 connectivityService->unlockAllModems().connect([menu](){ menu->unlockAllModems(); });
103
104+ // unlockModem is dispatched from GMainLoop
105+ connectivityService->unlockModem().connect([menu](const std::string &name){ menu->unlockModem(name); });
106+
107 if (getenv("VALGRIND") != 0) {
108 g_timeout_add(1000, (GSourceFunc)stop_main_loop, nullptr);
109 mainloop.run();
110
111=== modified file 'src/indicator/modem-manager.cpp'
112--- src/indicator/modem-manager.cpp 2014-10-31 14:15:50 +0000
113+++ src/indicator/modem-manager.cpp 2014-12-09 10:47:58 +0000
114@@ -234,6 +234,20 @@
115 }
116 }
117
118+void
119+ModemManager::unlockModemByName(const std::string &name)
120+{
121+#ifdef INDICATOR_NETWORK_TRACE_MESSAGES
122+ std::cout << __PRETTY_FUNCTION__ << std::endl;
123+#endif
124+ for (auto const &m : d->m_modems.get()) {
125+ if (m->name() == name) {
126+ unlockModem(m);
127+ return;
128+ }
129+ }
130+}
131+
132
133 const core::Property<std::set<Modem::Ptr>> &
134 ModemManager::modems()
135
136=== modified file 'src/indicator/modem-manager.h'
137--- src/indicator/modem-manager.h 2014-10-29 18:12:05 +0000
138+++ src/indicator/modem-manager.h 2014-12-09 10:47:58 +0000
139@@ -48,6 +48,11 @@
140 void unlockAllModems();
141
142 /**
143+ * must be called from GMainLoop
144+ */
145+ void unlockModemByName(const std::string &name);
146+
147+ /**
148 * changed() emitted from GMainLoop
149 */
150 const core::Property<std::set<Modem::Ptr>> &modems();
151
152=== modified file 'src/indicator/modem.cpp'
153--- src/indicator/modem.cpp 2014-10-29 18:12:05 +0000
154+++ src/indicator/modem.cpp 2014-12-09 10:47:58 +0000
155@@ -383,3 +383,10 @@
156 return d->m_index;
157 }
158
159+const std::string &
160+Modem::name() const
161+{
162+ return d->m_ofonoModem->object->path().as_string();
163+}
164+
165+
166
167=== modified file 'src/indicator/modem.h'
168--- src/indicator/modem.h 2014-10-29 18:12:05 +0000
169+++ src/indicator/modem.h 2014-12-09 10:47:58 +0000
170@@ -101,6 +101,8 @@
171 const core::Property<std::string> &simIdentifier();
172 int index();
173
174+ const std::string &name() const;
175+
176 static const std::string strengthIcon(int8_t strength)
177 {
178 /* Using same values as used by Android, not linear (LP: #1329945)*/
179
180=== modified file 'src/indicator/service.h'
181--- src/indicator/service.h 2014-10-09 10:58:30 +0000
182+++ src/indicator/service.h 2014-12-09 10:47:58 +0000
183@@ -167,6 +167,11 @@
184 {
185 m_wwanSection->unlockAllModems();
186 }
187+
188+ void unlockModem(const std::string &name)
189+ {
190+ m_wwanSection->unlockModem(name);
191+ }
192 };
193
194 #endif
195
196=== modified file 'src/indicator/wwan-section.cpp'
197--- src/indicator/wwan-section.cpp 2014-10-29 18:12:05 +0000
198+++ src/indicator/wwan-section.cpp 2014-12-09 10:47:58 +0000
199@@ -182,3 +182,9 @@
200 {
201 d->m_modemManager->unlockAllModems();
202 }
203+
204+void
205+WwanSection::unlockModem(const std::string &name)
206+{
207+ d->m_modemManager->unlockModemByName(name);
208+}
209
210=== modified file 'src/indicator/wwan-section.h'
211--- src/indicator/wwan-section.h 2014-10-29 18:12:05 +0000
212+++ src/indicator/wwan-section.h 2014-12-09 10:47:58 +0000
213@@ -38,6 +38,7 @@
214 virtual MenuModel::Ptr menuModel();
215
216 void unlockAllModems();
217+ void unlockModem(const std::string &name);
218 };
219
220 #endif

Subscribers

People subscribed via source and target branches