blob: be9c458e18f6bd0d56f72e5ff19f67355514ccc7 [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
Liam McLoughlinef342b42013-09-13 21:05:36 +010010#include "dbus_proxies/org.freedesktop.ModemManager1.Modem.h"
Jason Glasgowee1081c2012-03-06 15:14:53 -050011#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
mukesh agrawalf407d592013-07-31 11:37:57 -070017// A proxy to org.freedesktop.ModemManager1.Modem.
Jason Glasgowee1081c2012-03-06 15:14:53 -050018class ModemProxy : public ModemProxyInterface {
19 public:
20 // Constructs a org.freedesktop.ModemManager1.Modem DBus object
Eric Shienbrood9a245532012-03-07 14:20:39 -050021 // proxy at |path| owned by |service|.
22 ModemProxy(DBus::Connection *connection,
Jason Glasgowee1081c2012-03-06 15:14:53 -050023 const std::string &path,
24 const std::string &service);
25 virtual ~ModemProxy();
26
27 // Inherited methods from ModemProxyInterface.
Eric Shienbrood9a245532012-03-07 14:20:39 -050028 virtual void Enable(bool enable,
29 Error *error,
30 const ResultCallback &callback,
Jason Glasgowee1081c2012-03-06 15:14:53 -050031 int timeout);
Eric Shienbrood9a245532012-03-07 14:20:39 -050032 virtual void CreateBearer(const DBusPropertiesMap &properties,
33 Error *error,
34 const DBusPathCallback &callback,
35 int timeout);
Jason Glasgowee1081c2012-03-06 15:14:53 -050036 virtual void DeleteBearer(const ::DBus::Path &bearer,
Eric Shienbrood9a245532012-03-07 14:20:39 -050037 Error *error,
38 const ResultCallback &callback,
Jason Glasgowee1081c2012-03-06 15:14:53 -050039 int timeout);
Eric Shienbrood9a245532012-03-07 14:20:39 -050040 virtual void Reset(Error *error,
41 const ResultCallback &callback,
42 int timeout);
Jason Glasgowee1081c2012-03-06 15:14:53 -050043 virtual void FactoryReset(const std::string &code,
Eric Shienbrood9a245532012-03-07 14:20:39 -050044 Error *error,
45 const ResultCallback &callback,
Jason Glasgowee1081c2012-03-06 15:14:53 -050046 int timeout);
Ben Chan74924d82013-06-15 17:52:55 -070047 virtual void SetCurrentCapabilities(const uint32_t &capabilities,
48 Error *error,
49 const ResultCallback &callback,
50 int timeout);
51 virtual void SetCurrentModes(const ::DBus::Struct<uint32_t, uint32_t> &modes,
52 Error *error,
53 const ResultCallback &callback,
54 int timeout);
55 virtual void SetCurrentBands(const std::vector<uint32_t> &bands,
56 Error *error,
57 const ResultCallback &callback,
58 int timeout);
Jason Glasgowee1081c2012-03-06 15:14:53 -050059 virtual void Command(const std::string &cmd,
60 const uint32_t &user_timeout,
Eric Shienbrood9a245532012-03-07 14:20:39 -050061 Error *error,
62 const StringCallback &callback,
Jason Glasgowee1081c2012-03-06 15:14:53 -050063 int timeout);
Arman Ugurayee464d32013-02-13 17:14:36 -080064 virtual void SetPowerState(const uint32_t &power_state,
65 Error *error,
66 const ResultCallback &callback,
67 int timeout);
Jason Glasgowee1081c2012-03-06 15:14:53 -050068
Eric Shienbrood9a245532012-03-07 14:20:39 -050069 virtual void set_state_changed_callback(
70 const ModemStateChangedSignalCallback &callback);
71
Jason Glasgowee1081c2012-03-06 15:14:53 -050072 private:
73 class Proxy : public org::freedesktop::ModemManager1::Modem_proxy,
74 public DBus::ObjectProxy {
75 public:
Eric Shienbrood9a245532012-03-07 14:20:39 -050076 Proxy(DBus::Connection *connection,
Jason Glasgowee1081c2012-03-06 15:14:53 -050077 const std::string &path,
78 const std::string &service);
79 virtual ~Proxy();
80
Eric Shienbrood9a245532012-03-07 14:20:39 -050081 void set_state_changed_callback(
82 const ModemStateChangedSignalCallback &callback);
83
Jason Glasgowee1081c2012-03-06 15:14:53 -050084 private:
85 // Signal callbacks inherited from Proxy
86 // handle signals
Nathan Williamsa31e79c2012-03-30 15:07:00 -040087 void StateChanged(const int32_t &old,
88 const int32_t &_new,
Jason Glasgowee1081c2012-03-06 15:14:53 -050089 const uint32_t &reason);
90
91 // Method callbacks inherited from
92 // org::freedesktop::ModemManager1::ModemProxy
93 virtual void EnableCallback(const ::DBus::Error &dberror, void *data);
Jason Glasgowee1081c2012-03-06 15:14:53 -050094 virtual void CreateBearerCallback(const ::DBus::Path &bearer,
95 const ::DBus::Error &dberror, void *data);
96 virtual void DeleteBearerCallback(const ::DBus::Error &dberror, void *data);
97 virtual void ResetCallback(const ::DBus::Error &dberror, void *data);
98 virtual void FactoryResetCallback(const ::DBus::Error &dberror, void *data);
Ben Chan74924d82013-06-15 17:52:55 -070099 virtual void SetCurrentCapabilitesCallback(const ::DBus::Error &dberror,
100 void *data);
101 virtual void SetCurrentModesCallback(const ::DBus::Error &dberror,
102 void *data);
103 virtual void SetCurrentBandsCallback(const ::DBus::Error &dberror,
104 void *data);
Jason Glasgowee1081c2012-03-06 15:14:53 -0500105 virtual void CommandCallback(const std::string &response,
106 const ::DBus::Error &dberror,
107 void *data);
Arman Ugurayee464d32013-02-13 17:14:36 -0800108 virtual void SetPowerStateCallback(const ::DBus::Error &dberror,
109 void *data);
Jason Glasgowee1081c2012-03-06 15:14:53 -0500110
Eric Shienbrood9a245532012-03-07 14:20:39 -0500111 ModemStateChangedSignalCallback state_changed_callback_;
Jason Glasgowee1081c2012-03-06 15:14:53 -0500112
113 DISALLOW_COPY_AND_ASSIGN(Proxy);
114 };
115
116 Proxy proxy_;
117
mukesh agrawal0e9e9d12014-04-18 16:09:58 -0700118 template<typename TraceMsgT, typename CallT, typename CallbackT,
119 typename... ArgTypes>
120 void BeginCall(
121 const TraceMsgT &trace_msg, const CallT &call, CallbackT &callback,
122 Error *error, int timeout, ArgTypes... rest);
123
Jason Glasgowee1081c2012-03-06 15:14:53 -0500124 DISALLOW_COPY_AND_ASSIGN(ModemProxy);
125};
126
127} // namespace mm1
128} // namespace shill
129
Ben Chan74924d82013-06-15 17:52:55 -0700130#endif // SHILL_MM1_MODEM_PROXY_H_