Darin Petkov | e4b2702 | 2012-05-16 13:28:50 +0200 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium OS Authors. All rights reserved. |
Darin Petkov | e0a312e | 2011-07-20 13:45:28 -0700 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
Darin Petkov | 25665aa | 2012-05-21 14:08:12 +0200 | [diff] [blame] | 5 | #ifndef SHILL_DBUS_PROPERTIES_H_ |
| 6 | #define SHILL_DBUS_PROPERTIES_H_ |
Darin Petkov | e0a312e | 2011-07-20 13:45:28 -0700 | [diff] [blame] | 7 | |
| 8 | #include <map> |
| 9 | #include <string> |
Jason Glasgow | 9c09e36 | 2012-04-18 15:16:29 -0400 | [diff] [blame] | 10 | #include <vector> |
Darin Petkov | e0a312e | 2011-07-20 13:45:28 -0700 | [diff] [blame] | 11 | |
| 12 | #include <base/basictypes.h> |
| 13 | #include <dbus-c++/types.h> |
| 14 | |
Darin Petkov | e4b2702 | 2012-05-16 13:28:50 +0200 | [diff] [blame] | 15 | #include "shill/accessor_interface.h" |
| 16 | |
Darin Petkov | e0a312e | 2011-07-20 13:45:28 -0700 | [diff] [blame] | 17 | namespace shill { |
| 18 | |
| 19 | typedef std::map<std::string, DBus::Variant> DBusPropertiesMap; |
| 20 | |
| 21 | class DBusProperties { |
| 22 | public: |
Eric Shienbrood | 7fce52c | 2012-04-13 19:11:02 -0400 | [diff] [blame] | 23 | static bool GetBool(const DBusPropertiesMap &properties, |
| 24 | const std::string &key, |
| 25 | bool *value); |
| 26 | |
| 27 | static bool GetInt32(const DBusPropertiesMap &properties, |
| 28 | const std::string &key, |
| 29 | int32 *value); |
Darin Petkov | e0a312e | 2011-07-20 13:45:28 -0700 | [diff] [blame] | 30 | |
Nathan Williams | e984080 | 2012-04-18 18:47:40 -0400 | [diff] [blame] | 31 | static bool GetObjectPath(const DBusPropertiesMap &properties, |
| 32 | const std::string &key, |
| 33 | std::string *value); |
| 34 | |
Eric Shienbrood | 7fce52c | 2012-04-13 19:11:02 -0400 | [diff] [blame] | 35 | static bool GetString(const DBusPropertiesMap &properties, |
Darin Petkov | e0a312e | 2011-07-20 13:45:28 -0700 | [diff] [blame] | 36 | const std::string &key, |
Eric Shienbrood | 7fce52c | 2012-04-13 19:11:02 -0400 | [diff] [blame] | 37 | std::string *value); |
Darin Petkov | e0a312e | 2011-07-20 13:45:28 -0700 | [diff] [blame] | 38 | |
Jason Glasgow | 9c09e36 | 2012-04-18 15:16:29 -0400 | [diff] [blame] | 39 | static bool GetStrings(const DBusPropertiesMap &properties, |
| 40 | const std::string &key, |
| 41 | std::vector<std::string> *value); |
| 42 | |
Darin Petkov | ceb6817 | 2011-07-29 14:47:48 -0700 | [diff] [blame] | 43 | static bool GetUint16(const DBusPropertiesMap &properties, |
| 44 | const std::string &key, |
| 45 | uint16 *value); |
| 46 | |
Eric Shienbrood | 7fce52c | 2012-04-13 19:11:02 -0400 | [diff] [blame] | 47 | static bool GetUint32(const DBusPropertiesMap &properties, |
| 48 | const std::string &key, |
| 49 | uint32 *value); |
| 50 | |
Darin Petkov | e4b2702 | 2012-05-16 13:28:50 +0200 | [diff] [blame] | 51 | static bool GetRpcIdentifiers(const DBusPropertiesMap &properties, |
| 52 | const std::string &key, |
Darin Petkov | 9893d9c | 2012-05-17 15:27:31 -0700 | [diff] [blame] | 53 | RpcIdentifiers *value); |
| 54 | |
| 55 | static void ConvertPathsToRpcIdentifiers( |
| 56 | const std::vector<DBus::Path> &dbus_paths, |
| 57 | RpcIdentifiers *rpc_identifiers); |
Darin Petkov | e4b2702 | 2012-05-16 13:28:50 +0200 | [diff] [blame] | 58 | |
Darin Petkov | 25665aa | 2012-05-21 14:08:12 +0200 | [diff] [blame] | 59 | static void ConvertKeyValueStoreToMap( |
| 60 | const KeyValueStore &store, DBusPropertiesMap *properties); |
| 61 | |
Gary Morain | 610977f | 2012-05-04 16:03:52 -0700 | [diff] [blame] | 62 | static std::string KeysToString(const std::map<std::string, |
| 63 | ::DBus::Variant> &args); |
| 64 | |
Darin Petkov | e0a312e | 2011-07-20 13:45:28 -0700 | [diff] [blame] | 65 | private: |
| 66 | DISALLOW_COPY_AND_ASSIGN(DBusProperties); |
| 67 | }; |
| 68 | |
| 69 | } // namespace shill |
| 70 | |
Darin Petkov | 25665aa | 2012-05-21 14:08:12 +0200 | [diff] [blame] | 71 | #endif // SHILL_DBUS_PROPERTIES_H_ |