Darin Petkov | fb0625e | 2012-01-16 13:05:56 +0100 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium OS Authors. All rights reserved. |
Darin Petkov | e9d12e0 | 2011-07-27 15:09:37 -0700 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef SHILL_MODEM_PROXY_ |
| 6 | #define SHILL_MODEM_PROXY_ |
| 7 | |
Hristo Stefanov | ed2c28c | 2011-11-29 15:37:30 -0800 | [diff] [blame] | 8 | #include <string> |
| 9 | |
Darin Petkov | e9d12e0 | 2011-07-27 15:09:37 -0700 | [diff] [blame] | 10 | #include <base/basictypes.h> |
| 11 | |
| 12 | #include "shill/dbus_bindings/modem.h" |
| 13 | #include "shill/modem_proxy_interface.h" |
| 14 | |
| 15 | namespace shill { |
| 16 | |
mukesh agrawal | f407d59 | 2013-07-31 11:37:57 -0700 | [diff] [blame] | 17 | // A proxy to (old) ModemManager.Modem. |
Darin Petkov | e9d12e0 | 2011-07-27 15:09:37 -0700 | [diff] [blame] | 18 | class ModemProxy : public ModemProxyInterface { |
| 19 | public: |
Darin Petkov | c5f5656 | 2011-08-06 16:40:05 -0700 | [diff] [blame] | 20 | // Constructs a ModemManager.Modem DBus object proxy at |path| owned by |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 21 | // |service|. |
| 22 | ModemProxy(DBus::Connection *connection, |
Darin Petkov | e9d12e0 | 2011-07-27 15:09:37 -0700 | [diff] [blame] | 23 | const std::string &path, |
| 24 | const std::string &service); |
| 25 | virtual ~ModemProxy(); |
| 26 | |
| 27 | // Inherited from ModemProxyInterface. |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 28 | virtual void Enable(bool enable, Error *error, |
| 29 | const ResultCallback &callback, int timeout); |
| 30 | virtual void Disconnect(Error *error, const ResultCallback &callback, |
| 31 | int timeout); |
| 32 | virtual void GetModemInfo(Error *error, const ModemInfoCallback &callback, |
| 33 | int timeout); |
| 34 | |
| 35 | virtual void set_state_changed_callback( |
| 36 | const ModemStateChangedSignalCallback &callback); |
Darin Petkov | e9d12e0 | 2011-07-27 15:09:37 -0700 | [diff] [blame] | 37 | |
| 38 | private: |
| 39 | class Proxy : public org::freedesktop::ModemManager::Modem_proxy, |
| 40 | public DBus::ObjectProxy { |
| 41 | public: |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 42 | Proxy(DBus::Connection *connection, |
Darin Petkov | e9d12e0 | 2011-07-27 15:09:37 -0700 | [diff] [blame] | 43 | const std::string &path, |
| 44 | const std::string &service); |
| 45 | virtual ~Proxy(); |
| 46 | |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 47 | void set_state_changed_callback( |
| 48 | const ModemStateChangedSignalCallback &callback); |
| 49 | |
Darin Petkov | e9d12e0 | 2011-07-27 15:09:37 -0700 | [diff] [blame] | 50 | private: |
| 51 | // Signal callbacks inherited from ModemManager::Modem_proxy. |
Eric Shienbrood | 5de44ab | 2011-12-05 10:46:27 -0500 | [diff] [blame] | 52 | virtual void StateChanged( |
| 53 | const uint32 &old, const uint32 &_new, const uint32 &reason); |
| 54 | |
| 55 | // Method callbacks inherited from ModemManager::Modem_proxy. |
| 56 | virtual void EnableCallback(const DBus::Error &dberror, void *data); |
| 57 | virtual void GetInfoCallback(const ModemHardwareInfo &info, |
| 58 | const DBus::Error &dberror, void *data); |
| 59 | virtual void DisconnectCallback(const DBus::Error &dberror, void *data); |
Darin Petkov | e9d12e0 | 2011-07-27 15:09:37 -0700 | [diff] [blame] | 60 | |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 61 | ModemStateChangedSignalCallback state_changed_callback_; |
Darin Petkov | c5f5656 | 2011-08-06 16:40:05 -0700 | [diff] [blame] | 62 | |
Darin Petkov | e9d12e0 | 2011-07-27 15:09:37 -0700 | [diff] [blame] | 63 | DISALLOW_COPY_AND_ASSIGN(Proxy); |
| 64 | }; |
| 65 | |
| 66 | Proxy proxy_; |
| 67 | |
| 68 | DISALLOW_COPY_AND_ASSIGN(ModemProxy); |
| 69 | }; |
| 70 | |
| 71 | } // namespace shill |
| 72 | |
| 73 | #endif // SHILL_MODEM_PROXY_ |