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 | |
| 5 | #ifndef SHILL_MM1_MODEM_PROXY_ |
| 6 | #define SHILL_MM1_MODEM_PROXY_ |
| 7 | |
| 8 | #include <string> |
| 9 | |
| 10 | #include "shill/dbus_bindings/mm1-modem.h" |
| 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 | |
| 17 | class ModemProxy : public ModemProxyInterface { |
| 18 | public: |
| 19 | // Constructs a org.freedesktop.ModemManager1.Modem DBus object |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 20 | // proxy at |path| owned by |service|. |
| 21 | ModemProxy(DBus::Connection *connection, |
Jason Glasgow | ee1081c | 2012-03-06 15:14:53 -0500 | [diff] [blame] | 22 | const std::string &path, |
| 23 | const std::string &service); |
| 24 | virtual ~ModemProxy(); |
| 25 | |
| 26 | // Inherited methods from ModemProxyInterface. |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 27 | virtual void Enable(bool enable, |
| 28 | Error *error, |
| 29 | const ResultCallback &callback, |
Jason Glasgow | ee1081c | 2012-03-06 15:14:53 -0500 | [diff] [blame] | 30 | int timeout); |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 31 | virtual void ListBearers(Error *error, |
| 32 | const DBusPathsCallback &callback, |
| 33 | int timeout); |
| 34 | virtual void CreateBearer(const DBusPropertiesMap &properties, |
| 35 | Error *error, |
| 36 | const DBusPathCallback &callback, |
| 37 | int timeout); |
Jason Glasgow | ee1081c | 2012-03-06 15:14:53 -0500 | [diff] [blame] | 38 | virtual void DeleteBearer(const ::DBus::Path &bearer, |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 39 | Error *error, |
| 40 | const ResultCallback &callback, |
Jason Glasgow | ee1081c | 2012-03-06 15:14:53 -0500 | [diff] [blame] | 41 | int timeout); |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 42 | virtual void Reset(Error *error, |
| 43 | const ResultCallback &callback, |
| 44 | int timeout); |
Jason Glasgow | ee1081c | 2012-03-06 15:14:53 -0500 | [diff] [blame] | 45 | virtual void FactoryReset(const std::string &code, |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 46 | Error *error, |
| 47 | const ResultCallback &callback, |
Jason Glasgow | ee1081c | 2012-03-06 15:14:53 -0500 | [diff] [blame] | 48 | int timeout); |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 49 | virtual void SetAllowedModes(const uint32_t &modes, |
| 50 | const uint32_t &preferred, |
| 51 | Error *error, |
| 52 | const ResultCallback &callback, |
Jason Glasgow | ee1081c | 2012-03-06 15:14:53 -0500 | [diff] [blame] | 53 | int timeout); |
| 54 | virtual void SetBands(const std::vector< uint32_t > &bands, |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 55 | Error *error, |
| 56 | const ResultCallback &callback, |
Jason Glasgow | ee1081c | 2012-03-06 15:14:53 -0500 | [diff] [blame] | 57 | int timeout); |
| 58 | virtual void Command(const std::string &cmd, |
| 59 | const uint32_t &user_timeout, |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 60 | Error *error, |
| 61 | const StringCallback &callback, |
Jason Glasgow | ee1081c | 2012-03-06 15:14:53 -0500 | [diff] [blame] | 62 | int timeout); |
| 63 | |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 64 | virtual void set_state_changed_callback( |
| 65 | const ModemStateChangedSignalCallback &callback); |
| 66 | |
Jason Glasgow | ee1081c | 2012-03-06 15:14:53 -0500 | [diff] [blame] | 67 | // Inherited properties from ModemProxyInterface. |
| 68 | virtual const ::DBus::Path Sim(); |
| 69 | virtual uint32_t ModemCapabilities(); |
| 70 | virtual uint32_t CurrentCapabilities(); |
| 71 | virtual uint32_t MaxBearers(); |
| 72 | virtual uint32_t MaxActiveBearers(); |
| 73 | virtual const std::string Manufacturer(); |
| 74 | virtual const std::string Model(); |
| 75 | virtual const std::string Revision(); |
| 76 | virtual const std::string DeviceIdentifier(); |
| 77 | virtual const std::string Device(); |
Ben Chan | 34e5d68 | 2012-08-24 19:10:49 -0700 | [diff] [blame] | 78 | virtual const std::vector<std::string> Drivers(); |
Jason Glasgow | ee1081c | 2012-03-06 15:14:53 -0500 | [diff] [blame] | 79 | virtual const std::string Plugin(); |
| 80 | virtual const std::string EquipmentIdentifier(); |
| 81 | virtual uint32_t UnlockRequired(); |
| 82 | virtual const std::map< uint32_t, uint32_t > UnlockRetries(); |
| 83 | virtual uint32_t State(); |
| 84 | virtual uint32_t AccessTechnologies(); |
| 85 | virtual const ::DBus::Struct< uint32_t, bool > SignalQuality(); |
Jason Glasgow | 90d216d | 2012-04-04 15:57:14 -0400 | [diff] [blame] | 86 | virtual const std::vector< std::string > OwnNumbers(); |
Jason Glasgow | ee1081c | 2012-03-06 15:14:53 -0500 | [diff] [blame] | 87 | virtual uint32_t SupportedModes(); |
| 88 | virtual uint32_t AllowedModes(); |
| 89 | virtual uint32_t PreferredMode(); |
| 90 | virtual const std::vector< uint32_t > SupportedBands(); |
| 91 | virtual const std::vector< uint32_t > Bands(); |
| 92 | |
| 93 | private: |
| 94 | class Proxy : public org::freedesktop::ModemManager1::Modem_proxy, |
| 95 | public DBus::ObjectProxy { |
| 96 | public: |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 97 | Proxy(DBus::Connection *connection, |
Jason Glasgow | ee1081c | 2012-03-06 15:14:53 -0500 | [diff] [blame] | 98 | const std::string &path, |
| 99 | const std::string &service); |
| 100 | virtual ~Proxy(); |
| 101 | |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 102 | void set_state_changed_callback( |
| 103 | const ModemStateChangedSignalCallback &callback); |
| 104 | |
Jason Glasgow | ee1081c | 2012-03-06 15:14:53 -0500 | [diff] [blame] | 105 | private: |
| 106 | // Signal callbacks inherited from Proxy |
| 107 | // handle signals |
Nathan Williams | a31e79c | 2012-03-30 15:07:00 -0400 | [diff] [blame] | 108 | void StateChanged(const int32_t &old, |
| 109 | const int32_t &_new, |
Jason Glasgow | ee1081c | 2012-03-06 15:14:53 -0500 | [diff] [blame] | 110 | const uint32_t &reason); |
| 111 | |
| 112 | // Method callbacks inherited from |
| 113 | // org::freedesktop::ModemManager1::ModemProxy |
| 114 | virtual void EnableCallback(const ::DBus::Error &dberror, void *data); |
| 115 | virtual void ListBearersCallback( |
| 116 | const std::vector< ::DBus::Path > &bearers, |
| 117 | const ::DBus::Error &dberror, void *data); |
| 118 | virtual void CreateBearerCallback(const ::DBus::Path &bearer, |
| 119 | const ::DBus::Error &dberror, void *data); |
| 120 | virtual void DeleteBearerCallback(const ::DBus::Error &dberror, void *data); |
| 121 | virtual void ResetCallback(const ::DBus::Error &dberror, void *data); |
| 122 | virtual void FactoryResetCallback(const ::DBus::Error &dberror, void *data); |
| 123 | virtual void SetAllowedModesCallback(const ::DBus::Error &dberror, |
| 124 | void *data); |
| 125 | virtual void SetBandsCallback(const ::DBus::Error &dberror, void *data); |
| 126 | virtual void CommandCallback(const std::string &response, |
| 127 | const ::DBus::Error &dberror, |
| 128 | void *data); |
| 129 | |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 130 | ModemStateChangedSignalCallback state_changed_callback_; |
Jason Glasgow | ee1081c | 2012-03-06 15:14:53 -0500 | [diff] [blame] | 131 | |
| 132 | DISALLOW_COPY_AND_ASSIGN(Proxy); |
| 133 | }; |
| 134 | |
| 135 | Proxy proxy_; |
| 136 | |
| 137 | DISALLOW_COPY_AND_ASSIGN(ModemProxy); |
| 138 | }; |
| 139 | |
| 140 | } // namespace mm1 |
| 141 | } // namespace shill |
| 142 | |
| 143 | #endif // SHILL_MM1_MODEM_PROXY_ |