Chris Masone | d7732e4 | 2011-05-20 11:08:56 -0700 | [diff] [blame] | 1 | // 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_DBUS_ADAPTOR_H_ |
| 6 | #define SHILL_DBUS_ADAPTOR_H_ |
| 7 | |
Chris Masone | 8fe2c7e | 2011-06-09 15:51:19 -0700 | [diff] [blame] | 8 | #include <map> |
Chris Masone | d7732e4 | 2011-05-20 11:08:56 -0700 | [diff] [blame] | 9 | #include <string> |
Chris Masone | 8fe2c7e | 2011-06-09 15:51:19 -0700 | [diff] [blame] | 10 | #include <vector> |
Chris Masone | d7732e4 | 2011-05-20 11:08:56 -0700 | [diff] [blame] | 11 | |
Chris Masone | d0ceb8c | 2011-06-02 10:05:39 -0700 | [diff] [blame] | 12 | #include <base/basictypes.h> |
Chris Masone | d7732e4 | 2011-05-20 11:08:56 -0700 | [diff] [blame] | 13 | #include <dbus-c++/dbus.h> |
| 14 | |
Chris Masone | d7732e4 | 2011-05-20 11:08:56 -0700 | [diff] [blame] | 15 | namespace shill { |
| 16 | |
| 17 | #define SHILL_INTERFACE "org.chromium.flimflam" |
| 18 | #define SHILL_PATH "/org/chromium/flimflam" |
| 19 | |
Chris Masone | 8fe2c7e | 2011-06-09 15:51:19 -0700 | [diff] [blame] | 20 | class PropertyStoreInterface; |
| 21 | |
Chris Masone | d7732e4 | 2011-05-20 11:08:56 -0700 | [diff] [blame] | 22 | // Superclass for all DBus-backed Adaptor objects |
| 23 | class DBusAdaptor : public DBus::ObjectAdaptor { |
| 24 | public: |
Chris Masone | d0ceb8c | 2011-06-02 10:05:39 -0700 | [diff] [blame] | 25 | DBusAdaptor(DBus::Connection* conn, const std::string& object_path); |
| 26 | virtual ~DBusAdaptor(); |
| 27 | |
Chris Masone | 8fe2c7e | 2011-06-09 15:51:19 -0700 | [diff] [blame] | 28 | static bool DispatchOnType(PropertyStoreInterface *store, |
| 29 | const std::string& name, |
| 30 | const ::DBus::Variant& value, |
| 31 | ::DBus::Error &error); |
Chris Masone | d0ceb8c | 2011-06-02 10:05:39 -0700 | [diff] [blame] | 32 | |
Chris Masone | 8fe2c7e | 2011-06-09 15:51:19 -0700 | [diff] [blame] | 33 | static ::DBus::Variant BoolToVariant(bool value); |
| 34 | static ::DBus::Variant ByteToVariant(uint8 value); |
| 35 | static ::DBus::Variant Int16ToVariant(int16 value); |
| 36 | static ::DBus::Variant Int32ToVariant(int32 value); |
| 37 | static ::DBus::Variant StringToVariant(const std::string& value); |
| 38 | static ::DBus::Variant StringmapToVariant( |
| 39 | const std::map<std::string, std::string>& value); |
| 40 | static ::DBus::Variant StringsToVariant( |
| 41 | const std::vector<std::string>& value); |
| 42 | static ::DBus::Variant Uint16ToVariant(uint16 value); |
| 43 | static ::DBus::Variant Uint32ToVariant(uint32 value); |
| 44 | |
| 45 | static bool IsBool(::DBus::Signature signature); |
| 46 | static bool IsByte(::DBus::Signature signature); |
| 47 | static bool IsInt16(::DBus::Signature signature); |
| 48 | static bool IsInt32(::DBus::Signature signature); |
| 49 | static bool IsString(::DBus::Signature signature); |
| 50 | static bool IsStringmap(::DBus::Signature signature); |
| 51 | static bool IsStrings(::DBus::Signature signature); |
| 52 | static bool IsUint16(::DBus::Signature signature); |
| 53 | static bool IsUint32(::DBus::Signature signature); |
| 54 | |
| 55 | private: |
| 56 | static const char kStringmapSig[]; |
| 57 | static const char kStringsSig[]; |
| 58 | DISALLOW_COPY_AND_ASSIGN(DBusAdaptor); |
Chris Masone | d7732e4 | 2011-05-20 11:08:56 -0700 | [diff] [blame] | 59 | }; |
| 60 | |
| 61 | } // namespace shill |
| 62 | #endif // SHILL_DBUS_ADAPTOR_H_ |