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" |
Gaurav Shah | 3df47b7 | 2013-03-22 15:40:41 -0700 | [diff] [blame] | 16 | #include "shill/dbus_variant_gmock_printer.h" |
Darin Petkov | e4b2702 | 2012-05-16 13:28:50 +0200 | [diff] [blame] | 17 | |
Darin Petkov | e0a312e | 2011-07-20 13:45:28 -0700 | [diff] [blame] | 18 | namespace shill { |
| 19 | |
| 20 | typedef std::map<std::string, DBus::Variant> DBusPropertiesMap; |
Arman Uguray | 2c39fab | 2012-12-12 16:56:34 -0800 | [diff] [blame] | 21 | typedef std::map<uint32_t, DBus::Variant> DBusEnumValueMap; |
Darin Petkov | e0a312e | 2011-07-20 13:45:28 -0700 | [diff] [blame] | 22 | |
| 23 | class DBusProperties { |
| 24 | public: |
Eric Shienbrood | 7fce52c | 2012-04-13 19:11:02 -0400 | [diff] [blame] | 25 | static bool GetBool(const DBusPropertiesMap &properties, |
| 26 | const std::string &key, |
| 27 | bool *value); |
| 28 | |
| 29 | static bool GetInt32(const DBusPropertiesMap &properties, |
| 30 | const std::string &key, |
| 31 | int32 *value); |
Darin Petkov | e0a312e | 2011-07-20 13:45:28 -0700 | [diff] [blame] | 32 | |
Nathan Williams | e984080 | 2012-04-18 18:47:40 -0400 | [diff] [blame] | 33 | static bool GetObjectPath(const DBusPropertiesMap &properties, |
| 34 | const std::string &key, |
| 35 | std::string *value); |
| 36 | |
Eric Shienbrood | 7fce52c | 2012-04-13 19:11:02 -0400 | [diff] [blame] | 37 | static bool GetString(const DBusPropertiesMap &properties, |
Darin Petkov | e0a312e | 2011-07-20 13:45:28 -0700 | [diff] [blame] | 38 | const std::string &key, |
Eric Shienbrood | 7fce52c | 2012-04-13 19:11:02 -0400 | [diff] [blame] | 39 | std::string *value); |
Darin Petkov | e0a312e | 2011-07-20 13:45:28 -0700 | [diff] [blame] | 40 | |
Jason Glasgow | 9c09e36 | 2012-04-18 15:16:29 -0400 | [diff] [blame] | 41 | static bool GetStrings(const DBusPropertiesMap &properties, |
| 42 | const std::string &key, |
| 43 | std::vector<std::string> *value); |
| 44 | |
Darin Petkov | ceb6817 | 2011-07-29 14:47:48 -0700 | [diff] [blame] | 45 | static bool GetUint16(const DBusPropertiesMap &properties, |
| 46 | const std::string &key, |
| 47 | uint16 *value); |
| 48 | |
Eric Shienbrood | 7fce52c | 2012-04-13 19:11:02 -0400 | [diff] [blame] | 49 | static bool GetUint32(const DBusPropertiesMap &properties, |
| 50 | const std::string &key, |
| 51 | uint32 *value); |
| 52 | |
Darin Petkov | e4b2702 | 2012-05-16 13:28:50 +0200 | [diff] [blame] | 53 | static bool GetRpcIdentifiers(const DBusPropertiesMap &properties, |
| 54 | const std::string &key, |
Darin Petkov | 9893d9c | 2012-05-17 15:27:31 -0700 | [diff] [blame] | 55 | RpcIdentifiers *value); |
| 56 | |
| 57 | static void ConvertPathsToRpcIdentifiers( |
| 58 | const std::vector<DBus::Path> &dbus_paths, |
| 59 | RpcIdentifiers *rpc_identifiers); |
Darin Petkov | e4b2702 | 2012-05-16 13:28:50 +0200 | [diff] [blame] | 60 | |
Darin Petkov | 25665aa | 2012-05-21 14:08:12 +0200 | [diff] [blame] | 61 | static void ConvertKeyValueStoreToMap( |
| 62 | const KeyValueStore &store, DBusPropertiesMap *properties); |
| 63 | |
Gary Morain | 610977f | 2012-05-04 16:03:52 -0700 | [diff] [blame] | 64 | static std::string KeysToString(const std::map<std::string, |
| 65 | ::DBus::Variant> &args); |
| 66 | |
Darin Petkov | e0a312e | 2011-07-20 13:45:28 -0700 | [diff] [blame] | 67 | private: |
| 68 | DISALLOW_COPY_AND_ASSIGN(DBusProperties); |
| 69 | }; |
| 70 | |
| 71 | } // namespace shill |
| 72 | |
Darin Petkov | 25665aa | 2012-05-21 14:08:12 +0200 | [diff] [blame] | 73 | #endif // SHILL_DBUS_PROPERTIES_H_ |