Elly Jones | 16227d3 | 2012-02-09 14:17:25 -0500 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium OS Authors. All rights reserved. |
Chris Masone | d7732e4 | 2011-05-20 11:08:56 -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 | |
| 5 | #ifndef SHILL_MANAGER_DBUS_ADAPTOR_H_ |
| 6 | #define SHILL_MANAGER_DBUS_ADAPTOR_H_ |
| 7 | |
| 8 | #include <map> |
| 9 | #include <string> |
| 10 | |
| 11 | #include <base/basictypes.h> |
Chris Masone | 8fe2c7e | 2011-06-09 15:51:19 -0700 | [diff] [blame] | 12 | #include <dbus-c++/dbus.h> |
Chris Masone | d7732e4 | 2011-05-20 11:08:56 -0700 | [diff] [blame] | 13 | |
| 14 | #include "shill/adaptor_interfaces.h" |
| 15 | #include "shill/dbus_adaptor.h" |
Liam McLoughlin | ef342b4 | 2013-09-13 21:05:36 +0100 | [diff] [blame] | 16 | #include "shill/dbus_adaptors/org.chromium.flimflam.Manager.h" |
Chris Masone | d7732e4 | 2011-05-20 11:08:56 -0700 | [diff] [blame] | 17 | |
| 18 | namespace shill { |
Chris Masone | ec6b18b | 2011-06-08 14:09:10 -0700 | [diff] [blame] | 19 | |
Chris Masone | d7732e4 | 2011-05-20 11:08:56 -0700 | [diff] [blame] | 20 | class Manager; |
| 21 | |
| 22 | // Subclass of DBusAdaptor for Manager objects |
Chris Masone | ec6b18b | 2011-06-08 14:09:10 -0700 | [diff] [blame] | 23 | // There is a 1:1 mapping between Manager and ManagerDBusAdaptor |
| 24 | // instances. Furthermore, the Manager owns the ManagerDBusAdaptor |
| 25 | // and manages its lifetime, so we're OK with ManagerDBusAdaptor |
| 26 | // having a bare pointer to its owner manager. |
Chris Masone | d7732e4 | 2011-05-20 11:08:56 -0700 | [diff] [blame] | 27 | class ManagerDBusAdaptor : public org::chromium::flimflam::Manager_adaptor, |
| 28 | public DBusAdaptor, |
Christopher Wiley | 0d9cf0c | 2013-02-19 19:24:57 -0800 | [diff] [blame] | 29 | public ManagerAdaptorInterface, |
| 30 | public base::SupportsWeakPtr<ManagerDBusAdaptor> { |
Chris Masone | d7732e4 | 2011-05-20 11:08:56 -0700 | [diff] [blame] | 31 | public: |
Chris Masone | d7732e4 | 2011-05-20 11:08:56 -0700 | [diff] [blame] | 32 | static const char kPath[]; |
| 33 | |
Chris Masone | d0ceb8c | 2011-06-02 10:05:39 -0700 | [diff] [blame] | 34 | ManagerDBusAdaptor(DBus::Connection *conn, Manager *manager); |
Chris Masone | d7732e4 | 2011-05-20 11:08:56 -0700 | [diff] [blame] | 35 | virtual ~ManagerDBusAdaptor(); |
Chris Masone | d0ceb8c | 2011-06-02 10:05:39 -0700 | [diff] [blame] | 36 | |
| 37 | // Implementation of ManagerAdaptorInterface. |
Chris Masone | 95207da | 2011-06-29 16:50:49 -0700 | [diff] [blame] | 38 | virtual const std::string &GetRpcIdentifier() { return path(); } |
Chris Masone | d7732e4 | 2011-05-20 11:08:56 -0700 | [diff] [blame] | 39 | void UpdateRunning(); |
Chris Masone | 8fe2c7e | 2011-06-09 15:51:19 -0700 | [diff] [blame] | 40 | void EmitBoolChanged(const std::string &name, bool value); |
| 41 | void EmitUintChanged(const std::string &name, uint32 value); |
| 42 | void EmitIntChanged(const std::string &name, int value); |
| 43 | void EmitStringChanged(const std::string &name, const std::string &value); |
Gaurav Shah | 435de2c | 2011-11-17 19:01:07 -0800 | [diff] [blame] | 44 | void EmitStringsChanged(const std::string &name, |
| 45 | const std::vector<std::string> &value); |
Paul Stewart | 49739c0 | 2012-08-08 17:24:03 -0700 | [diff] [blame] | 46 | void EmitRpcIdentifierChanged( |
| 47 | const std::string &name, const std::string &value); |
mukesh agrawal | 3239932 | 2011-09-01 10:53:43 -0700 | [diff] [blame] | 48 | void EmitRpcIdentifierArrayChanged( |
| 49 | const std::string &name, const std::vector<std::string> &value); |
Chris Masone | 8fe2c7e | 2011-06-09 15:51:19 -0700 | [diff] [blame] | 50 | void EmitStateChanged(const std::string &new_state); |
Chris Masone | d7732e4 | 2011-05-20 11:08:56 -0700 | [diff] [blame] | 51 | |
| 52 | // Implementation of Manager_adaptor |
| 53 | std::map<std::string, ::DBus::Variant> GetProperties(::DBus::Error &error); |
Chris Masone | 8fe2c7e | 2011-06-09 15:51:19 -0700 | [diff] [blame] | 54 | void SetProperty(const std::string &name, |
| 55 | const ::DBus::Variant &value, |
Chris Masone | d7732e4 | 2011-05-20 11:08:56 -0700 | [diff] [blame] | 56 | ::DBus::Error &error); |
| 57 | std::string GetState(::DBus::Error &error); |
Chris Masone | 8fe2c7e | 2011-06-09 15:51:19 -0700 | [diff] [blame] | 58 | ::DBus::Path CreateProfile(const std::string &name, ::DBus::Error &error); |
| 59 | void RemoveProfile(const std::string &name, ::DBus::Error &error); |
| 60 | ::DBus::Path PushProfile(const std::string &, ::DBus::Error &error); |
Paul Stewart | f3eced9 | 2013-04-17 12:18:22 -0700 | [diff] [blame] | 61 | ::DBus::Path InsertUserProfile(const std::string &, |
| 62 | const std::string &, |
| 63 | ::DBus::Error &error); |
Chris Masone | 8fe2c7e | 2011-06-09 15:51:19 -0700 | [diff] [blame] | 64 | void PopProfile(const std::string &, ::DBus::Error &error); |
Chris Masone | ccc8881 | 2011-06-08 18:00:10 -0700 | [diff] [blame] | 65 | void PopAnyProfile(::DBus::Error &error); |
Paul Stewart | 307c250 | 2013-03-23 12:32:10 -0700 | [diff] [blame] | 66 | void PopAllUserProfiles(::DBus::Error &error); |
Paul Stewart | c681fa0 | 2012-03-02 19:40:04 -0800 | [diff] [blame] | 67 | void RecheckPortal(::DBus::Error &error); |
Chris Masone | 8fe2c7e | 2011-06-09 15:51:19 -0700 | [diff] [blame] | 68 | void RequestScan(const std::string &, ::DBus::Error &error); |
Chris Masone | d7732e4 | 2011-05-20 11:08:56 -0700 | [diff] [blame] | 69 | |
Chris Masone | 8fe2c7e | 2011-06-09 15:51:19 -0700 | [diff] [blame] | 70 | void EnableTechnology(const std::string &, ::DBus::Error &error); |
| 71 | void DisableTechnology(const std::string &, ::DBus::Error &error); |
Chris Masone | d7732e4 | 2011-05-20 11:08:56 -0700 | [diff] [blame] | 72 | |
Darin Petkov | b65c245 | 2012-02-23 15:17:06 +0100 | [diff] [blame] | 73 | ::DBus::Path GetService(const std::map<std::string, ::DBus::Variant> &args, |
Chris Masone | d7732e4 | 2011-05-20 11:08:56 -0700 | [diff] [blame] | 74 | ::DBus::Error &error); |
Darin Petkov | b65c245 | 2012-02-23 15:17:06 +0100 | [diff] [blame] | 75 | ::DBus::Path GetVPNService(const std::map<std::string, ::DBus::Variant> &args, |
| 76 | ::DBus::Error &error); |
| 77 | ::DBus::Path GetWifiService( |
| 78 | const std::map<std::string, ::DBus::Variant> &args, |
| 79 | ::DBus::Error &error); |
Paul Stewart | d39d692 | 2012-12-21 08:59:57 -0800 | [diff] [blame] | 80 | ::DBus::Path ConfigureService( |
| 81 | const std::map<std::string, ::DBus::Variant> &args, |
| 82 | ::DBus::Error &error); |
Paul Stewart | d2e1c36 | 2013-03-03 19:06:07 -0800 | [diff] [blame] | 83 | ::DBus::Path ConfigureServiceForProfile( |
| 84 | const ::DBus::Path &profile_rpcid, |
| 85 | const std::map<std::string, ::DBus::Variant> &args, |
| 86 | ::DBus::Error &error); |
Paul Stewart | 7a20aa4 | 2013-01-17 12:21:41 -0800 | [diff] [blame] | 87 | ::DBus::Path FindMatchingService( |
| 88 | const std::map<std::string, ::DBus::Variant> &args, |
| 89 | ::DBus::Error &error); |
Chris Masone | d7732e4 | 2011-05-20 11:08:56 -0700 | [diff] [blame] | 90 | |
Chris Masone | 7ccc819 | 2011-05-24 14:54:49 -0700 | [diff] [blame] | 91 | int32_t GetDebugLevel(::DBus::Error &error); |
Chris Masone | 8fe2c7e | 2011-06-09 15:51:19 -0700 | [diff] [blame] | 92 | void SetDebugLevel(const int32_t &level, ::DBus::Error &error); |
Chris Masone | d7732e4 | 2011-05-20 11:08:56 -0700 | [diff] [blame] | 93 | |
| 94 | std::string GetServiceOrder(::DBus::Error &error); |
Chris Masone | 8fe2c7e | 2011-06-09 15:51:19 -0700 | [diff] [blame] | 95 | void SetServiceOrder(const std::string &, ::DBus::Error &error); |
Chris Masone | d7732e4 | 2011-05-20 11:08:56 -0700 | [diff] [blame] | 96 | |
Elly Jones | 16227d3 | 2012-02-09 14:17:25 -0500 | [diff] [blame] | 97 | std::string GetDebugTags(::DBus::Error &error); |
| 98 | void SetDebugTags(const std::string &tags, ::DBus::Error &error); |
| 99 | std::string ListDebugTags(::DBus::Error &error); |
| 100 | |
Gaurav Shah | 645bff8 | 2012-10-08 14:06:04 -0700 | [diff] [blame] | 101 | std::map<std::string, ::DBus::Variant> GetNetworksForGeolocation( |
| 102 | ::DBus::Error &error); |
| 103 | |
Christopher Wiley | 3d5ab40 | 2013-02-15 13:25:58 -0800 | [diff] [blame] | 104 | bool VerifyDestination(const std::string &certificate, |
| 105 | const std::string &public_key, |
| 106 | const std::string &nonce, |
| 107 | const std::string &signed_data, |
| 108 | const std::string &destination_udn, |
Christopher Wiley | cdde79f | 2013-05-01 14:26:56 -0700 | [diff] [blame] | 109 | const std::string &hotspot_ssid, |
| 110 | const std::string &hotspot_bssid, |
Christopher Wiley | 3d5ab40 | 2013-02-15 13:25:58 -0800 | [diff] [blame] | 111 | ::DBus::Error &error); |
| 112 | |
| 113 | std::string VerifyAndEncryptCredentials(const std::string &certificate, |
| 114 | const std::string &public_key, |
| 115 | const std::string &nonce, |
| 116 | const std::string &signed_data, |
| 117 | const std::string &destination_udn, |
Christopher Wiley | cdde79f | 2013-05-01 14:26:56 -0700 | [diff] [blame] | 118 | const std::string &hotspot_ssid, |
| 119 | const std::string &hotspot_bssid, |
Christopher Wiley | 3d5ab40 | 2013-02-15 13:25:58 -0800 | [diff] [blame] | 120 | const ::DBus::Path &path, |
| 121 | ::DBus::Error &error); |
| 122 | |
| 123 | std::string VerifyAndEncryptData(const std::string &certificate, |
| 124 | const std::string &public_key, |
| 125 | const std::string &nonce, |
| 126 | const std::string &signed_data, |
| 127 | const std::string &destination_udn, |
Christopher Wiley | cdde79f | 2013-05-01 14:26:56 -0700 | [diff] [blame] | 128 | const std::string &hotspot_ssid, |
| 129 | const std::string &hotspot_bssid, |
Christopher Wiley | 3d5ab40 | 2013-02-15 13:25:58 -0800 | [diff] [blame] | 130 | const std::string &data, |
| 131 | ::DBus::Error &error); |
| 132 | |
Paul Stewart | 39db5ca | 2013-03-18 14:15:17 -0700 | [diff] [blame] | 133 | void ConnectToBestServices(::DBus::Error &error); |
| 134 | |
Chris Masone | d7732e4 | 2011-05-20 11:08:56 -0700 | [diff] [blame] | 135 | private: |
| 136 | Manager *manager_; |
| 137 | DISALLOW_COPY_AND_ASSIGN(ManagerDBusAdaptor); |
| 138 | }; |
| 139 | |
| 140 | } // namespace shill |
| 141 | #endif // SHILL_MANAGER_DBUS_ADAPTOR_H_ |