libunique-1.1.6-upstream_fixes-1.patch 32 KB

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