blob: 09c9830b54e946c8a4ad94555540f3066a0d97fc [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>
Alex Vakulenko8a532292014-06-16 17:18:44 -07009#include <vector>
Jason Glasgowee1081c2012-03-06 15:14:53 -050010
Liam McLoughlinef342b42013-09-13 21:05:36 +010011#include "dbus_proxies/org.freedesktop.ModemManager1.Modem.h"
Jason Glasgowee1081c2012-03-06 15:14:53 -050012#include "shill/dbus_properties.h"
13#include "shill/mm1_modem_proxy_interface.h"
14
15namespace shill {
Jason Glasgowee1081c2012-03-06 15:14:53 -050016namespace mm1 {
17
mukesh agrawalf407d592013-07-31 11:37:57 -070018// A proxy to org.freedesktop.ModemManager1.Modem.
Jason Glasgowee1081c2012-03-06 15:14:53 -050019class ModemProxy : public ModemProxyInterface {
20 public:
21 // Constructs a org.freedesktop.ModemManager1.Modem DBus object
Eric Shienbrood9a245532012-03-07 14:20:39 -050022 // proxy at |path| owned by |service|.
23 ModemProxy(DBus::Connection *connection,
Jason Glasgowee1081c2012-03-06 15:14:53 -050024 const std::string &path,
25 const std::string &service);
26 virtual ~ModemProxy();
27
28 // Inherited methods from ModemProxyInterface.
Eric Shienbrood9a245532012-03-07 14:20:39 -050029 virtual void Enable(bool enable,
30 Error *error,
31 const ResultCallback &callback,
Jason Glasgowee1081c2012-03-06 15:14:53 -050032 int timeout);
Eric Shienbrood9a245532012-03-07 14:20:39 -050033 virtual void CreateBearer(const DBusPropertiesMap &properties,
34 Error *error,
35 const DBusPathCallback &callback,
36 int timeout);
Jason Glasgowee1081c2012-03-06 15:14:53 -050037 virtual void DeleteBearer(const ::DBus::Path &bearer,
Eric Shienbrood9a245532012-03-07 14:20:39 -050038 Error *error,
39 const ResultCallback &callback,
Jason Glasgowee1081c2012-03-06 15:14:53 -050040 int timeout);
Eric Shienbrood9a245532012-03-07 14:20:39 -050041 virtual void Reset(Error *error,
42 const ResultCallback &callback,
43 int timeout);
Jason Glasgowee1081c2012-03-06 15:14:53 -050044 virtual void FactoryReset(const std::string &code,
Eric Shienbrood9a245532012-03-07 14:20:39 -050045 Error *error,
46 const ResultCallback &callback,
Jason Glasgowee1081c2012-03-06 15:14:53 -050047 int timeout);
Ben Chan74924d82013-06-15 17:52:55 -070048 virtual void SetCurrentCapabilities(const uint32_t &capabilities,
49 Error *error,
50 const ResultCallback &callback,
51 int timeout);
52 virtual void SetCurrentModes(const ::DBus::Struct<uint32_t, uint32_t> &modes,
53 Error *error,
54 const ResultCallback &callback,
55 int timeout);
56 virtual void SetCurrentBands(const std::vector<uint32_t> &bands,
57 Error *error,
58 const ResultCallback &callback,
59 int timeout);
Jason Glasgowee1081c2012-03-06 15:14:53 -050060 virtual void Command(const std::string &cmd,
61 const uint32_t &user_timeout,
Eric Shienbrood9a245532012-03-07 14:20:39 -050062 Error *error,
63 const StringCallback &callback,
Jason Glasgowee1081c2012-03-06 15:14:53 -050064 int timeout);
Arman Ugurayee464d32013-02-13 17:14:36 -080065 virtual void SetPowerState(const uint32_t &power_state,
66 Error *error,
67 const ResultCallback &callback,
68 int timeout);
Jason Glasgowee1081c2012-03-06 15:14:53 -050069
Eric Shienbrood9a245532012-03-07 14:20:39 -050070 virtual void set_state_changed_callback(
71 const ModemStateChangedSignalCallback &callback);
72
Jason Glasgowee1081c2012-03-06 15:14:53 -050073 private:
74 class Proxy : public org::freedesktop::ModemManager1::Modem_proxy,
75 public DBus::ObjectProxy {
76 public:
Eric Shienbrood9a245532012-03-07 14:20:39 -050077 Proxy(DBus::Connection *connection,
Jason Glasgowee1081c2012-03-06 15:14:53 -050078 const std::string &path,
79 const std::string &service);
80 virtual ~Proxy();
81
Eric Shienbrood9a245532012-03-07 14:20:39 -050082 void set_state_changed_callback(
83 const ModemStateChangedSignalCallback &callback);
84
Jason Glasgowee1081c2012-03-06 15:14:53 -050085 private:
86 // Signal callbacks inherited from Proxy
87 // handle signals
Nathan Williamsa31e79c2012-03-30 15:07:00 -040088 void StateChanged(const int32_t &old,
89 const int32_t &_new,
Jason Glasgowee1081c2012-03-06 15:14:53 -050090 const uint32_t &reason);
91
92 // Method callbacks inherited from
93 // org::freedesktop::ModemManager1::ModemProxy
94 virtual void EnableCallback(const ::DBus::Error &dberror, void *data);
Jason Glasgowee1081c2012-03-06 15:14:53 -050095 virtual void CreateBearerCallback(const ::DBus::Path &bearer,
96 const ::DBus::Error &dberror, void *data);
97 virtual void DeleteBearerCallback(const ::DBus::Error &dberror, void *data);
98 virtual void ResetCallback(const ::DBus::Error &dberror, void *data);
99 virtual void FactoryResetCallback(const ::DBus::Error &dberror, void *data);
Ben Chan74924d82013-06-15 17:52:55 -0700100 virtual void SetCurrentCapabilitesCallback(const ::DBus::Error &dberror,
101 void *data);
102 virtual void SetCurrentModesCallback(const ::DBus::Error &dberror,
103 void *data);
104 virtual void SetCurrentBandsCallback(const ::DBus::Error &dberror,
105 void *data);
Jason Glasgowee1081c2012-03-06 15:14:53 -0500106 virtual void CommandCallback(const std::string &response,
107 const ::DBus::Error &dberror,
108 void *data);
Arman Ugurayee464d32013-02-13 17:14:36 -0800109 virtual void SetPowerStateCallback(const ::DBus::Error &dberror,
110 void *data);
Jason Glasgowee1081c2012-03-06 15:14:53 -0500111
Eric Shienbrood9a245532012-03-07 14:20:39 -0500112 ModemStateChangedSignalCallback state_changed_callback_;
Jason Glasgowee1081c2012-03-06 15:14:53 -0500113
114 DISALLOW_COPY_AND_ASSIGN(Proxy);
115 };
116
117 Proxy proxy_;
118
mukesh agrawal0e9e9d12014-04-18 16:09:58 -0700119 template<typename TraceMsgT, typename CallT, typename CallbackT,
120 typename... ArgTypes>
121 void BeginCall(
Alex Vakulenko8a532292014-06-16 17:18:44 -0700122 const TraceMsgT &trace_msg, const CallT &call,
123 const CallbackT &callback, Error *error, int timeout,
124 ArgTypes... rest);
mukesh agrawal0e9e9d12014-04-18 16:09:58 -0700125
Jason Glasgowee1081c2012-03-06 15:14:53 -0500126 DISALLOW_COPY_AND_ASSIGN(ModemProxy);
127};
128
129} // namespace mm1
130} // namespace shill
131
Ben Chan74924d82013-06-15 17:52:55 -0700132#endif // SHILL_MM1_MODEM_PROXY_H_