blob: a64aa9d7d0861345f05cf5ea11b2c2897a114b2c [file] [log] [blame]
Chris Masoned7732e42011-05-20 11:08:56 -07001// Copyright (c) 2011 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_SERVICE_DBUS_ADAPTOR_H_
6#define SHILL_SERVICE_DBUS_ADAPTOR_H_
7
8#include <map>
9#include <string>
10
11#include <base/basictypes.h>
12
13#include "shill/adaptor_interfaces.h"
14#include "shill/dbus_adaptor.h"
15#include "shill/flimflam-service.h"
16
17namespace shill {
Chris Masoned7732e42011-05-20 11:08:56 -070018
Chris Masoneec6b18b2011-06-08 14:09:10 -070019class Service;
20
Chris Masoned7732e42011-05-20 11:08:56 -070021// Subclass of DBusAdaptor for Service objects
Chris Masoneec6b18b2011-06-08 14:09:10 -070022// There is a 1:1 mapping between Service and ServiceDBusAdaptor
23// instances. Furthermore, the Service owns the ServiceDBusAdaptor
24// and manages its lifetime, so we're OK with ServiceDBusAdaptor
25// having a bare pointer to its owner service.
Chris Masoned7732e42011-05-20 11:08:56 -070026class ServiceDBusAdaptor : public org::chromium::flimflam::Service_adaptor,
27 public DBusAdaptor,
28 public ServiceAdaptorInterface {
29 public:
30 static const char kInterfaceName[];
31 static const char kPath[];
32
Chris Masoneec6b18b2011-06-08 14:09:10 -070033 ServiceDBusAdaptor(DBus::Connection* conn, Service *service);
Chris Masoned7732e42011-05-20 11:08:56 -070034 virtual ~ServiceDBusAdaptor();
Chris Masoned0ceb8c2011-06-02 10:05:39 -070035
36 // Implementation of ServiceAdaptorInterface.
Chris Masoned7732e42011-05-20 11:08:56 -070037 void UpdateConnected();
Chris Masoned0ceb8c2011-06-02 10:05:39 -070038 void EmitBoolChanged(const std::string& name, bool value);
39 void EmitUintChanged(const std::string& name, uint32 value);
40 void EmitIntChanged(const std::string& name, int value);
41 void EmitStringChanged(const std::string& name, const std::string& value);
Chris Masoned7732e42011-05-20 11:08:56 -070042
43 // Implementation of Service_adaptor
44 std::map<std::string, ::DBus::Variant> GetProperties(::DBus::Error &error);
Chris Masone8fe2c7e2011-06-09 15:51:19 -070045 void SetProperty(const std::string& name,
46 const ::DBus::Variant& value,
Chris Masoned7732e42011-05-20 11:08:56 -070047 ::DBus::Error &error);
48 void ClearProperty(const std::string& , ::DBus::Error &error);
49 void Connect(::DBus::Error &error);
50 void Disconnect(::DBus::Error &error);
51 void Remove(::DBus::Error &error);
52 void MoveBefore(const ::DBus::Path& , ::DBus::Error &error);
53 void MoveAfter(const ::DBus::Path& , ::DBus::Error &error);
54 void ActivateCellularModem(const std::string& , ::DBus::Error &error);
55
56 private:
Chris Masoneec6b18b2011-06-08 14:09:10 -070057 Service *service_;
Chris Masoned7732e42011-05-20 11:08:56 -070058 DISALLOW_COPY_AND_ASSIGN(ServiceDBusAdaptor);
59};
60
61} // namespace shill
62#endif // SHILL_SERVICE_DBUS_ADAPTOR_H_