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

Side by Side Diff: dbus_interface.h

Issue 6594025: AU: Full proxy support (Closed) Base URL: http://git.chromium.org/git/update_engine.git@master
Patch Set: fixes for review Created 9 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « dbus_constants.h ('k') | main.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. 1 // Copyright (c) 2010 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_PLATFORM_UPDATE_ENGINE_DBUS_INTERFACE_H__ 5 #ifndef CHROMEOS_PLATFORM_UPDATE_ENGINE_DBUS_INTERFACE_H__
6 #define CHROMEOS_PLATFORM_UPDATE_ENGINE_DBUS_INTERFACE_H__ 6 #define CHROMEOS_PLATFORM_UPDATE_ENGINE_DBUS_INTERFACE_H__
7 7
8 // This class interfaces with DBus. The interface allows it to be mocked. 8 // This class interfaces with DBus. The interface allows it to be mocked.
9 9
10 #include <base/logging.h> 10 #include <base/logging.h>
11 #include <dbus/dbus-glib.h> 11 #include <dbus/dbus-glib.h>
12 #include <dbus/dbus-glib-lowlevel.h>
12 13
13 namespace chromeos_update_engine { 14 namespace chromeos_update_engine {
14 15
15 class DbusGlibInterface { 16 class DbusGlibInterface {
16 public: 17 public:
17 // wraps dbus_g_proxy_new_for_name_owner 18 // wraps dbus_g_proxy_new_for_name_owner
18 virtual DBusGProxy* ProxyNewForNameOwner(DBusGConnection* connection, 19 virtual DBusGProxy* ProxyNewForNameOwner(DBusGConnection* connection,
19 const char* name, 20 const char* name,
20 const char* path, 21 const char* path,
21 const char* interface, 22 const char* interface,
22 GError** error) = 0; 23 GError** error) = 0;
23 24
24 // wraps g_object_unref 25 // wraps g_object_unref
25 virtual void ProxyUnref(DBusGProxy* proxy) = 0; 26 virtual void ProxyUnref(DBusGProxy* proxy) = 0;
26 27
27 // wraps dbus_g_bus_get 28 // wraps dbus_g_bus_get
28 virtual DBusGConnection* BusGet(DBusBusType type, GError** error) = 0; 29 virtual DBusGConnection* BusGet(DBusBusType type, GError** error) = 0;
29 30
30 // wraps dbus_g_proxy_call 31 // wraps dbus_g_proxy_call
31 virtual gboolean ProxyCall(DBusGProxy* proxy, 32 virtual gboolean ProxyCall(DBusGProxy* proxy,
32 const char* method, 33 const char* method,
33 GError** error, 34 GError** error,
34 GType first_arg_type, 35 GType first_arg_type,
35 GType var_arg1, 36 GType var_arg1,
36 GHashTable** var_arg2, 37 GHashTable** var_arg2,
37 GType var_arg3) = 0; 38 GType var_arg3) = 0;
38 39
39 virtual gboolean ProxyCall(DBusGProxy* proxy, 40 virtual gboolean ProxyCall(DBusGProxy* proxy,
40 const char* method, 41 const char* method,
41 GError** error, 42 GError** error,
42 GType var_arg1, const char* var_arg2, 43 GType var_arg1, const char* var_arg2,
43 GType var_arg3, 44 GType var_arg3,
44 GType var_arg4, gchar** var_arg5, 45 GType var_arg4, gchar** var_arg5,
45 GType var_arg6, GArray** var_arg7, 46 GType var_arg6, GArray** var_arg7,
46 GType var_arg8) = 0; 47 GType var_arg8) = 0;
48
49 virtual gboolean ProxyCall(DBusGProxy* proxy,
50 const char* method,
51 GError** error,
52 GType var_arg1, const char* var_arg2,
53 GType var_arg3, const char* var_arg4,
54 GType var_arg5, const char* var_arg6,
55 GType var_arg7, GType var_arg8) = 0;
56
57 virtual DBusConnection* ConnectionGetConnection(DBusGConnection* gbus) = 0;
58
59 virtual void DbusBusAddMatch(DBusConnection* connection,
60 const char* rule,
61 DBusError* error) = 0;
62
63 virtual dbus_bool_t DbusConnectionAddFilter(
64 DBusConnection* connection,
65 DBusHandleMessageFunction function,
66 void* user_data,
67 DBusFreeFunction free_data_function) = 0;
68 virtual void DbusConnectionRemoveFilter(DBusConnection* connection,
69 DBusHandleMessageFunction function,
70 void* user_data) = 0;
71 virtual dbus_bool_t DbusMessageIsSignal(DBusMessage* message,
72 const char* interface,
73 const char* signal_name) = 0;
74 virtual dbus_bool_t DbusMessageGetArgs(DBusMessage* message,
75 DBusError* error,
76 GType var_arg1, char** var_arg2,
77 GType var_arg3, char** var_arg4,
78 GType var_arg5, char** var_arg6,
79 GType var_arg7) = 0;
47 }; 80 };
48 81
49 class ConcreteDbusGlib : public DbusGlibInterface { 82 class ConcreteDbusGlib : public DbusGlibInterface {
50 virtual DBusGProxy* ProxyNewForNameOwner(DBusGConnection* connection, 83 virtual DBusGProxy* ProxyNewForNameOwner(DBusGConnection* connection,
51 const char* name, 84 const char* name,
52 const char* path, 85 const char* path,
53 const char* interface, 86 const char* interface,
54 GError** error) { 87 GError** error) {
55 return dbus_g_proxy_new_for_name_owner(connection, 88 return dbus_g_proxy_new_for_name_owner(connection,
56 name, 89 name,
57 path, 90 path,
58 interface, 91 interface,
59 error); 92 error);
60 } 93 }
61 94
62 virtual void ProxyUnref(DBusGProxy* proxy) { 95 virtual void ProxyUnref(DBusGProxy* proxy) {
63 g_object_unref(proxy); 96 g_object_unref(proxy);
64 } 97 }
65 98
66 virtual DBusGConnection* BusGet(DBusBusType type, GError** error) { 99 virtual DBusGConnection* BusGet(DBusBusType type, GError** error) {
67 return dbus_g_bus_get(type, error); 100 return dbus_g_bus_get(type, error);
68 } 101 }
69 102
70 virtual gboolean ProxyCall(DBusGProxy* proxy, 103 virtual gboolean ProxyCall(DBusGProxy* proxy,
71 const char* method, 104 const char* method,
72 GError** error, 105 GError** error,
73 GType first_arg_type, 106 GType first_arg_type,
74 GType var_arg1, 107 GType var_arg1,
75 GHashTable** var_arg2, 108 GHashTable** var_arg2,
76 GType var_arg3) { 109 GType var_arg3) {
77 return dbus_g_proxy_call( 110 return dbus_g_proxy_call(
78 proxy, method, error, first_arg_type, var_arg1, var_arg2, var_arg3); 111 proxy, method, error, first_arg_type, var_arg1, var_arg2, var_arg3);
79 } 112 }
80 113
81 virtual gboolean ProxyCall(DBusGProxy* proxy, 114 virtual gboolean ProxyCall(DBusGProxy* proxy,
82 const char* method, 115 const char* method,
83 GError** error, 116 GError** error,
84 GType var_arg1, const char* var_arg2, 117 GType var_arg1, const char* var_arg2,
85 GType var_arg3, 118 GType var_arg3,
86 GType var_arg4, gchar** var_arg5, 119 GType var_arg4, gchar** var_arg5,
87 GType var_arg6, GArray** var_arg7, 120 GType var_arg6, GArray** var_arg7,
88 GType var_arg8) { 121 GType var_arg8) {
89 return dbus_g_proxy_call( 122 return dbus_g_proxy_call(
90 proxy, method, error, var_arg1, var_arg2, var_arg3, 123 proxy, method, error, var_arg1, var_arg2, var_arg3,
91 var_arg4, var_arg5, var_arg6, var_arg7, var_arg8); 124 var_arg4, var_arg5, var_arg6, var_arg7, var_arg8);
92 } 125 }
126
127 virtual gboolean ProxyCall(DBusGProxy* proxy,
128 const char* method,
129 GError** error,
130 GType var_arg1, const char* var_arg2,
131 GType var_arg3, const char* var_arg4,
132 GType var_arg5, const char* var_arg6,
133 GType var_arg7, GType var_arg8) {
134 return dbus_g_proxy_call(
135 proxy, method, error, var_arg1, var_arg2, var_arg3,
136 var_arg4, var_arg5, var_arg6, var_arg7, var_arg8);
137 }
138
139
140 virtual DBusConnection* ConnectionGetConnection(DBusGConnection* gbus) {
141 return dbus_g_connection_get_connection(gbus);
142 }
143
144 virtual void DbusBusAddMatch(DBusConnection* connection,
145 const char* rule,
146 DBusError* error) {
147 dbus_bus_add_match(connection, rule, error);
148 }
149
150 virtual dbus_bool_t DbusConnectionAddFilter(
151 DBusConnection* connection,
152 DBusHandleMessageFunction function,
153 void* user_data,
154 DBusFreeFunction free_data_function) {
155 return dbus_connection_add_filter(connection,
156 function,
157 user_data,
158 free_data_function);
159 }
160 virtual void DbusConnectionRemoveFilter(DBusConnection* connection,
161 DBusHandleMessageFunction function,
162 void* user_data) {
163 dbus_connection_remove_filter(connection, function, user_data);
164 }
165 dbus_bool_t DbusMessageIsSignal(DBusMessage* message,
166 const char* interface,
167 const char* signal_name) {
168 return dbus_message_is_signal(message, interface, signal_name);
169 }
170 virtual dbus_bool_t DbusMessageGetArgs(DBusMessage* message,
171 DBusError* error,
172 GType var_arg1, char** var_arg2,
173 GType var_arg3, char** var_arg4,
174 GType var_arg5, char** var_arg6,
175 GType var_arg7) {
176 return dbus_message_get_args(message, error,
177 var_arg1, var_arg2,
178 var_arg3, var_arg4,
179 var_arg5, var_arg6,
180 var_arg7);
181 }
93 }; 182 };
94 183
95 } // namespace chromeos_update_engine 184 } // namespace chromeos_update_engine
96 185
97 #endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_DBUS_INTERFACE_H__ 186 #endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_DBUS_INTERFACE_H__
OLDNEW
« no previous file with comments | « dbus_constants.h ('k') | main.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698