wok-next view libunique/stuff/patches/libunique-1.1.6-upstream_fixes-1.patch @ rev 21119
libarchive: depends on libzstd
author | Aleksej Bobylev <al.bobylev@gmail.com> |
---|---|
date | Mon Jan 14 03:39:08 2019 +0200 (2019-01-14) |
parents | |
children |
line source
1 Submitted By: Armin K. <krejzi at email dot com>
2 Date: 2013-03-16
3 Initial Package Version: 1.1.6
4 Upstream Status: In Upstream VCS
5 Origin: Upstream VCS
6 Description: Varius fixes from upstream including build system fixes, compilation
7 fixes and new GDBus backend.
9 --- a/build/autotools/introspection.m4 2009-09-21 14:31:14.000000000 +0200
10 +++ b/build/autotools/introspection.m4 2013-03-16 23:47:50.178671206 +0100
11 @@ -59,12 +59,18 @@
12 INTROSPECTION_GENERATE=`$PKG_CONFIG --variable=g_ir_generate gobject-introspection-1.0`
13 INTROSPECTION_GIRDIR=`$PKG_CONFIG --variable=girdir gobject-introspection-1.0`
14 INTROSPECTION_TYPELIBDIR="$($PKG_CONFIG --variable=typelibdir gobject-introspection-1.0)"
15 + INTROSPECTION_CFLAGS=`$PKG_CONFIG --cflags gobject-introspection-1.0`
16 + INTROSPECTION_LIBS=`$PKG_CONFIG --libs gobject-introspection-1.0`
17 + INTROSPECTION_MAKEFILE=`$PKG_CONFIG --variable=datadir gobject-introspection-1.0`/gobject-introspection-1.0/Makefile.introspection
18 fi
19 AC_SUBST(INTROSPECTION_SCANNER)
20 AC_SUBST(INTROSPECTION_COMPILER)
21 AC_SUBST(INTROSPECTION_GENERATE)
22 AC_SUBST(INTROSPECTION_GIRDIR)
23 AC_SUBST(INTROSPECTION_TYPELIBDIR)
24 + AC_SUBST(INTROSPECTION_CFLAGS)
25 + AC_SUBST(INTROSPECTION_LIBS)
26 + AC_SUBST(INTROSPECTION_MAKEFILE)
28 AM_CONDITIONAL(HAVE_INTROSPECTION, test "x$found_introspection" = "xyes")
29 ])
30 --- a/build/autotools/Makefile.am 2009-11-01 18:52:21.000000000 +0100
31 +++ b/build/autotools/Makefile.am 2013-03-16 23:47:50.178671206 +0100
32 @@ -1,7 +1,4 @@
33 EXTRA_DIST = \
34 - shave-libtool.in \
35 - shave.in \
36 - shave.m4 \
37 as-compiler-flag.m4 \
38 introspection.m4 \
39 Makefile.am.enums \
40 --- a/build/autotools/Makefile.am.silent 2009-11-01 19:00:57.000000000 +0100
41 +++ b/build/autotools/Makefile.am.silent 2013-03-16 23:47:50.178671206 +0100
42 @@ -1,10 +1,5 @@
43 # custom rules for quiet builds
45 -if USE_SHAVE
46 -QUIET_GEN = $(Q:@=@echo ' GEN '$@;)
47 -QUIET_LN = $(Q:@=@echo ' LN '$@;)
48 -QUIET_RM = $(Q:@=@echo ' RM '$@;)
49 -else
50 QUIET_GEN = $(AM_V_GEN)
52 QUIET_LN = $(QUIET_LN_$(V))
53 @@ -14,4 +9,3 @@
54 QUIET_RM = $(QUIET_RM_$(V))
55 QUIET_RM_ = $(QUIET_RM_$(AM_DEFAULT_VERBOSITY))
56 QUIET_RM_0 = @echo ' RM '$@;
57 -endif # USE_SHAVE
58 --- a/build/autotools/shave.in 2009-09-21 14:31:14.000000000 +0200
59 +++ b/build/autotools/shave.in 1970-01-01 01:00:00.000000000 +0100
60 @@ -1,79 +0,0 @@
61 -#!/bin/sh
62 -
63 -# we need sed
64 -SED=@SED@
65 -if test -z "$SED" ; then
66 -SED=sed
67 -fi
68 -
69 -lt_unmangle ()
70 -{
71 - last_result=`echo $1 | $SED -e 's#.libs/##' -e 's#[0-9a-zA-Z_\-\.]*_la-##'`
72 -}
73 -
74 -# the tool to wrap (cc, cxx, ar, ranlib, ..)
75 -tool="$1"
76 -shift
77 -
78 -# the reel tool (to call)
79 -REEL_TOOL="$1"
80 -shift
81 -
82 -pass_through=0
83 -preserved_args=
84 -while test "$#" -gt 0; do
85 - opt="$1"
86 - shift
87 -
88 - case $opt in
89 - --shave-mode=*)
90 - mode=`echo $opt | $SED -e 's/[-_a-zA-Z0-9]*=//'`
91 - ;;
92 - -o)
93 - lt_output="$1"
94 - preserved_args="$preserved_args $opt"
95 - ;;
96 - *)
97 - preserved_args="$preserved_args $opt"
98 - ;;
99 - esac
100 -done
101 -
102 -# mode=link is handled in the libtool wrapper
103 -case "$mode,$tool" in
104 -link,*)
105 - pass_through=1
106 - ;;
107 -*,cxx)
108 - Q=" CXX "
109 - ;;
110 -*,cc)
111 - Q=" CC "
112 - ;;
113 -*,fc)
114 - Q=" FC "
115 - ;;
116 -*,f77)
117 - Q=" F77 "
118 - ;;
119 -*,objc)
120 - Q=" OBJC "
121 - ;;
122 -*,*)
123 - # should not happen
124 - Q=" CC "
125 - ;;
126 -esac
127 -
128 -lt_unmangle "$lt_output"
129 -output=$last_result
130 -
131 -if test -z $V; then
132 - if test $pass_through -eq 0; then
133 - echo "$Q$output"
134 - fi
135 - $REEL_TOOL $preserved_args
136 -else
137 - echo $REEL_TOOL $preserved_args
138 - $REEL_TOOL $preserved_args
139 -fi
140 --- a/build/autotools/shave-libtool.in 2009-09-21 14:31:14.000000000 +0200
141 +++ b/build/autotools/shave-libtool.in 1970-01-01 01:00:00.000000000 +0100
142 @@ -1,69 +0,0 @@
143 -#!/bin/sh
144 -
145 -# we need sed
146 -SED=@SED@
147 -if test -z "$SED" ; then
148 -SED=sed
149 -fi
150 -
151 -lt_unmangle ()
152 -{
153 - last_result=`echo $1 | $SED -e 's#.libs/##' -e 's#[0-9a-zA-Z_\-\.]*_la-##'`
154 -}
155 -
156 -# the real libtool to use
157 -LIBTOOL="$1"
158 -shift
159 -
160 -# if 1, don't print anything, the underlaying wrapper will do it
161 -pass_though=0
162 -
163 -# scan the arguments, keep the right ones for libtool, and discover the mode
164 -preserved_args=
165 -while test "$#" -gt 0; do
166 - opt="$1"
167 - shift
168 -
169 - case $opt in
170 - --mode=*)
171 - mode=`echo $opt | $SED -e 's/[-_a-zA-Z0-9]*=//'`
172 - preserved_args="$preserved_args $opt"
173 - ;;
174 - -o)
175 - lt_output="$1"
176 - preserved_args="$preserved_args $opt"
177 - ;;
178 - *)
179 - preserved_args="$preserved_args $opt"
180 - ;;
181 - esac
182 -done
183 -
184 -case "$mode" in
185 -compile)
186 - # shave will be called and print the actual CC/CXX/LINK line
187 - preserved_args="$preserved_args --shave-mode=$mode"
188 - pass_though=1
189 - ;;
190 -link)
191 - preserved_args="$preserved_args --shave-mode=$mode"
192 - Q=" LINK "
193 - ;;
194 -*)
195 - # let's u
196 - # echo "*** libtool: Unimplemented mode: $mode, fill a bug report"
197 - ;;
198 -esac
199 -
200 -lt_unmangle "$lt_output"
201 -output=$last_result
202 -
203 -if test -z $V; then
204 - if test $pass_though -eq 0; then
205 - echo "$Q$output"
206 - fi
207 - $LIBTOOL --silent $preserved_args
208 -else
209 - echo $LIBTOOL $preserved_args
210 - $LIBTOOL $preserved_args
211 -fi
212 --- a/build/autotools/shave.m4 2009-09-21 14:31:14.000000000 +0200
213 +++ b/build/autotools/shave.m4 1970-01-01 01:00:00.000000000 +0100
214 @@ -1,77 +0,0 @@
215 -dnl Make automake/libtool output more friendly to humans
216 -dnl Damien Lespiau <damien.lespiau@gmail.com>
217 -dnl
218 -dnl SHAVE_INIT([shavedir],[default_mode])
219 -dnl
220 -dnl shavedir: the directory where the shave scripts are, it defaults to
221 -dnl $(top_builddir)
222 -dnl default_mode: (enable|disable) default shave mode. This parameter
223 -dnl controls shave's behaviour when no option has been
224 -dnl given to configure. It defaults to disable.
225 -dnl
226 -dnl * SHAVE_INIT should be called late in your configure.(ac|in) file (just
227 -dnl before AC_CONFIG_FILE/AC_OUTPUT is perfect. This macro rewrites CC and
228 -dnl LIBTOOL, you don't want the configure tests to have these variables
229 -dnl re-defined.
230 -dnl * This macro requires GNU make's -s option.
231 -
232 -AC_DEFUN([_SHAVE_ARG_ENABLE],
233 -[
234 - AC_ARG_ENABLE([shave],
235 - AS_HELP_STRING(
236 - [--enable-shave],
237 - [use shave to make the build pretty [[default=$1]]]),,
238 - [enable_shave=$1]
239 - )
240 -])
241 -
242 -AC_DEFUN([SHAVE_INIT],
243 -[
244 - dnl you can tweak the default value of enable_shave
245 - m4_if([$2], [enable], [_SHAVE_ARG_ENABLE(yes)], [_SHAVE_ARG_ENABLE(no)])
246 -
247 - if test x"$enable_shave" = xyes; then
248 - dnl where can we find the shave scripts?
249 - m4_if([$1],,
250 - [shavedir="$ac_pwd"],
251 - [shavedir="$ac_pwd/$1"])
252 - AC_SUBST(shavedir)
253 -
254 - dnl make is now quiet
255 - AC_SUBST([MAKEFLAGS], [-s])
256 - AC_SUBST([AM_MAKEFLAGS], ['`test -z $V && echo -s`'])
257 -
258 - dnl we need sed
259 - AC_CHECK_PROG(SED,sed,sed,false)
260 -
261 - dnl substitute libtool
262 - SHAVE_SAVED_LIBTOOL=$LIBTOOL
263 - LIBTOOL="${SHELL} ${shavedir}/shave-libtool '${SHAVE_SAVED_LIBTOOL}'"
264 - AC_SUBST(LIBTOOL)
265 -
266 - dnl substitute cc/cxx
267 - SHAVE_SAVED_CC=$CC
268 - SHAVE_SAVED_CXX=$CXX
269 - SHAVE_SAVED_FC=$FC
270 - SHAVE_SAVED_F77=$F77
271 - SHAVE_SAVED_OBJC=$OBJC
272 - CC="${SHELL} ${shavedir}/shave cc ${SHAVE_SAVED_CC}"
273 - CXX="${SHELL} ${shavedir}/shave cxx ${SHAVE_SAVED_CXX}"
274 - FC="${SHELL} ${shavedir}/shave fc ${SHAVE_SAVED_FC}"
275 - F77="${SHELL} ${shavedir}/shave f77 ${SHAVE_SAVED_F77}"
276 - OBJC="${SHELL} ${shavedir}/shave objc ${SHAVE_SAVED_OBJC}"
277 - AC_SUBST(CC)
278 - AC_SUBST(CXX)
279 - AC_SUBST(FC)
280 - AC_SUBST(F77)
281 - AC_SUBST(OBJC)
282 -
283 - V=@
284 - else
285 - V=1
286 - fi
287 - Q='$(V:1=)'
288 - AC_SUBST(V)
289 - AC_SUBST(Q)
290 -])
291 -
292 --- a/configure.ac 2009-11-12 14:57:39.000000000 +0100
293 +++ b/configure.ac 2013-03-16 23:48:53.856423651 +0100
294 @@ -14,7 +14,7 @@
295 # This is the X.Y used in the protocol negotiation
296 m4_define([unique_protocol_version], [1.0])
298 -AC_PREREQ([2.59])
299 +AC_PREREQ([2.63])
301 AC_INIT([unique], [unique_version],
302 [http://bugzilla.gnome.org/enter_bug.cgi?product=libunique],
303 @@ -23,8 +23,20 @@
304 AC_CONFIG_SRCDIR([unique/unique.h])
305 AC_CONFIG_MACRO_DIR([build/autotools])
307 -AM_INIT_AUTOMAKE([1.10])
308 -AM_CONFIG_HEADER([config.h])
309 +AM_INIT_AUTOMAKE([1.11 no-define -Wno-portability dist-bzip2])
310 +AC_CONFIG_HEADERS([config.h])
311 +
312 +AM_SILENT_RULES([yes])
313 +
314 +AC_PROG_CC_C_O
315 +
316 +AM_PATH_GLIB_2_0
317 +
318 +LT_PREREQ([2.2])
319 +LT_INIT([disable-static])
320 +
321 +# Honor aclocal flags
322 +ACLOCAL="$ACLOCAL $ACLOCAL_FLAGS"
324 # version symbols
325 UNIQUE_MAJOR_VERSION=unique_major_version
326 @@ -49,21 +61,6 @@
327 AC_SUBST(UNIQUE_LT_VERSION_INFO)
328 AC_SUBST(UNIQUE_LT_CURRENT_MINUS_AGE)
330 -AC_ISC_POSIX
331 -AC_PROG_CC
332 -AC_PROG_INSTALL
333 -AC_PROG_MAKE_SET
334 -AC_C_CONST
335 -AC_PROG_LIBTOOL
336 -AC_PATH_PROG(GLIB_MKENUMS, [glib-mkenums])
337 -AC_PATH_PROG(GLIB_GENMARSHAL, [glib-genmarshal])
338 -
339 -AM_SANITY_CHECK
340 -AM_PROG_CC_STDC
341 -
342 -# Honor aclocal flags
343 -ACLOCAL="$ACLOCAL $ACLOCAL_FLAGS"
344 -
345 m4_define([glib_required], [2.12.0])
346 m4_define([gtk_required], [2.11.0])
347 m4_define([dbus_required], [0.70])
348 @@ -119,10 +116,22 @@
350 AM_CONDITIONAL([HAVE_DBUS], [test "x$have_dbus" = "xyes"])
352 +dnl GDBus backend
353 +dnl This is the default backend if GIO is recent enough
354 +m4_define([gdbus_gio_required],[2.25.7])
355 +PKG_CHECK_MODULES([GDBUS],[gio-2.0 >= gdbus_gio_required],[have_gdbus=yes],[have_gdbus=no])
356 +
357 +AS_IF([test "x$have_gdbus" = "xyes"],
358 + [
359 + AC_DEFINE([HAVE_GDBUS],[1],[Define if GDBus backend is enabled])
360 + ]
361 + )
362 +
363 +AM_CONDITIONAL([HAVE_GDBUS],[test "$have_gdbus" = "yes"])
364 +
365 dnl Bacon backend
366 dnl This is the fallback backend, so we *need* these headers and functions
367 dnl even if we end up using D-Bus
368 -dnl D-Bus backend dependencies
369 m4_define([have_bacon_default], [yes])
370 AC_ARG_ENABLE([bacon],
371 [AC_HELP_STRING([--enable-bacon=@<:@yes/no@:>@],
372 @@ -150,7 +159,13 @@
374 dnl Choose the default backend
375 AC_MSG_CHECKING([for default IPC mechanism])
376 -AS_IF([test "x$have_dbus" = "xyes"],
377 +AS_IF([test "x$have_gdbus" = "xyes"],
378 + [
379 + UNIQUE_DEFAULT_BACKEND=gdbus
380 + AC_MSG_RESULT([GDBus])
381 + ],
382 +
383 + [test "x$have_dbus" = "xyes"],
384 [
385 UNIQUE_DEFAULT_BACKEND=dbus
386 AC_MSG_RESULT([D-Bus])
387 @@ -178,9 +193,9 @@
388 AS_IF([test "x$enable_maintainer_flags" = "xyes" && test "x$GCC" = "xyes"],
389 [
390 AS_COMPILER_FLAGS([MAINTAINER_CFLAGS],
391 - ["-Werror -Wall -Wshadow -Wcast-align
392 - -Wno-uninitialized -Wempty-body -Wformat-security
393 - -Winit-self"])
394 + ["-Wall -Wshadow -Wcast-align
395 + -Wno-uninitialized -Wempty-body
396 + -Wformat-security -Winit-self"])
397 ]
398 )
400 @@ -230,27 +245,10 @@
401 AM_GLIB_DEFINE_LOCALEDIR(UNIQUE_LOCALEDIR)
403 # introspection
404 -GOBJECT_INTROSPECTION_CHECK([0.6.3])
405 +GOBJECT_INTROSPECTION_CHECK([0.6.7])
407 # gtk-doc
408 -GTK_DOC_CHECK([1.11])
409 -
410 -# nice builds
411 -m4_ifdef([AM_SILENT_RULES],
412 - [
413 - AM_SILENT_RULES([yes])
414 - use_shave=no
415 - ],
416 - [
417 - SHAVE_INIT([build/autotools], [enable])
418 - AC_CONFIG_FILES([
419 - build/autotools/shave-libtool
420 - build/autotools/shave
421 - ])
422 - use_shave=yes
423 - ])
424 -
425 -AM_CONDITIONAL([USE_SHAVE], [test "x$use_shave" = "xyes"])
426 +GTK_DOC_CHECK([1.13])
428 AC_CONFIG_FILES([
429 Makefile
430 @@ -264,6 +262,7 @@
431 unique/uniqueversion.h
432 unique/bacon/Makefile
433 unique/dbus/Makefile
434 + unique/gdbus/Makefile
435 tests/Makefile
436 po/Makefile.in
437 ])
438 @@ -282,6 +281,7 @@
439 Backends:
440 Unix Domain Socket: $have_bacon
441 D-BUS: $have_dbus
442 + GDBus: $have_gdbus
444 Default backend: $UNIQUE_DEFAULT_BACKEND
445 "
446 --- a/doc/reference/Makefile.am 2009-09-21 14:31:14.000000000 +0200
447 +++ b/doc/reference/Makefile.am 2013-03-16 23:48:20.572522852 +0100
448 @@ -50,7 +50,8 @@
449 uniquemarshal.h \
450 stamp-uniquemarshal.h \
451 bacon \
452 - dbus
453 + dbus \
454 + gdbus
456 EXTRA_HFILES =
458 --- a/unique/dbus/uniquebackend-dbus.c 2009-11-01 20:15:26.000000000 +0100
459 +++ b/unique/dbus/uniquebackend-dbus.c 2013-03-16 23:48:03.088891381 +0100
460 @@ -84,7 +84,6 @@
461 static gboolean
462 unique_backend_dbus_request_name (UniqueBackend *backend)
463 {
464 - UniqueBackendDBus *backend_dbus;
465 const gchar *name;
466 DBusGConnection *connection;
467 DBusGProxy *proxy;
468 @@ -97,8 +96,6 @@
469 if (!connection)
470 return FALSE;
472 - backend_dbus = UNIQUE_BACKEND_DBUS (backend);
473 -
474 retval = TRUE;
475 name = unique_backend_get_name (backend);
476 g_assert (name != NULL);
477 @@ -207,10 +204,14 @@
478 cmd, data, time_,
479 &resp,
480 &error);
481 - if (error)
482 + if (!res)
483 {
484 - g_warning ("Error while sending message: %s", error->message);
485 - g_error_free (error);
486 + if (error)
487 + {
488 + g_warning ("Error while sending message: %s", error->message);
489 + g_error_free (error);
490 + }
491 +
492 g_free (cmd);
494 return UNIQUE_RESPONSE_INVALID;
495 --- a/unique/gdbus/.gitignore 1970-01-01 01:00:00.000000000 +0100
496 +++ b/unique/gdbus/.gitignore 2013-03-16 23:48:20.572522852 +0100
497 @@ -0,0 +1,2 @@
498 +libunique_gdbus_la-uniquebackend-gdbus.lo
499 +libunique-gdbus.la
500 --- a/unique/gdbus/Makefile.am 1970-01-01 01:00:00.000000000 +0100
501 +++ b/unique/gdbus/Makefile.am 2013-03-16 23:48:20.572522852 +0100
502 @@ -0,0 +1,24 @@
503 +include $(top_srcdir)/build/autotools/Makefile.am.silent
504 +
505 +noinst_LTLIBRARIES = libunique-gdbus.la
506 +
507 +libunique_gdbus_la_SOURCES = \
508 + uniquebackend-gdbus.h \
509 + uniquebackend-gdbus.c
510 +
511 +libunique_gdbus_la_PPCFLAGS = \
512 + -DG_LOG_DOMAIN=\"Unique-GDBus\" \
513 + -DG_DISABLE_SINGLE_INCLUDES \
514 + -I$(top_srcdir) \
515 + $(AM_CPPFLAGS)
516 +
517 +libunique_gdbus_la_CFLAGS = \
518 + $(UNIQUE_CFLAGS) \
519 + $(UNIQUE_DEBUG_CFLAGS) \
520 + $(MAINTAINER_CFLAGS) \
521 + $(GDBUS_CFLAGS) \
522 + $(AM_CFLAGS)
523 +
524 +libunique_gdbus_la_LIBADD = \
525 + $(UNIQUE_LIBS) \
526 + $(GDBUS_LIBS)
527 --- a/unique/gdbus/uniquebackend-gdbus.c 1970-01-01 01:00:00.000000000 +0100
528 +++ b/unique/gdbus/uniquebackend-gdbus.c 2013-03-16 23:48:20.575856242 +0100
529 @@ -0,0 +1,303 @@
530 +/* Unique - Single Instance application library
531 + * uniquebackend-gdbus.c: GDBus implementation of UniqueBackend
532 + *
533 + * Copyright (C) 2007 Emmanuele Bassi <ebassi@o-hand.com>
534 + * Copyright © 2010 Christian Persch
535 + *
536 + * This library is free software; you can redistribute it and/or
537 + * modify it under the terms of the GNU Lesser General Public
538 + * License as published by the Free Software Foundation; either
539 + * version 2.1 of the License, or (at your option) any later version.
540 + *
541 + * This library is distributed in the hope that it will be useful,
542 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
543 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
544 + * Lesser General Public License for more details.
545 + *
546 + * You should have received a copy of the GNU Lesser General Public
547 + * License along with this library; if not, write to the Free Software
548 + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
549 + * 02110-1301 USA
550 + */
551 +
552 +#ifdef HAVE_CONFIG_H
553 +#include "config.h"
554 +#endif
555 +
556 +#include <gio/gio.h>
557 +#include <gdk/gdk.h>
558 +
559 +#include "../uniqueinternals.h"
560 +#include "uniquebackend-gdbus.h"
561 +
562 +struct _UniqueBackendGDBus
563 +{
564 + UniqueBackend parent_instance;
565 +
566 + GDBusConnection *connection;
567 + guint registration_id;
568 + guint owner_id;
569 + gboolean owns_name;
570 + GMainLoop *loop;
571 +};
572 +
573 +struct _UniqueBackendGDBusClass
574 +{
575 + UniqueBackendClass parent_class;
576 + GDBusNodeInfo *introspection_data;
577 +};
578 +
579 +G_DEFINE_TYPE (UniqueBackendGDBus, unique_backend_gdbus, UNIQUE_TYPE_BACKEND);
580 +
581 +static const char introspection_xml[] =
582 + "<node name='/'>"
583 + "<interface name='org.gtk.UniqueApp'>"
584 + "<method name='SendMessage'>"
585 + "<arg name='command' type='s' direction='in'/>"
586 + "<arg name='message' type='(suuus)' direction='in'/>"
587 + "<arg name='time' type='u' direction='in'/>"
588 + "<arg name='response' type='s' direction='out'/>"
589 + "</method>"
590 + "</interface>"
591 + "</node>";
592 +
593 +static void
594 +method_call_cb (GDBusConnection *connection,
595 + const gchar *sender,
596 + const gchar *object_path,
597 + const gchar *interface_name,
598 + const gchar *method_name,
599 + GVariant *parameters,
600 + GDBusMethodInvocation *invocation,
601 + gpointer user_data)
602 +{
603 + if (g_strcmp0 (interface_name, "org.gtk.UniqueApp") != 0 ||
604 + g_strcmp0 (object_path, "/Factory") != 0)
605 + return;
606 +
607 + if (g_strcmp0 (method_name, "SendMessage") == 0)
608 + {
609 + UniqueBackend *backend = UNIQUE_BACKEND (user_data);
610 + const gchar *command_str, *data, *startup_id;
611 + guint len, screen_num, workspace, time_;
612 + UniqueMessageData message_data;
613 + gint command;
614 + UniqueResponse response;
615 + GdkDisplay *display;
616 +
617 + g_variant_get (parameters,
618 + "(&s(&suuu&s)u)",
619 + &command_str,
620 + &data, &len, &screen_num, &workspace, &startup_id,
621 + &time_);
622 +
623 + command = unique_command_from_string (backend->parent, command_str);
624 + if (command == 0)
625 + {
626 + g_dbus_method_invocation_return_error (invocation,
627 + G_DBUS_ERROR,
628 + G_DBUS_ERROR_INVALID_ARGS,
629 + "Invalid command `%s' received",
630 + command_str);
631 + return;
632 + }
633 +
634 + display = gdk_display_get_default ();
635 +
636 + message_data.data = len > 0 ? (guchar *) data : NULL;
637 + message_data.length = (gint) len;
638 + message_data.workspace = workspace;
639 + message_data.startup_id = (char *) startup_id;
640 + if (screen_num >= 0 && screen_num < gdk_display_get_n_screens (display))
641 + message_data.screen = gdk_display_get_screen (display, screen_num);
642 + else
643 + message_data.screen = gdk_screen_get_default ();
644 +
645 + response = unique_app_emit_message_received (backend->parent, command, &message_data, time_);
646 +
647 + g_dbus_method_invocation_return_value (invocation,
648 + g_variant_new ("(s)", unique_response_to_string (response)));
649 + return;
650 + }
651 +}
652 +
653 +static void
654 +name_acquired_cb (GDBusConnection *connection,
655 + const gchar *name,
656 + gpointer user_data)
657 +{
658 + UniqueBackendGDBus *backend_gdbus = UNIQUE_BACKEND_GDBUS (user_data);
659 +
660 + backend_gdbus->owns_name = TRUE;
661 + if (backend_gdbus->loop && g_main_loop_is_running (backend_gdbus->loop))
662 + g_main_loop_quit (backend_gdbus->loop);
663 +}
664 +
665 +static void
666 +name_lost_cb (GDBusConnection *connection,
667 + const gchar *name,
668 + gpointer user_data)
669 +{
670 + UniqueBackendGDBus *backend_gdbus = UNIQUE_BACKEND_GDBUS (user_data);
671 +
672 + backend_gdbus->owns_name = FALSE;
673 + if (backend_gdbus->loop && g_main_loop_is_running (backend_gdbus->loop))
674 + g_main_loop_quit (backend_gdbus->loop);
675 +}
676 +
677 +static const GDBusInterfaceVTable interface_vtable = {
678 + method_call_cb,
679 + NULL,
680 + NULL
681 +};
682 +
683 +static gboolean
684 +unique_backend_gdbus_request_name (UniqueBackend *backend)
685 +{
686 + UniqueBackendGDBus *backend_gdbus = UNIQUE_BACKEND_GDBUS (backend);
687 + UniqueBackendGDBusClass *klass = UNIQUE_BACKEND_GDBUS_GET_CLASS (backend);
688 + GError *error;
689 +
690 + error = NULL;
691 + backend_gdbus->connection = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error);
692 + if (!backend_gdbus->connection)
693 + {
694 + g_warning ("Unable to open a connection to the session bus: %s",
695 + error->message);
696 + g_error_free (error);
697 +
698 + return FALSE;
699 + }
700 +
701 + backend_gdbus->registration_id =
702 + g_dbus_connection_register_object (backend_gdbus->connection,
703 + "/Factory",
704 + klass->introspection_data->interfaces[0],
705 + &interface_vtable,
706 + backend, NULL,
707 + &error);
708 + if (backend_gdbus->registration_id == 0)
709 + {
710 + g_warning ("Unable to register object with the session bus: %s",
711 + error->message);
712 + g_error_free (error);
713 +
714 + return FALSE;
715 + }
716 +
717 + backend_gdbus->owns_name = FALSE;
718 +
719 + backend_gdbus->owner_id =
720 + g_bus_own_name_on_connection (backend_gdbus->connection,
721 + unique_backend_get_name (backend),
722 + G_BUS_NAME_OWNER_FLAGS_NONE,
723 + name_acquired_cb,
724 + name_lost_cb,
725 + backend, NULL);
726 +
727 + backend_gdbus->loop = g_main_loop_new (NULL, FALSE);
728 + g_main_loop_run (backend_gdbus->loop);
729 + g_main_loop_unref (backend_gdbus->loop);
730 + backend_gdbus->loop = NULL;
731 +
732 + return backend_gdbus->owns_name;
733 +}
734 +
735 +static UniqueResponse
736 +unique_backend_gdbus_send_message (UniqueBackend *backend,
737 + gint command,
738 + UniqueMessageData *message_data,
739 + guint time_)
740 +{
741 + UniqueBackendGDBus *backend_gdbus = UNIQUE_BACKEND_GDBUS (backend);
742 + GVariantBuilder builder;
743 + GVariant *result;
744 + const gchar *command_str, *resp;
745 + UniqueResponse response;
746 + GError *error;
747 +
748 + command_str = unique_command_to_string (backend->parent, command);
749 +
750 + g_variant_builder_init (&builder, G_VARIANT_TYPE ("(s(suuus)u)"));
751 + g_variant_builder_add (&builder, "s", command_str ? command_str : "");
752 + g_variant_builder_open (&builder, G_VARIANT_TYPE ("(suuus)"));
753 + g_variant_builder_add (&builder, "s", message_data->data ? (char *) message_data->data : "");
754 + g_variant_builder_add (&builder, "u", (guint) message_data->length);
755 + g_variant_builder_add (&builder, "u", (guint) gdk_screen_get_number (message_data->screen));
756 + g_variant_builder_add (&builder, "u", (guint) message_data->workspace);
757 + g_variant_builder_add (&builder, "s", message_data->startup_id ? message_data->startup_id : "");
758 + g_variant_builder_close (&builder);
759 + g_variant_builder_add (&builder, "u", time_);
760 +
761 + error = NULL;
762 + result = g_dbus_connection_call_sync (backend_gdbus->connection,
763 + unique_backend_get_name (backend),
764 + "/Factory",
765 + "org.gtk.UniqueApp",
766 + "SendMessage",
767 + g_variant_builder_end (&builder),
768 + G_VARIANT_TYPE ("(s)"),
769 + G_DBUS_CALL_FLAGS_NO_AUTO_START,
770 + -1,
771 + NULL,
772 + &error);
773 + if (error)
774 + {
775 + g_warning ("Error while sending message: %s", error->message);
776 + g_error_free (error);
777 +
778 + return UNIQUE_RESPONSE_INVALID;
779 + }
780 +
781 + g_variant_get (result, "(&s)", &resp);
782 + response = unique_response_from_string (resp);
783 + g_variant_unref (result);
784 +
785 + return response;
786 +}
787 +
788 +static void
789 +unique_backend_gdbus_dispose (GObject *gobject)
790 +{
791 + UniqueBackendGDBus *backend_gdbus = UNIQUE_BACKEND_GDBUS (gobject);
792 +
793 + if (backend_gdbus->owner_id != 0)
794 + {
795 + g_bus_unown_name (backend_gdbus->owner_id);
796 + backend_gdbus->owner_id = 0;
797 + }
798 + if (backend_gdbus->registration_id != 0)
799 + {
800 + g_assert (backend_gdbus->connection != NULL);
801 + g_dbus_connection_unregister_object (backend_gdbus->connection,
802 + backend_gdbus->registration_id);
803 + backend_gdbus->registration_id = 0;
804 + }
805 + if (backend_gdbus->connection)
806 + {
807 + g_object_unref (backend_gdbus->connection);
808 + backend_gdbus->connection = NULL;
809 + }
810 +
811 + G_OBJECT_CLASS (unique_backend_gdbus_parent_class)->dispose (gobject);
812 +}
813 +
814 +static void
815 +unique_backend_gdbus_class_init (UniqueBackendGDBusClass *klass)
816 +{
817 + GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
818 + UniqueBackendClass *backend_class = UNIQUE_BACKEND_CLASS (klass);
819 +
820 + gobject_class->dispose = unique_backend_gdbus_dispose;
821 +
822 + backend_class->request_name = unique_backend_gdbus_request_name;
823 + backend_class->send_message = unique_backend_gdbus_send_message;
824 +
825 + klass->introspection_data = g_dbus_node_info_new_for_xml (introspection_xml, NULL);
826 + g_assert (klass->introspection_data != NULL);
827 +}
828 +
829 +static void
830 +unique_backend_gdbus_init (UniqueBackendGDBus *backend)
831 +{
832 +}
833 --- a/unique/gdbus/uniquebackend-gdbus.h 1970-01-01 01:00:00.000000000 +0100
834 +++ b/unique/gdbus/uniquebackend-gdbus.h 2013-03-16 23:48:20.575856242 +0100
835 @@ -0,0 +1,43 @@
836 +/* Unique - Single Instance application library
837 + * uniquebackend-gdbus.c: GDBus implementation of UniqueBackend
838 + *
839 + * Copyright (C) 2007 Emmanuele Bassi <ebassi@o-hand.com>
840 + *
841 + * This library is free software; you can redistribute it and/or
842 + * modify it under the terms of the GNU Lesser General Public
843 + * License as published by the Free Software Foundation; either
844 + * version 2.1 of the License, or (at your option) any later version.
845 + *
846 + * This library is distributed in the hope that it will be useful,
847 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
848 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
849 + * Lesser General Public License for more details.
850 + *
851 + * You should have received a copy of the GNU Lesser General Public
852 + * License along with this library; if not, write to the Free Software
853 + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
854 + * 02110-1301 USA
855 + */
856 +
857 +#ifndef __UNIQUE_BACKEND_GDBUS_H__
858 +#define __UNIQUE_BACKEND_GDBUS_H__
859 +
860 +#include <unique/uniquebackend.h>
861 +
862 +G_BEGIN_DECLS
863 +
864 +#define UNIQUE_TYPE_BACKEND_GDBUS (unique_backend_gdbus_get_type ())
865 +#define UNIQUE_BACKEND_GDBUS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), UNIQUE_TYPE_BACKEND_GDBUS, UniqueBackendGDBus))
866 +#define UNIQUE_IS_BACKEND_GDBUS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), UNIQUE_TYPE_BACKEND_GDBUS))
867 +#define UNIQUE_BACKEND_GDBUS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), UNIQUE_TYPE_BACKEND_GDBUS, UniqueBackendGDBusClass))
868 +#define UNIQUE_IS_BACKEND_GDBUS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), UNIQUE_TYPE_BACKEND_GDBUS))
869 +#define UNIQUE_BACKEND_GDBUS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), UNIQUE_TYPE_BACKEND_GDBUS, UniqueBackendGDBusClass))
870 +
871 +typedef struct _UniqueBackendGDBus UniqueBackendGDBus;
872 +typedef struct _UniqueBackendGDBusClass UniqueBackendGDBusClass;
873 +
874 +GType unique_backend_gdbus_get_type (void) G_GNUC_CONST;
875 +
876 +G_END_DECLS
877 +
878 +#endif /* __UNIQUE_BACKEND_GDBUS_H__ */
879 --- a/unique/Makefile.am 2009-11-12 14:53:10.000000000 +0100
880 +++ b/unique/Makefile.am 2013-03-16 23:48:20.572522852 +0100
881 @@ -12,7 +12,11 @@
882 SUBDIRS += dbus
883 endif
885 -DIST_SUBDIRS = bacon dbus
886 +if HAVE_GDBUS
887 +SUBDIRS += gdbus
888 +endif
889 +
890 +DIST_SUBDIRS = bacon dbus gdbus
892 INCLUDES = -I$(top_srcdir)
894 @@ -72,6 +76,10 @@
895 unique_backend_libs += $(top_builddir)/unique/dbus/libunique-dbus.la
896 endif
898 +if HAVE_GDBUS
899 +unique_backend_libs += $(top_builddir)/unique/gdbus/libunique-gdbus.la
900 +endif
901 +
902 uniquedir = $(includedir)/unique-1.0/unique
903 unique_HEADERS = \
904 $(unique_sources_h) \
905 --- a/unique/uniqueapp.c 2009-11-01 19:33:13.000000000 +0100
906 +++ b/unique/uniqueapp.c 2013-03-16 23:49:05.236617643 +0100
907 @@ -781,7 +781,7 @@
908 }
911 -G_CONST_RETURN gchar *
912 +const gchar *
913 unique_command_to_string (UniqueApp *app,
914 gint command)
915 {
916 @@ -863,7 +863,7 @@
917 return retval;
918 }
920 -G_CONST_RETURN gchar *
921 +const gchar *
922 unique_response_to_string (UniqueResponse response)
923 {
924 GEnumClass *enum_class;
925 --- a/unique/uniquebackend.c 2009-11-09 12:02:06.000000000 +0100
926 +++ b/unique/uniquebackend.c 2013-03-16 23:49:05.236617643 +0100
927 @@ -111,7 +111,7 @@
928 *
929 * Return value: FIXME
930 */
931 -G_CONST_RETURN gchar *
932 +const gchar *
933 unique_backend_get_name (UniqueBackend *backend)
934 {
935 g_return_val_if_fail (UNIQUE_IS_BACKEND (backend), NULL);
936 @@ -154,7 +154,7 @@
937 *
938 * Return value: FIXME
939 */
940 -G_CONST_RETURN gchar *
941 +const gchar *
942 unique_backend_get_startup_id (UniqueBackend *backend)
943 {
944 g_return_val_if_fail (UNIQUE_IS_BACKEND (backend), NULL);
945 @@ -298,6 +298,9 @@
946 #ifdef HAVE_DBUS
947 #include "dbus/uniquebackend-dbus.h"
948 #endif
949 +#ifdef HAVE_GDBUS
950 +#include "gdbus/uniquebackend-gdbus.h"
951 +#endif
953 /**
954 * unique_backend_create:
955 @@ -329,6 +332,10 @@
956 if (strcmp (backend_name, "dbus") == 0)
957 backend_gtype = unique_backend_dbus_get_type ();
958 #endif /* HAVE_DBUS */
959 +#ifdef HAVE_GDBUS
960 + if (strcmp (backend_name, "gdbus") == 0)
961 + backend_gtype = unique_backend_gdbus_get_type ();
962 +#endif /* HAVE_GDBUS */
963 #if !defined(HAVE_BACON) && !defined(HAVE_DBUS)
964 #error Need either bacon or dbus
965 #endif
966 --- a/unique/uniquebackend.h 2009-09-21 14:31:14.000000000 +0200
967 +++ b/unique/uniquebackend.h 2013-03-16 23:49:05.236617643 +0100
968 @@ -94,10 +94,10 @@
970 UniqueBackend * unique_backend_create (void);
972 -G_CONST_RETURN gchar *unique_backend_get_name (UniqueBackend *backend);
973 +const gchar *unique_backend_get_name (UniqueBackend *backend);
974 void unique_backend_set_name (UniqueBackend *backend,
975 const gchar *name);
976 -G_CONST_RETURN gchar *unique_backend_get_startup_id (UniqueBackend *backend);
977 +const gchar *unique_backend_get_startup_id (UniqueBackend *backend);
978 void unique_backend_set_startup_id (UniqueBackend *backend,
979 const gchar *startup_id);
980 GdkScreen * unique_backend_get_screen (UniqueBackend *backend);
981 --- a/unique/uniqueinternals.h 2009-09-21 14:31:14.000000000 +0200
982 +++ b/unique/uniqueinternals.h 2013-03-16 23:49:05.236617643 +0100
983 @@ -44,11 +44,11 @@
984 * and then back into an id
985 */
986 UniqueResponse unique_response_from_string (const gchar *response);
987 -G_CONST_RETURN gchar *unique_response_to_string (UniqueResponse response);
988 +const gchar *unique_response_to_string (UniqueResponse response);
990 gint unique_command_from_string (UniqueApp *app,
991 const gchar *command);
992 -G_CONST_RETURN gchar *unique_command_to_string (UniqueApp *app,
993 +const gchar *unique_command_to_string (UniqueApp *app,
994 gint command);
996 G_END_DECLS
997 --- a/unique/uniquemessage.c 2009-11-09 12:02:06.000000000 +0100
998 +++ b/unique/uniquemessage.c 2013-03-16 23:49:05.236617643 +0100
999 @@ -185,7 +185,7 @@
1000 *
1001 * Since: 1.0.2
1002 */
1003 -G_CONST_RETURN guchar *
1004 +const guchar *
1005 unique_message_data_get (UniqueMessageData *message_data,
1006 gsize *length)
1007 {
1008 @@ -525,7 +525,7 @@
1009 * owned by the #UniqueMessageData structure and should not be
1010 * modified or freed
1011 */
1012 -G_CONST_RETURN gchar *
1013 +const gchar *
1014 unique_message_data_get_startup_id (UniqueMessageData *message_data)
1015 {
1016 g_return_val_if_fail (message_data != NULL, NULL);
1017 --- a/unique/uniquemessage.h 2009-09-21 14:31:14.000000000 +0200
1018 +++ b/unique/uniquemessage.h 2013-03-16 23:49:05.236617643 +0100
1019 @@ -48,7 +48,7 @@
1020 void unique_message_data_set (UniqueMessageData *message_data,
1021 const guchar *data,
1022 gsize length);
1023 -G_CONST_RETURN guchar *unique_message_data_get (UniqueMessageData *message_data,
1024 +const guchar *unique_message_data_get (UniqueMessageData *message_data,
1025 gsize *length);
1027 gboolean unique_message_data_set_text (UniqueMessageData *message_data,
1028 @@ -63,7 +63,7 @@
1029 gchar * unique_message_data_get_filename (UniqueMessageData *message_data);
1031 GdkScreen * unique_message_data_get_screen (UniqueMessageData *message_data);
1032 -G_CONST_RETURN gchar * unique_message_data_get_startup_id (UniqueMessageData *message_data);
1033 +const gchar * unique_message_data_get_startup_id (UniqueMessageData *message_data);
1034 guint unique_message_data_get_workspace (UniqueMessageData *message_data);
1036 G_END_DECLS