blob: c7ad25fdb20629742dbfd39994beeaf38cb21c79 [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);
Jason Glasgowee1081c2012-03-06 15:14:53 -050049 virtual void Command(const std::string &cmd,
50 const uint32_t &user_timeout,
Eric Shienbrood9a245532012-03-07 14:20:39 -050051 Error *error,
52 const StringCallback &callback,
Jason Glasgowee1081c2012-03-06 15:14:53 -050053 int timeout);
Arman Ugurayee464d32013-02-13 17:14:36 -080054 virtual void SetPowerState(const uint32_t &power_state,
55 Error *error,
56 const ResultCallback &callback,
57 int timeout);
Jason Glasgowee1081c2012-03-06 15:14:53 -050058
Eric Shienbrood9a245532012-03-07 14:20:39 -050059 virtual void set_state_changed_callback(
60 const ModemStateChangedSignalCallback &callback);
61
Jason Glasgowee1081c2012-03-06 15:14:53 -050062 // Inherited properties from ModemProxyInterface.
63 virtual const ::DBus::Path Sim();
Jason Glasgowee1081c2012-03-06 15:14:53 -050064 virtual uint32_t CurrentCapabilities();
65 virtual uint32_t MaxBearers();
66 virtual uint32_t MaxActiveBearers();
67 virtual const std::string Manufacturer();
68 virtual const std::string Model();
69 virtual const std::string Revision();
70 virtual const std::string DeviceIdentifier();
71 virtual const std::string Device();
Ben Chan34e5d682012-08-24 19:10:49 -070072 virtual const std::vector<std::string> Drivers();
Jason Glasgowee1081c2012-03-06 15:14:53 -050073 virtual const std::string Plugin();
74 virtual const std::string EquipmentIdentifier();
75 virtual uint32_t UnlockRequired();
76 virtual const std::map< uint32_t, uint32_t > UnlockRetries();
77 virtual uint32_t State();
78 virtual uint32_t AccessTechnologies();
79 virtual const ::DBus::Struct< uint32_t, bool > SignalQuality();
Jason Glasgow90d216d2012-04-04 15:57:14 -040080 virtual const std::vector< std::string > OwnNumbers();
Jason Glasgowee1081c2012-03-06 15:14:53 -050081 virtual const std::vector< uint32_t > SupportedBands();
Arman Ugurayee464d32013-02-13 17:14:36 -080082 virtual uint32_t PowerState();
Jason Glasgowee1081c2012-03-06 15:14:53 -050083
84 private:
85 class Proxy : public org::freedesktop::ModemManager1::Modem_proxy,
86 public DBus::ObjectProxy {
87 public:
Eric Shienbrood9a245532012-03-07 14:20:39 -050088 Proxy(DBus::Connection *connection,
Jason Glasgowee1081c2012-03-06 15:14:53 -050089 const std::string &path,
90 const std::string &service);
91 virtual ~Proxy();
92
Eric Shienbrood9a245532012-03-07 14:20:39 -050093 void set_state_changed_callback(
94 const ModemStateChangedSignalCallback &callback);
95
Jason Glasgowee1081c2012-03-06 15:14:53 -050096 private:
97 // Signal callbacks inherited from Proxy
98 // handle signals
Nathan Williamsa31e79c2012-03-30 15:07:00 -040099 void StateChanged(const int32_t &old,
100 const int32_t &_new,
Jason Glasgowee1081c2012-03-06 15:14:53 -0500101 const uint32_t &reason);
102
103 // Method callbacks inherited from
104 // org::freedesktop::ModemManager1::ModemProxy
105 virtual void EnableCallback(const ::DBus::Error &dberror, void *data);
106 virtual void ListBearersCallback(
107 const std::vector< ::DBus::Path > &bearers,
108 const ::DBus::Error &dberror, void *data);
109 virtual void CreateBearerCallback(const ::DBus::Path &bearer,
110 const ::DBus::Error &dberror, void *data);
111 virtual void DeleteBearerCallback(const ::DBus::Error &dberror, void *data);
112 virtual void ResetCallback(const ::DBus::Error &dberror, void *data);
113 virtual void FactoryResetCallback(const ::DBus::Error &dberror, void *data);
Jason Glasgowee1081c2012-03-06 15:14:53 -0500114 virtual void CommandCallback(const std::string &response,
115 const ::DBus::Error &dberror,
116 void *data);
Arman Ugurayee464d32013-02-13 17:14:36 -0800117 virtual void SetPowerStateCallback(const ::DBus::Error &dberror,
118 void *data);
Jason Glasgowee1081c2012-03-06 15:14:53 -0500119
Eric Shienbrood9a245532012-03-07 14:20:39 -0500120 ModemStateChangedSignalCallback state_changed_callback_;
Jason Glasgowee1081c2012-03-06 15:14:53 -0500121
122 DISALLOW_COPY_AND_ASSIGN(Proxy);
123 };
124
125 Proxy proxy_;
126
127 DISALLOW_COPY_AND_ASSIGN(ModemProxy);
128};
129
130} // namespace mm1
131} // namespace shill
132
133#endif // SHILL_MM1_MODEM_PROXY_