blob: c6463269dd4351001cf1fa79716ec6537df05aa5 [file] [log] [blame]
Jason Glasgowee1081c2012-03-06 15:14:53 -05001// 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 Chan74924d82013-06-15 17:52:55 -07005#ifndef SHILL_MM1_MODEM_PROXY_H_
6#define SHILL_MM1_MODEM_PROXY_H_
Jason Glasgowee1081c2012-03-06 15:14:53 -05007
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
14namespace shill {
Jason Glasgowee1081c2012-03-06 15:14:53 -050015namespace mm1 {
16
17class ModemProxy : public ModemProxyInterface {
18 public:
19 // Constructs a org.freedesktop.ModemManager1.Modem DBus object
Eric Shienbrood9a245532012-03-07 14:20:39 -050020 // proxy at |path| owned by |service|.
21 ModemProxy(DBus::Connection *connection,
Jason Glasgowee1081c2012-03-06 15:14:53 -050022 const std::string &path,
23 const std::string &service);
24 virtual ~ModemProxy();
25
26 // Inherited methods from ModemProxyInterface.
Eric Shienbrood9a245532012-03-07 14:20:39 -050027 virtual void Enable(bool enable,
28 Error *error,
29 const ResultCallback &callback,
Jason Glasgowee1081c2012-03-06 15:14:53 -050030 int timeout);
Eric Shienbrood9a245532012-03-07 14:20:39 -050031 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 Glasgowee1081c2012-03-06 15:14:53 -050038 virtual void DeleteBearer(const ::DBus::Path &bearer,
Eric Shienbrood9a245532012-03-07 14:20:39 -050039 Error *error,
40 const ResultCallback &callback,
Jason Glasgowee1081c2012-03-06 15:14:53 -050041 int timeout);
Eric Shienbrood9a245532012-03-07 14:20:39 -050042 virtual void Reset(Error *error,
43 const ResultCallback &callback,
44 int timeout);
Jason Glasgowee1081c2012-03-06 15:14:53 -050045 virtual void FactoryReset(const std::string &code,
Eric Shienbrood9a245532012-03-07 14:20:39 -050046 Error *error,
47 const ResultCallback &callback,
Jason Glasgowee1081c2012-03-06 15:14:53 -050048 int timeout);
Ben Chan74924d82013-06-15 17:52:55 -070049 virtual void SetCurrentCapabilities(const uint32_t &capabilities,
50 Error *error,
51 const ResultCallback &callback,
52 int timeout);
53 virtual void SetCurrentModes(const ::DBus::Struct<uint32_t, uint32_t> &modes,
54 Error *error,
55 const ResultCallback &callback,
56 int timeout);
57 virtual void SetCurrentBands(const std::vector<uint32_t> &bands,
58 Error *error,
59 const ResultCallback &callback,
60 int timeout);
Jason Glasgowee1081c2012-03-06 15:14:53 -050061 virtual void Command(const std::string &cmd,
62 const uint32_t &user_timeout,
Eric Shienbrood9a245532012-03-07 14:20:39 -050063 Error *error,
64 const StringCallback &callback,
Jason Glasgowee1081c2012-03-06 15:14:53 -050065 int timeout);
Arman Ugurayee464d32013-02-13 17:14:36 -080066 virtual void SetPowerState(const uint32_t &power_state,
67 Error *error,
68 const ResultCallback &callback,
69 int timeout);
Jason Glasgowee1081c2012-03-06 15:14:53 -050070
Eric Shienbrood9a245532012-03-07 14:20:39 -050071 virtual void set_state_changed_callback(
72 const ModemStateChangedSignalCallback &callback);
73
Jason Glasgowee1081c2012-03-06 15:14:53 -050074 // Inherited properties from ModemProxyInterface.
75 virtual const ::DBus::Path Sim();
Ben Chan74924d82013-06-15 17:52:55 -070076 virtual const std::vector<uint32_t> SupportedCapabilities();
Jason Glasgowee1081c2012-03-06 15:14:53 -050077 virtual uint32_t CurrentCapabilities();
78 virtual uint32_t MaxBearers();
79 virtual uint32_t MaxActiveBearers();
80 virtual const std::string Manufacturer();
81 virtual const std::string Model();
82 virtual const std::string Revision();
83 virtual const std::string DeviceIdentifier();
84 virtual const std::string Device();
Ben Chan34e5d682012-08-24 19:10:49 -070085 virtual const std::vector<std::string> Drivers();
Jason Glasgowee1081c2012-03-06 15:14:53 -050086 virtual const std::string Plugin();
87 virtual const std::string EquipmentIdentifier();
88 virtual uint32_t UnlockRequired();
Ben Chan74924d82013-06-15 17:52:55 -070089 virtual const std::map<uint32_t, uint32_t> UnlockRetries();
Jason Glasgowee1081c2012-03-06 15:14:53 -050090 virtual uint32_t State();
91 virtual uint32_t AccessTechnologies();
Ben Chan74924d82013-06-15 17:52:55 -070092 virtual const ::DBus::Struct<uint32_t, bool> SignalQuality();
93 virtual const std::vector<std::string> OwnNumbers();
94 virtual const std::vector<::DBus::Struct<uint32_t, uint32_t>>
95 SupportedModes();
96 virtual const ::DBus::Struct<uint32_t, uint32_t> CurrentModes();
97 virtual const std::vector<uint32_t> SupportedBands();
98 virtual const std::vector<uint32_t> CurrentBands();
99 virtual uint32_t SupportedIpFamilies();
Arman Ugurayee464d32013-02-13 17:14:36 -0800100 virtual uint32_t PowerState();
Jason Glasgowee1081c2012-03-06 15:14:53 -0500101
102 private:
103 class Proxy : public org::freedesktop::ModemManager1::Modem_proxy,
104 public DBus::ObjectProxy {
105 public:
Eric Shienbrood9a245532012-03-07 14:20:39 -0500106 Proxy(DBus::Connection *connection,
Jason Glasgowee1081c2012-03-06 15:14:53 -0500107 const std::string &path,
108 const std::string &service);
109 virtual ~Proxy();
110
Eric Shienbrood9a245532012-03-07 14:20:39 -0500111 void set_state_changed_callback(
112 const ModemStateChangedSignalCallback &callback);
113
Jason Glasgowee1081c2012-03-06 15:14:53 -0500114 private:
115 // Signal callbacks inherited from Proxy
116 // handle signals
Nathan Williamsa31e79c2012-03-30 15:07:00 -0400117 void StateChanged(const int32_t &old,
118 const int32_t &_new,
Jason Glasgowee1081c2012-03-06 15:14:53 -0500119 const uint32_t &reason);
120
121 // Method callbacks inherited from
122 // org::freedesktop::ModemManager1::ModemProxy
123 virtual void EnableCallback(const ::DBus::Error &dberror, void *data);
124 virtual void ListBearersCallback(
Ben Chan74924d82013-06-15 17:52:55 -0700125 const std::vector<::DBus::Path> &bearers,
Jason Glasgowee1081c2012-03-06 15:14:53 -0500126 const ::DBus::Error &dberror, void *data);
127 virtual void CreateBearerCallback(const ::DBus::Path &bearer,
128 const ::DBus::Error &dberror, void *data);
129 virtual void DeleteBearerCallback(const ::DBus::Error &dberror, void *data);
130 virtual void ResetCallback(const ::DBus::Error &dberror, void *data);
131 virtual void FactoryResetCallback(const ::DBus::Error &dberror, void *data);
Ben Chan74924d82013-06-15 17:52:55 -0700132 virtual void SetCurrentCapabilitesCallback(const ::DBus::Error &dberror,
133 void *data);
134 virtual void SetCurrentModesCallback(const ::DBus::Error &dberror,
135 void *data);
136 virtual void SetCurrentBandsCallback(const ::DBus::Error &dberror,
137 void *data);
Jason Glasgowee1081c2012-03-06 15:14:53 -0500138 virtual void CommandCallback(const std::string &response,
139 const ::DBus::Error &dberror,
140 void *data);
Arman Ugurayee464d32013-02-13 17:14:36 -0800141 virtual void SetPowerStateCallback(const ::DBus::Error &dberror,
142 void *data);
Jason Glasgowee1081c2012-03-06 15:14:53 -0500143
Eric Shienbrood9a245532012-03-07 14:20:39 -0500144 ModemStateChangedSignalCallback state_changed_callback_;
Jason Glasgowee1081c2012-03-06 15:14:53 -0500145
146 DISALLOW_COPY_AND_ASSIGN(Proxy);
147 };
148
149 Proxy proxy_;
150
151 DISALLOW_COPY_AND_ASSIGN(ModemProxy);
152};
153
154} // namespace mm1
155} // namespace shill
156
Ben Chan74924d82013-06-15 17:52:55 -0700157#endif // SHILL_MM1_MODEM_PROXY_H_