blob: d6c934f0243f3615f9ce426e2f8231ade71045f0 [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
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
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);
Eric Shienbrood9a245532012-03-07 14:20:39 -050049 virtual void SetAllowedModes(const uint32_t &modes,
50 const uint32_t &preferred,
51 Error *error,
52 const ResultCallback &callback,
Jason Glasgowee1081c2012-03-06 15:14:53 -050053 int timeout);
54 virtual void SetBands(const std::vector< uint32_t > &bands,
Eric Shienbrood9a245532012-03-07 14:20:39 -050055 Error *error,
56 const ResultCallback &callback,
Jason Glasgowee1081c2012-03-06 15:14:53 -050057 int timeout);
58 virtual void Command(const std::string &cmd,
59 const uint32_t &user_timeout,
Eric Shienbrood9a245532012-03-07 14:20:39 -050060 Error *error,
61 const StringCallback &callback,
Jason Glasgowee1081c2012-03-06 15:14:53 -050062 int timeout);
Arman Ugurayee464d32013-02-13 17:14:36 -080063 virtual void SetPowerState(const uint32_t &power_state,
64 Error *error,
65 const ResultCallback &callback,
66 int timeout);
Jason Glasgowee1081c2012-03-06 15:14:53 -050067
Eric Shienbrood9a245532012-03-07 14:20:39 -050068 virtual void set_state_changed_callback(
69 const ModemStateChangedSignalCallback &callback);
70
Jason Glasgowee1081c2012-03-06 15:14:53 -050071 // Inherited properties from ModemProxyInterface.
72 virtual const ::DBus::Path Sim();
73 virtual uint32_t ModemCapabilities();
74 virtual uint32_t CurrentCapabilities();
75 virtual uint32_t MaxBearers();
76 virtual uint32_t MaxActiveBearers();
77 virtual const std::string Manufacturer();
78 virtual const std::string Model();
79 virtual const std::string Revision();
80 virtual const std::string DeviceIdentifier();
81 virtual const std::string Device();
Ben Chan34e5d682012-08-24 19:10:49 -070082 virtual const std::vector<std::string> Drivers();
Jason Glasgowee1081c2012-03-06 15:14:53 -050083 virtual const std::string Plugin();
84 virtual const std::string EquipmentIdentifier();
85 virtual uint32_t UnlockRequired();
86 virtual const std::map< uint32_t, uint32_t > UnlockRetries();
87 virtual uint32_t State();
88 virtual uint32_t AccessTechnologies();
89 virtual const ::DBus::Struct< uint32_t, bool > SignalQuality();
Jason Glasgow90d216d2012-04-04 15:57:14 -040090 virtual const std::vector< std::string > OwnNumbers();
Jason Glasgowee1081c2012-03-06 15:14:53 -050091 virtual uint32_t SupportedModes();
92 virtual uint32_t AllowedModes();
93 virtual uint32_t PreferredMode();
94 virtual const std::vector< uint32_t > SupportedBands();
95 virtual const std::vector< uint32_t > Bands();
Arman Ugurayee464d32013-02-13 17:14:36 -080096 virtual uint32_t PowerState();
Jason Glasgowee1081c2012-03-06 15:14:53 -050097
98 private:
99 class Proxy : public org::freedesktop::ModemManager1::Modem_proxy,
100 public DBus::ObjectProxy {
101 public:
Eric Shienbrood9a245532012-03-07 14:20:39 -0500102 Proxy(DBus::Connection *connection,
Jason Glasgowee1081c2012-03-06 15:14:53 -0500103 const std::string &path,
104 const std::string &service);
105 virtual ~Proxy();
106
Eric Shienbrood9a245532012-03-07 14:20:39 -0500107 void set_state_changed_callback(
108 const ModemStateChangedSignalCallback &callback);
109
Jason Glasgowee1081c2012-03-06 15:14:53 -0500110 private:
111 // Signal callbacks inherited from Proxy
112 // handle signals
Nathan Williamsa31e79c2012-03-30 15:07:00 -0400113 void StateChanged(const int32_t &old,
114 const int32_t &_new,
Jason Glasgowee1081c2012-03-06 15:14:53 -0500115 const uint32_t &reason);
116
117 // Method callbacks inherited from
118 // org::freedesktop::ModemManager1::ModemProxy
119 virtual void EnableCallback(const ::DBus::Error &dberror, void *data);
120 virtual void ListBearersCallback(
121 const std::vector< ::DBus::Path > &bearers,
122 const ::DBus::Error &dberror, void *data);
123 virtual void CreateBearerCallback(const ::DBus::Path &bearer,
124 const ::DBus::Error &dberror, void *data);
125 virtual void DeleteBearerCallback(const ::DBus::Error &dberror, void *data);
126 virtual void ResetCallback(const ::DBus::Error &dberror, void *data);
127 virtual void FactoryResetCallback(const ::DBus::Error &dberror, void *data);
128 virtual void SetAllowedModesCallback(const ::DBus::Error &dberror,
129 void *data);
130 virtual void SetBandsCallback(const ::DBus::Error &dberror, void *data);
131 virtual void CommandCallback(const std::string &response,
132 const ::DBus::Error &dberror,
133 void *data);
Arman Ugurayee464d32013-02-13 17:14:36 -0800134 virtual void SetPowerStateCallback(const ::DBus::Error &dberror,
135 void *data);
Jason Glasgowee1081c2012-03-06 15:14:53 -0500136
Eric Shienbrood9a245532012-03-07 14:20:39 -0500137 ModemStateChangedSignalCallback state_changed_callback_;
Jason Glasgowee1081c2012-03-06 15:14:53 -0500138
139 DISALLOW_COPY_AND_ASSIGN(Proxy);
140 };
141
142 Proxy proxy_;
143
144 DISALLOW_COPY_AND_ASSIGN(ModemProxy);
145};
146
147} // namespace mm1
148} // namespace shill
149
150#endif // SHILL_MM1_MODEM_PROXY_