Annotation of /trunk/libunique/patches/libunique-1.1.6-unique-gdbus.patch
Parent Directory | Revision Log
Revision 1920 -
(hide annotations)
(download)
Wed Oct 24 17:40:00 2012 UTC (11 years, 11 months ago) by niro
File size: 17849 byte(s)
Wed Oct 24 17:40:00 2012 UTC (11 years, 11 months ago) by niro
File size: 17849 byte(s)
-patches for libunique 1.1.6
1 | niro | 1920 | From 01066039529c0181f231325476bb4823c16a2aea Mon Sep 17 00:00:00 2001 |
2 | From: Christian Persch <chpe@gnome.org> | ||
3 | Date: Sat, 15 May 2010 17:47:45 +0000 | ||
4 | Subject: Add GDBus backend | ||
5 | |||
6 | Add backend using GDBus, the new D-BUS binding in GIO 2.25. | ||
7 | |||
8 | Bug #618723. | ||
9 | --- | ||
10 | diff --git a/configure.ac b/configure.ac | ||
11 | index bc3163a..b6a4221 100644 | ||
12 | --- a/configure.ac | ||
13 | +++ b/configure.ac | ||
14 | @@ -116,6 +116,19 @@ AS_IF([test "x$have_dbus" = "xyes"], | ||
15 | |||
16 | AM_CONDITIONAL([HAVE_DBUS], [test "x$have_dbus" = "xyes"]) | ||
17 | |||
18 | +dnl GDBus backend | ||
19 | +dnl This is the default backend if GIO is recent enough | ||
20 | +m4_define([gdbus_gio_required],[2.25.7]) | ||
21 | +PKG_CHECK_MODULES([GDBUS],[gio-2.0 >= gdbus_gio_required],[have_gdbus=yes],[have_gdbus=no]) | ||
22 | + | ||
23 | +AS_IF([test "x$have_gdbus" = "xyes"], | ||
24 | + [ | ||
25 | + AC_DEFINE([HAVE_GDBUS],[1],[Define if GDBus backend is enabled]) | ||
26 | + ] | ||
27 | + ) | ||
28 | + | ||
29 | +AM_CONDITIONAL([HAVE_GDBUS],[test "$have_gdbus" = "yes"]) | ||
30 | + | ||
31 | dnl Bacon backend | ||
32 | dnl This is the fallback backend, so we *need* these headers and functions | ||
33 | dnl even if we end up using D-Bus | ||
34 | @@ -146,7 +159,13 @@ AM_CONDITIONAL([HAVE_BACON], [test "x$have_bacon" = "xyes"]) | ||
35 | |||
36 | dnl Choose the default backend | ||
37 | AC_MSG_CHECKING([for default IPC mechanism]) | ||
38 | -AS_IF([test "x$have_dbus" = "xyes"], | ||
39 | +AS_IF([test "x$have_gdbus" = "xyes"], | ||
40 | + [ | ||
41 | + UNIQUE_DEFAULT_BACKEND=gdbus | ||
42 | + AC_MSG_RESULT([GDBus]) | ||
43 | + ], | ||
44 | + | ||
45 | + [test "x$have_dbus" = "xyes"], | ||
46 | [ | ||
47 | UNIQUE_DEFAULT_BACKEND=dbus | ||
48 | AC_MSG_RESULT([D-Bus]) | ||
49 | @@ -243,6 +262,7 @@ AC_CONFIG_FILES([ | ||
50 | unique/uniqueversion.h | ||
51 | unique/bacon/Makefile | ||
52 | unique/dbus/Makefile | ||
53 | + unique/gdbus/Makefile | ||
54 | tests/Makefile | ||
55 | po/Makefile.in | ||
56 | ]) | ||
57 | @@ -261,6 +281,7 @@ Configuration: | ||
58 | Backends: | ||
59 | Unix Domain Socket: $have_bacon | ||
60 | D-BUS: $have_dbus | ||
61 | + GDBus: $have_gdbus | ||
62 | |||
63 | Default backend: $UNIQUE_DEFAULT_BACKEND | ||
64 | " | ||
65 | diff --git a/doc/reference/Makefile.am b/doc/reference/Makefile.am | ||
66 | index 3172588..2c1dbf4 100644 | ||
67 | --- a/doc/reference/Makefile.am | ||
68 | +++ b/doc/reference/Makefile.am | ||
69 | @@ -50,7 +50,8 @@ IGNORE_HFILES = \ | ||
70 | uniquemarshal.h \ | ||
71 | stamp-uniquemarshal.h \ | ||
72 | bacon \ | ||
73 | - dbus | ||
74 | + dbus \ | ||
75 | + gdbus | ||
76 | |||
77 | EXTRA_HFILES = | ||
78 | |||
79 | diff --git a/unique/Makefile.am b/unique/Makefile.am | ||
80 | index 6475a87..8f0b7ba 100644 | ||
81 | --- a/unique/Makefile.am | ||
82 | +++ b/unique/Makefile.am | ||
83 | @@ -12,7 +12,11 @@ if HAVE_DBUS | ||
84 | SUBDIRS += dbus | ||
85 | endif | ||
86 | |||
87 | -DIST_SUBDIRS = bacon dbus | ||
88 | +if HAVE_GDBUS | ||
89 | +SUBDIRS += gdbus | ||
90 | +endif | ||
91 | + | ||
92 | +DIST_SUBDIRS = bacon dbus gdbus | ||
93 | |||
94 | INCLUDES = -I$(top_srcdir) | ||
95 | |||
96 | @@ -72,6 +76,10 @@ if HAVE_DBUS | ||
97 | unique_backend_libs += $(top_builddir)/unique/dbus/libunique-dbus.la | ||
98 | endif | ||
99 | |||
100 | +if HAVE_GDBUS | ||
101 | +unique_backend_libs += $(top_builddir)/unique/gdbus/libunique-gdbus.la | ||
102 | +endif | ||
103 | + | ||
104 | uniquedir = $(includedir)/unique-1.0/unique | ||
105 | unique_HEADERS = \ | ||
106 | $(unique_sources_h) \ | ||
107 | diff --git a/unique/gdbus/.gitignore b/unique/gdbus/.gitignore | ||
108 | new file mode 100644 | ||
109 | index 0000000..c7e22c3 | ||
110 | --- /dev/null | ||
111 | +++ b/unique/gdbus/.gitignore | ||
112 | @@ -0,0 +1,2 @@ | ||
113 | +libunique_gdbus_la-uniquebackend-gdbus.lo | ||
114 | +libunique-gdbus.la | ||
115 | diff --git a/unique/gdbus/Makefile.am b/unique/gdbus/Makefile.am | ||
116 | new file mode 100644 | ||
117 | index 0000000..e10637d | ||
118 | --- /dev/null | ||
119 | +++ b/unique/gdbus/Makefile.am | ||
120 | @@ -0,0 +1,24 @@ | ||
121 | +include $(top_srcdir)/build/autotools/Makefile.am.silent | ||
122 | + | ||
123 | +noinst_LTLIBRARIES = libunique-gdbus.la | ||
124 | + | ||
125 | +libunique_gdbus_la_SOURCES = \ | ||
126 | + uniquebackend-gdbus.h \ | ||
127 | + uniquebackend-gdbus.c | ||
128 | + | ||
129 | +libunique_gdbus_la_PPCFLAGS = \ | ||
130 | + -DG_LOG_DOMAIN=\"Unique-GDBus\" \ | ||
131 | + -DG_DISABLE_SINGLE_INCLUDES \ | ||
132 | + -I$(top_srcdir) \ | ||
133 | + $(AM_CPPFLAGS) | ||
134 | + | ||
135 | +libunique_gdbus_la_CFLAGS = \ | ||
136 | + $(UNIQUE_CFLAGS) \ | ||
137 | + $(UNIQUE_DEBUG_CFLAGS) \ | ||
138 | + $(MAINTAINER_CFLAGS) \ | ||
139 | + $(GDBUS_CFLAGS) \ | ||
140 | + $(AM_CFLAGS) | ||
141 | + | ||
142 | +libunique_gdbus_la_LIBADD = \ | ||
143 | + $(UNIQUE_LIBS) \ | ||
144 | + $(GDBUS_LIBS) | ||
145 | diff --git a/unique/gdbus/uniquebackend-gdbus.c b/unique/gdbus/uniquebackend-gdbus.c | ||
146 | new file mode 100644 | ||
147 | index 0000000..14d54a9 | ||
148 | --- /dev/null | ||
149 | +++ b/unique/gdbus/uniquebackend-gdbus.c | ||
150 | @@ -0,0 +1,303 @@ | ||
151 | +/* Unique - Single Instance application library | ||
152 | + * uniquebackend-gdbus.c: GDBus implementation of UniqueBackend | ||
153 | + * | ||
154 | + * Copyright (C) 2007 Emmanuele Bassi <ebassi@o-hand.com> | ||
155 | + * Copyright © 2010 Christian Persch | ||
156 | + * | ||
157 | + * This library is free software; you can redistribute it and/or | ||
158 | + * modify it under the terms of the GNU Lesser General Public | ||
159 | + * License as published by the Free Software Foundation; either | ||
160 | + * version 2.1 of the License, or (at your option) any later version. | ||
161 | + * | ||
162 | + * This library is distributed in the hope that it will be useful, | ||
163 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
164 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
165 | + * Lesser General Public License for more details. | ||
166 | + * | ||
167 | + * You should have received a copy of the GNU Lesser General Public | ||
168 | + * License along with this library; if not, write to the Free Software | ||
169 | + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA | ||
170 | + * 02110-1301 USA | ||
171 | + */ | ||
172 | + | ||
173 | +#ifdef HAVE_CONFIG_H | ||
174 | +#include "config.h" | ||
175 | +#endif | ||
176 | + | ||
177 | +#include <gio/gio.h> | ||
178 | +#include <gdk/gdk.h> | ||
179 | + | ||
180 | +#include "../uniqueinternals.h" | ||
181 | +#include "uniquebackend-gdbus.h" | ||
182 | + | ||
183 | +struct _UniqueBackendGDBus | ||
184 | +{ | ||
185 | + UniqueBackend parent_instance; | ||
186 | + | ||
187 | + GDBusConnection *connection; | ||
188 | + guint registration_id; | ||
189 | + guint owner_id; | ||
190 | + gboolean owns_name; | ||
191 | + GMainLoop *loop; | ||
192 | +}; | ||
193 | + | ||
194 | +struct _UniqueBackendGDBusClass | ||
195 | +{ | ||
196 | + UniqueBackendClass parent_class; | ||
197 | + GDBusNodeInfo *introspection_data; | ||
198 | +}; | ||
199 | + | ||
200 | +G_DEFINE_TYPE (UniqueBackendGDBus, unique_backend_gdbus, UNIQUE_TYPE_BACKEND); | ||
201 | + | ||
202 | +static const char introspection_xml[] = | ||
203 | + "<node name='/'>" | ||
204 | + "<interface name='org.gtk.UniqueApp'>" | ||
205 | + "<method name='SendMessage'>" | ||
206 | + "<arg name='command' type='s' direction='in'/>" | ||
207 | + "<arg name='message' type='(suuus)' direction='in'/>" | ||
208 | + "<arg name='time' type='u' direction='in'/>" | ||
209 | + "<arg name='response' type='s' direction='out'/>" | ||
210 | + "</method>" | ||
211 | + "</interface>" | ||
212 | + "</node>"; | ||
213 | + | ||
214 | +static void | ||
215 | +method_call_cb (GDBusConnection *connection, | ||
216 | + const gchar *sender, | ||
217 | + const gchar *object_path, | ||
218 | + const gchar *interface_name, | ||
219 | + const gchar *method_name, | ||
220 | + GVariant *parameters, | ||
221 | + GDBusMethodInvocation *invocation, | ||
222 | + gpointer user_data) | ||
223 | +{ | ||
224 | + if (g_strcmp0 (interface_name, "org.gtk.UniqueApp") != 0 || | ||
225 | + g_strcmp0 (object_path, "/Factory") != 0) | ||
226 | + return; | ||
227 | + | ||
228 | + if (g_strcmp0 (method_name, "SendMessage") == 0) | ||
229 | + { | ||
230 | + UniqueBackend *backend = UNIQUE_BACKEND (user_data); | ||
231 | + const gchar *command_str, *data, *startup_id; | ||
232 | + guint len, screen_num, workspace, time_; | ||
233 | + UniqueMessageData message_data; | ||
234 | + gint command; | ||
235 | + UniqueResponse response; | ||
236 | + GdkDisplay *display; | ||
237 | + | ||
238 | + g_variant_get (parameters, | ||
239 | + "(&s(&suuu&s)u)", | ||
240 | + &command_str, | ||
241 | + &data, &len, &screen_num, &workspace, &startup_id, | ||
242 | + &time_); | ||
243 | + | ||
244 | + command = unique_command_from_string (backend->parent, command_str); | ||
245 | + if (command == 0) | ||
246 | + { | ||
247 | + g_dbus_method_invocation_return_error (invocation, | ||
248 | + G_DBUS_ERROR, | ||
249 | + G_DBUS_ERROR_INVALID_ARGS, | ||
250 | + "Invalid command `%s' received", | ||
251 | + command_str); | ||
252 | + return; | ||
253 | + } | ||
254 | + | ||
255 | + display = gdk_display_get_default (); | ||
256 | + | ||
257 | + message_data.data = len > 0 ? (guchar *) data : NULL; | ||
258 | + message_data.length = (gint) len; | ||
259 | + message_data.workspace = workspace; | ||
260 | + message_data.startup_id = (char *) startup_id; | ||
261 | + if (screen_num >= 0 && screen_num < gdk_display_get_n_screens (display)) | ||
262 | + message_data.screen = gdk_display_get_screen (display, screen_num); | ||
263 | + else | ||
264 | + message_data.screen = gdk_screen_get_default (); | ||
265 | + | ||
266 | + response = unique_app_emit_message_received (backend->parent, command, &message_data, time_); | ||
267 | + | ||
268 | + g_dbus_method_invocation_return_value (invocation, | ||
269 | + g_variant_new ("(s)", unique_response_to_string (response))); | ||
270 | + return; | ||
271 | + } | ||
272 | +} | ||
273 | + | ||
274 | +static void | ||
275 | +name_acquired_cb (GDBusConnection *connection, | ||
276 | + const gchar *name, | ||
277 | + gpointer user_data) | ||
278 | +{ | ||
279 | + UniqueBackendGDBus *backend_gdbus = UNIQUE_BACKEND_GDBUS (user_data); | ||
280 | + | ||
281 | + backend_gdbus->owns_name = TRUE; | ||
282 | + if (backend_gdbus->loop && g_main_loop_is_running (backend_gdbus->loop)) | ||
283 | + g_main_loop_quit (backend_gdbus->loop); | ||
284 | +} | ||
285 | + | ||
286 | +static void | ||
287 | +name_lost_cb (GDBusConnection *connection, | ||
288 | + const gchar *name, | ||
289 | + gpointer user_data) | ||
290 | +{ | ||
291 | + UniqueBackendGDBus *backend_gdbus = UNIQUE_BACKEND_GDBUS (user_data); | ||
292 | + | ||
293 | + backend_gdbus->owns_name = FALSE; | ||
294 | + if (backend_gdbus->loop && g_main_loop_is_running (backend_gdbus->loop)) | ||
295 | + g_main_loop_quit (backend_gdbus->loop); | ||
296 | +} | ||
297 | + | ||
298 | +static const GDBusInterfaceVTable interface_vtable = { | ||
299 | + method_call_cb, | ||
300 | + NULL, | ||
301 | + NULL | ||
302 | +}; | ||
303 | + | ||
304 | +static gboolean | ||
305 | +unique_backend_gdbus_request_name (UniqueBackend *backend) | ||
306 | +{ | ||
307 | + UniqueBackendGDBus *backend_gdbus = UNIQUE_BACKEND_GDBUS (backend); | ||
308 | + UniqueBackendGDBusClass *klass = UNIQUE_BACKEND_GDBUS_GET_CLASS (backend); | ||
309 | + GError *error; | ||
310 | + | ||
311 | + error = NULL; | ||
312 | + backend_gdbus->connection = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error); | ||
313 | + if (!backend_gdbus->connection) | ||
314 | + { | ||
315 | + g_warning ("Unable to open a connection to the session bus: %s", | ||
316 | + error->message); | ||
317 | + g_error_free (error); | ||
318 | + | ||
319 | + return FALSE; | ||
320 | + } | ||
321 | + | ||
322 | + backend_gdbus->registration_id = | ||
323 | + g_dbus_connection_register_object (backend_gdbus->connection, | ||
324 | + "/Factory", | ||
325 | + klass->introspection_data->interfaces[0], | ||
326 | + &interface_vtable, | ||
327 | + backend, NULL, | ||
328 | + &error); | ||
329 | + if (backend_gdbus->registration_id == 0) | ||
330 | + { | ||
331 | + g_warning ("Unable to register object with the session bus: %s", | ||
332 | + error->message); | ||
333 | + g_error_free (error); | ||
334 | + | ||
335 | + return FALSE; | ||
336 | + } | ||
337 | + | ||
338 | + backend_gdbus->owns_name = FALSE; | ||
339 | + | ||
340 | + backend_gdbus->owner_id = | ||
341 | + g_bus_own_name_on_connection (backend_gdbus->connection, | ||
342 | + unique_backend_get_name (backend), | ||
343 | + G_BUS_NAME_OWNER_FLAGS_NONE, | ||
344 | + name_acquired_cb, | ||
345 | + name_lost_cb, | ||
346 | + backend, NULL); | ||
347 | + | ||
348 | + backend_gdbus->loop = g_main_loop_new (NULL, FALSE); | ||
349 | + g_main_loop_run (backend_gdbus->loop); | ||
350 | + g_main_loop_unref (backend_gdbus->loop); | ||
351 | + backend_gdbus->loop = NULL; | ||
352 | + | ||
353 | + return backend_gdbus->owns_name; | ||
354 | +} | ||
355 | + | ||
356 | +static UniqueResponse | ||
357 | +unique_backend_gdbus_send_message (UniqueBackend *backend, | ||
358 | + gint command, | ||
359 | + UniqueMessageData *message_data, | ||
360 | + guint time_) | ||
361 | +{ | ||
362 | + UniqueBackendGDBus *backend_gdbus = UNIQUE_BACKEND_GDBUS (backend); | ||
363 | + GVariantBuilder builder; | ||
364 | + GVariant *result; | ||
365 | + const gchar *command_str, *resp; | ||
366 | + UniqueResponse response; | ||
367 | + GError *error; | ||
368 | + | ||
369 | + command_str = unique_command_to_string (backend->parent, command); | ||
370 | + | ||
371 | + g_variant_builder_init (&builder, G_VARIANT_TYPE ("(s(suuus)u)")); | ||
372 | + g_variant_builder_add (&builder, "s", command_str ? command_str : ""); | ||
373 | + g_variant_builder_open (&builder, G_VARIANT_TYPE ("(suuus)")); | ||
374 | + g_variant_builder_add (&builder, "s", message_data->data ? (char *) message_data->data : ""); | ||
375 | + g_variant_builder_add (&builder, "u", (guint) message_data->length); | ||
376 | + g_variant_builder_add (&builder, "u", (guint) gdk_screen_get_number (message_data->screen)); | ||
377 | + g_variant_builder_add (&builder, "u", (guint) message_data->workspace); | ||
378 | + g_variant_builder_add (&builder, "s", message_data->startup_id ? message_data->startup_id : ""); | ||
379 | + g_variant_builder_close (&builder); | ||
380 | + g_variant_builder_add (&builder, "u", time_); | ||
381 | + | ||
382 | + error = NULL; | ||
383 | + result = g_dbus_connection_call_sync (backend_gdbus->connection, | ||
384 | + unique_backend_get_name (backend), | ||
385 | + "/Factory", | ||
386 | + "org.gtk.UniqueApp", | ||
387 | + "SendMessage", | ||
388 | + g_variant_builder_end (&builder), | ||
389 | + G_VARIANT_TYPE ("(s)"), | ||
390 | + G_DBUS_CALL_FLAGS_NO_AUTO_START, | ||
391 | + -1, | ||
392 | + NULL, | ||
393 | + &error); | ||
394 | + if (error) | ||
395 | + { | ||
396 | + g_warning ("Error while sending message: %s", error->message); | ||
397 | + g_error_free (error); | ||
398 | + | ||
399 | + return UNIQUE_RESPONSE_INVALID; | ||
400 | + } | ||
401 | + | ||
402 | + g_variant_get (result, "(&s)", &resp); | ||
403 | + response = unique_response_from_string (resp); | ||
404 | + g_variant_unref (result); | ||
405 | + | ||
406 | + return response; | ||
407 | +} | ||
408 | + | ||
409 | +static void | ||
410 | +unique_backend_gdbus_dispose (GObject *gobject) | ||
411 | +{ | ||
412 | + UniqueBackendGDBus *backend_gdbus = UNIQUE_BACKEND_GDBUS (gobject); | ||
413 | + | ||
414 | + if (backend_gdbus->owner_id != 0) | ||
415 | + { | ||
416 | + g_bus_unown_name (backend_gdbus->owner_id); | ||
417 | + backend_gdbus->owner_id = 0; | ||
418 | + } | ||
419 | + if (backend_gdbus->registration_id != 0) | ||
420 | + { | ||
421 | + g_assert (backend_gdbus->connection != NULL); | ||
422 | + g_dbus_connection_unregister_object (backend_gdbus->connection, | ||
423 | + backend_gdbus->registration_id); | ||
424 | + backend_gdbus->registration_id = 0; | ||
425 | + } | ||
426 | + if (backend_gdbus->connection) | ||
427 | + { | ||
428 | + g_object_unref (backend_gdbus->connection); | ||
429 | + backend_gdbus->connection = NULL; | ||
430 | + } | ||
431 | + | ||
432 | + G_OBJECT_CLASS (unique_backend_gdbus_parent_class)->dispose (gobject); | ||
433 | +} | ||
434 | + | ||
435 | +static void | ||
436 | +unique_backend_gdbus_class_init (UniqueBackendGDBusClass *klass) | ||
437 | +{ | ||
438 | + GObjectClass *gobject_class = G_OBJECT_CLASS (klass); | ||
439 | + UniqueBackendClass *backend_class = UNIQUE_BACKEND_CLASS (klass); | ||
440 | + | ||
441 | + gobject_class->dispose = unique_backend_gdbus_dispose; | ||
442 | + | ||
443 | + backend_class->request_name = unique_backend_gdbus_request_name; | ||
444 | + backend_class->send_message = unique_backend_gdbus_send_message; | ||
445 | + | ||
446 | + klass->introspection_data = g_dbus_node_info_new_for_xml (introspection_xml, NULL); | ||
447 | + g_assert (klass->introspection_data != NULL); | ||
448 | +} | ||
449 | + | ||
450 | +static void | ||
451 | +unique_backend_gdbus_init (UniqueBackendGDBus *backend) | ||
452 | +{ | ||
453 | +} | ||
454 | diff --git a/unique/gdbus/uniquebackend-gdbus.h b/unique/gdbus/uniquebackend-gdbus.h | ||
455 | new file mode 100644 | ||
456 | index 0000000..41eb6e5 | ||
457 | --- /dev/null | ||
458 | +++ b/unique/gdbus/uniquebackend-gdbus.h | ||
459 | @@ -0,0 +1,43 @@ | ||
460 | +/* Unique - Single Instance application library | ||
461 | + * uniquebackend-gdbus.c: GDBus implementation of UniqueBackend | ||
462 | + * | ||
463 | + * Copyright (C) 2007 Emmanuele Bassi <ebassi@o-hand.com> | ||
464 | + * | ||
465 | + * This library is free software; you can redistribute it and/or | ||
466 | + * modify it under the terms of the GNU Lesser General Public | ||
467 | + * License as published by the Free Software Foundation; either | ||
468 | + * version 2.1 of the License, or (at your option) any later version. | ||
469 | + * | ||
470 | + * This library is distributed in the hope that it will be useful, | ||
471 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
472 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
473 | + * Lesser General Public License for more details. | ||
474 | + * | ||
475 | + * You should have received a copy of the GNU Lesser General Public | ||
476 | + * License along with this library; if not, write to the Free Software | ||
477 | + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA | ||
478 | + * 02110-1301 USA | ||
479 | + */ | ||
480 | + | ||
481 | +#ifndef __UNIQUE_BACKEND_GDBUS_H__ | ||
482 | +#define __UNIQUE_BACKEND_GDBUS_H__ | ||
483 | + | ||
484 | +#include <unique/uniquebackend.h> | ||
485 | + | ||
486 | +G_BEGIN_DECLS | ||
487 | + | ||
488 | +#define UNIQUE_TYPE_BACKEND_GDBUS (unique_backend_gdbus_get_type ()) | ||
489 | +#define UNIQUE_BACKEND_GDBUS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), UNIQUE_TYPE_BACKEND_GDBUS, UniqueBackendGDBus)) | ||
490 | +#define UNIQUE_IS_BACKEND_GDBUS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), UNIQUE_TYPE_BACKEND_GDBUS)) | ||
491 | +#define UNIQUE_BACKEND_GDBUS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), UNIQUE_TYPE_BACKEND_GDBUS, UniqueBackendGDBusClass)) | ||
492 | +#define UNIQUE_IS_BACKEND_GDBUS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), UNIQUE_TYPE_BACKEND_GDBUS)) | ||
493 | +#define UNIQUE_BACKEND_GDBUS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), UNIQUE_TYPE_BACKEND_GDBUS, UniqueBackendGDBusClass)) | ||
494 | + | ||
495 | +typedef struct _UniqueBackendGDBus UniqueBackendGDBus; | ||
496 | +typedef struct _UniqueBackendGDBusClass UniqueBackendGDBusClass; | ||
497 | + | ||
498 | +GType unique_backend_gdbus_get_type (void) G_GNUC_CONST; | ||
499 | + | ||
500 | +G_END_DECLS | ||
501 | + | ||
502 | +#endif /* __UNIQUE_BACKEND_GDBUS_H__ */ | ||
503 | diff --git a/unique/uniquebackend.c b/unique/uniquebackend.c | ||
504 | index 18a0c45..a76e42e 100644 | ||
505 | --- a/unique/uniquebackend.c | ||
506 | +++ b/unique/uniquebackend.c | ||
507 | @@ -298,6 +298,9 @@ unique_backend_send_message (UniqueBackend *backend, | ||
508 | #ifdef HAVE_DBUS | ||
509 | #include "dbus/uniquebackend-dbus.h" | ||
510 | #endif | ||
511 | +#ifdef HAVE_GDBUS | ||
512 | +#include "gdbus/uniquebackend-gdbus.h" | ||
513 | +#endif | ||
514 | |||
515 | /** | ||
516 | * unique_backend_create: | ||
517 | @@ -329,6 +332,10 @@ unique_backend_create (void) | ||
518 | if (strcmp (backend_name, "dbus") == 0) | ||
519 | backend_gtype = unique_backend_dbus_get_type (); | ||
520 | #endif /* HAVE_DBUS */ | ||
521 | +#ifdef HAVE_GDBUS | ||
522 | + if (strcmp (backend_name, "gdbus") == 0) | ||
523 | + backend_gtype = unique_backend_gdbus_get_type (); | ||
524 | +#endif /* HAVE_GDBUS */ | ||
525 | #if !defined(HAVE_BACON) && !defined(HAVE_DBUS) | ||
526 | #error Need either bacon or dbus | ||
527 | #endif | ||
528 | -- | ||
529 | cgit v0.8.3.1 |