Jason Glasgow | ee1081c | 2012-03-06 15:14:53 -0500 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium OS Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
Ben Chan | 74924d8 | 2013-06-15 17:52:55 -0700 | [diff] [blame] | 5 | #ifndef SHILL_MM1_MODEM_PROXY_H_ |
| 6 | #define SHILL_MM1_MODEM_PROXY_H_ |
Jason Glasgow | ee1081c | 2012-03-06 15:14:53 -0500 | [diff] [blame] | 7 | |
| 8 | #include <string> |
| 9 | |
Liam McLoughlin | ef342b4 | 2013-09-13 21:05:36 +0100 | [diff] [blame] | 10 | #include "dbus_proxies/org.freedesktop.ModemManager1.Modem.h" |
Jason Glasgow | ee1081c | 2012-03-06 15:14:53 -0500 | [diff] [blame] | 11 | #include "shill/dbus_properties.h" |
| 12 | #include "shill/mm1_modem_proxy_interface.h" |
| 13 | |
| 14 | namespace shill { |
Jason Glasgow | ee1081c | 2012-03-06 15:14:53 -0500 | [diff] [blame] | 15 | namespace mm1 { |
| 16 | |
mukesh agrawal | f407d59 | 2013-07-31 11:37:57 -0700 | [diff] [blame] | 17 | // A proxy to org.freedesktop.ModemManager1.Modem. |
Jason Glasgow | ee1081c | 2012-03-06 15:14:53 -0500 | [diff] [blame] | 18 | class ModemProxy : public ModemProxyInterface { |
| 19 | public: |
| 20 | // Constructs a org.freedesktop.ModemManager1.Modem DBus object |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 21 | // proxy at |path| owned by |service|. |
| 22 | ModemProxy(DBus::Connection *connection, |
Jason Glasgow | ee1081c | 2012-03-06 15:14:53 -0500 | [diff] [blame] | 23 | const std::string &path, |
| 24 | const std::string &service); |
| 25 | virtual ~ModemProxy(); |
| 26 | |
| 27 | // Inherited methods from ModemProxyInterface. |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 28 | virtual void Enable(bool enable, |
| 29 | Error *error, |
| 30 | const ResultCallback &callback, |
Jason Glasgow | ee1081c | 2012-03-06 15:14:53 -0500 | [diff] [blame] | 31 | int timeout); |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 32 | virtual void CreateBearer(const DBusPropertiesMap &properties, |
| 33 | Error *error, |
| 34 | const DBusPathCallback &callback, |
| 35 | int timeout); |
Jason Glasgow | ee1081c | 2012-03-06 15:14:53 -0500 | [diff] [blame] | 36 | virtual void DeleteBearer(const ::DBus::Path &bearer, |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 37 | Error *error, |
| 38 | const ResultCallback &callback, |
Jason Glasgow | ee1081c | 2012-03-06 15:14:53 -0500 | [diff] [blame] | 39 | int timeout); |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 40 | virtual void Reset(Error *error, |
| 41 | const ResultCallback &callback, |
| 42 | int timeout); |
Jason Glasgow | ee1081c | 2012-03-06 15:14:53 -0500 | [diff] [blame] | 43 | virtual void FactoryReset(const std::string &code, |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 44 | Error *error, |
| 45 | const ResultCallback &callback, |
Jason Glasgow | ee1081c | 2012-03-06 15:14:53 -0500 | [diff] [blame] | 46 | int timeout); |
Ben Chan | 74924d8 | 2013-06-15 17:52:55 -0700 | [diff] [blame] | 47 | virtual void SetCurrentCapabilities(const uint32_t &capabilities, |
| 48 | Error *error, |
| 49 | const ResultCallback &callback, |
| 50 | int timeout); |
| 51 | virtual void SetCurrentModes(const ::DBus::Struct<uint32_t, uint32_t> &modes, |
| 52 | Error *error, |
| 53 | const ResultCallback &callback, |
| 54 | int timeout); |
| 55 | virtual void SetCurrentBands(const std::vector<uint32_t> &bands, |
| 56 | Error *error, |
| 57 | const ResultCallback &callback, |
| 58 | int timeout); |
Jason Glasgow | ee1081c | 2012-03-06 15:14:53 -0500 | [diff] [blame] | 59 | virtual void Command(const std::string &cmd, |
| 60 | const uint32_t &user_timeout, |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 61 | Error *error, |
| 62 | const StringCallback &callback, |
Jason Glasgow | ee1081c | 2012-03-06 15:14:53 -0500 | [diff] [blame] | 63 | int timeout); |
Arman Uguray | ee464d3 | 2013-02-13 17:14:36 -0800 | [diff] [blame] | 64 | virtual void SetPowerState(const uint32_t &power_state, |
| 65 | Error *error, |
| 66 | const ResultCallback &callback, |
| 67 | int timeout); |
Jason Glasgow | ee1081c | 2012-03-06 15:14:53 -0500 | [diff] [blame] | 68 | |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 69 | virtual void set_state_changed_callback( |
| 70 | const ModemStateChangedSignalCallback &callback); |
| 71 | |
Jason Glasgow | ee1081c | 2012-03-06 15:14:53 -0500 | [diff] [blame] | 72 | private: |
| 73 | class Proxy : public org::freedesktop::ModemManager1::Modem_proxy, |
| 74 | public DBus::ObjectProxy { |
| 75 | public: |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 76 | Proxy(DBus::Connection *connection, |
Jason Glasgow | ee1081c | 2012-03-06 15:14:53 -0500 | [diff] [blame] | 77 | const std::string &path, |
| 78 | const std::string &service); |
| 79 | virtual ~Proxy(); |
| 80 | |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 81 | void set_state_changed_callback( |
| 82 | const ModemStateChangedSignalCallback &callback); |
| 83 | |
Jason Glasgow | ee1081c | 2012-03-06 15:14:53 -0500 | [diff] [blame] | 84 | private: |
| 85 | // Signal callbacks inherited from Proxy |
| 86 | // handle signals |
Nathan Williams | a31e79c | 2012-03-30 15:07:00 -0400 | [diff] [blame] | 87 | void StateChanged(const int32_t &old, |
| 88 | const int32_t &_new, |
Jason Glasgow | ee1081c | 2012-03-06 15:14:53 -0500 | [diff] [blame] | 89 | const uint32_t &reason); |
| 90 | |
| 91 | // Method callbacks inherited from |
| 92 | // org::freedesktop::ModemManager1::ModemProxy |
| 93 | virtual void EnableCallback(const ::DBus::Error &dberror, void *data); |
Jason Glasgow | ee1081c | 2012-03-06 15:14:53 -0500 | [diff] [blame] | 94 | virtual void CreateBearerCallback(const ::DBus::Path &bearer, |
| 95 | const ::DBus::Error &dberror, void *data); |
| 96 | virtual void DeleteBearerCallback(const ::DBus::Error &dberror, void *data); |
| 97 | virtual void ResetCallback(const ::DBus::Error &dberror, void *data); |
| 98 | virtual void FactoryResetCallback(const ::DBus::Error &dberror, void *data); |
Ben Chan | 74924d8 | 2013-06-15 17:52:55 -0700 | [diff] [blame] | 99 | virtual void SetCurrentCapabilitesCallback(const ::DBus::Error &dberror, |
| 100 | void *data); |
| 101 | virtual void SetCurrentModesCallback(const ::DBus::Error &dberror, |
| 102 | void *data); |
| 103 | virtual void SetCurrentBandsCallback(const ::DBus::Error &dberror, |
| 104 | void *data); |
Jason Glasgow | ee1081c | 2012-03-06 15:14:53 -0500 | [diff] [blame] | 105 | virtual void CommandCallback(const std::string &response, |
| 106 | const ::DBus::Error &dberror, |
| 107 | void *data); |
Arman Uguray | ee464d3 | 2013-02-13 17:14:36 -0800 | [diff] [blame] | 108 | virtual void SetPowerStateCallback(const ::DBus::Error &dberror, |
| 109 | void *data); |
Jason Glasgow | ee1081c | 2012-03-06 15:14:53 -0500 | [diff] [blame] | 110 | |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 111 | ModemStateChangedSignalCallback state_changed_callback_; |
Jason Glasgow | ee1081c | 2012-03-06 15:14:53 -0500 | [diff] [blame] | 112 | |
| 113 | DISALLOW_COPY_AND_ASSIGN(Proxy); |
| 114 | }; |
| 115 | |
| 116 | Proxy proxy_; |
| 117 | |
mukesh agrawal | 0e9e9d1 | 2014-04-18 16:09:58 -0700 | [diff] [blame] | 118 | template<typename TraceMsgT, typename CallT, typename CallbackT, |
| 119 | typename... ArgTypes> |
| 120 | void BeginCall( |
| 121 | const TraceMsgT &trace_msg, const CallT &call, CallbackT &callback, |
| 122 | Error *error, int timeout, ArgTypes... rest); |
| 123 | |
Jason Glasgow | ee1081c | 2012-03-06 15:14:53 -0500 | [diff] [blame] | 124 | DISALLOW_COPY_AND_ASSIGN(ModemProxy); |
| 125 | }; |
| 126 | |
| 127 | } // namespace mm1 |
| 128 | } // namespace shill |
| 129 | |
Ben Chan | 74924d8 | 2013-06-15 17:52:55 -0700 | [diff] [blame] | 130 | #endif // SHILL_MM1_MODEM_PROXY_H_ |