1// Copyright (c) 2012 The Chromium 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 CHROMEOS_DBUS_SHILL_IPCONFIG_CLIENT_H_ 6#define CHROMEOS_DBUS_SHILL_IPCONFIG_CLIENT_H_ 7 8#include <string> 9 10#include "base/basictypes.h" 11#include "base/callback.h" 12#include "chromeos/chromeos_export.h" 13#include "chromeos/dbus/dbus_client.h" 14#include "chromeos/dbus/shill_client_helper.h" 15 16namespace base { 17 18class Value; 19class DictionaryValue; 20 21} // namespace base 22 23namespace dbus { 24 25class ObjectPath; 26 27} // namespace dbus 28 29namespace chromeos { 30 31class ShillPropertyChangedObserver; 32 33// ShillIPConfigClient is used to communicate with the Shill IPConfig 34// service. All methods should be called from the origin thread which 35// initializes the DBusThreadManager instance. 36class CHROMEOS_EXPORT ShillIPConfigClient : public DBusClient { 37 public: 38 typedef ShillClientHelper::PropertyChangedHandler PropertyChangedHandler; 39 typedef ShillClientHelper::DictionaryValueCallback DictionaryValueCallback; 40 41 class TestInterface { 42 public: 43 // Adds an IPConfig entry. 44 virtual void AddIPConfig(const std::string& ip_config_path, 45 const base::DictionaryValue& properties) = 0; 46 47 protected: 48 virtual ~TestInterface() {} 49 }; 50 51 virtual ~ShillIPConfigClient(); 52 53 // Factory function, creates a new instance which is owned by the caller. 54 // For normal usage, access the singleton via DBusThreadManager::Get(). 55 static ShillIPConfigClient* Create(); 56 57 // Adds a property changed |observer| for the ipconfig at |ipconfig_path|. 58 virtual void AddPropertyChangedObserver( 59 const dbus::ObjectPath& ipconfig_path, 60 ShillPropertyChangedObserver* observer) = 0; 61 62 // Removes a property changed |observer| for the ipconfig at |ipconfig_path|. 63 virtual void RemovePropertyChangedObserver( 64 const dbus::ObjectPath& ipconfig_path, 65 ShillPropertyChangedObserver* observer) = 0; 66 67 // Refreshes the active IP configuration after service property changes and 68 // renews the DHCP lease, if any. 69 virtual void Refresh(const dbus::ObjectPath& ipconfig_path, 70 const VoidDBusMethodCallback& callback) = 0; 71 72 // Calls GetProperties method. 73 // |callback| is called after the method call succeeds. 74 virtual void GetProperties(const dbus::ObjectPath& ipconfig_path, 75 const DictionaryValueCallback& callback) = 0; 76 77 // Calls SetProperty method. 78 // |callback| is called after the method call succeeds. 79 virtual void SetProperty(const dbus::ObjectPath& ipconfig_path, 80 const std::string& name, 81 const base::Value& value, 82 const VoidDBusMethodCallback& callback) = 0; 83 84 // Calls ClearProperty method. 85 // |callback| is called after the method call succeeds. 86 virtual void ClearProperty(const dbus::ObjectPath& ipconfig_path, 87 const std::string& name, 88 const VoidDBusMethodCallback& callback) = 0; 89 90 // Calls Remove method. 91 // |callback| is called after the method call succeeds. 92 virtual void Remove(const dbus::ObjectPath& ipconfig_path, 93 const VoidDBusMethodCallback& callback) = 0; 94 95 // Returns an interface for testing (stub only), or returns NULL. 96 virtual ShillIPConfigClient::TestInterface* GetTestInterface() = 0; 97 98 protected: 99 friend class ShillIPConfigClientTest; 100 101 // Create() should be used instead. 102 ShillIPConfigClient(); 103 104 private: 105 DISALLOW_COPY_AND_ASSIGN(ShillIPConfigClient); 106}; 107 108} // namespace chromeos 109 110#endif // CHROMEOS_DBUS_SHILL_IPCONFIG_CLIENT_H_ 111