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

Proposed by Antti Kaijanmäki
Status: Merged
Approved by: Jussi Pakkanen
Approved revision: 463
Merged at revision: 463
Proposed branch: lp:~unity-api-team/indicator-network/unlock-modem-15.04
Merge into: lp:indicator-network/15.04
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-15.04
Reviewer Review Type Date Requested Status
Jussi Pakkanen (community) Approve
Review via email: mp+244110@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
=== modified file 'src/dbus-cpp/services/connectivity.h'
--- src/dbus-cpp/services/connectivity.h 2014-10-23 21:46:41 +0000
+++ src/dbus-cpp/services/connectivity.h 2014-12-09 10:59:03 +0000
@@ -129,6 +129,22 @@
129 return std::chrono::seconds{30};129 return std::chrono::seconds{30};
130 }130 }
131 };131 };
132
133 struct UnlockModem {
134 static const std::string& name()
135 {
136 static const std::string s{"UnlockModem"};
137 return s;
138 }
139
140 typedef Private Interface;
141 typedef void ValueType;
142
143 static std::chrono::milliseconds default_timeout()
144 {
145 return std::chrono::seconds{30};
146 }
147 };
132 };148 };
133149
134 Private(std::shared_ptr<core::dbus::Service> &service,150 Private(std::shared_ptr<core::dbus::Service> &service,
135151
=== modified file 'src/indicator/connectivity-service/connectivity-service.cpp'
--- src/indicator/connectivity-service/connectivity-service.cpp 2014-11-03 11:47:59 +0000
+++ src/indicator/connectivity-service/connectivity-service.cpp 2014-12-09 10:59:03 +0000
@@ -101,7 +101,8 @@
101 core::dbus::Object::Ptr m_privateObject;101 core::dbus::Object::Ptr m_privateObject;
102 std::shared_ptr<com::ubuntu::connectivity::Interface::Private> m_private;102 std::shared_ptr<com::ubuntu::connectivity::Interface::Private> m_private;
103103
104 core::Signal<> m_unlockAllModems;104 core::Signal<> m_unlockAllModems;
105 core::Signal<std::string> m_unlockModem;
105106
106 std::shared_ptr<networking::Manager> m_manager;107 std::shared_ptr<networking::Manager> m_manager;
107108
@@ -201,6 +202,28 @@
201 auto that = shared_from_this();202 auto that = shared_from_this();
202 GMainLoopDispatch([that](){ that->m_unlockAllModems(); });203 GMainLoopDispatch([that](){ that->m_unlockAllModems(); });
203 });204 });
205
206 m_privateObject->install_method_handler<com::ubuntu::connectivity::Interface::Private::Method::UnlockModem>([this](const core::dbus::Message::Ptr& msg)
207 {
208 core::dbus::Message::Reader reader;
209 try {
210 reader = msg->reader();
211 } catch(...) {
212 m_bus->send(core::dbus::Message::make_error(msg, "org.freedesktop.DBus.Error.InvalidArgs", "no modem name specified"));
213 return;
214 }
215 if (reader.type() != core::dbus::ArgumentType::string) {
216 m_bus->send(core::dbus::Message::make_error(msg, "org.freedesktop.DBus.Error.InvalidArgs", "modem name must be a string"));
217 return;
218 }
219 std::string name = reader.pop_string();
220
221 auto reply = core::dbus::Message::make_method_return(msg);
222 m_bus->send(reply);
223
224 auto that = shared_from_this();
225 GMainLoopDispatch([that, name](){ that->m_unlockModem(name); });
226 });
204}227}
205228
206ConnectivityService::Private::~Private()229ConnectivityService::Private::~Private()
@@ -333,3 +356,9 @@
333 return d->m_unlockAllModems;356 return d->m_unlockAllModems;
334}357}
335358
359core::Signal<std::string> &
360ConnectivityService::unlockModem()
361{
362 return d->m_unlockModem;
363}
364
336365
=== modified file 'src/indicator/connectivity-service/connectivity-service.h'
--- src/indicator/connectivity-service/connectivity-service.h 2014-10-29 18:12:05 +0000
+++ src/indicator/connectivity-service/connectivity-service.h 2014-12-09 10:59:03 +0000
@@ -34,6 +34,11 @@
34 */34 */
35 core::Signal<> &unlockAllModems();35 core::Signal<> &unlockAllModems();
3636
37 /**
38 * synced with GMainLoop
39 */
40 core::Signal<std::string> &unlockModem();
41
37private:42private:
38 class Private;43 class Private;
39 std::shared_ptr<Private> d;44 std::shared_ptr<Private> d;
4045
=== modified file 'src/indicator/indicator-network-service.cpp'
--- src/indicator/indicator-network-service.cpp 2014-10-29 18:12:05 +0000
+++ src/indicator/indicator-network-service.cpp 2014-12-09 10:59:03 +0000
@@ -90,6 +90,9 @@
90 // unlockAllModems is dispatched from GMainLoop90 // unlockAllModems is dispatched from GMainLoop
91 connectivityService->unlockAllModems().connect([menu](){ menu->unlockAllModems(); });91 connectivityService->unlockAllModems().connect([menu](){ menu->unlockAllModems(); });
9292
93 // unlockModem is dispatched from GMainLoop
94 connectivityService->unlockModem().connect([menu](const std::string &name){ menu->unlockModem(name); });
95
93 if (getenv("VALGRIND") != 0) {96 if (getenv("VALGRIND") != 0) {
94 g_timeout_add(1000, (GSourceFunc)stop_main_loop, nullptr);97 g_timeout_add(1000, (GSourceFunc)stop_main_loop, nullptr);
95 mainloop.run();98 mainloop.run();
9699
=== modified file 'src/indicator/modem-manager.cpp'
--- src/indicator/modem-manager.cpp 2014-11-03 11:47:59 +0000
+++ src/indicator/modem-manager.cpp 2014-12-09 10:59:03 +0000
@@ -234,6 +234,20 @@
234 }234 }
235}235}
236236
237void
238ModemManager::unlockModemByName(const std::string &name)
239{
240#ifdef INDICATOR_NETWORK_TRACE_MESSAGES
241 std::cout << __PRETTY_FUNCTION__ << std::endl;
242#endif
243 for (auto const &m : d->m_modems.get()) {
244 if (m->name() == name) {
245 unlockModem(m);
246 return;
247 }
248 }
249}
250
237251
238const core::Property<std::set<Modem::Ptr>> &252const core::Property<std::set<Modem::Ptr>> &
239ModemManager::modems()253ModemManager::modems()
240254
=== modified file 'src/indicator/modem-manager.h'
--- src/indicator/modem-manager.h 2014-10-29 18:12:05 +0000
+++ src/indicator/modem-manager.h 2014-12-09 10:59:03 +0000
@@ -48,6 +48,11 @@
48 void unlockAllModems();48 void unlockAllModems();
4949
50 /**50 /**
51 * must be called from GMainLoop
52 */
53 void unlockModemByName(const std::string &name);
54
55 /**
51 * changed() emitted from GMainLoop56 * changed() emitted from GMainLoop
52 */57 */
53 const core::Property<std::set<Modem::Ptr>> &modems();58 const core::Property<std::set<Modem::Ptr>> &modems();
5459
=== modified file 'src/indicator/modem.cpp'
--- src/indicator/modem.cpp 2014-10-29 18:12:05 +0000
+++ src/indicator/modem.cpp 2014-12-09 10:59:03 +0000
@@ -383,3 +383,10 @@
383 return d->m_index;383 return d->m_index;
384}384}
385385
386const std::string &
387Modem::name() const
388{
389 return d->m_ofonoModem->object->path().as_string();
390}
391
392
386393
=== modified file 'src/indicator/modem.h'
--- src/indicator/modem.h 2014-10-29 18:12:05 +0000
+++ src/indicator/modem.h 2014-12-09 10:59:03 +0000
@@ -101,6 +101,8 @@
101 const core::Property<std::string> &simIdentifier();101 const core::Property<std::string> &simIdentifier();
102 int index();102 int index();
103103
104 const std::string &name() const;
105
104 static const std::string strengthIcon(int8_t strength)106 static const std::string strengthIcon(int8_t strength)
105 {107 {
106 /* Using same values as used by Android, not linear (LP: #1329945)*/108 /* Using same values as used by Android, not linear (LP: #1329945)*/
107109
=== modified file 'src/indicator/service.h'
--- src/indicator/service.h 2014-10-09 10:58:30 +0000
+++ src/indicator/service.h 2014-12-09 10:59:03 +0000
@@ -167,6 +167,11 @@
167 {167 {
168 m_wwanSection->unlockAllModems();168 m_wwanSection->unlockAllModems();
169 }169 }
170
171 void unlockModem(const std::string &name)
172 {
173 m_wwanSection->unlockModem(name);
174 }
170};175};
171176
172#endif177#endif
173178
=== modified file 'src/indicator/wwan-section.cpp'
--- src/indicator/wwan-section.cpp 2014-10-29 18:12:05 +0000
+++ src/indicator/wwan-section.cpp 2014-12-09 10:59:03 +0000
@@ -182,3 +182,9 @@
182{182{
183 d->m_modemManager->unlockAllModems();183 d->m_modemManager->unlockAllModems();
184}184}
185
186void
187WwanSection::unlockModem(const std::string &name)
188{
189 d->m_modemManager->unlockModemByName(name);
190}
185191
=== modified file 'src/indicator/wwan-section.h'
--- src/indicator/wwan-section.h 2014-10-29 18:12:05 +0000
+++ src/indicator/wwan-section.h 2014-12-09 10:59:03 +0000
@@ -38,6 +38,7 @@
38 virtual MenuModel::Ptr menuModel();38 virtual MenuModel::Ptr menuModel();
3939
40 void unlockAllModems();40 void unlockAllModems();
41 void unlockModem(const std::string &name);
41};42};
4243
43#endif44#endif

Subscribers

People subscribed via source and target branches