blob: 08b6a89dd6e4b12277e56eb994a1c5113aad469b [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#include "shill/service_dbus_adaptor.h"
6
7#include <map>
8#include <string>
9
Chris Masone8fe2c7e2011-06-09 15:51:19 -070010#include <base/logging.h>
11
12#include "shill/error.h"
Chris Masonea82b7112011-05-25 15:16:29 -070013#include "shill/service.h"
14
Chris Masoned7732e42011-05-20 11:08:56 -070015using std::map;
16using std::string;
17
18namespace shill {
19
Chris Masoned7732e42011-05-20 11:08:56 -070020// static
21const char ServiceDBusAdaptor::kInterfaceName[] = SHILL_INTERFACE;
Chris Masoned7732e42011-05-20 11:08:56 -070022// static
Chris Masonea82b7112011-05-25 15:16:29 -070023const char ServiceDBusAdaptor::kPath[] = "/service/";
Chris Masoned7732e42011-05-20 11:08:56 -070024
Chris Masoneec6b18b2011-06-08 14:09:10 -070025ServiceDBusAdaptor::ServiceDBusAdaptor(DBus::Connection* conn, Service *service)
Chris Masonea82b7112011-05-25 15:16:29 -070026 : DBusAdaptor(conn, kPath + service->UniqueName()),
Chris Masoned7732e42011-05-20 11:08:56 -070027 service_(service) {}
Chris Masoneec6b18b2011-06-08 14:09:10 -070028
29ServiceDBusAdaptor::~ServiceDBusAdaptor() {
30 service_ = NULL;
31}
Chris Masoned7732e42011-05-20 11:08:56 -070032
33void ServiceDBusAdaptor::UpdateConnected() {}
34
Chris Masoned0ceb8c2011-06-02 10:05:39 -070035void ServiceDBusAdaptor::EmitBoolChanged(const std::string& name, bool value) {
36 PropertyChanged(name, DBusAdaptor::BoolToVariant(value));
37}
38
39void ServiceDBusAdaptor::EmitUintChanged(const std::string& name,
40 uint32 value) {
Chris Masone8fe2c7e2011-06-09 15:51:19 -070041 PropertyChanged(name, DBusAdaptor::Uint32ToVariant(value));
Chris Masoned0ceb8c2011-06-02 10:05:39 -070042}
43
44void ServiceDBusAdaptor::EmitIntChanged(const std::string& name, int value) {
Chris Masone8fe2c7e2011-06-09 15:51:19 -070045 PropertyChanged(name, DBusAdaptor::Int32ToVariant(value));
Chris Masoned0ceb8c2011-06-02 10:05:39 -070046}
47
48void ServiceDBusAdaptor::EmitStringChanged(const std::string& name,
49 const std::string& value) {
50 PropertyChanged(name, DBusAdaptor::StringToVariant(value));
51
52}
53
Chris Masoned7732e42011-05-20 11:08:56 -070054map<string, ::DBus::Variant> ServiceDBusAdaptor::GetProperties(
55 ::DBus::Error &error) {
Chris Masonea8a2c252011-06-27 22:16:30 -070056 map<string, ::DBus::Variant> properties;
Chris Masone27c4aa52011-07-02 13:10:14 -070057 DBusAdaptor::GetProperties(service_->store(), &properties, &error);
Chris Masonea8a2c252011-06-27 22:16:30 -070058 return properties;
Chris Masoned7732e42011-05-20 11:08:56 -070059}
60
Chris Masone8fe2c7e2011-06-09 15:51:19 -070061void ServiceDBusAdaptor::SetProperty(const string& name,
62 const ::DBus::Variant& value,
Chris Masoned7732e42011-05-20 11:08:56 -070063 ::DBus::Error &error) {
Chris Masone27c4aa52011-07-02 13:10:14 -070064 DBusAdaptor::DispatchOnType(service_->store(), name, value, &error);
Chris Masoned7732e42011-05-20 11:08:56 -070065}
66
67void ServiceDBusAdaptor::ClearProperty(const string& , ::DBus::Error &error) {
68}
69
70void ServiceDBusAdaptor::Connect(::DBus::Error &error) {
Darin Petkov4d6d9412011-08-24 13:19:54 -070071 Error e;
72 service_->Connect(&e);
73 e.ToDBusError(&error);
Chris Masoned7732e42011-05-20 11:08:56 -070074}
75
76void ServiceDBusAdaptor::Disconnect(::DBus::Error &error) {
77}
78
79void ServiceDBusAdaptor::Remove(::DBus::Error &error) {
80}
81
82void ServiceDBusAdaptor::MoveBefore(const ::DBus::Path& ,
83 ::DBus::Error &error) {
84}
85
86void ServiceDBusAdaptor::MoveAfter(const ::DBus::Path& ,
87 ::DBus::Error &error) {
88}
89
Darin Petkovc408e692011-08-17 13:47:15 -070090void ServiceDBusAdaptor::ActivateCellularModem(const string &carrier,
Chris Masoned7732e42011-05-20 11:08:56 -070091 ::DBus::Error &error) {
Darin Petkovb100ae72011-08-24 16:19:45 -070092 Error e;
93 service_->ActivateCellularModem(carrier, &e);
94 e.ToDBusError(&error);
Chris Masoned7732e42011-05-20 11:08:56 -070095}
96
97} // namespace shill