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_INTROSPECTABLE_CLIENT_H_ 6 #define CHROMEOS_DBUS_INTROSPECTABLE_CLIENT_H_ 7 8 #include <string> 9 #include <vector> 10 11 #include "base/callback.h" 12 #include "chromeos/chromeos_export.h" 13 #include "chromeos/dbus/dbus_client_implementation_type.h" 14 #include "dbus/object_path.h" 15 16 namespace dbus { 17 class Bus; 18 } // namespace dbus 19 20 namespace chromeos { 21 22 // IntrospectableClient is used to retrieve the D-Bus introspection data 23 // from a remote object. 24 class CHROMEOS_EXPORT IntrospectableClient { 25 public: 26 virtual ~IntrospectableClient(); 27 28 // The IntrospectCallback is used for the Introspect() method. It receives 29 // four arguments, the first two are the |service_name| and |object_path| 30 // of the remote object being introspected, the third is the |xml_data| of 31 // the object as described in 32 // http://dbus.freedesktop.org/doc/dbus-specification.html, the fourth 33 // |success| indicates whether the request succeeded. 34 typedef base::Callback<void(const std::string&, const dbus::ObjectPath&, 35 const std::string&, bool)> IntrospectCallback; 36 37 // Retrieves introspection data from the remote object on service name 38 // |service_name| with object path |object_path|, calling |callback| with 39 // the XML-formatted data received. 40 virtual void Introspect(const std::string& service_name, 41 const dbus::ObjectPath& object_path, 42 const IntrospectCallback& callback) = 0; 43 44 // Parses XML-formatted introspection data returned by 45 // org.freedesktop.DBus.Introspectable.Introspect and returns the list of 46 // interface names declared within. 47 static std::vector<std::string> GetInterfacesFromIntrospectResult( 48 const std::string& xml_data); 49 50 // Creates the instance 51 static IntrospectableClient* Create(DBusClientImplementationType type, 52 dbus::Bus* bus); 53 54 protected: 55 IntrospectableClient(); 56 57 private: 58 DISALLOW_COPY_AND_ASSIGN(IntrospectableClient); 59 }; 60 61 } // namespace chromeos 62 63 #endif // CHROMEOS_DBUS_INTROSPECTABLE_CLIENT_H_ 64