OLD | NEW |
1 // Copyright (c) 2009 The Chromium OS Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium OS Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROMEOS_DBUS_H_ | 5 #ifndef CHROMEOS_DBUS_H_ |
6 #define CHROMEOS_DBUS_H_ | 6 #define CHROMEOS_DBUS_H_ |
7 | 7 |
8 #include <dbus/dbus-glib.h> | 8 #include <dbus/dbus-glib.h> |
9 #include <glib-object.h> | 9 #include <glib-object.h> |
10 | 10 |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 } | 98 } |
99 | 99 |
100 // Equivalent to Proxy(connection, name, path, interface, false). | 100 // Equivalent to Proxy(connection, name, path, interface, false). |
101 Proxy(const BusConnection& connection, | 101 Proxy(const BusConnection& connection, |
102 const char* name, | 102 const char* name, |
103 const char* path, | 103 const char* path, |
104 const char* interface) | 104 const char* interface) |
105 : object_(GetGProxy(connection, name, path, interface, false)) { | 105 : object_(GetGProxy(connection, name, path, interface, false)) { |
106 } | 106 } |
107 | 107 |
| 108 // Creates a peer proxy using dbus_g_proxy_new_for_peer. |
| 109 Proxy(const BusConnection& connection, |
| 110 const char* path, |
| 111 const char* interface) |
| 112 : object_(GetGPeerProxy(connection, path, interface)) { |
| 113 } |
| 114 |
108 Proxy(const Proxy& x) | 115 Proxy(const Proxy& x) |
109 : object_(x.object_) { | 116 : object_(x.object_) { |
110 if (object_) | 117 if (object_) |
111 ::g_object_ref(object_); | 118 ::g_object_ref(object_); |
112 } | 119 } |
113 | 120 |
114 ~Proxy() { | 121 ~Proxy() { |
115 if (object_) | 122 if (object_) |
116 ::g_object_unref(object_); | 123 ::g_object_unref(object_); |
117 } | 124 } |
(...skipping 20 matching lines...) Expand all Loading... |
138 return object_; | 145 return object_; |
139 } | 146 } |
140 | 147 |
141 private: | 148 private: |
142 static value_type GetGProxy(const BusConnection& connection, | 149 static value_type GetGProxy(const BusConnection& connection, |
143 const char* name, | 150 const char* name, |
144 const char* path, | 151 const char* path, |
145 const char* interface, | 152 const char* interface, |
146 bool connect_to_name_owner); | 153 bool connect_to_name_owner); |
147 | 154 |
| 155 static value_type GetGPeerProxy(const BusConnection& connection, |
| 156 const char* path, |
| 157 const char* interface); |
| 158 |
148 operator int() const; // for safe bool cast | 159 operator int() const; // for safe bool cast |
149 friend void swap(Proxy& x, Proxy& y); | 160 friend void swap(Proxy& x, Proxy& y); |
150 | 161 |
151 value_type object_; | 162 value_type object_; |
152 }; | 163 }; |
153 | 164 |
154 inline void swap(Proxy& x, Proxy& y) { | 165 inline void swap(Proxy& x, Proxy& y) { |
155 std::swap(x.object_, y.object_); | 166 std::swap(x.object_, y.object_); |
156 } | 167 } |
157 | 168 |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
339 BusConnection GetSystemBusConnection(); | 350 BusConnection GetSystemBusConnection(); |
340 | 351 |
341 // \brief Returns a private connection to a bus at |address|. | 352 // \brief Returns a private connection to a bus at |address|. |
342 | 353 |
343 BusConnection GetPrivateBusConnection(const char* address); | 354 BusConnection GetPrivateBusConnection(const char* address); |
344 | 355 |
345 } // namespace dbus | 356 } // namespace dbus |
346 } // namespace chromeos | 357 } // namespace chromeos |
347 | 358 |
348 #endif // CHROMEOS_DBUS_H_ | 359 #endif // CHROMEOS_DBUS_H_ |
OLD | NEW |