blob: d5021f611b3610e49ee7886308bc6a2eedbb0d94 [file] [log] [blame]
Darin Petkovfb0625e2012-01-16 13:05:56 +01001// Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
Darin Petkove9d12e02011-07-27 15:09:37 -07002// 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_MODEM_PROXY_
6#define SHILL_MODEM_PROXY_
7
Hristo Stefanoved2c28c2011-11-29 15:37:30 -08008#include <string>
9
Darin Petkove9d12e02011-07-27 15:09:37 -070010#include <base/basictypes.h>
11
12#include "shill/dbus_bindings/modem.h"
13#include "shill/modem_proxy_interface.h"
14
15namespace shill {
16
Darin Petkovc5f56562011-08-06 16:40:05 -070017// A proxy to ModemManager.Modem.
Darin Petkove9d12e02011-07-27 15:09:37 -070018class ModemProxy : public ModemProxyInterface {
19 public:
Darin Petkovc5f56562011-08-06 16:40:05 -070020 // Constructs a ModemManager.Modem DBus object proxy at |path| owned by
Darin Petkov580c7af2011-10-24 12:32:50 +020021 // |service|. Caught signals will be dispatched to |delegate|.
22 ModemProxy(ModemProxyDelegate *delegate,
Darin Petkovc5f56562011-08-06 16:40:05 -070023 DBus::Connection *connection,
Darin Petkove9d12e02011-07-27 15:09:37 -070024 const std::string &path,
25 const std::string &service);
26 virtual ~ModemProxy();
27
28 // Inherited from ModemProxyInterface.
Eric Shienbrood5de44ab2011-12-05 10:46:27 -050029 virtual void Enable(bool enable, AsyncCallHandler *call_handler, int timeout);
30 // TODO(ers): temporarily advertise the blocking version
31 // of Enable, until Cellular::Stop is converted for async.
32 virtual void Enable(bool enable);
Darin Petkovfb0625e2012-01-16 13:05:56 +010033 virtual void Disconnect();
Eric Shienbrood5de44ab2011-12-05 10:46:27 -050034 virtual void GetModemInfo(AsyncCallHandler *call_handler, int timeout);
Darin Petkove9d12e02011-07-27 15:09:37 -070035
36 private:
37 class Proxy : public org::freedesktop::ModemManager::Modem_proxy,
38 public DBus::ObjectProxy {
39 public:
Darin Petkov580c7af2011-10-24 12:32:50 +020040 Proxy(ModemProxyDelegate *delegate,
Darin Petkovc5f56562011-08-06 16:40:05 -070041 DBus::Connection *connection,
Darin Petkove9d12e02011-07-27 15:09:37 -070042 const std::string &path,
43 const std::string &service);
44 virtual ~Proxy();
45
46 private:
47 // Signal callbacks inherited from ModemManager::Modem_proxy.
Eric Shienbrood5de44ab2011-12-05 10:46:27 -050048 virtual void StateChanged(
49 const uint32 &old, const uint32 &_new, const uint32 &reason);
50
51 // Method callbacks inherited from ModemManager::Modem_proxy.
52 virtual void EnableCallback(const DBus::Error &dberror, void *data);
53 virtual void GetInfoCallback(const ModemHardwareInfo &info,
54 const DBus::Error &dberror, void *data);
55 virtual void DisconnectCallback(const DBus::Error &dberror, void *data);
Darin Petkove9d12e02011-07-27 15:09:37 -070056
Darin Petkov580c7af2011-10-24 12:32:50 +020057 ModemProxyDelegate *delegate_;
Darin Petkovc5f56562011-08-06 16:40:05 -070058
Darin Petkove9d12e02011-07-27 15:09:37 -070059 DISALLOW_COPY_AND_ASSIGN(Proxy);
60 };
61
62 Proxy proxy_;
63
64 DISALLOW_COPY_AND_ASSIGN(ModemProxy);
65};
66
67} // namespace shill
68
69#endif // SHILL_MODEM_PROXY_