Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(544)

Side by Side Diff: chromeos/dbus/privet_daemon_manager_client.h

Issue 2291693002: Remove obsolete ChromeOS DBus bindings for privetd (Closed)
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium 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 CHROMEOS_DBUS_PRIVET_DAEMON_MANAGER_CLIENT_H_
6 #define CHROMEOS_DBUS_PRIVET_DAEMON_MANAGER_CLIENT_H_
7
8 #include <stddef.h>
9 #include <stdint.h>
10
11 #include <string>
12 #include <vector>
13
14 #include "base/macros.h"
15 #include "chromeos/chromeos_export.h"
16 #include "chromeos/dbus/dbus_client.h"
17 #include "chromeos/dbus/dbus_method_call_status.h"
18 #include "dbus/object_path.h"
19 #include "dbus/property.h"
20
21 namespace chromeos {
22
23 // PrivetDaemonManagerClient is used to communicate with the
24 // privetd service. All methods should be called from
25 // the origin thread which initializes the DBusThreadManager instance.
26 class CHROMEOS_EXPORT PrivetDaemonManagerClient : public DBusClient {
27 public:
28 class PairingInfo {
29 public:
30 PairingInfo();
31 ~PairingInfo();
32
33 // Returns the value of the pairing code; not necessarily a printable
34 // string.
35 const std::vector<uint8_t>& code() const { return code_; }
36 void set_code(const uint8_t* data, size_t length) {
37 code_.assign(data, data + length);
38 }
39
40 // Returns the selected type of pairing (e.g. "pinCode", "embeddedCode").
41 const std::string& mode() const { return mode_; }
42 void set_mode(const std::string& mode) { mode_ = mode; }
43
44 // Returns a unique identifier representing the pairing session.
45 const std::string& session_id() const { return session_id_; }
46 void set_session_id(const std::string& id) { session_id_ = id; }
47
48 // Resets the values to empty values.
49 void Clear();
50
51 private:
52 std::vector<uint8_t> code_;
53 std::string mode_;
54 std::string session_id_;
55 };
56
57 class PairingInfoProperty : public dbus::PropertyBase {
58 public:
59 bool PopValueFromReader(dbus::MessageReader* reader) override;
60 void AppendSetValueToWriter(dbus::MessageWriter* writer) override;
61 void ReplaceValueWithSetValue() override;
62
63 const PairingInfo& value() const { return value_; }
64
65 private:
66 PairingInfo value_;
67 };
68
69 // Structure of properties associated with a privet Manager.
70 class Properties : public dbus::PropertySet {
71 public:
72 Properties(dbus::ObjectProxy* object_proxy,
73 const std::string& interface_name,
74 const PropertyChangedCallback& callback);
75 ~Properties() override;
76
77 // State of WiFi bootstrapping.
78 // Values are "disabled", "waiting", "connecting", "monitoring".
79 const std::string& wifi_bootstrap_state() const {
80 return wifi_bootstrap_state_.value();
81 }
82
83 // State of GCD bootstrapping.
84 // Values are "disabled", "offline", "connecting", "waiting", "registering",
85 // "online".
86 const std::string& gcd_boostrap_state() const {
87 return gcd_bootstrap_state_.value();
88 }
89
90 // State of device pairing.
91 const PairingInfo& pairing_info() const { return pairing_info_.value(); }
92
93 // Concise note describing a peer. Suitable for display to the user.
94 const std::string& description() const { return description_.value(); }
95
96 // Concise name describing a peer. Suitable for display to the user.
97 const std::string& name() const { return name_.value(); }
98
99 private:
100 dbus::Property<std::string> wifi_bootstrap_state_;
101 dbus::Property<std::string> gcd_bootstrap_state_;
102 PairingInfoProperty pairing_info_;
103 dbus::Property<std::string> description_;
104 dbus::Property<std::string> name_;
105
106 DISALLOW_COPY_AND_ASSIGN(Properties);
107 };
108
109 // Interface for observing changes from a privet daemon.
110 class Observer {
111 public:
112 virtual ~Observer();
113
114 // Called when the manager has been added.
115 virtual void ManagerAdded() = 0;
116
117 // Called when the manager has been removed.
118 virtual void ManagerRemoved() = 0;
119
120 // Called when the manager has a change in value of the property named
121 // |property_name|. Valid values are "Description", "GCDBootstrapState",
122 // "Name", "PairingInfo", "WiFiBootstrapState".
123 virtual void ManagerPropertyChanged(const std::string& property_name) = 0;
124 };
125
126 ~PrivetDaemonManagerClient() override;
127
128 // Factory function, creates a new instance which is owned by the caller.
129 // For normal usage, access the singleton via DBusThreadManager::Get().
130 static PrivetDaemonManagerClient* Create();
131
132 // Adds and removes observers for events on all privet daemon events.
133 virtual void AddObserver(Observer* observer) = 0;
134 virtual void RemoveObserver(Observer* observer) = 0;
135
136 // Calls SetDescription method.
137 // |callback| is called with its |call_status| argument set to
138 // DBUS_METHOD_CALL_SUCCESS if the method call succeeds. Otherwise,
139 // |callback| is called with |call_status| set to DBUS_METHOD_CALL_FAILURE.
140 virtual void SetDescription(const std::string& description,
141 const VoidDBusMethodCallback& callback) = 0;
142
143 // Obtains the properties for the manager any values should be
144 // copied if needed.
145 virtual const Properties* GetProperties() = 0;
146
147 protected:
148 // Create() should be used instead.
149 PrivetDaemonManagerClient();
150
151 private:
152 DISALLOW_COPY_AND_ASSIGN(PrivetDaemonManagerClient);
153 };
154
155 } // namespace chromeos
156
157 #endif // CHROMEOS_DBUS_PRIVET_DAEMON_MANAGER_CLIENT_H_
OLDNEW
« no previous file with comments | « chromeos/dbus/fake_privet_daemon_manager_client.cc ('k') | chromeos/dbus/privet_daemon_manager_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698