shill: Add ModemManager1 proxy interfaces and classes
Add ModemManager1 proxy interfaces and classes.
BUG=chromium-os:27487
TEST=compile the code
Change-Id: I4700cc40e0d73e9d3d1cab14a28238bb7a4ab71b
Reviewed-on: https://gerrit.chromium.org/gerrit/17521
Commit-Ready: Jason Glasgow <jglasgow@chromium.org>
Reviewed-by: Jason Glasgow <jglasgow@chromium.org>
Tested-by: Jason Glasgow <jglasgow@chromium.org>
diff --git a/Makefile b/Makefile
index 85b8e84..449bf1f 100644
--- a/Makefile
+++ b/Makefile
@@ -54,7 +54,11 @@
org.freedesktop.ModemManager.Modem.Cdma>modem-cdma \
org.freedesktop.ModemManager.Modem.Gsm.Card>modem-gsm-card \
org.freedesktop.ModemManager.Modem.Gsm.Network>modem-gsm-network \
- org.freedesktop.ModemManager.Modem.Simple>modem-simple
+ org.freedesktop.ModemManager.Modem.Simple>modem-simple \
+ org.freedesktop.ModemManager1.Modem>mm1-modem \
+ org.freedesktop.ModemManager1.Modem.Modem3gpp>mm1-modem-modem3gpp \
+ org.freedesktop.ModemManager1.Modem.ModemCdma>mm1-modem-modemcdma \
+ org.freedesktop.ModemManager1.Modem.Simple>mm1-modem-simple
# Rename local XML files with the names required by DBus to XML files with the
# names required by the style guide, which will then be turned into generated
@@ -140,6 +144,10 @@
manager.o \
manager_dbus_adaptor.o \
metrics.o \
+ mm1_modem_modem3gpp_proxy.o \
+ mm1_modem_modemcdma_proxy.o \
+ mm1_modem_proxy.o \
+ mm1_modem_simple_proxy.o \
modem.o \
modem_cdma_proxy.o \
modem_gsm_card_proxy.o \
diff --git a/mm1_modem_modem3gpp_proxy.cc b/mm1_modem_modem3gpp_proxy.cc
new file mode 100644
index 0000000..966bd97
--- /dev/null
+++ b/mm1_modem_modem3gpp_proxy.cc
@@ -0,0 +1,82 @@
+// Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "shill/mm1_modem_modem3gpp_proxy.h"
+
+#include <base/logging.h>
+
+#include "cellular_error.h"
+
+using std::string;
+
+namespace shill {
+namespace mm1 {
+
+ModemModem3gppProxy::ModemModem3gppProxy(
+ ModemModem3gppProxyDelegate *delegate,
+ DBus::Connection *connection,
+ const string &path,
+ const string &service)
+ : proxy_(delegate, connection, path, service) {}
+
+ModemModem3gppProxy::~ModemModem3gppProxy() {}
+
+void ModemModem3gppProxy::Register(const std::string &operator_id,
+ AsyncCallHandler *call_handler,
+ int timeout) {
+ proxy_.Register(operator_id, call_handler, timeout);
+}
+
+void ModemModem3gppProxy::Scan(AsyncCallHandler *call_handler, int timeout) {
+ proxy_.Scan(call_handler, timeout);
+}
+
+// Inherited properties from ModemModem3gppProxyInterface.
+std::string ModemModem3gppProxy::Imei() {
+ return proxy_.Imei();
+};
+uint32_t ModemModem3gppProxy::RegistrationState() {
+ return proxy_.RegistrationState();
+};
+std::string ModemModem3gppProxy::OperatorCode() {
+ return proxy_.OperatorCode();
+};
+std::string ModemModem3gppProxy::OperatorName() {
+ return proxy_.OperatorName();
+};
+uint32_t ModemModem3gppProxy::EnabledFacilityLocks() {
+ return proxy_.EnabledFacilityLocks();
+};
+
+// ModemModem3gppProxy::Proxy
+ModemModem3gppProxy::Proxy::Proxy(ModemModem3gppProxyDelegate *delegate,
+ DBus::Connection *connection,
+ const std::string &path,
+ const std::string &service)
+ : DBus::ObjectProxy(*connection, path, service.c_str()),
+ delegate_(delegate) {}
+
+ModemModem3gppProxy::Proxy::~Proxy() {}
+
+// Method callbacks inherited from
+// org::freedesktop::ModemManager1::Modem::ModemModem3gppProxy
+void ModemModem3gppProxy::Proxy::RegisterCallback(const ::DBus::Error& dberror,
+ void *data) {
+ AsyncCallHandler *call_handler = reinterpret_cast<AsyncCallHandler *>(data);
+ Error error;
+ CellularError::FromDBusError(dberror, &error),
+ delegate_->OnRegisterCallback(error, call_handler);
+}
+
+void ModemModem3gppProxy::Proxy::ScanCallback(
+ const std::vector<DBusPropertiesMap> &results,
+ const ::DBus::Error& dberror, void *data) {
+ AsyncCallHandler *call_handler = reinterpret_cast<AsyncCallHandler *>(data);
+ Error error;
+ CellularError::FromDBusError(dberror, &error),
+ delegate_->OnScanCallback(results, error, call_handler);
+}
+
+} // namespace mm1
+} // namespace shill
diff --git a/mm1_modem_modem3gpp_proxy.h b/mm1_modem_modem3gpp_proxy.h
new file mode 100644
index 0000000..2cd72e5
--- /dev/null
+++ b/mm1_modem_modem3gpp_proxy.h
@@ -0,0 +1,70 @@
+// Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef SHILL_MM1_MODEM_MODEM3GPP_PROXY_
+#define SHILL_MM1_MODEM_MODEM3GPP_PROXY_
+
+#include <string>
+
+#include "shill/dbus_bindings/mm1-modem-modem3gpp.h"
+#include "shill/dbus_properties.h"
+#include "shill/mm1_modem_modem3gpp_proxy_interface.h"
+
+namespace shill {
+namespace mm1 {
+
+class ModemModem3gppProxy : public ModemModem3gppProxyInterface {
+ public:
+ // Constructs a org.freedesktop.ModemManager1.Modem.Modem3gpp DBus
+ // object proxy at |path| owned by |service|. Caught signals and
+ // asynchronous method replies will be dispatched to |delegate|.
+ ModemModem3gppProxy(ModemModem3gppProxyDelegate *delegate,
+ DBus::Connection *connection,
+ const std::string &path,
+ const std::string &service);
+ virtual ~ModemModem3gppProxy();
+ // Inherited methods from ModemModem3gppProxyInterface.
+ virtual void Register(const std::string &operator_id,
+ AsyncCallHandler *call_handler,
+ int timeout);
+ virtual void Scan(AsyncCallHandler *call_handler, int timeout);
+
+ // Inherited properties from Modem3gppProxyInterface.
+ virtual std::string Imei();
+ virtual uint32_t RegistrationState();
+ virtual std::string OperatorCode();
+ virtual std::string OperatorName();
+ virtual uint32_t EnabledFacilityLocks();
+
+ private:
+ class Proxy : public org::freedesktop::ModemManager1::Modem::Modem3gpp_proxy,
+ public DBus::ObjectProxy {
+ public:
+ Proxy(ModemModem3gppProxyDelegate *delegate,
+ DBus::Connection *connection,
+ const std::string &path,
+ const std::string &service);
+ virtual ~Proxy();
+
+ private:
+ // Method callbacks inherited from
+ // org::freedesktop::ModemManager1::Modem::Modem3gppProxy
+ virtual void RegisterCallback(const ::DBus::Error& dberror, void *data);
+ virtual void ScanCallback(
+ const std::vector<DBusPropertiesMap> &results,
+ const ::DBus::Error& dberror, void *data);
+ ModemModem3gppProxyDelegate *delegate_;
+
+ DISALLOW_COPY_AND_ASSIGN(Proxy);
+ };
+
+ Proxy proxy_;
+
+ DISALLOW_COPY_AND_ASSIGN(ModemModem3gppProxy);
+};
+
+} // namespace mm1
+} // namespace shill
+
+#endif // MM1_SHILL_MODEM_MODEM3GPP_PROXY_
diff --git a/mm1_modem_modem3gpp_proxy_interface.h b/mm1_modem_modem3gpp_proxy_interface.h
new file mode 100644
index 0000000..3e875ea
--- /dev/null
+++ b/mm1_modem_modem3gpp_proxy_interface.h
@@ -0,0 +1,61 @@
+// Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef SHILL_MM1_MODEM_MODEM3GPP_PROXY_INTERFACE_
+#define SHILL_MM1_MODEM_MODEM3GPP_PROXY_INTERFACE_
+
+#include <string>
+
+#include <base/basictypes.h>
+
+#include "shill/dbus_properties.h"
+
+namespace shill {
+class AsyncCallHandler;
+class Error;
+
+namespace mm1 {
+
+// These are the methods that a
+// org.freedesktop.ModemManager1.Modem.Modem3gpp proxy must support.
+
+// The interface is provided so that it can be mocked in tests.
+// All calls are made asynchronously. Call completion is signalled through
+// the corresponding 'OnXXXCallback' method in the ProxyDelegate interface.
+class ModemModem3gppProxyInterface {
+ public:
+ virtual ~ModemModem3gppProxyInterface() {}
+
+ virtual void Register(const std::string &operator_id,
+ AsyncCallHandler *call_handler,
+ int timeout) = 0;
+ virtual void Scan(AsyncCallHandler *call_handler, int timeout) = 0;
+
+ // Properties.
+ virtual std::string Imei() = 0;
+ virtual uint32_t RegistrationState() = 0;
+ virtual std::string OperatorCode() = 0;
+ virtual std::string OperatorName() = 0;
+ virtual uint32_t EnabledFacilityLocks() = 0;
+};
+
+// ModemManager1.Modem.Modem3gpp signal delegate to be associated with
+// the proxy.
+class ModemModem3gppProxyDelegate {
+ public:
+ virtual ~ModemModem3gppProxyDelegate() {}
+
+ // Handle async callbacks
+ virtual void OnRegisterCallback(const Error &error,
+ AsyncCallHandler *call_handler) = 0;
+ virtual void OnScanCallback(
+ const std::vector<DBusPropertiesMap> &results,
+ const Error &error,
+ AsyncCallHandler *call_handler) = 0;
+};
+
+} // namespace mm1
+} // namespace shill
+
+#endif // SHILL_MM1_MODEM_MODEM3GPP_PROXY_INTERFACE_
diff --git a/mm1_modem_modemcdma_proxy.cc b/mm1_modem_modemcdma_proxy.cc
new file mode 100644
index 0000000..ecc82f3
--- /dev/null
+++ b/mm1_modem_modemcdma_proxy.cc
@@ -0,0 +1,97 @@
+// Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "shill/mm1_modem_modemcdma_proxy.h"
+
+#include <base/logging.h>
+
+#include "cellular_error.h"
+
+using std::string;
+
+namespace shill {
+namespace mm1 {
+
+ModemModemCdmaProxy::ModemModemCdmaProxy(ModemModemCdmaProxyDelegate *delegate,
+ DBus::Connection *connection,
+ const string &path,
+ const string &service)
+ : proxy_(delegate, connection, path, service) {}
+
+ModemModemCdmaProxy::~ModemModemCdmaProxy() {}
+
+void ModemModemCdmaProxy::Activate(const std::string &carrier,
+ AsyncCallHandler *call_handler,
+ int timeout) {
+ proxy_.Activate(carrier, call_handler, timeout);
+}
+
+void ModemModemCdmaProxy::ActivateManual(
+ const DBusPropertiesMap &properties,
+ AsyncCallHandler *call_handler,
+ int timeout) {
+ proxy_.ActivateManual(properties, call_handler, timeout);
+}
+
+// Inherited properties from ModemModemCdmaProxyInterface.
+std::string ModemModemCdmaProxy::Meid() {
+ return proxy_.Meid();
+};
+std::string ModemModemCdmaProxy::Esn() {
+ return proxy_.Esn();
+};
+uint32_t ModemModemCdmaProxy::Sid() {
+ return proxy_.Sid();
+};
+uint32_t ModemModemCdmaProxy::Nid() {
+ return proxy_.Nid();
+};
+uint32_t ModemModemCdmaProxy::Cdma1xRegistrationState() {
+ return proxy_.Cdma1xRegistrationState();
+};
+uint32_t ModemModemCdmaProxy::EvdoRegistrationState() {
+ return proxy_.EvdoRegistrationState();
+};
+
+// ModemModemCdmaProxy::Proxy
+ModemModemCdmaProxy::Proxy::Proxy(ModemModemCdmaProxyDelegate *delegate,
+ DBus::Connection *connection,
+ const std::string &path,
+ const std::string &service)
+ : DBus::ObjectProxy(*connection, path, service.c_str()),
+ delegate_(delegate) {}
+
+ModemModemCdmaProxy::Proxy::~Proxy() {}
+
+// Signal callbacks inherited from Proxy
+void ModemModemCdmaProxy::Proxy::ActivationStateChanged(
+ const uint32_t &activation_state,
+ const uint32_t &activation_error,
+ const DBusPropertiesMap &status_changes) {
+ delegate_->OnActivationStateChanged(activation_state,
+ activation_error,
+ status_changes);
+}
+
+// Method callbacks inherited from
+// org::freedesktop::ModemManager1::Modem::ModemModemCdmaProxy
+void ModemModemCdmaProxy::Proxy::ActivateCallback(const ::DBus::Error& dberror,
+ void *data) {
+ AsyncCallHandler *call_handler = reinterpret_cast<AsyncCallHandler *>(data);
+ Error error;
+ CellularError::FromDBusError(dberror, &error),
+ delegate_->OnActivateCallback(error, call_handler);
+}
+
+void ModemModemCdmaProxy::Proxy::ActivateManualCallback(
+ const ::DBus::Error& dberror,
+ void *data) {
+ AsyncCallHandler *call_handler = reinterpret_cast<AsyncCallHandler *>(data);
+ Error error;
+ CellularError::FromDBusError(dberror, &error),
+ delegate_->OnActivateManualCallback(error, call_handler);
+}
+
+} // namespace mm1
+} // namespace shill
diff --git a/mm1_modem_modemcdma_proxy.h b/mm1_modem_modemcdma_proxy.h
new file mode 100644
index 0000000..e4dadb7
--- /dev/null
+++ b/mm1_modem_modemcdma_proxy.h
@@ -0,0 +1,82 @@
+// Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef SHILL_MM1_MODEM_MODEMCDMA_PROXY_
+#define SHILL_MM1_MODEM_MODEMCDMA_PROXY_
+
+#include <string>
+
+#include "shill/dbus_bindings/mm1-modem-modemcdma.h"
+#include "shill/dbus_properties.h"
+#include "shill/mm1_modem_modemcdma_proxy_interface.h"
+
+namespace shill {
+class AsyncCallHandler;
+namespace mm1 {
+
+class ModemModemCdmaProxy : public ModemModemCdmaProxyInterface {
+ public:
+ // Constructs a org.freedesktop.ModemManager1.Modem.ModemCdma DBus
+ // object proxy at |path| owned by |service|. Caught signals and
+ // asynchronous method replies will be dispatched to |delegate|.
+ ModemModemCdmaProxy(ModemModemCdmaProxyDelegate *delegate,
+ DBus::Connection *connection,
+ const std::string &path,
+ const std::string &service);
+ virtual ~ModemModemCdmaProxy();
+
+ // Inherited methods from ModemModemCdmaProxyInterface.
+ virtual void Activate(const std::string &carrier,
+ AsyncCallHandler *call_handler,
+ int timeout);
+ virtual void ActivateManual(
+ const DBusPropertiesMap &properties,
+ AsyncCallHandler *call_handler,
+ int timeout);
+
+ // Inherited properties from ModemCdmaProxyInterface.
+ virtual std::string Meid();
+ virtual std::string Esn();
+ virtual uint32_t Sid();
+ virtual uint32_t Nid();
+ virtual uint32_t Cdma1xRegistrationState();
+ virtual uint32_t EvdoRegistrationState();
+
+ private:
+ class Proxy : public org::freedesktop::ModemManager1::Modem::ModemCdma_proxy,
+ public DBus::ObjectProxy {
+ public:
+ Proxy(ModemModemCdmaProxyDelegate *delegate,
+ DBus::Connection *connection,
+ const std::string &path,
+ const std::string &service);
+ virtual ~Proxy();
+
+ private:
+ // Signal callbacks inherited from Proxy
+ // handle signals
+ void ActivationStateChanged(
+ const uint32_t &activation_state,
+ const uint32_t &activation_error,
+ const DBusPropertiesMap &status_changes);
+
+ // Method callbacks inherited from
+ // org::freedesktop::ModemManager1::Modem::ModemCdmaProxy
+ virtual void ActivateCallback(const ::DBus::Error& dberror, void *data);
+ virtual void ActivateManualCallback(const ::DBus::Error& dberror,
+ void *data);
+ ModemModemCdmaProxyDelegate *delegate_;
+
+ DISALLOW_COPY_AND_ASSIGN(Proxy);
+ };
+
+ Proxy proxy_;
+
+ DISALLOW_COPY_AND_ASSIGN(ModemModemCdmaProxy);
+};
+
+} // namespace mm1
+} // namespace shill
+
+#endif // SHILL_MM1_MODEM_MODEMCDMA_PROXY_
diff --git a/mm1_modem_modemcdma_proxy_interface.h b/mm1_modem_modemcdma_proxy_interface.h
new file mode 100644
index 0000000..ee18506
--- /dev/null
+++ b/mm1_modem_modemcdma_proxy_interface.h
@@ -0,0 +1,71 @@
+// Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef SHILL_MM1_MODEM_MODEMCDMA_PROXY_INTERFACE_
+#define SHILL_MM1_MODEM_MODEMCDMA_PROXY_INTERFACE_
+
+#include <string>
+
+#include <base/basictypes.h>
+
+#include "shill/dbus_properties.h"
+
+namespace shill {
+class AsyncCallHandler;
+class Error;
+
+namespace mm1 {
+
+// These are the methods that a
+// org.freedesktop.ModemManager1.Modem.ModemCdma proxy must support.
+// The interface is provided so that it can be mocked in tests. All
+// calls are made asynchronously. Call completion is signalled through
+// the corresponding 'OnXXXCallback' method in the ProxyDelegate
+// interface.
+class ModemModemCdmaProxyInterface {
+ public:
+ virtual ~ModemModemCdmaProxyInterface() {}
+
+ virtual void Activate(const std::string &carrier,
+ AsyncCallHandler *call_handler,
+ int timeout) = 0;
+ virtual void ActivateManual(
+ const DBusPropertiesMap &properties,
+ AsyncCallHandler *call_handler, int timeout) = 0;
+
+
+ // Properties.
+ virtual std::string Meid() = 0;
+ virtual std::string Esn() = 0;
+ virtual uint32_t Sid() = 0;
+ virtual uint32_t Nid() = 0;
+ virtual uint32_t Cdma1xRegistrationState() = 0;
+ virtual uint32_t EvdoRegistrationState() = 0;
+};
+
+
+// ModemManager1.Modem.ModemCdma signal delegate to be associated with
+// the proxy.
+class ModemModemCdmaProxyDelegate {
+ public:
+ virtual ~ModemModemCdmaProxyDelegate() {}
+
+ // handle signals
+ virtual void OnActivationStateChanged(
+ const uint32_t &activation_state,
+ const uint32_t &activation_error,
+ const DBusPropertiesMap &status_changes) = 0;
+
+ // Handle async callbacks
+ virtual void OnActivateCallback(const Error &error,
+ AsyncCallHandler *call_handler) = 0;
+ virtual void OnActivateManualCallback(
+ const Error &error,
+ AsyncCallHandler *call_handler) = 0;
+};
+
+} // namespace mm1
+} // namespace shill
+
+#endif // SHILL_MM1_MODEM_MODEMCDMA_PROXY_INTERFACE_
diff --git a/mm1_modem_proxy.cc b/mm1_modem_proxy.cc
new file mode 100644
index 0000000..1ff47bf
--- /dev/null
+++ b/mm1_modem_proxy.cc
@@ -0,0 +1,245 @@
+// Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "shill/mm1_modem_proxy.h"
+
+#include <base/logging.h>
+
+#include "cellular_error.h"
+
+using std::string;
+
+namespace shill {
+namespace mm1 {
+
+ModemProxy::ModemProxy(ModemProxyDelegate *delegate,
+ DBus::Connection *connection,
+ const string &path,
+ const string &service)
+ : proxy_(delegate, connection, path, service) {}
+
+ModemProxy::~ModemProxy() {}
+
+void ModemProxy::Enable(const bool &enable,
+ AsyncCallHandler *call_handler,
+ int timeout) {
+ proxy_.Enable(enable, call_handler, timeout);
+}
+
+void ModemProxy::ListBearers(AsyncCallHandler *call_handler,
+ int timeout) {
+ proxy_.ListBearers(call_handler, timeout);
+}
+
+void ModemProxy::CreateBearer(
+ const DBusPropertiesMap &properties,
+ AsyncCallHandler *call_handler,
+ int timeout) {
+ proxy_.CreateBearer(properties, call_handler, timeout);
+}
+
+void ModemProxy::DeleteBearer(const ::DBus::Path &bearer,
+ AsyncCallHandler *call_handler,
+ int timeout) {
+ proxy_.DeleteBearer(bearer, call_handler, timeout);
+}
+
+void ModemProxy::Reset(AsyncCallHandler *call_handler, int timeout) {
+ proxy_.Reset(call_handler, timeout);
+}
+
+void ModemProxy::FactoryReset(const std::string &code,
+ AsyncCallHandler *call_handler,
+ int timeout) {
+ proxy_.FactoryReset(code, call_handler, timeout);
+}
+
+void ModemProxy::SetAllowedModes(const uint32_t &modes,
+ const uint32_t &preferred,
+ AsyncCallHandler *call_handler,
+ int timeout) {
+ proxy_.SetAllowedModes(modes, preferred, call_handler, timeout);
+}
+
+void ModemProxy::SetBands(const std::vector< uint32_t > &bands,
+ AsyncCallHandler *call_handler,
+ int timeout) {
+ proxy_.SetBands(bands, call_handler, timeout);
+}
+
+void ModemProxy::Command(const std::string &cmd,
+ const uint32_t &user_timeout,
+ AsyncCallHandler *call_handler,
+ int timeout) {
+ proxy_.Command(cmd, user_timeout, call_handler, timeout);
+}
+
+// Inherited properties from ModemProxyInterface.
+const ::DBus::Path ModemProxy::Sim() {
+ return proxy_.Sim();
+};
+uint32_t ModemProxy::ModemCapabilities() {
+ return proxy_.ModemCapabilities();
+};
+uint32_t ModemProxy::CurrentCapabilities() {
+ return proxy_.CurrentCapabilities();
+};
+uint32_t ModemProxy::MaxBearers() {
+ return proxy_.MaxBearers();
+};
+uint32_t ModemProxy::MaxActiveBearers() {
+ return proxy_.MaxActiveBearers();
+};
+const std::string ModemProxy::Manufacturer() {
+ return proxy_.Manufacturer();
+};
+const std::string ModemProxy::Model() {
+ return proxy_.Model();
+};
+const std::string ModemProxy::Revision() {
+ return proxy_.Revision();
+};
+const std::string ModemProxy::DeviceIdentifier() {
+ return proxy_.DeviceIdentifier();
+};
+const std::string ModemProxy::Device() {
+ return proxy_.Device();
+};
+const std::string ModemProxy::Driver() {
+ return proxy_.Driver();
+};
+const std::string ModemProxy::Plugin() {
+ return proxy_.Plugin();
+};
+const std::string ModemProxy::EquipmentIdentifier() {
+ return proxy_.EquipmentIdentifier();
+};
+uint32_t ModemProxy::UnlockRequired() {
+ return proxy_.UnlockRequired();
+};
+const std::map< uint32_t, uint32_t > ModemProxy::UnlockRetries() {
+ return proxy_.UnlockRetries();
+};
+uint32_t ModemProxy::State() {
+ return proxy_.State();
+};
+uint32_t ModemProxy::AccessTechnologies() {
+ return proxy_.AccessTechnologies();
+};
+const ::DBus::Struct< uint32_t, bool > ModemProxy::SignalQuality() {
+ return proxy_.SignalQuality();
+};
+uint32_t ModemProxy::SupportedModes() {
+ return proxy_.SupportedModes();
+};
+uint32_t ModemProxy::AllowedModes() {
+ return proxy_.AllowedModes();
+};
+uint32_t ModemProxy::PreferredMode() {
+ return proxy_.PreferredMode();
+};
+const std::vector< uint32_t > ModemProxy::SupportedBands() {
+ return proxy_.SupportedBands();
+};
+const std::vector< uint32_t > ModemProxy::Bands() {
+ return proxy_.Bands();
+};
+
+ModemProxy::Proxy::Proxy(ModemProxyDelegate *delegate,
+ DBus::Connection *connection,
+ const std::string &path,
+ const std::string &service)
+ : DBus::ObjectProxy(*connection, path, service.c_str()),
+ delegate_(delegate) {}
+
+ModemProxy::Proxy::~Proxy() {}
+
+// Signal callbacks inherited from Proxy
+void ModemProxy::Proxy::StateChanged(const uint32_t &old,
+ const uint32_t &_new,
+ const uint32_t &reason) {
+ delegate_->OnStateChanged(old, _new, reason);
+}
+
+// Method callbacks inherited from
+// org::freedesktop::ModemManager1::ModemProxy
+void ModemProxy::Proxy::EnableCallback(const ::DBus::Error& dberror,
+ void *data) {
+ AsyncCallHandler *call_handler = reinterpret_cast<AsyncCallHandler *>(data);
+ Error error;
+ CellularError::FromDBusError(dberror, &error),
+ delegate_->OnEnableCallback(error, call_handler);
+}
+
+void ModemProxy::Proxy::ListBearersCallback(
+ const std::vector< ::DBus::Path > &bearers,
+ const ::DBus::Error& dberror,
+ void *data) {
+ AsyncCallHandler *call_handler = reinterpret_cast<AsyncCallHandler *>(data);
+ Error error;
+ CellularError::FromDBusError(dberror, &error),
+ delegate_->OnListBearersCallback(bearers, error, call_handler);
+}
+
+void ModemProxy::Proxy::CreateBearerCallback(const ::DBus::Path &path,
+ const ::DBus::Error& dberror,
+ void *data) {
+ AsyncCallHandler *call_handler = reinterpret_cast<AsyncCallHandler *>(data);
+ Error error;
+ CellularError::FromDBusError(dberror, &error),
+ delegate_->OnCreateBearerCallback(path, error, call_handler);
+}
+
+void ModemProxy::Proxy::DeleteBearerCallback(const ::DBus::Error& dberror,
+ void *data) {
+ AsyncCallHandler *call_handler = reinterpret_cast<AsyncCallHandler *>(data);
+ Error error;
+ CellularError::FromDBusError(dberror, &error),
+ delegate_->OnDeleteBearerCallback(error, call_handler);
+}
+
+void ModemProxy::Proxy::ResetCallback(const ::DBus::Error& dberror,
+ void *data) {
+ AsyncCallHandler *call_handler = reinterpret_cast<AsyncCallHandler *>(data);
+ Error error;
+ CellularError::FromDBusError(dberror, &error),
+ delegate_->OnResetCallback(error, call_handler);
+}
+
+void ModemProxy::Proxy::FactoryResetCallback(const ::DBus::Error& dberror,
+ void *data) {
+ AsyncCallHandler *call_handler = reinterpret_cast<AsyncCallHandler *>(data);
+ Error error;
+ CellularError::FromDBusError(dberror, &error),
+ delegate_->OnFactoryResetCallback(error, call_handler);
+}
+
+void ModemProxy::Proxy::SetAllowedModesCallback(
+ const ::DBus::Error& dberror,
+ void *data) {
+ AsyncCallHandler *call_handler = reinterpret_cast<AsyncCallHandler *>(data);
+ Error error;
+ CellularError::FromDBusError(dberror, &error),
+ delegate_->OnSetAllowedModesCallback(error, call_handler);
+}
+
+void ModemProxy::Proxy::SetBandsCallback(const ::DBus::Error& dberror,
+ void *data) {
+ AsyncCallHandler *call_handler = reinterpret_cast<AsyncCallHandler *>(data);
+ Error error;
+ CellularError::FromDBusError(dberror, &error),
+ delegate_->OnSetBandsCallback(error, call_handler);
+}
+
+void ModemProxy::Proxy::CommandCallback(const std::string &response,
+ const ::DBus::Error& dberror,
+ void *data) {
+ AsyncCallHandler *call_handler = reinterpret_cast<AsyncCallHandler *>(data);
+ Error error;
+ CellularError::FromDBusError(dberror, &error),
+ delegate_->OnCommandCallback(response, error, call_handler);
+}
+
+} // namespace mm1
+} // namespace shill
diff --git a/mm1_modem_proxy.h b/mm1_modem_proxy.h
new file mode 100644
index 0000000..3758423
--- /dev/null
+++ b/mm1_modem_proxy.h
@@ -0,0 +1,130 @@
+// Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef SHILL_MM1_MODEM_PROXY_
+#define SHILL_MM1_MODEM_PROXY_
+
+#include <string>
+
+#include "shill/dbus_bindings/mm1-modem.h"
+#include "shill/dbus_properties.h"
+#include "shill/mm1_modem_proxy_interface.h"
+
+namespace shill {
+class AsyncCallHandler;
+
+namespace mm1 {
+
+class ModemProxy : public ModemProxyInterface {
+ public:
+ // Constructs a org.freedesktop.ModemManager1.Modem DBus object
+ // proxy at |path| owned by |service|. Caught signals and
+ // asynchronous method replies will be dispatched to |delegate|.
+ ModemProxy(ModemProxyDelegate *delegate,
+ DBus::Connection *connection,
+ const std::string &path,
+ const std::string &service);
+ virtual ~ModemProxy();
+
+ // Inherited methods from ModemProxyInterface.
+ virtual void Enable(const bool &enable,
+ AsyncCallHandler *call_handler,
+ int timeout);
+ virtual void ListBearers(AsyncCallHandler *call_handler, int timeout);
+ virtual void CreateBearer(
+ const DBusPropertiesMap &properties,
+ AsyncCallHandler *call_handler,
+ int timeout);
+ virtual void DeleteBearer(const ::DBus::Path &bearer,
+ AsyncCallHandler *call_handler,
+ int timeout);
+ virtual void Reset(AsyncCallHandler *call_handler, int timeout);
+ virtual void FactoryReset(const std::string &code,
+ AsyncCallHandler *call_handler,
+ int timeout);
+ virtual void SetAllowedModes(const uint32_t &modes, const uint32_t &preferred,
+ AsyncCallHandler *call_handler,
+ int timeout);
+ virtual void SetBands(const std::vector< uint32_t > &bands,
+ AsyncCallHandler *call_handler,
+ int timeout);
+ virtual void Command(const std::string &cmd,
+ const uint32_t &user_timeout,
+ AsyncCallHandler *call_handler,
+ int timeout);
+
+ // Inherited properties from ModemProxyInterface.
+ virtual const ::DBus::Path Sim();
+ virtual uint32_t ModemCapabilities();
+ virtual uint32_t CurrentCapabilities();
+ virtual uint32_t MaxBearers();
+ virtual uint32_t MaxActiveBearers();
+ virtual const std::string Manufacturer();
+ virtual const std::string Model();
+ virtual const std::string Revision();
+ virtual const std::string DeviceIdentifier();
+ virtual const std::string Device();
+ virtual const std::string Driver();
+ virtual const std::string Plugin();
+ virtual const std::string EquipmentIdentifier();
+ virtual uint32_t UnlockRequired();
+ virtual const std::map< uint32_t, uint32_t > UnlockRetries();
+ virtual uint32_t State();
+ virtual uint32_t AccessTechnologies();
+ virtual const ::DBus::Struct< uint32_t, bool > SignalQuality();
+ virtual uint32_t SupportedModes();
+ virtual uint32_t AllowedModes();
+ virtual uint32_t PreferredMode();
+ virtual const std::vector< uint32_t > SupportedBands();
+ virtual const std::vector< uint32_t > Bands();
+
+ private:
+ class Proxy : public org::freedesktop::ModemManager1::Modem_proxy,
+ public DBus::ObjectProxy {
+ public:
+ Proxy(ModemProxyDelegate *delegate,
+ DBus::Connection *connection,
+ const std::string &path,
+ const std::string &service);
+ virtual ~Proxy();
+
+ private:
+ // Signal callbacks inherited from Proxy
+ // handle signals
+ void StateChanged(const uint32_t &old,
+ const uint32_t &_new,
+ const uint32_t &reason);
+
+ // Method callbacks inherited from
+ // org::freedesktop::ModemManager1::ModemProxy
+ virtual void EnableCallback(const ::DBus::Error &dberror, void *data);
+ virtual void ListBearersCallback(
+ const std::vector< ::DBus::Path > &bearers,
+ const ::DBus::Error &dberror, void *data);
+ virtual void CreateBearerCallback(const ::DBus::Path &bearer,
+ const ::DBus::Error &dberror, void *data);
+ virtual void DeleteBearerCallback(const ::DBus::Error &dberror, void *data);
+ virtual void ResetCallback(const ::DBus::Error &dberror, void *data);
+ virtual void FactoryResetCallback(const ::DBus::Error &dberror, void *data);
+ virtual void SetAllowedModesCallback(const ::DBus::Error &dberror,
+ void *data);
+ virtual void SetBandsCallback(const ::DBus::Error &dberror, void *data);
+ virtual void CommandCallback(const std::string &response,
+ const ::DBus::Error &dberror,
+ void *data);
+
+ ModemProxyDelegate *delegate_;
+
+ DISALLOW_COPY_AND_ASSIGN(Proxy);
+ };
+
+ Proxy proxy_;
+
+ DISALLOW_COPY_AND_ASSIGN(ModemProxy);
+};
+
+} // namespace mm1
+} // namespace shill
+
+#endif // SHILL_MM1_MODEM_PROXY_
diff --git a/mm1_modem_proxy_interface.h b/mm1_modem_proxy_interface.h
new file mode 100644
index 0000000..c12717a
--- /dev/null
+++ b/mm1_modem_proxy_interface.h
@@ -0,0 +1,122 @@
+// Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef SHILL_MM1_MODEM_PROXY_INTERFACE_
+#define SHILL_MM1_MODEM_PROXY_INTERFACE_
+
+#include <string>
+
+#include <base/basictypes.h>
+
+#include "shill/dbus_properties.h"
+
+namespace shill {
+class AsyncCallHandler;
+class Error;
+
+namespace mm1 {
+
+// These are the methods that a org.freedesktop.ModemManager1.Modem
+// proxy must support. The interface is provided so that it can be
+// mocked in tests. All calls are made asynchronously. Call
+// completion is signalled through the corresponding 'OnXXXCallback'
+// method in the ProxyDelegate interface.
+class ModemProxyInterface {
+ public:
+ virtual ~ModemProxyInterface() {}
+
+ virtual void Enable(const bool &enable,
+ AsyncCallHandler *call_handler,
+ int timeout) = 0;
+ virtual void ListBearers(AsyncCallHandler *call_handler,
+ int timeout) = 0;
+ virtual void CreateBearer(
+ const DBusPropertiesMap &properties,
+ AsyncCallHandler *call_handler,
+ int timeout) = 0;
+ virtual void DeleteBearer(const ::DBus::Path &bearer,
+ AsyncCallHandler *call_handler,
+ int timeout) = 0;
+ virtual void Reset(AsyncCallHandler *call_handler, int timeout) = 0;
+ virtual void FactoryReset(const std::string &code,
+ AsyncCallHandler *call_handler,
+ int timeout) = 0;
+ virtual void SetAllowedModes(const uint32_t &modes,
+ const uint32_t &preferred,
+ AsyncCallHandler *call_handler,
+ int timeout) = 0;
+ virtual void SetBands(const std::vector< uint32_t > &bands,
+ AsyncCallHandler *call_handler,
+ int timeout) = 0;
+ virtual void Command(const std::string &cmd,
+ const uint32_t &user_timeout,
+ AsyncCallHandler *call_handler,
+ int timeout) = 0;
+
+ // Properties.
+ virtual const ::DBus::Path Sim() = 0;
+ virtual uint32_t ModemCapabilities() = 0;
+ virtual uint32_t CurrentCapabilities() = 0;
+ virtual uint32_t MaxBearers() = 0;
+ virtual uint32_t MaxActiveBearers() = 0;
+ virtual const std::string Manufacturer() = 0;
+ virtual const std::string Model() = 0;
+ virtual const std::string Revision() = 0;
+ virtual const std::string DeviceIdentifier() = 0;
+ virtual const std::string Device() = 0;
+ virtual const std::string Driver() = 0;
+ virtual const std::string Plugin() = 0;
+ virtual const std::string EquipmentIdentifier() = 0;
+ virtual uint32_t UnlockRequired() = 0;
+ virtual const std::map< uint32_t, uint32_t > UnlockRetries() = 0;
+ virtual uint32_t State() = 0;
+ virtual uint32_t AccessTechnologies() = 0;
+ virtual const ::DBus::Struct< uint32_t, bool > SignalQuality() = 0;
+ virtual uint32_t SupportedModes() = 0;
+ virtual uint32_t AllowedModes() = 0;
+ virtual uint32_t PreferredMode() = 0;
+ virtual const std::vector< uint32_t > SupportedBands() = 0;
+ virtual const std::vector< uint32_t > Bands() = 0;
+};
+
+
+// ModemManager1.Modem signal delegate to be associated with the proxy.
+class ModemProxyDelegate {
+ public:
+ virtual ~ModemProxyDelegate() {}
+
+ // handle signals
+ virtual void OnStateChanged(const uint32_t &old,
+ const uint32_t &_new,
+ const uint32_t &reason) = 0;
+
+ // Handle async callbacks
+ virtual void OnEnableCallback(const Error &error,
+ AsyncCallHandler *call_handler) = 0;
+ virtual void OnListBearersCallback(
+ const std::vector< ::DBus::Path > &bearers,
+ const Error &error,
+ AsyncCallHandler *call_handler) = 0;
+ virtual void OnCreateBearerCallback(const ::DBus::Path &bearer,
+ const Error &error,
+ AsyncCallHandler *call_handler) = 0;
+ virtual void OnDeleteBearerCallback(const Error &error,
+ AsyncCallHandler *call_handler) = 0;
+ virtual void OnResetCallback(const Error &error,
+ AsyncCallHandler *call_handler) = 0;
+ virtual void OnFactoryResetCallback(const Error &error,
+ AsyncCallHandler *call_handler) = 0;
+ virtual void OnSetAllowedModesCallback(const Error &error,
+ AsyncCallHandler *call_handler) = 0;
+ virtual void OnSetBandsCallback(const Error &error,
+ AsyncCallHandler *call_handler) = 0;
+ virtual void OnCommandCallback(const std::string &response,
+ const Error &error,
+ AsyncCallHandler *call_handler) = 0;
+};
+
+} // namespace mm1
+} // namespace shill
+
+#endif // SHILL_MM1_MODEM_PROXY_INTERFACE_
diff --git a/mm1_modem_simple_proxy.cc b/mm1_modem_simple_proxy.cc
new file mode 100644
index 0000000..077d982
--- /dev/null
+++ b/mm1_modem_simple_proxy.cc
@@ -0,0 +1,83 @@
+// Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "shill/mm1_modem_simple_proxy.h"
+
+#include <base/logging.h>
+
+#include "cellular_error.h"
+#include "async_call_handler.h"
+
+using std::string;
+
+namespace shill {
+namespace mm1 {
+
+ModemSimpleProxy::ModemSimpleProxy(ModemSimpleProxyDelegate *delegate,
+ DBus::Connection *connection,
+ const string &path,
+ const string &service)
+ : proxy_(delegate, connection, path, service) {}
+
+ModemSimpleProxy::~ModemSimpleProxy() {}
+
+void ModemSimpleProxy::Connect(
+ const DBusPropertiesMap &properties,
+ AsyncCallHandler *call_handler,
+ int timeout) {
+ proxy_.Connect(properties, call_handler, timeout);
+}
+
+void ModemSimpleProxy::Disconnect(const ::DBus::Path &bearer,
+ AsyncCallHandler *call_handler,
+ int timeout) {
+ proxy_.Disconnect(bearer, call_handler, timeout);
+}
+
+void ModemSimpleProxy::GetStatus(AsyncCallHandler *call_handler, int timeout) {
+ proxy_.GetStatus(call_handler, timeout);
+}
+
+
+// ModemSimpleProxy::Proxy
+ModemSimpleProxy::Proxy::Proxy(ModemSimpleProxyDelegate *delegate,
+ DBus::Connection *connection,
+ const std::string &path,
+ const std::string &service)
+ : DBus::ObjectProxy(*connection, path, service.c_str()),
+ delegate_(delegate) {}
+
+ModemSimpleProxy::Proxy::~Proxy() {}
+
+// Method callbacks inherited from
+// org::freedesktop::ModemManager1::Modem::ModemSimpleProxy
+void ModemSimpleProxy::Proxy::ConnectCallback(const ::DBus::Path &bearer,
+ const ::DBus::Error &dberror,
+ void *data) {
+ AsyncCallHandler *call_handler = reinterpret_cast<AsyncCallHandler *>(data);
+ Error error;
+ CellularError::FromDBusError(dberror, &error),
+ delegate_->OnConnectCallback(bearer, error, call_handler);
+}
+
+void ModemSimpleProxy::Proxy::DisconnectCallback(const ::DBus::Error &dberror,
+ void *data) {
+ AsyncCallHandler *call_handler = reinterpret_cast<AsyncCallHandler *>(data);
+ Error error;
+ CellularError::FromDBusError(dberror, &error),
+ delegate_->OnDisconnectCallback(error, call_handler);
+}
+
+void ModemSimpleProxy::Proxy::GetStatusCallback(
+ const DBusPropertiesMap &properties,
+ const ::DBus::Error &dberror,
+ void *data) {
+ AsyncCallHandler *call_handler = reinterpret_cast<AsyncCallHandler *>(data);
+ Error error;
+ CellularError::FromDBusError(dberror, &error),
+ delegate_->OnGetStatusCallback(properties, error, call_handler);
+}
+
+} // namespace mm1
+} // namespace shill
diff --git a/mm1_modem_simple_proxy.h b/mm1_modem_simple_proxy.h
new file mode 100644
index 0000000..a438df0
--- /dev/null
+++ b/mm1_modem_simple_proxy.h
@@ -0,0 +1,72 @@
+// Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef SHILL_MM1_MODEM_SIMPLE_PROXY_
+#define SHILL_MM1_MODEM_SIMPLE_PROXY_
+
+#include <string>
+
+#include "shill/dbus_bindings/mm1-modem-simple.h"
+#include "shill/dbus_properties.h"
+#include "shill/mm1_modem_simple_proxy_interface.h"
+
+namespace shill {
+namespace mm1 {
+
+class ModemSimpleProxy : public ModemSimpleProxyInterface {
+ public:
+ // Constructs a org.freedesktop.ModemManager1.Modem.Simple DBus
+ // object proxy at |path| owned by |service|. Caught signals and
+ // asynchronous method replies will be dispatched to |delegate|.
+ ModemSimpleProxy(ModemSimpleProxyDelegate *delegate,
+ DBus::Connection *connection,
+ const std::string &path,
+ const std::string &service);
+ virtual ~ModemSimpleProxy();
+
+ // Inherited methods from SimpleProxyInterface.
+ virtual void Connect(
+ const DBusPropertiesMap &properties,
+ AsyncCallHandler *call_handler,
+ int timeout);
+ virtual void Disconnect(const ::DBus::Path &bearer,
+ AsyncCallHandler *call_handler,
+ int timeout);
+ virtual void GetStatus(AsyncCallHandler *call_handler, int timeout);
+
+ private:
+ class Proxy : public org::freedesktop::ModemManager1::Modem::Simple_proxy,
+ public DBus::ObjectProxy {
+ public:
+ Proxy(ModemSimpleProxyDelegate *delegate,
+ DBus::Connection *connection,
+ const std::string &path,
+ const std::string &service);
+ virtual ~Proxy();
+
+ private:
+ // Method callbacks inherited from
+ // org::freedesktop::ModemManager1::Modem::SimpleProxy
+ virtual void ConnectCallback(const ::DBus::Path &bearer,
+ const ::DBus::Error &dberror,
+ void *data);
+ virtual void DisconnectCallback(const ::DBus::Error &dberror, void *data);
+ virtual void GetStatusCallback(
+ const DBusPropertiesMap &bearer,
+ const ::DBus::Error &dberror,
+ void *data);
+ ModemSimpleProxyDelegate *delegate_;
+
+ DISALLOW_COPY_AND_ASSIGN(Proxy);
+ };
+
+ Proxy proxy_;
+
+ DISALLOW_COPY_AND_ASSIGN(ModemSimpleProxy);
+};
+
+} // namespace mm1
+} // namespace shill
+
+#endif // SHILL_MM1_MODEM_SIMPLE_PROXY_
diff --git a/mm1_modem_simple_proxy_interface.h b/mm1_modem_simple_proxy_interface.h
new file mode 100644
index 0000000..99bdafc
--- /dev/null
+++ b/mm1_modem_simple_proxy_interface.h
@@ -0,0 +1,62 @@
+// Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef SHILL_MM1_MODEM_SIMPLE_PROXY_INTERFACE_
+#define SHILL_MM1_MODEM_SIMPLE_PROXY_INTERFACE_
+
+#include <string>
+
+#include <base/basictypes.h>
+
+#include "shill/dbus_properties.h"
+
+namespace shill {
+class AsyncCallHandler;
+class Error;
+
+namespace mm1 {
+
+// These are the methods that a
+// org.freedesktop.ModemManager1.Modem.Simple proxy must support. The
+// interface is provided so that it can be mocked in tests. All calls
+// are made asynchronously. Call completion is signalled through the
+// corresponding 'OnXXXCallback' method in the ProxyDelegate
+// interface.
+class ModemSimpleProxyInterface {
+ public:
+ virtual ~ModemSimpleProxyInterface() {}
+
+ virtual void Connect(
+ const DBusPropertiesMap &properties,
+ AsyncCallHandler *call_handler,
+ int timeout) = 0;
+ virtual void Disconnect(const ::DBus::Path &bearer,
+ AsyncCallHandler *call_handler,
+ int timeout) = 0;
+ virtual void GetStatus(AsyncCallHandler *call_handler,
+ int timeout) = 0;
+};
+
+// ModemManager1.Modem.Simple signal delegate to be associated with
+// the proxy.
+class ModemSimpleProxyDelegate {
+ public:
+ virtual ~ModemSimpleProxyDelegate() {}
+
+ // Handle async callbacks
+ virtual void OnConnectCallback(const ::DBus::Path &bearer,
+ const Error &error,
+ AsyncCallHandler *call_handler) = 0;
+ virtual void OnDisconnectCallback(const Error &error,
+ AsyncCallHandler *call_handler) = 0;
+ virtual void OnGetStatusCallback(
+ const DBusPropertiesMap &bearer,
+ const Error &error,
+ AsyncCallHandler *call_handler) = 0;
+};
+
+} // namespace mm1
+} // namespace shill
+
+#endif // SHILL_MM1_MODEM_SIMPLE_PROXY_INTERFACE_