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