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 | b925cc8 | 2011-06-22 15:39:57 -0700 | [diff] [blame] | 20 | class PropertyStore; |
Chris Masone | 8fe2c7e | 2011-06-09 15:51:19 -0700 | [diff] [blame] | 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 | b925cc8 | 2011-06-22 15:39:57 -0700 | [diff] [blame] | 25 | DBusAdaptor(DBus::Connection* conn, const std::string &object_path); |
Chris Masone | d0ceb8c | 2011-06-02 10:05:39 -0700 | [diff] [blame] | 26 | virtual ~DBusAdaptor(); |
| 27 | |
Chris Masone | b925cc8 | 2011-06-22 15:39:57 -0700 | [diff] [blame] | 28 | static bool DispatchOnType(PropertyStore *store, |
| 29 | const std::string &name, |
| 30 | const ::DBus::Variant &value, |
Chris Masone | 8fe2c7e | 2011-06-09 15:51:19 -0700 | [diff] [blame] | 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); |
Chris Masone | b925cc8 | 2011-06-22 15:39:57 -0700 | [diff] [blame] | 37 | static ::DBus::Variant PathToVariant(const ::DBus::Path &value); |
| 38 | static ::DBus::Variant StringToVariant(const std::string &value); |
Chris Masone | 8fe2c7e | 2011-06-09 15:51:19 -0700 | [diff] [blame] | 39 | static ::DBus::Variant StringmapToVariant( |
Chris Masone | b925cc8 | 2011-06-22 15:39:57 -0700 | [diff] [blame] | 40 | const std::map<std::string, std::string> &value); |
| 41 | static ::DBus::Variant StringmapsToVariant( |
| 42 | const std::vector<std::map<std::string, std::string> > &value); |
Chris Masone | 8fe2c7e | 2011-06-09 15:51:19 -0700 | [diff] [blame] | 43 | static ::DBus::Variant StringsToVariant( |
Chris Masone | b925cc8 | 2011-06-22 15:39:57 -0700 | [diff] [blame] | 44 | const std::vector<std::string> &value); |
Chris Masone | 8fe2c7e | 2011-06-09 15:51:19 -0700 | [diff] [blame] | 45 | static ::DBus::Variant Uint16ToVariant(uint16 value); |
| 46 | static ::DBus::Variant Uint32ToVariant(uint32 value); |
| 47 | |
| 48 | static bool IsBool(::DBus::Signature signature); |
| 49 | static bool IsByte(::DBus::Signature signature); |
| 50 | static bool IsInt16(::DBus::Signature signature); |
| 51 | static bool IsInt32(::DBus::Signature signature); |
Chris Masone | 3bd3c8c | 2011-06-13 08:20:26 -0700 | [diff] [blame] | 52 | static bool IsPath(::DBus::Signature signature); |
Chris Masone | 8fe2c7e | 2011-06-09 15:51:19 -0700 | [diff] [blame] | 53 | static bool IsString(::DBus::Signature signature); |
| 54 | static bool IsStringmap(::DBus::Signature signature); |
| 55 | static bool IsStrings(::DBus::Signature signature); |
| 56 | static bool IsUint16(::DBus::Signature signature); |
| 57 | static bool IsUint32(::DBus::Signature signature); |
| 58 | |
| 59 | private: |
| 60 | static const char kStringmapSig[]; |
| 61 | static const char kStringsSig[]; |
| 62 | DISALLOW_COPY_AND_ASSIGN(DBusAdaptor); |
Chris Masone | d7732e4 | 2011-05-20 11:08:56 -0700 | [diff] [blame] | 63 | }; |
| 64 | |
| 65 | } // namespace shill |
| 66 | #endif // SHILL_DBUS_ADAPTOR_H_ |