summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon McVittie <smcv@debian.org>2018-01-29 08:48:58 +0000
committerSimon McVittie <smcv@debian.org>2018-01-29 08:48:58 +0000
commitc80ae773e1cc50b6acde492b1b6f83f49f6e53c8 (patch)
treef5fcf079882170af41c16007cfb39076c23611da
parent232cae5253382d8d8f7678dbda1ee37424904cab (diff)
downloaddbus-glib-c80ae773e1cc50b6acde492b1b6f83f49f6e53c8.tar.gz
Remove everything except dbus-gmain subdirectory
Signed-off-by: Simon McVittie <smcv@debian.org>
-rw-r--r--.gitignore234
-rw-r--r--AUTHORS23
-rw-r--r--Android.mk34
-rw-r--r--COPYING550
-rw-r--r--HACKING72
-rw-r--r--INSTALL220
-rw-r--r--Makefile.am56
-rw-r--r--NEWS615
-rw-r--r--README6
-rwxr-xr-xautogen.sh177
-rw-r--r--configure.ac353
-rw-r--r--dbus-bus-introspect.xml77
-rw-r--r--dbus-glib-1-uninstalled.pc.in12
-rw-r--r--dbus-glib-1.pc.in13
-rw-r--r--dbus/.cvsignore13
-rw-r--r--dbus/Makefile.am146
-rw-r--r--dbus/dbus-bash-completion-helper.c507
-rw-r--r--dbus/dbus-bash-completion.sh.in21
-rw-r--r--dbus/dbus-binding-tool-glib.c1701
-rw-r--r--dbus/dbus-binding-tool-glib.h40
-rw-r--r--dbus/dbus-gidl.c780
-rw-r--r--dbus/dbus-gidl.h154
-rw-r--r--dbus/dbus-glib-lowlevel.h65
-rw-r--r--dbus/dbus-glib-tool.c478
-rw-r--r--dbus/dbus-glib-tool.h38
-rw-r--r--dbus/dbus-glib.c639
-rw-r--r--dbus/dbus-glib.h346
-rw-r--r--dbus/dbus-gloader-expat.c268
-rw-r--r--dbus/dbus-gmarshal.c92
-rw-r--r--dbus/dbus-gmarshal.h21
-rw-r--r--dbus/dbus-gmarshal.list1
-rw-r--r--dbus/dbus-gobject.c3406
-rw-r--r--dbus/dbus-gobject.h37
-rw-r--r--dbus/dbus-gparser.c931
-rw-r--r--dbus/dbus-gparser.h65
-rw-r--r--dbus/dbus-gproxy.c3275
-rw-r--r--dbus/dbus-gsignature.c219
-rw-r--r--dbus/dbus-gsignature.h19
-rw-r--r--dbus/dbus-gtest-main.c51
-rw-r--r--dbus/dbus-gtest.c76
-rw-r--r--dbus/dbus-gtest.h34
-rw-r--r--dbus/dbus-gthread.c53
-rw-r--r--dbus/dbus-gtool-test.h31
-rw-r--r--dbus/dbus-gtype-specialized-priv.h48
-rw-r--r--dbus/dbus-gtype-specialized.c1845
-rw-r--r--dbus/dbus-gtype-specialized.h178
-rw-r--r--dbus/dbus-gutils.c109
-rw-r--r--dbus/dbus-gutils.h53
-rw-r--r--dbus/dbus-gvalue-parse-variant.c549
-rw-r--r--dbus/dbus-gvalue-parse-variant.h39
-rw-r--r--dbus/dbus-gvalue-utils.c1370
-rw-r--r--dbus/dbus-gvalue-utils.h73
-rw-r--r--dbus/dbus-gvalue.c2099
-rw-r--r--dbus/dbus-gvalue.h44
-rw-r--r--dbus/examples/.cvsignore17
-rw-r--r--dbus/examples/Makefile.am44
-rw-r--r--dbus/examples/example-client.c123
-rw-r--r--dbus/examples/example-service.c155
-rw-r--r--dbus/examples/example-service.xml19
-rw-r--r--dbus/examples/example-signal-emitter.c134
-rw-r--r--dbus/examples/example-signal-emitter.xml13
-rw-r--r--dbus/examples/example-signal-recipient.c104
-rw-r--r--dbus/examples/statemachine/.cvsignore16
-rw-r--r--dbus/examples/statemachine/Makefile.am46
-rw-r--r--dbus/examples/statemachine/sm-marshal.list1
-rw-r--r--dbus/examples/statemachine/statemachine-client.c664
-rw-r--r--dbus/examples/statemachine/statemachine-server.c232
-rw-r--r--dbus/examples/statemachine/statemachine-server.h37
-rw-r--r--dbus/examples/statemachine/statemachine-server.xml14
-rw-r--r--dbus/examples/statemachine/statemachine.c355
-rw-r--r--dbus/examples/statemachine/statemachine.h77
-rw-r--r--dbus/examples/statemachine/statemachine.xml33
-rw-r--r--doc/Makefile.am5
-rw-r--r--doc/dbus-binding-tool.1294
-rw-r--r--doc/reference/Makefile.am123
-rw-r--r--doc/reference/dbus-binding-tool.xml62
-rw-r--r--doc/reference/dbus-glib-docs.sgml68
-rw-r--r--doc/reference/dbus-glib-overrides.txt0
-rw-r--r--doc/reference/dbus-glib-sections.txt201
-rw-r--r--doc/reference/dbus-glib.types0
-rw-r--r--doc/reference/version.xml.in1
-rw-r--r--m4/Makefile.am1
l---------m4/gtk-doc.m41
-rw-r--r--test/Makefile.am58
-rw-r--r--test/core/Makefile.am177
-rw-r--r--test/core/error-mapping.c308
-rw-r--r--test/core/manual/invalid-usage.c320
-rw-r--r--test/core/my-object-marshal.list2
-rw-r--r--test/core/my-object-subclass.c115
-rw-r--r--test/core/my-object-subclass.h33
-rw-r--r--test/core/my-object.c869
-rw-r--r--test/core/my-object.h127
-rw-r--r--test/core/peer-client.c140
-rw-r--r--test/core/peer-on-bus.c148
-rw-r--r--test/core/peer-server.c59
-rw-r--r--test/core/private.c268
-rw-r--r--test/core/proxy-noc.c264
-rw-r--r--test/core/proxy-peer.c274
-rw-r--r--test/core/registrations.c445
-rwxr-xr-xtest/core/run-peer-test.sh6
-rwxr-xr-xtest/core/run-test.sh55
-rw-r--r--test/core/shared-bus.c135
-rw-r--r--test/core/test-dbus-glib.c2415
-rw-r--r--test/core/test-gvariant.c956
-rw-r--r--test/core/test-profile.c1146
-rw-r--r--test/core/test-service-glib-subclass.xml8
-rw-r--r--test/core/test-service-glib.c112
-rw-r--r--test/core/test-service-glib.xml210
-rw-r--r--test/core/test-types.c52
-rw-r--r--test/core/test-variant-recursion.c109
-rw-r--r--test/data/nested-introspect.xml10
-rw-r--r--test/data/valid-service-files/debug-echo.service.in3
-rw-r--r--test/data/valid-service-files/debug-glib.service.in3
-rw-r--r--test/data/valid-service-files/interfaces-test.service.in3
-rw-r--r--test/errors.c78
-rw-r--r--test/interfaces/.gitignore4
-rw-r--r--test/interfaces/Makefile.am136
-rw-r--r--test/interfaces/invalid-annotated-node.xml8
-rw-r--r--test/interfaces/invalid-nested-annotation.xml8
-rwxr-xr-xtest/interfaces/run-test.sh39
-rw-r--r--test/interfaces/test-client.c290
-rw-r--r--test/interfaces/test-dup-prop-a.xml6
-rw-r--r--test/interfaces/test-dup-prop-b.xml6
-rw-r--r--test/interfaces/test-dup-prop.c192
-rw-r--r--test/interfaces/test-dup-prop.h60
-rw-r--r--test/interfaces/test-goodbye.xml9
-rw-r--r--test/interfaces/test-hello.xml10
-rw-r--r--test/interfaces/test-interfaces.c126
-rw-r--r--test/interfaces/test-interfaces.h48
-rw-r--r--test/interfaces/test-objects.c75
-rw-r--r--test/interfaces/test-objects.h31
-rw-r--r--test/interfaces/test-server.c68
-rw-r--r--test/interfaces/test-song.xml9
-rw-r--r--test/interfaces/valid-annotations.xml27
-rw-r--r--test/specialized-types.c489
-rwxr-xr-xtest/test-compile-nested.sh5
-rw-r--r--test/test-service.c375
-rw-r--r--tools/Makefile.am22
-rw-r--r--tools/dbus-glib-tests.supp64
-rw-r--r--tools/dbus-glib.supp297
-rw-r--r--tools/lcov.am47
-rwxr-xr-xtools/run-with-tmp-session-bus.sh51
-rw-r--r--tools/session.conf24
143 files changed, 0 insertions, 36630 deletions
diff --git a/.gitignore b/.gitignore
deleted file mode 100644
index cef0517..0000000
--- a/.gitignore
+++ /dev/null
@@ -1,234 +0,0 @@
-*~
-*.o
-*.lo
-*.deps
-*.gcno
-*.gcda
-*.libs
-*.lineno
-Android.mk
-dbus-glib-*.tar.gz
-Makefile
-Makefile.in
-ChangeLog
-Doxyfile
-aclocal.m4
-autom4te.cache/
-/compile
-config.guess
-config.h
-config.h.in
-config.h.in~
-config.log
-config.status
-config.sub
-configure
-dbus-glib-1.pc
-dbus-glib-1-uninstalled.pc
-dbus/Makefile
-dbus/Makefile.in
-/dbus/dbus-bash-completion-helper
-/dbus/dbus-bash-completion.sh
-dbus/dbus-binding-tool
-dbus/dbus-glib-test
-dbus/examples/Makefile
-dbus/examples/Makefile.in
-dbus/examples/example-client
-dbus/examples/example-service
-dbus/examples/example-service-glue.h
-dbus/examples/example-signal-emitter
-dbus/examples/example-signal-emitter-glue.h
-dbus/examples/example-signal-recipient
-dbus/examples/statemachine/Makefile
-dbus/examples/statemachine/Makefile.in
-dbus/examples/statemachine/sm-marshal.c
-dbus/examples/statemachine/sm-marshal.h
-dbus/examples/statemachine/statemachine-glue.h
-dbus/examples/statemachine/statemachine-server
-dbus/examples/statemachine/statemachine-server-glue.h
-dbus/libdbus-glib-1.la
-dbus/libdbus-gtool.la
-depcomp
-doc/Makefile
-doc/Makefile.in
-doc/reference/Makefile
-doc/reference/Makefile.in
-doc/reference/dbus-glib-decl-list.txt
-doc/reference/dbus-glib-decl-list.txt.bak
-doc/reference/dbus-glib-decl.txt
-doc/reference/dbus-glib-decl.txt.bak
-/doc/reference/dbus-glib-undeclared.txt
-/doc/reference/dbus-glib-undocumented.txt
-doc/reference/dbus-glib-unused.txt
-doc/reference/dbus-glib.args
-doc/reference/dbus-glib.hierarchy
-doc/reference/dbus-glib.interfaces
-doc/reference/dbus-glib.prerequisites
-doc/reference/dbus-glib.signals
-doc/reference/html-build.stamp
-doc/reference/html.stamp
-doc/reference/html/
-doc/reference/scan-build.stamp
-doc/reference/sgml-build.stamp
-doc/reference/sgml.stamp
-doc/reference/tmpl-build.stamp
-doc/reference/tmpl.stamp
-doc/reference/tmpl/
-doc/reference/version.xml
-doc/reference/xml/
-gtk-doc.make
-install-sh
-libtool
-ltmain.sh
-/lcov.info
-/lcov.html/
-m4/Makefile
-m4/Makefile.in
-/m4/libtool.m4
-/m4/ltoptions.m4
-/m4/ltsugar.m4
-/m4/ltversion.m4
-/m4/lt~obsolete.m4
-missing
-stamp-h1
-test/Makefile
-test/Makefile.in
-test/core/Makefile
-test/core/Makefile.in
-/test/core/test-5688
-/test/core/test-30574
-test/core/my-object-marshal.c
-test/core/my-object-marshal.h
-test/core/run-with-tmp-session-bus.conf
-test/core/test-dbus-glib
-/test/core/test-gvariant
-/test/core/test-private
-test/core/test-profile
-test/core/test-service-glib
-test/core/test-service-glib-bindings.h
-test/core/test-service-glib-glue.h
-/test/core/test-service-glib-subclass-glue.h
-test/core/test-thread-client
-test/core/test-thread-server
-/test/core/test-registrations
-/test/core/test-variant-recursion
-test/data/valid-service-files/debug-echo.service
-test/data/valid-service-files/debug-glib.service
-test/data/valid-service-files/test-interfaces.service.in
-test/data/valid-service-files/interfaces-test.service
-test/test-service
-/test-driver
-tools/Makefile
-tools/Makefile.in
-tools/dbus-bus-introspect.xml
-tools/dbus-glib-bindings.h
-ChangeLog
-Doxyfile
-Makefile
-Makefile.in
-aclocal.m4
-autom4te.cache
-config.guess
-config.h
-config.h.in
-config.h.in~
-config.log
-config.status
-config.sub
-configure
-dbus-glib-1.pc
-dbus/Makefile
-dbus/Makefile.in
-dbus/dbus-binding-tool
-dbus/dbus-glib-test
-dbus/examples/Makefile
-dbus/examples/Makefile.in
-dbus/examples/example-client
-dbus/examples/example-service
-dbus/examples/example-service-glue.h
-dbus/examples/example-signal-emitter
-dbus/examples/example-signal-emitter-glue.h
-dbus/examples/example-signal-recipient
-dbus/examples/statemachine/Makefile
-dbus/examples/statemachine/Makefile.in
-dbus/examples/statemachine/sm-marshal.c
-dbus/examples/statemachine/sm-marshal.h
-dbus/examples/statemachine/statemachine-glue.h
-dbus/examples/statemachine/statemachine-server
-dbus/examples/statemachine/statemachine-server-glue.h
-dbus/libdbus-glib-1.la
-dbus/libdbus-gtool.la
-depcomp
-doc/Makefile
-doc/Makefile.in
-doc/reference/Makefile
-doc/reference/Makefile.in
-doc/reference/dbus-glib-decl-list.txt
-doc/reference/dbus-glib-decl-list.txt.bak
-doc/reference/dbus-glib-decl.txt
-doc/reference/dbus-glib-decl.txt.bak
-doc/reference/dbus-glib-unused.txt
-doc/reference/dbus-glib.args
-doc/reference/dbus-glib.hierarchy
-doc/reference/dbus-glib.interfaces
-doc/reference/dbus-glib.prerequisites
-doc/reference/dbus-glib.signals
-doc/reference/html-build.stamp
-doc/reference/html.stamp
-doc/reference/html
-doc/reference/scan-build.stamp
-doc/reference/sgml-build.stamp
-doc/reference/sgml.stamp
-doc/reference/tmpl-build.stamp
-doc/reference/tmpl.stamp
-doc/reference/tmpl
-doc/reference/version.xml
-doc/reference/xml
-gtk-doc.make
-install-sh
-libtool
-ltmain.sh
-m4/Makefile
-m4/Makefile.in
-missing
-stamp-h1
-test/Makefile
-test/Makefile.in
-/test/test-errors
-/test/test-specialized-types
-test/core/Makefile
-test/core/Makefile.in
-test/core/my-object-marshal.c
-test/core/my-object-marshal.h
-test/core/run-with-tmp-session-bus.conf
-test/core/peer-client
-test/core/peer-server
-test/core/test-dbus-glib
-/test/core/test-error-mapping
-/test/core/test-peer-on-bus
-test/core/test-profile
-test/core/test-proxy-peer
-test/core/test-service-glib
-test/core/test-service-glib-bindings.h
-test/core/test-service-glib-glue.h
-/test/core/test-shared-bus
-test/core/test-thread-client
-test/core/test-thread-server
-test/core/test-types
-test/data/valid-service-files/debug-echo.service
-test/data/valid-service-files/debug-glib.service
-test/data/valid-service-files/test-interfaces.service.in
-test/test-service
-tools/Makefile
-tools/Makefile.in
-tools/dbus-bus-introspect.xml
-tools/dbus-glib-bindings.h
-/test/interfaces/run-with-tmp-session-bus.conf
-/test/interfaces/*-bindings.h
-/test/interfaces/*-bindings.h.tmp
-/test/interfaces/*-glue.h
-/test/interfaces/*-glue.h.tmp
-/test/interfaces/test-server
-/test/interfaces/test-service
-/test/interfaces/test-client
-/test/manual/test-invalid-usage
diff --git a/AUTHORS b/AUTHORS
deleted file mode 100644
index d76be04..0000000
--- a/AUTHORS
+++ /dev/null
@@ -1,23 +0,0 @@
-Ross Burton <ross@openedhand.com>
-S. Nallammai <snallammai@novell.com>
-Luiz Augusto von Dentz <luiz.dentz@gmail.com>
-Steve Frécinaux <steve@istique_dot_net>
-Marc-Andre Lureau <marcandre.lureau@gmail.com>
-Rob Taylor <rob.taylor@codethink.co.uk>
-Olivier Andrieu <oliv__a@users.sourceforge.net>
-Philip Blundell <pb@nexus.co.uk>
-Anders Carlsson <andersca@gnome.org>
-Kristian Hogsberg <krh@redhat.com>
-Alex Larsson <alexl@redhat.com>
-Robert McQueen <robot101@debian.org>
-Michael Meeks <michael@ximian.com>
-Seth Nickell <seth@gnome.org>
-John (J5) Palmieri <johnp@redhat.com>
-Havoc Pennington <hp@redhat.com>
-Harri Porten <porten@kde.org>
-Matthew Rickard <mjricka@epoch.ncsc.mil>
-Zack Rusin <zack@kde.org>
-Joe Shaw <joe@assbarn.com>
-Colin Walters <walters@verbum.org>
-David Zeuthen <david@fubar.dk>
-
diff --git a/Android.mk b/Android.mk
deleted file mode 100644
index 7d30b96..0000000
--- a/Android.mk
+++ /dev/null
@@ -1,34 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-
-include $(CLEAR_VARS)
-
-DBUS_GLIB_BUILT_SOURCES := \
- dbus-glib-1.pc \
- dbus/Android.mk
-
-dbus-glib-configure-real:
- cd $(DBUS_GLIB_TOP) ; \
- CC="$(CONFIGURE_CC)" \
- CFLAGS="$(CONFIGURE_CFLAGS)" \
- LD=$(TARGET_LD) \
- LDFLAGS="$(CONFIGURE_LDFLAGS)" \
- CPP=$(CONFIGURE_CPP) \
- CPPFLAGS="$(CONFIGURE_CPPFLAGS)" \
- PKG_CONFIG_LIBDIR="$(CONFIGURE_PKG_CONFIG_LIBDIR)" \
- PKG_CONFIG_TOP_BUILD_DIR=$(PKG_CONFIG_TOP_BUILD_DIR) \
- ac_cv_lib_expat_XML_ParserCreate_MM=yes \
- $(DBUS_GLIB_TOP)/$(CONFIGURE) --host=arm-linux-androideabi \
- --disable-nls --disable-gtk-doc && \
- for file in $(DBUS_GLIB_BUILT_SOURCES); do \
- rm -f $$file && \
- make -C $$(dirname $$file) $$(basename $$file) ; \
- done
-
-dbus-glib-configure: dbus-glib-configure-real
-
-.PHONY: dbus-glib-configure
-
-CONFIGURE_TARGETS += dbus-glib-configure
-
-#include all the subdirs...
--include $(DBUS_GLIB_TOP)/dbus/Android.mk
diff --git a/COPYING b/COPYING
deleted file mode 100644
index 8f263ca..0000000
--- a/COPYING
+++ /dev/null
@@ -1,550 +0,0 @@
-The D-Bus glib bindings are licensed to you under your choice of the Academic
-Free License version 2.1, or the GNU General Public License version 2. Both
-licenses are included here. Some of the standalone binaries are under the GPL
-only; in particular, but not limted to, tests/decode-gcov.c. Each source code
-file is marked with the proper copyright information.
-
-
-
-The Academic Free License
-v. 2.1
-
-This Academic Free License (the "License") applies to any original work of authorship (the "Original Work") whose owner (the "Licensor") has placed the following notice immediately following the copyright notice for the Original Work:
-
-Licensed under the Academic Free License version 2.1
-
-1) Grant of Copyright License. Licensor hereby grants You a
-world-wide, royalty-free, non-exclusive, perpetual, sublicenseable
-license to do the following:
-
-a) to reproduce the Original Work in copies;
-
-b) to prepare derivative works ("Derivative Works") based upon the Original Work;
-
-c) to distribute copies of the Original Work and Derivative Works to the public;
-
-d) to perform the Original Work publicly; and
-
-e) to display the Original Work publicly.
-
-2) Grant of Patent License. Licensor hereby grants You a world-wide,
-royalty-free, non-exclusive, perpetual, sublicenseable license, under
-patent claims owned or controlled by the Licensor that are embodied in
-the Original Work as furnished by the Licensor, to make, use, sell and
-offer for sale the Original Work and Derivative Works.
-
-3) Grant of Source Code License. The term "Source Code" means the
-preferred form of the Original Work for making modifications to it and
-all available documentation describing how to modify the Original
-Work. Licensor hereby agrees to provide a machine-readable copy of the
-Source Code of the Original Work along with each copy of the Original
-Work that Licensor distributes. Licensor reserves the right to satisfy
-this obligation by placing a machine-readable copy of the Source Code
-in an information repository reasonably calculated to permit
-inexpensive and convenient access by You for as long as Licensor
-continues to distribute the Original Work, and by publishing the
-address of that information repository in a notice immediately
-following the copyright notice that applies to the Original Work.
-
-4) Exclusions From License Grant. Neither the names of Licensor, nor
-the names of any contributors to the Original Work, nor any of their
-trademarks or service marks, may be used to endorse or promote
-products derived from this Original Work without express prior written
-permission of the Licensor. Nothing in this License shall be deemed to
-grant any rights to trademarks, copyrights, patents, trade secrets or
-any other intellectual property of Licensor except as expressly stated
-herein. No patent license is granted to make, use, sell or offer to
-sell embodiments of any patent claims other than the licensed claims
-defined in Section 2. No right is granted to the trademarks of
-Licensor even if such marks are included in the Original Work. Nothing
-in this License shall be interpreted to prohibit Licensor from
-licensing under different terms from this License any Original Work
-that Licensor otherwise would have a right to license.
-
-5) This section intentionally omitted.
-
-6) Attribution Rights. You must retain, in the Source Code of any
-Derivative Works that You create, all copyright, patent or trademark
-notices from the Source Code of the Original Work, as well as any
-notices of licensing and any descriptive text identified therein as an
-"Attribution Notice." You must cause the Source Code for any
-Derivative Works that You create to carry a prominent Attribution
-Notice reasonably calculated to inform recipients that You have
-modified the Original Work.
-
-7) Warranty of Provenance and Disclaimer of Warranty. Licensor
-warrants that the copyright in and to the Original Work and the patent
-rights granted herein by Licensor are owned by the Licensor or are
-sublicensed to You under the terms of this License with the permission
-of the contributor(s) of those copyrights and patent rights. Except as
-expressly stated in the immediately proceeding sentence, the Original
-Work is provided under this License on an "AS IS" BASIS and WITHOUT
-WARRANTY, either express or implied, including, without limitation,
-the warranties of NON-INFRINGEMENT, MERCHANTABILITY or FITNESS FOR A
-PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY OF THE ORIGINAL
-WORK IS WITH YOU. This DISCLAIMER OF WARRANTY constitutes an essential
-part of this License. No license to Original Work is granted hereunder
-except under this disclaimer.
-
-8) Limitation of Liability. Under no circumstances and under no legal
-theory, whether in tort (including negligence), contract, or
-otherwise, shall the Licensor be liable to any person for any direct,
-indirect, special, incidental, or consequential damages of any
-character arising as a result of this License or the use of the
-Original Work including, without limitation, damages for loss of
-goodwill, work stoppage, computer failure or malfunction, or any and
-all other commercial damages or losses. This limitation of liability
-shall not apply to liability for death or personal injury resulting
-from Licensor's negligence to the extent applicable law prohibits such
-limitation. Some jurisdictions do not allow the exclusion or
-limitation of incidental or consequential damages, so this exclusion
-and limitation may not apply to You.
-
-9) Acceptance and Termination. If You distribute copies of the
-Original Work or a Derivative Work, You must make a reasonable effort
-under the circumstances to obtain the express assent of recipients to
-the terms of this License. Nothing else but this License (or another
-written agreement between Licensor and You) grants You permission to
-create Derivative Works based upon the Original Work or to exercise
-any of the rights granted in Section 1 herein, and any attempt to do
-so except under the terms of this License (or another written
-agreement between Licensor and You) is expressly prohibited by
-U.S. copyright law, the equivalent laws of other countries, and by
-international treaty. Therefore, by exercising any of the rights
-granted to You in Section 1 herein, You indicate Your acceptance of
-this License and all of its terms and conditions.
-
-10) Termination for Patent Action. This License shall terminate
-automatically and You may no longer exercise any of the rights granted
-to You by this License as of the date You commence an action,
-including a cross-claim or counterclaim, against Licensor or any
-licensee alleging that the Original Work infringes a patent. This
-termination provision shall not apply for an action alleging patent
-infringement by combinations of the Original Work with other software
-or hardware.
-
-11) Jurisdiction, Venue and Governing Law. Any action or suit relating
-to this License may be brought only in the courts of a jurisdiction
-wherein the Licensor resides or in which Licensor conducts its primary
-business, and under the laws of that jurisdiction excluding its
-conflict-of-law provisions. The application of the United Nations
-Convention on Contracts for the International Sale of Goods is
-expressly excluded. Any use of the Original Work outside the scope of
-this License or after its termination shall be subject to the
-requirements and penalties of the U.S. Copyright Act, 17 U.S.C. § 101
-et seq., the equivalent laws of other countries, and international
-treaty. This section shall survive the termination of this License.
-
-12) Attorneys Fees. In any action to enforce the terms of this License
-or seeking damages relating thereto, the prevailing party shall be
-entitled to recover its costs and expenses, including, without
-limitation, reasonable attorneys' fees and costs incurred in
-connection with such action, including any appeal of such action. This
-section shall survive the termination of this License.
-
-13) Miscellaneous. This License represents the complete agreement
-concerning the subject matter hereof. If any provision of this License
-is held to be unenforceable, such provision shall be reformed only to
-the extent necessary to make it enforceable.
-
-14) Definition of "You" in This License. "You" throughout this
-License, whether in upper or lower case, means an individual or a
-legal entity exercising rights under, and complying with all of the
-terms of, this License. For legal entities, "You" includes any entity
-that controls, is controlled by, or is under common control with
-you. For purposes of this definition, "control" means (i) the power,
-direct or indirect, to cause the direction or management of such
-entity, whether by contract or otherwise, or (ii) ownership of fifty
-percent (50%) or more of the outstanding shares, or (iii) beneficial
-ownership of such entity.
-
-15) Right to Use. You may use the Original Work in all ways not
-otherwise restricted or conditioned by this License or by law, and
-Licensor promises not to interfere with or be responsible for such
-uses by You.
-
-This license is Copyright (C) 2003-2004 Lawrence E. Rosen. All rights
-reserved. Permission is hereby granted to copy and distribute this
-license without modification. This license may not be modified without
-the express written permission of its copyright owner.
-
-
---
-END OF ACADEMIC FREE LICENSE. The following is intended to describe the essential
-differences between the Academic Free License (AFL) version 1.0 and other
-open source licenses:
-
-The Academic Free License is similar to the BSD, MIT, UoI/NCSA and Apache
-licenses in many respects but it is intended to solve a few problems with
-those licenses.
-
-* The AFL is written so as to make it clear what software is being
-licensed (by the inclusion of a statement following the copyright notice
-in the software). This way, the license functions better than a template
-license. The BSD, MIT and UoI/NCSA licenses apply to unidentified software.
-
-* The AFL contains a complete copyright grant to the software. The BSD
-and Apache licenses are vague and incomplete in that respect.
-
-* The AFL contains a complete patent grant to the software. The BSD, MIT,
-UoI/NCSA and Apache licenses rely on an implied patent license and contain
-no explicit patent grant.
-
-* The AFL makes it clear that no trademark rights are granted to the
-licensor's trademarks. The Apache license contains such a provision, but the
-BSD, MIT and UoI/NCSA licenses do not.
-
-* The AFL includes the warranty by the licensor that it either owns the
-copyright or that it is distributing the software under a license. None of
-the other licenses contain that warranty. All other warranties are disclaimed,
-as is the case for the other licenses.
-
-* The AFL is itself copyrighted (with the right granted to copy and distribute
-without modification). This ensures that the owner of the copyright to the
-license will control changes. The Apache license contains a copyright notice,
-but the BSD, MIT and UoI/NCSA licenses do not.
---
-START OF GNU GENERAL PUBLIC LICENSE
---
-
- GNU GENERAL PUBLIC LICENSE
- Version 2, June 1991
-
- Copyright (C) 1989, 1991 Free Software Foundation, Inc.
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
- Preamble
-
- The licenses for most software are designed to take away your
-freedom to share and change it. By contrast, the GNU General Public
-License is intended to guarantee your freedom to share and change free
-software--to make sure the software is free for all its users. This
-General Public License applies to most of the Free Software
-Foundation's software and to any other program whose authors commit to
-using it. (Some other Free Software Foundation software is covered by
-the GNU Library General Public License instead.) You can apply it to
-your programs, too.
-
- When we speak of free software, we are referring to freedom, not
-price. Our General Public Licenses are designed to make sure that you
-have the freedom to distribute copies of free software (and charge for
-this service if you wish), that you receive source code or can get it
-if you want it, that you can change the software or use pieces of it
-in new free programs; and that you know you can do these things.
-
- To protect your rights, we need to make restrictions that forbid
-anyone to deny you these rights or to ask you to surrender the rights.
-These restrictions translate to certain responsibilities for you if you
-distribute copies of the software, or if you modify it.
-
- For example, if you distribute copies of such a program, whether
-gratis or for a fee, you must give the recipients all the rights that
-you have. You must make sure that they, too, receive or can get the
-source code. And you must show them these terms so they know their
-rights.
-
- We protect your rights with two steps: (1) copyright the software, and
-(2) offer you this license which gives you legal permission to copy,
-distribute and/or modify the software.
-
- Also, for each author's protection and ours, we want to make certain
-that everyone understands that there is no warranty for this free
-software. If the software is modified by someone else and passed on, we
-want its recipients to know that what they have is not the original, so
-that any problems introduced by others will not reflect on the original
-authors' reputations.
-
- Finally, any free program is threatened constantly by software
-patents. We wish to avoid the danger that redistributors of a free
-program will individually obtain patent licenses, in effect making the
-program proprietary. To prevent this, we have made it clear that any
-patent must be licensed for everyone's free use or not licensed at all.
-
- The precise terms and conditions for copying, distribution and
-modification follow.
-
- GNU GENERAL PUBLIC LICENSE
- TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-
- 0. This License applies to any program or other work which contains
-a notice placed by the copyright holder saying it may be distributed
-under the terms of this General Public License. The "Program", below,
-refers to any such program or work, and a "work based on the Program"
-means either the Program or any derivative work under copyright law:
-that is to say, a work containing the Program or a portion of it,
-either verbatim or with modifications and/or translated into another
-language. (Hereinafter, translation is included without limitation in
-the term "modification".) Each licensee is addressed as "you".
-
-Activities other than copying, distribution and modification are not
-covered by this License; they are outside its scope. The act of
-running the Program is not restricted, and the output from the Program
-is covered only if its contents constitute a work based on the
-Program (independent of having been made by running the Program).
-Whether that is true depends on what the Program does.
-
- 1. You may copy and distribute verbatim copies of the Program's
-source code as you receive it, in any medium, provided that you
-conspicuously and appropriately publish on each copy an appropriate
-copyright notice and disclaimer of warranty; keep intact all the
-notices that refer to this License and to the absence of any warranty;
-and give any other recipients of the Program a copy of this License
-along with the Program.
-
-You may charge a fee for the physical act of transferring a copy, and
-you may at your option offer warranty protection in exchange for a fee.
-
- 2. You may modify your copy or copies of the Program or any portion
-of it, thus forming a work based on the Program, and copy and
-distribute such modifications or work under the terms of Section 1
-above, provided that you also meet all of these conditions:
-
- a) You must cause the modified files to carry prominent notices
- stating that you changed the files and the date of any change.
-
- b) You must cause any work that you distribute or publish, that in
- whole or in part contains or is derived from the Program or any
- part thereof, to be licensed as a whole at no charge to all third
- parties under the terms of this License.
-
- c) If the modified program normally reads commands interactively
- when run, you must cause it, when started running for such
- interactive use in the most ordinary way, to print or display an
- announcement including an appropriate copyright notice and a
- notice that there is no warranty (or else, saying that you provide
- a warranty) and that users may redistribute the program under
- these conditions, and telling the user how to view a copy of this
- License. (Exception: if the Program itself is interactive but
- does not normally print such an announcement, your work based on
- the Program is not required to print an announcement.)
-
-These requirements apply to the modified work as a whole. If
-identifiable sections of that work are not derived from the Program,
-and can be reasonably considered independent and separate works in
-themselves, then this License, and its terms, do not apply to those
-sections when you distribute them as separate works. But when you
-distribute the same sections as part of a whole which is a work based
-on the Program, the distribution of the whole must be on the terms of
-this License, whose permissions for other licensees extend to the
-entire whole, and thus to each and every part regardless of who wrote it.
-
-Thus, it is not the intent of this section to claim rights or contest
-your rights to work written entirely by you; rather, the intent is to
-exercise the right to control the distribution of derivative or
-collective works based on the Program.
-
-In addition, mere aggregation of another work not based on the Program
-with the Program (or with a work based on the Program) on a volume of
-a storage or distribution medium does not bring the other work under
-the scope of this License.
-
- 3. You may copy and distribute the Program (or a work based on it,
-under Section 2) in object code or executable form under the terms of
-Sections 1 and 2 above provided that you also do one of the following:
-
- a) Accompany it with the complete corresponding machine-readable
- source code, which must be distributed under the terms of Sections
- 1 and 2 above on a medium customarily used for software interchange; or,
-
- b) Accompany it with a written offer, valid for at least three
- years, to give any third party, for a charge no more than your
- cost of physically performing source distribution, a complete
- machine-readable copy of the corresponding source code, to be
- distributed under the terms of Sections 1 and 2 above on a medium
- customarily used for software interchange; or,
-
- c) Accompany it with the information you received as to the offer
- to distribute corresponding source code. (This alternative is
- allowed only for noncommercial distribution and only if you
- received the program in object code or executable form with such
- an offer, in accord with Subsection b above.)
-
-The source code for a work means the preferred form of the work for
-making modifications to it. For an executable work, complete source
-code means all the source code for all modules it contains, plus any
-associated interface definition files, plus the scripts used to
-control compilation and installation of the executable. However, as a
-special exception, the source code distributed need not include
-anything that is normally distributed (in either source or binary
-form) with the major components (compiler, kernel, and so on) of the
-operating system on which the executable runs, unless that component
-itself accompanies the executable.
-
-If distribution of executable or object code is made by offering
-access to copy from a designated place, then offering equivalent
-access to copy the source code from the same place counts as
-distribution of the source code, even though third parties are not
-compelled to copy the source along with the object code.
-
- 4. You may not copy, modify, sublicense, or distribute the Program
-except as expressly provided under this License. Any attempt
-otherwise to copy, modify, sublicense or distribute the Program is
-void, and will automatically terminate your rights under this License.
-However, parties who have received copies, or rights, from you under
-this License will not have their licenses terminated so long as such
-parties remain in full compliance.
-
- 5. You are not required to accept this License, since you have not
-signed it. However, nothing else grants you permission to modify or
-distribute the Program or its derivative works. These actions are
-prohibited by law if you do not accept this License. Therefore, by
-modifying or distributing the Program (or any work based on the
-Program), you indicate your acceptance of this License to do so, and
-all its terms and conditions for copying, distributing or modifying
-the Program or works based on it.
-
- 6. Each time you redistribute the Program (or any work based on the
-Program), the recipient automatically receives a license from the
-original licensor to copy, distribute or modify the Program subject to
-these terms and conditions. You may not impose any further
-restrictions on the recipients' exercise of the rights granted herein.
-You are not responsible for enforcing compliance by third parties to
-this License.
-
- 7. If, as a consequence of a court judgment or allegation of patent
-infringement or for any other reason (not limited to patent issues),
-conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License. If you cannot
-distribute so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you
-may not distribute the Program at all. For example, if a patent
-license would not permit royalty-free redistribution of the Program by
-all those who receive copies directly or indirectly through you, then
-the only way you could satisfy both it and this License would be to
-refrain entirely from distribution of the Program.
-
-If any portion of this section is held invalid or unenforceable under
-any particular circumstance, the balance of the section is intended to
-apply and the section as a whole is intended to apply in other
-circumstances.
-
-It is not the purpose of this section to induce you to infringe any
-patents or other property right claims or to contest validity of any
-such claims; this section has the sole purpose of protecting the
-integrity of the free software distribution system, which is
-implemented by public license practices. Many people have made
-generous contributions to the wide range of software distributed
-through that system in reliance on consistent application of that
-system; it is up to the author/donor to decide if he or she is willing
-to distribute software through any other system and a licensee cannot
-impose that choice.
-
-This section is intended to make thoroughly clear what is believed to
-be a consequence of the rest of this License.
-
- 8. If the distribution and/or use of the Program is restricted in
-certain countries either by patents or by copyrighted interfaces, the
-original copyright holder who places the Program under this License
-may add an explicit geographical distribution limitation excluding
-those countries, so that distribution is permitted only in or among
-countries not thus excluded. In such case, this License incorporates
-the limitation as if written in the body of this License.
-
- 9. The Free Software Foundation may publish revised and/or new versions
-of the General Public License from time to time. Such new versions will
-be similar in spirit to the present version, but may differ in detail to
-address new problems or concerns.
-
-Each version is given a distinguishing version number. If the Program
-specifies a version number of this License which applies to it and "any
-later version", you have the option of following the terms and conditions
-either of that version or of any later version published by the Free
-Software Foundation. If the Program does not specify a version number of
-this License, you may choose any version ever published by the Free Software
-Foundation.
-
- 10. If you wish to incorporate parts of the Program into other free
-programs whose distribution conditions are different, write to the author
-to ask for permission. For software which is copyrighted by the Free
-Software Foundation, write to the Free Software Foundation; we sometimes
-make exceptions for this. Our decision will be guided by the two goals
-of preserving the free status of all derivatives of our free software and
-of promoting the sharing and reuse of software generally.
-
- NO WARRANTY
-
- 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
-FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
-OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
-PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
-OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
-TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
-PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
-REPAIR OR CORRECTION.
-
- 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
-REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
-INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
-OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
-TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
-YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
-PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGES.
-
- END OF TERMS AND CONDITIONS
-
- How to Apply These Terms to Your New Programs
-
- If you develop a new program, and you want it to be of the greatest
-possible use to the public, the best way to achieve this is to make it
-free software which everyone can redistribute and change under these terms.
-
- To do so, attach the following notices to the program. It is safest
-to attach them to the start of each source file to most effectively
-convey the exclusion of warranty; and each file should have at least
-the "copyright" line and a pointer to where the full notice is found.
-
- <one line to give the program's name and a brief idea of what it does.>
- Copyright (C) <year> <name of author>
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-
-
-Also add information on how to contact you by electronic and paper mail.
-
-If the program is interactive, make it output a short notice like this
-when it starts in an interactive mode:
-
- Gnomovision version 69, Copyright (C) year name of author
- Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
- This is free software, and you are welcome to redistribute it
- under certain conditions; type `show c' for details.
-
-The hypothetical commands `show w' and `show c' should show the appropriate
-parts of the General Public License. Of course, the commands you use may
-be called something other than `show w' and `show c'; they could even be
-mouse-clicks or menu items--whatever suits your program.
-
-You should also get your employer (if you work as a programmer) or your
-school, if any, to sign a "copyright disclaimer" for the program, if
-necessary. Here is a sample; alter the names:
-
- Yoyodyne, Inc., hereby disclaims all copyright interest in the program
- `Gnomovision' (which makes passes at compilers) written by James Hacker.
-
- <signature of Ty Coon>, 1 April 1989
- Ty Coon, President of Vice
-
-This General Public License does not permit incorporating your program into
-proprietary programs. If your program is a subroutine library, you may
-consider it more useful to permit linking proprietary applications with the
-library. If this is what you want to do, use the GNU Library General
-Public License instead of this License.
diff --git a/HACKING b/HACKING
deleted file mode 100644
index 7d6dd93..0000000
--- a/HACKING
+++ /dev/null
@@ -1,72 +0,0 @@
-The mainline git tree for this code is at
-git://anongit.freedesktop.org/git/dbus/dbus-glib.
-
-= Creating changes =
-
-Be sure to match the existing code style (Emacs: "gnu").
-
-If you are making major changes which you wish to be incorporated upstream,
-please do as small commits to your local git tree, so there is a good
-history of your changes.
-
-When you consider changes ready for merging to mainline, use
-"git-format-patch" or otherwise generate unified diffs. Post those diffs
-to a new bug at http://bugs.freedesktop.org, project DBus, component GLib.
-
-For nontrivial changes *please* try to extend the test suite to cover it. The
-test infrastructure is in test/core/. If possible, use a GTester-style test
-like registrations.c; or if necessary, add things to the giant catch-all
-test, test-dbus-glib.c.
-
-Run "make check" to run the test suite.
-
-= Committing =
-
-If applying a patch from someone else that created them via
-"git-format-patch", you can use "git-am -s" to apply. Otherwise
-apply the patch and then use "git commit --author ..."
-
-Regardless:
-
-== Nontrivial changes ==
-Nontrivial patches should always go through Bugzilla for peer review, so
-you should have a bug number. The commit should be of the form:
-
-Bug XXXXXX: Single line summary here
-
- * dbus/filename.c: Why I changed this.
- * dbus/otherfile.c: Why I changed this.
-
-== Trivial changes ==
-
-Just use a single line summary, like:
-
-Fix typo in NEWS
-
-= Making a release =
-
-DBus-Glib now uses an even-stable odd-development release numbering
-system. The current number in configure.ac should be odd.
-
-To make a release (please replace use of 0.76 with the new version)
-
-* make
-* make distcheck
-* edit configure.ac, change version to even (e.g. 0.75 -> 0.76)
-* also in configure.ac, update LT_CURRENT, LT_REVISION and LT_AGE
-* edit NEWS, summarize notable changes since the last release
-* ./autogen.sh
-* make
-* make distcheck
-* sign the tarball (or use: make dbus-glib-0.76.tar.gz.asc)
-* make maintainer-upload-release
-* git commit -m "Release"
-* git tag -a dbus-glib_0.76
-* edit configure.ac, change version to odd (e.g. 0.76 -> 0.77)
-* git commit -m "Bump version for development"
-* Update the wiki: http://www.freedesktop.org/wiki/Software/DBusBindings
-* Announce the release on the mailing list, quoting the notable changes
- from NEWS.
-
-NEWS is now maintained again (Simon finds it easier this way, and he
-does most of the releases).
diff --git a/INSTALL b/INSTALL
deleted file mode 100644
index 33f5913..0000000
--- a/INSTALL
+++ /dev/null
@@ -1,220 +0,0 @@
- DBus GLib Installation
- =================
-
-Quick start
-===========
-
-DBus uses GNU AutoTools for its build system, thus the basic install
-procedure can be summarized as:
-
- ./configure --prefix=/usr
- make
- su make install
-
-The configure script will automatically determine whether to try and
-build bindings for GLib, Qt, Qt3, Python and Mono based on what tools
-are installed on the host system. The default build behaviour can be
-overridden using the --enable-XXX/--disable-XXX arguments to configure.
-A typical scenario in which it is desirable to override automatic
-detection, is during packaging of binary builds, where a predictable
-dependancy chain is required. For more details on GNU AutoTools
-installation, consult the generic instructions later in this document
-
-External software dependancies
-==============================
-
- Requisite:
-
- - GLib >= 2.6
-
- Optional:
-
- - gtk-doc (for API documentation)
-
-====================================================================
-
-The rest of this document contains the generic GNU AutoTools install
-insructions....
-
-Basic Installation
-==================
-
- These are generic installation instructions.
-
- The `configure' shell script attempts to guess correct values for
-various system-dependent variables used during compilation. It uses
-those values to create a `Makefile' in each directory of the package.
-It may also create one or more `.h' files containing system-dependent
-definitions. Finally, it creates a shell script `config.status' that
-you can run in the future to recreate the current configuration, a file
-`config.cache' that saves the results of its tests to speed up
-reconfiguring, and a file `config.log' containing compiler output
-(useful mainly for debugging `configure').
-
- If you need to do unusual things to compile the package, please try
-to figure out how `configure' could check whether to do them, and mail
-diffs or instructions to the address given in the `README' so they can
-be considered for the next release. If at some point `config.cache'
-contains results you don't want to keep, you may remove or edit it.
-
- The file `configure.in' is used to create `configure' by a program
-called `autoconf'. You only need `configure.in' if you want to change
-it or regenerate `configure' using a newer version of `autoconf'.
-
-The simplest way to compile this package is:
-
- 1. `cd' to the directory containing the package's source code and type
- `./configure' to configure the package for your system. If you're
- using `csh' on an old version of System V, you might need to type
- `sh ./configure' instead to prevent `csh' from trying to execute
- `configure' itself.
-
- Running `configure' takes awhile. While running, it prints some
- messages telling which features it is checking for.
-
- 2. Type `make' to compile the package.
-
- 3. Optionally, type `make check' to run any self-tests that come with
- the package.
-
- 4. Type `make install' to install the programs and any data files and
- documentation.
-
- 5. You can remove the program binaries and object files from the
- source code directory by typing `make clean'. To also remove the
- files that `configure' created (so you can compile the package for
- a different kind of computer), type `make distclean'. There is
- also a `make maintainer-clean' target, but that is intended mainly
- for the package's developers. If you use it, you may have to get
- all sorts of other programs in order to regenerate files that came
- with the distribution.
-
-Compilers and Options
-=====================
-
- Some systems require unusual options for compilation or linking that
-the `configure' script does not know about. You can give `configure'
-initial values for variables by setting them in the environment. Using
-a Bourne-compatible shell, you can do that on the command line like
-this:
- CC=c89 CFLAGS=-O2 LIBS=-lposix ./configure
-
-Or on systems that have the `env' program, you can do it like this:
- env CPPFLAGS=-I/usr/local/include LDFLAGS=-s ./configure
-
-Compiling For Multiple Architectures
-====================================
-
- You can compile the package for more than one kind of computer at the
-same time, by placing the object files for each architecture in their
-own directory. To do this, you must use a version of `make' that
-supports the `VPATH' variable, such as GNU `make'. `cd' to the
-directory where you want the object files and executables to go and run
-the `configure' script. `configure' automatically checks for the
-source code in the directory that `configure' is in and in `..'.
-
- If you have to use a `make' that does not supports the `VPATH'
-variable, you have to compile the package for one architecture at a time
-in the source code directory. After you have installed the package for
-one architecture, use `make distclean' before reconfiguring for another
-architecture.
-
-Installation Names
-==================
-
- By default, `make install' will install the package's files in
-`/usr/local/bin', `/usr/local/man', etc. You can specify an
-installation prefix other than `/usr/local' by giving `configure' the
-option `--prefix=PATH'.
-
- You can specify separate installation prefixes for
-architecture-specific files and architecture-independent files. If you
-give `configure' the option `--exec-prefix=PATH', the package will use
-PATH as the prefix for installing programs and libraries.
-Documentation and other data files will still use the regular prefix.
-
- In addition, if you use an unusual directory layout you can give
-options like `--bindir=PATH' to specify different values for particular
-kinds of files. Run `configure --help' for a list of the directories
-you can set and what kinds of files go in them.
-
- If the package supports it, you can cause programs to be installed
-with an extra prefix or suffix on their names by giving `configure' the
-option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
-
-Optional Features
-=================
-
- Some packages pay attention to `--enable-FEATURE' options to
-`configure', where FEATURE indicates an optional part of the package.
-They may also pay attention to `--with-PACKAGE' options, where PACKAGE
-is something like `gnu-as' or `x' (for the X Window System). The
-`README' should mention any `--enable-' and `--with-' options that the
-package recognizes.
-
- For packages that use the X Window System, `configure' can usually
-find the X include and library files automatically, but if it doesn't,
-you can use the `configure' options `--x-includes=DIR' and
-`--x-libraries=DIR' to specify their locations.
-
-Specifying the System Type
-==========================
-
- There may be some features `configure' can not figure out
-automatically, but needs to determine by the type of host the package
-will run on. Usually `configure' can figure that out, but if it prints
-a message saying it can not guess the host type, give it the
-`--host=TYPE' option. TYPE can either be a short name for the system
-type, such as `sun4', or a canonical name with three fields:
- CPU-COMPANY-SYSTEM
-
-See the file `config.sub' for the possible values of each field. If
-`config.sub' isn't included in this package, then this package doesn't
-need to know the host type.
-
- If you are building compiler tools for cross-compiling, you can also
-use the `--target=TYPE' option to select the type of system they will
-produce code for and the `--build=TYPE' option to select the type of
-system on which you are compiling the package.
-
-Sharing Defaults
-================
-
- If you want to set default values for `configure' scripts to share,
-you can create a site shell script called `config.site' that gives
-default values for variables like `CC', `cache_file', and `prefix'.
-`configure' looks for `PREFIX/share/config.site' if it exists, then
-`PREFIX/etc/config.site' if it exists. Or, you can set the
-`CONFIG_SITE' environment variable to the location of the site script.
-A warning: not all `configure' scripts look for a site script.
-
-Operation Controls
-==================
-
- `configure' recognizes the following options to control how it
-operates.
-
-`--cache-file=FILE'
- Use and save the results of the tests in FILE instead of
- `./config.cache'. Set FILE to `/dev/null' to disable caching, for
- debugging `configure'.
-
-`--help'
- Print a summary of the options to `configure', and exit.
-
-`--quiet'
-`--silent'
-`-q'
- Do not print messages saying which checks are being made. To
- suppress all normal output, redirect it to `/dev/null' (any error
- messages will still be shown).
-
-`--srcdir=DIR'
- Look for the package's source code in directory DIR. Usually
- `configure' can determine that directory automatically.
-
-`--version'
- Print the version of Autoconf used to generate the `configure'
- script, and exit.
-
-`configure' also accepts some other, not widely useful, options.
diff --git a/Makefile.am b/Makefile.am
deleted file mode 100644
index c55c6fb..0000000
--- a/Makefile.am
+++ /dev/null
@@ -1,56 +0,0 @@
-ACLOCAL_AMFLAGS = -I m4
-GLIB_PC=dbus-glib-1.pc
-
-SUBDIRS = dbus-gmain dbus tools test doc
-DIST_SUBDIRS = dbus-gmain dbus tools test doc m4
-
-pkgconfigdir = $(libdir)/pkgconfig
-pkgconfig_DATA = $(GLIB_PC)
-
-DISTCLEANFILES = \
- $(GLIB_PC)
-
-EXTRA_DIST = \
- HACKING \
- NEWS \
- dbus-bus-introspect.xml \
- dbus-glib-1.pc.in
-
-# Creating ChangeLog from git log:
-
-MAINTAINERCLEANFILES = ChangeLog
-
-DISTCHECK_CONFIGURE_FLAGS=--enable-gtk-doc --enable-checks --enable-tests
-EXTRA_DIST += ChangeLog
-
-ChangeLog:
-$(srcdir)/ChangeLog:
- @if test -d "$(srcdir)/.git"; then \
- (cd "$(srcdir)" && \
- ./missing --run git log --stat) | fmt --split-only > $@.tmp \
- && mv -f $@.tmp $@ \
- || ($(RM) $@.tmp; \
- echo Failed to generate ChangeLog, your ChangeLog may be outdated >&2; \
- (test -f $@ || echo git-log is required to generate this file >> $@)); \
- else \
- test -f $@ || \
- (echo A git checkout and git log are required to generate ChangeLog >&2 && \
- echo A git checkout and git-log are required to generate this file >> $@); \
- fi
-
-%.tar.gz.asc: %.tar.gz
- $(AM_V_GEN)gpg --detach-sign --armor $@
-
-maintainer-upload-release:
- test -f @PACKAGE@-@VERSION@.tar.gz
- test -f @PACKAGE@-@VERSION@.tar.gz.asc
- gpg --verify @PACKAGE@-@VERSION@.tar.gz.asc
- rsync -vzP @PACKAGE@-@VERSION@.tar.gz dbus.freedesktop.org:/srv/dbus.freedesktop.org/www/releases/@PACKAGE@/@PACKAGE@-@VERSION@.tar.gz
- rsync -vzP @PACKAGE@-@VERSION@.tar.gz.asc dbus.freedesktop.org:/srv/dbus.freedesktop.org/www/releases/@PACKAGE@/@PACKAGE@-@VERSION@.tar.gz.asc
- rsync -rvzPp --chmod=Dg+s,ug+rwX,o=rX doc/reference/html/ \
- dbus.freedesktop.org:/srv/dbus.freedesktop.org/www/doc/@PACKAGE@/
-
-check-valgrind: all
- $(MAKE) -C test check-valgrind
-
-include tools/lcov.am
diff --git a/NEWS b/NEWS
deleted file mode 100644
index 883b496..0000000
--- a/NEWS
+++ /dev/null
@@ -1,615 +0,0 @@
-dbus-glib is deprecated, please use GDBus in new GLib-based projects.
-
-dbus-glib 0.109 (UNRELEASED)
-============================
-
-...
-
-dbus-glib 0.108 (2016-09-09)
-============================
-
-The “toxic chair” release.
-
-Fixes:
-
-• Use dbus-run-session instead of dbus-launch for tests.
-
-dbus-glib 0.106 (2016-01-14)
-============================
-
-The “crumbling vestige” release.
-
-Fixes:
-
-• Stop testing G_HAVE_INLINE, which ceased to work in GLib 2.47.2 and
- wasn't meant to be API anyway. Instead, rely on "static inline" doing
- the right thing. On pre-C99 compilers, this relies on <glib.h> defining
- inline to __inline, __inline__ or the empty string if the compiler
- requires it, which it has done since 2000. (fd.o #93513, Colin Watson)
-
-• Stop calling g_mem_profile() in the tests, which no longer does anything
- and caused the tests to fail by issuing a warning (Simon McVittie)
-
-• Slightly modernize build system, and remove a weird cross-directory
- dependency which was breaking distcheck (Simon McVittie)
-
-• Stop distributing generated marshallers in the tarball (Simon McVittie)
-
-dbus-glib 0.104 (2015-02-09)
-============================
-
-The “smoke and ashes” release.
-
-Deprecations:
-
-• Document the entire library as deprecated (Simon McVittie, Philip Withnall)
-
-Dependencies:
-
-• libdbus 1.8 is required
-• GLib 2.32 is required
-
-Enhancements:
-
-• The libdbus 1.8 dependency means we can now document that
- dbus_g_thread_init() is idempotent and thread-safe
- (fd.o #54770, Simon McVittie)
-
-• Use g_cclosure_marshal_generic for all marshalling (fd.o #64214,
- Simon McVittie)
-
-Fixes:
-
-• Allow timeouts to be migrated from one main context to another
- without an assertion failure (fd.o #30574, Mike Gorse)
-
-• Don't trip a libdbus fatal warning if a Unix fd or other unsupported type
- is encountered in a message (fd.o #80557, Alban Crequy)
-
-• Make the tests pass with newer GLib by not removing removed sources
- (fd.o #83530, Simon McVittie)
-
-• Fix some typos in the documentation (fd.o #45686, Jiří Klimeš)
-
-• Make the Autotools setup less awful (fd.o #58698;
- Rafał Mużyło, Simon McVittie)
-
-dbus-glib 0.102 (2014-02-12)
-============================
-
-The “I've come to the conclusion that Debian should choose Russ Allbery
-to be its new init system” release. [1]
-
-Enhancements:
-
-• Add dbus_g_method_invocation_get_connection (fd.o #55729, Dan Williams)
-
-• Add dbus_g_connection_open_private (fd.o #55730, Dan Williams)
-
-• Better regression tests (fd.o #23633, fd.o #40711, fd.o #41129, fd.o #51511,
- fd.o #68603; Simon McVittie, Dan Williams)
-
-• Get rid of more dead code (fd.o #40711, Simon McVittie)
-
-• dbus-binding-tool: check validity of names (fd.o #7909, Simon McVittie)
-
-Fixes:
-
-• dbus_g_value_build_g_variant: treat GValues containing (G_TYPE_STRING, NULL)
- or (G_TYPE_STRV, NULL) as empty string or empty array instead of asserting
- (fd.o #71811, Xavier Claessens)
-
-• Upload documentation correctly (Simon McVittie)
-
-• Fix under-linking (fd.o #68601, Simon McVittie)
-
-[1] credit: https://twitter.com/keybuk/status/433058371290157056
-
-dbus-glib 0.100.2 (2013-02-25)
-==============================
-
-The "I would prefer lengthier studies, and fewer explosions" release.
-
-This release is a respin of the 0.100.1 tarball to drop some old,
-broken versions of generated documentation files (fd.o #55830). There
-are no source changes.
-
-dbus-glib 0.100.1 (2013-02-15)
-==============================
-
-Security:
-
-• Sebastian Krahmer discovered and published an authentication bypass
- vulnerability in pam_fprintd, caused by a bug in dbus-glib. It is
- possible that other users of dbus-glib can be exploited in the same
- way. CVE-2013-0292 has been allocated for this vulnerability.
-
- This vulnerability is fixed in dbus-glib version 0.100.1 by git commit
- 166978a. All users of dbus-glib should upgrade.
-
- (fd.o #60916; Colin Walters, Simon McVittie)
-
-dbus-glib 0.100 (2012-06-25)
-============================
-
-The "Flabbergasted Jerome" release.
-
-Enhancements:
-
-• Support building on Android with androgenizer
- (fd.o #42532, Derek Foreman)
-
-• Respect NOCONFIGURE=1 in autogen.sh (Colin Walters)
-
-Fixes:
-
-• Fix several GVariant reference leaks in dbus_g_value_parse_variant
- (fd.o #41125, Simon McVittie)
-
-• Don't crash if an error code is out of range for its domain or
- has a negative code (fd.o #40151; David Woodhouse, Simon McVittie)
-
-• Fix compilation with -Werror=format-security (Matthias Klose)
-
-• Don't crash if dbus_g_proxy_new_for_peer() is used to talk to
- the dbus-daemon (fd.o #41126, Simon McVittie)
-
-dbus-glib 0.98 (2011-09-30)
-===========================
-
-The "undocumented feature" release.
-
-• Fix the documentation, a lot. We have nearly 100% coverage now.
- (fd.o #37793, smcv)
-
-• In specialized collection iterators, check that the type is correct;
- g_critical and return harmlessly, rather than crashing, if not (smcv)
-
-• If library users register specialized GTypes, warn if their vtables have
- missing callbacks which would cause accessors to crash (smcv)
-
-• Fix production of documentation out-of-tree with newer gtk-doc (smcv)
-
-• Simplify invoke_object_method() and OOM handling in dbus-gobject
- (fd.o #35767, smcv)
-
-dbus-glib 0.96 (2011-09-21)
-===========================
-
-The "terminating at New Cross Gate" release.
-
-• Fix a regression in marshalling GObject instances as object paths,
- which broke NetworkManager (fd.o #37852, Debian #628890; Simon McVittie)
-
-• Fix crashes when sending a message when disconnected from D-Bus but still
- working through our backlog of incoming messages, similar to fd.o #12675
- (fd.o #38406, Simon McVittie)
-
-• Cope more gracefully, with a critical warning instead of a memory leak,
- if programmer error causes G_VALUE_COLLECT to fail
- (fd.o #38406, NB#86280, NB#180486; Kimmo Hämäläinen, Christian Dywan,
- Simon McVittie)
-
-• Avoid an assertion failure when unregistering a proxy if GetNameOwner failed
- (fd.o #38408, NB#116862; Janne Karhunen, Simon McVittie)
-
-• Don't report various programmer errors as "out of memory"; raise suitable
- critical warnings instead, and don't leak memory (fd.o #35767, fd.o #35766;
- Simon McVittie)
-
-• If a remote process sends a wrong method call on the Properties interface,
- send back an error reply, instead of warning on stderr and not replying
- (fd.o #35766, Simon McVittie)
-
-• Show a warning if dbus_g_method_return fails to marshal something
- (fd.o #29884, NB#180486; Christian Dywan, Simon McVittie)
-
-• Remove remnants of i18n (fd.o #36428, Simon McVittie)
-
-• Remove dead code (NB#180486; Christian Dywan)
-
-dbus-glib 0.94 (2011-06-01)
-===========================
-
-The "Norwegian Blue" release.
-
-Dependencies:
-
-* dbus 1.2.16 is required (dbus 1.4 is recommended)
-
-* GIO 2.26 (packaged with GLib) is required
-
-Fixes:
-
-* fd.o #10890: remove Doxygen support, to clarify that gtk-doc
- is the way to get dbus-glib documentation (Simon McVittie)
-
-* fd.o #22667: improve documentation (Will Thompson)
-
-* fd.o #22854: update libtool versioning (Simon McVittie)
-
-* fd.o #23616: document which DBusGProxy methods stop working on ::destroy,
- and improve precondition checks (Simon McVittie)
-
-* fd.o #26952: add infrastructure to upload tarballs and documentation
- (Simon McVittie)
-
-* fd.o #27193, Gentoo #254192: don't use ${SHELL} to run shell scripts
- (Simon McVittie)
-
-* fd.o #27598: allow signals and properties to be annotated
- (Christian Dywan, Simon McVittie)
-
-* fd.o #29884: improve error handling in various places
- (Christian Dywan)
-
-* fd.o #30171: check validity of more arguments, don't report
- "out of memory" or "should not have been reached" if an invalid string or
- boolean is given, and abandon broken containers more gracefully
- (Simon McVittie)
-
-* fd.o #30274: allow underscores in error names (Christian Dywan)
-
-* fd.o #32087: if an object is on more than one connection, emit signals
- on all of them; if it's unregistered, only unregister it from the
- requested connection (Simon McVittie)
-
-* fd.o #32351: fix memory leaks in dbus-binding-tool (Christian Dywan)
-
-* fd.o #33145, fd.o #37789: improve error output if dependencies are too old
- (Simon McVittie)
-
-* fd.o #33646: don't duplicate match rules (Alban Crequy)
-
-* fd.o #34282: fix linking order for modern ld (Robert Ancell)
-
-* fd.o #35115: fix ability to switch a DBusConnection from one GMainContext
- to another (Mike Gorse)
-
-* fd.o #35952: forbid a ReturnVal annotation after the first OUT <arg>,
- which had never worked correctly anyway (Simon McVittie)
-
-* fd.o #36216: remove false claim that we use Introspect() at runtime,
- and document more error cases (Simon McVittie)
-
-* fd.o #36428: remove unused support for translated messages
- (Simon McVittie)
-
-* fd.o #36793: don't corrupt internal data if a GObject is registered
- twice on the same (connection, path) tuple, and fix out-of-bounds reading
- (Simon McVittie)
-
-* fd.o #36811: fix multiple signal emissions if an object is removed from
- all of its locations then re-exported, and a memory leak if an exported
- object is disposed (Simon McVittie)
-
-* fd.o #37060: rebuild everything if gcov is enabled/disabled, or if gcc
- is upgraded while gcov is enabled (Simon McVittie)
-
-* fd.o #37062: fail to build if our assumptions about int sizes are not
- met, and remove useless variables detected by gcc 4.6 (Simon McVittie)
-
-* fd.o #37790: remove empty "tests" which don't test anything
- (Simon McVittie)
-
-* fd.o #37795: log the error message if object registration fails
- (Dan Williams)
-
-* fd.o #37812: delete temporary file if dbus-binding-tool fails
- (Simon McVittie)
-
-dbus-glib 0.92 (2010-11-10)
-===========================
-
-Fixes:
-
-* check for GLib 2.26 correctly
-
-dbus-glib 0.90 (2010-11-07)
-===========================
-
-Dependencies:
-
-* GLib 2.26 is required
-
-Enhancements:
-
-* Add DBusGObjectPath, DBusGSignature typedefs
-* Give specialized GArrays iteration/appending support
-* Test dbus_g_value_build_g_variant for various fixed arrays
-* Remove gcov decoder, which hasn't worked since dbus-glib left libdbus
-* replace remnants of gcov support with lcov.am from telepathy-glib
-* fd.o #30428: add dbus_g_value_parse_g_variant
-* dbus_g_type_specialized_map_append: document that the value contents are
- stolen
-
-Fixes:
-
-* Remove unused method attribute variables in introspect_interfaces
-* Dereference main loop once variant recursion test is done
-* Plug leak of expected_str in threaded server test
-* Free path string after emission in in statemachine server example
-* Always free method_c_name in dbus binding tool
-* Free looked up function name in dbus binding tool
-* Fix switching a connection's GMainContext
-* dbus_g_value_build_g_variant: cope with empty arrays, maps
-* Build test/ before its subdirs
-
-dbus-glib 0.88 (2010-08-12)
-===========================
-
-First note, and most importantly, this fixes a security issue:
-https://bugzilla.redhat.com/show_bug.cgi?id=585394
-Note that affected system services will need to be rebuilt (but not
-necessarily patched).
-
-Dependencies:
-
-* GLib 2.24 is required
-
-Security:
-
-* CVE-2010-1172: Respect property access flags for writing, allow disabling
- for reads
-
-Enhancements:
-
-* Allow duplicate object path registrations for different connections
-* fd.o #28715: Add dbus_g_value_build_g_variant()
-* Support DBUS_TYPE_G_SIGNATURE
-* fd.o #27958: dbus_g_error_domain_register: rewrite the documentation
-
-Other fixes:
-
-* Refer to dbus_g_connection_flush rather than the plain dbus call
-* core: don't pass malformed error interface to dbus (rh#581794)
-* Fix lookup of regular properties when shadow properties are used
-* Don't use the identifier "interface" in public headers
-* Use AC_CANONICAL_HOST, not _TARGET
-* Use EXEEXT so that we satisfy dependencies when cross-compiling
-* Fix linking of tests on Windows
-* Put the G_OS_WIN32 check where it can be defined.
-* add mising DBUS_TYPE_G_* to the doc
-* Bug 14579: remove pending call from hash table before cancelling it
-* Add various tests etc. to .gitignore
-
-dbus-glib 0.86 (2010-03-24)
-===========================
-
-Enhancements:
-
-* [configure.ac] Use AM_SILENT_RULES if available
-* core: allow duplicate property names on GInterfaces
-* core: performance optimization for object info lookup
-* turn the gtk-doc documentation into buildable shape
-
-Fixes:
-
-* Fix hyphenated error codes
-* [dbus-gobject.c] Trivial compiler warning fixes
-* Free errors returned by method implementations
-
-dbus-glib 0.84 (2010-01-27)
-===========================
-
-Enhancements:
-
-* Import dbus-bus-introspect.xml upstream
-* Bug 19623 - Add dbus_g_bus_get_private
-* Support duplicate object registrations
-* fd.o #20936: Update FSF address
-
-Fixes:
-
-* dbus-gvalue: set an error when demarshal_basic doesn't recognize type
-* Fix bad NAME in dbus-binding-tool man page
-* fd.o #25119: Don't leak DBusGMethodInvocation for no-reply calls
-
-dbus-glib 0.82 (2009-07-16)
-===========================
-
-Enhancements:
-
-* Bug 20343 - Add a man page for dbus-binding-tool
-* Bug 14183 - Listen to NameOwnerChanged using arg0 matching
-* Bug 19927 - Use const for GError * param we're not modifying
-* Clean up some compilation warnings
-* Bug 21362 - Remove use of deprecated symbols
-* Bug 13908: make dbus_g_type_specialized_init() safe for library users to call
-* add --with-dbus-binding-tool option to use an external dbus-binding-tool
-* Bug 16776: teach dbus_g_method_return_error about DBUS_GERROR
-* Remove all sorts of libdbus cruft from configure.ac
-* dbus_g_type_specialized_init: make some effort at being thread-safe
-* fd.o #21219: implement unregistration of objects
-* fd.o #13908: silently initialize specialized types whenever required
-
-Fixes:
-
-* Bug 18294 - Be defensive about a possibly NULL property string
-* Bug 21753 - Correctly initialize GValues in dbus-binding-tool
- generated code
-* Use -fno-strict-aliasing by default
-* Add missing prototype for dbus_g_connection_unregister_g_object
-* Fix format-security warning
-* Bug 22244 - Only include <glib.h>, not individual headers
-* build: fix undefined macro: AM_PROG_LIBTOOL with recent libtool
-* fd.o#20884: dbus_g_proxy_manager_replace_name_owner: don't leave
- freed memory in the hash table if the name was the owner's first
-* fd.o #5688: don't assert when exported object is destroyed
- after D-Bus connection closes
-* Use g_strdup instead of strdup in dbus_g_method_get_sender
-* Bug 20879 - Use --skip-source argument for glib-genmarshal
-
-dbus-glib 0.80 (2009-02-02)
-===========================
-
-Fixes:
-
-* Bug 19441: Don't send replies for messages explicitly not requesting one
-* Bug 19065 - handle nested nodes in dbus-binding-tool
-* Bug 19325 - parallel build fix
-* Bug 19259: Always use /etc/bash_completion.d
-* Bug 19647: Move test-types inside run-test to avoid dep on
- existing session bus
-* Fix linking order so -Wl,--as-needed works
-* Use the provided interface for org.freedesktop.DBus.Properties.GetAll call.
-
-D-Bus GLib Bindings 0.78 (04 Dec 2008)
-
-Thanks to Robert McQueen, Philip Van Hoof, David Zeuthen,
-Colin Walters, Dan Williams, Nick Welch, Tomas Pelka and
-others for their contributions.
-
-Reliability fixes:
-
- - #16114 [patch] wincaps-to-uscore property names for GetAll()
- - #16419: recursive variants demarshaling limits
- - #18573: service tracker race
-
-Other notable fixes and enhancements:
-
- - #17329: allow hash tables to contain complex types
- - #17798: add support for 'o', 'g' and 'as' in dictionaries
- - #16925: bash completion for dbus-send
-
-D-Bus GLib Bindings 0.75 (05 Jun 2008)
-==
-
-Thanks to Dan Williams, David Zeuthen, Kimmo Hämäläinen,
-Ross Burton, William Jon McCann, Colin Walters, Brian Cameron,
-Peter O'Gorman, Peter Kjellerstedt, Christian Persch,
-Rob Taylor and others for their contributions in this release.
-
-Critical fixes:
-
- - #15430: ABI now guaranteed frozen
- - #8607: Fix broken introspection XML
- - #16079: Return an error on unknown property Get
- - #10834: Fix error handling in dbus_g_proxy_end_call_internal
-
-Other notable fixes:
-
- - #11672: Fixes for /bin/sh as dash
- - #11675: Fixes for non-gcc compilers
- - #10668: Correctly detect path to dbus-daemon
- - #12849, #12857: Memory leak fixes
- - New function to specify default timeout for calls on proxy
- - Implement org.freedesktop.DBus.Properties.GetAll
- - Require DBus 1.1
-
-D-Bus GLib Bindings 0.74 (27 Jun 2007)
-==
-
- - Init threading first to stop a warning from new GLib.
- - Remove the XML documentation support in configure
- - Fix typo in _dbus_gvalue_signals_error (#10837) (Thanks to Peter Kjellerstedt)
- - Update GLib requirement (Closes #10889).
- - Document dbus-gtype-specialized
- - Add simple test suite for peer objects.
- - Support peer-to-peer proxies. (Closes #10233).
- - Add dbus_connection_get_g_connection.
- - Stop compiler warnings (Closes #10374).
- - Handle dbus errors which are not name has no owner
- - Update abstract socket test from DBus, which now cross-compiles
- - Rename the error quark to be unique
- - Update AUTHORS
-
-D-Bus GLib Bindings 0.73 (13 Feb 2007)
-==
-
- - Allow passing of NULL to strv out arguments.
- (Patch due to Luiz Augusto von Dentz <luiz.dentz@gmail.com>.
- Fixes bug #8795.)
- - Make uscore_to_wincaps return NULL when passed NULL. (Fixes bug #8318.)
- - Only respond to NameOwnerChanged if its one of our names.
- (Patch by Kimmo Hämäläinen <kimmo.hamalainen@nokia.com>. Fixes bug #8235.)
- - Fix dbus-binding-tool to generate headers usable from C++.
- (Thanks to Christian Persch <chpe@gnome.org>. Fixes bug #6358.)
- - Only require --prefix for server side binding generation.
- (Fixes reopened bug #4185.)
- - Clarify documentation for dbus_g_method_get_sender.
- (Fixes #8832.)
- - Add new API for specifying the timeout in DBusGProxy calls.
- (Patch due to S. Nalliami <snallammai@novell.com>. Fixes bug #9832.)
- - Don't check for libxml2 when expat not found. (Fixes bugs #9894 and #9000.)
- - Add configure flags --with-introspect-xml. (Fixes bug #9105)
- - Use dbus_threads_init_default() rather than using own threading primitives.
- (Fixes bug #9259.)
- - Reduce dependency to dbus version 0.93, error out if correct version
- not found. (Patch due to Luiz Augusto von Dentz <luiz.dentz@gmail.com>.
- Fixes bug #8793.)
- - Allow dbus and dbus-glib to live in different prefixes. (Fixes bug #9384.)
- - Add pkg-config support for uninstalled use.
- (Fix due to Damien Carbery <damien.carbery@sun.com>. Fixes bug #9769.)
-
-D-Bus GLib Bindings 0.72 (26 Oct 2006)
-==
- - Only use -Wfloat-equal if compiler supports it (Closes #7658. Thanks
-to Jens Granseuer <jensgr@gmx.net> for the patch).
- - Return NULL from g_return_val_if_fail in dbus_g_proxy_begin_call
-(Closes #4159.)
- - Add dbus-gidl.h to IGNORE_HFILES for doxygen docs
- - Update tools/Makefile.am for new dbus-binding-tool behaviour
- - Remove bashism in make-dbus-glib-error-enum.sh (Closes #6700).
- - Fix introspection when object has exported properties.
-(dbus-gobject:write_interface was completely broken)
- - Fix thanks to mccann@jhu.edu. (Closes #8607).
- - Require --prefix in dbus-binding-tool (Closes #4185).
- - Don't shadow index. Rename usage of index to index_. Thanks stdlib...
-(Closes #8353).
- - Fix small leak when marshal_table is destroyed (Closes #6870 with
-patch from Richard Hult <richard@imendio.com>).
- - Fixes crash if disposing one DBusGProxy causes another for the same
-service to be unrefed in a destroyed callback.
- - Use modern AC_INIT, AM_INIT_AUTOMAKE
- - Clean generated run-with-tmp-session-bus.conf on make clean
- - Actually run unit tests and checks when doing make distcheck
- - Use TEST_CORE_SERVICE_BINARY path for core test service file
- - Use dbus-daemon --introspect to generate DBus service introspect xml
- - Add tests for new interfaces functionaility
- - Bump GLib dependency to 2.6 (Closes #4390).
- - Add gobject-2.0 to dbus-glib-1.pc.in
- - Puts all exposed services in the org.freedesktop.DBus.GLib namespace
- - Update COPYING and HACKING to be correct for dbus-glib
- - Move tests/glib to test/core
- - Rename configure.in to configure.ac for modernity
- - Fix memleak in lookup_or_register_specialized (Applies fix from
-Daniel d'Andrada Tenório de Carvalho, closing bug #7352).
- - Add an m4 directory and add gtk-doc.m4, which is installed in the
-tree by gtkdocize.
- - tools/Makefile.am: Add tools/session.conf to EXTRA_DIST so make check
-works from tarballs
- - Fix compilation with -Werror
- - Make test scripts run during out-of-tree compilation
- - Fix out-of-tree compilation
- - Replace doxygen with gtk-doc in INSTALL
- - Commit patch to switch to gtk-doc with gtype-specialized doc and
- - Updates from Marc-Andre Lureau <marcandre.lureau@gmail.com>, with
-minor cleanup. (Closes #7726.)
-
-D-Bus GLib Bindings 0.71 (24 July 2006)
-==
-- Correctly installs a few missing headers
-- Build was cleaned up a bit
-
-D-Bus GLib Bindings 0.70 (17 July 2006)
-==
-- First release after bindings split
-- dbus-binding-tool heeds org.freedesktop.DBus.GLib.ClientCSymbol C symbol
- name annotations when generating glib client bindings
-- DBusGProxy can now be inherited from
-- Support added for generating bindings to arrays that are represented as
- GPtrArrays rather than GArrays (ie size-variable things, such as strings,
- objects, structs, etc).
-- Modification of the existing specialised types to have N type parameters
- (rather than the current 1 or 2 for arrays and dictionaries respectively).
- You can then use this to get a glib type to represent any arbitrary
- D-Bus struct type using dbus_g_type_get_struct. The only implementation of
- these types is with GValueArrays as before, but it's now possible to store
- these in arrays, emit them in signals, etc.
-- New methodbus_g_connection_open provides a way to open connections to an
- arbitrary address
-- Various bugs and memory leaks fixed
-Sleep after starting the peer server, before starting the peer client.
-This fixes random failures due to the race.
-
diff --git a/README b/README
deleted file mode 100644
index db9ebb0..0000000
--- a/README
+++ /dev/null
@@ -1,6 +0,0 @@
-dbus-glib is a deprecated D-Bus binding for GLib.
-
-dbus-glib receives minimal maintenance and security fixes for the benefit
-of projects like Telepathy and NetworkManager that still rely on it, but
-should not be used in new projects (and existing projects should try
-to move away from it, too). Please use GDBus, part of GLib since 2.26.
diff --git a/autogen.sh b/autogen.sh
deleted file mode 100755
index 6cb13d8..0000000
--- a/autogen.sh
+++ /dev/null
@@ -1,177 +0,0 @@
-#!/bin/sh
-# Run this to generate all the initial makefiles, etc.
-
-srcdir=`dirname $0`
-test -z "$srcdir" && srcdir=.
-
-ORIGDIR=`pwd`
-cd $srcdir
-
-PROJECT=dbus-glib
-TEST_TYPE=-f
-FILE=dbus-glib-1.pc.in
-
-DEFAULT_CONFIGURE_ARGS="--enable-maintainer-mode --enable-gtk-doc --enable-tests --enable-verbose-mode --enable-checks --enable-asserts"
-
-# Not all echo versions allow -n, so we check what is possible. This test is
-# based on the one in autoconf.
-case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in
- *c*,-n*) ECHO_N= ;;
- *c*,* ) ECHO_N=-n ;;
- *) ECHO_N= ;;
-esac
-
-
-# some terminal codes ...
-boldface="`tput bold 2>/dev/null`"
-normal="`tput sgr0 2>/dev/null`"
-printbold() {
- echo $ECHO_N "$boldface"
- echo "$@"
- echo $ECHO_N "$normal"
-}
-printerr() {
- echo "$@" >&2
-}
-
-# Usage:
-# compare_versions MIN_VERSION ACTUAL_VERSION
-# returns true if ACTUAL_VERSION >= MIN_VERSION
-compare_versions() {
- ch_min_version=$1
- ch_actual_version=$2
- ch_status=0
- IFS="${IFS= }"; ch_save_IFS="$IFS"; IFS="."
- set $ch_actual_version
- for ch_min in $ch_min_version; do
- ch_cur=`echo $1 | sed 's/[^0-9].*$//'`; shift # remove letter suffixes
- if [ -z "$ch_min" ]; then break; fi
- if [ -z "$ch_cur" ]; then ch_status=1; break; fi
- if [ $ch_cur -gt $ch_min ]; then break; fi
- if [ $ch_cur -lt $ch_min ]; then ch_status=1; break; fi
- done
- IFS="$ch_save_IFS"
- return $ch_status
-}
-
-# Usage:
-# version_check PACKAGE VARIABLE CHECKPROGS MIN_VERSION SOURCE
-# checks to see if the package is available
-version_check() {
- vc_package=$1
- vc_variable=$2
- vc_checkprogs=$3
- vc_min_version=$4
- vc_source=$5
- vc_status=1
-
- vc_checkprog=`eval echo "\\$$vc_variable"`
- if [ -n "$vc_checkprog" ]; then
- printbold "using $vc_checkprog for $vc_package"
- return 0
- fi
-
- printbold "checking for $vc_package >= $vc_min_version..."
- for vc_checkprog in $vc_checkprogs; do
- echo $ECHO_N " testing $vc_checkprog... "
- if $vc_checkprog --version < /dev/null > /dev/null 2>&1; then
- vc_actual_version=`$vc_checkprog --version 2>/dev/null | head -n 1 | \
- sed 's/^.*[ ]\([0-9.]*[a-z]*\).*$/\1/'`
-
- if [ -z "$vc_actual_version" ]; then
- # In gtk-doc 1.26, gtkdoc-scan --version prints to stderr
- vc_actual_version=`$vc_checkprog --version 2>&1 | head -n 1 | \
- sed 's/^.*[ ]\([0-9.]*[a-z]*\).*$/\1/'`
- fi
-
- if compare_versions $vc_min_version $vc_actual_version; then
- echo "found $vc_actual_version"
- # set variable
- eval "$vc_variable=$vc_checkprog"
- vc_status=0
- break
- else
- echo "too old (found version $vc_actual_version)"
- fi
- else
- echo "not found."
- fi
- done
- if [ "$vc_status" != 0 ]; then
- printerr "***Error***: You must have $vc_package >= $vc_min_version installed"
- printerr " to build $PROJECT. Download the appropriate package for"
- printerr " from your distribution or get the source tarball at"
- printerr " $vc_source"
- printerr
- fi
- return $vc_status
-}
-
-#tell Mandrake autoconf wrapper we want autoconf 2.5x, not 2.13
-WANT_AUTOCONF_2_5=1
-export WANT_AUTOCONF_2_5
-version_check autoreconf AUTORECONF 'autoreconf' 2.59 \
- "http://ftp.gnu.org/pub/gnu/autoconf/autoconf-2.59.tar.gz" || DIE=1
-
-automake_progs="automake automake-1.9"
-
-version_check automake AUTOMAKE "$automake_progs" 1.9 \
- "http://ftp.gnu.org/pub/gnu/automake/automake-1.9.tar.gz" || DIE=1
-ACLOCAL=`echo $AUTOMAKE | sed s/automake/aclocal/`
-ACLOCAL="$ACLOCAL $ACLOCAL_FLAGS"
-
-version_check gtkdoc GTKDOC 'gtkdoc-scan' 1.6 \
- "http://ftp.gnome.org/pub/GNOME/sources/gtk-doc/" || DIE=1
-
-test $TEST_TYPE $FILE || {
- printbold "You must run this script in the top-level $PROJECT directory"
- exit 1
-}
-
-if test -z "$*"; then
- printbold
- printbold "I am going to run ./configure with default arguments:"
- printbold "$DEFAULT_CONFIGURE_ARGS"
- printbold "If you wish to pass any others to it, please specify them on the"
- printbold "$0 command line."
- printbold
-fi
-
-
-libtoolize --force || echo "libtoolize failed"
-gtkdocize || echo "gtkdocize failed"
-
-export AUTOMAKE ACLOCAL
-autoreconf --install || exit 1
-
-DIE=0
-cd $ORIGDIR
-
-if test -z "$NOCONFIGURE"; then
- run_configure=true
- for arg in $*; do
- case $arg in
- --no-configure)
- run_configure=false
- ;;
- *)
- ;;
- esac
- done
-else
- run_configure=false
-fi
-
-if $run_configure; then
- if test -z "$*"; then
- $srcdir/configure $DEFAULT_CONFIGURE_ARGS
- else
- $srcdir/configure --enable-maintainer-mode "$@"
- fi
- echo
- echo "Now type 'make' to compile $PROJECT."
-else
- echo
- echo "Now run 'configure' and 'make' to compile $PROJECT."
-fi
-
diff --git a/configure.ac b/configure.ac
deleted file mode 100644
index 889faf9..0000000
--- a/configure.ac
+++ /dev/null
@@ -1,353 +0,0 @@
-dnl -*- mode: m4 -*-
-AC_PREREQ(2.52)
-
-AC_INIT([dbus-glib], [0.109],
- [https://bugs.freedesktop.org/enter_bug.cgi?product=dbus&component=GLib])
-
-AC_CANONICAL_HOST
-
-AM_INIT_AUTOMAKE([1.9 subdir-objects])
-
-AC_CONFIG_HEADERS(config.h)
-
-# Honor aclocal flags
-ACLOCAL="$ACLOCAL $ACLOCAL_FLAGS"
-AC_CONFIG_MACRO_DIR(m4)
-
- ## must come before we use the $USE_MAINTAINER_MODE variable later
-AM_MAINTAINER_MODE
-
-m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])
-
-# libtool versioning - this applies to libdbus
-#
-# See http://sources.redhat.com/autobook/autobook/autobook_91.html#SEC91 for details
-#
-
-## increment if the interface has additions, changes, removals.
-LT_CURRENT=5
-
-## increment any time the source changes; set to
-## 0 if you increment CURRENT
-LT_REVISION=3
-
-## increment if any interfaces have been added; set to 0
-## if any interfaces have been changed or removed. removal has
-## precedence over adding, so set to 0 if both happened.
-LT_AGE=3
-
-AC_SUBST(LT_CURRENT)
-AC_SUBST(LT_REVISION)
-AC_SUBST(LT_AGE)
-
-
-AC_PROG_CC
-AC_ISC_POSIX
-AC_HEADER_STDC
-
-AC_ARG_ENABLE(tests, AS_HELP_STRING([--enable-tests],[enable unit test code]),enable_tests=$enableval,enable_tests=$USE_MAINTAINER_MODE)
-AC_ARG_ENABLE(ansi, AS_HELP_STRING([--enable-ansi],[enable -ansi -pedantic gcc flags]),enable_ansi=$enableval,enable_ansi=no)
-AC_ARG_ENABLE(gcov, AS_HELP_STRING([--enable-gcov],[compile with coverage profiling instrumentation (gcc only)]),enable_gcov=$enableval,enable_gcov=no)
-AC_ARG_ENABLE(bash-completion, AS_HELP_STRING([--enable-bash-completion],[install bash completion scripts]),enable_bash_completion=$enableval,enable_bash_completion=yes)
-
-AM_CONDITIONAL(DBUS_BASH_COMPLETION, test x$enable_bash_completion = xyes)
-if test x$enable_bash_completion = xyes; then
- AC_DEFINE(DBUS_BASH_COMPLETION,1,[Enable bash completion])
-fi
-
-AC_ARG_WITH(dbus-binding-tool,
- AS_HELP_STRING([--with-dbus-binding-tool=[filename]],[Use external dbus-binding-tool program]),
- [DBUS_BINDING_TOOL=$withval],[DBUS_BINDING_TOOL=\$\(top_builddir\)/dbus/dbus-binding-tool])
-AC_SUBST(DBUS_BINDING_TOOL)
-
-
-dnl DBUS_BUILD_TESTS controls unit tests built in to .c files
-dnl and also some stuff in the test/ subdir
-AM_CONDITIONAL(DBUS_BUILD_TESTS, test x$enable_tests = xyes)
-if test x$enable_tests = xyes; then
- AC_DEFINE(DBUS_BUILD_TESTS,1,[Build test code])
-fi
-
-AC_ARG_ENABLE([asserts],
- [AS_HELP_STRING([--enable-asserts], [include assertion checks])],
- [enable_asserts=$enableval], [enable_asserts=$USE_MAINTAINER_MODE])
-if test x$enable_asserts = xno; then
- AC_DEFINE([G_DISABLE_ASSERT], [1], [Disable GLib assertion macros])
-fi
-
-AC_ARG_ENABLE([checks],
- [AS_HELP_STRING([--enable-checks], [include sanity checks on public API])],
- [enable_checks=$enableval], [enable_checks=yes])
-if test x$enable_checks = xno; then
- AC_DEFINE([G_DISABLE_CHECKS], [1], [Disable GLib public API sanity checking])
-fi
-
-#### gcc warning flags
-
-AC_DEFUN([AC_CC_TRY_FLAG], [
- AC_MSG_CHECKING([whether gcc understands $1])
-
- ac_save_CFLAGS="$CFLAGS"
- CFLAGS="$CFLAGS $1"
-
- AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])], [ac_cc_flag=yes], [ac_cc_flag=no])
- CFLAGS="$ac_save_CFLAGS"
-
- if test "x$ac_cc_flag" = "xyes"; then
- ifelse([$2], , :, [$2])
- else
- ifelse([$3], , :, [$3])
- fi
- AC_MSG_RESULT([$ac_cc_flag])
-])
-
-if test "x$GCC" = "xyes"; then
- AC_CC_TRY_FLAG([-Wfloat-equal],
- [ac_flag_float_equal=yes],
- [ac_flag_float_equal=no])
-
- changequote(,)dnl
- case " $CFLAGS " in
- *[\ \ ]-Wall[\ \ ]*) ;;
- *) CFLAGS="$CFLAGS -Wall" ;;
- esac
-
- case " $CFLAGS " in
- *[\ \ ]-Wchar-subscripts[\ \ ]*) ;;
- *) CFLAGS="$CFLAGS -Wchar-subscripts" ;;
- esac
-
- case " $CFLAGS " in
- *[\ \ ]-Wmissing-declarations[\ \ ]*) ;;
- *) CFLAGS="$CFLAGS -Wmissing-declarations" ;;
- esac
-
- case " $CFLAGS " in
- *[\ \ ]-Wmissing-prototypes[\ \ ]*) ;;
- *) CFLAGS="$CFLAGS -Wmissing-prototypes" ;;
- esac
-
- case " $CFLAGS " in
- *[\ \ ]-Wnested-externs[\ \ ]*) ;;
- *) CFLAGS="$CFLAGS -Wnested-externs" ;;
- esac
-
- case " $CFLAGS " in
- *[\ \ ]-Wpointer-arith[\ \ ]*) ;;
- *) CFLAGS="$CFLAGS -Wpointer-arith" ;;
- esac
-
- case " $CFLAGS " in
- *[\ \ ]-Wcast-align[\ \ ]*) ;;
- *) CFLAGS="$CFLAGS -Wcast-align" ;;
- esac
-
- if test "x$ac_flag_float_equal" = "xyes"; then
- case " $CFLAGS " in
- *[\ \ ]-Wfloat-equal[\ \ ]*) ;;
- *) CFLAGS="$CFLAGS -Wfloat-equal" ;;
- esac
- fi
-
- case " $CFLAGS " in
- *[\ \ ]-Wsign-compare[\ \ ]*) ;;
- *) CFLAGS="$CFLAGS -Wsign-compare" ;;
- esac
-
- # This one is special - it's not a warning override.
- # http://bugs.freedesktop.org/show_bug.cgi?id=10599
- # is the bug for DBus core.
- case " $CFLAGS " in
- *[\ \ ]-fno-strict-aliasing[\ \ ]*) ;;
- *) CFLAGS="$CFLAGS -fno-strict-aliasing" ;;
- esac
-
- if test "x$enable_ansi" = "xyes"; then
- case " $CFLAGS " in
- *[\ \ ]-ansi[\ \ ]*) ;;
- *) CFLAGS="$CFLAGS -ansi" ;;
- esac
-
- case " $CFLAGS " in
- *[\ \ ]-D_POSIX_C_SOURCE*) ;;
- *) CFLAGS="$CFLAGS -D_POSIX_C_SOURCE=199309L" ;;
- esac
-
- case " $CFLAGS " in
- *[\ \ ]-D_BSD_SOURCE[\ \ ]*) ;;
- *) CFLAGS="$CFLAGS -D_BSD_SOURCE" ;;
- esac
-
- case " $CFLAGS " in
- *[\ \ ]-pedantic[\ \ ]*) ;;
- *) CFLAGS="$CFLAGS -pedantic" ;;
- esac
- fi
- if test x$enable_gcov = xyes; then
- case " $CFLAGS " in
- *[\ \ ]-fprofile-arcs[\ \ ]*) ;;
- *) CFLAGS="$CFLAGS -fprofile-arcs" ;;
- esac
- case " $CFLAGS " in
- *[\ \ ]-ftest-coverage[\ \ ]*) ;;
- *) CFLAGS="$CFLAGS -ftest-coverage" ;;
- esac
-
- ## remove optimization
- CFLAGS=`echo "$CFLAGS" | sed -e 's/-O[0-9]*//g'`
- fi
- changequote([,])dnl
-else
- if test x$enable_gcov = xyes; then
- AC_MSG_ERROR([--enable-gcov can only be used with gcc])
- fi
-fi
-
-LT_INIT
-
-changequote(,)dnl
-# compress spaces in flags
-CFLAGS=`echo "$CFLAGS" | sed -e 's/ +/ /g'`
-CPPFLAGS=`echo "$CPPFLAGS" | sed -e 's/ +/ /g'`
-changequote([,])dnl
-
-if test x$enable_gcov = xyes; then
- # so that config.h changes when you toggle gcov support
- AC_DEFINE_UNQUOTED([DBUS_GCOV_ENABLED],
- [__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__],
- [Defined to the gcc version if gcov is enabled, to force a rebuild due to config.h changing])
-fi
-
-#### Various functions
-AC_SEARCH_LIBS([socket], [socket])
-
-dnl check for socklen_t
-AC_MSG_CHECKING(whether socklen_t is defined)
-AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netdb.h>
-]],[[
-socklen_t foo;
-foo = 1;
-]])],dbus_have_socklen_t=yes,dbus_have_socklen_t=no)
-AC_MSG_RESULT($dbus_have_socklen_t)
-
-if test "x$dbus_have_socklen_t" = "xyes"; then
- AC_DEFINE(HAVE_SOCKLEN_T,1,[Have socklen_t type])
-fi
-
-#### Sort out XML library
-
-# see what we have
-AC_CHECK_LIB(expat, XML_ParserCreate_MM,
- [ AC_CHECK_HEADERS(expat.h, have_expat=true, have_expat=false) ],
- have_expat=false)
-
-if ! $have_expat ; then
- AC_MSG_ERROR([expat library not found, check config.log for failed attempts])
-fi
-
-XML_LIBS=-lexpat
-XML_CFLAGS=
-
-
-#### Set up final flags
-
-PKG_CHECK_MODULES([DBUS], [dbus-1 >= 1.8])
-AC_SUBST([DBUS_CFLAGS])
-AC_SUBST([DBUS_LIBS])
-
-# Glib detection
-AC_DEFINE([GLIB_VERSION_MAX_ALLOWED], [GLIB_VERSION_2_32],
- [Warn on use of APIs added after GLib 2.32])
-AC_DEFINE([GLIB_VERSION_MIN_REQUIRED], [GLIB_VERSION_2_32],
- [Warn on use of APIs deprecated before GLib 2.32])
-PKG_CHECK_MODULES([DBUS_GLIB], [gobject-2.0 >= 2.32, gio-2.0 >= 2.32])
-
-GLIB_GENMARSHAL=`$PKG_CONFIG --variable=glib_genmarshal glib-2.0`
-AC_SUBST(GLIB_GENMARSHAL)
-
-dnl GLib flags
-AC_SUBST(DBUS_GLIB_CFLAGS)
-AC_SUBST(DBUS_GLIB_LIBS)
-AC_SUBST(DBUS_GLIB_THREADS_LIBS)
-
-DBUS_GLIB_TOOL_CFLAGS=$XML_CFLAGS
-DBUS_GLIB_TOOL_LIBS="$XML_LIBS"
-AC_SUBST(DBUS_GLIB_TOOL_CFLAGS)
-AC_SUBST(DBUS_GLIB_TOOL_LIBS)
-
-AC_ARG_VAR([DBUS_RUN_SESSION],
- [The dbus-run-session tool from dbus 1.8 or later])
-AC_PATH_PROG([DBUS_RUN_SESSION], [dbus-run-session], [dbus-run-session])
-
-### gtk-doc Documentation
-GTK_DOC_CHECK([1.14], [--flavour no-tmpl])
-
-# Make dbus-gmain submodule part of dbus-glib's namespace
-AH_BOTTOM([
-#define DBUS_GMAIN_FUNCTION_NAME(name) _dbus_g_ ## name
-])
-
-AC_CONFIG_FILES([
-Makefile
-m4/Makefile
-doc/Makefile
-doc/reference/Makefile
-doc/reference/version.xml
-dbus/Makefile
-dbus/examples/Makefile
-dbus/examples/statemachine/Makefile
-dbus-gmain/Makefile
-test/Makefile
-test/core/Makefile
-test/interfaces/Makefile
-test/data/valid-service-files/debug-glib.service
-test/data/valid-service-files/debug-echo.service
-test/data/valid-service-files/interfaces-test.service
-tools/Makefile
-dbus-glib-1.pc
-dbus-glib-1-uninstalled.pc
-])
-AC_OUTPUT
-
-dnl ==========================================================================
-echo "
- D-BUS GLIB BINDINGS $VERSION
- ==============
-
- prefix: ${prefix}
- exec_prefix: ${exec_prefix}
- source code location: ${srcdir}
- compiler: ${CC}
- cflags: ${CFLAGS}
- cppflags: ${CPPFLAGS}
-"
-
-echo "
- Maintainer mode: ${USE_MAINTAINER_MODE}
- gcc coverage profiling: ${enable_gcov}
- Building unit tests: ${enable_tests}
- Building assertions: ${enable_asserts}
- Building checks: ${enable_checks}
- Building Gtk-doc docs: ${enable_gtk_doc}
- Bash Completion: ${enable_bash_completion}
- Using XML parser: ${with_xml}
-"
-
-if test x$enable_tests = xyes; then
- echo "NOTE: building with unit tests increases the size of the installed library and renders it insecure."
-fi
-if test x$enable_tests = xyes -a x$enable_asserts = xno; then
- echo "NOTE: building with unit tests but without assertions means tests may not properly report failures (this configuration is only useful when doing something like profiling the tests)"
-fi
-if test x$enable_gcov = xyes; then
- echo "NOTE: building with coverage profiling is definitely for developers only."
-fi
-if test x$enable_asserts = xyes; then
- echo "NOTE: building with assertions increases library size and decreases performance."
-fi
-if test x$enable_checks = xno; then
- echo "NOTE: building without checks for arguments passed to public API makes it harder to debug apps using D-BUS, but will slightly decrease D-BUS library size and _very_ slightly improve performance."
-fi
diff --git a/dbus-bus-introspect.xml b/dbus-bus-introspect.xml
deleted file mode 100644
index 9a38c31..0000000
--- a/dbus-bus-introspect.xml
+++ /dev/null
@@ -1,77 +0,0 @@
- <!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
-"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
-<node>
- <interface name="org.freedesktop.DBus.Introspectable">
- <method name="Introspect">
- <arg name="data" direction="out" type="s"/>
- </method>
- </interface>
- <interface name="org.freedesktop.DBus">
- <method name="RequestName">
- <arg direction="in" type="s"/>
- <arg direction="in" type="u"/>
- <arg direction="out" type="u"/>
- </method>
- <method name="ReleaseName">
- <arg direction="in" type="s"/>
- <arg direction="out" type="u"/>
- </method>
- <method name="StartServiceByName">
- <arg direction="in" type="s"/>
- <arg direction="in" type="u"/>
- <arg direction="out" type="u"/>
- </method>
- <method name="Hello">
- <arg direction="out" type="s"/>
- </method>
- <method name="NameHasOwner">
- <arg direction="in" type="s"/>
- <arg direction="out" type="b"/>
- </method>
- <method name="ListNames">
- <arg direction="out" type="as"/>
- </method>
- <method name="ListActivatableNames">
- <arg direction="out" type="as"/>
- </method>
- <method name="AddMatch">
- <arg direction="in" type="s"/>
- </method>
- <method name="RemoveMatch">
- <arg direction="in" type="s"/>
- </method>
- <method name="GetNameOwner">
- <arg direction="in" type="s"/>
- <arg direction="out" type="s"/>
- </method>
- <method name="ListQueuedOwners">
- <arg direction="in" type="s"/>
- <arg direction="out" type="as"/>
- </method>
- <method name="GetConnectionUnixUser">
- <arg direction="in" type="s"/>
- <arg direction="out" type="u"/>
- </method>
- <method name="GetConnectionUnixProcessID">
- <arg direction="in" type="s"/>
- <arg direction="out" type="u"/>
- </method>
- <method name="GetConnectionSELinuxSecurityContext">
- <arg direction="in" type="s"/>
- <arg direction="out" type="ay"/>
- </method>
- <method name="ReloadConfig">
- </method>
- <signal name="NameOwnerChanged">
- <arg type="s"/>
- <arg type="s"/>
- <arg type="s"/>
- </signal>
- <signal name="NameLost">
- <arg type="s"/>
- </signal>
- <signal name="NameAcquired">
- <arg type="s"/>
- </signal>
- </interface>
-</node>
diff --git a/dbus-glib-1-uninstalled.pc.in b/dbus-glib-1-uninstalled.pc.in
deleted file mode 100644
index 150db5f..0000000
--- a/dbus-glib-1-uninstalled.pc.in
+++ /dev/null
@@ -1,12 +0,0 @@
-prefix=@prefix@
-exec_prefix=@exec_prefix@
-libdir=@libdir@
-includedir=@includedir@
-
-Name: dbus-glib
-Description: GLib integration for the free desktop message bus
-Version: @VERSION@
-Requires: dbus-1 glib-2.0 gobject-2.0
-Libs: ${pc_top_builddir}/${pcfiledir}/dbus/libdbus-glib-1.la
-Cflags: -I${pc_top_builddir}/${pcfiledir}
-
diff --git a/dbus-glib-1.pc.in b/dbus-glib-1.pc.in
deleted file mode 100644
index 599901a..0000000
--- a/dbus-glib-1.pc.in
+++ /dev/null
@@ -1,13 +0,0 @@
-prefix=@prefix@
-exec_prefix=@exec_prefix@
-libdir=@libdir@
-includedir=@includedir@
-
-Name: dbus-glib
-Description: GLib integration for the free desktop message bus
-Version: @VERSION@
-Requires: dbus-1 glib-2.0 gobject-2.0
-Libs: -L${libdir} -ldbus-glib-1
-Cflags: -I${includedir}/dbus-1.0
-
-
diff --git a/dbus/.cvsignore b/dbus/.cvsignore
deleted file mode 100644
index 91ea246..0000000
--- a/dbus/.cvsignore
+++ /dev/null
@@ -1,13 +0,0 @@
-.deps
-.libs
-Makefile
-Makefile.in
-*.lo
-*.la
-dbus-glib-test
-dbus-binding-tool
-dbus-glib-error-switch.h
-*.bb
-*.bbg
-*.da
-*.gcov
diff --git a/dbus/Makefile.am b/dbus/Makefile.am
deleted file mode 100644
index a51750e..0000000
--- a/dbus/Makefile.am
+++ /dev/null
@@ -1,146 +0,0 @@
-SUBDIRS = . examples
-
-AM_CPPFLAGS = \
- -I$(top_srcdir) \
- -I$(top_builddir) \
- $(DBUS_CFLAGS) \
- $(DBUS_GLIB_CFLAGS) \
- $(DBUS_GLIB_TOOL_CFLAGS) \
- -DDBUS_COMPILATION=1 \
- -DDBUS_LOCALEDIR=\"$(prefix)/@DATADIRNAME@/locale\"
-
-lib_LTLIBRARIES=libdbus-glib-1.la
-
-CLEANFILES = $(BUILT_SOURCES)
-
-DBUS_GLIB_INTERNALS = \
- dbus-gtype-specialized.c \
- dbus-gtype-specialized-priv.h \
- dbus-gutils.c \
- dbus-gutils.h \
- dbus-gsignature.c \
- dbus-gsignature.h \
- dbus-gvalue.h \
- dbus-gvalue-utils.c \
- dbus-gvalue-utils.h
-
-libdbus_glib_1_la_SOURCES = \
- dbus-glib.c \
- dbus-gmarshal.c \
- dbus-gmarshal.h \
- dbus-gobject.c \
- dbus-gobject.h \
- dbus-gproxy.c \
- dbus-gtest.c \
- dbus-gtest.h \
- dbus-gvalue.c \
- dbus-gvalue.h \
- dbus-gvalue-parse-variant.c \
- dbus-gthread.c \
- $(DBUS_GLIB_INTERNALS)
-
-libdbus_glib_HEADERS = \
- dbus-gtype-specialized.h \
- dbus-gvalue-parse-variant.h \
- dbus-glib.h \
- dbus-glib-lowlevel.h \
- $(NULL)
-
-libdbus_glibdir = $(includedir)/dbus-1.0/dbus
-
-libdbus_glib_1_la_LIBADD = \
- $(top_builddir)/dbus-gmain/libdbus-gmain.la \
- $(DBUS_LIBS) \
- $(DBUS_GLIB_LIBS) \
- $(NULL)
-## don't export symbols that start with "_" (we use this
-## convention for internal symbols)
-libdbus_glib_1_la_LDFLAGS= -export-symbols-regex "^[^_].*" -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) -no-undefined
-
-# convenience lib used here and by dbus-viewer
-noinst_LTLIBRARIES = libdbus-gtool.la
-
-libdbus_gtool_la_SOURCES = $(DBUS_GLIB_INTERNALS) \
- dbus-gidl.c \
- dbus-gidl.h \
- dbus-gloader-expat.c \
- dbus-gparser.c \
- dbus-gparser.h
-
-libdbus_gtool_la_LIBADD = \
- -lexpat \
- $(DBUS_LIBS) \
- $(DBUS_GLIB_LIBS) \
- libdbus-glib-1.la \
- $(NULL)
-
-bin_PROGRAMS=dbus-binding-tool
-
-dbus_binding_tool_SOURCES = \
- dbus-binding-tool-glib.h \
- dbus-binding-tool-glib.c \
- dbus-glib-tool.h \
- dbus-glib-tool.c
-
-dbus_binding_tool_LDADD= $(builddir)/libdbus-gtool.la $(builddir)/libdbus-glib-1.la $(DBUS_LIBS) $(DBUS_GLIB_LIBS) -lexpat
-
-## we just rebuilt these manually and check them into cvs; easier than
-## convincing automake/make to do this properly
-regenerate-built-sources:
- @GLIB_GENMARSHAL@ --prefix=_dbus_g_marshal dbus-gmarshal.list --header > dbus-gmarshal.h && \
- echo '#include <config.h>' > dbus-gmarshal.c && \
- echo '#include "dbus-gmarshal.h"' >> dbus-gmarshal.c && \
- @GLIB_GENMARSHAL@ --prefix=_dbus_g_marshal dbus-gmarshal.list --body >> dbus-gmarshal.c
-
-
-completiondir = $(sysconfdir)/bash_completion.d
-if DBUS_BASH_COMPLETION
-libexec_PROGRAMS=dbus-bash-completion-helper
-completion_SCRIPTS=dbus-bash-completion.sh
-endif
-
-dbus-bash-completion.sh : dbus-bash-completion.sh.in
- @sed -e "s|\@libexecdir\@|$(libexecdir)|" $< > $@
-CLEANFILES += dbus-bash-completion.sh
-
-dbus_bash_completion_helper_SOURCES = \
- dbus-bash-completion-helper.c
-dbus_bash_completion_helper_LDADD=$(builddir)/libdbus-gtool.la -lexpat $(builddir)/libdbus-glib-1.la $(DBUS_LIBS) $(DBUS_GLIB_LIBS)
-
-
-EXTRA_DIST=dbus-gmarshal.list dbus-bash-completion.sh.in
-
-Android.mk: Makefile.am
- androgenizer -:PROJECT dbus-glib -:SHARED libdbus-glib-1 -:TAGS eng debug \
- -:REL_TOP $(top_srcdir) -:ABS_TOP $(abs_top_srcdir) \
- -:SOURCES $(libdbus_glib_1_la_SOURCES) \
- -:CFLAGS $(DEFS) $(CFLAGS) $(DEFAULT_INCLUDES) $(AM_CPPFLAGS) $(AM_CFLAGS) \
- -:CPPFLAGS $(CPPFLAGS) $(AM_CPPFLAGS) \
- -:LDFLAGS $(libdbus_glib_1_la_LIBADD) $(libdbus_glib_1_la_LDFLAGS) \
- > $@
-
-if DBUS_BUILD_TESTS
-
-## we use noinst_PROGRAMS not check_PROGRAMS for TESTS so that we
-## build even when not doing "make check"
-noinst_PROGRAMS= $(TESTS)
-
-## note that TESTS has special meaning (stuff to use in make check)
-## so if adding tests not to be run in make check, don't add them to
-## TESTS
-TESTS_ENVIRONMENT=DBUS_TEST_DATA=$(top_builddir)/test/data DBUS_TEST_HOMEDIR=$(top_builddir)/dbus
-TESTS=dbus-glib-test
-
-## FIXME we aren't running dbus-glib-tool --self-test
-
-dbus_glib_test_SOURCES= \
- dbus-gtest-main.c
-
-dbus_glib_test_LDADD= $(builddir)/libdbus-glib-1.la
-
-else
-### not building tests
-TESTS=
-
-endif
-
diff --git a/dbus/dbus-bash-completion-helper.c b/dbus/dbus-bash-completion-helper.c
deleted file mode 100644
index ac79039..0000000
--- a/dbus/dbus-bash-completion-helper.c
+++ /dev/null
@@ -1,507 +0,0 @@
-/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
-/* dbus-bash-completion-helper.c Bash Completion helper routines
- *
- * Copyright (C) 2008 David Zeuthen <davidz@redhat.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- */
-
-#include <config.h>
-#include <ctype.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include <dbus/dbus.h>
-#include <glib.h>
-#include "dbus-gparser.h"
-
-static void
-print_services (DBusConnection *connection)
-{
- DBusMessage *message;
- DBusMessage *reply;
- DBusError error;
- DBusMessageIter iter;
- DBusMessageIter iter_array;
- const char *name;
-
- /* list both active and activatable names (the shell will sort and
- * uniquify them) - also avoid names that are not well-known
- * (e.g. :1.42).
- */
-
- message = dbus_message_new_method_call (DBUS_SERVICE_DBUS,
- DBUS_PATH_DBUS,
- DBUS_INTERFACE_DBUS,
- "ListNames");
- dbus_error_init (&error);
- reply = dbus_connection_send_with_reply_and_block (connection,
- message,
- -1,
- &error);
- dbus_message_unref (message);
- dbus_message_iter_init (reply, &iter);
- dbus_message_iter_recurse (&iter, &iter_array);
- while (dbus_message_iter_get_arg_type (&iter_array) != DBUS_TYPE_INVALID)
- {
- dbus_message_iter_get_basic (&iter_array, &name);
- if (name[0] != ':')
- printf ("%s \n", name);
- dbus_message_iter_next (&iter_array);
- }
- dbus_message_unref (reply);
-
- message = dbus_message_new_method_call (DBUS_SERVICE_DBUS,
- DBUS_PATH_DBUS,
- DBUS_INTERFACE_DBUS,
- "ListActivatableNames");
- dbus_error_init (&error);
- reply = dbus_connection_send_with_reply_and_block (connection,
- message,
- -1,
- &error);
- dbus_message_unref (message);
- dbus_message_iter_init (reply, &iter);
- dbus_message_iter_recurse (&iter, &iter_array);
- while (dbus_message_iter_get_arg_type (&iter_array) != DBUS_TYPE_INVALID)
- {
- dbus_message_iter_get_basic (&iter_array, &name);
- printf ("%s \n", name);
- dbus_message_iter_next (&iter_array);
- }
- dbus_message_unref (reply);
-}
-
-static gboolean
-have_option (char **tokens, const char *option)
-{
- int n;
- for (n = 0; tokens[n] != NULL; n++)
- if (strcmp (tokens[n], option) == 0)
- return TRUE;
- return FALSE;
-}
-
-static gboolean
-have_option_with_value (char **tokens, const char *option, const char **value)
-{
- int n;
- for (n = 0; tokens[n] != NULL; n++)
- {
- if (g_str_has_prefix (tokens[n], option))
- {
- if (strlen (tokens[n]) > strlen (option))
- *value = tokens[n] + strlen (option);
- return TRUE;
- }
- }
- return FALSE;
-}
-
-static void
-print_objects (DBusConnection *connection, const char *service_name, const char *cur)
-{
- DBusMessage *message;
- DBusMessage *reply;
- DBusError error;
- DBusMessageIter iter;
- const char *introspection_xml;
- NodeInfo *root;
- GSList *nodes;
- GSList *l;
-
- if (cur == NULL)
- cur = "/";
-
- message = dbus_message_new_method_call (service_name,
- cur,
- DBUS_INTERFACE_INTROSPECTABLE,
- "Introspect");
- dbus_error_init (&error);
- reply = dbus_connection_send_with_reply_and_block (connection,
- message,
- -1,
- &error);
- dbus_message_unref (message);
- dbus_message_iter_init (reply, &iter);
- dbus_message_iter_get_basic (&iter, &introspection_xml);
-
- root = description_load_from_string (introspection_xml, strlen (introspection_xml), NULL);
- nodes = node_info_get_nodes (root);
-
- if (g_slist_length (node_info_get_interfaces (root)) > 0)
- printf ("%s \n", cur);
-
- for (l = nodes; l != NULL; l = l->next)
- {
- NodeInfo *node = (NodeInfo *) l->data;
- const char *name;
- char *new_path;
-
- name = node_info_get_name (node);
- if (strcmp (cur, "/") == 0)
- new_path = g_strdup_printf ("/%s", name);
- else
- new_path = g_strdup_printf ("%s/%s", cur, name);
-
- print_objects (connection, service_name, new_path);
-
- g_free (new_path);
- }
- node_info_unref (root);
-
- dbus_message_unref (reply);
-}
-
-static gboolean
-is_object_path_with_interfaces (DBusConnection *connection, const char *service_name, const char *object_path)
-{
- DBusMessage *message;
- DBusMessage *reply;
- DBusError error;
- DBusMessageIter iter;
- const char *introspection_xml;
- NodeInfo *root;
- gboolean ret;
-
- ret = FALSE;
-
- message = dbus_message_new_method_call (service_name,
- object_path,
- DBUS_INTERFACE_INTROSPECTABLE,
- "Introspect");
- dbus_error_init (&error);
- reply = dbus_connection_send_with_reply_and_block (connection,
- message,
- -1,
- &error);
- dbus_message_unref (message);
- dbus_message_iter_init (reply, &iter);
- dbus_message_iter_get_basic (&iter, &introspection_xml);
-
- root = description_load_from_string (introspection_xml, strlen (introspection_xml), NULL);
-
- if (g_slist_length (node_info_get_interfaces (root)) > 0)
- ret = TRUE;
-
- node_info_unref (root);
- dbus_message_unref (reply);
-
- return ret;
-}
-
-static void
-print_methods (DBusConnection *connection, const char *service_name, const char *object_path)
-{
- DBusMessage *message;
- DBusMessage *reply;
- DBusError error;
- DBusMessageIter iter;
- const char *introspection_xml;
- NodeInfo *root;
- GSList *interfaces;
- GSList *l;
-
- message = dbus_message_new_method_call (service_name,
- object_path,
- DBUS_INTERFACE_INTROSPECTABLE,
- "Introspect");
- dbus_error_init (&error);
- reply = dbus_connection_send_with_reply_and_block (connection,
- message,
- -1,
- &error);
- dbus_message_unref (message);
- dbus_message_iter_init (reply, &iter);
- dbus_message_iter_get_basic (&iter, &introspection_xml);
-
- root = description_load_from_string (introspection_xml, strlen (introspection_xml), NULL);
- interfaces = node_info_get_interfaces (root);
- for (l = interfaces; l != NULL; l = l->next)
- {
- InterfaceInfo *interface = (InterfaceInfo *) l->data;
- GSList *methods;
- GSList *ll;
- methods = interface_info_get_methods (interface);
- for (ll = methods; ll != NULL; ll = ll->next)
- {
- MethodInfo *method = (MethodInfo *) ll->data;
- printf ("%s.%s \n", interface_info_get_name (interface), method_info_get_name (method));
- }
- }
- node_info_unref (root);
- dbus_message_unref (reply);
-}
-
-static void
-print_signature (DBusConnection *connection, const char *service_name, const char *object_path, const char *method)
-{
- DBusMessage *message;
- DBusMessage *reply;
- DBusError error;
- DBusMessageIter iter;
- const char *introspection_xml;
- NodeInfo *root;
- GSList *interfaces;
- GSList *l;
- char *s;
- char *method_name;
- char *interface_name;
- int n;
-
- method_name = NULL;
- interface_name = NULL;
-
- s = strrchr (method, '.');
- if (s == NULL || strlen (s) < 2 || s - method < 1)
- goto fail;
- method_name = g_strdup (s + 1);
- interface_name = g_strndup (method, s - method);
- printf (" \n");
-
- message = dbus_message_new_method_call (service_name,
- object_path,
- DBUS_INTERFACE_INTROSPECTABLE,
- "Introspect");
- dbus_error_init (&error);
- reply = dbus_connection_send_with_reply_and_block (connection,
- message,
- -1,
- &error);
- dbus_message_unref (message);
- dbus_message_iter_init (reply, &iter);
- dbus_message_iter_get_basic (&iter, &introspection_xml);
-
- root = description_load_from_string (introspection_xml, strlen (introspection_xml), NULL);
- interfaces = node_info_get_interfaces (root);
- for (l = interfaces; l != NULL; l = l->next)
- {
- InterfaceInfo *interface = (InterfaceInfo *) l->data;
-
- if (strcmp (interface_name, interface_info_get_name (interface)) == 0)
- {
- GSList *methods;
- GSList *ll;
- methods = interface_info_get_methods (interface);
- for (ll = methods; ll != NULL; ll = ll->next)
- {
- MethodInfo *method = (MethodInfo *) ll->data;
- if (strcmp (method_name, method_info_get_name (method)) == 0)
- {
- GSList *args;
- GSList *lll;
- args = method_info_get_args (method);
- for (lll = args, n = 0; lll != NULL; lll = lll->next, n++)
- {
- ArgInfo *arg = (ArgInfo *) lll->data;
- printf ("# %s: arg %d: %s (%s) \n",
- arg_info_get_direction (arg) == ARG_IN ? " IN" : "OUT",
- n,
- arg_info_get_name (arg),
- arg_info_get_type (arg));
- }
- break;
- }
- }
- }
- }
- node_info_unref (root);
- dbus_message_unref (reply);
- fail:
- g_free (method_name);
- g_free (interface_name);
-}
-
-
-static int
-complete_dbus_send (char *str)
-{
- int ret;
- char **tokens;
- int num_tokens;
- const char *cur;
- gboolean have_system;
- gboolean have_session;
- gboolean have_print_reply;
- gboolean have_dest;
- DBusConnection *connection;
- DBusBusType bus_type;
- DBusError error;
- const char *target_service;
- const char *object_path;
- const char *method;
- int n;
- int object_path_index;
-
- ret = 1;
- connection = NULL;
- target_service = NULL;
-
- tokens = g_strsplit (str, " ", 0);
- num_tokens = g_strv_length (tokens);
- if (num_tokens >= 1) {
- cur = tokens[num_tokens - 1];
- } else {
- cur = "";
- }
-
- have_system = have_option (tokens, "--system");
- have_session = have_option (tokens, "--session");
- have_print_reply = have_option (tokens, "--print-reply");
- have_dest = have_option_with_value (tokens, "--dest=", &target_service);
-
- if (!have_print_reply)
- printf ("--print-reply \n");
-
- if (!have_system && !have_session)
- {
- printf ("--system \n");
- printf ("--session \n");
- goto done;
- }
-
- if (!have_dest && !g_str_has_prefix (cur, "--dest="))
- {
- printf ("--dest=\n");
- goto done;
- }
-
- if (have_system || have_session)
- {
- bus_type = have_system ? DBUS_BUS_SYSTEM : DBUS_BUS_SESSION;
-
- dbus_error_init (&error);
- connection = dbus_bus_get (bus_type, &error);
- if (connection == NULL)
- {
- fprintf (stderr, "Failed to open connection to %s message bus: %s: %s\n",
- (bus_type == DBUS_BUS_SYSTEM) ? "system" : "session",
- error.name, error.message);
- dbus_error_free (&error);
- goto fail;
- }
- }
-
- if (connection != NULL && g_str_has_prefix (cur, "--dest="))
- {
- print_services (connection);
- goto done;
- }
-
- /* see if we have an object path */
- object_path = NULL;
- object_path_index = 0;
- if (connection != NULL && target_service != NULL)
- {
- for (n = 0; tokens[n] != NULL; n++)
- {
- if (tokens[n] == cur)
- continue;
-
- if (*(tokens[n]) == '/')
- {
- if (is_object_path_with_interfaces (connection, target_service, tokens[n]))
- {
- object_path = tokens[n];
- object_path_index = n;
- }
- }
- }
- }
-
- /* if we have a connection and a destination but no object path, go ahead and list the object paths */
- if (connection != NULL && target_service != NULL && object_path == NULL)
- {
- print_objects (connection, target_service, NULL);
- goto done;
- }
-
- /* see if we have a method; it's directly after the object_path */
- method = NULL;
- if (connection != NULL && target_service != NULL && object_path != NULL)
- {
- if ((object_path_index + 1 < num_tokens - 1) &&
- (strlen (tokens[object_path_index + 1]) > 0) &&
- !(strcmp (cur, tokens[object_path_index + 1]) == 0))
- method = tokens[object_path_index + 1];
- }
-
- /* if we have connection, destination and object path but no method yet, list the methods */
- if (connection != NULL && target_service != NULL && object_path != NULL && method == NULL)
- {
- print_methods (connection, target_service, object_path);
- goto done;
- }
-
- /* print signature as comment */
- if (connection != NULL && target_service != NULL && object_path != NULL && method != NULL)
- {
- print_signature (connection, target_service, object_path, method);
- }
-
- done:
- ret = 0;
-
- fail:
-
- g_strfreev (tokens);
-
- if (connection != NULL)
- dbus_connection_unref (connection);
- return ret;
-}
-
-int
-main (int argc, char *argv[])
-{
- int ret;
- char *cur;
- gboolean dbus_send;
-
- ret = 1;
- dbus_send = FALSE;
-
- if (argc != 3)
- {
- fprintf (stderr, "invalid use\n");
- goto out;
- }
-
- if (strcmp (argv[1], "dbus-send") == 0)
- {
- dbus_send = TRUE;
- }
- else
- {
- fprintf (stderr, "unknown program '%s'\n", argv[1]);
- goto out;
- }
-
- if (strlen (argv[2]) < strlen (argv[1]) + 1)
- {
- fprintf (stderr, "error");
- goto out;
- }
-
- cur = argv[2] + strlen (argv[1]) + 1;
-
- if (dbus_send)
- ret = complete_dbus_send (cur);
-
- out:
- return ret;
-}
diff --git a/dbus/dbus-bash-completion.sh.in b/dbus/dbus-bash-completion.sh.in
deleted file mode 100644
index a7751da..0000000
--- a/dbus/dbus-bash-completion.sh.in
+++ /dev/null
@@ -1,21 +0,0 @@
-
-# Check for bash
-[ -z "$BASH_VERSION" ] && return
-
-################################################################################
-
-__dbus_send() {
- local IFS=$'\n'
- local cur="${COMP_WORDS[COMP_CWORD]}"
-
- # --name=value style option
- if [[ "$cur" == *=* ]] ; then
- cur=${cur/*=/}
- fi
-
- COMPREPLY=($(compgen -W "$(@libexecdir@/dbus-bash-completion-helper dbus-send ${COMP_WORDS[@]:0})" -- $cur))
-}
-
-################################################################################
-
-complete -o nospace -F __dbus_send dbus-send
diff --git a/dbus/dbus-binding-tool-glib.c b/dbus/dbus-binding-tool-glib.c
deleted file mode 100644
index f0b6bf6..0000000
--- a/dbus/dbus-binding-tool-glib.c
+++ /dev/null
@@ -1,1701 +0,0 @@
-/* -*- mode: C; c-file-style: "gnu" -*- */
-/* dbus-binding-tool-glib.c: Output C glue
- *
- * Copyright (C) 2003, 2004, 2005 Red Hat, Inc.
- * Copyright (C) 2005 Nokia
- *
- * Licensed under the Academic Free License version 2.1
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- */
-
-#include <config.h>
-#include "dbus/dbus-glib.h"
-#include "dbus-gidl.h"
-#include "dbus-gparser.h"
-#include "dbus-gutils.h"
-#include "dbus-gtype-specialized.h"
-#include "dbus-gsignature.h"
-#include "dbus-gvalue-utils.h"
-#include "dbus-glib-tool.h"
-#include "dbus-binding-tool-glib.h"
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-
-/* Remember to grep for ->format_version in the code if you change this,
- * most changes should be in dbus-gobject.c. */
-#define FORMAT_VERSION 1
-
-#define MARSHAL_PREFIX "dbus_glib_marshal_"
-
-typedef struct
-{
- gboolean ignore_unsupported;
- const char* prefix;
- GIOChannel *channel;
-
- GError **error;
-
- GHashTable *generated;
- GString *blob;
- GString *signal_blob;
- GString *property_blob;
- guint count;
-} DBusBindingToolCData;
-
-static gboolean gather_marshallers (BaseInfo *base, DBusBindingToolCData *data, GError **error);
-static gboolean generate_glue_toplevel (BaseInfo *base, DBusBindingToolCData *data, GError **error);
-static gboolean generate_glue (BaseInfo *base, DBusBindingToolCData *data, GError **error);
-static gboolean generate_client_glue (BaseInfo *base, DBusBindingToolCData *data, GError **error);
-
-static const char *
-dbus_g_type_get_marshal_name (GType gtype)
-{
- switch (G_TYPE_FUNDAMENTAL (gtype))
- {
- case G_TYPE_NONE:
- return "NONE";
- case G_TYPE_BOOLEAN:
- return "BOOLEAN";
- case G_TYPE_UCHAR:
- return "UCHAR";
- case G_TYPE_INT:
- return "INT";
- case G_TYPE_UINT:
- return "UINT";
- case G_TYPE_INT64:
- return "INT64";
- case G_TYPE_UINT64:
- return "UINT64";
- case G_TYPE_DOUBLE:
- return "DOUBLE";
- case G_TYPE_STRING:
- return "STRING";
- case G_TYPE_POINTER:
- return "POINTER";
- case G_TYPE_BOXED:
- return "BOXED";
- case G_TYPE_OBJECT:
- return "OBJECT";
- default:
- return NULL;
- }
-}
-
-/* This entire function is kind of...ugh. */
-static const char *
-dbus_g_type_get_c_name (GType gtype)
-{
- GType subtype;
- if (dbus_g_type_is_struct (gtype))
- {
- return "GValueArray";
- }
- if (dbus_g_type_is_collection (gtype))
- {
- subtype = dbus_g_type_get_collection_specialization(gtype);
- if (_dbus_g_type_is_fixed (subtype))
- return "GArray";
- else
- return "GPtrArray";
- }
-
- if (dbus_g_type_is_map (gtype))
- return "GHashTable";
-
- if (g_type_is_a (gtype, G_TYPE_STRING))
- return "char *";
-
- /* This one is even more hacky...we get an extra *
- * because G_TYPE_STRV is a G_TYPE_BOXED
- */
- if (g_type_is_a (gtype, G_TYPE_STRV))
- return "char *";
-
- if (g_type_is_a (gtype, DBUS_TYPE_G_OBJECT_PATH))
- return "char";
-
- if (g_type_is_a (gtype, DBUS_TYPE_G_SIGNATURE))
- return "char";
-
- return g_type_name (gtype);
-}
-
-static gboolean
-compute_gsignature (MethodInfo *method, GType *rettype, GArray **params, GError **error)
-{
- GSList *elt;
- GType retval_type;
- GArray *ret;
- gboolean is_async;
- const char *arg_type;
- gboolean retval_signals_error;
-
- is_async = method_info_get_annotation (method, DBUS_GLIB_ANNOTATION_ASYNC) != NULL;
- retval_signals_error = FALSE;
-
- ret = g_array_new (TRUE, TRUE, sizeof (GType));
-
- if (is_async)
- retval_type = G_TYPE_NONE;
- else
- {
- gboolean found_retval;
-
- /* Look for return value */
- found_retval = FALSE;
- for (elt = method_info_get_args (method); elt; elt = elt->next)
- {
- ArgInfo *arg = elt->data;
- const char *returnval_annotation;
-
- returnval_annotation = arg_info_get_annotation (arg, DBUS_GLIB_ANNOTATION_RETURNVAL);
- if (returnval_annotation != NULL)
- {
- arg_type = arg_info_get_type (arg);
- retval_type = _dbus_gtype_from_signature (arg_type, FALSE);
- if (retval_type == G_TYPE_INVALID)
- goto invalid_type;
- found_retval = TRUE;
- if (!strcmp (returnval_annotation, "error"))
- retval_signals_error = TRUE;
- break;
- }
- }
- if (!found_retval)
- {
- retval_type = G_TYPE_BOOLEAN;
- retval_signals_error = TRUE;
- }
- }
-
- *rettype = retval_type;
-
- /* Handle all input arguments */
- for (elt = method_info_get_args (method); elt; elt = elt->next)
- {
- ArgInfo *arg = elt->data;
- if (arg_info_get_direction (arg) == ARG_IN)
- {
- GType gtype;
-
- arg_type = arg_info_get_type (arg);
- gtype = _dbus_gtype_from_signature (arg_type, FALSE);
- if (gtype == G_TYPE_INVALID)
- goto invalid_type;
-
- g_array_append_val (ret, gtype);
- }
- }
-
- if (!is_async)
- {
- /* Append pointer for each out arg storage */
- for (elt = method_info_get_args (method); elt; elt = elt->next)
- {
- ArgInfo *arg = elt->data;
-
- /* Skip return value */
- if (arg_info_get_annotation (arg, DBUS_GLIB_ANNOTATION_RETURNVAL) != NULL)
- continue;
-
- if (arg_info_get_direction (arg) == ARG_OUT)
- {
- GType gtype;
- arg_type = arg_info_get_type (arg);
- gtype = _dbus_gtype_from_signature (arg_type, FALSE);
- if (gtype == G_TYPE_INVALID)
- goto invalid_type;
- /* We actually just need a pointer for the return value
- storage */
- gtype = G_TYPE_POINTER;
- g_array_append_val (ret, gtype);
- }
- }
-
- if (retval_signals_error)
- {
- /* Final GError parameter */
- GType gtype = G_TYPE_POINTER;
- g_array_append_val (ret, gtype);
- }
- }
- else
- {
- /* Context pointer */
- GType gtype = G_TYPE_POINTER;
- g_array_append_val (ret, gtype);
- }
-
- *params = ret;
- return TRUE;
-
- invalid_type:
- g_set_error (error,
- DBUS_BINDING_TOOL_ERROR,
- DBUS_BINDING_TOOL_ERROR_UNSUPPORTED_CONVERSION,
- "Unsupported conversion from D-BUS type %s to glib-genmarshal type",
- arg_type);
- return FALSE;
-}
-
-
-static char *
-compute_marshaller (MethodInfo *method, GError **error)
-{
- GArray *signature;
- GType rettype;
- const char *marshal_name;
- GString *ret;
- guint i;
-
- if (!compute_gsignature (method, &rettype, &signature, error))
- return NULL;
-
- ret = g_string_new ("");
- marshal_name = dbus_g_type_get_marshal_name (rettype);
- g_assert (marshal_name != NULL);
- g_string_append (ret, marshal_name);
- g_string_append_c (ret, ':');
- for (i = 0; i < signature->len; i++)
- {
- marshal_name = dbus_g_type_get_marshal_name (g_array_index (signature, GType, i));
- g_assert (marshal_name != NULL);
- g_string_append (ret, marshal_name);
- if (i < signature->len - 1)
- g_string_append_c (ret, ',');
- }
- if (signature->len == 0)
- {
- marshal_name = dbus_g_type_get_marshal_name (G_TYPE_NONE);
- g_assert (marshal_name != NULL);
- g_string_append (ret, marshal_name);
- }
- g_array_free (signature, TRUE);
- return g_string_free (ret, FALSE);
-}
-
-static char *
-compute_marshaller_name (MethodInfo *method, const char *prefix, GError **error)
-{
- GString *ret;
- GArray *signature;
- GType rettype;
- const char *marshal_name;
- guint i;
-
- if (!compute_gsignature (method, &rettype, &signature, error))
- return NULL;
-
- ret = g_string_new (MARSHAL_PREFIX);
- g_string_append (ret, prefix);
- g_string_append_c (ret, '_');
-
- marshal_name = dbus_g_type_get_marshal_name (rettype);
- g_assert (marshal_name != NULL);
- g_string_append (ret, marshal_name);
- g_string_append (ret, "__");
- for (i = 0; i < signature->len; i++)
- {
- marshal_name = dbus_g_type_get_marshal_name (g_array_index (signature, GType, i));
- g_assert (marshal_name != NULL);
- g_string_append (ret, marshal_name);
- if (i < signature->len - 1)
- g_string_append_c (ret, '_');
- }
- if (signature->len == 0)
- {
- marshal_name = dbus_g_type_get_marshal_name (G_TYPE_NONE);
- g_assert (marshal_name != NULL);
- g_string_append (ret, marshal_name);
- }
- g_array_free (signature, TRUE);
- return g_string_free (ret, FALSE);
-}
-
-static gboolean
-gather_marshallers_list (GSList *list, DBusBindingToolCData *data, GError **error)
-{
- GSList *tmp;
-
- tmp = list;
- while (tmp != NULL)
- {
- if (!gather_marshallers (tmp->data, data, error))
- return FALSE;
- tmp = tmp->next;
- }
- return TRUE;
-}
-
-static gboolean
-gather_marshallers (BaseInfo *base, DBusBindingToolCData *data, GError **error)
-{
- if (base_info_get_type (base) == INFO_TYPE_NODE)
- {
- if (!gather_marshallers_list (node_info_get_nodes ((NodeInfo *) base),
- data, error))
- return FALSE;
- if (!gather_marshallers_list (node_info_get_interfaces ((NodeInfo *) base),
- data, error))
- return FALSE;
- }
- else
- {
- InterfaceInfo *interface;
- GSList *methods;
- GSList *tmp;
- const char *interface_c_name;
-
- interface = (InterfaceInfo *) base;
- interface_c_name = interface_info_get_annotation (interface, DBUS_GLIB_ANNOTATION_C_SYMBOL);
- if (interface_c_name == NULL)
- {
- if (!data->prefix)
- return TRUE;
- }
-
- methods = interface_info_get_methods (interface);
-
- /* Generate the necessary marshallers for the methods. */
-
- for (tmp = methods; tmp != NULL; tmp = g_slist_next (tmp))
- {
- MethodInfo *method;
- char *marshaller_name;
-
- method = (MethodInfo *) tmp->data;
-
- marshaller_name = compute_marshaller (method, error);
- if (!marshaller_name)
- return FALSE;
-
- if (g_hash_table_lookup (data->generated, marshaller_name))
- {
- g_free (marshaller_name);
- continue;
- }
-
- g_hash_table_insert (data->generated, marshaller_name, NULL);
- }
-
- }
- return TRUE;
-}
-
-static gboolean
-generate_glue_list (GSList *list, DBusBindingToolCData *data, GError **error)
-{
- GSList *tmp;
-
- tmp = list;
- while (tmp != NULL)
- {
- if (!generate_glue (tmp->data, data, error))
- return FALSE;
- tmp = tmp->next;
- }
- return TRUE;
-}
-
-#define WRITE_OR_LOSE(x) do { gsize bytes_written; if (!g_io_channel_write_chars (channel, x, -1, &bytes_written, error)) goto io_lose; } while (0)
-
-static gboolean
-write_printf_to_iochannel (const char *fmt, GIOChannel *channel, GError **error, ...)
-{
- char *str;
- va_list args;
- GIOStatus status;
- gsize written;
- gboolean ret;
-
- va_start (args, error);
-
- str = g_strdup_vprintf (fmt, args);
- if ((status = g_io_channel_write_chars (channel, str, -1, &written, error)) == G_IO_STATUS_NORMAL)
- ret = TRUE;
- else
- ret = FALSE;
-
- g_free (str);
-
- va_end (args);
-
- return ret;
-}
-
-static gboolean
-write_quoted_string (GIOChannel *channel, GString *string, GError **error)
-{
- guint i;
-
- WRITE_OR_LOSE ("\"");
- for (i = 0; i < string->len; i++)
- {
- if (string->str[i] != '\0')
- {
- if (!g_io_channel_write_chars (channel, string->str + i, 1, NULL, error))
- return FALSE;
- }
- else
- {
- if (!g_io_channel_write_chars (channel, "\\0", -1, NULL, error))
- return FALSE;
- }
- }
- WRITE_OR_LOSE ("\\0\"");
- return TRUE;
- io_lose:
- return FALSE;
-}
-
-static gboolean
-generate_glue_toplevel (BaseInfo *base, DBusBindingToolCData *data, GError **error)
-{
- GString *object_introspection_data_blob;
- GIOChannel *channel;
-
- channel = data->channel;
-
- object_introspection_data_blob = g_string_new_len ("", 0);
- data->blob = object_introspection_data_blob;
- data->count = 0;
-
- data->signal_blob = g_string_new_len ("", 0);
- data->property_blob = g_string_new_len ("", 0);
-
- if (!write_printf_to_iochannel ("static const DBusGMethodInfo dbus_glib_%s_methods[] = {\n", channel, error, data->prefix))
- goto io_lose;
-
- if (!generate_glue_list (node_info_get_nodes ((NodeInfo *) base),
- data, error))
- return FALSE;
- if (!generate_glue_list (node_info_get_interfaces ((NodeInfo *) base),
- data, error))
- return FALSE;
-
- WRITE_OR_LOSE ("};\n\n");
- /* Information about the object. */
-
- if (!write_printf_to_iochannel ("const DBusGObjectInfo dbus_glib_%s_object_info = { %d,\n",
- channel, error, data->prefix, FORMAT_VERSION))
- goto io_lose;
- if (!write_printf_to_iochannel (" dbus_glib_%s_methods,\n", channel, error, data->prefix))
- goto io_lose;
- if (!write_printf_to_iochannel (" %d,\n", channel, error, data->count))
- goto io_lose;
- if (!write_quoted_string (channel, object_introspection_data_blob, error))
- goto io_lose;
- WRITE_OR_LOSE (",\n");
- if (!write_quoted_string (channel, data->signal_blob, error))
- goto io_lose;
- WRITE_OR_LOSE (",\n");
- if (!write_quoted_string (channel, data->property_blob, error))
- goto io_lose;
- WRITE_OR_LOSE ("\n};\n\n");
- g_string_free (object_introspection_data_blob, TRUE);
- g_string_free (data->signal_blob, TRUE);
- g_string_free (data->property_blob, TRUE);
- data->signal_blob = NULL;
- data->property_blob = NULL;
- return TRUE;
-io_lose:
- return FALSE;
-}
-
-static gboolean
-generate_glue (BaseInfo *base, DBusBindingToolCData *data, GError **error)
-{
- if (base_info_get_type (base) == INFO_TYPE_NODE)
- {
- if (!generate_glue_list (node_info_get_nodes ((NodeInfo *) base),
- data, error))
- return FALSE;
- if (!generate_glue_list (node_info_get_interfaces ((NodeInfo *) base),
- data, error))
- return FALSE;
- }
- else
- {
- GIOChannel *channel;
- InterfaceInfo *interface;
- GSList *methods;
- GSList *signals;
- GSList *properties;
- GSList *tmp;
- const char *interface_c_name;
- GString *object_introspection_data_blob;
-
- channel = data->channel;
- object_introspection_data_blob = data->blob;
-
- interface = (InterfaceInfo *) base;
- interface_c_name = interface_info_get_annotation (interface, DBUS_GLIB_ANNOTATION_C_SYMBOL);
- if (interface_c_name == NULL)
- {
- if (data->prefix == NULL)
- return TRUE;
- interface_c_name = data->prefix;
- }
-
- methods = interface_info_get_methods (interface);
-
- /* Table of marshalled methods. */
-
- for (tmp = methods; tmp != NULL; tmp = g_slist_next (tmp))
- {
- MethodInfo *method;
- char *marshaller_name;
- char *method_c_name;
- gboolean async = FALSE;
- GSList *args;
- gboolean found_retval = FALSE;
- guint found_out_args = 0;
-
- method = (MethodInfo *) tmp->data;
- method_c_name = g_strdup (method_info_get_annotation (method, DBUS_GLIB_ANNOTATION_C_SYMBOL));
- if (method_c_name == NULL)
- {
- char *method_name_uscored;
- method_name_uscored = _dbus_gutils_wincaps_to_uscore (method_info_get_name (method));
- method_c_name = g_strdup_printf ("%s_%s",
- interface_c_name,
- method_name_uscored);
- g_free (method_name_uscored);
- }
-
- if (!write_printf_to_iochannel (" { (GCallback) %s, ", channel, error,
- method_c_name))
- {
- g_free (method_c_name);
- goto io_lose;
- }
- g_free (method_c_name);
-
- marshaller_name = compute_marshaller_name (method, data->prefix, error);
- if (!marshaller_name)
- goto io_lose;
-
- if (!write_printf_to_iochannel ("%s, %d },\n", channel, error,
- marshaller_name,
- object_introspection_data_blob->len))
- {
- g_free (marshaller_name);
- goto io_lose;
- }
-
- if (method_info_get_annotation (method, DBUS_GLIB_ANNOTATION_ASYNC) != NULL)
- async = TRUE;
-
- /* Object method data blob format:
- * <iface>\0<name>\0(<argname>\0<argdirection>\0<argtype>\0)*\0
- */
-
- g_string_append (object_introspection_data_blob, interface_info_get_name (interface));
- g_string_append_c (object_introspection_data_blob, '\0');
-
- g_string_append (object_introspection_data_blob, method_info_get_name (method));
- g_string_append_c (object_introspection_data_blob, '\0');
-
- g_string_append_c (object_introspection_data_blob, async ? 'A' : 'S');
- g_string_append_c (object_introspection_data_blob, '\0');
-
- for (args = method_info_get_args (method); args; args = args->next)
- {
- ArgInfo *arg;
- char direction;
- const char *returnval_annotation;
-
- arg = args->data;
-
- g_string_append (object_introspection_data_blob, arg_info_get_name (arg));
- g_string_append_c (object_introspection_data_blob, '\0');
-
- switch (arg_info_get_direction (arg))
- {
- case ARG_IN:
- direction = 'I';
- break;
- case ARG_OUT:
- direction = 'O';
- found_out_args++;
- break;
- case ARG_INVALID:
- default:
- g_assert_not_reached ();
- direction = 0; /* silence gcc */
- break;
- }
- g_string_append_c (object_introspection_data_blob, direction);
- g_string_append_c (object_introspection_data_blob, '\0');
-
- if (arg_info_get_annotation (arg, DBUS_GLIB_ANNOTATION_CONST) != NULL)
- {
- if (arg_info_get_direction (arg) == ARG_IN)
- {
- g_set_error (error,
- DBUS_BINDING_TOOL_ERROR,
- DBUS_BINDING_TOOL_ERROR_INVALID_ANNOTATION,
- "Input argument \"%s\" cannot have const annotation in method \"%s\" of interface \"%s\"\n",
- arg_info_get_name (arg),
- method_info_get_name (method),
- interface_info_get_name (interface));
- return FALSE;
- }
- g_string_append_c (object_introspection_data_blob, 'C');
- g_string_append_c (object_introspection_data_blob, '\0');
- }
- else if (arg_info_get_direction (arg) == ARG_OUT)
- {
- g_string_append_c (object_introspection_data_blob, 'F');
- g_string_append_c (object_introspection_data_blob, '\0');
- }
-
- returnval_annotation = arg_info_get_annotation (arg, DBUS_GLIB_ANNOTATION_RETURNVAL);
- if (returnval_annotation != NULL)
- {
- GType gtype;
-
- if (found_retval)
- {
- g_set_error (error,
- DBUS_BINDING_TOOL_ERROR,
- DBUS_BINDING_TOOL_ERROR_INVALID_ANNOTATION,
- "Multiple arguments with return value annotation in method \"%s\" of interface \"%s\"\n",
- method_info_get_name (method),
- interface_info_get_name (interface));
- return FALSE;
- }
- found_retval = TRUE;
- if (arg_info_get_direction (arg) == ARG_IN)
- {
- g_set_error (error,
- DBUS_BINDING_TOOL_ERROR,
- DBUS_BINDING_TOOL_ERROR_INVALID_ANNOTATION,
- "Input argument \"%s\" cannot have return value annotation in method \"%s\" of interface \"%s\"\n",
- arg_info_get_name (arg),
- method_info_get_name (method),
- interface_info_get_name (interface));
- return FALSE;
- }
-
- if (found_out_args != 1)
- {
- g_set_error (error,
- DBUS_BINDING_TOOL_ERROR,
- DBUS_BINDING_TOOL_ERROR_INVALID_ANNOTATION,
- "An output <arg> after the first cannot have the ReturnVal annotation, in argument \"%s\" of method \"%s\" of interface \"%s\"\n",
- arg_info_get_name (arg),
- method_info_get_name (method),
- interface_info_get_name (interface));
- return FALSE;
- }
-
- if (!strcmp ("", returnval_annotation))
- g_string_append_c (object_introspection_data_blob, 'R');
- else if (!strcmp ("error", returnval_annotation))
- {
- gtype = _dbus_gtype_from_signature (arg_info_get_type (arg), TRUE);
- if (!_dbus_gtype_can_signal_error (gtype))
- {
- g_set_error (error,
- DBUS_BINDING_TOOL_ERROR,
- DBUS_BINDING_TOOL_ERROR_INVALID_ANNOTATION,
- "Output argument \"%s\" cannot signal error with type \"%s\" in method \"%s\" of interface \"%s\"\n",
- arg_info_get_name (arg),
- g_type_name (gtype),
- method_info_get_name (method),
- interface_info_get_name (interface));
- return FALSE;
- }
- g_string_append_c (object_introspection_data_blob, 'E');
- }
- else
- {
- g_set_error (error,
- DBUS_BINDING_TOOL_ERROR,
- DBUS_BINDING_TOOL_ERROR_INVALID_ANNOTATION,
- "Invalid ReturnVal annotation for argument \"%s\" in method \"%s\" of interface \"%s\"\n",
- arg_info_get_name (arg),
- method_info_get_name (method),
- interface_info_get_name (interface));
- return FALSE;
- }
-
- g_string_append_c (object_introspection_data_blob, '\0');
- }
- else if (arg_info_get_direction (arg) == ARG_OUT)
- {
- g_string_append_c (object_introspection_data_blob, 'N');
- g_string_append_c (object_introspection_data_blob, '\0');
- }
-
- g_string_append (object_introspection_data_blob, arg_info_get_type (arg));
- g_string_append_c (object_introspection_data_blob, '\0');
- }
-
- g_string_append_c (object_introspection_data_blob, '\0');
-
- data->count++;
- }
-
- signals = interface_info_get_signals (interface);
-
- for (tmp = signals; tmp != NULL; tmp = g_slist_next (tmp))
- {
- SignalInfo *sig;
-
- sig = tmp->data;
-
- g_string_append (data->signal_blob, interface_info_get_name (interface));
- g_string_append_c (data->signal_blob, '\0');
- g_string_append (data->signal_blob, signal_info_get_name (sig));
- g_string_append_c (data->signal_blob, '\0');
- }
-
- properties = interface_info_get_properties (interface);
-
- for (tmp = properties; tmp != NULL; tmp = g_slist_next (tmp))
- {
- PropertyInfo *prop;
- PropertyAccessFlags access_flags;
- const char *access_string;
- char *uscored;
-
- prop = tmp->data;
-
- access_flags = property_info_get_access (prop);
- if ((access_flags & PROPERTY_READ) && (access_flags & PROPERTY_WRITE))
- access_string = "readwrite";
- else if (access_flags & PROPERTY_READ)
- access_string = "read";
- else if (access_flags & PROPERTY_WRITE)
- access_string = "write";
- else
- continue;
-
- /* We append both in the blob so we have to malloc() less when processing
- * properties */
- uscored = _dbus_gutils_wincaps_to_uscore (property_info_get_name (prop));
-
- g_string_append (data->property_blob, interface_info_get_name (interface));
- g_string_append_c (data->property_blob, '\0');
- g_string_append (data->property_blob, property_info_get_name (prop));
- g_string_append_c (data->property_blob, '\0');
- g_string_append (data->property_blob, uscored);
- g_string_append_c (data->property_blob, '\0');
- g_string_append (data->property_blob, access_string);
- g_string_append_c (data->property_blob, '\0');
-
- g_free (uscored);
- }
- }
- return TRUE;
- io_lose:
- return FALSE;
-}
-
-static void
-write_marshaller (gpointer key, gpointer value, gpointer user_data)
-{
- DBusBindingToolCData *data;
- const char *marshaller;
- gsize bytes_written;
-
- data = user_data;
- marshaller = key;
-
- if (data->error && *data->error)
- return;
-
- if (g_io_channel_write_chars (data->channel, marshaller, -1, &bytes_written, data->error) == G_IO_STATUS_NORMAL)
- g_io_channel_write_chars (data->channel, "\n", -1, &bytes_written, data->error);
-}
-
-gboolean
-dbus_binding_tool_output_glib_server (BaseInfo *info, GIOChannel *channel, const char *prefix, GError **error)
-{
- gboolean ret;
- GPtrArray *argv;
- gint child_stdout;
- GIOChannel *genmarshal_stdout;
- GPid child_pid;
- DBusBindingToolCData data;
- char *tempfile_name;
- gint tempfile_fd;
- GIOStatus iostatus;
- char buf[4096];
- gsize bytes_read, bytes_written;
-
- memset (&data, 0, sizeof (data));
-
- dbus_g_type_specialized_init ();
- _dbus_g_type_specialized_builtins_init ();
-
- data.prefix = prefix;
- data.generated = g_hash_table_new_full (g_str_hash, g_str_equal, (GDestroyNotify) g_free, NULL);
- data.error = error;
- genmarshal_stdout = NULL;
- tempfile_name = NULL;
-
- if (!gather_marshallers (info, &data, error))
- goto io_lose;
-
- tempfile_fd = g_file_open_tmp ("dbus-binding-tool-c-marshallers.XXXXXX",
- &tempfile_name, error);
- if (tempfile_fd < 0)
- goto io_lose;
-
- data.channel = g_io_channel_unix_new (tempfile_fd);
- if (!g_io_channel_set_encoding (data.channel, NULL, error))
- goto io_lose;
- g_hash_table_foreach (data.generated, write_marshaller, &data);
- if (error && *error != NULL)
- {
- ret = FALSE;
- g_io_channel_shutdown (data.channel, TRUE, error);
- g_io_channel_unref (data.channel);
- goto io_lose;
- }
-
- g_io_channel_shutdown (data.channel, TRUE, error);
- g_io_channel_unref (data.channel);
-
- /* Now spawn glib-genmarshal to insert all our required marshallers */
- argv = g_ptr_array_new ();
- g_ptr_array_add (argv, "glib-genmarshal");
- g_ptr_array_add (argv, "--header");
- g_ptr_array_add (argv, "--body");
- g_ptr_array_add (argv, "--skip-source");
- g_ptr_array_add (argv, g_strdup_printf ("--prefix=%s%s", MARSHAL_PREFIX, prefix));
- g_ptr_array_add (argv, tempfile_name);
- g_ptr_array_add (argv, NULL);
- if (!g_spawn_async_with_pipes (NULL, (char**)argv->pdata, NULL,
- G_SPAWN_SEARCH_PATH,
- NULL, NULL,
- &child_pid,
- NULL,
- &child_stdout, NULL, error))
- {
- g_ptr_array_free (argv, TRUE);
- goto io_lose;
- }
- g_ptr_array_free (argv, TRUE);
-
- genmarshal_stdout = g_io_channel_unix_new (child_stdout);
- if (!g_io_channel_set_encoding (genmarshal_stdout, NULL, error))
- goto io_lose;
-
- WRITE_OR_LOSE ("/* Generated by dbus-binding-tool; do not edit! */\n\n");
-
- while ((iostatus = g_io_channel_read_chars (genmarshal_stdout, buf, sizeof (buf),
- &bytes_read, error)) == G_IO_STATUS_NORMAL)
- if (g_io_channel_write_chars (channel, buf, bytes_read, &bytes_written, error) != G_IO_STATUS_NORMAL)
- goto io_lose;
- if (iostatus != G_IO_STATUS_EOF)
- goto io_lose;
-
- g_io_channel_shutdown (genmarshal_stdout, TRUE, error);
-
- WRITE_OR_LOSE ("#include <dbus/dbus-glib.h>\n");
-
- data.channel = channel;
- g_io_channel_ref (data.channel);
- if (!generate_glue_toplevel (info, &data, error))
- goto io_lose;
-
- ret = TRUE;
- cleanup:
- if (tempfile_name)
- unlink (tempfile_name);
- g_free (tempfile_name);
- if (genmarshal_stdout)
- g_io_channel_unref (genmarshal_stdout);
- if (data.channel)
- g_io_channel_unref (data.channel);
- g_hash_table_destroy (data.generated);
-
- return ret;
- io_lose:
- ret = FALSE;
- goto cleanup;
-}
-
-static char *
-iface_to_c_prefix (const char *iface)
-{
- char **components;
- char **component;
- GString *ret;
- gboolean first;
-
- components = g_strsplit (iface, ".", 0);
-
- first = TRUE;
- ret = g_string_new ("");
- for (component = components; *component; component++)
- {
- if (!first)
- g_string_append_c (ret, '_');
- else
- first = FALSE;
- g_string_append (ret, *component);
- }
- g_strfreev (components);
- return g_string_free (ret, FALSE);
-}
-
-static char *
-compute_client_method_name (const char *iface_prefix, MethodInfo *method)
-{
- char *method_name_uscored, *ret;
-
- method_name_uscored = _dbus_gutils_wincaps_to_uscore (method_info_get_name (method));
- ret = g_strdup_printf ("%s_%s", iface_prefix, method_name_uscored);
- g_free (method_name_uscored);
-
- return ret;
-}
-
-static gboolean
-write_formal_parameters (InterfaceInfo *iface, MethodInfo *method, GIOChannel *channel, GError **error)
-{
- GSList *args;
-
- for (args = method_info_get_args (method); args; args = args->next)
- {
- ArgInfo *arg;
- const char *type_str;
- const char *type_suffix;
- GType gtype;
- int direction;
-
- arg = args->data;
-
- WRITE_OR_LOSE (", ");
-
- direction = arg_info_get_direction (arg);
-
- gtype = _dbus_gtype_from_signature (arg_info_get_type (arg), TRUE);
- if (gtype == G_TYPE_INVALID)
- {
- g_set_error (error,
- DBUS_BINDING_TOOL_ERROR,
- DBUS_BINDING_TOOL_ERROR_UNSUPPORTED_CONVERSION,
- "Unsupported conversion from D-BUS type signature \"%s\" to glib C type in method \"%s\" of interface \"%s\"",
- arg_info_get_type (arg),
- method_info_get_name (method),
- interface_info_get_name (iface));
- return FALSE;
- }
- type_str = dbus_g_type_get_c_name (gtype);
- g_assert (type_str);
- /* Variants are special...*/
- if (gtype == G_TYPE_VALUE)
- {
- if (direction == ARG_IN)
- type_suffix = "*";
- else
- type_suffix = "";
- }
- else if ((g_type_is_a (gtype, G_TYPE_BOXED)
- || g_type_is_a (gtype, G_TYPE_OBJECT)
- || g_type_is_a (gtype, G_TYPE_POINTER)))
- type_suffix = "*";
- else
- type_suffix = "";
-
-
- switch (direction)
- {
- case ARG_IN:
- if (!write_printf_to_iochannel ("const %s%s IN_%s", channel, error,
- type_str,
- type_suffix,
- arg_info_get_name (arg)))
- goto io_lose;
- break;
- case ARG_OUT:
- if (!write_printf_to_iochannel ("%s%s* OUT_%s", channel, error,
- type_str,
- type_suffix,
- arg_info_get_name (arg)))
- goto io_lose;
- break;
- case ARG_INVALID:
- break;
- }
- }
-
- return TRUE;
- io_lose:
- return FALSE;
-}
-
-#define MAP_FUNDAMENTAL(NAME) \
- case G_TYPE_ ## NAME: \
- return g_strdup ("G_TYPE_" #NAME);
-#define MAP_KNOWN(NAME) \
- if (gtype == NAME) \
- return g_strdup (#NAME)
-static char *
-dbus_g_type_get_lookup_function (GType gtype)
-{
- char *type_lookup;
- switch (gtype)
- {
- MAP_FUNDAMENTAL(CHAR);
- MAP_FUNDAMENTAL(UCHAR);
- MAP_FUNDAMENTAL(BOOLEAN);
- MAP_FUNDAMENTAL(LONG);
- MAP_FUNDAMENTAL(ULONG);
- MAP_FUNDAMENTAL(INT);
- MAP_FUNDAMENTAL(UINT);
- MAP_FUNDAMENTAL(INT64);
- MAP_FUNDAMENTAL(UINT64);
- MAP_FUNDAMENTAL(FLOAT);
- MAP_FUNDAMENTAL(DOUBLE);
- MAP_FUNDAMENTAL(STRING);
- }
- if (dbus_g_type_is_collection (gtype))
- {
- GType elt_gtype;
- char *sublookup;
-
- elt_gtype = dbus_g_type_get_collection_specialization (gtype);
- sublookup = dbus_g_type_get_lookup_function (elt_gtype);
- g_assert (sublookup);
-
- if (_dbus_g_type_is_fixed (elt_gtype))
- {
- type_lookup = g_strdup_printf ("dbus_g_type_get_collection "
- "(\"GArray\", %s)", sublookup);
- }
- else
- {
- type_lookup = g_strdup_printf ("dbus_g_type_get_collection "
- "(\"GPtrArray\", %s)", sublookup);
- }
-
- g_free (sublookup);
-
- return type_lookup;
- }
- else if (dbus_g_type_is_map (gtype))
- {
- GType key_gtype;
- char *key_lookup;
- GType value_gtype;
- char *value_lookup;
-
- key_gtype = dbus_g_type_get_map_key_specialization (gtype);
- value_gtype = dbus_g_type_get_map_value_specialization (gtype);
- key_lookup = dbus_g_type_get_lookup_function (key_gtype);
- g_assert (key_lookup);
- value_lookup = dbus_g_type_get_lookup_function (value_gtype);
- g_assert (value_lookup);
- type_lookup = g_strdup_printf ("dbus_g_type_get_map (\"GHashTable\", %s, %s)",
- key_lookup, value_lookup);
- g_free (key_lookup);
- g_free (value_lookup);
- return type_lookup;
- }
- else if (dbus_g_type_is_struct (gtype))
- {
- GType value_gtype;
- GString *string;
- char *value_lookup = NULL;
- guint size, i;
-
- string = g_string_new ("dbus_g_type_get_struct (\"GValueArray\"");
-
- size = dbus_g_type_get_struct_size (gtype);
- for (i=0; i < size; i++)
- {
- value_gtype = dbus_g_type_get_struct_member_type(gtype, i);
- value_lookup = dbus_g_type_get_lookup_function (value_gtype);
- g_assert (value_lookup);
- g_string_append_printf (string, ", %s", value_lookup);
- g_free (value_lookup);
- }
- g_string_append (string, ", G_TYPE_INVALID)");
- return g_string_free (string, FALSE);
- }
-
- MAP_KNOWN(G_TYPE_VALUE);
- MAP_KNOWN(G_TYPE_STRV);
- MAP_KNOWN(G_TYPE_VALUE_ARRAY);
- MAP_KNOWN(DBUS_TYPE_G_PROXY);
- MAP_KNOWN(DBUS_TYPE_G_OBJECT_PATH);
- MAP_KNOWN(DBUS_TYPE_G_SIGNATURE);
- return NULL;
-}
-#undef MAP_FUNDAMENTAL
-#undef MAP_KNOWN
-
-static gboolean
-write_args_for_direction (InterfaceInfo *iface, MethodInfo *method, GIOChannel *channel, int direction, GError **error)
-{
- GSList *args;
- char *type_lookup = NULL;
-
- for (args = method_info_get_args (method); args; args = args->next)
- {
- ArgInfo *arg;
- GType gtype;
-
- arg = args->data;
-
- if (direction != arg_info_get_direction (arg))
- continue;
-
- gtype = _dbus_gtype_from_signature (arg_info_get_type (arg), TRUE);
- g_assert (gtype != G_TYPE_INVALID);
- type_lookup = dbus_g_type_get_lookup_function (gtype);
- g_assert (type_lookup != NULL);
-
- switch (direction)
- {
-
- case ARG_IN:
- if (!write_printf_to_iochannel ("%s, IN_%s, ", channel, error,
- type_lookup,
- arg_info_get_name (arg)))
- goto io_lose;
- break;
- case ARG_OUT:
- if (!write_printf_to_iochannel ("%s, OUT_%s, ", channel, error,
- type_lookup,
- arg_info_get_name (arg)))
- goto io_lose;
- break;
- case ARG_INVALID:
- break;
- }
- g_free (type_lookup);
- }
-
- return TRUE;
- io_lose:
- g_free (type_lookup);
- return FALSE;
-}
-
-static gboolean
-check_supported_parameters (MethodInfo *method)
-{
- GSList *args;
-
- for (args = method_info_get_args (method); args; args = args->next)
- {
- ArgInfo *arg;
- GType gtype;
-
- arg = args->data;
- gtype = _dbus_gtype_from_signature (arg_info_get_type (arg), TRUE);
- if (gtype == G_TYPE_INVALID)
- return FALSE;
- }
- return TRUE;
-}
-
-static gboolean
-write_untyped_out_args (InterfaceInfo *iface, MethodInfo *method, GIOChannel *channel, GError **error)
-{
- GSList *args;
-
- for (args = method_info_get_args (method); args; args = args->next)
- {
- ArgInfo *arg;
-
- arg = args->data;
- if (arg_info_get_direction (arg) != ARG_OUT)
- continue;
-
- if (!write_printf_to_iochannel ("OUT_%s, ", channel, error,
- arg_info_get_name (arg)))
- goto io_lose;
- }
-
- return TRUE;
- io_lose:
- return FALSE;
-}
-
-static gboolean
-write_formal_declarations_for_direction (InterfaceInfo *iface, MethodInfo *method, GIOChannel *channel, const int direction, GError **error)
- {
- GSList *args;
-
- for (args = method_info_get_args (method); args; args = args->next)
- {
- ArgInfo *arg;
- GType gtype;
- const char *type_str, *type_suffix, *type_initializer = "";
- int dir;
-
- arg = args->data;
-
- dir = arg_info_get_direction (arg);
-
- gtype = _dbus_gtype_from_signature (arg_info_get_type (arg), TRUE);
- type_str = dbus_g_type_get_c_name (gtype);
-
- if (!type_str)
- {
- g_set_error (error,
- DBUS_BINDING_TOOL_ERROR,
- DBUS_BINDING_TOOL_ERROR_UNSUPPORTED_CONVERSION,
- "Unsupported conversion from D-BUS type signature \"%s\" to glib C type in method \"%s\" of interface \"%s\"",
- arg_info_get_type (arg),
- method_info_get_name (method),
- interface_info_get_name (iface));
- return FALSE;
- }
-
- /* Variants are special...*/
- if (gtype == G_TYPE_VALUE)
- {
- if (direction == ARG_IN)
- type_suffix = "*";
- else
- {
- type_suffix = "";
- type_initializer = " = { 0, }";
- }
- }
- else if ((g_type_is_a (gtype, G_TYPE_BOXED)
- || g_type_is_a (gtype, G_TYPE_OBJECT)
- || g_type_is_a (gtype, G_TYPE_POINTER)))
- type_suffix = "*";
- else
- type_suffix = "";
-
- if (direction != dir)
- continue;
-
- switch (dir)
- {
- case ARG_IN:
- if (!write_printf_to_iochannel (" %s%s IN_%s;\n", channel, error,
- type_str, type_suffix,
- arg_info_get_name (arg)))
- goto io_lose;
- break;
- case ARG_OUT:
- if (!write_printf_to_iochannel (" %s%s OUT_%s%s;\n", channel, error,
- type_str, type_suffix,
- arg_info_get_name (arg),
- type_initializer))
- goto io_lose;
- break;
- case ARG_INVALID:
- break;
- }
- }
- return TRUE;
- io_lose:
- return FALSE;
- }
-
-static gboolean
-write_formal_parameters_for_direction (InterfaceInfo *iface, MethodInfo *method, int dir, GIOChannel *channel, GError **error)
-{
- GSList *args;
-
- for (args = method_info_get_args (method); args; args = args->next)
- {
- ArgInfo *arg;
- const char *type_str;
- const char *type_suffix;
- GType gtype;
- int direction;
-
- arg = args->data;
-
- direction = arg_info_get_direction (arg);
- if (dir != direction) continue;
-
- WRITE_OR_LOSE (", ");
-
- gtype = _dbus_gtype_from_signature (arg_info_get_type (arg), TRUE);
- type_str = dbus_g_type_get_c_name (gtype);
- /* Variants are special...*/
- if (gtype == G_TYPE_VALUE)
- {
- if (direction == ARG_IN)
- type_suffix = "*";
- else
- type_suffix = "";
- }
- else if ((g_type_is_a (gtype, G_TYPE_BOXED)
- || g_type_is_a (gtype, G_TYPE_OBJECT)
- || g_type_is_a (gtype, G_TYPE_POINTER)))
- type_suffix = "*";
- else
- type_suffix = "";
-
- if (!type_str)
- {
- g_set_error (error,
- DBUS_BINDING_TOOL_ERROR,
- DBUS_BINDING_TOOL_ERROR_UNSUPPORTED_CONVERSION,
- "Unsupported conversion from D-BUS type signature \"%s\" to glib C type in method \"%s\" of interface \"%s\"",
- arg_info_get_type (arg),
- method_info_get_name (method),
- interface_info_get_name (iface));
- return FALSE;
- }
-
- switch (direction)
- {
- case ARG_IN:
- if (!write_printf_to_iochannel ("const %s%s IN_%s", channel, error,
- type_str,
- type_suffix,
- arg_info_get_name (arg)))
- goto io_lose;
- break;
- case ARG_OUT:
- if (!write_printf_to_iochannel ("%s%s* OUT_%s", channel, error,
- type_str,
- type_suffix,
- arg_info_get_name (arg)))
- goto io_lose;
- break;
- case ARG_INVALID:
- break;
- }
- }
- return TRUE;
- io_lose:
- return FALSE;
-}
-
-static gboolean
-write_typed_args_for_direction (InterfaceInfo *iface, MethodInfo *method, GIOChannel *channel, const int direction, GError **error)
-{
- GSList *args;
- char *type_lookup = NULL;
-
- for (args = method_info_get_args (method); args; args = args->next)
- {
- ArgInfo *arg;
- int dir;
- GType gtype;
-
- arg = args->data;
-
- dir = arg_info_get_direction (arg);
-
- if (dir != direction)
- continue;
-
- gtype = _dbus_gtype_from_signature (arg_info_get_type (arg), TRUE);
- type_lookup = dbus_g_type_get_lookup_function (gtype);
-
- if (!write_printf_to_iochannel ("%s, &%s_%s, ", channel, error, type_lookup, direction == ARG_IN ? "IN" : "OUT", arg_info_get_name (arg)))
- goto io_lose;
- g_free (type_lookup);
- }
- return TRUE;
- io_lose:
- g_free (type_lookup);
- return FALSE;
-}
-
-static gboolean
-write_async_method_client (GIOChannel *channel, InterfaceInfo *interface, MethodInfo *method, GError **error)
-{
- char *method_name, *iface_prefix;
- const char *interface_c_name;
-
- iface_prefix = iface_to_c_prefix (interface_info_get_name (interface));
- interface_c_name = interface_info_get_annotation (interface, DBUS_GLIB_ANNOTATION_CLIENT_C_SYMBOL);
- if (interface_c_name == NULL)
- {
- interface_c_name = (const char *) iface_prefix;
- }
-
- method_name = g_strdup (method_info_get_annotation (method, DBUS_GLIB_ANNOTATION_CLIENT_C_SYMBOL));
- if (method_name == NULL)
- {
- method_name = compute_client_method_name (interface_c_name, method);
- }
- g_free(iface_prefix);
-
- /* Write the typedef for the client callback */
- if (!write_printf_to_iochannel ("typedef void (*%s_reply) (DBusGProxy *proxy, ", channel, error, method_name))
- goto io_lose;
- {
- GSList *args;
- for (args = method_info_get_args (method); args; args = args->next)
- {
- ArgInfo *arg;
- const char *type_suffix, *type_str;
- GType gtype;
-
- arg = args->data;
-
- if (arg_info_get_direction (arg) != ARG_OUT)
- continue;
- gtype = _dbus_gtype_from_signature (arg_info_get_type (arg), TRUE);
- if (gtype != G_TYPE_VALUE && (g_type_is_a (gtype, G_TYPE_BOXED)
- || g_type_is_a (gtype, G_TYPE_OBJECT)
- || g_type_is_a (gtype, G_TYPE_POINTER)))
- type_suffix = "*";
- else
- type_suffix = "";
- type_str = dbus_g_type_get_c_name (_dbus_gtype_from_signature (arg_info_get_type (arg), TRUE));
- if (!write_printf_to_iochannel ("%s %sOUT_%s, ", channel, error, type_str, type_suffix, arg_info_get_name (arg)))
- goto io_lose;
- }
- }
- WRITE_OR_LOSE ("GError *error, gpointer userdata);\n\n");
-
-
- /* Write the callback when the call returns */
- WRITE_OR_LOSE ("static void\n");
- if (!write_printf_to_iochannel ("%s_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data)\n", channel, error, method_name))
- goto io_lose;
- WRITE_OR_LOSE ("{\n");
- WRITE_OR_LOSE (" DBusGAsyncData *data = (DBusGAsyncData*) user_data;\n GError *error = NULL;\n");
- if (!write_formal_declarations_for_direction (interface, method, channel, ARG_OUT, error))
- goto io_lose;
- /* TODO: handle return boolean of end_call */
- WRITE_OR_LOSE (" dbus_g_proxy_end_call (proxy, call, &error, ");
- if (!write_typed_args_for_direction (interface, method, channel, ARG_OUT, error))
- goto io_lose;
- WRITE_OR_LOSE("G_TYPE_INVALID);\n");
- if (!write_printf_to_iochannel (" (*(%s_reply)data->cb) (proxy, ", channel, error, method_name))
- goto io_lose;
- if (!write_untyped_out_args (interface, method, channel, error))
- goto io_lose;
- WRITE_OR_LOSE ("error, data->userdata);\n");
- WRITE_OR_LOSE (" return;\n}\n\n");
-
-
- /* Write the main wrapper function */
- WRITE_OR_LOSE ("static inline DBusGProxyCall*\n");
- if (!write_printf_to_iochannel ("%s_async (DBusGProxy *proxy", channel, error,
- method_name))
- goto io_lose;
- if (!write_formal_parameters_for_direction (interface, method, ARG_IN, channel, error))
- goto io_lose;
-
- if (!write_printf_to_iochannel (", %s_reply callback, gpointer userdata)\n\n", channel, error, method_name))
- goto io_lose;
-
- WRITE_OR_LOSE ("{\n");
- WRITE_OR_LOSE (" DBusGAsyncData *stuff;\n stuff = g_slice_new (DBusGAsyncData);\n stuff->cb = G_CALLBACK (callback);\n stuff->userdata = userdata;\n");
- if (!write_printf_to_iochannel (" return dbus_g_proxy_begin_call (proxy, \"%s\", %s_async_callback, stuff, _dbus_glib_async_data_free, ", channel, error, method_info_get_name (method), method_name))
- goto io_lose;
- if (!write_args_for_direction (interface, method, channel, ARG_IN, error))
- goto io_lose;
- WRITE_OR_LOSE ("G_TYPE_INVALID);\n}\n");
-
- g_free (method_name);
- return TRUE;
- io_lose:
- g_free (method_name);
- return FALSE;
- }
-
-static gboolean
-generate_client_glue_list (GSList *list, DBusBindingToolCData *data, GError **error)
-{
- GSList *tmp;
-
- tmp = list;
- while (tmp != NULL)
- {
- if (!generate_client_glue (tmp->data, data, error))
- return FALSE;
- tmp = tmp->next;
- }
- return TRUE;
-}
-
-static gboolean
-generate_client_glue (BaseInfo *base, DBusBindingToolCData *data, GError **error)
-{
- char *iface_prefix;
- char *method_c_name;
- iface_prefix = NULL;
- method_c_name = NULL;
-
- if (base_info_get_type (base) == INFO_TYPE_NODE)
- {
- if (!generate_client_glue_list (node_info_get_nodes ((NodeInfo *) base),
- data, error))
- return FALSE;
- if (!generate_client_glue_list (node_info_get_interfaces ((NodeInfo *) base),
- data, error))
- return FALSE;
- }
- else
- {
- GIOChannel *channel;
- InterfaceInfo *interface;
- GSList *methods;
- GSList *tmp;
- const char *interface_c_name;
-
- channel = data->channel;
-
- interface = (InterfaceInfo *) base;
-
- methods = interface_info_get_methods (interface);
-
- iface_prefix = iface_to_c_prefix (interface_info_get_name (interface));
- interface_c_name = interface_info_get_annotation (interface, DBUS_GLIB_ANNOTATION_CLIENT_C_SYMBOL);
- if (interface_c_name == NULL)
- {
- interface_c_name = (const char *) iface_prefix;
- }
-
- if (!write_printf_to_iochannel ("#ifndef DBUS_GLIB_CLIENT_WRAPPERS_%s\n"
- "#define DBUS_GLIB_CLIENT_WRAPPERS_%s\n\n",
- channel, error,
- iface_prefix, iface_prefix))
- goto io_lose;
-
- for (tmp = methods; tmp != NULL; tmp = g_slist_next (tmp))
- {
- MethodInfo *method;
- gboolean is_noreply;
-
- method = (MethodInfo *) tmp->data;
- method_c_name = g_strdup (method_info_get_annotation (method, DBUS_GLIB_ANNOTATION_CLIENT_C_SYMBOL));
- if (method_c_name == NULL)
- {
- method_c_name = compute_client_method_name (interface_c_name, method);
- }
-
- is_noreply = method_info_get_annotation (method, DBUS_GLIB_ANNOTATION_NOREPLY) != NULL;
-
- if (data->ignore_unsupported && !check_supported_parameters (method))
- {
- g_warning ("Ignoring unsupported signature in method \"%s\" of interface \"%s\"\n",
- method_info_get_name (method),
- interface_info_get_name (interface));
- g_free (method_c_name);
- method_c_name = NULL;
- continue;
- }
-
-
- WRITE_OR_LOSE ("static inline gboolean\n");
- if (!write_printf_to_iochannel ("%s (DBusGProxy *proxy", channel, error,
- method_c_name))
- goto io_lose;
- g_free (method_c_name);
- method_c_name = NULL;
-
- if (!write_formal_parameters (interface, method, channel, error))
- goto io_lose;
-
- WRITE_OR_LOSE (", GError **error)\n\n");
-
- WRITE_OR_LOSE ("{\n");
-
- if (is_noreply) {
- if (!write_printf_to_iochannel (" dbus_g_proxy_call_no_reply (proxy, \"%s\", ", channel, error,
- method_info_get_name (method)))
- goto io_lose;
-
- if (!write_args_for_direction (interface, method, channel, ARG_IN, error))
- goto io_lose;
-
- WRITE_OR_LOSE ("G_TYPE_INVALID, ");
-
- if (!write_args_for_direction (interface, method, channel, ARG_OUT, error))
- goto io_lose;
-
- WRITE_OR_LOSE ("G_TYPE_INVALID);\n");
-
- WRITE_OR_LOSE (" return TRUE;\n}\n\n");
- } else {
- if (!write_printf_to_iochannel (" return dbus_g_proxy_call (proxy, \"%s\", ", channel, error,
- method_info_get_name (method)))
- goto io_lose;
-
- WRITE_OR_LOSE ("error, ");
-
- if (!write_args_for_direction (interface, method, channel, ARG_IN, error))
- goto io_lose;
-
- WRITE_OR_LOSE ("G_TYPE_INVALID, ");
-
- if (!write_args_for_direction (interface, method, channel, ARG_OUT, error))
- goto io_lose;
-
- WRITE_OR_LOSE ("G_TYPE_INVALID);\n}\n\n");
- }
-
- write_async_method_client (channel, interface, method, error);
- }
-
- if (!write_printf_to_iochannel ("#endif /* defined DBUS_GLIB_CLIENT_WRAPPERS_%s */\n\n", channel, error, iface_prefix))
- goto io_lose;
-
- g_free (iface_prefix);
- }
- return TRUE;
- io_lose:
- g_free (method_c_name);
- g_free (iface_prefix);
- return FALSE;
-}
-
-
-gboolean
-dbus_binding_tool_output_glib_client (BaseInfo *info, GIOChannel *channel, gboolean ignore_unsupported, GError **error)
-{
- DBusBindingToolCData data;
- gboolean ret;
-
- memset (&data, 0, sizeof (data));
-
- data.channel = channel;
- data.ignore_unsupported = ignore_unsupported;
-
- dbus_g_type_specialized_init ();
- _dbus_g_type_specialized_builtins_init ();
-
- WRITE_OR_LOSE ("/* Generated by dbus-binding-tool; do not edit! */\n\n");
- WRITE_OR_LOSE ("#include <glib.h>\n");
- WRITE_OR_LOSE ("#include <dbus/dbus-glib.h>\n\n");
- WRITE_OR_LOSE ("G_BEGIN_DECLS\n\n");
-
- WRITE_OR_LOSE ("#ifndef _DBUS_GLIB_ASYNC_DATA_FREE\n");
- WRITE_OR_LOSE ("#define _DBUS_GLIB_ASYNC_DATA_FREE\n");
- WRITE_OR_LOSE ("static inline void\n");
- WRITE_OR_LOSE ("_dbus_glib_async_data_free (gpointer stuff)\n{\n\tg_slice_free (DBusGAsyncData, stuff);\n}\n");
- WRITE_OR_LOSE ("#endif\n\n");
-
- ret = generate_client_glue (info, &data, error);
- if (!ret)
- goto io_lose;
-
- WRITE_OR_LOSE ("G_END_DECLS\n");
-
- return ret;
- io_lose:
- return FALSE;
-}
diff --git a/dbus/dbus-binding-tool-glib.h b/dbus/dbus-binding-tool-glib.h
deleted file mode 100644
index 9abe7d0..0000000
--- a/dbus/dbus-binding-tool-glib.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/* -*- mode: C; c-file-style: "gnu" -*- */
-/* dbus-binding-tool-output-glib.h prototypes for glib output
- *
- * Copyright (C) 2005 Red Hat, Inc.
- *
- * Licensed under the Academic Free License version 2.1
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it bwill be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- */
-#ifndef DBUS_BINDING_TOOL_OUTPUT_GLIB_H
-#define DBUS_BINDING_TOOL_OUTPUT_GLIB_H
-
-G_BEGIN_DECLS
-
-#define DBUS_GLIB_ANNOTATION_C_SYMBOL "org.freedesktop.DBus.GLib.CSymbol"
-#define DBUS_GLIB_ANNOTATION_CLIENT_C_SYMBOL "org.freedesktop.DBus.GLib.ClientCSymbol"
-#define DBUS_GLIB_ANNOTATION_ASYNC "org.freedesktop.DBus.GLib.Async"
-#define DBUS_GLIB_ANNOTATION_CONST "org.freedesktop.DBus.GLib.Const"
-#define DBUS_GLIB_ANNOTATION_RETURNVAL "org.freedesktop.DBus.GLib.ReturnVal"
-#define DBUS_GLIB_ANNOTATION_NOREPLY "org.freedesktop.DBus.Method.NoReply"
-
-gboolean dbus_binding_tool_output_glib_client (BaseInfo *info, GIOChannel *channel, gboolean ignore_unsupported, GError **error);
-gboolean dbus_binding_tool_output_glib_server (BaseInfo *info, GIOChannel *channel, const char *prefix, GError **error);
-
-G_END_DECLS
-
-#endif
diff --git a/dbus/dbus-gidl.c b/dbus/dbus-gidl.c
deleted file mode 100644
index cde4d79..0000000
--- a/dbus/dbus-gidl.c
+++ /dev/null
@@ -1,780 +0,0 @@
-/* -*- mode: C; c-file-style: "gnu" -*- */
-/* dbus-gidl.c data structure describing an interface, to be generated from IDL
- * or something
- *
- * Copyright (C) 2003, 2005 Red Hat, Inc.
- *
- * Licensed under the Academic Free License version 2.1
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- */
-
-#include <config.h>
-
-#include "dbus-gidl.h"
-
-#include <gio/gio.h>
-
-struct BaseInfo
-{
- unsigned int refcount : 28;
- unsigned int type : 4;
- char *name;
-};
-
-struct NodeInfo
-{
- BaseInfo base;
- GSList *interfaces;
- GSList *nodes;
-};
-
-struct InterfaceInfo
-{
- BaseInfo base;
- GHashTable *annotations;
- /* Since we have BaseInfo now these could be one list */
- GSList *methods;
- GSList *signals;
- GSList *properties;
-};
-
-struct MethodInfo
-{
- BaseInfo base;
- GHashTable *annotations;
- GSList *args;
-};
-
-struct SignalInfo
-{
- BaseInfo base;
- GSList *args;
-};
-
-struct PropertyInfo
-{
- BaseInfo base;
- char *type;
- PropertyAccessFlags access;
-};
-
-struct ArgInfo
-{
- BaseInfo base;
- char *type;
- ArgDirection direction;
- GHashTable *annotations;
-};
-
-static void
-get_hash_key (gpointer key, gpointer value, gpointer data)
-{
- GSList **list = data;
- *list = g_slist_prepend (*list, key);
-}
-
-static GSList *
-get_hash_keys (GHashTable *table)
-{
- GSList *ret = NULL;
-
- g_hash_table_foreach (table, get_hash_key, &ret);
-
- return ret;
-}
-
-BaseInfo *
-base_info_ref (BaseInfo *info)
-{
- g_return_val_if_fail (info != NULL, NULL);
- g_return_val_if_fail (info->refcount > 0, NULL);
-
- info->refcount += 1;
-
- return info;
-}
-
-static void
-base_info_free (void *ptr)
-{
- BaseInfo *info;
-
- info = ptr;
-
- g_free (info->name);
- g_free (info);
-}
-
-void
-base_info_unref (BaseInfo *info)
-{
- g_return_if_fail (info != NULL);
- g_return_if_fail (info->refcount > 0);
-
- /* This is sort of bizarre, BaseInfo was tacked on later */
-
- switch (info->type)
- {
- case INFO_TYPE_NODE:
- node_info_unref ((NodeInfo*) info);
- break;
- case INFO_TYPE_INTERFACE:
- interface_info_unref ((InterfaceInfo*) info);
- break;
- case INFO_TYPE_SIGNAL:
- signal_info_unref ((SignalInfo*) info);
- break;
- case INFO_TYPE_METHOD:
- method_info_unref ((MethodInfo*) info);
- break;
- case INFO_TYPE_PROPERTY:
- property_info_unref ((PropertyInfo*) info);
- break;
- case INFO_TYPE_ARG:
- arg_info_unref ((ArgInfo*) info);
- break;
- }
-}
-
-InfoType
-base_info_get_type (BaseInfo *info)
-{
- return info->type;
-}
-
-const char*
-base_info_get_name (BaseInfo *info)
-{
- return info->name;
-}
-
-void
-base_info_set_name (BaseInfo *info,
- const char *name)
-{
- char *old;
-
- old = info->name;
- info->name = g_strdup (name);
- g_free (old);
-}
-
-GType
-base_info_get_gtype (void)
-{
- static GType our_type = 0;
-
- if (our_type == 0)
- our_type = g_boxed_type_register_static ("BaseInfo",
- (GBoxedCopyFunc) base_info_ref,
- (GBoxedFreeFunc) base_info_unref);
-
- return our_type;
-}
-
-static void
-free_interface_list (GSList **interfaces_p)
-{
- GSList *tmp;
- tmp = *interfaces_p;
- while (tmp != NULL)
- {
- interface_info_unref (tmp->data);
- tmp = tmp->next;
- }
- g_slist_free (*interfaces_p);
- *interfaces_p = NULL;
-}
-
-static void
-free_node_list (GSList **nodes_p)
-{
- GSList *tmp;
- tmp = *nodes_p;
- while (tmp != NULL)
- {
- node_info_unref (tmp->data);
- tmp = tmp->next;
- }
- g_slist_free (*nodes_p);
- *nodes_p = NULL;
-}
-
-static void
-free_method_list (GSList **methods_p)
-{
- GSList *tmp;
- tmp = *methods_p;
- while (tmp != NULL)
- {
- method_info_unref (tmp->data);
- tmp = tmp->next;
- }
- g_slist_free (*methods_p);
- *methods_p = NULL;
-}
-
-static void
-free_signal_list (GSList **signals_p)
-{
- GSList *tmp;
- tmp = *signals_p;
- while (tmp != NULL)
- {
- signal_info_unref (tmp->data);
- tmp = tmp->next;
- }
- g_slist_free (*signals_p);
- *signals_p = NULL;
-}
-
-static void
-free_property_list (GSList **props_p)
-{
- GSList *tmp;
- tmp = *props_p;
- while (tmp != NULL)
- {
- property_info_unref (tmp->data);
- tmp = tmp->next;
- }
- g_slist_free (*props_p);
- *props_p = NULL;
-}
-
-NodeInfo*
-node_info_new (const char *name)
-{
- NodeInfo *info;
-
- /* name can be NULL */
-
- info = g_new0 (NodeInfo, 1);
- info->base.refcount = 1;
- info->base.name = g_strdup (name);
- info->base.type = INFO_TYPE_NODE;
-
- return info;
-}
-
-NodeInfo *
-node_info_ref (NodeInfo *info)
-{
- info->base.refcount += 1;
-
- return info;
-}
-
-void
-node_info_unref (NodeInfo *info)
-{
- info->base.refcount -= 1;
- if (info->base.refcount == 0)
- {
- free_interface_list (&info->interfaces);
- free_node_list (&info->nodes);
- base_info_free (info);
- }
-}
-
-const char*
-node_info_get_name (NodeInfo *info)
-{
- return info->base.name;
-}
-
-GSList*
-node_info_get_interfaces (NodeInfo *info)
-{
- return info->interfaces;
-}
-
-void
-node_info_add_interface (NodeInfo *info,
- InterfaceInfo *interface)
-{
- interface_info_ref (interface);
- info->interfaces = g_slist_append (info->interfaces, interface);
-}
-
-GSList*
-node_info_get_nodes (NodeInfo *info)
-{
- return info->nodes;
-}
-
-void
-node_info_add_node (NodeInfo *info,
- NodeInfo *node)
-{
- node_info_ref (node);
- info->nodes = g_slist_append (info->nodes, node);
-}
-
-void
-node_info_replace_node (NodeInfo *info,
- NodeInfo *old_child,
- NodeInfo *new_child)
-{
- GSList *link;
-
- node_info_ref (new_child); /* before unref old_child in case they are the same */
- link = g_slist_find (info->nodes, old_child);
- g_assert (link != NULL);
- node_info_unref (old_child);
- link->data = new_child;
-}
-
-InterfaceInfo*
-interface_info_new (const char *name)
-{
- InterfaceInfo *info;
-
- g_return_val_if_fail (g_dbus_is_interface_name (name), NULL);
-
- info = g_new0 (InterfaceInfo, 1);
- info->base.refcount = 1;
- info->base.name = g_strdup (name);
- info->base.type = INFO_TYPE_INTERFACE;
- info->annotations = g_hash_table_new_full (g_str_hash, g_str_equal,
- (GDestroyNotify) g_free,
- (GDestroyNotify) g_free);
-
- return info;
-}
-
-InterfaceInfo *
-interface_info_ref (InterfaceInfo *info)
-{
- info->base.refcount += 1;
-
- return info;
-}
-
-void
-interface_info_unref (InterfaceInfo *info)
-{
- info->base.refcount -= 1;
- if (info->base.refcount == 0)
- {
- g_hash_table_destroy (info->annotations);
- free_method_list (&info->methods);
- free_signal_list (&info->signals);
- free_property_list (&info->properties);
- base_info_free (info);
- }
-}
-
-const char*
-interface_info_get_name (InterfaceInfo *info)
-{
- return info->base.name;
-}
-
-GSList *
-interface_info_get_annotations (InterfaceInfo *info)
-{
- return get_hash_keys (info->annotations);
-}
-
-const char*
-interface_info_get_annotation (InterfaceInfo *info,
- const char *name)
-{
- return g_hash_table_lookup (info->annotations, name);
-}
-
-GSList*
-interface_info_get_methods (InterfaceInfo *info)
-{
- return info->methods;
-}
-
-GSList*
-interface_info_get_signals (InterfaceInfo *info)
-{
- return info->signals;
-}
-
-GSList*
-interface_info_get_properties (InterfaceInfo *info)
-{
- return info->properties;
-}
-
-void
-interface_info_add_annotation (InterfaceInfo *info,
- const char *name,
- const char *value)
-{
- g_hash_table_insert (info->annotations,
- g_strdup (name),
- g_strdup (value));
-}
-
-void
-interface_info_add_method (InterfaceInfo *info,
- MethodInfo *method)
-{
- method_info_ref (method);
- info->methods = g_slist_append (info->methods, method);
-}
-
-void
-interface_info_add_signal (InterfaceInfo *info,
- SignalInfo *signal)
-{
- signal_info_ref (signal);
- info->signals = g_slist_append (info->signals, signal);
-}
-
-void
-interface_info_add_property (InterfaceInfo *info,
- PropertyInfo *property)
-{
- property_info_ref (property);
- info->properties = g_slist_append (info->properties, property);
-}
-
-static void
-free_arg_list (GSList **args_p)
-{
- GSList *tmp;
- tmp = *args_p;
- while (tmp != NULL)
- {
- ArgInfo *ai = tmp->data;
- g_assert (ai->base.type == INFO_TYPE_ARG);
- arg_info_unref (tmp->data);
- tmp = tmp->next;
- }
- g_slist_free (*args_p);
- *args_p = NULL;
-}
-
-MethodInfo*
-method_info_new (const char *name)
-{
- MethodInfo *info;
-
- g_return_val_if_fail (g_dbus_is_member_name (name), NULL);
-
- info = g_new0 (MethodInfo, 1);
- info->base.refcount = 1;
- info->base.name = g_strdup (name);
- info->base.type = INFO_TYPE_METHOD;
- info->annotations = g_hash_table_new_full (g_str_hash, g_str_equal,
- (GDestroyNotify) g_free,
- (GDestroyNotify) g_free);
-
- return info;
-}
-
-MethodInfo *
-method_info_ref (MethodInfo *info)
-{
- info->base.refcount += 1;
-
- return info;
-}
-
-void
-method_info_unref (MethodInfo *info)
-{
- info->base.refcount -= 1;
- if (info->base.refcount == 0)
- {
- g_hash_table_destroy (info->annotations);
- free_arg_list (&info->args);
- base_info_free (info);
- }
-}
-
-const char*
-method_info_get_name (MethodInfo *info)
-{
- return info->base.name;
-}
-
-GSList *
-method_info_get_annotations (MethodInfo *info)
-{
- return get_hash_keys (info->annotations);
-}
-
-const char*
-method_info_get_annotation (MethodInfo *info,
- const char *name)
-{
- return g_hash_table_lookup (info->annotations, name);
-}
-
-GSList*
-method_info_get_args (MethodInfo *info)
-{
- return info->args;
-}
-
-int
-method_info_get_n_args (MethodInfo *info)
-{
- return g_slist_length (info->args);
-}
-
-static int
-args_sort_by_direction (const void *a,
- const void *b)
-{
- const ArgInfo *arg_a = a;
- const ArgInfo *arg_b = b;
-
- if (arg_a->direction == arg_b->direction)
- return 0;
- else if (arg_a->direction == ARG_IN)
- return -1; /* in is less than out */
- else
- return 1;
-}
-
-void
-method_info_add_annotation (MethodInfo *info,
- const char *name,
- const char *value)
-{
- g_hash_table_insert (info->annotations,
- g_strdup (name),
- g_strdup (value));
-}
-
-void
-method_info_add_arg (MethodInfo *info,
- ArgInfo *arg)
-{
- arg_info_ref (arg);
- info->args = g_slist_append (info->args, arg);
-
- /* Keep "in" args sorted before "out" and otherwise maintain
- * stable order (g_slist_sort is stable, at least in sufficiently
- * new glib)
- */
- info->args = g_slist_sort (info->args, args_sort_by_direction);
-}
-
-SignalInfo*
-signal_info_new (const char *name)
-{
- SignalInfo *info;
-
- g_return_val_if_fail (g_dbus_is_member_name (name), NULL);
-
- info = g_new0 (SignalInfo, 1);
- info->base.refcount = 1;
- info->base.name = g_strdup (name);
- info->base.type = INFO_TYPE_SIGNAL;
-
- return info;
-}
-
-SignalInfo *
-signal_info_ref (SignalInfo *info)
-{
- info->base.refcount += 1;
-
- return info;
-}
-
-void
-signal_info_unref (SignalInfo *info)
-{
- info->base.refcount -= 1;
- if (info->base.refcount == 0)
- {
- free_arg_list (&info->args);
- base_info_free (info);
- }
-}
-
-const char*
-signal_info_get_name (SignalInfo *info)
-{
- return info->base.name;
-}
-
-GSList*
-signal_info_get_args (SignalInfo *info)
-{
- return info->args;
-}
-
-int
-signal_info_get_n_args (SignalInfo *info)
-{
- return g_slist_length (info->args);
-}
-
-void
-signal_info_add_arg (SignalInfo *info,
- ArgInfo *arg)
-{
- g_assert (arg->direction == ARG_OUT);
-
- arg_info_ref (arg);
- info->args = g_slist_append (info->args, arg);
-
- /* signal args don't need sorting since only "out" is allowed */
-}
-
-PropertyInfo*
-property_info_new (const char *name,
- const char *type,
- PropertyAccessFlags access)
-{
- PropertyInfo *info;
-
- g_return_val_if_fail (g_utf8_validate (name, -1, NULL), NULL);
- g_return_val_if_fail (g_variant_is_signature (type), NULL);
-
- info = g_new0 (PropertyInfo, 1);
- info->base.refcount = 1;
- info->base.name = g_strdup (name);
- info->base.type = INFO_TYPE_PROPERTY;
-
- info->type = g_strdup (type);
- info->access = access;
-
- return info;
-}
-
-PropertyInfo*
-property_info_ref (PropertyInfo *info)
-{
- info->base.refcount += 1;
-
- return info;
-}
-
-void
-property_info_unref (PropertyInfo *info)
-{
- info->base.refcount -= 1;
- if (info->base.refcount == 0)
- {
- g_free (info->type);
- base_info_free (info);
- }
-}
-
-const char*
-property_info_get_name (PropertyInfo *info)
-{
- return info->base.name;
-}
-
-const char *
-property_info_get_type (PropertyInfo *info)
-{
- return info->type;
-}
-
-PropertyAccessFlags
-property_info_get_access (PropertyInfo *info)
-{
- return info->access;
-}
-
-ArgInfo*
-arg_info_new (const char *name,
- ArgDirection direction,
- const char *type)
-{
- ArgInfo *info;
-
- info = g_new0 (ArgInfo, 1);
- info->base.refcount = 1;
- info->base.type = INFO_TYPE_ARG;
-
- /* name can be NULL */
- info->base.name = g_strdup (name);
- info->direction = direction;
- info->type = g_strdup (type);
- info->annotations = g_hash_table_new_full (g_str_hash, g_str_equal,
- (GDestroyNotify) g_free,
- (GDestroyNotify) g_free);
-
- return info;
-}
-
-ArgInfo *
-arg_info_ref (ArgInfo *info)
-{
- info->base.refcount += 1;
-
- return info;
-}
-
-void
-arg_info_unref (ArgInfo *info)
-{
- info->base.refcount -= 1;
- if (info->base.refcount == 0)
- {
- g_hash_table_destroy (info->annotations);
- g_free (info->type);
- base_info_free (info);
- }
-}
-
-const char*
-arg_info_get_name (ArgInfo *info)
-{
- return info->base.name;
-}
-
-const char *
-arg_info_get_type (ArgInfo *info)
-{
- return info->type;
-}
-
-ArgDirection
-arg_info_get_direction (ArgInfo *info)
-{
- return info->direction;
-}
-
-GSList*
-arg_info_get_annotations (ArgInfo *info)
-{
- return get_hash_keys (info->annotations);
-}
-
-const char*
-arg_info_get_annotation (ArgInfo *info,
- const char *annotation)
-{
- return g_hash_table_lookup (info->annotations, annotation);
-}
-
-void
-arg_info_add_annotation (ArgInfo *info,
- const char *name,
- const char *value)
-{
- g_hash_table_insert (info->annotations,
- g_strdup (name),
- g_strdup (value));
-}
diff --git a/dbus/dbus-gidl.h b/dbus/dbus-gidl.h
deleted file mode 100644
index d9837ce..0000000
--- a/dbus/dbus-gidl.h
+++ /dev/null
@@ -1,154 +0,0 @@
-/* -*- mode: C; c-file-style: "gnu" -*- */
-/* dbus-gidl.h data structure describing an interface, to be generated from IDL
- * or something
- *
- * Copyright (C) 2003 Red Hat, Inc.
- *
- * Licensed under the Academic Free License version 2.1
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- */
-#ifndef DBUS_GLIB_IDL_H
-#define DBUS_GLIB_IDL_H
-
-#include <dbus/dbus.h>
-#include <glib-object.h>
-
-G_BEGIN_DECLS
-
-typedef struct BaseInfo BaseInfo;
-typedef struct NodeInfo NodeInfo;
-typedef struct InterfaceInfo InterfaceInfo;
-typedef struct MethodInfo MethodInfo;
-typedef struct SignalInfo SignalInfo;
-typedef struct PropertyInfo PropertyInfo;
-typedef struct ArgInfo ArgInfo;
-
-typedef enum
-{
- ARG_INVALID = -1,
- ARG_IN,
- ARG_OUT
-} ArgDirection;
-
-typedef enum
-{
- PROPERTY_READ = 1 << 0,
- PROPERTY_WRITE = 1 << 1
-} PropertyAccessFlags;
-
-typedef enum
-{
- INFO_TYPE_NODE,
- INFO_TYPE_INTERFACE,
- INFO_TYPE_METHOD,
- INFO_TYPE_SIGNAL,
- INFO_TYPE_ARG,
- INFO_TYPE_PROPERTY
-
-} InfoType;
-
-BaseInfo* base_info_ref (BaseInfo *info);
-void base_info_unref (BaseInfo *info);
-InfoType base_info_get_type (BaseInfo *info);
-const char* base_info_get_name (BaseInfo *info);
-void base_info_set_name (BaseInfo *info,
- const char *name);
-GType base_info_get_gtype (void);
-#define BASE_INFO_TYPE (base_info_get_gtype ())
-
-
-NodeInfo* node_info_new (const char *name);
-NodeInfo* node_info_ref (NodeInfo *info);
-void node_info_unref (NodeInfo *info);
-const char* node_info_get_name (NodeInfo *info);
-GSList* node_info_get_interfaces (NodeInfo *info);
-GSList* node_info_get_nodes (NodeInfo *info);
-void node_info_add_interface (NodeInfo *info,
- InterfaceInfo *iface);
-void node_info_add_node (NodeInfo *info,
- NodeInfo *child);
-void node_info_replace_node (NodeInfo *info,
- NodeInfo *old_child,
- NodeInfo *new_child);
-InterfaceInfo* interface_info_new (const char *name);
-InterfaceInfo* interface_info_ref (InterfaceInfo *info);
-void interface_info_unref (InterfaceInfo *info);
-const char* interface_info_get_name (InterfaceInfo *info);
-GSList* interface_info_get_annotations(InterfaceInfo *info);
-const char* interface_info_get_annotation (InterfaceInfo*info,
- const char *annotation);
-GSList* interface_info_get_methods (InterfaceInfo *info);
-GSList* interface_info_get_signals (InterfaceInfo *info);
-GSList* interface_info_get_properties (InterfaceInfo *info);
-void interface_info_add_annotation (InterfaceInfo *info,
- const char *name,
- const char *value);
-void interface_info_add_method (InterfaceInfo *info,
- MethodInfo *method);
-void interface_info_add_signal (InterfaceInfo *info,
- SignalInfo *signal);
-void interface_info_add_property (InterfaceInfo *info,
- PropertyInfo *property);
-MethodInfo* method_info_new (const char *name);
-MethodInfo* method_info_ref (MethodInfo *info);
-void method_info_unref (MethodInfo *info);
-const char* method_info_get_name (MethodInfo *info);
-GSList* method_info_get_annotations (MethodInfo *info);
-const char* method_info_get_annotation (MethodInfo *info,
- const char *annotation);
-void method_info_add_annotation (MethodInfo *info,
- const char *name,
- const char *value);
-GSList* method_info_get_args (MethodInfo *info);
-void method_info_add_arg (MethodInfo *info,
- ArgInfo *arg);
-int method_info_get_n_args (MethodInfo *info);
-SignalInfo* signal_info_new (const char *name);
-SignalInfo* signal_info_ref (SignalInfo *info);
-void signal_info_unref (SignalInfo *info);
-const char* signal_info_get_name (SignalInfo *info);
-GSList* signal_info_get_args (SignalInfo *info);
-void signal_info_add_arg (SignalInfo *info,
- ArgInfo *arg);
-int signal_info_get_n_args (SignalInfo *info);
-PropertyInfo* property_info_new (const char *name,
- const char *type,
- PropertyAccessFlags access);
-PropertyInfo* property_info_ref (PropertyInfo *info);
-void property_info_unref (PropertyInfo *info);
-const char* property_info_get_name (PropertyInfo *info);
-const char* property_info_get_type (PropertyInfo *info);
-PropertyAccessFlags property_info_get_access (PropertyInfo *info);
-ArgInfo* arg_info_new (const char *name,
- ArgDirection direction,
- const char *type);
-ArgInfo* arg_info_ref (ArgInfo *info);
-void arg_info_unref (ArgInfo *info);
-const char* arg_info_get_name (ArgInfo *info);
-const char* arg_info_get_type (ArgInfo *info);
-ArgDirection arg_info_get_direction (ArgInfo *info);
-GSList* arg_info_get_annotations (ArgInfo *info);
-const char* arg_info_get_annotation (ArgInfo *info,
- const char *annotation);
-void arg_info_add_annotation (ArgInfo *info,
- const char *name,
- const char *value);
-
-
-G_END_DECLS
-
-#endif /* DBUS_GLIB_IDL_H */
diff --git a/dbus/dbus-glib-lowlevel.h b/dbus/dbus-glib-lowlevel.h
deleted file mode 100644
index d08f951..0000000
--- a/dbus/dbus-glib-lowlevel.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/* -*- mode: C; c-file-style: "gnu" -*- */
-/* dbus-glib-lowlevel.h GLib integration details that require dbus/dbus.h
- *
- * Copyright (C) 2002, 2003 CodeFactory AB
- * Copyright (C) 2003, 2004 Red Hat, Inc.
- *
- * Licensed under the Academic Free License version 2.1
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- */
-#ifndef DBUS_GLIB_LOWLEVEL_H
-#define DBUS_GLIB_LOWLEVEL_H
-
-#include <dbus/dbus-glib.h>
-#include <dbus/dbus.h>
-
-G_BEGIN_DECLS
-
-void dbus_set_g_error (GError **gerror,
- DBusError *derror);
-
-#define DBUS_TYPE_CONNECTION (dbus_connection_get_g_type ())
-#define DBUS_TYPE_MESSAGE (dbus_message_get_g_type ())
-GType dbus_connection_get_g_type (void) G_GNUC_CONST;
-GType dbus_message_get_g_type (void) G_GNUC_CONST;
-
-void dbus_connection_setup_with_g_main (DBusConnection *connection,
- GMainContext *context);
-void dbus_server_setup_with_g_main (DBusServer *server,
- GMainContext *context);
-
-void dbus_g_proxy_send (DBusGProxy *proxy,
- DBusMessage *message,
- dbus_uint32_t *client_serial);
-
-DBusConnection* dbus_g_connection_get_connection (DBusGConnection *gconnection);
-DBusGConnection* dbus_connection_get_g_connection (DBusConnection *connection);
-DBusMessage* dbus_g_message_get_message (DBusGMessage *gmessage);
-
-gchar* dbus_g_method_get_sender (DBusGMethodInvocation *context);
-
-DBusMessage* dbus_g_method_get_reply (DBusGMethodInvocation *context);
-
-void dbus_g_method_send_reply (DBusGMethodInvocation *context,
- DBusMessage *reply);
-
-G_END_DECLS
-
-#endif /* DBUS_GLIB_LOWLEVEL_H */
-
-
-
diff --git a/dbus/dbus-glib-tool.c b/dbus/dbus-glib-tool.c
deleted file mode 100644
index ce9ad75..0000000
--- a/dbus/dbus-glib-tool.c
+++ /dev/null
@@ -1,478 +0,0 @@
-/* -*- mode: C; c-file-style: "gnu" -*- */
-/* dbus-glib-tool.c Tool used by apps using glib bindings
- *
- * Copyright (C) 2003, 2004 Red Hat, Inc.
- *
- * Licensed under the Academic Free License version 2.1
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- */
-
-#include <config.h>
-#include "dbus-gidl.h"
-#include "dbus-gparser.h"
-#include "dbus-gutils.h"
-#include "dbus-glib-tool.h"
-#include "dbus-binding-tool-glib.h"
-#include <glib/gstdio.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <errno.h>
-#include <sys/stat.h>
-#include <string.h>
-#include <time.h>
-
-typedef enum {
- DBUS_BINDING_OUTPUT_NONE,
- DBUS_BINDING_OUTPUT_PRETTY,
- DBUS_BINDING_OUTPUT_GLIB_SERVER,
- DBUS_BINDING_OUTPUT_GLIB_CLIENT
-} DBusBindingOutputMode;
-
-static void
-indent (int depth)
-{
- depth *= 2; /* 2-space indent */
-
- while (depth > 0)
- {
- putc (' ', stdout);
- --depth;
- }
-}
-
-static void pretty_print (BaseInfo *base,
- int depth);
-
-static void
-pretty_print_list (GSList *list,
- int depth)
-{
- GSList *tmp;
-
- tmp = list;
- while (tmp != NULL)
- {
- pretty_print (tmp->data, depth);
- tmp = tmp->next;
- }
-}
-
-static void
-pretty_print (BaseInfo *base,
- int depth)
-{
- InfoType t;
- const char *name;
-
- t = base_info_get_type (base);
- name = base_info_get_name (base);
-
- indent (depth);
-
- switch (t)
- {
- case INFO_TYPE_NODE:
- {
- NodeInfo *n = (NodeInfo*) base;
-
- if (name == NULL)
- printf ("<anonymous node> {\n");
- else
- printf ("node \"%s\" {\n", name);
-
- pretty_print_list (node_info_get_interfaces (n), depth + 1);
- pretty_print_list (node_info_get_nodes (n), depth + 1);
-
- indent (depth);
- printf ("}\n");
- }
- break;
- case INFO_TYPE_INTERFACE:
- {
- InterfaceInfo *i = (InterfaceInfo*) base;
- GSList *annotations, *elt;
-
- g_assert (name != NULL);
-
- printf ("interface \"%s\" {\n", name);
-
- annotations = interface_info_get_annotations (i);
- for (elt = annotations; elt; elt = elt->next)
- {
- const char *name = elt->data;
- const char *value = interface_info_get_annotation (i, name);
-
- printf (" (binding \"%s\": \"%s\") ",
- name, value);
- }
- g_slist_free (annotations);
-
- pretty_print_list (interface_info_get_methods (i), depth + 1);
- pretty_print_list (interface_info_get_signals (i), depth + 1);
- pretty_print_list (interface_info_get_properties (i), depth + 1);
-
- indent (depth);
- printf ("}\n");
- }
- break;
- case INFO_TYPE_METHOD:
- {
- MethodInfo *m = (MethodInfo*) base;
- GSList *annotations, *elt;
-
- g_assert (name != NULL);
-
- annotations = method_info_get_annotations (m);
- printf ("method \"%s\" (\n", name);
- for (elt = annotations; elt; elt = elt->next)
- {
- const char *name = elt->data;
- const char *value = method_info_get_annotation (m, name);
-
- printf (" (annotation \"%s\": \"%s\") ",
- name, value);
- }
- g_slist_free (annotations);
-
- pretty_print_list (method_info_get_args (m), depth + 1);
-
- indent (depth);
- printf (")\n");
- }
- break;
- case INFO_TYPE_SIGNAL:
- {
- SignalInfo *s = (SignalInfo*) base;
-
- g_assert (name != NULL);
-
- printf ("signal \"%s\" (\n", name);
-
- pretty_print_list (signal_info_get_args (s), depth + 1);
-
- indent (depth);
- printf (")\n");
- }
- break;
- case INFO_TYPE_PROPERTY:
- {
- PropertyInfo *a = (PropertyInfo*) base;
- const char *pt = property_info_get_type (a);
- PropertyAccessFlags acc = property_info_get_access (a);
-
- printf ("%s%s %s",
- acc & PROPERTY_READ ? "read" : "",
- acc & PROPERTY_WRITE ? "write" : "",
- pt);
- if (name)
- printf (" %s\n", name);
- else
- printf ("\n");
- }
- break;
- case INFO_TYPE_ARG:
- {
- ArgInfo *a = (ArgInfo*) base;
- const char *at = arg_info_get_type (a);
- ArgDirection d = arg_info_get_direction (a);
-
- printf ("%s %s",
- d == ARG_IN ? "in" : "out",
- at);
- if (name)
- printf (" %s\n", name);
- else
- printf ("\n");
- }
- break;
- }
-}
-
-GQuark
-dbus_binding_tool_error_quark (void)
-{
- static GQuark quark = 0;
- if (!quark)
- quark = g_quark_from_static_string ("dbus_binding_tool_error");
-
- return quark;
-}
-
-static void warn (const char *fmt, ...) G_GNUC_PRINTF (1, 2);
-static void warn_gerror (const char *prefix, GError *error);
-
-static void
-warn (const char *str, ...)
-{
- va_list args;
-
- va_start (args, str);
-
- vfprintf (stderr, str, args);
- fputc ('\n', stderr);
-
- va_end (args);
-}
-
-static void
-warn_gerror (const char *prefix, GError *error)
-{
- warn ("%s: %s", prefix, error->message);
-}
-
-static void
-usage (int ecode)
-{
- fprintf (stderr, "dbus-binding-tool [--version] [--help]\n");
- fprintf (stderr, "dbus-binding-tool --mode=[pretty|glib-server|glib-client] [--prefix=SYMBOL_PREFIX] [--ignore-unsupported] [--force] [--output=FILE]\n");
- fprintf (stderr, "dbus-binding-tool --mode=glib-server --prefix=SYMBOL_PREFIX [--ignore-unsupported] [--force] [--output=FILE]\n");
- exit (ecode);
-}
-
-static void
-version (void)
-{
- printf ("D-BUS Binding Tool %s\n"
- "Copyright (C) 2003-2005 Red Hat, Inc.\n"
- "This is free software; see the source for copying conditions.\n"
- "There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n",
- VERSION);
- exit (0);
-}
-
-int
-main (int argc, char **argv)
-{
- const char *output_file;
- const char *prefix;
- char *output_file_tmp = NULL;
- int i;
- GSList *files;
- DBusBindingOutputMode outputmode;
- gboolean end_of_args;
- GSList *tmp;
- GIOChannel *channel = NULL;
- GError *error;
- time_t newest_src;
- struct stat srcbuf;
- struct stat targetbuf;
- gboolean force;
- gboolean ignore_unsupported;
- gboolean has_prefix = FALSE;
-
- g_type_init ();
-
- outputmode = DBUS_BINDING_OUTPUT_NONE;
- end_of_args = FALSE;
- files = NULL;
- output_file = NULL;
- prefix = "";
- ignore_unsupported = FALSE;
- force = FALSE;
- i = 1;
- while (i < argc)
- {
- const char *arg = argv[i];
-
- if (!end_of_args)
- {
- if (strcmp (arg, "--help") == 0 ||
- strcmp (arg, "-h") == 0 ||
- strcmp (arg, "-?") == 0)
- usage (0);
- else if (strcmp (arg, "--version") == 0)
- version ();
- else if (strcmp (arg, "--force") == 0)
- force = TRUE;
- else if (strncmp (arg, "--mode=", 7) == 0)
- {
- const char *mode = arg + 7;
- if (!strcmp (mode, "pretty"))
- outputmode = DBUS_BINDING_OUTPUT_PRETTY;
- else if (!strcmp (mode, "glib-server"))
- outputmode = DBUS_BINDING_OUTPUT_GLIB_SERVER;
- else if (!strcmp (mode, "glib-client"))
- outputmode = DBUS_BINDING_OUTPUT_GLIB_CLIENT;
- else
- usage (1);
- }
- else if (strcmp (arg, "--ignore-unsupported") == 0)
- ignore_unsupported = TRUE;
- else if (strncmp (arg, "--output=", 9) == 0)
- {
- output_file = arg + 9;
- }
- else if (strncmp (arg, "--prefix=", 9) == 0)
- {
- has_prefix = TRUE;
- prefix = arg + 9;
- }
- else if (arg[0] == '-' &&
- arg[1] == '-' &&
- arg[2] == '\0')
- end_of_args = TRUE;
- else if (arg[0] == '-')
- {
- usage (1);
- }
- else
- {
- files = g_slist_prepend (files, (char*) arg);
- }
- }
- else
- files = g_slist_prepend (files, (char*) arg);
-
- ++i;
- }
-
- if (outputmode == DBUS_BINDING_OUTPUT_GLIB_SERVER && !has_prefix)
- usage (1);
-
- error = NULL;
-
- files = g_slist_reverse (files);
-
- if (output_file && !force)
- {
- newest_src = 0;
- for (tmp = files; tmp != NULL; tmp = tmp->next)
- {
- const char *filename;
-
- filename = tmp->data;
- if (stat (filename, &srcbuf) < 0)
- {
- warn ("Couldn't stat %s: %s", filename, g_strerror (errno));
- goto lose;
- }
-
- if (srcbuf.st_mtime > newest_src)
- newest_src = srcbuf.st_mtime;
- }
-
- if (stat (output_file, &targetbuf) > 0
- && targetbuf.st_mtime >= newest_src)
- exit (0);
- }
-
- if (output_file)
- {
- output_file_tmp = g_strconcat (output_file, ".tmp", NULL);
-
- if (!(channel = g_io_channel_new_file (output_file_tmp, "w", &error)))
- {
- warn_gerror ("Couldn't open temporary file", error);
- goto lose;
- }
- }
- else
- {
- channel = g_io_channel_unix_new (fileno (stdout));
- }
-
- if (!g_io_channel_set_encoding (channel, NULL, &error))
- {
- warn_gerror ("Couldn't set channel encoding to NULL", error);
- goto lose;
- }
-
-
- for (tmp = files; tmp != NULL; tmp = tmp->next)
- {
- NodeInfo *node;
- GError *error;
- const char *filename;
-
- filename = tmp->data;
-
- error = NULL;
- node = description_load_from_file (filename,
- &error);
- if (node == NULL)
- {
- warn ("Unable to load \"%s\": %s", filename, error->message);
- goto lose;
- }
- else
- {
- switch (outputmode)
- {
- case DBUS_BINDING_OUTPUT_PRETTY:
- pretty_print ((BaseInfo*) node, 0);
- break;
- case DBUS_BINDING_OUTPUT_GLIB_SERVER:
- if (!dbus_binding_tool_output_glib_server ((BaseInfo *) node, channel, prefix, &error))
- {
- warn_gerror ("Compilation failed", error);
- node_info_unref (node);
- goto lose;
- }
- break;
- case DBUS_BINDING_OUTPUT_GLIB_CLIENT:
- if (!dbus_binding_tool_output_glib_client ((BaseInfo *) node, channel, ignore_unsupported, &error))
- {
- warn_gerror ("Compilation failed", error);
- node_info_unref (node);
- goto lose;
- }
- break;
- case DBUS_BINDING_OUTPUT_NONE:
- break;
- }
- }
-
- if (node)
- node_info_unref (node);
- }
-
- if (g_io_channel_shutdown (channel, TRUE, &error) != G_IO_STATUS_NORMAL)
- {
- warn_gerror ("Failed to shutdown IO channel", error);
- goto lose;
- }
-
- g_io_channel_unref (channel);
- channel = NULL;
-
- if (output_file)
- {
- if (rename (output_file_tmp, output_file) < 0)
- {
- warn ("Failed to rename %s to %s: %s", output_file_tmp, output_file,
- g_strerror (errno));
- goto lose;
- }
- g_free (output_file_tmp);
- }
-
- return 0;
-
-lose:
- /* ignore errors, we're already handling an error */
- if (channel != NULL)
- {
- (void) g_io_channel_shutdown (channel, FALSE, NULL);
- g_io_channel_unref (channel);
- }
-
- if (output_file_tmp != NULL)
- (void) g_remove (output_file_tmp);
-
- g_free (output_file_tmp);
- return 1;
-}
diff --git a/dbus/dbus-glib-tool.h b/dbus/dbus-glib-tool.h
deleted file mode 100644
index 58f25d2..0000000
--- a/dbus/dbus-glib-tool.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/* -*- mode: C; c-file-style: "gnu" -*- */
-/* dbus-glib-tool.h: Definitions used internally by binding tool
- *
- * Copyright (C) 2005 Red Hat, Inc.
- *
- * Licensed under the Academic Free License version 2.1
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- */
-#ifndef DBUS_BINDING_TOOL_H
-#define DBUS_BINDING_TOOL_H
-
-#include <glib.h>
-
-typedef enum
-{
- DBUS_BINDING_TOOL_ERROR_UNSUPPORTED_CONVERSION,
- DBUS_BINDING_TOOL_ERROR_INVALID_ANNOTATION
-} DBusBindingToolError;
-
-#define DBUS_BINDING_TOOL_ERROR dbus_binding_tool_error_quark ()
-
-GQuark dbus_binding_tool_error_quark (void);
-
-#endif
diff --git a/dbus/dbus-glib.c b/dbus/dbus-glib.c
deleted file mode 100644
index 9723882..0000000
--- a/dbus/dbus-glib.c
+++ /dev/null
@@ -1,639 +0,0 @@
-/* -*- mode: C; c-file-style: "gnu" -*- */
-/* dbus-glib.c General GLib binding stuff
- *
- * Copyright (C) 2004 Red Hat, Inc.
- *
- * Licensed under the Academic Free License version 2.1
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- */
-
-#include <config.h>
-#include "dbus/dbus-glib.h"
-#include "dbus/dbus-glib-lowlevel.h"
-#include "dbus-gmain/dbus-gmain.h"
-#include "dbus-gtest.h"
-#include "dbus-gutils.h"
-#include "dbus-gvalue.h"
-#include "dbus-gobject.h"
-#include <string.h>
-
-/**
- * SECTION:dbus-gconnection
- * @title: DBusGConnection
- * @short_description: DBus Connection
- * @see_also: #DBusConnection
- * @stability: Stable
- *
- * A #DBusGConnection is a boxed type abstracting a DBusConnection.
- */
-
-/**
- * DBusGConnection:
- *
- * A #DBusGConnection is a boxed type abstracting a DBusConnection from
- * libdbus.
- *
- * Deprecated: New code should use #GDBusConnection from the GIO library,
- * which is not based on libdbus or dbus-glib.
- */
-
-/**
- * dbus_g_connection_flush:
- * @connection: the #DBusGConnection to flush
- *
- * Blocks until outgoing calls and signal emissions have been sent.
- *
- * Deprecated: The closest equivalent in GDBus is
- * #g_dbus_connection_flush_sync().
- */
-void
-dbus_g_connection_flush (DBusGConnection *connection)
-{
- dbus_connection_flush (DBUS_CONNECTION_FROM_G_CONNECTION (connection));
-}
-
-/**
- * dbus_g_connection_ref:
- * @connection: the #DBusGConnection to ref
- *
- * Increment refcount on a #DBusGConnection
- *
- * Returns: the connection that was ref'd
- *
- * Deprecated: New code should use #GDBusConnection instead.
- */
-DBusGConnection*
-dbus_g_connection_ref (DBusGConnection *connection)
-{
- DBusConnection *c;
-
- c = DBUS_CONNECTION_FROM_G_CONNECTION (connection);
- dbus_connection_ref (c);
- return connection;
-}
-
-
-/**
- * dbus_g_connection_unref:
- * @connection: the connection to unref
- *
- * Decrement refcount on a #DBusGConnection
- *
- * Deprecated: New code should use #GDBusConnection instead.
- */
-void
-dbus_g_connection_unref (DBusGConnection *connection)
-{
- DBusConnection *c;
-
- c = DBUS_CONNECTION_FROM_G_CONNECTION (connection);
- dbus_connection_unref (c);
-}
-
-
-/**
- * SECTION:dbus-gmessage
- * @title: DBusGMessage
- * @short_description: DBus Message
- * @see_also: #DBusMessage
- * @stability: Stable
- *
- * A #DBusGMessage is a boxed type abstracting a DBusMessage.
- */
-
-/**
- * DBusGMessage:
- *
- * A #DBusGMessage is a boxed type abstracting a DBusMessage from
- * libdbus.
- *
- * Deprecated: New code should use #GDBusMessage instead.
- */
-
-/**
- * dbus_g_message_ref:
- * @message: the message to ref
- *
- * Increment refcount on a #DBusGMessage
- *
- * Returns: the message that was ref'd
- *
- * Deprecated: New code should use #GDBusMessage instead.
- */
-DBusGMessage*
-dbus_g_message_ref (DBusGMessage *message)
-{
- DBusMessage *c;
-
- c = DBUS_MESSAGE_FROM_G_MESSAGE (message);
- dbus_message_ref (c);
- return message;
-}
-
-/**
- * dbus_g_message_unref:
- * @message: the message to unref
- *
- * Decrement refcount on a #DBusGMessage
- *
- * Deprecated: New code should use #GDBusMessage instead.
- */
-void
-dbus_g_message_unref (DBusGMessage *message)
-{
- DBusMessage *c;
-
- c = DBUS_MESSAGE_FROM_G_MESSAGE (message);
- dbus_message_unref (c);
-}
-
-/**
- * SECTION:dbus-gerror
- * @title: DBusGError
- * @short_description: DBus GError
- * @see_also: #GError
- * @stability: Stable
- *
- * #DBusGError is the #GError used by DBus.
- */
-
-/**
- * DBusGError:
- *
- * A #GError enumeration for the domain %DBUS_GERROR. The values' meanings
- * can be found by looking at the comments for the corresponding constants
- * in dbus-protocol.h.
- *
- * Deprecated: New code should use GDBus and its #GDBusError enum instead.
- */
-
-/**
- * DBUS_GERROR:
- *
- * Expands to a function call returning the error domain quark for #DBusGError,
- * for use with #GError.
- *
- * Deprecated: New code should use GDBus and its #GDBusError enum instead.
- */
-GQuark
-dbus_g_error_quark (void)
-{
- static GQuark quark = 0;
- if (quark == 0)
- quark = g_quark_from_static_string ("dbus-glib-error-quark");
- return quark;
-}
-
-/**
- * dbus_g_error_has_name:
- * @error: the GError given from the remote method
- * @name: the D-BUS error name
- *
- * Determine whether D-BUS error name for a remote exception matches
- * the given name. This function is intended to be invoked on a
- * #GError returned from an invocation of a remote method, e.g. via
- * dbus_g_proxy_end_call(). It will silently return %FALSE for errors
- * which are not remote D-BUS exceptions (i.e. with a domain other
- * than %DBUS_GERROR or a code other than
- * %DBUS_GERROR_REMOTE_EXCEPTION).
- *
- * Returns: %TRUE if and only if the remote error has the given name
- *
- * Deprecated: New code should use GDBus instead. The closest equivalent
- * is g_dbus_error_get_remote_error().
- */
-gboolean
-dbus_g_error_has_name (GError *error, const char *name)
-{
- g_return_val_if_fail (error != NULL, FALSE);
-
- if (error->domain != DBUS_GERROR
- || error->code != DBUS_GERROR_REMOTE_EXCEPTION)
- return FALSE;
-
- return !strcmp (dbus_g_error_get_name (error), name);
-}
-
-/**
- * dbus_g_error_get_name:
- * @error: the #GError given from the remote method
- *
- * This function may only be invoked on a #GError returned from an
- * invocation of a remote method, e.g. via dbus_g_proxy_end_call().
- * Moreover, you must ensure that the error's domain is %DBUS_GERROR,
- * and the code is %DBUS_GERROR_REMOTE_EXCEPTION.
- *
- * Returns: the D-BUS name for a remote exception.
- *
- * Deprecated: New code should use GDBus instead. The closest equivalent
- * is g_dbus_error_get_remote_error().
- */
-const char *
-dbus_g_error_get_name (GError *error)
-{
- g_return_val_if_fail (error != NULL, NULL);
- g_return_val_if_fail (error->domain == DBUS_GERROR, NULL);
- g_return_val_if_fail (error->code == DBUS_GERROR_REMOTE_EXCEPTION, NULL);
-
- return error->message + strlen (error->message) + 1;
-}
-
-/**
- * DBUS_TYPE_CONNECTION:
- *
- * Expands to a function call returning a boxed #GType representing a
- * #DBusConnection pointer from libdbus. Not to be confused with
- * %DBUS_TYPE_G_CONNECTION, which you should usually use instead.
- *
- * Returns: the GLib type
- *
- * Deprecated: New code should use GDBus instead.
- */
-GType
-dbus_connection_get_g_type (void)
-{
- static GType our_type = 0;
-
- if (our_type == 0)
- our_type = g_boxed_type_register_static ("DBusConnection",
- (GBoxedCopyFunc) dbus_connection_ref,
- (GBoxedFreeFunc) dbus_connection_unref);
-
- return our_type;
-}
-
-/**
- * DBUS_TYPE_MESSAGE:
- *
- * Expands to a function call returning a boxed #GType representing a
- * #DBusMessage pointer from libdbus. Not to be confused with
- * %DBUS_TYPE_G_MESSAGE, which you should usually use instead.
- *
- *
- * Returns: the GLib type
- *
- * Deprecated: New code should use GDBus instead.
- */
-GType
-dbus_message_get_g_type (void)
-{
- static GType our_type = 0;
-
- if (our_type == 0)
- our_type = g_boxed_type_register_static ("DBusMessage",
- (GBoxedCopyFunc) dbus_message_ref,
- (GBoxedFreeFunc) dbus_message_unref);
-
- return our_type;
-}
-
-/**
- * DBUS_TYPE_G_CONNECTION:
- *
- * Expands to a function call returning the boxed #GType of a #DBusGConnection.
- *
- * Returns: the GLib type
- *
- * Deprecated: New code should use GDBus instead.
- */
-GType
-dbus_g_connection_get_g_type (void)
-{
- static GType our_type = 0;
-
- if (our_type == 0)
- our_type = g_boxed_type_register_static ("DBusGConnection",
- (GBoxedCopyFunc) dbus_g_connection_ref,
- (GBoxedFreeFunc) dbus_g_connection_unref);
-
- return our_type;
-}
-
-/**
- * DBUS_TYPE_G_MESSAGE:
- *
- * Expands to a function call returning the boxed #GType of a #DBusGConnection.
- *
- * Returns: the GLib type
- *
- * Deprecated: New code should use GDBus instead.
- */
-GType
-dbus_g_message_get_g_type (void)
-{
- static GType our_type = 0;
-
- if (our_type == 0)
- our_type = g_boxed_type_register_static ("DBusGMessage",
- (GBoxedCopyFunc) dbus_g_message_ref,
- (GBoxedFreeFunc) dbus_g_message_unref);
-
- return our_type;
-}
-
-/**
- * SECTION:dbus-glib-lowlevel
- * @title: DBus GLib low level
- * @short_description: DBus lower level functions
- * @stability: Unstable
- *
- * These functions can be used to access lower level of DBus.
- */
-
-/**
- * dbus_g_connection_get_connection:
- * @gconnection: a #DBusGConnection
- *
- * Get the #DBusConnection corresponding to this #DBusGConnection.
- * The return value does not have its refcount incremented.
- *
- * Returns: #DBusConnection
- *
- * Deprecated: New code should use GDBus instead.
- */
-DBusConnection*
-dbus_g_connection_get_connection (DBusGConnection *gconnection)
-{
- g_return_val_if_fail (gconnection, NULL);
- return DBUS_CONNECTION_FROM_G_CONNECTION (gconnection);
-}
-
-extern dbus_int32_t _dbus_gmain_connection_slot;
-
-/**
- * dbus_connection_get_g_connection:
- * @connection: a #DBusConnection
- *
- * Get the #DBusGConnection corresponding to this #DBusConnection. This only
- * makes sense if the #DBusConnection was originally a #DBusGConnection that was
- * registered with the GLib main loop. The return value does not have its
- * refcount incremented.
- *
- * Returns: #DBusGConnection
- *
- * Deprecated: New code should use GDBus instead.
- */
-DBusGConnection*
-dbus_connection_get_g_connection (DBusConnection *connection)
-{
- g_return_val_if_fail (connection, NULL);
- g_return_val_if_fail (dbus_connection_get_data (connection, _dbus_gmain_connection_slot), NULL);
-
- return DBUS_G_CONNECTION_FROM_CONNECTION (connection);
-}
-
-
-/**
- * dbus_g_message_get_message:
- * @gmessage: a #DBusGMessage
- *
- * Get the #DBusMessage corresponding to this #DBusGMessage.
- * The return value does not have its refcount incremented.
- *
- * Returns: #DBusMessage
- *
- * Deprecated: New code should use GDBus instead.
- */
-DBusMessage*
-dbus_g_message_get_message (DBusGMessage *gmessage)
-{
- return DBUS_MESSAGE_FROM_G_MESSAGE (gmessage);
-}
-
-/**
- * dbus_g_connection_open:
- * @address: address of the connection to open
- * @error: address where an error can be returned.
- *
- * Returns a connection to the given address.
- *
- * (Internally, calls dbus_connection_open() then calls
- * dbus_connection_setup_with_g_main() on the result.)
- *
- * Returns: a DBusConnection
- *
- * Deprecated: New code should use GDBus instead. The closest equivalent
- * is g_dbus_connection_new_for_address_sync().
- */
-DBusGConnection*
-dbus_g_connection_open (const gchar *address,
- GError **error)
-{
- DBusConnection *connection;
- DBusError derror;
-
- g_return_val_if_fail (error == NULL || *error == NULL, NULL);
-
- _dbus_g_value_types_init ();
-
- dbus_error_init (&derror);
-
- connection = dbus_connection_open (address, &derror);
- if (connection == NULL)
- {
- dbus_set_g_error (error, &derror);
- dbus_error_free (&derror);
- return NULL;
- }
-
- /* does nothing if it's already been done */
- dbus_connection_setup_with_g_main (connection, NULL);
-
- return DBUS_G_CONNECTION_FROM_CONNECTION (connection);
-}
-
-/**
- * dbus_g_connection_open_private:
- * @address: address of the connection to open
- * @context: the #GMainContext or %NULL for default context
- * @error: address where an error can be returned.
- *
- * Returns a private connection to the given address; this
- * connection does not talk to a bus daemon and thus the caller
- * must set up any authentication by itself. If the address
- * refers to a message bus, the caller must call dbus_bus_register().
- *
- * (Internally, calls dbus_connection_open_private() then calls
- * dbus_connection_setup_with_g_main() on the result.)
- *
- * Returns: (transfer full): a #DBusGConnection
- *
- * Deprecated: New code should use GDBus instead. The closest equivalent
- * is g_dbus_connection_new_for_address_sync().
- */
-DBusGConnection *
-dbus_g_connection_open_private (const gchar *address,
- GMainContext *context,
- GError **error)
-{
- DBusConnection *connection;
- DBusError derror;
-
- g_return_val_if_fail (error == NULL || *error == NULL, NULL);
-
- _dbus_g_value_types_init ();
-
- dbus_error_init (&derror);
-
- connection = dbus_connection_open_private (address, &derror);
- if (connection == NULL)
- {
- dbus_set_g_error (error, &derror);
- dbus_error_free (&derror);
- return NULL;
- }
-
- dbus_connection_setup_with_g_main (connection, context);
-
- return DBUS_G_CONNECTION_FROM_CONNECTION (connection);
-}
-
-/**
- * dbus_g_bus_get:
- * @type: bus type
- * @error: address where an error can be returned.
- *
- * Returns a connection to the given bus. The connection is a global variable
- * shared with other callers of this function.
- *
- * (Internally, calls dbus_bus_get() then calls
- * dbus_connection_setup_with_g_main() on the result.)
- *
- * Returns: a DBusConnection
- *
- * Deprecated: New code should use GDBus instead. The closest equivalent
- * is g_bus_get_sync().
- */
-DBusGConnection*
-dbus_g_bus_get (DBusBusType type,
- GError **error)
-{
- DBusConnection *connection;
- DBusError derror;
-
- g_return_val_if_fail (error == NULL || *error == NULL, NULL);
-
- _dbus_g_value_types_init ();
-
- dbus_error_init (&derror);
-
- connection = dbus_bus_get (type, &derror);
- if (connection == NULL)
- {
- dbus_set_g_error (error, &derror);
- dbus_error_free (&derror);
- return NULL;
- }
-
- /* does nothing if it's already been done */
- dbus_connection_setup_with_g_main (connection, NULL);
-
- return DBUS_G_CONNECTION_FROM_CONNECTION (connection);
-}
-
-/**
- * dbus_g_bus_get_private:
- * @type: bus type
- * @context: Mainloop context to attach to
- * @error: address where an error can be returned.
- *
- * Returns a connection to the given bus. The connection will be a private
- * non-shared connection and should be closed when usage is complete.
- *
- * Internally this function calls dbus_bus_get_private() then calls
- * dbus_connection_setup_with_g_main() on the result; see the documentation
- * of the former function for more information on private connections.
- *
- * Returns: a DBusConnection
- *
- * Deprecated: New code should use GDBus instead. The closest equivalent
- * is g_bus_get_sync().
- */
-DBusGConnection*
-dbus_g_bus_get_private (DBusBusType type,
- GMainContext *context,
- GError **error)
-{
- DBusConnection *connection;
- DBusError derror;
-
- g_return_val_if_fail (error == NULL || *error == NULL, NULL);
-
- _dbus_g_value_types_init ();
-
- dbus_error_init (&derror);
-
- connection = dbus_bus_get_private (type, &derror);
- if (connection == NULL)
- {
- dbus_set_g_error (error, &derror);
- dbus_error_free (&derror);
- return NULL;
- }
-
- /* does nothing if it's already been done */
- dbus_connection_setup_with_g_main (connection, context);
-
- return DBUS_G_CONNECTION_FROM_CONNECTION (connection);
-}
-
-/**
- * dbus_connection_setup_with_g_main:
- * @connection: the connection
- * @context: the #GMainContext or %NULL for default context
- *
- * Sets the watch and timeout functions of a #DBusConnection
- * to integrate the connection with the GLib main loop.
- * Pass in %NULL for the #GMainContext unless you're
- * doing something specialized.
- *
- * If called twice for the same context, does nothing the second
- * time. If called once with context A and once with context B,
- * context B replaces context A as the context monitoring the
- * connection.
- *
- * Deprecated: New code should use GDBus instead.
- */
-void
-dbus_connection_setup_with_g_main (DBusConnection *connection,
- GMainContext *context)
-{
- _dbus_g_set_up_connection (connection, context);
-}
-
-/**
- * dbus_server_setup_with_g_main:
- * @server: the server
- * @context: the #GMainContext or %NULL for default
- *
- * Sets the watch and timeout functions of a #DBusServer
- * to integrate the server with the GLib main loop.
- * In most cases the context argument should be %NULL.
- *
- * If called twice for the same context, does nothing the second
- * time. If called once with context A and once with context B,
- * context B replaces context A as the context monitoring the
- * connection.
- *
- * Deprecated: New code should use GDBus instead.
- */
-void
-dbus_server_setup_with_g_main (DBusServer *server,
- GMainContext *context)
-{
- _dbus_g_set_up_server (server, context);
-}
diff --git a/dbus/dbus-glib.h b/dbus/dbus-glib.h
deleted file mode 100644
index 9aa71c1..0000000
--- a/dbus/dbus-glib.h
+++ /dev/null
@@ -1,346 +0,0 @@
-/* -*- mode: C; c-file-style: "gnu" -*- */
-/* dbus-glib.h GLib integration
- *
- * Copyright (C) 2002, 2003 CodeFactory AB
- * Copyright (C) 2003, 2004 Red Hat, Inc.
- *
- * Licensed under the Academic Free License version 2.1
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- */
-#ifndef DBUS_GLIB_H
-#define DBUS_GLIB_H
-
-#include <glib-object.h>
-#include <dbus/dbus-shared.h>
-
-G_BEGIN_DECLS
-
-#define DBUS_INSIDE_DBUS_GLIB_H 1
-
-
-/*
- * Convert to DBusConnection with dbus_g_connection_get_connection() in dbus-glib-lowlevel.h
- */
-typedef struct _DBusGConnection DBusGConnection;
-/*
- * Convert to DBusMessage with dbus_g_message_get_message() in dbus-glib-lowlevel.h
- */
-typedef struct _DBusGMessage DBusGMessage;
-
-
-#define DBUS_TYPE_G_CONNECTION (dbus_g_connection_get_g_type ())
-#define DBUS_TYPE_G_MESSAGE (dbus_g_message_get_g_type ())
-GType dbus_g_connection_get_g_type (void) G_GNUC_CONST;
-GType dbus_g_message_get_g_type (void) G_GNUC_CONST;
-
-
-DBusGConnection* dbus_g_connection_ref (DBusGConnection *connection);
-void dbus_g_connection_unref (DBusGConnection *connection);
-DBusGMessage* dbus_g_message_ref (DBusGMessage *message);
-void dbus_g_message_unref (DBusGMessage *message);
-
-void dbus_g_connection_flush (DBusGConnection *connection);
-
-GQuark dbus_g_error_quark (void);
-#define DBUS_GERROR dbus_g_error_quark ()
-
-typedef enum
-{
-DBUS_GERROR_FAILED,
-DBUS_GERROR_NO_MEMORY,
-DBUS_GERROR_SERVICE_UNKNOWN,
-DBUS_GERROR_NAME_HAS_NO_OWNER,
-DBUS_GERROR_NO_REPLY,
-DBUS_GERROR_IO_ERROR,
-DBUS_GERROR_BAD_ADDRESS,
-DBUS_GERROR_NOT_SUPPORTED,
-DBUS_GERROR_LIMITS_EXCEEDED,
-DBUS_GERROR_ACCESS_DENIED,
-DBUS_GERROR_AUTH_FAILED,
-DBUS_GERROR_NO_SERVER,
-DBUS_GERROR_TIMEOUT,
-DBUS_GERROR_NO_NETWORK,
-DBUS_GERROR_ADDRESS_IN_USE,
-DBUS_GERROR_DISCONNECTED,
-DBUS_GERROR_INVALID_ARGS,
-DBUS_GERROR_FILE_NOT_FOUND,
-DBUS_GERROR_FILE_EXISTS,
-DBUS_GERROR_UNKNOWN_METHOD,
-DBUS_GERROR_TIMED_OUT,
-DBUS_GERROR_MATCH_RULE_NOT_FOUND,
-DBUS_GERROR_MATCH_RULE_INVALID,
-DBUS_GERROR_SPAWN_EXEC_FAILED,
-DBUS_GERROR_SPAWN_FORK_FAILED,
-DBUS_GERROR_SPAWN_CHILD_EXITED,
-DBUS_GERROR_SPAWN_CHILD_SIGNALED,
-DBUS_GERROR_SPAWN_FAILED,
-DBUS_GERROR_UNIX_PROCESS_ID_UNKNOWN,
-DBUS_GERROR_INVALID_SIGNATURE,
-DBUS_GERROR_INVALID_FILE_CONTENT,
-DBUS_GERROR_SELINUX_SECURITY_CONTEXT_UNKNOWN,
-DBUS_GERROR_REMOTE_EXCEPTION
-} DBusGError;
-
-gboolean dbus_g_error_has_name (GError *error,
- const char *name);
-const char * dbus_g_error_get_name (GError *error);
-
-void dbus_g_thread_init (void);
-
-DBusGConnection* dbus_g_connection_open (const gchar *address,
- GError **error);
-DBusGConnection* dbus_g_connection_open_private (const gchar *address,
- GMainContext *context,
- GError **error);
-DBusGConnection* dbus_g_bus_get (DBusBusType type,
- GError **error);
-DBusGConnection* dbus_g_bus_get_private (DBusBusType type,
- GMainContext *context,
- GError **error);
-
-
-typedef struct _DBusGObjectInfo DBusGObjectInfo;
-typedef struct _DBusGMethodInfo DBusGMethodInfo;
-
-/**
- * DBusGMethodInfo:
- * @function: C method to invoke
- * @marshaller: Marshaller to invoke method
- * @data_offset: Offset into the introspection data
- *
- * Object typically generated by #dbus-binding-tool that
- * stores a mapping from introspection data to a
- * function pointer for a C method to be invoked.
- */
-struct _DBusGMethodInfo
-{
- GCallback function;
- GClosureMarshal marshaller;
- int data_offset;
-};
-
-/**
- * DBusGObjectInfo:
- * @format_version: Allows us to change the rest of this struct
- * by adding DBusGObjectInfo2, DBusGObjectInfo3, etc.
- * @method_infos: Array of method pointers
- * @n_method_infos: Length of the infos array
- * @data: Introspection data
- * @exported_signals: Exported signals
- * @exported_properties: Exported properties
- *
- * Introspection data for a #GObject, normally autogenerated by
- * a tool such as #dbus-binding-tool.
- */
-struct _DBusGObjectInfo
-{
- int format_version;
-
- const DBusGMethodInfo *method_infos;
- int n_method_infos;
- const char *data;
- const char *exported_signals;
- const char *exported_properties;
-};
-
-void dbus_glib_global_set_disable_legacy_property_access (void);
-
-void dbus_g_object_type_install_info (GType object_type,
- const DBusGObjectInfo *info);
-
-void dbus_g_object_type_register_shadow_property (GType iface_type,
- const char *dbus_prop_name,
- const char *shadow_prop_name);
-
-void dbus_g_error_domain_register (GQuark domain,
- const char * default_iface,
- GType code_enum);
-
-void dbus_g_connection_register_g_object (DBusGConnection *connection,
- const char *at_path,
- GObject *object);
-void dbus_g_connection_unregister_g_object (DBusGConnection *connection,
- GObject *object);
-GObject * dbus_g_connection_lookup_g_object (DBusGConnection *connection,
- const char *at_path);
-
-#ifdef DBUS_COMPILATION
-#include "dbus/dbus-gtype-specialized.h"
-#else
-#include <dbus/dbus-gtype-specialized.h>
-#endif
-
-/* definitions for some basic array types */
-#define DBUS_TYPE_G_BOOLEAN_ARRAY (dbus_g_type_get_collection ("GArray", G_TYPE_BOOLEAN))
-#define DBUS_TYPE_G_UCHAR_ARRAY (dbus_g_type_get_collection ("GArray", G_TYPE_UCHAR))
-#define DBUS_TYPE_G_UINT_ARRAY (dbus_g_type_get_collection ("GArray", G_TYPE_UINT))
-#define DBUS_TYPE_G_INT_ARRAY (dbus_g_type_get_collection ("GArray", G_TYPE_INT))
-#define DBUS_TYPE_G_UINT64_ARRAY (dbus_g_type_get_collection ("GArray", G_TYPE_UINT64))
-#define DBUS_TYPE_G_INT64_ARRAY (dbus_g_type_get_collection ("GArray", G_TYPE_INT64))
-#define DBUS_TYPE_G_OBJECT_ARRAY (dbus_g_type_get_collection ("GPtrArray", G_TYPE_OBJECT))
-
-#define DBUS_TYPE_G_STRING_STRING_HASHTABLE (dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_STRING))
-
-typedef gchar DBusGObjectPath;
-GType dbus_g_object_path_get_g_type (void) G_GNUC_CONST;
-#define DBUS_TYPE_G_OBJECT_PATH (dbus_g_object_path_get_g_type ())
-
-typedef gchar DBusGSignature;
-GType dbus_g_signature_get_g_type (void) G_GNUC_CONST;
-#define DBUS_TYPE_G_SIGNATURE (dbus_g_signature_get_g_type ())
-
-void dbus_g_object_register_marshaller (GClosureMarshal marshaller,
- GType rettype,
- ...);
-void dbus_g_object_register_marshaller_array(GClosureMarshal marshaller,
- GType rettype,
- guint n_types,
- const GType* types);
-
-typedef struct _DBusGProxy DBusGProxy;
-typedef struct _DBusGProxyClass DBusGProxyClass;
-
-#define DBUS_TYPE_G_PROXY (dbus_g_proxy_get_type ())
-#define DBUS_G_PROXY(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), DBUS_TYPE_G_PROXY, DBusGProxy))
-#define DBUS_G_PROXY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DBUS_TYPE_G_PROXY, DBusGProxyClass))
-#define DBUS_IS_G_PROXY(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), DBUS_TYPE_G_PROXY))
-#define DBUS_IS_G_PROXY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DBUS_TYPE_G_PROXY))
-#define DBUS_G_PROXY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DBUS_TYPE_G_PROXY, DBusGProxyClass))
-
-struct _DBusGProxy
-{
- /*< private >*/
- GObject parent;
-};
-
-struct _DBusGProxyClass
-{
- /*< private >*/
- GObjectClass parent_class; /**< Parent class */
-};
-
-typedef struct _DBusGProxyCall DBusGProxyCall;
-typedef void (* DBusGProxyCallNotify) (DBusGProxy *proxy,
- DBusGProxyCall *call_id,
- void *user_data);
-
-GType dbus_g_proxy_get_type (void) G_GNUC_CONST;
-DBusGProxy* dbus_g_proxy_new_for_name (DBusGConnection *connection,
- const char *name,
- const char *path,
- const char *iface);
-DBusGProxy* dbus_g_proxy_new_for_name_owner (DBusGConnection *connection,
- const char *name,
- const char *path,
- const char *iface,
- GError **error);
-DBusGProxy* dbus_g_proxy_new_from_proxy (DBusGProxy *proxy,
- const char *iface,
- const char *path);
-DBusGProxy* dbus_g_proxy_new_for_peer (DBusGConnection *connection,
- const char *path,
- const char *iface);
-
-void dbus_g_proxy_set_interface (DBusGProxy *proxy,
- const char *interface_name);
-void dbus_g_proxy_add_signal (DBusGProxy *proxy,
- const char *signal_name,
- GType first_type,
- ...);
-
-void dbus_g_proxy_connect_signal (DBusGProxy *proxy,
- const char *signal_name,
- GCallback handler,
- void *data,
- GClosureNotify free_data_func);
-void dbus_g_proxy_disconnect_signal (DBusGProxy *proxy,
- const char *signal_name,
- GCallback handler,
- void *data);
-
-gboolean dbus_g_proxy_call (DBusGProxy *proxy,
- const char *method,
- GError **error,
- GType first_arg_type,
- ...);
-
-gboolean dbus_g_proxy_call_with_timeout (DBusGProxy *proxy,
- const char *method,
- int timeout,
- GError **error,
- GType first_arg_type,
- ...);
-
-void dbus_g_proxy_call_no_reply (DBusGProxy *proxy,
- const char *method,
- GType first_arg_type,
- ...);
-
-DBusGProxyCall * dbus_g_proxy_begin_call (DBusGProxy *proxy,
- const char *method,
- DBusGProxyCallNotify notify,
- gpointer user_data,
- GDestroyNotify destroy,
- GType first_arg_type,
- ...);
-DBusGProxyCall * dbus_g_proxy_begin_call_with_timeout (DBusGProxy *proxy,
- const char *method,
- DBusGProxyCallNotify notify,
- gpointer user_data,
- GDestroyNotify destroy,
- int timeout,
- GType first_arg_type,
- ...);
-
-void dbus_g_proxy_set_default_timeout (DBusGProxy *proxy,
- int timeout);
-
-gboolean dbus_g_proxy_end_call (DBusGProxy *proxy,
- DBusGProxyCall *call,
- GError **error,
- GType first_arg_type,
- ...);
-void dbus_g_proxy_cancel_call (DBusGProxy *proxy,
- DBusGProxyCall *call);
-
-const char* dbus_g_proxy_get_path (DBusGProxy *proxy);
-
-const char* dbus_g_proxy_get_bus_name (DBusGProxy *proxy);
-
-const char* dbus_g_proxy_get_interface (DBusGProxy *proxy);
-
-typedef struct _DBusGMethodInvocation DBusGMethodInvocation;
-
-void dbus_g_method_return (DBusGMethodInvocation *context, ...);
-
-void dbus_g_method_return_error (DBusGMethodInvocation *context, const GError *error);
-
-DBusGConnection * dbus_g_method_invocation_get_g_connection (DBusGMethodInvocation *context);
-
-/* Probably possible to replace this with a closure */
-typedef struct {
- GCallback cb;
- gpointer userdata;
-} DBusGAsyncData;
-
-#undef DBUS_INSIDE_DBUS_GLIB_H
-
-#include <dbus/dbus-gvalue-parse-variant.h>
-
-G_END_DECLS
-
-#endif /* DBUS_GLIB_H */
diff --git a/dbus/dbus-gloader-expat.c b/dbus/dbus-gloader-expat.c
deleted file mode 100644
index 9a53f02..0000000
--- a/dbus/dbus-gloader-expat.c
+++ /dev/null
@@ -1,268 +0,0 @@
-/* -*- mode: C; c-file-style: "gnu" -*- */
-/* dbus-gloader-expat.c expat XML loader
- *
- * Copyright (C) 2003 Red Hat, Inc.
- *
- * Licensed under the Academic Free License version 2.1
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- */
-
-#include <config.h>
-
-#include "dbus-gparser.h"
-#include <expat.h>
-#include <string.h>
-
-static void*
-expat_g_malloc (size_t sz)
-{
- return g_malloc (sz);
-}
-
-static void*
-expat_g_realloc (void *mem, size_t sz)
-{
- return g_realloc (mem, sz);
-}
-
-static XML_Memory_Handling_Suite memsuite =
-{
- expat_g_malloc,
- expat_g_realloc,
- g_free
-};
-
-/*
- * Context for Expat parser for introspection data.
- */
-typedef struct
-{
- Parser *parser; /**< The parser for the introspection data */
- const char *filename; /**< The filename being loaded */
- GString *content; /**< The content of the current element */
- GError **error; /**< Error return location */
- gboolean failed; /**< True if parse has failed */
-} ExpatParseContext;
-
-static dbus_bool_t
-process_content (ExpatParseContext *context)
-{
- if (context->failed)
- return FALSE;
-
- if (context->content->len > 0)
- {
- if (!parser_content (context->parser,
- context->content->str,
- context->content->len,
- context->error))
- {
- context->failed = TRUE;
- return FALSE;
- }
- g_string_set_size (context->content, 0);
- }
-
- return TRUE;
-}
-
-static void
-expat_StartElementHandler (void *userData,
- const XML_Char *name,
- const XML_Char **atts)
-{
- ExpatParseContext *context = userData;
- int i;
- char **names;
- char **values;
-
- /* Expat seems to suck and can't abort the parse if we
- * throw an error. Expat 2.0 is supposed to fix this.
- */
- if (context->failed)
- return;
-
- if (!process_content (context))
- return;
-
- /* "atts" is key, value, key, value, NULL */
- for (i = 0; atts[i] != NULL; ++i)
- ; /* nothing */
-
- g_assert (i % 2 == 0);
- names = g_new0 (char *, i / 2 + 1);
- values = g_new0 (char *, i / 2 + 1);
-
- i = 0;
- while (atts[i] != NULL)
- {
- g_assert (i % 2 == 0);
- names [i / 2] = (char*) atts[i];
- values[i / 2] = (char*) atts[i+1];
-
- i += 2;
- }
-
- if (!parser_start_element (context->parser,
- name,
- (const char **) names,
- (const char **) values,
- context->error))
- {
- g_free (names);
- g_free (values);
- context->failed = TRUE;
- return;
- }
-
- g_free (names);
- g_free (values);
-}
-
-static void
-expat_EndElementHandler (void *userData,
- const XML_Char *name)
-{
- ExpatParseContext *context = userData;
-
- if (!process_content (context))
- return;
-
- if (!parser_end_element (context->parser,
- name,
- context->error))
- {
- context->failed = TRUE;
- return;
- }
-}
-
-/* s is not 0 terminated. */
-static void
-expat_CharacterDataHandler (void *userData,
- const XML_Char *s,
- int len)
-{
- ExpatParseContext *context = userData;
-
- if (context->failed)
- return;
-
- g_string_append_len (context->content,
- s, len);
-}
-
-NodeInfo*
-description_load_from_file (const char *filename,
- GError **error)
-{
- char *contents;
- gsize len;
- NodeInfo *nodes;
-
- contents = NULL;
- if (!g_file_get_contents (filename, &contents, &len, error))
- return NULL;
-
- nodes = description_load_from_string (contents, len, error);
- g_free (contents);
-
- return nodes;
-}
-
-NodeInfo*
-description_load_from_string (const char *str,
- int len,
- GError **error)
-{
- XML_Parser expat;
- ExpatParseContext context;
- NodeInfo *nodes;
-
- g_return_val_if_fail (error == NULL || *error == NULL, NULL);
-
- if (len < 0)
- len = strlen (str);
-
- expat = NULL;
- context.parser = NULL;
- context.error = error;
- context.failed = FALSE;
-
- expat = XML_ParserCreate_MM ("UTF-8", &memsuite, NULL);
- if (expat == NULL)
- g_error ("No memory to create XML parser\n");
-
- context.parser = parser_new ();
- context.content = g_string_new (NULL);
-
- XML_SetUserData (expat, &context);
- XML_SetElementHandler (expat,
- expat_StartElementHandler,
- expat_EndElementHandler);
- XML_SetCharacterDataHandler (expat,
- expat_CharacterDataHandler);
-
- if (!XML_Parse (expat, str, len, TRUE))
- {
- if (context.error != NULL &&
- *context.error == NULL)
- {
- enum XML_Error e;
-
- e = XML_GetErrorCode (expat);
- if (e == XML_ERROR_NO_MEMORY)
- g_error ("Not enough memory to parse XML document");
- else
- g_set_error (error,
- G_MARKUP_ERROR,
- G_MARKUP_ERROR_PARSE,
- "Error in D-BUS description XML, line %ld, column %ld: %s\n",
- (gulong)XML_GetCurrentLineNumber (expat),
- (gulong)XML_GetCurrentColumnNumber (expat),
- XML_ErrorString (e));
- }
-
- goto failed;
- }
-
- if (context.failed)
- goto failed;
-
- if (!parser_finished (context.parser, error))
- goto failed;
-
- XML_ParserFree (expat);
- g_string_free (context.content, TRUE);
-
- g_return_val_if_fail (error == NULL || *error == NULL, NULL);
- nodes = parser_get_nodes (context.parser);
- node_info_ref (nodes);
- parser_unref (context.parser);
- return nodes;
-
- failed:
- g_return_val_if_fail (error == NULL || *error != NULL, NULL);
-
- g_string_free (context.content, TRUE);
- if (expat)
- XML_ParserFree (expat);
- if (context.parser)
- parser_unref (context.parser);
- return NULL;
-}
-
diff --git a/dbus/dbus-gmarshal.c b/dbus/dbus-gmarshal.c
deleted file mode 100644
index 65f13c7..0000000
--- a/dbus/dbus-gmarshal.c
+++ /dev/null
@@ -1,92 +0,0 @@
-#include <config.h>
-#include "dbus-gmarshal.h"
-
-#include <glib-object.h>
-
-
-#ifdef G_ENABLE_DEBUG
-#define g_marshal_value_peek_boolean(v) g_value_get_boolean (v)
-#define g_marshal_value_peek_char(v) g_value_get_char (v)
-#define g_marshal_value_peek_uchar(v) g_value_get_uchar (v)
-#define g_marshal_value_peek_int(v) g_value_get_int (v)
-#define g_marshal_value_peek_uint(v) g_value_get_uint (v)
-#define g_marshal_value_peek_long(v) g_value_get_long (v)
-#define g_marshal_value_peek_ulong(v) g_value_get_ulong (v)
-#define g_marshal_value_peek_int64(v) g_value_get_int64 (v)
-#define g_marshal_value_peek_uint64(v) g_value_get_uint64 (v)
-#define g_marshal_value_peek_enum(v) g_value_get_enum (v)
-#define g_marshal_value_peek_flags(v) g_value_get_flags (v)
-#define g_marshal_value_peek_float(v) g_value_get_float (v)
-#define g_marshal_value_peek_double(v) g_value_get_double (v)
-#define g_marshal_value_peek_string(v) (char*) g_value_get_string (v)
-#define g_marshal_value_peek_param(v) g_value_get_param (v)
-#define g_marshal_value_peek_boxed(v) g_value_get_boxed (v)
-#define g_marshal_value_peek_pointer(v) g_value_get_pointer (v)
-#define g_marshal_value_peek_object(v) g_value_get_object (v)
-#define g_marshal_value_peek_variant(v) g_value_get_variant (v)
-#else /* !G_ENABLE_DEBUG */
-/* WARNING: This code accesses GValues directly, which is UNSUPPORTED API.
- * Do not access GValues directly in your code. Instead, use the
- * g_value_get_*() functions
- */
-#define g_marshal_value_peek_boolean(v) (v)->data[0].v_int
-#define g_marshal_value_peek_char(v) (v)->data[0].v_int
-#define g_marshal_value_peek_uchar(v) (v)->data[0].v_uint
-#define g_marshal_value_peek_int(v) (v)->data[0].v_int
-#define g_marshal_value_peek_uint(v) (v)->data[0].v_uint
-#define g_marshal_value_peek_long(v) (v)->data[0].v_long
-#define g_marshal_value_peek_ulong(v) (v)->data[0].v_ulong
-#define g_marshal_value_peek_int64(v) (v)->data[0].v_int64
-#define g_marshal_value_peek_uint64(v) (v)->data[0].v_uint64
-#define g_marshal_value_peek_enum(v) (v)->data[0].v_long
-#define g_marshal_value_peek_flags(v) (v)->data[0].v_ulong
-#define g_marshal_value_peek_float(v) (v)->data[0].v_float
-#define g_marshal_value_peek_double(v) (v)->data[0].v_double
-#define g_marshal_value_peek_string(v) (v)->data[0].v_pointer
-#define g_marshal_value_peek_param(v) (v)->data[0].v_pointer
-#define g_marshal_value_peek_boxed(v) (v)->data[0].v_pointer
-#define g_marshal_value_peek_pointer(v) (v)->data[0].v_pointer
-#define g_marshal_value_peek_object(v) (v)->data[0].v_pointer
-#define g_marshal_value_peek_variant(v) (v)->data[0].v_pointer
-#endif /* !G_ENABLE_DEBUG */
-
-
-/* NONE:STRING,STRING,STRING (dbus-gmarshal.list:1) */
-void
-_dbus_g_marshal_VOID__STRING_STRING_STRING (GClosure *closure,
- GValue *return_value G_GNUC_UNUSED,
- guint n_param_values,
- const GValue *param_values,
- gpointer invocation_hint G_GNUC_UNUSED,
- gpointer marshal_data)
-{
- typedef void (*GMarshalFunc_VOID__STRING_STRING_STRING) (gpointer data1,
- gpointer arg_1,
- gpointer arg_2,
- gpointer arg_3,
- gpointer data2);
- register GMarshalFunc_VOID__STRING_STRING_STRING callback;
- register GCClosure *cc = (GCClosure*) closure;
- register gpointer data1, data2;
-
- g_return_if_fail (n_param_values == 4);
-
- if (G_CCLOSURE_SWAP_DATA (closure))
- {
- data1 = closure->data;
- data2 = g_value_peek_pointer (param_values + 0);
- }
- else
- {
- data1 = g_value_peek_pointer (param_values + 0);
- data2 = closure->data;
- }
- callback = (GMarshalFunc_VOID__STRING_STRING_STRING) (marshal_data ? marshal_data : cc->callback);
-
- callback (data1,
- g_marshal_value_peek_string (param_values + 1),
- g_marshal_value_peek_string (param_values + 2),
- g_marshal_value_peek_string (param_values + 3),
- data2);
-}
-
diff --git a/dbus/dbus-gmarshal.h b/dbus/dbus-gmarshal.h
deleted file mode 100644
index 2cdb3d7..0000000
--- a/dbus/dbus-gmarshal.h
+++ /dev/null
@@ -1,21 +0,0 @@
-
-#ifndef ___dbus_g_marshal_MARSHAL_H__
-#define ___dbus_g_marshal_MARSHAL_H__
-
-#include <glib-object.h>
-
-G_BEGIN_DECLS
-
-/* NONE:STRING,STRING,STRING (dbus-gmarshal.list:1) */
-extern void _dbus_g_marshal_VOID__STRING_STRING_STRING (GClosure *closure,
- GValue *return_value,
- guint n_param_values,
- const GValue *param_values,
- gpointer invocation_hint,
- gpointer marshal_data);
-#define _dbus_g_marshal_NONE__STRING_STRING_STRING _dbus_g_marshal_VOID__STRING_STRING_STRING
-
-G_END_DECLS
-
-#endif /* ___dbus_g_marshal_MARSHAL_H__ */
-
diff --git a/dbus/dbus-gmarshal.list b/dbus/dbus-gmarshal.list
deleted file mode 100644
index 12974e2..0000000
--- a/dbus/dbus-gmarshal.list
+++ /dev/null
@@ -1 +0,0 @@
-NONE:STRING,STRING,STRING
diff --git a/dbus/dbus-gobject.c b/dbus/dbus-gobject.c
deleted file mode 100644
index aebd97a..0000000
--- a/dbus/dbus-gobject.c
+++ /dev/null
@@ -1,3406 +0,0 @@
-/* -*- mode: C; c-file-style: "gnu" -*- */
-/* dbus-gobject.c Exporting a GObject remotely
- *
- * Copyright (C) 2003, 2004, 2005 Red Hat, Inc.
- * Copyright (C) 2005 Nokia
- *
- * Licensed under the Academic Free License version 2.1
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- */
-
-#include <config.h>
-#include <gobject/gvaluecollector.h>
-#include <dbus/dbus-glib.h>
-#include <dbus/dbus-glib-lowlevel.h>
-#include "dbus-gtest.h"
-#include "dbus-gutils.h"
-#include "dbus-gobject.h"
-#include "dbus-gsignature.h"
-#include "dbus-gvalue.h"
-#include "dbus-gmarshal.h"
-#include "dbus-gvalue-utils.h"
-#include <string.h>
-
-#include <gio/gio.h>
-
-G_GNUC_NORETURN static void
-oom (const gchar *explanation)
-{
- g_error ("%s", explanation == NULL ? "Out of memory" : explanation);
- g_assert_not_reached ();
-}
-
-static DBusMessage *
-reply_or_die (DBusMessage *in_reply_to)
-{
- DBusMessage *reply;
-
- g_return_val_if_fail (in_reply_to != NULL, NULL);
-
- reply = dbus_message_new_method_return (in_reply_to);
-
- if (reply == NULL)
- oom ("dbus_message_new_method_return failed: out of memory?");
-
- return reply;
-}
-
-static DBusMessage *
-error_or_die (DBusMessage *in_reply_to,
- const gchar *error_name,
- const gchar *error_message)
-{
- DBusMessage *reply;
-
- g_return_val_if_fail (in_reply_to != NULL, NULL);
- /* error names are syntactically the same as interface names */
- g_return_val_if_fail (g_dbus_is_interface_name (error_name), NULL);
- g_return_val_if_fail (g_utf8_validate (error_message, -1, NULL), NULL);
-
- reply = dbus_message_new_error (in_reply_to, error_name, error_message);
-
- if (reply == NULL)
- oom ("dbus_message_new_error failed: out of memory?");
-
- return reply;
-}
-
-static void
-connection_send_or_die (DBusConnection *connection,
- DBusMessage *message)
-{
- g_return_if_fail (connection != NULL);
- g_return_if_fail (message != NULL);
-
- if (!dbus_connection_send (connection, message, NULL))
- oom ("dbus_connection_send failed: out of memory?");
-}
-
-static char *lookup_property_name (GObject *object,
- const char *wincaps_propiface,
- const char *requested_propname);
-
-typedef struct
-{
- char *default_iface;
- GType code_enum;
-} DBusGErrorInfo;
-
-static GStaticRWLock globals_lock = G_STATIC_RW_LOCK_INIT;
-/* See comments in check_property_access */
-static gboolean disable_legacy_property_access = FALSE;
-static GData *error_metadata = NULL;
-
-static char*
-uscore_to_wincaps_full (const char *uscore,
- gboolean uppercase_first,
- gboolean strip_underscores)
-{
- const char *p;
- GString *str;
- gboolean last_was_uscore;
-
- last_was_uscore = uppercase_first;
-
- str = g_string_new (NULL);
- p = uscore;
- while (p && *p)
- {
- if (*p == '-' || (strip_underscores && *p == '_'))
- {
- last_was_uscore = TRUE;
- }
- else
- {
- if (last_was_uscore)
- {
- g_string_append_c (str, g_ascii_toupper (*p));
- last_was_uscore = FALSE;
- }
- else
- g_string_append_c (str, *p);
- }
- ++p;
- }
-
- return g_string_free (str, FALSE);
-}
-
-/* Ugly yes - but we have to accept strings from both formats */
-static gboolean
-compare_strings_ignoring_uscore_vs_dash (const char *a, const char *b)
-{
- guint i;
-
- for (i = 0; a[i] && b[i]; i++)
- {
- if ((a[i] == '-' && b[i] == '_')
- || (a[i] == '_' && b[i] == '-'))
- continue;
- if (a[i] != b[i])
- return FALSE;
- }
- return (a[i] == '\0') && (b[i] == '\0');
-}
-
-static char *
-uscore_to_wincaps (const char *uscore)
-{
- return uscore_to_wincaps_full (uscore, TRUE, TRUE);
-}
-
-static const char *
-string_table_next (const char *table)
-{
- return (table + (strlen (table) + 1));
-}
-
-static const char *
-string_table_lookup (const char *table, int index)
-{
- const char *ret;
-
- ret = table;
-
- while (index--)
- ret = string_table_next (ret);
-
- return ret;
-}
-
-static const char *
-get_method_data (const DBusGObjectInfo *object,
- const DBusGMethodInfo *method)
-{
- return object->data + method->data_offset;
-}
-
-static char *
-object_error_domain_prefix_from_object_info (const DBusGObjectInfo *info)
-{
- /* FIXME */
- return NULL;
-}
-
-static char *
-object_error_code_from_object_info (const DBusGObjectInfo *info, GQuark domain, gint code)
-{
- /* FIXME */
- return NULL;
-}
-
-static const char *
-method_interface_from_object_info (const DBusGObjectInfo *object,
- const DBusGMethodInfo *method)
-{
- return string_table_lookup (get_method_data (object, method), 0);
-}
-
-static const char *
-method_name_from_object_info (const DBusGObjectInfo *object,
- const DBusGMethodInfo *method)
-{
- return string_table_lookup (get_method_data (object, method), 1);
-}
-
-static const char *
-method_arg_info_from_object_info (const DBusGObjectInfo *object,
- const DBusGMethodInfo *method)
-{
- return string_table_lookup (get_method_data (object, method), 3);/*RB was 2*/
-}
-
-typedef enum
-{
- RETVAL_NONE,
- RETVAL_NOERROR,
- RETVAL_ERROR
-} RetvalType;
-
-/*
- * arg_iterate:
- * @data: a pointer to the beginning of an argument entry in a string table
- * @name: (out) (allow-none): used to return the name of the next argument
- * @in: (out) (allow-none): used to return %TRUE for an "in" argument or
- * %FALSE for an "out" argument
- * @constval: (out) (allow-none): used to return %TRUE if the argument is
- * an "out" argument and has the "C" (const) flag indicating that it
- * should not be freed after it is returned; normally, "out" arguments
- * are freed
- * @retval: (out) (allow-none): used to return %RETVAL_NONE if this
- * D-Bus argument is not an "out" argument or is obtained like a C "out"
- * parameter, %RETVAL_ERROR if this argument is obtained from the C
- * return value and is also used to signal errors, or %RETVAL_NOERROR
- * if this argument is obtained from the C return value and the method
- * can never raise an error
- * @type: (out) (allow-none): used to return the D-Bus signature of this
- * argument
- *
- * The data format is:
- *
- * argument name
- * \0
- * direction: I or O
- * \0
- * if direction == "O":
- * freeable? F or C
- * \0
- * retval? N, E or R
- * \0
- * signature
- * \0
- *
- * If none of the arguments has @retval != %RETVAL_NONE, the method is
- * assumed to return a gboolean, which behaves like %RETVAL_ERROR but is
- * not sent over D-Bus at all.
- *
- * Returns: the value of @data to use for the next call, or a pointer to '\0'
- * if this function must not be called again
- */
-static const char *
-arg_iterate (const char *data,
- const char **name,
- gboolean *in,
- gboolean *constval,
- RetvalType *retval,
- const char **type)
-{
- gboolean inarg;
-
- if (name)
- *name = data;
-
- data = string_table_next (data);
- switch (*data)
- {
- case 'I':
- inarg = TRUE;
- break;
- case 'O':
- inarg = FALSE;
- break;
- default:
- g_warning ("invalid arg direction '%c'", *data);
- inarg = FALSE;
- break;
- }
- if (in)
- *in = inarg;
-
- if (!inarg)
- {
- data = string_table_next (data);
- switch (*data)
- {
- case 'F':
- if (constval)
- *constval = FALSE;
- break;
- case 'C':
- if (constval)
- *constval = TRUE;
- break;
- default:
- g_warning ("invalid arg const value '%c'", *data);
- break;
- }
- data = string_table_next (data);
- switch (*data)
- {
- case 'N':
- if (retval)
- *retval = RETVAL_NONE;
- break;
- case 'E':
- if (retval)
- *retval = RETVAL_ERROR;
- break;
- case 'R':
- if (retval)
- *retval = RETVAL_NOERROR;
- break;
- default:
- g_warning ("invalid arg ret value '%c'", *data);
- break;
- }
- }
- else
- {
- if (constval)
- *constval = FALSE;
- if (retval)
- *retval = FALSE;
- }
-
- data = string_table_next (data);
- if (type)
- *type = data;
-
- return string_table_next (data);
-}
-
-static char *
-method_dir_signature_from_object_info (const DBusGObjectInfo *object,
- const DBusGMethodInfo *method,
- gboolean in)
-{
- const char *arg;
- GString *ret;
-
- arg = method_arg_info_from_object_info (object, method);
-
- ret = g_string_new (NULL);
-
- while (*arg)
- {
- const char *name;
- gboolean arg_in;
- const char *type;
-
- arg = arg_iterate (arg, &name, &arg_in, NULL, NULL, &type);
-
- if (arg_in == in)
- g_string_append (ret, type);
- }
-
- return g_string_free (ret, FALSE);
-}
-
-static char *
-method_input_signature_from_object_info (const DBusGObjectInfo *object,
- const DBusGMethodInfo *method)
-{
- return method_dir_signature_from_object_info (object, method, TRUE);
-}
-
-static char *
-method_output_signature_from_object_info (const DBusGObjectInfo *object,
- const DBusGMethodInfo *method)
-{
- return method_dir_signature_from_object_info (object, method, FALSE);
-}
-
-static const char *
-signal_iterate (const char *data, const char **iface, const char **name)
-{
- *iface = data;
-
- data = string_table_next (data);
- *name = data;
-
- return string_table_next (data);
-}
-
-static const char *
-property_iterate (const char *data,
- int format_version,
- const char **iface,
- const char **exported_name,
- const char **name_uscored,
- const char **access_type)
-{
- *iface = data;
-
- data = string_table_next (data);
- *exported_name = data;
-
- data = string_table_next (data);
- if (format_version == 1)
- {
- *name_uscored = data;
- data = string_table_next (data);
- *access_type = data;
- return string_table_next (data);
- }
- else
- {
- /* This tells the caller they need to compute it */
- *name_uscored = NULL;
- /* We don't know here, however note that we will still check against the
- * readable/writable flags from GObject's metadata.
- */
- *access_type = "readwrite";
- return data;
- }
-}
-
-/**
- * property_info_from_object_info:
- * @object: introspection data
- * @interface_name: (allow-none): Expected interface name, or %NULL for any
- * @property_name: Expected property name (can use "-" or "_" as separator)
- * @access_type: (out): Can be one of "read", "write", "readwrite"
- *
- * Look up property introspection data for the given interface/name pair.
- *
- * Returns: %TRUE if property was found
- */
-static gboolean
-property_info_from_object_info (const DBusGObjectInfo *object,
- const char *interface_name,
- const char *property_name,
- const char **access_type)
-{
- const char *properties_iter;
-
- properties_iter = object->exported_properties;
- while (properties_iter != NULL && *properties_iter)
- {
- const char *cur_interface_name;
- const char *cur_property_name;
- const char *cur_uscore_property_name;
- const char *cur_access_type;
-
-
- properties_iter = property_iterate (properties_iter, object->format_version,
- &cur_interface_name, &cur_property_name,
- &cur_uscore_property_name, &cur_access_type);
-
- if (interface_name && strcmp (interface_name, cur_interface_name) != 0)
- continue;
-
- /* This big pile of ugly is necessary to support the matrix resulting from multiplying
- * (v0 data, v1 data) * (FooBar, foo-bar)
- * In v1 data we have both forms of string, so we do a comparison against both without
- * having to malloc.
- * For v0 data, we need to reconstruct the foo-bar form.
- *
- * Adding to the complexity is that we *also* have to ignore the distinction between
- * '-' and '_', because g_object_{get,set} does.
- */
- /* First, compare against the primary property name - no malloc required */
- if (!compare_strings_ignoring_uscore_vs_dash (property_name, cur_property_name))
- {
- if (cur_uscore_property_name != NULL
- && !compare_strings_ignoring_uscore_vs_dash (property_name, cur_uscore_property_name))
- continue;
- else
- {
- /* v0 metadata, construct uscore */
- char *tmp_uscored;
- gboolean matches;
- tmp_uscored = _dbus_gutils_wincaps_to_uscore (cur_property_name);
- matches = compare_strings_ignoring_uscore_vs_dash (property_name, tmp_uscored);
- g_free (tmp_uscored);
- if (!matches)
- continue;
- }
- }
-
- *access_type = cur_access_type;
- return TRUE;
- }
- return FALSE;
-}
-
-static GQuark
-dbus_g_object_type_dbus_metadata_quark (void)
-{
- static GQuark quark;
-
- if (!quark)
- quark = g_quark_from_static_string ("DBusGObjectTypeDBusMetadataQuark");
- return quark;
-}
-
-/* Iterator function should return FALSE to stop iteration, TRUE to continue */
-typedef gboolean (*ForeachObjectInfoFn) (const DBusGObjectInfo *info,
- GType gtype,
- gpointer user_data);
-
-static void
-foreach_object_info (GObject *object,
- ForeachObjectInfoFn callback,
- gpointer user_data)
-{
- GType *interfaces, *p;
- const DBusGObjectInfo *info;
- GType classtype;
-
- interfaces = g_type_interfaces (G_TYPE_FROM_INSTANCE (object), NULL);
-
- for (p = interfaces; *p != 0; p++)
- {
- info = g_type_get_qdata (*p, dbus_g_object_type_dbus_metadata_quark ());
- if (info != NULL && info->format_version >= 0)
- {
- if (!callback (info, *p, user_data))
- break;
- }
- }
-
- g_free (interfaces);
-
- for (classtype = G_TYPE_FROM_INSTANCE (object); classtype != 0; classtype = g_type_parent (classtype))
- {
- info = g_type_get_qdata (classtype, dbus_g_object_type_dbus_metadata_quark ());
- if (info != NULL && info->format_version >= 0)
- {
- if (!callback (info, classtype, user_data))
- break;
- }
- }
-
-}
-
-static gboolean
-lookup_object_info_cb (const DBusGObjectInfo *info,
- GType gtype,
- gpointer user_data)
-{
- GList **list = (GList **) user_data;
-
- *list = g_list_prepend (*list, (gpointer) info);
- return TRUE;
-}
-
-static GList *
-lookup_object_info (GObject *object)
-{
- GList *info_list = NULL;
-
- foreach_object_info (object, lookup_object_info_cb, &info_list);
-
- return info_list;
-}
-
-typedef struct {
- const char *iface;
- const DBusGObjectInfo *info;
- gboolean fallback;
- GType iface_type;
-} LookupObjectInfoByIfaceData;
-
-static gboolean
-lookup_object_info_by_iface_cb (const DBusGObjectInfo *info,
- GType gtype,
- gpointer user_data)
-{
- LookupObjectInfoByIfaceData *lookup_data = (LookupObjectInfoByIfaceData *) user_data;
-
- /* If interface is not specified, choose the first info */
- if (lookup_data->fallback && (!lookup_data->iface || strlen (lookup_data->iface) == 0))
- {
- lookup_data->info = info;
- lookup_data->iface_type = gtype;
- }
- else if (info->exported_properties && !strcmp (info->exported_properties, lookup_data->iface))
- {
- lookup_data->info = info;
- lookup_data->iface_type = gtype;
- }
-
- return !lookup_data->info;
-}
-
-static const DBusGObjectInfo *
-lookup_object_info_by_iface (GObject *object,
- const char *iface,
- gboolean fallback,
- GType *out_iface_type)
-{
- LookupObjectInfoByIfaceData data;
-
- data.iface = iface;
- data.info = NULL;
- data.fallback = fallback;
- data.iface_type = 0;
-
- foreach_object_info (object, lookup_object_info_by_iface_cb, &data);
-
- if (out_iface_type && data.info)
- *out_iface_type = data.iface_type;
-
- return data.info;
-}
-
-typedef struct {
- /* owned */
- GSList *registrations;
- /* weak ref, or NULL if the object has been disposed */
- GObject *object;
-} ObjectExport;
-
-typedef struct {
- /* pseudo-weak ref, never NULL */
- DBusGConnection *connection;
- /* owned, never NULL */
- gchar *object_path;
- /* borrowed pointer to parent, never NULL */
- ObjectExport *export;
-} ObjectRegistration;
-
-static void object_export_object_died (gpointer user_data, GObject *dead);
-
-static void
-object_export_unregister_all (ObjectExport *oe)
-{
- while (oe->registrations != NULL)
- {
- GSList *old = oe->registrations;
- ObjectRegistration *o = oe->registrations->data;
-
- dbus_connection_unregister_object_path (
- DBUS_CONNECTION_FROM_G_CONNECTION (o->connection), o->object_path);
-
- /* the link should have been removed by doing that */
- g_assert (oe->registrations != old);
- }
-}
-
-static void
-object_export_free (ObjectExport *oe)
-{
- g_slice_free (ObjectExport, oe);
-}
-
-static ObjectExport *
-object_export_new (void)
-{
- return g_slice_new0 (ObjectExport);
-}
-
-static ObjectRegistration *
-object_registration_new (DBusGConnection *connection,
- const gchar *object_path,
- ObjectExport *export)
-{
- ObjectRegistration *o = g_slice_new0 (ObjectRegistration);
-
- o->connection = connection;
- o->object_path = g_strdup (object_path);
- o->export = export;
-
- return o;
-}
-
-static void
-object_registration_free (ObjectRegistration *o)
-{
- g_assert (o->export != NULL);
- o->export->registrations = g_slist_remove (o->export->registrations, o);
-
- g_free (o->object_path);
-
- g_slice_free (ObjectRegistration, o);
-}
-
-/* Called when the object falls off the bus (e.g. because connection just
- * closed) */
-static void
-object_registration_unregistered (DBusConnection *connection,
- void *user_data)
-{
- object_registration_free (user_data);
-}
-
-typedef struct
-{
- GObject *object;
- GString *xml;
- GType gtype;
- const DBusGObjectInfo *object_info;
-} DBusGLibWriteIterfaceData;
-
-typedef struct
-{
- GSList *methods;
- GSList *signals;
- GSList *properties;
-} DBusGLibWriteInterfaceValues;
-
-static void
-write_interface (gpointer key, gpointer val, gpointer user_data)
-{
- const char *name;
- GSList *methods;
- GSList *signals;
- GSList *properties;
- GString *xml;
- const DBusGObjectInfo *object_info;
- DBusGLibWriteIterfaceData *data;
- DBusGLibWriteInterfaceValues *values;
-
- name = key;
-
- values = val;
- methods = values->methods;
- signals = values->signals;
- properties = values->properties;
-
- data = user_data;
- xml = data->xml;
- object_info = data->object_info;
-
- g_string_append_printf (xml, " <interface name=\"%s\">\n", name);
-
- /* FIXME: recurse to parent types ? */
- for (; methods; methods = methods->next)
- {
- DBusGMethodInfo *method;
- const char *args;
- method = methods->data;
-
- g_string_append_printf (xml, " <method name=\"%s\">\n",
- method_name_from_object_info (object_info, method));
-
- args = method_arg_info_from_object_info (object_info, method);
-
- while (*args)
- {
- const char *name;
- gboolean arg_in;
- const char *type;
-
- args = arg_iterate (args, &name, &arg_in, NULL, NULL, &type);
-
- /* FIXME - handle container types */
- g_string_append_printf (xml, " <arg name=\"%s\" type=\"%s\" direction=\"%s\"/>\n",
- name, type, arg_in ? "in" : "out");
-
- }
- g_string_append (xml, " </method>\n");
-
- }
- g_slist_free (values->methods);
-
- for (; signals; signals = signals->next)
- {
- guint id;
- guint arg;
- const char *signame;
- GSignalQuery query;
- char *s;
-
- signame = signals->data;
-
- s = _dbus_gutils_wincaps_to_uscore (signame);
-
- id = g_signal_lookup (s, data->gtype);
- g_assert (id != 0);
-
- g_signal_query (id, &query);
- g_assert (query.return_type == G_TYPE_NONE);
-
- g_string_append_printf (xml, " <signal name=\"%s\">\n", signame);
-
- for (arg = 0; arg < query.n_params; arg++)
- {
- char *dbus_type = _dbus_gtype_to_signature (query.param_types[arg]);
-
- g_assert (dbus_type != NULL);
-
- g_string_append (xml, " <arg type=\"");
- g_string_append (xml, dbus_type);
- g_string_append (xml, "\"/>\n");
- g_free (dbus_type);
- }
-
- g_string_append (xml, " </signal>\n");
- g_free (s);
- }
- g_slist_free (values->signals);
-
- for (; properties; properties = properties->next)
- {
- const char *iface;
- const char *propname;
- const char *propname_uscore;
- const char *access_type;
- GParamSpec *spec;
- char *dbus_type;
- gboolean can_set;
- gboolean can_get;
- char *s;
-
- spec = NULL;
-
- property_iterate (properties->data, object_info->format_version, &iface, &propname, &propname_uscore, &access_type);
-
- s = lookup_property_name (data->object, name, propname);
-
- spec = g_object_class_find_property (g_type_class_peek (data->gtype), s);
- g_assert (spec != NULL);
- g_free (s);
-
- dbus_type = _dbus_gtype_to_signature (G_PARAM_SPEC_VALUE_TYPE (spec));
- g_assert (dbus_type != NULL);
-
- can_set = strcmp (access_type, "readwrite") == 0
- && ((spec->flags & G_PARAM_WRITABLE) != 0
- && (spec->flags & G_PARAM_CONSTRUCT_ONLY) == 0);
-
- can_get = (spec->flags & G_PARAM_READABLE) != 0;
-
- if (can_set || can_get)
- {
- g_string_append_printf (xml, " <property name=\"%s\" ", propname);
- g_string_append (xml, "type=\"");
- g_string_append (xml, dbus_type);
- g_string_append (xml, "\" access=\"");
-
- if (can_set && can_get)
- g_string_append (xml, "readwrite");
- else if (can_get)
- g_string_append (xml, "read");
- else
- {
- g_assert (can_set);
- g_string_append (xml, "write");
- }
-
- g_string_append (xml, "\"/>\n");
- }
-
- g_free (dbus_type);
- }
- g_slist_free (values->properties);
-
- g_free (values);
- g_string_append (xml, " </interface>\n");
-}
-
-static DBusGLibWriteInterfaceValues *
-lookup_values (GHashTable *interfaces, const char *method_interface)
-{
- DBusGLibWriteInterfaceValues *values;
- if ((values = g_hash_table_lookup (interfaces, (gpointer) method_interface)) == NULL)
- {
- values = g_new0 (DBusGLibWriteInterfaceValues, 1);
- g_hash_table_insert (interfaces, (gpointer) method_interface, values);
- }
- return values;
-}
-
-static void
-introspect_interfaces (GObject *object, GString *xml)
-{
- GList *info_list;
- const GList *info_list_walk;
- const DBusGObjectInfo *info;
- DBusGLibWriteIterfaceData data;
- int i;
- GHashTable *interfaces;
- DBusGLibWriteInterfaceValues *values;
- const char *propsig;
-
- info_list = lookup_object_info (object);
-
- g_assert (info_list != NULL);
-
- /* Gather a list of all interfaces, indexed into their methods */
- for (info_list_walk = info_list; info_list_walk != NULL; info_list_walk = g_list_next (info_list_walk))
- {
- info = (DBusGObjectInfo *) info_list_walk->data;
- interfaces = g_hash_table_new (g_str_hash, g_str_equal);
-
- g_assert (info != NULL);
-
- for (i = 0; i < info->n_method_infos; i++)
- {
- const char *method_interface;
- const DBusGMethodInfo *method;
-
- method = &(info->method_infos[i]);
-
- method_interface = method_interface_from_object_info (info, method);
-
- values = lookup_values (interfaces, method_interface);
- values->methods = g_slist_prepend (values->methods, (gpointer) method);
- }
-
- propsig = info->exported_signals;
- while (propsig != NULL && *propsig)
- {
- const char *iface;
- const char *signame;
-
- propsig = signal_iterate (propsig, &iface, &signame);
-
- values = lookup_values (interfaces, iface);
- values->signals = g_slist_prepend (values->signals, (gpointer) signame);
- }
-
- propsig = info->exported_properties;
- while (propsig != NULL && *propsig)
- {
- const char *iface;
- const char *propname;
- const char *propname_uscore;
- const char *access_type;
-
- propsig = property_iterate (propsig, info->format_version, &iface, &propname, &propname_uscore, &access_type);
-
- values = lookup_values (interfaces, iface);
- values->properties = g_slist_prepend (values->properties, (gpointer)iface);
- }
-
- memset (&data, 0, sizeof (data));
- data.xml = xml;
- data.gtype = G_TYPE_FROM_INSTANCE (object);
- data.object_info = info;
- data.object = object;
-
- g_hash_table_foreach (interfaces, write_interface, &data);
- g_hash_table_destroy (interfaces);
- }
-
- g_list_free (info_list);
-}
-
-static DBusHandlerResult
-handle_introspect (DBusConnection *connection,
- DBusMessage *message,
- GObject *object)
-{
- GString *xml;
- unsigned int i;
- DBusMessage *ret;
- char **children;
-
- if (!dbus_connection_list_registered (connection,
- dbus_message_get_path (message),
- &children))
- oom (NULL);
-
- xml = g_string_new (NULL);
-
- g_string_append (xml, DBUS_INTROSPECT_1_0_XML_DOCTYPE_DECL_NODE);
-
- g_string_append (xml, "<node>\n");
-
- /* We are introspectable, though I guess that was pretty obvious */
- g_string_append_printf (xml, " <interface name=\"%s\">\n", DBUS_INTERFACE_INTROSPECTABLE);
- g_string_append (xml, " <method name=\"Introspect\">\n");
- g_string_append_printf (xml, " <arg name=\"data\" direction=\"out\" type=\"%s\"/>\n", DBUS_TYPE_STRING_AS_STRING);
- g_string_append (xml, " </method>\n");
- g_string_append (xml, " </interface>\n");
-
- /* We support get/set/getall properties */
- g_string_append_printf (xml, " <interface name=\"%s\">\n", DBUS_INTERFACE_PROPERTIES);
- g_string_append (xml, " <method name=\"Get\">\n");
- g_string_append_printf (xml, " <arg name=\"interface\" direction=\"in\" type=\"%s\"/>\n", DBUS_TYPE_STRING_AS_STRING);
- g_string_append_printf (xml, " <arg name=\"propname\" direction=\"in\" type=\"%s\"/>\n", DBUS_TYPE_STRING_AS_STRING);
- g_string_append_printf (xml, " <arg name=\"value\" direction=\"out\" type=\"%s\"/>\n", DBUS_TYPE_VARIANT_AS_STRING);
- g_string_append (xml, " </method>\n");
- g_string_append (xml, " <method name=\"Set\">\n");
- g_string_append_printf (xml, " <arg name=\"interface\" direction=\"in\" type=\"%s\"/>\n", DBUS_TYPE_STRING_AS_STRING);
- g_string_append_printf (xml, " <arg name=\"propname\" direction=\"in\" type=\"%s\"/>\n", DBUS_TYPE_STRING_AS_STRING);
- g_string_append_printf (xml, " <arg name=\"value\" direction=\"in\" type=\"%s\"/>\n", DBUS_TYPE_VARIANT_AS_STRING);
- g_string_append (xml, " </method>\n");
- g_string_append (xml, " <method name=\"GetAll\">\n");
- g_string_append_printf (xml, " <arg name=\"interface\" direction=\"in\" type=\"%s\"/>\n", DBUS_TYPE_STRING_AS_STRING);
- g_string_append_printf (xml, " <arg name=\"props\" direction=\"out\" type=\"%s\"/>\n",
- DBUS_TYPE_ARRAY_AS_STRING
- DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING
- DBUS_TYPE_STRING_AS_STRING
- DBUS_TYPE_VARIANT_AS_STRING
- DBUS_DICT_ENTRY_END_CHAR_AS_STRING
- );
-
- g_string_append (xml, " </method>\n");
- g_string_append (xml, " </interface>\n");
-
- introspect_interfaces (object, xml);
-
- /* Append child nodes */
- for (i = 0; children[i]; i++)
- g_string_append_printf (xml, " <node name=\"%s\"/>\n",
- children[i]);
-
- /* Close the XML, and send it to the requesting app */
- g_string_append (xml, "</node>\n");
-
- ret = reply_or_die (message);
-
- dbus_message_append_args (ret,
- DBUS_TYPE_STRING, &xml->str,
- DBUS_TYPE_INVALID);
-
- connection_send_or_die (connection, ret);
- dbus_message_unref (ret);
-
- g_string_free (xml, TRUE);
-
- dbus_free_string_array (children);
-
- return DBUS_HANDLER_RESULT_HANDLED;
-}
-
-static DBusMessage*
-set_object_property (DBusConnection *connection,
- DBusMessage *message,
- DBusMessageIter *iter,
- GObject *object,
- GParamSpec *pspec)
-{
- GValue value = { 0, };
- DBusMessage *ret;
- DBusMessageIter sub;
- DBusGValueMarshalCtx context;
-
- dbus_message_iter_recurse (iter, &sub);
-
- context.recursion_depth = 0;
- context.gconnection = DBUS_G_CONNECTION_FROM_CONNECTION (connection);
- context.proxy = NULL;
-
- g_value_init (&value, pspec->value_type);
- if (_dbus_gvalue_demarshal (&context, &sub, &value, NULL))
- {
- g_object_set_property (object,
- pspec->name,
- &value);
-
- g_value_unset (&value);
-
- ret = reply_or_die (message);
- }
- else
- {
- ret = error_or_die (message,
- DBUS_ERROR_INVALID_ARGS,
- "Argument's D-BUS type can't be converted to a GType");
- }
-
- return ret;
-}
-
-/*
- * @pspec: the paramspec for a D-Bus-exported property
- *
- * Returns: a reply for the Get() D-Bus method, either successful or error
- */
-static DBusMessage*
-get_object_property (DBusConnection *connection,
- DBusMessage *message,
- GObject *object,
- GParamSpec *pspec)
-{
- GType value_gtype;
- GValue value = {0, };
- gchar *variant_sig;
- DBusMessage *ret;
- DBusMessageIter iter, subiter;
- gchar *error_message = NULL;
-
- ret = reply_or_die (message);
-
- g_value_init (&value, pspec->value_type);
- g_object_get_property (object, pspec->name, &value);
-
- variant_sig = _dbus_gvalue_to_signature (&value);
- if (variant_sig == NULL)
- {
- value_gtype = G_VALUE_TYPE (&value);
- error_message = g_strdup_printf (
- "Internal error: cannot marshal type \"%s\" in variant",
- g_type_name (value_gtype));
- goto out;
- }
-
- dbus_message_iter_init_append (ret, &iter);
- if (!dbus_message_iter_open_container (&iter,
- DBUS_TYPE_VARIANT,
- variant_sig,
- &subiter))
- {
- error_message = g_strdup_printf (
- "Internal error: cannot open variant container for signature %s",
- variant_sig);
- goto out;
- }
-
- if (!_dbus_gvalue_marshal (&subiter, &value))
- {
- dbus_message_iter_abandon_container (&iter, &subiter);
- error_message = g_strdup_printf (
- "Internal error: could not marshal type \"%s\" in variant",
- G_VALUE_TYPE_NAME (&value));
- goto out;
- }
-
- dbus_message_iter_close_container (&iter, &subiter);
-
-out:
- g_value_unset (&value);
- g_free (variant_sig);
-
- if (error_message != NULL)
- {
- dbus_message_unref (ret);
- ret = error_or_die (message, DBUS_ERROR_FAILED, error_message);
- g_critical ("%s", error_message);
- g_free (error_message);
- }
-
- return ret;
-}
-
-#define SHADOW_PROP_QUARK (dbus_g_object_type_dbus_shadow_property_quark ())
-
-static GQuark
-dbus_g_object_type_dbus_shadow_property_quark (void)
-{
- static GQuark quark;
-
- if (!quark)
- quark = g_quark_from_static_string ("DBusGObjectTypeDBusShadowPropertyQuark");
- return quark;
-}
-
-/* Look for shadow properties on the given interface first, otherwise
- * just return the original property name. This allows implementations to
- * get around the glib limitation of unique property names among all
- * GInterfaces by registering a "shadow" property name that the get/set
- * request will be redirected to.
- *
- * Shadow property data is stored as qdata on each GInterface. If there
- * is no interface info, or there is no registered shadow property, just
- * return the original property name.
- */
-static char *
-lookup_property_name (GObject *object,
- const char *wincaps_propiface,
- const char *requested_propname)
-{
- const DBusGObjectInfo *object_info;
- GHashTable *shadow_props;
- char *shadow_prop_name = NULL, *uscore_name;
- GType iface_type = 0;
-
- g_assert (wincaps_propiface != NULL);
- g_assert (requested_propname != NULL);
-
- uscore_name = _dbus_gutils_wincaps_to_uscore (requested_propname);
-
- object_info = lookup_object_info_by_iface (object, wincaps_propiface, FALSE, &iface_type);
- if (!object_info)
- return uscore_name;
-
- shadow_props = (GHashTable *) g_type_get_qdata (iface_type, SHADOW_PROP_QUARK);
- if (shadow_props)
- {
- shadow_prop_name = g_strdup (g_hash_table_lookup (shadow_props, requested_propname));
- if (shadow_prop_name)
- g_free (uscore_name);
- }
-
- return shadow_prop_name ? shadow_prop_name : uscore_name;
-}
-
-/**
- * dbus_g_object_type_register_shadow_property:
- * @iface_type: #GType for the #GInterface
- * @dbus_prop_name: D-Bus property name (as specified in the introspection data)
- * to override with the shadow property name (as specified in the GType's
- * initialization function, ie glib-style)
- * @shadow_prop_name: property name which should override the shadow property
- *
- * Registers a new property name @shadow_prop_name that overrides the
- * @dbus_prop_name in D-Bus property get/set requests. Since all properties for
- * all interfaces implemented by a GObject exist in the same namespace, this
- * allows implementations to use the same property name in two or more D-Bus
- * interfaces implemented by the same GObject, as long as one of those D-Bus
- * interface properties is registered with a shadow property name.
- *
- * For example, if both org.foobar.Baz.InterfaceA and org.foobar.Baz.InterfaceB
- * have a D-Bus property called "Bork", the developer assigns a shadow property
- * name to the conflicting property name in one or both of these GInterfaces to
- * resolve the conflict. Assume the GInterface implementing
- * org.foobar.Baz.InterfaceA registers a shadow property called "a-bork", while
- * the GInterface implementing org.foobar.Baz.InterfaceB registers a shadow
- * property called "b-bork". The GObject implementing both these GInterfaces
- * would then use #g_object_class_override_property() to implement both
- * "a-bork" and "b-bork" and D-Bus requests for "Bork" on either D-Bus interface
- * will not conflict.
- *
- * Deprecated: New code should use GDBus instead. There is no
- * equivalent for this function, because GDBus does not conflate
- * GObject and D-Bus property names in the same way.
- */
-void
-dbus_g_object_type_register_shadow_property (GType iface_type,
- const char *dbus_prop_name,
- const char *shadow_prop_name)
-{
- GHashTable *shadow_props;
-
- g_return_if_fail (G_TYPE_IS_CLASSED (iface_type) || G_TYPE_IS_INTERFACE (iface_type));
- g_return_if_fail (dbus_prop_name != NULL);
- g_return_if_fail (shadow_prop_name != NULL);
-
- shadow_props = (GHashTable *) g_type_get_qdata (iface_type, SHADOW_PROP_QUARK);
- if (!shadow_props)
- {
- shadow_props = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
- g_type_set_qdata (iface_type,
- dbus_g_object_type_dbus_shadow_property_quark (),
- shadow_props);
- }
-
- g_assert (shadow_props);
- g_hash_table_insert (shadow_props, g_strdup (dbus_prop_name), g_strdup (shadow_prop_name));
-}
-
-static DBusMessage*
-get_all_object_properties (DBusConnection *connection,
- DBusMessage *message,
- const DBusGObjectInfo *object_info,
- const char *wincaps_propiface,
- GObject *object)
-{
- DBusMessage *ret;
- DBusMessageIter iter_ret;
- DBusMessageIter iter_dict;
- DBusMessageIter iter_dict_entry;
- DBusMessageIter iter_dict_value;
- const char *p;
- char *uscore_propname;
-
- ret = reply_or_die (message);
-
- dbus_message_iter_init_append (ret, &iter_ret);
-
- /* the types are all hard-coded, so this can only fail via OOM */
- if (!dbus_message_iter_open_container (&iter_ret,
- DBUS_TYPE_ARRAY,
- DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING
- DBUS_TYPE_STRING_AS_STRING
- DBUS_TYPE_VARIANT_AS_STRING
- DBUS_DICT_ENTRY_END_CHAR_AS_STRING,
- &iter_dict))
- oom (NULL);
-
- p = object_info->exported_properties;
- while (p != NULL && *p != '\0')
- {
- const char *prop_ifname;
- const char *prop_name;
- const char *prop_uscored;
- const char *access_flags;
- GParamSpec *pspec;
- GType value_gtype;
- GValue value = {0, };
- gchar *variant_sig;
-
- p = property_iterate (p, object_info->format_version, &prop_ifname, &prop_name, &prop_uscored, &access_flags);
-
- /* Conventionally, property names are valid member names, but dbus-glib
- * doesn't enforce this, and some dbus-glib services use GObject-style
- * property names (e.g. "foo-bar"). */
- if (!g_utf8_validate (prop_name, -1, NULL))
- {
- g_critical ("property name isn't UTF-8: %s", prop_name);
- continue;
- }
-
- uscore_propname = lookup_property_name (object, wincaps_propiface, prop_name);
-
- pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (object), uscore_propname);
- if (pspec == NULL)
- {
- g_warning ("introspection data references non-existing property %s", uscore_propname);
- g_free (uscore_propname);
- continue;
- }
-
- g_free (uscore_propname);
-
- g_value_init (&value, pspec->value_type);
- g_object_get_property (object, pspec->name, &value);
-
- variant_sig = _dbus_gvalue_to_signature (&value);
- if (variant_sig == NULL)
- {
- value_gtype = G_VALUE_TYPE (&value);
- g_warning ("Cannot marshal type \"%s\" in variant", g_type_name (value_gtype));
- g_value_unset (&value);
- continue;
- }
-
- /* a signature returned by _dbus_gvalue_to_signature had better be
- * valid */
- g_assert (g_variant_is_signature (variant_sig));
-
- /* type is hard-coded, so this can't fail except by OOM */
- if (!dbus_message_iter_open_container (&iter_dict,
- DBUS_TYPE_DICT_ENTRY,
- NULL,
- &iter_dict_entry))
- oom (NULL);
-
- /* prop_name is valid UTF-8, so this can't fail except by OOM; no point
- * in abandoning @iter_dict_entry since we're about to crash out */
- if (!dbus_message_iter_append_basic (&iter_dict_entry, DBUS_TYPE_STRING, &prop_name))
- oom (NULL);
-
- /* variant_sig has been asserted to be valid, so this can't fail
- * except by OOM */
- if (!dbus_message_iter_open_container (&iter_dict_entry,
- DBUS_TYPE_VARIANT,
- variant_sig,
- &iter_dict_value))
- oom (NULL);
-
- g_free (variant_sig);
-
- /* this can fail via programming error: the GObject property was
- * malformed (non-UTF8 string or something) */
- if (!_dbus_gvalue_marshal (&iter_dict_value, &value))
- {
- gchar *contents = g_strdup_value_contents (&value);
- gchar *error_message = g_strdup_printf (
- "cannot GetAll(%s): failed to serialize %s value of type %s: %s",
- wincaps_propiface, prop_name, G_VALUE_TYPE_NAME (&value),
- contents);
-
- g_critical ("%s", error_message);
-
- /* abandon ship! */
- dbus_message_iter_abandon_container (&iter_dict_entry,
- &iter_dict_value);
- dbus_message_iter_abandon_container (&iter_dict, &iter_dict_entry);
- dbus_message_unref (ret);
- ret = error_or_die (message, DBUS_ERROR_FAILED, error_message);
-
- g_free (contents);
- g_free (error_message);
- g_value_unset (&value);
- return ret;
- }
-
- /* these shouldn't fail except by OOM now that we were successful */
- if (!dbus_message_iter_close_container (&iter_dict_entry,
- &iter_dict_value))
- oom (NULL);
- if (!dbus_message_iter_close_container (&iter_dict, &iter_dict_entry))
- oom (NULL);
-
- g_value_unset (&value);
- }
-
- if (!dbus_message_iter_close_container (&iter_ret, &iter_dict))
- oom (NULL);
-
- return ret;
-}
-
-static gboolean
-lookup_object_and_method (GObject *object,
- DBusMessage *message,
- const DBusGObjectInfo **object_ret,
- const DBusGMethodInfo **method_ret)
-{
- const char *interface;
- const char *member;
- const char *signature;
- GList *info_list;
- const GList *info_list_walk;
- const DBusGObjectInfo *info;
- int i;
-
- interface = dbus_message_get_interface (message);
- member = dbus_message_get_member (message);
- signature = dbus_message_get_signature (message);
-
- info_list = lookup_object_info (object);
-
- for (info_list_walk = info_list; info_list_walk != NULL; info_list_walk = g_list_next (info_list_walk))
- {
- info = (DBusGObjectInfo *) info_list_walk->data;
- *object_ret = info;
-
- for (i = 0; i < info->n_method_infos; i++)
- {
- const char *expected_member;
- const char *expected_interface;
- char *expected_signature;
- const DBusGMethodInfo *method;
-
- method = &(info->method_infos[i]);
-
- /* Check method interface/name and input signature */
- expected_interface = method_interface_from_object_info (*object_ret, method);
- expected_member = method_name_from_object_info (*object_ret, method);
- expected_signature = method_input_signature_from_object_info (*object_ret, method);
-
- if ((interface == NULL
- || strcmp (expected_interface, interface) == 0)
- && strcmp (expected_member, member) == 0
- && strcmp (expected_signature, signature) == 0)
- {
- g_free (expected_signature);
- *method_ret = method;
- g_list_free (info_list);
- return TRUE;
- }
- g_free (expected_signature);
- }
- }
-
- if (info_list)
- g_list_free (info_list);
-
- return FALSE;
-}
-
-static char *
-gerror_domaincode_to_dbus_error_name (const DBusGObjectInfo *object_info,
- const char *msg_interface,
- GQuark domain, gint code)
-{
- const char *domain_str;
- const char *code_str;
- GString *dbus_error_name;
-
- domain_str = object_error_domain_prefix_from_object_info (object_info);
- code_str = object_error_code_from_object_info (object_info, domain, code);
-
- if (!domain_str || !code_str)
- {
- DBusGErrorInfo *info;
-
- g_static_rw_lock_reader_lock (&globals_lock);
-
- if (error_metadata != NULL)
- info = g_datalist_id_get_data (&error_metadata, domain);
- else
- info = NULL;
-
- g_static_rw_lock_reader_unlock (&globals_lock);
-
- if (info)
- {
- GEnumValue *value;
- GEnumClass *klass;
-
- klass = g_type_class_ref (info->code_enum);
- value = g_enum_get_value (klass, code);
- g_type_class_unref (klass);
-
- domain_str = info->default_iface;
- if (value)
- {
- code_str = value->value_nick;
- }
- else
- {
- g_warning ("Error code %d out of range for GError domain %s",
- code, g_quark_to_string (domain));
- code_str = NULL;
- }
- }
- }
-
- if (!domain_str)
- domain_str = msg_interface;
-
- if (!domain_str || !code_str)
- {
- const char *domain_string;
- /* If we can't map it sensibly, make up an error name */
-
- dbus_error_name = g_string_new ("org.freedesktop.DBus.GLib.UnmappedError.");
-
- domain_string = g_quark_to_string (domain);
- if (domain_string != NULL)
- {
- char *uscored = uscore_to_wincaps (domain_string);
- g_string_append (dbus_error_name, uscored);
- g_string_append_c (dbus_error_name, '.');
- g_free (uscored);
- }
-
- /* Map -1 to (unsigned) -1 to avoid "-", which is not valid */
- g_string_append_printf (dbus_error_name, "Code%u", (unsigned) code);
- }
- else
- {
- gchar *code_str_wincaps;
- dbus_error_name = g_string_new (domain_str);
- g_string_append_c (dbus_error_name, '.');
- /* We can't uppercase here for backwards compatibility
- * reasons; if someone had a lowercase enumeration value,
- * previously we'd just send it across unaltered.
- */
- code_str_wincaps = uscore_to_wincaps_full (code_str, FALSE, FALSE);
- g_string_append (dbus_error_name, code_str_wincaps);
- g_free (code_str_wincaps);
- }
-
- return g_string_free (dbus_error_name, FALSE);
-}
-
-static DBusMessage *
-gerror_to_dbus_error_message (const DBusGObjectInfo *object_info,
- DBusMessage *message,
- const GError *error)
-{
- DBusMessage *reply;
-
- if (!error)
- {
- char *error_msg;
-
- error_msg = g_strdup_printf ("Method invoked for %s returned FALSE but did not set error", dbus_message_get_member (message));
- reply = error_or_die (message, "org.freedesktop.DBus.GLib.ErrorError", error_msg);
- g_free (error_msg);
- }
- else
- {
- if (error->domain == DBUS_GERROR)
- {
- const gchar *name = DBUS_ERROR_FAILED;
-
- switch (error->code)
- {
- case DBUS_GERROR_FAILED:
- name = DBUS_ERROR_FAILED;
- break;
- case DBUS_GERROR_NO_MEMORY:
- name = DBUS_ERROR_NO_MEMORY;
- break;
- case DBUS_GERROR_SERVICE_UNKNOWN:
- name = DBUS_ERROR_SERVICE_UNKNOWN;
- break;
- case DBUS_GERROR_NAME_HAS_NO_OWNER:
- name = DBUS_ERROR_NAME_HAS_NO_OWNER;
- break;
- case DBUS_GERROR_NO_REPLY:
- name = DBUS_ERROR_NO_REPLY;
- break;
- case DBUS_GERROR_IO_ERROR:
- name = DBUS_ERROR_IO_ERROR;
- break;
- case DBUS_GERROR_BAD_ADDRESS:
- name = DBUS_ERROR_BAD_ADDRESS;
- break;
- case DBUS_GERROR_NOT_SUPPORTED:
- name = DBUS_ERROR_NOT_SUPPORTED;
- break;
- case DBUS_GERROR_LIMITS_EXCEEDED:
- name = DBUS_ERROR_LIMITS_EXCEEDED;
- break;
- case DBUS_GERROR_ACCESS_DENIED:
- name = DBUS_ERROR_ACCESS_DENIED;
- break;
- case DBUS_GERROR_AUTH_FAILED:
- name = DBUS_ERROR_AUTH_FAILED;
- break;
- case DBUS_GERROR_NO_SERVER:
- name = DBUS_ERROR_NO_SERVER;
- break;
- case DBUS_GERROR_TIMEOUT:
- name = DBUS_ERROR_TIMEOUT;
- break;
- case DBUS_GERROR_NO_NETWORK:
- name = DBUS_ERROR_NO_NETWORK;
- break;
- case DBUS_GERROR_ADDRESS_IN_USE:
- name = DBUS_ERROR_ADDRESS_IN_USE;
- break;
- case DBUS_GERROR_DISCONNECTED:
- name = DBUS_ERROR_DISCONNECTED;
- break;
- case DBUS_GERROR_INVALID_ARGS:
- name = DBUS_ERROR_INVALID_ARGS;
- break;
- case DBUS_GERROR_FILE_NOT_FOUND:
- name = DBUS_ERROR_FILE_NOT_FOUND;
- break;
- case DBUS_GERROR_REMOTE_EXCEPTION:
- name = dbus_g_error_get_name ((GError*) error);
- break;
- }
-
- reply = error_or_die (message, name, error->message);
- }
- else
- {
- char *error_name;
- error_name = gerror_domaincode_to_dbus_error_name (object_info,
- dbus_message_get_interface (message),
- error->domain, error->code);
- reply = error_or_die (message, error_name, error->message);
- g_free (error_name);
- }
- }
-
- return reply;
-}
-
-/**
- * SECTION:dbus-gmethod
- * @title: DBusGMethod
- * @short_description: GMethod Info & Invocation
- * @see_also: #DBusGMessage
- * @stability: Stable
- *
- * These types are used to call methods on #GObject objects.
- */
-
-/**
- * DBusGMethodInvocation:
- *
- * The context of an asynchronous method call. See dbus_g_method_return() and
- * dbus_g_method_return_error().
- *
- * Deprecated: New code should use GDBus instead. The closest
- * equivalent is #GDBusMethodInvocation.
- */
-struct _DBusGMethodInvocation {
- DBusGConnection *connection; /**< The connection */
- DBusGMessage *message; /**< The message which generated the method call */
- const DBusGObjectInfo *object; /**< The object the method was called on */
- const DBusGMethodInfo *method; /**< The method called */
- gboolean send_reply;
-};
-
-static DBusHandlerResult
-invoke_object_method (GObject *object,
- const DBusGObjectInfo *object_info,
- const DBusGMethodInfo *method,
- DBusConnection *connection,
- DBusMessage *message)
-{
- gboolean had_error, is_async, send_reply;
- GError *gerror;
- GValueArray *value_array;
- GValue return_value = {0,};
- GClosure closure;
- char *in_signature;
- GArray *out_param_values = NULL;
- GValueArray *out_param_gvalues = NULL;
- int out_param_count;
- int out_param_pos, out_param_gvalue_pos;
- DBusMessage *reply = NULL;
- gboolean have_retval;
- gboolean retval_signals_error;
- gboolean retval_is_synthetic;
- gboolean retval_is_constant;
- const char *arg_metadata;
-
- gerror = NULL;
-
- /* This flag says whether invokee is handed a special DBusGMethodInvocation structure,
- * instead of being required to fill out all return values in the context of the function.
- * Some additional data is also exposed, such as the message sender.
- */
- is_async = strcmp (string_table_lookup (get_method_data (object_info, method), 2), "A") == 0;
-
- /* Messages can be sent with a flag that says "I don't need a reply". This is an optimization
- * normally, but in the context of the system bus it's important to not send a reply
- * to these kinds of messages, because they will be unrequested replies, and thus subject
- * to denial and logging. We don't want to fill up logs.
- * http://bugs.freedesktop.org/show_bug.cgi?id=19441
- */
- send_reply = !dbus_message_get_no_reply (message);
-
- have_retval = FALSE;
- retval_signals_error = FALSE;
- retval_is_synthetic = FALSE;
- retval_is_constant = FALSE;
-
- /* This is evil. We do this to work around the fact that
- * the generated glib marshallers check a flag in the closure object
- * which we don't care about. We don't need/want to create
- * a new closure for each invocation.
- */
- memset (&closure, 0, sizeof (closure));
-
- in_signature = method_input_signature_from_object_info (object_info, method);
-
- /* Convert method IN parameters to GValueArray */
- {
- GArray *types_array;
- guint n_params;
- const GType *types;
- DBusGValueMarshalCtx context;
- GError *error = NULL;
-
- context.recursion_depth = 0;
- context.gconnection = DBUS_G_CONNECTION_FROM_CONNECTION (connection);
- context.proxy = NULL;
-
- types_array = _dbus_gtypes_from_arg_signature (in_signature, FALSE);
- n_params = types_array->len;
- types = (const GType*) types_array->data;
-
- value_array = _dbus_gvalue_demarshal_message (&context, message, n_params, types, &error);
- if (value_array == NULL)
- {
- g_free (in_signature);
- g_array_free (types_array, TRUE);
- reply = error_or_die (message, "org.freedesktop.DBus.GLib.ErrorError", error->message);
- connection_send_or_die (connection, reply);
- dbus_message_unref (reply);
- g_error_free (error);
- return DBUS_HANDLER_RESULT_HANDLED;
- }
- g_array_free (types_array, TRUE);
- }
-
- /* Prepend object as first argument */
- g_value_array_prepend (value_array, NULL);
- g_value_init (g_value_array_get_nth (value_array, 0), G_TYPE_OBJECT);
- g_value_set_object (g_value_array_get_nth (value_array, 0), object);
-
- if (is_async)
- {
- GValue context_value = {0,};
- DBusGMethodInvocation *context;
- context = g_new (DBusGMethodInvocation, 1);
- context->connection = dbus_g_connection_ref (DBUS_G_CONNECTION_FROM_CONNECTION (connection));
- context->message = dbus_g_message_ref (DBUS_G_MESSAGE_FROM_MESSAGE (message));
- context->object = object_info;
- context->method = method;
- context->send_reply = send_reply;
- g_value_init (&context_value, G_TYPE_POINTER);
- g_value_set_pointer (&context_value, context);
- g_value_array_append (value_array, &context_value);
- }
- else
- {
- RetvalType retval;
- gboolean arg_in;
- gboolean arg_const;
- const char *argsig;
-
- arg_metadata = method_arg_info_from_object_info (object_info, method);
-
- /* Count number of output parameters, and look for a return value */
- out_param_count = 0;
- while (*arg_metadata)
- {
- arg_metadata = arg_iterate (arg_metadata, NULL, &arg_in, &arg_const, &retval, &argsig);
- if (arg_in)
- continue;
- if (retval != RETVAL_NONE)
- {
- DBusSignatureIter tmp_sigiter;
- /* This is the function return value */
- g_assert (!have_retval);
- have_retval = TRUE;
- retval_is_synthetic = FALSE;
-
- switch (retval)
- {
- case RETVAL_NONE:
- g_assert_not_reached ();
- break;
- case RETVAL_NOERROR:
- retval_signals_error = FALSE;
- break;
- case RETVAL_ERROR:
- retval_signals_error = TRUE;
- break;
- }
-
- retval_is_constant = arg_const;
-
- /* Initialize our return GValue with the specified type */
- dbus_signature_iter_init (&tmp_sigiter, argsig);
- g_value_init (&return_value, _dbus_gtype_from_signature_iter (&tmp_sigiter, FALSE));
- }
- else
- {
- /* It's a regular output value */
- out_param_count++;
- }
- }
-
- /* For compatibility, if we haven't found a return value, we assume
- * the function returns a gboolean for signalling an error
- * (and therefore also takes a GError). We also note that it
- * is a "synthetic" return value; i.e. we aren't going to be
- * sending it over the bus, it's just to signal an error.
- */
- if (!have_retval)
- {
- have_retval = TRUE;
- retval_is_synthetic = TRUE;
- retval_signals_error = TRUE;
- g_value_init (&return_value, G_TYPE_BOOLEAN);
- }
-
- /* Create an array to store the actual values of OUT parameters
- * (other than the real function return, if any). Then, create
- * a GValue boxed POINTER to each of those values, and append to
- * the invocation, so the method can return the OUT parameters.
- */
- out_param_values = g_array_sized_new (FALSE, TRUE, sizeof (GTypeCValue), out_param_count);
-
- /* We have a special array of GValues for toplevel GValue return
- * types.
- */
- out_param_gvalues = g_value_array_new (out_param_count);
- out_param_pos = 0;
- out_param_gvalue_pos = 0;
-
- /* Reset argument metadata pointer */
- arg_metadata = method_arg_info_from_object_info (object_info, method);
-
- /* Iterate over output arguments again, this time allocating space for
- * them as appopriate.
- */
- while (*arg_metadata)
- {
- GValue value = {0, };
- GTypeCValue storage;
- DBusSignatureIter tmp_sigiter;
- GType current_gtype;
-
- arg_metadata = arg_iterate (arg_metadata, NULL, &arg_in, NULL, &retval, &argsig);
- /* Skip over input arguments and the return value, if any */
- if (arg_in || retval != RETVAL_NONE)
- continue;
-
- dbus_signature_iter_init (&tmp_sigiter, argsig);
- current_gtype = _dbus_gtype_from_signature_iter (&tmp_sigiter, FALSE);
-
- g_value_init (&value, G_TYPE_POINTER);
-
- /* We special case variants to make method invocation a bit nicer */
- if (current_gtype != G_TYPE_VALUE)
- {
- memset (&storage, 0, sizeof (storage));
- g_array_append_val (out_param_values, storage);
- g_value_set_pointer (&value, &(g_array_index (out_param_values, GTypeCValue, out_param_pos)));
- out_param_pos++;
- }
- else
- {
- g_value_array_append (out_param_gvalues, NULL);
- g_value_set_pointer (&value, out_param_gvalues->values + out_param_gvalue_pos);
- out_param_gvalue_pos++;
- }
- g_value_array_append (value_array, &value);
- }
- }
-
- /* Append GError as final argument if necessary */
- if (retval_signals_error)
- {
- g_assert (have_retval);
- g_value_array_append (value_array, NULL);
- g_value_init (g_value_array_get_nth (value_array, value_array->n_values - 1), G_TYPE_POINTER);
- g_value_set_pointer (g_value_array_get_nth (value_array, value_array->n_values - 1), &gerror);
- }
-
- /* Actually invoke method */
- method->marshaller (&closure, have_retval ? &return_value : NULL,
- value_array->n_values,
- value_array->values,
- NULL, method->function);
- if (is_async)
- {
- goto done;
- }
-
- if (retval_signals_error)
- had_error = _dbus_gvalue_signals_error (&return_value);
- else
- had_error = FALSE;
-
- if (!had_error)
- {
- DBusMessageIter iter;
-
- /* Careful here - there are two major cases in this section of the code.
- * If send_reply is TRUE, we're constructing a dbus message and freeing
- * the return values. If it's FALSE, then we just need to free the
- * values.
- */
- if (send_reply)
- {
- reply = reply_or_die (message);
-
- /* Append output arguments to reply */
- dbus_message_iter_init_append (reply, &iter);
- }
-
- /* First, append the return value, unless it's synthetic */
- if (have_retval && !retval_is_synthetic)
- {
- if (reply != NULL && !_dbus_gvalue_marshal (&iter, &return_value))
- {
- gchar *desc = g_strdup_value_contents (&return_value);
-
- g_critical ("unable to append retval of type %s for %s: %s",
- G_VALUE_TYPE_NAME (&return_value),
- method_name_from_object_info (object_info, method),
- desc);
- g_free (desc);
- /* the reply is now unusable but we still need to free
- * everything */
- dbus_message_unref (reply);
- reply = NULL;
- }
-
- if (!retval_is_constant)
- g_value_unset (&return_value);
- }
-
- /* Grab the argument metadata and iterate over it */
- arg_metadata = method_arg_info_from_object_info (object_info, method);
-
- /* Now append any remaining return values */
- out_param_pos = 0;
- out_param_gvalue_pos = 0;
- while (*arg_metadata)
- {
- GValue gvalue = {0, };
- const char *arg_name;
- gboolean arg_in;
- gboolean constval;
- RetvalType retval;
- const char *arg_signature;
- DBusSignatureIter argsigiter;
-
- do
- {
- /* Iterate over only output values; skip over input
- arguments and the return value */
- arg_metadata = arg_iterate (arg_metadata, &arg_name, &arg_in, &constval, &retval, &arg_signature);
- }
- while ((arg_in || retval != RETVAL_NONE) && *arg_metadata);
-
- /* If the last argument we saw was input or the return
- * value, we must be done iterating over output arguments.
- */
- if (arg_in || retval != RETVAL_NONE)
- break;
-
- dbus_signature_iter_init (&argsigiter, arg_signature);
-
- g_value_init (&gvalue, _dbus_gtype_from_signature_iter (&argsigiter, FALSE));
- if (G_VALUE_TYPE (&gvalue) != G_TYPE_VALUE)
- {
- if (!_dbus_gvalue_take (&gvalue,
- &(g_array_index (out_param_values, GTypeCValue, out_param_pos))))
- g_assert_not_reached ();
- out_param_pos++;
- }
- else
- {
- g_value_set_static_boxed (&gvalue, out_param_gvalues->values + out_param_gvalue_pos);
- out_param_gvalue_pos++;
- }
-
- if (reply && !_dbus_gvalue_marshal (&iter, &gvalue))
- {
- gchar *desc = g_strdup_value_contents (&gvalue);
-
- g_critical ("unable to append OUT arg of type %s for %s: %s",
- G_VALUE_TYPE_NAME (&gvalue),
- method_name_from_object_info (object_info, method),
- desc);
- g_free (desc);
- /* the reply is now unusable but we still need to free
- * everything */
- dbus_message_unref (reply);
- reply = NULL;
- }
-
- /* Here we actually free the allocated value; we
- * took ownership of it with _dbus_gvalue_take, unless
- * an annotation has specified this value as constant.
- */
- if (!constval)
- g_value_unset (&gvalue);
- }
- }
- else if (send_reply)
- reply = gerror_to_dbus_error_message (object_info, message, gerror);
-
- if (reply)
- {
- connection_send_or_die (connection, reply);
- dbus_message_unref (reply);
- }
-
-done:
- g_free (in_signature);
-
- if (!is_async)
- {
- g_array_free (out_param_values, TRUE);
- g_value_array_free (out_param_gvalues);
- }
-
- if (gerror != NULL)
- g_clear_error (&gerror);
-
- g_value_array_free (value_array);
- return DBUS_HANDLER_RESULT_HANDLED;
-}
-
-/*
- * @wincaps_propiface: the D-Bus interface name, conventionally WindowsCaps
- * @requested_propname: the D-Bus property name, conventionally WindowsCaps
- * @uscore_propname: the GObject property name, conventionally
- * words_with_underscores or words-with-dashes
- * @is_set: %TRUE if we're going to set the property, %FALSE if we're going
- * to get it
- *
- * Check that the requested property exists and the requested access is
- * allowed. If not, reply with a D-Bus AccessDenied error message.
- *
- * Returns: %TRUE if property access can continue, or %FALSE if an error
- * reply has been sent
- */
-static gboolean
-check_property_access (DBusConnection *connection,
- DBusMessage *message,
- GObject *object,
- const char *wincaps_propiface,
- const char *requested_propname,
- const char *uscore_propname,
- gboolean is_set)
-{
- const DBusGObjectInfo *object_info;
- const char *access_type;
- DBusMessage *ret;
- gchar *error_message;
-
- if (!is_set && !disable_legacy_property_access)
- return TRUE;
-
- object_info = lookup_object_info_by_iface (object, wincaps_propiface, TRUE, NULL);
- if (!object_info)
- {
- error_message = g_strdup_printf (
- "Interface \"%s\" isn't exported (or may not exist), can't access property \"%s\"",
- wincaps_propiface, requested_propname);
-
- goto error;
- }
-
- /* Try both forms of property names: "foo_bar" or "FooBar"; for historical
- * reasons we accept both.
- */
- if (object_info
- && !(property_info_from_object_info (object_info, wincaps_propiface, requested_propname, &access_type)
- || property_info_from_object_info (object_info, wincaps_propiface, uscore_propname, &access_type)))
- {
- error_message = g_strdup_printf (
- "Property \"%s\" of interface \"%s\" isn't exported (or may not exist)",
- requested_propname, wincaps_propiface);
-
- goto error;
- }
-
- if (strcmp (access_type, "readwrite") == 0)
- return TRUE;
-
- if (is_set ? strcmp (access_type, "read") == 0
- : strcmp (access_type, "write") == 0)
- {
- error_message = g_strdup_printf (
- "Property \"%s\" of interface \"%s\" is not %s",
- requested_propname,
- wincaps_propiface,
- is_set ? "settable" : "readable");
-
- goto error;
- }
-
- return TRUE;
-
-error:
- ret = error_or_die (message, DBUS_ERROR_ACCESS_DENIED, error_message);
- g_free (error_message);
-
- connection_send_or_die (connection, ret);
- dbus_message_unref (ret);
- return FALSE;
-}
-
-static DBusHandlerResult
-object_registration_message (DBusConnection *connection,
- DBusMessage *message,
- void *user_data)
-{
- GParamSpec *pspec;
- GObject *object;
- gboolean setter;
- gboolean getter;
- gboolean getall;
- char *s;
- const char *requested_propname;
- const char *wincaps_propiface;
- DBusMessageIter iter;
- const DBusGMethodInfo *method;
- const DBusGObjectInfo *object_info;
- DBusMessage *ret;
- ObjectRegistration *o;
-
- o = user_data;
- /* export is always non-NULL. If the object has been disposed, the weak-ref
- * callback removes all registrations from the DBusConnection, so this
- * should never be reached with object = NULL. */
- object = G_OBJECT (o->export->object);
- g_assert (object != NULL);
-
- if (dbus_message_is_method_call (message,
- DBUS_INTERFACE_INTROSPECTABLE,
- "Introspect"))
- return handle_introspect (connection, message, object);
-
- /* Try the metainfo, which lets us invoke methods */
- object_info = NULL;
- if (lookup_object_and_method (object, message, &object_info, &method))
- return invoke_object_method (object, object_info, method, connection, message);
-
- /* If no metainfo, we can still do properties and signals
- * via standard GLib introspection. Note we do now check
- * property access against the metainfo if available.
- */
- getter = FALSE;
- setter = FALSE;
- getall = FALSE;
- if (dbus_message_is_method_call (message,
- DBUS_INTERFACE_PROPERTIES,
- "Get"))
- getter = TRUE;
- else if (dbus_message_is_method_call (message,
- DBUS_INTERFACE_PROPERTIES,
- "Set"))
- setter = TRUE;
- else if (dbus_message_is_method_call (message,
- DBUS_INTERFACE_PROPERTIES,
- "GetAll"))
- getall = TRUE;
-
- if (!(setter || getter || getall))
- return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
-
- ret = NULL;
-
- dbus_message_iter_init (message, &iter);
-
- if (dbus_message_iter_get_arg_type (&iter) != DBUS_TYPE_STRING)
- {
- ret = error_or_die (message, DBUS_ERROR_INVALID_ARGS,
- "First argument to Get(), GetAll() or Set() must be an interface string");
- goto out;
- }
-
- dbus_message_iter_get_basic (&iter, &wincaps_propiface);
- dbus_message_iter_next (&iter);
-
- if (getall)
- {
- object_info = lookup_object_info_by_iface (object, wincaps_propiface, TRUE, NULL);
- if (object_info != NULL)
- ret = get_all_object_properties (connection, message, object_info, wincaps_propiface, object);
- else
- return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
- }
- else
- {
- g_assert (getter || setter);
-
- if (dbus_message_iter_get_arg_type (&iter) != DBUS_TYPE_STRING)
- {
- ret = error_or_die (message, DBUS_ERROR_INVALID_ARGS,
- "Second argument to Get() or Set() must be a property name string");
- goto out;
- }
-
- dbus_message_iter_get_basic (&iter, &requested_propname);
- dbus_message_iter_next (&iter);
-
- s = lookup_property_name (object, wincaps_propiface, requested_propname);
-
- if (!check_property_access (connection, message, object, wincaps_propiface, requested_propname, s, setter))
- {
- g_free (s);
- return DBUS_HANDLER_RESULT_HANDLED;
- }
-
- pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (object),
- s);
-
- g_free (s);
-
- if (pspec != NULL)
- {
- if (setter)
- {
- if (dbus_message_iter_get_arg_type (&iter) != DBUS_TYPE_VARIANT)
- {
- ret = error_or_die (message, DBUS_ERROR_INVALID_ARGS,
- "Third argument to Set() must be a variant");
- goto out;
- }
-
- ret = set_object_property (connection, message, &iter,
- object, pspec);
- dbus_message_iter_next (&iter);
- }
- else
- {
- g_assert (getter);
- ret = get_object_property (connection, message,
- object, pspec);
- }
- }
- else
- {
- gchar *error_message = g_strdup_printf ("No such property %s",
- requested_propname);
-
- ret = error_or_die (message, DBUS_ERROR_INVALID_ARGS, error_message);
- g_free (error_message);
- }
- }
-
- g_assert (ret != NULL);
-
- /* FIXME: this should be returned as a D-Bus error, not spammed out
- * as a warning. This is too late to do that, though - we've already
- * had any side-effects we were going to have - and it would break
- * anything that's relying on ability to give us too many arguments. */
- if (dbus_message_iter_get_arg_type (&iter) != DBUS_TYPE_INVALID)
- g_warning ("Property get, set or set all had too many arguments\n");
-
-out:
- connection_send_or_die (connection, ret);
- dbus_message_unref (ret);
- return DBUS_HANDLER_RESULT_HANDLED;
-}
-
-static const DBusObjectPathVTable gobject_dbus_vtable = {
- object_registration_unregistered,
- object_registration_message,
- NULL
-};
-
-typedef struct {
- GClosure closure;
- DBusGConnection *connection;
- GObject *object;
- const char *signame;
- const char *sigiface;
-} DBusGSignalClosure;
-
-static GClosure *
-dbus_g_signal_closure_new (GObject *object,
- const char *signame,
- const char *sigiface)
-{
- DBusGSignalClosure *closure;
-
- closure = (DBusGSignalClosure*) g_closure_new_simple (sizeof (DBusGSignalClosure), NULL);
-
- closure->object = object;
- closure->signame = signame;
- closure->sigiface = sigiface;
- return (GClosure*) closure;
-}
-
-static void
-emit_signal_for_registration (ObjectRegistration *o,
- DBusGSignalClosure *sigclosure,
- GValue *retval,
- guint n_param_values,
- const GValue *param_values)
-{
- DBusMessage *signal;
- DBusMessageIter iter;
- guint i;
-
- g_assert (g_variant_is_object_path (o->object_path));
- g_assert (g_dbus_is_interface_name (sigclosure->sigiface));
- g_assert (g_dbus_is_member_name (sigclosure->signame));
-
- signal = dbus_message_new_signal (o->object_path,
- sigclosure->sigiface,
- sigclosure->signame);
- if (!signal)
- oom (NULL);
-
- dbus_message_iter_init_append (signal, &iter);
-
- /* First argument is the object itself, and we can't marshall that */
- for (i = 1; i < n_param_values; i++)
- {
- if (!_dbus_gvalue_marshal (&iter,
- (GValue *) (&(param_values[i]))))
- {
- g_warning ("failed to marshal parameter %d for signal %s",
- i, sigclosure->signame);
- goto out;
- }
- }
-
- connection_send_or_die (DBUS_CONNECTION_FROM_G_CONNECTION (o->connection),
- signal);
-out:
- dbus_message_unref (signal);
-}
-
-static void
-signal_emitter_marshaller (GClosure *closure,
- GValue *retval,
- guint n_param_values,
- const GValue *param_values,
- gpointer invocation_hint,
- gpointer marshal_data)
-{
- DBusGSignalClosure *sigclosure;
- const ObjectExport *oe;
- const GSList *iter;
-
- sigclosure = (DBusGSignalClosure *) closure;
-
- g_assert (retval == NULL);
-
- oe = g_object_get_data (sigclosure->object, "dbus_glib_object_registrations");
- /* If the object has ever been exported, this should exist; it persists until
- * the object is actually freed. */
- g_assert (oe != NULL);
-
- for (iter = oe->registrations; iter; iter = iter->next)
- {
- ObjectRegistration *o = iter->data;
-
- emit_signal_for_registration (o, sigclosure, retval, n_param_values, param_values);
- }
-}
-
-static void
-export_signals (const GList *info_list, GObject *object)
-{
- GType gtype;
- const char *sigdata;
- const char *iface;
- const char *signame;
- const DBusGObjectInfo *info;
-
- gtype = G_TYPE_FROM_INSTANCE (object);
-
- for (; info_list != NULL; info_list = g_list_next (info_list))
- {
- info = (DBusGObjectInfo *) info_list->data;
-
- sigdata = info->exported_signals;
-
- while (*sigdata != '\0')
- {
- guint id;
- GSignalQuery query;
- GClosure *closure;
- char *s;
-
- sigdata = signal_iterate (sigdata, &iface, &signame);
-
- if (!g_dbus_is_interface_name (iface))
- {
- g_critical ("invalid interface name found in %s: %s",
- g_type_name (gtype), iface);
- continue;
- }
-
- if (!g_dbus_is_member_name (signame))
- {
- g_critical ("invalid signal name found in %s: %s",
- g_type_name (gtype), signame);
- continue;
- }
-
- s = _dbus_gutils_wincaps_to_uscore (signame);
-
- id = g_signal_lookup (s, gtype);
- if (id == 0)
- {
- g_warning ("signal \"%s\" (from \"%s\") exported but not found in object class \"%s\"",
- s, signame, g_type_name (gtype));
- g_free (s);
- continue;
- }
-
- g_signal_query (id, &query);
-
- if (query.return_type != G_TYPE_NONE)
- {
- g_warning ("Not exporting signal \"%s\" for object class \"%s\" as it has a return type \"%s\"",
- s, g_type_name (gtype), g_type_name (query.return_type));
- g_free (s);
- continue; /* FIXME: these could be listed as methods ? */
- }
-
- closure = dbus_g_signal_closure_new (object, signame, (char*) iface);
- g_closure_set_marshal (closure, signal_emitter_marshaller);
-
- g_signal_connect_closure_by_id (object,
- id,
- 0,
- closure,
- FALSE);
-
- g_free (s);
- }
- }
-}
-
-static gint
-dbus_error_to_gerror_code (const char *derr)
-{
- if (0) ;
- else if (!strcmp (derr, DBUS_ERROR_FAILED ))
- return DBUS_GERROR_FAILED ;
- else if (!strcmp (derr, DBUS_ERROR_NO_MEMORY ))
- return DBUS_GERROR_NO_MEMORY ;
- else if (!strcmp (derr, DBUS_ERROR_SERVICE_UNKNOWN ))
- return DBUS_GERROR_SERVICE_UNKNOWN ;
- else if (!strcmp (derr, DBUS_ERROR_NAME_HAS_NO_OWNER ))
- return DBUS_GERROR_NAME_HAS_NO_OWNER ;
- else if (!strcmp (derr, DBUS_ERROR_NO_REPLY ))
- return DBUS_GERROR_NO_REPLY ;
- else if (!strcmp (derr, DBUS_ERROR_IO_ERROR ))
- return DBUS_GERROR_IO_ERROR ;
- else if (!strcmp (derr, DBUS_ERROR_BAD_ADDRESS ))
- return DBUS_GERROR_BAD_ADDRESS ;
- else if (!strcmp (derr, DBUS_ERROR_NOT_SUPPORTED ))
- return DBUS_GERROR_NOT_SUPPORTED ;
- else if (!strcmp (derr, DBUS_ERROR_LIMITS_EXCEEDED ))
- return DBUS_GERROR_LIMITS_EXCEEDED ;
- else if (!strcmp (derr, DBUS_ERROR_ACCESS_DENIED ))
- return DBUS_GERROR_ACCESS_DENIED ;
- else if (!strcmp (derr, DBUS_ERROR_AUTH_FAILED ))
- return DBUS_GERROR_AUTH_FAILED ;
- else if (!strcmp (derr, DBUS_ERROR_NO_SERVER ))
- return DBUS_GERROR_NO_SERVER ;
- else if (!strcmp (derr, DBUS_ERROR_TIMEOUT ))
- return DBUS_GERROR_TIMEOUT ;
- else if (!strcmp (derr, DBUS_ERROR_NO_NETWORK ))
- return DBUS_GERROR_NO_NETWORK ;
- else if (!strcmp (derr, DBUS_ERROR_ADDRESS_IN_USE ))
- return DBUS_GERROR_ADDRESS_IN_USE ;
- else if (!strcmp (derr, DBUS_ERROR_DISCONNECTED ))
- return DBUS_GERROR_DISCONNECTED ;
- else if (!strcmp (derr, DBUS_ERROR_INVALID_ARGS ))
- return DBUS_GERROR_INVALID_ARGS ;
- else if (!strcmp (derr, DBUS_ERROR_FILE_NOT_FOUND ))
- return DBUS_GERROR_FILE_NOT_FOUND ;
- else if (!strcmp (derr, DBUS_ERROR_FILE_EXISTS ))
- return DBUS_GERROR_FILE_EXISTS ;
- else if (!strcmp (derr, DBUS_ERROR_UNKNOWN_METHOD ))
- return DBUS_GERROR_UNKNOWN_METHOD ;
- else if (!strcmp (derr, DBUS_ERROR_TIMED_OUT ))
- return DBUS_GERROR_TIMED_OUT ;
- else if (!strcmp (derr, DBUS_ERROR_MATCH_RULE_NOT_FOUND ))
- return DBUS_GERROR_MATCH_RULE_NOT_FOUND ;
- else if (!strcmp (derr, DBUS_ERROR_MATCH_RULE_INVALID ))
- return DBUS_GERROR_MATCH_RULE_INVALID ;
- else if (!strcmp (derr, DBUS_ERROR_SPAWN_EXEC_FAILED ))
- return DBUS_GERROR_SPAWN_EXEC_FAILED ;
- else if (!strcmp (derr, DBUS_ERROR_SPAWN_FORK_FAILED ))
- return DBUS_GERROR_SPAWN_FORK_FAILED ;
- else if (!strcmp (derr, DBUS_ERROR_SPAWN_CHILD_EXITED ))
- return DBUS_GERROR_SPAWN_CHILD_EXITED ;
- else if (!strcmp (derr, DBUS_ERROR_SPAWN_CHILD_SIGNALED ))
- return DBUS_GERROR_SPAWN_CHILD_SIGNALED ;
- else if (!strcmp (derr, DBUS_ERROR_SPAWN_FAILED ))
- return DBUS_GERROR_SPAWN_FAILED ;
- else if (!strcmp (derr, DBUS_ERROR_UNIX_PROCESS_ID_UNKNOWN ))
- return DBUS_GERROR_UNIX_PROCESS_ID_UNKNOWN ;
- else if (!strcmp (derr, DBUS_ERROR_INVALID_SIGNATURE ))
- return DBUS_GERROR_INVALID_SIGNATURE ;
- else if (!strcmp (derr, DBUS_ERROR_INVALID_FILE_CONTENT ))
- return DBUS_GERROR_INVALID_FILE_CONTENT ;
- else if (!strcmp (derr, DBUS_ERROR_SELINUX_SECURITY_CONTEXT_UNKNOWN ))
- return DBUS_GERROR_SELINUX_SECURITY_CONTEXT_UNKNOWN ;
- else
- return DBUS_GERROR_REMOTE_EXCEPTION;
-}
-
-/**
- * dbus_set_g_error:
- * @gerror: an error
- * @derror: a #DBusError
- *
- * Store the information from a DBus method error return into a
- * GError. For the normal case of an arbitrary remote process,
- * the error code will be DBUS_GERROR_REMOTE_EXCEPTION. Now,
- * DBus errors have two components; a message and a "name".
- * The former is an arbitrary (normally American English) string.
- * The second is a string like com.example.FooFailure which
- * programs can use as a conditional source. Because a GError
- * only has one string, we use a hack to encode both values:
- *
- * &lt;human readable string&gt;&lt;null&gt;&lt;error name&gt;&lt;null&gt;
- *
- * You can use the following code to retrieve both values:
- *
- * |[const char *msg = error->message;
- * size_t len = strlen(msg);
- * const char *error_name = msg+len+1;]|
- *
- * Deprecated: New code should use GDBus instead. GDBus' error encoding
- * is much simpler and more reliable, and the closest equivalent
- * is g_dbus_error_new_for_dbus_error().
- */
-void
-dbus_set_g_error (GError **gerror,
- DBusError *derror)
-{
- int code;
-
- g_return_if_fail (derror != NULL);
- g_return_if_fail (dbus_error_is_set (derror));
- g_return_if_fail (gerror == NULL || *gerror == NULL);
-
- code = dbus_error_to_gerror_code (derror->name);
- if (code != DBUS_GERROR_REMOTE_EXCEPTION)
- g_set_error (gerror, DBUS_GERROR,
- code,
- "%s",
- derror->message);
- else
- g_set_error (gerror, DBUS_GERROR,
- code,
- "%s%c%s",
- derror->message ? derror->message : "",
- '\0',
- derror->name);
-}
-
-static void
-dbus_g_error_info_free (gpointer p)
-{
- DBusGErrorInfo *info;
-
- info = p;
-
- g_free (info->default_iface);
- g_free (info);
-}
-
-/**
- * SECTION:dbus-gobject
- * @title: DBus GObject related functions
- * @short_description: Exporting a GObject remotely
- * @see_also: #GObject
- * @stability: Stable
- *
- * FIXME
- */
-
-/**
- * dbus_glib_global_set_disable_legacy_property_access:
- *
- * For historical reasons, DBus-GLib will allow read-only
- * access to every GObject property of an object exported
- * to the bus, regardless of whether or not the property
- * is listed in the type info installed with
- * dbus_g_object_type_install_info(). (Write access is
- * denied however).
- *
- * If you wish to restrict even read-only access, you
- * can call this method to globally change the behavior
- * for the entire process.
- *
- * Since: 0.88
- *
- * Deprecated: New code should use GDBus instead. There is no
- * equivalent for this function.
- */
-void
-dbus_glib_global_set_disable_legacy_property_access (void)
-{
- disable_legacy_property_access = TRUE;
-}
-
-/**
- * dbus_g_object_type_install_info:
- * @object_type: #GType for the object
- * @info: introspection data generated by #dbus-glib-tool
- *
- * Install introspection information about the given object #GType
- * sufficient to allow methods on the object to be invoked by name.
- * The introspection information is normally generated by
- * dbus-glib-tool, then this function is called in the
- * class_init() for the object class.
- *
- * Once introspection information has been installed, instances of the
- * object registered with dbus_g_connection_register_g_object() can have
- * their methods invoked remotely.
- *
- * Deprecated: New code should use GDBus instead. There is no direct
- * equivalent for this function.
- */
-void
-dbus_g_object_type_install_info (GType object_type,
- const DBusGObjectInfo *info)
-{
- g_return_if_fail (G_TYPE_IS_CLASSED (object_type) || G_TYPE_IS_INTERFACE (object_type));
-
- _dbus_g_value_types_init ();
-
- g_type_set_qdata (object_type,
- dbus_g_object_type_dbus_metadata_quark (),
- (gpointer) info);
-}
-
-/**
- * dbus_g_error_domain_register:
- * @domain: the #GError domain
- * @default_iface: the prefix used for error values, or %NULL
- * @code_enum: a #GType for a #GEnum of the error codes
- *
- * Register a #GError domain and set of codes with D-Bus. When an object
- * raises a #GError in the domain @domain from one of its D-Bus methods,
- * the D-Bus error name used will be @default_iface, followed by a dot,
- * followed by the #GEnumValue.value_nick corresponding to the #GError.code.
- * For D-Bus, it's conventional to use an error name (value_nick) that is
- * in CamelCase.
- *
- * (For instance, if a D-Bus method <code>com.example.MyObject.GetThings</code>
- * can raise a #GError with domain <code>MY_ERROR</code> and code
- * <code>MY_ERROR_NOT_HAPPY</code>, you could call
- * <code>dbus_g_error_domain_register (MY_ERROR, "com.example.MyError",
- * MY_TYPE_ERROR)</code>, and set up the value_nick for
- * <code>MY_ERROR_NOT_HAPPY</code> to be <code>NotHappy</code>,
- * resulting in the D-Bus error string
- * <code>com.example.MyError.NotHappy</code>.)
- *
- * If @default_iface is %NULL, the D-Bus interface of the method that failed
- * will be used.
- *
- * (For instance, if the above example had called
- * <code>dbus_g_error_domain_register (MY_ERROR, NULL, MY_TYPE_ERROR)</code>
- * instead, then the D-Bus error string would be
- * <code>com.example.MyObject.NotHappy</code>.)
- *
- * Deprecated: New code should use GDBus instead. The closest equivalent
- * is g_dbus_error_register_error_domain().
- */
-void
-dbus_g_error_domain_register (GQuark domain,
- const char *default_iface,
- GType code_enum)
-{
- DBusGErrorInfo *info;
-
- g_return_if_fail (g_quark_to_string (domain) != NULL);
- g_return_if_fail (code_enum != G_TYPE_INVALID);
- g_return_if_fail (G_TYPE_FUNDAMENTAL (code_enum) == G_TYPE_ENUM);
-
- g_static_rw_lock_writer_lock (&globals_lock);
-
- if (error_metadata == NULL)
- g_datalist_init (&error_metadata);
-
- info = g_datalist_id_get_data (&error_metadata, domain);
-
- if (info != NULL)
- {
- g_warning ("Metadata for error domain \"%s\" already registered\n",
- g_quark_to_string (domain));
- }
- else
- {
- info = g_new0 (DBusGErrorInfo, 1);
- info->default_iface = g_strdup (default_iface);
- info->code_enum = code_enum;
-
- g_datalist_id_set_data_full (&error_metadata,
- domain,
- info,
- dbus_g_error_info_free);
- }
-
- g_static_rw_lock_writer_unlock (&globals_lock);
-}
-
-/* Called when the object is destroyed */
-static void
-object_export_object_died (gpointer user_data, GObject *dead)
-{
- ObjectExport *oe = user_data;
-
- g_assert (dead == oe->object);
-
- /* this prevents the weak unref from taking place, which would cause an
- * assertion failure since the object has already gone... */
- oe->object = NULL;
-
- /* ... while this results in a call to object_registration_unregistered
- * for each contained registration */
- object_export_unregister_all (oe);
-
- /* We deliberately don't remove the ObjectExport yet, in case the object is
- * resurrected and re-registered: if that happens, we wouldn't want to call
- * export_signals() again. */
-}
-
-/**
- * dbus_g_connection_unregister_g_object:
- * @connection: the D-BUS connection
- * @object: the object
- *
- * Removes @object from any object paths at which it is exported on
- * @connection. Properties, methods, and signals
- * of the object can no longer be accessed remotely.
- *
- * Deprecated: New code should use GDBus instead.
- * The closest equivalent is g_dbus_connection_unregister_object().
- */
-void
-dbus_g_connection_unregister_g_object (DBusGConnection *connection,
- GObject *object)
-{
- ObjectExport *oe;
- GSList *registrations;
-
- g_return_if_fail (connection != NULL);
- g_return_if_fail (G_IS_OBJECT (object));
-
- oe = g_object_get_data (object, "dbus_glib_object_registrations");
-
- g_return_if_fail (oe != NULL);
- g_return_if_fail (oe->registrations != NULL);
-
- /* Copy the list before iterating it: it will be modified in
- * object_registration_free() each time an object path is unregistered.
- */
- for (registrations = g_slist_copy (oe->registrations);
- registrations != NULL;
- registrations = g_slist_delete_link (registrations, registrations))
- {
- ObjectRegistration *o = registrations->data;
-
- if (o->connection != connection)
- continue;
-
- dbus_connection_unregister_object_path (DBUS_CONNECTION_FROM_G_CONNECTION (o->connection),
- o->object_path);
- }
-}
-
-/**
- * dbus_g_connection_register_g_object:
- * @connection: the D-BUS connection
- * @at_path: the path where the object will live (the object's name)
- * @object: the object
- *
- * Registers a #GObject at the given path. Properties, methods, and signals
- * of the object can then be accessed remotely. Methods are only available
- * if method introspection data has been added to the object's class
- * with dbus_g_object_type_install_info().
- *
- * The registration will be cancelled if either the #DBusConnection or
- * the #GObject gets finalized, or if dbus_g_connection_unregister_g_object()
- * is used.
- *
- * Note: If an object is registered multiple times, the first registration
- * takes priority for cases such as turning an object into an object path.
- *
- * Deprecated: New code should use GDBus instead.
- * The closest equivalent is g_dbus_connection_register_object(),
- * but #GDBusObjectManagerServer and #GDBusObjectSkeleton provide
- * a higher-level API.
- */
-void
-dbus_g_connection_register_g_object (DBusGConnection *connection,
- const char *at_path,
- GObject *object)
-{
- ObjectExport *oe;
- GSList *iter;
- ObjectRegistration *o;
- DBusError error;
-
- g_return_if_fail (connection != NULL);
- g_return_if_fail (g_variant_is_object_path (at_path));
- g_return_if_fail (G_IS_OBJECT (object));
-
- oe = g_object_get_data (object, "dbus_glib_object_registrations");
-
- if (oe == NULL)
- {
- GList *info_list = lookup_object_info (object);
-
- if (info_list == NULL)
- {
- g_warning ("No introspection data registered for object class \"%s\"",
- g_type_name (G_TYPE_FROM_INSTANCE (object)));
- return;
- }
-
- /* This adds a hook into every signal for the object. Only do this
- * on the first registration, because inside the signal marshaller
- * we emit a signal for each registration.
- */
- export_signals (info_list, object);
- g_list_free (info_list);
-
- oe = object_export_new ();
- g_object_set_data_full (object, "dbus_glib_object_registrations", oe,
- (GDestroyNotify) object_export_free);
- }
-
- if (oe->object == NULL)
- {
- /* Either the ObjectExport is newly-created, or it already existed but
- * the object was disposed and resurrected, causing the weak ref to
- * fall off */
- oe->object = object;
- g_object_weak_ref (object, object_export_object_died, oe);
- }
-
- for (iter = oe->registrations; iter; iter = iter->next)
- {
- o = iter->data;
-
- /* Silently ignore duplicate registrations */
- if (strcmp (o->object_path, at_path) == 0 && o->connection == connection)
- return;
- }
-
- o = object_registration_new (connection, at_path, oe);
-
- dbus_error_init (&error);
- if (!dbus_connection_try_register_object_path (DBUS_CONNECTION_FROM_G_CONNECTION (connection),
- at_path,
- &gobject_dbus_vtable,
- o,
- &error))
- {
- g_error ("Failed to register GObject with DBusConnection: %s %s",
- error.name, error.message);
- dbus_error_free (&error);
- object_registration_free (o);
- return;
- }
-
- oe->registrations = g_slist_append (oe->registrations, o);
-}
-
-/**
- * dbus_g_connection_lookup_g_object:
- * @connection: a #DBusGConnection
- * @at_path: path
- *
- * FIXME
- *
- * Returns: the object at path @at_path
- *
- * Deprecated: New code should use GDBus instead. There is no direct
- * equivalent for this function.
- */
-GObject *
-dbus_g_connection_lookup_g_object (DBusGConnection *connection,
- const char *at_path)
-{
- gpointer p;
- ObjectRegistration *o;
-
- g_return_val_if_fail (connection != NULL, NULL);
- g_return_val_if_fail (g_variant_is_object_path (at_path), NULL);
-
- if (!dbus_connection_get_object_path_data (DBUS_CONNECTION_FROM_G_CONNECTION (connection), at_path, &p))
- return NULL;
-
- if (p == NULL)
- return NULL;
-
- o = p;
-
- if (o->export->object == NULL)
- return NULL;
-
- return G_OBJECT (o->export->object);
-}
-
-typedef struct {
- GType rettype;
- guint n_params;
- GType *params;
-} DBusGFuncSignature;
-
-/**
- * dbus_g_object_register_marshaller:
- * @marshaller: a GClosureMarshal to be used for invocation
- * @rettype: a GType for the return type of the function
- * @...: The parameter #GTypes, followed by %G_TYPE_INVALID
- *
- * Register a #GClosureMarshal to be used for signal invocations,
- * giving its return type and a list of parameter types,
- * followed by %G_TYPE_INVALID.
- *
- * This function is no longer useful, and is only provided
- * for compatibility with older dbus-glib. The #GClosureMarshal
- * will not be called.
- *
- * Deprecated: New code should use GDBus instead.
- */
-void
-dbus_g_object_register_marshaller (GClosureMarshal marshaller,
- GType rettype,
- ...)
-{
-}
-
-/**
- * dbus_g_object_register_marshaller_array:
- * @marshaller: a #GClosureMarshal to be used for invocation
- * @rettype: a #GType for the return type of the function
- * @n_types: number of function parameters
- * @types: a C array of GTypes values
- *
- * Register a #GClosureMarshal to be used for signal invocations.
- * @see_also dbus_g_object_register_marshaller()
- *
- * Deprecated: New code should use GDBus instead.
- */
-void
-dbus_g_object_register_marshaller_array (GClosureMarshal marshaller,
- GType rettype,
- guint n_types,
- const GType* types)
-{
-}
-
-/**
- * dbus_g_method_get_sender:
- * @context: the method context
- *
- * Get the sender of a message so we can send a
- * "reply" later (i.e. send a message directly
- * to a service which invoked the method at a
- * later time).
- *
- * Returns: the unique name of the sender. It
- * is up to the caller to free the returned string.
- *
- * Deprecated: New code should use GDBus instead. The closest equivalent
- * is g_dbus_method_invocation_get_sender().
- */
-gchar *
-dbus_g_method_get_sender (DBusGMethodInvocation *context)
-{
- const gchar *sender;
-
- g_return_val_if_fail (context != NULL, NULL);
-
- sender = dbus_message_get_sender (dbus_g_message_get_message (context->message));
- return g_strdup (sender);
-}
-
-/**
- * dbus_g_method_get_reply:
- * @context: the method context
- *
- * Get the reply message to append reply values
- * Used as a sidedoor when you can't generate dbus values
- * of the correct type due to glib binding limitations
- *
- * Returns: a #DBusMessage with the reply
- *
- * Deprecated: New code should use GDBus instead. The closest equivalent
- * is g_dbus_method_invocation_return_value().
- */
-DBusMessage *
-dbus_g_method_get_reply (DBusGMethodInvocation *context)
-{
- g_return_val_if_fail (context != NULL, NULL);
-
- return reply_or_die (dbus_g_message_get_message (context->message));
-}
-
-/**
- * dbus_g_method_send_reply:
- * @context: the method context
- * @reply: the reply message, will be unreffed
- *
- * Send a manually created reply message.
- *
- * Used as a sidedoor when you can't generate dbus values
- * of the correct type due to glib binding limitations
- *
- * Deprecated: New code should use GDBus instead. The closest equivalent
- * is g_dbus_method_invocation_return_value().
- */
-void
-dbus_g_method_send_reply (DBusGMethodInvocation *context, DBusMessage *reply)
-{
- g_return_if_fail (context != NULL);
- g_return_if_fail (reply != NULL);
-
- connection_send_or_die (dbus_g_connection_get_connection (context->connection),
- reply);
- dbus_message_unref (reply);
-
- dbus_g_connection_unref (context->connection);
- dbus_g_message_unref (context->message);
- g_free (context);
-}
-
-
-/**
- * dbus_g_method_return:
- * @context: the method context
- * @...: zero or more values to return from the method, with their number
- * and types given by its #DBusGObjectInfo
- *
- * Send a return message for a given method invocation, with arguments.
- * This function also frees the sending context.
- *
- * Deprecated: New code should use GDBus instead. The closest equivalent
- * is g_dbus_method_invocation_return_value().
- */
-void
-dbus_g_method_return (DBusGMethodInvocation *context, ...)
-{
- DBusMessage *reply;
- DBusMessageIter iter;
- va_list args;
- char *out_sig;
- GArray *argsig;
- guint i;
-
- g_return_if_fail (context != NULL);
-
- /* This field was initialized inside invoke_object_method; we
- * carry it over through the async invocation to here.
- */
- if (!context->send_reply)
- goto out;
-
- reply = dbus_g_method_get_reply (context);
- out_sig = method_output_signature_from_object_info (context->object, context->method);
- argsig = _dbus_gtypes_from_arg_signature (out_sig, FALSE);
-
- dbus_message_iter_init_append (reply, &iter);
-
- va_start (args, context);
- for (i = 0; i < argsig->len; i++)
- {
- GValue value = {0,};
- char *error;
- g_value_init (&value, g_array_index (argsig, GType, i));
- error = NULL;
- G_VALUE_COLLECT (&value, args, G_VALUE_NOCOPY_CONTENTS, &error);
- if (error)
- {
- g_warning("%s", error);
- g_free (error);
- }
- else
- {
- if (!_dbus_gvalue_marshal (&iter, &value))
- g_warning ("failed to marshal parameter %d for method %s",
- i, dbus_message_get_member (
- dbus_g_message_get_message (context->message)));
- }
- }
- va_end (args);
-
- connection_send_or_die (dbus_g_connection_get_connection (context->connection),
- reply);
- dbus_message_unref (reply);
-
- g_free (out_sig);
- g_array_free (argsig, TRUE);
-
-out:
- dbus_g_connection_unref (context->connection);
- dbus_g_message_unref (context->message);
- g_free (context);
-}
-
-/**
- * dbus_g_method_return_error:
- * @context: the method context
- * @error: the error to send
- *
- * Send a error message for a given method invocation.
- * This function also frees the sending context.
- *
- * Deprecated: New code should use GDBus instead. The closest equivalent
- * is g_dbus_method_invocation_return_gerror().
- */
-void
-dbus_g_method_return_error (DBusGMethodInvocation *context, const GError *error)
-{
- DBusMessage *reply;
-
- g_return_if_fail (context != NULL);
- g_return_if_fail (error != NULL);
-
- /* See comment in dbus_g_method_return */
- if (!context->send_reply)
- goto out;
-
- reply = gerror_to_dbus_error_message (context->object, dbus_g_message_get_message (context->message), error);
- connection_send_or_die (
- dbus_g_connection_get_connection (context->connection), reply);
- dbus_message_unref (reply);
-
-out:
- dbus_g_connection_unref (context->connection);
- dbus_g_message_unref (context->message);
- g_free (context);
-}
-
-/**
- * dbus_g_method_invocation_get_g_connection:
- * @context: the method context
- *
- * <!-- Returns: says it all -->
- *
- * Returns: (transfer none): the @DBusGConnection from which the method was called.
- *
- * Deprecated: New code should use GDBus instead. The closest equivalent
- * is g_dbus_method_invocation_get_connection().
- */
-DBusGConnection *
-dbus_g_method_invocation_get_g_connection (DBusGMethodInvocation *context)
-{
- g_return_val_if_fail (context != NULL, NULL);
-
- return context->connection;
-}
-
-const char *
-_dbus_gobject_get_path (GObject *obj)
-{
- ObjectExport *oe;
- ObjectRegistration *o;
-
- oe = g_object_get_data (obj, "dbus_glib_object_registrations");
-
- if (oe == NULL || oe->registrations == NULL)
- return NULL;
-
- /* First one to have been registered wins */
- o = oe->registrations->data;
-
- return o->object_path;
-}
-
-#ifdef DBUS_BUILD_TESTS
-#include <stdlib.h>
-
-static void
-_dummy_function (void)
-{
-}
-
-/* Data structures copied from one generated by current dbus-binding-tool;
- * we need to support this layout forever
- */
-static const DBusGMethodInfo dbus_glib_internal_test_methods[] = {
- { (GCallback) _dummy_function, g_cclosure_marshal_VOID__VOID, 0 },
- { (GCallback) _dummy_function, g_cclosure_marshal_VOID__VOID, 49 },
- { (GCallback) _dummy_function, g_cclosure_marshal_VOID__VOID, 117 },
- { (GCallback) _dummy_function, g_cclosure_marshal_VOID__VOID, 191 },
- { (GCallback) _dummy_function, g_cclosure_marshal_VOID__VOID, 270 },
- { (GCallback) _dummy_function, g_cclosure_marshal_VOID__VOID, 320 },
- { (GCallback) _dummy_function, g_cclosure_marshal_VOID__VOID, 391 },
- { (GCallback) _dummy_function, g_cclosure_marshal_VOID__VOID, 495 },
- { (GCallback) _dummy_function, g_cclosure_marshal_VOID__VOID, 623 },
- { (GCallback) _dummy_function, g_cclosure_marshal_VOID__VOID, 693 },
- { (GCallback) _dummy_function, g_cclosure_marshal_VOID__VOID, 765 },
- { (GCallback) _dummy_function, g_cclosure_marshal_VOID__VOID, 838 },
- { (GCallback) _dummy_function, g_cclosure_marshal_VOID__VOID, 911 },
- { (GCallback) _dummy_function, g_cclosure_marshal_VOID__VOID, 988 },
- { (GCallback) _dummy_function, g_cclosure_marshal_VOID__VOID, 1064 },
- { (GCallback) _dummy_function, g_cclosure_marshal_VOID__VOID, 1140 },
- { (GCallback) _dummy_function, g_cclosure_marshal_VOID__VOID, 1204 },
- { (GCallback) _dummy_function, g_cclosure_marshal_VOID__VOID, 1278 },
- { (GCallback) _dummy_function, g_cclosure_marshal_VOID__VOID, 1347 },
- { (GCallback) _dummy_function, g_cclosure_marshal_VOID__VOID, 1408 },
- { (GCallback) _dummy_function, g_cclosure_marshal_VOID__VOID, 1460 },
- { (GCallback) _dummy_function, g_cclosure_marshal_VOID__VOID, 1533 },
- { (GCallback) _dummy_function, g_cclosure_marshal_VOID__VOID, 1588 },
- { (GCallback) _dummy_function, g_cclosure_marshal_VOID__VOID, 1647 },
- { (GCallback) _dummy_function, g_cclosure_marshal_VOID__VOID, 1730 },
- { (GCallback) _dummy_function, g_cclosure_marshal_VOID__VOID, 1784 },
- { (GCallback) _dummy_function, g_cclosure_marshal_VOID__VOID, 1833 },
- { (GCallback) _dummy_function, g_cclosure_marshal_VOID__VOID, 1895 },
- { (GCallback) _dummy_function, g_cclosure_marshal_VOID__VOID, 1947 },
- { (GCallback) _dummy_function, g_cclosure_marshal_VOID__VOID, 1999 },
-};
-
-const DBusGObjectInfo dbus_glib_internal_test_object_info = {
- 0,
- dbus_glib_internal_test_methods,
- 30,
-"org.freedesktop.DBus.Tests.MyObject\0DoNothing\0S\0\0org.freedesktop.DBus.Tests.MyObject\0Increment\0S\0x\0I\0u\0arg1\0O\0F\0N\0u\0\0org.freedesktop.DBus.Tests.MyObject\0IncrementRetval\0S\0x\0I\0u\0arg1\0O\0F\0R\0u\0\0org.freedesktop.DBus.Tests.MyObject\0IncrementRetvalError\0S\0x\0I\0u\0arg1\0O\0F\0E\0u\0\0org.freedesktop.DBus.Tests.MyObject\0ThrowError\0S\0\0org.freedesktop.DBus.Tests.MyObject\0Uppercase\0S\0arg0\0I\0s\0arg1\0O\0F\0N\0s\0\0org.freedesktop.DBus.Tests.MyObject\0ManyArgs\0S\0x\0I\0u\0str\0I\0s\0trouble\0I\0d\0d_ret\0O\0F\0N\0d\0str_ret\0O\0F\0N\0s\0\0org.freedesktop.DBus.Tests.MyObject\0ManyReturn\0S\0arg0\0O\0F\0N\0u\0arg1\0O\0F\0N\0s\0arg2\0O\0F\0N\0i\0arg3\0O\0F\0N\0u\0arg4\0O\0F\0N\0u\0arg5\0O\0C\0N\0s\0\0org.freedesktop.DBus.Tests.MyObject\0Stringify\0S\0val\0I\0v\0arg1\0O\0F\0N\0s\0\0org.freedesktop.DBus.Tests.MyObject\0Unstringify\0S\0val\0I\0s\0arg1\0O\0F\0N\0v\0\0org.freedesktop.DBus.Tests.MyObject\0Recursive1\0S\0arg0\0I\0au\0arg1\0O\0F\0N\0u\0\0org.freedesktop.DBus.Tests.MyObject\0Recursive2\0S\0arg0\0I\0u\0arg1\0O\0F\0N\0au\0\0org.freedesktop.DBus.Tests.MyObject\0ManyUppercase\0S\0arg0\0I\0as\0arg1\0O\0F\0N\0as\0\0org.freedesktop.DBus.Tests.MyObject\0StrHashLen\0S\0arg0\0I\0a{ss}\0arg1\0O\0F\0N\0u\0\0org.freedesktop.DBus.Tests.MyObject\0SendCar\0S\0arg0\0I\0(suv)\0arg1\0O\0F\0N\0(uo)\0\0org.freedesktop.DBus.Tests.MyObject\0GetHash\0S\0arg0\0O\0F\0N\0a{ss}\0\0org.freedesktop.DBus.Tests.MyObject\0RecArrays\0S\0val\0I\0aas\0arg1\0O\0F\0N\0aau\0\0org.freedesktop.DBus.Tests.MyObject\0Objpath\0S\0arg0\0I\0o\0arg1\0O\0C\0N\0o\0\0org.freedesktop.DBus.Tests.MyObject\0GetObjs\0S\0arg0\0O\0F\0N\0ao\0\0org.freedesktop.DBus.Tests.MyObject\0IncrementVal\0S\0\0org.freedesktop.DBus.Tests.MyObject\0AsyncIncrement\0A\0x\0I\0u\0arg1\0O\0F\0N\0u\0\0org.freedesktop.DBus.Tests.MyObject\0AsyncThrowError\0A\0\0org.freedesktop.DBus.Tests.MyObject\0GetVal\0S\0arg0\0O\0F\0N\0u\0\0org.freedesktop.DBus.Tests.MyObject\0ManyStringify\0S\0arg0\0I\0a{sv}\0arg1\0O\0F\0N\0a{sv}\0\0org.freedesktop.DBus.Tests.MyObject\0EmitFrobnicate\0S\0\0org.freedesktop.DBus.Tests.MyObject\0Terminate\0S\0\0org.freedesktop.DBus.Tests.FooObject\0GetValue\0S\0arg0\0O\0F\0N\0u\0\0org.freedesktop.DBus.Tests.FooObject\0EmitSignals\0S\0\0org.freedesktop.DBus.Tests.FooObject\0EmitSignal2\0S\0\0org.freedesktop.DBus.Tests.FooObject\0Terminate\0S\0\0\0",
-"org.freedesktop.DBus.Tests.MyObject\0Frobnicate\0org.freedesktop.DBus.Tests.FooObject\0Sig0\0org.freedesktop.DBus.Tests.FooObject\0Sig1\0org.freedesktop.DBus.Tests.FooObject\0Sig2\0\0",
-"\0"
-};
-
-
-/*
- * Unit test for GLib GObject integration ("skeletons")
- * Returns: %TRUE on success.
- */
-gboolean
-_dbus_gobject_test (const char *test_data_dir)
-{
- int i;
- const char *arg;
- const char *arg_name;
- gboolean arg_in;
- gboolean constval;
- RetvalType retval;
- const char *arg_signature;
- const char *sigdata;
- const char *iface;
- const char *signame;
-
- static struct { const char *wincaps; const char *uscore; } name_pairs[] = {
- { "SetFoo", "set_foo" },
- { "Foo", "foo" },
- { "GetFooBar", "get_foo_bar" },
- { "Hello", "hello" }
-
- /* Impossible-to-handle cases */
- /* { "FrobateUIHandler", "frobate_ui_handler" } */
- };
-
- /* Test lookup in our hardcoded object info; if these tests fail
- * then it likely means you changed the generated object info in an
- * incompatible way and broke the lookup functions. In that case
- * you need to bump the version and use a new structure instead. */
- /* DoNothing */
- arg = method_arg_info_from_object_info (&dbus_glib_internal_test_object_info,
- &(dbus_glib_internal_test_methods[0]));
- g_assert (*arg == '\0');
-
- /* Increment */
- arg = method_arg_info_from_object_info (&dbus_glib_internal_test_object_info,
- &(dbus_glib_internal_test_methods[1]));
- g_assert (*arg != '\0');
- arg = arg_iterate (arg, &arg_name, &arg_in, &constval, &retval, &arg_signature);
- g_assert (!strcmp (arg_name, "x"));
- g_assert (arg_in == TRUE);
- g_assert (!strcmp (arg_signature, "u"));
- g_assert (*arg != '\0');
- arg = arg_iterate (arg, &arg_name, &arg_in, &constval, &retval, &arg_signature);
- g_assert (arg_in == FALSE);
- g_assert (retval == RETVAL_NONE);
- g_assert (!strcmp (arg_signature, "u"));
- g_assert (*arg == '\0');
-
- /* IncrementRetval */
- arg = method_arg_info_from_object_info (&dbus_glib_internal_test_object_info,
- &(dbus_glib_internal_test_methods[2]));
- g_assert (*arg != '\0');
- arg = arg_iterate (arg, &arg_name, &arg_in, &constval, &retval, &arg_signature);
- g_assert (!strcmp (arg_name, "x"));
- g_assert (arg_in == TRUE);
- g_assert (!strcmp (arg_signature, "u"));
- g_assert (*arg != '\0');
- arg = arg_iterate (arg, &arg_name, &arg_in, &constval, &retval, &arg_signature);
- g_assert (retval == RETVAL_NOERROR);
- g_assert (arg_in == FALSE);
- g_assert (!strcmp (arg_signature, "u"));
- g_assert (*arg == '\0');
-
- /* IncrementRetvalError */
- arg = method_arg_info_from_object_info (&dbus_glib_internal_test_object_info,
- &(dbus_glib_internal_test_methods[3]));
- g_assert (*arg != '\0');
- arg = arg_iterate (arg, &arg_name, &arg_in, &constval, &retval, &arg_signature);
- g_assert (!strcmp (arg_name, "x"));
- g_assert (arg_in == TRUE);
- g_assert (!strcmp (arg_signature, "u"));
- g_assert (*arg != '\0');
- arg = arg_iterate (arg, &arg_name, &arg_in, &constval, &retval, &arg_signature);
- g_assert (retval == RETVAL_ERROR);
- g_assert (arg_in == FALSE);
- g_assert (!strcmp (arg_signature, "u"));
- g_assert (*arg == '\0');
-
- /* Stringify */
- arg = method_arg_info_from_object_info (&dbus_glib_internal_test_object_info,
- &(dbus_glib_internal_test_methods[8]));
- g_assert (*arg != '\0');
- arg = arg_iterate (arg, &arg_name, &arg_in, &constval, &retval, &arg_signature);
- g_assert (!strcmp (arg_name, "val"));
- g_assert (arg_in == TRUE);
- g_assert (!strcmp (arg_signature, "v"));
- g_assert (*arg != '\0');
- arg = arg_iterate (arg, &arg_name, &arg_in, &constval, &retval, &arg_signature);
- g_assert (retval == RETVAL_NONE);
- g_assert (arg_in == FALSE);
- g_assert (!strcmp (arg_signature, "s"));
- g_assert (*arg == '\0');
-
- sigdata = dbus_glib_internal_test_object_info.exported_signals;
- g_assert (*sigdata != '\0');
- sigdata = signal_iterate (sigdata, &iface, &signame);
- g_assert (!strcmp (iface, "org.freedesktop.DBus.Tests.MyObject"));
- g_assert (!strcmp (signame, "Frobnicate"));
- g_assert (*sigdata != '\0');
- sigdata = signal_iterate (sigdata, &iface, &signame);
- g_assert (!strcmp (iface, "org.freedesktop.DBus.Tests.FooObject"));
- g_assert (!strcmp (signame, "Sig0"));
- g_assert (*sigdata != '\0');
- sigdata = signal_iterate (sigdata, &iface, &signame);
- g_assert (!strcmp (iface, "org.freedesktop.DBus.Tests.FooObject"));
- g_assert (!strcmp (signame, "Sig1"));
- g_assert (*sigdata != '\0');
- sigdata = signal_iterate (sigdata, &iface, &signame);
- g_assert (!strcmp (iface, "org.freedesktop.DBus.Tests.FooObject"));
- g_assert (!strcmp (signame, "Sig2"));
- g_assert (*sigdata == '\0');
-
-
- i = 0;
- while (i < (int) G_N_ELEMENTS (name_pairs))
- {
- char *uscore;
- char *wincaps;
-
- uscore = _dbus_gutils_wincaps_to_uscore (name_pairs[i].wincaps);
- wincaps = uscore_to_wincaps (name_pairs[i].uscore);
-
- if (strcmp (uscore, name_pairs[i].uscore) != 0)
- {
- g_printerr ("\"%s\" should have been converted to \"%s\" not \"%s\"\n",
- name_pairs[i].wincaps, name_pairs[i].uscore,
- uscore);
- exit (1);
- }
-
- if (strcmp (wincaps, name_pairs[i].wincaps) != 0)
- {
- g_printerr ("\"%s\" should have been converted to \"%s\" not \"%s\"\n",
- name_pairs[i].uscore, name_pairs[i].wincaps,
- wincaps);
- exit (1);
- }
-
- g_free (uscore);
- g_free (wincaps);
-
- ++i;
- }
-
- return TRUE;
-}
-
-#endif /* DBUS_BUILD_TESTS */
diff --git a/dbus/dbus-gobject.h b/dbus/dbus-gobject.h
deleted file mode 100644
index cf97cd0..0000000
--- a/dbus/dbus-gobject.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/* -*- mode: C; c-file-style: "gnu" -*- */
-/* dbus-gobject.h: common functions used to map between D-BUS and GObject
- *
- * Copyright (C) 2005 Red Hat, Inc.
- *
- * Licensed under the Academic Free License version 2.1
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- */
-#ifndef DBUS_GLIB_OBJECT_H
-#define DBUS_GLIB_OBJECT_H
-
-#include <dbus/dbus.h>
-#include <dbus/dbus-signature.h>
-#include <glib.h>
-#include "dbus/dbus-glib.h"
-
-G_BEGIN_DECLS
-
-const char * _dbus_gobject_get_path (GObject *obj);
-
-G_END_DECLS
-
-#endif
diff --git a/dbus/dbus-gparser.c b/dbus/dbus-gparser.c
deleted file mode 100644
index af74e30..0000000
--- a/dbus/dbus-gparser.c
+++ /dev/null
@@ -1,931 +0,0 @@
-/* -*- mode: C; c-file-style: "gnu" -*- */
-/* dbus-gparser.c parse DBus description files
- *
- * Copyright (C) 2003, 2005 Red Hat, Inc.
- *
- * Licensed under the Academic Free License version 2.1
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- */
-
-#include <config.h>
-
-#include "dbus-gparser.h"
-#include "dbus/dbus-glib-lowlevel.h"
-#include "dbus-gidl.h"
-#include "dbus-gobject.h"
-#include "dbus/dbus-signature.h"
-#include <string.h>
-
-#include <gio/gio.h>
-
-#define ELEMENT_IS(name) (strcmp (element_name, (name)) == 0)
-
-typedef struct
-{
- const char *name;
- const char **retloc;
-} LocateAttr;
-
-static gboolean
-locate_attributes (const char *element_name,
- const char **attribute_names,
- const char **attribute_values,
- GError **error,
- const char *first_attribute_name,
- const char **first_attribute_retloc,
- ...)
-{
- va_list args;
- const char *name;
- const char **retloc;
- int n_attrs;
-#define MAX_ATTRS 24
- LocateAttr attrs[MAX_ATTRS];
- gboolean retval;
- int i;
-
- g_return_val_if_fail (first_attribute_name != NULL, FALSE);
- g_return_val_if_fail (first_attribute_retloc != NULL, FALSE);
-
- retval = TRUE;
-
- n_attrs = 1;
- attrs[0].name = first_attribute_name;
- attrs[0].retloc = first_attribute_retloc;
- *first_attribute_retloc = NULL;
-
- va_start (args, first_attribute_retloc);
-
- name = va_arg (args, const char*);
- retloc = va_arg (args, const char**);
-
- while (name != NULL)
- {
- if (retloc == NULL)
- {
- va_end (args);
- return FALSE;
- }
-
- g_assert (n_attrs < MAX_ATTRS);
-
- attrs[n_attrs].name = name;
- attrs[n_attrs].retloc = retloc;
- n_attrs += 1;
- *retloc = NULL;
-
- name = va_arg (args, const char*);
- retloc = va_arg (args, const char**);
- }
-
- va_end (args);
-
- i = 0;
- while (attribute_names[i])
- {
- int j;
- gboolean found;
-
- found = FALSE;
- j = 0;
- while (j < n_attrs)
- {
- if (strcmp (attrs[j].name, attribute_names[i]) == 0)
- {
- retloc = attrs[j].retloc;
-
- if (*retloc != NULL)
- {
- g_set_error (error,
- G_MARKUP_ERROR,
- G_MARKUP_ERROR_PARSE,
- "Attribute \"%s\" repeated twice on the same <%s> element",
- attrs[j].name, element_name);
- retval = FALSE;
- goto out;
- }
-
- *retloc = attribute_values[i];
- found = TRUE;
- }
-
- ++j;
- }
-
- if (!found)
- {
- /* We want to passthrough namespaced XML nodes that we don't know anything about. */
- if (strchr (attribute_names[i], ':') == NULL)
- {
- g_set_error (error,
- G_MARKUP_ERROR,
- G_MARKUP_ERROR_PARSE,
- "Attribute \"%s\" is invalid on <%s> element in this context",
- attribute_names[i], element_name);
- retval = FALSE;
- goto out;
- }
- }
-
- ++i;
- }
-
- out:
- return retval;
-}
-
-#if 0
-static gboolean
-check_no_attributes (const char *element_name,
- const char **attribute_names,
- const char **attribute_values,
- GError **error)
-{
- if (attribute_names[0] != NULL)
- {
- g_set_error (error,
- G_MARKUP_ERROR,
- G_MARKUP_ERROR_PARSE,
- "Attribute \"%s\" is invalid on <%s> element in this context",
- attribute_names[0], element_name);
- return FALSE;
- }
-
- return TRUE;
-}
-#endif
-
-struct Parser
-{
- int refcount;
-
- NodeInfo *result; /* Filled in when we pop the last node */
- GSList *node_stack;
- InterfaceInfo *interface;
- MethodInfo *method;
- SignalInfo *signal;
- PropertyInfo *property;
- ArgInfo *arg;
- gboolean in_annotation;
- guint unknown_namespaced_depth;
-};
-
-Parser*
-parser_new (void)
-{
- Parser *parser;
-
- parser = g_new0 (Parser, 1);
-
- parser->refcount = 1;
-
- return parser;
-}
-
-Parser *
-parser_ref (Parser *parser)
-{
- parser->refcount += 1;
-
- return parser;
-}
-
-void
-parser_unref (Parser *parser)
-{
- parser->refcount -= 1;
- if (parser->refcount == 0)
- {
- if (parser->result)
- node_info_unref (parser->result);
-
- g_free (parser);
- }
-}
-
-gboolean
-parser_check_doctype (Parser *parser,
- const char *doctype,
- GError **error)
-{
- g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
-
- if (strcmp (doctype, "node") != 0)
- {
- g_set_error (error,
- G_MARKUP_ERROR,
- G_MARKUP_ERROR_PARSE,
- "D-BUS description file has the wrong document type %s, use node or interface",
- doctype);
- return FALSE;
- }
- else
- return TRUE;
-}
-
-static gboolean
-parse_node (Parser *parser,
- const char *element_name,
- const char **attribute_names,
- const char **attribute_values,
- GError **error)
-{
- const char *name;
- NodeInfo *node;
-
- if (parser->interface ||
- parser->method ||
- parser->signal ||
- parser->property ||
- parser->arg ||
- parser->in_annotation)
- {
- g_set_error (error, G_MARKUP_ERROR,
- G_MARKUP_ERROR_PARSE,
- "Can't put <%s> element here",
- element_name);
- return FALSE;
- }
-
- name = NULL;
- if (!locate_attributes (element_name, attribute_names,
- attribute_values, error,
- "name", &name,
- NULL))
- return FALSE;
-
- /* Only the root node can have no name */
- if (parser->node_stack != NULL && name == NULL)
- {
- g_set_error (error, G_MARKUP_ERROR,
- G_MARKUP_ERROR_PARSE,
- "\"%s\" attribute required on <%s> element ",
- "name", element_name);
- return FALSE;
- }
-
- /* Root element name must be absolute */
- if (parser->node_stack == NULL && name && *name != '/')
- {
- g_set_error (error, G_MARKUP_ERROR,
- G_MARKUP_ERROR_PARSE,
- "\"%s\" attribute on <%s> element must be an absolute object path, \"%s\" not OK",
- "name", element_name, name);
- return FALSE;
- }
-
- /* Other element names must not be absolute */
- if (parser->node_stack != NULL && name && *name == '/')
- {
- g_set_error (error, G_MARKUP_ERROR,
- G_MARKUP_ERROR_PARSE,
- "\"%s\" attribute on <%s> element must not be an absolute object path, \"%s\" starts with /",
- "name", element_name, name);
- return FALSE;
- }
-
- node = node_info_new (name);
-
- if (parser->node_stack != NULL)
- {
- node_info_add_node (parser->node_stack->data,
- node);
- }
-
- parser->node_stack = g_slist_prepend (parser->node_stack,
- node);
-
- return TRUE;
-}
-
-static gboolean
-parse_interface (Parser *parser,
- const char *element_name,
- const char **attribute_names,
- const char **attribute_values,
- GError **error)
-{
- const char *name;
- InterfaceInfo *iface;
- NodeInfo *top;
-
- if (parser->interface ||
- parser->method ||
- parser->signal ||
- parser->property ||
- parser->arg ||
- parser->in_annotation ||
- (parser->node_stack == NULL))
- {
- g_set_error (error, G_MARKUP_ERROR,
- G_MARKUP_ERROR_PARSE,
- "Can't put <%s> element here",
- element_name);
- return FALSE;
- }
-
- name = NULL;
- if (!locate_attributes (element_name, attribute_names,
- attribute_values, error,
- "name", &name,
- NULL))
- return FALSE;
-
- if (name == NULL)
- {
- g_set_error (error, G_MARKUP_ERROR,
- G_MARKUP_ERROR_PARSE,
- "\"%s\" attribute required on <%s> element ",
- "name", element_name);
- return FALSE;
- }
-
- if (!g_dbus_is_interface_name (name))
- {
- g_set_error (error, G_MARKUP_ERROR,
- G_MARKUP_ERROR_PARSE,
- "\"%s\" is not a valid D-Bus interface name", name);
- return FALSE;
- }
-
- top = parser->node_stack->data;
-
- iface = interface_info_new (name);
- node_info_add_interface (top, iface);
- interface_info_unref (iface);
-
- parser->interface = iface;
-
- return TRUE;
-}
-
-static gboolean
-parse_method (Parser *parser,
- const char *element_name,
- const char **attribute_names,
- const char **attribute_values,
- GError **error)
-{
- const char *name;
- MethodInfo *method;
-
- if (parser->interface == NULL ||
- parser->node_stack == NULL ||
- parser->method ||
- parser->signal ||
- parser->property ||
- parser->in_annotation ||
- parser->arg)
- {
- g_set_error (error, G_MARKUP_ERROR,
- G_MARKUP_ERROR_PARSE,
- "Can't put <%s> element here",
- element_name);
- return FALSE;
- }
-
- name = NULL;
- if (!locate_attributes (element_name, attribute_names,
- attribute_values, error,
- "name", &name,
- NULL))
- return FALSE;
-
- if (name == NULL)
- {
- g_set_error (error, G_MARKUP_ERROR,
- G_MARKUP_ERROR_PARSE,
- "\"%s\" attribute required on <%s> element ",
- "name", element_name);
- return FALSE;
- }
-
- if (!g_dbus_is_member_name (name))
- {
- g_set_error (error, G_MARKUP_ERROR,
- G_MARKUP_ERROR_PARSE,
- "\"%s\" is not a valid D-Bus member name", name);
- return FALSE;
- }
-
- method = method_info_new (name);
- interface_info_add_method (parser->interface, method);
- method_info_unref (method);
-
- parser->method = method;
-
- return TRUE;
-}
-
-static gboolean
-parse_signal (Parser *parser,
- const char *element_name,
- const char **attribute_names,
- const char **attribute_values,
- GError **error)
-{
- const char *name;
- SignalInfo *signal;
-
- if (parser->interface == NULL ||
- parser->node_stack == NULL ||
- parser->signal ||
- parser->method ||
- parser->property ||
- parser->in_annotation ||
- parser->arg)
- {
- g_set_error (error, G_MARKUP_ERROR,
- G_MARKUP_ERROR_PARSE,
- "Can't put <%s> element here",
- element_name);
- return FALSE;
- }
-
- name = NULL;
- if (!locate_attributes (element_name, attribute_names,
- attribute_values, error,
- "name", &name,
- NULL))
- return FALSE;
-
- if (name == NULL)
- {
- g_set_error (error, G_MARKUP_ERROR,
- G_MARKUP_ERROR_PARSE,
- "\"%s\" attribute required on <%s> element ",
- "name", element_name);
- return FALSE;
- }
-
- if (!g_dbus_is_member_name (name))
- {
- g_set_error (error, G_MARKUP_ERROR,
- G_MARKUP_ERROR_PARSE,
- "\"%s\" is not a valid D-Bus member name", name);
- return FALSE;
- }
-
- signal = signal_info_new (name);
- interface_info_add_signal (parser->interface, signal);
- signal_info_unref (signal);
-
- parser->signal = signal;
-
- return TRUE;
-}
-
-static gboolean
-validate_signature (const char *str,
- const char *element_name,
- GError **error)
-{
- DBusError derror;
-
- dbus_error_init (&derror);
-
- if (!dbus_signature_validate (str, &derror))
- {
- dbus_set_g_error (error, &derror);
- return FALSE;
- }
- return TRUE;
-}
-
-static gboolean
-parse_property (Parser *parser,
- const char *element_name,
- const char **attribute_names,
- const char **attribute_values,
- GError **error)
-{
- const char *name;
- const char *access;
- const char *type;
- PropertyInfo *property;
- PropertyAccessFlags access_flags;
-
- if (parser->interface == NULL ||
- parser->node_stack == NULL ||
- parser->signal ||
- parser->method ||
- parser->property ||
- parser->in_annotation ||
- parser->arg)
- {
- g_set_error (error, G_MARKUP_ERROR,
- G_MARKUP_ERROR_PARSE,
- "Can't put <%s> element here",
- element_name);
- return FALSE;
- }
-
- name = NULL;
- if (!locate_attributes (element_name, attribute_names,
- attribute_values, error,
- "name", &name,
- "access", &access,
- "type", &type,
- NULL))
- return FALSE;
-
- if (name == NULL)
- {
- g_set_error (error, G_MARKUP_ERROR,
- G_MARKUP_ERROR_PARSE,
- "\"%s\" attribute required on <%s> element ",
- "name", element_name);
- return FALSE;
- }
-
- if (access == NULL)
- {
- g_set_error (error, G_MARKUP_ERROR,
- G_MARKUP_ERROR_PARSE,
- "\"%s\" attribute required on <%s> element ",
- "access", element_name);
- return FALSE;
- }
-
- if (type == NULL)
- {
- g_set_error (error, G_MARKUP_ERROR,
- G_MARKUP_ERROR_PARSE,
- "\"%s\" attribute required on <%s> element ",
- "type", element_name);
- return FALSE;
- }
-
- if (!validate_signature (type, element_name, error))
- return FALSE;
-
- access_flags = 0;
- if (strcmp (access, "readwrite") == 0)
- access_flags = PROPERTY_READ | PROPERTY_WRITE;
- else if (strcmp (access, "read") == 0)
- access_flags = PROPERTY_READ;
- else if (strcmp (access, "write") == 0)
- access_flags = PROPERTY_WRITE;
- else
- {
- g_set_error (error, G_MARKUP_ERROR,
- G_MARKUP_ERROR_PARSE,
- "access=\"%s\" must have value readwrite, read, or write on %s\n",
- access, element_name);
- return FALSE;
- }
-
- if (!g_utf8_validate (name, -1, NULL))
- {
- g_set_error (error, G_MARKUP_ERROR,
- G_MARKUP_ERROR_PARSE,
- "\"%s\" is not UTF-8", name);
- return FALSE;
- }
-
- property = property_info_new (name, type, access_flags);
- interface_info_add_property (parser->interface, property);
- property_info_unref (property);
-
- parser->property = property;
-
- return TRUE;
-}
-
-static gboolean
-parse_arg (Parser *parser,
- const char *element_name,
- const char **attribute_names,
- const char **attribute_values,
- GError **error)
-{
- const char *name;
- const char *type;
- const char *direction;
- ArgDirection dir;
- ArgInfo *arg;
- char *generated_name;
-
- if (!(parser->method || parser->signal) ||
- parser->node_stack == NULL ||
- parser->property ||
- parser->in_annotation ||
- parser->arg)
- {
- g_set_error (error, G_MARKUP_ERROR,
- G_MARKUP_ERROR_PARSE,
- "Can't put <%s> element here",
- element_name);
- return FALSE;
- }
-
- name = NULL;
- if (!locate_attributes (element_name, attribute_names,
- attribute_values, error,
- "name", &name,
- "type", &type,
- "direction", &direction,
- NULL))
- return FALSE;
-
- /* name can be null for args */
-
- if (type == NULL)
- {
- g_set_error (error, G_MARKUP_ERROR,
- G_MARKUP_ERROR_PARSE,
- "\"%s\" attribute required on <%s> element ",
- "type", element_name);
- return FALSE;
- }
-
- if (direction == NULL)
- {
- /* methods default to in, signal to out */
- if (parser->method)
- direction = "in";
- else if (parser->signal)
- direction = "out";
- else
- g_assert_not_reached ();
- }
-
- dir = ARG_INVALID;
-
- if (strcmp (direction, "in") == 0)
- dir = ARG_IN;
- else if (strcmp (direction, "out") == 0)
- dir = ARG_OUT;
-
- if (dir == ARG_INVALID ||
- (parser->signal && dir == ARG_IN))
- {
- if (parser->signal)
- g_set_error (error, G_MARKUP_ERROR,
- G_MARKUP_ERROR_PARSE,
- "Signals must have direction=\"out\" (just omit the direction attribute)");
- else
- g_set_error (error, G_MARKUP_ERROR,
- G_MARKUP_ERROR_PARSE,
- "\"%s\" attribute on <%s> has value \"in\" or \"out\"",
- "direction", element_name);
- return FALSE;
- }
-
- if (!validate_signature (type, element_name, error))
- return FALSE;
-
- generated_name = NULL;
- if (name == NULL)
- generated_name = g_strdup_printf ("arg%d",
- parser->method ?
- method_info_get_n_args (parser->method) :
- signal_info_get_n_args (parser->signal));
-
- arg = arg_info_new (name ? name : generated_name, dir, type);
- if (parser->method)
- method_info_add_arg (parser->method, arg);
- else if (parser->signal)
- signal_info_add_arg (parser->signal, arg);
- else
- g_assert_not_reached ();
-
- g_free (generated_name);
-
- arg_info_unref (arg);
-
- parser->arg = arg;
-
- return TRUE;
-}
-
-static gboolean
-parse_annotation (Parser *parser,
- const char *element_name,
- const char **attribute_names,
- const char **attribute_values,
- GError **error)
-{
- const char *name;
- const char *value;
-
- if (!(parser->method || parser->interface || parser->arg ||
- parser->property || parser->signal) ||
- parser->node_stack == NULL ||
- parser->in_annotation)
- {
- g_set_error (error, G_MARKUP_ERROR,
- G_MARKUP_ERROR_PARSE,
- "Can't put <%s> element here",
- element_name);
- return FALSE;
- }
-
- name = NULL;
- if (!locate_attributes (element_name, attribute_names,
- attribute_values, error,
- "name", &name,
- "value", &value,
- NULL))
- return FALSE;
-
- if (name == NULL)
- {
- g_set_error (error, G_MARKUP_ERROR,
- G_MARKUP_ERROR_PARSE,
- "\"%s\" attribute required on <%s> element ",
- "name", element_name);
- return FALSE;
- }
- if (value == NULL)
- {
- g_set_error (error, G_MARKUP_ERROR,
- G_MARKUP_ERROR_PARSE,
- "\"%s\" attribute required on <%s> element ",
- "value", element_name);
- return FALSE;
- }
-
- if (parser->arg)
- arg_info_add_annotation (parser->arg, name, value);
- else if (parser->method)
- method_info_add_annotation (parser->method, name, value);
- else if (parser->interface)
- interface_info_add_annotation (parser->interface, name, value);
- else
- g_assert_not_reached ();
-
- parser->in_annotation = TRUE;
-
- return TRUE;
-}
-
-gboolean
-parser_start_element (Parser *parser,
- const char *element_name,
- const char **attribute_names,
- const char **attribute_values,
- GError **error)
-{
- g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
-
- if (ELEMENT_IS ("node"))
- {
- if (!parse_node (parser, element_name, attribute_names,
- attribute_values, error))
- return FALSE;
- }
- else if (ELEMENT_IS ("interface"))
- {
- if (!parse_interface (parser, element_name, attribute_names,
- attribute_values, error))
- return FALSE;
- }
- else if (ELEMENT_IS ("method"))
- {
- if (!parse_method (parser, element_name, attribute_names,
- attribute_values, error))
- return FALSE;
- }
- else if (ELEMENT_IS ("signal"))
- {
- if (!parse_signal (parser, element_name, attribute_names,
- attribute_values, error))
- return FALSE;
- }
- else if (ELEMENT_IS ("property"))
- {
- if (!parse_property (parser, element_name, attribute_names,
- attribute_values, error))
- return FALSE;
- }
- else if (ELEMENT_IS ("arg"))
- {
- if (!parse_arg (parser, element_name, attribute_names,
- attribute_values, error))
- return FALSE;
- }
- else if (ELEMENT_IS ("annotation"))
- {
- if (!parse_annotation (parser, element_name, attribute_names,
- attribute_values, error))
- return FALSE;
- }
- else
- {
- if (strchr (element_name, ':') != NULL)
- /* Passthrough XML-namespaced nodes */
- parser->unknown_namespaced_depth += 1;
- else if (parser->unknown_namespaced_depth == 0)
- {
- g_set_error (error, G_MARKUP_ERROR,
- G_MARKUP_ERROR_PARSE,
- "Element <%s> not recognized",
- element_name);
- return FALSE;
- }
- }
-
- return TRUE;
-}
-
-gboolean
-parser_end_element (Parser *parser,
- const char *element_name,
- GError **error)
-{
- g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
-
- if (ELEMENT_IS ("interface"))
- {
- parser->interface = NULL;
- }
- else if (ELEMENT_IS ("method"))
- {
- parser->method = NULL;
- }
- else if (ELEMENT_IS ("signal"))
- {
- parser->signal = NULL;
- }
- else if (ELEMENT_IS ("property"))
- {
- parser->property = NULL;
- }
- else if (ELEMENT_IS ("arg"))
- {
- parser->arg = NULL;
- }
- else if (ELEMENT_IS ("annotation"))
- {
- parser->in_annotation = FALSE;
- }
- else if (ELEMENT_IS ("node"))
- {
- NodeInfo *top;
-
- g_assert (parser->node_stack != NULL);
- top = parser->node_stack->data;
-
- parser->node_stack = g_slist_remove (parser->node_stack,
- top);
-
- if (parser->node_stack == NULL)
- parser->result = top; /* We are done, store the result */
- }
- else if (strchr (element_name, ':') != NULL)
- {
- /* Passthrough XML-namespaced nodes */
- parser->unknown_namespaced_depth -= 1;
- }
- else if (parser->unknown_namespaced_depth > 0)
- {
- /* pass through unknown elements underneath a namespace */
- }
- else
- g_assert_not_reached (); /* should have had an error on start_element */
-
- return TRUE;
-}
-
-gboolean
-parser_content (Parser *parser,
- const char *content,
- int len,
- GError **error)
-{
- g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
-
- /* FIXME check that it's all whitespace */
-
- return TRUE;
-}
-
-gboolean
-parser_finished (Parser *parser,
- GError **error)
-{
- g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
-
- return TRUE;
-}
-
-NodeInfo*
-parser_get_nodes (Parser *parser)
-{
- return parser->result;
-}
diff --git a/dbus/dbus-gparser.h b/dbus/dbus-gparser.h
deleted file mode 100644
index 347b39b..0000000
--- a/dbus/dbus-gparser.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/* -*- mode: C; c-file-style: "gnu" -*- */
-/* dbus-gparser.h parse DBus description files
- *
- * Copyright (C) 2003 Red Hat, Inc.
- *
- * Licensed under the Academic Free License version 2.1
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- */
-#ifndef DBUS_GLIB_PARSER_H
-#define DBUS_GLIB_PARSER_H
-
-#include <dbus/dbus.h>
-#include <glib.h>
-#include "dbus-gidl.h"
-
-G_BEGIN_DECLS
-
-typedef struct Parser Parser;
-
-Parser* parser_new (void);
-Parser* parser_ref (Parser *parser);
-void parser_unref (Parser *parser);
-gboolean parser_check_doctype (Parser *parser,
- const char *doctype,
- GError **error);
-gboolean parser_start_element (Parser *parser,
- const char *element_name,
- const char **attribute_names,
- const char **attribute_values,
- GError **error);
-gboolean parser_end_element (Parser *parser,
- const char *element_name,
- GError **error);
-gboolean parser_content (Parser *parser,
- const char *content,
- int len,
- GError **error);
-gboolean parser_finished (Parser *parser,
- GError **error);
-
-NodeInfo* description_load_from_file (const char *filename,
- GError **error);
-NodeInfo* description_load_from_string (const char *str,
- int len,
- GError **error);
-
-NodeInfo* parser_get_nodes (Parser *parser);
-
-G_END_DECLS
-
-#endif /* DBUS_GLIB_GPARSER_H */
diff --git a/dbus/dbus-gproxy.c b/dbus/dbus-gproxy.c
deleted file mode 100644
index 2ced17b..0000000
--- a/dbus/dbus-gproxy.c
+++ /dev/null
@@ -1,3275 +0,0 @@
-/* -*- mode: C; c-file-style: "gnu" -*- */
-/* dbus-gproxy.c Proxy for remote objects
- *
- * Copyright (C) 2003, 2004, 2005 Red Hat, Inc.
- * Copyright (C) 2005 Nokia
- *
- * Licensed under the Academic Free License version 2.1
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- */
-
-#include <config.h>
-
-#include <dbus/dbus-glib.h>
-#include <dbus/dbus-glib-lowlevel.h>
-#include <dbus/dbus-signature.h>
-#include "dbus-gutils.h"
-#include "dbus-gsignature.h"
-#include "dbus-gvalue.h"
-#include "dbus-gvalue-utils.h"
-#include "dbus-gobject.h"
-#include <string.h>
-#include <gobject/gvaluecollector.h>
-#include <gio/gio.h>
-
-#define DBUS_G_PROXY_CALL_TO_ID(x) (GPOINTER_TO_UINT(x))
-#define DBUS_G_PROXY_ID_TO_CALL(x) (GUINT_TO_POINTER(x))
-#define DBUS_G_PROXY_GET_PRIVATE(o) \
- (G_TYPE_INSTANCE_GET_PRIVATE ((o), DBUS_TYPE_G_PROXY, DBusGProxyPrivate))
-
-static void oom (void) G_GNUC_NORETURN;
-static void
-oom (void)
-{
- g_error ("no memory");
-}
-
-typedef struct _DBusGProxyManager DBusGProxyManager;
-
-typedef struct _DBusGProxyPrivate DBusGProxyPrivate;
-
-struct _DBusGProxyPrivate
-{
- DBusGProxyManager *manager; /**< Proxy manager */
- char *name; /**< Name messages go to or NULL */
- char *path; /**< Path messages go to or NULL */
- char *interface; /**< Interface messages go to or NULL */
-
- DBusGProxyCall *name_call; /**< Pending call id to retrieve name owner */
- guint for_owner : 1; /**< Whether or not this proxy is for a name owner */
- guint associated : 1; /**< Whether or not this proxy is associated (for name proxies) */
-
- /* FIXME: make threadsafe? */
- guint call_id_counter; /**< Integer counter for pending calls */
-
- GData *signal_signatures; /**< D-BUS signatures for each signal */
-
- GHashTable *pending_calls; /**< Calls made on this proxy which have not yet returned */
-
- int default_timeout; /**< Default timeout to use, see dbus_g_proxy_set_default_timeout */
-};
-
-static void dbus_g_proxy_init (DBusGProxy *proxy);
-static void dbus_g_proxy_class_init (DBusGProxyClass *klass);
-static GObject *dbus_g_proxy_constructor (GType type,
- guint n_construct_properties,
- GObjectConstructParam *construct_properties);
-static void dbus_g_proxy_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec);
-static void dbus_g_proxy_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec);
-
-static void dbus_g_proxy_finalize (GObject *object);
-static void dbus_g_proxy_dispose (GObject *object);
-static void dbus_g_proxy_destroy (DBusGProxy *proxy);
-static void dbus_g_proxy_emit_remote_signal (DBusGProxy *proxy,
- DBusMessage *message);
-
-static DBusGProxyCall *manager_begin_bus_call (DBusGProxyManager *manager,
- const char *method,
- DBusGProxyCallNotify notify,
- gpointer data,
- GDestroyNotify destroy,
- GType first_arg_type,
- ...);
-static guint dbus_g_proxy_begin_call_internal (DBusGProxy *proxy,
- const char *method,
- DBusGProxyCallNotify notify,
- gpointer data,
- GDestroyNotify destroy,
- GValueArray *args,
- int timeout );
-static gboolean dbus_g_proxy_end_call_internal (DBusGProxy *proxy,
- guint call_id,
- GError **error,
- GType first_arg_type,
- va_list args);
-
-/*
- * A list of proxies with a given name+path+interface, used to
- * route incoming signals.
- */
-typedef struct
-{
- GSList *proxies; /**< The list of proxies */
-
- char name[4]; /**< name (empty string for none), nul byte,
- * path, nul byte,
- * interface, nul byte
- */
-
-} DBusGProxyList;
-
-/*
- * DBusGProxyManager's primary task is to route signals to the proxies
- * those signals are emitted on. In order to do this it also has to
- * track the owners of the names proxies are bound to.
- */
-struct _DBusGProxyManager
-{
- GStaticMutex lock; /**< Thread lock */
- int refcount; /**< Reference count */
- DBusConnection *connection; /**< Connection we're associated with. */
-
- DBusGProxy *bus_proxy; /**< Special internal proxy used to talk to the bus */
-
- GHashTable *proxy_lists; /**< Hash used to route incoming signals
- * and iterate over proxies
- * tristring -> DBusGProxyList
- */
- GHashTable *owner_match_rules; /**< Hash to keep track of match rules of
- * NameOwnerChanged.
- * gchar *name -> guint *refcount
- */
- GHashTable *owner_names; /**< Hash to keep track of mapping from
- * char * -> GSList of DBusGProxyNameOwnerInfo
- * base name -> [name,name,...] for proxies which
- * are for names.
- */
- GSList *unassociated_proxies; /**< List of name proxies for which
- * there was no result for
- * GetNameOwner
- */
-};
-
-static DBusGProxyManager *dbus_g_proxy_manager_ref (DBusGProxyManager *manager);
-static DBusHandlerResult dbus_g_proxy_manager_filter (DBusConnection *connection,
- DBusMessage *message,
- void *user_data);
-
-
-/** Lock the DBusGProxyManager */
-#define LOCK_MANAGER(mgr) (g_static_mutex_lock (&(mgr)->lock))
-/** Unlock the DBusGProxyManager */
-#define UNLOCK_MANAGER(mgr) (g_static_mutex_unlock (&(mgr)->lock))
-
-static int g_proxy_manager_slot = -1;
-
-/* Lock controlling get/set manager as data on each connection */
-static GStaticMutex connection_g_proxy_lock = G_STATIC_MUTEX_INIT;
-
-static DBusGProxyManager*
-dbus_g_proxy_manager_get (DBusConnection *connection)
-{
- DBusGProxyManager *manager;
-
- dbus_connection_allocate_data_slot (&g_proxy_manager_slot);
- if (g_proxy_manager_slot < 0)
- g_error ("out of memory");
-
- g_static_mutex_lock (&connection_g_proxy_lock);
-
- manager = dbus_connection_get_data (connection, g_proxy_manager_slot);
- if (manager != NULL)
- {
- dbus_connection_free_data_slot (&g_proxy_manager_slot);
- dbus_g_proxy_manager_ref (manager);
- g_static_mutex_unlock (&connection_g_proxy_lock);
- return manager;
- }
-
- manager = g_new0 (DBusGProxyManager, 1);
-
- manager->refcount = 1;
- manager->connection = connection;
-
- g_static_mutex_init (&manager->lock);
-
- /* Proxy managers keep the connection alive, which means that
- * DBusGProxy indirectly does. To free a connection you have to free
- * all the proxies referring to it.
- */
- dbus_connection_ref (manager->connection);
-
- dbus_connection_set_data (connection, g_proxy_manager_slot,
- manager, NULL);
-
- dbus_connection_add_filter (connection, dbus_g_proxy_manager_filter,
- manager, NULL);
-
- g_static_mutex_unlock (&connection_g_proxy_lock);
-
- return manager;
-}
-
-static DBusGProxyManager *
-dbus_g_proxy_manager_ref (DBusGProxyManager *manager)
-{
- g_assert (manager != NULL);
- g_assert (manager->refcount > 0);
-
- LOCK_MANAGER (manager);
-
- manager->refcount += 1;
-
- UNLOCK_MANAGER (manager);
-
- return manager;
-}
-
-static void
-dbus_g_proxy_manager_unref (DBusGProxyManager *manager)
-{
- g_assert (manager != NULL);
- g_assert (manager->refcount > 0);
-
- LOCK_MANAGER (manager);
- manager->refcount -= 1;
- if (manager->refcount == 0)
- {
- UNLOCK_MANAGER (manager);
-
- if (manager->bus_proxy)
- g_object_unref (manager->bus_proxy);
-
- if (manager->proxy_lists)
- {
- /* can't have any proxies left since they hold
- * a reference to the proxy manager.
- */
- g_assert (g_hash_table_size (manager->proxy_lists) == 0);
-
- g_hash_table_destroy (manager->proxy_lists);
- manager->proxy_lists = NULL;
-
- }
-
- if (manager->owner_match_rules)
- {
- /* Since we destroyed all proxies, none can be tracking
- * name owners
- */
- g_assert (g_hash_table_size (manager->owner_match_rules) == 0);
- g_hash_table_destroy (manager->owner_match_rules);
- manager->owner_match_rules = NULL;
- }
-
- if (manager->owner_names)
- {
- /* Since we destroyed all proxies, none can be tracking
- * name owners
- */
- g_assert (g_hash_table_size (manager->owner_names) == 0);
-
- g_hash_table_destroy (manager->owner_names);
- manager->owner_names = NULL;
- }
-
- g_assert (manager->unassociated_proxies == NULL);
-
- g_static_mutex_free (&manager->lock);
-
- g_static_mutex_lock (&connection_g_proxy_lock);
-
- dbus_connection_remove_filter (manager->connection, dbus_g_proxy_manager_filter,
- manager);
-
- dbus_connection_set_data (manager->connection,
- g_proxy_manager_slot,
- NULL, NULL);
-
- g_static_mutex_unlock (&connection_g_proxy_lock);
-
- dbus_connection_unref (manager->connection);
- g_free (manager);
-
- dbus_connection_free_data_slot (&g_proxy_manager_slot);
- }
- else
- {
- UNLOCK_MANAGER (manager);
- }
-}
-
-static guint
-tristring_hash (gconstpointer key)
-{
- const char *p = key;
- guint h = *p;
-
- if (h)
- {
- for (p += 1; *p != '\0'; p++)
- h = (h << 5) - h + *p;
- }
-
- /* skip nul and do the next substring */
- for (p += 1; *p != '\0'; p++)
- h = (h << 5) - h + *p;
-
- /* skip nul again and another substring */
- for (p += 1; *p != '\0'; p++)
- h = (h << 5) - h + *p;
-
- return h;
-}
-
-static gboolean
-strequal_len (const char *a,
- const char *b,
- size_t *lenp)
-{
- size_t a_len;
- size_t b_len;
-
- a_len = strlen (a);
- b_len = strlen (b);
-
- if (a_len != b_len)
- return FALSE;
-
- if (memcmp (a, b, a_len) != 0)
- return FALSE;
-
- *lenp = a_len;
-
- return TRUE;
-}
-
-static gboolean
-tristring_equal (gconstpointer a,
- gconstpointer b)
-{
- const char *ap = a;
- const char *bp = b;
- size_t len;
-
- if (!strequal_len (ap, bp, &len))
- return FALSE;
-
- ap += len + 1;
- bp += len + 1;
-
- if (!strequal_len (ap, bp, &len))
- return FALSE;
-
- ap += len + 1;
- bp += len + 1;
-
- if (strcmp (ap, bp) != 0)
- return FALSE;
-
- return TRUE;
-}
-
-static char*
-tristring_alloc_from_strings (size_t padding_before,
- const char *name,
- const char *path,
- const char *interface)
-{
- size_t name_len, iface_len, path_len, len;
- char *tri;
-
- if (name)
- name_len = strlen (name);
- else
- name_len = 0;
-
- path_len = strlen (path);
-
- iface_len = strlen (interface);
-
- tri = g_malloc (padding_before + name_len + path_len + iface_len + 3);
-
- len = padding_before;
-
- if (name)
- memcpy (&tri[len], name, name_len);
-
- len += name_len;
- tri[len] = '\0';
- len += 1;
-
- g_assert (len == (padding_before + name_len + 1));
-
- memcpy (&tri[len], path, path_len);
- len += path_len;
- tri[len] = '\0';
- len += 1;
-
- g_assert (len == (padding_before + name_len + path_len + 2));
-
- memcpy (&tri[len], interface, iface_len);
- len += iface_len;
- tri[len] = '\0';
- len += 1;
-
- g_assert (len == (padding_before + name_len + path_len + iface_len + 3));
-
- return tri;
-}
-
-static char*
-tristring_from_proxy (DBusGProxy *proxy)
-{
- DBusGProxyPrivate *priv = DBUS_G_PROXY_GET_PRIVATE(proxy);
-
- return tristring_alloc_from_strings (0,
- priv->name,
- priv->path,
- priv->interface);
-}
-
-static char*
-tristring_from_message (DBusMessage *message)
-{
- const char *path;
- const char *interface;
-
- path = dbus_message_get_path (message);
- interface = dbus_message_get_interface (message);
-
- g_assert (path);
- g_assert (interface);
-
- return tristring_alloc_from_strings (0,
- dbus_message_get_sender (message),
- path, interface);
-}
-
-static DBusGProxyList*
-g_proxy_list_new (DBusGProxy *first_proxy)
-{
- DBusGProxyList *list;
- DBusGProxyPrivate *priv = DBUS_G_PROXY_GET_PRIVATE(first_proxy);
-
- list = (void*) tristring_alloc_from_strings (G_STRUCT_OFFSET (DBusGProxyList, name),
- priv->name,
- priv->path,
- priv->interface);
- list->proxies = NULL;
-
- return list;
-}
-
-static void
-g_proxy_list_free (DBusGProxyList *list)
-{
- /* we don't hold a reference to the proxies in the list,
- * as they ref the GProxyManager
- */
- g_slist_free (list->proxies);
-
- g_free (list);
-}
-
-static char*
-g_proxy_get_signal_match_rule (DBusGProxy *proxy)
-{
- DBusGProxyPrivate *priv = DBUS_G_PROXY_GET_PRIVATE(proxy);
- /* FIXME Escaping is required here */
-
- if (priv->name)
- return g_strdup_printf ("type='signal',sender='%s',path='%s',interface='%s'",
- priv->name, priv->path, priv->interface);
- else
- return g_strdup_printf ("type='signal',path='%s',interface='%s'",
- priv->path, priv->interface);
-}
-
-static char *
-get_owner_match_rule (const gchar *name)
-{
- return g_strdup_printf ("type='signal',sender='" DBUS_SERVICE_DBUS
- "',path='" DBUS_PATH_DBUS
- "',interface='" DBUS_INTERFACE_DBUS
- "',member='NameOwnerChanged'"
- ",arg0='%s'", name);
-}
-
-typedef struct
-{
- char *name;
- guint refcount;
-} DBusGProxyNameOwnerInfo;
-
-static gint
-find_name_in_info (gconstpointer a, gconstpointer b)
-{
- const DBusGProxyNameOwnerInfo *info = a;
- const char *name = b;
-
- return strcmp (info->name, name);
-}
-
-typedef struct
-{
- const char *name;
- const char *owner;
- DBusGProxyNameOwnerInfo *info;
-} DBusGProxyNameOwnerForeachData;
-
-static void
-name_owner_foreach (gpointer key, gpointer val, gpointer data)
-{
- const char *owner;
- DBusGProxyNameOwnerForeachData *foreach_data;
- GSList *names;
- GSList *link;
-
- owner = key;
- names = val;
- foreach_data = data;
-
- if (foreach_data->owner != NULL)
- return;
-
- g_assert (foreach_data->info == NULL);
-
- link = g_slist_find_custom (names, foreach_data->name, find_name_in_info);
- if (link)
- {
- foreach_data->owner = owner;
- foreach_data->info = link->data;
- }
-}
-
-static gboolean
-dbus_g_proxy_manager_lookup_name_owner (DBusGProxyManager *manager,
- const char *name,
- DBusGProxyNameOwnerInfo **info,
- const char **owner)
-{
- DBusGProxyNameOwnerForeachData foreach_data;
-
- foreach_data.name = name;
- foreach_data.owner = NULL;
- foreach_data.info = NULL;
-
- g_hash_table_foreach (manager->owner_names, name_owner_foreach, &foreach_data);
-
- *info = foreach_data.info;
- *owner = foreach_data.owner;
- return *info != NULL;
-}
-
-static void
-insert_nameinfo (DBusGProxyManager *manager,
- const char *owner,
- DBusGProxyNameOwnerInfo *info)
-{
- GSList *names;
- gboolean insert;
-
- names = g_hash_table_lookup (manager->owner_names, owner);
-
- /* Only need to g_hash_table_insert the first time */
- insert = (names == NULL);
-
- names = g_slist_append (names, info);
-
- if (insert)
- g_hash_table_insert (manager->owner_names, g_strdup (owner), names);
-}
-
-static void
-dbus_g_proxy_manager_monitor_name_owner (DBusGProxyManager *manager,
- const char *owner,
- const char *name)
-{
- GSList *names;
- GSList *link;
- DBusGProxyNameOwnerInfo *nameinfo;
-
- names = g_hash_table_lookup (manager->owner_names, owner);
- link = g_slist_find_custom (names, name, find_name_in_info);
-
- if (!link)
- {
- nameinfo = g_new0 (DBusGProxyNameOwnerInfo, 1);
- nameinfo->name = g_strdup (name);
- nameinfo->refcount = 1;
-
- insert_nameinfo (manager, owner, nameinfo);
- }
- else
- {
- nameinfo = link->data;
- nameinfo->refcount++;
- }
-}
-
-static void
-dbus_g_proxy_manager_unmonitor_name_owner (DBusGProxyManager *manager,
- const char *name)
-{
- DBusGProxyNameOwnerInfo *info;
- const char *owner;
- gboolean ret;
-
- ret = dbus_g_proxy_manager_lookup_name_owner (manager, name, &info, &owner);
- g_assert (ret);
- g_assert (info != NULL);
- g_assert (owner != NULL);
-
- info->refcount--;
- if (info->refcount == 0)
- {
- GSList *names;
- GSList *link;
-
- names = g_hash_table_lookup (manager->owner_names, owner);
- link = g_slist_find_custom (names, name, find_name_in_info);
- names = g_slist_delete_link (names, link);
- if (names != NULL)
- g_hash_table_insert (manager->owner_names, g_strdup (owner), names);
- else
- g_hash_table_remove (manager->owner_names, owner);
-
- g_free (info->name);
- g_free (info);
- }
-}
-
-typedef struct
-{
- const char *name;
- GSList *destroyed;
-} DBusGProxyUnassociateData;
-
-static void
-unassociate_proxies (gpointer key, gpointer val, gpointer user_data)
-{
- DBusGProxyList *list;
- const char *name;
- GSList *tmp;
- DBusGProxyUnassociateData *data;
-
- list = val;
- data = user_data;
- name = data->name;
-
- for (tmp = list->proxies; tmp; tmp = tmp->next)
- {
- DBusGProxy *proxy = DBUS_G_PROXY (tmp->data);
- DBusGProxyPrivate *priv = DBUS_G_PROXY_GET_PRIVATE(proxy);
- DBusGProxyManager *manager;
-
- manager = priv->manager;
-
- if (priv->name != NULL && !strcmp (priv->name, name))
- {
- if (!priv->for_owner)
- {
- /* If a service appeared and then vanished very quickly,
- * it's conceivable we have an inflight request for
- * GetNameOwner here. Cancel it.
- * https://bugs.freedesktop.org/show_bug.cgi?id=18573
- */
- if (priv->name_call)
- dbus_g_proxy_cancel_call (manager->bus_proxy, priv->name_call);
-
- priv->name_call = NULL;
-
- priv->associated = FALSE;
- manager->unassociated_proxies = g_slist_prepend (manager->unassociated_proxies, proxy);
- }
- else
- {
- data->destroyed = g_slist_prepend (data->destroyed, proxy);
- /* make contents of list into weak pointers in case the objects
- * unref each other when disposing */
- g_object_add_weak_pointer (G_OBJECT (proxy),
- &(data->destroyed->data));
- }
- }
- }
-}
-
-static void
-dbus_g_proxy_manager_replace_name_owner (DBusGProxyManager *manager,
- const char *name,
- const char *prev_owner,
- const char *new_owner)
-{
- GSList *names;
-
- if (prev_owner[0] == '\0')
- {
- GSList *tmp;
- GSList *removed;
-
- /* We have a new service, look at unassociated proxies */
-
- removed = NULL;
-
- for (tmp = manager->unassociated_proxies; tmp ; tmp = tmp->next)
- {
- DBusGProxy *proxy = tmp->data;
- DBusGProxyPrivate *priv = DBUS_G_PROXY_GET_PRIVATE(proxy);
-
- if (!strcmp (priv->name, name))
- {
- removed = g_slist_prepend (removed, tmp);
-
- dbus_g_proxy_manager_monitor_name_owner (manager, new_owner, name);
- priv->associated = TRUE;
- }
- }
-
- for (tmp = removed; tmp; tmp = tmp->next)
- manager->unassociated_proxies = g_slist_delete_link (manager->unassociated_proxies, tmp->data);
- g_slist_free (removed);
- }
- else
- {
- DBusGProxyNameOwnerInfo *info;
- GSList *link;
-
- /* Name owner changed or deleted */
-
- names = g_hash_table_lookup (manager->owner_names, prev_owner);
-
- info = NULL;
- if (names != NULL)
- {
- link = g_slist_find_custom (names, name, find_name_in_info);
-
- if (link != NULL)
- {
- info = link->data;
-
- names = g_slist_delete_link (names, link);
-
- if (names == NULL)
- {
- g_hash_table_remove (manager->owner_names, prev_owner);
- }
- else
- {
- g_hash_table_insert (manager->owner_names,
- g_strdup (prev_owner), names);
- }
- }
- }
-
- if (new_owner[0] == '\0')
- {
- DBusGProxyUnassociateData data;
- GSList *tmp;
-
- data.name = name;
- data.destroyed = NULL;
-
- /* A service went away, we need to unassociate proxies */
- g_hash_table_foreach (manager->proxy_lists,
- unassociate_proxies, &data);
-
- UNLOCK_MANAGER (manager);
-
- /* the destroyed list's data pointers are weak pointers, so that we
- * don't end up calling destroy on proxies which have already been
- * freed up as a result of other ones being destroyed */
- for (tmp = data.destroyed; tmp; tmp = tmp->next)
- if (tmp->data != NULL)
- {
- g_object_remove_weak_pointer (G_OBJECT (tmp->data),
- &(tmp->data));
- dbus_g_proxy_destroy (tmp->data);
- }
- g_slist_free (data.destroyed);
-
- LOCK_MANAGER (manager);
-
- if (info)
- {
- g_free (info->name);
- g_free (info);
- }
- }
- else if (info)
- {
- insert_nameinfo (manager, new_owner, info);
- }
- }
-}
-
-static void
-got_name_owner_cb (DBusGProxy *bus_proxy,
- DBusGProxyCall *call,
- void *user_data)
-{
- DBusGProxy *proxy = user_data;
- DBusGProxyPrivate *priv = DBUS_G_PROXY_GET_PRIVATE(proxy);
- GError *error;
- char *owner;
-
- error = NULL;
- owner = NULL;
-
- LOCK_MANAGER (priv->manager);
-
- if (!dbus_g_proxy_end_call (bus_proxy, call, &error,
- G_TYPE_STRING, &owner,
- G_TYPE_INVALID))
- {
- if (error->domain == DBUS_GERROR && error->code == DBUS_GERROR_NAME_HAS_NO_OWNER)
- {
- priv->manager->unassociated_proxies = g_slist_prepend (priv->manager->unassociated_proxies, proxy);
- }
- else if (error->domain == DBUS_GERROR && error->code == DBUS_GERROR_REMOTE_EXCEPTION)
- g_warning ("Couldn't get name owner (%s): %s",
- dbus_g_error_get_name (error),
- error->message);
- else
- g_warning ("Couldn't get name owner (code %d): %s",
- error->code, error->message);
- g_clear_error (&error);
- goto out;
- }
- else
- {
- dbus_g_proxy_manager_monitor_name_owner (priv->manager, owner, priv->name);
- priv->associated = TRUE;
- }
-
- out:
- priv->name_call = NULL;
- UNLOCK_MANAGER (priv->manager);
- g_free (owner);
-}
-
-static char *
-get_name_owner (DBusConnection *connection,
- const char *name,
- GError **error)
-{
- DBusError derror;
- DBusMessage *request, *reply;
- char *base_name;
-
- dbus_error_init (&derror);
-
- base_name = NULL;
- reply = NULL;
-
- request = dbus_message_new_method_call (DBUS_SERVICE_DBUS,
- DBUS_PATH_DBUS,
- DBUS_INTERFACE_DBUS,
- "GetNameOwner");
- if (request == NULL)
- g_error ("Out of memory");
-
- if (!dbus_message_append_args (request,
- DBUS_TYPE_STRING, &name,
- DBUS_TYPE_INVALID))
- g_error ("Out of memory");
-
- reply =
- dbus_connection_send_with_reply_and_block (connection,
- request,
- 2000, &derror);
- if (reply == NULL)
- goto error;
-
- if (dbus_set_error_from_message (&derror, reply))
- goto error;
-
- if (!dbus_message_get_args (reply, &derror,
- DBUS_TYPE_STRING, &base_name,
- DBUS_TYPE_INVALID))
- goto error;
-
- base_name = g_strdup (base_name);
- goto out;
-
- error:
- g_assert (dbus_error_is_set (&derror));
- dbus_set_g_error (error, &derror);
- dbus_error_free (&derror);
-
- out:
- if (request)
- dbus_message_unref (request);
- if (reply)
- dbus_message_unref (reply);
-
- return base_name;
-}
-
-
-static void
-guint_slice_free (gpointer data)
-{
- g_slice_free (guint, data);
-}
-
-
-static void
-dbus_g_proxy_manager_register (DBusGProxyManager *manager,
- DBusGProxy *proxy)
-{
- DBusGProxyList *list;
- DBusGProxyPrivate *priv = DBUS_G_PROXY_GET_PRIVATE(proxy);
-
- LOCK_MANAGER (manager);
-
- if (manager->proxy_lists == NULL)
- {
- g_assert (manager->owner_names == NULL);
- g_assert (manager->owner_match_rules == NULL);
-
- list = NULL;
- manager->proxy_lists = g_hash_table_new_full (tristring_hash,
- tristring_equal,
- NULL,
- (GFreeFunc) g_proxy_list_free);
- manager->owner_names = g_hash_table_new_full (g_str_hash,
- g_str_equal,
- g_free,
- NULL);
- manager->owner_match_rules = g_hash_table_new_full (g_str_hash,
- g_str_equal,
- g_free,
- guint_slice_free);
- }
- else
- {
- char *tri;
-
- tri = tristring_from_proxy (proxy);
-
- list = g_hash_table_lookup (manager->proxy_lists, tri);
-
- g_free (tri);
- }
-
- if (list == NULL)
- {
- list = g_proxy_list_new (proxy);
-
- g_hash_table_replace (manager->proxy_lists,
- list->name, list);
- }
-
- if (list->proxies == NULL && priv->name)
- {
- /* We have to add match rules to the server,
- * but only if the server is a message bus,
- * not if it's a peer.
- */
- char *rule;
- guint *refcount;
-
- rule = g_proxy_get_signal_match_rule (proxy);
- /* We don't check for errors; it's not like anyone would handle them, and
- * we don't want a round trip here.
- */
- dbus_bus_add_match (manager->connection, rule, NULL);
- g_free (rule);
-
- refcount = g_hash_table_lookup (manager->owner_match_rules, priv->name);
-
- if (refcount != NULL)
- {
- g_assert (*refcount != 0);
- g_assert (*refcount < G_MAXUINT);
- (*refcount)++;
- }
- else
- {
- char *rule;
- rule = get_owner_match_rule (priv->name);
- dbus_bus_add_match (manager->connection,
- rule, NULL);
- g_free (rule);
-
- refcount = g_slice_new (guint);
- *refcount = 1;
- g_hash_table_insert (manager->owner_match_rules,
- g_strdup (priv->name), refcount);
- }
- }
-
- g_assert (g_slist_find (list->proxies, proxy) == NULL);
-
- list->proxies = g_slist_prepend (list->proxies, proxy);
-
- if (!priv->for_owner)
- {
- const char *owner;
- DBusGProxyNameOwnerInfo *info;
-
- if (!dbus_g_proxy_manager_lookup_name_owner (manager, priv->name, &info, &owner))
- {
- priv->name_call = manager_begin_bus_call (manager, "GetNameOwner",
- got_name_owner_cb,
- proxy, NULL,
- G_TYPE_STRING,
- priv->name,
- G_TYPE_INVALID);
-
- priv->associated = FALSE;
- }
- else
- {
- info->refcount++;
- priv->associated = TRUE;
- }
- }
-
- UNLOCK_MANAGER (manager);
-}
-
-static void
-dbus_g_proxy_manager_unregister (DBusGProxyManager *manager,
- DBusGProxy *proxy)
-{
- DBusGProxyList *list;
- DBusGProxyPrivate *priv = DBUS_G_PROXY_GET_PRIVATE(proxy);
- char *tri;
-
- LOCK_MANAGER (manager);
-
-#ifndef G_DISABLE_CHECKS
- if (manager->proxy_lists == NULL)
- {
- g_warning ("Trying to unregister a proxy but there aren't any registered");
- return;
- }
-#endif
-
- tri = tristring_from_proxy (proxy);
-
- list = g_hash_table_lookup (manager->proxy_lists, tri);
-
-#ifndef G_DISABLE_CHECKS
- if (list == NULL)
- {
- g_warning ("Trying to unregister a proxy but it isn't registered");
- return;
- }
-#endif
-
- g_assert (g_slist_find (list->proxies, proxy) != NULL);
-
- list->proxies = g_slist_remove (list->proxies, proxy);
-
- g_assert (g_slist_find (list->proxies, proxy) == NULL);
-
- if (!priv->for_owner)
- {
- if (!priv->associated)
- {
- GSList *link;
-
- if (priv->name_call != 0)
- {
- dbus_g_proxy_cancel_call (manager->bus_proxy, priv->name_call);
- priv->name_call = 0;
- }
- else
- {
- link = g_slist_find (manager->unassociated_proxies, proxy);
- if (link != NULL)
- {
- manager->unassociated_proxies = g_slist_delete_link (
- manager->unassociated_proxies, link);
- }
- }
- }
- else
- {
- g_assert (priv->name_call == 0);
-
- dbus_g_proxy_manager_unmonitor_name_owner (manager, priv->name);
- }
- }
-
- if (list->proxies == NULL)
- {
- char *rule;
- g_hash_table_remove (manager->proxy_lists,
- tri);
-
- rule = g_proxy_get_signal_match_rule (proxy);
- dbus_bus_remove_match (manager->connection,
- rule, NULL);
- g_free (rule);
-
- if (priv->name)
- {
- guint *refcount;
- refcount = g_hash_table_lookup (manager->owner_match_rules, priv->name);
- (*refcount)--;
-
- if (*refcount == 0)
- {
- rule = get_owner_match_rule (priv->name);
- dbus_bus_remove_match (manager->connection,
- rule, NULL);
- g_free (rule);
- g_hash_table_remove (manager->owner_match_rules, priv->name);
- }
- }
- }
-
- if (g_hash_table_size (manager->proxy_lists) == 0)
- {
- g_hash_table_destroy (manager->proxy_lists);
- manager->proxy_lists = NULL;
- }
-
- if (manager->owner_match_rules != NULL &&
- g_hash_table_size (manager->owner_match_rules) == 0)
- {
- g_hash_table_destroy (manager->owner_match_rules);
- manager->owner_match_rules = NULL;
- }
-
- g_free (tri);
-
- UNLOCK_MANAGER (manager);
-}
-
-static void
-list_proxies_foreach (gpointer key,
- gpointer value,
- gpointer user_data)
-{
- DBusGProxyList *list;
- GSList **ret;
- GSList *tmp;
-
- list = value;
- ret = user_data;
-
- tmp = list->proxies;
- while (tmp != NULL)
- {
- DBusGProxy *proxy = DBUS_G_PROXY (tmp->data);
-
- g_object_ref (proxy);
- *ret = g_slist_prepend (*ret, proxy);
-
- tmp = tmp->next;
- }
-}
-
-static GSList*
-dbus_g_proxy_manager_list_all (DBusGProxyManager *manager)
-{
- GSList *ret;
-
- ret = NULL;
-
- if (manager->proxy_lists)
- {
- g_hash_table_foreach (manager->proxy_lists,
- list_proxies_foreach,
- &ret);
- }
-
- return ret;
-}
-
-static DBusHandlerResult
-dbus_g_proxy_manager_filter (DBusConnection *connection,
- DBusMessage *message,
- void *user_data)
-{
- DBusGProxyManager *manager;
-
- if (dbus_message_get_type (message) != DBUS_MESSAGE_TYPE_SIGNAL)
- return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
-
- manager = user_data;
-
- dbus_g_proxy_manager_ref (manager);
-
- LOCK_MANAGER (manager);
-
- if (dbus_message_is_signal (message,
- DBUS_INTERFACE_LOCAL,
- "Disconnected"))
- {
- /* Destroy all the proxies, quite possibly resulting in unreferencing
- * the proxy manager and the connection as well.
- */
- GSList *all;
- GSList *tmp;
-
- all = dbus_g_proxy_manager_list_all (manager);
-
- tmp = all;
- while (tmp != NULL)
- {
- DBusGProxy *proxy;
-
- proxy = DBUS_G_PROXY (tmp->data);
-
- UNLOCK_MANAGER (manager);
- dbus_g_proxy_destroy (proxy);
- g_object_unref (G_OBJECT (proxy));
- LOCK_MANAGER (manager);
-
- tmp = tmp->next;
- }
-
- g_slist_free (all);
-
-#ifndef G_DISABLE_CHECKS
- if (manager->proxy_lists != NULL)
- g_warning ("Disconnection emitted \"destroy\" on all DBusGProxy, but somehow new proxies were created in response to one of those destroy signals. This will cause a memory leak.");
-#endif
- }
- else
- {
- char *tri;
- GSList *full_list;
- GSList *owned_names;
- GSList *tmp;
- const char *sender;
-
- sender = dbus_message_get_sender (message);
-
- /* First we handle NameOwnerChanged internally */
- if (g_strcmp0 (sender, DBUS_SERVICE_DBUS) == 0 &&
- dbus_message_is_signal (message,
- DBUS_INTERFACE_DBUS,
- "NameOwnerChanged"))
- {
- const char *name;
- const char *prev_owner;
- const char *new_owner;
- DBusError derr;
-
- dbus_error_init (&derr);
- if (!dbus_message_get_args (message,
- &derr,
- DBUS_TYPE_STRING,
- &name,
- DBUS_TYPE_STRING,
- &prev_owner,
- DBUS_TYPE_STRING,
- &new_owner,
- DBUS_TYPE_INVALID))
- {
- /* Ignore this error */
- dbus_error_free (&derr);
- }
- else if (manager->owner_names != NULL)
- {
- dbus_g_proxy_manager_replace_name_owner (manager, name, prev_owner, new_owner);
- }
- }
-
- /* dbus spec requires these, libdbus validates */
- g_assert (dbus_message_get_path (message) != NULL);
- g_assert (dbus_message_get_interface (message) != NULL);
- g_assert (dbus_message_get_member (message) != NULL);
-
- tri = tristring_from_message (message);
-
- if (manager->proxy_lists)
- {
- DBusGProxyList *owner_list;
- owner_list = g_hash_table_lookup (manager->proxy_lists, tri);
- if (owner_list)
- full_list = g_slist_copy (owner_list->proxies);
- else
- full_list = NULL;
- }
- else
- full_list = NULL;
-
- g_free (tri);
-
- if (manager->owner_names && sender)
- {
- owned_names = g_hash_table_lookup (manager->owner_names, sender);
- for (tmp = owned_names; tmp; tmp = tmp->next)
- {
- DBusGProxyList *owner_list;
- DBusGProxyNameOwnerInfo *nameinfo;
-
- nameinfo = tmp->data;
- g_assert (nameinfo->refcount > 0);
- tri = tristring_alloc_from_strings (0, nameinfo->name,
- dbus_message_get_path (message),
- dbus_message_get_interface (message));
-
- owner_list = g_hash_table_lookup (manager->proxy_lists, tri);
- if (owner_list != NULL)
- {
- GSList *elt;
-
- /* Ignore duplicates when adding to full_list */
- for (elt = owner_list->proxies; elt; elt = g_slist_next (elt))
- {
- if (!g_slist_find (full_list, elt->data))
- full_list = g_slist_append (full_list, elt->data);
- }
- }
- g_free (tri);
- }
- }
-
-#if 0
- g_print ("proxy got %s,%s,%s = list %p\n",
- tri,
- tri + strlen (tri) + 1,
- tri + strlen (tri) + 1 + strlen (tri + strlen (tri) + 1) + 1,
- list);
-#endif
-
- /* Emit the signal */
-
- g_slist_foreach (full_list, (GFunc) g_object_ref, NULL);
-
- for (tmp = full_list; tmp; tmp = tmp->next)
- {
- DBusGProxy *proxy;
-
- proxy = DBUS_G_PROXY (tmp->data);
-
- UNLOCK_MANAGER (manager);
- dbus_g_proxy_emit_remote_signal (proxy, message);
- g_object_unref (G_OBJECT (proxy));
- LOCK_MANAGER (manager);
- }
- g_slist_free (full_list);
- }
-
- UNLOCK_MANAGER (manager);
- dbus_g_proxy_manager_unref (manager);
-
- /* "Handling" signals doesn't make sense, they are for everyone
- * who cares
- */
- return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
-}
-
-
-
-/* ---------- DBusGProxy -------------- */
-#define DBUS_G_PROXY_DESTROYED(proxy) (DBUS_G_PROXY_GET_PRIVATE(proxy)->manager == NULL)
-
-static void
-marshal_dbus_message_to_g_marshaller (GClosure *closure,
- GValue *return_value,
- guint n_param_values,
- const GValue *param_values,
- gpointer invocation_hint,
- gpointer marshal_data);
-enum
-{
- PROP_0,
- PROP_NAME,
- PROP_PATH,
- PROP_INTERFACE,
- PROP_CONNECTION
-};
-
-enum
-{
- DESTROY,
- RECEIVED,
- LAST_SIGNAL
-};
-
-static void *parent_class;
-static guint signals[LAST_SIGNAL] = { 0 };
-
-static void
-dbus_g_proxy_init (DBusGProxy *proxy)
-{
- DBusGProxyPrivate *priv = DBUS_G_PROXY_GET_PRIVATE(proxy);
-
- g_datalist_init (&priv->signal_signatures);
- priv->pending_calls = g_hash_table_new_full (NULL, NULL, NULL,
- (GDestroyNotify) dbus_pending_call_unref);
- priv->name_call = 0;
- priv->associated = FALSE;
- priv->default_timeout = -1;
-}
-
-static GObject *
-dbus_g_proxy_constructor (GType type,
- guint n_construct_properties,
- GObjectConstructParam *construct_properties)
-{
- DBusGProxy *proxy;
- DBusGProxyClass *klass;
- GObjectClass *parent_class;
- DBusGProxyPrivate *priv;
-
- klass = DBUS_G_PROXY_CLASS (g_type_class_peek (DBUS_TYPE_G_PROXY));
-
- parent_class = G_OBJECT_CLASS (g_type_class_peek_parent (klass));
-
- proxy = DBUS_G_PROXY (parent_class->constructor (type, n_construct_properties,
- construct_properties));
-
- priv = DBUS_G_PROXY_GET_PRIVATE (proxy);
-
- /* if these assertions fail, a deriving class has not set our required
- * parameters - our own public constructors do return_if_fail checks
- * on these parameters being provided. unfortunately we can't assert
- * for manager because it's allowed to be NULL when tha mangager is
- * setting up a bus proxy for its own calls */
- g_assert (priv->path != NULL);
- g_assert (priv->interface != NULL);
-
- if (priv->manager != NULL)
- {
- dbus_g_proxy_manager_register (priv->manager, proxy);
- }
-
- return G_OBJECT (proxy);
-}
-
-static void
-dbus_g_proxy_class_init (DBusGProxyClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
- parent_class = g_type_class_peek_parent (klass);
-
- g_type_class_add_private (klass, sizeof (DBusGProxyPrivate));
-
- object_class->set_property = dbus_g_proxy_set_property;
- object_class->get_property = dbus_g_proxy_get_property;
-
- g_object_class_install_property (object_class,
- PROP_NAME,
- g_param_spec_string ("name",
- "name",
- "name",
- NULL,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
-
- g_object_class_install_property (object_class,
- PROP_PATH,
- g_param_spec_string ("path",
- "path",
- "path",
- NULL,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
-
- g_object_class_install_property (object_class,
- PROP_INTERFACE,
- g_param_spec_string ("interface",
- "interface",
- "interface",
- NULL,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
-
- g_object_class_install_property (object_class,
- PROP_CONNECTION,
- g_param_spec_boxed ("connection",
- "connection",
- "connection",
- DBUS_TYPE_G_CONNECTION,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
-
- object_class->finalize = dbus_g_proxy_finalize;
- object_class->dispose = dbus_g_proxy_dispose;
- object_class->constructor = dbus_g_proxy_constructor;
-
-/**
- * DBusGProxy::destroy:
- * @dbusgproxy: the object which received the signal.
- *
- *
- */
- signals[DESTROY] =
- g_signal_new ("destroy",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_CLEANUP | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS,
- 0,
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
-
-/*
- * DBusGProxy::received:
- * @dbusgproxy: the object which received the signal.
- *
- *
- */
- signals[RECEIVED] =
- g_signal_new ("received",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
- 0,
- NULL, NULL,
- marshal_dbus_message_to_g_marshaller,
- G_TYPE_NONE, 2, DBUS_TYPE_MESSAGE, G_TYPE_POINTER);
-}
-
-static gboolean
-cancel_pending_call (gpointer key, gpointer val, gpointer data)
-{
- DBusPendingCall *pending = val;
-
- dbus_pending_call_cancel (pending);
-
- return TRUE;
-}
-
-static void
-dbus_g_proxy_dispose (GObject *object)
-{
- DBusGProxy *proxy = DBUS_G_PROXY (object);
- DBusGProxyPrivate *priv = DBUS_G_PROXY_GET_PRIVATE(proxy);
-
- if (priv->pending_calls == NULL)
- {
- return;
- }
-
- /* Cancel outgoing pending calls */
- g_hash_table_foreach_remove (priv->pending_calls, cancel_pending_call, NULL);
- g_hash_table_destroy (priv->pending_calls);
- priv->pending_calls = NULL;
-
- if (priv->manager && proxy != priv->manager->bus_proxy)
- {
- dbus_g_proxy_manager_unregister (priv->manager, proxy);
- dbus_g_proxy_manager_unref (priv->manager);
- }
- priv->manager = NULL;
-
- g_datalist_clear (&priv->signal_signatures);
-
- g_signal_emit (object, signals[DESTROY], 0);
-
- G_OBJECT_CLASS (parent_class)->dispose (object);
-}
-
-static void
-dbus_g_proxy_finalize (GObject *object)
-{
- DBusGProxy *proxy = DBUS_G_PROXY (object);
- DBusGProxyPrivate *priv = DBUS_G_PROXY_GET_PRIVATE(proxy);
-
- g_return_if_fail (DBUS_G_PROXY_DESTROYED (proxy));
-
- g_free (priv->name);
- g_free (priv->path);
- g_free (priv->interface);
-
- G_OBJECT_CLASS (parent_class)->finalize (object);
-}
-
-static void
-dbus_g_proxy_destroy (DBusGProxy *proxy)
-{
- /* FIXME do we need the GTK_IN_DESTRUCTION style flag
- * from GtkObject?
- */
- g_object_run_dispose (G_OBJECT (proxy));
-}
-
-static void
-dbus_g_proxy_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- DBusGProxy *proxy = DBUS_G_PROXY (object);
- DBusGProxyPrivate *priv = DBUS_G_PROXY_GET_PRIVATE(proxy);
- DBusGConnection *connection;
-
- switch (prop_id)
- {
- case PROP_NAME:
- priv->name = g_strdup (g_value_get_string (value));
- if (priv->name)
- priv->for_owner = (priv->name[0] == ':');
- else
- priv->for_owner = TRUE;
- break;
- case PROP_PATH:
- priv->path = g_strdup (g_value_get_string (value));
- break;
- case PROP_INTERFACE:
- priv->interface = g_strdup (g_value_get_string (value));
- break;
- case PROP_CONNECTION:
- connection = g_value_get_boxed (value);
- if (connection != NULL)
- {
- priv->manager = dbus_g_proxy_manager_get (DBUS_CONNECTION_FROM_G_CONNECTION (connection));
- }
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-dbus_g_proxy_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
-{
- DBusGProxy *proxy = DBUS_G_PROXY (object);
- DBusGProxyPrivate *priv = DBUS_G_PROXY_GET_PRIVATE(proxy);
-
- switch (prop_id)
- {
- case PROP_NAME:
- g_value_set_string (value, priv->name);
- break;
- case PROP_PATH:
- g_value_set_string (value, priv->path);
- break;
- case PROP_INTERFACE:
- g_value_set_string (value, priv->interface);
- break;
- case PROP_CONNECTION:
- g_value_set_boxed (value, DBUS_G_CONNECTION_FROM_CONNECTION(priv->manager->connection));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-/* this is to avoid people using g_signal_connect() directly,
- * to avoid confusion with local signal names, and because
- * of the horribly broken current setup (signals are added
- * globally to all proxies)
- */
-static char*
-create_signal_name (const char *interface,
- const char *signal)
-{
- GString *str;
- char *p;
-
- str = g_string_new (interface);
-
- g_string_append (str, "-");
-
- g_string_append (str, signal);
-
- /* GLib will silently barf on '.' in signal names */
- p = str->str;
- while (*p)
- {
- if (*p == '.')
- *p = '-';
- ++p;
- }
-
- return g_string_free (str, FALSE);
-}
-
-static void
-marshal_dbus_message_to_g_marshaller (GClosure *closure,
- GValue *return_value,
- guint n_param_values,
- const GValue *param_values,
- gpointer invocation_hint,
- gpointer marshal_data)
-{
- /* Incoming here we have three params, the instance (Proxy), the
- * DBusMessage, the signature. We want to convert that to an
- * expanded GValue array, then call an appropriate normal GLib
- * marshaller.
- */
-#define MAX_SIGNATURE_ARGS 20
- GValueArray *value_array;
- DBusGProxy *proxy;
- DBusMessage *message;
- GArray *gsignature;
- const GType *types;
- DBusGProxyPrivate *priv;
-
- g_assert (n_param_values == 3);
-
- proxy = g_value_get_object (&param_values[0]);
- message = g_value_get_boxed (&param_values[1]);
- gsignature = g_value_get_pointer (&param_values[2]);
-
- g_return_if_fail (DBUS_IS_G_PROXY (proxy));
- g_return_if_fail (message != NULL);
- g_return_if_fail (gsignature != NULL);
-
- priv = DBUS_G_PROXY_GET_PRIVATE(proxy);
-
- {
- DBusGValueMarshalCtx context;
- context.recursion_depth = 0;
- context.gconnection = DBUS_G_CONNECTION_FROM_CONNECTION (priv->manager->connection);
- context.proxy = proxy;
-
- types = (const GType*) gsignature->data;
- value_array = _dbus_gvalue_demarshal_message (&context, message,
- gsignature->len, types, NULL);
- }
-
- if (value_array == NULL)
- return;
-
- g_value_array_prepend (value_array, NULL);
- g_value_init (g_value_array_get_nth (value_array, 0), G_TYPE_FROM_INSTANCE (proxy));
- g_value_set_instance (g_value_array_get_nth (value_array, 0), proxy);
-
- g_cclosure_marshal_generic (closure, return_value, value_array->n_values,
- value_array->values, invocation_hint, marshal_data);
-
- g_value_array_free (value_array);
-}
-
-static void
-dbus_g_proxy_emit_remote_signal (DBusGProxy *proxy,
- DBusMessage *message)
-{
- const char *interface;
- const char *signal;
- char *name;
- GQuark q;
- DBusGProxyPrivate *priv = DBUS_G_PROXY_GET_PRIVATE(proxy);
- GArray *msg_gsignature = NULL;
-
- g_return_if_fail (!DBUS_G_PROXY_DESTROYED (proxy));
-
- interface = dbus_message_get_interface (message);
- signal = dbus_message_get_member (message);
-
- g_assert (interface != NULL);
- g_assert (signal != NULL);
-
- name = create_signal_name (interface, signal);
-
- /* If the quark isn't preexisting, there's no way there
- * are any handlers connected. We don't want to create
- * extra quarks for every possible signal.
- */
- q = g_quark_try_string (name);
-
- if (q != 0)
- {
- GArray *gsignature;
- guint i;
-
- gsignature = g_datalist_id_get_data (&priv->signal_signatures, q);
- if (gsignature == NULL)
- goto out;
-
- msg_gsignature = _dbus_gtypes_from_arg_signature (dbus_message_get_signature (message),
- TRUE);
- for (i = 0; i < gsignature->len; i++)
- {
- if (msg_gsignature->len == i
- || g_array_index (gsignature, GType, i) != g_array_index (msg_gsignature, GType, i))
- goto mismatch;
- }
- if (msg_gsignature->len != i)
- goto mismatch;
-
- g_signal_emit (proxy,
- signals[RECEIVED],
- q,
- message,
- msg_gsignature);
- }
-
- out:
- g_free (name);
- if (msg_gsignature)
- g_array_free (msg_gsignature, TRUE);
- return;
- mismatch:
-#if 0
- /* Don't spew on remote errors */
- g_warning ("Unexpected message signature '%s' for signal '%s'\n",
- dbus_message_get_signature (message),
- name);
-#endif
- goto out;
-}
-
-/**
- * DBusGProxyCallNotify:
- * @proxy: the proxy on which the method was called
- * @call_id: the call in progress
- * @user_data: data passed to dbus_g_proxy_begin_call() or similar
- *
- * Called when a reply to the call represented by @call_id arrives.
- * Use dbus_g_proxy_end_call() to see whether @call_id succeeded or
- * failed, and get the arguments returned (if any) on success.
- *
- * Deprecated: New code should use GDBus instead. The closest equivalent
- * is the standard #GAsyncReadyCallback mechanism.
- */
-
-typedef struct
-{
- DBusGProxy *proxy;
- guint call_id;
- DBusGProxyCallNotify func;
- void *data;
- GDestroyNotify free_data_func;
-} GPendingNotifyClosure;
-
-static void
-d_pending_call_notify (DBusPendingCall *dcall,
- void *data)
-{
- GPendingNotifyClosure *closure = data;
-
- (* closure->func) (closure->proxy, DBUS_G_PROXY_ID_TO_CALL (closure->call_id), closure->data);
-}
-
-static void
-d_pending_call_free (void *data)
-{
- GPendingNotifyClosure *closure = data;
-
- if (closure->free_data_func)
- (* closure->free_data_func) (closure->data);
-
- g_free (closure);
-}
-
-#define DBUS_G_VALUE_ARRAY_COLLECT_ALL(VALARRAY, FIRST_ARG_TYPE, ARGS) \
-G_STMT_START { \
- GType valtype; \
- guint i = 0; \
- \
- VALARRAY = g_value_array_new (6); \
- valtype = FIRST_ARG_TYPE; \
- \
- while (valtype != G_TYPE_INVALID) \
- { \
- gchar *collect_err; \
- GValue *val; \
- \
- g_value_array_append (VALARRAY, NULL); \
- val = g_value_array_get_nth (VALARRAY, i); \
- g_value_init (val, valtype); \
- collect_err = NULL; \
- G_VALUE_COLLECT (val, ARGS, G_VALUE_NOCOPY_CONTENTS, &collect_err); \
- \
- if (collect_err) \
- { \
- g_critical ("%s: unable to collect argument %u: %s", \
- G_STRFUNC, i, collect_err); \
- g_free (collect_err); \
- g_value_array_free (VALARRAY); \
- VALARRAY = NULL; \
- break; \
- } \
- \
- valtype = va_arg (ARGS, GType); \
- i++; \
- } \
-} G_STMT_END
-
-DBusGProxyCall *
-manager_begin_bus_call (DBusGProxyManager *manager,
- const char *method,
- DBusGProxyCallNotify notify,
- gpointer user_data,
- GDestroyNotify destroy,
- GType first_arg_type,
- ...)
-{
- guint call_id = 0;
- DBusGProxyPrivate *priv;
- va_list args;
- GValueArray *arg_values;
-
- va_start (args, first_arg_type);
-
- if (!manager->bus_proxy)
- {
- manager->bus_proxy = g_object_new (DBUS_TYPE_G_PROXY,
- "name", DBUS_SERVICE_DBUS,
- "path", DBUS_PATH_DBUS,
- "interface", DBUS_INTERFACE_DBUS,
- NULL);
- priv = DBUS_G_PROXY_GET_PRIVATE(manager->bus_proxy);
- priv->manager = manager;
- }
-
- DBUS_G_VALUE_ARRAY_COLLECT_ALL (arg_values, first_arg_type, args);
-
- if (arg_values != NULL)
- {
- call_id = dbus_g_proxy_begin_call_internal (manager->bus_proxy, method,
- notify, user_data, destroy, arg_values, -1);
-
- g_value_array_free (arg_values);
- }
-
- va_end (args);
-
- return DBUS_G_PROXY_ID_TO_CALL (call_id);
-}
-
-/**
- * SECTION:dbus-gproxy
- * @title: DBusGProxy
- * @short_description: DBus Proxy
- * @see_also: #DBusGProxy
- * @stability: Stable
- *
- * A #DBusGProxy is a #GObject representing a remote object in a D-Bus
- * service.
- */
-
-/**
- * DBusGProxy:
- *
- * A #GObject representing a remote object in a D-Bus service.
- *
- * Deprecated: New code should use GDBus instead. The closest equivalent
- * is #GDBusProxy.
- */
-
-/**
- * DBusGProxyCall:
- *
- * An opaque pointer representing an asynchronous call in progress.
- *
- * Deprecated: New code should use GDBus instead. There is no direct
- * equivalent in GDBus, but the standard #GCancellable mechanism is
- * analogous.
- */
-
-/*
- * dbus_g_proxy_get_type:
- * Standard GObject get_type() function for DBusGProxy.
- *
- * Returns: type ID for DBusGProxy class
- */
-GType
-dbus_g_proxy_get_type (void)
-{
- static GType object_type = 0;
-
- if (!object_type)
- {
- static const GTypeInfo object_info =
- {
- sizeof (DBusGProxyClass),
- (GBaseInitFunc) NULL,
- (GBaseFinalizeFunc) NULL,
- (GClassInitFunc) dbus_g_proxy_class_init,
- NULL, /* class_finalize */
- NULL, /* class_data */
- sizeof (DBusGProxy),
- 0, /* n_preallocs */
- (GInstanceInitFunc) dbus_g_proxy_init,
- };
-
- object_type = g_type_register_static (G_TYPE_OBJECT,
- "DBusGProxy",
- &object_info, 0);
- }
-
- return object_type;
-}
-
-static DBusGProxy*
-dbus_g_proxy_new (DBusGConnection *connection,
- const char *name,
- const char *path_name,
- const char *interface_name)
-{
- DBusGProxy *proxy;
-
- g_assert (connection != NULL);
-
- proxy = g_object_new (DBUS_TYPE_G_PROXY,
- "name", name,
- "path", path_name,
- "interface", interface_name,
- "connection", connection, NULL);
-
- return proxy;
-}
-
-/**
- * dbus_g_proxy_new_for_name:
- * @connection: the connection to the remote bus
- * @name: any name on the message bus
- * @path: name of the object instance to call methods on
- * @iface: name of the interface to call methods on
- *
- * Creates a new proxy for a remote interface exported by a connection
- * on a message bus. Method calls and signal connections over this
- * proxy will go to the name owner; the name's owner is expected to
- * support the given interface name. THE NAME OWNER MAY CHANGE OVER
- * TIME, for example between two different method calls, unless the
- * name is a unique name. If you need a fixed owner, you need to
- * request the current owner and bind a proxy to its unique name
- * rather than to the generic name; see
- * dbus_g_proxy_new_for_name_owner().
- *
- * A name-associated proxy only makes sense with a message bus, not
- * for app-to-app direct dbus connections.
- *
- * This proxy will only emit the "destroy" signal if the
- * #DBusConnection is disconnected, the proxy has no remaining
- * references, or the name is a unique name and its owner
- * disappears. If a well-known name changes owner, the proxy will
- * still be alive.
- *
- * Returns: new proxy object
- *
- * Deprecated: New code should use GDBus instead. The closest equivalent
- * is g_dbus_proxy_new_sync().
- */
-DBusGProxy*
-dbus_g_proxy_new_for_name (DBusGConnection *connection,
- const char *name,
- const char *path,
- const char *iface)
-{
- g_return_val_if_fail (connection != NULL, NULL);
- g_return_val_if_fail (g_dbus_is_name (name), NULL);
- g_return_val_if_fail (g_variant_is_object_path (path), NULL);
- g_return_val_if_fail (g_dbus_is_interface_name (iface), NULL);
-
- return dbus_g_proxy_new (connection, name, path, iface);
-}
-
-/**
- * dbus_g_proxy_new_for_name_owner:
- * @connection: the connection to the remote bus
- * @name: any name on the message bus
- * @path: name of the object inside the service to call methods on
- * @iface: name of the interface to call methods on
- * @error: return location for an error
- *
- * Similar to dbus_g_proxy_new_for_name(), but makes a round-trip
- * request to the message bus to get the current name owner, then
- * binds the proxy to the unique name of the current owner, rather
- * than to the well-known name. As a result, the name owner will
- * not change over time, and the proxy will emit the "destroy" signal
- * when the owner disappears from the message bus.
- *
- * An example of the difference between dbus_g_proxy_new_for_name()
- * and dbus_g_proxy_new_for_name_owner(): if you provide the well-known name
- * "org.freedesktop.Database" dbus_g_proxy_new_for_name() remains bound
- * to that name as it changes owner. dbus_g_proxy_new_for_name_owner()
- * will fail if the name has no owner. If the name has an owner,
- * dbus_g_proxy_new_for_name_owner() will bind to the unique name
- * of that owner rather than the generic name.
- *
- * Returns: new proxy object, or %NULL on error
- *
- * Deprecated: New code should use GDBus instead. The closest equivalent
- * is g_dbus_proxy_new_sync() with the name owner's unique name
- * passed as @name.
- */
-DBusGProxy*
-dbus_g_proxy_new_for_name_owner (DBusGConnection *connection,
- const char *name,
- const char *path,
- const char *iface,
- GError **error)
-{
- DBusGProxy *proxy;
- char *unique_name;
-
- g_return_val_if_fail (connection != NULL, NULL);
- g_return_val_if_fail (g_dbus_is_name (name), NULL);
- g_return_val_if_fail (g_variant_is_object_path (path), NULL);
- g_return_val_if_fail (g_dbus_is_interface_name (iface), NULL);
-
- if (!(unique_name = get_name_owner (DBUS_CONNECTION_FROM_G_CONNECTION (connection), name, error)))
- return NULL;
-
- proxy = dbus_g_proxy_new (connection, unique_name, path, iface);
- g_free (unique_name);
- return proxy;
-}
-
-/**
- * dbus_g_proxy_new_from_proxy:
- * @proxy: the proxy to use as a template
- * @iface: name of the interface to call methods on
- * @path: of the object inside the peer to call methods on
- *
- * Creates a proxy using an existing proxy as a template, substituting
- * the specified interface and path. Either or both may be NULL.
- *
- * Returns: new proxy object
- *
- * Deprecated: New code should use GDBus instead. The closest equivalent
- * is g_dbus_proxy_new_sync().
- */
-DBusGProxy*
-dbus_g_proxy_new_from_proxy (DBusGProxy *proxy,
- const char *iface,
- const char *path)
-{
- DBusGProxyPrivate *priv;
-
- g_return_val_if_fail (DBUS_IS_G_PROXY (proxy), NULL);
- g_return_val_if_fail (path == NULL || g_variant_is_object_path (path), NULL);
- g_return_val_if_fail (iface == NULL ||
- g_dbus_is_interface_name (iface), NULL);
-
- priv = DBUS_G_PROXY_GET_PRIVATE(proxy);
-
- if (iface == NULL)
- iface = priv->interface;
- if (path == NULL)
- path = priv->path;
-
- return dbus_g_proxy_new (DBUS_G_CONNECTION_FROM_CONNECTION (priv->manager->connection),
- priv->name,
- path, iface);
-}
-
-/**
- * dbus_g_proxy_new_for_peer:
- * @connection: the connection to the peer
- * @path: name of the object inside the peer to call methods on
- * @iface: name of the interface to call methods on
- *
- * Creates a proxy for an object in peer application (one
- * we're directly connected to). That is, this function is
- * intended for use when there's no message bus involved,
- * we're doing a simple 1-to-1 communication between two
- * applications.
- *
- * Returns: new proxy object
- *
- * Deprecated: New code should use GDBus instead. The closest equivalent
- * is g_dbus_proxy_new_sync().
- */
-DBusGProxy*
-dbus_g_proxy_new_for_peer (DBusGConnection *connection,
- const char *path,
- const char *iface)
-{
- DBusGProxy *proxy;
-
- g_return_val_if_fail (connection != NULL, NULL);
- g_return_val_if_fail (g_variant_is_object_path (path), NULL);
- g_return_val_if_fail (g_dbus_is_interface_name (iface), NULL);
-
- proxy = dbus_g_proxy_new (connection, NULL, path, iface);
-
- return proxy;
-}
-
-/**
- * dbus_g_proxy_get_bus_name:
- * @proxy: the proxy
- *
- * Gets the bus name a proxy is bound to (may be %NULL in some cases).
- * If you created the proxy with dbus_g_proxy_new_for_name(), then
- * the name you passed to that will be returned.
- * If you created it with dbus_g_proxy_new_for_name_owner(), then the
- * unique connection name will be returned. If you created it
- * with dbus_g_proxy_new_for_peer() then %NULL will be returned.
- *
- * It is an error to call this method on a proxy that has emitted
- * the #DBusGProxy::destroy signal.
- *
- * Returns: the bus name the proxy sends messages to
- *
- * Deprecated: New code should use GDBus instead. The closest equivalent
- * is g_dbus_proxy_get_name() or g_dbus_proxy_get_name_owner(),
- * depending how the proxy was created.
- */
-const char*
-dbus_g_proxy_get_bus_name (DBusGProxy *proxy)
-{
- DBusGProxyPrivate *priv;
-
- g_return_val_if_fail (DBUS_IS_G_PROXY (proxy), NULL);
- g_return_val_if_fail (!DBUS_G_PROXY_DESTROYED (proxy), NULL);
-
- priv = DBUS_G_PROXY_GET_PRIVATE(proxy);
-
- return priv->name;
-}
-
-/**
- * dbus_g_proxy_get_interface:
- * @proxy: the proxy
- *
- * Gets the object interface proxy is bound to (may be %NULL in some cases).
- *
- * It is an error to call this method on a proxy that has emitted
- * the #DBusGProxy::destroy signal.
- *
- * Returns: an object interface
- *
- * Deprecated: New code should use GDBus instead. The closest equivalent
- * is g_dbus_proxy_get_interface_name().
- */
-const char*
-dbus_g_proxy_get_interface (DBusGProxy *proxy)
-{
- DBusGProxyPrivate *priv;
-
- g_return_val_if_fail (DBUS_IS_G_PROXY (proxy), NULL);
- g_return_val_if_fail (!DBUS_G_PROXY_DESTROYED (proxy), NULL);
-
- priv = DBUS_G_PROXY_GET_PRIVATE(proxy);
-
- return priv->interface;
-}
-
-/**
- * dbus_g_proxy_set_interface:
- * @proxy: the proxy
- * @interface_name: an object interface
- *
- * Sets the object interface proxy is bound to
- *
- * It is an error to call this method on a proxy that has emitted
- * the #DBusGProxy::destroy signal.
- *
- * Deprecated: New code should use GDBus instead. There is no
- * direct equivalent for this function: construct a new proxy instead.
- */
-void
-dbus_g_proxy_set_interface (DBusGProxy *proxy,
- const char *interface_name)
-{
- DBusGProxyPrivate *priv = DBUS_G_PROXY_GET_PRIVATE(proxy);
-
- g_return_if_fail (DBUS_IS_G_PROXY (proxy));
- g_return_if_fail (!DBUS_G_PROXY_DESTROYED (proxy));
- g_return_if_fail (g_dbus_is_interface_name (interface_name));
-
- /* FIXME - need to unregister when we switch interface for now
- * later should support idea of unset interface
- */
- dbus_g_proxy_manager_unregister (priv->manager, proxy);
- g_free (priv->interface);
- priv->interface = g_strdup (interface_name);
- dbus_g_proxy_manager_register (priv->manager, proxy);
-}
-
-/**
- * dbus_g_proxy_get_path:
- * @proxy: the proxy
- *
- * Gets the path this proxy is bound to
- *
- * It is an error to call this method on a proxy that has emitted
- * the #DBusGProxy::destroy signal.
- *
- * Returns: an object path
- *
- * Deprecated: New code should use GDBus instead. The closest equivalent
- * is g_dbus_proxy_get_object_path().
- */
-const char*
-dbus_g_proxy_get_path (DBusGProxy *proxy)
-{
- DBusGProxyPrivate *priv;
-
- g_return_val_if_fail (DBUS_IS_G_PROXY (proxy), NULL);
- g_return_val_if_fail (!DBUS_G_PROXY_DESTROYED (proxy), NULL);
-
- priv = DBUS_G_PROXY_GET_PRIVATE(proxy);
-
- return priv->path;
-}
-
-static DBusMessage *
-dbus_g_proxy_marshal_args_to_message (DBusGProxy *proxy,
- const char *method,
- GValueArray *args)
-{
- DBusMessage *message;
- DBusMessageIter msgiter;
- guint i;
- DBusGProxyPrivate *priv = DBUS_G_PROXY_GET_PRIVATE(proxy);
-
- message = dbus_message_new_method_call (priv->name,
- priv->path,
- priv->interface,
- method);
- if (message == NULL)
- return NULL;
-
- dbus_message_iter_init_append (message, &msgiter);
- for (i = 0; i < args->n_values; i++)
- {
- GValue *gvalue;
-
- gvalue = g_value_array_get_nth (args, i);
-
- if (!_dbus_gvalue_marshal (&msgiter, gvalue))
- {
- /* This is a programming error by the caller, most likely */
- gchar *contents = g_strdup_value_contents (gvalue);
-
- g_critical ("Could not marshal argument %u for %s: type %s, value %s",
- i, method, G_VALUE_TYPE_NAME (gvalue), contents);
- g_free (contents);
- dbus_message_unref (message);
- return NULL;
- }
- }
-
- return message;
-}
-
-static guint
-dbus_g_proxy_begin_call_internal (DBusGProxy *proxy,
- const char *method,
- DBusGProxyCallNotify notify,
- gpointer user_data,
- GDestroyNotify destroy,
- GValueArray *args,
- int timeout)
-{
- DBusMessage *message;
- DBusPendingCall *pending;
- GPendingNotifyClosure *closure;
- guint call_id;
- DBusGProxyPrivate *priv = DBUS_G_PROXY_GET_PRIVATE(proxy);
-
- pending = NULL;
-
- message = dbus_g_proxy_marshal_args_to_message (proxy, method, args);
-
- /* can only happen on a programming error or OOM; we already critical'd */
- if (!message)
- return 0;
-
- if (!dbus_connection_send_with_reply (priv->manager->connection,
- message,
- &pending,
- timeout))
- oom ();
-
- dbus_message_unref (message);
-
- /* If we got a NULL pending, that means the connection was disconnected,
- * and we need to abort this call.
- * https://bugs.freedesktop.org/show_bug.cgi?id=12675
- */
- if (pending == NULL)
- return 0;
-
- call_id = ++priv->call_id_counter;
-
- if (notify != NULL)
- {
- closure = g_new (GPendingNotifyClosure, 1);
- closure->proxy = proxy; /* No need to ref as the lifecycle is tied to proxy */
- closure->call_id = call_id;
- closure->func = notify;
- closure->data = user_data;
- closure->free_data_func = destroy;
- dbus_pending_call_set_notify (pending, d_pending_call_notify,
- closure,
- d_pending_call_free);
- }
-
- g_hash_table_insert (priv->pending_calls, GUINT_TO_POINTER (call_id), pending);
-
- return call_id;
-}
-
-static gboolean
-dbus_g_proxy_end_call_internal (DBusGProxy *proxy,
- guint call_id,
- GError **error,
- GType first_arg_type,
- va_list args)
-{
- DBusMessage *reply;
- DBusMessageIter msgiter;
- DBusError derror;
- va_list args_unwind;
- guint over;
- int n_retvals_processed;
- gboolean ret;
- GType valtype;
- DBusPendingCall *pending;
- DBusGProxyPrivate *priv = DBUS_G_PROXY_GET_PRIVATE(proxy);
-
- if (call_id == 0)
- {
- /* Being disconnected is the only reason this can happen, except
- * for programmer error; if it was programmer error, we already
- * emitted a critical warning. */
- g_set_error (error, DBUS_GERROR, DBUS_GERROR_DISCONNECTED,
- "Disconnected from D-Bus (or argument error during call)");
- return FALSE;
- }
-
- reply = NULL;
- ret = FALSE;
- n_retvals_processed = 0;
- over = 0;
-
- /* Keep around a copy of output arguments so we can free on error. */
- G_VA_COPY(args_unwind, args);
-
- pending = g_hash_table_lookup (priv->pending_calls, GUINT_TO_POINTER (call_id));
-
- dbus_pending_call_block (pending);
- reply = dbus_pending_call_steal_reply (pending);
-
- g_assert (reply != NULL);
-
- dbus_error_init (&derror);
-
- switch (dbus_message_get_type (reply))
- {
- case DBUS_MESSAGE_TYPE_METHOD_RETURN:
- dbus_message_iter_init (reply, &msgiter);
- valtype = first_arg_type;
- while (valtype != G_TYPE_INVALID)
- {
- int arg_type;
- gpointer return_storage;
- GValue gvalue = { 0, };
- DBusGValueMarshalCtx context;
-
- context.recursion_depth = 0;
- context.gconnection = DBUS_G_CONNECTION_FROM_CONNECTION (priv->manager->connection);
- context.proxy = proxy;
-
- arg_type = dbus_message_iter_get_arg_type (&msgiter);
- if (arg_type == DBUS_TYPE_INVALID)
- {
- g_set_error (error, DBUS_GERROR,
- DBUS_GERROR_INVALID_ARGS,
- "Too few arguments in reply");
- goto out;
- }
-
- return_storage = va_arg (args, gpointer);
- if (return_storage == NULL)
- goto next;
-
- /* We handle variants specially; the caller is expected
- * to have already allocated storage for them.
- */
- if (arg_type == DBUS_TYPE_VARIANT
- && g_type_is_a (valtype, G_TYPE_VALUE))
- {
- if (!_dbus_gvalue_demarshal_variant (&context, &msgiter, (GValue*) return_storage, NULL))
- {
- g_set_error (error,
- DBUS_GERROR,
- DBUS_GERROR_INVALID_ARGS,
- "Couldn't convert argument, expected \"%s\"",
- g_type_name (valtype));
- goto out;
- }
- }
- else
- {
- g_value_init (&gvalue, valtype);
-
- if (!_dbus_gvalue_demarshal (&context, &msgiter, &gvalue, error))
- goto out;
-
- /* Anything that can be demarshaled must be storable */
- if (!_dbus_gvalue_store (&gvalue, return_storage))
- g_assert_not_reached ();
- /* Ownership of the value passes to the client, don't unset */
- }
-
- next:
- n_retvals_processed++;
- dbus_message_iter_next (&msgiter);
- valtype = va_arg (args, GType);
- }
-
- while (dbus_message_iter_get_arg_type (&msgiter) != DBUS_TYPE_INVALID)
- {
- over++;
- dbus_message_iter_next (&msgiter);
- }
-
- if (over > 0)
- {
- g_set_error (error, DBUS_GERROR,
- DBUS_GERROR_INVALID_ARGS,
- "Too many arguments in reply; expected %d, got %d",
- n_retvals_processed, over);
- goto out;
- }
- break;
- case DBUS_MESSAGE_TYPE_ERROR:
- dbus_set_error_from_message (&derror, reply);
- dbus_set_g_error (error, &derror);
- dbus_error_free (&derror);
- goto out;
- break;
- default:
- dbus_set_error (&derror, DBUS_ERROR_FAILED,
- "Reply was neither a method return nor an exception");
- dbus_set_g_error (error, &derror);
- dbus_error_free (&derror);
- goto out;
- break;
- }
-
- ret = TRUE;
- out:
- if (ret == FALSE)
- {
- int i;
-
- valtype = first_arg_type;
- for (i = 0; i < n_retvals_processed; i++)
- {
- GValue value = {0,};
- gpointer retval;
-
- g_value_init (&value, valtype);
-
- retval = va_arg (args_unwind, gpointer);
- if (retval == NULL)
- {
- i--;
- continue;
- }
-
- _dbus_gvalue_take (&value, retval);
- g_value_unset (&value);
-
- valtype = va_arg (args_unwind, GType);
- }
- }
- va_end (args_unwind);
- va_end (args);
-
- g_hash_table_remove (priv->pending_calls, GUINT_TO_POINTER (call_id));
-
- if (reply)
- dbus_message_unref (reply);
- return ret;
-}
-
-/**
- * dbus_g_proxy_begin_call:
- * @proxy: a proxy for a remote interface
- * @method: the name of the method to invoke
- * @notify: callback to be invoked when method returns
- * @user_data: user data passed to callback
- * @destroy: function called to destroy user_data
- * @first_arg_type: type of the first argument, or %G_TYPE_INVALID if there
- * are no arguments
- * @...: first argument, followed by any further type/value pairs, followed
- * by %G_TYPE_INVALID
- *
- * Asynchronously invokes a method on a remote interface. The method
- * call will not be sent over the wire until the application returns
- * to the main loop, or blocks in dbus_g_connection_flush() to write out
- * pending data. The call will be completed after a timeout, or when
- * a reply is received. When the call returns, the callback specified
- * will be invoked; you can then collect the results of the call
- * (which may be an error, or a reply), use dbus_g_proxy_end_call().
- *
- * It is an error to call this method on a proxy that has emitted
- * the #DBusGProxy::destroy signal.
- *
- * TODO this particular function shouldn't die on out of memory,
- * since you should be able to do a call with large arguments.
- *
- * Returns: call identifier.
- *
- * Deprecated: New code should use GDBus instead. The closest equivalent
- * is g_dbus_proxy_call().
- */
-DBusGProxyCall *
-dbus_g_proxy_begin_call (DBusGProxy *proxy,
- const char *method,
- DBusGProxyCallNotify notify,
- gpointer user_data,
- GDestroyNotify destroy,
- GType first_arg_type,
- ...)
-{
- guint call_id = 0;
- va_list args;
- GValueArray *arg_values;
- DBusGProxyPrivate *priv = DBUS_G_PROXY_GET_PRIVATE(proxy);
-
- g_return_val_if_fail (DBUS_IS_G_PROXY (proxy), NULL);
- g_return_val_if_fail (!DBUS_G_PROXY_DESTROYED (proxy), NULL);
- g_return_val_if_fail (g_dbus_is_member_name (method), NULL);
-
- va_start (args, first_arg_type);
-
- DBUS_G_VALUE_ARRAY_COLLECT_ALL (arg_values, first_arg_type, args);
-
- if (arg_values != NULL)
- {
- call_id = dbus_g_proxy_begin_call_internal (proxy, method, notify,
- user_data, destroy, arg_values, priv->default_timeout);
-
- g_value_array_free (arg_values);
- }
-
- va_end (args);
-
- return DBUS_G_PROXY_ID_TO_CALL (call_id);
-}
-
-/**
- * dbus_g_proxy_begin_call_with_timeout:
- * @proxy: a proxy for a remote interface
- * @method: the name of the method to invoke
- * @notify: callback to be invoked when method returns
- * @user_data: user data passed to callback
- * @destroy: function called to destroy user_data
- * @timeout: the timeout in milliseconds, or -1 to use a default
- * @first_arg_type: type of the first argument, or %G_TYPE_INVALID if there
- * are no arguments
- * @...: first argument, followed by any further type/value pairs, followed
- * by %G_TYPE_INVALID
- *
- * Asynchronously invokes a method on a remote interface. The method
- * call will not be sent over the wire until the application returns
- * to the main loop, or blocks in dbus_g_connection_flush() to write out
- * pending data. The call will be completed after a timeout, or when
- * a reply is received. When the call returns, the callback specified
- * will be invoked; you can then collect the results of the call
- * (which may be an error, or a reply), use dbus_g_proxy_end_call().
- *
- * It is an error to call this method on a proxy that has emitted
- * the #DBusGProxy::destroy signal.
- *
- * TODO this particular function shouldn't die on out of memory,
- * since you should be able to do a call with large arguments.
- *
- * Returns: call identifier.
- *
- * Deprecated: New code should use GDBus instead. The closest equivalent
- * is g_dbus_proxy_call().
- */
-DBusGProxyCall *
-dbus_g_proxy_begin_call_with_timeout (DBusGProxy *proxy,
- const char *method,
- DBusGProxyCallNotify notify,
- gpointer user_data,
- GDestroyNotify destroy,
- int timeout,
- GType first_arg_type,
- ...)
-{
- guint call_id = 0;
- va_list args;
- GValueArray *arg_values;
-
- g_return_val_if_fail (DBUS_IS_G_PROXY (proxy), NULL);
- g_return_val_if_fail (!DBUS_G_PROXY_DESTROYED (proxy), NULL);
- g_return_val_if_fail (g_dbus_is_member_name (method), NULL);
- g_return_val_if_fail (timeout >= 0 || timeout == -1, NULL);
-
- va_start (args, first_arg_type);
-
- DBUS_G_VALUE_ARRAY_COLLECT_ALL (arg_values, first_arg_type, args);
-
- if (arg_values != NULL)
- {
- call_id = dbus_g_proxy_begin_call_internal (proxy, method, notify,
- user_data, destroy, arg_values, timeout);
-
- g_value_array_free (arg_values);
- }
-
- va_end (args);
-
- return DBUS_G_PROXY_ID_TO_CALL (call_id);
-}
-
-/**
- * dbus_g_proxy_end_call:
- * @proxy: a proxy for a remote interface
- * @call: the pending call ID from dbus_g_proxy_begin_call()
- * @error: return location for an error
- * @first_arg_type: type of first "out" argument, or %G_TYPE_INVALID if
- * there are no "out" arguments
- * @...: return location for first "out" argument, followed by any further
- * type/location pairs, followed by %G_TYPE_INVALID
- *
- * Collects the results of a method call. The method call was normally
- * initiated with dbus_g_proxy_end_call(). You may use this function
- * outside of the callback given to dbus_g_proxy_begin_call; in that
- * case this function will block if the results haven't yet been
- * received.
- *
- * All D-Bus method calls can fail with a remote error. If this occurs,
- * the @error will be set and this function will return %FALSE.
- *
- * Otherwise, the "out" parameters and return value of the
- * method are stored in the provided varargs list.
- * The list should be terminated with G_TYPE_INVALID.
- *
- * Returns: %TRUE on success
- *
- * Deprecated: New code should use GDBus instead. The closest equivalent
- * is g_dbus_proxy_call_finish().
- */
-gboolean
-dbus_g_proxy_end_call (DBusGProxy *proxy,
- DBusGProxyCall *call,
- GError **error,
- GType first_arg_type,
- ...)
-{
- gboolean ret;
- va_list args;
-
- g_return_val_if_fail (DBUS_IS_G_PROXY (proxy), FALSE);
-
- va_start (args, first_arg_type);
-
- ret = dbus_g_proxy_end_call_internal (proxy, GPOINTER_TO_UINT (call), error, first_arg_type, args);
-
- va_end (args);
-
- return ret;
-}
-
-/**
- * dbus_g_proxy_call:
- * @proxy: a proxy for a remote interface
- * @method: method to invoke
- * @error: return location for an error
- * @first_arg_type: type of first "in" argument, or %G_TYPE_INVALID if none
- * @...: value of first "in" argument, any further type/value pairs,
- * %G_TYPE_INVALID, type/location pairs for "out" arguments,
- * and %G_TYPE_INVALID again
- *
- * Function for synchronously invoking a method and receiving reply
- * values. This function is equivalent to dbus_g_proxy_begin_call
- * followed by dbus_g_proxy_end_call. All of the input arguments are
- * specified first, followed by G_TYPE_INVALID, followed by all of the
- * output values, followed by a second G_TYPE_INVALID. Note that
- * this means you must always specify G_TYPE_INVALID twice.
- *
- * It is an error to call this method on a proxy that has emitted
- * the #DBusGProxy::destroy signal.
- *
- * Returns: %TRUE if the method succeeds, %FALSE if it fails
- *
- * Deprecated: New code should use GDBus instead. The closest equivalent
- * is g_dbus_proxy_call_sync().
- */
-gboolean
-dbus_g_proxy_call (DBusGProxy *proxy,
- const char *method,
- GError **error,
- GType first_arg_type,
- ...)
-{
- gboolean ret;
- guint call_id = 0;
- va_list args;
- GValueArray *in_args;
- DBusGProxyPrivate *priv;
-
- g_return_val_if_fail (DBUS_IS_G_PROXY (proxy), FALSE);
- g_return_val_if_fail (!DBUS_G_PROXY_DESTROYED (proxy), FALSE);
-
- priv = DBUS_G_PROXY_GET_PRIVATE(proxy);
-
- va_start (args, first_arg_type);
-
- DBUS_G_VALUE_ARRAY_COLLECT_ALL (in_args, first_arg_type, args);
-
- if (in_args != NULL)
- {
- call_id = dbus_g_proxy_begin_call_internal (proxy, method, NULL, NULL,
- NULL, in_args, priv->default_timeout);
-
- g_value_array_free (in_args);
- }
-
- first_arg_type = va_arg (args, GType);
- ret = dbus_g_proxy_end_call_internal (proxy, call_id, error, first_arg_type,
- args);
-
- va_end (args);
-
- return ret;
-}
-
-/**
- * dbus_g_proxy_call_with_timeout:
- * @proxy: a proxy for a remote interface
- * @method: method to invoke
- * @timeout: the timeout in milliseconds, or -1 to use a default
- * @error: return location for an error
- * @first_arg_type: type of first "in" argument
- * @...: as for dbus_g_proxy_call()
- *
- * Function for synchronously invoking a method and receiving reply
- * values. This function is equivalent to dbus_g_proxy_begin_call
- * followed by dbus_g_proxy_end_call. All of the input arguments are
- * specified first, followed by G_TYPE_INVALID, followed by all of the
- * output values, followed by a second G_TYPE_INVALID. Note that
- * this means you must always specify G_TYPE_INVALID twice.
- *
- * It is an error to call this method on a proxy that has emitted
- * the #DBusGProxy::destroy signal.
- *
- * Returns: %TRUE if the method succeeds, %FALSE if it fails
- *
- * Deprecated: New code should use GDBus instead. The closest equivalent
- * is g_dbus_proxy_call_sync().
- */
-gboolean
-dbus_g_proxy_call_with_timeout (DBusGProxy *proxy,
- const char *method,
- int timeout,
- GError **error,
- GType first_arg_type,
- ...)
-{
- gboolean ret;
- guint call_id = 0;
- va_list args;
- GValueArray *in_args;
-
- g_return_val_if_fail (DBUS_IS_G_PROXY (proxy), FALSE);
- g_return_val_if_fail (!DBUS_G_PROXY_DESTROYED (proxy), FALSE);
- g_return_val_if_fail (g_dbus_is_member_name (method), FALSE);
- g_return_val_if_fail (timeout >= 0 || timeout == -1, FALSE);
-
- va_start (args, first_arg_type);
-
- DBUS_G_VALUE_ARRAY_COLLECT_ALL (in_args, first_arg_type, args);
-
- if (in_args != NULL)
- {
- call_id = dbus_g_proxy_begin_call_internal (proxy, method, NULL, NULL,
- NULL, in_args, timeout);
-
- g_value_array_free (in_args);
- }
-
- first_arg_type = va_arg (args, GType);
- ret = dbus_g_proxy_end_call_internal (proxy, call_id, error,
- first_arg_type, args);
-
- va_end (args);
-
- return ret;
-}
-
-/**
- * dbus_g_proxy_call_no_reply:
- * @proxy: a proxy for a remote interface
- * @method: the name of the method to invoke
- * @first_arg_type: type of the first argument, or %G_TYPE_INVALID to call
- * the method without arguments
- * @...: the first argument and any remaining type/argument pairs, followed by
- * %G_TYPE_INVALID to terminate the list
- *
- * Sends a method call message as with dbus_g_proxy_begin_call(), but
- * does not ask for a reply or allow you to receive one.
- *
- * It is an error to call this method on a proxy that has emitted
- * the #DBusGProxy::destroy signal.
- *
- * TODO: this particular function shouldn't die on out of memory,
- * since you should be able to do a call with large arguments.
- *
- * Deprecated: New code should use GDBus instead. The closest equivalent
- * is g_dbus_proxy_call() with @callback = %NULL.
- */
-void
-dbus_g_proxy_call_no_reply (DBusGProxy *proxy,
- const char *method,
- GType first_arg_type,
- ...)
-{
- DBusMessage *message = NULL;
- va_list args;
- GValueArray *in_args;
- DBusGProxyPrivate *priv;
-
- g_return_if_fail (DBUS_IS_G_PROXY (proxy));
- g_return_if_fail (g_dbus_is_member_name (method));
- g_return_if_fail (!DBUS_G_PROXY_DESTROYED (proxy));
-
- priv = DBUS_G_PROXY_GET_PRIVATE(proxy);
-
- va_start (args, first_arg_type);
- DBUS_G_VALUE_ARRAY_COLLECT_ALL (in_args, first_arg_type, args);
-
- if (in_args != NULL)
- {
- message = dbus_g_proxy_marshal_args_to_message (proxy, method, in_args);
-
- g_value_array_free (in_args);
- }
-
- va_end (args);
-
- /* can only happen on a programming error or OOM; we already critical'd */
- if (!message)
- return;
-
- dbus_message_set_no_reply (message, TRUE);
-
- if (!dbus_connection_send (priv->manager->connection,
- message,
- NULL))
- oom ();
-
- dbus_message_unref (message);
-}
-
-/**
- * dbus_g_proxy_cancel_call
- * @proxy: a proxy for a remote interface
- * @call: the pending call ID from dbus_g_proxy_begin_call()
- *
- * Cancels a pending method call. The method call was normally
- * initiated with dbus_g_proxy_begin_call(). This function
- * may not be used on pending calls that have already been
- * ended with dbus_g_proxy_end_call.
- *
- * It is an error to call this method on a proxy that has emitted
- * the #DBusGProxy::destroy signal.
- *
- * Deprecated: New code should use GDBus instead. The closest equivalent
- * is g_cancellable_cancel().
- */
-void
-dbus_g_proxy_cancel_call (DBusGProxy *proxy,
- DBusGProxyCall *call)
-{
- guint call_id;
- DBusPendingCall *pending;
- DBusGProxyPrivate *priv;
-
- g_return_if_fail (DBUS_IS_G_PROXY (proxy));
- g_return_if_fail (!DBUS_G_PROXY_DESTROYED (proxy));
-
- priv = DBUS_G_PROXY_GET_PRIVATE(proxy);
-
- call_id = DBUS_G_PROXY_CALL_TO_ID (call);
-
- if (call_id == 0)
- {
- /* nothing to cancel */
- return;
- }
-
- pending = g_hash_table_lookup (priv->pending_calls, GUINT_TO_POINTER (call_id));
- g_hash_table_remove (priv->pending_calls, GUINT_TO_POINTER (call_id));
- g_return_if_fail (pending != NULL);
-
- dbus_pending_call_cancel (pending);
-}
-
-/**
- * dbus_g_proxy_send:
- * @proxy: a proxy for a remote interface
- * @message: the message to address and send
- * @client_serial: return location for message's serial, or %NULL
- *
- * Sends a message to the interface we're proxying for. Does not
- * block or wait for a reply. The message is only actually written out
- * when you return to the main loop or block in
- * dbus_g_connection_flush().
- *
- * The message is modified to be addressed to the target interface.
- * That is, a destination name field or whatever is needed will be
- * added to the message. The basic point of this function is to add
- * the necessary header fields, otherwise it's equivalent to
- * dbus_connection_send().
- *
- * This function adds a reference to the message, so the caller
- * still owns its original reference.
- *
- * It is an error to call this method on a proxy that has emitted
- * the #DBusGProxy::destroy signal.
- *
- * Deprecated: New code should use GDBus instead. The closest equivalent
- * is g_dbus_connection_send_message().
- */
-void
-dbus_g_proxy_send (DBusGProxy *proxy,
- DBusMessage *message,
- dbus_uint32_t *client_serial)
-{
- DBusGProxyPrivate *priv;
-
- g_return_if_fail (DBUS_IS_G_PROXY (proxy));
- g_return_if_fail (!DBUS_G_PROXY_DESTROYED (proxy));
-
- priv = DBUS_G_PROXY_GET_PRIVATE(proxy);
-
- if (priv->name)
- {
- if (!dbus_message_set_destination (message, priv->name))
- g_error ("Out of memory");
- }
- if (priv->path)
- {
- if (!dbus_message_set_path (message, priv->path))
- g_error ("Out of memory");
- }
- if (priv->interface)
- {
- if (!dbus_message_set_interface (message, priv->interface))
- g_error ("Out of memory");
- }
-
- if (!dbus_connection_send (priv->manager->connection, message, client_serial))
- g_error ("Out of memory\n");
-}
-
-static void
-array_free_all (gpointer array)
-{
- g_array_free (array, TRUE);
-}
-
-/**
- * dbus_g_proxy_add_signal:
- * @proxy: the proxy for a remote interface
- * @signal_name: the name of the signal
- * @first_type: the first argument type, or %G_TYPE_INVALID if none
- * @...: any subsequent argument types, followed by %G_TYPE_INVALID
- *
- * Specifies the argument signature of a D-Bus signal. When the signal is
- * emitted by the remote object, if the GTypes corresponding to its arguments'
- * types do not match the types given here, the signal will be ignored.
- *
- * It is an error to add the same @signal_name to the same @proxy more than
- * once, even if the argument types given are the same.
- *
- * It is also an error to call this method on a proxy that has emitted
- * the #DBusGProxy::destroy signal.
- *
- * Deprecated: New code should use GDBus instead.
- */
-void
-dbus_g_proxy_add_signal (DBusGProxy *proxy,
- const char *signal_name,
- GType first_type,
- ...)
-{
- GQuark q;
- char *name;
- GArray *gtypesig;
- GType gtype;
- va_list args;
- DBusGProxyPrivate *priv;
-
- g_return_if_fail (DBUS_IS_G_PROXY (proxy));
- g_return_if_fail (!DBUS_G_PROXY_DESTROYED (proxy));
- g_return_if_fail (g_dbus_is_member_name (signal_name));
-
- priv = DBUS_G_PROXY_GET_PRIVATE(proxy);
-
- name = create_signal_name (priv->interface, signal_name);
-
- q = g_quark_from_string (name);
-
- g_return_if_fail (g_datalist_id_get_data (&priv->signal_signatures, q) == NULL);
-
- gtypesig = g_array_new (FALSE, TRUE, sizeof (GType));
-
- va_start (args, first_type);
- gtype = first_type;
- while (gtype != G_TYPE_INVALID)
- {
- g_array_append_val (gtypesig, gtype);
- gtype = va_arg (args, GType);
- }
- va_end (args);
-
- g_datalist_id_set_data_full (&priv->signal_signatures,
- q, gtypesig,
- array_free_all);
-
- g_free (name);
-}
-
-/**
- * dbus_g_proxy_connect_signal:
- * @proxy: a proxy for a remote interface
- * @signal_name: the DBus signal name to listen for
- * @handler: the handler to connect
- * @data: data to pass to handler
- * @free_data_func: callback function to destroy data
- *
- * Connect a signal handler to a proxy for a remote interface. When
- * the remote interface emits the specified signal, the proxy will
- * emit a corresponding GLib signal.
- *
- * It is an error to call this method on a proxy that has emitted
- * the #DBusGProxy::destroy signal.
- *
- * Deprecated: New code should use GDBus instead. The closest equivalent
- * is g_dbus_connection_signal_subscribe().
- */
-void
-dbus_g_proxy_connect_signal (DBusGProxy *proxy,
- const char *signal_name,
- GCallback handler,
- void *data,
- GClosureNotify free_data_func)
-{
- char *name;
- GClosure *closure;
- GQuark q;
- DBusGProxyPrivate *priv;
-
- g_return_if_fail (DBUS_IS_G_PROXY (proxy));
- g_return_if_fail (!DBUS_G_PROXY_DESTROYED (proxy));
- g_return_if_fail (g_dbus_is_member_name (signal_name));
- g_return_if_fail (handler != NULL);
-
- priv = DBUS_G_PROXY_GET_PRIVATE(proxy);
- name = create_signal_name (priv->interface, signal_name);
-
- q = g_quark_try_string (name);
-
-#ifndef G_DISABLE_CHECKS
- if (q == 0 || g_datalist_id_get_data (&priv->signal_signatures, q) == NULL)
- {
- g_warning ("Must add the signal '%s' with dbus_g_proxy_add_signal() prior to connecting to it\n", name);
- g_free (name);
- return;
- }
-#endif
-
- closure = g_cclosure_new (G_CALLBACK (handler), data, free_data_func);
-
- g_signal_connect_closure_by_id (G_OBJECT (proxy),
- signals[RECEIVED],
- q,
- closure, FALSE);
-
- g_free (name);
-}
-
-/**
- * dbus_g_proxy_disconnect_signal:
- * @proxy: a proxy for a remote interface
- * @signal_name: the DBus signal name to disconnect
- * @handler: the handler to disconnect
- * @data: the data that was registered with handler
- *
- * Disconnect all signal handlers from a proxy that match the given
- * criteria.
- *
- * It is an error to call this method on a proxy that has emitted
- * the #DBusGProxy::destroy signal.
- *
- * Deprecated: New code should use GDBus instead. The closest equivalent
- * is g_dbus_connection_signal_unsubscribe().
- */
-void
-dbus_g_proxy_disconnect_signal (DBusGProxy *proxy,
- const char *signal_name,
- GCallback handler,
- void *data)
-{
- char *name;
- GQuark q;
- DBusGProxyPrivate *priv;
-
- g_return_if_fail (DBUS_IS_G_PROXY (proxy));
- g_return_if_fail (!DBUS_G_PROXY_DESTROYED (proxy));
- g_return_if_fail (g_dbus_is_member_name (signal_name));
- g_return_if_fail (handler != NULL);
-
- priv = DBUS_G_PROXY_GET_PRIVATE(proxy);
- name = create_signal_name (priv->interface, signal_name);
-
- q = g_quark_try_string (name);
-
- if (q != 0)
- {
- g_signal_handlers_disconnect_matched (G_OBJECT (proxy),
- G_SIGNAL_MATCH_DETAIL |
- G_SIGNAL_MATCH_FUNC |
- G_SIGNAL_MATCH_DATA,
- signals[RECEIVED],
- q,
- NULL,
- G_CALLBACK (handler), data);
- }
- else
- {
- g_warning ("Attempt to disconnect from signal '%s' which is not registered\n",
- name);
- }
-
- g_free (name);
-}
-
-/**
- * dbus_g_proxy_set_default_timeout:
- * @proxy: a proxy for a remote interface
- * @timeout: the timeout in milliseconds, or -1 to reset to the libdbus default
- *
- * Sets the default timeout to use for a proxy. This timeout will be
- * used in calls where the timeout is not specified, or is specified to be -1.
- * If this timeout is also set to -1, libdbus will use a reasonable default
- * value.
- *
- * This is useful for long-running operations that takes longer than
- * the default timeout (which is a on the order of magnitude of tens
- * of seconds). For some applications, consider using a pattern where
- * the method returns once the operation is underway
- * (e.g. immediately) and emits a signal when the operation terminates
- * (though beware of leaking information with/in the signal return value).
- *
- * It is an error to call this method on a proxy that has emitted
- * the #DBusGProxy::destroy signal.
- *
- * Since: 0.75
- *
- * Deprecated: New code should use GDBus instead.
- */
-void
-dbus_g_proxy_set_default_timeout (DBusGProxy *proxy,
- int timeout)
-{
- DBusGProxyPrivate *priv;
-
- g_return_if_fail (DBUS_IS_G_PROXY (proxy));
- g_return_if_fail (!DBUS_G_PROXY_DESTROYED (proxy));
- g_return_if_fail (timeout >= 0 || timeout == -1);
-
- priv = DBUS_G_PROXY_GET_PRIVATE(proxy);
- priv->default_timeout = timeout;
-}
diff --git a/dbus/dbus-gsignature.c b/dbus/dbus-gsignature.c
deleted file mode 100644
index ed0880e..0000000
--- a/dbus/dbus-gsignature.c
+++ /dev/null
@@ -1,219 +0,0 @@
-/* -*- mode: C; c-file-style: "gnu" -*- */
-/* dbus-gsignature.c Mapping from dbus type signatures to GType
- *
- * Copyright (C) 2005 Red Hat, Inc.
- *
- * Licensed under the Academic Free License version 2.1
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- */
-
-#include "config.h"
-#include "dbus-gtest.h"
-#include "dbus-gsignature.h"
-#include "dbus-gvalue-utils.h"
-#include <string.h>
-#include <glib.h>
-
-#define MAP_BASIC(d_t, g_t) \
- case DBUS_TYPE_##d_t: \
- return G_TYPE_##g_t;
-static GType
-typecode_to_gtype (int type)
-{
- switch (type)
- {
- MAP_BASIC (BOOLEAN, BOOLEAN);
- MAP_BASIC (BYTE, UCHAR);
- MAP_BASIC (INT16, INT);
- MAP_BASIC (INT32, INT);
- MAP_BASIC (UINT16, UINT);
- MAP_BASIC (UINT32, UINT);
- MAP_BASIC (INT64, INT64);
- MAP_BASIC (UINT64, UINT64);
- MAP_BASIC (DOUBLE, DOUBLE);
- MAP_BASIC (STRING, STRING);
- default:
- return G_TYPE_INVALID;
- }
-}
-#undef MAP_BASIC
-
-static gboolean
-dbus_typecode_maps_to_basic (int typecode)
-{
- return typecode_to_gtype (typecode) != G_TYPE_INVALID;
-}
-
-GType
-_dbus_gtype_from_basic_typecode (int typecode)
-{
- g_assert (dbus_type_is_basic (typecode));
- g_assert (dbus_typecode_maps_to_basic (typecode));
- return typecode_to_gtype (typecode);
-}
-
-static GType
-signature_iter_to_g_type_dict (const DBusSignatureIter *subiter, gboolean is_client)
-{
- DBusSignatureIter iter;
- GType key_gtype;
- GType value_gtype;
-
- g_assert (dbus_signature_iter_get_current_type (subiter) == DBUS_TYPE_DICT_ENTRY);
-
- dbus_signature_iter_recurse (subiter, &iter);
-
- key_gtype = _dbus_gtype_from_signature_iter (&iter, is_client);
- if (key_gtype == G_TYPE_INVALID)
- return G_TYPE_INVALID;
-
- dbus_signature_iter_next (&iter);
- value_gtype = _dbus_gtype_from_signature_iter (&iter, is_client);
- if (value_gtype == G_TYPE_INVALID)
- return G_TYPE_INVALID;
-
- if (!_dbus_gtype_is_valid_hash_key (key_gtype)
- || !_dbus_gtype_is_valid_hash_value (value_gtype))
- /* Later we need to return DBUS_TYPE_G_VALUE */
- return G_TYPE_INVALID;
-
- return dbus_g_type_get_map ("GHashTable", key_gtype, value_gtype);
-}
-
-static GType
-signature_iter_to_g_type_array (DBusSignatureIter *iter, gboolean is_client)
-{
- GType elt_gtype;
-
- elt_gtype = _dbus_gtype_from_signature_iter (iter, is_client);
- if (elt_gtype == G_TYPE_INVALID)
- return G_TYPE_INVALID;
-
- if (elt_gtype == G_TYPE_OBJECT)
- return DBUS_TYPE_G_OBJECT_ARRAY;
- if (elt_gtype == G_TYPE_STRING)
- return G_TYPE_STRV;
- if (_dbus_g_type_is_fixed (elt_gtype))
- return dbus_g_type_get_collection ("GArray", elt_gtype);
- else if (g_type_is_a (elt_gtype, G_TYPE_OBJECT)
- || g_type_is_a (elt_gtype, G_TYPE_BOXED))
- return dbus_g_type_get_collection ("GPtrArray", elt_gtype);
-
- /* Later we need to return DBUS_TYPE_G_VALUE */
- return G_TYPE_INVALID;
-}
-
-static GType
-signature_iter_to_g_type_struct (DBusSignatureIter *iter, gboolean is_client)
-{
- GArray *types;
- GType ret;
- types = g_array_new (FALSE, FALSE, sizeof (GType));
- do
- {
- GType curtype;
- curtype = _dbus_gtype_from_signature_iter (iter, is_client);
- g_array_append_val (types, curtype);
- }
- while (dbus_signature_iter_next (iter));
-
- ret = dbus_g_type_get_structv ("GValueArray", types->len, (GType*) types->data);
- g_array_free (types, TRUE);
- return ret;
-}
-
-GType
-_dbus_gtype_from_signature_iter (DBusSignatureIter *iter, gboolean is_client)
-{
- int current_type;
-
- current_type = dbus_signature_iter_get_current_type (iter);
-
- if (dbus_typecode_maps_to_basic (current_type))
- return _dbus_gtype_from_basic_typecode (current_type);
- else if (current_type == DBUS_TYPE_OBJECT_PATH)
- return DBUS_TYPE_G_OBJECT_PATH;
- else if (current_type == DBUS_TYPE_SIGNATURE)
- return DBUS_TYPE_G_SIGNATURE;
- else if (current_type == DBUS_TYPE_VARIANT ||
- current_type == DBUS_TYPE_ARRAY ||
- current_type == DBUS_TYPE_STRUCT)
- {
- DBusSignatureIter subiter;
-
- g_assert (dbus_type_is_container (current_type));
-
- if (current_type == DBUS_TYPE_VARIANT)
- return G_TYPE_VALUE;
-
- dbus_signature_iter_recurse (iter, &subiter);
-
- if (current_type == DBUS_TYPE_ARRAY)
- {
- int elt_type = dbus_signature_iter_get_current_type (&subiter);
- if (elt_type == DBUS_TYPE_DICT_ENTRY)
- return signature_iter_to_g_type_dict (&subiter, is_client);
- else
- return signature_iter_to_g_type_array (&subiter, is_client);
- }
- else if (current_type == DBUS_TYPE_STRUCT)
- {
- return signature_iter_to_g_type_struct (&subiter, is_client);
- }
- else
- {
- g_assert_not_reached ();
- return G_TYPE_INVALID;
- }
- }
- else
- {
- /* dbus-glib does not handle DBUS_TYPE_UNIX_FD or DBUS_TYPE_MAYBE */
- return G_TYPE_INVALID;
- }
-}
-
-GType
-_dbus_gtype_from_signature (const char *signature, gboolean is_client)
-{
- DBusSignatureIter iter;
-
- dbus_signature_iter_init (&iter, signature);
-
- return _dbus_gtype_from_signature_iter (&iter, is_client);
-}
-
-GArray *
-_dbus_gtypes_from_arg_signature (const char *argsig, gboolean is_client)
-{
- GArray *ret;
- int current_type;
- DBusSignatureIter sigiter;
-
- ret = g_array_new (FALSE, FALSE, sizeof (GType));
-
- dbus_signature_iter_init (&sigiter, argsig);
- while ((current_type = dbus_signature_iter_get_current_type (&sigiter)) != DBUS_TYPE_INVALID)
- {
- GType curtype;
-
- curtype = _dbus_gtype_from_signature_iter (&sigiter, is_client);
- g_array_append_val (ret, curtype);
- dbus_signature_iter_next (&sigiter);
- }
- return ret;
-}
diff --git a/dbus/dbus-gsignature.h b/dbus/dbus-gsignature.h
deleted file mode 100644
index 08757e1..0000000
--- a/dbus/dbus-gsignature.h
+++ /dev/null
@@ -1,19 +0,0 @@
-#ifndef DBUS_GOBJECT_SIGNATURE_H
-#define DBUS_GOBJECT_SIGNATURE_H
-
-#include <dbus/dbus.h>
-#include <dbus/dbus-signature.h>
-#include <glib.h>
-
-GType _dbus_gtype_from_basic_typecode (int typecode);
-
-GType _dbus_gtype_from_signature (const char *signature,
- gboolean is_client);
-
-GType _dbus_gtype_from_signature_iter (DBusSignatureIter *sigiter,
- gboolean is_client);
-
-GArray * _dbus_gtypes_from_arg_signature (const char *signature,
- gboolean is_client);
-
-#endif
diff --git a/dbus/dbus-gtest-main.c b/dbus/dbus-gtest-main.c
deleted file mode 100644
index 9ff65ac..0000000
--- a/dbus/dbus-gtest-main.c
+++ /dev/null
@@ -1,51 +0,0 @@
-/* -*- mode: C; c-file-style: "gnu" -*- */
-/* dbus-gtest-main.c Program to run all libdbus-glib tests
- *
- * Copyright (C) 2003 Red Hat Inc.
- *
- * Licensed under the Academic Free License version 2.1
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- */
-#include <config.h>
-
-#ifdef DBUS_BUILD_TESTS
-
-#include "dbus-gtest.h"
-#include <stdio.h>
-#include <stdlib.h>
-#include <locale.h>
-
-int
-main (int argc,
- char **argv)
-{
- const char *test_data_dir;
-
- setlocale(LC_ALL, "");
-
-
- if (argc > 1)
- test_data_dir = argv[1];
- else
- test_data_dir = NULL;
-
- dbus_glib_internal_do_not_use_run_tests (test_data_dir);
-
- return 0;
-}
-
-#endif
diff --git a/dbus/dbus-gtest.c b/dbus/dbus-gtest.c
deleted file mode 100644
index c9572ef..0000000
--- a/dbus/dbus-gtest.c
+++ /dev/null
@@ -1,76 +0,0 @@
-/* -*- mode: C; c-file-style: "gnu" -*- */
-/* dbus-test.c Program to run all tests
- *
- * Copyright (C) 2002, 2003 Red Hat Inc.
- *
- * Licensed under the Academic Free License version 2.1
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- */
-
-#include <config.h>
-#include "dbus-gtest.h"
-#include <stdio.h>
-#include <stdlib.h>
-#include <glib.h>
-
-#ifdef DBUS_BUILD_TESTS
-static void
-die (const char *failure)
-{
- fprintf (stderr, "Unit test failed: %s\n", failure);
- exit (1);
-}
-#endif /* DBUS_BUILD_TESTS */
-
-/*
- * An exported symbol to be run in order to execute
- * unit tests. Should not be used by
- * any app other than our test app, this symbol
- * won't exist in some builds of the library.
- * (with --enable-tests=no)
- *
- * @param test_data_dir the directory with test data (test/data normally)
- */
-void
-dbus_glib_internal_do_not_use_run_tests (const char *test_data_dir)
-{
-#ifdef DBUS_BUILD_TESTS
- if (test_data_dir == NULL)
- test_data_dir = g_getenv ("DBUS_TEST_DATA");
-
- if (test_data_dir != NULL)
- printf ("Test data in %s\n", test_data_dir);
- else
- printf ("No test data!\n");
-
- g_type_init ();
-
- printf ("%s: running GValue tests\n", "dbus-glib-test");
- if (!_dbus_gvalue_test (test_data_dir))
- die ("gvalue utils");
-
- printf ("%s: running GObject tests\n", "dbus-glib-test");
- if (!_dbus_gobject_test (test_data_dir))
- die ("gobject");
-
- printf ("%s: completed successfully\n", "dbus-glib-test");
-#else
- printf ("Not compiled with unit tests, not running any\n");
-#endif
-}
-
-
diff --git a/dbus/dbus-gtest.h b/dbus/dbus-gtest.h
deleted file mode 100644
index 21661fc..0000000
--- a/dbus/dbus-gtest.h
+++ /dev/null
@@ -1,34 +0,0 @@
-/* -*- mode: C; c-file-style: "gnu" -*- */
-/* dbus-gtest.h Declarations of test functions.
- *
- * Copyright (C) 2003 Red Hat Inc.
- *
- * Licensed under the Academic Free License version 2.1
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- */
-
-#ifndef DBUS_GLIB_TEST_H
-#define DBUS_GLIB_TEST_H
-
-#include <dbus/dbus-glib.h>
-
-gboolean _dbus_gobject_test (const char *test_data_dir);
-gboolean _dbus_gvalue_test (const char *test_data_dir);
-
-void dbus_glib_internal_do_not_use_run_tests (const char *test_data_dir);
-
-#endif /* DBUS_GLIB_TEST_H */
diff --git a/dbus/dbus-gthread.c b/dbus/dbus-gthread.c
deleted file mode 100644
index a88141b..0000000
--- a/dbus/dbus-gthread.c
+++ /dev/null
@@ -1,53 +0,0 @@
-/* -*- mode: C; c-file-style: "gnu" -*- */
-/* dbus-gthread.c GThread integration
- *
- * Copyright (C) 2002 CodeFactory AB
- *
- * Licensed under the Academic Free License version 2.1
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- */
-
-#include <config.h>
-
-/* #define G_DEBUG_LOCKS 1 */
-
-#include <glib.h>
-#include <dbus/dbus.h>
-#include "dbus-glib.h"
-
-/**
- * dbus_g_thread_init:
- *
- * Initializes the D-BUS thread system.
- * This function may only be called
- * once and must be called prior to calling any
- * other function in the D-BUS API.
- *
- * Equivalent to dbus_threads_init_default(), which does nothing.
- * dbus-glib requires dbus >= 1.8, which is thread-safe by default.
- *
- * Note that dbus-glib's GObject mapping is explicitly *not* thread-safe.
- *
- * Deprecated: New code should use GDBus instead. GDBus is always
- * thread-safe, whereas dbus-glib is never thread-safe.
- */
-void
-dbus_g_thread_init (void)
-{
- /* keep this pointless method call just in case */
- dbus_threads_init_default ();
-}
diff --git a/dbus/dbus-gtool-test.h b/dbus/dbus-gtool-test.h
deleted file mode 100644
index b8dbf31..0000000
--- a/dbus/dbus-gtool-test.h
+++ /dev/null
@@ -1,31 +0,0 @@
-/* -*- mode: C; c-file-style: "gnu" -*- */
-/* dbus-gtool-test.h Declarations of test functions for dbus-glib-tool.
- *
- * Copyright (C) 2003 Red Hat Inc.
- *
- * Licensed under the Academic Free License version 2.1
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- */
-
-#ifndef DBUS_GLIB_TOOL_TEST_H
-#define DBUS_GLIB_TOOL_TEST_H
-
-#include <dbus/dbus-glib.h>
-
-gboolean _dbus_gtool_test (const char *test_data_dir);
-
-#endif /* DBUS_GLIB_TEST_H */
diff --git a/dbus/dbus-gtype-specialized-priv.h b/dbus/dbus-gtype-specialized-priv.h
deleted file mode 100644
index c80ebfc..0000000
--- a/dbus/dbus-gtype-specialized-priv.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/* -*- mode: C; c-file-style: "gnu" -*- */
-/* dbus-gtype-specialized-priv.h: internals of specialized GTypes
- *
- * Copyright (C) 2009 Collabora Ltd.
- *
- * Licensed under the Academic Free License version 2.1
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- */
-
-#ifndef DBUS_GOBJECT_TYPE_SPECIALIZED_PRIV_H
-#define DBUS_GOBJECT_TYPE_SPECIALIZED_PRIV_H
-
-#include "dbus-gtype-specialized.h"
-
-G_BEGIN_DECLS
-
-G_GNUC_INTERNAL
-void _dbus_g_type_register_collection (const char *name,
- const DBusGTypeSpecializedCollectionVtable *vtable,
- guint flags);
-
-G_GNUC_INTERNAL
-void _dbus_g_type_register_map (const char *name,
- const DBusGTypeSpecializedMapVtable *vtable,
- guint flags);
-
-G_GNUC_INTERNAL
-void _dbus_g_type_register_struct (const char *name,
- const DBusGTypeSpecializedStructVtable *vtable,
- guint flags);
-
-G_END_DECLS
-
-#endif
diff --git a/dbus/dbus-gtype-specialized.c b/dbus/dbus-gtype-specialized.c
deleted file mode 100644
index 46fdef8..0000000
--- a/dbus/dbus-gtype-specialized.c
+++ /dev/null
@@ -1,1845 +0,0 @@
-/* -*- mode: C; c-file-style: "gnu" -*- */
-/* dbus-gtype-specialized.c: Non-DBus-specific functions for specialized GTypes
- *
- * Copyright (C) 2005 Red Hat, Inc.
- * Copyright (C) 2007 Codethink Ltd.
- *
- * Licensed under the Academic Free License version 2.1
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- */
-
-#include <config.h>
-
-#include "dbus-glib.h"
-#include "dbus-gtype-specialized-priv.h"
-#include "dbus-gvalue-utils.h"
-#include <glib.h>
-#include <string.h>
-#include <gobject/gvaluecollector.h>
-
-/**
- * SECTION:dbus-gtype-specialized
- * @title: Specializable GType System
- * @short_description: Specialized GTypes
- * @stability: Unstable
- *
- * Specialized gtypes are basically a way to allow the definition of
- * recursive #GTypes. It allows the definition of 'containers' which is
- * basically a user defined structure capable of holding other data, and a
- * set of functions defining how to access that structure. Containers come in
- * 3 flavors: collections, maps and structs.
- *
- * A collection is a container that holds an ordered set of items, all
- * of which must be the same type. (This is an <emphasis>array</emphasis>
- * in standard D-Bus terminology.) dbus-glib specialized collections can be
- * #GArray (for numeric elements), #GPtrArray (for string, object or
- * boxed elements), #GSList (for boxed elements, not recommended), or a
- * user-defined type.
- *
- * A map is a container that holds a set of key/value pairs.
- * The keys have one type, and the values another; the type of the keys
- * must be a numeric or string-like type. (This is a <emphasis>dict</emphasis>
- * (dictionary) or <emphasis>array of dict entry</emphasis> in standard D-Bus
- * terminology.) dbus-glib specialized maps can be #GHashTable or a
- * user-defined type.
- *
- * A struct is a container that holds a fixed number of members, each member
- * having a predefined type. (This is a <emphasis>struct</emphasis> in
- * standard D-Bus terminology.) It is analogous to the C @struct keyword, but
- * dbus-glib does not generally represent D-Bus structs in C structs.
- * dbus-glib specialized structs can be #GValueArray or a user-defined type.
- *
- * A specialization is a GType detailing a particular container with
- * particular types (a type specialization).
- *
- * Functions are provided for constructing and manipulating specializations.
- *
- * This documentation needs splitting into two pages, one for defining new
- * containers and using existing containers. I expect most users to only do
- * the latter. I also need to add some examples.
- *
- * Deprecated: New code should use GDBus instead. The closest equivalent
- * is #GVariant, which is much better-designed.
- */
-
-/**
- * DBUS_TYPE_G_BOOLEAN_ARRAY:
- *
- * Expands to a function call returning the #GType of a #GArray of #gboolean
- * (corresponding to the D-Bus signature "ab").
- *
- * Deprecated: New code should use GDBus instead. The closest equivalent
- * is `G_VARIANT_TYPE ("ab")`.
- */
-
-/**
- * DBUS_TYPE_G_INT_ARRAY:
- *
- * Expands to a function call returning the #GType of a #GArray of #gint
- * (corresponding to the D-Bus signature "ai").
- *
- * Deprecated: New code should use GDBus instead. The closest equivalent
- * is `G_VARIANT_TYPE ("ai")`.
- */
-
-/**
- * DBUS_TYPE_G_UINT_ARRAY:
- *
- * Expands to a function call returning the #GType of a #GArray of #guint
- * (corresponding to the D-Bus signature "au").
- *
- * Deprecated: New code should use GDBus instead. The closest equivalent
- * is `G_VARIANT_TYPE ("au")`.
- */
-
-/**
- * DBUS_TYPE_G_INT64_ARRAY:
- *
- * Expands to a function call returning the #GType of a #GArray of #gint64
- * (corresponding to the D-Bus signature "ax").
- *
- * Deprecated: New code should use GDBus instead. The closest equivalent
- * is `G_VARIANT_TYPE ("ax")`.
- */
-
-/**
- * DBUS_TYPE_G_UINT64_ARRAY:
- *
- * Expands to a function call returning the #GType of a #GArray of #guint64
- * (corresponding to the D-Bus signature "at").
- *
- * Deprecated: New code should use GDBus instead. The closest equivalent
- * is `G_VARIANT_TYPE ("at")`.
- */
-
-/**
- * DBUS_TYPE_G_UCHAR_ARRAY:
- *
- * Expands to a function call returning the #GType of a #GArray of #guchar
- * (corresponding to the D-Bus signature "ay").
- *
- * Note that this is not the same thing as a #GByteArray! dbus-glib does not
- * know about the #GByteArray type.
- *
- * Deprecated: New code should use GDBus instead. The closest equivalent
- * is %G_VARIANT_TYPE_BYTESTRING.
- */
-
-/**
- * DBUS_TYPE_G_OBJECT_ARRAY:
- *
- * Expands to a function call returning the #GType of a #GPtrArray of #GObject.
- *
- * Use this type with caution: it can sometimes be used as a representation
- * of arrays whose D-Bus signature is "ao" (transferred as an array of object
- * paths), but the conventional type for such arrays is
- * <literal>(dbus_g_type_get_collection ("GPtrArray",
- * DBUS_TYPE_G_OBJECT_PATH))</literal>.
- *
- * Deprecated: New code should use GDBus instead. The closest equivalent
- * is %G_VARIANT_TYPE_OBJECT_PATH_ARRAY.
- */
-
-/**
- * DBUS_TYPE_G_STRING_STRING_HASHTABLE:
- *
- * Expands to a function call returning the #GType of a #GHashTable where the
- * keys are strings and the values are also strings (corresponding to the
- * D-Bus signature "a{ss}").
- *
- * Deprecated: New code should use GDBus instead. The closest equivalent
- * is `G_VARIANT_TYPE ("a{ss}")`.
- */
-
-/**
- * DBusGTypeSpecializedVtable:
- * @constructor: returns a new, blank instance of the @type
- * @free_func: if not %NULL, frees the @type instance @val
- * @copy_func: returns a "deep copy" of the @type instance @val
- * @simple_free_func: if not %NULL, frees its argument
- *
- * A table of methods used to implement specialized container behaviour on
- * user-defined collections, maps and structs. Exactly one of @free_func and
- * @simple_free_func must be implemented; the other must be %NULL.
- * @constructor and @copy_func must always be implemented.
- *
- * There are additional members, which are reserved for future expansion and
- * must be %NULL.
- *
- * Deprecated: New code should use GDBus instead.
- */
-
-/**
- * DBusGTypeSpecializedConstructor:
- * @type: a specialized boxed type
- *
- * <!-- -->
- *
- * Returns: a new instance of @type
- *
- * Deprecated: New code should use GDBus instead.
- */
-
-/**
- * DBusGTypeSpecializedFreeFunc:
- * @type: a specialized boxed type
- * @val: an instance of @type
- *
- * Frees @val according to @type. This is analogous to #GBoxedFreeFunc, but
- * can use information from @type (for instance to free the contents of a
- * container before freeing the actual container).
- *
- * Deprecated: New code should use GDBus instead.
- */
-
-/**
- * DBusGTypeSpecializedCopyFunc:
- * @type: a specialized boxed type
- * @src: an instance of @type
- *
- * Copies @src according to @type. This is analogous to #GBoxedCopyFunc, but
- * can use information from @type (for instance to copy each element of a
- * collection).
- *
- * Returns: a deep copy of @src
- *
- * Deprecated: New code should use GDBus instead.
- */
-
-/**
- * DBusGTypeSpecializedCollectionFixedAccessorFunc:
- * @type: a specialized collection boxed type
- * @instance: an instance of @type
- * @values: used to return a pointer to the contents of @instance
- * @len: used to return the number of elements in @instance
- *
- * Implements dbus_g_type_collection_get_fixed() for a #GValue with type
- * @type, containing @instance.
- *
- * Returns: %TRUE on success
- *
- * Deprecated: New code should use GDBus instead.
- */
-
-/**
- * DBusGTypeSpecializedCollectionIterator:
- * @value: an element of the collection
- * @user_data: the data supplied when calling
- * dbus_g_type_collection_value_iterate()
- *
- * A library-user-supplied function, called for each element in the
- * collection when dbus_g_type_collection_value_iterate() is called.
- *
- * Deprecated: New code should use GDBus instead.
- */
-
-/**
- * DBusGTypeSpecializedCollectionIteratorFunc:
- * @type: a specialized collection boxed type
- * @instance: an instance of @type
- * @iterator: the function to call for each element
- * @user_data: data to pass to @iterator
- *
- * Implements dbus_g_type_collection_value_iterate() for a #GValue with
- * type @type, containing @instance.
- *
- * Deprecated: New code should use GDBus instead.
- */
-
-/**
- * DBusGTypeSpecializedCollectionAppendFunc:
- * @ctx: an appending context returned by dbus_g_type_specialized_init_append()
- * @val: a value to copy into the collection
- *
- * Implements dbus_g_type_specialized_collection_append().
- *
- * This function should use the @val and @specialization_type members of @ctx.
- *
- * Deprecated: New code should use GDBus instead.
- */
-
-/**
- * DBusGTypeSpecializedCollectionEndAppendFunc:
- * @ctx: an appending context returned by dbus_g_type_specialized_init_append()
- *
- * Implements dbus_g_type_specialized_collection_end_append().
- *
- * This function should use the @val and @specialization_type members of @ctx.
- *
- * Deprecated: New code should use GDBus instead.
- */
-
-/**
- * DBusGTypeSpecializedCollectionVtable:
- * @base_vtable: base methods shared between collections and other types
- * @fixed_accessor: if not %NULL, provides access to the contents of this
- * collection, as documented for dbus_g_type_collection_get_fixed()
- * @iterator: iterates through the members of @instance
- * @append_func: appends a new member to @instance
- * @end_append_func: if not %NULL, called after each group of calls to
- * the @append_func
- *
- * A table of methods used to implement specialized collection behaviour
- * on user-defined types. At least @iterator and @append_func must be
- * implemented.
- *
- * Deprecated: New code should use GDBus instead.
- */
-
-/**
- * DBusGTypeSpecializedMapIterator:
- * @key_val: a key from the map
- * @value_val: a value from the map
- * @user_data: the data supplied when calling
- * dbus_g_type_map_value_iterate()
- *
- * A library-user-supplied function, called for each key/value pair in the
- * collection when dbus_g_type_map_value_iterate() is called.
- *
- * Deprecated: New code should use GDBus instead.
- */
-
-/**
- * DBusGTypeSpecializedMapIteratorFunc:
- * @type: a specialized map boxed type
- * @instance: an instance of @type
- * @iterator: the function to call for each key/value pair
- * @user_data: data to pass to @iterator
- *
- * Implements dbus_g_type_map_value_iterate() for a #GValue with
- * type @type, containing @instance.
- *
- * Deprecated: New code should use GDBus instead.
- */
-
-/**
- * DBusGTypeSpecializedMapAppendFunc:
- * @ctx: an appending context returned by dbus_g_type_specialized_init_append()
- * @key: a key to add to the collection
- * @val: a value to add to the collection
- *
- * Implements dbus_g_type_specialized_map_append().
- *
- * This function should use the @val and @specialization_type members of @ctx,
- * and replace any existing value with key equal to @key.
- *
- * Deprecated: New code should use GDBus instead.
- */
-
-/**
- * DBusGTypeSpecializedMapVtable:
- * @base_vtable: base methods shared between maps and other types
- * @iterator: iterates through the members of @instance
- * @append_func: adds a new key/value pair to @instance
- *
- * A table of methods used to implement specialized collection behaviour
- * on user-defined types. Both methods must be implemented.
- *
- * Deprecated: New code should use GDBus instead.
- */
-
-/**
- * DBusGTypeSpecializedStructGetMember:
- * @type: a specialized struct boxed type
- * @instance: an instance of @type
- * @member: the index of the member, starting from 0
- * @ret_value: an initialized #GValue of the appropriate type for the given
- * member of @type
- *
- * Implements dbus_g_type_struct_get_member() for a #GValue with type @type,
- * containing @instance.
- *
- * Returns: %TRUE on success
- *
- * Deprecated: New code should use GDBus instead.
- */
-
-/**
- * DBusGTypeSpecializedStructSetMember:
- * @type: a specialized struct boxed type
- * @instance: an instance of @type
- * @member: the index of the member, starting from 0
- * @new_value: an initialized #GValue of the appropriate type for the given
- * member of @type
- *
- * Implements dbus_g_type_struct_set_member() for a #GValue with type @type,
- * containing @instance.
- *
- * Returns: %TRUE on success
- *
- * Deprecated: New code should use GDBus instead.
- */
-
-/**
- * DBusGTypeSpecializedStructVtable:
- * @base_vtable: base methods shared between maps and other types
- * @get_member: returns a member by its index
- * @set_member: sets a member by its index
- *
- * A table of methods used to implement specialized collection behaviour
- * on user-defined types. Both methods must be implemented.
- *
- * Deprecated: New code should use GDBus instead.
- */
-
-typedef enum {
- DBUS_G_SPECTYPE_COLLECTION,
- DBUS_G_SPECTYPE_MAP,
- DBUS_G_SPECTYPE_STRUCT
-} DBusGTypeSpecializedType;
-
-typedef struct {
- DBusGTypeSpecializedType type;
- const DBusGTypeSpecializedVtable *vtable;
-} DBusGTypeSpecializedContainer;
-
-typedef struct {
- guint num_types;
- GType *types;
- const DBusGTypeSpecializedContainer *klass;
-} DBusGTypeSpecializedData;
-
-static GHashTable /* char * -> data* */ *specialized_containers;
-
-static GQuark
-specialized_type_data_quark ()
-{
- static GQuark quark;
- if (!quark)
- quark = g_quark_from_static_string ("DBusGTypeSpecializedData");
-
- return quark;
-}
-
-static gpointer
-specialized_init (gpointer arg G_GNUC_UNUSED)
-{
- g_assert (specialized_containers == NULL);
-
- specialized_containers = g_hash_table_new_full (g_str_hash, g_str_equal,
- g_free, NULL);
-
- _dbus_g_type_specialized_builtins_init ();
- return NULL;
-}
-
-/**
- * dbus_g_type_specialized_init:
- *
- * Initialize dbus-glib specialized #GType<!-- -->s.
- *
- * In older versions of dbus-glib, it was necessary to do this before
- * instantiating or registering any specialized type. It is now done
- * automatically whenever necessary.
- *
- * Deprecated: New code should use GDBus instead.
- */
-void
-dbus_g_type_specialized_init (void)
-{
- static GOnce once = G_ONCE_INIT;
-
- g_once (&once, specialized_init, NULL);
-}
-
-static DBusGTypeSpecializedData *
-lookup_specialization_data (GType type)
-{
- return g_type_get_qdata (type, specialized_type_data_quark ());
-}
-
-
-/* Copied from gboxed.c */
-static void
-proxy_value_init (GValue *value)
-{
- value->data[0].v_pointer = NULL;
-}
-
-/* Adapted from gboxed.c */
-static void
-proxy_value_free (GValue *value)
-{
- if (value->data[0].v_pointer && !(value->data[1].v_uint & G_VALUE_NOCOPY_CONTENTS))
- {
- DBusGTypeSpecializedData *data;
- GType type;
-
- type = G_VALUE_TYPE (value);
- data = lookup_specialization_data (type);
- g_assert (data != NULL);
-
- if (data->klass->vtable->free_func)
- {
- data->klass->vtable->free_func (type, value->data[0].v_pointer);
- }
- else
- {
- g_assert (data->klass->vtable->simple_free_func != NULL);
- data->klass->vtable->simple_free_func (value->data[0].v_pointer);
- }
- }
-}
-
-/* Adapted from gboxed.c */
-static void
-proxy_value_copy (const GValue *src_value,
- GValue *dest_value)
-{
- if (src_value->data[0].v_pointer)
- {
- DBusGTypeSpecializedData *data;
- GType type;
- type = G_VALUE_TYPE (src_value);
- data = lookup_specialization_data (type);
- g_assert (data != NULL);
- dest_value->data[0].v_pointer = data->klass->vtable->copy_func (type, src_value->data[0].v_pointer);
- }
- else
- dest_value->data[0].v_pointer = src_value->data[0].v_pointer;
-}
-
-/* Copied from gboxed.c */
-static gpointer
-proxy_value_peek_pointer (const GValue *value)
-{
- return value->data[0].v_pointer;
-}
-
-/* Adapted from gboxed.c */
-static gchar*
-proxy_collect_value (GValue *value,
- guint n_collect_values,
- GTypeCValue *collect_values,
- guint collect_flags)
-{
- DBusGTypeSpecializedData *data;
- GType type;
-
- type = G_VALUE_TYPE (value);
- data = lookup_specialization_data (type);
-
- if (!collect_values[0].v_pointer)
- value->data[0].v_pointer = NULL;
- else
- {
- if (collect_flags & G_VALUE_NOCOPY_CONTENTS)
- {
- value->data[0].v_pointer = collect_values[0].v_pointer;
- value->data[1].v_uint = G_VALUE_NOCOPY_CONTENTS;
- }
- else
- {
- value->data[0].v_pointer = data->klass->vtable->copy_func (type, collect_values[0].v_pointer);
- }
- }
-
- return NULL;
-}
-
-/* Adapted from gboxed.c */
-static gchar*
-proxy_lcopy_value (const GValue *value,
- guint n_collect_values,
- GTypeCValue *collect_values,
- guint collect_flags)
-{
- gpointer *boxed_p = collect_values[0].v_pointer;
-
- if (!boxed_p)
- return g_strdup_printf ("value location for `%s' passed as NULL", G_VALUE_TYPE_NAME (value));
-
- if (!value->data[0].v_pointer)
- *boxed_p = NULL;
- else if (collect_flags & G_VALUE_NOCOPY_CONTENTS)
- *boxed_p = value->data[0].v_pointer;
- else
- {
- DBusGTypeSpecializedData *data;
- GType type;
-
- type = G_VALUE_TYPE (value);
- data = lookup_specialization_data (type);
-
- *boxed_p = data->klass->vtable->copy_func (type, value->data[0].v_pointer);
- }
-
- return NULL;
-}
-
-static char *
-build_specialization_name (const char *prefix, guint num_types, const GType *types)
-{
- GString *fullname;
- guint i;
-
- fullname = g_string_new (prefix);
-
- g_string_append_c (fullname, '_');
- for (i=0; i < num_types; i++)
- {
- if (i!=0)
- g_string_append_c (fullname, '+');
- g_string_append (fullname, g_type_name (types[i]));
- }
- g_string_append_c (fullname, '_');
- return g_string_free (fullname, FALSE);
-}
-
-static void
-register_container (const char *name,
- DBusGTypeSpecializedType type,
- const DBusGTypeSpecializedVtable *vtable)
-{
- DBusGTypeSpecializedContainer *klass;
-
- g_warn_if_fail (vtable->constructor != NULL);
- /* must have either free_func or simple_free_func */
- g_warn_if_fail (vtable->free_func != NULL ||
- vtable->simple_free_func != NULL);
- g_warn_if_fail (vtable->copy_func != NULL);
-
- klass = g_new0 (DBusGTypeSpecializedContainer, 1);
- klass->type = type;
- klass->vtable = vtable;
-
- g_hash_table_insert (specialized_containers, g_strdup (name), klass);
-}
-
-/**
- * dbus_g_type_register_collection:
- * @name: The name of a new collection container
- * @vtable: the vtable defining the new container
- * @flags: As yet unused.
- *
- * Defines a new collection container.
- *
- * Deprecated: New code should use GDBus instead.
- */
-void
-dbus_g_type_register_collection (const char *name,
- const DBusGTypeSpecializedCollectionVtable *vtable,
- guint flags)
-{
- dbus_g_type_specialized_init();
-
- _dbus_g_type_register_collection (name, vtable, flags);
-}
-
-void
-_dbus_g_type_register_collection (const char *name,
- const DBusGTypeSpecializedCollectionVtable *vtable,
- guint flags)
-{
- /* fixed_accessor is optional */
- g_warn_if_fail (vtable->iterator != NULL);
- g_warn_if_fail (vtable->append_func != NULL);
- /* end_append_func is optional */
-
- register_container (name, DBUS_G_SPECTYPE_COLLECTION, (const DBusGTypeSpecializedVtable*) vtable);
-}
-
-/**
- * dbus_g_type_register_map:
- * @name: The name of a new map container
- * @vtable: the vtable defining the new container
- * @flags: As yet unused.
- *
- * Defines a new map container.
- *
- * Deprecated: New code should use GDBus instead.
- */
-void
-dbus_g_type_register_map (const char *name,
- const DBusGTypeSpecializedMapVtable *vtable,
- guint flags)
-{
- dbus_g_type_specialized_init();
-
- _dbus_g_type_register_map (name, vtable, flags);
-}
-
-void
-_dbus_g_type_register_map (const char *name,
- const DBusGTypeSpecializedMapVtable *vtable,
- guint flags)
-{
- g_warn_if_fail (vtable->iterator != NULL);
- g_warn_if_fail (vtable->append_func != NULL);
-
- register_container (name, DBUS_G_SPECTYPE_MAP, (const DBusGTypeSpecializedVtable*) vtable);
-}
-
-/**
- * dbus_g_type_register_struct:
- * @name: The name of a new struct container
- * @vtable: the vtable defining the new container
- * @flags: As yet unused.
- *
- * Defines a new struct container.
- *
- * Deprecated: New code should use GDBus instead.
- */
-void
-dbus_g_type_register_struct (const char *name,
- const DBusGTypeSpecializedStructVtable *vtable,
- guint flags)
-{
- dbus_g_type_specialized_init();
-
- _dbus_g_type_register_struct (name, vtable, flags);
-}
-
-void
-_dbus_g_type_register_struct (const char *name,
- const DBusGTypeSpecializedStructVtable *vtable,
- guint flags)
-{
- g_warn_if_fail (vtable->get_member != NULL);
- g_warn_if_fail (vtable->set_member != NULL);
-
- register_container (name, DBUS_G_SPECTYPE_STRUCT, (const DBusGTypeSpecializedVtable*) vtable);
-}
-
-/**
- * dbus_g_type_map_peek_vtable:
- * @map_type: a gtype of a map specialization
- *
- * Peek the vtable for a given map specialization
- *
- * Returns: the vtable
- *
- * Deprecated: New code should use GDBus instead.
- */
-const DBusGTypeSpecializedMapVtable* dbus_g_type_map_peek_vtable (GType map_type)
-{
- DBusGTypeSpecializedData *data;
- g_return_val_if_fail (dbus_g_type_is_map(map_type), NULL);
-
- data = lookup_specialization_data (map_type);
- g_assert (data != NULL);
-
- return (DBusGTypeSpecializedMapVtable *)(data->klass->vtable);
-}
-
-/**
- * dbus_g_type_collection_peek_vtable:
- * @collection_type: a gtype of a collection specialization
- *
- * Peek the vtable for a given collection specialization
- *
- * Returns: the vtable
- *
- * Deprecated: New code should use GDBus instead.
- */
-const DBusGTypeSpecializedCollectionVtable* dbus_g_type_collection_peek_vtable (GType collection_type)
-{
- DBusGTypeSpecializedData *data;
- g_return_val_if_fail (dbus_g_type_is_collection(collection_type), NULL);
-
- data = lookup_specialization_data (collection_type);
- g_assert (data != NULL);
-
- return (DBusGTypeSpecializedCollectionVtable *)(data->klass->vtable);
-}
-
-/**
- * dbus_g_type_struct_peek_vtable:
- * @struct_type: a gtype of a struct specialization
- *
- * Peek the vtable for a given struct specialization
- *
- * Returns: the vtable
- *
- * Deprecated: New code should use GDBus instead.
- */
-const DBusGTypeSpecializedStructVtable* dbus_g_type_struct_peek_vtable (GType struct_type)
-{
- DBusGTypeSpecializedData *data;
- g_return_val_if_fail (dbus_g_type_is_struct (struct_type), NULL);
-
- data = lookup_specialization_data (struct_type);
- g_assert (data != NULL);
-
- return (DBusGTypeSpecializedStructVtable *)(data->klass->vtable);
-}
-
-static GType
-register_specialized_instance (const DBusGTypeSpecializedContainer *klass,
- const char *name,
- guint num_types,
- const GType *types)
-{
- GType ret;
-
- static const GTypeValueTable vtable =
- {
- proxy_value_init,
- proxy_value_free,
- proxy_value_copy,
- proxy_value_peek_pointer,
- "p",
- proxy_collect_value,
- "p",
- proxy_lcopy_value,
- };
- static const GTypeInfo derived_info =
- {
- 0, /* class_size */
- NULL, /* base_init */
- NULL, /* base_finalize */
- NULL, /* class_init */
- NULL, /* class_finalize */
- NULL, /* class_data */
- 0, /* instance_size */
- 0, /* n_preallocs */
- NULL, /* instance_init */
- &vtable, /* value_table */
- };
-
- ret = g_type_register_static (G_TYPE_BOXED, name, &derived_info, 0);
- /* install proxy functions upon successfull registration */
- if (ret != G_TYPE_INVALID)
- {
- DBusGTypeSpecializedData *data;
- data = g_new0 (DBusGTypeSpecializedData, 1);
- data->num_types = num_types;
- data->types = g_memdup (types, sizeof (GType) * num_types);
- data->klass = klass;
- g_type_set_qdata (ret, specialized_type_data_quark (), data);
- }
-
- return ret;
-}
-
-static GType
-lookup_or_register_specialized (const char *container,
- guint num_types,
- const GType *types)
-{
- GType ret;
- char *name;
- const DBusGTypeSpecializedContainer *klass;
-
- dbus_g_type_specialized_init();
-
- klass = g_hash_table_lookup (specialized_containers, container);
- g_return_val_if_fail (klass != NULL, G_TYPE_INVALID);
-
- name = build_specialization_name (container, num_types, types);
- ret = g_type_from_name (name);
- if (ret == G_TYPE_INVALID)
- {
- /* Take ownership of name */
- ret = register_specialized_instance (klass, name,
- num_types,
- types);
- }
- g_free (name);
- return ret;
-}
-
-
-/**
- * dbus_g_type_get_collection:
- * @container: a string specifying a registered collection type
- * @specialization: #GType of collection elements
- *
- * Gets a #GType for a particular collection instance,
- * creating the type if not already created.
- *
- * Returns: the #GType of that instance
- *
- * Deprecated: New code should use GDBus instead.
- */
-GType
-dbus_g_type_get_collection (const char *container,
- GType specialization)
-{
- return lookup_or_register_specialized (container, 1, &specialization);
-}
-
-/**
- * dbus_g_type_get_map:
- * @container: a string specifying a registered map type
- * @key_specialization: #GType of keys
- * @value_specialization: #GType of values
- *
- * Gets a #GType for a particular map instance,
- * creating the type if not already created.
- *
- * Returns: the #GType of that instance
- *
- * Deprecated: New code should use GDBus instead.
- */
-GType
-dbus_g_type_get_map (const char *container,
- GType key_specialization,
- GType value_specialization)
-{
- GType types[2];
- types[0] = key_specialization;
- types[1] = value_specialization;
- return lookup_or_register_specialized (container, 2, types);
-}
-
-/**
- * dbus_g_type_get_structv:
- * @container: a string specifying a registered struct type
- * @num_members: number of members in the struct
- * @types: an array specufying a GType for each struct element
- *
- * Gets a #GType for a particular struct instance,
- * creating the type if not already created.
- *
- * Returns: the #GType of that instance
- *
- * Deprecated: New code should use GDBus instead.
- */
-GType
-dbus_g_type_get_structv (const char *container,
- guint num_members,
- GType *types)
-{
- return lookup_or_register_specialized (container, num_members, types);
-}
-
-/**
- * dbus_g_type_get_struct:
- * @container: a string specifying a registered struct type
- * @first_type: #GType for the struct's first member
- * @...: more GTypes for the struct's members, terminated by G_TYPE_INVALID
- *
- * Varags method to get a #GType for a particular struct instance,
- * creating the type if not already created.
- *
- * Returns: the #GType of that instance
- *
- * Deprecated: New code should use GDBus instead.
- */
-GType
-dbus_g_type_get_struct (const char *container,
- GType first_type,
- ...)
-{
- GArray *types;
- GType curtype, ret;
- va_list args;
- va_start (args, first_type);
-
- types = g_array_new (FALSE, FALSE, sizeof (GType));
- curtype = first_type;
- while (curtype != G_TYPE_INVALID)
- {
- g_array_append_val (types, curtype);
- curtype = va_arg (args, GType);
- }
- va_end (args);
-
- ret = lookup_or_register_specialized (container, types->len,
- (GType *) types->data);
-
- g_array_free (types, TRUE);
-
- return ret;
-}
-
-
-/**
- * dbus_g_type_is_collection:
- * @gtype: a GType to test
- *
- * Tests if a given GType is a collection.
- *
- * Returns: true if the given GType is a collection
- *
- * Deprecated: New code should use GDBus instead.
- */
-gboolean
-dbus_g_type_is_collection (GType gtype)
-{
- DBusGTypeSpecializedData *data;
- data = lookup_specialization_data (gtype);
- if (data == NULL)
- return FALSE;
- return data->klass->type == DBUS_G_SPECTYPE_COLLECTION;
-}
-
-/**
- * dbus_g_type_is_map:
- * @gtype: a GType to test
- *
- * Tests if a given GType is a map,
- * i.e. it was created with dbus_g_type_get_map().
- *
- * Returns: true if the given GType is a map
- *
- * Deprecated: New code should use GDBus instead.
- */
-gboolean
-dbus_g_type_is_map (GType gtype)
-{
- DBusGTypeSpecializedData *data;
- data = lookup_specialization_data (gtype);
- if (data == NULL)
- return FALSE;
- return data->klass->type == DBUS_G_SPECTYPE_MAP;
-}
-
-/**
- * dbus_g_type_is_struct:
- * @gtype: a GType to test
- *
- * Tests if a given GType is a struct,
- * i.e. it was created with dbus_g_type_get_struct()
- *
- * Returns: true if the given GType is a struct
- *
- * Deprecated: New code should use GDBus instead.
- */
-gboolean
-dbus_g_type_is_struct (GType gtype)
-{
- DBusGTypeSpecializedData *data;
- data = lookup_specialization_data (gtype);
- if (data == NULL)
- return FALSE;
- return data->klass->type == DBUS_G_SPECTYPE_STRUCT;
-}
-
-
-static GType
-get_specialization_index (GType gtype, guint i)
-{
- DBusGTypeSpecializedData *data;
-
- data = lookup_specialization_data (gtype);
- if (i < data->num_types)
- return data->types[i];
- else
- return G_TYPE_INVALID;
-}
-
-/**
- * dbus_g_type_get_collection_specialization:
- * @gtype: a collection #GType, as created by dbus_g_type_get_collection()
- *
- * Return the type of each element in collections of type @gtype.
- * It is an error to call this function on a non-collection type.
- *
- * Returns: the element type for a given collection GType.
- *
- * Deprecated: New code should use GDBus instead.
- */
-GType
-dbus_g_type_get_collection_specialization (GType gtype)
-{
- g_return_val_if_fail (dbus_g_type_is_collection (gtype), G_TYPE_INVALID);
- return get_specialization_index (gtype, 0);
-}
-
-/**
- * dbus_g_type_get_map_key_specialization:
- * @gtype: a map #GType, as created by dbus_g_type_get_map()
- *
- * Return the type of the keys in maps of type @gtype.
- * It is an error to call this function on a non-map type.
- *
- * Returns: the key type for a given map #GType.
- *
- * Deprecated: New code should use GDBus instead.
- */
-GType
-dbus_g_type_get_map_key_specialization (GType gtype)
-{
- g_return_val_if_fail (dbus_g_type_is_map (gtype), G_TYPE_INVALID);
- return get_specialization_index (gtype, 0);
-}
-
-/**
- * dbus_g_type_get_map_value_specialization:
- * @gtype: a map GType, as created by dbus_g_type_get_map().
- *
- * Return the type of the values in maps of type @gtype.
- * It is an error to call this function on a non-map type.
- *
- * Returns: the value type for a given map GType.
- *
- * Deprecated: New code should use GDBus instead.
- */
-GType
-dbus_g_type_get_map_value_specialization (GType gtype)
-{
- g_return_val_if_fail (dbus_g_type_is_map (gtype), G_TYPE_INVALID);
- return get_specialization_index (gtype, 1);
-}
-
-/**
- * dbus_g_type_get_struct_member_type
- * @gtype: a struct GType, as created with dbus_g_type_get_struct()
- * @member: the index of a struct member
- *
- * Get the type of a member of a specialized struct.
- * It is an error to call this function on a non-struct type.
- *
- * Returns: the type for a given member of a struct #GType,
- * or %G_TYPE_INVALID if @member &gt;= dbus_g_type_get_struct_size()
- *
- * Deprecated: New code should use GDBus instead.
- */
-GType
-dbus_g_type_get_struct_member_type (GType gtype, guint member)
-{
- g_return_val_if_fail (dbus_g_type_is_struct (gtype), G_TYPE_INVALID);
- return get_specialization_index (gtype, member);
-}
-
-/**
- * dbus_g_type_get_struct_size
- * @gtype: a struct GType, as created with dbus_g_type_get_struct().
- *
- * Get the number of members in a specialized struct.
- * It is an error to call this function on a non-struct type.
- *
- * Returns: the number of members in a given struct #GType.
- *
- * Deprecated: New code should use GDBus instead.
- */
-guint
-dbus_g_type_get_struct_size (GType gtype)
-{
- DBusGTypeSpecializedData *data;
- g_return_val_if_fail (dbus_g_type_is_struct (gtype), G_TYPE_INVALID);
-
- data = lookup_specialization_data (gtype);
- return data->num_types;
-}
-
-/**
- * dbus_g_type_specialized_construct:
- * @gtype: a specialized #GType, as created by dbus_g_type_get_collection(),
- * dbus_g_type_get_map() or dbus_g_type_get_struct()
- *
- * Create an instance of a given specialized type.
- * The structure created and returned will depend on the container type of the
- * GType. E.g. If the given type was created by
- * dbus_g_type_get_collection("GArray", G_TYPE_INT),
- * then this will return a GArray with element_size of sizeof(int)
- *
- * Returns: a pointer to a newly constructed instance of the given type.
- *
- * Deprecated: New code should use GDBus instead.
- */
-gpointer
-dbus_g_type_specialized_construct (GType gtype)
-{
- DBusGTypeSpecializedData *data;
-
- dbus_g_type_specialized_init();
-
- data = lookup_specialization_data (gtype);
- g_return_val_if_fail (data != NULL, FALSE);
-
- return data->klass->vtable->constructor (gtype);
-}
-
-/**
- * dbus_g_type_collection_get_fixed:
- * @value: a GValue containing a boxed specialized collection
- * that has a @fixed_accessor in its vtable
- * @data_ret: used to return a pointer to the fixed data, which must not be
- * modified (for instance, for a #GArray of #gint, this would point
- * to an array of #gint)
- * @len_ret: used to return the length (counting collection elements, not
- * bytes: in a #GArray containing one #gint, this would be 1)
- *
- * Calling this function is likely to be a bad idea. Consider using
- * dbus_g_type_collection_value_iterate() instead.
- *
- * On success, @data_ret is a pointer to the underlying data in a collection
- * of fixed-length fundamental types. Knowledge of the underlying data model
- * of the collection is needed in order to use @data_ret correctly.
- *
- * It is an error to call this function on a specialized type that is not a
- * collection, or on a collection that does not have a @fixed_accessor in its
- * #DBusGTypeSpecializedCollectionVtable.
- *
- * Specialized #GArray<!---->s are the only types provided by dbus-glib that
- * can be used with this function; user-defined types might also work.
- *
- * Returns: %TRUE on success
- *
- * Deprecated: New code should use GDBus instead.
- */
-gboolean
-dbus_g_type_collection_get_fixed (GValue *value,
- gpointer *data_ret,
- guint *len_ret)
-{
- DBusGTypeSpecializedData *data;
- DBusGTypeSpecializedCollectionVtable *vtable;
- GType gtype;
-
- dbus_g_type_specialized_init();
-
- g_return_val_if_fail (G_VALUE_HOLDS_BOXED (value), FALSE);
-
- gtype = G_VALUE_TYPE (value);
- g_return_val_if_fail (dbus_g_type_is_collection (gtype), FALSE);
-
- data = lookup_specialization_data (gtype);
- /* dbus_g_type_is_collection() already checked this */
- g_assert (data != NULL);
-
- vtable = (DBusGTypeSpecializedCollectionVtable *) (data->klass->vtable);
- g_return_val_if_fail (vtable->fixed_accessor != NULL, FALSE);
-
- return vtable->fixed_accessor (gtype, g_value_get_boxed (value),
- data_ret, len_ret);
-}
-
-/**
- * dbus_g_type_collection_value_iterate:
- * @value: a #GValue holding a collection type.
- * @iterator: a function to call for each element
- * @user_data: user data to pass to the @iterator
- *
- * Calls the given function for each element of the collection.
- * The function is passed a #GValue containing the element and the given
- * @user_data parameter. The collection may not be modified while iterating over
- * it.
- *
- * Deprecated: New code should use GDBus instead.
- */
-void
-dbus_g_type_collection_value_iterate (const GValue *value,
- DBusGTypeSpecializedCollectionIterator iterator,
- gpointer user_data)
-{
- DBusGTypeSpecializedData *data;
- GType gtype;
-
- dbus_g_type_specialized_init();
-
- g_return_if_fail (G_VALUE_HOLDS_BOXED (value));
-
- gtype = G_VALUE_TYPE (value);
- g_return_if_fail (dbus_g_type_is_collection (gtype));
-
- data = lookup_specialization_data (gtype);
- /* dbus_g_type_is_collection() already checked this */
- g_assert (data != NULL);
-
- ((DBusGTypeSpecializedCollectionVtable *) data->klass->vtable)->iterator (gtype,
- g_value_get_boxed (value),
- iterator, user_data);
-}
-
-/**
- * DBusGTypeSpecializedAppendContext:
- * @val: the #GValue containing the array to which you're appending
- * @specialization_type: the #GType of the array's elements
- *
- * A context for appending. There are more fields, which are private.
- *
- * Deprecated: New code should use GDBus instead.
- */
-
-typedef struct {
- GValue *val;
- GType specialization_type;
- DBusGTypeSpecializedData *specdata;
- guint c;
- gpointer d;
-} DBusGTypeSpecializedAppendContextReal;
-
-G_STATIC_ASSERT (sizeof (DBusGTypeSpecializedAppendContextReal) ==
- sizeof (DBusGTypeSpecializedAppendContext));
-
-/**
- * dbus_g_type_specialized_init_append:
- * @value: a #GValue containing an instance of specialized type
- * @ctx: a #DBusGTypeSpecializedAppendContext in which to return a new appending context.
- *
- * Create a new context for adding elements to a collection or key/value pairs
- * to a map. You generally don't need or want to use this..
- *
- * Deprecated: New code should use GDBus instead.
- */
-void
-dbus_g_type_specialized_init_append (GValue *value, DBusGTypeSpecializedAppendContext *ctx)
-{
- DBusGTypeSpecializedAppendContextReal *realctx = (DBusGTypeSpecializedAppendContextReal *) ctx;
- GType gtype;
- DBusGTypeSpecializedData *specdata;
-
- dbus_g_type_specialized_init();
-
- g_return_if_fail (G_VALUE_HOLDS_BOXED (value));
- gtype = G_VALUE_TYPE (value);
- specdata = lookup_specialization_data (gtype);
- g_return_if_fail (specdata != NULL);
- g_return_if_fail (specdata->num_types != 0);
-
- realctx->val = value;
- realctx->specialization_type = specdata->types[0];
- realctx->specdata = specdata;
-}
-
-/**
- * dbus_g_type_specialized_collection_append:
- * @ctx: a context created by dbus_g_type_specialized_init_append()
- * for a #GValue containing a collection
- * @elt: a #GValue containing an element to append to the collection
- *
- * Appends a given element to the end of a collection.
- *
- * Deprecated: New code should use GDBus instead.
- */
-void
-dbus_g_type_specialized_collection_append (DBusGTypeSpecializedAppendContext *ctx,
- GValue *elt)
-{
- DBusGTypeSpecializedAppendContextReal *realctx = (DBusGTypeSpecializedAppendContextReal *) ctx;
-
- g_return_if_fail (dbus_g_type_is_collection (G_VALUE_TYPE (ctx->val)));
-
- ((DBusGTypeSpecializedCollectionVtable *) realctx->specdata->klass->vtable)->append_func (ctx, elt);
-}
-
-/**
- * dbus_g_type_specialized_collection_end_append:
- * @ctx: a context created by dbus_g_type_specialized_init_append()
- * for a #GValue containing a collection
- *
- * Finish appending elements to a given collection
- *
- * Deprecated: New code should use GDBus instead.
- */
-void
-dbus_g_type_specialized_collection_end_append (DBusGTypeSpecializedAppendContext *ctx)
-{
- DBusGTypeSpecializedAppendContextReal *realctx = (DBusGTypeSpecializedAppendContextReal *) ctx;
-
- g_return_if_fail (dbus_g_type_is_collection (G_VALUE_TYPE (ctx->val)));
-
- if (((DBusGTypeSpecializedCollectionVtable *) realctx->specdata->klass->vtable)->end_append_func != NULL)
- ((DBusGTypeSpecializedCollectionVtable *) realctx->specdata->klass->vtable)->end_append_func (ctx);
-}
-
-/**
- * dbus_g_type_specialized_map_append:
- * @ctx: a context created by dbus_g_type_specialized_init_append()
- * for a #GValue containing a map
- * @key: a GValue containing a key, whose contents will be stolen by @ctx
- * @val: a GValue containing a value, whose contents will be stolen by @ctx
- *
- * Inserts the given key/value pair into the map instance.
- *
- * Deprecated: New code should use GDBus instead.
- */
-void
-dbus_g_type_specialized_map_append (DBusGTypeSpecializedAppendContext *ctx,
- GValue *key,
- GValue *val)
-{
- DBusGTypeSpecializedAppendContextReal *realctx = (DBusGTypeSpecializedAppendContextReal *) ctx;
-
- g_return_if_fail (dbus_g_type_is_map (G_VALUE_TYPE (ctx->val)));
-
- ((DBusGTypeSpecializedMapVtable *) realctx->specdata->klass->vtable)->append_func (ctx, key, val);
-}
-
-
-/**
- * dbus_g_type_map_value_iterate:
- * @value: a #GValue holding a specialized map
- * @iterator: a function to call for each element
- * @user_data: user data to pass to the @iterator
- *
- * Calls the given function for each key/value pair of the map.
- * The function is passed two GValues containing the key/value pair and the given
- * @user_data parameter. The map may not be modified while iterating over
- * it.
- *
- * Deprecated: New code should use GDBus instead.
- */
-void
-dbus_g_type_map_value_iterate (const GValue *value,
- DBusGTypeSpecializedMapIterator iterator,
- gpointer user_data)
-{
- DBusGTypeSpecializedData *data;
- GType gtype;
-
- dbus_g_type_specialized_init();
-
- g_return_if_fail (G_VALUE_HOLDS_BOXED (value));
-
- gtype = G_VALUE_TYPE (value);
- g_return_if_fail (dbus_g_type_is_map (gtype));
-
- data = lookup_specialization_data (gtype);
- /* already checked by dbus_g_type_is_map() */
- g_assert (data != NULL);
-
- ((DBusGTypeSpecializedMapVtable *) data->klass->vtable)->iterator (gtype,
- g_value_get_boxed (value),
- iterator, user_data);
-}
-
-/**
- * dbus_g_type_struct_get_member:
- * @value: a #GValue containing a struct instance
- * @member: the index of a given member
- * @dest: an initialised #GValue in which to return the struct member
- *
- * Fetches a given member of a given struct instance. @dest must be initialised
- * was the correct type for that member, e.g. as returned by
- * @dbus_g_type_get_struct_member_type
- *
- * Returns: %TRUE if successful
- *
- * Deprecated: New code should use GDBus instead.
- */
-gboolean
-dbus_g_type_struct_get_member (const GValue *value,
- guint member,
- GValue *dest)
-{
- DBusGTypeSpecializedData *data;
- GType gtype;
-
- dbus_g_type_specialized_init();
-
- g_return_val_if_fail (G_VALUE_HOLDS_BOXED (value), FALSE);
-
- gtype = G_VALUE_TYPE (value);
- g_return_val_if_fail (dbus_g_type_is_struct (gtype), FALSE);
-
- data = lookup_specialization_data (gtype);
- /* already checked by dbus_g_type_is_struct() */
- g_assert (data != NULL);
-
- return ((DBusGTypeSpecializedStructVtable *) (data->klass->vtable))->get_member(gtype,
- g_value_get_boxed (value),
- member, dest);
-}
-
-/**
- * dbus_g_type_struct_set_member:
- * @value: a #GValue containing a struct instance
- * @member: the index of a given member
- * @src: an #GValue containing the new value for that struct member
- *
- * Sets a given member of a struct to a new value. The type of @src must match
- * the existing type of @member member of the struct.
- *
- * Returns: %TRUE if successful
- *
- * Deprecated: New code should use GDBus instead.
- */
-gboolean
-dbus_g_type_struct_set_member (GValue *value,
- guint member,
- const GValue *src)
-{
- DBusGTypeSpecializedData *data;
- GType gtype;
-
- dbus_g_type_specialized_init();
-
- g_return_val_if_fail (G_VALUE_HOLDS_BOXED (value), FALSE);
-
- gtype = G_VALUE_TYPE (value);
- g_return_val_if_fail (dbus_g_type_is_struct (gtype), FALSE);
-
- data = lookup_specialization_data (gtype);
- /* already checked by dbus_g_type_is_struct() */
- g_assert (data != NULL);
-
- return ((DBusGTypeSpecializedStructVtable *) (data->klass->vtable))->set_member(gtype,
- g_value_get_boxed (value),
- member, src);
-}
-
-/**
- * dbus_g_type_struct_get:
- * @value: a #GValue containing a struct instance
- * @member: struct member to get
- * @...: location in which to return the value of this member,
- * followed optionally by more member/return locations pairs, followed
- * by %G_MAXUINT
- *
- * Collects the selected values of this struct into the return locations
- * provided.
- *
- * Returns: %FALSE on failure
- *
- * Deprecated: New code should use GDBus instead.
- */
-
-gboolean
-dbus_g_type_struct_get (const GValue *value,
- guint first_member,
- ...)
-{
- va_list var_args;
- GType type;
- guint size,i;
- gchar *error;
- GValue val = {0,};
-
- g_return_val_if_fail (dbus_g_type_is_struct (G_VALUE_TYPE (value)), FALSE);
-
- va_start (var_args, first_member);
- size = dbus_g_type_get_struct_size (G_VALUE_TYPE (value));
- i = first_member;
- while (i != G_MAXUINT)
- {
- if (i >= size)
- goto error;
-
- type = dbus_g_type_get_struct_member_type (G_VALUE_TYPE (value),i);
-
- g_value_init (&val, type);
- dbus_g_type_struct_get_member (value, i, &val);
-
- G_VALUE_LCOPY (&val, var_args, 0, &error);
- if (error)
- {
- g_warning ("%s, %s", G_STRFUNC, error);
- g_free (error);
- g_value_unset (&val);
- goto error;
- }
- g_value_unset (&val);
- i = va_arg (var_args, guint);
- }
- va_end (var_args);
- return TRUE;
-error:
- va_end (var_args);
- return FALSE;
-}
-
-/**
- * dbus_g_type_struct_set:
- * @value: a #GValue containing a struct instance
- * @member: struct member to set
- * @...: value for the first member, followed optionally by
- * more member/value pairs, followed by %G_MAXUINT
- *
- * Sets the selected members of the struct in @value.
- *
- * Returns: %FALSE on failure
- *
- * Deprecated: New code should use GDBus instead.
- */
-
-gboolean
-dbus_g_type_struct_set (GValue *value,
- guint first_member,
- ...)
-{
- va_list var_args;
- GType type;
- guint size,i;
- gchar *error;
- GValue val = {0,};
-
- g_return_val_if_fail (dbus_g_type_is_struct (G_VALUE_TYPE (value)), FALSE);
-
- va_start (var_args, first_member);
- size = dbus_g_type_get_struct_size (G_VALUE_TYPE (value));
- i = first_member;
- while (i != G_MAXUINT)
- {
- if (i >= size)
- goto error;
-
- type = dbus_g_type_get_struct_member_type (G_VALUE_TYPE (value),i);
-
- g_value_init (&val, type);
-
- G_VALUE_COLLECT (&val, var_args, 0, &error);
- if (error)
- {
- g_warning ("%s, %s", G_STRFUNC, error);
- g_free (error);
- g_value_unset (&val);
- goto error;
- }
-
- dbus_g_type_struct_set_member (value, i, &val);
-
- g_value_unset (&val);
- i = va_arg (var_args, guint);
- }
- va_end (var_args);
- return TRUE;
-error:
- va_end (var_args);
- return FALSE;
-}
-
-static void
-_collection_iterator (const GValue *value,
- gpointer user_data)
-{
- GPtrArray *children = user_data;
-
- g_ptr_array_add (children, dbus_g_value_build_g_variant (value));
-}
-
-static void
-_map_iterator (const GValue *kvalue,
- const GValue *vvalue,
- gpointer user_data)
-{
- GPtrArray *children = user_data;
-
- g_ptr_array_add (children,
- g_variant_new_dict_entry (
- dbus_g_value_build_g_variant (kvalue),
- dbus_g_value_build_g_variant (vvalue)));
-}
-
-static GVariantType *
-dbus_g_value_type_build_g_variant_type (GType type)
-{
- if (dbus_g_type_is_collection (type))
- {
- GType element_type = dbus_g_type_get_collection_specialization (type);
- GVariantType *element_sig = dbus_g_value_type_build_g_variant_type (
- element_type);
- GVariantType *ret = g_variant_type_new_array (element_sig);
-
- g_variant_type_free (element_sig);
- return ret;
- }
- else if (dbus_g_type_is_map (type))
- {
- GType key_type = dbus_g_type_get_map_key_specialization (type);
- GType value_type = dbus_g_type_get_map_value_specialization (type);
- GVariantType *key_sig = dbus_g_value_type_build_g_variant_type (
- key_type);
- GVariantType *value_sig = dbus_g_value_type_build_g_variant_type (
- value_type);
- GVariantType *entry_sig = g_variant_type_new_dict_entry (key_sig,
- value_sig);
- GVariantType *ret = g_variant_type_new_array (entry_sig);
-
- g_variant_type_free (key_sig);
- g_variant_type_free (value_sig);
- g_variant_type_free (entry_sig);
- return ret;
- }
- else if (dbus_g_type_is_struct (type))
- {
- guint size = dbus_g_type_get_struct_size (type);
- guint i;
- GVariantType **sigs = g_new0 (GVariantType *, size);
- GVariantType *ret;
-
- for (i = 0; i < size; i++)
- {
- GType t = dbus_g_type_get_struct_member_type (type, i);
-
- sigs[i] = dbus_g_value_type_build_g_variant_type (t);
- }
-
- ret = g_variant_type_new_tuple ((const GVariantType * const *) sigs,
- size);
-
- for (i = 0; i < size; i++)
- g_variant_type_free (sigs[i]);
-
- g_free (sigs);
- return ret;
- }
- else if (type == G_TYPE_BOOLEAN)
- return g_variant_type_copy (G_VARIANT_TYPE_BOOLEAN);
- else if (type == G_TYPE_UCHAR)
- return g_variant_type_copy (G_VARIANT_TYPE_BYTE);
- else if (type == G_TYPE_INT)
- return g_variant_type_copy (G_VARIANT_TYPE_INT32);
- else if (type == G_TYPE_UINT)
- return g_variant_type_copy (G_VARIANT_TYPE_UINT32);
- else if (type == G_TYPE_INT64)
- return g_variant_type_copy (G_VARIANT_TYPE_INT64);
- else if (type == G_TYPE_UINT64)
- return g_variant_type_copy (G_VARIANT_TYPE_UINT64);
- else if (type == G_TYPE_DOUBLE)
- return g_variant_type_copy (G_VARIANT_TYPE_DOUBLE);
- else if (type == G_TYPE_STRING)
- return g_variant_type_copy (G_VARIANT_TYPE_STRING);
- else if (type == G_TYPE_STRV)
- return g_variant_type_copy (G_VARIANT_TYPE_STRING_ARRAY);
- else if (type == DBUS_TYPE_G_OBJECT_PATH)
- return g_variant_type_copy (G_VARIANT_TYPE_OBJECT_PATH);
- else if (type == DBUS_TYPE_G_SIGNATURE)
- return g_variant_type_copy (G_VARIANT_TYPE_SIGNATURE);
- else if (type == G_TYPE_VALUE)
- return g_variant_type_copy (G_VARIANT_TYPE_VARIANT);
- else
- g_error ("%s: Unknown type: %s", G_STRFUNC, g_type_name (type));
-}
-
-/**
- * dbus_g_value_build_g_variant:
- * @value: a simple or specialized #GValue to convert to a #GVariant
- *
- * Recurses @value and converts its contents to a #GVariant.
- *
- * The value must either be a simple value (integer, string, boolean,
- * object path etc.) or a specialized container registered with
- * dbus_g_type_get_collection(), dbus_g_type_get_map() or
- * dbus_g_type_get_struct(). Providing any other type is a programming error
- * (including as a child type).
- *
- * Returns: a new #GVariant containing @value with a floating reference
- *
- * Deprecated: New code should use GDBus instead.
- */
-GVariant *
-dbus_g_value_build_g_variant (const GValue *value)
-{
- GType type;
-
- g_return_val_if_fail (G_IS_VALUE (value), NULL);
-
- type = G_VALUE_TYPE (value);
-
- if (dbus_g_type_is_collection (type))
- {
- GVariant *variant;
- GPtrArray *children;
- GVariantType *signature = NULL;
-
- children = g_ptr_array_new ();
- dbus_g_type_collection_value_iterate (value, _collection_iterator,
- children);
-
- if (children->len == 0)
- {
- /* we can't cheat by saying "the type of the children? that!" */
- GType element_type = dbus_g_type_get_collection_specialization (
- type);
-
- signature = dbus_g_value_type_build_g_variant_type (element_type);
- }
-
- variant = g_variant_new_array (signature, (GVariant **) children->pdata,
- children->len);
- g_ptr_array_free (children, TRUE);
- g_variant_type_free (signature);
-
- return variant;
- }
- else if (dbus_g_type_is_map (type))
- {
- GVariant *variant;
- GPtrArray *children;
- GVariantType *signature = NULL;
-
- children = g_ptr_array_new ();
- dbus_g_type_map_value_iterate (value, _map_iterator, children);
-
- if (children->len == 0)
- {
- /* we can't cheat by saying "the type of the children? that!" */
- GType key_type = dbus_g_type_get_map_key_specialization (
- type);
- GType value_type = dbus_g_type_get_map_value_specialization (
- type);
- GVariantType *k = dbus_g_value_type_build_g_variant_type (key_type);
- GVariantType *v = dbus_g_value_type_build_g_variant_type (
- value_type);
-
- signature = g_variant_type_new_dict_entry (k, v);
- g_variant_type_free (k);
- g_variant_type_free (v);
- }
-
- variant = g_variant_new_array (signature, (GVariant **) children->pdata,
- children->len);
- g_ptr_array_free (children, TRUE);
- g_variant_type_free (signature);
-
- return variant;
- }
- else if (dbus_g_type_is_struct (type))
- {
- GVariant *variant, **children;
- guint size, i;
-
- size = dbus_g_type_get_struct_size (type);
- children = g_new0 (GVariant *, size);
-
- for (i = 0; i < size; i++)
- {
- GValue cvalue = { 0, };
-
- g_value_init (&cvalue, dbus_g_type_get_struct_member_type (type, i));
- dbus_g_type_struct_get_member (value, i, &cvalue);
-
- children[i] = dbus_g_value_build_g_variant (&cvalue);
- g_value_unset (&cvalue);
- }
-
- variant = g_variant_new_tuple (children, size);
- g_free (children);
-
- return variant;
- }
- else if (type == G_TYPE_BOOLEAN)
- return g_variant_new_boolean (g_value_get_boolean (value));
- else if (type == G_TYPE_UCHAR)
- return g_variant_new_byte (g_value_get_uchar (value));
- else if (type == G_TYPE_INT)
- return g_variant_new_int32 (g_value_get_int (value));
- else if (type == G_TYPE_UINT)
- return g_variant_new_uint32 (g_value_get_uint (value));
- else if (type == G_TYPE_INT64)
- return g_variant_new_int64 (g_value_get_int64 (value));
- else if (type == G_TYPE_UINT64)
- return g_variant_new_uint64 (g_value_get_uint64 (value));
- else if (type == G_TYPE_DOUBLE)
- return g_variant_new_double (g_value_get_double (value));
- else if (type == G_TYPE_STRING)
- {
- const gchar *str = g_value_get_string (value);
- return g_variant_new_string ((str != NULL) ? str : "");
- }
- else if (type == G_TYPE_STRV)
- {
- const gchar * const *strv = g_value_get_boxed (value);
- return g_variant_new_strv (strv, (strv != NULL) ? -1 : 0);
- }
- else if (type == DBUS_TYPE_G_OBJECT_PATH)
- return g_variant_new_object_path (g_value_get_boxed (value));
- else if (type == DBUS_TYPE_G_SIGNATURE)
- return g_variant_new_signature (g_value_get_boxed (value));
- else if (type == G_TYPE_VALUE)
- return g_variant_new_variant (
- dbus_g_value_build_g_variant (g_value_get_boxed (value)));
- else
- {
- g_error ("%s: Unknown type: %s", G_STRFUNC, g_type_name (type));
- }
-}
diff --git a/dbus/dbus-gtype-specialized.h b/dbus/dbus-gtype-specialized.h
deleted file mode 100644
index e40cdc7..0000000
--- a/dbus/dbus-gtype-specialized.h
+++ /dev/null
@@ -1,178 +0,0 @@
-/* -*- mode: C; c-file-style: "gnu" -*- */
-/* dbus-gtype-specialized.h: Non-DBus-specific functions for specialized GTypes
- *
- * Copyright (C) 2005 Red Hat, Inc.
- *
- * Licensed under the Academic Free License version 2.1
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- */
-
-#ifndef DBUS_GOBJECT_TYPE_SPECIALIZED_H
-#define DBUS_GOBJECT_TYPE_SPECIALIZED_H
-
-#include <glib.h>
-#include <glib-object.h>
-
-G_BEGIN_DECLS
-
-GType dbus_g_type_get_collection (const char *container,
- GType specialization);
-GType dbus_g_type_get_map (const char *container,
- GType key_specialization,
- GType value_specialization);
-GType dbus_g_type_get_structv (const char *container,
- guint num_members,
- GType *types);
-GType dbus_g_type_get_struct (const char *container,
- GType first_type,
- ...);
-gboolean dbus_g_type_is_collection (GType gtype);
-gboolean dbus_g_type_is_map (GType gtype);
-gboolean dbus_g_type_is_struct (GType gtype);
-GType dbus_g_type_get_collection_specialization (GType gtype);
-GType dbus_g_type_get_map_key_specialization (GType gtype);
-GType dbus_g_type_get_map_value_specialization (GType gtype);
-GType dbus_g_type_get_struct_member_type (GType gtype,
- guint member);
-guint dbus_g_type_get_struct_size (GType gtype);
-
-typedef void (*DBusGTypeSpecializedCollectionIterator) (const GValue *value,
- gpointer user_data);
-typedef void (*DBusGTypeSpecializedMapIterator) (const GValue *key_val,
- const GValue *value_val,
- gpointer user_data);
-
-gpointer dbus_g_type_specialized_construct (GType gtype);
-
-typedef struct {
- /* public */
- GValue *val;
- GType specialization_type;
- /*< private >*/
- /* padding */
- gpointer b;
- guint c;
- gpointer d;
-} DBusGTypeSpecializedAppendContext;
-
-void dbus_g_type_specialized_init_append (GValue *value, DBusGTypeSpecializedAppendContext *ctx);
-
-void dbus_g_type_specialized_collection_append (DBusGTypeSpecializedAppendContext *ctx, GValue *elt);
-
-void dbus_g_type_specialized_collection_end_append (DBusGTypeSpecializedAppendContext *ctx);
-
-void dbus_g_type_specialized_map_append (DBusGTypeSpecializedAppendContext *ctx,
- GValue *key,
- GValue *val);
-
-
-gboolean dbus_g_type_collection_get_fixed (GValue *value,
- gpointer *data_ret,
- guint *len_ret);
-
-void dbus_g_type_collection_value_iterate (const GValue *value,
- DBusGTypeSpecializedCollectionIterator iterator,
- gpointer user_data);
-
-void dbus_g_type_map_value_iterate (const GValue *value,
- DBusGTypeSpecializedMapIterator iterator,
- gpointer user_data);
-
-gboolean dbus_g_type_struct_get_member (const GValue *value,
- guint member,
- GValue *dest);
-gboolean dbus_g_type_struct_set_member (GValue *value,
- guint member,
- const GValue *src);
-
-gboolean dbus_g_type_struct_get (const GValue *value,
- guint member,
- ...);
-
-gboolean dbus_g_type_struct_set (GValue *value,
- guint member,
- ...);
-
-typedef gpointer (*DBusGTypeSpecializedConstructor) (GType type);
-typedef void (*DBusGTypeSpecializedFreeFunc) (GType type, gpointer val);
-typedef gpointer (*DBusGTypeSpecializedCopyFunc) (GType type, gpointer src);
-
-typedef struct {
- DBusGTypeSpecializedConstructor constructor;
- DBusGTypeSpecializedFreeFunc free_func;
- DBusGTypeSpecializedCopyFunc copy_func;
- GDestroyNotify simple_free_func; /* for type-independent freeing if possible */
- /*<private>*/
- gpointer padding2;
- gpointer padding3;
-} DBusGTypeSpecializedVtable;
-
-typedef gboolean (*DBusGTypeSpecializedCollectionFixedAccessorFunc) (GType type, gpointer instance, gpointer *values, guint *len);
-typedef void (*DBusGTypeSpecializedCollectionIteratorFunc) (GType type, gpointer instance, DBusGTypeSpecializedCollectionIterator iterator, gpointer user_data);
-typedef void (*DBusGTypeSpecializedCollectionAppendFunc) (DBusGTypeSpecializedAppendContext *ctx, GValue *val);
-typedef void (*DBusGTypeSpecializedCollectionEndAppendFunc) (DBusGTypeSpecializedAppendContext *ctx);
-
-typedef struct {
- DBusGTypeSpecializedVtable base_vtable;
- DBusGTypeSpecializedCollectionFixedAccessorFunc fixed_accessor;
- DBusGTypeSpecializedCollectionIteratorFunc iterator;
- DBusGTypeSpecializedCollectionAppendFunc append_func;
- DBusGTypeSpecializedCollectionEndAppendFunc end_append_func;
-} DBusGTypeSpecializedCollectionVtable;
-
-typedef void (*DBusGTypeSpecializedMapIteratorFunc) (GType type, gpointer instance, DBusGTypeSpecializedMapIterator iterator, gpointer user_data);
-typedef void (*DBusGTypeSpecializedMapAppendFunc) (DBusGTypeSpecializedAppendContext *ctx, GValue *key, GValue *val);
-
-typedef struct {
- DBusGTypeSpecializedVtable base_vtable;
- DBusGTypeSpecializedMapIteratorFunc iterator;
- DBusGTypeSpecializedMapAppendFunc append_func;
-} DBusGTypeSpecializedMapVtable;
-
-typedef gboolean (*DBusGTypeSpecializedStructGetMember) (GType type, gpointer instance, guint member, GValue *ret_value);
-typedef gboolean (*DBusGTypeSpecializedStructSetMember) (GType type, gpointer instance, guint member, const GValue *new_value);
-
-typedef struct {
- DBusGTypeSpecializedVtable base_vtable;
- DBusGTypeSpecializedStructGetMember get_member;
- DBusGTypeSpecializedStructSetMember set_member;
-} DBusGTypeSpecializedStructVtable;
-
-void dbus_g_type_specialized_init (void);
-
-void dbus_g_type_register_collection (const char *name,
- const DBusGTypeSpecializedCollectionVtable *vtable,
- guint flags);
-
-void dbus_g_type_register_map (const char *name,
- const DBusGTypeSpecializedMapVtable *vtable,
- guint flags);
-
-void dbus_g_type_register_struct (const char *name,
- const DBusGTypeSpecializedStructVtable *vtable,
- guint flags);
-
-const DBusGTypeSpecializedMapVtable* dbus_g_type_map_peek_vtable (GType map_type);
-const DBusGTypeSpecializedCollectionVtable* dbus_g_type_collection_peek_vtable (GType collection_type);
-
-const DBusGTypeSpecializedStructVtable* dbus_g_type_struct_peek_vtable (GType struct_type);
-
-GVariant *dbus_g_value_build_g_variant (const GValue *value);
-
-G_END_DECLS
-
-#endif
diff --git a/dbus/dbus-gutils.c b/dbus/dbus-gutils.c
deleted file mode 100644
index f70c760..0000000
--- a/dbus/dbus-gutils.c
+++ /dev/null
@@ -1,109 +0,0 @@
-/* -*- mode: C; c-file-style: "gnu" -*- */
-/* dbus-gutils.c Utils shared between convenience lib and installed lib
- *
- * Copyright (C) 2003 Red Hat, Inc.
- *
- * Licensed under the Academic Free License version 2.1
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- */
-
-#include <config.h>
-#include "dbus-gutils.h"
-#include "dbus-gtest.h"
-#include <string.h>
-
-char**
-_dbus_gutils_split_path (const char *path)
-{
- int len;
- char **split;
- int n_components;
- int i, j, comp;
-
- len = strlen (path);
-
- n_components = 0;
- if (path[1] != '\0') /* if not "/" */
- {
- i = 0;
- while (i < len)
- {
- if (path[i] == '/')
- n_components += 1;
- ++i;
- }
- }
-
- split = g_new0 (char*, n_components + 1);
-
- comp = 0;
- if (n_components == 0)
- i = 1;
- else
- i = 0;
- while (comp < n_components)
- {
- if (path[i] == '/')
- ++i;
- j = i;
-
- while (j < len && path[j] != '/')
- ++j;
-
- /* Now [i, j) is the path component */
- g_assert (i < j);
- g_assert (path[i] != '/');
- g_assert (j == len || path[j] == '/');
-
- split[comp] = g_strndup (&path[i], j - i + 1);
-
- split[comp][j-i] = '\0';
-
- ++comp;
- i = j;
- }
- g_assert (i == len);
-
- return split;
-}
-
-char*
-_dbus_gutils_wincaps_to_uscore (const char *caps)
-{
- const char *p;
- GString *str;
-
- str = g_string_new (NULL);
- p = caps;
- while (*p)
- {
- if (g_ascii_isupper (*p))
- {
- if (str->len > 0 &&
- (str->len < 2 || str->str[str->len-2] != '_'))
- g_string_append_c (str, '_');
- g_string_append_c (str, g_ascii_tolower (*p));
- }
- else
- {
- g_string_append_c (str, *p);
- }
- ++p;
- }
-
- return g_string_free (str, FALSE);
-}
diff --git a/dbus/dbus-gutils.h b/dbus/dbus-gutils.h
deleted file mode 100644
index 8468a55..0000000
--- a/dbus/dbus-gutils.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/* -*- mode: C; c-file-style: "gnu" -*- */
-/* dbus-gutils.h Utils shared between convenience lib and installed lib
- *
- * Copyright (C) 2003 Red Hat, Inc.
- *
- * Licensed under the Academic Free License version 2.1
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- */
-
-#ifndef DBUS_GLIB_UTILS_H
-#define DBUS_GLIB_UTILS_H
-
-#include <dbus/dbus.h>
-#include <glib-object.h>
-
-G_BEGIN_DECLS
-
-char **_dbus_gutils_split_path (const char *path);
-
-char *_dbus_gutils_wincaps_to_uscore (const char *uscore);
-
-/* These munge the pointer to enforce that a plain cast won't work,
- * accessor functions must be used; i.e. to ensure the ABI
- * reflects our encapsulation.
- */
-#define _DBUS_POINTER_SHIFT(p) ((void*) (((char*)p) + sizeof (void*)))
-#define _DBUS_POINTER_UNSHIFT(p) ((void*) (((char*)p) - sizeof (void*)))
-
-#define DBUS_CONNECTION_FROM_G_CONNECTION(x) ((DBusConnection*) _DBUS_POINTER_UNSHIFT(x))
-#define DBUS_MESSAGE_FROM_G_MESSAGE(x) ((DBusMessage*) _DBUS_POINTER_UNSHIFT(x))
-#define DBUS_PENDING_CALL_FROM_G_PENDING_CALL(x) ((DBusPendingCall*) _DBUS_POINTER_UNSHIFT(x))
-
-#define DBUS_G_CONNECTION_FROM_CONNECTION(x) ((DBusGConnection*) _DBUS_POINTER_SHIFT(x))
-#define DBUS_G_MESSAGE_FROM_MESSAGE(x) ((DBusGMessage*) _DBUS_POINTER_SHIFT(x))
-#define DBUS_G_PENDING_CALL_FROM_PENDING_CALL(x) ((DBusGPendingCall*) _DBUS_POINTER_SHIFT(x))
-
-G_END_DECLS
-
-#endif /* DBUS_GLIB_UTILS_H */
diff --git a/dbus/dbus-gvalue-parse-variant.c b/dbus/dbus-gvalue-parse-variant.c
deleted file mode 100644
index 29c4336..0000000
--- a/dbus/dbus-gvalue-parse-variant.c
+++ /dev/null
@@ -1,549 +0,0 @@
-/* GVariant to dbus-glib escape hatch
- *
- * Copyright © 2010 Collabora Ltd. <http://www.collabora.co.uk/>
- *
- * Licensed under the Academic Free License version 2.1
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * Alternatively, at your option, you can redistribute and/or modify
- * this single file under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 2.1 of
- * that license, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- */
-
-#include <config.h>
-
-#include <dbus/dbus-gvalue-parse-variant.h>
-
-#include <string.h>
-
-#include <dbus/dbus-glib.h>
-
-/* Static functions in this file are a bit weird: they take a GVariant as first
- * argument, but it can be NULL. If it is, @value will be initialized with the
- * right type for that GVariant, but not filled in, so it'll contain 0 or NULL
- * or whatever. */
-
-static void dbus_g_value_parse_variant_by_type (GVariant *variant,
- const GVariantType *variant_type,
- GValue *value);
-
-static void
-dbus_g_value_dict_parse_variant (GVariant *variant,
- const GVariantType *member_type,
- GValue *value)
-{
- const GVariantType *key_type, *value_type;
- GValue key_parsed = { 0 }, value_parsed = { 0 };
-
- g_assert (g_variant_type_is_dict_entry (member_type));
- key_type = g_variant_type_key (member_type);
- value_type = g_variant_type_value (member_type);
-
- /* first get the GTypes, without getting actual values */
- dbus_g_value_parse_variant_by_type (NULL, key_type, &key_parsed);
- dbus_g_value_parse_variant_by_type (NULL, value_type, &value_parsed);
-
- g_value_init (value, dbus_g_type_get_map ("GHashTable",
- G_VALUE_TYPE (&key_parsed),
- G_VALUE_TYPE (&value_parsed)));
- g_value_unset (&key_parsed);
- g_value_unset (&value_parsed);
-
- if (variant != NULL)
- {
- GVariantIter iter;
- GVariant *child;
- DBusGTypeSpecializedAppendContext ctx;
-
- g_value_take_boxed (value, dbus_g_type_specialized_construct (
- G_VALUE_TYPE (value)));
- dbus_g_type_specialized_init_append (value, &ctx);
-
- g_variant_iter_init (&iter, variant);
-
- for (child = g_variant_iter_next_value (&iter);
- child != NULL;
- child = g_variant_iter_next_value (&iter))
- {
- GVariant *grandchild;
-
- grandchild = g_variant_get_child_value (child, 0);
- dbus_g_value_parse_variant_by_type (grandchild, key_type,
- &key_parsed);
- g_variant_unref (grandchild);
-
- grandchild = g_variant_get_child_value (child, 1);
- dbus_g_value_parse_variant_by_type (grandchild, value_type,
- &value_parsed);
- g_variant_unref (grandchild);
-
- /* Here be dragons: this steals the *contents of* key_parsed and
- * value_parsed, so we can't g_value_unset() them. */
- dbus_g_type_specialized_map_append (&ctx, &key_parsed,
- &value_parsed);
- memset (&key_parsed, '\0', sizeof (key_parsed));
- memset (&value_parsed, '\0', sizeof (value_parsed));
- g_variant_unref (child);
- }
- }
-}
-
-static void
-dbus_g_value_basic_array_parse_variant (GVariant *variant,
- gchar type_char,
- GValue *value)
-{
- GType gtype = G_TYPE_INVALID;
- guint dg_size = 0, gv_size = 0;
-
- switch ((GVariantClass) type_char)
- {
- case G_VARIANT_CLASS_STRING:
- g_value_init (value, G_TYPE_STRV);
-
- if (variant != NULL)
- g_value_take_boxed (value, g_variant_dup_strv (variant, NULL));
- return;
-
- case G_VARIANT_CLASS_OBJECT_PATH:
- case G_VARIANT_CLASS_SIGNATURE:
- {
- if (type_char == G_VARIANT_CLASS_OBJECT_PATH)
- gtype = DBUS_TYPE_G_OBJECT_PATH;
- else
- gtype = DBUS_TYPE_G_SIGNATURE;
-
- g_value_init (value,
- dbus_g_type_get_collection ("GPtrArray", gtype));
-
- if (variant != NULL)
- {
- gsize n = g_variant_n_children (variant);
- gsize i;
- GPtrArray *pa = g_ptr_array_sized_new (n);
-
- for (i = 0; i < n; i++)
- {
- GVariant *child = g_variant_get_child_value (variant, i);
- gchar *s = g_variant_dup_string (child, NULL);
-
- g_ptr_array_add (pa, s);
- g_variant_unref (child);
- }
-
- g_value_take_boxed (value, pa);
- }
- }
- return;
-
- /* From here down handles fixed-size types. */
-
- case G_VARIANT_CLASS_BYTE:
- gtype = G_TYPE_UCHAR;
- gv_size = dg_size = sizeof (guchar);
- break;
-
- case G_VARIANT_CLASS_BOOLEAN:
- gtype = G_TYPE_BOOLEAN;
- dg_size = sizeof (gboolean);
- gv_size = sizeof (guchar);
- break;
-
- case G_VARIANT_CLASS_INT16:
- gtype = G_TYPE_INT;
- dg_size = sizeof (gint);
- gv_size = sizeof (gint16);
- break;
-
- case G_VARIANT_CLASS_INT32:
- gtype = G_TYPE_INT;
- dg_size = sizeof (gint);
- gv_size = sizeof (gint32);
- break;
-
- case G_VARIANT_CLASS_UINT16:
- gtype = G_TYPE_UINT;
- dg_size = sizeof (guint);
- gv_size = sizeof (guint16);
- break;
-
- case G_VARIANT_CLASS_UINT32:
- gtype = G_TYPE_UINT;
- dg_size = sizeof (guint);
- gv_size = sizeof (guint32);
- break;
-
- case G_VARIANT_CLASS_INT64:
- gtype = G_TYPE_INT64;
- dg_size = gv_size = sizeof (gint64);
- break;
-
- case G_VARIANT_CLASS_UINT64:
- gtype = G_TYPE_UINT64;
- dg_size = gv_size = sizeof (guint64);
- break;
-
- case G_VARIANT_CLASS_DOUBLE:
- gtype = G_TYPE_DOUBLE;
- dg_size = gv_size = sizeof (gdouble);
- break;
-
- case G_VARIANT_CLASS_HANDLE:
- case G_VARIANT_CLASS_VARIANT:
- case G_VARIANT_CLASS_MAYBE:
- case G_VARIANT_CLASS_ARRAY:
- case G_VARIANT_CLASS_TUPLE:
- case G_VARIANT_CLASS_DICT_ENTRY:
- g_return_if_reached ();
- }
-
- g_assert (gtype != G_TYPE_INVALID);
- g_assert (dg_size != 0);
- g_assert (gv_size != 0);
-
- g_value_init (value, dbus_g_type_get_collection ("GArray", gtype));
-
- if (variant != NULL)
- {
- GArray *arr;
- gsize n, i;
- gconstpointer blob = g_variant_get_fixed_array (variant, &n, gv_size);
-
- arr = g_array_sized_new (FALSE, FALSE, dg_size, n);
- g_value_take_boxed (value, arr);
-
- if (dg_size == gv_size)
- {
- /* fast path: we can just memcpy them in */
- g_array_append_vals (arr, blob, n);
- }
- else
- {
- DBusGTypeSpecializedAppendContext ctx;
-
- dbus_g_type_specialized_init_append (value, &ctx);
-
- for (i = 0; i < n; i++)
- {
- GVariant *child;
- GValue v = { 0 };
-
- child = g_variant_get_child_value (variant, i);
- dbus_g_value_parse_g_variant (child, &v);
- g_variant_unref (child);
- dbus_g_type_specialized_collection_append (&ctx, &v);
- }
-
- dbus_g_type_specialized_collection_end_append (&ctx);
- }
- }
-}
-
-static void
-dbus_g_value_tuple_parse_variant (GVariant *variant,
- const GVariantType *variant_type,
- GValue *value)
-{
- gsize n = g_variant_type_n_items (variant_type);
- GType *types;
- gsize i;
- GValueArray *va = g_value_array_new (n);
- const GVariantType *inner_type;
-
- types = g_new0 (GType, n);
-
- for (i = 0, inner_type = g_variant_type_first (variant_type);
- i < n;
- i++, inner_type = g_variant_type_next (inner_type))
- {
- GVariant *inner_variant;
-
- if (variant == NULL)
- inner_variant = NULL;
- else
- inner_variant = g_variant_get_child_value (variant, i);
-
- g_value_array_append (va, NULL);
- dbus_g_value_parse_variant_by_type (inner_variant, inner_type,
- &va->values[i]);
- types[i] = G_VALUE_TYPE (&va->values[i]);
-
- if (inner_variant != NULL)
- g_variant_unref (inner_variant);
- }
-
- g_value_init (value, dbus_g_type_get_structv ("GValueArray", n, types));
-
- if (variant == NULL)
- g_value_array_free (va);
- else
- g_value_take_boxed (value, va);
-
- g_free (types);
-}
-
-static void
-dbus_g_value_array_parse_variant (GVariant *variant,
- const GVariantType *variant_type,
- GValue *value)
-{
- const GVariantType *member_type;
- gchar type_char;
- GPtrArray *pa = NULL;
- gsize n = 0, i;
-
- g_assert (g_variant_type_is_array (variant_type));
-
- member_type = g_variant_type_element (variant_type);
- type_char = g_variant_type_peek_string (member_type)[0];
-
- if (g_variant_type_is_dict_entry (member_type))
- {
- dbus_g_value_dict_parse_variant (variant, member_type, value);
- return;
- }
-
- if (g_variant_type_is_basic (member_type))
- {
- dbus_g_value_basic_array_parse_variant (variant, type_char, value);
- return;
- }
-
- /* all the non-basic types end up as a GPtrArray of boxed */
- if (variant != NULL)
- {
- n = g_variant_n_children (variant);
- pa = g_ptr_array_sized_new (n);
- }
-
- switch ((GVariantClass) type_char)
- {
- case G_VARIANT_CLASS_VARIANT:
- {
- g_value_init (value,
- dbus_g_type_get_collection ("GPtrArray", G_TYPE_VALUE));
- }
- break;
-
- case G_VARIANT_CLASS_ARRAY:
- {
- GValue v = { 0 };
-
- dbus_g_value_array_parse_variant (NULL, member_type, &v);
- g_value_init (value, dbus_g_type_get_collection ("GPtrArray",
- G_VALUE_TYPE (&v)));
- }
- break;
-
- case G_VARIANT_CLASS_TUPLE:
- {
- GValue v = { 0 };
-
- dbus_g_value_tuple_parse_variant (NULL, member_type, &v);
- g_value_init (value, dbus_g_type_get_collection ("GPtrArray",
- G_VALUE_TYPE (&v)));
- }
- break;
-
- case G_VARIANT_CLASS_DICT_ENTRY:
- case G_VARIANT_CLASS_MAYBE:
- default:
- g_critical ("unhandled GVariantClass array<%d>", type_char);
- g_return_if_reached ();
- }
-
- if (variant != NULL)
- {
- for (i = 0; i < n; i++)
- {
- GVariant *child = g_variant_get_child_value (variant, i);
- GValue tmp = { 0 };
-
- dbus_g_value_parse_g_variant (child, &tmp);
- g_ptr_array_add (pa, g_value_dup_boxed (&tmp));
- g_variant_unref (child);
- g_value_unset (&tmp);
- }
-
- g_value_take_boxed (value, pa);
- }
-}
-
-static void
-dbus_g_value_parse_variant_by_type (GVariant *variant,
- const GVariantType *variant_type,
- GValue *value)
-{
- gchar type_char = g_variant_type_peek_string (variant_type)[0];
-
- switch ((GVariantClass) type_char)
- {
- case G_VARIANT_CLASS_BOOLEAN:
- g_value_init (value, G_TYPE_BOOLEAN);
-
- if (variant != NULL)
- g_value_set_boolean (value, !!g_variant_get_boolean (variant));
-
- break;
-
- case G_VARIANT_CLASS_BYTE:
- g_value_init (value, G_TYPE_UCHAR);
-
- if (variant != NULL)
- g_value_set_uchar (value, g_variant_get_byte (variant));
-
- break;
-
- case G_VARIANT_CLASS_UINT16:
- /* there is no G_TYPE_UINT16 */
- g_value_init (value, G_TYPE_UINT);
-
- if (variant != NULL)
- g_value_set_uint (value, g_variant_get_uint16 (variant));
-
- break;
-
- case G_VARIANT_CLASS_UINT32:
- g_value_init (value, G_TYPE_UINT);
-
- if (variant != NULL)
- g_value_set_uint (value, g_variant_get_uint32 (variant));
-
- break;
-
- case G_VARIANT_CLASS_UINT64:
- g_value_init (value, G_TYPE_UINT64);
-
- if (variant != NULL)
- g_value_set_uint64 (value, g_variant_get_uint64 (variant));
-
- break;
-
- case G_VARIANT_CLASS_INT16:
- /* there is no G_TYPE_INT16 */
- g_value_init (value, G_TYPE_INT);
-
- if (variant != NULL)
- g_value_set_int (value, g_variant_get_int16 (variant));
-
- break;
-
- case G_VARIANT_CLASS_INT32:
- g_value_init (value, G_TYPE_INT);
-
- if (variant != NULL)
- g_value_set_int (value, g_variant_get_int32 (variant));
-
- break;
-
- case G_VARIANT_CLASS_INT64:
- g_value_init (value, G_TYPE_INT64);
-
- if (variant != NULL)
- g_value_set_int64 (value, g_variant_get_int64 (variant));
-
- break;
-
- case G_VARIANT_CLASS_DOUBLE:
- g_value_init (value, G_TYPE_DOUBLE);
-
- if (variant != NULL)
- g_value_set_double (value, g_variant_get_double (variant));
-
- break;
-
- case G_VARIANT_CLASS_STRING:
- g_value_init (value, G_TYPE_STRING);
-
- if (variant != NULL)
- g_value_set_string (value, g_variant_get_string (variant, NULL));
-
- break;
-
- case G_VARIANT_CLASS_OBJECT_PATH:
- g_value_init (value, DBUS_TYPE_G_OBJECT_PATH);
-
- if (variant != NULL)
- g_value_set_boxed (value, g_variant_get_string (variant, NULL));
-
- break;
-
- case G_VARIANT_CLASS_SIGNATURE:
- g_value_init (value, DBUS_TYPE_G_SIGNATURE);
-
- if (variant != NULL)
- g_value_set_boxed (value, g_variant_get_string (variant, NULL));
-
- break;
-
- case G_VARIANT_CLASS_VARIANT:
- g_value_init (value, G_TYPE_VALUE);
-
- if (variant != NULL)
- {
- GVariant *inner_variant = g_variant_get_variant (variant);
- GValue *inner_value = g_new0 (GValue, 1);
-
- dbus_g_value_parse_g_variant (inner_variant, inner_value);
- g_value_take_boxed (value, inner_value);
- g_variant_unref (inner_variant);
- }
- break;
-
- case G_VARIANT_CLASS_ARRAY:
- dbus_g_value_array_parse_variant (variant, variant_type, value);
- break;
-
- case G_VARIANT_CLASS_TUPLE:
- dbus_g_value_tuple_parse_variant (variant, variant_type, value);
- break;
-
- case G_VARIANT_CLASS_DICT_ENTRY:
- g_critical ("found a dict entry not in a dict");
- break;
-
- case G_VARIANT_CLASS_HANDLE:
- case G_VARIANT_CLASS_MAYBE:
- g_critical ("unhandled GVariantClass '%c' (%d)",
- CLAMP (type_char, ' ', '~'),
- type_char);
- break;
- }
-}
-
-/**
- * dbus_g_value_parse_g_variant:
- * @variant: a #GVariant
- * @value: a zero-filled #GValue
- *
- * Deserialize @variant and put an equivalent dbus-glib data structure in
- * @value.
- *
- * It is an error if @variant contains any #GVariant extensions not supported
- * by dbus-glib, including handles (file descriptor passing) and 'maybe' types.
- *
- * Deprecated: New code should use GDBus instead.
- */
-void
-dbus_g_value_parse_g_variant (GVariant *variant,
- GValue *value)
-{
- g_return_if_fail (variant != NULL);
- dbus_g_value_parse_variant_by_type (variant, g_variant_get_type (variant),
- value);
-}
diff --git a/dbus/dbus-gvalue-parse-variant.h b/dbus/dbus-gvalue-parse-variant.h
deleted file mode 100644
index 9759972..0000000
--- a/dbus/dbus-gvalue-parse-variant.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/* GVariant to dbus-glib escape hatch
- *
- * Copyright © 2010 Collabora Ltd. <http://www.collabora.co.uk/>
- *
- * Licensed under the Academic Free License version 2.1
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * Alternatively, at your option, you can redistribute and/or modify
- * this single file under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 2.1 of
- * that license, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- */
-
-#ifndef __DBUS_GVALUE_PARSE_VARIANT_H__
-#define __DBUS_GVALUE_PARSE_VARIANT_H__
-
-#include <glib-object.h>
-
-G_BEGIN_DECLS
-
-void dbus_g_value_parse_g_variant (GVariant *variant, GValue *value);
-
-G_END_DECLS
-
-#endif
diff --git a/dbus/dbus-gvalue-utils.c b/dbus/dbus-gvalue-utils.c
deleted file mode 100644
index b517620..0000000
--- a/dbus/dbus-gvalue-utils.c
+++ /dev/null
@@ -1,1370 +0,0 @@
-/* -*- mode: C; c-file-style: "gnu" -*- */
-/* dbus-gvalue-utils.c: Non-DBus-specific functions related to GType/GValue
- *
- * Copyright (C) 2005 Red Hat, Inc.
- *
- * Licensed under the Academic Free License version 2.1
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- */
-
-#include <config.h>
-#include "dbus/dbus-glib.h"
-#include "dbus-gtype-specialized-priv.h"
-#include "dbus-gvalue-utils.h"
-#include "dbus-gtest.h"
-#include <glib.h>
-#include <string.h>
-#include <gobject/gvaluecollector.h>
-
-
-static guint
-fixed_type_get_size (GType type)
-{
- switch (type)
- {
- case G_TYPE_CHAR:
- case G_TYPE_UCHAR:
- return sizeof (gchar);
- case G_TYPE_BOOLEAN:
- return sizeof (gboolean);
- case G_TYPE_LONG:
- case G_TYPE_ULONG:
- return sizeof (glong);
- case G_TYPE_INT:
- case G_TYPE_UINT:
- return sizeof (gint);
- case G_TYPE_INT64:
- case G_TYPE_UINT64:
- return sizeof (gint64);
- case G_TYPE_FLOAT:
- return sizeof (gfloat);
- case G_TYPE_DOUBLE:
- return sizeof (gdouble);
- default:
- return 0;
- }
-}
-
-gboolean
-_dbus_g_type_is_fixed (GType type)
-{
- return fixed_type_get_size (type) > 0;
-}
-
-guint
-_dbus_g_type_fixed_get_size (GType type)
-{
- g_assert (_dbus_g_type_is_fixed (type));
- return fixed_type_get_size (type);
-}
-
-gboolean
-_dbus_gvalue_store (GValue *value,
- gpointer storage)
-{
- /* FIXME - can we use the GValue lcopy_value method
- * to do this in a cleaner way?
- */
- switch (g_type_fundamental (G_VALUE_TYPE (value)))
- {
- case G_TYPE_CHAR:
- *((gchar *) storage) = g_value_get_char (value);
- return TRUE;
- case G_TYPE_UCHAR:
- *((guchar *) storage) = g_value_get_uchar (value);
- return TRUE;
- case G_TYPE_BOOLEAN:
- *((gboolean *) storage) = g_value_get_boolean (value);
- return TRUE;
- case G_TYPE_LONG:
- *((glong *) storage) = g_value_get_long (value);
- return TRUE;
- case G_TYPE_ULONG:
- *((gulong *) storage) = g_value_get_ulong (value);
- return TRUE;
- case G_TYPE_INT:
- *((gint *) storage) = g_value_get_int (value);
- return TRUE;
- case G_TYPE_UINT:
- *((guint *) storage) = g_value_get_uint (value);
- return TRUE;
- case G_TYPE_INT64:
- *((gint64 *) storage) = g_value_get_int64 (value);
- return TRUE;
- case G_TYPE_UINT64:
- *((guint64 *) storage) = g_value_get_uint64 (value);
- return TRUE;
- case G_TYPE_DOUBLE:
- *((gdouble *) storage) = g_value_get_double (value);
- return TRUE;
- case G_TYPE_STRING:
- *((gchar **) storage) = (char*) g_value_get_string (value);
- return TRUE;
- case G_TYPE_OBJECT:
- *((gpointer *) storage) = g_value_get_object (value);
- return TRUE;
- case G_TYPE_BOXED:
- *((gpointer *) storage) = g_value_get_boxed (value);
- return TRUE;
- default:
- return FALSE;
- }
-}
-
-gboolean
-_dbus_gvalue_set_from_pointer (GValue *value,
- gconstpointer storage)
-{
- /* FIXME - is there a better way to do this? */
- switch (g_type_fundamental (G_VALUE_TYPE (value)))
- {
- case G_TYPE_CHAR:
- g_value_set_char (value, *((gchar *) storage));
- return TRUE;
- case G_TYPE_UCHAR:
- g_value_set_uchar (value, *((guchar *) storage));
- return TRUE;
- case G_TYPE_BOOLEAN:
- g_value_set_boolean (value, *((gboolean *) storage));
- return TRUE;
- case G_TYPE_LONG:
- g_value_set_long (value, *((glong *) storage));
- return TRUE;
- case G_TYPE_ULONG:
- g_value_set_ulong (value, *((gulong *) storage));
- return TRUE;
- case G_TYPE_INT:
- g_value_set_int (value, *((gint *) storage));
- return TRUE;
- case G_TYPE_UINT:
- g_value_set_uint (value, *((guint *) storage));
- return TRUE;
- case G_TYPE_INT64:
- g_value_set_int64 (value, *((gint64 *) storage));
- return TRUE;
- case G_TYPE_UINT64:
- g_value_set_uint64 (value, *((guint64 *) storage));
- return TRUE;
- case G_TYPE_DOUBLE:
- g_value_set_double (value, *((gdouble *) storage));
- return TRUE;
- case G_TYPE_STRING:
- g_value_set_string (value, *((gchar **) storage));
- return TRUE;
- case G_TYPE_OBJECT:
- g_value_set_object (value, *((gpointer *) storage));
- return TRUE;
- case G_TYPE_BOXED:
- g_value_set_boxed (value, *((gpointer *) storage));
- return TRUE;
- default:
- return FALSE;
- }
-}
-
-gboolean
-_dbus_gvalue_take (GValue *value,
- GTypeCValue *cvalue)
-{
- GType g_type;
- GTypeValueTable *value_table;
- char *error_msg;
-
- g_type = G_VALUE_TYPE (value);
- value_table = g_type_value_table_peek (g_type);
-
- error_msg = value_table->collect_value (value, 1, cvalue, G_VALUE_NOCOPY_CONTENTS);
- if (error_msg)
- {
- g_warning ("%s: %s", G_STRLOC, error_msg);
- g_free (error_msg);
- return FALSE;
- }
- /* Clear the NOCOPY_CONTENTS flag; we want to take ownership
- * of the value.
- */
- value->data[1].v_uint &= ~(G_VALUE_NOCOPY_CONTENTS);
- return TRUE;
-}
-
-gboolean
-_dbus_gtype_can_signal_error (GType gtype)
-{
- switch (gtype)
- {
- case G_TYPE_BOOLEAN:
- case G_TYPE_INT:
- case G_TYPE_UINT:
- case G_TYPE_STRING:
- case G_TYPE_BOXED:
- case G_TYPE_OBJECT:
- return TRUE;
- default:
- return FALSE;
- }
-}
-
-gboolean
-_dbus_gvalue_signals_error (const GValue *value)
-{
- /* Hardcoded rules for return value semantics for certain
- * types. Perhaps in the future we'd want an annotation
- * specifying which return values are errors, but in
- * reality people will probably just use boolean and
- * boxed, and there the semantics are pretty standard.
- */
- switch (G_TYPE_FUNDAMENTAL (G_VALUE_TYPE (value)))
- {
- case G_TYPE_BOOLEAN:
- return (g_value_get_boolean (value) == FALSE);
- break;
- case G_TYPE_INT:
- return (g_value_get_int (value) < 0);
- break;
- case G_TYPE_UINT:
- return (g_value_get_uint (value) == 0);
- break;
- case G_TYPE_STRING:
- return (g_value_get_string (value) == NULL);
- break;
- case G_TYPE_BOXED:
- return (g_value_get_boxed (value) == NULL);
- break;
- case G_TYPE_OBJECT:
- return (g_value_get_object (value) == NULL);
- break;
- default:
- g_assert_not_reached ();
- return FALSE;
- }
-}
-
-
-static gboolean
-hash_func_from_gtype (GType gtype, GHashFunc *func)
-{
- switch (gtype)
- {
- case G_TYPE_CHAR:
- case G_TYPE_UCHAR:
- case G_TYPE_BOOLEAN:
- case G_TYPE_INT:
- case G_TYPE_UINT:
- *func = NULL;
- return TRUE;
- case G_TYPE_STRING:
- *func = g_str_hash;
- return TRUE;
- default:
- if (gtype == DBUS_TYPE_G_OBJECT_PATH)
- {
- *func = g_str_hash;
- return TRUE;
- }
- else if (gtype == DBUS_TYPE_G_SIGNATURE)
- {
- *func = g_str_hash;
- return TRUE;
- }
- return FALSE;
- }
-}
-
-static void
-unset_and_free_g_value (gpointer val)
-{
- GValue *value = val;
-
- g_value_unset (value);
- g_free (value);
-}
-
-static gboolean
-gtype_can_simple_free (GType type);
-
-static gboolean
-hash_simple_free_from_gtype (GType gtype, GDestroyNotify *func)
-{
- switch (gtype)
- {
- case G_TYPE_CHAR:
- case G_TYPE_UCHAR:
- case G_TYPE_BOOLEAN:
- case G_TYPE_INT:
- case G_TYPE_UINT:
- *func = NULL;
- return TRUE;
- case G_TYPE_DOUBLE:
- case G_TYPE_STRING:
- *func = g_free;
- return TRUE;
- default:
- if (gtype == G_TYPE_VALUE)
- {
- *func = unset_and_free_g_value;
- return TRUE;
- }
- else if (gtype == G_TYPE_VALUE_ARRAY)
- {
- *func = (GDestroyNotify) g_value_array_free;
- return TRUE;
- }
- else if (gtype == G_TYPE_STRV)
- {
- *func = (GDestroyNotify) g_strfreev;
- return TRUE;
- }
- else if (gtype == DBUS_TYPE_G_OBJECT_PATH)
- {
- *func = g_free;
- return TRUE;
- }
- else if (gtype == DBUS_TYPE_G_SIGNATURE)
- {
- *func = g_free;
- return TRUE;
- }
- else if (dbus_g_type_is_collection (gtype))
- {
- const DBusGTypeSpecializedCollectionVtable* vtable;
- vtable = dbus_g_type_collection_peek_vtable (gtype);
- if (vtable->base_vtable.simple_free_func)
- {
- *func = vtable->base_vtable.simple_free_func;
- return TRUE;
- }
- }
- else if (dbus_g_type_is_map (gtype))
- {
- const DBusGTypeSpecializedMapVtable* vtable;
- GType key_gtype, value_gtype;
-
- key_gtype = dbus_g_type_get_map_key_specialization (gtype);
- value_gtype = dbus_g_type_get_map_value_specialization (gtype);
-
- /* if either the key or the value don't have "simple" (without a
- * GType) free functions, then the hashtable's contents must be freed
- * with hashtable_free, so the hashtable itself can't have a simple
- * free function. */
- if (!gtype_can_simple_free (key_gtype) ||
- !gtype_can_simple_free (value_gtype))
- return FALSE;
-
- vtable = dbus_g_type_map_peek_vtable (gtype);
- if (vtable->base_vtable.simple_free_func)
- {
- *func = vtable->base_vtable.simple_free_func;
- return TRUE;
- }
- }
- else if (dbus_g_type_is_struct (gtype))
- {
- const DBusGTypeSpecializedStructVtable *vtable;
- vtable = dbus_g_type_struct_peek_vtable (gtype);
- if (vtable->base_vtable.simple_free_func)
- {
- *func = vtable->base_vtable.simple_free_func;
- return TRUE;
- }
- }
- return FALSE;
- }
-}
-
-static gboolean
-gtype_can_simple_free (GType type)
-{
- GDestroyNotify func;
- return hash_simple_free_from_gtype (type, &func);
-}
-
-gboolean
-_dbus_gtype_is_valid_hash_key (GType type)
-{
- GHashFunc func;
- return hash_func_from_gtype (type, &func);
-}
-
-gboolean
-_dbus_gtype_is_valid_hash_value (GType gtype)
-{
- /* anything we can take into a GValue using gvalue_take_hash_value is fine */
- switch (g_type_fundamental (gtype))
- {
- case G_TYPE_CHAR:
- case G_TYPE_UCHAR:
- case G_TYPE_BOOLEAN:
- case G_TYPE_INT:
- case G_TYPE_UINT:
- case G_TYPE_DOUBLE:
- case G_TYPE_STRING:
- case G_TYPE_BOXED:
- case G_TYPE_OBJECT:
- return TRUE;
- }
-
- return FALSE;
-}
-
-GHashFunc
-_dbus_g_hash_func_from_gtype (GType gtype)
-{
- GHashFunc func;
- gboolean ret;
- ret = hash_func_from_gtype (gtype, &func);
- g_assert (ret != FALSE);
- return func;
-}
-
-GEqualFunc
-_dbus_g_hash_equal_from_gtype (GType gtype)
-{
- g_assert (_dbus_gtype_is_valid_hash_key (gtype));
-
- switch (gtype)
- {
- case G_TYPE_CHAR:
- case G_TYPE_UCHAR:
- case G_TYPE_BOOLEAN:
- case G_TYPE_INT:
- case G_TYPE_UINT:
- return NULL;
- case G_TYPE_STRING:
- return g_str_equal;
- default:
- if (gtype == DBUS_TYPE_G_OBJECT_PATH)
- return g_str_equal;
- else if (gtype == DBUS_TYPE_G_SIGNATURE)
- return g_str_equal;
- g_assert_not_reached ();
- return NULL;
- }
-}
-
-static void
-hash_fake_simple_free_func (gpointer val)
-{
- /* Havoc would be proud... :P */
- g_critical ("If you see this message then the author of this application or "
- "one of its libraries has tried to remove or replace the value %p in a "
- "hash table which was constructed by the D-Bus Glib bindings.\n\n"
-
- "However, it was not possible for the bindings to provide a destroy "
- "function to g_hash_table_new_full which is able to free this value, as "
- "its GType must be known in order to free it. This means the memory "
- "allocated to store the value has most likely just been leaked.\n\n"
-
- "To avoid this error, the GHashTable (or keys/values \"stolen\" from "
- "it) should be freed by using g_boxed_free as follows:\n"
- " g_boxed_free (dbus_g_type_get_map (\"GHashTable\", key_gtype, "
- "value_gtype), hash_table);\n", val);
-}
-
-GDestroyNotify
-_dbus_g_hash_free_from_gtype (GType gtype)
-{
- GDestroyNotify func;
- gboolean ret;
-
- ret = hash_simple_free_from_gtype (gtype, &func);
-
- /* if the value doesn't have a simple free function, we cannot define a
- * meaningful free function here. instead, this hash table must be freed
- * using g_boxed_free so that the hash_free function gets invoked. if the
- * user does not do so, we provide a fake free function to provide a warning
- * in this case. */
- if (ret == FALSE)
- {
- g_assert (_dbus_gtype_is_valid_hash_value (gtype));
-
- func = hash_fake_simple_free_func;
- }
-
- return func;
-}
-
-static void gvalue_take_ptrarray_value (GValue *value, gpointer instance);
-
-static void
-gvalue_take_hash_value (GValue *value, gpointer instance)
-{
- switch (g_type_fundamental (G_VALUE_TYPE (value)))
- {
- case G_TYPE_CHAR:
- g_value_set_char (value, (gchar) GPOINTER_TO_INT (instance));
- break;
- case G_TYPE_UCHAR:
- g_value_set_uchar (value, (guchar) GPOINTER_TO_UINT (instance));
- break;
- case G_TYPE_BOOLEAN:
- g_value_set_boolean (value, (gboolean) GPOINTER_TO_UINT (instance));
- break;
- case G_TYPE_INT:
- g_value_set_int (value, GPOINTER_TO_INT (instance));
- break;
- case G_TYPE_UINT:
- g_value_set_uint (value, GPOINTER_TO_UINT (instance));
- break;
- case G_TYPE_DOUBLE:
- g_value_set_double (value, *(gdouble *) instance);
- break;
- default:
- gvalue_take_ptrarray_value (value, instance);
- break;
- }
-}
-
-static gpointer ptrarray_value_from_gvalue (const GValue *value);
-
-static gpointer
-hash_value_from_gvalue (GValue *value)
-{
- switch (g_type_fundamental (G_VALUE_TYPE (value)))
- {
- case G_TYPE_CHAR:
- return GINT_TO_POINTER ((int) g_value_get_char (value));
- break;
- case G_TYPE_UCHAR:
- return GUINT_TO_POINTER ((guint) g_value_get_uchar (value));
- break;
- case G_TYPE_BOOLEAN:
- return GUINT_TO_POINTER ((guint) g_value_get_boolean (value));
- break;
- case G_TYPE_INT:
- return GINT_TO_POINTER (g_value_get_int (value));
- break;
- case G_TYPE_UINT:
- return GUINT_TO_POINTER (g_value_get_uint (value));
- break;
- case G_TYPE_DOUBLE:
- {
- gdouble *p = (gdouble *) g_malloc0 (sizeof (gdouble));
- *p = g_value_get_double (value);
- return (gpointer) p;
- }
- break;
- default:
- return ptrarray_value_from_gvalue (value);
- break;
- }
-}
-
-struct DBusGHashTableValueForeachData
-{
- DBusGTypeSpecializedMapIterator func;
- GType key_type;
- GType value_type;
- gpointer data;
-};
-
-static void
-hashtable_foreach_with_values (gpointer key, gpointer value, gpointer user_data)
-{
- GValue key_val = {0, };
- GValue value_val = {0, };
- struct DBusGHashTableValueForeachData *data = user_data;
-
- g_value_init (&key_val, data->key_type);
- g_value_init (&value_val, data->value_type);
- gvalue_take_hash_value (&key_val, key);
- gvalue_take_hash_value (&value_val, value);
-
- data->func (&key_val, &value_val, data->data);
-}
-
-
-static void
-hashtable_iterator (GType hash_type,
- gpointer instance,
- DBusGTypeSpecializedMapIterator iterator,
- gpointer user_data)
-{
- struct DBusGHashTableValueForeachData data;
- GType key_gtype;
- GType value_gtype;
-
- key_gtype = dbus_g_type_get_map_key_specialization (hash_type);
- value_gtype = dbus_g_type_get_map_value_specialization (hash_type);
-
- data.func = iterator;
- data.key_type = key_gtype;
- data.value_type = value_gtype;
- data.data = user_data;
-
- g_hash_table_foreach (instance, hashtable_foreach_with_values, &data);
-}
-
-void
-_dbus_g_hash_table_insert_steal_values (GHashTable *table,
- GValue *key_val,
- GValue *value_val)
-{
- gpointer key, val;
-
- key = hash_value_from_gvalue (key_val);
- val = hash_value_from_gvalue (value_val);
-
- g_hash_table_insert (table, key, val);
-}
-
-static void
-hashtable_append (DBusGTypeSpecializedAppendContext *ctx,
- GValue *key,
- GValue *val)
-{
- GHashTable *table;
-
- table = g_value_get_boxed (ctx->val);
- _dbus_g_hash_table_insert_steal_values (table, key, val);
-}
-
-static gpointer
-hashtable_constructor (GType type)
-{
- GHashTable *ret;
- GType key_gtype;
- GType value_gtype;
-
- key_gtype = dbus_g_type_get_map_key_specialization (type);
- value_gtype = dbus_g_type_get_map_value_specialization (type);
-
- ret = g_hash_table_new_full (_dbus_g_hash_func_from_gtype (key_gtype),
- _dbus_g_hash_equal_from_gtype (key_gtype),
- _dbus_g_hash_free_from_gtype (key_gtype),
- _dbus_g_hash_free_from_gtype (value_gtype));
- return ret;
-}
-
-static void
-hashtable_insert_values (GHashTable *table,
- const GValue *key_val,
- const GValue *value_val)
-{
- GValue key_copy = {0, };
- GValue value_copy = {0, };
-
- g_value_init (&key_copy, G_VALUE_TYPE (key_val));
- g_value_copy (key_val, &key_copy);
- g_value_init (&value_copy, G_VALUE_TYPE (value_val));
- g_value_copy (value_val, &value_copy);
-
- _dbus_g_hash_table_insert_steal_values (table, &key_copy, &value_copy);
-}
-
-static void
-hashtable_foreach_copy (const GValue *key, const GValue *val, gpointer data)
-{
- hashtable_insert_values ((GHashTable *) data, key, val);
-}
-
-static gpointer
-hashtable_copy (GType type, gpointer src)
-{
- GHashTable *ghash;
- GHashTable *ret;
- GValue hashval = {0,};
-
- ghash = src;
-
- ret = hashtable_constructor (type);
-
- g_value_init (&hashval, type);
- g_value_set_static_boxed (&hashval, ghash);
- dbus_g_type_map_value_iterate (&hashval, hashtable_foreach_copy, ret);
- return ret;
-}
-
-/* we leave this here for backwards compatibility - any hash tables nested
- * inside hash tables will use this as their free function if users were
- * already relying on it, but dbus-glib itself will never use it directly as
- * hashtable_free is also defined. */
-static void
-hashtable_simple_free (gpointer val)
-{
- g_hash_table_unref (val);
-}
-
-struct DBusGHashTableFreeData
-{
- GType key_gtype;
- GType value_gtype;
-};
-
-static gboolean
-hashtable_free_foreach_steal (gpointer key,
- gpointer value,
- gpointer user_data)
-{
- struct DBusGHashTableFreeData *data = user_data;
- GValue val = { 0, };
-
- g_value_init (&val, data->key_gtype);
- gvalue_take_hash_value (&val, key);
- g_value_unset (&val);
-
- g_value_init (&val, data->value_gtype);
- gvalue_take_hash_value (&val, value);
- g_value_unset (&val);
-
- return TRUE;
-}
-
-static void
-hashtable_free (GType type,
- gpointer val)
-{
- struct DBusGHashTableFreeData data = { 0, };
- GHashTable *hash = val;
-
- data.key_gtype = dbus_g_type_get_map_key_specialization (type);
- data.value_gtype = dbus_g_type_get_map_value_specialization (type);
-
- /* wheee, fun. two cases here. either:
- *
- * a) the keys and value types both have simple (ie, no * GType parameter is
- * needed to know how to free them) free functions, in which case they were
- * set as the hash free functions when the hash table was constructed. in
- * this case, it's sufficient for us to unref the hash table as before. we
- * have to keep doing this in order to maintain compatibility with the ABI
- * which was around before hash tables could contain types which don't have
- * simple free functions (such as GPtrArrays of other stuff). for these
- * tables, users were able to ref the hash tables and add/remove values, and
- * rely on meaningful free functions.
- *
- * b) for any other key or value types where /do/ need to know the GType in
- * order to free it, this function is the only "right" way to free the hash
- * table. both the key and value free functions were set to print a big nasty
- * warning, and we free the contents of the hashtable with foreach_steal.
- */
- if (gtype_can_simple_free (data.key_gtype) &&
- gtype_can_simple_free (data.value_gtype))
- {
- g_hash_table_unref (hash);
- }
- else
- {
- g_hash_table_foreach_steal (hash, hashtable_free_foreach_steal, &data);
- g_hash_table_unref (hash);
- }
-}
-
-static gpointer
-valuearray_constructor (GType type)
-{
- GValueArray *ret;
- guint size = dbus_g_type_get_struct_size (type);
- guint i;
- ret = g_value_array_new (size);
- for (i=0; i < size; i++)
- {
- GValue val = {0,};
- g_value_init (&val, dbus_g_type_get_struct_member_type (type, i));
- g_value_array_append(ret, &val);
- }
- return (gpointer)ret;
-}
-
-static gpointer
-valuearray_copy (GType type, gpointer src)
-{
- return g_value_array_copy ((GValueArray*) src);
-}
-
-static void
-valuearray_simple_free (gpointer val)
-{
- g_value_array_free (val);
-}
-
-static gboolean
-valuearray_get_member (GType type, gpointer instance,
- guint member, GValue *ret)
-{
- GValueArray *va = (GValueArray*) instance;
- const GValue *val;
- if (member < dbus_g_type_get_struct_size (type))
- {
- val = g_value_array_get_nth (va, member);
- g_value_copy (val, ret);
- return TRUE;
- }
- else
- return FALSE;
-}
-
-static gboolean
-valuearray_set_member (GType type, gpointer instance,
- guint member, const GValue *member_type)
-{
- GValueArray *va = (GValueArray*) instance;
- GValue *vp;
- if (member < dbus_g_type_get_struct_size (type))
- {
- vp = g_value_array_get_nth (va, member);
- g_value_copy (member_type, vp);
- return TRUE;
- }
- else
- return FALSE;
-}
-
-
-static gpointer
-array_constructor (GType type)
-{
- GArray *array;
- guint elt_size;
- GType elt_type;
- gboolean zero_terminated;
- gboolean clear;
-
- elt_type = dbus_g_type_get_collection_specialization (type);
- g_assert (elt_type != G_TYPE_INVALID);
-
- elt_size = _dbus_g_type_fixed_get_size (elt_type);
-
- /* These are "safe" defaults */
- zero_terminated = TRUE; /* ((struct _DBusGRealArray*) garray)->zero_terminated; */
- clear = TRUE; /* ((struct _DBusGRealArray*) garray)->clear; */
-
- array = g_array_new (zero_terminated, clear, elt_size);
- return array;
-}
-
-static void
-array_iterator (GType garray_type,
- gpointer instance,
- DBusGTypeSpecializedCollectionIterator iterator,
- gpointer user_data)
-{
- GArray *array;
- GType elt_gtype;
- guint i;
-
- array = instance;
-
- elt_gtype = dbus_g_type_get_collection_specialization (garray_type);
-
- for (i = 0; i < array->len; i++)
- {
- GValue val = {0, };
- g_value_init (&val, elt_gtype);
-
- switch (elt_gtype)
- {
- case G_TYPE_BOOLEAN:
- g_value_set_boolean (&val, !!g_array_index (array, gboolean, i));
- break;
-
- case G_TYPE_FLOAT:
- g_value_set_float (&val, g_array_index (array, gfloat, i));
- break;
-
- case G_TYPE_DOUBLE:
- g_value_set_double (&val, g_array_index (array, gdouble, i));
- break;
-
- case G_TYPE_CHAR:
- g_value_set_char (&val, g_array_index (array, gchar, i));
- break;
-
- case G_TYPE_UCHAR:
- g_value_set_uchar (&val, g_array_index (array, guchar, i));
- break;
-
- case G_TYPE_INT:
- g_value_set_int (&val, g_array_index (array, gint, i));
- break;
-
- case G_TYPE_UINT:
- g_value_set_uint (&val, g_array_index (array, guint, i));
- break;
-
- case G_TYPE_LONG:
- g_value_set_long (&val, g_array_index (array, glong, i));
- break;
-
- case G_TYPE_ULONG:
- g_value_set_ulong (&val, g_array_index (array, gulong, i));
- break;
-
- case G_TYPE_INT64:
- g_value_set_int64 (&val, g_array_index (array, gint64, i));
- break;
-
- case G_TYPE_UINT64:
- g_value_set_uint64 (&val, g_array_index (array, guint64, i));
- break;
-
- default:
- g_assert_not_reached ();
- }
-
- iterator (&val, user_data);
- }
-}
-
-static void
-array_append (DBusGTypeSpecializedAppendContext *ctx,
- GValue *value)
-{
- GArray *array = g_value_get_boxed (ctx->val);
- GType elt_gtype;
- union {
- guint64 u64;
- gint64 i64;
- gulong ul;
- glong l;
- guint u;
- gint i;
- guchar uc;
- gchar c;
- gboolean b;
- gfloat f;
- gdouble d;
- } tmp;
-
- elt_gtype = dbus_g_type_get_collection_specialization (
- G_VALUE_TYPE (ctx->val));
-
- switch (elt_gtype)
- {
- case G_TYPE_BOOLEAN:
- tmp.b = g_value_get_boolean (value);
- g_array_append_val (array, tmp.b);
- break;
-
- case G_TYPE_FLOAT:
- tmp.f = g_value_get_float (value);
- g_array_append_val (array, tmp.f);
- break;
-
- case G_TYPE_DOUBLE:
- tmp.d = g_value_get_double (value);
- g_array_append_val (array, tmp.d);
- break;
-
- case G_TYPE_CHAR:
- tmp.c = g_value_get_char (value);
- g_array_append_val (array, tmp.c);
- break;
-
- case G_TYPE_UCHAR:
- tmp.uc = g_value_get_uchar (value);
- g_array_append_val (array, tmp.uc);
- break;
-
- case G_TYPE_INT:
- tmp.i = g_value_get_int (value);
- g_array_append_val (array, tmp.i);
- break;
-
- case G_TYPE_UINT:
- tmp.u = g_value_get_uint (value);
- g_array_append_val (array, tmp.u);
- break;
-
- case G_TYPE_LONG:
- tmp.l = g_value_get_long (value);
- g_array_append_val (array, tmp.l);
- break;
-
- case G_TYPE_ULONG:
- tmp.ul = g_value_get_ulong (value);
- g_array_append_val (array, tmp.ul);
- break;
-
- case G_TYPE_INT64:
- tmp.i64 = g_value_get_int64 (value);
- g_array_append_val (array, tmp.i64);
- break;
-
- case G_TYPE_UINT64:
- tmp.u64 = g_value_get_uint64 (value);
- g_array_append_val (array, tmp.u64);
- break;
-
- default:
- g_assert_not_reached ();
- }
-}
-
-static gpointer
-array_copy (GType type, gpointer src)
-{
- GArray *garray;
- GArray *new;
-
- garray = src;
-
- new = array_constructor (type);
- g_array_append_vals (new, garray->data, garray->len);
-
- return new;
-}
-
-static void
-array_simple_free (gpointer val)
-{
- GArray *array;
- array = val;
- g_array_free (array, TRUE);
-}
-
-static gboolean
-array_fixed_accessor (GType type, gpointer instance, gpointer *values, guint *len)
-{
- GType elt_type;
- GArray *array = instance;
-
- elt_type = dbus_g_type_get_collection_specialization (type);
- if (!_dbus_g_type_is_fixed (elt_type))
- return FALSE;
-
- *values = array->data;
- *len = array->len;
- return TRUE;
-}
-
-static gpointer
-ptrarray_constructor (GType type)
-{
- /* Later we should determine a destructor, need g_ptr_array_destroy */
- return g_ptr_array_new ();
-}
-
-static void
-gvalue_take_ptrarray_value (GValue *value, gpointer instance)
-{
- switch (g_type_fundamental (G_VALUE_TYPE (value)))
- {
- case G_TYPE_STRING:
- g_value_take_string (value, instance);
- break;
- case G_TYPE_BOXED:
- g_value_take_boxed (value, instance);
- break;
- case G_TYPE_OBJECT:
- g_value_take_object (value, instance);
- break;
- default:
- g_assert_not_reached ();
- break;
- }
-}
-
-static gpointer
-ptrarray_value_from_gvalue (const GValue *value)
-{
- GValue tmp = {0, };
-
- /* if the NOCOPY flag is set, then value was created via set_static and hence
- * is not owned by us. in order to preserve the "take" semantics that the API
- * has in general (which avoids copying in the common case), we must copy any
- * static values so that we can indiscriminately free the entire collection
- * later. */
- if (value->data[1].v_uint & G_VALUE_NOCOPY_CONTENTS)
- {
- g_value_init (&tmp, G_VALUE_TYPE (value));
- g_value_copy (value, &tmp);
- value = &tmp;
- }
-
- switch (g_type_fundamental (G_VALUE_TYPE (value)))
- {
- case G_TYPE_STRING:
- return (gpointer) g_value_get_string (value);
- break;
- case G_TYPE_BOXED:
- return g_value_get_boxed (value);
- break;
- case G_TYPE_OBJECT:
- return g_value_get_object (value);
- break;
- default:
- g_assert_not_reached ();
- return NULL;
- }
-}
-
-static void
-ptrarray_iterator (GType ptrarray_type,
- gpointer instance,
- DBusGTypeSpecializedCollectionIterator iterator,
- gpointer user_data)
-{
- GPtrArray *ptrarray;
- GType elt_gtype;
- guint i;
-
- ptrarray = instance;
-
- elt_gtype = dbus_g_type_get_collection_specialization (ptrarray_type);
-
- for (i = 0; i < ptrarray->len; i++)
- {
- GValue val = {0, };
- g_value_init (&val, elt_gtype);
- gvalue_take_ptrarray_value (&val, g_ptr_array_index (ptrarray, i));
- iterator (&val, user_data);
- }
-}
-
-static void
-ptrarray_copy_elt (const GValue *val, gpointer user_data)
-{
- GPtrArray *dest = user_data;
- GValue val_copy = {0, };
-
- g_value_init (&val_copy, G_VALUE_TYPE (val));
- g_value_copy (val, &val_copy);
-
- g_ptr_array_add (dest, ptrarray_value_from_gvalue (&val_copy));
-}
-
-static gpointer
-ptrarray_copy (GType type, gpointer src)
-{
- GPtrArray *new;
- GValue array_val = {0, };
-
- g_value_init (&array_val, type);
- g_value_set_static_boxed (&array_val, src);
-
- new = ptrarray_constructor (type);
- dbus_g_type_collection_value_iterate (&array_val, ptrarray_copy_elt, new);
-
- return new;
-}
-
-static void
-ptrarray_append (DBusGTypeSpecializedAppendContext *ctx, GValue *value)
-{
- GPtrArray *array;
-
- array = g_value_get_boxed (ctx->val);
-
- g_ptr_array_add (array, ptrarray_value_from_gvalue (value));
-}
-
-static void
-ptrarray_free (GType type, gpointer val)
-{
- GPtrArray *array;
- GValue elt_val = {0, };
- GType elt_gtype;
- unsigned int i;
-
- array = val;
-
- elt_gtype = dbus_g_type_get_collection_specialization (type);
-
- for (i = 0; i < array->len; i++)
- {
- g_value_init (&elt_val, elt_gtype);
- gvalue_take_ptrarray_value (&elt_val, g_ptr_array_index (array, i));
- g_value_unset (&elt_val);
- }
-
- g_ptr_array_free (array, TRUE);
-}
-
-static gpointer
-slist_constructor (GType type)
-{
- return NULL;
-}
-
-static void
-slist_iterator (GType list_type,
- gpointer instance,
- DBusGTypeSpecializedCollectionIterator iterator,
- gpointer user_data)
-{
- GSList *slist;
- GType elt_gtype;
-
- slist = instance;
-
- elt_gtype = dbus_g_type_get_collection_specialization (list_type);
-
- for (slist = instance; slist != NULL; slist = slist->next)
- {
- GValue val = {0, };
- g_value_init (&val, elt_gtype);
- gvalue_take_ptrarray_value (&val, slist->data);
- iterator (&val, user_data);
- }
-}
-
-static void
-slist_copy_elt (const GValue *val, gpointer user_data)
-{
- GSList **dest = user_data;
- GValue val_copy = {0, };
-
- g_value_init (&val_copy, G_VALUE_TYPE (val));
- g_value_copy (val, &val_copy);
-
- *dest = g_slist_append (*dest, ptrarray_value_from_gvalue (&val_copy));
-}
-
-static gpointer
-slist_copy (GType type, gpointer src)
-{
- GSList *new;
- GValue slist_val = {0, };
-
- g_value_init (&slist_val, type);
- g_value_set_static_boxed (&slist_val, src);
-
- new = slist_constructor (type);
- dbus_g_type_collection_value_iterate (&slist_val, slist_copy_elt, &new);
-
- return new;
-}
-
-static void
-slist_append (DBusGTypeSpecializedAppendContext *ctx, GValue *value)
-{
- GSList *list;
-
- list = g_value_get_boxed (ctx->val);
- list = g_slist_prepend (list, ptrarray_value_from_gvalue (value));
- g_value_set_static_boxed (ctx->val, list);
-}
-
-static void
-slist_end_append (DBusGTypeSpecializedAppendContext *ctx)
-{
- GSList *list;
-
- /* if you append multiple times to the slist, this will reverse the existing
- * elements... we need an init_append function */
- list = g_value_get_boxed (ctx->val);
- list = g_slist_reverse (list);
-
- g_value_take_boxed (ctx->val, list);
-}
-
-static void
-slist_free (GType type, gpointer val)
-{
- GSList *list;
- GType elt_gtype;
- list = val;
-
- elt_gtype = dbus_g_type_get_collection_specialization (type);
-
- while (list != NULL)
- {
- GValue elt_val = {0, };
- g_value_init (&elt_val, elt_gtype);
- gvalue_take_ptrarray_value (&elt_val, list->data);
- g_value_unset (&elt_val);
- list = g_slist_next(list);
- }
- list=val;
- g_slist_free (list);
-}
-
-void
-_dbus_g_type_specialized_builtins_init (void)
-{
- /* types with a simple_free function can be freed at run-time without
- * the destroy function needing to know the type, so they can be
- * stored in hash tables */
-
- static const DBusGTypeSpecializedCollectionVtable array_vtable = {
- {
- array_constructor,
- NULL,
- array_copy,
- array_simple_free,
- NULL,
- NULL,
- },
- array_fixed_accessor,
- array_iterator,
- array_append,
- NULL
- };
-
-
- static const DBusGTypeSpecializedCollectionVtable ptrarray_vtable = {
- {
- ptrarray_constructor,
- ptrarray_free,
- ptrarray_copy,
- NULL,
- NULL,
- NULL,
- },
- NULL,
- ptrarray_iterator,
- ptrarray_append,
- NULL,
- };
-
-
- static const DBusGTypeSpecializedCollectionVtable slist_vtable = {
- {
- slist_constructor,
- slist_free,
- slist_copy,
- NULL,
- NULL,
- NULL,
- },
- NULL,
- slist_iterator,
- slist_append,
- slist_end_append,
- };
-
- static const DBusGTypeSpecializedMapVtable hashtable_vtable = {
- {
- hashtable_constructor,
- hashtable_free,
- hashtable_copy,
- hashtable_simple_free,
- NULL,
- NULL
- },
- hashtable_iterator,
- hashtable_append
- };
-
- static const DBusGTypeSpecializedStructVtable valuearray_vtable = {
- {
- valuearray_constructor,
- NULL,
- valuearray_copy,
- valuearray_simple_free,
- NULL,
- NULL
- },
- valuearray_get_member,
- valuearray_set_member
- };
-
- _dbus_g_type_register_collection ("GSList", &slist_vtable, 0);
- _dbus_g_type_register_collection ("GArray", &array_vtable, 0);
- _dbus_g_type_register_collection ("GPtrArray", &ptrarray_vtable, 0);
- _dbus_g_type_register_map ("GHashTable", &hashtable_vtable, 0);
- _dbus_g_type_register_struct ("GValueArray", &valuearray_vtable, 0);
-}
diff --git a/dbus/dbus-gvalue-utils.h b/dbus/dbus-gvalue-utils.h
deleted file mode 100644
index 7f411fc..0000000
--- a/dbus/dbus-gvalue-utils.h
+++ /dev/null
@@ -1,73 +0,0 @@
-/* -*- mode: C; c-file-style: "gnu" -*- */
-/* dbus-gvalue-utils.h: Non-DBus-specific functions related to GType/GValue
- *
- * Copyright (C) 2005 Red Hat, Inc.
- *
- * Licensed under the Academic Free License version 2.1
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- */
-
-#ifndef DBUS_GOBJECT_VALUE_UTILS_H
-#define DBUS_GOBJECT_VALUE_UTILS_H
-
-#include <glib.h>
-#include <glib-object.h>
-
-G_BEGIN_DECLS
-
-void _dbus_g_type_specialized_builtins_init (void);
-
-gboolean _dbus_g_type_is_fixed (GType gtype);
-guint _dbus_g_type_fixed_get_size (GType gtype);
-
-gboolean _dbus_gvalue_set_from_pointer (GValue *value,
- gconstpointer storage);
-
-typedef void (*DBusGHashValueForeachFunc) (GValue * key, GValue *val, gpointer data);
-
-void _dbus_g_hash_table_value_foreach (GHashTable *table,
- GType hash_type,
- DBusGHashValueForeachFunc func,
- gpointer data);
-
-void _dbus_g_hash_table_insert_values (GHashTable *table,
- GValue *key_val,
- GValue *value_val);
-void _dbus_g_hash_table_insert_steal_values (GHashTable *table,
- GValue *key_val,
- GValue *value_val);
-
-gboolean _dbus_gtype_is_valid_hash_key (GType type);
-gboolean _dbus_gtype_is_valid_hash_value (GType type);
-
-GHashFunc _dbus_g_hash_func_from_gtype (GType gtype);
-GEqualFunc _dbus_g_hash_equal_from_gtype (GType gtype);
-GDestroyNotify _dbus_g_hash_free_from_gtype (GType gtype);
-
-gboolean _dbus_gvalue_store (GValue *value,
- gpointer storage);
-
-gboolean _dbus_gvalue_take (GValue *value,
- GTypeCValue *cvalue);
-
-gboolean _dbus_gtype_can_signal_error (GType gtype);
-gboolean _dbus_gvalue_signals_error (const GValue *value);
-
-
-G_END_DECLS
-
-#endif
diff --git a/dbus/dbus-gvalue.c b/dbus/dbus-gvalue.c
deleted file mode 100644
index fc3d78c..0000000
--- a/dbus/dbus-gvalue.c
+++ /dev/null
@@ -1,2099 +0,0 @@
-/* -*- mode: C; c-file-style: "gnu" -*- */
-/* dbus-gvalue.c GValue to-from DBusMessageIter
- *
- * Copyright (C) 2004 Ximian, Inc.
- * Copyright (C) 2005 Red Hat, Inc.
- *
- * Licensed under the Academic Free License version 2.1
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- */
-
-#include "config.h"
-#include "dbus-gtest.h"
-#include "dbus-gvalue.h"
-#include "dbus-gsignature.h"
-#include "dbus-gobject.h"
-#include "dbus-gvalue-utils.h"
-#include "dbus/dbus-glib.h"
-#include <string.h>
-#include <glib.h>
-#include "dbus/dbus-signature.h"
-
-/* Seems reasonable, but this should probably be part of the standard protocol */
-#define DBUS_GLIB_MAX_VARIANT_RECURSION 32
-
-static gboolean demarshal_static_variant (DBusGValueMarshalCtx *context,
- DBusMessageIter *iter,
- GValue *value,
- GError **error);
-
-
-static gboolean marshal_basic (DBusMessageIter *iter,
- const GValue *value);
-static gboolean demarshal_basic (DBusGValueMarshalCtx *context,
- DBusMessageIter *iter,
- GValue *value,
- GError **error);
-static gboolean marshal_strv (DBusMessageIter *iter,
- const GValue *value);
-static gboolean demarshal_strv (DBusGValueMarshalCtx *context,
- DBusMessageIter *iter,
- GValue *value,
- GError **error);
-static gboolean marshal_valuearray (DBusMessageIter *iter,
- const GValue *value);
-static gboolean demarshal_valuearray (DBusGValueMarshalCtx *context,
- DBusMessageIter *iter,
- GValue *value,
- GError **error);
-static gboolean marshal_variant (DBusMessageIter *iter,
- const GValue *value);
-static gboolean demarshal_variant (DBusGValueMarshalCtx *context,
- DBusMessageIter *iter,
- GValue *value,
- GError **error);
-static gboolean marshal_proxy (DBusMessageIter *iter,
- const GValue *value);
-static gboolean demarshal_proxy (DBusGValueMarshalCtx *context,
- DBusMessageIter *iter,
- GValue *value,
- GError **error);
-static gboolean marshal_object_path (DBusMessageIter *iter,
- const GValue *value);
-static gboolean demarshal_object_path (DBusGValueMarshalCtx *context,
- DBusMessageIter *iter,
- GValue *value,
- GError **error);
-static gboolean marshal_object (DBusMessageIter *iter,
- const GValue *value);
-static gboolean demarshal_object (DBusGValueMarshalCtx *context,
- DBusMessageIter *iter,
- GValue *value,
- GError **error);
-static gboolean marshal_signature (DBusMessageIter *iter,
- const GValue *value);
-static gboolean demarshal_signature (DBusGValueMarshalCtx *context,
- DBusMessageIter *iter,
- GValue *value,
- GError **error);
-static gboolean marshal_map (DBusMessageIter *iter,
- const GValue *value);
-static gboolean demarshal_map (DBusGValueMarshalCtx *context,
- DBusMessageIter *iter,
- GValue *value,
- GError **error);
-
-static gboolean marshal_collection (DBusMessageIter *iter,
- const GValue *value);
-static gboolean marshal_collection_ptrarray (DBusMessageIter *iter,
- const GValue *value);
-static gboolean marshal_collection_array (DBusMessageIter *iter,
- const GValue *value);
-static gboolean demarshal_collection (DBusGValueMarshalCtx *context,
- DBusMessageIter *iter,
- GValue *value,
- GError **error);
-static gboolean demarshal_collection_ptrarray (DBusGValueMarshalCtx *context,
- DBusMessageIter *iter,
- GValue *value,
- GError **error);
-static gboolean demarshal_collection_array (DBusGValueMarshalCtx *context,
- DBusMessageIter *iter,
- GValue *value,
- GError **error);
-static gboolean marshal_struct (DBusMessageIter *iter,
- const GValue *value);
-static gboolean demarshal_struct (DBusGValueMarshalCtx *context,
- DBusMessageIter *iter,
- GValue *value,
- GError **error);
-
-
-typedef gboolean (*DBusGValueMarshalFunc) (DBusMessageIter *iter,
- const GValue *value);
-typedef gboolean (*DBusGValueDemarshalFunc) (DBusGValueMarshalCtx *context,
- DBusMessageIter *iter,
- GValue *value,
- GError **error);
-
-typedef struct {
- DBusGValueMarshalFunc marshaller;
- DBusGValueDemarshalFunc demarshaller;
-} DBusGTypeMarshalVtable;
-
-typedef struct {
- const char *sig;
- const DBusGTypeMarshalVtable *vtable;
-} DBusGTypeMarshalData;
-
-static GQuark
-dbus_g_type_metadata_data_quark ()
-{
- static GQuark quark;
- if (!quark)
- quark = g_quark_from_static_string ("DBusGTypeMetaData");
-
- return quark;
-}
-
-static void
-set_type_metadata (GType type, const DBusGTypeMarshalData *data)
-{
- g_type_set_qdata (type, dbus_g_type_metadata_data_quark (), (gpointer) data);
-}
-
-static void
-register_basic (int typecode, const DBusGTypeMarshalData *typedata)
-{
- set_type_metadata (_dbus_gtype_from_basic_typecode (typecode), typedata);
-}
-
-void
-_dbus_g_value_types_init (void)
-{
- static gboolean types_initialized;
-
- static const DBusGTypeMarshalVtable basic_vtable = {
- marshal_basic,
- demarshal_basic
- };
-
- if (types_initialized)
- return;
-
- dbus_g_type_specialized_init ();
-
- /* Register basic types */
- {
- static const DBusGTypeMarshalData typedata = {
- DBUS_TYPE_BOOLEAN_AS_STRING,
- &basic_vtable,
- };
- register_basic (DBUS_TYPE_BOOLEAN, &typedata);
- }
- {
- static const DBusGTypeMarshalData typedata = {
- DBUS_TYPE_BYTE_AS_STRING,
- &basic_vtable,
- };
- register_basic (DBUS_TYPE_BYTE, &typedata);
- }
- {
- static const DBusGTypeMarshalData typedata = {
- DBUS_TYPE_INT16_AS_STRING,
- &basic_vtable,
- };
- register_basic (DBUS_TYPE_INT16, &typedata);
- }
- {
- static const DBusGTypeMarshalData typedata = {
- DBUS_TYPE_UINT16_AS_STRING,
- &basic_vtable,
- };
- register_basic (DBUS_TYPE_UINT16, &typedata);
- }
- {
- static const DBusGTypeMarshalData typedata = {
- DBUS_TYPE_UINT32_AS_STRING,
- &basic_vtable,
- };
- register_basic (DBUS_TYPE_UINT32, &typedata);
- }
- {
- static const DBusGTypeMarshalData typedata = {
- DBUS_TYPE_INT32_AS_STRING,
- &basic_vtable,
- };
- register_basic (DBUS_TYPE_INT32, &typedata);
- }
- {
- static const DBusGTypeMarshalData typedata = {
- DBUS_TYPE_UINT64_AS_STRING,
- &basic_vtable,
- };
- register_basic (DBUS_TYPE_UINT64, &typedata);
- }
- {
- static const DBusGTypeMarshalData typedata = {
- DBUS_TYPE_INT64_AS_STRING,
- &basic_vtable,
- };
- register_basic (DBUS_TYPE_INT64, &typedata);
- }
- {
- static const DBusGTypeMarshalData typedata = {
- DBUS_TYPE_DOUBLE_AS_STRING,
- &basic_vtable,
- };
- register_basic (DBUS_TYPE_DOUBLE, &typedata);
- }
- {
- static const DBusGTypeMarshalData typedata = {
- DBUS_TYPE_STRING_AS_STRING,
- &basic_vtable,
- };
- register_basic (DBUS_TYPE_STRING, &typedata);
- }
- /* fundamental GTypes that don't map 1:1 with D-BUS types */
- {
- static const DBusGTypeMarshalData typedata = {
- DBUS_TYPE_BYTE_AS_STRING,
- &basic_vtable,
- };
- set_type_metadata (G_TYPE_CHAR, &typedata);
- }
- {
- static const DBusGTypeMarshalData typedata = {
- DBUS_TYPE_INT32_AS_STRING,
- &basic_vtable,
- };
- set_type_metadata (G_TYPE_LONG, &typedata);
- }
- {
- static const DBusGTypeMarshalData typedata = {
- DBUS_TYPE_UINT32_AS_STRING,
- &basic_vtable,
- };
- set_type_metadata (G_TYPE_ULONG, &typedata);
- }
- {
- static const DBusGTypeMarshalData typedata = {
- DBUS_TYPE_DOUBLE_AS_STRING,
- &basic_vtable,
- };
- set_type_metadata (G_TYPE_FLOAT, &typedata);
- }
-
- /* Register complex types with builtin GType mappings */
- {
- static const DBusGTypeMarshalVtable vtable = {
- marshal_variant,
- demarshal_variant
- };
- static const DBusGTypeMarshalData typedata = {
- DBUS_TYPE_VARIANT_AS_STRING,
- &vtable
- };
- set_type_metadata (G_TYPE_VALUE, &typedata);
- };
- {
- static const DBusGTypeMarshalVtable vtable = {
- marshal_strv,
- demarshal_strv
- };
- static const DBusGTypeMarshalData typedata = {
- DBUS_TYPE_ARRAY_AS_STRING DBUS_TYPE_STRING_AS_STRING,
- &vtable
- };
- set_type_metadata (G_TYPE_STRV, &typedata);
- };
-
-
- /* Register some types specific to the D-BUS GLib bindings */
- {
- static const DBusGTypeMarshalVtable vtable = {
- marshal_proxy,
- demarshal_proxy
- };
- static const DBusGTypeMarshalData typedata = {
- DBUS_TYPE_OBJECT_PATH_AS_STRING,
- &vtable
- };
- set_type_metadata (DBUS_TYPE_G_PROXY, &typedata);
- }
-
- {
- static const DBusGTypeMarshalVtable vtable = {
- marshal_object_path,
- demarshal_object_path
- };
- static const DBusGTypeMarshalData typedata = {
- DBUS_TYPE_OBJECT_PATH_AS_STRING,
- &vtable
- };
- set_type_metadata (DBUS_TYPE_G_OBJECT_PATH, &typedata);
- }
-
- {
- static const DBusGTypeMarshalVtable vtable = {
- marshal_object,
- demarshal_object
- };
- static const DBusGTypeMarshalData typedata = {
- DBUS_TYPE_OBJECT_PATH_AS_STRING,
- &vtable
- };
- set_type_metadata (G_TYPE_OBJECT, &typedata);
- }
-
- {
- static const DBusGTypeMarshalVtable vtable = {
- marshal_signature,
- demarshal_signature
- };
- static const DBusGTypeMarshalData typedata = {
- DBUS_TYPE_SIGNATURE_AS_STRING,
- &vtable
- };
- set_type_metadata (DBUS_TYPE_G_SIGNATURE, &typedata);
- }
-
- types_initialized = TRUE;
-}
-
-/**
- * DBusGObjectPath:
- *
- * A typedef for a string used to represent D-Bus object paths.
- * Its GType is %DBUS_TYPE_G_OBJECT_PATH, derived from %G_TYPE_BOXED.
- *
- * Prior to version 0.FIXME this was used as the type name of
- * %DBUS_TYPE_G_OBJECT_PATH, but did not actually exist as a typedef.
- *
- * Since: 0.FIXME
- *
- * Deprecated: New code should use GDBus instead. The closest equivalent
- * is a #GVariant (%G_TYPE_VARIANT) of type %G_VARIANT_TYPE_OBJECT_PATH.
- */
-
-/**
- * DBUS_TYPE_G_OBJECT_PATH:
- *
- * The #GType of a #DBusGObjectPath, which is a boxed type containing a
- * D-Bus object path as a zero-terminated string. Object paths can be
- * copied with g_strdup() and freed with g_free(), just like %G_TYPE_STRING,
- * but have a distinct boxed type to allow them to be distinguished when
- * stored in a #GValue.
- *
- * Returns: a type derived from %G_TYPE_BOXED
- *
- * Deprecated: New code should use GDBus instead. The closest equivalent
- * is a #GVariant (%G_TYPE_VARIANT) of type %G_VARIANT_TYPE_OBJECT_PATH.
- */
-GType
-dbus_g_object_path_get_g_type (void)
-{
- static GType type_id = 0;
-
- if (!type_id)
- type_id = g_boxed_type_register_static ("DBusGObjectPath",
- (GBoxedCopyFunc) g_strdup,
- (GBoxedFreeFunc) g_free);
- return type_id;
-}
-
-/**
- * DBusGSignature:
- *
- * A typedef for a string used to represent D-Bus signatures.
- * Its GType is %DBUS_TYPE_G_SIGNATURE, derived from %G_TYPE_BOXED.
- *
- * Prior to version 0.FIXME this was used as the type name of
- * %DBUS_TYPE_G_SIGNATURE, but did not actually exist as a typedef.
- *
- * Since: 0.FIXME
- *
- * Deprecated: New code should use GDBus instead. The closest equivalent
- * is a #GVariant (%G_TYPE_VARIANT) of type %G_VARIANT_TYPE_SIGNATURE.
- */
-
-/**
- * DBUS_TYPE_G_SIGNATURE:
- *
- * The #GType of a #DBusGSignature, which is a boxed type containing a
- * D-Bus signature as a zero-terminated string. Signatures can be
- * copied with g_strdup() and freed with g_free(), just like %G_TYPE_STRING,
- * but have a distinct boxed type to allow them to be distinguished when
- * stored in a #GValue.
- *
- * Returns: a type derived from %G_TYPE_BOXED
- *
- * Deprecated: New code should use GDBus instead. The closest equivalent
- * is a #GVariant (%G_TYPE_VARIANT) of type %G_VARIANT_TYPE_SIGNATURE.
- */
-GType
-dbus_g_signature_get_g_type (void)
-{
- static GType type_id = 0;
-
- if (G_UNLIKELY (type_id == 0))
- type_id = g_boxed_type_register_static ("DBusGSignature",
- (GBoxedCopyFunc) g_strdup,
- (GBoxedFreeFunc) g_free);
-
- return type_id;
-}
-
-
-char *
-_dbus_gtype_to_signature (GType gtype)
-{
- char *ret;
- DBusGTypeMarshalData *typedata;
-
- if (dbus_g_type_is_collection (gtype))
- {
- GType elt_gtype;
- char *subsig;
-
- elt_gtype = dbus_g_type_get_collection_specialization (gtype);
- subsig = _dbus_gtype_to_signature (elt_gtype);
- ret = g_strconcat (DBUS_TYPE_ARRAY_AS_STRING, subsig, NULL);
- g_free (subsig);
- }
- else if (dbus_g_type_is_map (gtype))
- {
- GType key_gtype;
- GType val_gtype;
- char *key_subsig;
- char *val_subsig;
-
- key_gtype = dbus_g_type_get_map_key_specialization (gtype);
- val_gtype = dbus_g_type_get_map_value_specialization (gtype);
- key_subsig = _dbus_gtype_to_signature (key_gtype);
- val_subsig = _dbus_gtype_to_signature (val_gtype);
- ret = g_strconcat (DBUS_TYPE_ARRAY_AS_STRING DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING, key_subsig, val_subsig, DBUS_DICT_ENTRY_END_CHAR_AS_STRING, NULL);
- g_free (key_subsig);
- g_free (val_subsig);
- }
- else if (dbus_g_type_is_struct (gtype))
- {
- guint i, size;
- GString *sig;
- size = dbus_g_type_get_struct_size (gtype);
- sig = g_string_sized_new (size+2); /*some sensible starting size*/
- g_string_assign (sig, DBUS_STRUCT_BEGIN_CHAR_AS_STRING);
- for (i = 0; i < size; i++)
- {
- gchar *subsig;
- subsig = _dbus_gtype_to_signature (
- dbus_g_type_get_struct_member_type (gtype, i));
- g_string_append (sig, subsig);
- g_free (subsig);
- }
- g_string_append (sig, DBUS_STRUCT_END_CHAR_AS_STRING);
- ret = g_string_free (sig, FALSE);
- }
- else
- {
- typedata = g_type_get_qdata (gtype, dbus_g_type_metadata_data_quark ());
- if (typedata == NULL)
- return NULL;
- ret = g_strdup (typedata->sig);
- }
- return ret;
-}
-
-char *
-_dbus_gvalue_to_signature (const GValue *val)
-{
- GType gtype;
-
- gtype = G_VALUE_TYPE (val);
- if (g_type_is_a (gtype, G_TYPE_VALUE_ARRAY))
- {
- GString *str;
- guint i;
- GValueArray *array;
-
- array = g_value_get_boxed (val);
-
- str = g_string_new (DBUS_STRUCT_BEGIN_CHAR_AS_STRING);
- for (i = 0; i < array->n_values; i++)
- {
- char *sig;
- sig = _dbus_gvalue_to_signature (g_value_array_get_nth (array, i));
- g_string_append (str, sig);
- g_free (sig);
- }
- g_string_append (str, DBUS_STRUCT_END_CHAR_AS_STRING);
-
- return g_string_free (str, FALSE);
- }
- else
- return _dbus_gtype_to_signature (gtype);
-}
-
-static gboolean
-demarshal_basic (DBusGValueMarshalCtx *context,
- DBusMessageIter *iter,
- GValue *value,
- GError **error)
-{
- int current_type;
-
- current_type = dbus_message_iter_get_arg_type (iter);
- g_assert (dbus_type_is_basic (current_type));
-
- switch (current_type)
- {
- case DBUS_TYPE_BOOLEAN:
- {
- dbus_bool_t bool;
- if (!G_VALUE_HOLDS (value, G_TYPE_BOOLEAN))
- goto invalid_type;
- dbus_message_iter_get_basic (iter, &bool);
- g_value_set_boolean (value, bool);
- return TRUE;
- }
- case DBUS_TYPE_BYTE:
- {
- unsigned char byte;
- if (!G_VALUE_HOLDS (value, G_TYPE_UCHAR))
- goto invalid_type;
- dbus_message_iter_get_basic (iter, &byte);
- g_value_set_uchar (value, byte);
- return TRUE;
- }
- case DBUS_TYPE_INT32:
- {
- dbus_int32_t intval;
- if (!G_VALUE_HOLDS (value, G_TYPE_INT))
- goto invalid_type;
- dbus_message_iter_get_basic (iter, &intval);
- g_value_set_int (value, intval);
- return TRUE;
- }
- case DBUS_TYPE_UINT32:
- {
- dbus_uint32_t intval;
- if (!G_VALUE_HOLDS (value, G_TYPE_UINT))
- goto invalid_type;
- dbus_message_iter_get_basic (iter, &intval);
- g_value_set_uint (value, intval);
- return TRUE;
- }
- case DBUS_TYPE_INT64:
- {
- dbus_int64_t intval;
- if (!G_VALUE_HOLDS (value, G_TYPE_INT64))
- goto invalid_type;
- dbus_message_iter_get_basic (iter, &intval);
- g_value_set_int64 (value, intval);
- return TRUE;
- }
- case DBUS_TYPE_UINT64:
- {
- dbus_uint64_t intval;
- if (!G_VALUE_HOLDS (value, G_TYPE_UINT64))
- goto invalid_type;
- dbus_message_iter_get_basic (iter, &intval);
- g_value_set_uint64 (value, intval);
- return TRUE;
- }
- case DBUS_TYPE_DOUBLE:
- {
- double dval;
- if (!G_VALUE_HOLDS (value, G_TYPE_DOUBLE))
- goto invalid_type;
- dbus_message_iter_get_basic (iter, &dval);
- g_value_set_double (value, dval);
- return TRUE;
- }
- case DBUS_TYPE_INT16:
- {
- dbus_int16_t v;
- if (!G_VALUE_HOLDS (value, G_TYPE_INT))
- goto invalid_type;
- dbus_message_iter_get_basic (iter, &v);
- g_value_set_int (value, v);
- return TRUE;
- }
- case DBUS_TYPE_UINT16:
- {
- dbus_uint16_t v;
- if (!G_VALUE_HOLDS (value, G_TYPE_UINT))
- goto invalid_type;
- dbus_message_iter_get_basic (iter, &v);
- g_value_set_uint (value, v);
- return TRUE;
- }
- case DBUS_TYPE_STRING:
- {
- const char *s;
- if (!G_VALUE_HOLDS (value, G_TYPE_STRING))
- goto invalid_type;
- dbus_message_iter_get_basic (iter, &s);
- g_value_set_string (value, s);
- return TRUE;
- }
- default:
- /* fall through to invalid_type */
- break;
- }
- invalid_type:
- g_set_error (error,
- DBUS_GERROR,
- DBUS_GERROR_INVALID_ARGS,
- "Expected type %s, got type code \'%c\'",
- g_type_name (G_VALUE_TYPE (value)),
- (guchar) current_type);
- return FALSE;
-}
-
-static gboolean
-demarshal_static_variant (DBusGValueMarshalCtx *context,
- DBusMessageIter *iter,
- GValue *value,
- GError **error)
-{
- char *sig;
- DBusMessageIter subiter;
- GType variant_type;
-
- dbus_message_iter_recurse (iter, &subiter);
- sig = dbus_message_iter_get_signature (&subiter);
-
- variant_type = _dbus_gtype_from_signature (sig, context->proxy != NULL);
- if (variant_type == G_TYPE_INVALID)
- {
- /* It can happen if we received an unknown type such as
- * DBUS_TYPE_UNIX_FD or DBUS_TYPE_MAYBE. */
- g_set_error (error, DBUS_GERROR,
- DBUS_GERROR_INVALID_SIGNATURE,
- "Variant contains unknown signature \'%s\'", sig);
- dbus_free (sig);
- return FALSE;
- }
-
- dbus_free (sig);
-
- g_value_init (value, variant_type);
-
- if (!_dbus_gvalue_demarshal (context, &subiter, value, error))
- return FALSE;
-
- return TRUE;
-}
-
-static gboolean
-demarshal_variant (DBusGValueMarshalCtx *context,
- DBusMessageIter *iter,
- GValue *value,
- GError **error)
-
-{
- GValue *variant_val;
- variant_val = g_new0 (GValue, 1);
-
- if (!demarshal_static_variant (context, iter, variant_val, error))
- return FALSE;
-
- g_value_take_boxed (value, variant_val);
- return TRUE;
-}
-
-static gboolean
-demarshal_proxy (DBusGValueMarshalCtx *context,
- DBusMessageIter *iter,
- GValue *value,
- GError **error)
-{
- DBusGProxy *new_proxy;
- const char *objpath;
- int current_type;
-
- current_type = dbus_message_iter_get_arg_type (iter);
- if (current_type != DBUS_TYPE_OBJECT_PATH)
- {
- g_set_error (error,
- DBUS_GERROR,
- DBUS_GERROR_INVALID_ARGS,
- "Expected D-BUS object path, got type code \'%c\'", (guchar) current_type);
- return FALSE;
- }
-
- g_assert (context->proxy != NULL);
-
- dbus_message_iter_get_basic (iter, &objpath);
-
- new_proxy = dbus_g_proxy_new_from_proxy (context->proxy, NULL, objpath);
- g_value_take_object (value, new_proxy);
-
- return TRUE;
-}
-
-static gboolean
-demarshal_object_path (DBusGValueMarshalCtx *context,
- DBusMessageIter *iter,
- GValue *value,
- GError **error)
-{
- const char *objpath;
- int current_type;
-
- current_type = dbus_message_iter_get_arg_type (iter);
- if (current_type != DBUS_TYPE_OBJECT_PATH)
- {
- g_set_error (error,
- DBUS_GERROR,
- DBUS_GERROR_INVALID_ARGS,
- "Expected D-BUS object path, got type code \'%c\'", (guchar) current_type);
- return FALSE;
- }
-
- dbus_message_iter_get_basic (iter, &objpath);
-
- g_value_set_boxed (value, objpath);
-
- return TRUE;
-}
-
-static gboolean
-demarshal_object (DBusGValueMarshalCtx *context,
- DBusMessageIter *iter,
- GValue *value,
- GError **error)
-{
- const char *objpath;
- int current_type;
- GObject *obj;
-
- current_type = dbus_message_iter_get_arg_type (iter);
- if (current_type != DBUS_TYPE_OBJECT_PATH)
- {
- g_set_error (error,
- DBUS_GERROR,
- DBUS_GERROR_INVALID_ARGS,
- "Expected D-BUS object path, got type code \'%c\'", (guchar) current_type);
- return FALSE;
- }
- g_assert (context->proxy == NULL);
-
- dbus_message_iter_get_basic (iter, &objpath);
-
- obj = dbus_g_connection_lookup_g_object (context->gconnection, objpath);
- if (obj == NULL)
- {
- g_set_error (error,
- DBUS_GERROR,
- DBUS_GERROR_INVALID_ARGS,
- "Unregistered object at path '%s'",
- objpath);
- return FALSE;
- }
- g_value_set_object (value, obj);
-
- return TRUE;
-}
-
-static gboolean
-demarshal_signature (DBusGValueMarshalCtx *context,
- DBusMessageIter *iter,
- GValue *value,
- GError **error)
-{
- const char *sig;
- int current_type;
-
- current_type = dbus_message_iter_get_arg_type (iter);
- if (current_type != DBUS_TYPE_SIGNATURE)
- {
- g_set_error (error,
- DBUS_GERROR,
- DBUS_GERROR_INVALID_ARGS,
- "Expected D-BUS signature, got type code \'%c\'", (guchar) current_type);
- return FALSE;
- }
-
- dbus_message_iter_get_basic (iter, &sig);
-
- g_value_set_boxed (value, sig);
-
- return TRUE;
-}
-
-static gboolean
-demarshal_strv (DBusGValueMarshalCtx *context,
- DBusMessageIter *iter,
- GValue *value,
- GError **error)
-{
- DBusMessageIter subiter;
- int current_type;
- GArray *arr;
-
- current_type = dbus_message_iter_get_arg_type (iter);
- if (current_type != DBUS_TYPE_ARRAY)
- {
- g_set_error (error,
- DBUS_GERROR,
- DBUS_GERROR_INVALID_ARGS,
- "Expected D-BUS array, got type code \'%c\'", (guchar) current_type);
- return FALSE;
- }
-
- dbus_message_iter_recurse (iter, &subiter);
-
- current_type = dbus_message_iter_get_arg_type (&subiter);
- if (current_type != DBUS_TYPE_INVALID
- && current_type != DBUS_TYPE_STRING)
- {
- g_set_error (error,
- DBUS_GERROR,
- DBUS_GERROR_INVALID_ARGS,
- "Expected D-BUS string, got type code \'%c\'", (guchar) current_type);
- return FALSE;
- }
-
- arr = g_array_new (TRUE, FALSE, sizeof (char *));
-
- while ((current_type = dbus_message_iter_get_arg_type (&subiter)) != DBUS_TYPE_INVALID)
- {
- g_assert (current_type == DBUS_TYPE_STRING);
- const char *str;
- char *copy;
-
- dbus_message_iter_get_basic (&subiter, &str);
- copy = g_strdup (str);
- g_array_append_val (arr, copy);
-
- dbus_message_iter_next (&subiter);
- }
-
- g_value_take_boxed (value, arr->data);
- g_array_free (arr, FALSE);
-
- return TRUE;
-}
-
-static gboolean
-demarshal_valuearray (DBusGValueMarshalCtx *context,
- DBusMessageIter *iter,
- GValue *value,
- GError **error)
-{
- int current_type;
- GValueArray *ret;
- DBusMessageIter subiter;
-
- current_type = dbus_message_iter_get_arg_type (iter);
- if (current_type != DBUS_TYPE_STRUCT)
- {
- g_set_error (error,
- DBUS_GERROR,
- DBUS_GERROR_INVALID_ARGS,
- "Expected D-BUS struct, got type code \'%c\'", (guchar) current_type);
- return FALSE;
- }
-
- dbus_message_iter_recurse (iter, &subiter);
-
- ret = g_value_array_new (12);
-
- while ((current_type = dbus_message_iter_get_arg_type (&subiter)) != DBUS_TYPE_INVALID)
- {
- GValue *val;
- GType elt_type;
- char *current_sig;
-
- g_value_array_append (ret, NULL);
- val = g_value_array_get_nth (ret, ret->n_values - 1);
-
- current_sig = dbus_message_iter_get_signature (&subiter);
- elt_type = _dbus_gtype_from_signature (current_sig, TRUE);
-
- if (elt_type == G_TYPE_INVALID)
- {
- g_value_array_free (ret);
- g_set_error (error,
- DBUS_GERROR,
- DBUS_GERROR_INVALID_ARGS,
- "Couldn't demarshal argument with signature \"%s\"", current_sig);
- dbus_free (current_sig);
- return FALSE;
- }
- dbus_free (current_sig);
-
- g_value_init (val, elt_type);
-
- if (!_dbus_gvalue_demarshal (context, &subiter, val, error))
- {
- g_value_array_free (ret);
- return FALSE;
- }
-
- dbus_message_iter_next (&subiter);
- }
-
- g_value_take_boxed (value, ret);
-
- return TRUE;
-}
-
-static gboolean
-demarshal_map (DBusGValueMarshalCtx *context,
- DBusMessageIter *iter,
- GValue *value,
- GError **error)
-{
- GType gtype;
- DBusMessageIter subiter;
- int current_type;
- gpointer ret;
- GType key_gtype;
- GType value_gtype;
- DBusGTypeSpecializedAppendContext appendctx;
-
- current_type = dbus_message_iter_get_arg_type (iter);
- if (current_type != DBUS_TYPE_ARRAY)
- {
- g_set_error (error,
- DBUS_GERROR,
- DBUS_GERROR_INVALID_ARGS,
- "Expected D-BUS array, got type code \'%c\'", (guchar) current_type);
- return FALSE;
- }
-
- gtype = G_VALUE_TYPE (value);
-
- dbus_message_iter_recurse (iter, &subiter);
-
- current_type = dbus_message_iter_get_arg_type (&subiter);
- if (current_type != DBUS_TYPE_INVALID
- && current_type != DBUS_TYPE_DICT_ENTRY)
- {
- g_set_error (error,
- DBUS_GERROR,
- DBUS_GERROR_INVALID_ARGS,
- "Expected D-BUS dict entry, got type code \'%c\'", (guchar) current_type);
- return FALSE;
- }
-
- key_gtype = dbus_g_type_get_map_key_specialization (gtype);
- value_gtype = dbus_g_type_get_map_value_specialization (gtype);
-
- ret = dbus_g_type_specialized_construct (gtype);
- g_value_take_boxed (value, ret);
-
- dbus_g_type_specialized_init_append (value, &appendctx);
-
- while ((current_type = dbus_message_iter_get_arg_type (&subiter)) != DBUS_TYPE_INVALID)
- {
- DBusMessageIter entry_iter;
- GValue key_value = {0,};
- GValue value_value = {0,};
-
- current_type = dbus_message_iter_get_arg_type (&subiter);
- g_assert (current_type == DBUS_TYPE_DICT_ENTRY);
-
- dbus_message_iter_recurse (&subiter, &entry_iter);
-
- g_value_init (&key_value, key_gtype);
- if (!_dbus_gvalue_demarshal (context,
- &entry_iter,
- &key_value,
- error))
- return FALSE;
-
- dbus_message_iter_next (&entry_iter);
-
- g_value_init (&value_value, value_gtype);
- if (!_dbus_gvalue_demarshal (context,
- &entry_iter,
- &value_value,
- error))
- return FALSE;
-
- dbus_g_type_specialized_map_append (&appendctx, &key_value, &value_value);
- /* Ownership of values passes to map, don't unset */
-
- dbus_message_iter_next (&subiter);
- }
-
- return TRUE;
-}
-
-static gboolean
-demarshal_struct (DBusGValueMarshalCtx *context,
- DBusMessageIter *iter,
- GValue *value,
- GError **error)
-{
- int current_type;
- DBusMessageIter subiter;
- guint i, size;
- GValue val = {0,};
- GType elt_type;
-
- current_type = dbus_message_iter_get_arg_type (iter);
- if (current_type != DBUS_TYPE_STRUCT)
- {
- g_set_error (error,
- DBUS_GERROR,
- DBUS_GERROR_INVALID_ARGS,
- "Expected D-BUS struct, got type code \'%c\'", (guchar) current_type);
- return FALSE;
- }
-
- dbus_message_iter_recurse (iter, &subiter);
-
- g_value_take_boxed (value,
- dbus_g_type_specialized_construct (G_VALUE_TYPE (value)));
-
- size = dbus_g_type_get_struct_size (G_VALUE_TYPE (value));
-
- for (i=0; i < size; i++)
- {
-
- elt_type = dbus_g_type_get_struct_member_type (G_VALUE_TYPE(value), i);
- if (elt_type == G_TYPE_INVALID)
- {
- g_value_unset (value);
- g_set_error (error,
- DBUS_GERROR,
- DBUS_GERROR_INVALID_ARGS,
- "Couldn't demarshal argument, "
- "struct type %s has no member %d",
- g_type_name (G_VALUE_TYPE(value)), i);
- return FALSE;
- }
-
- g_value_init (&val, elt_type);
-
- if (!_dbus_gvalue_demarshal (context, &subiter, &val, error))
- {
- g_value_unset (&val);
- g_value_unset (value);
- return FALSE;
- }
- if (!dbus_g_type_struct_set_member (value, i, &val))
- {
- g_value_unset (&val);
- g_value_unset (value);
- return FALSE;
- }
-
- dbus_message_iter_next (&subiter);
- g_value_unset (&val);
- }
-
- g_assert (dbus_message_iter_get_arg_type (&subiter) == DBUS_TYPE_INVALID);
-
- return TRUE;
-}
-
-
-static DBusGValueDemarshalFunc
-get_type_demarshaller (GType type)
-{
- DBusGTypeMarshalData *typedata;
-
- typedata = g_type_get_qdata (type, dbus_g_type_metadata_data_quark ());
- if (typedata == NULL)
- {
- if (g_type_is_a (type, G_TYPE_VALUE_ARRAY))
- return demarshal_valuearray;
- if (dbus_g_type_is_collection (type))
- return demarshal_collection;
- if (dbus_g_type_is_map (type))
- return demarshal_map;
- if (dbus_g_type_is_struct (type))
- return demarshal_struct;
-
- g_warning ("No demarshaller registered for type \"%s\"", g_type_name (type));
- return NULL;
- }
- g_assert (typedata->vtable);
- return typedata->vtable->demarshaller;
-}
-
-static gboolean
-demarshal_collection (DBusGValueMarshalCtx *context,
- DBusMessageIter *iter,
- GValue *value,
- GError **error)
-{
- GType coltype;
- GType subtype;
-
- coltype = G_VALUE_TYPE (value);
- subtype = dbus_g_type_get_collection_specialization (coltype);
-
- if (_dbus_g_type_is_fixed (subtype))
- return demarshal_collection_array (context, iter, value, error);
- else
- return demarshal_collection_ptrarray (context, iter, value, error);
-}
-
-static gboolean
-demarshal_collection_ptrarray (DBusGValueMarshalCtx *context,
- DBusMessageIter *iter,
- GValue *value,
- GError **error)
-{
- GType coltype;
- GType subtype;
- gpointer instance;
- DBusGTypeSpecializedAppendContext ctx;
- DBusGValueDemarshalFunc demarshaller;
- DBusMessageIter subiter;
- int current_type;
-
- current_type = dbus_message_iter_get_arg_type (iter);
-
- if (current_type != DBUS_TYPE_ARRAY)
- {
- g_set_error (error,
- DBUS_GERROR,
- DBUS_GERROR_INVALID_ARGS,
- "Expected D-BUS array, got type code \'%c\'", (guchar) current_type);
- return FALSE;
- }
-
- dbus_message_iter_recurse (iter, &subiter);
-
- coltype = G_VALUE_TYPE (value);
- subtype = dbus_g_type_get_collection_specialization (coltype);
-
- demarshaller = get_type_demarshaller (subtype);
-
- if (!demarshaller)
- {
- g_set_error (error,
- DBUS_GERROR,
- DBUS_GERROR_INVALID_ARGS,
- "No demarshaller registered for type \"%s\" of collection \"%s\"",
- g_type_name (coltype),
- g_type_name (subtype));
- return FALSE;
- }
-
- instance = dbus_g_type_specialized_construct (coltype);
- g_value_take_boxed (value, instance);
-
- dbus_g_type_specialized_init_append (value, &ctx);
-
- while ((current_type = dbus_message_iter_get_arg_type (&subiter)) != DBUS_TYPE_INVALID)
- {
- GValue eltval = {0, };
-
- g_value_init (&eltval, subtype);
-
- if (!demarshaller (context, &subiter, &eltval, error))
- {
- dbus_g_type_specialized_collection_end_append (&ctx);
- g_value_unset (value);
- return FALSE;
- }
- dbus_g_type_specialized_collection_append (&ctx, &eltval);
-
- dbus_message_iter_next (&subiter);
- }
- dbus_g_type_specialized_collection_end_append (&ctx);
-
- return TRUE;
-}
-
-static gboolean
-demarshal_collection_array (DBusGValueMarshalCtx *context,
- DBusMessageIter *iter,
- GValue *value,
- GError **error)
-{
- DBusMessageIter subiter;
- GArray *ret;
- GType elt_gtype;
- int elt_size;
- void *msgarray;
- int msgarray_len;
-
- dbus_message_iter_recurse (iter, &subiter);
-
- elt_gtype = dbus_g_type_get_collection_specialization (G_VALUE_TYPE (value));
- g_assert (elt_gtype != G_TYPE_INVALID);
- g_assert (_dbus_g_type_is_fixed (elt_gtype));
-
- elt_size = _dbus_g_type_fixed_get_size (elt_gtype);
-
- ret = g_array_new (FALSE, TRUE, elt_size);
-
- msgarray = NULL;
- dbus_message_iter_get_fixed_array (&subiter,
- &msgarray,
- &msgarray_len);
- g_assert (msgarray != NULL || msgarray_len == 0);
-
- if (msgarray_len)
- g_array_append_vals (ret, msgarray, (guint) msgarray_len);
-
- g_value_take_boxed (value, ret);
-
- return TRUE;
-}
-
-gboolean
-_dbus_gvalue_demarshal (DBusGValueMarshalCtx *context,
- DBusMessageIter *iter,
- GValue *value,
- GError **error)
-{
- GType gtype;
- DBusGValueDemarshalFunc demarshaller;
- gboolean retcode = FALSE;
-
- if (context->recursion_depth > DBUS_GLIB_MAX_VARIANT_RECURSION)
- {
- g_set_error (error, DBUS_GERROR,
- DBUS_GERROR_NO_MEMORY,
- "Variant recursion limit exceeded");
- return FALSE;
- }
- context->recursion_depth++;
-
- gtype = G_VALUE_TYPE (value);
-
- demarshaller = get_type_demarshaller (gtype);
-
- if (demarshaller == NULL)
- {
- g_set_error (error,
- DBUS_GERROR,
- DBUS_GERROR_INVALID_ARGS,
- "No demarshaller registered for type \"%s\"",
- g_type_name (gtype));
-
- goto out;
- }
-
- retcode = demarshaller (context, iter, value, error);
- out:
- context->recursion_depth--;
- return retcode;
-}
-
-gboolean
-_dbus_gvalue_demarshal_variant (DBusGValueMarshalCtx *context,
- DBusMessageIter *iter,
- GValue *value,
- GError **error)
-{
- return demarshal_static_variant (context, iter, value, error);
-}
-
-GValueArray *
-_dbus_gvalue_demarshal_message (DBusGValueMarshalCtx *context,
- DBusMessage *message,
- guint n_types,
- const GType *types,
- GError **error)
-{
- GValueArray *ret;
- DBusMessageIter iter;
- int current_type;
- guint index_;
-
- ret = g_value_array_new (6); /* 6 is a typical maximum for arguments */
-
- dbus_message_iter_init (message, &iter);
- index_ = 0;
- while ((current_type = dbus_message_iter_get_arg_type (&iter)) != DBUS_TYPE_INVALID)
- {
- GValue *value;
- GType gtype;
-
- if (index_ >= n_types)
- {
- g_set_error (error, DBUS_GERROR,
- DBUS_GERROR_INVALID_ARGS,
- "Too many arguments in message");
- goto lose;
- }
-
- g_value_array_append (ret, NULL);
- value = g_value_array_get_nth (ret, index_);
-
- gtype = types[index_];
- g_value_init (value, gtype);
-
- if (!_dbus_gvalue_demarshal (context, &iter, value, error))
- goto lose;
- dbus_message_iter_next (&iter);
- index_++;
- }
- if (index_ < n_types)
- {
- g_set_error (error, DBUS_GERROR,
- DBUS_GERROR_INVALID_ARGS,
- "Too few arguments in message");
- goto lose;
- }
-
- return ret;
- lose:
- g_value_array_free (ret);
- return NULL;
-}
-
-static void oom (void) G_GNUC_NORETURN;
-static void
-oom (void)
-{
- g_error ("no memory");
-}
-
-static gboolean
-marshal_basic (DBusMessageIter *iter, const GValue *value)
-{
- GType value_type;
-
- value_type = G_VALUE_TYPE (value);
-
- switch (value_type)
- {
- case G_TYPE_CHAR:
- {
- char b = g_value_get_char (value);
- if (!dbus_message_iter_append_basic (iter,
- DBUS_TYPE_BYTE,
- &b))
- oom ();
- }
- return TRUE;
- case G_TYPE_UCHAR:
- {
- unsigned char b = g_value_get_uchar (value);
- if (!dbus_message_iter_append_basic (iter,
- DBUS_TYPE_BYTE,
- &b))
- oom ();
- }
- return TRUE;
- case G_TYPE_BOOLEAN:
- {
- dbus_bool_t b = g_value_get_boolean (value);
-
- g_return_val_if_fail (b == TRUE || b == FALSE, FALSE);
-
- if (!dbus_message_iter_append_basic (iter,
- DBUS_TYPE_BOOLEAN,
- &b))
- oom ();
- }
- return TRUE;
- case G_TYPE_INT:
- {
- dbus_int32_t v = g_value_get_int (value);
- if (!dbus_message_iter_append_basic (iter,
- DBUS_TYPE_INT32,
- &v))
- oom ();
- }
- return TRUE;
- case G_TYPE_UINT:
- {
- dbus_uint32_t v = g_value_get_uint (value);
- if (!dbus_message_iter_append_basic (iter,
- DBUS_TYPE_UINT32,
- &v))
- oom ();
- }
- return TRUE;
- case G_TYPE_LONG:
- {
- dbus_int32_t v = g_value_get_long (value);
- if (!dbus_message_iter_append_basic (iter,
- DBUS_TYPE_INT32,
- &v))
- oom ();
- }
- return TRUE;
- case G_TYPE_ULONG:
- {
- dbus_uint32_t v = g_value_get_ulong (value);
- if (!dbus_message_iter_append_basic (iter,
- DBUS_TYPE_UINT32,
- &v))
- oom ();
- }
- return TRUE;
- case G_TYPE_INT64:
- {
- gint64 v = g_value_get_int64 (value);
- if (!dbus_message_iter_append_basic (iter,
- DBUS_TYPE_INT64,
- &v))
- oom ();
- }
- return TRUE;
- case G_TYPE_UINT64:
- {
- guint64 v = g_value_get_uint64 (value);
- if (!dbus_message_iter_append_basic (iter,
- DBUS_TYPE_UINT64,
- &v))
- oom ();
- }
- return TRUE;
- case G_TYPE_FLOAT:
- {
- double v = g_value_get_float (value);
-
- if (!dbus_message_iter_append_basic (iter,
- DBUS_TYPE_DOUBLE,
- &v))
- oom ();
- }
- return TRUE;
- case G_TYPE_DOUBLE:
- {
- double v = g_value_get_double (value);
-
- if (!dbus_message_iter_append_basic (iter,
- DBUS_TYPE_DOUBLE,
- &v))
- oom ();
- }
- return TRUE;
- case G_TYPE_STRING:
- {
- const char *v = g_value_get_string (value);
- if (!v)
- v = "";
-
- /* FIXME: fd.o #16320: consider using g_return_if_fail to check UTF-8
- * validity */
-
- if (!dbus_message_iter_append_basic (iter,
- DBUS_TYPE_STRING,
- &v))
- {
- gchar *s = g_strdup_value_contents (value);
-
- g_critical ("Unable to marshal string (not UTF-8 or OOM?): %s",
- s);
- g_free (s);
- return FALSE;
- }
- }
- return TRUE;
-
- default:
- {
- g_assert_not_reached ();
- return FALSE;
- }
- }
-}
-
-static gboolean
-marshal_strv (DBusMessageIter *iter,
- const GValue *value)
-{
- DBusMessageIter subiter;
- char **array;
- char **elt;
- gboolean ret = FALSE;
-
- g_assert (G_VALUE_TYPE (value) == g_strv_get_type ());
-
- array = g_value_get_boxed (value);
-
- if (!dbus_message_iter_open_container (iter,
- DBUS_TYPE_ARRAY,
- "s",
- &subiter))
- goto out;
-
- if (array)
- {
- for (elt = array; *elt; elt++)
- {
- if (!dbus_message_iter_append_basic (&subiter,
- DBUS_TYPE_STRING,
- elt))
- goto out;
- }
- }
-
- if (!dbus_message_iter_close_container (iter, &subiter))
- goto out;
- ret = TRUE;
- out:
- return ret;
-}
-
-static gboolean
-marshal_valuearray (DBusMessageIter *iter,
- const GValue *value)
-{
- GValueArray *array;
- guint i;
- DBusMessageIter subiter;
-
- g_assert (G_VALUE_TYPE (value) == G_TYPE_VALUE_ARRAY);
-
- array = g_value_get_boxed (value);
-
- if (!dbus_message_iter_open_container (iter,
- DBUS_TYPE_STRUCT,
- NULL,
- &subiter))
- oom ();
-
- if (array)
- {
- for (i = 0; i < array->n_values; i++)
- {
- if (!_dbus_gvalue_marshal (&subiter, g_value_array_get_nth (array, i)))
- {
- dbus_message_iter_abandon_container (iter, &subiter);
- return FALSE;
- }
- }
- }
-
- return dbus_message_iter_close_container (iter, &subiter);
-}
-
-static gboolean
-marshal_proxy (DBusMessageIter *iter,
- const GValue *value)
-{
- const char *path;
- DBusGProxy *proxy;
-
- g_assert (G_VALUE_TYPE (value) == dbus_g_proxy_get_type ());
-
- proxy = g_value_get_object (value);
- g_return_val_if_fail (DBUS_IS_G_PROXY (proxy), FALSE);
- path = dbus_g_proxy_get_path (proxy);
- g_return_val_if_fail (g_variant_is_object_path (path), FALSE);
-
- if (!dbus_message_iter_append_basic (iter,
- DBUS_TYPE_OBJECT_PATH,
- &path))
- oom ();
-
- return TRUE;
-}
-
-static gboolean
-marshal_object_path (DBusMessageIter *iter,
- const GValue *value)
-{
- const char *path;
-
- g_assert (G_VALUE_TYPE (value) == DBUS_TYPE_G_OBJECT_PATH);
-
- path = g_value_get_boxed (value);
- g_return_val_if_fail (g_variant_is_object_path (path), FALSE);
-
- if (!dbus_message_iter_append_basic (iter,
- DBUS_TYPE_OBJECT_PATH,
- &path))
- oom ();
-
- return TRUE;
-}
-
-static gboolean
-marshal_object (DBusMessageIter *iter,
- const GValue *value)
-{
- const char *path;
- GObject *obj;
-
- obj = g_value_get_object (value);
- g_return_val_if_fail (G_IS_OBJECT (obj), FALSE);
-
- path = _dbus_gobject_get_path (obj);
- g_return_val_if_fail (g_variant_is_object_path (path), FALSE);
-
- if (!dbus_message_iter_append_basic (iter,
- DBUS_TYPE_OBJECT_PATH,
- &path))
- oom ();
-
- return TRUE;
-}
-
-static gboolean
-marshal_signature (DBusMessageIter *iter,
- const GValue *value)
-{
- const char *sig;
-
- g_assert (G_VALUE_TYPE (value) == DBUS_TYPE_G_SIGNATURE);
-
- sig = g_value_get_boxed (value);
- g_return_val_if_fail (g_variant_is_signature (sig), FALSE);
-
- /* failure here isn't strictly *guaranteed* to be OOM, since GDBus might
- * understand more type-codes than our libdbus */
- if (!dbus_message_iter_append_basic (iter,
- DBUS_TYPE_SIGNATURE,
- &sig))
- return FALSE;
-
- return TRUE;
-}
-
-struct DBusGLibHashMarshalData
-{
- const char *entry_sig;
- DBusMessageIter *iter;
- gboolean err;
-};
-
-static void
-marshal_map_entry (const GValue *key,
- const GValue *value,
- gpointer data)
-{
- struct DBusGLibHashMarshalData *hashdata = data;
- DBusMessageIter subiter;
-
- if (hashdata->err)
- return;
-
- if (!dbus_message_iter_open_container (hashdata->iter,
- DBUS_TYPE_DICT_ENTRY,
- NULL,
- &subiter))
- goto lose;
-
- if (!_dbus_gvalue_marshal (&subiter, key))
- goto lose;
-
- if (!_dbus_gvalue_marshal (&subiter, value))
- goto lose;
-
- if (!dbus_message_iter_close_container (hashdata->iter, &subiter))
- goto lose;
-
- return;
- lose:
- hashdata->err = TRUE;
-}
-
-static gboolean
-marshal_map (DBusMessageIter *iter,
- const GValue *value)
-{
- GType gtype;
- DBusMessageIter arr_iter;
- struct DBusGLibHashMarshalData hashdata;
- char *key_sig;
- char *value_sig;
- GType key_type;
- GType value_type;
- char *entry_sig;
- char *array_sig;
-
- gtype = G_VALUE_TYPE (value);
-
- key_type = dbus_g_type_get_map_key_specialization (gtype);
- g_assert (_dbus_gtype_is_valid_hash_key (key_type));
- value_type = dbus_g_type_get_map_value_specialization (gtype);
- g_assert (_dbus_gtype_is_valid_hash_value (value_type));
-
- key_sig = _dbus_gtype_to_signature (key_type);
- if (!key_sig)
- {
- g_warning ("Cannot marshal type \"%s\" in map\n", g_type_name (key_type));
- return FALSE;
- }
- value_sig = _dbus_gtype_to_signature (value_type);
- if (!value_sig)
- {
- g_free (key_sig);
- g_warning ("Cannot marshal type \"%s\" in map\n", g_type_name (value_type));
- return FALSE;
- }
- entry_sig = g_strdup_printf ("%s%s", key_sig, value_sig);
- g_free (key_sig);
- g_free (value_sig);
- array_sig = g_strdup_printf ("%c%s%c",
- DBUS_DICT_ENTRY_BEGIN_CHAR,
- entry_sig,
- DBUS_DICT_ENTRY_END_CHAR);
- if (!dbus_message_iter_open_container (iter,
- DBUS_TYPE_ARRAY,
- array_sig,
- &arr_iter))
- goto lose;
-
- hashdata.iter = &arr_iter;
- hashdata.err = FALSE;
- hashdata.entry_sig = entry_sig;
-
- dbus_g_type_map_value_iterate (value,
- marshal_map_entry,
- &hashdata);
-
- if (hashdata.err)
- {
- dbus_message_iter_abandon_container (iter, &arr_iter);
- goto lose;
- }
- else if (!dbus_message_iter_close_container (iter, &arr_iter))
- {
- goto lose;
- }
-
- out:
- g_free (entry_sig);
- g_free (array_sig);
- return !hashdata.err;
- lose:
- hashdata.err = TRUE;
- goto out;
-}
-
-static gboolean
-marshal_struct (DBusMessageIter *iter,
- const GValue *value)
-{
- GType gtype;
- DBusMessageIter subiter;
- guint size, i;
- GValue val = {0,};
-
- gtype = G_VALUE_TYPE (value);
-
- size = dbus_g_type_get_struct_size (gtype);
-
- if (!dbus_message_iter_open_container (iter,
- DBUS_TYPE_STRUCT,
- NULL,
- &subiter))
- oom ();
-
- for (i = 0; i < size; i++)
- {
- g_value_init (&val, dbus_g_type_get_struct_member_type
- (G_VALUE_TYPE(value), i));
-
- if (!dbus_g_type_struct_get_member (value, i, &val))
- goto abandon;
-
- if (!_dbus_gvalue_marshal (&subiter, &val))
- goto abandon;
-
- g_value_unset(&val);
- }
-
- return dbus_message_iter_close_container (iter, &subiter);
-
-abandon:
- dbus_message_iter_abandon_container (iter, &subiter);
- return FALSE;
-}
-
-static gboolean
-marshal_variant (DBusMessageIter *iter,
- const GValue *value)
-{
- GType value_gtype;
- DBusMessageIter subiter;
- char *variant_sig;
- GValue *real_value;
- gboolean ret = FALSE;
-
- real_value = g_value_get_boxed (value);
- value_gtype = G_VALUE_TYPE (real_value);
-
- variant_sig = _dbus_gvalue_to_signature (real_value);
- if (variant_sig == NULL)
- {
- g_warning ("Cannot marshal type \"%s\" in variant", g_type_name (value_gtype));
- return FALSE;
- }
-
- if (!dbus_message_iter_open_container (iter,
- DBUS_TYPE_VARIANT,
- variant_sig,
- &subiter))
- goto out;
-
- if (!_dbus_gvalue_marshal (&subiter, real_value))
- {
- dbus_message_iter_abandon_container (iter, &subiter);
- goto out;
- }
-
- if (!dbus_message_iter_close_container (iter, &subiter))
- goto out;
-
- ret = TRUE;
- out:
- g_free (variant_sig);
- return ret;
-}
-
-static DBusGValueMarshalFunc
-get_type_marshaller (GType type)
-{
- DBusGTypeMarshalData *typedata;
-
- typedata = g_type_get_qdata (type, dbus_g_type_metadata_data_quark ());
- if (typedata == NULL)
- {
- if (g_type_is_a (type, G_TYPE_VALUE_ARRAY))
- return marshal_valuearray;
- if (dbus_g_type_is_collection (type))
- return marshal_collection;
- if (dbus_g_type_is_map (type))
- return marshal_map;
- if (dbus_g_type_is_struct (type))
- return marshal_struct;
-
- g_warning ("No marshaller registered for type \"%s\"", g_type_name (type));
- return NULL;
- }
- g_assert (typedata->vtable);
- return typedata->vtable->marshaller;
-}
-
-typedef struct
-{
- DBusMessageIter *iter;
- DBusGValueMarshalFunc marshaller;
- gboolean err;
-} DBusGValueCollectionMarshalData;
-
-static void
-collection_marshal_iterator (const GValue *eltval,
- gpointer user_data)
-{
- DBusGValueCollectionMarshalData *data = user_data;
-
- if (data->err)
- return;
-
- if (!data->marshaller (data->iter, eltval))
- data->err = TRUE;
-}
-
-static gboolean
-marshal_collection (DBusMessageIter *iter,
- const GValue *value)
-{
- GType coltype;
- GType subtype;
-
- coltype = G_VALUE_TYPE (value);
- subtype = dbus_g_type_get_collection_specialization (coltype);
-
- if (_dbus_g_type_is_fixed (subtype))
- return marshal_collection_array (iter, value);
- else
- return marshal_collection_ptrarray (iter, value);
-}
-
-static gboolean
-marshal_collection_ptrarray (DBusMessageIter *iter,
- const GValue *value)
-{
- GType coltype;
- GType elt_gtype;
- DBusGValueCollectionMarshalData data;
- DBusMessageIter subiter;
- char *elt_sig;
-
- coltype = G_VALUE_TYPE (value);
- elt_gtype = dbus_g_type_get_collection_specialization (coltype);
- data.marshaller = get_type_marshaller (elt_gtype);
- if (!data.marshaller)
- return FALSE;
-
- elt_sig = _dbus_gtype_to_signature (elt_gtype);
- if (!elt_sig)
- {
- g_warning ("Cannot marshal type \"%s\" in collection\n", g_type_name (elt_gtype));
- return FALSE;
- }
- g_assert (g_variant_is_signature (elt_sig));
-
- if (!dbus_message_iter_open_container (iter,
- DBUS_TYPE_ARRAY,
- elt_sig,
- &subiter))
- oom ();
-
- g_free (elt_sig);
-
- data.iter = &subiter;
- data.err = FALSE;
-
- dbus_g_type_collection_value_iterate (value,
- collection_marshal_iterator,
- &data);
-
- if (data.err)
- {
- dbus_message_iter_abandon_container (iter, &subiter);
- return FALSE;
- }
-
- return dbus_message_iter_close_container (iter, &subiter);
-}
-
-/* If any of these assertions are violated, then marshal_collection_array
- * is buggy for that type. dbus_g_value_basic_array_parse_variant() has
- * general size-conversion code, if needed. */
-G_STATIC_ASSERT (sizeof (dbus_bool_t) == sizeof (gboolean));
-G_STATIC_ASSERT (sizeof (dbus_int32_t) == sizeof (gint));
-G_STATIC_ASSERT (sizeof (dbus_uint32_t) == sizeof (guint));
-/* These should be true regardless, but just for completeness... */
-G_STATIC_ASSERT (sizeof (dbus_int64_t) == sizeof (gint64));
-G_STATIC_ASSERT (sizeof (dbus_uint64_t) == sizeof (guint64));
-G_STATIC_ASSERT (sizeof (double) == sizeof (gdouble));
-
-static gboolean
-marshal_collection_array (DBusMessageIter *iter,
- const GValue *value)
-{
- GType elt_gtype;
- DBusMessageIter subiter;
- GArray *array;
- char *subsignature_str;
-
- array = g_value_get_boxed (value);
- g_return_val_if_fail (array != NULL, FALSE);
-
- elt_gtype = dbus_g_type_get_collection_specialization (G_VALUE_TYPE (value));
- g_assert (_dbus_g_type_is_fixed (elt_gtype));
- subsignature_str = _dbus_gtype_to_signature (elt_gtype);
- if (!subsignature_str)
- {
- g_warning ("Cannot marshal type \"%s\" in collection\n", g_type_name (elt_gtype));
- return FALSE;
- }
- g_assert (g_variant_is_signature (subsignature_str));
-
- if (!dbus_message_iter_open_container (iter,
- DBUS_TYPE_ARRAY,
- subsignature_str,
- &subiter))
- oom ();
-
- /* TODO - This assumes that basic values are the same size
- * is this always true? If it is we can probably avoid
- * a lot of the overhead in _marshal_basic_instance...
- */
- if (!dbus_message_iter_append_fixed_array (&subiter,
- subsignature_str[0],
- &(array->data),
- array->len))
- {
- g_critical ("Unable to serialize %u GArray members as signature %s "
- "(OOM or invalid boolean value?)", array->len, subsignature_str);
-
- g_free (subsignature_str);
- dbus_message_iter_abandon_container (iter, &subiter);
- return FALSE;
- }
-
- g_free (subsignature_str);
- return dbus_message_iter_close_container (iter, &subiter);
-}
-
-gboolean
-_dbus_gvalue_marshal (DBusMessageIter *iter,
- const GValue *value)
-{
- GType gtype;
- DBusGValueMarshalFunc marshaller;
-
- gtype = G_VALUE_TYPE (value);
-
- marshaller = get_type_marshaller (gtype);
- if (marshaller == NULL)
- return FALSE;
- return marshaller (iter, value);
-}
-
-#ifdef DBUS_BUILD_TESTS
-
-static void
-assert_type_maps_to (GType gtype, const char *expected_sig)
-{
- char *sig;
- sig = _dbus_gtype_to_signature (gtype);
- g_assert (sig != NULL);
- g_assert (!strcmp (expected_sig, sig));
- g_free (sig);
-}
-
-static void
-assert_signature_maps_to (const char *sig, GType expected_gtype)
-{
- g_assert (_dbus_gtype_from_signature (sig, TRUE) == expected_gtype);
-}
-
-static void
-assert_bidirectional_mapping (GType gtype, const char *expected_sig)
-{
- assert_type_maps_to (gtype, expected_sig);
- assert_signature_maps_to (expected_sig, gtype);
-}
-
-/*
- * Unit test for general glib stuff
- * Returns: %TRUE on success.
- */
-gboolean
-_dbus_gvalue_test (const char *test_data_dir)
-{
- GType type;
- GType rectype;
-
- g_type_init ();
- _dbus_g_value_types_init ();
-
- assert_bidirectional_mapping (G_TYPE_STRING, DBUS_TYPE_STRING_AS_STRING);
- assert_bidirectional_mapping (G_TYPE_UCHAR, DBUS_TYPE_BYTE_AS_STRING);
- assert_bidirectional_mapping (G_TYPE_UINT, DBUS_TYPE_UINT32_AS_STRING);
-
- assert_bidirectional_mapping (dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_VALUE),
- DBUS_TYPE_ARRAY_AS_STRING DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING DBUS_TYPE_STRING_AS_STRING DBUS_TYPE_VARIANT_AS_STRING DBUS_DICT_ENTRY_END_CHAR_AS_STRING);
- assert_bidirectional_mapping (dbus_g_type_get_collection ("GPtrArray", DBUS_TYPE_G_OBJECT_PATH),
- DBUS_TYPE_ARRAY_AS_STRING DBUS_TYPE_OBJECT_PATH_AS_STRING);
- assert_bidirectional_mapping (dbus_g_type_get_collection ("GArray", G_TYPE_INT),
- DBUS_TYPE_ARRAY_AS_STRING DBUS_TYPE_INT32_AS_STRING);
-
- assert_bidirectional_mapping (dbus_g_type_get_struct ("GValueArray", G_TYPE_INT, G_TYPE_STRING, DBUS_TYPE_G_OBJECT_PATH, G_TYPE_INVALID),
- DBUS_STRUCT_BEGIN_CHAR_AS_STRING DBUS_TYPE_INT32_AS_STRING DBUS_TYPE_STRING_AS_STRING DBUS_TYPE_OBJECT_PATH_AS_STRING DBUS_STRUCT_END_CHAR_AS_STRING );
-
- rectype = dbus_g_type_get_collection ("GArray", G_TYPE_UINT);
- g_assert (rectype != G_TYPE_INVALID);
- g_assert (!strcmp (g_type_name (rectype), "GArray_guint_"));
-
- type = _dbus_gtype_from_signature ("au", TRUE);
- g_assert (type == rectype);
-
- rectype = dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_STRING);
- g_assert (rectype != G_TYPE_INVALID);
- g_assert (!strcmp (g_type_name (rectype), "GHashTable_gchararray+gchararray_"));
-
- type = _dbus_gtype_from_signature ("a{ss}", TRUE);
- g_assert (type == rectype);
-
- type = _dbus_gtype_from_signature ("o", FALSE);
- g_assert (type == DBUS_TYPE_G_OBJECT_PATH);
- type = _dbus_gtype_from_signature ("o", TRUE);
- g_assert (type == DBUS_TYPE_G_OBJECT_PATH);
-
- type = _dbus_gtype_from_signature ("g", TRUE);
- g_assert (type == DBUS_TYPE_G_SIGNATURE);
-
- return TRUE;
-}
-
-#endif /* DBUS_BUILD_TESTS */
diff --git a/dbus/dbus-gvalue.h b/dbus/dbus-gvalue.h
deleted file mode 100644
index 35e05be..0000000
--- a/dbus/dbus-gvalue.h
+++ /dev/null
@@ -1,44 +0,0 @@
-#ifndef DBUS_GOBJECT_VALUE_H
-#define DBUS_GOBJECT_VALUE_H
-
-#include <dbus/dbus.h>
-#include <dbus/dbus-signature.h>
-#include <glib.h>
-#include <glib-object.h>
-#include "dbus/dbus-glib.h"
-
-G_BEGIN_DECLS
-
-typedef struct {
- DBusGConnection *gconnection;
- DBusGProxy *proxy;
- guint recursion_depth;
-} DBusGValueMarshalCtx;
-
-void _dbus_g_value_types_init (void);
-
-char * _dbus_gtype_to_signature (GType type);
-char * _dbus_gvalue_to_signature (const GValue *val);
-
-gboolean _dbus_gvalue_demarshal (DBusGValueMarshalCtx *context,
- DBusMessageIter *iter,
- GValue *value,
- GError **error);
-
-gboolean _dbus_gvalue_demarshal_variant (DBusGValueMarshalCtx *context,
- DBusMessageIter *iter,
- GValue *value,
- GError **error);
-
-GValueArray * _dbus_gvalue_demarshal_message (DBusGValueMarshalCtx *context,
- DBusMessage *message,
- guint n_params,
- const GType *types,
- GError **error);
-
-gboolean _dbus_gvalue_marshal (DBusMessageIter *iter,
- const GValue *value);
-
-G_END_DECLS
-
-#endif /* DBUS_GOBJECT_VALUE_H */
diff --git a/dbus/examples/.cvsignore b/dbus/examples/.cvsignore
deleted file mode 100644
index fc6a063..0000000
--- a/dbus/examples/.cvsignore
+++ /dev/null
@@ -1,17 +0,0 @@
-.deps
-.libs
-Makefile
-Makefile.in
-*.lo
-*.la
-example-client
-example-service
-example-service-glue.h
-example-signal-recipient
-example-signal-emitter
-example-signal-emitter-glue.h
-run-with-tmp-session-bus.conf
-*.bb
-*.bbg
-*.da
-*.gcov
diff --git a/dbus/examples/Makefile.am b/dbus/examples/Makefile.am
deleted file mode 100644
index 867f307..0000000
--- a/dbus/examples/Makefile.am
+++ /dev/null
@@ -1,44 +0,0 @@
-SUBDIRS = . statemachine
-
-AM_CPPFLAGS = \
- -I$(top_srcdir) \
- -I$(top_builddir) \
- -I$(top_builddir)/dbus \
- $(DBUS_CFLAGS) \
- $(DBUS_GLIB_CFLAGS) \
- -DDBUS_COMPILATION
-
-LDADD = \
- $(DBUS_GLIB_LIBS) \
- $(top_builddir)/dbus/libdbus-glib-1.la
-
-## Makefile.am bits for sample client/server pair
-
-noinst_PROGRAMS= example-client example-service
-
-example_client_SOURCES= example-client.c
-
-example_service_SOURCES= example-service.c
-
-BUILT_SOURCES = example-service-glue.h
-
-example-service-glue.h: example-service.xml
- $(LIBTOOL) --mode=execute $(DBUS_BINDING_TOOL) --prefix=some_object --mode=glib-server --output=example-service-glue.h $(srcdir)/example-service.xml
-
-
-## Makefile.am bits for another client/server pair
-
-noinst_PROGRAMS += example-signal-recipient example-signal-emitter
-
-example_signal_recipient_SOURCES= example-signal-recipient.c
-
-example_signal_emitter_SOURCES= example-signal-emitter.c
-
-BUILT_SOURCES += example-signal-emitter-glue.h
-
-example-signal-emitter-glue.h: example-signal-emitter.xml
- $(LIBTOOL) --mode=execute $(DBUS_BINDING_TOOL) --prefix=test_object --mode=glib-server --output=example-signal-emitter-glue.h $(srcdir)/example-signal-emitter.xml
-
-CLEANFILES = $(BUILT_SOURCES)
-
-EXTRA_DIST = example-service.xml example-signal-emitter.xml
diff --git a/dbus/examples/example-client.c b/dbus/examples/example-client.c
deleted file mode 100644
index fe310fd..0000000
--- a/dbus/examples/example-client.c
+++ /dev/null
@@ -1,123 +0,0 @@
-#include <config.h>
-
-#include <dbus/dbus-glib.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-static void lose (const char *fmt, ...) G_GNUC_NORETURN G_GNUC_PRINTF (1, 2);
-static void lose_gerror (const char *prefix, GError *error) G_GNUC_NORETURN;
-
-static void
-lose (const char *str, ...)
-{
- va_list args;
-
- va_start (args, str);
-
- vfprintf (stderr, str, args);
- fputc ('\n', stderr);
-
- va_end (args);
-
- exit (1);
-}
-
-static void
-lose_gerror (const char *prefix, GError *error)
-{
- lose ("%s: %s", prefix, error->message);
-}
-
-static void
-print_hash_value (gpointer key, gpointer val, gpointer data)
-{
- printf ("%s -> %s\n", (char *) key, (char *) val);
-}
-
-int
-main (int argc, char **argv)
-{
- DBusGConnection *bus;
- DBusGProxy *remote_object;
- DBusGProxy *remote_object_introspectable;
- GError *error = NULL;
- char **reply_list;
- char **reply_ptr;
- GValueArray *hello_reply_struct;
- GHashTable *hello_reply_dict;
- char *introspect_data;
- guint i;
-
- g_type_init ();
-
- {
- GLogLevelFlags fatal_mask;
-
- fatal_mask = g_log_set_always_fatal (G_LOG_FATAL_MASK);
- fatal_mask |= G_LOG_LEVEL_WARNING | G_LOG_LEVEL_CRITICAL;
- g_log_set_always_fatal (fatal_mask);
- }
-
- bus = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
- if (!bus)
- lose_gerror ("Couldn't connect to session bus", error);
-
- remote_object = dbus_g_proxy_new_for_name (bus,
- "org.designfu.SampleService",
- "/SomeObject",
- "org.designfu.SampleInterface");
-
- if (!dbus_g_proxy_call (remote_object, "HelloWorld", &error,
- G_TYPE_STRING, "Hello from example-client.c!", G_TYPE_INVALID,
- G_TYPE_STRV, &reply_list, G_TYPE_INVALID))
- lose_gerror ("Failed to complete HelloWorld", error);
-
-
- if (!dbus_g_proxy_call (remote_object, "GetTuple", &error,
- G_TYPE_INVALID,
- G_TYPE_VALUE_ARRAY, &hello_reply_struct, G_TYPE_INVALID))
- lose_gerror ("Failed to complete GetTuple", error);
-
- if (!dbus_g_proxy_call (remote_object, "GetDict", &error,
- G_TYPE_INVALID,
- DBUS_TYPE_G_STRING_STRING_HASHTABLE, &hello_reply_dict, G_TYPE_INVALID))
- lose_gerror ("Failed to complete GetDict", error);
-
- printf ("reply_list: ");
- for (reply_ptr = reply_list; *reply_ptr; reply_ptr++)
- printf ("\"%s\" ", *reply_ptr);
- printf ("\n");
- g_strfreev (reply_list);
-
- for (i = 0; i < hello_reply_struct->n_values; i++)
- {
- GValue strval = { 0, };
-
- g_value_init (&strval, G_TYPE_STRING);
- if (!g_value_transform (g_value_array_get_nth (hello_reply_struct, i), &strval))
- g_value_set_static_string (&strval, "(couldn't transform to string)");
- g_print ("%s: %s\n", g_type_name (G_VALUE_TYPE (g_value_array_get_nth (hello_reply_struct, i))),
- g_value_get_string (&strval));
- }
- g_value_array_free (hello_reply_struct);
- printf ("\n");
-
- g_hash_table_foreach (hello_reply_dict, print_hash_value, NULL);
- g_hash_table_destroy (hello_reply_dict);
-
- remote_object_introspectable = dbus_g_proxy_new_for_name (bus,
- "org.designfu.SampleService",
- "/SomeObject",
- "org.freedesktop.DBus.Introspectable");
- if (!dbus_g_proxy_call (remote_object_introspectable, "Introspect", &error,
- G_TYPE_INVALID,
- G_TYPE_STRING, &introspect_data, G_TYPE_INVALID))
- lose_gerror ("Failed to complete Introspect", error);
- printf ("%s", introspect_data);
- g_free (introspect_data);
-
- g_object_unref (G_OBJECT (remote_object_introspectable));
- g_object_unref (G_OBJECT (remote_object));
-
- exit(0);
-}
diff --git a/dbus/examples/example-service.c b/dbus/examples/example-service.c
deleted file mode 100644
index 19d2efd..0000000
--- a/dbus/examples/example-service.c
+++ /dev/null
@@ -1,155 +0,0 @@
-#include <config.h>
-
-#include <dbus/dbus-glib.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-static void lose (const char *fmt, ...) G_GNUC_NORETURN G_GNUC_PRINTF (1, 2);
-static void lose_gerror (const char *prefix, GError *error) G_GNUC_NORETURN;
-
-static void
-lose (const char *str, ...)
-{
- va_list args;
-
- va_start (args, str);
-
- vfprintf (stderr, str, args);
- fputc ('\n', stderr);
-
- va_end (args);
-
- exit (1);
-}
-
-static void
-lose_gerror (const char *prefix, GError *error)
-{
- lose ("%s: %s", prefix, error->message);
-}
-
-typedef struct SomeObject SomeObject;
-typedef struct SomeObjectClass SomeObjectClass;
-
-GType some_object_get_type (void);
-
-struct SomeObject
-{
- GObject parent;
-};
-
-struct SomeObjectClass
-{
- GObjectClass parent;
-};
-
-#define SOME_TYPE_OBJECT (some_object_get_type ())
-#define SOME_OBJECT(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), SOME_TYPE_OBJECT, SomeObject))
-#define SOME_OBJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SOME_TYPE_OBJECT, SomeObjectClass))
-#define SOME_IS_OBJECT(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), SOME_TYPE_OBJECT))
-#define SOME_IS_OBJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SOME_TYPE_OBJECT))
-#define SOME_OBJECT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SOME_TYPE_OBJECT, SomeObjectClass))
-
-G_DEFINE_TYPE(SomeObject, some_object, G_TYPE_OBJECT)
-
-gboolean some_object_hello_world (SomeObject *obj, const char *hello_message, char ***ret, GError **error);
-gboolean some_object_get_tuple (SomeObject *obj, GValueArray **ret, GError **error);
-gboolean some_object_get_dict (SomeObject *obj, GHashTable **ret, GError **error);
-
-#include "example-service-glue.h"
-
-static void
-some_object_init (SomeObject *obj)
-{
-}
-
-static void
-some_object_class_init (SomeObjectClass *klass)
-{
-}
-
-gboolean
-some_object_hello_world (SomeObject *obj, const char *hello_message, char ***ret, GError **error)
-{
- printf ("%s\n", hello_message);
- *ret = g_new (char *, 3);
- (*ret)[0] = g_strdup ("Hello");
- (*ret)[1] = g_strdup (" from example-service.c");
- (*ret)[2] = NULL;
-
- return TRUE;
-}
-
-gboolean
-some_object_get_tuple (SomeObject *obj, GValueArray **ret, GError **error)
-{
- *ret = g_value_array_new (6);
- g_value_array_prepend (*ret, NULL);
- g_value_init (g_value_array_get_nth (*ret, 0), G_TYPE_STRING);
- g_value_set_string (g_value_array_get_nth (*ret, 0), "hello");
- g_value_array_prepend (*ret, NULL);
- g_value_init (g_value_array_get_nth (*ret, 0), G_TYPE_UINT);
- g_value_set_uint (g_value_array_get_nth (*ret, 0), 42);
-
- return TRUE;
-}
-
-gboolean
-some_object_get_dict (SomeObject *obj, GHashTable **ret, GError **error)
-{
- *ret = g_hash_table_new (g_str_hash, g_str_equal);
- g_hash_table_insert (*ret, "first", "Hello Dict");
- g_hash_table_insert (*ret, "second", " from example-service.c");
- return TRUE;
-}
-
-int
-main (int argc, char **argv)
-{
- DBusGConnection *bus;
- DBusGProxy *bus_proxy;
- GError *error = NULL;
- SomeObject *obj;
- GMainLoop *mainloop;
- guint request_name_result;
-
- g_type_init ();
-
- {
- GLogLevelFlags fatal_mask;
-
- fatal_mask = g_log_set_always_fatal (G_LOG_FATAL_MASK);
- fatal_mask |= G_LOG_LEVEL_WARNING | G_LOG_LEVEL_CRITICAL;
- g_log_set_always_fatal (fatal_mask);
- }
-
- dbus_g_object_type_install_info (SOME_TYPE_OBJECT, &dbus_glib_some_object_object_info);
-
- mainloop = g_main_loop_new (NULL, FALSE);
-
- bus = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
- if (!bus)
- lose_gerror ("Couldn't connect to session bus", error);
-
- bus_proxy = dbus_g_proxy_new_for_name (bus, "org.freedesktop.DBus",
- "/org/freedesktop/DBus",
- "org.freedesktop.DBus");
-
- if (!dbus_g_proxy_call (bus_proxy, "RequestName", &error,
- G_TYPE_STRING, "org.designfu.SampleService",
- G_TYPE_UINT, 0,
- G_TYPE_INVALID,
- G_TYPE_UINT, &request_name_result,
- G_TYPE_INVALID))
- lose_gerror ("Failed to acquire org.designfu.SampleService", error);
-
- obj = g_object_new (SOME_TYPE_OBJECT, NULL);
-
- dbus_g_connection_register_g_object (bus, "/SomeObject", G_OBJECT (obj));
-
- printf ("service running\n");
-
- g_main_loop_run (mainloop);
-
- exit (0);
-}
diff --git a/dbus/examples/example-service.xml b/dbus/examples/example-service.xml
deleted file mode 100644
index 9c39bb0..0000000
--- a/dbus/examples/example-service.xml
+++ /dev/null
@@ -1,19 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-
-<node name="/">
- <interface name="org.designfu.SampleInterface">
- <method name="HelloWorld">
- <arg type="s"/>
- <arg type="as" direction="out"/>
- </method>
-
- <method name="GetTuple">
- <arg type="(ss)" direction="out" />
- </method>
-
- <method name="GetDict">
- <arg type="a{ss}" direction="out"/>
- </method>
-
- </interface>
-</node>
diff --git a/dbus/examples/example-signal-emitter.c b/dbus/examples/example-signal-emitter.c
deleted file mode 100644
index 0693dff..0000000
--- a/dbus/examples/example-signal-emitter.c
+++ /dev/null
@@ -1,134 +0,0 @@
-#include <config.h>
-
-#include <dbus/dbus-glib.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-static void lose (const char *fmt, ...) G_GNUC_NORETURN G_GNUC_PRINTF (1, 2);
-static void lose_gerror (const char *prefix, GError *error) G_GNUC_NORETURN;
-
-static void
-lose (const char *str, ...)
-{
- va_list args;
-
- va_start (args, str);
-
- vfprintf (stderr, str, args);
- fputc ('\n', stderr);
-
- va_end (args);
-
- exit (1);
-}
-
-static void
-lose_gerror (const char *prefix, GError *error)
-{
- lose ("%s: %s", prefix, error->message);
-}
-
-typedef struct TestObject TestObject;
-typedef struct TestObjectClass TestObjectClass;
-
-GType test_object_get_type (void);
-
-struct TestObject
-{
- GObject parent;
-};
-
-struct TestObjectClass
-{
- GObjectClass parent;
-};
-
-enum
-{
- HELLO_SIGNAL,
- LAST_SIGNAL
-};
-
-static guint signals[LAST_SIGNAL] = { 0 };
-
-#define TEST_TYPE_OBJECT (test_object_get_type ())
-#define TEST_OBJECT(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), TEST_TYPE_OBJECT, TestObject))
-#define TEST_OBJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TEST_TYPE_OBJECT, TestObjectClass))
-#define TEST_IS_OBJECT(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), TEST_TYPE_OBJECT))
-#define TEST_IS_OBJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TEST_TYPE_OBJECT))
-#define TEST_OBJECT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TEST_TYPE_OBJECT, TestObjectClass))
-
-G_DEFINE_TYPE(TestObject, test_object, G_TYPE_OBJECT)
-
-gboolean test_object_emit_hello_signal (TestObject *obj, GError **error);
-
-#include "example-signal-emitter-glue.h"
-
-static void
-test_object_init (TestObject *obj)
-{
-}
-
-static void
-test_object_class_init (TestObjectClass *klass)
-{
- signals[HELLO_SIGNAL] =
- g_signal_new ("hello_signal",
- G_OBJECT_CLASS_TYPE (klass),
- G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
- 0,
- NULL, NULL,
- g_cclosure_marshal_VOID__STRING,
- G_TYPE_NONE, 1, G_TYPE_STRING);
-}
-
-gboolean
-test_object_emit_hello_signal (TestObject *obj, GError **error)
-{
- g_signal_emit (obj, signals[HELLO_SIGNAL], 0, "Hello");
- return TRUE;
-}
-
-
-int
-main (int argc, char **argv)
-{
- DBusGConnection *bus;
- DBusGProxy *bus_proxy;
- GError *error = NULL;
- TestObject *obj;
- GMainLoop *mainloop;
- guint request_name_result;
-
- g_type_init ();
-
- dbus_g_object_type_install_info (TEST_TYPE_OBJECT, &dbus_glib_test_object_object_info);
-
- mainloop = g_main_loop_new (NULL, FALSE);
-
- bus = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
- if (!bus)
- lose_gerror ("Couldn't connect to session bus", error);
-
- bus_proxy = dbus_g_proxy_new_for_name (bus, "org.freedesktop.DBus",
- "/org/freedesktop/DBus",
- "org.freedesktop.DBus");
-
- if (!dbus_g_proxy_call (bus_proxy, "RequestName", &error,
- G_TYPE_STRING, "org.designfu.TestService",
- G_TYPE_UINT, 0,
- G_TYPE_INVALID,
- G_TYPE_UINT, &request_name_result,
- G_TYPE_INVALID))
- lose_gerror ("Failed to acquire org.designfu.TestService", error);
-
- obj = g_object_new (TEST_TYPE_OBJECT, NULL);
-
- dbus_g_connection_register_g_object (bus, "/org/designfu/TestService/object", G_OBJECT (obj));
-
- printf ("test service running\n");
-
- g_main_loop_run (mainloop);
-
- exit (0);
-}
diff --git a/dbus/examples/example-signal-emitter.xml b/dbus/examples/example-signal-emitter.xml
deleted file mode 100644
index ae178e3..0000000
--- a/dbus/examples/example-signal-emitter.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-
-<node name="/">
- <interface name="org.designfu.TestService">
-
- <method name="emitHelloSignal">
- </method>
-
- <!-- Mark the signal as exported -->
- <signal name="HelloSignal"/>
-
- </interface>
-</node>
diff --git a/dbus/examples/example-signal-recipient.c b/dbus/examples/example-signal-recipient.c
deleted file mode 100644
index 0ebd2d0..0000000
--- a/dbus/examples/example-signal-recipient.c
+++ /dev/null
@@ -1,104 +0,0 @@
-#include <config.h>
-
-#include <dbus/dbus-glib.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-static void lose (const char *fmt, ...) G_GNUC_NORETURN G_GNUC_PRINTF (1, 2);
-static void lose_gerror (const char *prefix, GError *error) G_GNUC_NORETURN;
-
-static void
-lose (const char *str, ...)
-{
- va_list args;
-
- va_start (args, str);
-
- vfprintf (stderr, str, args);
- fputc ('\n', stderr);
-
- va_end (args);
-
- exit (1);
-}
-
-static void
-lose_gerror (const char *prefix, GError *error)
-{
- lose ("%s: %s", prefix, error->message);
-}
-
-static gboolean
-emit_signal (gpointer arg)
-{
- DBusGProxy *proxy = arg;
-
- dbus_g_proxy_call_no_reply (proxy, "emitHelloSignal", G_TYPE_INVALID);
- return TRUE;
-}
-
-static void
-hello_signal_handler (DBusGProxy *proxy, const char *hello_string, gpointer user_data)
-{
- printf ("Received signal and it says: %s\n", hello_string);
-}
-
-int
-main (int argc, char **argv)
-{
- DBusGConnection *bus;
- DBusGProxy *remote_object;
- GError *error = NULL;
- GMainLoop *mainloop;
-
- g_type_init ();
-
- mainloop = g_main_loop_new (NULL, FALSE);
-
- bus = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
- if (!bus)
- lose_gerror ("Couldn't connect to session bus", error);
-
- /* We use _for_name_owner in order to track this particular service
- * instance, which lets us receive signals.
- */
- remote_object = dbus_g_proxy_new_for_name (bus,
- "org.designfu.TestService",
- "/org/designfu/TestService/object",
- "org.designfu.TestService");
- if (!remote_object)
- lose_gerror ("Failed to get name owner", error);
-
- /* IMPORTANT:
- *
- * Note because this signal's signature is VOID__STRING, we do not
- * need to register a marshaller, since there is a builtin one.
- * However for other signatures, you must generate a marshaller,
- * then call dbus_g_object_register_marshaller. It would look like
- * this:
- *
- * dbus_g_object_register_marshaller (g_cclosure_marshal_VOID__STRING, G_TYPE_NONE, G_TYPE_STRING, G_TYPE_INVALID);
- *
- */
-
- /* Tell DBus what the type signature of the signal callback is; this
- * allows us to sanity-check incoming messages before invoking the
- * callback. You need to do this once for each proxy you create,
- * not every time you want to connect to the signal.
- */
- dbus_g_proxy_add_signal (remote_object, "HelloSignal", G_TYPE_STRING, G_TYPE_INVALID);
-
- /* Actually connect to the signal. Note you can call
- * dbus_g_proxy_connect_signal multiple times for one invocation of
- * dbus_g_proxy_add_signal.
- */
- dbus_g_proxy_connect_signal (remote_object, "HelloSignal", G_CALLBACK (hello_signal_handler),
- NULL, NULL);
-
-
- g_timeout_add (2000, emit_signal, remote_object);
-
- g_main_loop_run (mainloop);
-
- exit (0);
-}
diff --git a/dbus/examples/statemachine/.cvsignore b/dbus/examples/statemachine/.cvsignore
deleted file mode 100644
index 6bf7421..0000000
--- a/dbus/examples/statemachine/.cvsignore
+++ /dev/null
@@ -1,16 +0,0 @@
-.deps
-.libs
-Makefile
-Makefile.in
-*.lo
-*.la
-statemachine-client
-statemachine-server
-statemachine-glue.h
-statemachine-server-glue.h
-run-with-tmp-session-bus.conf
-sm-marshal.[ch]
-*.bb
-*.bbg
-*.da
-*.gcov
diff --git a/dbus/examples/statemachine/Makefile.am b/dbus/examples/statemachine/Makefile.am
deleted file mode 100644
index 671fcda..0000000
--- a/dbus/examples/statemachine/Makefile.am
+++ /dev/null
@@ -1,46 +0,0 @@
-AM_CPPFLAGS = \
- -I$(top_srcdir) \
- -I$(top_builddir) \
- -I$(top_builddir)/dbus \
- $(DBUS_CFLAGS) \
- $(DBUS_GLIB_CFLAGS) \
- $(DBUS_GTK_THREADS_CFLAGS) \
- -DDBUS_COMPILATION
-
-LDADD = $(top_builddir)/dbus/libdbus-glib-1.la \
- $(DBUS_GLIB_LIBS)
-
-## Makefile.am bits for sample client/server pair
-
-noinst_PROGRAMS= statemachine-server
-
-#if HAVE_GTK
-#noinst_PROGRAMS += statemachine-client
-#endif
-
-EXTRA_DIST = statemachine.h statemachine-server.h sm-marshal.list statemachine-server.xml statemachine.xml
-
-statemachine_server_SOURCES= statemachine-server.c sm-marshal.c statemachine.c
-
-#statemachine_client_SOURCES= statemachine-client.c sm-marshal.c statemachine.h
-#statemachine_client_LDADD= $(LDADD) $(DBUS_GTK_THREADS_LIBS)
-
-BUILT_SOURCES = statemachine-server-glue.h statemachine-glue.h
-
-statemachine-server-glue.h: statemachine-server.xml
- $(LIBTOOL) --mode=execute $(DBUS_BINDING_TOOL) --prefix=sm_server --mode=glib-server --output=$@ $<
-
-statemachine-glue.h: statemachine.xml
- $(LIBTOOL) --mode=execute $(DBUS_BINDING_TOOL) --prefix=sm_object --mode=glib-server --output=$@ $<
-
-sm-marshal.c: Makefile sm-marshal.list
- echo "#include <config.h>" > $@.tmp
- @GLIB_GENMARSHAL@ --prefix=sm_marshal $(srcdir)/sm-marshal.list --header --body >> $@.tmp
- mv $@.tmp $@
-
-sm-marshal.h: Makefile sm-marshal.list
- @GLIB_GENMARSHAL@ --prefix=sm_marshal $(srcdir)/sm-marshal.list --header > $@.tmp && mv $@.tmp $@
-
-BUILT_SOURCES += sm-marshal.c sm-marshal.h
-
-CLEANFILES = $(BUILT_SOURCES)
diff --git a/dbus/examples/statemachine/sm-marshal.list b/dbus/examples/statemachine/sm-marshal.list
deleted file mode 100644
index e72aa4b..0000000
--- a/dbus/examples/statemachine/sm-marshal.list
+++ /dev/null
@@ -1 +0,0 @@
-VOID:STRING,BOXED
diff --git a/dbus/examples/statemachine/statemachine-client.c b/dbus/examples/statemachine/statemachine-client.c
deleted file mode 100644
index f0b0457..0000000
--- a/dbus/examples/statemachine/statemachine-client.c
+++ /dev/null
@@ -1,664 +0,0 @@
-#include <config.h>
-
-#include <dbus/dbus-glib.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <gtk/gtk.h>
-#include <glib/gi18n.h>
-#include "sm-marshal.h"
-
-static void lose (const char *fmt, ...) G_GNUC_NORETURN G_GNUC_PRINTF (1, 2);
-static void lose_gerror (const char *prefix, GError *error) G_GNUC_NORETURN;
-
-static void
-lose (const char *str, ...)
-{
- va_list args;
- GtkWidget *dialog;
- char *text;
-
- va_start (args, str);
-
- text = g_strdup_vprintf (str, args);
-
- va_end (args);
-
- dialog = gtk_message_dialog_new (NULL,
- GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_MESSAGE_ERROR,
- GTK_BUTTONS_CLOSE,
- "%s",
- text);
- gtk_dialog_run (GTK_DIALOG (dialog));
-
- g_free (text);
-
- exit (1);
-}
-
-static void
-lose_gerror (const char *prefix, GError *error)
-{
- GtkWidget *dialog;
-
- dialog = gtk_message_dialog_new (NULL,
- GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_MESSAGE_ERROR,
- GTK_BUTTONS_CLOSE,
- "%s",
- prefix);
- gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
- "%s",
- error->message);
-
- gtk_dialog_run (GTK_DIALOG (dialog));
-
- exit (1);
-}
-
-typedef struct
-{
- char *name;
- char *state;
- gdouble progress;
- DBusGProxy *proxy;
- DBusGProxyCall *get_progress_call;
-} MachineInfo;
-
-typedef struct
-{
- GtkWindow *window;
- GtkWidget *view;
- GtkTreeModel *store;
-
- DBusGConnection *bus;
- DBusGProxy *server_proxy;
-
- GSList *pending_creation_calls;
- DBusGProxyCall *get_machines_call;
-} ClientState;
-
-static gboolean
-proxy_to_iter (GtkTreeModel *model, DBusGProxy *proxy, GtkTreeIter *iter)
-{
- if (!gtk_tree_model_get_iter_first (model, iter))
- return FALSE;
- do {
- MachineInfo *info;
- gtk_tree_model_get (model, iter, 0, &info, -1);
- if (info->proxy == proxy)
- return TRUE;
- } while (gtk_tree_model_iter_next (model, iter));
- return FALSE;
-}
-
-static void
-signal_row_change (ClientState *state, GtkTreeIter *iter)
-{
- GtkTreePath *path;
- path = gtk_tree_model_get_path (state->store, iter);
- gtk_tree_model_row_changed (state->store, path, iter);
- gtk_tree_path_free (path);
-}
-
-static void
-get_machine_info_cb (DBusGProxy *proxy,
- DBusGProxyCall *call,
- gpointer data)
-{
- GtkTreeIter iter;
- ClientState *state = data;
- GError *error = NULL;
- char *name, *statename;
- MachineInfo *info;
-
- if (!dbus_g_proxy_end_call (proxy, call, &error,
- G_TYPE_STRING, &name,
- G_TYPE_STRING, &statename,
- G_TYPE_INVALID))
- lose_gerror ("Couldn't complete GetInfo", error);
-
- if (!proxy_to_iter (state->store, proxy, &iter))
- g_assert_not_reached ();
-
- gtk_tree_model_get (state->store, &iter, 0, &info, -1);
- g_free (info->name);
- info->name = name;
- g_free (info->state);
- info->state = statename;
- signal_row_change (state, &iter);
-}
-
-static void
-set_proxy_acquisition_progress (ClientState *state,
- DBusGProxy *proxy,
- double progress)
-{
- MachineInfo *info;
- GtkTreeIter iter;
-
- if (!proxy_to_iter (state->store, proxy, &iter))
- g_assert_not_reached ();
- gtk_tree_model_get (state->store, &iter, 0, &info, -1);
-
- /* Ignore machines in unknown state */
- if (!info->state)
- return;
-
- if (strcmp (info->state, "Acquired"))
- lose ("Got AcquisitionProgress signal in bad state %s",
- info->state);
-
- g_print ("Got acquisition progress change for %p (%s) to %f\n", proxy, info->name ? info->name : "(unknown)", progress);
-
- info->progress = progress;
-
- signal_row_change (state, &iter);
-}
-
-static void
-proxy_acquisition_changed_cb (DBusGProxy *proxy,
- double progress,
- gpointer user_data)
-{
- set_proxy_acquisition_progress (user_data, proxy, progress);
-}
-
-static void
-get_acquiring_progress_cb (DBusGProxy *proxy,
- DBusGProxyCall *call,
- gpointer user_data)
-{
- GError *error = NULL;
- MachineInfo *info;
- GtkTreeIter iter;
- ClientState *state = user_data;
- gdouble progress;
-
- if (!proxy_to_iter (state->store, proxy, &iter))
- g_assert_not_reached ();
- gtk_tree_model_get (state->store, &iter, 0, &info, -1);
-
- g_assert (info->get_progress_call == call);
-
- if (!dbus_g_proxy_end_call (proxy, call, &error,
- G_TYPE_DOUBLE, &progress, G_TYPE_INVALID))
- lose_gerror ("Failed to complete GetAcquiringProgress call", error);
- info->get_progress_call = NULL;
-
- set_proxy_acquisition_progress (state, proxy, progress);
-}
-
-static void
-proxy_state_changed_cb (DBusGProxy *proxy,
- const char *statename,
- gpointer user_data)
-{
- MachineInfo *info;
- GtkTreeIter iter;
- ClientState *state = user_data;
-
- if (!proxy_to_iter (state->store, proxy, &iter))
- g_assert_not_reached ();
- gtk_tree_model_get (state->store, &iter, 0, &info, -1);
-
- g_print ("Got state change for %p (%s) to %s\n", proxy, info->name ? info->name : "(unknown)", statename);
-
- g_free (info->state);
- info->state = g_strdup (statename);
-
- if (!strcmp (info->state, "Acquired"))
- {
- g_print ("Starting GetAcquiringProgress call for %p\n", info->proxy);
- if (info->get_progress_call != NULL)
- {
- dbus_g_proxy_cancel_call (info->proxy, info->get_progress_call);
- info->get_progress_call = NULL;
- }
- info->get_progress_call =
- dbus_g_proxy_begin_call (info->proxy, "GetAcquiringProgress",
- get_acquiring_progress_cb,
- state, NULL,
- G_TYPE_INVALID);
- }
- else
- info->progress = 0.0;
-
- signal_row_change (state, &iter);
-}
-
-static void
-add_machine (ClientState *state,
- const char *name,
- const char *mstate,
- const char *path)
-{
- MachineInfo *info;
- GtkTreeIter iter;
-
- info = g_new0 (MachineInfo, 1);
- info->name = g_strdup (name);
- info->state = g_strdup (mstate);
- info->progress = 0.0;
-
- info->proxy = dbus_g_proxy_new_for_name (state->bus,
- "com.example.StateServer",
- path,
- "com.example.StateMachine");
-
- if (!info->state)
- {
- g_print ("Starting GetInfo call for %p\n", info->proxy);
- dbus_g_proxy_begin_call (info->proxy, "GetInfo",
- get_machine_info_cb,
- state, NULL,
- G_TYPE_INVALID);
- }
-
- /* Watch for state changes */
- dbus_g_proxy_add_signal (info->proxy, "StateChanged",
- G_TYPE_STRING, G_TYPE_INVALID);
-
- dbus_g_proxy_connect_signal (info->proxy,
- "StateChanged",
- G_CALLBACK (proxy_state_changed_cb),
- state,
- NULL);
-
- dbus_g_proxy_add_signal (info->proxy, "AcquisitionProgress",
- G_TYPE_DOUBLE, G_TYPE_INVALID);
-
- dbus_g_proxy_connect_signal (info->proxy,
- "AcquisitionProgress",
- G_CALLBACK (proxy_acquisition_changed_cb),
- state,
- NULL);
-
- gtk_list_store_prepend (GTK_LIST_STORE (state->store), &iter);
- gtk_list_store_set (GTK_LIST_STORE (state->store), &iter, 0, info, -1);
-
-}
-
-static void
-machine_created_cb (DBusGProxy *proxy,
- const char *name,
- const char *path,
- gpointer data)
-{
- ClientState *state = data;
-
- add_machine (state, name, NULL, path);
-}
-
-static void
-server_destroyed_cb (DBusGProxy *proxy, gpointer data)
-{
- g_print ("Server terminated!\n");
- GtkWidget *dialog;
-
- dialog = gtk_message_dialog_new (NULL,
- GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_MESSAGE_INFO,
- GTK_BUTTONS_CLOSE,
- "State Machine server has exited");
-
- gtk_dialog_run (GTK_DIALOG (dialog));
-
- exit (1);
-}
-
-static void
-window_destroyed_cb (GtkWidget *window, gpointer data)
-{
- gtk_main_quit ();
-}
-
-static void
-create_machine_completed_cb (DBusGProxy *proxy, DBusGProxyCall *call, gpointer data)
-{
- GError *error = NULL;
- ClientState *state = data;
-
- if (!dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_INVALID))
- {
- /* Ignore NameInUse errors */
- if (dbus_g_error_has_name (error, "com.example.StateServer.NameInUse"))
- ;
- else
- lose_gerror ("Failed to create new state machine", error);
- }
- g_print ("machine created successfully\n");
- state->pending_creation_calls = g_slist_remove (state->pending_creation_calls, call);
-}
-
-static void
-send_create_machine (ClientState *state)
-{
- DBusGProxyCall *call;
- char *name;
- gint n_children;
-
- n_children = gtk_tree_model_iter_n_children (state->store, NULL);
- name = g_strdup_printf ("machine%d", n_children);
-
- g_print ("Invoking CreateMachine(%s)\n", name);
- call = dbus_g_proxy_begin_call (state->server_proxy, "CreateMachine",
- create_machine_completed_cb,
- state, NULL,
- G_TYPE_STRING, name, G_TYPE_INVALID);
- g_free (name);
- state->pending_creation_calls = g_slist_prepend (state->pending_creation_calls, call);
-}
-
-static void
-do_a_state_change (ClientState *state)
-{
- gint index;
- GtkTreeIter iter;
- gint n_children;
- MachineInfo *info;
-
- n_children = gtk_tree_model_iter_n_children (state->store, NULL);
- if (n_children == 0)
- {
- g_print ("No machines yet, not doing a state switch\n");
- return;
- }
-
- index = g_random_int_range (0, n_children);
- gtk_tree_model_iter_nth_child (state->store, &iter, NULL, index);
- gtk_tree_model_get (state->store, &iter, 0, &info, -1);
-
- if (!info->state)
- {
- g_print ("Machine not yet in known state, skipping state switch\n");
- return;
- }
-
- if (!strcmp (info->state, "Shutdown"))
- {
- g_print ("Sending Start request to machine %s\n", info->name);
- dbus_g_proxy_call_no_reply (info->proxy, "Start", G_TYPE_INVALID);
- }
- else if (!strcmp (info->state, "Loading"))
- {
-
- g_print ("Sending Reacquire request to machine %s\n", info->name);
- dbus_g_proxy_call_no_reply (info->proxy, "Reacquire", G_TYPE_INVALID);
- }
- else
- {
- g_print ("Sending Shutdown request to machine %s\n", info->name);
- dbus_g_proxy_call_no_reply (info->proxy, "Shutdown", G_TYPE_INVALID);
- }
-}
-
-static gboolean
-do_something_random_2 (gpointer data)
-{
- ClientState *state = data;
- do_a_state_change (state);
- g_timeout_add (g_random_int_range (2000, 5000), do_something_random_2, state);
- return FALSE;
-}
-
-static gboolean
-do_something_random (gpointer data)
-{
- ClientState *state = data;
- gint n_children;
-
- switch (g_random_int_range (0, 3))
- {
- case 0:
- send_create_machine (state);
- break;
- case 1:
- case 2:
- do_a_state_change (state);
- break;
- default:
- g_assert_not_reached ();
- }
-
- n_children = gtk_tree_model_iter_n_children (state->store, NULL);
- if (n_children >= 5)
- {
- g_print ("MAX children reached, switching to state changes only\n");
- g_timeout_add (g_random_int_range (500, 3000), do_something_random_2, state);
- }
- else
- g_timeout_add (g_random_int_range (500, 3000), do_something_random, state);
- return FALSE;
-}
-
-static void
-set_cell_name (GtkTreeViewColumn *tree_column,
- GtkCellRenderer *cell,
- GtkTreeModel *tree_model,
- GtkTreeIter *iter,
- gpointer data)
-{
- MachineInfo *info;
-
- gtk_tree_model_get (tree_model, iter, 0, &info, -1);
-
- g_object_set (cell, "text", info->name ? info->name : "", NULL);
-}
-
-static gint
-sort_by_name (GtkTreeModel *model,
- GtkTreeIter *a,
- GtkTreeIter *b,
- gpointer user_data)
-{
- MachineInfo *info_a, *info_b;
-
- gtk_tree_model_get (model, a, 0, &info_a, -1);
- gtk_tree_model_get (model, b, 0, &info_b, -1);
-
- return strcmp (info_a->name ? info_a->name : "",
- info_b ? info_b->name : "");
-}
-
-static void
-set_cell_state (GtkTreeViewColumn *tree_column,
- GtkCellRenderer *cell,
- GtkTreeModel *tree_model,
- GtkTreeIter *iter,
- gpointer data)
-{
- MachineInfo *info;
-
- gtk_tree_model_get (tree_model, iter, 0, &info, -1);
-
- g_object_set (cell, "text", info->state ? info->state : "", NULL);
-}
-
-static gint
-sort_by_state (GtkTreeModel *model,
- GtkTreeIter *a,
- GtkTreeIter *b,
- gpointer user_data)
-{
- MachineInfo *info_a, *info_b;
-
- gtk_tree_model_get (model, a, 0, &info_a, -1);
- gtk_tree_model_get (model, b, 0, &info_b, -1);
-
- return strcmp (info_a->state ? info_a->state : "",
- info_b ? info_b->state : "");
-}
-
-static void
-set_cell_progress (GtkTreeViewColumn *tree_column,
- GtkCellRenderer *cell,
- GtkTreeModel *tree_model,
- GtkTreeIter *iter,
- gpointer data)
-{
- MachineInfo *info;
-
- gtk_tree_model_get (tree_model, iter, 0, &info, -1);
-
- g_object_set (cell, "value", (int) (info->progress * 100), NULL);
-}
-
-static gint
-sort_by_progress (GtkTreeModel *model,
- GtkTreeIter *a,
- GtkTreeIter *b,
- gpointer user_data)
-{
- MachineInfo *info_a, *info_b;
-
- gtk_tree_model_get (model, a, 0, &info_a, -1);
- gtk_tree_model_get (model, b, 0, &info_b, -1);
-
- return info_a->progress > info_b->progress ? 1 : -1;
-}
-
-static void
-get_machines_cb (DBusGProxy *proxy, DBusGProxyCall *call, gpointer data)
-{
- GError *error = NULL;
- ClientState *state = data;
- GPtrArray *objs;
- guint i;
- GtkWidget *scrolledwin;
- GtkTreeViewColumn *col;
- GtkCellRenderer *rend;
-
- g_assert (call == state->get_machines_call);
-
- if (!dbus_g_proxy_end_call (proxy, call, &error,
- dbus_g_type_get_collection ("GPtrArray", DBUS_TYPE_G_OBJECT_PATH),
- &objs,
- G_TYPE_INVALID))
- lose_gerror ("Failed to get current machine list", error);
-
- gtk_container_remove (GTK_CONTAINER (state->window),
- gtk_bin_get_child (GTK_BIN (state->window)));
-
- scrolledwin = gtk_scrolled_window_new (NULL, NULL);
- gtk_widget_show (scrolledwin);
-
- state->store = GTK_TREE_MODEL (gtk_list_store_new (1, G_TYPE_POINTER));
- state->view = gtk_tree_view_new_with_model (GTK_TREE_MODEL (state->store));
- gtk_widget_show (state->view);
- gtk_container_add (GTK_CONTAINER (scrolledwin), state->view);
- gtk_container_add (GTK_CONTAINER (state->window), scrolledwin);
-
- rend = gtk_cell_renderer_text_new ();
- col = gtk_tree_view_column_new_with_attributes (_("Name"),
- rend,
- NULL);
- gtk_tree_view_column_set_cell_data_func (col, rend, set_cell_name, NULL, NULL);
- gtk_tree_view_column_set_resizable (col, TRUE);
- gtk_tree_sortable_set_sort_func (GTK_TREE_SORTABLE (state->store),
- 0, sort_by_name, NULL, NULL);
- gtk_tree_view_column_set_sort_column_id (col, 0);
- gtk_tree_view_append_column (GTK_TREE_VIEW (state->view), col);
-
- rend = gtk_cell_renderer_text_new ();
- col = gtk_tree_view_column_new_with_attributes (_("State"),
- rend,
- NULL);
- gtk_tree_view_column_set_cell_data_func (col, rend, set_cell_state, NULL, NULL);
- gtk_tree_view_column_set_resizable (col, TRUE);
- gtk_tree_sortable_set_sort_func (GTK_TREE_SORTABLE (state->store),
- 0, sort_by_state, NULL, NULL);
- gtk_tree_view_column_set_sort_column_id (col, 0);
- gtk_tree_view_append_column (GTK_TREE_VIEW (state->view), col);
-
- rend = gtk_cell_renderer_progress_new ();
- col = gtk_tree_view_column_new_with_attributes (_("Progress"),
- rend,
- NULL);
- gtk_tree_view_column_set_cell_data_func (col, rend, set_cell_progress, NULL, NULL);
- gtk_tree_view_column_set_resizable (col, TRUE);
- gtk_tree_sortable_set_sort_func (GTK_TREE_SORTABLE (state->store),
- 0, sort_by_progress, NULL, NULL);
- gtk_tree_view_column_set_sort_column_id (col, 0);
- gtk_tree_view_append_column (GTK_TREE_VIEW (state->view), col);
-
- for (i = 0; i < objs->len; i++)
- {
- add_machine (state, NULL, NULL, g_ptr_array_index (objs, i));
- g_free (g_ptr_array_index (objs, i));
- }
- g_ptr_array_free (objs, TRUE);
-
- g_idle_add (do_something_random, state);
-}
-
-int
-main (int argc, char **argv)
-{
- DBusGConnection *bus;
- DBusGProxy *server;
- GError *error = NULL;
- ClientState state;
- GtkWidget *label;
-
- gtk_init (&argc, &argv);
-
- g_log_set_always_fatal (G_LOG_LEVEL_WARNING | G_LOG_LEVEL_CRITICAL);
-
- state.window = GTK_WINDOW (gtk_window_new (GTK_WINDOW_TOPLEVEL));
- gtk_window_set_resizable (GTK_WINDOW (state.window), TRUE);
- g_signal_connect (G_OBJECT (state.window), "destroy",
- G_CALLBACK (window_destroyed_cb),
- &state);
- gtk_window_set_title (GTK_WINDOW (state.window), _("D-BUS State Machine Demo"));
- gtk_window_set_default_size (GTK_WINDOW (state.window), 320, 240);
-
- label = gtk_label_new ("");
- gtk_label_set_markup (GTK_LABEL (label), "<b>Loading...</b>");
- gtk_widget_show (label);
-
- gtk_container_add (GTK_CONTAINER (state.window), label);
-
- bus = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
- if (!bus)
- lose_gerror ("Couldn't connect to session bus", error);
-
- state.bus = bus;
-
- server = dbus_g_proxy_new_for_name_owner (bus,
- "com.example.StateServer",
- "/com/example/StateServer",
- "com.example.StateMachineServer",
- &error);
- if (!server)
- lose_gerror ("Couldn't find \"com.example.StateServer\"", error);
-
- state.server_proxy = server;
-
- g_signal_connect (server, "destroy",
- G_CALLBACK (server_destroyed_cb),
- &state);
-
- dbus_g_object_register_marshaller (sm_marshal_VOID__STRING_BOXED,
- G_TYPE_NONE, G_TYPE_STRING,
- DBUS_TYPE_G_OBJECT_PATH);
-
- dbus_g_proxy_add_signal (server, "MachineCreated", G_TYPE_STRING, DBUS_TYPE_G_OBJECT_PATH, G_TYPE_INVALID);
-
- dbus_g_proxy_connect_signal (server, "MachineCreated",
- G_CALLBACK (machine_created_cb),
- &state, NULL);
-
- state.get_machines_call = dbus_g_proxy_begin_call (server, "GetMachines",
- get_machines_cb, &state, NULL,
- G_TYPE_INVALID);
-
- gtk_widget_show (GTK_WIDGET (state.window));
-
- gtk_main ();
-
- g_object_unref (G_OBJECT (server));
-
- exit(0);
-}
diff --git a/dbus/examples/statemachine/statemachine-server.c b/dbus/examples/statemachine/statemachine-server.c
deleted file mode 100644
index b92cb0e..0000000
--- a/dbus/examples/statemachine/statemachine-server.c
+++ /dev/null
@@ -1,232 +0,0 @@
-#include <config.h>
-
-#include <dbus/dbus-glib.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-#include "statemachine.h"
-#include "sm-marshal.h"
-#include "statemachine-server.h"
-
-enum
-{
- PROP_O,
- PROP_BUS
-};
-
-enum
-{
- MACHINE_CREATED,
- LAST_SIGNAL
-};
-
-static guint sm_server_signals[LAST_SIGNAL] = { 0 };
-
-static void sm_server_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec);
-static void sm_server_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec);
-
-G_DEFINE_TYPE(SMServer, sm_server, G_TYPE_OBJECT)
-
-#include "statemachine-server-glue.h"
-#include "statemachine-glue.h"
-
-static void
-sm_server_init (SMServer *obj)
-{
- obj->machines = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref);
-}
-
-static void
-sm_server_class_init (SMServerClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
- object_class->set_property = sm_server_set_property;
- object_class->get_property = sm_server_get_property;
-
- g_object_class_install_property (object_class,
- PROP_BUS,
- g_param_spec_boxed ("bus",
- "bus",
- "bus",
- DBUS_TYPE_G_CONNECTION,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
-
- sm_server_signals[MACHINE_CREATED] =
- g_signal_new ("machine-created",
- G_OBJECT_CLASS_TYPE (klass),
- G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
- 0,
- NULL, NULL,
- sm_marshal_VOID__STRING_BOXED,
- G_TYPE_NONE, 2, G_TYPE_STRING, DBUS_TYPE_G_OBJECT_PATH);
-}
-
-static void
-sm_server_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- SMServer *server = SM_SERVER (object);
-
- switch (prop_id)
- {
- case PROP_BUS:
- server->bus = g_value_get_boxed (value);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-sm_server_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
-{
- SMServer *server = SM_SERVER (object);
-
- switch (prop_id)
- {
- case PROP_BUS:
- g_value_set_boxed (value, server->bus);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-machine_state_changed_cb (SMObject *obj, const char *state, gpointer data)
-{
- char *name;
-
- g_object_get (obj, "name", &name, NULL);
- g_print ("Machine %s switching to state %s\n", name, state);
- g_free (name);
-}
-
-static void
-machine_acquisition_changed_cb (SMObject *obj, gdouble progress, gpointer data)
-{
- char *name;
-
- g_object_get (obj, "name", &name, NULL);
- g_print ("Machine %s got progress %f\n", name, progress);
- g_free (name);
-}
-
-gboolean
-sm_server_create_machine (SMServer *server, const char *name, GError **error)
-{
- SMObject *machine;
- char *path;
-
- machine = g_hash_table_lookup (server->machines, name);
- if (machine != NULL)
- {
- g_set_error (error,
- SM_ERROR,
- SM_ERROR_NAME_IN_USE,
- "Statemachine name \"%s\" is already in use",
- name);
- return FALSE;
- }
-
- machine = g_object_new (SM_TYPE_OBJECT, "name", name, NULL);
-
- path = g_strdup_printf ("/com/example/StateMachines/%s", name);
- dbus_g_connection_register_g_object (server->bus, path, G_OBJECT (machine));
-
- g_hash_table_insert (server->machines, g_strdup (name), machine);
-
- g_print ("Created state machine with name %s at %s\n", name, path);
-
- g_signal_connect_object (machine, "state-changed",
- G_CALLBACK (machine_state_changed_cb),
- NULL, 0);
- g_signal_connect_object (machine, "acquisition-progress",
- G_CALLBACK (machine_acquisition_changed_cb),
- NULL, 0);
-
- g_signal_emit (server, sm_server_signals[MACHINE_CREATED], 0, name, path);
- g_free (path);
-
- return TRUE;
-}
-
-static void
-add_machine_to_ptr_array (gpointer key, gpointer val, gpointer data)
-{
- const char *name = key;
- /* SMObject *sm = val; */
- GPtrArray *ptrarray = data;
-
- g_ptr_array_add (ptrarray, g_strdup_printf ("/com/example/StateMachines/%s",
- name));
-}
-
-gboolean
-sm_server_get_machines (SMServer *server, GPtrArray **machines, GError **error)
-{
- *machines = g_ptr_array_new ();
-
- g_hash_table_foreach (server->machines, add_machine_to_ptr_array, *machines);
-
- return TRUE;
-}
-
-int
-main (int argc, char **argv)
-{
- DBusGConnection *bus;
- DBusGProxy *bus_proxy;
- GError *error = NULL;
- SMServer *server;
- GMainLoop *mainloop;
- guint request_name_result;
-
- g_type_init ();
-
- dbus_g_object_type_install_info (SM_TYPE_SERVER, &dbus_glib_sm_server_object_info);
- dbus_g_object_type_install_info (SM_TYPE_OBJECT, &dbus_glib_sm_object_object_info);
- dbus_g_error_domain_register (SM_ERROR, NULL, SM_TYPE_ERROR);
-
- mainloop = g_main_loop_new (NULL, FALSE);
-
- bus = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
- if (!bus)
- g_critical ("Couldn't connect to session bus: %s\n", error->message);
-
- bus_proxy = dbus_g_proxy_new_for_name (bus, "org.freedesktop.DBus",
- "/org/freedesktop/DBus",
- "org.freedesktop.DBus");
-
- if (!dbus_g_proxy_call (bus_proxy, "RequestName", &error,
- G_TYPE_STRING, "com.example.StateServer",
- G_TYPE_UINT, 0,
- G_TYPE_INVALID,
- G_TYPE_UINT, &request_name_result,
- G_TYPE_INVALID))
- g_critical ("Couldn't acquire com.example.StateServer: %s\n", error->message);
-
- server = g_object_new (SM_TYPE_SERVER, "bus", bus, NULL);
-
- dbus_g_connection_register_g_object (bus, "/com/example/StateServer", G_OBJECT (server));
-
- g_print ("StateMachine server initialized\n");
-
- g_main_loop_run (mainloop);
-
- exit (0);
-}
diff --git a/dbus/examples/statemachine/statemachine-server.h b/dbus/examples/statemachine/statemachine-server.h
deleted file mode 100644
index 360be3a..0000000
--- a/dbus/examples/statemachine/statemachine-server.h
+++ /dev/null
@@ -1,37 +0,0 @@
-#ifndef _SM_SERVER_H
-#define _SM_SERVER_H
-
-#include "statemachine.h"
-#include <dbus/dbus-glib.h>
-
-typedef struct SMServer SMServer;
-typedef struct SMServerClass SMServerClass;
-
-struct SMServer
-{
- GObject parent;
-
- /* Private */
- DBusGConnection *bus;
- GHashTable *machines;
-};
-
-struct SMServerClass
-{
- GObjectClass parent;
-};
-
-#define SM_TYPE_SERVER (sm_server_get_type ())
-#define SM_SERVER(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), SM_TYPE_SERVER, SMServer))
-#define SM_SERVER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SM_TYPE_SERVER, SMServerClass))
-#define SM_IS_SERVER(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), SM_TYPE_SERVER))
-#define SM_IS_SERVER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SM_TYPE_SERVER))
-#define SM_SERVER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SM_TYPE_SERVER, SMServerClass))
-
-GType sm_server_get_type (void);
-
-gboolean sm_server_create_machine (SMServer *server, const char *name, GError **error);
-
-gboolean sm_server_get_machines (SMServer *server, GPtrArray **machines, GError **error);
-
-#endif
diff --git a/dbus/examples/statemachine/statemachine-server.xml b/dbus/examples/statemachine/statemachine-server.xml
deleted file mode 100644
index fe9caaf..0000000
--- a/dbus/examples/statemachine/statemachine-server.xml
+++ /dev/null
@@ -1,14 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-
-<node name="/">
- <interface name="com.example.StateMachineServer">
- <method name="CreateMachine">
- <arg type="s" name="name" direction="in"/>
- </method>
-
- <method name="GetMachines">
- <arg type="ao" direction="out"/>
- </method>
- <signal name="MachineCreated"/>
- </interface>
-</node>
diff --git a/dbus/examples/statemachine/statemachine.c b/dbus/examples/statemachine/statemachine.c
deleted file mode 100644
index 239d38c..0000000
--- a/dbus/examples/statemachine/statemachine.c
+++ /dev/null
@@ -1,355 +0,0 @@
-#include <config.h>
-
-#include <stdio.h>
-#include <stdlib.h>
-#include "statemachine.h"
-
-static void clear_pending_tasks (SMObject *object);
-static void state_change (SMObject *object, SMObjectState new_state);
-static void sm_object_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec);
-static void sm_object_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec);
-enum
-{
- PROP_0,
- PROP_NAME
-};
-
-enum
-{
- STATE_CHANGED,
- ACQUISITION_FAILED,
- ACQUISITION_PROGRESS,
- LAST_SIGNAL
-};
-
-static guint sm_object_signals[LAST_SIGNAL] = { 0 };
-
-G_DEFINE_TYPE(SMObject, sm_object, G_TYPE_OBJECT)
-
-static void
-sm_object_init (SMObject *obj)
-{
- obj->state = SM_OBJECT_STATE_SHUTDOWN;
-}
-
-static void
-sm_object_class_init (SMObjectClass *klass)
-{
- GObjectClass *object_class;
-
- object_class = G_OBJECT_CLASS (klass);
-
- object_class->set_property = sm_object_set_property;
- object_class->get_property = sm_object_get_property;
-
- g_object_class_install_property (object_class,
- PROP_NAME,
- g_param_spec_string ("name",
- "name",
- "name",
- NULL,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
- sm_object_signals[STATE_CHANGED] =
- g_signal_new ("state-changed",
- G_OBJECT_CLASS_TYPE (klass),
- G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
- 0,
- NULL, NULL,
- g_cclosure_marshal_VOID__STRING,
- G_TYPE_NONE, 1, G_TYPE_STRING);
- sm_object_signals[ACQUISITION_PROGRESS] =
- g_signal_new ("acquisition-progress",
- G_OBJECT_CLASS_TYPE (klass),
- G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
- 0,
- NULL, NULL,
- g_cclosure_marshal_VOID__DOUBLE,
- G_TYPE_NONE, 1, G_TYPE_DOUBLE);
- sm_object_signals[ACQUISITION_FAILED] =
- g_signal_new ("acquisition-failed",
- G_OBJECT_CLASS_TYPE (klass),
- G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
- 0,
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
-}
-
-/* This should really be standard. */
-#define ENUM_ENTRY(NAME, DESC) { NAME, "" #NAME "", DESC }
-
-GQuark
-sm_error_quark (void)
-{
- static GQuark ret = 0;
- if (!ret)
- ret = g_quark_from_static_string ("SMObjectErrorQuark");
- return ret;
-}
-
-GType
-sm_object_state_get_type (void)
-{
- static GType etype = 0;
-
- if (etype == 0)
- {
- static const GEnumValue values[] =
- {
-
- ENUM_ENTRY (SM_OBJECT_STATE_SHUTDOWN, "Shutdown"),
- ENUM_ENTRY (SM_OBJECT_STATE_INITIALIZED, "Loading"),
- ENUM_ENTRY (SM_OBJECT_STATE_ACQUIRED, "Acquired"),
- ENUM_ENTRY (SM_OBJECT_STATE_OPERATING, "Operating"),
- { 0, 0, 0 }
- };
-
- etype = g_enum_register_static ("SMObjectState", values);
- }
-
- return etype;
-}
-
-GType
-sm_error_get_type (void)
-{
- static GType etype = 0;
-
- if (etype == 0)
- {
- static const GEnumValue values[] =
- {
-
- ENUM_ENTRY (SM_ERROR_INVALID_STATE, "InvalidState"),
- ENUM_ENTRY (SM_ERROR_NAME_IN_USE, "NameInUse"),
- { 0, 0, 0 }
- };
-
- g_assert (SM_NUM_ERRORS == G_N_ELEMENTS (values) - 1);
-
- etype = g_enum_register_static ("SMError", values);
- }
-
- return etype;
-}
-
-static void
-sm_object_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- SMObject *sm = SM_OBJECT (object);
-
- switch (prop_id)
- {
- case PROP_NAME:
- sm->name = g_strdup (g_value_get_string (value));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-sm_object_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
-{
- SMObject *sm= SM_OBJECT (object);
-
- switch (prop_id)
- {
- case PROP_NAME:
- g_value_set_string (value, sm->name);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static const char *
-state_to_string (SMObjectState state)
-{
- GEnumValue *value;
- GEnumClass *prop_class;
- const char *ret;
-
- prop_class = g_type_class_ref (SM_TYPE_OBJECT_STATE);
- value = g_enum_get_value (prop_class, state);
- ret = value->value_nick;
-
- g_type_class_unref (prop_class);
- return ret;
-}
-
-static void
-queue_task (SMObject *object, guint delay, GSourceFunc func)
-{
- guint id;
- id = g_timeout_add (delay, func, object);
- object->pending_tasks = g_slist_prepend (object->pending_tasks, GUINT_TO_POINTER (id));
-}
-
-static gboolean
-idle_state_change (gpointer data)
-{
- SMObject *object = data;
-
- g_print ("doing idle state change for %s to %s\n",
- object->name, state_to_string (object->requested_state));
- state_change (object, object->requested_state);
- return FALSE;
-}
-
-static gboolean
-idle_further_acquire (gpointer data)
-{
- SMObject *object = data;
-
- g_print ("doing idle acquisition for machine %s\n", object->name);
- object->acquisition_progress += g_random_double_range (0.20, 0.7);
- if (object->acquisition_progress > 1.0)
- {
- object->acquisition_progress = 1.0;
- return FALSE;
- }
- else
- {
- g_signal_emit (object, sm_object_signals[ACQUISITION_PROGRESS], 0, object->acquisition_progress);
- return TRUE;
- }
-}
-
-static void
-clear_pending_tasks (SMObject *object)
-{
- GSList *tmp;
- for (tmp = object->pending_tasks; tmp; tmp = tmp->next)
- g_source_remove (GPOINTER_TO_UINT (tmp->data));
- g_slist_free (object->pending_tasks);
- object->pending_tasks = NULL;
-}
-
-static void
-state_change (SMObject *object, SMObjectState new_state)
-{
- g_signal_emit (object, sm_object_signals[STATE_CHANGED], 0,
- state_to_string (new_state));
-
- clear_pending_tasks (object);
-
- if (new_state == SM_OBJECT_STATE_ACQUIRED)
- {
- object->acquisition_progress = 0.0;
- queue_task (object, 1000, idle_further_acquire);
- }
- else if (new_state == SM_OBJECT_STATE_INITIALIZED)
- {
- if (g_random_int_range (0, 2) == 0)
- {
- object->requested_state = SM_OBJECT_STATE_ACQUIRED;
- queue_task (object, 3000, idle_state_change);
- }
- }
-
- object->state = new_state;
-}
-
-gboolean
-sm_object_get_info (SMObject *object, char **name, char **state, GError **error)
-{
- *name= g_strdup (object->name);
- *state = g_strdup (state_to_string (object->state));
- return TRUE;
-}
-
-gboolean
-sm_object_start (SMObject *object, GError **error)
-{
- if (object->state != SM_OBJECT_STATE_SHUTDOWN)
- {
- g_set_error (error,
- SM_ERROR,
- SM_ERROR_INVALID_STATE,
- "%s",
- "Can't start from non-shutdown state");
- return FALSE;
- }
- state_change (object, SM_OBJECT_STATE_INITIALIZED);
- return TRUE;
-}
-
-gboolean
-sm_object_shutdown (SMObject *object, GError **error)
-{
- if (object->state == SM_OBJECT_STATE_SHUTDOWN)
- {
- g_set_error (error,
- SM_ERROR,
- SM_ERROR_INVALID_STATE,
- "%s",
- "Can't shutdown from shutdown state");
- return FALSE;
- }
- state_change (object, SM_OBJECT_STATE_SHUTDOWN);
- return TRUE;
-}
-
-gboolean
-sm_object_reinitialize (SMObject *object, GError **error)
-{
- if (object->state != SM_OBJECT_STATE_ACQUIRED
- && object->state != SM_OBJECT_STATE_OPERATING)
- {
- g_set_error (error,
- SM_ERROR,
- SM_ERROR_INVALID_STATE,
- "Can't reinitialize from state %d",
- object->state);
- return FALSE;
- }
- state_change (object, SM_OBJECT_STATE_INITIALIZED);
- return TRUE;
-}
-
-gboolean
-sm_object_reacquire (SMObject *object, GError **error)
-{
- if (object->state == SM_OBJECT_STATE_ACQUIRED)
- {
- g_set_error (error,
- SM_ERROR,
- SM_ERROR_INVALID_STATE,
- "Can't reacquire from state %d",
- object->state);
- return FALSE;
- }
- state_change (object, SM_OBJECT_STATE_ACQUIRED);
- return TRUE;
-}
-
-gboolean
-sm_object_get_acquiring_progress (SMObject *object, gdouble *out, GError **error)
-{
- if (object->state != SM_OBJECT_STATE_ACQUIRED)
- {
- g_set_error (error,
- SM_ERROR,
- SM_ERROR_INVALID_STATE,
- "Can't get progress from state %d",
- object->state);
- return FALSE;
- }
- *out = object->acquisition_progress;
- return TRUE;
-}
diff --git a/dbus/examples/statemachine/statemachine.h b/dbus/examples/statemachine/statemachine.h
deleted file mode 100644
index ac6047b..0000000
--- a/dbus/examples/statemachine/statemachine.h
+++ /dev/null
@@ -1,77 +0,0 @@
-#ifndef _SM_OBJECT_H
-#define _SM_OBJECT_H
-
-#include <glib.h>
-#include <glib-object.h>
-
-GQuark sm_error_quark (void);
-
-#define SM_ERROR (sm_error_quark ())
-
-typedef enum
-{
- SM_ERROR_INVALID_STATE = 0,
- SM_ERROR_NAME_IN_USE,
- SM_NUM_ERRORS
-} SMError;
-
-GType sm_error_get_type (void);
-#define SM_TYPE_ERROR (sm_error_get_type ())
-
-typedef enum
-{
- SM_OBJECT_STATE_SHUTDOWN = 0,
- SM_OBJECT_STATE_INITIALIZED,
- SM_OBJECT_STATE_ACQUIRED,
- SM_OBJECT_STATE_OPERATING,
- SM_OBJECT_NUM_STATES
-} SMObjectState;
-
-GType sm_object_state_get_type (void);
-
-#define SM_TYPE_OBJECT_STATE (sm_object_state_get_type ())
-
-typedef struct SMObject SMObject;
-typedef struct SMObjectClass SMObjectClass;
-
-struct SMObject
-{
- GObject parent;
-
- /* Private */
- char *name;
- SMObjectState state;
- double acquisition_progress;
-
- GSList /* guint */ *pending_tasks;
-
- SMObjectState requested_state;
-};
-
-struct SMObjectClass
-{
- GObjectClass parent;
-};
-
-#define SM_TYPE_OBJECT (sm_object_get_type ())
-#define SM_OBJECT(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), SM_TYPE_OBJECT, SMObject))
-#define SM_OBJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SM_TYPE_OBJECT, SMObjectClass))
-#define SM_IS_OBJECT(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), SM_TYPE_OBJECT))
-#define SM_IS_OBJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SM_TYPE_OBJECT))
-#define SM_OBJECT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SM_TYPE_OBJECT, SMObjectClass))
-
-GType sm_object_get_type (void);
-
-gboolean sm_object_get_info (SMObject *object, char **name, char **state, GError **error);
-
-gboolean sm_object_start (SMObject *object, GError **error);
-
-gboolean sm_object_shutdown (SMObject *object, GError **error);
-
-gboolean sm_object_reinitialize (SMObject *object, GError **error);
-
-gboolean sm_object_reacquire (SMObject *object, GError **error);
-
-gboolean sm_object_get_acquiring_progress (SMObject *object, gdouble *out, GError **error);
-
-#endif
diff --git a/dbus/examples/statemachine/statemachine.xml b/dbus/examples/statemachine/statemachine.xml
deleted file mode 100644
index c375ef1..0000000
--- a/dbus/examples/statemachine/statemachine.xml
+++ /dev/null
@@ -1,33 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-
-<node name="/">
- <interface name="com.example.StateMachine">
-
- <method name="GetInfo">
- <arg type="s" name="name" direction="out"/>
- <arg type="s" name="state" direction="out"/>
- </method>
-
- <method name="Start">
- </method>
-
- <method name="Shutdown">
- </method>
-
- <method name="Reinitialize">
- </method>
-
- <method name="Reacquire">
- </method>
-
- <method name="GetAcquiringProgress">
- <arg type="d" direction="out"/>
- </method>
-
- <!-- Mark the signals as exported -->
- <signal name="StateChanged"/>
- <signal name="AcquisitionFailed"/>
- <signal name="AcquisitionProgress"/>
-
- </interface>
-</node>
diff --git a/doc/Makefile.am b/doc/Makefile.am
deleted file mode 100644
index 9e6f5cb..0000000
--- a/doc/Makefile.am
+++ /dev/null
@@ -1,5 +0,0 @@
-SUBDIRS=reference
-
-man_MANS = dbus-binding-tool.1
-
-EXTRA_DIST = $(man_MANS) \ No newline at end of file
diff --git a/doc/dbus-binding-tool.1 b/doc/dbus-binding-tool.1
deleted file mode 100644
index 391c87c..0000000
--- a/doc/dbus-binding-tool.1
+++ /dev/null
@@ -1,294 +0,0 @@
-'\" te
-.TH dbus-binding-tool 1 "26 Feb 2009" "SunOS 5.11" "User Commands"
-.SH "NAME"
-dbus-binding-tool \- C language GLib bindings generation utility\&.
-.SH "SYNOPSIS"
-.PP
-\fBdbus-binding-tool\fR [-\fB-force\fR] [-\fB-help\fR] [-\fB-ignore-unsupported\fR] [-\fB-mode=\fIpretty|glib-client|glib-server\fR\fR] [-\fB-output=\fIfile\fR\fR] [-\fB-prefix=\fIsymbol-prefix\fR\fR] [-\fB-version\fR] [\fB\fIfile\fR\fR\&...]
-.SH "DESCRIPTION"
-.PP
-\fBdbus-binding-tool\fR is used to expose a GObject via D\-Bus\&. As input,
-\fBdbus-binding-tool\fR uses a D\-Bus Introspection XML file\&. As output,
-the client-side or server-side bindings is generated\&. This output is a header
-file which eases the use of a remote D\-Bus object\&. Output is sent to standard
-out or to the filename specified with the -\fB-output\fR argument\&.
-.SH "EXTENDED DESCRIPTION"
-.SS ""
-.PP
-The following is a sample D\-Bus Introspection XML file which describes an
-object that exposes one method, named ManyArgs:
-.PP
-.nf
-<?xml version="1\&.0" encoding="UTF-8" ?>
-<node name="/com/example/MyObject">
- <interface name="com\&.example\&.MyObject">
- <method name="ManyArgs">
- <arg type="u" name="x" direction="in" />
- <arg type="s" name="str" direction="in" />
- <arg type="d" name="trouble" direction="in" />
- <arg type="d" name="d_ret" direction="out" />
- <arg type="s" name="str_ret" direction="out" />
- </method>
- </interface>
-</node>
-.fi
-.PP
-\fBdbus-binding-tool\fR supports annotations in the XML format to further
-control how the bindings are generated\&.
-.SS "client-side bindings"
-.PP
-When building client-side bindings, the -\fB-mode=glib-client\fR
-argument is used\&. The client-side bindings support the
-"org\&.freedesktop\&.DBus\&.Glib\&.NoReply" annotation\&. This is specified
-within the <method> tag to indicate that the client is not expecting
-a reply to the method call, so a reply should not be sent\&. This is
-often used to speed up rapid method calls where there are no "out"
-arguments, and not knowing if the method succeeded is an acceptable compromise
-to halve the traffic on the bus\&. For example:
-.PP
-.nf
-<method name "FooMethod">
- [\&.\&.\&.]
- <annotation name="org\&.freedesktop\&.DBus\&.GLib\&.NoReply" value="yes"/>
- [\&.\&.\&.]
-</method>
-.fi
-.SS "server-side bindings"
-.PP
-When building server-side bindings, the -\fB-mode=glib-server\fR
-argument is used\&. Also the -\fB-prefix\fR argument must be used when
-building server-side bindings so that functions in the generated output are
-prefexed with the specified value\&. The server-side bindings support the
-following annotations:
-.PP
-"org\&.freedesktop\&.DBus\&.GLib\&.CSymbol"
-.PP
-This annotation is used to specify the C symbol names for the various types
-(interface, method, etc\&.), if it differs from the name D\-Bus generates\&.
-.PP
-.PP
-.nf
-<interface name="com\&.example\&.MyObject">
- <annotation name="org\&.freedesktop\&.DBus\&.GLib\&.CSymbol" value="my_object"/>
- [\&.\&.\&.]
- <method name "ManyArgs">
- <annotation name="org\&.freedesktop\&.DBus\&.GLib\&.CSymbol" value="my_object_many_args"/>
- [\&.\&.\&.]
- </method>
-</interface>
-.fi
-.PP
-"org\&.freedesktop\&.DBus\&.GLib\&.Async"
-.PP
-This annotation marks the method implementation as an asynchronous function,
-which does not return a response straight away but will send the response at
-some later point to complete the call\&. This is used to implement non-blocking
-services where method calls can take time\&.
-.PP
-When a method is asynchronous, the function prototype is different\&. It is
-required that the function conform to the following rules:
-.sp
-.in +2
-\(bu
-.mk
-.in +3
-.rt
-The function must return a value of type gboolean; TRUE on success,
-and FALSE otherwise\&.
-.in -3
-\(bu
-.mk
-.in +3
-.rt
-The first parameter is a pointer to an instance of the object\&.
-.in -3
-\(bu
-.mk
-.in +3
-.rt
-Following the object instance pointer are the method input values\&.
-.in -3
-\(bu
-.mk
-.in +3
-.rt
-The final parameter must be a (DBusGMethodInvocation *)\&. This is used
-when sending the response message back to the client, by calling
-dbus_g_method_return or dbus_g_method_return_error\&.
-.in -3
-.in -2
-.PP
-For example:
-.PP
-.nf
-<method name "FooMethod">
- [\&.\&.\&.]
- <annotation name="org\&.freedesktop\&.DBus\&.GLib\&.Async" value="yes"/>
- [\&.\&.\&.]
-</method>
-.fi
-.PP
-"org\&.freedesktop\&.DBus\&.GLib\&.Const"
-.PP
-This attribute can only be applied to "out" <arg> nodes, and
-specifies that the parameter is not being copied when returned\&. For example,
-this turns a \&'s\&' argument from a (char **) to a (const char **), and results in
-the argument not being freed by D\-Bus after the message is sent\&. For example:
-.PP
-.nf
- <arg type="u" name="x" direction="out">
- <annotation name="org\&.freedesktop\&.DBus\&.GLib\&.Const" value=""/>
- </arg>
-.fi
-.PP
-"org\&.freedesktop\&.DBus\&.GLib\&.ReturnVal"
-.PP
-This attribute can only be applied to "out" <arg> nodes, and
-alters the expected function signature\&. It currently can be set to two values:
-"" or "error"\&. The argument marked with this attribute is
-not returned via a pointer argument, but by the function\&'s return value\&. If the
-attribute\&'s value is the empty string, the (GError *) argument is also omitted
-so there is no standard way to return an error value\&. This is very useful for
-interfacing with existing code, as it is possible to match existing APIs\&. If
-the attribute\&'s value is "error", then the final argument is a
-(GError *) as usual\&. For example:
-.PP
-.nf
- <arg type="u" name="x" direction="out">
- <annotation name="org\&.freedesktop\&.DBus\&.GLib\&.ReturnVal" value=""/>
- </arg>
-.fi
-.SH "OPTIONS"
-.PP
-The following options are supported:
-.sp
-.ne 2
-.mk
-\fB-\fB-force\fR\fR
-.sp .6
-.in +4
-Overwrite the output file if it already exists with a newer timestamp than the
-source files\&.
-.sp
-.sp 1
-.in -4
-.sp
-.ne 2
-.mk
-\fB-\fB-help\fR\fR
-.sp .6
-.in +4
-Display usage information\&.
-.sp
-.sp 1
-.in -4
-.sp
-.ne 2
-.mk
-\fB-\fB-ignore-unsupported\fR\fR
-.sp .6
-.in +4
-If set, then unsupported signatures for <method> parameters are
-ignored\&.
-.sp
-.sp 1
-.in -4
-.sp
-.ne 2
-.mk
-\fB-\fB-mode=\fIpretty|glib-client|glib-server\fR\fR\fR
-.sp .6
-.in +4
-If the value is "glib-client", then client bindings are generated\&.
-If the value is "glib-server", then server bindings are generated\&.
-If the value is "pretty", then the output is in a more human readable
-format\&.
-.sp
-.sp 1
-.in -4
-.sp
-.ne 2
-.mk
-\fB-\fB-output=\fIfile\fR\fR\fR
-.sp .6
-.in +4
-Specify the output \fIfile\fR\&.
-.sp
-.sp 1
-.in -4
-.sp
-.ne 2
-.mk
-\fB-\fB-prefix=\fIsymbol-prefix\fR\fR\fR
-.sp .6
-.in +4
-Functions in the generated output are prefixed with the
-\fIsymbol-prefix\fR value\&.
-.sp
-.sp 1
-.in -4
-.sp
-.ne 2
-.mk
-\fB-\fB-version\fR\fR
-.sp .6
-.in +4
-Display the version number of the \fBdbus-binding-tool\fR command\&.
-.sp
-.sp 1
-.in -4
-.SH "OPERANDS"
-.PP
-The following operands are supported:
-.sp
-.ne 2
-.mk
-\fB\fB\fIfile\fR\fR\fR
-.in +16n
-.rt
-A list of one or more input D\-Bus Introspection XML files to include in the
-generated output\&.
-.sp
-.sp 1
-.in -16n
-.SH "FILES"
-.PP
-The following files are used by this application:
-.sp
-.ne 2
-.mk
-\fB\fB/usr/bin/dbus-binding-tool\fR \fR
-.in +32n
-.rt
-Executable for the D\-Bus Binding Tool application\&.
-.sp
-.sp 1
-.in -32n
-.SH "ATTRIBUTES"
-.PP
-See \fBattributes\fR(5)
-for descriptions of the following attributes:
-.sp
-.TS
-tab() allbox;
-cw(2.750000i)| cw(2.750000i)
-lw(2.750000i)| lw(2.750000i).
-ATTRIBUTE TYPEATTRIBUTE VALUE
-AvailabilitySUNWdbus-bindings
-Interface stabilityVolatile
-.TE
-.sp
-.SH "SEE ALSO"
-.PP
-\fBdbus-cleanup-sockets\fR(1),
-\fBdbus-daemon\fR(1),
-\fBdbus-monitor\fR(1),
-\fBdbus-send\fR(1),
-\fBdbus-uuidgen\fR(1),
-\fBlibdbus-glib-1\fR(3),
-\fBattributes\fR(5)
-.SH "NOTES"
-.PP
-Written by Brian Cameron, Sun Microsystems Inc\&., 2009\&.
-...\" created by instant / solbook-to-man, Thu 26 Feb 2009, 19:15
-...\" LSARC 2006/368 D-BUS Message Bus System
diff --git a/doc/reference/Makefile.am b/doc/reference/Makefile.am
deleted file mode 100644
index 4592d99..0000000
--- a/doc/reference/Makefile.am
+++ /dev/null
@@ -1,123 +0,0 @@
-## Process this file with automake to produce Makefile.in
-
-# We require automake 1.6 at least.
-AUTOMAKE_OPTIONS = 1.6
-
-# This is a blank Makefile.am for using gtk-doc.
-# Copy this to your project's API docs directory and modify the variables to
-# suit your project. See the GTK+ Makefiles in gtk+/docs/reference for examples
-# of using the various options.
-
-# The name of the module, e.g. 'glib'.
-DOC_MODULE=dbus-glib
-
-# Uncomment for versioned docs and specify the version of the module, e.g. '2'.
-#DOC_MODULE_VERSION=2
-
-
-# The top-level SGML file. You can change this if you want to.
-DOC_MAIN_SGML_FILE=$(DOC_MODULE)-docs.sgml
-
-# Directories containing the source code.
-# gtk-doc will search all .c and .h files beneath these paths
-# for inline comments documenting functions and macros.
-# e.g. DOC_SOURCE_DIR=$(top_srcdir)/gtk $(top_srcdir)/gdk
-DOC_SOURCE_DIR=@abs_top_srcdir@/dbus
-
-# Extra options to pass to gtkdoc-scangobj. Not normally needed.
-SCANGOBJ_OPTIONS=
-
-# Extra options to supply to gtkdoc-scan.
-# e.g. SCAN_OPTIONS=--deprecated-guards="GTK_DISABLE_DEPRECATED"
-SCAN_OPTIONS=
-
-# Extra options to supply to gtkdoc-mkdb.
-# e.g. MKDB_OPTIONS=--xml-mode --output-format=xml
-MKDB_OPTIONS=--xml-mode --output-format=xml
-
-# Extra options to supply to gtkdoc-mktmpl
-# e.g. MKTMPL_OPTIONS=--only-section-tmpl
-MKTMPL_OPTIONS=
-
-# Extra options to supply to gtkdoc-mkhtml
-MKHTML_OPTIONS=
-
-# Extra options to supply to gtkdoc-fixref. Not normally needed.
-# e.g. FIXXREF_OPTIONS=--extra-dir=../gdk-pixbuf/html --extra-dir=../gdk/html
-FIXXREF_OPTIONS=
-
-# Used for dependencies. The docs will be rebuilt if any of these change.
-# e.g. HFILE_GLOB=$(top_srcdir)/gtk/*.h
-# e.g. CFILE_GLOB=$(top_srcdir)/gtk/*.c
-HFILE_GLOB=$(top_srcdir)/dbus/*.h
-CFILE_GLOB=$(top_srcdir)/dbus/*.c
-
-# Extra header to include when scanning, which are not under DOC_SOURCE_DIR
-# e.g. EXTRA_HFILES=$(top_srcdir}/contrib/extra.h
-EXTRA_HFILES=
-
-# Header files or dirs to ignore when scanning. Use base file/dir names
-# e.g. IGNORE_HFILES=gtkdebug.h gtkintl.h private_code
-IGNORE_HFILES= \
- dbus-binding-tool-glib.h \
- dbus-gidl.h \
- dbus-glib-tool.h \
- dbus-gparser.h \
- dbus-gutils.h \
- dbus-gsignature.h \
- dbus-gtest.h \
- dbus-gvalue.h \
- dbus-gvalue-utils.h \
- dbus-gmarshal.h \
- example-service-glue.h \
- example-signal-emitter-glue.h \
- sm-marshal.h \
- statemachine-glue.h \
- statemachine.h \
- statemachine-server-glue.h \
- statemachine-server.h
-
-# Images to copy into HTML directory.
-# e.g. HTML_IMAGES=$(top_srcdir)/gtk/stock-icons/stock_about_24.png
-HTML_IMAGES=
-
-# Extra SGML files that are included by $(DOC_MAIN_SGML_FILE).
-# e.g. content_files=running.sgml building.sgml changes-2.0.sgml
-content_files=version.xml \
- dbus-binding-tool.xml
-
-# SGML files where gtk-doc abbrevations (#GtkWidget) are expanded
-# These files must be listed here *and* in content_files
-# e.g. expand_content_files=running.sgml
-expand_content_files=
-
-# CFLAGS and LDFLAGS for compiling gtkdoc-scangobj with your library.
-# Only needed if you are using gtkdoc-scangobj to dynamically query widget
-# signals and properties.
-# e.g. GTKDOC_CFLAGS=-I$(top_srcdir) -I$(top_builddir) $(GTK_DEBUG_FLAGS)
-# e.g. GTKDOC_LIBS=$(top_builddir)/gtk/$(gtktargetlib)
-GTKDOC_CFLAGS=-I$(top_srcdir) $(DBUS_CFLAGS) $(DBUS_GLIB_CFLAGS) $(DBUS_GLIB_TOOL_CFLAGS)
-GTKDOC_LIBS=$(top_builddir)/dbus/libdbus-glib-1.la
-
-# This includes the standard gtk-doc make rules, copied by gtkdocize.
-include $(top_srcdir)/gtk-doc.make
-
-# Other files to distribute
-# e.g. EXTRA_DIST += version.xml.in
-EXTRA_DIST += version.xml.in
-
-# Files not to distribute
-# for --rebuild-types in $(SCAN_OPTIONS), e.g. $(DOC_MODULE).types
-# for --rebuild-sections in $(SCAN_OPTIONS) e.g. $(DOC_MODULE)-sections.txt
-#DISTCLEANFILES +=
-
-# Comment this out if you want 'make check' to test you doc status
-# and run some sanity checks
-if ENABLE_GTK_DOC
-TESTS_ENVIRONMENT = cd $(srcdir) && \
- DOC_MODULE=$(DOC_MODULE) DOC_MAIN_SGML_FILE=$(DOC_MAIN_SGML_FILE) \
- SRCDIR=$(abs_srcdir) BUILDDIR=$(abs_builddir)
-#TESTS = $(GTKDOC_CHECK)
-endif
-
--include $(top_srcdir)/git.mk
diff --git a/doc/reference/dbus-binding-tool.xml b/doc/reference/dbus-binding-tool.xml
deleted file mode 100644
index 0dcc3ea..0000000
--- a/doc/reference/dbus-binding-tool.xml
+++ /dev/null
@@ -1,62 +0,0 @@
-<refentry id="dbus-binding-tool">
-
-<refmeta>
-<refentrytitle>dbus-binding-tool</refentrytitle>
-<manvolnum>1</manvolnum>
-</refmeta>
-
-<refnamediv>
-<refname>dbus-binding-tool</refname>
-<refpurpose>C language GLib bindings generation utility</refpurpose>
-</refnamediv>
-
-<refsynopsisdiv>
-<cmdsynopsis>
-<arg choice="opt" rep="repeat">options</arg>
-<arg choice="opt" rep="repeat">files</arg>
-</cmdsynopsis>
-</refsynopsisdiv>
-
-<refsect1><title>Description</title>
-<para><command>dbus-binding-tool</command> bla bla bla
-</para>
-</refsect1>
-
-<refsect1><title>Invocation</title>
-<para><command>dbus-binding-tool</command> bla bla bla
-</para>
-
-<refsect2><title>Options</title>
-<variablelist>
-
-<varlistentry>
-<term><option>--mode</option><replaceable>pretty|glib-server|glib-client</replaceable></term>
-<listitem><para>
-bla bla
-</para></listitem>
-</varlistentry>
-
-
-<varlistentry>
-<term><option>--help</option></term>
-<listitem><para>
-Print brief help and exit.
-</para></listitem>
-</varlistentry>
-
-<varlistentry>
-<term><option>--version</option></term>
-<listitem><para>
-Print version and exit.
-</para></listitem>
-</varlistentry>
-
-</variablelist>
-</refsect2>
-
-</refsect1>
-<refsect1><title>See also</title>
-<para><command>glib-genmarshal</command>(1)
-</para>
-</refsect1>
-</refentry>
diff --git a/doc/reference/dbus-glib-docs.sgml b/doc/reference/dbus-glib-docs.sgml
deleted file mode 100644
index c434c02..0000000
--- a/doc/reference/dbus-glib-docs.sgml
+++ /dev/null
@@ -1,68 +0,0 @@
-<?xml version="1.0"?>
-<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
- "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd" [
-<!ENTITY dbus-binding-tool SYSTEM "dbus-binding-tool.xml">
-<!ENTITY version SYSTEM "version.xml">
-]>
-<book id="index" xmlns:xi="http://www.w3.org/2003/XInclude">
- <bookinfo>
- <title>D-Bus GLib bindings - Reference Manual</title>
- <releaseinfo>for version &version;</releaseinfo>
- </bookinfo>
-
- <warning>
- <para>dbus-glib is a deprecated API for use of D-Bus from GLib
- applications. Do not use it in new code.</para>
-
- <para>Since version 2.26, GLib's accompanying GIO library
- provides a high-level API for D-Bus, "GDBus", based on an
- independent reimplementation of the D-Bus protocol. The maintainers
- of D-Bus recommend that GLib applications should use GDBus
- instead of dbus-glib.</para>
- </warning>
-
- <chapter>
- <title>Introduction</title>
-
- <para>D-Bus is a message bus system, a simple way for applications
- to talk to one another. For more information on D-Bus, see
- <ulink url="http://www.freedesktop.org/wiki/Software/dbus">
- http://www.freedesktop.org/wiki/Software/dbus</ulink>.
- </para>
-
- <warning>
- <para>dbus-glib is a deprecated API for use of D-Bus from GLib
- applications. Do not use it in new code.</para>
-
- <para>Since version 2.26, GLib's accompanying GIO library
- provides a high-level API for D-Bus, "GDBus", based on an
- independent reimplementation of the D-Bus protocol. The maintainers
- of D-Bus recommend that GLib applications should use GDBus
- instead of dbus-glib.</para>
- </warning>
- </chapter>
-
- <chapter>
- <title>API Reference</title>
- <xi:include href="xml/dbus-gconnection.xml"/>
- <xi:include href="xml/dbus-gobject.xml"/>
- <xi:include href="xml/dbus-gmessage.xml"/>
- <xi:include href="xml/dbus-gmethod.xml"/>
- <xi:include href="xml/dbus-gerror.xml"/>
- <xi:include href="xml/dbus-gproxy.xml"/>
- <xi:include href="xml/dbus-gtype-specialized.xml"/>
- <xi:include href="xml/dbus-glib-lowlevel.xml"/>
- </chapter>
-
- <chapter>
- <title>Tools Reference</title>
-
- &dbus-binding-tool;
-
- </chapter>
- <index id="api-index-full">
- <title>Index of all symbols</title>
- <xi:include href="xml/api-index-full.xml"><xi:fallback /></xi:include>
- </index>
-
-</book>
diff --git a/doc/reference/dbus-glib-overrides.txt b/doc/reference/dbus-glib-overrides.txt
deleted file mode 100644
index e69de29..0000000
--- a/doc/reference/dbus-glib-overrides.txt
+++ /dev/null
diff --git a/doc/reference/dbus-glib-sections.txt b/doc/reference/dbus-glib-sections.txt
deleted file mode 100644
index e844ff0..0000000
--- a/doc/reference/dbus-glib-sections.txt
+++ /dev/null
@@ -1,201 +0,0 @@
-<SECTION>
-<FILE>dbus-gconnection</FILE>
-<TITLE>DBusGConnection</TITLE>
-<INCLUDE>dbus/dbus-glib.h</INCLUDE>
-DBusGConnection
-DBUS_TYPE_G_CONNECTION
-dbus_g_bus_get
-dbus_g_bus_get_private
-dbus_g_thread_init
-dbus_g_connection_open
-dbus_g_connection_ref
-dbus_g_connection_unref
-dbus_g_connection_flush
-dbus_g_connection_get_connection
-dbus_g_connection_register_g_object
-dbus_g_connection_unregister_g_object
-dbus_g_connection_lookup_g_object
-<SUBSECTION Standard>
-dbus_g_connection_get_g_type
-</SECTION>
-
-<SECTION>
-<FILE>dbus-gobject</FILE>
-<TITLE>DBus GObject related functions</TITLE>
-<INCLUDE>dbus/dbus-glib.h</INCLUDE>
-DBusGObjectInfo
-dbus_g_object_type_install_info
-dbus_g_object_type_register_shadow_property
-dbus_g_object_register_marshaller
-dbus_g_object_register_marshaller_array
-dbus_glib_global_set_disable_legacy_property_access
-<SUBSECTION Standard>
-dbus_g_object_path_get_g_type
-</SECTION>
-
-<SECTION>
-<FILE>dbus-gmessage</FILE>
-<TITLE>DBusGMessage</TITLE>
-<INCLUDE>dbus/dbus-glib.h</INCLUDE>
-DBusGMessage
-DBUS_TYPE_G_MESSAGE
-dbus_g_message_ref
-dbus_g_message_unref
-dbus_g_message_get_message
-<SUBSECTION Standard>
-dbus_g_message_get_g_type
-</SECTION>
-
-<SECTION>
-<FILE>dbus-gmethod</FILE>
-<TITLE>DBusGMethod</TITLE>
-<INCLUDE>dbus/dbus-glib.h</INCLUDE>
-DBusGMethodInfo
-DBusGMethodInvocation
-dbus_g_method_get_sender
-dbus_g_method_get_reply
-dbus_g_method_send_reply
-dbus_g_method_return
-dbus_g_method_return_error
-</SECTION>
-
-<SECTION>
-<FILE>dbus-gerror</FILE>
-<TITLE>DBusGError</TITLE>
-<INCLUDE>dbus/dbus-glib.h</INCLUDE>
-DBusGError
-dbus_g_error_has_name
-dbus_g_error_get_name
-dbus_g_error_domain_register
-DBUS_GERROR
-<SUBSECTION Standard>
-dbus_g_error_quark
-</SECTION>
-
-<SECTION>
-<FILE>dbus-gproxy</FILE>
-<TITLE>DBusGProxy</TITLE>
-<INCLUDE>dbus/dbus-glib.h</INCLUDE>
-DBusGProxy
-DBusGProxyCall
-DBusGProxyCallNotify
-dbus_g_proxy_new_for_name
-dbus_g_proxy_new_for_name_owner
-dbus_g_proxy_new_from_proxy
-dbus_g_proxy_new_for_peer
-dbus_g_proxy_set_interface
-dbus_g_proxy_get_path
-dbus_g_proxy_get_bus_name
-dbus_g_proxy_get_interface
-dbus_g_proxy_add_signal
-dbus_g_proxy_connect_signal
-dbus_g_proxy_disconnect_signal
-dbus_g_proxy_send
-dbus_g_proxy_call
-dbus_g_proxy_call_with_timeout
-dbus_g_proxy_call_no_reply
-dbus_g_proxy_begin_call
-dbus_g_proxy_begin_call_with_timeout
-dbus_g_proxy_end_call
-dbus_g_proxy_cancel_call
-dbus_g_proxy_set_default_timeout
-<SUBSECTION Standard>
-DBUS_G_PROXY
-DBUS_IS_G_PROXY
-DBUS_TYPE_G_PROXY
-dbus_g_proxy_get_type
-DBUS_G_PROXY_CLASS
-DBUS_IS_G_PROXY_CLASS
-DBUS_G_PROXY_GET_CLASS
-<SUBSECTION Private>
-DBusGAsyncData
-</SECTION>
-
-<SECTION>
-<FILE>dbus-glib-lowlevel</FILE>
-<TITLE>DBus GLib low level</TITLE>
-<INCLUDE>dbus/dbus-glib-lowlevel.h</INCLUDE>
-dbus_set_g_error
-dbus_connection_setup_with_g_main
-dbus_connection_get_g_connection
-dbus_server_setup_with_g_main
-DBUS_TYPE_CONNECTION
-DBUS_TYPE_MESSAGE
-<SUBSECTION Standard>
-dbus_connection_get_g_type
-dbus_message_get_g_type
-<SUBSECTION Private>
-DBUS_INSIDE_DBUS_GLIB_H
-</SECTION>
-
-<SECTION>
-<FILE>dbus-gtype-specialized</FILE>
-<TITLE>Specializable GType System</TITLE>
-<INCLUDE>dbus/dbus-glib.h</INCLUDE>
-DBusGTypeSpecializedCollectionIterator
-DBusGTypeSpecializedMapIterator
-DBusGTypeSpecializedAppendContext
-DBusGTypeSpecializedConstructor
-DBusGTypeSpecializedFreeFunc
-DBusGTypeSpecializedCopyFunc
-DBusGTypeSpecializedVtable
-DBusGTypeSpecializedCollectionFixedAccessorFunc
-DBusGTypeSpecializedCollectionIteratorFunc
-DBusGTypeSpecializedCollectionAppendFunc
-DBusGTypeSpecializedCollectionEndAppendFunc
-DBusGTypeSpecializedCollectionVtable
-DBusGTypeSpecializedMapIteratorFunc
-DBusGTypeSpecializedMapAppendFunc
-DBusGTypeSpecializedMapVtable
-DBusGTypeSpecializedStructGetMember
-DBusGTypeSpecializedStructSetMember
-DBusGTypeSpecializedStructVtable
-dbus_g_type_get_collection
-dbus_g_type_get_map
-dbus_g_type_get_structv
-dbus_g_type_get_struct
-dbus_g_type_is_collection
-dbus_g_type_is_map
-dbus_g_type_is_struct
-dbus_g_type_get_collection_specialization
-dbus_g_type_get_map_key_specialization
-dbus_g_type_get_map_value_specialization
-dbus_g_type_get_struct_member_type
-dbus_g_type_get_struct_size
-dbus_g_type_specialized_construct
-dbus_g_type_specialized_init_append
-dbus_g_type_specialized_collection_append
-dbus_g_type_specialized_collection_end_append
-dbus_g_type_specialized_map_append
-dbus_g_type_collection_get_fixed
-dbus_g_type_collection_value_iterate
-dbus_g_type_map_value_iterate
-dbus_g_type_struct_get_member
-dbus_g_type_struct_set_member
-dbus_g_type_struct_get
-dbus_g_type_struct_set
-dbus_g_type_specialized_init
-dbus_g_type_register_collection
-dbus_g_type_register_map
-dbus_g_type_map_peek_vtable
-dbus_g_type_collection_peek_vtable
-dbus_g_type_struct_peek_vtable
-dbus_g_type_register_struct
-dbus_g_value_build_g_variant
-dbus_g_value_parse_g_variant
-DBUS_TYPE_G_BOOLEAN_ARRAY
-DBUS_TYPE_G_UCHAR_ARRAY
-DBUS_TYPE_G_UINT_ARRAY
-DBUS_TYPE_G_INT_ARRAY
-DBUS_TYPE_G_UINT64_ARRAY
-DBUS_TYPE_G_INT64_ARRAY
-DBUS_TYPE_G_OBJECT_ARRAY
-DBUS_TYPE_G_STRING_STRING_HASHTABLE
-DBusGSignature
-DBUS_TYPE_G_SIGNATURE
-DBusGObjectPath
-DBUS_TYPE_G_OBJECT_PATH
-<SUBSECTION Private>
-dbus_g_object_path_get_g_type
-dbus_g_signature_get_g_type
-</SECTION>
diff --git a/doc/reference/dbus-glib.types b/doc/reference/dbus-glib.types
deleted file mode 100644
index e69de29..0000000
--- a/doc/reference/dbus-glib.types
+++ /dev/null
diff --git a/doc/reference/version.xml.in b/doc/reference/version.xml.in
deleted file mode 100644
index 27323da..0000000
--- a/doc/reference/version.xml.in
+++ /dev/null
@@ -1 +0,0 @@
-@VERSION@ \ No newline at end of file
diff --git a/m4/Makefile.am b/m4/Makefile.am
deleted file mode 100644
index e2f06ce..0000000
--- a/m4/Makefile.am
+++ /dev/null
@@ -1 +0,0 @@
-EXTRA_DIST = gtk-doc.m4
diff --git a/m4/gtk-doc.m4 b/m4/gtk-doc.m4
deleted file mode 120000
index d214c6a..0000000
--- a/m4/gtk-doc.m4
+++ /dev/null
@@ -1 +0,0 @@
-/usr/share/aclocal/gtk-doc.m4 \ No newline at end of file
diff --git a/test/Makefile.am b/test/Makefile.am
deleted file mode 100644
index e538f2d..0000000
--- a/test/Makefile.am
+++ /dev/null
@@ -1,58 +0,0 @@
-SUBDIRS = . core interfaces
-DIST_SUBDIRS = core interfaces
-
-AM_CPPFLAGS = \
- -I$(top_srcdir) \
- -I$(top_builddir) \
- -I$(top_builddir)/dbus \
- $(DBUS_CFLAGS) \
- $(DBUS_GLIB_CFLAGS) \
- $(NULL)
-
-LDADD = \
- $(top_builddir)/dbus/libdbus-glib-1.la \
- $(DBUS_GLIB_LIBS) \
- $(DBUS_LIBS) \
- $(NULL)
-
-if DBUS_BUILD_TESTS
-test_programs = \
- test-errors \
- test-specialized-types \
- $(NULL)
-
-# not actually tests, but used by tests
-test_related_programs = \
- test-service \
- $(NULL)
-endif
-
-test_errors_SOURCES = errors.c
-test_specialized_types_SOURCES = specialized-types.c
-
-test_service_SOURCES= \
- test-service.c
-
-test_service_LDADD=$(DBUS_LIBS)
-
-EXTRA_DIST = data/nested-introspect.xml test-compile-nested.sh
-
-TESTS_ENVIRONMENT=top_builddir=$(top_builddir) srcdir=$(srcdir)
-
-test_scripts = \
- test-compile-nested.sh \
- $(NULL)
-
-TESTS = \
- $(test_programs) \
- $(test_scripts) \
- $(NULL)
-
-noinst_PROGRAMS = \
- $(test_programs) \
- $(test_related_programs) \
- $(NULL)
-
-check-valgrind: all
- $(MAKE) -C core check-valgrind
- $(MAKE) -C interfaces check-valgrind
diff --git a/test/core/Makefile.am b/test/core/Makefile.am
deleted file mode 100644
index 314ff40..0000000
--- a/test/core/Makefile.am
+++ /dev/null
@@ -1,177 +0,0 @@
-AM_CPPFLAGS = \
- -I$(top_srcdir) \
- -I$(top_srcdir)/dbus \
- -I$(top_builddir) \
- -I$(top_builddir)/dbus \
- $(DBUS_CFLAGS) \
- $(DBUS_GLIB_CFLAGS) \
- -DDBUS_COMPILATION
-
-LDADD = \
- $(DBUS_GLIB_THREADS_LIBS) \
- $(DBUS_GLIB_LIBS) \
- $(DBUS_LIBS) \
- $(top_builddir)/dbus/libdbus-glib-1.la \
- $(top_builddir)/dbus-gmain/tests/libtest.la \
- $(NULL)
-
-tool_ldadd = \
- $(LDADD) \
- $(DBUS_GLIB_TOOL_LIBS) \
- $(top_builddir)/dbus/libdbus-gtool.la
-
-## note that TESTS has special meaning (stuff to use in make check)
-## so if adding tests not to be run in make check, don't add them to
-## TESTS
-if DBUS_BUILD_TESTS
-TESTS_ENVIRONMENT=DBUS_TOP_BUILDDIR=@abs_top_builddir@
-TESTS=run-test.sh run-peer-test.sh
-else
-TESTS=
-endif
-
-VALGRIND_ENV = G_DEBUG=gc-friendly G_SLICE=always-malloc
-VALGRIND = valgrind
-VALGRIND_ARGS = \
- --gen-suppressions=all \
- --leak-check=full \
- --leak-resolution=high \
- --num-callers=20 \
- --suppressions=$(abs_top_srcdir)/tools/dbus-glib.supp \
- --suppressions=$(abs_top_srcdir)/tools/dbus-glib-tests.supp \
- --verbose \
- $(NULL)
-
-check-valgrind: all
- $(MAKE) check-TESTS \
- DEBUG="env $(VALGRIND_ENV) $(VALGRIND) $(VALGRIND_ARGS)"
-
-EXTRA_DIST = \
- run-peer-test.sh \
- run-test.sh \
- test-service-glib-subclass.xml \
- test-service-glib.xml \
- $(NULL)
-
-if DBUS_BUILD_TESTS
-
-## we use noinst_PROGRAMS not check_PROGRAMS for TESTS so that we
-## build even when not doing "make check"
-noinst_PROGRAMS = \
- test-dbus-glib \
- test-error-mapping \
- test-service-glib \
- test-profile \
- manual/test-invalid-usage \
- peer-server \
- peer-client \
- test-types \
- test-private \
- test-peer-on-bus \
- test-proxy-noc \
- test-proxy-peer \
- test-registrations \
- test-variant-recursion \
- test-gvariant \
- test-shared-bus \
- $(NULL)
-
-# This "test" exercises invalid usage. It is deliberately not run in
-# TESTS, because it's (by design) full of bugs.
-manual_test_invalid_usage_SOURCES = \
- manual/invalid-usage.c \
- my-object.c \
- my-object.h \
- $(NULL)
-
-test_private_SOURCES = \
- my-object.c \
- my-object.h \
- private.c
-
-test_proxy_noc_SOURCES = \
- proxy-noc.c
-
-test_proxy_peer_SOURCES = \
- my-object.c \
- my-object.h \
- proxy-peer.c
-
-test_registrations_SOURCES = \
- my-object.c \
- my-object.h \
- my-object-subclass.c \
- my-object-subclass.h \
- registrations.c
-
-test_dbus_glib_SOURCES= \
- my-object.c \
- my-object.h \
- test-dbus-glib.c
-
-test_dbus_glib_LDADD= $(tool_ldadd)
-
-test_error_mapping_SOURCES = \
- my-object.c \
- my-object.h \
- error-mapping.c
-
-test_variant_recursion_SOURCES=test-variant-recursion.c
-
-test_variant_recursion_LDADD= $(tool_ldadd)
-
-BUILT_SOURCES = \
- test-service-glib-bindings.h \
- test-service-glib-glue.h \
- test-service-glib-subclass-glue.h \
- $(NULL)
-
-test_service_glib_SOURCES= \
- my-object.c \
- my-object.h \
- my-object-subclass.c \
- my-object-subclass.h \
- test-service-glib.c
-
-test-service-glib-glue.h: test-service-glib.xml $(top_builddir)/dbus/dbus-binding-tool$(EXEEXT)
- $(DEBUG) $(DBUS_BINDING_TOOL) --prefix=my_object --mode=glib-server --output=test-service-glib-glue.h $(srcdir)/test-service-glib.xml
-
-test-service-glib-subclass-glue.h: test-service-glib-subclass.xml $(top_builddir)/dbus/dbus-binding-tool$(EXEEXT)
- $(DEBUG) $(DBUS_BINDING_TOOL) --prefix=my_object_subclass --mode=glib-server --output=test-service-glib-subclass-glue.h $(srcdir)/test-service-glib-subclass.xml
-
-test-service-glib-bindings.h: test-service-glib.xml $(top_builddir)/dbus/dbus-binding-tool$(EXEEXT)
- $(DEBUG) $(DBUS_BINDING_TOOL) --prefix=my_object --mode=glib-client --output=test-service-glib-bindings.h $(srcdir)/test-service-glib.xml
-
-peer_server_SOURCES = \
- my-object.c \
- my-object.h \
- my-object-subclass.c \
- my-object-subclass.h \
- peer-server.c
-
-peer_client_SOURCES = \
- peer-client.c
-
-test_types_SOURCES = \
- test-types.c
-
-test_gvariant_SOURCES = \
- test-gvariant.c
-
-test_peer_on_bus_SOURCES = peer-on-bus.c
-
-test_shared_bus_SOURCES = shared-bus.c
-
-CLEANFILES = \
- $(BUILT_SOURCES) \
- run-with-tmp-session-bus.conf
-
-else
-### not building tests
-
-noinst_PROGRAMS=test-profile
-
-endif
-
-test_profile_SOURCES= \
- test-profile.c
diff --git a/test/core/error-mapping.c b/test/core/error-mapping.c
deleted file mode 100644
index d66985f..0000000
--- a/test/core/error-mapping.c
+++ /dev/null
@@ -1,308 +0,0 @@
-/* Feature test for exported object methods raising errors
- *
- * Copyright © 2006-2010 Red Hat, Inc.
- * Copyright © 2006-2010 Collabora Ltd.
- * Copyright © 2006-2011 Nokia Corporation
- * Copyright © 2006 Steve Frécinaux
- *
- * Licensed under the Academic Free License version 2.1
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301 USA
- */
-
-#include <config.h>
-
-#include <glib.h>
-#include <gio/gio.h>
-
-#include <dbus/dbus.h>
-#include <dbus/dbus-glib.h>
-#include <dbus/dbus-glib-lowlevel.h>
-
-#include <string.h>
-
-#include "my-object.h"
-#include "test-service-glib-bindings.h"
-
-/* my-object wants this to exist */
-GMainLoop *loop = NULL;
-
-typedef struct {
- GError *error;
- gchar *error_name;
- DBusGConnection *conn;
- DBusGProxy *proxy;
- GObject *object;
-} Fixture;
-
-#define assert_contains(haystack, needle) \
- assert_contains_impl (__FILE__, __LINE__, G_STRINGIFY (haystack), haystack, \
- G_STRINGIFY (needle), needle)
-
-static void
-assert_contains_impl (const gchar *file,
- gint line,
- const gchar *haystack_desc,
- const gchar *haystack,
- const gchar *needle_desc,
- const gchar *needle)
-{
- if (G_UNLIKELY (strstr (haystack, needle) == NULL))
- {
- g_error ("%s:%d: assertion failed: (%s) contains (%s): "
- "values are \"%s\", \"%s\"",
- file, line, haystack_desc, needle_desc, haystack, needle);
- }
-}
-
-static void
-setup (Fixture *f,
- gconstpointer context)
-{
- static gsize once = 0;
-
- dbus_g_type_specialized_init ();
-
- if (g_once_init_enter (&once))
- {
- /* this may only be called once */
- dbus_g_error_domain_register (MY_OBJECT_ERROR, NULL, MY_TYPE_ERROR);
-
- g_once_init_leave (&once, 1);
- }
-
- f->conn = dbus_g_bus_get_private (DBUS_BUS_SESSION, NULL, &f->error);
- g_assert_no_error (f->error);
- g_assert (f->conn != NULL);
-
- f->object = g_object_new (MY_TYPE_OBJECT, NULL);
- g_assert (MY_IS_OBJECT (f->object));
- dbus_g_connection_register_g_object (f->conn, "/com/example/Test/Object",
- f->object);
-
- f->proxy = dbus_g_proxy_new_for_name (f->conn,
- dbus_bus_get_unique_name (dbus_g_connection_get_connection (f->conn)),
- "/com/example/Test/Object", "org.freedesktop.DBus.GLib.Tests.MyObject");
- g_assert (f->proxy != NULL);
-}
-
-static void
-throw_error_cb (DBusGProxy *proxy,
- GError *error,
- gpointer user_data)
-{
- Fixture *f = user_data;
-
- g_assert (error != NULL);
- g_clear_error (&f->error);
- g_free (f->error_name);
- f->error = g_error_copy (error);
-
- if (g_error_matches (error, DBUS_GERROR, DBUS_GERROR_REMOTE_EXCEPTION))
- f->error_name = g_strdup (dbus_g_error_get_name (error));
- else
- f->error_name = NULL;
-
- /* On error, this callback is expected to free it, which is pretty
- * astonishing, but is how it's always been. In principle, the generated
- * code ought to document this, or something.
- * https://bugs.freedesktop.org/show_bug.cgi?id=29195
- */
- g_error_free (error);
-}
-
-static void
-test_async (Fixture *f,
- gconstpointer context)
-{
- /* This is equivalent to test_simple but uses a method that's implemented
- * async at the service side - it's a different calling convention for the
- * service, but is indistinguishable here. */
-
- my_object_save_error ((MyObject *) f->object, MY_OBJECT_ERROR,
- MY_OBJECT_ERROR_FOO, "<foo>");
-
- if (!org_freedesktop_DBus_GLib_Tests_MyObject_async_throw_error_async (
- f->proxy, throw_error_cb, f))
- g_error ("Failed to start async AsyncThrowError call");
-
- while (f->error == NULL)
- g_main_context_iteration (NULL, TRUE);
-
- g_assert_error (f->error, DBUS_GERROR, DBUS_GERROR_REMOTE_EXCEPTION);
- g_assert_cmpstr (f->error_name, ==,
- "org.freedesktop.DBus.GLib.Tests.MyObject.Foo");
- assert_contains (f->error->message, "<foo>");
-}
-
-static void
-test_simple (Fixture *f,
- gconstpointer context)
-{
- my_object_save_error ((MyObject *) f->object, MY_OBJECT_ERROR,
- MY_OBJECT_ERROR_FOO, "<foo>");
-
- if (!org_freedesktop_DBus_GLib_Tests_MyObject_throw_error_async (
- f->proxy, throw_error_cb, f))
- g_error ("Failed to start async ThrowError call");
-
- while (f->error == NULL)
- g_main_context_iteration (NULL, TRUE);
-
- g_assert_error (f->error, DBUS_GERROR, DBUS_GERROR_REMOTE_EXCEPTION);
- g_assert_cmpstr (f->error_name, ==,
- "org.freedesktop.DBus.GLib.Tests.MyObject.Foo");
- assert_contains (f->error->message, "<foo>");
-}
-
-static void
-test_builtin (Fixture *f,
- gconstpointer context)
-{
- g_test_bug ("16776");
-
- my_object_save_error ((MyObject *) f->object, DBUS_GERROR,
- DBUS_GERROR_NOT_SUPPORTED, "<not supported>");
-
- if (!org_freedesktop_DBus_GLib_Tests_MyObject_throw_error_async (
- f->proxy, throw_error_cb, f))
- g_error ("Failed to start async ThrowError call");
-
- while (f->error == NULL)
- g_main_context_iteration (NULL, TRUE);
-
- g_assert_error (f->error, DBUS_GERROR, DBUS_GERROR_NOT_SUPPORTED);
- assert_contains (f->error->message, "<not supported>");
-}
-
-static void
-test_multi_word (Fixture *f,
- gconstpointer context)
-{
- /* no bug#, but this is a regression test for commit 3d69cfeab177e */
-
- my_object_save_error ((MyObject *) f->object, MY_OBJECT_ERROR,
- MY_OBJECT_ERROR_MULTI_WORD, "this method's error has a hyphen");
-
- if (!org_freedesktop_DBus_GLib_Tests_MyObject_throw_error_async (
- f->proxy, throw_error_cb, f))
- g_error ("Failed to start async ThrowError call");
-
- while (f->error == NULL)
- g_main_context_iteration (NULL, TRUE);
-
- g_assert_error (f->error, DBUS_GERROR, DBUS_GERROR_REMOTE_EXCEPTION);
- g_assert_cmpstr (f->error_name, ==,
- "org.freedesktop.DBus.GLib.Tests.MyObject.MultiWord");
- assert_contains (f->error->message, "this method's error has a hyphen");
-}
-
-static void
-test_underscore (Fixture *f,
- gconstpointer context)
-{
- g_test_bug ("30274");
-
- my_object_save_error ((MyObject *) f->object, MY_OBJECT_ERROR,
- MY_OBJECT_ERROR_UNDER_SCORE, "this method's error has an underscore");
-
- if (!org_freedesktop_DBus_GLib_Tests_MyObject_throw_error_async (
- f->proxy, throw_error_cb, f))
- g_error ("Failed to start async ThrowError call");
-
- while (f->error == NULL)
- g_main_context_iteration (NULL, TRUE);
-
- g_assert_error (f->error, DBUS_GERROR, DBUS_GERROR_REMOTE_EXCEPTION);
- g_assert_cmpstr (f->error_name, ==,
- "org.freedesktop.DBus.GLib.Tests.MyObject.Under_score");
- assert_contains (f->error->message, "this method's error has an underscore");
-}
-
-static void
-test_unregistered (Fixture *f,
- gconstpointer context)
-{
- g_test_bug ("27799");
-
- my_object_save_error ((MyObject *) f->object, G_IO_ERROR,
- G_IO_ERROR_NOT_INITIALIZED,
- "dbus-glib does not know about this error domain");
-
- if (!org_freedesktop_DBus_GLib_Tests_MyObject_throw_error_async (
- f->proxy, throw_error_cb, f))
- g_error ("Failed to start async ThrowError call");
-
- while (f->error == NULL)
- g_main_context_iteration (NULL, TRUE);
-
- g_assert_error (f->error, DBUS_GERROR, DBUS_GERROR_REMOTE_EXCEPTION);
- assert_contains (f->error->message,
- "dbus-glib does not know about this error domain");
-}
-
-static void
-teardown (Fixture *f,
- gconstpointer context G_GNUC_UNUSED)
-{
- g_free (f->error_name);
-
- g_clear_error (&f->error);
-
- if (f->proxy != NULL)
- {
- g_object_unref (f->proxy);
- f->proxy = NULL;
- }
-
- if (f->object != NULL)
- {
- g_object_unref (f->object);
- f->object = NULL;
- }
-
- if (f->conn != NULL)
- {
- dbus_connection_close (dbus_g_connection_get_connection (f->conn));
- dbus_g_connection_unref (f->conn);
- f->conn = NULL;
- }
-}
-
-int
-main (int argc,
- char **argv)
-{
- g_test_init (&argc, &argv, NULL);
- g_test_bug_base ("https://bugs.freedesktop.org/show_bug.cgi?id=");
-
- g_type_init ();
-
- g_test_add ("/error-mapping/async", Fixture, NULL, setup, test_async,
- teardown);
- g_test_add ("/error-mapping/builtin", Fixture, NULL, setup, test_builtin,
- teardown);
- g_test_add ("/error-mapping/multi-word", Fixture, NULL, setup,
- test_multi_word, teardown);
- g_test_add ("/error-mapping/simple", Fixture, NULL, setup, test_simple,
- teardown);
- g_test_add ("/error-mapping/underscore", Fixture, NULL, setup,
- test_underscore, teardown);
- g_test_add ("/error-mapping/unregistered", Fixture, NULL, setup,
- test_unregistered, teardown);
-
- return g_test_run ();
-}
diff --git a/test/core/manual/invalid-usage.c b/test/core/manual/invalid-usage.c
deleted file mode 100644
index 95a2591..0000000
--- a/test/core/manual/invalid-usage.c
+++ /dev/null
@@ -1,320 +0,0 @@
-/* Manual test for various invalid usages which should not crash us (in order
- * to be nice to fallible programmers), unless checks have been disabled (in
- * which case, you asked for it, you got it).
- *
- * Copyright © 2006-2010 Red Hat, Inc.
- * Copyright © 2006-2010 Collabora Ltd.
- * Copyright © 2006-2011 Nokia Corporation
- * Copyright © 2006 Steve Frécinaux
- *
- * Licensed under the Academic Free License version 2.1
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301 USA
- */
-
-#include <config.h>
-
-#include <glib.h>
-
-#include <dbus/dbus.h>
-#include <dbus/dbus-glib.h>
-#include <dbus/dbus-glib-lowlevel.h>
-
-#include <string.h>
-
-#include "my-object.h"
-#include "test-service-glib-bindings.h"
-
-/* my-object wants this to exist */
-GMainLoop *loop = NULL;
-
-typedef struct {
- GError *error;
- DBusGConnection *conn;
- DBusGProxy *proxy;
- DBusGProxy *proxy_for_self;
- GObject *object;
-} Fixture;
-
-static void
-setup (Fixture *f,
- gconstpointer context)
-{
- /* this test is all about (mostly critical) warnings, so don't crash out on
- * programming errors */
- g_setenv ("DBUS_FATAL_WARNINGS", "0", TRUE);
- g_log_set_always_fatal (G_LOG_LEVEL_ERROR);
-
- dbus_g_type_specialized_init ();
-
- /* This is a bug: you're not meant to register any domain more than
- * once. It shouldn't crash, though. */
- dbus_g_error_domain_register (MY_OBJECT_ERROR, NULL, MY_TYPE_ERROR);
-
- f->conn = dbus_g_bus_get_private (DBUS_BUS_SESSION, NULL, &f->error);
- g_assert_no_error (f->error);
- g_assert (f->conn != NULL);
-
- f->proxy = dbus_g_proxy_new_for_name (f->conn, "com.example.Test",
- "/com/example/Test/Object", "com.example.Test.Fallible");
- g_assert (f->proxy != NULL);
-
- f->object = g_object_new (MY_TYPE_OBJECT, NULL);
- g_assert (MY_IS_OBJECT (f->object));
- dbus_g_connection_register_g_object (f->conn, "/com/example/Test/Object",
- f->object);
-
- f->proxy_for_self = dbus_g_proxy_new_for_name (f->conn,
- dbus_bus_get_unique_name (dbus_g_connection_get_connection (f->conn)),
- "/com/example/Test/Object", "org.freedesktop.DBus.GLib.Tests.MyObject");
- g_assert (f->proxy_for_self != NULL);
-}
-
-static void
-test_invalid_gtype (Fixture *f,
- gconstpointer context)
-{
- /* G_TYPE_GTYPE is not handled by the dbus-glib type system (and would make
- * no sense anyway) */
- dbus_g_proxy_call_no_reply (f->proxy, "Fail",
- G_TYPE_GTYPE, G_TYPE_STRING,
- G_TYPE_INVALID);
-}
-
-static void
-test_invalid_utf8 (Fixture *f,
- gconstpointer context)
-{
- g_test_bug ("30171");
-
- /* This provokes a libdbus warning, which is fatal-by-default */
- dbus_g_proxy_call_no_reply (f->proxy, "Fail",
- G_TYPE_STRING, "\xfe\xfe\xfe",
- G_TYPE_INVALID);
-}
-
-static void
-test_invalid_bool (Fixture *f,
- gconstpointer context)
-{
- g_test_bug ("30171");
-
- /* This provokes a libdbus warning, which is fatal-by-default */
- dbus_g_proxy_call_no_reply (f->proxy, "Fail",
- G_TYPE_BOOLEAN, (gboolean) (-42),
- G_TYPE_INVALID);
-}
-
-static void
-test_invalid_path (Fixture *f,
- gconstpointer context)
-{
- g_test_bug ("30171");
-
- /* This provokes a libdbus warning, which is fatal-by-default */
- dbus_g_proxy_call_no_reply (f->proxy, "Fail",
- DBUS_TYPE_G_OBJECT_PATH, "$%#*!",
- G_TYPE_INVALID);
-}
-
-static void
-test_invalid_utf8s (Fixture *f,
- gconstpointer context)
-{
- gchar *bad_strings[] = { "\xfe\xfe\xfe", NULL };
- GStrv bad_strv = bad_strings;
-
- g_test_bug ("30171");
-
- /* This provokes a libdbus warning, which is fatal-by-default */
- dbus_g_proxy_call_no_reply (f->proxy, "Fail",
- G_TYPE_STRV, bad_strv,
- G_TYPE_INVALID);
-}
-
-static void
-test_invalid_bools (Fixture *f,
- gconstpointer context)
-{
- GArray *array;
- gboolean maybe = (gboolean) (-23);
-
- g_test_bug ("30171");
-
- array = g_array_new (FALSE, FALSE, sizeof (gboolean));
-
- g_array_append_val (array, maybe);
-
- /* This provokes a libdbus warning, which is fatal-by-default */
- dbus_g_proxy_call_no_reply (f->proxy, "Fail",
- dbus_g_type_get_collection ("GArray", G_TYPE_BOOLEAN), array,
- G_TYPE_INVALID);
-
- g_array_free (array, TRUE);
-}
-
-static void
-test_invalid_paths (Fixture *f,
- gconstpointer context)
-{
- GPtrArray *array;
-
- g_test_bug ("30171");
-
- array = g_ptr_array_new ();
- g_ptr_array_add (array, "bees");
-
- /* This provokes a libdbus warning, which is fatal-by-default */
- dbus_g_proxy_call_no_reply (f->proxy, "Fail",
- dbus_g_type_get_collection ("GPtrArray", DBUS_TYPE_G_OBJECT_PATH), array,
- G_TYPE_INVALID);
-
- g_ptr_array_free (array, TRUE);
-}
-
-static void
-throw_error_cb (DBusGProxy *proxy,
- GError *error,
- gpointer user_data)
-{
- GError **error_out = user_data;
-
- g_assert (error != NULL);
- *error_out = g_error_copy (error);
-}
-
-static void
-test_error_out_of_range (Fixture *f,
- gconstpointer context)
-{
- GError *error = NULL;
-
- g_test_bug ("40151");
-
- /* This is a bug: -1 isn't a valid code for the domain. */
- my_object_save_error ((MyObject *) f->object, MY_OBJECT_ERROR, -1,
- "stop being so negative");
-
- if (!org_freedesktop_DBus_GLib_Tests_MyObject_throw_error_async (
- f->proxy_for_self, throw_error_cb, &error))
- g_error ("Failed to start async ThrowError call");
-
- while (error == NULL)
- g_main_context_iteration (NULL, TRUE);
-
- g_assert_error (error, DBUS_GERROR, DBUS_GERROR_REMOTE_EXCEPTION);
- g_clear_error (&error);
-
- /* This is a bug: 666 isn't a valid code for the domain. */
- my_object_save_error ((MyObject *) f->object, MY_OBJECT_ERROR, 666,
- "demonic possession detected");
-
- if (!org_freedesktop_DBus_GLib_Tests_MyObject_throw_error_async (
- f->proxy_for_self, throw_error_cb, &error))
- g_error ("Failed to start async ThrowError call");
-
- while (error == NULL)
- g_main_context_iteration (NULL, TRUE);
-
- g_assert_error (error, DBUS_GERROR, DBUS_GERROR_REMOTE_EXCEPTION);
- g_clear_error (&error);
-}
-
-static void
-test_error_domain_0 (Fixture *f,
- gconstpointer context)
-{
- /* This throws an error with domain 0 and code 0, which makes no sense.
- * It's programmer error, really: g_error_new() would critical if given
- * the same domain and code. See GNOME#660371.
- *
- * This was added for fd.o #27799, but there's a difference between
- * "this is an error domain, but not one registered with dbus-glib" and
- * "this isn't even an error domain". */
- g_test_bug ("27799");
-
- if (!org_freedesktop_DBus_GLib_Tests_MyObject_throw_unregistered_error_async (
- f->proxy_for_self, throw_error_cb, f))
- g_error ("Failed to start async ThrowUnregisteredError call");
-
- while (f->error == NULL)
- g_main_context_iteration (NULL, TRUE);
-
- g_assert_error (f->error, DBUS_GERROR, DBUS_GERROR_REMOTE_EXCEPTION);
-}
-
-static void
-teardown (Fixture *f,
- gconstpointer context G_GNUC_UNUSED)
-{
- g_clear_error (&f->error);
-
- if (f->proxy != NULL)
- {
- g_object_unref (f->proxy);
- f->proxy = NULL;
- }
-
- if (f->object != NULL)
- {
- g_object_unref (f->object);
- f->object = NULL;
- }
-
- if (f->proxy_for_self != NULL)
- {
- g_object_unref (f->proxy_for_self);
- f->proxy_for_self = NULL;
- }
-
- if (f->conn != NULL)
- {
- dbus_connection_close (dbus_g_connection_get_connection (f->conn));
- dbus_g_connection_unref (f->conn);
- f->conn = NULL;
- }
-}
-
-int
-main (int argc,
- char **argv)
-{
- g_test_init (&argc, &argv, NULL);
- g_test_bug_base ("https://bugs.freedesktop.org/show_bug.cgi?id=");
-
- g_type_init ();
-
- g_test_add ("/invalid/gtype", Fixture, NULL, setup, test_invalid_gtype,
- teardown);
- g_test_add ("/invalid/utf8", Fixture, NULL, setup, test_invalid_utf8,
- teardown);
- g_test_add ("/invalid/bool", Fixture, NULL, setup, test_invalid_bool,
- teardown);
- g_test_add ("/invalid/path", Fixture, NULL, setup, test_invalid_path,
- teardown);
- g_test_add ("/invalid/utf8s", Fixture, NULL, setup, test_invalid_utf8s,
- teardown);
- g_test_add ("/invalid/bools", Fixture, NULL, setup, test_invalid_bools,
- teardown);
- g_test_add ("/invalid/paths", Fixture, NULL, setup, test_invalid_paths,
- teardown);
- g_test_add ("/invalid/error/out-of-range", Fixture, NULL, setup,
- test_error_out_of_range, teardown);
- g_test_add ("/invalid/error/domain-0", Fixture, NULL, setup,
- test_error_domain_0, teardown);
-
- return g_test_run ();
-}
diff --git a/test/core/my-object-marshal.list b/test/core/my-object-marshal.list
deleted file mode 100644
index 48cbfad..0000000
--- a/test/core/my-object-marshal.list
+++ /dev/null
@@ -1,2 +0,0 @@
-NONE:STRING,INT,STRING
-NONE:STRING,BOXED
diff --git a/test/core/my-object-subclass.c b/test/core/my-object-subclass.c
deleted file mode 100644
index 7b4ae9e..0000000
--- a/test/core/my-object-subclass.c
+++ /dev/null
@@ -1,115 +0,0 @@
-#include <config.h>
-#include <string.h>
-#include <glib/gi18n.h>
-#include <glib-object.h>
-#include "my-object-subclass.h"
-
-#include "test-service-glib-subclass-glue.h"
-
-/* Properties */
-enum
-{
- PROP_0,
- PROP_THIS_IS_A_SUBCLASS_STRING,
- PROP_THIS_IS_A_SUBCLASS_UINT
-};
-
-G_DEFINE_TYPE(MyObjectSubclass, my_object_subclass, MY_TYPE_OBJECT)
-
-static void
-my_object_subclass_finalize (GObject *object)
-{
- MyObjectSubclass *mobject = MY_OBJECT_SUBCLASS (object);
-
- g_free (mobject->this_is_a_subclass_string);
-
- (G_OBJECT_CLASS (my_object_subclass_parent_class)->finalize) (object);
-}
-
-static void
-my_object_subclass_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- MyObjectSubclass *mobject;
-
- mobject = MY_OBJECT_SUBCLASS (object);
-
- switch (prop_id)
- {
- case PROP_THIS_IS_A_SUBCLASS_STRING:
- g_free (mobject->this_is_a_subclass_string);
- mobject->this_is_a_subclass_string = g_value_dup_string (value);
- break;
-
- case PROP_THIS_IS_A_SUBCLASS_UINT:
- mobject->this_is_a_subclass_uint = g_value_get_uint (value);
- break;
-
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-my_object_subclass_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
-{
- MyObjectSubclass *mobject;
-
- mobject = MY_OBJECT_SUBCLASS (object);
-
- switch (prop_id)
- {
- case PROP_THIS_IS_A_SUBCLASS_STRING:
- g_value_set_string (value, mobject->this_is_a_subclass_string);
- break;
-
- case PROP_THIS_IS_A_SUBCLASS_UINT:
- g_value_set_uint (value, mobject->this_is_a_subclass_uint);
- break;
-
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-my_object_subclass_init (MyObjectSubclass *obj)
-{
-}
-
-static void
-my_object_subclass_class_init (MyObjectSubclassClass *mobject_class)
-{
- GObjectClass *gobject_class = G_OBJECT_CLASS (mobject_class);
-
- dbus_g_object_type_install_info (MY_TYPE_OBJECT_SUBCLASS,
- &dbus_glib_my_object_subclass_object_info);
-
- gobject_class->finalize = my_object_subclass_finalize;
- gobject_class->set_property = my_object_subclass_set_property;
- gobject_class->get_property = my_object_subclass_get_property;
-
- g_object_class_install_property (gobject_class,
- PROP_THIS_IS_A_SUBCLASS_STRING,
- g_param_spec_string ("this_is_a_subclass_string",
- _("Sample string"),
- _("Example of a string property"),
- "default subclass value",
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
-
- g_object_class_install_property (gobject_class,
- PROP_THIS_IS_A_SUBCLASS_UINT,
- g_param_spec_uint ("this_is_a_subclass_uint",
- _("Sample uint"),
- _("Example of a uint property"),
- 0, G_MAXUINT32, 1234567,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
-}
-
diff --git a/test/core/my-object-subclass.h b/test/core/my-object-subclass.h
deleted file mode 100644
index edb03cd..0000000
--- a/test/core/my-object-subclass.h
+++ /dev/null
@@ -1,33 +0,0 @@
-#ifndef __MY_OBJECT_SUBCLASS_H__
-#define __MY_OBJECT_SUBCLASS_H__
-
-#include <glib-object.h>
-#include <dbus/dbus-glib.h>
-
-#include "my-object.h"
-
-typedef struct MyObjectSubclass MyObjectSubclass;
-typedef struct MyObjectSubclassClass MyObjectSubclassClass;
-
-GType my_object_subclass_get_type (void);
-
-struct MyObjectSubclass
-{
- MyObject parent;
- char *this_is_a_subclass_string;
- guint this_is_a_subclass_uint;
-};
-
-struct MyObjectSubclassClass
-{
- MyObjectClass parent;
-};
-
-#define MY_TYPE_OBJECT_SUBCLASS (my_object_subclass_get_type ())
-#define MY_OBJECT_SUBCLASS(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), MY_TYPE_OBJECT_SUBCLASS, MyObjectSubclass))
-#define MY_OBJECT_SUBCLASS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MY_TYPE_OBJECT_SUBCLASS, MyObjectSubclassClass))
-#define MY_IS_OBJECT_SUBCLASS(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), MY_TYPE_OBJECT_SUBCLASS))
-#define MY_IS_OBJECT_SUBCLASS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MY_TYPE_OBJECT_SUBCLASS))
-#define MY_OBJECT_SUBCLASS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MY_TYPE_OBJECT_SUBCLASS, MyObjectSubclassClass))
-
-#endif
diff --git a/test/core/my-object.c b/test/core/my-object.c
deleted file mode 100644
index 4a0002e..0000000
--- a/test/core/my-object.c
+++ /dev/null
@@ -1,869 +0,0 @@
-#include <config.h>
-#include <string.h>
-#include <glib/gi18n.h>
-#include <glib-object.h>
-#include "my-object.h"
-
-#include "test-service-glib-glue.h"
-
-/* Properties */
-enum
-{
- PROP_0,
- PROP_THIS_IS_A_STRING,
- PROP_NO_TOUCHING,
- PROP_SUPER_STUDLY,
- PROP_SHOULD_BE_HIDDEN
-};
-
-enum
-{
- FROBNICATE,
- OBJECTIFIED,
- SIG0,
- SIG1,
- SIG2,
- LAST_SIGNAL
-};
-
-static guint signals[LAST_SIGNAL] = { 0 };
-
-G_DEFINE_TYPE(MyObject, my_object, G_TYPE_OBJECT)
-
-static void
-my_object_finalize (GObject *object)
-{
- MyObject *mobject = MY_OBJECT (object);
-
- g_free (mobject->this_is_a_string);
- g_clear_error (&mobject->saved_error);
-
- (G_OBJECT_CLASS (my_object_parent_class)->finalize) (object);
-}
-
-static void
-my_object_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- MyObject *mobject;
-
- mobject = MY_OBJECT (object);
-
- switch (prop_id)
- {
- case PROP_THIS_IS_A_STRING:
- g_free (mobject->this_is_a_string);
- mobject->this_is_a_string = g_value_dup_string (value);
- break;
-
- case PROP_NO_TOUCHING:
- mobject->notouching = g_value_get_uint (value);
- break;
-
- case PROP_SUPER_STUDLY:
- mobject->super_studly = g_value_get_double (value);
- break;
-
- case PROP_SHOULD_BE_HIDDEN:
- mobject->should_be_hidden = g_value_get_boolean (value);
- break;
-
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-my_object_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
-{
- MyObject *mobject;
-
- mobject = MY_OBJECT (object);
-
- switch (prop_id)
- {
- case PROP_THIS_IS_A_STRING:
- g_value_set_string (value, mobject->this_is_a_string);
- break;
-
- case PROP_NO_TOUCHING:
- g_value_set_uint (value, mobject->notouching);
- break;
-
- case PROP_SUPER_STUDLY:
- g_value_set_double (value, mobject->super_studly);
- break;
-
- case PROP_SHOULD_BE_HIDDEN:
- g_value_set_boolean (value, mobject->should_be_hidden);
- break;
-
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-my_object_init (MyObject *obj)
-{
- obj->val = 0;
- obj->notouching = 42;
- obj->saved_error = g_error_new_literal (MY_OBJECT_ERROR,
- MY_OBJECT_ERROR_FOO, "this method always loses");
-}
-
-static void
-my_object_class_init (MyObjectClass *mobject_class)
-{
- GObjectClass *gobject_class = G_OBJECT_CLASS (mobject_class);
-
- dbus_g_object_type_install_info (MY_TYPE_OBJECT,
- &dbus_glib_my_object_object_info);
-
- gobject_class->finalize = my_object_finalize;
- gobject_class->set_property = my_object_set_property;
- gobject_class->get_property = my_object_get_property;
-
- g_object_class_install_property (gobject_class,
- PROP_THIS_IS_A_STRING,
- g_param_spec_string ("this_is_a_string",
- _("Sample string"),
- _("Example of a string property"),
- "default value",
- G_PARAM_READWRITE));
- g_object_class_install_property (gobject_class,
- PROP_NO_TOUCHING,
- g_param_spec_uint ("no_touching",
- _("Don't touch"),
- _("Example of a readonly property (for export)"),
- 0, 100, 42,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (gobject_class,
- PROP_SUPER_STUDLY,
- g_param_spec_double ("super-studly",
- _("In Studly Caps"),
- _("Example of a StudlyCaps property"),
- 0, 256, 128,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (gobject_class,
- PROP_SHOULD_BE_HIDDEN,
- g_param_spec_boolean ("should-be-hidden",
- _("A non-exported property"),
- _("Example of a property we don't want exported"),
- FALSE,
- G_PARAM_READWRITE));
-
- signals[FROBNICATE] =
- g_signal_new ("frobnicate",
- G_OBJECT_CLASS_TYPE (mobject_class),
- G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
- 0,
- NULL, NULL,
- g_cclosure_marshal_VOID__INT,
- G_TYPE_NONE, 1, G_TYPE_INT);
-
- signals[OBJECTIFIED] =
- g_signal_new ("objectified",
- G_OBJECT_CLASS_TYPE (mobject_class),
- G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
- 0,
- NULL, NULL,
- g_cclosure_marshal_VOID__OBJECT,
- G_TYPE_NONE, 1, G_TYPE_OBJECT);
-
- signals[SIG0] =
- g_signal_new ("sig0",
- G_OBJECT_CLASS_TYPE (mobject_class),
- G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
- 0,
- NULL, NULL, NULL,
- G_TYPE_NONE, 3, G_TYPE_STRING, G_TYPE_INT, G_TYPE_STRING);
-
- signals[SIG1] =
- g_signal_new ("sig1",
- G_OBJECT_CLASS_TYPE (mobject_class),
- G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
- 0,
- NULL, NULL, NULL,
- G_TYPE_NONE, 2, G_TYPE_STRING, G_TYPE_VALUE);
-
- signals[SIG2] =
- g_signal_new ("sig2",
- G_OBJECT_CLASS_TYPE (mobject_class),
- G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
- 0,
- NULL, NULL,
- g_cclosure_marshal_VOID__BOXED,
- G_TYPE_NONE, 1, DBUS_TYPE_G_STRING_STRING_HASHTABLE);
-}
-
-GQuark
-my_object_error_quark (void)
-{
- static GQuark quark = 0;
- if (!quark)
- quark = g_quark_from_static_string ("my_object_error");
-
- return quark;
-}
-
-/* This should really be standard. */
-#define ENUM_ENTRY(NAME, DESC) { NAME, "" #NAME "", DESC }
-
-GType
-my_object_error_get_type (void)
-{
- static GType etype = 0;
-
- if (etype == 0)
- {
- static const GEnumValue values[] =
- {
-
- ENUM_ENTRY (MY_OBJECT_ERROR_FOO, "Foo"),
- ENUM_ENTRY (MY_OBJECT_ERROR_BAR, "Bar"),
- ENUM_ENTRY (MY_OBJECT_ERROR_MULTI_WORD, "Multi-word"),
- ENUM_ENTRY (MY_OBJECT_ERROR_UNDER_SCORE, "Under_score"),
- { 0, 0, 0 }
- };
-
- etype = g_enum_register_static ("MyObjectError", values);
- }
-
- return etype;
-}
-
-gboolean
-my_object_do_nothing (MyObject *obj, GError **error)
-{
- return TRUE;
-}
-
-gboolean
-my_object_increment (MyObject *obj, gint32 x, gint32 *ret, GError **error)
-{
- *ret = x +1;
- return TRUE;
-}
-
-gint32
-my_object_increment_retval (MyObject *obj, gint32 x)
-{
- return x + 1;
-}
-
-gint32
-my_object_increment_retval_error (MyObject *obj, gint32 x, GError **error)
-{
- if (x + 1 > 10)
- {
- g_set_error (error,
- MY_OBJECT_ERROR,
- MY_OBJECT_ERROR_FOO,
- "%s",
- "x is bigger than 9");
- return FALSE;
- }
- return x + 1;
-}
-
-void
-my_object_save_error (MyObject *obj,
- GQuark domain,
- gint code,
- const gchar *message)
-{
- g_clear_error (&obj->saved_error);
- g_set_error_literal (&obj->saved_error, domain, code, message);
-}
-
-gboolean
-my_object_throw_error (MyObject *obj, GError **error)
-{
- g_set_error_literal (error, obj->saved_error->domain,
- obj->saved_error->code, obj->saved_error->message);
- return FALSE;
-}
-
-gboolean
-my_object_throw_unregistered_error (MyObject *obj, GError **error)
-{
- /* Unregistered errors shouldn't cause a dbus abort. See
- * https://bugzilla.redhat.com/show_bug.cgi?id=581794
- *
- * This is arguably invalid usage - a domain of 0 (which stringifies
- * to NULL) is meaningless. (See GNOME#660731.)
- *
- * We can't just use my_object_save_error() and ThrowError() for
- * this, because g_error_new() is stricter about the domain than
- * g_error_new_valist(). Perhaps this method should be removed entirely,
- * though.
- */
- g_set_error (error, 0, 0,
- "%s",
- "this method always loses more");
- return FALSE;
-}
-
-
-gboolean
-my_object_uppercase (MyObject *obj, const char *str, char **ret, GError **error)
-{
- *ret = g_ascii_strup (str, -1);
- return TRUE;
-}
-
-gboolean
-my_object_many_args (MyObject *obj, guint32 x, const char *str, double trouble, double *d_ret, char **str_ret, GError **error)
-{
- *d_ret = trouble + (x * 2);
- *str_ret = g_ascii_strup (str, -1);
- return TRUE;
-}
-
-gboolean
-my_object_many_return (MyObject *obj, guint32 *arg0, char **arg1, gint32 *arg2, guint32 *arg3, guint32 *arg4, const char **arg5, GError **error)
-{
- *arg0 = 42;
- *arg1 = g_strdup ("42");
- *arg2 = -67;
- *arg3 = 2;
- *arg4 = 26;
- *arg5 = "hello world"; /* Annotation specifies as const */
- return TRUE;
-}
-
-gboolean
-my_object_stringify (MyObject *obj, GValue *value, char **ret, GError **error)
-{
- GValue valstr = {0, };
-
- g_value_init (&valstr, G_TYPE_STRING);
- if (!g_value_transform (value, &valstr))
- {
- g_set_error (error,
- MY_OBJECT_ERROR,
- MY_OBJECT_ERROR_FOO,
- "couldn't transform value");
- return FALSE;
- }
- *ret = g_value_dup_string (&valstr);
- g_value_unset (&valstr);
- return TRUE;
-}
-
-gboolean
-my_object_unstringify (MyObject *obj, const char *str, GValue *value, GError **error)
-{
- if (str[0] == '\0' || !g_ascii_isdigit (str[0])) {
- g_value_init (value, G_TYPE_STRING);
- g_value_set_string (value, str);
- } else {
- g_value_init (value, G_TYPE_INT);
- g_value_set_int (value, (int) g_ascii_strtoull (str, NULL, 10));
- }
- return TRUE;
-}
-
-gboolean
-my_object_recursive1 (MyObject *obj, GArray *array, guint32 *len_ret, GError **error)
-{
- *len_ret = array->len;
- return TRUE;
-}
-
-gboolean
-my_object_recursive2 (MyObject *obj, guint32 reqlen, GArray **ret, GError **error)
-{
- guint32 val;
- GArray *array;
-
- array = g_array_new (FALSE, TRUE, sizeof (guint32));
-
- while (reqlen > 0) {
- val = 42;
- g_array_append_val (array, val);
- val = 26;
- g_array_append_val (array, val);
- reqlen--;
- }
- val = 2;
- g_array_append_val (array, val);
- *ret = array;
- return TRUE;
-}
-
-gboolean
-my_object_many_uppercase (MyObject *obj, const char * const *in, char ***out, GError **error)
-{
- int len;
- int i;
-
- len = g_strv_length ((char**) in);
-
- *out = g_new0 (char *, len + 1);
- for (i = 0; i < len; i++)
- {
- (*out)[i] = g_ascii_strup (in[i], -1);
- }
- (*out)[i] = NULL;
-
- return TRUE;
-}
-
-static void
-hash_foreach_stringify (gpointer key, gpointer val, gpointer user_data)
-{
- const char *keystr = key;
- const GValue *value = val;
- GValue *sval;
- GHashTable *ret = user_data;
-
- sval = g_new0 (GValue, 1);
- g_value_init (sval, G_TYPE_STRING);
- if (!g_value_transform (value, sval))
- g_assert_not_reached ();
-
- g_hash_table_insert (ret, g_strdup (keystr), sval);
-}
-
-static void
-unset_and_free_gvalue (gpointer val)
-{
- g_value_unset (val);
- g_free (val);
-}
-
-gboolean
-my_object_many_stringify (MyObject *obj, GHashTable /* char * -> GValue * */ *vals, GHashTable /* char * -> GValue * */ **ret, GError **error)
-{
- *ret = g_hash_table_new_full (g_str_hash, g_str_equal,
- g_free, unset_and_free_gvalue);
- g_hash_table_foreach (vals, hash_foreach_stringify, *ret);
- return TRUE;
-}
-
-gboolean
-my_object_rec_arrays (MyObject *obj, GPtrArray *in, GPtrArray **ret, GError **error)
-{
- char **strs;
- GArray *ints;
- guint v_UINT;
-
- if (in->len != 2)
- {
- g_set_error (error,
- MY_OBJECT_ERROR,
- MY_OBJECT_ERROR_FOO,
- "invalid array len");
- return FALSE;
- }
-
- strs = g_ptr_array_index (in, 0);
- if (!*strs || strcmp (*strs, "foo"))
- {
- g_set_error (error,
- MY_OBJECT_ERROR,
- MY_OBJECT_ERROR_FOO,
- "invalid string 0");
- return FALSE;
- }
- strs++;
- if (!*strs || strcmp (*strs, "bar"))
- {
- g_set_error (error,
- MY_OBJECT_ERROR,
- MY_OBJECT_ERROR_FOO,
- "invalid string 1");
- return FALSE;
- }
- strs++;
- if (*strs)
- {
- g_set_error (error,
- MY_OBJECT_ERROR,
- MY_OBJECT_ERROR_FOO,
- "invalid string array len in pos 0");
- return FALSE;
- }
- strs = g_ptr_array_index (in, 1);
- if (!*strs || strcmp (*strs, "baz"))
- {
- g_set_error (error,
- MY_OBJECT_ERROR,
- MY_OBJECT_ERROR_FOO,
- "invalid string 0");
- return FALSE;
- }
- strs++;
- if (!*strs || strcmp (*strs, "whee"))
- {
- g_set_error (error,
- MY_OBJECT_ERROR,
- MY_OBJECT_ERROR_FOO,
- "invalid string 1");
- return FALSE;
- }
- strs++;
- if (!*strs || strcmp (*strs, "moo"))
- {
- g_set_error (error,
- MY_OBJECT_ERROR,
- MY_OBJECT_ERROR_FOO,
- "invalid string 2");
- return FALSE;
- }
- strs++;
- if (*strs)
- {
- g_set_error (error,
- MY_OBJECT_ERROR,
- MY_OBJECT_ERROR_FOO,
- "invalid string array len in pos 1");
- return FALSE;
- }
-
- *ret = g_ptr_array_new ();
-
- ints = g_array_new (TRUE, TRUE, sizeof (guint));
- v_UINT = 10;
- g_array_append_val (ints, v_UINT);
- v_UINT = 42;
- g_array_append_val (ints, v_UINT);
- v_UINT = 27;
- g_array_append_val (ints, v_UINT);
- g_ptr_array_add (*ret, ints);
-
- ints = g_array_new (TRUE, TRUE, sizeof (guint));
- v_UINT = 30;
- g_array_append_val (ints, v_UINT);
- g_ptr_array_add (*ret, ints);
- return TRUE;
-}
-
-gboolean
-my_object_objpath (MyObject *obj, const char *incoming, const char **outgoing, GError **error)
-{
- if (strcmp (incoming, "/org/freedesktop/DBus/GLib/Tests/MyTestObject"))
- {
- g_set_error (error,
- MY_OBJECT_ERROR,
- MY_OBJECT_ERROR_FOO,
- "invalid incoming object");
- return FALSE;
- }
- *outgoing = "/org/freedesktop/DBus/GLib/Tests/MyTestObject2";
- return TRUE;
-}
-
-gboolean
-my_object_get_objs (MyObject *obj, GPtrArray **objs, GError **error)
-{
- *objs = g_ptr_array_new ();
-
- g_ptr_array_add (*objs, g_strdup ("/org/freedesktop/DBus/GLib/Tests/MyTestObject"));
- g_ptr_array_add (*objs, g_strdup ("/org/freedesktop/DBus/GLib/Tests/MyTestObject2"));
-
- return TRUE;
-}
-
-static void
-hash_foreach (gpointer key, gpointer val, gpointer user_data)
-{
- const char *keystr = key;
- const char *valstr = val;
- guint *count = user_data;
-
- *count += (strlen (keystr) + strlen (valstr));
- g_print ("%s -> %s\n", keystr, valstr);
-}
-
-gboolean
-my_object_str_hash_len (MyObject *obj, GHashTable *table, guint *len, GError **error)
-{
- *len = 0;
- g_hash_table_foreach (table, hash_foreach, len);
- return TRUE;
-}
-
-gboolean
-my_object_send_car (MyObject *obj, GValueArray *invals, GValueArray **outvals, GError **error)
-{
- if (invals->n_values != 3
- || G_VALUE_TYPE (g_value_array_get_nth (invals, 0)) != G_TYPE_STRING
- || G_VALUE_TYPE (g_value_array_get_nth (invals, 1)) != G_TYPE_UINT
- || G_VALUE_TYPE (g_value_array_get_nth (invals, 2)) != G_TYPE_VALUE)
- {
- g_set_error (error,
- MY_OBJECT_ERROR,
- MY_OBJECT_ERROR_FOO,
- "invalid incoming values");
- return FALSE;
- }
- *outvals = g_value_array_new (2);
- g_value_array_append (*outvals, NULL);
- g_value_init (g_value_array_get_nth (*outvals, (*outvals)->n_values - 1), G_TYPE_UINT);
- g_value_set_uint (g_value_array_get_nth (*outvals, (*outvals)->n_values - 1),
- g_value_get_uint (g_value_array_get_nth (invals, 1)) + 1);
- g_value_array_append (*outvals, NULL);
- g_value_init (g_value_array_get_nth (*outvals, (*outvals)->n_values - 1), DBUS_TYPE_G_OBJECT_PATH);
- g_value_set_boxed (g_value_array_get_nth (*outvals, (*outvals)->n_values - 1),
- g_strdup ("/org/freedesktop/DBus/GLib/Tests/MyTestObject2"));
- return TRUE;
-}
-
-gboolean
-my_object_get_hash (MyObject *obj, GHashTable **ret, GError **error)
-{
- GHashTable *table;
-
- table = g_hash_table_new (g_str_hash, g_str_equal);
- g_hash_table_insert (table, "foo", "bar");
- g_hash_table_insert (table, "baz", "whee");
- g_hash_table_insert (table, "cow", "crack");
- *ret = table;
- return TRUE;
-}
-
-gboolean
-my_object_increment_val (MyObject *obj, GError **error)
-{
- obj->val++;
- return TRUE;
-}
-
-gboolean
-my_object_get_val (MyObject *obj, guint *ret, GError **error)
-{
- *ret = obj->val;
- return TRUE;
-}
-
-gboolean
-my_object_get_value (MyObject *obj, guint *ret, GError **error)
-{
- *ret = obj->val;
- return TRUE;
-}
-
-gboolean
-my_object_echo_variant (MyObject *obj, GValue *variant, GValue *ret, GError **error)
-{
- GType t;
- t = G_VALUE_TYPE(variant);
- g_value_init (ret, t);
- g_value_copy (variant, ret);
-
- return TRUE;
-}
-
-gboolean
-my_object_echo_signature (MyObject *obj, const gchar *in, gchar **out, GError **error)
-{
- *out = g_strdup (in);
- return TRUE;
-}
-
-gboolean
-my_object_process_variant_of_array_of_ints123 (MyObject *obj, GValue *variant, GError **error)
-{
- GArray *array;
- int i;
- int j;
-
- j = 0;
-
- array = (GArray *)g_value_get_boxed (variant);
-
- for (i = 0; i <= 2; i++)
- {
- j = g_array_index (array, int, i);
- if (j != i + 1)
- goto error;
- }
-
- return TRUE;
-
-error:
- *error = g_error_new (MY_OBJECT_ERROR,
- MY_OBJECT_ERROR_FOO,
- "Error decoding a variant of type ai (i + 1 = %i, j = %i)",
- i, j + 1);
- return FALSE;
-}
-
-
-typedef struct _HashAndString HashAndString;
-
-struct _HashAndString
-{
- GHashTable *hash;
- gchar* string;
-};
-
-static void
-hash_foreach_prepend_string (gpointer key, gpointer val, gpointer user_data)
-{
- HashAndString *data = (HashAndString*) user_data;
- gchar *in = (gchar*) val;
- g_hash_table_insert (data->hash, g_strdup ((gchar*) key),
- g_strjoin (" ", data->string, in, NULL));
-}
-
-
-static void
-hash_foreach_mangle_dict_of_strings (gpointer key, gpointer val, gpointer user_data)
-{
- GHashTable *out = (GHashTable*) user_data;
- GHashTable *in_dict = (GHashTable *) val;
- HashAndString *data = g_new0 (HashAndString, 1);
-
- data->string = (gchar*) key;
- data->hash = g_hash_table_new_full (g_str_hash, g_str_equal,
- g_free, g_free);
- g_hash_table_foreach (in_dict, hash_foreach_prepend_string, data);
-
- g_hash_table_insert(out, g_strdup ((gchar*) key), data->hash);
-}
-
-gboolean
-my_object_dict_of_dicts (MyObject *obj, GHashTable *in,
- GHashTable **out, GError **error)
-{
- *out = g_hash_table_new_full (g_str_hash, g_str_equal,
- (GDestroyNotify) g_free,
- (GDestroyNotify) g_hash_table_destroy);
- g_hash_table_foreach (in, hash_foreach_mangle_dict_of_strings, *out);
- return TRUE;
-}
-
-void
-my_object_dict_of_sigs (MyObject *obj,
- GHashTable *dict,
- DBusGMethodInvocation *context)
-{
- dbus_g_method_return (context, dict);
-}
-
-void
-my_object_dict_of_objs (MyObject *obj,
- GHashTable *dict,
- DBusGMethodInvocation *context)
-{
- dbus_g_method_return (context, dict);
-}
-
-gboolean
-my_object_emit_frobnicate (MyObject *obj, GError **error)
-{
- g_signal_emit (obj, signals[FROBNICATE], 0, 42);
- return TRUE;
-}
-
-gboolean
-my_object_emit_signals (MyObject *obj, GError **error)
-{
- GValue val = {0, };
-
- g_signal_emit (obj, signals[SIG0], 0, "foo", 22, "moo");
-
- g_value_init (&val, G_TYPE_STRING);
- g_value_set_string (&val, "bar");
- g_signal_emit (obj, signals[SIG1], 0, "baz", &val);
- g_value_unset (&val);
-
- return TRUE;
-}
-
-gboolean
-my_object_emit_signal2 (MyObject *obj, GError **error)
-{
- GHashTable *table;
-
- table = g_hash_table_new (g_str_hash, g_str_equal);
- g_hash_table_insert (table, "baz", "cow");
- g_hash_table_insert (table, "bar", "foo");
- g_signal_emit (obj, signals[SIG2], 0, table);
- g_hash_table_destroy (table);
- return TRUE;
-}
-
-typedef struct {
- gint32 x;
- DBusGMethodInvocation *context;
-} IncrementData;
-
-static gboolean
-do_async_increment (IncrementData *data)
-{
- gint32 newx = data->x + 1;
- dbus_g_method_return (data->context, newx);
- g_free (data);
- return FALSE;
-}
-
-void
-my_object_async_increment (MyObject *obj, gint32 x, DBusGMethodInvocation *context)
-{
- IncrementData *data = g_new0 (IncrementData, 1);
- data->x = x;
- data->context = context;
- g_idle_add ((GSourceFunc)do_async_increment, data);
-}
-
-typedef struct {
- GError *error;
- DBusGMethodInvocation *context;
-} ErrorData;
-
-static gboolean
-do_async_error (ErrorData *data)
-{
- dbus_g_method_return_error (data->context, data->error);
- g_error_free (data->error);
- g_free (data);
- return FALSE;
-}
-
-void
-my_object_async_throw_error (MyObject *obj, DBusGMethodInvocation *context)
-{
- ErrorData *data = g_new0 (ErrorData, 1);
-
- data->error = g_error_copy (obj->saved_error);
- data->context = context;
- g_idle_add ((GSourceFunc) do_async_error, data);
-}
-
-gboolean
-my_object_unsafe_disable_legacy_property_access (MyObject *obj,
- GError **error)
-{
- dbus_glib_global_set_disable_legacy_property_access ();
- return TRUE;
-}
-
-extern GMainLoop *loop;
-
-gboolean
-my_object_terminate (MyObject *obj, GError **error)
-{
- g_main_loop_quit (loop);
- return TRUE;
-}
-
-void
-my_object_emit_objectified (MyObject *obj,
- GObject *other)
-{
- g_signal_emit (obj, signals[OBJECTIFIED], 0, other);
-}
diff --git a/test/core/my-object.h b/test/core/my-object.h
deleted file mode 100644
index 416610e..0000000
--- a/test/core/my-object.h
+++ /dev/null
@@ -1,127 +0,0 @@
-#ifndef __MY_OBJECT_H__
-#define __MY_OBJECT_H__
-
-#include <glib-object.h>
-#include <dbus/dbus-glib.h>
-
-typedef struct MyObject MyObject;
-typedef struct MyObjectClass MyObjectClass;
-
-GType my_object_get_type (void);
-
-struct MyObject
-{
- GObject parent;
- GError *saved_error;
- char *this_is_a_string;
- guint notouching;
- guint val;
- gdouble super_studly;
- gboolean should_be_hidden;
-};
-
-struct MyObjectClass
-{
- GObjectClass parent;
-};
-
-#define MY_TYPE_OBJECT (my_object_get_type ())
-#define MY_OBJECT(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), MY_TYPE_OBJECT, MyObject))
-#define MY_OBJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MY_TYPE_OBJECT, MyObjectClass))
-#define MY_IS_OBJECT(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), MY_TYPE_OBJECT))
-#define MY_IS_OBJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MY_TYPE_OBJECT))
-#define MY_OBJECT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MY_TYPE_OBJECT, MyObjectClass))
-
-typedef enum
-{
- MY_OBJECT_ERROR_FOO,
- MY_OBJECT_ERROR_BAR,
- MY_OBJECT_ERROR_MULTI_WORD,
- MY_OBJECT_ERROR_UNDER_SCORE
-} MyObjectError;
-
-#define MY_OBJECT_ERROR (my_object_error_quark ())
-#define MY_TYPE_ERROR (my_object_error_get_type ())
-
-GQuark my_object_error_quark (void);
-GType my_object_error_get_type (void);
-
-gboolean my_object_do_nothing (MyObject *obj, GError **error);
-
-gboolean my_object_increment (MyObject *obj, gint32 x, gint32 *ret, GError **error);
-
-gint32 my_object_increment_retval (MyObject *obj, gint32 x);
-
-gint32 my_object_increment_retval_error (MyObject *obj, gint32 x, GError **error);
-
-gboolean my_object_throw_error (MyObject *obj, GError **error);
-gboolean my_object_throw_not_supported (MyObject *obj, GError **error);
-gboolean my_object_throw_error_multi_word (MyObject *obj, GError **error);
-gboolean my_object_throw_unregistered_error (MyObject *obj, GError **error);
-
-gboolean my_object_uppercase (MyObject *obj, const char *str, char **ret, GError **error);
-
-gboolean my_object_many_args (MyObject *obj, guint32 x, const char *str, double trouble, double *d_ret, char **str_ret, GError **error);
-
-gboolean my_object_many_return (MyObject *obj, guint32 *arg0, char **arg1, gint32 *arg2, guint32 *arg3, guint32 *arg4, const char **arg5, GError **error);
-
-gboolean my_object_recursive1 (MyObject *obj, GArray *array, guint32 *len_ret, GError **error);
-gboolean my_object_recursive2 (MyObject *obj, guint32 reqlen, GArray **array, GError **error);
-
-gboolean my_object_many_stringify (MyObject *obj, GHashTable *vals, GHashTable **ret, GError **error);
-
-gboolean my_object_rec_arrays (MyObject *obj, GPtrArray *in, GPtrArray **ret, GError **error);
-
-gboolean my_object_objpath (MyObject *obj, const char *in, const char **arg1, GError **error);
-
-gboolean my_object_get_objs (MyObject *obj, GPtrArray **objs, GError **error);
-
-gboolean my_object_stringify (MyObject *obj, GValue *value, char **ret, GError **error);
-gboolean my_object_unstringify (MyObject *obj, const char *str, GValue *value, GError **error);
-
-gboolean my_object_many_uppercase (MyObject *obj, const char * const *in, char ***out, GError **error);
-
-gboolean my_object_str_hash_len (MyObject *obj, GHashTable *table, guint *len, GError **error);
-
-gboolean my_object_send_car (MyObject *obj, GValueArray *invals, GValueArray **outvals, GError **error);
-
-gboolean my_object_get_hash (MyObject *obj, GHashTable **table, GError **error);
-
-gboolean my_object_increment_val (MyObject *obj, GError **error);
-
-gboolean my_object_get_val (MyObject *obj, guint *ret, GError **error);
-
-gboolean my_object_get_value (MyObject *obj, guint *ret, GError **error);
-
-gboolean my_object_emit_signals (MyObject *obj, GError **error);
-gboolean my_object_emit_signal2 (MyObject *obj, GError **error);
-
-gboolean my_object_emit_frobnicate (MyObject *obj, GError **error);
-
-gboolean my_object_echo_variant (MyObject *obj, GValue *variant, GValue *ret, GError **error);
-gboolean my_object_echo_signature (MyObject *obj, const gchar *in, gchar **out, GError **error);
-
-gboolean my_object_process_variant_of_array_of_ints123 (MyObject *obj, GValue *variant, GError **error);
-
-gboolean my_object_dict_of_dicts (MyObject *obj, GHashTable *dict, GHashTable **ret, GError **error);
-
-void my_object_dict_of_sigs (MyObject *obj, GHashTable *dict, DBusGMethodInvocation *ctx);
-
-void my_object_dict_of_objs (MyObject *obj, GHashTable *dict, DBusGMethodInvocation *ctx);
-
-gboolean my_object_terminate (MyObject *obj, GError **error);
-
-void my_object_async_increment (MyObject *obj, gint32 x, DBusGMethodInvocation *context);
-
-void my_object_async_throw_error (MyObject *obj, DBusGMethodInvocation *context);
-
-gboolean my_object_unsafe_disable_legacy_property_access (MyObject *obj,
- GError **error);
-
-void my_object_emit_objectified (MyObject *obj, GObject *other);
-
-/* Not a D-Bus method. */
-void my_object_save_error (MyObject *obj, GQuark domain, gint code,
- const gchar *message);
-
-#endif
diff --git a/test/core/peer-client.c b/test/core/peer-client.c
deleted file mode 100644
index 9a944f1..0000000
--- a/test/core/peer-client.c
+++ /dev/null
@@ -1,140 +0,0 @@
-#include <config.h>
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <dbus/dbus.h>
-#include <dbus/dbus-glib.h>
-
-static GMainLoop *loop;
-static guint exit_timeout = 0;
-static int n_times_frobnicate_received = 0;
-static gboolean terminating = FALSE, terminated = FALSE;
-
-static void
-lose (const char *str, ...)
-{
- va_list args;
- va_start (args, str);
-
- vfprintf (stderr, str, args);
- fputc ('\n', stderr);
-
- va_end (args);
- exit (1);
-}
-
-static void
-lose_gerror (const char *prefix, GError *error)
-{
- if (error->domain == DBUS_GERROR && error->code == DBUS_GERROR_REMOTE_EXCEPTION)
- lose ("%s (%s): %s", prefix, dbus_g_error_get_name (error),
- error->message);
- else
- lose ("%s: %s", prefix, error->message);
-}
-
-static gboolean
-timed_exit (gpointer loop)
-{
- g_print ("timed exit!\n");
- g_main_loop_quit (loop);
- return TRUE;
-}
-
-static void
-frobnicate_signal_handler (DBusGProxy *proxy, int val, void *user_data)
-{
- n_times_frobnicate_received += 1;
-
- g_assert (val == 42);
-
- g_main_loop_quit (loop);
- g_source_remove (exit_timeout);
-}
-
-static void
-destroy_cb (DBusGProxy *proxy, gpointer user_data)
-{
- if (!terminating) {
- lose ("Proxy destroyed when it shouldn't have been");
- } else {
- terminated = TRUE;
- g_main_loop_quit (loop);
- g_source_remove (exit_timeout);
- }
-}
-
-int
-main (int argc, char **argv)
-{
- GError *error = NULL;
- DBusGConnection *conn;
- DBusGProxy *proxy;
- guint32 v_UINT32_2;
- char *addrbuf;
- gsize lineoffset;
- GIOChannel *io;
-
- dbus_g_thread_init ();
- g_type_init ();
-
- io = g_io_channel_unix_new (0);
- if (!g_io_channel_read_line (io, &addrbuf, NULL, &lineoffset, &error))
- lose_gerror ("failed to read address from stdin", error);
- /* trim newline */
- addrbuf[lineoffset] = '\0';
-
- loop = g_main_loop_new (NULL, TRUE);
-
- conn = dbus_g_connection_open (addrbuf, &error);
- if (!conn)
- g_error ("Cannot open connection: %s", error->message);
-
- proxy = dbus_g_proxy_new_for_peer (conn, "/", "org.freedesktop.DBus.GLib.Tests.MyObject");
- g_assert (proxy);
-
-
- if (!dbus_g_proxy_call (proxy, "DoNothing", &error, G_TYPE_INVALID, G_TYPE_INVALID))
- lose_gerror ("Failed to complete DoNothing call", error);
-
-
- if (!dbus_g_proxy_call (proxy, "Increment", &error,
- G_TYPE_UINT, 42,
- G_TYPE_INVALID,
- G_TYPE_UINT, &v_UINT32_2,
- G_TYPE_INVALID))
- lose_gerror ("Failed to complete Increment call", error);
- if (v_UINT32_2 != 43)
- lose ("Increment call returned %d, should be 43", v_UINT32_2);
-
-
- n_times_frobnicate_received = 0;
- dbus_g_proxy_add_signal (proxy, "Frobnicate", G_TYPE_INT, G_TYPE_INVALID);
- dbus_g_proxy_connect_signal (proxy, "Frobnicate",
- G_CALLBACK (frobnicate_signal_handler),
- NULL, NULL);
- g_signal_connect (G_OBJECT (proxy), "destroy",
- G_CALLBACK (destroy_cb),
- NULL);
-
- if (!dbus_g_proxy_call (proxy, "EmitFrobnicate", &error, G_TYPE_INVALID, G_TYPE_INVALID))
- lose_gerror ("Failed to complete EmitFrobnicate call", error);
- exit_timeout = g_timeout_add (5000, timed_exit, loop);
- g_main_loop_run (loop);
- if (n_times_frobnicate_received != 1)
- lose ("Frobnicate signal received %d times, should have been 1", n_times_frobnicate_received);
-
- terminating = TRUE;
- if (!dbus_g_proxy_call (proxy, "Terminate", &error, G_TYPE_INVALID, G_TYPE_INVALID))
- lose_gerror ("Failed to complete Terminate call", error);
- exit_timeout = g_timeout_add (5000, timed_exit, loop);
- g_main_loop_run (loop);
- if (!terminated)
- lose ("Proxy didn't destroy when peer terminated");
-
- g_main_loop_unref (loop);
-
- return 0;
-}
diff --git a/test/core/peer-on-bus.c b/test/core/peer-on-bus.c
deleted file mode 100644
index a1eb231..0000000
--- a/test/core/peer-on-bus.c
+++ /dev/null
@@ -1,148 +0,0 @@
-/* Regression test for object registration and unregistration
- *
- * Copyright © 2009 Collabora Ltd. <http://www.collabora.co.uk/>
- * Copyright © 2009-2011 Nokia Corporation
- *
- * In preparation for dbus-glib relicensing (if it ever happens), this file is
- * licensed under (at your option) either the AFL v2.1, the GPL v2 or later,
- * or an MIT/X11-style license:
- *
- * Licensed under the Academic Free License version 2.1
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * Permission is hereby granted, free of charge, to any person
- * obtaining a copy of this software and associated documentation
- * files (the "Software"), to deal in the Software without
- * restriction, including without limitation the rights to use, copy,
- * modify, merge, publish, distribute, sublicense, and/or sell copies
- * of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
- * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
- * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- */
-
-#include <config.h>
-
-#include <dbus/dbus-glib.h>
-#include <dbus/dbus-glib-lowlevel.h>
-
-#include "dbus-gmain/tests/util.h"
-
-GMainLoop *loop = NULL;
-
-typedef struct {
- DBusGConnection *bus;
- DBusGConnection *bus2;
-} Fixture;
-
-static void
-setup (Fixture *f,
- gconstpointer path_to_use)
-{
- f->bus = dbus_g_bus_get_private (DBUS_BUS_SESSION, NULL, NULL);
- g_assert (f->bus != NULL);
-
- f->bus2 = dbus_g_bus_get_private (DBUS_BUS_SESSION, NULL, NULL);
- g_assert (f->bus2 != NULL);
-}
-
-static void
-teardown (Fixture *f,
- gconstpointer test_data G_GNUC_UNUSED)
-{
- if (f->bus != NULL)
- {
- test_run_until_disconnected (dbus_g_connection_get_connection (f->bus), NULL);
- dbus_g_connection_unref (f->bus);
- }
-
- if (f->bus2 != NULL)
- {
- test_run_until_disconnected (dbus_g_connection_get_connection (f->bus2), NULL);
- dbus_g_connection_unref (f->bus2);
- }
-
- dbus_shutdown ();
-}
-
-static void
-destroy_cb (DBusGProxy *proxy G_GNUC_UNUSED,
- gpointer user_data)
-{
- gboolean *destroyed = user_data;
-
- *destroyed = TRUE;
-}
-
-static void
-test_name_owner_changed (Fixture *f,
- gconstpointer test_data G_GNUC_UNUSED)
-{
- DBusGProxy *peer;
- DBusGProxy *named;
- gboolean destroyed = FALSE;
-
- g_test_bug ("41126");
-
- /* bus has a proxy for bus2... */
- named = dbus_g_proxy_new_for_name (f->bus,
- dbus_bus_get_unique_name (dbus_g_connection_get_connection (f->bus2)),
- "/", "org.freedesktop.DBus.Peer");
- /* ... and also a proxy for the peer (i.e. the dbus-daemon) */
- peer = dbus_g_proxy_new_for_peer (f->bus, "/", "org.freedesktop.DBus.Peer");
-
- g_signal_connect (G_OBJECT (named), "destroy", G_CALLBACK (destroy_cb),
- &destroyed);
-
- /* Disconnect bus2, to provoke a NameOwnerChanged signal on bus */
- test_run_until_disconnected (dbus_g_connection_get_connection (f->bus2), NULL);
- dbus_g_connection_unref (f->bus2);
- f->bus2 = NULL;
-
- /* Wait for that NameOwnerChanged to be processed */
- while (!destroyed)
- g_main_context_iteration (NULL, TRUE);
-
- g_signal_handlers_disconnect_by_func (named, destroy_cb, &destroyed);
-
- /* The first part of the bug was that we'd never get here, because checking
- * whether 'peer' was affected by the NameOwnerChanged caused a NULL
- * dereference and segfault. If we get here, all is OK.
- *
- * The second part of the bug was that if the last proxy in existence was
- * for a peer, when it was unregistered there would be no owner_match_rules,
- * causing a crash. Unref named before peer, to exercise that. */
-
- g_object_unref (named);
- g_object_unref (peer);
-}
-
-int
-main (int argc, char **argv)
-{
- g_setenv ("DBUS_FATAL_WARNINGS", "1", TRUE);
- g_type_init ();
- g_log_set_always_fatal (G_LOG_LEVEL_WARNING | G_LOG_LEVEL_CRITICAL);
- dbus_g_type_specialized_init ();
- g_test_bug_base ("https://bugs.freedesktop.org/show_bug.cgi?id=");
- g_test_init (&argc, &argv, NULL);
-
- g_test_add ("/peer-on-bus/name-owner-changed", Fixture, NULL,
- setup, test_name_owner_changed, teardown);
-
- return g_test_run ();
-}
diff --git a/test/core/peer-server.c b/test/core/peer-server.c
deleted file mode 100644
index b44daac..0000000
--- a/test/core/peer-server.c
+++ /dev/null
@@ -1,59 +0,0 @@
-#include <config.h>
-
-#include <stdio.h>
-#include <stdlib.h>
-
-#include <dbus/dbus.h>
-#include <dbus/dbus-glib.h>
-#include <dbus/dbus-glib-lowlevel.h>
-
-#include "my-object.h"
-
-GMainLoop *loop;
-
-static void
-new_connection_func (DBusServer *server, DBusConnection *conn, gpointer user_data)
-{
- GObject *obj;
-
- obj = g_object_new (MY_TYPE_OBJECT, NULL);
-
- dbus_connection_ref (conn);
- dbus_connection_setup_with_g_main (conn, NULL);
-
- dbus_g_connection_register_g_object
- (dbus_connection_get_g_connection (conn), "/", obj);
-}
-
-int
-main (int argc, char **argv)
-{
- DBusError error;
- DBusServer *server;
- char *addr;
-
- dbus_error_init (&error);
-
- dbus_g_thread_init ();
- g_type_init ();
-
- loop = g_main_loop_new (NULL, TRUE);
-
- server = dbus_server_listen ("unix:tmpdir=/tmp", &error);
- if (!server)
- {
- g_warning ("Cannot create server: %s", error.message);
- return 1;
- }
- addr = dbus_server_get_address (server);
- fprintf (stdout, "%s\n", addr);
- fflush (stdout);
- free (addr);
- dbus_server_setup_with_g_main (server, NULL);
- dbus_server_set_new_connection_function (server, new_connection_func, NULL, NULL);
-
- g_main_loop_run (loop);
-
- g_main_loop_unref (loop);
- return 0;
-}
diff --git a/test/core/private.c b/test/core/private.c
deleted file mode 100644
index 30df437..0000000
--- a/test/core/private.c
+++ /dev/null
@@ -1,268 +0,0 @@
-/* Feature test for freedesktop.org #23633 - non-default main context
- *
- * Copyright © 2009 Collabora Ltd. <http://www.collabora.co.uk/>
- * Copyright © 2009-2011 Nokia Corporation
- *
- * In preparation for dbus-glib relicensing (if it ever happens), this file is
- * licensed under (at your option) either the AFL v2.1, the GPL v2 or later,
- * or an MIT/X11-style license:
- *
- * Licensed under the Academic Free License version 2.1
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * Permission is hereby granted, free of charge, to any person
- * obtaining a copy of this software and associated documentation
- * files (the "Software"), to deal in the Software without
- * restriction, including without limitation the rights to use, copy,
- * modify, merge, publish, distribute, sublicense, and/or sell copies
- * of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
- * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
- * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- */
-
-#include <dbus/dbus-glib.h>
-#include <dbus/dbus-glib-lowlevel.h>
-
-#include "my-object.h"
-
-/* MyObject needs this, but it doesn't do anything useful... */
-GMainLoop *loop = NULL;
-
-typedef struct {
- GMainContext *context;
- DBusGConnection *bus;
- GObject *object;
- DBusGProxy *proxy;
- DBusGProxyCall *call;
-
- gsize in_flight;
-} Fixture;
-
-static void
-call_cb (DBusGProxy *proxy,
- DBusGProxyCall *call,
- gpointer user_data)
-{
- Fixture *f = user_data;
-
- g_assert (proxy == f->proxy);
- g_assert (call == f->call);
-
- f->in_flight--;
-}
-
-static void
-frobnicate_cb (DBusGProxy *proxy,
- int arg,
- gpointer user_data)
-{
- Fixture *f = user_data;
-
- g_assert (proxy == f->proxy);
-
- f->in_flight--;
-
- g_assert_cmpint (arg, ==, 42);
-}
-
-static void
-setup (Fixture *f,
- gconstpointer path_to_use)
-{
- f->context = g_main_context_new ();
-
- f->in_flight = 0;
-
- f->bus = dbus_g_bus_get_private (DBUS_BUS_SESSION, f->context, NULL);
- g_assert (f->bus != NULL);
-
- f->object = g_object_new (MY_TYPE_OBJECT, NULL);
- g_assert (MY_IS_OBJECT (f->object));
- dbus_g_connection_register_g_object (f->bus, "/object",
- (GObject *) f->object);
-
- f->proxy = dbus_g_proxy_new_for_name (f->bus,
- dbus_bus_get_unique_name (dbus_g_connection_get_connection (f->bus)),
- "/object", "org.freedesktop.DBus.GLib.Tests.MyObject");
-
- dbus_g_proxy_add_signal (f->proxy, "Frobnicate", G_TYPE_INT, G_TYPE_INVALID);
- dbus_g_proxy_connect_signal (f->proxy, "Frobnicate",
- G_CALLBACK (frobnicate_cb), f, NULL);
-}
-
-static void
-teardown (Fixture *f,
- gconstpointer test_data G_GNUC_UNUSED)
-{
- if (f->proxy != NULL)
- {
- dbus_g_proxy_disconnect_signal (f->proxy, "Frobnicate",
- G_CALLBACK (frobnicate_cb), f);
-
- g_object_unref (f->proxy);
- }
-
- if (f->object != NULL)
- {
- dbus_g_connection_unregister_g_object (f->bus, f->object);
- g_object_unref (f->object);
- }
-
- if (f->bus != NULL)
- {
- dbus_connection_close (dbus_g_connection_get_connection (f->bus));
- dbus_g_connection_unref (f->bus);
- }
-
- if (f->context != NULL)
- g_main_context_unref (f->context);
-}
-
-static void
-test_call (Fixture *f,
- gconstpointer test_data G_GNUC_UNUSED)
-{
- guint i, iterations;
- double t;
-
- if (g_test_perf ())
- iterations = 100000;
- else
- iterations = 1000;
-
- g_test_timer_start ();
-
- for (i = 0; i < iterations; i++)
- {
- GError *error = NULL;
- guint result;
- gboolean ok;
-
- f->in_flight++;
- f->call = dbus_g_proxy_begin_call (f->proxy, "Increment",
- call_cb, f, NULL,
- G_TYPE_UINT, 666,
- G_TYPE_INVALID);
-
- while (f->in_flight)
- g_main_context_iteration (f->context, TRUE);
-
- ok = dbus_g_proxy_end_call (f->proxy, f->call, &error,
- G_TYPE_UINT, &result,
- G_TYPE_INVALID);
-
- g_assert_no_error (error);
- g_assert (ok);
- g_assert_cmpuint (result, ==, 667);
- }
-
- t = g_test_timer_elapsed ();
-
- g_test_maximized_result (t / iterations,
- "%f seconds / %u iterations = %f s**-1", t, iterations, t / iterations);
-}
-
-static void
-test_emit (Fixture *f,
- gconstpointer test_data G_GNUC_UNUSED)
-{
- guint i, iterations;
- double t;
-
- if (g_test_perf ())
- iterations = 100000;
- else
- iterations = 1000;
-
- g_test_timer_start ();
-
- for (i = 0; i < iterations; i++)
- {
- f->in_flight++;
-
- my_object_emit_frobnicate (MY_OBJECT (f->object), NULL);
-
- while (f->in_flight)
- g_main_context_iteration (f->context, TRUE);
- }
-
- t = g_test_timer_elapsed ();
-
- g_test_maximized_result (t / iterations,
- "%f seconds / %u iterations = %f s**-1", t, iterations, t / iterations);
-}
-
-static void
-test_timeout (Fixture *f,
- gconstpointer test_data G_GNUC_UNUSED)
-{
- guint i;
-
- for (i = 0; i < 100; i++)
- {
- GError *error = NULL;
- guint result;
- gboolean ok;
-
- f->in_flight++;
- /* AsyncIncrement doesn't return until the default main context
- * runs, and we're not letting it run, so this will time out after 1
- * millisecond */
- f->call = dbus_g_proxy_begin_call_with_timeout (f->proxy,
- "AsyncIncrement",
- call_cb, f, NULL, 1,
- G_TYPE_UINT, 666,
- G_TYPE_INVALID);
-
- while (f->in_flight)
- g_main_context_iteration (f->context, TRUE);
-
- ok = dbus_g_proxy_end_call (f->proxy, f->call, &error,
- G_TYPE_UINT, &result,
- G_TYPE_INVALID);
-
- g_assert_error (error, DBUS_GERROR, DBUS_GERROR_NO_REPLY);
- g_assert (!ok);
- g_clear_error (&error);
- }
-
- /* drain the queue of idles with replies (which will be ignored)
- * just so we don't leak them */
- while (g_main_context_pending (NULL))
- g_main_context_iteration (NULL, FALSE);
-
- while (g_main_context_pending (f->context))
- g_main_context_iteration (f->context, FALSE);
-}
-
-int
-main (int argc,
- char **argv)
-{
- g_type_init ();
- dbus_g_type_specialized_init ();
-
- g_test_init (&argc, &argv, NULL);
-
- g_test_add ("/private/call", Fixture, NULL, setup, test_call, teardown);
- g_test_add ("/private/emit", Fixture, NULL, setup, test_emit, teardown);
- g_test_add ("/private/timeout", Fixture, NULL, setup, test_timeout,
- teardown);
-
- return g_test_run ();
-}
diff --git a/test/core/proxy-noc.c b/test/core/proxy-noc.c
deleted file mode 100644
index 5c798ff..0000000
--- a/test/core/proxy-noc.c
+++ /dev/null
@@ -1,264 +0,0 @@
-/* Regression tests for DBusGProxy's NameOwnerChanged handling.
- *
- * Author: Simon McVittie <simon.mcvittie@collabora.co.uk>
- * Copyright © 2011 Nokia Corporation
- * Copyright © 2013 Collabora Ltd.
- *
- * Permission is hereby granted, free of charge, to any person
- * obtaining a copy of this software and associated documentation files
- * (the "Software"), to deal in the Software without restriction,
- * including without limitation the rights to use, copy, modify, merge,
- * publish, distribute, sublicense, and/or sell copies of the Software,
- * and to permit persons to whom the Software is furnished to do so,
- * subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-/* To compile outside dbus-glib:
- cc -otest-proxy-noc \
- `pkg-config --cflags --libs gobject-2.0 dbus-glib-1 dbus-1` \
- proxy-noc.c
- */
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <glib.h>
-#include <glib-object.h>
-
-#include <dbus/dbus-glib.h>
-#include <dbus/dbus-glib-lowlevel.h>
-
-#define WELL_KNOWN_NAME "com.example.AuthService"
-#define PATH "/"
-#define IFACE WELL_KNOWN_NAME
-#define AUTH_RESULT "AuthenticationResult"
-
-typedef struct {
- GError *error;
- DBusError dbus_error;
-
- DBusConnection *service_conn;
- DBusGConnection *service_gconn;
- DBusConnection *attacker_conn;
- DBusGConnection *attacker_gconn;
- DBusConnection *client_conn;
- DBusGConnection *client_gconn;
- DBusGProxy *proxy;
-
- GPtrArray *auth_results;
-} Fixture;
-
-static void oom (void) G_GNUC_NORETURN;
-
-static void
-oom (void)
-{
- g_error ("out of memory");
-}
-
-static void
-assert_no_error (const DBusError *e)
-{
- if (G_UNLIKELY (dbus_error_is_set (e)))
- g_error ("expected success but got error: %s: %s", e->name, e->message);
-}
-
-static void
-auth_result_cb (DBusGProxy *proxy,
- const gchar *res,
- gpointer user_data)
-{
- Fixture *f = user_data;
-
- g_assert (proxy == f->proxy);
- g_ptr_array_add (f->auth_results, g_strdup (res));
-}
-
-static void
-setup (Fixture *f,
- gconstpointer addr)
-{
- int ret;
-
- dbus_error_init (&f->dbus_error);
-
- /* A trusted service on the bus. (For this to be a vulnerability, it
- * would have to be the system bus.) */
- f->service_gconn = dbus_g_bus_get_private (DBUS_BUS_SESSION, NULL,
- &f->error);
- g_assert_no_error (f->error);
- g_assert (f->service_gconn != NULL);
- f->service_conn = dbus_g_connection_get_connection (f->service_gconn);
-
- /* An attacker that intends to pretend to be that service. */
- f->attacker_gconn = dbus_g_bus_get_private (DBUS_BUS_SESSION, NULL,
- &f->error);
- g_assert_no_error (f->error);
- g_assert (f->attacker_gconn != NULL);
- f->attacker_conn = dbus_g_connection_get_connection (f->attacker_gconn);
-
- /* The service owns a well-known name. */
- ret = dbus_bus_request_name (f->service_conn, WELL_KNOWN_NAME,
- DBUS_NAME_FLAG_DO_NOT_QUEUE, &f->dbus_error);
- assert_no_error (&f->dbus_error);
- g_assert_cmpint (ret, ==, DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER);
-
- /* The victim of the attack. */
- f->client_gconn = dbus_g_bus_get_private (DBUS_BUS_SESSION, NULL, &f->error);
- g_assert_no_error (f->error);
- g_assert (f->client_gconn != NULL);
- f->client_conn = dbus_g_connection_get_connection (f->client_gconn);
-
- f->proxy = dbus_g_proxy_new_for_name (f->client_gconn, WELL_KNOWN_NAME,
- PATH, IFACE);
- g_assert (DBUS_IS_G_PROXY (f->proxy));
-
- /* The proxy is listening for the signal. */
- f->auth_results = g_ptr_array_new_with_free_func (g_free);
- dbus_g_proxy_add_signal (f->proxy, AUTH_RESULT,
- G_TYPE_STRING,
- G_TYPE_INVALID);
- dbus_g_proxy_connect_signal (f->proxy, AUTH_RESULT,
- G_CALLBACK (auth_result_cb), f, NULL);
-}
-
-static void
-test_spoof (Fixture *f,
- gconstpointer addr)
-{
- DBusMessage *message;
- const char *well_known_name = WELL_KNOWN_NAME;
- const char *service_name = dbus_bus_get_unique_name (f->service_conn);
- const char *client_name = dbus_bus_get_unique_name (f->client_conn);
- const char *attacker_name = dbus_bus_get_unique_name (f->attacker_conn);
- const char *auth_result;
-
- auth_result = "on yr bus spoofing yr authentication";
-
- /* The attacker tries to pretend to be the service by spoofing
- * NameOwnerChanged(name=WELL_KNOWN_NAME, old=service, new=attacker). */
- message = dbus_message_new_signal (DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS,
- "NameOwnerChanged");
-
- if (message == NULL ||
- /* Bypass match rules by sending it unicast */
- !dbus_message_set_destination (message, client_name) ||
- !dbus_message_append_args (message,
- DBUS_TYPE_STRING, &well_known_name,
- DBUS_TYPE_STRING, &service_name,
- DBUS_TYPE_STRING, &attacker_name,
- DBUS_TYPE_INVALID) ||
- !dbus_connection_send (f->attacker_conn, message, NULL))
- {
- oom ();
- }
-
- dbus_message_unref (message);
-
- /* The attacker sends a message purporting to be from the service. */
- message = dbus_message_new_signal (PATH, IFACE, AUTH_RESULT);
-
- if (message == NULL ||
- /* Again, bypass match rules by sending it unicast */
- !dbus_message_set_destination (message, client_name) ||
- !dbus_message_append_args (message,
- DBUS_TYPE_STRING, &auth_result,
- DBUS_TYPE_INVALID) ||
- !dbus_connection_send (f->attacker_conn, message, NULL))
- {
- oom ();
- }
-
- dbus_message_unref (message);
-
- /* The service sends a message - too slow! The attacker won the race. */
- auth_result = "access denied";
- message = dbus_message_new_signal (PATH, IFACE, AUTH_RESULT);
-
- if (message == NULL ||
- !dbus_message_append_args (message,
- DBUS_TYPE_STRING, &auth_result,
- DBUS_TYPE_INVALID) ||
- !dbus_connection_send (f->service_conn, message, NULL))
- {
- oom ();
- }
-
- dbus_message_unref (message);
-
- /* Client waits for the first response */
- while (f->auth_results->len < 1)
- g_main_context_iteration (NULL, TRUE);
-
- /* The spoofed result was ignored, the real result was used. */
- g_assert_cmpstr (g_ptr_array_index (f->auth_results, 0), ==,
- "access denied");
-}
-
-static void
-teardown (Fixture *f,
- gconstpointer addr G_GNUC_UNUSED)
-{
- f->client_gconn = NULL;
- f->service_gconn = NULL;
- f->attacker_gconn = NULL;
-
- g_ptr_array_unref (f->auth_results);
-
- if (f->proxy != NULL)
- {
- dbus_g_proxy_disconnect_signal (f->proxy, AUTH_RESULT,
- G_CALLBACK (auth_result_cb), f);
- g_object_unref (f->proxy);
- f->proxy = NULL;
- }
-
- if (f->client_conn != NULL)
- {
- dbus_connection_close (f->client_conn);
- dbus_connection_unref (f->client_conn);
- f->client_conn = NULL;
- }
-
- if (f->service_conn != NULL)
- {
- dbus_connection_close (f->service_conn);
- dbus_connection_unref (f->service_conn);
- f->service_conn = NULL;
- }
-
- if (f->attacker_conn != NULL)
- {
- dbus_connection_close (f->attacker_conn);
- dbus_connection_unref (f->attacker_conn);
- f->attacker_conn = NULL;
- }
-}
-
-int
-main (int argc,
- char **argv)
-{
- g_test_init (&argc, &argv, NULL);
- g_type_init ();
- dbus_g_type_specialized_init ();
-
- g_test_bug_base ("https://bugs.freedesktop.org/show_bug.cgi?id=");
-
- g_test_add ("/proxy/spoof", Fixture, "unix:tmpdir=/tmp", setup,
- test_spoof, teardown);
-
- return g_test_run ();
-}
diff --git a/test/core/proxy-peer.c b/test/core/proxy-peer.c
deleted file mode 100644
index 8c1b867..0000000
--- a/test/core/proxy-peer.c
+++ /dev/null
@@ -1,274 +0,0 @@
-/* Regression tests for using a DBusGProxy on a peer-to-peer connection.
- *
- * Author: Simon McVittie <simon.mcvittie@collabora.co.uk>
- * Copyright © 2011 Nokia Corporation
- *
- * Permission is hereby granted, free of charge, to any person
- * obtaining a copy of this software and associated documentation files
- * (the "Software"), to deal in the Software without restriction,
- * including without limitation the rights to use, copy, modify, merge,
- * publish, distribute, sublicense, and/or sell copies of the Software,
- * and to permit persons to whom the Software is furnished to do so,
- * subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#include <config.h>
-
-#include <glib.h>
-
-#include <dbus/dbus.h>
-#include <dbus/dbus-glib.h>
-#include <dbus/dbus-glib-lowlevel.h>
-
-#include "my-object.h"
-
-GMainLoop *loop;
-
-typedef struct {
- DBusError e;
-
- DBusServer *server;
- DBusConnection *server_conn;
- DBusGConnection *server_gconn;
-
- DBusConnection *client_conn;
- DBusGConnection *client_gconn;
-
- DBusGProxy *proxy;
- gboolean proxy_destroyed;
- GObject *object;
- GHashTable *in_flight;
- GHashTable *completed;
-} Fixture;
-
-static void
-assert_no_error (const DBusError *e)
-{
- if (G_UNLIKELY (dbus_error_is_set (e)))
- g_error ("expected success but got error: %s: %s", e->name, e->message);
-}
-
-static void
-new_conn_cb (DBusServer *server,
- DBusConnection *server_conn,
- void *data)
-{
- Fixture *f = data;
-
- g_assert (f->server_conn == NULL);
- f->server_conn = dbus_connection_ref (server_conn);
- dbus_connection_setup_with_g_main (server_conn, NULL);
- f->server_gconn = dbus_connection_get_g_connection (server_conn);
-}
-
-static void
-destroy_cb (DBusGProxy *proxy,
- gpointer user_data)
-{
- Fixture *f = user_data;
-
- g_assert (proxy == f->proxy);
-
- f->proxy_destroyed = TRUE;
-}
-
-static void
-setup (Fixture *f,
- gconstpointer addr)
-{
- dbus_error_init (&f->e);
-
- f->server = dbus_server_listen (addr, &f->e);
- assert_no_error (&f->e);
- g_assert (f->server != NULL);
-
- dbus_server_set_new_connection_function (f->server,
- new_conn_cb, f, NULL);
- dbus_server_setup_with_g_main (f->server, NULL);
-
- g_assert (f->server_conn == NULL);
-
- f->client_conn = dbus_connection_open_private (
- dbus_server_get_address (f->server), &f->e);
- assert_no_error (&f->e);
- g_assert (f->client_conn != NULL);
- dbus_connection_setup_with_g_main (f->client_conn, NULL);
- f->client_gconn = dbus_connection_get_g_connection (f->client_conn);
-
- while (f->server_conn == NULL)
- {
- g_print (".");
- g_main_context_iteration (NULL, TRUE);
- }
-
- f->object = g_object_new (MY_TYPE_OBJECT,
- NULL);
- dbus_g_connection_register_g_object (f->server_gconn,
- "/org/freedesktop/DBus/GLib/Tests/MyTestObject", f->object);
-
- f->proxy = dbus_g_proxy_new_for_peer (f->client_gconn,
- "/org/freedesktop/DBus/GLib/Tests/MyTestObject",
- "org.freedesktop.DBus.GLib.Tests.MyObject");
- g_assert (f->proxy != NULL);
- g_assert (DBUS_IS_G_PROXY (f->proxy));
-
- g_signal_connect (f->proxy, "destroy", G_CALLBACK (destroy_cb), f);
-
- f->in_flight = g_hash_table_new (NULL, NULL);
- f->completed = g_hash_table_new (NULL, NULL);
-}
-
-static void
-call_cb (DBusGProxy *proxy,
- DBusGProxyCall *call,
- gpointer data)
-{
- Fixture *f = data;
- gboolean found;
-
- found = g_hash_table_remove (f->in_flight, call);
- g_assert (found);
- g_hash_table_insert (f->completed, call, call);
-}
-
-static void
-test_method (Fixture *f,
- gconstpointer addr)
-{
- GError *error = NULL;
- gboolean ok;
- DBusGProxyCall *call;
-
- call = dbus_g_proxy_begin_call (f->proxy, "DoNothing", call_cb, f, NULL,
- G_TYPE_INVALID);
- g_assert (call != NULL);
- g_hash_table_insert (f->in_flight, call, call);
-
- while (g_hash_table_size (f->in_flight) > 0)
- {
- g_print (".");
- g_main_context_iteration (NULL, TRUE);
- }
-
- ok = g_hash_table_remove (f->completed, call);
- g_assert (ok);
- ok = dbus_g_proxy_end_call (f->proxy, call, &error,
- G_TYPE_INVALID);
- g_assert_no_error (error);
- g_assert (ok);
-}
-
-static void
-test_disconnect (Fixture *f,
- gconstpointer addr)
-{
- GError *error = NULL;
- gboolean ok;
- DBusGProxyCall *fail;
-
- g_test_bug ("38406");
-
- dbus_connection_close (f->client_conn);
- dbus_connection_close (f->server_conn);
-
- fail = dbus_g_proxy_begin_call (f->proxy, "DoNothing", call_cb, f, NULL,
- G_TYPE_INVALID);
- g_assert (fail == NULL);
-
- ok = dbus_g_proxy_end_call (f->proxy, fail, &error,
- G_TYPE_INVALID);
- g_assert_error (error, DBUS_GERROR, DBUS_GERROR_DISCONNECTED);
- g_assert (!ok);
- g_clear_error (&error);
-
- while (!f->proxy_destroyed)
- {
- g_print (".");
- g_main_context_iteration (NULL, TRUE);
- }
-}
-
-static void
-teardown (Fixture *f,
- gconstpointer addr G_GNUC_UNUSED)
-{
- f->client_gconn = NULL;
- f->server_gconn = NULL;
-
- if (f->in_flight != NULL)
- {
- g_hash_table_unref (f->in_flight);
- f->in_flight = NULL;
- }
-
- if (f->completed != NULL)
- {
- g_hash_table_unref (f->completed);
- f->completed = NULL;
- }
-
- if (f->proxy != NULL)
- {
- g_signal_handlers_disconnect_by_func (f->proxy, destroy_cb, f);
- g_object_unref (f->proxy);
- f->proxy = NULL;
- }
-
- if (f->object != NULL)
- {
- g_object_unref (f->object);
- f->object = NULL;
- }
-
- if (f->client_conn != NULL)
- {
- dbus_connection_close (f->client_conn);
- dbus_connection_unref (f->client_conn);
- f->client_conn = NULL;
- }
-
- if (f->server_conn != NULL)
- {
- dbus_connection_close (f->server_conn);
- dbus_connection_unref (f->server_conn);
- f->server_conn = NULL;
- }
-
- if (f->server != NULL)
- {
- dbus_server_disconnect (f->server);
- dbus_server_unref (f->server);
- f->server = NULL;
- }
-}
-
-int
-main (int argc,
- char **argv)
-{
- g_test_init (&argc, &argv, NULL);
- g_type_init ();
- dbus_g_type_specialized_init ();
-
- g_test_bug_base ("https://bugs.freedesktop.org/show_bug.cgi?id=");
-
- g_test_add ("/proxy/method", Fixture, "unix:tmpdir=/tmp", setup,
- test_method, teardown);
-
- g_test_add ("/proxy/disconnect", Fixture, "unix:tmpdir=/tmp", setup,
- test_disconnect, teardown);
-
- return g_test_run ();
-}
diff --git a/test/core/registrations.c b/test/core/registrations.c
deleted file mode 100644
index 0eea468..0000000
--- a/test/core/registrations.c
+++ /dev/null
@@ -1,445 +0,0 @@
-/* Regression test for object registration and unregistration
- *
- * Copyright © 2009 Collabora Ltd. <http://www.collabora.co.uk/>
- * Copyright © 2009-2011 Nokia Corporation
- *
- * In preparation for dbus-glib relicensing (if it ever happens), this file is
- * licensed under (at your option) either the AFL v2.1, the GPL v2 or later,
- * or an MIT/X11-style license:
- *
- * Licensed under the Academic Free License version 2.1
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * Permission is hereby granted, free of charge, to any person
- * obtaining a copy of this software and associated documentation
- * files (the "Software"), to deal in the Software without
- * restriction, including without limitation the rights to use, copy,
- * modify, merge, publish, distribute, sublicense, and/or sell copies
- * of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
- * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
- * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- */
-
-#include <config.h>
-
-#include <dbus/dbus-glib.h>
-#include <dbus/dbus-glib-lowlevel.h>
-
-#include "my-object.h"
-
-#include "dbus-gmain/tests/util.h"
-
-GMainLoop *loop = NULL;
-
-typedef struct {
- DBusError dbus_error;
- DBusGConnection *bus;
- DBusGConnection *bus2;
- GObject *object;
- DBusMessage *frobnicate1_message;
- DBusMessage *frobnicate2_message;
- gboolean received_objectified;
-} Fixture;
-
-#define assert_no_error(e) _assert_no_error (e, __FILE__, __LINE__)
-static void
-_assert_no_error (const DBusError *e,
- const char *file,
- int line)
-{
- if (G_UNLIKELY (dbus_error_is_set (e)))
- g_error ("%s:%d: expected success but got error: %s: %s",
- file, line, e->name, e->message);
-}
-
-static void
-setup (Fixture *f,
- gconstpointer path_to_use)
-{
- dbus_error_init (&f->dbus_error);
-
- f->bus = dbus_g_bus_get_private (DBUS_BUS_SESSION, NULL, NULL);
- g_assert (f->bus != NULL);
-
- f->bus2 = dbus_g_bus_get_private (DBUS_BUS_SESSION, NULL, NULL);
- g_assert (f->bus2 != NULL);
-
- f->object = g_object_new (MY_TYPE_OBJECT, NULL);
- g_assert (MY_IS_OBJECT (f->object));
-}
-
-static void
-teardown (Fixture *f,
- gconstpointer test_data G_GNUC_UNUSED)
-{
- /* we close the connection before releasing the object, to test fd.o #5688
- * in test_lookup() */
- if (f->bus != NULL)
- {
- test_run_until_disconnected (dbus_g_connection_get_connection (f->bus), NULL);
- dbus_g_connection_unref (f->bus);
- }
-
- if (f->bus2 != NULL)
- {
- test_run_until_disconnected (dbus_g_connection_get_connection (f->bus2), NULL);
- dbus_g_connection_unref (f->bus2);
- }
-
- if (f->object != NULL)
- {
- g_object_unref (f->object);
- }
-
- /* This is safe to call on an initialized-but-unset DBusError, a bit like
- * g_clear_error */
- dbus_error_free (&f->dbus_error);
-
- dbus_shutdown ();
-}
-
-static void
-test_lookup (Fixture *f,
- gconstpointer test_data G_GNUC_UNUSED)
-{
- /* teardown() closes the connection before f->object is destroyed, which
- * used to be broken */
- g_test_bug ("5688");
-
- dbus_g_connection_register_g_object (f->bus, "/foo", f->object);
- g_assert (dbus_g_connection_lookup_g_object (f->bus, "/foo") ==
- f->object);
- /* this was briefly broken while fixing fd.o#5688 */
- g_assert (dbus_g_connection_lookup_g_object (f->bus, "/bar") == NULL);
-}
-
-static void
-test_unregister (Fixture *f,
- gconstpointer test_data G_GNUC_UNUSED)
-{
- /* feature test: objects can be unregistered */
- g_test_bug ("21219");
-
- dbus_g_connection_register_g_object (f->bus, "/foo", f->object);
- g_assert (dbus_g_connection_lookup_g_object (f->bus, "/foo") ==
- f->object);
- dbus_g_connection_unregister_g_object (f->bus, f->object);
- g_assert (dbus_g_connection_lookup_g_object (f->bus, "/foo") == NULL);
-}
-
-static void
-test_unregister_on_last_unref (Fixture *f,
- gconstpointer test_data G_GNUC_UNUSED)
-{
- gpointer weak_pointer;
-
- weak_pointer = f->object;
- g_object_add_weak_pointer (weak_pointer, &weak_pointer);
-
- dbus_g_connection_register_g_object (f->bus, "/foo", f->object);
- g_assert (dbus_g_connection_lookup_g_object (f->bus, "/foo") ==
- f->object);
- /* implicit unregistration by the last-unref of the object */
- g_object_unref (f->object);
- f->object = NULL;
-
- g_assert (weak_pointer == NULL);
-
- g_assert (dbus_g_connection_lookup_g_object (f->bus, "/foo") == NULL);
-}
-
-static void
-test_unregister_on_forced_dispose (Fixture *f,
- gconstpointer test_data G_GNUC_UNUSED)
-{
- dbus_g_connection_register_g_object (f->bus, "/foo", f->object);
- g_assert (dbus_g_connection_lookup_g_object (f->bus, "/foo") ==
- f->object);
- /* implicit unregistration by dispose() of the object (don't try
- * this at home) */
- g_object_run_dispose (f->object);
-
- g_assert (dbus_g_connection_lookup_g_object (f->bus, "/foo") == NULL);
-}
-
-static void
-test_reregister (Fixture *f,
- gconstpointer test_data G_GNUC_UNUSED)
-{
- dbus_g_connection_register_g_object (f->bus, "/foo", f->object);
- g_assert (dbus_g_connection_lookup_g_object (f->bus, "/foo") ==
- f->object);
-
- /* Before 0.82, re-registering the same object path was leaky but successful.
- * 0.82 disallowed this behaviour. Since 0.84 it was meant to be allowed
- * again, and a no-op, but it actually had the effect of removing all
- * record of the registrations (while leaving the object registered with
- * libdbus). */
- dbus_g_connection_register_g_object (f->bus, "/foo", f->object);
- g_assert (dbus_g_connection_lookup_g_object (f->bus, "/foo") ==
- f->object);
-
- /* This would critical in 0.84. */
- dbus_g_connection_unregister_g_object (f->bus, f->object);
- g_assert (dbus_g_connection_lookup_g_object (f->bus, "/foo") == NULL);
-}
-
-static DBusHandlerResult
-frobnicate_cb (DBusConnection *conn,
- DBusMessage *message,
- void *user_data)
-{
- Fixture *f = user_data;
-
- if (dbus_message_is_signal (message,
- "org.freedesktop.DBus.GLib.Tests.MyObject", "Frobnicate"))
- {
- const char *sender = dbus_message_get_sender (message);
- const char *path = dbus_message_get_path (message);
-
- g_assert (sender != NULL);
- g_assert (path != NULL);
-
- if (g_strcmp0 (path, "/foo") == 0)
- {
- g_assert_cmpstr (sender, ==, dbus_bus_get_unique_name (
- dbus_g_connection_get_connection (f->bus)));
-
- g_assert (f->frobnicate1_message == NULL);
- f->frobnicate1_message = dbus_message_ref (message);
- }
- else
- {
- g_assert_cmpstr (path, ==, "/bar");
- g_assert_cmpstr (sender, ==, dbus_bus_get_unique_name (
- dbus_g_connection_get_connection (f->bus2)));
-
- g_assert (f->frobnicate2_message == NULL);
- f->frobnicate2_message = dbus_message_ref (message);
- }
- }
-
- return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
-}
-
-static void
-test_twice (Fixture *f,
- gconstpointer test_data G_GNUC_UNUSED)
-{
- dbus_bool_t mem;
-
- g_test_bug ("32087");
-
- dbus_g_connection_register_g_object (f->bus, "/foo", f->object);
-
- dbus_g_connection_register_g_object (f->bus2, "/bar", f->object);
-
- g_assert (dbus_g_connection_lookup_g_object (f->bus, "/foo") ==
- f->object);
- g_assert (dbus_g_connection_lookup_g_object (f->bus2, "/bar") ==
- f->object);
-
- dbus_bus_add_match (dbus_g_connection_get_connection (f->bus),
- "type='signal'", &f->dbus_error);
- assert_no_error (&f->dbus_error);
- mem = dbus_connection_add_filter (dbus_g_connection_get_connection (f->bus),
- frobnicate_cb, f, NULL);
- g_assert (mem);
-
- my_object_emit_frobnicate ((MyObject *) f->object, NULL);
-
- /* The object should emit the signal once onto each connection,
- * from the appropriate location */
- while (f->frobnicate1_message == NULL || f->frobnicate2_message == NULL)
- g_main_context_iteration (NULL, TRUE);
-
- dbus_message_unref (f->frobnicate1_message);
- f->frobnicate1_message = NULL;
- dbus_message_unref (f->frobnicate2_message);
- f->frobnicate2_message = NULL;
-
- /* try again, to catch any extra emissions, but first unregister one of the
- * object's locations */
- dbus_g_connection_unregister_g_object (f->bus, f->object);
- my_object_emit_frobnicate ((MyObject *) f->object, NULL);
-
- while (f->frobnicate2_message == NULL)
- g_main_context_iteration (NULL, TRUE);
-
- g_assert (f->frobnicate1_message == NULL);
- dbus_message_unref (f->frobnicate2_message);
- f->frobnicate2_message = NULL;
-}
-
-static void
-test_clean_slate (Fixture *f,
- gconstpointer test_data G_GNUC_UNUSED)
-{
- dbus_bool_t mem;
-
- dbus_bus_add_match (dbus_g_connection_get_connection (f->bus),
- "type='signal'", &f->dbus_error);
- assert_no_error (&f->dbus_error);
- mem = dbus_connection_add_filter (dbus_g_connection_get_connection (f->bus),
- frobnicate_cb, f, NULL);
- g_assert (mem);
-
- dbus_g_connection_register_g_object (f->bus, "/foo", f->object);
- g_assert (dbus_g_connection_lookup_g_object (f->bus, "/foo") ==
- f->object);
-
- my_object_emit_frobnicate ((MyObject *) f->object, NULL);
-
- while (f->frobnicate1_message == NULL)
- g_main_context_iteration (NULL, TRUE);
-
- dbus_message_unref (f->frobnicate1_message);
- f->frobnicate1_message = NULL;
-
- /* unregister the object from its last object path, then put it back
- * in the same location */
- dbus_g_connection_unregister_g_object (f->bus, f->object);
- dbus_g_connection_register_g_object (f->bus, "/foo", f->object);
- g_assert (dbus_g_connection_lookup_g_object (f->bus, "/foo") ==
- f->object);
-
- /* bug: in 0.92, this would be emitted twice because the hook was added
- * twice */
- my_object_emit_frobnicate ((MyObject *) f->object, NULL);
-
- while (f->frobnicate1_message == NULL)
- g_main_context_iteration (NULL, TRUE);
-
- dbus_message_unref (f->frobnicate1_message);
- f->frobnicate1_message = NULL;
-
- /* unregister the object from its last object path, then put it back
- * at a different location */
- dbus_g_connection_unregister_g_object (f->bus, f->object);
- dbus_g_connection_register_g_object (f->bus2, "/bar", f->object);
- g_assert (dbus_g_connection_lookup_g_object (f->bus2, "/bar") ==
- f->object);
-
- my_object_emit_frobnicate ((MyObject *) f->object, NULL);
-
- while (f->frobnicate2_message == NULL)
- g_main_context_iteration (NULL, TRUE);
-
- /* check that this wasn't received anyway, which would indicate that
- * either unregistration from /foo was unsuccessful, or the double
- * emission mentioned above was seen */
- g_assert (f->frobnicate1_message == NULL);
-
- dbus_message_unref (f->frobnicate2_message);
- f->frobnicate2_message = NULL;
-}
-
-static DBusHandlerResult
-objectified_cb (DBusConnection *conn,
- DBusMessage *message,
- void *user_data)
-{
- Fixture *f = user_data;
-
- if (dbus_message_is_signal (message,
- "org.freedesktop.DBus.GLib.Tests.MyObject", "Objectified"))
- {
- const char *sender = dbus_message_get_sender (message);
- const char *path = dbus_message_get_path (message);
- dbus_bool_t ok;
- DBusError e;
-
- dbus_error_init (&e);
-
- g_assert (sender != NULL);
- g_assert (path != NULL);
-
- g_assert_cmpstr (path, ==, "/foo");
- g_assert_cmpstr (sender, ==, dbus_bus_get_unique_name (
- dbus_g_connection_get_connection (f->bus)));
-
- path = NULL;
- ok = dbus_message_get_args (message, &e,
- DBUS_TYPE_OBJECT_PATH, &path,
- DBUS_TYPE_INVALID);
-
- if (dbus_error_is_set (&e))
- g_error ("%s: %s", e.name, e.message);
-
- g_assert (ok);
- g_assert_cmpstr (path, ==, "/foo");
-
- f->received_objectified = TRUE;
- }
-
- return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
-}
-
-static void
-test_marshal_object (Fixture *f,
- gconstpointer test_data G_GNUC_UNUSED)
-{
- dbus_bool_t mem;
-
- g_test_bug ("37852");
-
- dbus_g_connection_register_g_object (f->bus, "/foo", f->object);
- g_assert (dbus_g_connection_lookup_g_object (f->bus, "/foo") ==
- f->object);
-
- dbus_bus_add_match (dbus_g_connection_get_connection (f->bus),
- "type='signal'", &f->dbus_error);
- assert_no_error (&f->dbus_error);
- mem = dbus_connection_add_filter (dbus_g_connection_get_connection (f->bus),
- objectified_cb, f, NULL);
- g_assert (mem);
-
- my_object_emit_objectified ((MyObject *) f->object, f->object);
-
- while (!f->received_objectified)
- g_main_context_iteration (NULL, TRUE);
-}
-
-int
-main (int argc, char **argv)
-{
- g_type_init ();
- g_log_set_always_fatal (G_LOG_LEVEL_WARNING | G_LOG_LEVEL_CRITICAL);
- dbus_g_type_specialized_init ();
- g_test_bug_base ("https://bugs.freedesktop.org/show_bug.cgi?id=");
- g_test_init (&argc, &argv, NULL);
-
- g_test_add ("/registrations/lookup", Fixture, NULL,
- setup, test_lookup, teardown);
- g_test_add ("/registrations/unregister", Fixture, NULL,
- setup, test_unregister, teardown);
- g_test_add ("/registrations/unregister-on-last-unref", Fixture, NULL,
- setup, test_unregister_on_last_unref, teardown);
- g_test_add ("/registrations/unregister-on-forced-dispose", Fixture, NULL,
- setup, test_unregister_on_forced_dispose, teardown);
- g_test_add ("/registrations/reregister", Fixture, NULL,
- setup, test_reregister, teardown);
- g_test_add ("/registrations/twice", Fixture, NULL,
- setup, test_twice, teardown);
- g_test_add ("/registrations/clean-slate", Fixture, NULL,
- setup, test_clean_slate, teardown);
- g_test_add ("/registrations/marshal-object", Fixture, NULL,
- setup, test_marshal_object, teardown);
-
- return g_test_run ();
-}
diff --git a/test/core/run-peer-test.sh b/test/core/run-peer-test.sh
deleted file mode 100755
index 10d9528..0000000
--- a/test/core/run-peer-test.sh
+++ /dev/null
@@ -1,6 +0,0 @@
-#!/bin/sh
-
-set -e
-
-# The peer server writes its address over stdout, which the client reads
-${DBUS_TOP_BUILDDIR}/libtool --mode=execute ./peer-server | ${DBUS_TOP_BUILDDIR}/libtool --mode=execute ./peer-client
diff --git a/test/core/run-test.sh b/test/core/run-test.sh
deleted file mode 100755
index fe0d3f8..0000000
--- a/test/core/run-test.sh
+++ /dev/null
@@ -1,55 +0,0 @@
-#! /bin/sh
-
-SCRIPTNAME=$0
-MODE=$1
-
-die()
-{
- echo $@ 1>&2
- exit 1
-}
-
-## so the tests can complain if you fail to use the script to launch them
-DBUS_TEST_GLIB_RUN_TEST_SCRIPT=1
-export DBUS_TEST_GLIB_RUN_TEST_SCRIPT
-DBUS_TOP_SRCDIR=`dirname "$0"`/../..
-export DBUS_TOP_SRCDIR
-# Rerun ourselves with tmp session bus if we're not already
-if test -z "$DBUS_TEST_GLIB_IN_RUN_TEST"; then
- DBUS_TEST_GLIB_IN_RUN_TEST=1
- export DBUS_TEST_GLIB_IN_RUN_TEST
- exec $DBUS_TOP_SRCDIR/tools/run-with-tmp-session-bus.sh $SCRIPTNAME $MODE
-fi
-
-if test x$MODE = xprofile ; then
- echo "profiling type $PROFILE_TYPE"
- sleep 2 ## this lets the bus get started so its startup time doesn't affect the profile too much
- if test x$PROFILE_TYPE = x ; then
- PROFILE_TYPE=all
- fi
- ${DBUS_TOP_BUILDDIR}/libtool --mode=execute $DEBUG $DBUS_TOP_BUILDDIR/test/core/test-profile $PROFILE_TYPE || die "test-profile failed"
-elif test x$MODE = xviewer ; then
- echo "Launching dbus-viewer"
- ARGS=
- if test x$DEBUG = x ; then
- ARGS="--services org.freedesktop.DBus org.freedesktop.DBus.GLib.TestService"
- fi
- ${DBUS_TOP_BUILDDIR}/libtool --mode=execute $DEBUG $DBUS_TOP_BUILDDIR/tools/dbus-viewer $ARGS || die "could not run dbus-viewer"
-elif test x$MODE = xwait ; then
- echo "Waiting DBUS_SESSION_BUS_ADDRESS=$DBUS_SESSION_BUS_ADDRESS"
- sleep 86400
-else
- echo "running test-dbus-glib"
- if test x$DBUS_TEST_MONITOR != x; then
- dbus-monitor --session &
- fi
- ${DBUS_TOP_BUILDDIR}/libtool --mode=execute $DEBUG $DBUS_TOP_BUILDDIR/test/core/test-shared-bus || die "test-shared-bus failed"
- ${DBUS_TOP_BUILDDIR}/libtool --mode=execute $DEBUG $DBUS_TOP_BUILDDIR/test/core/test-types || die "test-types failed"
- ${DBUS_TOP_BUILDDIR}/libtool --mode=execute $DEBUG $DBUS_TOP_BUILDDIR/test/core/test-registrations || die "test-registrations failed"
- ${DBUS_TOP_BUILDDIR}/libtool --mode=execute $DEBUG $DBUS_TOP_BUILDDIR/test/core/test-dbus-glib || die "test-dbus-glib failed"
- ${DBUS_TOP_BUILDDIR}/libtool --mode=execute $DEBUG $DBUS_TOP_BUILDDIR/test/core/test-variant-recursion || die "test-variant-recursion failed"
- ${DBUS_TOP_BUILDDIR}/libtool --mode=execute $DEBUG $DBUS_TOP_BUILDDIR/test/core/test-gvariant || die "test-gvariant failed"
- ${DBUS_TOP_BUILDDIR}/libtool --mode=execute $DEBUG $DBUS_TOP_BUILDDIR/test/core/test-private || die "test-private failed"
- ${DBUS_TOP_BUILDDIR}/libtool --mode=execute $DEBUG $DBUS_TOP_BUILDDIR/test/core/test-error-mapping || die "test-error-mapping failed"
- ${DBUS_TOP_BUILDDIR}/libtool --mode=execute $DEBUG $DBUS_TOP_BUILDDIR/test/core/test-peer-on-bus || die "test-peer-on-bus failed"
-fi
diff --git a/test/core/shared-bus.c b/test/core/shared-bus.c
deleted file mode 100644
index 0ab575c..0000000
--- a/test/core/shared-bus.c
+++ /dev/null
@@ -1,135 +0,0 @@
-/* Regression test for the shared bus instance.
- * This test is expected to "leak" the shared connection.
- *
- * Copyright © 2006-2010 Red Hat, Inc.
- * Copyright © 2006-2008 Collabora Ltd. <http://www.collabora.co.uk/>
- * Copyright © 2011 Nokia Corporation
- *
- * Licensed under the Academic Free License version 2.1
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA
- */
-
-#include <config.h>
-
-#include <glib.h>
-
-#include <dbus/dbus-glib.h>
-#include <dbus/dbus-glib-lowlevel.h>
-
-GMainLoop *loop = NULL;
-
-typedef struct {
- DBusGConnection *bus;
- DBusGConnection *priv;
- GError *error;
-} Fixture;
-
-static void
-destroy_cb (DBusGProxy *proxy G_GNUC_UNUSED,
- gpointer user_data)
-{
- gboolean *disconnected = user_data;
-
- *disconnected = TRUE;
-}
-
-static void
-disconnect (DBusGConnection **bus)
-{
- DBusGProxy *proxy;
- gboolean disconnected = FALSE;
-
- g_printerr ("Disconnecting... ");
-
- dbus_connection_set_exit_on_disconnect (dbus_g_connection_get_connection (*bus),
- FALSE);
- proxy = dbus_g_proxy_new_for_peer (*bus, "/",
- "org.freedesktop.DBus.Peer");
- g_signal_connect (G_OBJECT (proxy), "destroy", G_CALLBACK (destroy_cb),
- &disconnected);
-
- dbus_connection_close (dbus_g_connection_get_connection (*bus));
-
- while (!disconnected)
- {
- g_printerr (".");
- g_main_context_iteration (NULL, TRUE);
- }
-
- g_signal_handlers_disconnect_by_func (proxy, destroy_cb, &disconnected);
- g_object_unref (proxy);
- dbus_g_connection_unref (*bus);
- *bus = NULL;
-
- g_printerr (" disconnected\n");
-}
-
-static void
-setup (Fixture *f,
- gconstpointer test_data G_GNUC_UNUSED)
-{
-}
-
-static void
-teardown (Fixture *f,
- gconstpointer test_data G_GNUC_UNUSED)
-{
- if (f->bus != NULL)
- dbus_g_connection_unref (f->bus);
-
- if (f->priv != NULL)
- disconnect (&f->priv);
-
- g_clear_error (&f->error);
- dbus_shutdown ();
-}
-
-static void
-test_shared_bus (Fixture *f,
- gconstpointer test_data G_GNUC_UNUSED)
-{
- f->bus = dbus_g_bus_get (DBUS_BUS_SESSION, &f->error);
- g_assert_no_error (f->error);
- g_assert (f->bus != NULL);
- dbus_connection_set_exit_on_disconnect (dbus_g_connection_get_connection (f->bus),
- FALSE);
-
- g_assert (f->bus == dbus_g_bus_get (DBUS_BUS_SESSION, NULL));
- g_assert (f->bus == dbus_g_bus_get (DBUS_BUS_SESSION, NULL));
- g_assert (f->bus == dbus_g_bus_get (DBUS_BUS_SESSION, NULL));
-
- f->priv = dbus_g_bus_get_private (DBUS_BUS_SESSION, NULL, &f->error);
- g_assert_no_error (f->error);
- g_assert (f->priv != NULL);
- g_assert (f->priv != f->bus);
- dbus_connection_set_exit_on_disconnect (dbus_g_connection_get_connection (f->priv),
- FALSE);
-}
-
-int
-main (int argc, char **argv)
-{
- g_type_init ();
- g_log_set_always_fatal (G_LOG_LEVEL_WARNING | G_LOG_LEVEL_CRITICAL);
- g_test_bug_base ("https://bugs.freedesktop.org/show_bug.cgi?id=");
- g_test_init (&argc, &argv, NULL);
-
- g_test_add ("/shared-bus", Fixture, NULL, setup, test_shared_bus,
- teardown);
-
- return g_test_run ();
-}
diff --git a/test/core/test-dbus-glib.c b/test/core/test-dbus-glib.c
deleted file mode 100644
index 1ae2ec7..0000000
--- a/test/core/test-dbus-glib.c
+++ /dev/null
@@ -1,2415 +0,0 @@
-/* General tests for dbus-glib. Please make new tests into a standalone
- * binary using GTest instead, where feasible.
- *
- * Copyright © 2006-2010 Red Hat, Inc.
- * Copyright © 2006-2010 Collabora Ltd.
- * Copyright © 2006-2011 Nokia Corporation
- * Copyright © 2006 Steve Frécinaux
- *
- * Licensed under the Academic Free License version 2.1
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301 USA
- */
-
-#include <config.h>
-
-/* -*- mode: C; c-file-style: "gnu" -*- */
-#include <dbus/dbus-glib.h>
-#include <dbus/dbus-glib-lowlevel.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include "test-service-glib-bindings.h"
-#include <dbus/dbus-gidl.h>
-#include <dbus/dbus-gparser.h>
-#include <glib.h>
-#include <glib-object.h>
-#include "my-object.h"
-#include "dbus-gmain/tests/util.h"
-
-GMainLoop *loop = NULL;
-
-static const char *await_terminating_service = NULL;
-static int n_times_foo_received = 0;
-static int n_times_frobnicate_received = 0;
-static int n_times_frobnicate_received_2 = 0;
-static int n_times_compat_frobnicate_received = 0;
-static int n_times_sig0_received = 0;
-static int n_times_sig1_received = 0;
-static int n_times_sig2_received = 0;
-static guint exit_timeout = 0;
-static gboolean proxy_destroyed = FALSE;
-static gboolean proxy_destroy_and_nameowner = FALSE;
-static gboolean proxy_destroy_and_nameowner_complete = FALSE;
-
-static DBusGProxy *test_terminate_proxy1 = NULL;
-static DBusGProxy *test_terminate_proxy2 = NULL;
-
-static void
-cancel_exit_timeout (void)
-{
- if (exit_timeout != 0)
- {
- g_source_remove (exit_timeout);
- exit_timeout = 0;
- }
-}
-
-#define lose(...) g_error (__VA_ARGS__)
-
-static void lose_gerror (const char *prefix, GError *error) G_GNUC_NORETURN;
-
-static void
-unset_and_free_gvalue (gpointer val)
-{
- g_value_unset (val);
- g_free (val);
-}
-
-static gboolean
-timed_exit (gpointer loop)
-{
- g_print ("timed exit!\n");
- g_main_loop_quit (loop);
- /* will repeat, so do not clear exit_timeout */
- return TRUE;
-}
-
-static void
-proxy_destroyed_cb (DBusGProxy *proxy, gpointer user_data)
-{
- proxy_destroyed = TRUE;
- if (proxy_destroy_and_nameowner && !proxy_destroy_and_nameowner_complete && await_terminating_service == NULL)
- {
- cancel_exit_timeout ();
- g_main_loop_quit (loop);
- proxy_destroy_and_nameowner_complete = TRUE;
- }
-}
-
-static void
-test_terminate_proxy1_destroyed_cb (DBusGProxy *proxy, gpointer user_data)
-{
- proxy_destroyed = TRUE;
-
- if (proxy_destroy_and_nameowner && !proxy_destroy_and_nameowner_complete && await_terminating_service == NULL)
- {
- g_object_unref(test_terminate_proxy1);
- test_terminate_proxy1 = NULL;
- g_object_unref(test_terminate_proxy2);
- test_terminate_proxy2 = NULL;
- cancel_exit_timeout ();
- g_main_loop_quit (loop);
- proxy_destroy_and_nameowner_complete = TRUE;
- }
-}
-
-
-static void
-name_owner_changed (DBusGProxy *proxy,
- const char *name,
- const char *prev_owner,
- const char *new_owner,
- gpointer user_data)
-{
- g_print ("(signal NameOwnerChanged) name owner changed for %s from %s to %s\n",
- name, prev_owner, new_owner);
- if (await_terminating_service &&
- !strcmp (name, await_terminating_service)
- && !strcmp ("", new_owner))
- {
- g_print ("Caught expected ownership loss for %s\n", name);
- await_terminating_service = NULL;
- if (proxy_destroy_and_nameowner && !proxy_destroy_and_nameowner_complete && proxy_destroyed)
- {
- cancel_exit_timeout ();
- g_main_loop_quit (loop);
- proxy_destroy_and_nameowner_complete = TRUE;
- }
- else if (!proxy_destroy_and_nameowner)
- {
- cancel_exit_timeout ();
- g_main_loop_quit (loop);
- }
- }
-}
-
-static void
-foo_signal_handler (DBusGProxy *proxy,
- double d,
- void *user_data)
-{
- n_times_foo_received += 1;
-
- g_print ("Got Foo signal\n");
-
- g_main_loop_quit (loop);
- cancel_exit_timeout ();
-}
-
-static void
-frobnicate_signal_handler (DBusGProxy *proxy,
- int val,
- void *user_data)
-{
- n_times_frobnicate_received += 1;
-
- g_assert (val == 42);
- g_print ("Got Frobnicate signal\n");
-
- g_main_loop_quit (loop);
- cancel_exit_timeout ();
-}
-
-static void
-frobnicate_signal_handler_2 (DBusGProxy *proxy,
- int val,
- void *user_data)
-{
- n_times_frobnicate_received_2 += 1;
-
- g_assert (val == 42);
- g_print ("Got Frobnicate signal (again)\n");
-}
-
-static void
-frobnicate_signal_handler_compat (DBusGProxy *proxy,
- int val,
- void *user_data)
-{
- n_times_compat_frobnicate_received += 1;
-
- g_assert (val == 42);
- g_print ("Got Frobnicate signal (compat)\n");
-
- g_main_loop_quit (loop);
- cancel_exit_timeout ();
-}
-
-static void
-sig0_signal_handler (DBusGProxy *proxy,
- const char *str0,
- int val,
- const char *str1,
- void *user_data)
-{
- n_times_sig0_received += 1;
-
- g_assert (!strcmp (str0, "foo"));
-
- g_assert (val == 22);
-
- g_assert (!strcmp (str1, "moo"));
-
- g_print ("Got Sig0 signal\n");
-
- g_main_loop_quit (loop);
- cancel_exit_timeout ();
-}
-
-static void
-sig1_signal_handler (DBusGProxy *proxy,
- const char *str0,
- GValue *value,
- void *user_data)
-{
- n_times_sig1_received += 1;
-
- g_assert (!strcmp (str0, "baz"));
-
- g_assert (G_VALUE_HOLDS_STRING (value));
-
- g_assert (!strcmp (g_value_get_string (value), "bar"));
-
- g_print ("Got Sig1 signal\n");
-
- g_main_loop_quit (loop);
- cancel_exit_timeout ();
-}
-
-static void
-sig2_signal_handler (DBusGProxy *proxy,
- GHashTable *table,
- void *user_data)
-{
- n_times_sig2_received += 1;
-
- g_assert (g_hash_table_size (table) == 2);
-
- g_assert (g_hash_table_lookup (table, "baz") != NULL);
- g_assert (!strcmp (g_hash_table_lookup (table, "baz"), "cow"));
- g_assert (g_hash_table_lookup (table, "bar") != NULL);
- g_assert (!strcmp (g_hash_table_lookup (table, "bar"), "foo"));
-
- g_print ("Got Sig2 signal\n");
-
- g_main_loop_quit (loop);
- cancel_exit_timeout ();
-}
-
-static DBusGProxyCall *echo_call;
-static guint n_times_echo_cb_entered;
-static void
-echo_received_cb (DBusGProxy *proxy,
- DBusGProxyCall *call,
- gpointer data)
-{
- GError *error;
- char *echo_data;
-
- g_assert (call == echo_call);
- g_assert (data == NULL);
-
- error = NULL;
- echo_data = NULL;
- n_times_echo_cb_entered++;
-
- if (!dbus_g_proxy_end_call (proxy, call, &error,
- G_TYPE_STRING,
- &echo_data,
- G_TYPE_INVALID))
- lose_gerror ("Failed to complete async Echo", error);
- g_assert (echo_data != NULL);
- g_print ("Async echo gave \"%s\"\n", echo_data);
- g_free (echo_data);
- g_main_loop_quit (loop);
- cancel_exit_timeout ();
-}
-
-static void
-increment_received_cb (DBusGProxy *proxy,
- DBusGProxyCall *call,
- gpointer data)
-{
- GError *error;
- guint val;
-
- g_assert (!strcmp (data, "moo"));
-
- error = NULL;
- if (!dbus_g_proxy_end_call (proxy, call, &error,
- G_TYPE_UINT, &val,
- G_TYPE_INVALID))
- lose_gerror ("Failed to complete (async) Increment call", error);
-
- if (val != 43)
- lose ("Increment call returned %d, should be 43", val);
-
- g_print ("Async increment gave \"%d\"\n", val);
- g_main_loop_quit (loop);
- cancel_exit_timeout ();
-}
-
-static void
-increment_async_cb (DBusGProxy *proxy, guint val, GError *error, gpointer data)
-{
- if (error)
- lose_gerror ("Failed to complete (wrapped async) Increment call", error);
-
- if (data != NULL)
- lose ("(wrapped async) Increment call gave unexpected data");
- if (val != 43)
- lose ("(wrapped async) Increment call returned %d, should be 43", val);
-
- g_print ("(wrapped async) increment gave \"%d\"\n", val);
- g_main_loop_quit (loop);
- cancel_exit_timeout ();
-}
-
-#define DBUS_TYPE_G_MAP_OF_VARIANT (dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_VALUE))
-static gboolean
-test_base_class_get_all (DBusGConnection *connection,
- const char *object_path,
- const char *expected_string_value)
-{
- DBusGProxy *proxy;
- GError *error = NULL;
- GHashTable *hash = NULL;
-
- /* g_test_bug (19145); */
-
- g_assert (expected_string_value != NULL);
- g_assert (object_path != NULL);
-
- /* Test GetAll with interfaces on the base class */
-
- proxy = dbus_g_proxy_new_for_name (connection,
- "org.freedesktop.DBus.GLib.TestService",
- object_path,
- DBUS_INTERFACE_PROPERTIES);
- g_assert (proxy != NULL);
-
- g_print ("%s: Calling GetAll for unknown interface\n", object_path);
- {
- if (dbus_g_proxy_call (proxy, "GetAll", &error,
- G_TYPE_STRING, "org.freedesktop.DBus.foobar.blahblah",
- G_TYPE_INVALID,
- DBUS_TYPE_G_MAP_OF_VARIANT, &hash, G_TYPE_INVALID))
- lose ("Unexpected success for GetAll call of unknown interface\n");
- g_clear_error (&error);
- hash = NULL;
- }
-
- g_print ("%s: Calling GetAll for base class interface\n", object_path);
- {
- GValue *value;
- const char *foo = NULL;
-
- if (!dbus_g_proxy_call (proxy, "GetAll", &error,
- G_TYPE_STRING, "org.freedesktop.DBus.GLib.Tests.MyObject",
- G_TYPE_INVALID,
- DBUS_TYPE_G_MAP_OF_VARIANT, &hash, G_TYPE_INVALID))
- lose_gerror ("Unexpected error for GetProperty call of base class interface", error);
- g_clear_error (&error);
-
- if (!hash)
- {
- lose ("%s: Unexpected NULL hash table returned for GetAll call of base "
- "class interface", object_path);
- }
-
- if (g_hash_table_size (hash) != 3)
- {
- lose ("%s: Unexpected hash table size %d (expected 3) returned for GetAll "
- " call of base class interface", object_path, g_hash_table_size (hash));
- }
- value = g_hash_table_lookup (hash, "this_is_a_string");
- if (!value)
- {
- lose ("%s: Unexpected missing 'this_is_a_string' property for GetAll "
- "call of base class interface", object_path);
- }
- if (!G_VALUE_HOLDS_STRING (value))
- {
- lose ("%s: Unexpected wrong type for 'this_is_a_string' property for "
- "GetAll call of base class interface", object_path);
- }
- foo = g_value_get_string (value);
- if (!foo || strcmp (foo, expected_string_value))
- {
- lose ("%s: Unexpected value for 'this_is_a_string' property for GetAll "
- "call of base class interface", object_path);
- }
-
- value = g_hash_table_lookup (hash, "no-touching");
- if (!value)
- lose ("%s: Unexpected missing 'no-touching' property for GetAll "
- "call of base class interface", object_path);
- if (!G_VALUE_HOLDS_UINT (value))
- lose ("%s: Unexpected wrong type for 'no-touching' property for "
- "GetAll call of base class interface", object_path);
- if (g_value_get_uint (value) != 42)
- lose ("%s: Unexpected wrong value \"%d\" for 'no-touching' property for "
- "GetAll call of base class interface", object_path, g_value_get_uint (value));
- g_hash_table_destroy (hash);
- hash = NULL;
- }
-
- g_object_unref (proxy);
- return TRUE;
-}
-
-static gboolean
-test_subclass_get_all (DBusGConnection *connection,
- const char *object_path)
-{
- DBusGProxy *proxy;
- GError *error = NULL;
- GHashTable *hash = NULL;
-
- /* g_test_bug (19145); */
-
- g_assert (object_path != NULL);
-
- /* Test GetAll with interfaces on the subclass */
-
- proxy = dbus_g_proxy_new_for_name (connection,
- "org.freedesktop.DBus.GLib.TestService",
- object_path,
- DBUS_INTERFACE_PROPERTIES);
- g_assert (proxy != NULL);
-
- g_print ("%s: Calling GetAll for subclass interface\n", object_path);
- {
- GValue *value;
- const char *string = NULL;
- guint num = 0;
-
- if (!dbus_g_proxy_call (proxy, "GetAll", &error,
- G_TYPE_STRING, "org.freedesktop.DBus.GLib.Tests.MyObjectSubclass",
- G_TYPE_INVALID,
- DBUS_TYPE_G_MAP_OF_VARIANT, &hash, G_TYPE_INVALID))
- lose_gerror ("Unexpected error for GetProperty call of base subclass interface\n", error);
- g_clear_error (&error);
-
- if (!hash)
- {
- lose ("%s: Unexpected NULL hash table returned for GetAll call of "
- "subclass interface\n", object_path);
- }
-
- if (g_hash_table_size (hash) != 2)
- {
- lose ("%s: Unexpected hash table size %d (expected 2) returned for GetAll "
- " call of subclass interface\n", object_path, g_hash_table_size (hash));
- }
-
- /* Test the string property */
- value = g_hash_table_lookup (hash, "this_is_a_subclass_string");
- if (!value)
- {
- lose ("%s: Unexpected missing 'this_is_a_subclass_string' property for "
- "GetAll call of subclass interface\n", object_path);
- }
- if (!G_VALUE_HOLDS_STRING (value))
- {
- lose ("%s: Unexpected wrong type for 'this_is_a_subclass_string' "
- "property for GetAll call of subclass interface\n", object_path);
- }
- string = g_value_get_string (value);
- if (!string || strcmp (string, "default subclass value"))
- {
- lose ("%s: Unexpected value for 'this_is_a_subclass_string' property "
- "for GetAll call of subclass interface\n", object_path);
- }
-
- /* Test the uint property */
- value = g_hash_table_lookup (hash, "this_is_a_subclass_uint");
- if (!value)
- {
- lose ("%s: Unexpected missing 'this_is_a_subclass_uint' property for "
- "GetAll call of subclass interface\n", object_path);
- }
- if (!G_VALUE_HOLDS_UINT (value))
- {
- lose ("%s: Unexpected wrong type for 'this_is_a_subclass_uint' "
- "property for GetAll call of subclass interface\n", object_path);
- }
- num = g_value_get_uint (value);
- if (num != 1234567)
- {
- lose ("%s: Unexpected value for 'this_is_a_subclass_uint' property "
- "for GetAll call of subclass interface\n", object_path);
- }
-
- g_hash_table_destroy (hash);
- hash = NULL;
- }
-
- g_object_unref (proxy);
- return TRUE;
-}
-
-static void
-lose_gerror (const char *prefix, GError *error)
-{
- if (error->domain == DBUS_GERROR && error->code == DBUS_GERROR_REMOTE_EXCEPTION)
- lose ("%s (%s): %s", prefix, dbus_g_error_get_name (error),
- error->message);
- else
- lose ("%s: %s#%d: %s", prefix, g_quark_to_string (error->domain),
- error->code, error->message);
-}
-
-static void
-run_mainloop (void)
-{
- GMainContext *ctx;
-
- ctx = g_main_loop_get_context (loop);
-
- while (g_main_context_pending (ctx))
- g_main_context_iteration (ctx, FALSE);
-}
-
-int
-main (int argc, char **argv)
-{
- DBusGConnection *connection;
- GError *error;
- DBusGProxy *driver;
- DBusGProxy *proxy;
- DBusGProxy *proxy2;
- DBusGProxy *property_proxy;
- char **name_list;
- guint name_list_len;
- guint i;
- DBusGProxyCall *call;
- guint32 result;
- char *v_STRING_2;
- guint32 v_UINT32_2;
- double v_DOUBLE_2;
-
- g_type_init ();
-
- g_log_set_always_fatal (G_LOG_LEVEL_WARNING | G_LOG_LEVEL_CRITICAL);
-
- loop = g_main_loop_new (NULL, FALSE);
-
- error = NULL;
- connection = dbus_g_bus_get_private (DBUS_BUS_SESSION, NULL, &error);
-
- if (connection == NULL)
- lose_gerror ("Failed to open connection to bus", error);
-
- /* Create a proxy object for the "bus driver" */
-
- driver = dbus_g_proxy_new_for_name (connection,
- DBUS_SERVICE_DBUS,
- DBUS_PATH_DBUS,
- DBUS_INTERFACE_DBUS);
-
- dbus_g_proxy_add_signal (driver,
- "NameOwnerChanged",
- G_TYPE_STRING,
- G_TYPE_STRING,
- G_TYPE_STRING,
- G_TYPE_INVALID);
-
- dbus_g_proxy_connect_signal (driver,
- "NameOwnerChanged",
- G_CALLBACK (name_owner_changed),
- NULL,
- NULL);
- /* Call ListNames method */
-
- error = NULL;
- if (!dbus_g_proxy_call (driver, "ListNames", &error,
- G_TYPE_INVALID,
- G_TYPE_STRV, &name_list,
- G_TYPE_INVALID))
- lose_gerror ("Failed to complete ListNames call", error);
-
- g_print ("Names on the message bus:\n");
- i = 0;
- name_list_len = g_strv_length (name_list);
- while (i < name_list_len)
- {
- g_assert (name_list[i] != NULL);
- g_print (" %s\n", name_list[i]);
- ++i;
- }
- g_assert (name_list[i] == NULL);
-
- g_strfreev (name_list);
-
- g_print ("calling ThisMethodDoesNotExist\n");
- /* Test handling of unknown method */
- if (dbus_g_proxy_call (driver, "ThisMethodDoesNotExist", &error,
- G_TYPE_STRING,
- "blah blah blah blah blah",
- G_TYPE_INT,
- 10,
- G_TYPE_INVALID, G_TYPE_INVALID) != FALSE)
- lose ("Calling nonexistent method succeeded!");
-
- g_print ("Got EXPECTED error from calling unknown method: %s\n", error->message);
- g_clear_error (&error);
-
- run_mainloop ();
-
- /* Activate a service */
- g_print ("Activating echo service\n");
- if (!dbus_g_proxy_call (driver, "StartServiceByName", &error,
- G_TYPE_STRING,
- "org.freedesktop.DBus.GLib.TestEchoService",
- G_TYPE_UINT, 0,
- G_TYPE_INVALID,
- G_TYPE_UINT, &result,
- G_TYPE_INVALID))
- lose_gerror ("Failed to complete Activate call", error);
-
- g_print ("Starting echo service result = 0x%x\n", result);
-
- /* Activate a service again */
- g_print ("Activating echo service again\n");
- if (!dbus_g_proxy_call (driver, "StartServiceByName", &error,
- G_TYPE_STRING,
- "org.freedesktop.DBus.GLib.TestEchoService",
- G_TYPE_UINT,
- 0,
- G_TYPE_INVALID,
- G_TYPE_UINT, &result,
- G_TYPE_INVALID))
- lose_gerror ("Failed to complete Activate call", error);
-
- g_print ("Duplicate start of echo service = 0x%x\n", result);
-
- /* Talk to the new service */
-
- g_print ("Creating proxy for echo service\n");
- proxy = dbus_g_proxy_new_for_name_owner (connection,
- "org.freedesktop.DBus.GLib.TestEchoService",
- "/org/freedesktop/DBus/GLib/TestSuite",
- "org.freedesktop.DBus.GLib.TestSuite",
- &error);
-
- if (proxy == NULL)
- lose_gerror ("Failed to create proxy for name owner", error);
-
- run_mainloop ();
-
- g_print ("Calling Echo\n");
- if (!dbus_g_proxy_call (proxy, "Echo", &error,
- G_TYPE_STRING, "my string hello",
- G_TYPE_INVALID,
- G_TYPE_STRING, &v_STRING_2,
- G_TYPE_INVALID))
- lose_gerror ("Failed to complete Echo call", error);
-
- g_print ("String echoed = \"%s\"\n", v_STRING_2);
- g_free (v_STRING_2);
-
- g_print ("Calling Echo (async)\n");
- echo_call = dbus_g_proxy_begin_call (proxy, "Echo",
- echo_received_cb, NULL, NULL,
- G_TYPE_STRING, "my string hello",
- G_TYPE_INVALID);
- dbus_g_connection_flush (connection);
- exit_timeout = g_timeout_add (5000, timed_exit, loop);
- g_main_loop_run (loop);
-
- /* Exercise invalid number/type of return values */
-
- g_print ("Invalid args; calling Echo\n");
- if (dbus_g_proxy_call (proxy, "Echo", &error,
- G_TYPE_STRING, "my string hello",
- G_TYPE_INVALID,
- G_TYPE_INVALID))
- lose ("Unexpected success for invalid Echo return values");
- g_clear_error (&error);
-
- g_print ("Invalid args 2; calling Echo\n");
- if (dbus_g_proxy_call (proxy, "Echo", &error,
- G_TYPE_STRING, "my string hello",
- G_TYPE_INVALID,
- G_TYPE_UINT, &v_UINT32_2,
- G_TYPE_INVALID))
- lose ("Unexpected success for invalid Echo return values");
- g_clear_error (&error);
-
- g_print ("Invalid args 3; calling Echo\n");
- if (dbus_g_proxy_call (proxy, "Echo", &error,
- G_TYPE_STRING, "my string hello",
- G_TYPE_INVALID,
- G_TYPE_STRING, &v_STRING_2,
- G_TYPE_UINT, &v_UINT32_2,
- G_TYPE_INVALID))
- lose ("Unexpected success for invalid Echo return values");
- g_clear_error (&error);
-
- /* Test oneway call and signal handling */
-
- g_print ("Testing Foo emission\n");
- dbus_g_proxy_add_signal (proxy, "Foo", G_TYPE_DOUBLE, G_TYPE_INVALID);
-
- dbus_g_proxy_connect_signal (proxy, "Foo",
- G_CALLBACK (foo_signal_handler),
- NULL, NULL);
-
- dbus_g_proxy_call_no_reply (proxy, "EmitFoo",
- G_TYPE_INVALID);
-
- dbus_g_connection_flush (connection);
- exit_timeout = g_timeout_add (5000, timed_exit, loop);
- g_main_loop_run (loop);
-
- if (n_times_foo_received != 1)
- lose ("Foo signal received %d times, should have been 1", n_times_foo_received);
-
- /* Activate test servie */
- g_print ("Activating GLib.TestService\n");
- error = NULL;
- if (!dbus_g_proxy_call (driver, "StartServiceByName", &error,
- G_TYPE_STRING,
- "org.freedesktop.DBus.GLib.TestService",
- G_TYPE_UINT,
- 0,
- G_TYPE_INVALID,
- G_TYPE_UINT, &result,
- G_TYPE_INVALID)) {
- lose_gerror ("Failed to complete Activate call", error);
- }
-
- g_print ("GLib.TestService activated\n");
-
- if (getenv ("DBUS_GLIB_TEST_SLEEP_AFTER_ACTIVATION"))
- g_usleep (8 * G_USEC_PER_SEC);
-
- g_object_unref (G_OBJECT (proxy));
-
- run_mainloop ();
-
- proxy = dbus_g_proxy_new_for_name_owner (connection,
- "org.freedesktop.DBus.GLib.TestService",
- "/org/freedesktop/DBus/GLib/Tests/MyTestObject",
- "org.freedesktop.DBus.GLib.Tests.MyObject",
- &error);
-
- if (proxy == NULL)
- lose_gerror ("Failed to create proxy for name owner", error);
-
- g_print ("Calling DoNothing\n");
- if (!dbus_g_proxy_call (proxy, "DoNothing", &error,
- G_TYPE_INVALID, G_TYPE_INVALID))
- lose_gerror ("Failed to complete DoNothing call", error);
-
- g_print ("Calling Increment\n");
- error = NULL;
- if (!dbus_g_proxy_call (proxy, "Increment", &error,
- G_TYPE_UINT, 42,
- G_TYPE_INVALID,
- G_TYPE_UINT, &v_UINT32_2,
- G_TYPE_INVALID))
- lose_gerror ("Failed to complete Increment call", error);
- if (v_UINT32_2 != 43)
- lose ("Increment call returned %d, should be 43", v_UINT32_2);
-
- v_UINT32_2 = 0;
- g_print ("Calling Increment (async)\n");
- call = dbus_g_proxy_begin_call (proxy, "Increment",
- increment_received_cb, g_strdup ("moo"), g_free,
- G_TYPE_UINT, 42,
- G_TYPE_INVALID);
- if (call == NULL)
- lose ("Failed to begin Increment call");
-
- dbus_g_connection_flush (connection);
- cancel_exit_timeout ();
- exit_timeout = g_timeout_add (5000, timed_exit, loop);
- g_main_loop_run (loop);
-
- g_print ("Calling IncrementRetval\n");
- error = NULL;
- v_UINT32_2 = 0;
- if (!dbus_g_proxy_call (proxy, "IncrementRetval", &error,
- G_TYPE_UINT, 42,
- G_TYPE_INVALID,
- G_TYPE_UINT, &v_UINT32_2,
- G_TYPE_INVALID))
- lose_gerror ("Failed to complete Increment call", error);
- if (v_UINT32_2 != 43)
- lose ("IncrementRetval call returned %d, should be 43", v_UINT32_2);
-
- g_print ("Calling IncrementRetvalError\n");
- error = NULL;
- v_UINT32_2 = 0;
- if (!dbus_g_proxy_call (proxy, "IncrementRetvalError", &error,
- G_TYPE_UINT, 5,
- G_TYPE_INVALID,
- G_TYPE_UINT, &v_UINT32_2,
- G_TYPE_INVALID))
- lose_gerror ("Failed to complete Increment call", error);
- if (v_UINT32_2 != 6)
- lose ("IncrementRetval call returned %d, should be 6", v_UINT32_2);
-
- g_print ("Calling ThrowError\n");
- if (dbus_g_proxy_call (proxy, "ThrowError", &error,
- G_TYPE_INVALID, G_TYPE_INVALID) != FALSE)
- lose ("ThrowError call unexpectedly succeeded!");
-
- if (!dbus_g_error_has_name (error, "org.freedesktop.DBus.GLib.Tests.MyObject.Foo"))
- lose ("ThrowError call returned unexpected error \"%s\": %s", dbus_g_error_get_name (error),
- error->message);
-
- g_print ("ThrowError failed (as expected) returned error: %s\n", error->message);
- g_clear_error (&error);
-
- g_print ("Calling IncrementRetvalError (for error)\n");
- error = NULL;
- v_UINT32_2 = 0;
- if (dbus_g_proxy_call (proxy, "IncrementRetvalError", &error,
- G_TYPE_UINT, 20,
- G_TYPE_INVALID,
- G_TYPE_UINT, &v_UINT32_2,
- G_TYPE_INVALID) != FALSE)
- lose ("IncrementRetvalError call unexpectedly succeeded!");
- if (!dbus_g_error_has_name (error, "org.freedesktop.DBus.GLib.Tests.MyObject.Foo"))
- lose ("IncrementRetvalError call returned unexpected error \"%s\": %s", dbus_g_error_get_name (error), error->message);
- g_clear_error (&error);
-
- error = NULL;
- g_print ("Calling Uppercase\n");
- if (!dbus_g_proxy_call (proxy, "Uppercase", &error,
- G_TYPE_STRING, "foobar",
- G_TYPE_INVALID,
- G_TYPE_STRING, &v_STRING_2,
- G_TYPE_INVALID))
- lose_gerror ("Failed to complete Uppercase call", error);
- if (strcmp ("FOOBAR", v_STRING_2) != 0)
- lose ("Uppercase call returned unexpected string %s", v_STRING_2);
- g_free (v_STRING_2);
-
- run_mainloop ();
-
- g_print ("Calling ManyArgs\n");
- if (!dbus_g_proxy_call (proxy, "ManyArgs", &error,
- G_TYPE_UINT, 26,
- G_TYPE_STRING, "bazwhee",
- G_TYPE_DOUBLE, G_PI,
- G_TYPE_INVALID,
- G_TYPE_DOUBLE, &v_DOUBLE_2,
- G_TYPE_STRING, &v_STRING_2,
- G_TYPE_INVALID))
- lose_gerror ("Failed to complete ManyArgs call", error);
- if (v_DOUBLE_2 < 55 || v_DOUBLE_2 > 56)
- lose ("ManyArgs call returned unexpected double value %f", v_DOUBLE_2);
- if (strcmp ("BAZWHEE", v_STRING_2) != 0)
- lose ("ManyArgs call returned unexpected string %s", v_STRING_2);
- g_free (v_STRING_2);
-
- g_print ("Calling (wrapped) do_nothing\n");
- if (!org_freedesktop_DBus_GLib_Tests_MyObject_do_nothing (proxy, &error))
- lose_gerror ("Failed to complete (wrapped) DoNothing call", error);
-
- g_print ("Calling (wrapped) increment\n");
- if (!org_freedesktop_DBus_GLib_Tests_MyObject_increment (proxy, 42, &v_UINT32_2, &error))
- lose_gerror ("Failed to complete (wrapped) Increment call", error);
-
- if (v_UINT32_2 != 43)
- lose ("(wrapped) increment call returned %d, should be 43", v_UINT32_2);
-
- g_print ("Calling (wrapped async) increment\n");
- if (!org_freedesktop_DBus_GLib_Tests_MyObject_increment_async (proxy, 42, increment_async_cb, NULL))
- lose_gerror ("Failed to complete (wrapped) Increment call", error);
- dbus_g_connection_flush (connection);
- cancel_exit_timeout ();
- exit_timeout = g_timeout_add (5000, timed_exit, loop);
- g_main_loop_run (loop);
-
- v_UINT32_2 = 0;
- if (!org_freedesktop_DBus_GLib_Tests_MyObject_async_increment (proxy, 42, &v_UINT32_2, &error))
- lose_gerror ("Failed to complete (wrapped) AsyncIncrement call", error);
-
- if (v_UINT32_2 != 43)
- lose ("(wrapped) async increment call returned %d, should be 43", v_UINT32_2);
-
- g_print ("Calling (wrapped) throw_error\n");
- if (org_freedesktop_DBus_GLib_Tests_MyObject_throw_error (proxy, &error) != FALSE)
- lose ("(wrapped) ThrowError call unexpectedly succeeded!");
-
- g_print ("(wrapped) ThrowError failed (as expected) returned error: %s\n", error->message);
- g_clear_error (&error);
-
- g_print ("Calling (wrapped) uppercase\n");
- if (!org_freedesktop_DBus_GLib_Tests_MyObject_uppercase (proxy, "foobar", &v_STRING_2, &error))
- lose_gerror ("Failed to complete (wrapped) Uppercase call", error);
- if (strcmp ("FOOBAR", v_STRING_2) != 0)
- lose ("(wrapped) Uppercase call returned unexpected string %s", v_STRING_2);
- g_free (v_STRING_2);
-
- g_print ("Calling (wrapped) many_args\n");
- if (!org_freedesktop_DBus_GLib_Tests_MyObject_many_args (proxy, 26, "bazwhee", G_PI,
- &v_DOUBLE_2, &v_STRING_2, &error))
- lose_gerror ("Failed to complete (wrapped) ManyArgs call", error);
-
- if (v_DOUBLE_2 < 55 || v_DOUBLE_2 > 56)
-
- lose ("(wrapped) ManyArgs call returned unexpected double value %f", v_DOUBLE_2);
-
- if (strcmp ("BAZWHEE", v_STRING_2) != 0)
- lose ("(wrapped) ManyArgs call returned unexpected string %s", v_STRING_2);
- g_free (v_STRING_2);
-
- {
- guint32 arg0;
- char *arg1;
- gint32 arg2;
- guint32 arg3;
- guint32 arg4;
- char *arg5;
-
- g_print ("Calling (wrapped) many_return\n");
- if (!org_freedesktop_DBus_GLib_Tests_MyObject_many_return (proxy, &arg0, &arg1, &arg2, &arg3, &arg4, &arg5, &error))
- lose_gerror ("Failed to complete (wrapped) ManyReturn call", error);
-
- if (arg0 != 42)
- lose ("(wrapped) ManyReturn call returned unexpected guint32 value %u", arg0);
-
- if (strcmp ("42", arg1) != 0)
- lose ("(wrapped) ManyReturn call returned unexpected string %s", arg1);
- g_free (arg1);
-
- if (arg2 != -67)
- lose ("(wrapped) ManyReturn call returned unexpected gint32 value %u", arg2);
-
- if (arg3 != 2)
- lose ("(wrapped) ManyReturn call returned unexpected guint32 value %u", arg3);
-
- if (arg4 != 26)
- lose ("(wrapped) ManyReturn call returned unexpected guint32 value %u", arg4);
-
- if (strcmp ("hello world", arg5))
- lose ("(wrapped) ManyReturn call returned unexpected string %s", arg5);
- g_free (arg5);
- }
-
- run_mainloop ();
-
- {
- GValue value = {0, };
-
- g_value_init (&value, G_TYPE_STRING);
- g_value_set_string (&value, "foo");
-
- g_print ("Calling (wrapped) stringify, with string\n");
- if (!org_freedesktop_DBus_GLib_Tests_MyObject_stringify (proxy,
- &value,
- &v_STRING_2,
- &error))
- lose_gerror ("Failed to complete (wrapped) stringify call", error);
- if (strcmp ("foo", v_STRING_2) != 0)
- lose ("(wrapped) stringify call returned unexpected string %s", v_STRING_2);
- g_free (v_STRING_2);
-
- g_value_unset (&value);
- g_value_init (&value, G_TYPE_INT);
- g_value_set_int (&value, 42);
-
- g_print ("Calling (wrapped) stringify, with int\n");
- if (!org_freedesktop_DBus_GLib_Tests_MyObject_stringify (proxy,
- &value,
- &v_STRING_2,
- &error))
- lose_gerror ("Failed to complete (wrapped) stringify call 2", error);
- if (strcmp ("42", v_STRING_2) != 0)
- lose ("(wrapped) stringify call 2 returned unexpected string %s", v_STRING_2);
- g_value_unset (&value);
- g_free (v_STRING_2);
-
- g_value_init (&value, G_TYPE_INT);
- g_value_set_int (&value, 88);
- g_print ("Calling (wrapped) stringify, with another int\n");
- if (!org_freedesktop_DBus_GLib_Tests_MyObject_stringify (proxy,
- &value,
- NULL,
- &error))
- lose_gerror ("Failed to complete (wrapped) stringify call 3", error);
- g_value_unset (&value);
-
- g_print ("Calling (wrapped) unstringify, for string\n");
- if (!org_freedesktop_DBus_GLib_Tests_MyObject_unstringify (proxy,
- "foo",
- &value,
- &error))
- lose_gerror ("Failed to complete (wrapped) unstringify call", error);
- if (!G_VALUE_HOLDS_STRING (&value))
- lose ("(wrapped) unstringify call returned unexpected value type %d", (int) G_VALUE_TYPE (&value));
- if (strcmp (g_value_get_string (&value), "foo"))
- lose ("(wrapped) unstringify call returned unexpected string %s",
- g_value_get_string (&value));
-
- g_value_unset (&value);
-
- g_print ("Calling (wrapped) unstringify, for int\n");
- if (!org_freedesktop_DBus_GLib_Tests_MyObject_unstringify (proxy,
- "10",
- &value,
- &error))
- lose_gerror ("Failed to complete (wrapped) unstringify call", error);
- if (!G_VALUE_HOLDS_INT (&value))
- lose ("(wrapped) unstringify call returned unexpected value type %d", (int) G_VALUE_TYPE (&value));
- if (g_value_get_int (&value) != 10)
- lose ("(wrapped) unstringify call returned unexpected integer %d",
- g_value_get_int (&value));
-
- g_value_unset (&value);
- }
-
- run_mainloop ();
-
- {
- GArray *array;
- guint32 arraylen;
-
- array = g_array_new (FALSE, TRUE, sizeof (guint32));
-
- arraylen = 0;
- g_print ("Calling (wrapped) zero-length recursive1\n");
- if (!org_freedesktop_DBus_GLib_Tests_MyObject_recursive1 (proxy, array,
- &arraylen, &error))
- lose_gerror ("Failed to complete (wrapped) zero-length recursive1 call", error);
- if (arraylen != 0)
- lose ("(wrapped) zero-length recursive1 call returned invalid length %u", arraylen);
-
- g_array_unref (array);
- }
-
- {
- GArray *array;
- guint32 val;
- guint32 arraylen;
-
- array = g_array_new (FALSE, TRUE, sizeof (guint32));
- val = 42;
- g_array_append_val (array, val);
- val = 69;
- g_array_append_val (array, val);
- val = 88;
- g_array_append_val (array, val);
- val = 26;
- g_array_append_val (array, val);
- val = 2;
- g_array_append_val (array, val);
-
- arraylen = 0;
- g_print ("Calling (wrapped) recursive1\n");
- if (!org_freedesktop_DBus_GLib_Tests_MyObject_recursive1 (proxy, array,
- &arraylen, &error))
- lose_gerror ("Failed to complete (wrapped) recursive1 call", error);
- if (arraylen != 5)
- lose ("(wrapped) recursive1 call returned invalid length %u", arraylen);
-
- g_array_unref (array);
- }
-
- {
- GArray *array = NULL;
- guint32 *arrayvals;
-
- g_print ("Calling (wrapped) recursive2\n");
- if (!org_freedesktop_DBus_GLib_Tests_MyObject_recursive2 (proxy, 2, &array, &error))
- lose_gerror ("Failed to complete (wrapped) Recursive2 call", error);
-
- if (array == NULL)
- lose ("(wrapped) Recursive2 call returned NULL");
- if (array->len != 5)
- lose ("(wrapped) Recursive2 call returned unexpected array length %u", array->len);
-
- arrayvals = (guint32*) array->data;
- if (arrayvals[0] != 42)
- lose ("(wrapped) Recursive2 call returned unexpected value %d in position 0", arrayvals[0]);
- if (arrayvals[1] != 26)
- lose ("(wrapped) Recursive2 call returned unexpected value %d in position 1", arrayvals[1]);
- if (arrayvals[4] != 2)
- lose ("(wrapped) Recursive2 call returned unexpected value %d in position 4", arrayvals[4]);
-
- g_array_free (array, TRUE);
- }
-
- run_mainloop ();
-
- {
- const char *strs[] = { "hello", "HellO", "HELLO", NULL };
- char **strs_ret;
-
- strs_ret = NULL;
- g_print ("Calling (wrapped) many_uppercase\n");
- if (!org_freedesktop_DBus_GLib_Tests_MyObject_many_uppercase (proxy, strs, &strs_ret, &error))
- lose_gerror ("Failed to complete (wrapped) ManyUppercase call", error);
- g_assert (strs_ret != NULL);
- if (strcmp ("HELLO", strs_ret[0]) != 0)
- lose ("(wrapped) ManyUppercase call returned unexpected string %s", strs_ret[0]);
- if (strcmp ("HELLO", strs_ret[1]) != 0)
- lose ("(wrapped) ManyUppercase call returned unexpected string %s", strs_ret[1]);
- if (strcmp ("HELLO", strs_ret[2]) != 0)
- lose ("(wrapped) ManyUppercase call returned unexpected string %s", strs_ret[2]);
-
- g_strfreev (strs_ret);
- }
-
- {
- GHashTable *table;
- guint len;
-
- table = g_hash_table_new (g_str_hash, g_str_equal);
- g_hash_table_insert (table, "moooo", "b");
- g_hash_table_insert (table, "xxx", "cow!");
-
- len = 0;
- g_print ("Calling (wrapped) str_hash_len\n");
- if (!org_freedesktop_DBus_GLib_Tests_MyObject_str_hash_len (proxy, table, &len, &error))
- lose_gerror ("(wrapped) StrHashLen call failed", error);
- if (len != 13)
- lose ("(wrapped) StrHashLen returned unexpected length %u", len);
- g_hash_table_destroy (table);
- }
-
- {
- GHashTable *table;
- const char *val;
-
- g_print ("Calling (wrapped) get_hash\n");
- if (!org_freedesktop_DBus_GLib_Tests_MyObject_get_hash (proxy, &table, &error))
- lose_gerror ("(wrapped) GetHash call failed", error);
- val = g_hash_table_lookup (table, "foo");
- if (val == NULL || strcmp ("bar", val))
- lose ("(wrapped) StrHashLen returned invalid value %s for key \"foo\"",
- val ? val : "(null)");
- val = g_hash_table_lookup (table, "baz");
- if (val == NULL || strcmp ("whee", val))
- lose ("(wrapped) StrHashLen returned invalid value %s for key \"whee\"",
- val ? val : "(null)");
- val = g_hash_table_lookup (table, "cow");
- if (val == NULL || strcmp ("crack", val))
- lose ("(wrapped) StrHashLen returned invalid value %s for key \"cow\"",
- val ? val : "(null)");
- if (g_hash_table_size (table) != 3)
- lose ("(wrapped) StrHashLen returned unexpected hash size %u",
- g_hash_table_size (table));
-
- g_hash_table_destroy (table);
- }
-
- run_mainloop ();
-
- {
- GValueArray *vals;
- GValueArray *vals_ret;
- GValue *val;
-
- vals = g_value_array_new (3);
-
- g_value_array_append (vals, NULL);
- g_value_init (g_value_array_get_nth (vals, vals->n_values - 1), G_TYPE_STRING);
- g_value_set_string (g_value_array_get_nth (vals, 0), "foo");
-
- g_value_array_append (vals, NULL);
- g_value_init (g_value_array_get_nth (vals, vals->n_values - 1), G_TYPE_UINT);
- g_value_set_uint (g_value_array_get_nth (vals, vals->n_values - 1), 42);
-
- g_value_array_append (vals, NULL);
- g_value_init (g_value_array_get_nth (vals, vals->n_values - 1), G_TYPE_VALUE);
- val = g_new0 (GValue, 1);
- g_value_init (val, G_TYPE_UCHAR);
- g_value_set_uchar (val, '!');
- g_value_set_boxed (g_value_array_get_nth (vals, vals->n_values - 1), val);
-
- vals_ret = NULL;
- g_print ("Calling SendCar\n");
- if (!dbus_g_proxy_call (proxy, "SendCar", &error,
- G_TYPE_VALUE_ARRAY, vals,
- G_TYPE_INVALID,
- G_TYPE_VALUE_ARRAY, &vals_ret,
- G_TYPE_INVALID))
- lose_gerror ("Failed to complete SendCar call", error);
-
- g_assert (vals_ret != NULL);
- g_assert (vals_ret->n_values == 2);
-
- g_assert (G_VALUE_HOLDS_UINT (g_value_array_get_nth (vals_ret, 0)));
- g_assert (g_value_get_uint (g_value_array_get_nth (vals_ret, 0)) == 43);
-
- g_assert (G_VALUE_TYPE (g_value_array_get_nth (vals_ret, 1)) == DBUS_TYPE_G_OBJECT_PATH);
- g_assert (!strcmp ("/org/freedesktop/DBus/GLib/Tests/MyTestObject2",
- g_value_get_boxed (g_value_array_get_nth (vals_ret, 1))));
-
- g_free (val);
- g_value_array_free (vals);
- g_value_array_free (vals_ret);
- }
-
- {
- const gchar *in_sig = "a(iou)sq";
- gchar *out_sig = NULL;
-
- g_print ("Calling EchoSignature: %s\n", in_sig);
- if (!org_freedesktop_DBus_GLib_Tests_MyObject_echo_signature (proxy,
- in_sig, &out_sig, &error))
- lose_gerror ("Failed to complete EchoSignature call", error);
-
- if (out_sig == NULL)
- lose ("EchoSignature returned NULL");
- if (strcmp (in_sig, out_sig) != 0)
- lose ("EchoSignature changed the signature");
-
- g_print ("EchoSignature returned: %s\n", out_sig);
-
- g_free (out_sig);
- }
-
- {
- GValue *val;
- GHashTable *table;
- GHashTable *ret_table;
-
- table = g_hash_table_new_full (g_str_hash, g_str_equal,
- g_free, unset_and_free_gvalue);
-
- val = g_new0 (GValue, 1);
- g_value_init (val, G_TYPE_UINT);
- g_value_set_uint (val, 42);
- g_hash_table_insert (table, g_strdup ("foo"), val);
-
- val = g_new0 (GValue, 1);
- g_value_init (val, G_TYPE_STRING);
- g_value_set_string (val, "hello");
- g_hash_table_insert (table, g_strdup ("bar"), val);
-
- ret_table = NULL;
- g_print ("Calling ManyStringify\n");
- if (!dbus_g_proxy_call (proxy, "ManyStringify", &error,
- dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_VALUE), table,
- G_TYPE_INVALID,
- dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_VALUE), &ret_table,
- G_TYPE_INVALID))
- lose_gerror ("Failed to complete ManyStringify call", error);
-
- g_assert (ret_table != NULL);
- g_assert (g_hash_table_size (ret_table) == 2);
-
- val = g_hash_table_lookup (ret_table, "foo");
- g_assert (val != NULL);
- g_assert (G_VALUE_HOLDS_STRING (val));
- g_assert (!strcmp ("42", g_value_get_string (val)));
-
- val = g_hash_table_lookup (ret_table, "bar");
- g_assert (val != NULL);
- g_assert (G_VALUE_HOLDS_STRING (val));
- g_assert (!strcmp ("hello", g_value_get_string (val)));
-
- g_hash_table_destroy (table);
- g_hash_table_destroy (ret_table);
- }
-
- {
- GPtrArray *in_array;
- GPtrArray *out_array;
- char **strs;
- GArray *uints;
-
- in_array = g_ptr_array_new ();
-
- strs = g_new0 (char *, 3);
- strs[0] = "foo";
- strs[1] = "bar";
- strs[2] = NULL;
- g_ptr_array_add (in_array, strs);
-
- strs = g_new0 (char *, 4);
- strs[0] = "baz";
- strs[1] = "whee";
- strs[2] = "moo";
- strs[3] = NULL;
- g_ptr_array_add (in_array, strs);
-
- out_array = NULL;
- g_print ("Calling RecArrays\n");
- if (!dbus_g_proxy_call (proxy, "RecArrays", &error,
- dbus_g_type_get_collection ("GPtrArray", G_TYPE_STRV), in_array,
- G_TYPE_INVALID,
- dbus_g_type_get_collection ("GPtrArray",
- dbus_g_type_get_collection ("GPtrArray",
- G_TYPE_UINT)), &out_array,
- G_TYPE_INVALID))
- lose_gerror ("Failed to complete RecArrays call", error);
- g_free (g_ptr_array_index (in_array, 0));
- g_free (g_ptr_array_index (in_array, 1));
- g_ptr_array_free (in_array, TRUE);
-
- g_assert (out_array);
- g_assert (out_array->len == 2);
- uints = g_ptr_array_index (out_array, 0);
- g_assert (uints);
- g_assert (uints->len == 3);
- g_assert (g_array_index (uints, guint, 0) == 10);
- g_assert (g_array_index (uints, guint, 1) == 42);
- g_assert (g_array_index (uints, guint, 2) == 27);
- g_array_free (uints, TRUE);
- uints = g_ptr_array_index (out_array, 1);
- g_assert (uints);
- g_assert (uints->len == 1);
- g_assert (g_array_index (uints, guint, 0) == 30);
- g_array_free (uints, TRUE);
- g_ptr_array_free (out_array, TRUE);
- }
-
- {
- guint val;
- char *ret_path;
- DBusGProxy *ret_proxy;
-
- g_print ("Calling (wrapped) objpath\n");
- if (!dbus_g_proxy_call (proxy, "Objpath", &error,
- DBUS_TYPE_G_PROXY, proxy, G_TYPE_INVALID,
- DBUS_TYPE_G_PROXY, &ret_proxy, G_TYPE_INVALID))
- lose_gerror ("Failed to complete Objpath call", error);
- if (strcmp ("/org/freedesktop/DBus/GLib/Tests/MyTestObject2",
- dbus_g_proxy_get_path (ret_proxy)) != 0)
- lose ("(wrapped) objpath call returned unexpected proxy %s",
- dbus_g_proxy_get_path (ret_proxy));
-
- g_print ("Doing get/increment val tests\n");
- val = 1;
- if (!org_freedesktop_DBus_GLib_Tests_MyObject_get_val (ret_proxy, &val, &error))
- lose_gerror ("Failed to complete (wrapped) GetVal call", error);
- if (val != 0)
- lose ("(wrapped) GetVal returned invalid value %d", val);
-
- if (!org_freedesktop_DBus_GLib_Tests_MyObject_increment_val (ret_proxy, &error))
- lose_gerror ("Failed to complete (wrapped) IncrementVal call", error);
-
- if (!org_freedesktop_DBus_GLib_Tests_MyObject_increment_val (ret_proxy, &error))
- lose_gerror ("Failed to complete (wrapped) IncrementVal call", error);
-
- if (!org_freedesktop_DBus_GLib_Tests_MyObject_increment_val (ret_proxy, &error))
- lose_gerror ("Failed to complete (wrapped) IncrementVal call", error);
-
- if (!org_freedesktop_DBus_GLib_Tests_MyObject_get_val (ret_proxy, &val, &error))
- lose_gerror ("Failed to complete (wrapped) GetVal call", error);
- if (val != 3)
- lose ("(wrapped) GetVal returned invalid value %d", val);
-
- if (!org_freedesktop_DBus_GLib_Tests_MyObject_get_val (proxy, &val, &error))
- lose_gerror ("Failed to complete (wrapped) GetVal call", error);
- if (val != 0)
- lose ("(wrapped) GetVal returned invalid value %d", val);
-
- if (!org_freedesktop_DBus_GLib_Tests_MyObject_increment_val (proxy, &error))
- lose_gerror ("Failed to complete (wrapped) IncrementVal call", error);
-
- if (!org_freedesktop_DBus_GLib_Tests_MyObject_get_val (proxy, &val, &error))
- lose_gerror ("Failed to complete (wrapped) GetVal call", error);
- if (val != 1)
- lose ("(wrapped) GetVal returned invalid value %d", val);
-
- if (!org_freedesktop_DBus_GLib_Tests_MyObject_get_val (ret_proxy, &val, &error))
- lose_gerror ("Failed to complete (wrapped) GetVal call", error);
- if (val != 3)
- lose ("(wrapped) GetVal returned invalid value %d", val);
-
- g_object_unref (G_OBJECT (ret_proxy));
-
- g_print ("Calling objpath again\n");
- ret_proxy = NULL;
-
- if (!dbus_g_proxy_call (proxy, "Objpath", &error,
- DBUS_TYPE_G_OBJECT_PATH,
- dbus_g_proxy_get_path (proxy),
- G_TYPE_INVALID,
- DBUS_TYPE_G_OBJECT_PATH,
- &ret_path,
- G_TYPE_INVALID))
- lose_gerror ("Failed to complete Objpath call 2", error);
- if (strcmp ("/org/freedesktop/DBus/GLib/Tests/MyTestObject2", ret_path) != 0)
- lose ("Objpath call 2 returned unexpected path %s",
- ret_path);
-
- ret_proxy = dbus_g_proxy_new_for_name_owner (connection,
- "org.freedesktop.DBus.GLib.TestService",
- ret_path,
- "org.freedesktop.DBus.GLib.Tests.FooObject",
- &error);
- g_free (ret_path);
-
- val = 0;
- if (!org_freedesktop_DBus_GLib_Tests_FooObject_get_value (ret_proxy, &val, &error))
- lose_gerror ("Failed to complete (wrapped) GetValue call", error);
- if (val != 3)
- lose ("(wrapped) GetValue returned invalid value %d", val);
-
- g_object_unref (ret_proxy);
- }
-
- run_mainloop ();
-
- {
- GPtrArray *objs;
- guint i;
-
- g_print ("Calling GetObjs\n");
-
- if (!dbus_g_proxy_call (proxy, "GetObjs", &error, G_TYPE_INVALID,
- dbus_g_type_get_collection ("GPtrArray", DBUS_TYPE_G_OBJECT_PATH),
- &objs,
- G_TYPE_INVALID))
- lose_gerror ("Failed to complete GetObjs call", error);
- if (objs->len != 2)
- lose ("GetObjs call returned unexpected number of objects %d, expected 2",
- objs->len);
-
- if (strcmp ("/org/freedesktop/DBus/GLib/Tests/MyTestObject",
- g_ptr_array_index (objs, 0)) != 0)
- lose ("GetObjs call returned unexpected path \"%s\" in position 0; expected /org/freedesktop/DBus/GLib/Tests/MyTestObject", (char*) g_ptr_array_index (objs, 0));
-
- if (strcmp ("/org/freedesktop/DBus/GLib/Tests/MyTestObject2",
- g_ptr_array_index (objs, 1)) != 0)
- lose ("GetObjs call returned unexpected path \"%s\" in position 1; expected /org/freedesktop/DBus/GLib/Tests/MyTestObject2", (char*) g_ptr_array_index (objs, 1));
-
- for (i = 0; i < objs->len; i++)
- g_free (g_ptr_array_index (objs, i));
- g_ptr_array_free (objs, TRUE);
- }
-
- {
- GValue *variant;
- GArray *array;
- gint i;
-
- g_print ("Calling ProcessVariantOfArrayOfInts123\n");
-
- array = g_array_sized_new (FALSE, FALSE, sizeof(gint), 3);
- i = 1;
- g_array_append_val (array, i);
- i++;
- g_array_append_val (array, i);
- i++;
- g_array_append_val (array, i);
-
- variant = g_new0 (GValue, 1);
- g_value_init (variant, dbus_g_type_get_collection ("GArray", G_TYPE_INT));
- g_value_take_boxed (variant, array);
-
- if (!dbus_g_proxy_call (proxy, "ProcessVariantOfArrayOfInts123", &error,
- G_TYPE_VALUE, variant,
- G_TYPE_INVALID,
- G_TYPE_INVALID))
- lose_gerror ("Failed to send a vairant of array of ints 1, 2 and 3!", error);
-
- g_value_unset (variant);
- g_free (variant);
- }
-
- for (i=0; i<3; i++)
- {
- gchar *val;
- GHashTable *table;
- GHashTable *subtable;
- GHashTable *ret_table;
-
- table = g_hash_table_new_full (g_str_hash, g_str_equal,
- (GDestroyNotify) (g_free),
- (GDestroyNotify) (g_hash_table_destroy));
-
- subtable = g_hash_table_new_full (g_str_hash, g_str_equal,
- (GDestroyNotify) (g_free),
- (GDestroyNotify) (g_free));
- g_hash_table_insert (subtable, g_strdup ("foo"), g_strdup("1"));
- g_hash_table_insert (subtable, g_strdup ("bar"), g_strdup("2"));
- g_hash_table_insert (subtable, g_strdup ("baz"), g_strdup("3"));
-
- g_hash_table_insert (table, g_strdup("dict1"), subtable);
-
- subtable = g_hash_table_new_full (g_str_hash, g_str_equal,
- (GDestroyNotify) (g_free),
- (GDestroyNotify) (g_free));
- g_hash_table_insert (subtable, g_strdup ("foo"), g_strdup("4"));
- g_hash_table_insert (subtable, g_strdup ("bar"), g_strdup("5"));
- g_hash_table_insert (subtable, g_strdup ("baz"), g_strdup("6"));
-
- g_hash_table_insert (table, g_strdup("dict2"), subtable);
-
- subtable = NULL;
-
- ret_table = NULL;
-
- g_print ("Calling DictOfDicts\n");
- if (!dbus_g_proxy_call (proxy, "DictOfDicts", &error,
- dbus_g_type_get_map ("GHashTable", G_TYPE_STRING,
- dbus_g_type_get_map ("GHashTable", G_TYPE_STRING,
- G_TYPE_STRING)), table,
- G_TYPE_INVALID,
- dbus_g_type_get_map ("GHashTable", G_TYPE_STRING,
- dbus_g_type_get_map ("GHashTable", G_TYPE_STRING,
- G_TYPE_STRING)), &ret_table,
- G_TYPE_INVALID))
- lose_gerror ("Failed to complete DictOfDicts call", error);
-
- g_assert (ret_table != NULL);
- g_assert (g_hash_table_size (ret_table) == 2);
-
- subtable = g_hash_table_lookup (ret_table, "dict1");
- g_assert(subtable);
- g_assert (g_hash_table_size (subtable) == 3);
-
- val = g_hash_table_lookup (subtable, "foo");
- g_assert (val != NULL);
- g_assert (!strcmp ("dict1 1", val));
-
- val = g_hash_table_lookup (subtable, "bar");
- g_assert (val != NULL);
- g_assert (!strcmp ("dict1 2", val));
-
- val = g_hash_table_lookup (subtable, "baz");
- g_assert (val != NULL);
- g_assert (!strcmp ("dict1 3", val));
-
- subtable = g_hash_table_lookup (ret_table, "dict2");
- g_assert(subtable);
- g_assert (g_hash_table_size (subtable) == 3);
-
- val = g_hash_table_lookup (subtable, "foo");
- g_assert (val != NULL);
- g_assert (!strcmp ("dict2 4", val));
-
- val = g_hash_table_lookup (subtable, "bar");
- g_assert (val != NULL);
- g_assert (!strcmp ("dict2 5", val));
-
- val = g_hash_table_lookup (subtable, "baz");
- g_assert (val != NULL);
- g_assert (!strcmp ("dict2 6", val));
-
- g_hash_table_destroy (table);
- g_hash_table_destroy (ret_table);
- }
-
- for (i=0; i<3; i++)
- {
- GHashTable *table;
- GHashTable *ret_table = NULL;
- const gchar *foo[] = { "foo", NULL };
- const gchar *bar[] = { "bar", "baz", NULL };
- const gchar **ret_foo = NULL, **ret_bar = NULL;
-
- table = g_hash_table_new (g_str_hash, g_str_equal);
- g_hash_table_insert (table, "dub", foo);
- g_hash_table_insert (table, "sox", bar);
-
- g_print ("Calling DictOfSigs\n");
-
- if (!org_freedesktop_DBus_GLib_Tests_MyObject_dict_of_sigs (proxy, table,
- &ret_table, &error))
- lose_gerror ("Failed to complete DictOfSigs call", error);
-
- if (ret_table == NULL)
- lose ("DictOfSigs didn't return a hash table");
-
- if (g_hash_table_size (ret_table) != 2)
- lose ("DictOfSigs has too many entries");
-
- ret_foo = g_hash_table_lookup (ret_table, "dub");
- ret_bar = g_hash_table_lookup (ret_table, "sox");
-
- if (ret_foo == NULL || ret_bar == NULL)
- lose ("DictOfSigs is missing entries");
-
- if (ret_foo[0] == NULL ||
- ret_foo[1] != NULL ||
- strcmp (ret_foo[0], "foo") != 0)
- lose ("DictOfSigs mangled foo");
-
- if (ret_bar[0] == NULL ||
- ret_bar[1] == NULL ||
- ret_bar[2] != NULL ||
- strcmp (ret_bar[0], "bar") != 0 ||
- strcmp (ret_bar[1], "baz") != 0)
- lose ("DictOfSigs mangled bar");
-
- g_hash_table_destroy (table);
- g_hash_table_destroy (ret_table);
- }
-
- for (i=0; i<3; i++)
- {
- GHashTable *table;
- GHashTable *ret_table = NULL;
- GPtrArray *foo, *bar;
- GPtrArray *ret_foo = NULL, *ret_bar = NULL;
-
- foo = g_ptr_array_new ();
- g_ptr_array_add (foo, "/foo");
-
- bar = g_ptr_array_new ();
- g_ptr_array_add (bar, "/bar");
- g_ptr_array_add (bar, "/baz");
-
- table = g_hash_table_new (g_str_hash, g_str_equal);
- g_hash_table_insert (table, "/foo", foo);
- g_hash_table_insert (table, "/bar", bar);
-
- g_print ("Calling DictOfObjs\n");
-
- if (!org_freedesktop_DBus_GLib_Tests_MyObject_dict_of_objs (proxy, table,
- &ret_table, &error))
- lose_gerror ("Failed to complete DictOfObjs call", error);
-
- g_ptr_array_free (foo, TRUE);
- g_ptr_array_free (bar, TRUE);
- g_hash_table_destroy (table);
-
- if (ret_table == NULL)
- lose ("DictOfObjs didn't return a hash table");
-
- if (g_hash_table_size (ret_table) != 2)
- lose ("DictOfObjs has too many entries");
-
- ret_foo = g_hash_table_lookup (ret_table, "/foo");
- ret_bar = g_hash_table_lookup (ret_table, "/bar");
-
- if (ret_foo == NULL || ret_bar == NULL)
- lose ("DictOfObjs is missing entries");
-
- if (ret_foo->len != 1 ||
- strcmp (g_ptr_array_index (ret_foo, 0), "/foo") != 0)
- lose ("DictOfObjs mangled /foo");
-
- if (ret_bar->len != 2 ||
- strcmp (g_ptr_array_index (ret_bar, 0), "/bar") != 0 ||
- strcmp (g_ptr_array_index (ret_bar, 1), "/baz") != 0)
- lose ("DictOfObjs mangled /bar");
-
- g_boxed_free (dbus_g_type_get_map ("GHashTable", DBUS_TYPE_G_OBJECT_PATH,
- dbus_g_type_get_collection ("GPtrArray", DBUS_TYPE_G_OBJECT_PATH)), ret_table);
- }
-
-
-
- /* Signal handling tests */
-
- g_print ("Testing signal handling\n");
- dbus_g_proxy_add_signal (proxy, "Frobnicate", G_TYPE_INT, G_TYPE_INVALID);
-
- dbus_g_proxy_connect_signal (proxy, "Frobnicate",
- G_CALLBACK (frobnicate_signal_handler),
- NULL, NULL);
-
- g_print ("Calling EmitFrobnicate\n");
- if (!dbus_g_proxy_call (proxy, "EmitFrobnicate", &error,
- G_TYPE_INVALID, G_TYPE_INVALID))
- lose_gerror ("Failed to complete EmitFrobnicate call", error);
-
-
- dbus_g_connection_flush (connection);
- cancel_exit_timeout ();
- exit_timeout = g_timeout_add (5000, timed_exit, loop);
- g_main_loop_run (loop);
-
- if (n_times_frobnicate_received != 1)
- lose ("Frobnicate signal received %d times, should have been 1", n_times_frobnicate_received);
-
- g_print ("Calling EmitFrobnicate again\n");
- if (!dbus_g_proxy_call (proxy, "EmitFrobnicate", &error,
- G_TYPE_INVALID, G_TYPE_INVALID))
- lose_gerror ("Failed to complete EmitFrobnicate call", error);
-
- dbus_g_connection_flush (connection);
- cancel_exit_timeout ();
- exit_timeout = g_timeout_add (5000, timed_exit, loop);
- g_main_loop_run (loop);
-
- if (n_times_frobnicate_received != 2)
- lose ("Frobnicate signal received %d times, should have been 2", n_times_frobnicate_received);
-
- g_object_unref (G_OBJECT (proxy));
-
- run_mainloop ();
-
- g_print ("Creating proxy for FooObject interface\n");
- proxy = dbus_g_proxy_new_for_name_owner (connection,
- "org.freedesktop.DBus.GLib.TestService",
- "/org/freedesktop/DBus/GLib/Tests/MyTestObject",
- "org.freedesktop.DBus.GLib.Tests.FooObject",
- &error);
-
- if (proxy == NULL)
- lose_gerror ("Failed to create proxy for name owner", error);
-
- dbus_g_proxy_add_signal (proxy, "Sig0", G_TYPE_STRING, G_TYPE_INT, G_TYPE_STRING, G_TYPE_INVALID);
- dbus_g_proxy_add_signal (proxy, "Sig1", G_TYPE_STRING, G_TYPE_VALUE, G_TYPE_INVALID);
- dbus_g_proxy_add_signal (proxy, "Sig2", DBUS_TYPE_G_STRING_STRING_HASHTABLE, G_TYPE_INVALID);
-
- dbus_g_proxy_connect_signal (proxy, "Sig0",
- G_CALLBACK (sig0_signal_handler),
- NULL, NULL);
- dbus_g_proxy_connect_signal (proxy, "Sig1",
- G_CALLBACK (sig1_signal_handler),
- NULL, NULL);
- dbus_g_proxy_connect_signal (proxy, "Sig2",
- G_CALLBACK (sig2_signal_handler),
- NULL, NULL);
-
- g_print ("Calling FooObject EmitSignals\n");
- dbus_g_proxy_call_no_reply (proxy, "EmitSignals", G_TYPE_INVALID);
-
- dbus_g_connection_flush (connection);
- cancel_exit_timeout ();
- exit_timeout = g_timeout_add (5000, timed_exit, loop);
- g_main_loop_run (loop);
- cancel_exit_timeout ();
- exit_timeout = g_timeout_add (5000, timed_exit, loop);
- g_main_loop_run (loop);
-
- if (n_times_sig0_received != 1)
- lose ("Sig0 signal received %d times, should have been 1", n_times_sig0_received);
- if (n_times_sig1_received != 1)
- lose ("Sig1 signal received %d times, should have been 1", n_times_sig1_received);
-
- g_print ("Calling FooObject EmitSignals and EmitSignal2\n");
- dbus_g_proxy_call_no_reply (proxy, "EmitSignal2", G_TYPE_INVALID);
- dbus_g_connection_flush (connection);
-
- cancel_exit_timeout ();
- exit_timeout = g_timeout_add (5000, timed_exit, loop);
- g_main_loop_run (loop);
-
- if (n_times_sig2_received != 1)
- lose ("Sig2 signal received %d times, should have been 1", n_times_sig2_received);
-
- g_print ("Calling FooObject EmitSignals two more times\n");
- dbus_g_proxy_call_no_reply (proxy, "EmitSignals", G_TYPE_INVALID);
- dbus_g_proxy_call_no_reply (proxy, "EmitSignals", G_TYPE_INVALID);
-
- dbus_g_connection_flush (connection);
- cancel_exit_timeout ();
- exit_timeout = g_timeout_add (5000, timed_exit, loop);
- g_main_loop_run (loop);
- cancel_exit_timeout ();
- exit_timeout = g_timeout_add (5000, timed_exit, loop);
- g_main_loop_run (loop);
- cancel_exit_timeout ();
- exit_timeout = g_timeout_add (5000, timed_exit, loop);
- g_main_loop_run (loop);
- cancel_exit_timeout ();
- exit_timeout = g_timeout_add (5000, timed_exit, loop);
- g_main_loop_run (loop);
-
- if (n_times_sig0_received != 3)
- lose ("Sig0 signal received %d times, should have been 3", n_times_sig0_received);
- if (n_times_sig1_received != 3)
- lose ("Sig1 signal received %d times, should have been 3", n_times_sig1_received);
-
- /* Terminate again */
- g_print ("Terminating service\n");
- await_terminating_service = "org.freedesktop.DBus.GLib.TestService";
- dbus_g_proxy_call_no_reply (proxy, "Terminate", G_TYPE_INVALID);
-
- proxy_destroyed = FALSE;
- proxy_destroy_and_nameowner = TRUE;
- proxy_destroy_and_nameowner_complete = FALSE;
-
- g_signal_connect (G_OBJECT (proxy),
- "destroy",
- G_CALLBACK (proxy_destroyed_cb),
- NULL);
-
- dbus_g_connection_flush (connection);
- cancel_exit_timeout ();
- exit_timeout = g_timeout_add (5000, timed_exit, loop);
- g_main_loop_run (loop);
-
- if (await_terminating_service != NULL)
- lose ("Didn't see name loss for \"org.freedesktop.DBus.GLib.TestService\"");
- if (!proxy_destroyed)
- lose ("Didn't get proxy_destroyed");
- g_print ("Proxy destroyed successfully\n");
-
- /* "destroy" does not mean last-unref! */
- g_object_unref (proxy);
-
- run_mainloop ();
-
- /* Create a new proxy for the name; should not be associated */
- proxy = dbus_g_proxy_new_for_name (connection,
- "org.freedesktop.DBus.GLib.TestService",
- "/org/freedesktop/DBus/GLib/Tests/MyTestObject",
- "org.freedesktop.DBus.GLib.Tests.MyObject");
- g_assert (proxy != NULL);
-
- proxy_destroyed = FALSE;
- proxy_destroy_and_nameowner = FALSE;
- proxy_destroy_and_nameowner_complete = FALSE;
-
- g_signal_connect (G_OBJECT (proxy),
- "destroy",
- G_CALLBACK (proxy_destroyed_cb),
- NULL);
-
- if (!dbus_g_proxy_call (driver, "GetNameOwner", &error,
- G_TYPE_STRING,
- "org.freedesktop.DBus.GLib.TestService",
- G_TYPE_INVALID,
- G_TYPE_STRING,
- &v_STRING_2,
- G_TYPE_INVALID)) {
- if (error->domain == DBUS_GERROR && error->code == DBUS_GERROR_NAME_HAS_NO_OWNER)
- g_print ("Got expected error \"org.freedesktop.DBus.Error.NameHasNoOwner\"\n");
- else
- lose_gerror ("Unexpected error from GetNameOwner", error);
- } else
- lose ("GetNameOwner unexpectedly succeeded!");
- g_clear_error (&error);
-
- /* This will have the side-effect of activating the service, thus
- * causing a NameOwnerChanged, which should let our name proxy
- * get signals
- */
- g_print ("Calling Uppercase for name proxy\n");
- if (!dbus_g_proxy_call (proxy, "Uppercase", &error,
- G_TYPE_STRING, "bazwhee",
- G_TYPE_INVALID,
- G_TYPE_STRING, &v_STRING_2,
- G_TYPE_INVALID))
- lose_gerror ("Failed to complete Uppercase call", error);
- g_free (v_STRING_2);
-
- if (getenv ("DBUS_GLIB_TEST_SLEEP_AFTER_ACTIVATION1"))
- g_usleep (8 * G_USEC_PER_SEC);
-
- dbus_g_proxy_add_signal (proxy, "Frobnicate", G_TYPE_INT, G_TYPE_INVALID);
-
- dbus_g_proxy_connect_signal (proxy, "Frobnicate",
- G_CALLBACK (frobnicate_signal_handler),
- NULL, NULL);
-
- g_print ("Calling EmitFrobnicate\n");
- if (!dbus_g_proxy_call (proxy, "EmitFrobnicate", &error,
- G_TYPE_INVALID, G_TYPE_INVALID))
- lose_gerror ("Failed to complete EmitFrobnicate call", error);
-
- n_times_frobnicate_received = 0;
-
- dbus_g_connection_flush (connection);
- cancel_exit_timeout ();
- exit_timeout = g_timeout_add (5000, timed_exit, loop);
- g_main_loop_run (loop);
-
- if (n_times_frobnicate_received != 1)
- lose ("Frobnicate signal received %d times, should have been 1", n_times_frobnicate_received);
-
- /* Now terminate the service, then start it again (implicitly) and wait for signals */
- g_print ("Terminating service (2)\n");
- await_terminating_service = "org.freedesktop.DBus.GLib.TestService";
- dbus_g_proxy_call_no_reply (proxy, "Terminate", G_TYPE_INVALID);
- dbus_g_connection_flush (connection);
- cancel_exit_timeout ();
- exit_timeout = g_timeout_add (5000, timed_exit, loop);
- g_main_loop_run (loop);
- if (await_terminating_service != NULL)
- lose ("Didn't see name loss for \"org.freedesktop.DBus.GLib.TestService\"");
-
- if (proxy_destroyed)
- lose ("Unexpectedly got proxy_destroyed!");
-
- n_times_frobnicate_received = 0;
-
- g_print ("Calling EmitFrobnicate (2)\n");
- if (!dbus_g_proxy_call (proxy, "EmitFrobnicate", &error,
- G_TYPE_INVALID, G_TYPE_INVALID))
- lose_gerror ("Failed to complete EmitFrobnicate call", error);
-
- if (getenv ("DBUS_GLIB_TEST_SLEEP_AFTER_ACTIVATION2"))
- g_usleep (8 * G_USEC_PER_SEC);
-
- dbus_g_connection_flush (connection);
- cancel_exit_timeout ();
- exit_timeout = g_timeout_add (5000, timed_exit, loop);
- g_main_loop_run (loop);
-
- if (n_times_frobnicate_received != 1)
- lose ("Frobnicate signal received %d times, should have been 1", n_times_frobnicate_received);
-
- if (proxy_destroyed)
- lose ("Unexpectedly got proxy_destroyed!");
-
- /* Create another proxy for the name; should be associated immediately */
- proxy2 = dbus_g_proxy_new_for_name (connection,
- "org.freedesktop.DBus.GLib.TestService",
- "/org/freedesktop/DBus/GLib/Tests/MyTestObject",
- "org.freedesktop.DBus.GLib.Tests.MyObject");
- g_assert (proxy2 != NULL);
-
- dbus_g_proxy_add_signal (proxy2, "Frobnicate", G_TYPE_INT, G_TYPE_INVALID);
-
- dbus_g_proxy_connect_signal (proxy2, "Frobnicate",
- G_CALLBACK (frobnicate_signal_handler_2),
- NULL, NULL);
-
- g_print ("Calling EmitFrobnicate (3)\n");
- if (!dbus_g_proxy_call (proxy, "EmitFrobnicate", &error,
- G_TYPE_INVALID, G_TYPE_INVALID))
- lose_gerror ("Failed to complete EmitFrobnicate call", error);
-
- dbus_g_connection_flush (connection);
- cancel_exit_timeout ();
- exit_timeout = g_timeout_add (5000, timed_exit, loop);
- g_main_loop_run (loop);
-
- if (n_times_frobnicate_received != 2)
- lose ("Frobnicate signal received %d times for 1st proxy, should have been 2", n_times_frobnicate_received);
- if (n_times_frobnicate_received_2 != 1)
- lose ("Frobnicate signal received %d times for 2nd proxy, should have been 1", n_times_frobnicate_received_2);
-
- g_object_unref (G_OBJECT (proxy));
- g_object_unref (G_OBJECT (proxy2));
-
- run_mainloop ();
-
- /* Tests for a "compatibilty" object path. This is the same object as above, just
- * at a different path.
- */
- proxy = dbus_g_proxy_new_for_name_owner (connection,
- "org.freedesktop.DBus.GLib.TestService",
- "/org/freedesktop/DBus/GLib/Tests/Compat/MyTestObjectCompat",
- "org.freedesktop.DBus.GLib.Tests.MyObject",
- &error);
- dbus_g_proxy_add_signal (proxy, "Frobnicate", G_TYPE_INT, G_TYPE_INVALID);
-
- dbus_g_proxy_connect_signal (proxy, "Frobnicate",
- G_CALLBACK (frobnicate_signal_handler_compat),
- NULL, NULL);
-
- g_print ("Calling EmitFrobnicate (compat)\n");
- if (!dbus_g_proxy_call (proxy, "EmitFrobnicate", &error,
- G_TYPE_INVALID, G_TYPE_INVALID))
- lose_gerror ("Failed to complete EmitFrobnicate call on compat proxy", error);
-
- g_main_loop_run (loop);
-
- if (n_times_compat_frobnicate_received != 1)
- lose ("Frobnicate signal received %d times for compat proxy, should have been 1", n_times_compat_frobnicate_received);
-
- g_object_unref (proxy);
-
- /* Test introspection */
- proxy = dbus_g_proxy_new_for_name_owner (connection,
- "org.freedesktop.DBus.GLib.TestService",
- "/org/freedesktop/DBus/GLib/Tests/MyTestObject",
- "org.freedesktop.DBus.Introspectable",
- &error);
- if (proxy == NULL)
- lose_gerror ("Failed to create proxy for name owner", error);
-
- g_print ("Testing introspect\n");
- if (!dbus_g_proxy_call (proxy, "Introspect", &error,
- G_TYPE_INVALID,
- G_TYPE_STRING, &v_STRING_2,
- G_TYPE_INVALID))
- lose_gerror ("Failed to complete Introspect call", error);
-
- /* Could just do strcmp(), but that seems more fragile */
- {
- NodeInfo *node;
- GSList *elt;
- gboolean found_introspectable;
- gboolean found_properties;
- gboolean found_myobject;
- gboolean found_fooobject;
-
- node = description_load_from_string (v_STRING_2, strlen (v_STRING_2), &error);
- if (!node)
- lose_gerror ("Failed to parse introspection data: %s", error);
-
- found_introspectable = FALSE;
- found_properties = FALSE;
- found_myobject = FALSE;
- found_fooobject = FALSE;
- for (elt = node_info_get_interfaces (node); elt ; elt = elt->next)
- {
- InterfaceInfo *iface = elt->data;
-
- if (!found_introspectable && strcmp (interface_info_get_name (iface), "org.freedesktop.DBus.Introspectable") == 0)
- found_introspectable = TRUE;
- else if (!found_properties && strcmp (interface_info_get_name (iface), "org.freedesktop.DBus.Properties") == 0)
- found_properties = TRUE;
- else if (!found_myobject && strcmp (interface_info_get_name (iface), "org.freedesktop.DBus.GLib.Tests.MyObject") == 0)
- {
- GSList *elt;
- gboolean found_manyargs;
- gboolean found_no_touching = FALSE;
-
- found_myobject = TRUE;
-
- found_manyargs = FALSE;
- for (elt = interface_info_get_methods (iface); elt; elt = elt->next)
- {
- MethodInfo *method;
-
- method = elt->data;
- if (strcmp (method_info_get_name (method), "ManyArgs") == 0)
- {
- found_manyargs = TRUE;
- break;
- }
- }
- if (!found_manyargs)
- lose ("Missing method org.freedesktop.DBus.GLib.Tests.MyObject.ManyArgs");
- for (elt = interface_info_get_properties (iface); elt; elt = elt->next)
- {
- PropertyInfo *prop = elt->data;
-
- if (strcmp (property_info_get_name (prop), "no-touching") == 0)
- {
- if (property_info_get_access (prop) != PROPERTY_READ)
- lose ("property no-touching had incorrect access %d", property_info_get_access (prop));
- else
- {
- found_no_touching = TRUE;
- break;
- }
- }
- }
- if (!found_no_touching)
- lose ("didn't find property \"no-touching\" in org.freedesktop.DBus.GLib.Tests.MyObject");
- }
- else if (!found_fooobject && strcmp (interface_info_get_name (iface), "org.freedesktop.DBus.GLib.Tests.FooObject") == 0)
- found_fooobject = TRUE;
- else
- lose ("Unexpected or duplicate interface %s", interface_info_get_name (iface));
- }
-
- if (!(found_introspectable && found_myobject && found_properties))
- lose ("Missing interface");
-
- node_info_unref (node);
- }
- g_free (v_STRING_2);
-
- /* Properties tests */
- property_proxy = dbus_g_proxy_new_from_proxy (proxy, DBUS_INTERFACE_PROPERTIES, NULL);
- g_object_unref (proxy);
- proxy = NULL;
-
- g_print ("Calling GetProperty (1)\n");
- {
- GValue value = {0,};
- if (!dbus_g_proxy_call (property_proxy, "Get", &error,
- G_TYPE_STRING, "org.freedesktop.DBus.GLib.Tests.MyObject",
- G_TYPE_STRING, "this_is_a_string",
- G_TYPE_INVALID,
- G_TYPE_VALUE, &value, G_TYPE_INVALID))
- lose_gerror ("Failed to complete GetProperty call", error);
- g_assert (G_VALUE_HOLDS (&value, G_TYPE_STRING));
- g_assert (!strcmp (g_value_get_string (&value), ""));
- g_value_unset (&value);
- }
-
- g_print ("Calling SetProperty (1)\n");
- {
- GValue value = {0,};
- g_value_init (&value, G_TYPE_STRING);
- g_value_set_string (&value, "testing value");
- if (!dbus_g_proxy_call (property_proxy, "Set", &error,
- G_TYPE_STRING, "org.freedesktop.DBus.GLib.Tests.MyObject",
- G_TYPE_STRING, "this_is_a_string",
- G_TYPE_VALUE, &value, G_TYPE_INVALID, G_TYPE_INVALID))
- lose_gerror ("Failed to complete SetProperty call", error);
- g_value_unset (&value);
- }
-
- g_print ("Calling GetProperty of read-only property\n");
- {
- GValue value = {0,};
- if (!dbus_g_proxy_call (property_proxy, "Get", &error,
- G_TYPE_STRING, "org.freedesktop.DBus.GLib.Tests.MyObject",
- G_TYPE_STRING, "no-touching",
- G_TYPE_INVALID,
- G_TYPE_VALUE, &value, G_TYPE_INVALID))
- lose_gerror ("Failed to complete GetProperty no-touching call", error);
- g_assert (G_VALUE_HOLDS (&value, G_TYPE_UINT));
- g_assert (g_value_get_uint (&value) == 42);
- g_value_unset (&value);
- }
-
- g_print ("Calling SetProperty (1)\n");
- {
- GValue value = {0,};
- g_value_init (&value, G_TYPE_UINT);
- g_value_set_uint (&value, 40);
- if (dbus_g_proxy_call (property_proxy, "Set", &error,
- G_TYPE_STRING, "org.freedesktop.DBus.GLib.Tests.MyObject",
- G_TYPE_STRING, "no-touching",
- G_TYPE_VALUE, &value, G_TYPE_INVALID, G_TYPE_INVALID))
- lose ("Unexpected success from SetProperty call for read-only value \"no-touching\"");
- g_clear_error (&error);
- g_value_unset (&value);
- }
-
- g_print ("Calling GetProperty of read-only property (again)\n");
- {
- GValue value = {0,};
- if (!dbus_g_proxy_call (property_proxy, "Get", &error,
- G_TYPE_STRING, "org.freedesktop.DBus.GLib.Tests.MyObject",
- G_TYPE_STRING, "no-touching",
- G_TYPE_INVALID,
- G_TYPE_VALUE, &value, G_TYPE_INVALID))
- lose_gerror ("Failed to complete GetProperty call", error);
- g_assert (G_VALUE_HOLDS (&value, G_TYPE_UINT));
- g_assert (g_value_get_uint (&value) == 42);
- g_value_unset (&value);
- }
-
- g_print ("Calling GetProperty (2)\n");
- {
- GValue value = {0,};
- if (!dbus_g_proxy_call (property_proxy, "Get", &error,
- G_TYPE_STRING, "org.freedesktop.DBus.GLib.Tests.MyObject",
- G_TYPE_STRING, "this_is_a_string",
- G_TYPE_INVALID,
- G_TYPE_VALUE, &value, G_TYPE_INVALID))
- lose_gerror ("Failed to complete GetProperty call", error);
- g_assert (G_VALUE_HOLDS (&value, G_TYPE_STRING));
- g_assert (!strcmp (g_value_get_string (&value), "testing value"));
- g_value_unset (&value);
- }
-
- g_print ("Calling GetProperty: SuperStudly\n");
- {
- GValue value = {0,};
- if (!dbus_g_proxy_call (property_proxy, "Get", &error,
- G_TYPE_STRING, "org.freedesktop.DBus.GLib.Tests.MyObject",
- G_TYPE_STRING, "SuperStudly",
- G_TYPE_INVALID,
- G_TYPE_VALUE, &value, G_TYPE_INVALID))
- lose_gerror ("Failed to complete GetProperty call", error);
- g_assert (G_VALUE_HOLDS (&value, G_TYPE_DOUBLE));
- g_value_unset (&value);
- }
-
- g_print ("Calling GetProperty: super-studly\n");
- {
- GValue value = {0,};
- if (!dbus_g_proxy_call (property_proxy, "Get", &error,
- G_TYPE_STRING, "org.freedesktop.DBus.GLib.Tests.MyObject",
- G_TYPE_STRING, "super-studly",
- G_TYPE_INVALID,
- G_TYPE_VALUE, &value, G_TYPE_INVALID))
- lose_gerror ("Failed to complete GetProperty call", error);
- g_assert (G_VALUE_HOLDS (&value, G_TYPE_DOUBLE));
- g_value_unset (&value);
- }
-
- g_print ("Calling GetProperty: super_studly\n");
- {
- GValue value = {0,};
- if (!dbus_g_proxy_call (property_proxy, "Get", &error,
- G_TYPE_STRING, "org.freedesktop.DBus.GLib.Tests.MyObject",
- G_TYPE_STRING, "super_studly",
- G_TYPE_INVALID,
- G_TYPE_VALUE, &value, G_TYPE_INVALID))
- lose_gerror ("Failed to complete GetProperty call", error);
- g_assert (G_VALUE_HOLDS (&value, G_TYPE_DOUBLE));
- g_value_unset (&value);
- }
-
- g_print ("Calling GetProperty on unknown property\n");
- {
- GValue value = {0,};
- if (dbus_g_proxy_call (property_proxy, "Get", &error,
- G_TYPE_STRING, "org.freedesktop.DBus.GLib.Tests.MyObject",
- G_TYPE_STRING, "SomeUnknownProperty",
- G_TYPE_INVALID,
- G_TYPE_VALUE, &value, G_TYPE_INVALID))
- lose ("Unexpected success for GetProperty call of unknown property");
-
- g_clear_error (&error);
- }
-
- /* These two are expected to pass unless we call disable_legacy_property_access */
-
- g_print ("Calling GetProperty on not-exported property (legacy enabled)\n");
- {
- GValue value = {0,};
- if (!dbus_g_proxy_call (property_proxy, "Get", &error,
- G_TYPE_STRING, "org.freedesktop.DBus.GLib.Tests.MyObject",
- G_TYPE_STRING, "should-be-hidden",
- G_TYPE_INVALID,
- G_TYPE_VALUE, &value, G_TYPE_INVALID))
- lose_gerror ("Failed GetProperty call of \"should-be-hidden\" property", error);
- g_assert (G_VALUE_HOLDS_BOOLEAN (&value));
- g_assert (g_value_get_boolean (&value) == FALSE);
- g_value_unset (&value);
- }
-
- g_print ("Calling GetProperty on not-exported property (legacy enabled)\n");
- {
- GValue value = {0,};
- if (!dbus_g_proxy_call (property_proxy, "Get", &error,
- G_TYPE_STRING, "org.freedesktop.DBus.GLib.Tests.MyObject",
- G_TYPE_STRING, "ShouldBeHidden",
- G_TYPE_INVALID,
- G_TYPE_VALUE, &value, G_TYPE_INVALID))
- lose_gerror ("Failed GetProperty call of \"ShouldBeHidden\" property", error);
-
- g_value_unset (&value);
- }
-
- g_print ("Calling SetProperty on not-exported property (legacy enabled)\n");
- {
- GValue value = {0,};
- g_value_init (&value, G_TYPE_BOOLEAN);
- g_value_set_boolean (&value, TRUE);
- if (dbus_g_proxy_call (property_proxy, "Set", &error,
- G_TYPE_STRING, "org.freedesktop.DBus.GLib.Tests.MyObject",
- G_TYPE_STRING, "should-be-hidden",
- G_TYPE_VALUE, &value,
- G_TYPE_INVALID, G_TYPE_INVALID))
- lose ("Unexpected success from SetProperty call of \"should-be-hidden\" property");
- g_value_unset (&value);
- g_clear_error (&error);
- }
-
- g_print ("Calling GetProperty on not-exported property (legacy enabled)\n");
- {
- GValue value = {0,};
- if (!dbus_g_proxy_call (property_proxy, "Get", &error,
- G_TYPE_STRING, "org.freedesktop.DBus.GLib.Tests.MyObject",
- G_TYPE_STRING, "should-be-hidden",
- G_TYPE_INVALID,
- G_TYPE_VALUE, &value, G_TYPE_INVALID))
- lose_gerror ("Failed GetProperty call of \"should-be-hidden\" property", error);
- g_assert (G_VALUE_HOLDS_BOOLEAN (&value));
- g_assert (g_value_get_boolean (&value) == FALSE);
- g_value_unset (&value);
- }
-
- /* Test GetAll */
- /* 'testing value' set earlier by the SetProperty tests */
- test_base_class_get_all (connection,
- "/org/freedesktop/DBus/GLib/Tests/MyTestObject",
- "testing value");
-
- /* "" is base class default for this_is_a_string property since the
- * property isn't marked with G_PARAM_CONSTRUT.
- */
- test_base_class_get_all (connection,
- "/org/freedesktop/DBus/GLib/Tests/MyTestObjectSubclass",
- "");
-
- /* Finally test GetAll of a subclass on a different interface to ensure that
- * the right properties are returned (fdo #19145)
- */
- test_subclass_get_all (connection, "/org/freedesktop/DBus/GLib/Tests/MyTestObjectSubclass");
-
- /* Now, call disable_legacy_property_access */
-
- g_assert (proxy == NULL);
- proxy = dbus_g_proxy_new_for_name_owner (connection,
- "org.freedesktop.DBus.GLib.TestService",
- "/org/freedesktop/DBus/GLib/Tests/MyTestObject",
- "org.freedesktop.DBus.GLib.Tests.MyObject",
- &error);
-
- if (!dbus_g_proxy_call (proxy, "UnsafeDisableLegacyPropertyAccess", &error,
- G_TYPE_INVALID, G_TYPE_INVALID))
- lose_gerror ("Failed to invoke UnsafeDisableLegacyPropertyAccess", error);
-
- g_object_unref (proxy);
- proxy = NULL;
-
- g_print ("Calling GetProperty on not-exported property (legacy *disabled*)\n");
- {
- GValue value = {0,};
- if (dbus_g_proxy_call (property_proxy, "Get", &error,
- G_TYPE_STRING, "org.freedesktop.DBus.GLib.Tests.MyObject",
- G_TYPE_STRING, "should-be-hidden",
- G_TYPE_INVALID,
- G_TYPE_VALUE, &value, G_TYPE_INVALID))
- lose ("Unexpected success from GetProperty call of \"should-be-hidden\" property");
- g_clear_error (&error);
- }
-
- g_print ("Calling GetProperty on not-exported property (legacy *disabled*)\n");
- {
- GValue value = {0,};
- if (dbus_g_proxy_call (property_proxy, "Get", &error,
- G_TYPE_STRING, "org.freedesktop.DBus.GLib.Tests.MyObject",
- G_TYPE_STRING, "ShouldBeHidden",
- G_TYPE_INVALID,
- G_TYPE_VALUE, &value, G_TYPE_INVALID))
- lose ("Unexpected success from GetProperty call of \"ShouldBeHidden\" property");
- g_clear_error (&error);
- }
-
- g_print ("Calling SetProperty on not-exported property (legacy *disabled*)\n");
- {
- GValue value = {0,};
- g_value_init (&value, G_TYPE_BOOLEAN);
- g_value_set_boolean (&value, FALSE);
- if (dbus_g_proxy_call (property_proxy, "Set", &error,
- G_TYPE_STRING, "org.freedesktop.DBus.GLib.Tests.MyObject",
- G_TYPE_STRING, "should-be-hidden",
- G_TYPE_VALUE, &value,
- G_TYPE_INVALID, G_TYPE_INVALID))
- lose ("Unexpected success from SetProperty call of \"should-be-hidden\" property");
- g_value_unset (&value);
- g_clear_error (&error);
- }
-
- g_object_unref (property_proxy);
- property_proxy = NULL;
-
- test_terminate_proxy1 = dbus_g_proxy_new_for_name_owner (connection,
- "org.freedesktop.DBus.GLib.TestService",
- "/org/freedesktop/DBus/GLib/Tests/MyTestObject",
- "org.freedesktop.DBus.GLib.Tests.MyObject",
- &error);
-
- if (test_terminate_proxy1 == NULL)
- lose_gerror ("Failed to create proxy for name owner", error);
-
- test_terminate_proxy2 = dbus_g_proxy_new_for_name_owner (connection,
- "org.freedesktop.DBus.GLib.TestService",
- "/org/freedesktop/DBus/GLib/Tests/MyTestObject",
- "org.freedesktop.DBus.GLib.Tests.MyObject",
- &error);
-
- if (test_terminate_proxy2 == NULL)
- lose_gerror ("Failed to create proxy for name owner", error);
-
- g_print ("Testing duplicate proxy destruction\n");
- await_terminating_service = "org.freedesktop.DBus.GLib.TestService";
- dbus_g_proxy_call_no_reply (test_terminate_proxy1, "Terminate", G_TYPE_INVALID);
-
- proxy_destroyed = FALSE;
- proxy_destroy_and_nameowner = TRUE;
- proxy_destroy_and_nameowner_complete = FALSE;
-
- g_signal_connect (G_OBJECT (test_terminate_proxy1),
- "destroy",
- G_CALLBACK (test_terminate_proxy1_destroyed_cb),
- NULL);
-
- dbus_g_connection_flush (connection);
- cancel_exit_timeout ();
- exit_timeout = g_timeout_add (5000, timed_exit, loop);
- g_main_loop_run (loop);
-
- if (await_terminating_service != NULL)
- lose ("Didn't see name loss for \"org.freedesktop.DBus.GLib.TestService\"");
- if (!proxy_destroyed)
- lose ("Didn't get proxy_destroyed");
- if (test_terminate_proxy2)
- lose ("Duplicate proxy wasn'tdestroyed");
-
- g_print ("Proxy and duplicate destroyed successfully\n");
-
- g_print ("Beginning private connection tests\n");
-
- {
- DBusGConnection *privconn = dbus_g_bus_get_private (DBUS_BUS_SESSION, NULL, &error);
-
- if (privconn == NULL)
- lose_gerror ("Failed to open private connection to bus", error);
- g_assert (privconn != connection);
-
- proxy = dbus_g_proxy_new_for_name (privconn,
- "org.freedesktop.DBus.GLib.TestService",
- "/org/freedesktop/DBus/GLib/Tests/MyTestObject",
- "org.freedesktop.DBus.GLib.Tests.MyObject");
-
- g_print ("[private connection] Calling (wrapped) do_nothing\n");
- if (!org_freedesktop_DBus_GLib_Tests_MyObject_do_nothing (proxy, &error))
- lose_gerror ("Failed to complete (wrapped) DoNothing call", error);
-
- g_object_unref (G_OBJECT (proxy));
-
- test_run_until_disconnected (dbus_g_connection_get_connection (privconn), NULL);
- dbus_g_connection_unref (privconn);
- }
-
- g_object_unref (G_OBJECT (driver));
-
- test_run_until_disconnected (dbus_g_connection_get_connection (connection), NULL);
- dbus_g_connection_unref (connection);
-
- g_print ("Successfully completed %s\n", argv[0]);
-
- dbus_shutdown ();
- g_main_loop_unref (loop);
-
- return 0;
-}
diff --git a/test/core/test-gvariant.c b/test/core/test-gvariant.c
deleted file mode 100644
index fc1406e..0000000
--- a/test/core/test-gvariant.c
+++ /dev/null
@@ -1,956 +0,0 @@
-/* GVariant to dbus-glib escape hatch
- *
- * Copyright © 2010 Collabora Ltd. <http://www.collabora.co.uk/>
- *
- * Licensed under the Academic Free License version 2.1
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * Alternatively, at your option, you can redistribute and/or modify
- * this single file under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 2.1 of
- * that license, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- */
-
-#include <config.h>
-
-#include <dbus/dbus-glib.h>
-#include <gio/gio.h>
-
-/**
- * test_g_variant_equivalent:
- *
- * The function g_variant_equal() cannot be used for dictionaries because it
- * cares about the ordering of dictionaries, which breaks our tests.
- */
-static gboolean
-test_g_variant_equivalent (GVariant *one,
- GVariant *two)
-{
- if (!g_variant_type_equal (
- g_variant_get_type (one),
- g_variant_get_type (two)))
- {
- return FALSE;
- }
- else if (g_variant_is_of_type (one, G_VARIANT_TYPE_DICTIONARY) &&
- g_variant_is_of_type (two, G_VARIANT_TYPE_DICTIONARY))
- {
- GHashTable *hash;
- GVariantIter iter;
- GVariant *child;
- gboolean equal = TRUE;
-
- if (g_variant_n_children (one) != g_variant_n_children (two))
- return FALSE;
-
- /* pack @one into a hash table */
- hash = g_hash_table_new_full (g_variant_hash, g_variant_equal,
- (GDestroyNotify) g_variant_unref, (GDestroyNotify) g_variant_unref);
-
- g_variant_iter_init (&iter, one);
- while ((child = g_variant_iter_next_value (&iter)))
- {
- g_hash_table_insert (hash,
- g_variant_get_child_value (child, 0),
- g_variant_get_child_value (child, 1));
- g_variant_unref (child);
- }
-
- /* now iterate @two to check for the keys in @hash */
- g_variant_iter_init (&iter, two);
- while (equal && (child = g_variant_iter_next_value (&iter)))
- {
- GVariant *k, *v1, *v2;
-
- k = g_variant_get_child_value (child, 0);
- v1 = g_variant_get_child_value (child, 1);
-
- v2 = g_hash_table_lookup (hash, k);
-
- if (v2 == NULL || !test_g_variant_equivalent (v1, v2))
- equal = FALSE;
- else
- g_hash_table_remove (hash, k);
-
- g_variant_unref (k);
- g_variant_unref (v1);
- g_variant_unref (child);
- }
-
- if (g_hash_table_size (hash) > 0)
- equal = FALSE;
-
- g_hash_table_destroy (hash);
-
- return equal;
- }
- else if (g_variant_is_container (one) &&
- g_variant_is_container (two))
- {
- guint i, size;
- gboolean equal = TRUE;
-
- if (g_variant_n_children (one) != g_variant_n_children (two))
- return FALSE;
-
- size = g_variant_n_children (one);
- for (i = 0; equal && i < size; i++)
- {
- GVariant *child1, *child2;
-
- child1 = g_variant_get_child_value (one, i);
- child2 = g_variant_get_child_value (two, i);
-
- equal = test_g_variant_equivalent (child1, child2);
-
- g_variant_unref (child1);
- g_variant_unref (child2);
- }
-
- return equal;
- }
- else
- {
- return g_variant_equal (one, two);
- }
-}
-
-#define assert_g_variant_equivalent(a,e) \
- assert_g_variant_equivalent_internal (__FILE__, __LINE__, \
- #a, a, #e, e)
-
-static void
-assert_g_variant_equivalent_internal (
- const gchar *file, gint line,
- const gchar *actual_name, GVariant *actual,
- const gchar *expected_name, GVariant *expected);
-
-static void
-assert_g_variant_equivalent_internal (const gchar *file,
- gint line,
- const gchar *actual_name,
- GVariant *actual,
- const gchar *expected_name,
- GVariant *expected)
-{
- if (!test_g_variant_equivalent (actual, expected))
- {
- gchar *a = g_variant_print (actual, TRUE);
- gchar *e = g_variant_print (expected, TRUE);
-
- g_error ("%s:%d: Variants should have been equal:\n"
- "%s = %s\n"
- "%s = %s", file, line, actual_name, a, expected_name, e);
- /* no point in freeing the strings, we've just crashed anyway */
- }
-}
-
-/* test_g_variant_equivalent tests */
-static void
-test_simple_equiv (void)
-{
- GVariant *v1, *v2;
-
- v1 = g_variant_new_int32 (1984);
- v2 = g_variant_new_int32 (1984);
-
- g_assert (test_g_variant_equivalent (v1, v2));
-
- g_variant_unref (v1);
- g_variant_unref (v2);
-}
-
-static void
-test_simple_not_equiv (void)
-{
- GVariant *v1, *v2;
-
- v1 = g_variant_new_int32 (1982);
- v2 = g_variant_new_int32 (1984);
-
- g_assert (!test_g_variant_equivalent (v1, v2));
-
- g_variant_unref (v1);
- g_variant_unref (v2);
-}
-
-static void
-test_array_not_equiv (void)
-{
- GVariantBuilder b;
- GVariant *v1, *v2;
-
- g_variant_builder_init (&b, G_VARIANT_TYPE ("av"));
- g_variant_builder_add (&b, "v", g_variant_new_int32 (1984));
- g_variant_builder_add (&b, "v", g_variant_new_string ("Orwell"));
- g_variant_builder_add (&b, "v", g_variant_new_object_path ("/cats/escher"));
- v1 = g_variant_builder_end (&b);
-
- g_variant_builder_init (&b, G_VARIANT_TYPE ("av"));
- /* note the order has changed */
- g_variant_builder_add (&b, "v", g_variant_new_string ("Orwell"));
- g_variant_builder_add (&b, "v", g_variant_new_int32 (1984));
- g_variant_builder_add (&b, "v", g_variant_new_object_path ("/cats/escher"));
- v2 = g_variant_builder_end (&b);
-
- g_assert (!test_g_variant_equivalent (v1, v2));
-
- g_variant_unref (v1);
- g_variant_unref (v2);
-}
-
-static void
-test_map_equiv (void)
-{
- GVariantBuilder b;
- GVariant *v1, *v2;
-
- g_variant_builder_init (&b, G_VARIANT_TYPE ("a{os}"));
- g_variant_builder_add (&b, "{os}", "/cats/escher", "Escher Moonbeam");
- g_variant_builder_add (&b, "{os}", "/cats/harvey", "Harvey Nomcat");
- g_variant_builder_add (&b, "{os}", "/cats/josh", "Josh Smith");
- v1 = g_variant_builder_end (&b);
-
- g_variant_builder_init (&b, G_VARIANT_TYPE ("a{os}"));
- /* note the order has changed */
- g_variant_builder_add (&b, "{os}", "/cats/harvey", "Harvey Nomcat");
- g_variant_builder_add (&b, "{os}", "/cats/escher", "Escher Moonbeam");
- g_variant_builder_add (&b, "{os}", "/cats/josh", "Josh Smith");
- v2 = g_variant_builder_end (&b);
-
- g_assert (test_g_variant_equivalent (v1, v2));
-
- g_variant_unref (v1);
- g_variant_unref (v2);
-}
-
-static void
-test_map_not_equiv1 (void)
-{
- GVariantBuilder b;
- GVariant *v1, *v2;
-
- g_variant_builder_init (&b, G_VARIANT_TYPE ("a{os}"));
- g_variant_builder_add (&b, "{os}", "/cats/escher", "Escher Moonbeam");
- g_variant_builder_add (&b, "{os}", "/cats/harvey", "Harvey Nomcat");
- g_variant_builder_add (&b, "{os}", "/cats/josh", "Josh Smith");
- v1 = g_variant_builder_end (&b);
-
- g_variant_builder_init (&b, G_VARIANT_TYPE ("a{os}"));
- g_variant_builder_add (&b, "{os}", "/cats/escher", "Escher Moonbeam");
- g_variant_builder_add (&b, "{os}", "/cats/harvey", "Harvey Nomcat");
- g_variant_builder_add (&b, "{os}", "/cats/josh", "Josh Smith");
- g_variant_builder_add (&b, "{os}", "/cats/rory", "Rory Cat");
- v2 = g_variant_builder_end (&b);
-
- g_assert (!test_g_variant_equivalent (v1, v2));
-
- g_variant_unref (v1);
- g_variant_unref (v2);
-}
-
-static void
-test_map_not_equiv2 (void)
-{
- GVariantBuilder b;
- GVariant *v1, *v2;
-
- g_variant_builder_init (&b, G_VARIANT_TYPE ("a{os}"));
- g_variant_builder_add (&b, "{os}", "/cats/escher", "Escher Moonbeam");
- g_variant_builder_add (&b, "{os}", "/cats/harvey", "Harvey Nomcat");
- g_variant_builder_add (&b, "{os}", "/cats/josh", "Josh Smith");
- v1 = g_variant_builder_end (&b);
-
- g_variant_builder_init (&b, G_VARIANT_TYPE ("a{os}"));
- g_variant_builder_add (&b, "{os}", "/cats/escher", "Escher Moonbeam");
- g_variant_builder_add (&b, "{os}", "/cats/harvey", "Harvey Nomcat");
- g_variant_builder_add (&b, "{os}", "/cats/josh", "Josh Cat");
- v2 = g_variant_builder_end (&b);
-
- g_assert (!test_g_variant_equivalent (v1, v2));
-
- g_variant_unref (v1);
- g_variant_unref (v2);
-}
-
-/* dbus_g_value_build_g_variant tests */
-static void
-test_i (void)
-{
- GValue v = { 0, };
- GVariant *var, *varc;
-
- g_value_init (&v, G_TYPE_INT);
- g_value_set_int (&v, 1984);
-
- var = dbus_g_value_build_g_variant (&v);
- g_value_unset (&v);
-
- varc = g_variant_new_int32 (1984);
-
- g_assert (test_g_variant_equivalent (var, varc));
-
- g_variant_unref (var);
- g_variant_unref (varc);
-}
-
-static void
-test_s (void)
-{
- GValue v = { 0, };
- GVariant *var, *varc;
-
- g_value_init (&v, G_TYPE_STRING);
- g_value_set_static_string (&v, "Orwell");
-
- var = dbus_g_value_build_g_variant (&v);
- g_value_unset (&v);
-
- varc = g_variant_new_string ("Orwell");
-
- g_assert (test_g_variant_equivalent (var, varc));
-
- g_variant_unref (var);
- g_variant_unref (varc);
-}
-
-static void
-test_o (void)
-{
- GValue v = { 0, };
- GVariant *var, *varc;
-
- g_value_init (&v, DBUS_TYPE_G_OBJECT_PATH);
- g_value_set_boxed (&v, "/cats/escher");
-
- var = dbus_g_value_build_g_variant (&v);
- g_value_unset (&v);
-
- varc = g_variant_new_object_path ("/cats/escher");
-
- g_assert (test_g_variant_equivalent (var, varc));
-
- g_variant_unref (var);
- g_variant_unref (varc);
-}
-
-static void
-test_us (void)
-{
- GValue v = { 0, };
- GVariant *var, *varc;
- GType us = dbus_g_type_get_struct ("GValueArray",
- G_TYPE_UINT,
- G_TYPE_STRING,
- G_TYPE_INVALID);
-
- g_value_init (&v, us);
- g_value_take_boxed (&v, dbus_g_type_specialized_construct (us));
- dbus_g_type_struct_set (&v,
- 0, 1984,
- 1, "Orwell",
- G_MAXUINT);
-
- var = dbus_g_value_build_g_variant (&v);
- g_value_unset (&v);
-
- varc = g_variant_new ("(us)", 1984, "Orwell");
-
- g_assert (test_g_variant_equivalent (var, varc));
-
- g_variant_unref (var);
- g_variant_unref (varc);
-}
-
-static void
-test_a_os (void)
-{
- GValue v = { 0, };
- GHashTable *map;
- GVariantBuilder b;
- GVariant *var, *varc;
- GType a_os = dbus_g_type_get_map ("GHashTable",
- DBUS_TYPE_G_OBJECT_PATH,
- G_TYPE_STRING);
-
- g_value_init (&v, a_os);
- map = dbus_g_type_specialized_construct (a_os);
-
- g_hash_table_insert (map,
- g_strdup ("/cats/escher"), g_strdup ("Escher Moonbeam"));
- g_hash_table_insert (map,
- g_strdup ("/cats/harvey"), g_strdup ("Harvey Nomcat"));
- g_hash_table_insert (map,
- g_strdup ("/cats/josh"), g_strdup ("Josh Smith"));
- g_value_take_boxed (&v, map);
-
- var = dbus_g_value_build_g_variant (&v);
- g_value_unset (&v);
-
- g_variant_builder_init (&b, G_VARIANT_TYPE ("a{os}"));
- g_variant_builder_add (&b, "{os}", "/cats/escher", "Escher Moonbeam");
- g_variant_builder_add (&b, "{os}", "/cats/harvey", "Harvey Nomcat");
- g_variant_builder_add (&b, "{os}", "/cats/josh", "Josh Smith");
- varc = g_variant_builder_end (&b);
-
- g_assert (test_g_variant_equivalent (var, varc));
-
- g_variant_unref (var);
- g_variant_unref (varc);
-}
-
-static void
-test_av (void)
-{
- GValue v = { 0, }, *v2;
- GVariantBuilder b;
- GVariant *var, *varc;
- GType av = dbus_g_type_get_collection ("GPtrArray", G_TYPE_VALUE);
- GPtrArray *array;
-
- g_value_init (&v, av);
- array = dbus_g_type_specialized_construct (av);
-
- v2 = g_new0 (GValue, 1);
- g_value_init (v2, G_TYPE_INT);
- g_value_set_int (v2, 1984);
- g_ptr_array_add (array, v2);
-
- v2 = g_new0 (GValue, 1);
- g_value_init (v2, G_TYPE_STRING);
- g_value_set_static_string (v2, "Orwell");
- g_ptr_array_add (array, v2);
-
- v2 = g_new0 (GValue, 1);
- g_value_init (v2, DBUS_TYPE_G_OBJECT_PATH);
- g_value_set_boxed (v2, "/cats/escher");
- g_ptr_array_add (array, v2);
-
- g_value_take_boxed (&v, array);
-
- var = dbus_g_value_build_g_variant (&v);
- g_value_unset (&v);
-
- g_variant_builder_init (&b, G_VARIANT_TYPE ("av"));
- g_variant_builder_add (&b, "v", g_variant_new_int32 (1984));
- g_variant_builder_add (&b, "v", g_variant_new_string ("Orwell"));
- g_variant_builder_add (&b, "v", g_variant_new_object_path ("/cats/escher"));
- varc = g_variant_builder_end (&b);
-
- g_assert (test_g_variant_equivalent (var, varc));
-
- g_variant_unref (var);
- g_variant_unref (varc);
-}
-
-static void
-test_ab (void)
-{
- GValue v = { 0, };
- gboolean bools[] = { TRUE, FALSE };
- GVariantBuilder b;
- GVariant *var, *varc;
- GType ab = dbus_g_type_get_collection ("GArray", G_TYPE_BOOLEAN);
- GArray *array;
-
- g_value_init (&v, ab);
- array = dbus_g_type_specialized_construct (ab);
-
- g_array_append_vals (array, bools, 2);
- g_assert_cmpint (g_array_index (array, gboolean, 0), ==, TRUE);
- g_assert_cmpint (g_array_index (array, gboolean, 1), ==, FALSE);
-
- g_value_take_boxed (&v, array);
-
- var = dbus_g_value_build_g_variant (&v);
- g_value_unset (&v);
-
- g_variant_builder_init (&b, G_VARIANT_TYPE ("ab"));
- g_variant_builder_add (&b, "b", TRUE);
- g_variant_builder_add (&b, "b", FALSE);
- varc = g_variant_builder_end (&b);
-
- g_assert (test_g_variant_equivalent (var, varc));
-
- g_variant_unref (var);
- g_variant_unref (varc);
-}
-
-static void
-test_ai (void)
-{
- GValue v = { 0, };
- gint ints[] = { 1984, 1066 };
- GVariantBuilder b;
- GVariant *var, *varc;
- GType ai = dbus_g_type_get_collection ("GArray", G_TYPE_INT);
- GArray *array;
-
- g_value_init (&v, ai);
- array = dbus_g_type_specialized_construct (ai);
-
- g_array_append_vals (array, ints, 2);
- g_assert_cmpint (g_array_index (array, gint, 0), ==, 1984);
- g_assert_cmpint (g_array_index (array, gint, 1), ==, 1066);
-
- g_value_take_boxed (&v, array);
-
- var = dbus_g_value_build_g_variant (&v);
- g_value_unset (&v);
-
- g_variant_builder_init (&b, G_VARIANT_TYPE ("ai"));
- g_variant_builder_add (&b, "i", 1984);
- g_variant_builder_add (&b, "i", 1066);
- varc = g_variant_builder_end (&b);
-
- g_assert (test_g_variant_equivalent (var, varc));
-
- g_variant_unref (var);
- g_variant_unref (varc);
-}
-
-static void
-test_au (void)
-{
- GValue v = { 0, };
- guint uints[] = { 1984, 1066 };
- GVariantBuilder b;
- GVariant *var, *varc;
- GType au = dbus_g_type_get_collection ("GArray", G_TYPE_UINT);
- GArray *array;
-
- g_value_init (&v, au);
- array = dbus_g_type_specialized_construct (au);
-
- g_array_append_vals (array, uints, 2);
- g_assert_cmpuint (g_array_index (array, guint, 0), ==, 1984);
- g_assert_cmpuint (g_array_index (array, guint, 1), ==, 1066);
-
- g_value_take_boxed (&v, array);
-
- var = dbus_g_value_build_g_variant (&v);
- g_value_unset (&v);
-
- g_variant_builder_init (&b, G_VARIANT_TYPE ("au"));
- g_variant_builder_add (&b, "u", 1984);
- g_variant_builder_add (&b, "u", 1066);
- varc = g_variant_builder_end (&b);
-
- g_assert (test_g_variant_equivalent (var, varc));
-
- g_variant_unref (var);
- g_variant_unref (varc);
-}
-
-static void
-test_ax (void)
-{
- GValue v = { 0, };
- gint64 ints[] = { G_GINT64_CONSTANT (-0xAAABBBBCCCCDDDD), 1066 };
- GVariantBuilder b;
- GVariant *var, *varc;
- GType ax = dbus_g_type_get_collection ("GArray", G_TYPE_INT64);
- GArray *array;
-
- g_value_init (&v, ax);
- array = dbus_g_type_specialized_construct (ax);
-
- g_array_append_vals (array, ints, 2);
- g_assert_cmpint ((g_array_index (array, gint64, 0)
- / G_GINT64_CONSTANT (0x100000000)), ==,
- -0xAAABBBB);
- g_assert_cmpuint ((-(g_array_index (array, gint64, 0)))
- % G_GINT64_CONSTANT (0x100000000), ==, 0xCCCCDDDDu);
- g_assert_cmpint ((g_array_index (array, gint64, 1)
- / G_GINT64_CONSTANT (0x100000000)), ==, 0);
- g_assert_cmpuint ((g_array_index (array, gint64, 1))
- % G_GINT64_CONSTANT (0x100000000), ==, 1066);
-
- g_value_take_boxed (&v, array);
-
- var = dbus_g_value_build_g_variant (&v);
- g_value_unset (&v);
-
- g_variant_builder_init (&b, G_VARIANT_TYPE ("ax"));
- g_variant_builder_add (&b, "x", G_GINT64_CONSTANT (-0xAAABBBBCCCCDDDD));
- g_variant_builder_add (&b, "x", G_GINT64_CONSTANT (1066));
- varc = g_variant_builder_end (&b);
-
- g_assert (test_g_variant_equivalent (var, varc));
-
- g_variant_unref (var);
- g_variant_unref (varc);
-}
-
-static void
-test_at (void)
-{
- GValue v = { 0, };
- guint64 uints[] = { G_GUINT64_CONSTANT (0xAAAABBBBCCCCDDDD), 1066 };
- GVariantBuilder b;
- GVariant *var, *varc;
- GType at = dbus_g_type_get_collection ("GArray", G_TYPE_UINT64);
- GArray *array;
-
- g_value_init (&v, at);
- array = dbus_g_type_specialized_construct (at);
-
- g_array_append_vals (array, uints, 2);
- g_assert_cmpuint ((g_array_index (array, guint64, 0)
- / G_GUINT64_CONSTANT (0x100000000)), ==, 0xAAAABBBBu);
- g_assert_cmpuint ((g_array_index (array, guint64, 0)
- % G_GUINT64_CONSTANT (0x100000000)), ==, 0xCCCCDDDDu);
- g_assert_cmpuint ((g_array_index (array, guint64, 1)
- / G_GUINT64_CONSTANT (0x100000000)), ==, 0);
- g_assert_cmpuint ((g_array_index (array, guint64, 1)
- % G_GUINT64_CONSTANT (0x100000000)), ==, 1066);
-
- g_value_take_boxed (&v, array);
-
- var = dbus_g_value_build_g_variant (&v);
- g_value_unset (&v);
-
- g_variant_builder_init (&b, G_VARIANT_TYPE ("at"));
- g_variant_builder_add (&b, "t", G_GUINT64_CONSTANT (0xAAAABBBBCCCCDDDD));
- g_variant_builder_add (&b, "t", G_GUINT64_CONSTANT (1066));
- varc = g_variant_builder_end (&b);
-
- g_assert (test_g_variant_equivalent (var, varc));
-
- g_variant_unref (var);
- g_variant_unref (varc);
-}
-
-static void
-test_ay (void)
-{
- GValue v = { 0, };
- guchar bytes[] = { 23, 42 };
- GVariantBuilder b;
- GVariant *var, *varc;
- GType ay = dbus_g_type_get_collection ("GArray", G_TYPE_UCHAR);
- GArray *array;
-
- g_value_init (&v, ay);
- array = dbus_g_type_specialized_construct (ay);
-
- g_array_append_vals (array, bytes, 2);
- g_assert_cmpint (g_array_index (array, guchar, 0), ==, 23);
- g_assert_cmpint (g_array_index (array, guchar, 1), ==, 42);
-
- g_value_take_boxed (&v, array);
-
- var = dbus_g_value_build_g_variant (&v);
- g_value_unset (&v);
-
- g_variant_builder_init (&b, G_VARIANT_TYPE ("ay"));
- g_variant_builder_add (&b, "y", 23);
- g_variant_builder_add (&b, "y", 42);
- varc = g_variant_builder_end (&b);
-
- g_assert (test_g_variant_equivalent (var, varc));
-
- g_variant_unref (var);
- g_variant_unref (varc);
-}
-
-static void
-test_g (void)
-{
- GValue v = { 0, };
- GVariant *var, *varc;
-
- g_value_init (&v, DBUS_TYPE_G_SIGNATURE);
- g_value_set_boxed (&v, "a{u(ua{sa{sv}})}");
-
- var = dbus_g_value_build_g_variant (&v);
- g_value_unset (&v);
-
- varc = g_variant_new_signature ("a{u(ua{sa{sv}})}");
-
- g_assert (test_g_variant_equivalent (var, varc));
-
- g_variant_unref (var);
- g_variant_unref (varc);
-}
-
-static void
-test_roundtrip (gconstpointer user_data)
-{
- const gchar *text = user_data;
- GVariant *before, *after;
- GValue v = { 0 };
-
- before = g_variant_new_parsed (text);
- dbus_g_value_parse_g_variant (before, &v);
- after = dbus_g_value_build_g_variant (&v);
- g_value_unset (&v);
- assert_g_variant_equivalent (before, after);
- g_variant_unref (before);
- g_variant_unref (after);
-}
-
-static void
-test_parse_basic (void)
-{
- GVariant *variant;
- GValue v = { 0 };
-
- variant = g_variant_new_parsed ("'o hai'");
- dbus_g_value_parse_g_variant (variant, &v);
- g_assert_cmpstr (G_VALUE_TYPE_NAME (&v), ==, g_type_name (G_TYPE_STRING));
- g_assert_cmpstr (g_value_get_string (&v), ==, "o hai");
- g_value_unset (&v);
- g_variant_unref (variant);
-
- variant = g_variant_new_parsed ("objectpath '/hello/world'");
- dbus_g_value_parse_g_variant (variant, &v);
- g_assert_cmpstr (G_VALUE_TYPE_NAME (&v), ==,
- g_type_name (DBUS_TYPE_G_OBJECT_PATH));
- g_assert_cmpstr ((gchar *) g_value_get_boxed (&v), ==, "/hello/world");
- g_value_unset (&v);
- g_variant_unref (variant);
-
- variant = g_variant_new_parsed ("signature 'a{sv}'");
- dbus_g_value_parse_g_variant (variant, &v);
- g_assert_cmpstr (G_VALUE_TYPE_NAME (&v), ==,
- g_type_name (DBUS_TYPE_G_SIGNATURE));
- g_assert_cmpstr ((gchar *) g_value_get_boxed (&v), ==, "a{sv}");
- g_value_unset (&v);
- g_variant_unref (variant);
-
- variant = g_variant_new_parsed ("23.5");
- dbus_g_value_parse_g_variant (variant, &v);
- g_assert_cmpstr (G_VALUE_TYPE_NAME (&v), ==, g_type_name (G_TYPE_DOUBLE));
- /* this is chosen to be exactly representable in binary; we use inequalities
- * to work around -Wfloat-equal */
- g_assert_cmpfloat (g_value_get_double (&v), >=, 23.5);
- g_assert_cmpfloat (g_value_get_double (&v), <=, 23.5);
- g_value_unset (&v);
- g_variant_unref (variant);
-
- variant = g_variant_new_parsed ("byte 42");
- dbus_g_value_parse_g_variant (variant, &v);
- g_assert_cmpstr (G_VALUE_TYPE_NAME (&v), ==, g_type_name (G_TYPE_UCHAR));
- g_assert_cmpuint (g_value_get_uchar (&v), ==, 42);
- g_value_unset (&v);
- g_variant_unref (variant);
-
- variant = g_variant_new_parsed ("uint16 16");
- dbus_g_value_parse_g_variant (variant, &v);
- g_assert_cmpstr (G_VALUE_TYPE_NAME (&v), ==, g_type_name (G_TYPE_UINT));
- g_assert_cmpuint (g_value_get_uint (&v), ==, 16);
- g_value_unset (&v);
- g_variant_unref (variant);
-
- variant = g_variant_new_parsed ("uint32 32");
- dbus_g_value_parse_g_variant (variant, &v);
- g_assert_cmpstr (G_VALUE_TYPE_NAME (&v), ==, g_type_name (G_TYPE_UINT));
- g_assert_cmpuint (g_value_get_uint (&v), ==, 32);
- g_value_unset (&v);
- g_variant_unref (variant);
-
- variant = g_variant_new_parsed ("uint64 64");
- dbus_g_value_parse_g_variant (variant, &v);
- g_assert_cmpstr (G_VALUE_TYPE_NAME (&v), ==, g_type_name (G_TYPE_UINT64));
- g_assert_cmpuint ((guint) g_value_get_uint64 (&v), ==, 64);
- g_value_unset (&v);
- g_variant_unref (variant);
-
- variant = g_variant_new_parsed ("int16 -16");
- dbus_g_value_parse_g_variant (variant, &v);
- g_assert_cmpstr (G_VALUE_TYPE_NAME (&v), ==, g_type_name (G_TYPE_INT));
- g_assert_cmpint (g_value_get_int (&v), ==, -16);
- g_value_unset (&v);
- g_variant_unref (variant);
-
- variant = g_variant_new_parsed ("int32 -32");
- dbus_g_value_parse_g_variant (variant, &v);
- g_assert_cmpstr (G_VALUE_TYPE_NAME (&v), ==, g_type_name (G_TYPE_INT));
- g_assert_cmpint (g_value_get_int (&v), ==, -32);
- g_value_unset (&v);
- g_variant_unref (variant);
-
- variant = g_variant_new_parsed ("int64 -64");
- dbus_g_value_parse_g_variant (variant, &v);
- g_assert_cmpstr (G_VALUE_TYPE_NAME (&v), ==, g_type_name (G_TYPE_INT64));
- g_assert_cmpint ((gint) g_value_get_int64 (&v), ==, -64);
- g_value_unset (&v);
- g_variant_unref (variant);
-}
-
-static void
-test_parse_array (void)
-{
- GVariant *variant;
- GValue v = { 0 };
- GArray *a;
-
- /* We can't test the 16-bit cases via a round-trip, because information is
- * lost. */
-
- variant = g_variant_new_parsed ("[uint16 16, uint16 1600]");
- dbus_g_value_parse_g_variant (variant, &v);
- g_assert_cmpstr (G_VALUE_TYPE_NAME (&v), ==,
- g_type_name (DBUS_TYPE_G_UINT_ARRAY));
- a = g_value_get_boxed (&v);
- g_assert_cmpuint (a->len, ==, 2);
- g_assert_cmpuint (g_array_index (a, guint, 0), ==, 16);
- g_assert_cmpuint (g_array_index (a, guint, 1), ==, 1600);
- g_value_unset (&v);
- g_variant_unref (variant);
-
- variant = g_variant_new_parsed ("[int16 -16, int16 -1600]");
- dbus_g_value_parse_g_variant (variant, &v);
- g_assert_cmpstr (G_VALUE_TYPE_NAME (&v), ==,
- g_type_name (DBUS_TYPE_G_INT_ARRAY));
- a = g_value_get_boxed (&v);
- g_assert_cmpuint (a->len, ==, 2);
- g_assert_cmpint (g_array_index (a, gint, 0), ==, -16);
- g_assert_cmpint (g_array_index (a, gint, 1), ==, -1600);
- g_value_unset (&v);
- g_variant_unref (variant);
-
- variant = g_variant_new_parsed ("@aq []");
- dbus_g_value_parse_g_variant (variant, &v);
- g_assert_cmpstr (G_VALUE_TYPE_NAME (&v), ==,
- g_type_name (DBUS_TYPE_G_UINT_ARRAY));
- a = g_value_get_boxed (&v);
- g_assert_cmpuint (a->len, ==, 0);
- g_value_unset (&v);
- g_variant_unref (variant);
-
- variant = g_variant_new_parsed ("@an []");
- dbus_g_value_parse_g_variant (variant, &v);
- g_assert_cmpstr (G_VALUE_TYPE_NAME (&v), ==,
- g_type_name (DBUS_TYPE_G_INT_ARRAY));
- a = g_value_get_boxed (&v);
- g_assert_cmpuint (a->len, ==, 0);
- g_value_unset (&v);
- g_variant_unref (variant);
-}
-
-static void
-test_parse_string_hash (void)
-{
- GVariant *variant;
- GHashTable *h;
- GValue v = { 0 };
-
- variant = g_variant_new_parsed ("@a{ss} {'foo': 'bar'}");
- dbus_g_value_parse_g_variant (variant, &v);
- g_assert_cmpstr (G_VALUE_TYPE_NAME (&v), ==,
- g_type_name (DBUS_TYPE_G_STRING_STRING_HASHTABLE));
- h = g_value_get_boxed (&v);
- g_assert_cmpuint (g_hash_table_size (h), ==, 1);
- g_assert_cmpstr (g_hash_table_lookup (h, "foo"), ==, "bar");
- g_value_unset (&v);
- g_variant_unref (variant);
-}
-
-int
-main (int argc,
- char **argv)
-{
- g_type_init ();
- dbus_g_type_specialized_init ();
-
- g_test_init (&argc, &argv, NULL);
-
- /* test_g_variant_equivalent tests */
- g_test_add_func ("/test_g_variant_equivalent/test_simple_equiv",
- test_simple_equiv);
- g_test_add_func ("/test_g_variant_equivalent/test_simple_not_equiv",
- test_simple_not_equiv);
- g_test_add_func ("/test_g_variant_equivalent/test_array_not_equiv",
- test_array_not_equiv);
- g_test_add_func ("/test_g_variant_equivalent/test_map_equiv",
- test_map_equiv);
- g_test_add_func ("/test_g_variant_equivalent/test_map_not_equiv1",
- test_map_not_equiv1);
- g_test_add_func ("/test_g_variant_equivalent/test_map_not_equiv2",
- test_map_not_equiv2);
-
- /* dbus_g_value_build_g_variant tests */
- g_test_add_func ("/gvalue-to-gvariant/i", test_i);
- g_test_add_func ("/gvalue-to-gvariant/s", test_s);
- g_test_add_func ("/gvalue-to-gvariant/o", test_o);
- g_test_add_func ("/gvalue-to-gvariant/us", test_us);
- g_test_add_func ("/gvalue-to-gvariant/a{os}", test_a_os);
- g_test_add_func ("/gvalue-to-gvariant/av", test_av);
- g_test_add_func ("/gvalue-to-gvariant/ab", test_ab);
- g_test_add_func ("/gvalue-to-gvariant/ai", test_ai);
- g_test_add_func ("/gvalue-to-gvariant/au", test_au);
- g_test_add_func ("/gvalue-to-gvariant/ax", test_ax);
- g_test_add_func ("/gvalue-to-gvariant/at", test_at);
- g_test_add_func ("/gvalue-to-gvariant/ay", test_ay);
- g_test_add_func ("/gvalue-to-gvariant/g", test_g);
-
- /* dbus_g_value_parse_g_variant tests */
- g_test_add_func ("/parse-gvariant/basic", test_parse_basic);
- g_test_add_func ("/parse-gvariant/array", test_parse_array);
- g_test_add_func ("/parse-gvariant/string_hash", test_parse_string_hash);
-
- /* round-trips */
- g_test_add_data_func ("/parse-gvariant/roundtrip/u",
- "@u 42", test_roundtrip);
- g_test_add_data_func ("/parse-gvariant/roundtrip/non_empty_array",
- "@ai [23, 42]", test_roundtrip);
- g_test_add_data_func ("/roundtrip/empty_array", "@ai []", test_roundtrip);
- g_test_add_data_func ("/roundtrip/aav", "[[<'bees'>]]", test_roundtrip);
- g_test_add_data_func ("/roundtrip/aau", "[[uint32 666]]", test_roundtrip);
- g_test_add_data_func ("/roundtrip/aax", "[[int64 666]]", test_roundtrip);
- g_test_add_data_func ("/roundtrip/aat", "[[uint64 666]]", test_roundtrip);
- g_test_add_data_func ("/roundtrip/aas", "[['a', 'b']]", test_roundtrip);
- g_test_add_data_func ("/roundtrip/aao",
- "[[objectpath '/a', objectpath '/b']]", test_roundtrip);
- g_test_add_data_func ("/roundtrip/aag", "[[signature 'ab', signature 'g']]",
- test_roundtrip);
- g_test_add_data_func ("/roundtrip/aad", "[[5.25, 3.5]]", test_roundtrip);
- g_test_add_data_func ("/roundtrip/aay", "@aay [[1, 2]]", test_roundtrip);
- g_test_add_data_func ("/roundtrip/empty_aay", "@aay [[]]", test_roundtrip);
- g_test_add_data_func ("/roundtrip/aab", "[[true, false]]", test_roundtrip);
- g_test_add_data_func ("/roundtrip/empty_aab", "@aab [[]]", test_roundtrip);
- g_test_add_data_func ("/roundtrip/aa_asv", "[[@a{sv} {'x': <'y'>}]]",
- test_roundtrip);
- g_test_add_data_func ("/roundtrip/empty_av", "@av []", test_roundtrip);
- g_test_add_data_func ("/roundtrip/empty_hash", "@a{uu} {}", test_roundtrip);
- g_test_add_data_func ("/roundtrip/easy_string_hash",
- "@a{ss} {'foo': 'bar'}", test_roundtrip);
- g_test_add_data_func ("/roundtrip/non_empty_asv",
- "@a{sv} {'badger': <42>, 'mushroom': <objectpath '/'>, 'snake': <''>}",
- test_roundtrip);
- g_test_add_data_func ("/roundtrip/variant_nesting", "<<<42>>>",
- test_roundtrip);
- g_test_add_data_func ("/roundtrip/tuple", "(23, 42, true)",
- test_roundtrip);
- g_test_add_data_func ("/roundtrip/nested", "[[[(1, 2)]]]", test_roundtrip);
- g_test_add_data_func ("/roundtrip/empty_aaa", "@aaav [[]]",
- test_roundtrip);
- g_test_add_data_func ("/roundtrip/empty_aa_asv", "@aaa{sv} [[]]",
- test_roundtrip);
- g_test_add_data_func ("/roundtrip/empty_aa_struct", "@aa(us) [[]]",
- test_roundtrip);
- g_test_add_data_func ("/roundtrip/empty_aaas", "@aaas [[]]", test_roundtrip);
- g_test_add_data_func ("/roundtrip/empty_aax", "@aax [[]]", test_roundtrip);
- g_test_add_data_func ("/roundtrip/empty_aat", "@aat [[]]", test_roundtrip);
- g_test_add_data_func ("/roundtrip/empty_aad", "@aad [[]]", test_roundtrip);
- g_test_add_data_func ("/roundtrip/empty_aao", "@aao [[]]", test_roundtrip);
- g_test_add_data_func ("/roundtrip/empty_aag", "@aag [[]]", test_roundtrip);
-
- return g_test_run ();
-}
diff --git a/test/core/test-profile.c b/test/core/test-profile.c
deleted file mode 100644
index fe2f476..0000000
--- a/test/core/test-profile.c
+++ /dev/null
@@ -1,1146 +0,0 @@
-/* -*- mode: C; c-file-style: "gnu" -*- */
-/* test-profile.c Program that does basic message-response for timing; doesn't really use glib bindings
- *
- * Copyright (C) 2003, 2004 Red Hat Inc.
- *
- * Licensed under the Academic Free License version 2.1
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- */
-
-#include <config.h>
-#include <glib.h>
-
-/* This test uses Unix-specific facilities */
-#ifdef G_OS_WIN32
-#define TEST_PROFILE_DISABLED
-#endif
-
-#ifndef TEST_PROFILE_DISABLED
-
-#include <dbus/dbus-glib-lowlevel.h>
-#include <stdlib.h>
-#include <unistd.h>
-
-#include <errno.h>
-#include <fcntl.h>
-#include <sys/socket.h>
-#include <sys/un.h>
-#include <netinet/in.h>
-#include <string.h>
-#include <sys/time.h>
-#include <sys/stat.h>
-#ifndef HAVE_SOCKLEN_T
-#define socklen_t int
-#endif
-
-#define _DBUS_ZERO(object) (memset (&(object), '\0', sizeof ((object))))
-#define _DBUS_MAX_SUN_PATH_LENGTH 99
-
-/* Note that if you set threads > 1 you get a bogus profile since the
- * clients start blocking on the server, so the client write() will go
- * higher in the profile the larger the number of threads.
- */
-#define N_CLIENT_THREADS 1
-/* It seems like at least 750000 or so iterations reduces the variability to sane levels */
-#define N_ITERATIONS 2000
-#define N_PROGRESS_UPDATES 20
-/* Don't make PAYLOAD_SIZE too huge because it gets used as a static buffer size */
-#define PAYLOAD_SIZE 0
-
-#define ECHO_SERVICE "org.freedesktop.DBus.GLib.EchoTestServer"
-#define ECHO_PATH "/org/freedesktop/DBus/GLib/EchoTest"
-#define ECHO_INTERFACE "org.freedesktop.DBus.GLib.EchoTest"
-#define ECHO_PING_METHOD "Ping"
-
-static const char *messages_address;
-static const char *plain_sockets_address;
-static unsigned char *payload;
-static int echo_call_size;
-static int echo_return_size;
-
-typedef struct ProfileRunVTable ProfileRunVTable;
-
-typedef struct
-{
- const ProfileRunVTable *vtable;
- int iterations;
- GMainLoop *loop;
-} ClientData;
-
-typedef struct
-{
- const ProfileRunVTable *vtable;
- int handled;
- GMainLoop *loop;
- int n_clients;
-} ServerData;
-
-struct ProfileRunVTable
-{
- const char *name;
- gboolean fake_malloc_overhead;
- void* (* init_server) (ServerData *sd);
- void (* stop_server) (ServerData *sd,
- void *server);
- void* (* client_thread_func) (void *data); /* Data has to be the vtable */
-
- /* this is so different runs show up in the profiler with
- * different backtrace
- */
- void (* main_loop_run_func) (GMainLoop *loop);
-};
-
-/* Note, this is all crack-a-rific; it isn't using DBusGProxy and thus is
- * a major pain
- */
-static void
-send_echo_method_call (DBusConnection *connection)
-{
- DBusMessage *message;
- const char *hello = "Hello World!";
- dbus_int32_t i32 = 123456;
-
- message = dbus_message_new_method_call (ECHO_SERVICE,
- ECHO_PATH,
- ECHO_INTERFACE,
- ECHO_PING_METHOD);
- dbus_message_append_args (message,
- DBUS_TYPE_STRING, &hello,
- DBUS_TYPE_INT32, &i32,
-#if PAYLOAD_SIZE > 0
- DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE,
- &payload, PAYLOAD_SIZE,
-#endif
- DBUS_TYPE_INVALID);
-
- dbus_connection_send (connection, message, NULL);
- dbus_message_unref (message);
- dbus_connection_flush (connection);
-}
-
-static void
-send_echo_method_return (DBusConnection *connection,
- DBusMessage *call_message)
-{
- DBusMessage *message;
-
- message = dbus_message_new_method_return (call_message);
-
- dbus_connection_send (connection, message, NULL);
- dbus_message_unref (message);
- dbus_connection_flush (connection);
-}
-
-static DBusHandlerResult
-with_or_without_bus_client_filter (DBusConnection *connection,
- DBusMessage *message,
- ClientData *cd)
-{
- if (dbus_message_is_signal (message,
- DBUS_INTERFACE_LOCAL,
- "Disconnected"))
- {
- g_printerr ("Client thread disconnected\n");
- exit (1);
- }
- else if (dbus_message_get_type (message) == DBUS_MESSAGE_TYPE_METHOD_RETURN)
- {
- cd->iterations += 1;
- if (cd->iterations >= N_ITERATIONS)
- {
- g_printerr ("\nCompleted %d iterations\n", N_ITERATIONS);
- g_main_loop_quit (cd->loop);
- }
- else if (cd->iterations % (N_ITERATIONS/N_PROGRESS_UPDATES) == 0)
- {
- g_printerr ("%d%% ", (int) (cd->iterations/(double)N_ITERATIONS * 100.0));
- }
-
- send_echo_method_call (connection);
- return DBUS_HANDLER_RESULT_HANDLED;
- }
-
- return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
-}
-
-static DBusHandlerResult
-no_bus_client_filter (DBusConnection *connection,
- DBusMessage *message,
- void *user_data)
-{
- ClientData *cd = user_data;
-
- return with_or_without_bus_client_filter (connection, message, cd);
-}
-
-static void*
-no_bus_thread_func (void *data)
-{
- DBusError error;
- GMainContext *context;
- DBusConnection *connection;
- ClientData cd;
-
- g_printerr ("Starting client thread %p\n", g_thread_self());
-
- dbus_error_init (&error);
- connection = dbus_connection_open_private (messages_address, &error);
- if (connection == NULL)
- {
- g_printerr ("could not open connection: %s\n", error.message);
- dbus_error_free (&error);
- exit (1);
- }
-
- dbus_connection_set_exit_on_disconnect (connection, FALSE);
-
- context = g_main_context_new ();
-
- cd.iterations = 1;
- cd.loop = g_main_loop_new (context, FALSE);
-
- if (!dbus_connection_add_filter (connection,
- no_bus_client_filter, &cd, NULL))
- g_error ("no memory");
-
-
- dbus_connection_setup_with_g_main (connection, context);
-
- g_printerr ("Client thread sending message to prime pingpong\n");
- send_echo_method_call (connection);
- g_printerr ("Client thread sent message\n");
-
- g_printerr ("Client thread entering main loop\n");
- g_main_loop_run (cd.loop);
- g_printerr ("Client thread %p exiting main loop\n",
- g_thread_self());
-
- dbus_connection_close (connection);
-
- g_main_loop_unref (cd.loop);
- g_main_context_unref (context);
-
- return NULL;
-}
-
-static DBusHandlerResult
-no_bus_server_filter (DBusConnection *connection,
- DBusMessage *message,
- void *user_data)
-{
- ServerData *sd = user_data;
-
- if (dbus_message_is_signal (message,
- DBUS_INTERFACE_LOCAL,
- "Disconnected"))
- {
- g_printerr ("Client disconnected from server\n");
- sd->n_clients -= 1;
- if (sd->n_clients == 0)
- g_main_loop_quit (sd->loop);
- }
- else if (dbus_message_is_method_call (message,
- ECHO_INTERFACE,
- ECHO_PING_METHOD))
- {
- sd->handled += 1;
- send_echo_method_return (connection, message);
- return DBUS_HANDLER_RESULT_HANDLED;
- }
-
- return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
-}
-
-static void
-no_bus_new_connection_callback (DBusServer *server,
- DBusConnection *new_connection,
- void *user_data)
-{
- ServerData *sd = user_data;
-
- dbus_connection_ref (new_connection);
- dbus_connection_setup_with_g_main (new_connection, NULL);
-
- if (!dbus_connection_add_filter (new_connection,
- no_bus_server_filter, sd, NULL))
- g_error ("no memory");
-
- sd->n_clients += 1;
-
- /* FIXME we leak the handler */
-}
-
-static void*
-no_bus_init_server (ServerData *sd)
-{
- DBusServer *server;
- DBusError error;
-
- dbus_error_init (&error);
- server = dbus_server_listen ("unix:tmpdir=/tmp", &error);
- if (server == NULL)
- {
- g_printerr ("Could not start server: %s\n",
- error.message);
- exit (1);
- }
-
- messages_address = dbus_server_get_address (server);
-
- dbus_server_set_new_connection_function (server,
- no_bus_new_connection_callback,
- sd, NULL);
-
- dbus_server_setup_with_g_main (server, NULL);
-
- return server;
-}
-
-static void
-no_bus_stop_server (ServerData *sd,
- void *server)
-{
- dbus_server_disconnect (server);
- dbus_server_unref (server);
-}
-
-static void
-no_bus_main_loop_run (GMainLoop *loop)
-{
- g_main_loop_run (loop);
-}
-
-static const ProfileRunVTable no_bus_vtable = {
- "dbus direct without bus",
- FALSE,
- no_bus_init_server,
- no_bus_stop_server,
- no_bus_thread_func,
- no_bus_main_loop_run
-};
-
-typedef struct
-{
- const ProfileRunVTable *vtable;
- ServerData *sd;
- GHashTable *client_names;
- DBusConnection *connection;
-} WithBusServer;
-
-static DBusHandlerResult
-with_bus_client_filter (DBusConnection *connection,
- DBusMessage *message,
- void *user_data)
-{
- ClientData *cd = user_data;
-
- return with_or_without_bus_client_filter (connection, message, cd);
-}
-
-static void*
-with_bus_thread_func (void *data)
-{
- DBusError error;
- DBusConnection *connection;
- ClientData cd;
- const char *address;
- GMainContext *context;
-
- g_printerr ("Starting client thread %p\n", g_thread_self());
-
- address = g_getenv ("DBUS_SESSION_BUS_ADDRESS");
- if (address == NULL)
- {
- g_printerr ("DBUS_SESSION_BUS_ADDRESS not set\n");
- exit (1);
- }
-
- dbus_error_init (&error);
- connection = dbus_connection_open_private (address, &error);
- if (connection == NULL)
- {
- g_printerr ("could not open connection to bus: %s\n", error.message);
- dbus_error_free (&error);
- exit (1);
- }
-
- dbus_connection_set_exit_on_disconnect (connection, FALSE);
-
- if (!dbus_bus_register (connection, &error))
- {
- g_printerr ("could not register with bus: %s\n", error.message);
- dbus_error_free (&error);
- exit (1);
- }
-
- context = g_main_context_new ();
-
- cd.iterations = 1;
- cd.loop = g_main_loop_new (context, FALSE);
-
- if (!dbus_connection_add_filter (connection,
- with_bus_client_filter, &cd, NULL))
- g_error ("no memory");
-
- dbus_connection_setup_with_g_main (connection, context);
-
- g_printerr ("Client thread sending message to prime pingpong\n");
- send_echo_method_call (connection);
- g_printerr ("Client thread sent message\n");
-
- g_printerr ("Client thread entering main loop\n");
- g_main_loop_run (cd.loop);
- g_printerr ("Client thread %p exiting main loop\n",
- g_thread_self());
-
- dbus_connection_close (connection);
-
- g_main_loop_unref (cd.loop);
- g_main_context_unref (context);
-
- return NULL;
-}
-
-static DBusHandlerResult
-with_bus_server_filter (DBusConnection *connection,
- DBusMessage *message,
- void *user_data)
-{
- WithBusServer *server = user_data;
-
- if (dbus_message_is_signal (message,
- DBUS_INTERFACE_LOCAL,
- "Disconnected"))
- {
- g_printerr ("Server disconnected from message bus\n");
- exit (1);
- }
- else if (dbus_message_has_sender (message,
- DBUS_SERVICE_DBUS) &&
- dbus_message_is_signal (message,
- DBUS_INTERFACE_DBUS,
- "NameOwnerChanged"))
- {
- const char *name, *old_owner, *new_owner;
- DBusError error;
-
- name = NULL;
- old_owner = NULL;
- new_owner = NULL;
-
- dbus_error_init (&error);
- if (!dbus_message_get_args (message,
- &error,
- DBUS_TYPE_STRING, &name,
- DBUS_TYPE_STRING, &old_owner,
- DBUS_TYPE_STRING, &new_owner,
- DBUS_TYPE_INVALID))
- {
- g_printerr ("dbus_message_get_args(): %s\n", error.message);
- exit (1);
- }
-
- if (g_hash_table_lookup (server->client_names,
- name) &&
- *old_owner != '\0' &&
- *new_owner == '\0')
- {
- g_hash_table_remove (server->client_names,
- name);
- server->sd->n_clients -= 1;
- if (server->sd->n_clients == 0)
- g_main_loop_quit (server->sd->loop);
- }
- }
- else if (dbus_message_is_method_call (message,
- ECHO_INTERFACE,
- ECHO_PING_METHOD))
- {
- const char *sender;
-
- sender = dbus_message_get_sender (message);
-
- if (!g_hash_table_lookup (server->client_names,
- sender))
- {
- g_printerr ("First message from new client %s on bus\n", sender);
-
- g_hash_table_replace (server->client_names,
- g_strdup (sender),
- GINT_TO_POINTER (1));
- server->sd->n_clients += 1;
- }
-
- server->sd->handled += 1;
- send_echo_method_return (connection, message);
- return DBUS_HANDLER_RESULT_HANDLED;
- }
-
- return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
-}
-
-static void*
-with_bus_init_server (ServerData *sd)
-{
- DBusGConnection *gconnection;
- DBusConnection *connection;
- GError *gerror;
- const char *s;
- WithBusServer *server;
- char *rule;
-
- server = g_new0 (WithBusServer, 1);
-
- server->vtable = sd->vtable;
- server->sd = sd;
-
- s = g_getenv ("DBUS_TEST_GLIB_RUN_TEST_SCRIPT");
- if (s == NULL ||
- *s != '1')
- {
- g_printerr ("You have to run with_bus mode with the run-test.sh script\n");
- exit (1);
- }
-
- /* Note that we use the standard global bus connection for the
- * server, and the clients open their own connections so they can
- * have their own main loops and because I'm not sure "talking to
- * yourself" really works yet
- */
- gerror = NULL;
- gconnection = dbus_g_bus_get (DBUS_BUS_SESSION, &gerror);
- if (gconnection == NULL)
- {
- g_printerr ("could not open connection to bus: %s\n", gerror->message);
- g_error_free (gerror);
- exit (1);
- }
-
- server->client_names = g_hash_table_new_full (g_str_hash, g_str_equal,
- g_free, NULL);
-
- connection = dbus_g_connection_get_connection (gconnection);
-
- dbus_connection_set_exit_on_disconnect (connection, FALSE);
-
- dbus_bus_request_name (connection,
- ECHO_SERVICE,
- 0, NULL); /* ignore errors because we suck */
-
- rule = g_strdup_printf ("type='signal',sender='%s',member='%s'",
- DBUS_SERVICE_DBUS,
- "NameOwnerChanged");
-
- /* ignore errors because we suck */
- dbus_bus_add_match (connection, rule, NULL);
-
- g_free (rule);
-
- if (!dbus_connection_add_filter (connection,
- with_bus_server_filter, server, NULL))
- g_error ("no memory");
-
- server->connection = connection;
- server->client_names = g_hash_table_new_full (g_str_hash, g_str_equal,
- g_free, NULL);
-
- return server;
-}
-
-static void
-with_bus_stop_server (ServerData *sd,
- void *serverv)
-{
- WithBusServer *server = serverv;
-
- dbus_connection_remove_filter (server->connection,
- with_bus_server_filter, server);
-
- g_hash_table_destroy (server->client_names);
- dbus_connection_unref (server->connection);
-
- g_free (server);
-}
-
-static void
-with_bus_main_loop_run (GMainLoop *loop)
-{
- g_main_loop_run (loop);
-}
-
-static const ProfileRunVTable with_bus_vtable = {
- "routing via a bus",
- FALSE,
- with_bus_init_server,
- with_bus_stop_server,
- with_bus_thread_func,
- with_bus_main_loop_run
-};
-
-
-typedef struct
-{
- const ProfileRunVTable *vtable;
- int listen_fd;
- ServerData *sd;
- unsigned int source_id;
-} PlainSocketServer;
-
-static void
-read_and_drop_on_floor (int fd,
- int count,
- gboolean fake_malloc_overhead)
-{
- int bytes_read;
- int val;
- char *buf;
- char *allocated;
- char not_allocated[512+PAYLOAD_SIZE];
-
- g_assert (count < (int) sizeof(not_allocated));
-
- if (fake_malloc_overhead)
- {
- allocated = g_malloc (count);
- buf = allocated;
- }
- else
- {
- allocated = NULL;
- buf = not_allocated;
- }
-
- bytes_read = 0;
-
- while (bytes_read < count)
- {
- again:
-
- val = read (fd, buf + bytes_read, count - bytes_read);
-
- if (val < 0)
- {
- if (errno == EINTR)
- goto again;
- else
- {
- g_printerr ("read() failed thread %p: %s\n",
- g_thread_self(), strerror (errno));
- exit (1);
- }
- }
- else
- {
- bytes_read += val;
- }
- }
-
- if (fake_malloc_overhead)
- g_free (allocated);
-
-#if 0
- g_printerr ("%p read %d bytes from fd %d\n",
- g_thread_self(), bytes_read, fd);
-#endif
-}
-
-static void
-write_junk (int fd,
- int count,
- gboolean fake_malloc_overhead)
-{
- int bytes_written;
- int val;
- char *buf;
- char *allocated;
- char not_allocated[512+PAYLOAD_SIZE] = { '\0', };
-
- g_assert (count < (int) sizeof(not_allocated));
-
- if (fake_malloc_overhead)
- {
- int i;
-
- allocated = g_malloc (count);
- buf = allocated;
-
- /* Write some stuff into the allocated buffer to simulate
- * creating some sort of data
- */
- i = 0;
- while (i < count)
- {
- allocated[i] = (char) i;
- ++i;
- }
- }
- else
- {
- allocated = NULL;
- buf = not_allocated;
- }
-
- bytes_written = 0;
-
- while (bytes_written < count)
- {
- again:
-
- val = write (fd, buf + bytes_written, count - bytes_written);
-
- if (val < 0)
- {
- if (errno == EINTR)
- goto again;
- else
- {
- g_printerr ("write() failed thread %p: %s\n",
- g_thread_self(), strerror (errno));
- exit (1);
- }
- }
- else
- {
- bytes_written += val;
- }
- }
-
- if (fake_malloc_overhead)
- g_free (allocated);
-
-#if 0
- g_printerr ("%p wrote %d bytes to fd %d\n",
- g_thread_self(), bytes_written, fd);
-#endif
-}
-
-static gboolean
-plain_sockets_talk_to_client_watch (GIOChannel *source,
- GIOCondition condition,
- gpointer data)
-{
- PlainSocketServer *server = data;
- int client_fd = g_io_channel_unix_get_fd (source);
-
- if (condition & G_IO_HUP)
- {
- g_printerr ("Client disconnected from server\n");
- server->sd->n_clients -= 1;
- if (server->sd->n_clients == 0)
- g_main_loop_quit (server->sd->loop);
-
- return FALSE; /* remove watch */
- }
- else if (condition & G_IO_IN)
- {
- server->sd->handled += 1;
-
- read_and_drop_on_floor (client_fd, echo_call_size, server->vtable->fake_malloc_overhead);
- write_junk (client_fd, echo_return_size, server->vtable->fake_malloc_overhead);
- }
- else
- {
- g_printerr ("Unexpected IO condition in server thread\n");
- exit (1);
- }
-
- return TRUE;
-}
-
-static gboolean
-plain_sockets_new_client_watch (GIOChannel *source,
- GIOCondition condition,
- gpointer data)
-{
- int client_fd;
- struct sockaddr addr;
- socklen_t addrlen;
- GIOChannel *channel;
- PlainSocketServer *server = data;
-
- if (!(condition & G_IO_IN))
- {
- g_printerr ("Unexpected IO condition on server socket\n");
- exit (1);
- }
-
- addrlen = sizeof (addr);
-
- retry:
- client_fd = accept (server->listen_fd, &addr, &addrlen);
-
- if (client_fd < 0)
- {
- if (errno == EINTR)
- goto retry;
- else
- {
- g_printerr ("Failed to accept() connection from client: %s\n",
- strerror (errno));
- exit (1);
- }
- }
-
- channel = g_io_channel_unix_new (client_fd);
- g_io_add_watch (channel,
- G_IO_IN | G_IO_ERR | G_IO_HUP | G_IO_NVAL | G_IO_PRI,
- plain_sockets_talk_to_client_watch,
- server);
- g_io_channel_unref (channel);
-
- server->sd->n_clients += 1;
-
- return TRUE;
-}
-
-static void*
-plain_sockets_init_server (ServerData *sd)
-{
- PlainSocketServer *server;
- struct sockaddr_un addr;
- static char path[] = "/tmp/dbus-test-profile-XXXXXX";
- char *p;
- GIOChannel *channel;
-
- server = g_new0 (PlainSocketServer, 1);
- server->sd = sd;
- server->vtable = sd->vtable; /* for convenience */
-
- p = path;
- while (*p)
- {
- if (*p == 'X')
- *p = 'a' + (int) (26.0*rand()/(RAND_MAX+1.0));
- ++p;
- }
-
- g_printerr ("Socket is %s\n", path);
-
- server->listen_fd = socket (PF_UNIX, SOCK_STREAM, 0);
-
- if (server->listen_fd < 0)
- {
- g_printerr ("Failed to create socket: %s",
- strerror (errno));
- exit (1);
- }
-
- _DBUS_ZERO (addr);
- addr.sun_family = AF_UNIX;
-
- {
- struct stat sb;
-
- if (stat (path, &sb) == 0 &&
- S_ISSOCK (sb.st_mode))
- unlink (path);
- }
-
- strncpy (addr.sun_path, path, _DBUS_MAX_SUN_PATH_LENGTH - 1);
-
- if (bind (server->listen_fd, (struct sockaddr*) &addr, sizeof (addr)) < 0)
- {
- g_printerr ("Failed to bind socket \"%s\": %s",
- path, strerror (errno));
- exit (1);
- }
-
- if (listen (server->listen_fd, 30 /* backlog */) < 0)
- {
- g_printerr ("Failed to listen on socket \"%s\": %s",
- path, strerror (errno));
- exit (1);
- }
-
- plain_sockets_address = path;
-
- channel = g_io_channel_unix_new (server->listen_fd);
- server->source_id =
- g_io_add_watch (channel,
- G_IO_IN | G_IO_ERR | G_IO_HUP | G_IO_NVAL | G_IO_PRI,
- plain_sockets_new_client_watch,
- server);
- g_io_channel_unref (channel);
-
- return server;
-}
-
-static void
-plain_sockets_stop_server (ServerData *sd,
- void *server_v)
-{
- PlainSocketServer *server = server_v;
-
- g_source_remove (server->source_id);
-
- close (server->listen_fd);
- g_free (server);
-
- {
- struct stat sb;
-
- if (stat (plain_sockets_address, &sb) == 0 &&
- S_ISSOCK (sb.st_mode))
- unlink (plain_sockets_address);
- }
-}
-
-static gboolean
-plain_sockets_client_side_watch (GIOChannel *source,
- GIOCondition condition,
- gpointer data)
-{
- ClientData *cd = data;
- int fd = g_io_channel_unix_get_fd (source);
-
- if (condition & G_IO_IN)
- {
- read_and_drop_on_floor (fd, echo_return_size, cd->vtable->fake_malloc_overhead);
- }
- else if (condition & G_IO_OUT)
- {
- cd->iterations += 1;
- if (cd->iterations >= N_ITERATIONS)
- {
- g_printerr ("\nCompleted %d iterations\n", N_ITERATIONS);
- g_main_loop_quit (cd->loop);
- }
- else if (cd->iterations % (N_ITERATIONS/N_PROGRESS_UPDATES) == 0)
- {
- g_printerr ("%d%% ", (int) (cd->iterations/(double)N_ITERATIONS * 100.0));
- }
-
- write_junk (fd, echo_call_size, cd->vtable->fake_malloc_overhead);
- }
- else
- {
- g_printerr ("Unexpected IO condition in client thread\n");
- exit (1);
- }
-
- return TRUE;
-}
-
-static void*
-plain_sockets_thread_func (void *data)
-{
- GMainContext *context;
- ClientData cd;
- int fd;
- struct sockaddr_un addr;
- GIOChannel *channel;
- GSource *gsource;
-
- g_printerr ("Starting client thread %p\n",
- g_thread_self());
-
- fd = socket (PF_UNIX, SOCK_STREAM, 0);
-
- if (fd < 0)
- {
- g_printerr ("Failed to create socket: %s",
- strerror (errno));
- exit (1);
- }
-
- _DBUS_ZERO (addr);
- addr.sun_family = AF_UNIX;
-
- strncpy (addr.sun_path, plain_sockets_address, _DBUS_MAX_SUN_PATH_LENGTH - 1);
-
- if (connect (fd, (struct sockaddr*) &addr, sizeof (addr)) < 0)
- {
- g_printerr ("Failed to connect to socket %s: %s",
- plain_sockets_address, strerror (errno));
- exit (1);
- }
-
- context = g_main_context_new ();
-
- cd.iterations = 1;
- cd.loop = g_main_loop_new (context, FALSE);
- cd.vtable = data;
-
- channel = g_io_channel_unix_new (fd);
-
- gsource = g_io_create_watch (channel,
- G_IO_IN | G_IO_OUT |
- G_IO_ERR | G_IO_HUP | G_IO_NVAL | G_IO_PRI);
-
- g_source_set_callback (gsource,
- (GSourceFunc)plain_sockets_client_side_watch,
- &cd, NULL);
-
- g_source_attach (gsource, context);
-
- g_io_channel_unref (channel);
-
- g_printerr ("Client thread writing to prime pingpong\n");
- write_junk (fd, echo_call_size, cd.vtable->fake_malloc_overhead);
- g_printerr ("Client thread done writing primer\n");
-
- g_printerr ("Client thread entering main loop\n");
- g_main_loop_run (cd.loop);
- g_printerr ("Client thread %p exiting main loop\n",
- g_thread_self());
-
- g_source_destroy (gsource);
-
- close (fd);
-
- g_main_loop_unref (cd.loop);
- g_main_context_unref (context);
-
- return NULL;
-}
-
-static void
-plain_sockets_main_loop_run (GMainLoop *loop)
-{
- g_main_loop_run (loop);
-}
-
-static const ProfileRunVTable plain_sockets_vtable = {
- "plain sockets",
- FALSE,
- plain_sockets_init_server,
- plain_sockets_stop_server,
- plain_sockets_thread_func,
- plain_sockets_main_loop_run
-};
-
-static const ProfileRunVTable plain_sockets_with_malloc_vtable = {
- "plain sockets with malloc overhead",
- TRUE,
- plain_sockets_init_server,
- plain_sockets_stop_server,
- plain_sockets_thread_func,
- plain_sockets_main_loop_run
-};
-
-static double
-do_profile_run (const ProfileRunVTable *vtable)
-{
- GTimer *timer;
- int i;
- double secs;
- ServerData sd;
- void *server;
-
- g_printerr ("Profiling %s\n", vtable->name);
-
- sd.handled = 0;
- sd.n_clients = 0;
- sd.loop = g_main_loop_new (NULL, FALSE);
- sd.vtable = vtable;
-
- server = (* vtable->init_server) (&sd);
-
- for (i = 0; i < N_CLIENT_THREADS; i++)
- {
- g_thread_create (vtable->client_thread_func, (void*) vtable, FALSE, NULL);
- }
-
- timer = g_timer_new ();
-
- g_printerr ("Server thread %p entering main loop\n",
- g_thread_self());
- (* vtable->main_loop_run_func) (sd.loop);
- g_printerr ("Server thread %p exiting main loop\n",
- g_thread_self());
-
- secs = g_timer_elapsed (timer, NULL);
- g_timer_destroy (timer);
-
- g_printerr ("%s: %g seconds, %d round trips, %f seconds per pingpong\n",
- vtable->name, secs, sd.handled, secs/sd.handled);
-
- (* vtable->stop_server) (&sd, server);
-
- g_main_loop_unref (sd.loop);
-
- return secs;
-}
-
-static void
-print_result (const ProfileRunVTable *vtable,
- double seconds,
- double baseline)
-{
- g_printerr (" %g times slower for %s (%g seconds, %f per iteration)\n",
- seconds/baseline, vtable->name,
- seconds, seconds / N_ITERATIONS);
-}
-#endif
-
-int
-main (int argc, char *argv[])
-{
-#if (!GLIB_CHECK_VERSION (2, 35, 1))
- g_type_init ();
-#endif
-
-#ifndef TEST_PROFILE_DISABLED
- dbus_g_thread_init ();
-
-#ifndef G_DISABLE_ASSERT
- g_printerr ("You should probably --disable-asserts before you profile as they have noticeable overhead\n");
-#endif
-
- payload = g_malloc (PAYLOAD_SIZE);
-
- /* The actual size of the DBusMessage on the wire, as of Nov 23 2004,
- * without the payload
- */
- echo_call_size = 140 + PAYLOAD_SIZE;
- echo_return_size = 32;
-
- if (argc > 1 && strcmp (argv[1], "plain_sockets") == 0)
- do_profile_run (&plain_sockets_vtable);
- else if (argc > 1 && strcmp (argv[1], "plain_sockets_with_malloc") == 0)
- do_profile_run (&plain_sockets_with_malloc_vtable);
- else if (argc > 1 && strcmp (argv[1], "no_bus") == 0)
- do_profile_run (&no_bus_vtable);
- else if (argc > 1 && strcmp (argv[1], "with_bus") == 0)
- do_profile_run (&with_bus_vtable);
- else if (argc > 1 && strcmp (argv[1], "all") == 0)
- {
- double e1, e2, e3, e4;
-
- e1 = do_profile_run (&plain_sockets_vtable);
- e2 = do_profile_run (&plain_sockets_with_malloc_vtable);
- e3 = do_profile_run (&no_bus_vtable);
- e4 = do_profile_run (&with_bus_vtable);
-
- g_printerr ("Baseline plain sockets time %g seconds for %d iterations\n",
- e1, N_ITERATIONS);
- print_result (&plain_sockets_vtable, e1, e1);
- print_result (&plain_sockets_with_malloc_vtable, e2, e1);
- print_result (&no_bus_vtable, e3, e1);
- print_result (&with_bus_vtable, e4, e1);
- }
- else
- {
- g_printerr ("Specify profile type plain_sockets, plain_sockets_with_malloc, no_bus, with_bus, all\n");
- exit (1);
- }
-
- /* Make valgrind happy */
- dbus_shutdown ();
-#endif /* TEST_PROFILE_DISABLED */
- return 0;
-}
diff --git a/test/core/test-service-glib-subclass.xml b/test/core/test-service-glib-subclass.xml
deleted file mode 100644
index ffa34de..0000000
--- a/test/core/test-service-glib-subclass.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-
-<node name="/org/freedesktop/DBus/GLib/Tests/MyTestObjectSubclass">
- <interface name="org.freedesktop.DBus.GLib.Tests.MyObjectSubclass">
- <property name="this_is_a_subclass_string" type="s" access="readwrite"/>
- <property name="this_is_a_subclass_uint" type="u" access="readwrite"/>
- </interface>
-</node>
diff --git a/test/core/test-service-glib.c b/test/core/test-service-glib.c
deleted file mode 100644
index 8da330a..0000000
--- a/test/core/test-service-glib.c
+++ /dev/null
@@ -1,112 +0,0 @@
-#include <config.h>
-
-/* -*- mode: C; c-file-style: "gnu" -*- */
-#include <dbus/dbus-glib.h>
-/* NOTE - outside of D-BUS core this would be
- * include <dbus/dbus-glib-bindings.h>
- */
-#include "tools/dbus-glib-bindings.h"
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <glib/gi18n.h>
-#include <glib-object.h>
-
-#include "my-object.h"
-#include "my-object-subclass.h"
-
-static GObject *obj;
-static GObject *obj2;
-static GObject *subobj;
-GMainLoop *loop;
-
-#define TEST_SERVICE_NAME "org.freedesktop.DBus.GLib.TestService"
-
-int
-main (int argc, char **argv)
-{
- DBusGConnection *connection;
- GError *error;
- DBusGProxy *driver_proxy;
- guint32 request_name_ret;
-
- g_type_init ();
- dbus_g_thread_init ();
-
- dbus_g_error_domain_register (MY_OBJECT_ERROR,
- NULL,
- MY_TYPE_ERROR);
-
- g_printerr ("Launching test-service-glib\n");
-
- loop = g_main_loop_new (NULL, FALSE);
-
- {
- GLogLevelFlags fatal_mask;
-
- fatal_mask = g_log_set_always_fatal (G_LOG_FATAL_MASK);
- fatal_mask |= G_LOG_LEVEL_WARNING | G_LOG_LEVEL_CRITICAL;
- g_log_set_always_fatal (fatal_mask);
- }
-
- error = NULL;
- connection = dbus_g_bus_get (DBUS_BUS_STARTER,
- &error);
- if (connection == NULL)
- {
- g_printerr ("Failed to open connection to bus: %s\n",
- error->message);
- g_error_free (error);
- exit (1);
- }
-
- obj = g_object_new (MY_TYPE_OBJECT, NULL);
- obj2 = g_object_new (MY_TYPE_OBJECT, NULL);
- subobj = g_object_new (MY_TYPE_OBJECT_SUBCLASS, NULL);
-
- dbus_g_connection_register_g_object (connection,
- "/org/freedesktop/DBus/GLib/Tests/MyTestObject",
- obj);
- /* Register a second time; we want the object to also be reachable through this interface */
- dbus_g_connection_register_g_object (connection,
- "/org/freedesktop/DBus/GLib/Tests/Compat/MyTestObjectCompat",
- obj);
- dbus_g_connection_register_g_object (connection,
- "/org/freedesktop/DBus/GLib/Tests/MyTestObject2",
- obj2);
-
- dbus_g_connection_register_g_object (connection,
- "/org/freedesktop/DBus/GLib/Tests/MyTestObjectSubclass",
- subobj);
-
- driver_proxy = dbus_g_proxy_new_for_name (connection,
- DBUS_SERVICE_DBUS,
- DBUS_PATH_DBUS,
- DBUS_INTERFACE_DBUS);
-
- if (!org_freedesktop_DBus_request_name (driver_proxy,
- TEST_SERVICE_NAME,
- 0, &request_name_ret, &error))
- {
- g_assert (error != NULL);
- g_printerr ("Failed to get name: %s\n",
- error->message);
- g_clear_error (&error);
- exit (1);
- }
-
- if (!(request_name_ret == DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER))
- {
- g_printerr ("Got result code %u from requesting name\n", request_name_ret);
- exit (1);
- }
-
- g_printerr ("GLib test service has name '%s'\n", TEST_SERVICE_NAME);
- g_printerr ("GLib test service entering main loop\n");
-
- g_main_loop_run (loop);
-
- g_printerr ("Successfully completed %s\n", argv[0]);
-
- return 0;
-}
diff --git a/test/core/test-service-glib.xml b/test/core/test-service-glib.xml
deleted file mode 100644
index d91620c..0000000
--- a/test/core/test-service-glib.xml
+++ /dev/null
@@ -1,210 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-
-<node name="/org/freedesktop/DBus/GLib/Tests/MyTestObject">
- <interface name="org.freedesktop.DBus.GLib.Tests.MyObject">
- <property name="this_is_a_string" type="s" access="readwrite"/>
- <property name="no-touching" type="u" access="read"/>
- <property name="SuperStudly" type="d" access="readwrite"/>
-
- <method name="DoNothing">
- </method>
-
- <method name="Increment">
- <arg type="u" name="x" />
- <arg type="u" direction="out" />
- </method>
-
- <method name="IncrementRetval">
- <arg type="u" name="x" />
- <arg type="u" direction="out">
- <annotation name="org.freedesktop.DBus.GLib.ReturnVal" value=""/>
- </arg>
- </method>
-
- <method name="IncrementRetvalError">
- <arg type="u" name="x" />
- <arg type="u" direction="out">
- <annotation name="org.freedesktop.DBus.GLib.ReturnVal" value="error"/>
- </arg>
- </method>
-
- <method name="ThrowError">
- </method>
-
- <method name="ThrowUnregisteredError">
- </method>
-
- <method name="Uppercase">
- <arg type="s" direction="in" />
- <arg type="s" direction="out" />
- </method>
-
- <method name="ManyArgs">
- <arg type="u" name="x" direction="in" />
- <arg type="s" name="str" direction="in" />
- <arg type="d" name="trouble" direction="in" />
- <arg type="d" name="d_ret" direction="out" />
- <arg type="s" name="str_ret" direction="out" />
- </method>
-
- <method name="ManyReturn">
- <arg type="u" direction="out" />
- <arg type="s" direction="out" />
- <arg type="i" direction="out" />
- <arg type="u" direction="out" />
- <arg type="u" direction="out" />
- <arg type="s" direction="out">
- <annotation name="org.freedesktop.DBus.GLib.Const" value=""/>
- </arg>
- </method>
-
- <method name="Stringify">
- <arg type="v" name="val" direction="in"/>
- <arg type="s" direction="out"/>
- </method>
-
- <method name="Unstringify">
- <arg type="s" name="val" direction="in"/>
- <arg type="v" direction="out"/>
- </method>
-
- <method name="Recursive1">
- <arg type="au" direction="in"/>
- <arg type="u" direction="out"/>
- </method>
-
- <method name="Recursive2">
- <arg type="u" direction="in"/>
- <arg type="au" direction="out"/>
- </method>
-
- <method name="ManyUppercase">
- <arg type="as" direction="in"/>
- <arg type="as" direction="out"/>
- </method>
-
- <method name="StrHashLen">
- <arg type="a{ss}" direction="in"/>
- <arg type="u" direction="out"/>
- </method>
-
- <method name="SendCar">
- <arg type="(suv)" direction="in"/>
- <arg type="(uo)" direction="out"/>
- </method>
-
- <method name="GetHash">
- <arg type="a{ss}" direction="out"/>
- </method>
-
- <method name="RecArrays">
- <arg type="aas" name="val" direction="in"/>
- <arg type="aau" direction="out"/>
- </method>
-
- <method name="Objpath">
- <arg type="o" direction="in"/>
- <arg type="o" direction="out">
- <annotation name="org.freedesktop.DBus.GLib.Const" value=""/>
- </arg>
- </method>
-
- <method name="GetObjs">
- <arg type="ao" direction="out"/>
- </method>
-
- <method name="IncrementVal">
- </method>
-
- <method name="AsyncIncrement">
- <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
- <arg type="u" name="x" />
- <arg type="u" direction="out" />
- </method>
-
- <method name="AsyncThrowError">
- <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
- </method>
-
- <method name="GetVal">
- <arg type="u" direction="out" />
- </method>
-
- <method name="ManyStringify">
- <arg type="a{sv}" direction="in"/>
- <arg type="a{sv}" direction="out"/>
- </method>
-
- <method name="EchoVariant">
- <arg type="v" direction="in" />
- <arg type="v" direction="out" />
- </method>
-
- <method name="EchoSignature">
- <arg type="g" direction="in" />
- <arg type="g" direction="out" />
- </method>
-
- <method name="ProcessVariantOfArrayOfInts123">
- <arg type="v" direction="in" />
- </method>
-
- <method name="DictOfDicts">
- <arg type="a{sa{ss}}" direction="in"/>
- <arg type="a{sa{ss}}" direction="out"/>
- </method>
-
- <method name="DictOfSigs">
- <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
- <arg type="a{gas}" direction="in" />
- <arg type="a{gas}" direction="out" />
- </method>
-
- <method name="DictOfObjs">
- <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
- <arg type="a{oao}" direction="in" />
- <arg type="a{oao}" direction="out" />
- </method>
-
- <method name="EmitFrobnicate">
- </method>
-
- <method name="UnsafeDisableLegacyPropertyAccess">
- </method>
-
- <!-- Export signals -->
- <signal name="Frobnicate"/>
-
- <signal name="Objectified">
- <arg type="o"/>
- </signal>
-
- <method name="Terminate">
- </method>
- </interface>
-
- <!-- Test multiple interfaces on the same object -->
-
- <interface name="org.freedesktop.DBus.GLib.Tests.FooObject">
- <method name="GetValue">
- <arg type="u" direction="out" />
- </method>
-
- <method name="EmitSignals">
- </method>
-
- <signal name="Sig0"/>
-
- <signal name="Sig1"/>
-
- <method name="EmitSignal2">
- </method>
-
- <signal name="Sig2"/>
-
- <method name="Terminate">
- </method>
-
- </interface>
-
-</node>
diff --git a/test/core/test-types.c b/test/core/test-types.c
deleted file mode 100644
index 58f309c..0000000
--- a/test/core/test-types.c
+++ /dev/null
@@ -1,52 +0,0 @@
-#include <config.h>
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <dbus-glib.h>
-#include <dbus-glib-lowlevel.h>
-
-static void
-lose (const char *str, ...)
-{
- va_list args;
-
- va_start (args, str);
-
- vfprintf (stderr, str, args);
- fputc ('\n', stderr);
-
- va_end (args);
-
- exit (1);
-}
-
-int
-main (int argc, char **argv)
-{
- DBusError derror;
- GError *gerror = NULL;
- DBusGConnection *gconn, *gconn2;
- DBusConnection *conn;
-
- g_type_init ();
- dbus_error_init (&derror);
-
- /* Check DBusGConnection -> DBusConnection -> DBusGConnection */
- gconn = dbus_g_bus_get_private (DBUS_BUS_SESSION, NULL, &gerror);
- if (!gconn)
- lose ("Cannot get connection: %s", gerror->message);
-
- conn = dbus_g_connection_get_connection (gconn);
- if (!conn)
- lose ("Cannot get DBusConnection from DBusGConnection");
-
- gconn2 = dbus_connection_get_g_connection (conn);
- if (gconn != gconn2)
- lose ("Retrieved DBusGConection != original DBusGConnection");
-
- dbus_connection_close (conn);
- dbus_g_connection_unref (gconn);
- dbus_shutdown ();
-
- return 0;
-}
diff --git a/test/core/test-variant-recursion.c b/test/core/test-variant-recursion.c
deleted file mode 100644
index 507ea4d..0000000
--- a/test/core/test-variant-recursion.c
+++ /dev/null
@@ -1,109 +0,0 @@
-#include <config.h>
-
-/* -*- mode: C; c-file-style: "gnu" -*- */
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include <glib.h>
-#include <glib-object.h>
-#include <dbus/dbus.h>
-#include <dbus/dbus-glib.h>
-#include <dbus/dbus-glib-lowlevel.h>
-
-#include "dbus-gmain/tests/util.h"
-
-static gboolean
-make_recursive_stringify_call (int recursion_depth,
- DBusGProxy *proxy,
- GError **error)
-{
- gchar *out_str;
- gboolean ret;
- int i;
- GValue *val = g_new0 (GValue, 1);
-
- g_value_init (val, G_TYPE_STRING);
- g_value_set_string (val, "end of the line");
-
- for (i = 0; i < recursion_depth; i++)
- {
- GValue *tmp = g_new0 (GValue, 1);
-
- g_value_init (tmp, G_TYPE_VALUE);
- g_value_take_boxed (tmp, val);
- val = tmp;
- }
-
- ret = dbus_g_proxy_call (proxy, "Stringify", error,
- G_TYPE_VALUE, val,
- G_TYPE_INVALID,
- G_TYPE_STRING, &out_str,
- G_TYPE_INVALID);
-
- g_boxed_free (G_TYPE_VALUE, val);
-
- /* the out parameter is meaningless if it failed */
- if (ret)
- g_free (out_str);
-
- return ret;
-}
-
-int
-main (int argc, char **argv)
-{
- DBusGConnection *connection;
- GError *error = NULL;
- DBusGProxy *proxy;
- GMainLoop *loop;
-
- g_type_init ();
-
- g_log_set_always_fatal (G_LOG_LEVEL_WARNING | G_LOG_LEVEL_CRITICAL);
-
- loop = g_main_loop_new (NULL, FALSE);
-
- connection = dbus_g_bus_get_private (DBUS_BUS_SESSION, NULL, &error);
- if (connection == NULL)
- g_error ("Failed to open connection to bus: %s", error->message);
-
- proxy = dbus_g_proxy_new_for_name (connection,
- "org.freedesktop.DBus.GLib.TestService",
- "/org/freedesktop/DBus/GLib/Tests/MyTestObject",
- "org.freedesktop.DBus.GLib.Tests.MyObject");
-
- if (proxy == NULL)
- g_error ("Failed to create proxy for name owner: %s", error->message);
-
- /* Do an echo to be sure it started */
- if (!dbus_g_proxy_call (proxy, "DoNothing", &error,
- G_TYPE_INVALID,
- G_TYPE_INVALID))
- g_error ("Failed to complete DoNothing call: %s", error->message);
-
- /* Fewer than the current internal limit (16) */
- if (make_recursive_stringify_call (10, proxy, &error))
- g_error ("Unexpected success code from 10 recursive variant call: %s", error->message);
- if (error->code != DBUS_GERROR_REMOTE_EXCEPTION)
- g_error ("Error code was not remote exception: %s", error->message);
- g_printerr ("Got expected error %d: \"%s\" from recursive variant call\n", error->code, error->message);
- g_clear_error (&error);
- /* More than the current internal limit (16) */
- if (make_recursive_stringify_call (50, proxy, &error))
- g_error ("Unexpected success code from 50 recursive variant call: %s", error->message);
- if (error->code != DBUS_GERROR_REMOTE_EXCEPTION)
- g_error ("Error code was not remote exception: %s", error->message);
- g_printerr ("Got expected error %d: \"%s\" from recursive variant call\n", error->code, error->message);
- g_clear_error (&error);
-
- g_object_unref (G_OBJECT (proxy));
-
- test_run_until_disconnected (dbus_g_connection_get_connection (connection), NULL);
- dbus_g_connection_unref (connection);
-
- g_main_loop_unref (loop);
- dbus_shutdown ();
-
- return 0;
-}
diff --git a/test/data/nested-introspect.xml b/test/data/nested-introspect.xml
deleted file mode 100644
index 6a88b31..0000000
--- a/test/data/nested-introspect.xml
+++ /dev/null
@@ -1,10 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<!-- http://bugs.freedesktop.org/show_bug.cgi?id=19065 -->
-<node name="/">
- <node name="org">
- <interface name="org.dummy">
- <method name="mycall">
- </method>
- </interface>
- </node>
-</node>
diff --git a/test/data/valid-service-files/debug-echo.service.in b/test/data/valid-service-files/debug-echo.service.in
deleted file mode 100644
index 64603c0..0000000
--- a/test/data/valid-service-files/debug-echo.service.in
+++ /dev/null
@@ -1,3 +0,0 @@
-[D-BUS Service]
-Name=org.freedesktop.DBus.GLib.TestEchoService
-Exec=@abs_top_builddir@/test/test-service@EXEEXT@
diff --git a/test/data/valid-service-files/debug-glib.service.in b/test/data/valid-service-files/debug-glib.service.in
deleted file mode 100644
index 4b1ceeb..0000000
--- a/test/data/valid-service-files/debug-glib.service.in
+++ /dev/null
@@ -1,3 +0,0 @@
-[D-BUS Service]
-Name=org.freedesktop.DBus.GLib.TestService
-Exec=@abs_top_builddir@/test/core/test-service-glib@EXEEXT@
diff --git a/test/data/valid-service-files/interfaces-test.service.in b/test/data/valid-service-files/interfaces-test.service.in
deleted file mode 100644
index 77bd001..0000000
--- a/test/data/valid-service-files/interfaces-test.service.in
+++ /dev/null
@@ -1,3 +0,0 @@
-[D-BUS Service]
-Name=org.freedesktop.DBus.GLib.Test.Interfaces
-Exec=@abs_top_builddir@/test/interfaces/test-service@EXEEXT@
diff --git a/test/errors.c b/test/errors.c
deleted file mode 100644
index 95a47d9..0000000
--- a/test/errors.c
+++ /dev/null
@@ -1,78 +0,0 @@
-/* Regression test for dbus-glib GError mapping
- *
- * Copyright © 2004 Red Hat, Inc.
- * Copyright © 2011 Nokia Corporation
- *
- * Licensed under the Academic Free License version 2.1
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA
- */
-
-#include <config.h>
-
-#include <string.h>
-
-#include <glib.h>
-
-#include <dbus/dbus-glib.h>
-#include <dbus/dbus-glib-lowlevel.h>
-
-typedef struct {
- int dummy;
-} Fixture;
-
-static void
-setup (Fixture *f G_GNUC_UNUSED,
- gconstpointer context G_GNUC_UNUSED)
-{
-}
-
-static void
-test_errors (Fixture *f G_GNUC_UNUSED,
- gconstpointer context G_GNUC_UNUSED)
-{
- DBusError err;
- GError *gerror = NULL;
-
- dbus_error_init (&err);
- dbus_set_error_const (&err, DBUS_ERROR_NO_MEMORY, "Out of memory!");
-
- dbus_set_g_error (&gerror, &err);
- g_assert (gerror != NULL);
- g_assert_error (gerror, DBUS_GERROR, DBUS_GERROR_NO_MEMORY);
- g_assert_cmpstr (gerror->message, ==, "Out of memory!");
-
- dbus_error_init (&err);
- g_clear_error (&gerror);
-}
-
-static void
-teardown (Fixture *f G_GNUC_UNUSED,
- gconstpointer addr G_GNUC_UNUSED)
-{
-}
-
-int
-main (int argc,
- char **argv)
-{
- g_test_init (&argc, &argv, NULL);
- g_type_init ();
-
- g_test_add ("/errors", Fixture, NULL, setup, test_errors, teardown);
-
- return g_test_run ();
-}
diff --git a/test/interfaces/.gitignore b/test/interfaces/.gitignore
deleted file mode 100644
index 575991c..0000000
--- a/test/interfaces/.gitignore
+++ /dev/null
@@ -1,4 +0,0 @@
-*-dbus-glue.h
-test-server
-test-client
-*-dbus-binding.h
diff --git a/test/interfaces/Makefile.am b/test/interfaces/Makefile.am
deleted file mode 100644
index fa5ae33..0000000
--- a/test/interfaces/Makefile.am
+++ /dev/null
@@ -1,136 +0,0 @@
-AM_CPPFLAGS = \
- -I$(top_srcdir) \
- -I$(top_builddir) \
- -I$(top_builddir)/dbus \
- $(DBUS_CFLAGS) \
- $(DBUS_GLIB_CFLAGS) \
- -DDBUS_COMPILATION
-
-LDADD = $(DBUS_GLIB_LIBS) \
- $(top_builddir)/dbus/libdbus-glib-1.la \
- $(top_builddir)/dbus/libdbus-gtool.la \
- $(top_builddir)/dbus-gmain/tests/libtest.la \
- $(NULL)
-
-## note that TESTS has special meaning (stuff to use in make check)
-## so if adding tests not to be run in make check, don't add them to
-## TESTS
-if DBUS_BUILD_TESTS
-TESTS_ENVIRONMENT = \
- DBUS_TOP_BUILDDIR=@abs_top_builddir@ \
- DBUS_BINDING_TOOL=$(DBUS_BINDING_TOOL) \
- $(NULL)
-TESTS=run-test.sh
-else
-TESTS=
-endif
-
-VALGRIND_ENV = G_DEBUG=gc-friendly G_SLICE=always-malloc
-VALGRIND = valgrind
-VALGRIND_ARGS = \
- --gen-suppressions=all \
- --leak-check=full \
- --leak-resolution=high \
- --num-callers=20 \
- --suppressions=$(abs_top_srcdir)/tools/dbus-glib.supp \
- --suppressions=$(abs_top_srcdir)/tools/dbus-glib-tests.supp \
- --verbose \
- $(NULL)
-
-check-valgrind: all
- $(MAKE) check-TESTS \
- DEBUG="env $(VALGRIND_ENV) $(VALGRIND) $(VALGRIND_ARGS)"
-
-EXTRA_DIST = \
- invalid-annotated-node.xml \
- invalid-nested-annotation.xml \
- run-test.sh \
- test-goodbye.xml \
- test-hello.xml \
- test-song.xml \
- test-dup-prop-a.xml \
- test-dup-prop-b.xml \
- valid-annotations.xml \
- $(NULL)
-
-if DBUS_BUILD_TESTS
-
-## we use noinst_PROGRAMS not check_PROGRAMS for TESTS so that we
-## build even when not doing "make check"
-noinst_PROGRAMS = test-service test-client
-
-test_service_SOURCES = \
- test-interfaces.c \
- test-interfaces.h \
- test-dup-prop.c \
- test-dup-prop.h \
- test-objects.c \
- test-objects.h \
- test-server.c
-
-test_client_SOURCES = \
- test-client.c
-
-BUILT_SOURCES = \
- test-song-glue.h \
- test-hello-glue.h \
- test-goodbye-glue.h \
- test-dup-prop-a-glue.h \
- test-dup-prop-b-glue.h \
- test-song-bindings.h \
- test-hello-bindings.h \
- test-goodbye-bindings.h \
- test-dup-prop-a-bindings.h \
- test-dup-prop-a-bindings.h \
- test-dup-prop-b-bindings.h \
- test-dup-prop-b-bindings.h \
- valid-annotations-glue.h \
- valid-annotations-bindings.h \
- $(NULL)
-
-test-song-glue.h: test-song.xml $(top_builddir)/dbus/dbus-binding-tool$(EXEEXT)
- $(DBUS_BINDING_TOOL) --prefix=test_song --mode=glib-server --output=test-song-glue.h $(srcdir)/test-song.xml
-
-test-song-bindings.h: test-song.xml $(top_builddir)/dbus/dbus-binding-tool$(EXEEXT)
- $(DBUS_BINDING_TOOL) --prefix=test_song --mode=glib-client --output=test-song-bindings.h $(srcdir)/test-song.xml
-
-test-hello-glue.h: test-hello.xml $(top_builddir)/dbus/dbus-binding-tool$(EXEEXT)
- $(DBUS_BINDING_TOOL) --prefix=test_hello --mode=glib-server --output=test-hello-glue.h $(srcdir)/test-hello.xml
-
-test-hello-bindings.h: test-hello.xml $(top_builddir)/dbus/dbus-binding-tool$(EXEEXT)
- $(DBUS_BINDING_TOOL) --prefix=test_hello --mode=glib-client --output=test-hello-bindings.h $(srcdir)/test-hello.xml
-
-test-goodbye-glue.h: test-goodbye.xml $(top_builddir)/dbus/dbus-binding-tool$(EXEEXT)
- $(DBUS_BINDING_TOOL) --prefix=test_goodbye --mode=glib-server --output=test-goodbye-glue.h $(srcdir)/test-goodbye.xml
-
-test-goodbye-bindings.h: test-goodbye.xml $(top_builddir)/dbus/dbus-binding-tool$(EXEEXT)
- $(DBUS_BINDING_TOOL) --prefix=test_goodbye --mode=glib-client --output=test-goodbye-bindings.h $(srcdir)/test-goodbye.xml
-
-test-dup-prop-a-glue.h: test-dup-prop-a.xml $(top_builddir)/dbus/dbus-binding-tool$(EXEEXT)
- $(DBUS_BINDING_TOOL) --prefix=test_dup_prop_a --mode=glib-server --output=test-dup-prop-a-glue.h $(srcdir)/test-dup-prop-a.xml
-
-test-dup-prop-a-bindings.h: test-dup-prop-a.xml $(top_builddir)/dbus/dbus-binding-tool$(EXEEXT)
- $(DBUS_BINDING_TOOL) --prefix=test_dup_prop_a --mode=glib-client --output=test-dup-prop-a-bindings.h $(srcdir)/test-dup-prop-a.xml
-
-test-dup-prop-b-glue.h: test-dup-prop-b.xml $(top_builddir)/dbus/dbus-binding-tool$(EXEEXT)
- $(DBUS_BINDING_TOOL) --prefix=test_dup_prop_b --mode=glib-server --output=test-dup-prop-b-glue.h $(srcdir)/test-dup-prop-b.xml
-
-test-dup-prop-b-bindings.h: test-dup-prop-b.xml $(top_builddir)/dbus/dbus-binding-tool$(EXEEXT)
- $(DBUS_BINDING_TOOL) --prefix=test_dup_prop_b --mode=glib-client --output=test-dup-prop-b-bindings.h $(srcdir)/test-dup-prop-b.xml
-
-valid-annotations-glue.h: valid-annotations.xml $(top_builddir)/dbus/dbus-binding-tool$(EXEEXT)
- $(DBUS_BINDING_TOOL) --prefix=test_annotated --mode=glib-server --output=$@ $<
-
-valid-annotations-bindings.h: valid-annotations.xml $(top_builddir)/dbus/dbus-binding-tool$(EXEEXT)
- $(DBUS_BINDING_TOOL) --prefix=test_annotated --mode=glib-client --output=$@ $<
-
-CLEANFILES = \
- $(BUILT_SOURCES) \
- run-with-tmp-session-bus.conf
-
-else
-### not building tests
-
-
-endif
-
diff --git a/test/interfaces/invalid-annotated-node.xml b/test/interfaces/invalid-annotated-node.xml
deleted file mode 100644
index 4759b1f..0000000
--- a/test/interfaces/invalid-annotated-node.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-<?xml version="1.0"?><!-- ex:set et ts=2: -->
-<node name="/org/freedesktop/DBus/GLib/Test/Interfaces">
- <annotation name="com.example.Invalid" value="not allowed here!"/>
-
- <interface name="org.freedesktop.DBus.GLib.Test.Interfaces.Annotated">
- <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="test_annotated"/>
- </interface>
-</node>
diff --git a/test/interfaces/invalid-nested-annotation.xml b/test/interfaces/invalid-nested-annotation.xml
deleted file mode 100644
index 8d98836..0000000
--- a/test/interfaces/invalid-nested-annotation.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-<?xml version="1.0"?><!-- ex:set et ts=2: -->
-<node name="/org/freedesktop/DBus/GLib/Test/Interfaces">
- <interface name="org.freedesktop.DBus.GLib.Test.Interfaces.Annotated">
- <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="test_annotated">
- <annotation name="com.example.Invalid" value="can't nest annotations"/>
- </annotation>
- </interface>
-</node>
diff --git a/test/interfaces/run-test.sh b/test/interfaces/run-test.sh
deleted file mode 100755
index 62d2fde..0000000
--- a/test/interfaces/run-test.sh
+++ /dev/null
@@ -1,39 +0,0 @@
-#! /bin/sh
-
-SCRIPTNAME=$0
-MODE=$1
-
-## so the tests can complain if you fail to use the script to launch them
-DBUS_TEST_GLIB_RUN_TEST_SCRIPT=1
-export DBUS_TEST_GLIB_RUN_TEST_SCRIPT
-srcdir=`dirname "$0"`
-DBUS_TOP_SRCDIR="$srcdir/../.."
-export DBUS_TOP_SRCDIR
-# Rerun ourselves with tmp session bus if we're not already
-if test -z "$DBUS_TEST_GLIB_IN_RUN_TEST"; then
- DBUS_TEST_GLIB_IN_RUN_TEST=1
- export DBUS_TEST_GLIB_IN_RUN_TEST
- exec $DBUS_TOP_SRCDIR/tools/run-with-tmp-session-bus.sh $SCRIPTNAME $MODE
-fi
-
-set -e
-
-for x in annotated-node nested-annotation; do
- if ! test -f $srcdir/invalid-$x.xml; then
- echo "invalid-$x.xml missing">&2
- exit 1
- fi
-
- if $DBUS_BINDING_TOOL --prefix=test_invalid --mode=glib-server \
- --output=invalid-glue.h $srcdir/invalid-$x.xml ||
- $DBUS_BINDING_TOOL --prefix=test_invalid --mode=glib-client \
- --output=invalid-bindings.h $srcdir/invalid-$x.xml; then
- echo "invalid-$x.xml should not have been processed successfully!">&2
- exit 1
- else
- echo "invalid-$x.xml failed, as expected">&2
- fi
-done
-
-echo "running test-client"
-${DBUS_TOP_BUILDDIR}/libtool --mode=execute $DEBUG $DBUS_TOP_BUILDDIR/test/interfaces/test-client
diff --git a/test/interfaces/test-client.c b/test/interfaces/test-client.c
deleted file mode 100644
index c3348e4..0000000
--- a/test/interfaces/test-client.c
+++ /dev/null
@@ -1,290 +0,0 @@
-#include <config.h>
-
-#include <stdlib.h>
-#include <string.h>
-
-#include <dbus/dbus-glib.h>
-#include <dbus/dbus-glib-lowlevel.h>
-
-#include "dbus/dbus-gparser.h"
-#include "test-song-bindings.h"
-#include "test-hello-bindings.h"
-#include "test-goodbye-bindings.h"
-#include "test-dup-prop-a-bindings.h"
-#include "test-dup-prop-b-bindings.h"
-
-#include "dbus-gmain/tests/util.h"
-
-#define TEST_NAMESPACE "org.freedesktop.DBus.GLib.Test.Interfaces"
-#define TEST_OBJECT_PATH "/org/freedesktop/DBus/GLib/Test/Interfaces"
-#define TEST_DP_OBJECT_PATH "/org/freedesktop/DBus/GLib/Test/DupPropInterfaces"
-
-#define TEST_DP_IFACE_A "org.freedesktop.DBus.GLib.Test.Interfaces.A"
-#define TEST_DP_IFACE_B "org.freedesktop.DBus.GLib.Test.Interfaces.B"
-
-static void
-test_dp_property (DBusGProxy *proxy,
- const char *detail,
- const char *iface,
- guint expected,
- gboolean get_only)
-{
- GError *error = NULL;
- gboolean success;
- GValue get_value = {0,};
-
- if (!get_only)
- {
- GValue set_value = {0,};
-
- g_value_init (&set_value, G_TYPE_UINT);
- g_value_set_uint (&set_value, expected);
- success = dbus_g_proxy_call (proxy, "Set", &error,
- G_TYPE_STRING, iface,
- G_TYPE_STRING, "Foobar",
- G_TYPE_VALUE, &set_value,
- G_TYPE_INVALID,
- G_TYPE_INVALID);
- g_value_unset (&set_value);
- if (!success)
- {
- g_print ("Error while setting DupProp Interface %s property: %s\n", detail, error->message);
- g_error_free (error);
- exit(1);
- }
- else
- g_print ("Set DupProp Interface %s property with success\n", detail);
- }
-
- success = dbus_g_proxy_call (proxy, "Get", &error,
- G_TYPE_STRING, iface,
- G_TYPE_STRING, "Foobar",
- G_TYPE_INVALID,
- G_TYPE_VALUE, &get_value,
- G_TYPE_INVALID);
- if (!success)
- {
- g_print ("Error while getting DupProp Interface %s property: %s\n", detail, error->message);
- g_error_free (error);
- exit(1);
- }
- else
- g_print ("Got DupProp Interface %s property with success\n", detail);
-
- if (!G_VALUE_HOLDS_UINT (&get_value))
- {
- g_print ("Error comparing DupProp %s Interface property: unexpected type %s\n",
- detail, G_VALUE_TYPE_NAME (&get_value));
- g_error_free (error);
- exit(1);
- }
- else if (g_value_get_uint (&get_value) != expected)
- {
- g_print ("Error comparing DupProp %s Interface property: expected %d, got %d\n",
- detail, expected, g_value_get_uint (&get_value));
- g_error_free (error);
- exit(1);
- }
- else
- g_print ("Got DupProp Interface %s property value matched expected\n", detail);
-}
-
-int
-main (int argc,
- char **argv)
-{
- DBusGConnection *connection;
- DBusGProxy *proxy;
- GError *error = NULL;
- gchar *str;
- gboolean success;
- DBusGProxy *dp_proxy;
-
- g_type_init ();
-
- connection = dbus_g_bus_get_private (DBUS_BUS_SESSION, NULL, &error);
- if (connection == NULL)
- {
- g_error ("Failed to make connection to session bus: %s", error->message);
- g_error_free (error);
- exit(1);
- }
-
- dbus_connection_set_exit_on_disconnect (dbus_g_connection_get_connection (connection),
- FALSE);
-
- proxy = dbus_g_proxy_new_for_name (connection, TEST_NAMESPACE, TEST_OBJECT_PATH,
- "org.freedesktop.DBus.GLib.Test.Interfaces.Song");
- success = org_freedesktop_DBus_GLib_Test_Interfaces_Song_get_title (proxy, &str, &error);
- g_object_unref (proxy);
-
- if (!success)
- {
- g_print ("Error while calling Parent object method: %s\n", error->message);
- g_error_free (error);
- exit(1);
- }
- else
- {
- g_free (str);
- g_print ("Called Parent object method with success\n");
- }
-
- proxy = dbus_g_proxy_new_for_name (connection, TEST_NAMESPACE, TEST_OBJECT_PATH,
- "org.freedesktop.DBus.GLib.Test.Interfaces.Hello");
- g_assert (proxy != NULL);
- success = org_freedesktop_DBus_GLib_Test_Interfaces_Hello_say_hello (proxy, &str, &error);
- g_object_unref (proxy);
-
- if (!success)
- {
- g_print ("Error while calling Parent Interface object method: %s\n", error->message);
- g_error_free (error);
- exit(1);
- }
- else
- {
- g_free (str);
- g_print ("Called Parent Interface object method with success\n");
- }
-
- proxy = dbus_g_proxy_new_for_name (connection, TEST_NAMESPACE, TEST_OBJECT_PATH,
- "org.freedesktop.DBus.GLib.Test.Interfaces.Goodbye");
- success = org_freedesktop_DBus_GLib_Test_Interfaces_Goodbye_say_goodbye (proxy, &str, &error);
- g_object_unref (proxy);
-
- if (!success)
- {
- g_print ("Error while calling Object Interface object method: %s\n", error->message);
- g_error_free (error);
- exit(1);
- }
- else
- {
- g_free (str);
- g_print ("Called Object Interface object method with success\n");
- }
-
- /* Test interfaces with conflicting property names on the same GObject */
- dp_proxy = dbus_g_proxy_new_for_name (connection, TEST_NAMESPACE, TEST_DP_OBJECT_PATH,
- "org.freedesktop.DBus.Properties");
-
- /* test that setting the property and reading it back works */
- test_dp_property (dp_proxy, "A", TEST_DP_IFACE_A, 235235, FALSE);
- test_dp_property (dp_proxy, "B", TEST_DP_IFACE_B, 11981241, FALSE);
-
- /* Test that setting A does not change B */
- test_dp_property (dp_proxy, "B", TEST_DP_IFACE_B, 11981241, FALSE);
- test_dp_property (dp_proxy, "A", TEST_DP_IFACE_A, 235235, FALSE);
- test_dp_property (dp_proxy, "B", TEST_DP_IFACE_B, 11981241, TRUE);
-
- /* And test that setting B does not change A */
- test_dp_property (dp_proxy, "A", TEST_DP_IFACE_A, 235235, FALSE);
- test_dp_property (dp_proxy, "B", TEST_DP_IFACE_B, 11981241, FALSE);
- test_dp_property (dp_proxy, "A", TEST_DP_IFACE_A, 235235, TRUE);
-
- g_object_unref (dp_proxy);
-
- /* Ensure the properties are introspectable */
- dp_proxy = dbus_g_proxy_new_for_name (connection, TEST_NAMESPACE, TEST_DP_OBJECT_PATH,
- "org.freedesktop.DBus.Introspectable");
-
- g_print ("Testing duplicate property name introspection\n");
- if (!dbus_g_proxy_call (dp_proxy, "Introspect", &error,
- G_TYPE_INVALID,
- G_TYPE_STRING, &str,
- G_TYPE_INVALID))
- {
- g_print ("Error while introspecting duplicate properties: %s\n", error->message);
- g_error_free (error);
- exit(1);
- }
- else
- g_print ("Introspected duplicate properties with success\n");
-
- {
- NodeInfo *node;
- GSList *elt;
- gboolean found_introspectable = FALSE;
- gboolean found_properties = FALSE;
- gboolean found_iface_a = FALSE;
- gboolean found_iface_a_prop = FALSE;
- gboolean found_iface_b = FALSE;
- gboolean found_iface_b_prop = FALSE;
-
- node = description_load_from_string (str, strlen (str), &error);
- if (!node)
- {
- g_print ("Failed to parse introspection data: %s\n", error->message);
- g_error_free (error);
- exit(1);
- }
-
- for (elt = node_info_get_interfaces (node); elt ; elt = elt->next)
- {
- InterfaceInfo *iface = elt->data;
-
- if (!found_introspectable && strcmp (interface_info_get_name (iface), "org.freedesktop.DBus.Introspectable") == 0)
- found_introspectable = TRUE;
- else if (!found_properties && strcmp (interface_info_get_name (iface), "org.freedesktop.DBus.Properties") == 0)
- found_properties = TRUE;
- else if (!found_iface_a && strcmp (interface_info_get_name (iface), "org.freedesktop.DBus.GLib.Test.Interfaces.A") == 0)
- {
- GSList *elt;
-
- found_iface_a = TRUE;
-
- for (elt = interface_info_get_properties (iface); elt; elt = elt->next)
- {
- PropertyInfo *prop;
-
- prop = elt->data;
- if (strcmp (property_info_get_name (prop), "Foobar") == 0)
- {
- found_iface_a_prop = TRUE;
- break;
- }
- }
- }
- else if (!found_iface_b && strcmp (interface_info_get_name (iface), "org.freedesktop.DBus.GLib.Test.Interfaces.B") == 0)
- {
- GSList *elt;
-
- found_iface_b = TRUE;
-
- for (elt = interface_info_get_properties (iface); elt; elt = elt->next)
- {
- PropertyInfo *prop;
-
- prop = elt->data;
- if (strcmp (property_info_get_name (prop), "Foobar") == 0)
- {
- found_iface_b_prop = TRUE;
- break;
- }
- }
- }
- }
-
- g_free (str);
- node_info_unref (node);
-
- if (!found_iface_a_prop || !found_iface_b_prop)
- {
- g_print ("Failed to find Foobar properties in introspection data\n");
- g_error_free (error);
- exit(1);
- }
- }
-
- g_object_unref (dp_proxy);
-
- test_run_until_disconnected (dbus_g_connection_get_connection (connection), NULL);
- dbus_g_connection_unref (connection);
-
- dbus_shutdown ();
- exit(0);
-}
-
-/* ex:ts=2:et: */
-
diff --git a/test/interfaces/test-dup-prop-a.xml b/test/interfaces/test-dup-prop-a.xml
deleted file mode 100644
index f3ebf33..0000000
--- a/test/interfaces/test-dup-prop-a.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-<?xml version="1.0"?><!-- ex:set et ts=2: -->
-<node name="/org/freedesktop/DBus/GLib/Test/Interfaces">
- <interface name="org.freedesktop.DBus.GLib.Test.Interfaces.A">
- <property name="Foobar" type="u" access="readwrite"/>
- </interface>
-</node>
diff --git a/test/interfaces/test-dup-prop-b.xml b/test/interfaces/test-dup-prop-b.xml
deleted file mode 100644
index 596cb54..0000000
--- a/test/interfaces/test-dup-prop-b.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-<?xml version="1.0"?><!-- ex:set et ts=2: -->
-<node name="/org/freedesktop/DBus/GLib/Test/Interfaces">
- <interface name="org.freedesktop.DBus.GLib.Test.Interfaces.B">
- <property name="Foobar" type="u" access="readwrite"/>
- </interface>
-</node>
diff --git a/test/interfaces/test-dup-prop.c b/test/interfaces/test-dup-prop.c
deleted file mode 100644
index 467ac4b..0000000
--- a/test/interfaces/test-dup-prop.c
+++ /dev/null
@@ -1,192 +0,0 @@
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-#include "test-dup-prop.h"
-
-#include "test-dup-prop-a-glue.h"
-#include "test-dup-prop-b-glue.h"
-
-#define TEST_A_FOOBAR "a-foobar"
-#define TEST_B_FOOBAR "b-foobar"
-
-static void
-test_a_class_init (gpointer g_iface)
-{
- GType iface_type = G_TYPE_FROM_INTERFACE (g_iface);
-
- g_object_interface_install_property (g_iface,
- g_param_spec_uint (TEST_A_FOOBAR,
- "A Foobar",
- "A description of something",
- 0, G_MAXUINT, 0,
- G_PARAM_READWRITE));
-
- dbus_g_object_type_install_info (iface_type,
- &dbus_glib_test_dup_prop_a_object_info);
- dbus_g_object_type_register_shadow_property (iface_type,
- "Foobar",
- TEST_A_FOOBAR);
-}
-
-GType
-test_a_get_type (void)
-{
- static GType the_type = 0;
-
- if (G_UNLIKELY (the_type == 0)) {
- static const GTypeInfo info = {
- sizeof (TestAIface),
- NULL, NULL,
- (GClassInitFunc) test_a_class_init,
- NULL, NULL, 0, 0, NULL
- };
-
- the_type = g_type_register_static (G_TYPE_INTERFACE,
- "TestA",
- &info, 0);
- g_type_interface_add_prerequisite (the_type, G_TYPE_OBJECT);
- }
- return the_type;
-}
-
-
-static void
-test_b_class_init (gpointer g_iface)
-{
- GType iface_type = G_TYPE_FROM_INTERFACE (g_iface);
-
- g_object_interface_install_property (g_iface,
- g_param_spec_uint (TEST_B_FOOBAR,
- "B Foobar",
- "A description of something",
- 0, G_MAXUINT, 0,
- G_PARAM_READWRITE));
-
- dbus_g_object_type_install_info (iface_type,
- &dbus_glib_test_dup_prop_b_object_info);
- dbus_g_object_type_register_shadow_property (iface_type,
- "Foobar",
- TEST_B_FOOBAR);
-}
-
-GType
-test_b_get_type (void)
-{
- static GType the_type = 0;
-
- if (G_UNLIKELY (the_type == 0)) {
- static const GTypeInfo info = {
- sizeof (TestBIface),
- NULL, NULL,
- (GClassInitFunc) test_b_class_init,
- NULL, NULL, 0, 0, NULL
- };
-
- the_type = g_type_register_static (G_TYPE_INTERFACE,
- "TestB",
- &info, 0);
- g_type_interface_add_prerequisite (the_type, G_TYPE_OBJECT);
- }
- return the_type;
-}
-
-
-
-static void test_a_init (TestAIface *a_class);
-static void test_b_init (TestBIface *b_class);
-
-G_DEFINE_TYPE_EXTENDED (TestDpObj, test_dp_obj, G_TYPE_OBJECT, 0,
- G_IMPLEMENT_INTERFACE (TEST_TYPE_A, test_a_init)
- G_IMPLEMENT_INTERFACE (TEST_TYPE_B, test_b_init))
-
-#define TEST_DP_OBJ_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TEST_TYPE_DP_OBJ, TestDpObjPrivate))
-
-enum {
- PROP_0,
- PROP_A_FOOBAR,
- PROP_B_FOOBAR
-};
-
-typedef struct {
- guint32 a_foobar;
- guint32 b_foobar;
-} TestDpObjPrivate;
-
-TestDpObj *
-test_dp_obj_new (void)
-{
- return TEST_DP_OBJ (g_object_new (TEST_TYPE_DP_OBJ, NULL));
-}
-
-static void
-test_a_init (TestAIface *a_class)
-{
-}
-
-static void
-test_b_init (TestBIface *b_class)
-{
-}
-
-static void
-test_dp_obj_init (TestDpObj *self)
-{
-}
-
-static void
-set_property (GObject *object, guint prop_id,
- const GValue *value, GParamSpec *pspec)
-{
- TestDpObjPrivate *priv = TEST_DP_OBJ_GET_PRIVATE (object);
-
- switch (prop_id) {
- case PROP_A_FOOBAR:
- priv->a_foobar = g_value_get_uint (value);
- break;
- case PROP_B_FOOBAR:
- priv->b_foobar = g_value_get_uint (value);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec)
-{
- TestDpObjPrivate *priv = TEST_DP_OBJ_GET_PRIVATE (object);
-
- switch (prop_id) {
- case PROP_A_FOOBAR:
- g_value_set_uint (value, priv->a_foobar);
- break;
- case PROP_B_FOOBAR:
- g_value_set_uint (value, priv->b_foobar);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-test_dp_obj_class_init (TestDpObjClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
- g_type_class_add_private (object_class, sizeof (TestDpObjPrivate));
-
- object_class->get_property = get_property;
- object_class->set_property = set_property;
-
- /* Properties */
- g_object_class_override_property (object_class,
- PROP_A_FOOBAR,
- TEST_A_FOOBAR);
-
- g_object_class_override_property (object_class,
- PROP_B_FOOBAR,
- TEST_B_FOOBAR);
-}
diff --git a/test/interfaces/test-dup-prop.h b/test/interfaces/test-dup-prop.h
deleted file mode 100644
index cc20ea7..0000000
--- a/test/interfaces/test-dup-prop.h
+++ /dev/null
@@ -1,60 +0,0 @@
-#ifndef __TEST_DUP_PROP_H__
-#define __TEST_DUP_PROP_H__
-
-#include <glib-object.h>
-
-#define TEST_TYPE_A (test_a_get_type ())
-#define TEST_A(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TEST_TYPE_A, TestA))
-#define TEST_A_IFACE(obj) (G_TYPE_CHECK_CLASS_CAST ((obj), TEST_TYPE_A, TestAIface))
-#define TEST_IS_IFACE_A(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TEST_TYPE_A))
-#define TEST_A_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), TEST_TYPE_A, TestAIface))
-
-#define TEST_TYPE_B (test_b_get_type ())
-#define TEST_B(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TEST_TYPE_B, TestB))
-#define TEST_B_IFACE(obj) (G_TYPE_CHECK_CLASS_CAST ((obj), TEST_TYPE_B, TestBIface))
-#define TEST_IS_B(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TEST_TYPE_B))
-#define TEST_B_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), TEST_TYPE_B, TestBIface))
-
-#define TEST_TYPE_DP_OBJ (test_dp_obj_get_type ())
-#define TEST_DP_OBJ(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TEST_TYPE_DP_OBJ, TestDpObj))
-#define TEST_DP_OBJ_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TEST_TYPE_DP_OBJ, TestDpObjClass))
-#define TEST_IS_DP_OBJ(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TEST_TYPE_DP_OBJ))
-#define TEST_IS_DP_OBJ_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TEST_TYPE_DP_OBJ))
-#define TEST_DP_OBJ_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TEST_TYPE_DP_OBJ, TestDpObjClass))
-
-
-typedef struct _TestA TestA; /* dummy */
-typedef struct _TestAIface TestAIface;
-
-typedef struct _TestB TestB; /* dummy */
-typedef struct _TestBIface TestBIface;
-
-typedef struct _TestDpObj TestDpObj;
-typedef struct _TestDpObjClass TestDpObjClass;
-
-struct _TestAIface {
- GTypeInterface interface;
-};
-
-struct _TestBIface {
- GTypeInterface interface;
-};
-
-struct _TestDpObj {
- GObject parent;
-};
-
-struct _TestDpObjClass {
- GObjectClass parent;
-};
-
-
-GType test_a_get_type (void) G_GNUC_CONST;
-
-GType test_b_get_type (void) G_GNUC_CONST;
-
-GType test_dp_obj_get_type (void) G_GNUC_CONST;
-
-TestDpObj *test_dp_obj_new (void);
-
-#endif
diff --git a/test/interfaces/test-goodbye.xml b/test/interfaces/test-goodbye.xml
deleted file mode 100644
index c4590ed..0000000
--- a/test/interfaces/test-goodbye.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-<?xml version="1.0"?><!-- ex:set et ts=2: -->
-<node name="/org/freedesktop/DBus/GLib/Test/Interfaces">
- <interface name="org.freedesktop.DBus.GLib.Test.Interfaces.Goodbye">
- <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="test_goodbye_dbus"/>
- <method name="SayGoodbye">
- <arg name="message" type="s" direction="out" />
- </method>
- </interface>
-</node>
diff --git a/test/interfaces/test-hello.xml b/test/interfaces/test-hello.xml
deleted file mode 100644
index 28f82bd..0000000
--- a/test/interfaces/test-hello.xml
+++ /dev/null
@@ -1,10 +0,0 @@
-<?xml version="1.0"?><!-- ex:set et ts=2: -->
-<node name="/org/freedesktop/DBus/GLib/Test/Interfaces">
- <interface name="org.freedesktop.DBus.GLib.Test.Interfaces.Hello">
- <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="test_hello_dbus"/>
- <method name="SayHello">
- <arg name="message" type="s" direction="out" />
- </method>
- <signal name="Greetings" />
- </interface>
-</node>
diff --git a/test/interfaces/test-interfaces.c b/test/interfaces/test-interfaces.c
deleted file mode 100644
index 2cb4f91..0000000
--- a/test/interfaces/test-interfaces.c
+++ /dev/null
@@ -1,126 +0,0 @@
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-#include "test-interfaces.h"
-
-static gboolean
-test_hello_dbus_say_hello (TestHello *hello,
- gchar **message,
- GError **error)
-{
- *message = test_hello_say_hello (hello);
- return TRUE;
-}
-
-static gboolean
-test_goodbye_dbus_say_goodbye (TestGoodbye *goodbye,
- gchar **message,
- GError **error)
-{
- *message = test_goodbye_say_goodbye (goodbye);
- return TRUE;
-}
-
-#include "test-hello-glue.h"
-#include "test-goodbye-glue.h"
-
-enum {
- GREETINGS,
- LAST_SIGNAL
-};
-
-static guint signals[LAST_SIGNAL];
-
-static void
-test_hello_class_init (gpointer g_iface)
-{
- GType iface_type = G_TYPE_FROM_INTERFACE (g_iface);
-
- signals[GREETINGS] =
- g_signal_new ("greetings",
- iface_type,
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (TestHelloIface, greetings),
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE,
- 0);
-
- dbus_g_object_type_install_info (iface_type,
- &dbus_glib_test_hello_object_info);
-}
-
-GType
-test_hello_get_type (void)
-{
- static GType the_type = 0;
-
- if (G_UNLIKELY (the_type == 0)) {
- static const GTypeInfo info = {
- sizeof (TestHelloIface),
- NULL, NULL,
- (GClassInitFunc) test_hello_class_init,
- NULL, NULL, 0, 0, NULL
- };
-
- the_type = g_type_register_static (G_TYPE_INTERFACE,
- "TestHello",
- &info, 0);
- g_type_interface_add_prerequisite (the_type, G_TYPE_OBJECT);
- }
- return the_type;
-}
-
-gchar *
-test_hello_say_hello (TestHello *hello)
-{
- g_return_val_if_fail (TEST_IS_HELLO (hello), NULL);
-
- return (* TEST_HELLO_GET_IFACE (hello)->say_hello) (hello);
-}
-
-void
-test_hello_greetings (TestHello *hello)
-{
- g_return_if_fail (TEST_IS_HELLO (hello));
-
- g_signal_emit (hello, signals[GREETINGS], 0);
-}
-
-static void
-test_goodbye_class_init (gpointer g_iface)
-{
- GType iface_type = G_TYPE_FROM_INTERFACE (g_iface);
-
- dbus_g_object_type_install_info (iface_type,
- &dbus_glib_test_goodbye_object_info);
-}
-
-GType
-test_goodbye_get_type (void)
-{
- static GType the_type = 0;
-
- if (G_UNLIKELY (the_type == 0)) {
- static const GTypeInfo info = {
- sizeof (TestGoodbyeIface),
- NULL, NULL,
- (GClassInitFunc) test_goodbye_class_init,
- NULL, NULL, 0, 0, NULL
- };
-
- the_type = g_type_register_static (G_TYPE_INTERFACE,
- "TestGoodbye",
- &info, 0);
- g_type_interface_add_prerequisite (the_type, G_TYPE_OBJECT);
- }
- return the_type;
-}
-
-gchar *
-test_goodbye_say_goodbye (TestGoodbye *goodbye)
-{
- g_return_val_if_fail (TEST_IS_GOODBYE (goodbye), NULL);
-
- return (* TEST_GOODBYE_GET_IFACE (goodbye)->say_goodbye) (goodbye);
-}
diff --git a/test/interfaces/test-interfaces.h b/test/interfaces/test-interfaces.h
deleted file mode 100644
index 7a2b81d..0000000
--- a/test/interfaces/test-interfaces.h
+++ /dev/null
@@ -1,48 +0,0 @@
-#ifndef __TEST_INTERFACES_H__
-#define __TEST_INTERFACES_H__
-
-#include <glib-object.h>
-
-#define TEST_TYPE_HELLO (test_hello_get_type ())
-#define TEST_HELLO(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TEST_TYPE_HELLO, TestHello))
-#define TEST_HELLO_IFACE(obj) (G_TYPE_CHECK_CLASS_CAST ((obj), TEST_TYPE_HELLO, TestHelloIface))
-#define TEST_IS_HELLO(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TEST_TYPE_HELLO))
-#define TEST_HELLO_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), TEST_TYPE_HELLO, TestHelloIface))
-
-#define TEST_TYPE_GOODBYE (test_goodbye_get_type ())
-#define TEST_GOODBYE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TEST_TYPE_GOODBYE, TestGoodbye))
-#define TEST_GOODBYE_IFACE(obj) (G_TYPE_CHECK_CLASS_CAST ((obj), TEST_TYPE_GOODBYE, TestGoodbyeIface))
-#define TEST_IS_GOODBYE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TEST_TYPE_GOODBYE))
-#define TEST_GOODBYE_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), TEST_TYPE_GOODBYE, TestGoodbyeIface))
-
-typedef struct _TestHello TestHello; /* dummy */
-typedef struct _TestHelloIface TestHelloIface;
-
-typedef struct _TestGoodbye TestGoodbye; /* dummy */
-typedef struct _TestGoodbyeIface TestGoodbyeIface;
-
-struct _TestHelloIface {
- GTypeInterface interface;
-
- /* VTable */
- gchar *(* say_hello) (TestHello *hello);
-
- /* Signals */
- void (* greetings) (TestHello *hello);
-};
-
-struct _TestGoodbyeIface {
- GTypeInterface interface;
-
- /* VTable */
- gchar *(* say_goodbye) (TestGoodbye *goodbye);
-};
-
-GType test_hello_get_type (void) G_GNUC_CONST;
-gchar *test_hello_say_hello (TestHello *hello);
-void test_hello_greetings (TestHello *hello);
-
-GType test_goodbye_get_type (void) G_GNUC_CONST;
-gchar *test_goodbye_say_goodbye (TestGoodbye *goodbye);
-
-#endif
diff --git a/test/interfaces/test-objects.c b/test/interfaces/test-objects.c
deleted file mode 100644
index e82fa08..0000000
--- a/test/interfaces/test-objects.c
+++ /dev/null
@@ -1,75 +0,0 @@
-#include <config.h>
-
-#include "test-objects.h"
-#include "test-interfaces.h"
-
-static gboolean
-test_song_dbus_get_title (TestSong *song,
- gchar **title,
- GError **error)
-{
- *title = g_strdup ("Hello, Goodbye");
- return TRUE;
-}
-
-#include "test-song-glue.h"
-
-static gchar *
-test_song_say_hello (TestHello *hello)
-{
- return g_strdup ("Hello, hello...");
-}
-
-static void
-test_song_init (TestSong *song)
-{
-}
-
-static void
-test_song_hello_init (TestHelloIface *iface)
-{
- iface->say_hello = test_song_say_hello;
-}
-
-
-static void
-test_song_class_init (TestSongClass *klass)
-{
- dbus_g_object_type_install_info (G_TYPE_FROM_CLASS (klass),
- &dbus_glib_test_song_object_info);
-}
-
-G_DEFINE_TYPE_WITH_CODE (TestSong, test_song, G_TYPE_OBJECT,
- G_IMPLEMENT_INTERFACE (TEST_TYPE_HELLO, test_song_hello_init))
-
-static gchar *
-test_beatles_song_say_goodbye (TestGoodbye *goodbye)
-{
- return g_strdup ("I don't know why you say goodbye, I say hello.");
-}
-
-static void
-test_beatles_song_init (TestBeatlesSong *song)
-{
-}
-
-static void
-test_beatles_song_goodbye_init (TestGoodbyeIface *iface)
-{
- iface->say_goodbye = test_beatles_song_say_goodbye;
-}
-
-static void
-test_beatles_song_class_init (TestBeatlesSongClass *klass)
-{
-}
-
-G_DEFINE_TYPE_WITH_CODE (TestBeatlesSong, test_beatles_song, TEST_TYPE_SONG,
- G_IMPLEMENT_INTERFACE (TEST_TYPE_GOODBYE, test_beatles_song_goodbye_init))
-
-
-TestBeatlesSong *
-test_beatles_song_new (void)
-{
- return TEST_BEATLES_SONG (g_object_new (TEST_TYPE_BEATLES_SONG, NULL));
-}
diff --git a/test/interfaces/test-objects.h b/test/interfaces/test-objects.h
deleted file mode 100644
index b7bf438..0000000
--- a/test/interfaces/test-objects.h
+++ /dev/null
@@ -1,31 +0,0 @@
-#ifndef __TEST_OBJECTS_H__
-#define __TEST_OBJECTS_H__
-
-#include <glib-object.h>
-
-#define TEST_TYPE_SONG (test_song_get_type ())
-#define TEST_SONG(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), TEST_TYPE_SONG, TestSong))
-#define TEST_SONG_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), TEST_TYPE_SONG, TestSongClass))
-#define TEST_IS_SONG(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), TEST_TYPE_SONG))
-#define TEST_IS_SONG_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), TEST_TYPE_SONG))
-#define TEST_SONG_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), TEST_TYPE_SONG, TestSongClass))
-
-#define TEST_TYPE_BEATLES_SONG (test_beatles_song_get_type ())
-#define TEST_BEATLES_SONG(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), TEST_TYPE_BEATLES_SONG, TestBeatlesSong))
-#define TEST_BEATLES_SONG_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), TEST_TYPE_BEATLES_SONG, TestBeatlesSongClass))
-#define TEST_IS_BEATLES_SONG(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), TEST_TYPE_BEATLES_SONG))
-#define TEST_IS_BEATLES_SONG_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), TEST_TYPE_BEATLES_SONG))
-#define TEST_BEATLES_SONG_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), TEST_TYPE_BEATLES_SONG, TestBeatlesSongClass))
-
-typedef GObject TestSong;
-typedef GObjectClass TestSongClass;
-
-typedef TestSong TestBeatlesSong;
-typedef TestSongClass TestBeatlesSongClass;
-
-GType test_song_get_type (void);
-
-GType test_beatles_song_get_type (void);
-TestSong *test_beatles_song_new (void);
-
-#endif
diff --git a/test/interfaces/test-server.c b/test/interfaces/test-server.c
deleted file mode 100644
index d9c1d91..0000000
--- a/test/interfaces/test-server.c
+++ /dev/null
@@ -1,68 +0,0 @@
-#include <config.h>
-
-#include <stdlib.h>
-#include "dbus/dbus-glib.h"
-#include "tools/dbus-glib-bindings.h"
-#include "test-objects.h"
-#include "test-dup-prop.h"
-
-#define TEST_NAMESPACE "org.freedesktop.DBus.GLib.Test.Interfaces"
-#define TEST_OBJECT_PATH "/org/freedesktop/DBus/GLib/Test/Interfaces"
-#define TEST_DP_OBJECT_PATH "/org/freedesktop/DBus/GLib/Test/DupPropInterfaces"
-
-static GMainLoop *loop = NULL;
-
-int
-main (int argc,
- char **argv)
-{
- DBusGConnection *connection;
- DBusGProxy *proxy;
- GError *error = NULL;
- guint32 ret;
- TestBeatlesSong *song;
- TestDpObj *dp_obj;
-
- g_type_init ();
-
- /* Get the connection and ensure the name is not used yet */
- connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
- if (connection == NULL) {
- g_warning ("Failed to make connection to session bus: %s",
- error->message);
- g_error_free (error);
- exit(1);
- }
-
- proxy = dbus_g_proxy_new_for_name (connection, DBUS_SERVICE_DBUS,
- DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS);
- if (!org_freedesktop_DBus_request_name (proxy, TEST_NAMESPACE,
- 0, &ret, &error)) {
- g_warning ("There was an error requesting the name: %s",
- error->message);
- g_error_free (error);
- exit(1);
- }
-
- if (ret != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) {
- /* Someone else registered the name before us */
- exit(1);
- }
-
- song = test_beatles_song_new ();
-
- /* Register the app on the bus */
- dbus_g_connection_register_g_object (connection,
- TEST_OBJECT_PATH,
- G_OBJECT (song));
-
- dp_obj = test_dp_obj_new ();
- dbus_g_connection_register_g_object (connection,
- TEST_DP_OBJECT_PATH,
- G_OBJECT (dp_obj));
-
- loop = g_main_loop_new (NULL, FALSE);
- g_main_loop_run (loop);
-
- return 0;
-}
diff --git a/test/interfaces/test-song.xml b/test/interfaces/test-song.xml
deleted file mode 100644
index 9a57dbc..0000000
--- a/test/interfaces/test-song.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-<?xml version="1.0"?><!-- ex:set et ts=2: -->
-<node name="/org/freedesktop/DBus/GLib/Test/Interfaces">
- <interface name="org.freedesktop.DBus.GLib.Test.Interfaces.Song">
- <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="test_song_dbus"/>
- <method name="GetTitle">
- <arg name="title" type="s" direction="out" />
- </method>
- </interface>
-</node>
diff --git a/test/interfaces/valid-annotations.xml b/test/interfaces/valid-annotations.xml
deleted file mode 100644
index 38115b0..0000000
--- a/test/interfaces/valid-annotations.xml
+++ /dev/null
@@ -1,27 +0,0 @@
-<?xml version="1.0"?><!-- ex:set et ts=2: -->
-<node name="/org/freedesktop/DBus/GLib/Test/Interfaces">
- <interface name="org.freedesktop.DBus.GLib.Test.Interfaces.Annotated">
- <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="test_annotated"/>
- <annotation name="com.example.Annotatable" value="yes"/>
-
- <method name="DoThings">
- <annotation name="com.example.Annotatable" value="yeah"/>
- <arg name="message" type="s" direction="out">
- <annotation name="com.example.MaybeAnnotatable"
- value="strictly speaking this isn't meant to be allowed"/>
- </arg>
- </method>
-
- <signal name="ThingsDone">
- <annotation name="com.example.Annotatable" value="fd.o#27598 says so"/>
- <arg name="message" type="s">
- <annotation name="com.example.MaybeAnnotatable"
- value="strictly speaking this isn't meant to be allowed"/>
- </arg>
- </signal>
-
- <property name="Things" type="s" access="read">
- <annotation name="com.example.Annotatable" value="hopefully"/>
- </property>
- </interface>
-</node>
diff --git a/test/specialized-types.c b/test/specialized-types.c
deleted file mode 100644
index 01216b3..0000000
--- a/test/specialized-types.c
+++ /dev/null
@@ -1,489 +0,0 @@
-/* Regression test for dbus-glib specialized types
- *
- * Copyright © 2005 Red Hat, Inc.
- * Copyright © 2011 Nokia Corporation
- *
- * Licensed under the Academic Free License version 2.1
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA
- */
-
-#include <config.h>
-
-#include <string.h>
-
-#include <glib.h>
-
-#include <dbus/dbus-glib.h>
-#include <dbus/dbus-glib-lowlevel.h>
-
-typedef struct {
- int dummy;
-} Fixture;
-
-static void
-setup (Fixture *f G_GNUC_UNUSED,
- gconstpointer context G_GNUC_UNUSED)
-{
- dbus_g_type_specialized_init ();
-}
-
-static void
-test_au (Fixture *f G_GNUC_UNUSED,
- gconstpointer context G_GNUC_UNUSED)
-{
- GType type;
- GArray *instance;
-
- type = dbus_g_type_get_collection ("GArray", G_TYPE_UINT);
- g_assert (dbus_g_type_is_collection (type));
- g_assert (dbus_g_type_get_collection_specialization (type) == G_TYPE_UINT);
-
- instance = dbus_g_type_specialized_construct (type);
- g_assert (instance->len == 0);
- g_array_free (instance, TRUE);
-}
-
-typedef struct
-{
- gboolean seen_foo;
- gboolean seen_baz;
-} TestSpecializedHashData;
-
-static void
-test_specialized_hash (const GValue *key, const GValue *val, gpointer user_data)
-{
- TestSpecializedHashData *data = user_data;
-
- g_assert (G_VALUE_HOLDS_STRING (key));
- g_assert (G_VALUE_HOLDS_STRING (val));
-
- if (!strcmp (g_value_get_string (key), "foo"))
- {
- data->seen_foo = TRUE;
- g_assert (!strcmp (g_value_get_string (val), "bar"));
- }
- else if (!strcmp (g_value_get_string (key), "baz"))
- {
- data->seen_baz = TRUE;
- g_assert (!strcmp (g_value_get_string (val), "moo"));
- }
- else
- {
- g_assert_not_reached ();
- }
-}
-
-static void
-test_specialized_hash_2 (const GValue *key, const GValue *val, gpointer user_data)
-{
- TestSpecializedHashData *data = user_data;
- const GValue *realval;
-
- g_assert (G_VALUE_HOLDS_STRING (key));
- g_assert (G_VALUE_TYPE (val) == G_TYPE_VALUE);
-
- realval = g_value_get_boxed (val);
-
- if (!strcmp (g_value_get_string (key), "foo"))
- {
- data->seen_foo = TRUE;
- g_assert (G_VALUE_HOLDS_UINT (realval));
- g_assert (g_value_get_uint (realval) == 20);
- }
- else if (!strcmp (g_value_get_string (key), "baz"))
- {
- data->seen_baz = TRUE;
- g_assert (G_VALUE_HOLDS_STRING (realval));
- g_assert (!strcmp ("bar", g_value_get_string (realval)));
- }
- else
- {
- g_assert_not_reached ();
- }
-}
-
-static void
-test_map_ss (Fixture *f G_GNUC_UNUSED,
- gconstpointer context G_GNUC_UNUSED)
-{
- GType type;
- GHashTable *instance;
- GValue val = { 0, };
- TestSpecializedHashData hashdata;
-
- type = dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_STRING);
- g_assert (dbus_g_type_is_map (type));
- g_assert (dbus_g_type_get_map_key_specialization (type) == G_TYPE_STRING);
- g_assert (dbus_g_type_get_map_value_specialization (type) == G_TYPE_STRING);
-
- instance = dbus_g_type_specialized_construct (type);
-
- g_assert (g_hash_table_size (instance) == 0);
- g_hash_table_insert (instance, g_strdup ("foo"), g_strdup ("bar"));
- g_hash_table_insert (instance, g_strdup ("baz"), g_strdup ("moo"));
- g_assert (g_hash_table_size (instance) == 2);
-
- g_value_init (&val, type);
- g_value_take_boxed (&val, instance);
- hashdata.seen_foo = FALSE;
- hashdata.seen_baz = FALSE;
- dbus_g_type_map_value_iterate (&val,
- test_specialized_hash,
- &hashdata);
-
- g_assert (hashdata.seen_foo);
- g_assert (hashdata.seen_baz);
-
- g_value_unset (&val);
-}
-
-static void
-test_map_sv (Fixture *f G_GNUC_UNUSED,
- gconstpointer context G_GNUC_UNUSED)
-{
- GType type;
-
- type = dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_VALUE);
- g_assert (dbus_g_type_is_map (type));
- g_assert (dbus_g_type_get_map_key_specialization (type) == G_TYPE_STRING);
- g_assert (dbus_g_type_get_map_value_specialization (type) == G_TYPE_VALUE);
- {
- GHashTable *instance;
- GValue val = { 0, };
- TestSpecializedHashData hashdata;
- DBusGTypeSpecializedAppendContext ctx;
- GValue *eltval;
-
- instance = dbus_g_type_specialized_construct (type);
- g_value_init (&val, type);
- g_value_take_boxed (&val, instance);
-
- dbus_g_type_specialized_init_append (&val, &ctx);
-
- {
- GValue keyval = { 0, };
- GValue valval = { 0, };
- g_value_init (&keyval, G_TYPE_STRING);
- g_value_set_string (&keyval, "foo");
-
- g_value_init (&valval, G_TYPE_VALUE);
- eltval = g_new0 (GValue, 1);
- g_value_init (eltval, G_TYPE_UINT);
- g_value_set_uint (eltval, 20);
- g_value_take_boxed (&valval, eltval);
- dbus_g_type_specialized_map_append (&ctx, &keyval, &valval);
- }
-
- {
- GValue keyval = { 0, };
- GValue valval = { 0, };
- g_value_init (&keyval, G_TYPE_STRING);
- g_value_set_string (&keyval, "baz");
- g_value_init (&valval, G_TYPE_VALUE);
- eltval = g_new0 (GValue, 1);
- g_value_init (eltval, G_TYPE_STRING);
- g_value_set_string (eltval, "bar");
- g_value_take_boxed (&valval, eltval);
- dbus_g_type_specialized_map_append (&ctx, &keyval, &valval);
- }
-
- hashdata.seen_foo = FALSE;
- hashdata.seen_baz = FALSE;
- dbus_g_type_map_value_iterate (&val,
- test_specialized_hash_2,
- &hashdata);
-
- g_assert (hashdata.seen_foo);
- g_assert (hashdata.seen_baz);
-
- g_value_unset (&val);
- }
-}
-
-static void
-test_ao_slist (Fixture *f G_GNUC_UNUSED,
- gconstpointer context G_GNUC_UNUSED)
-{
- GType type;
-
- type = dbus_g_type_get_collection ("GSList", G_TYPE_OBJECT);
- g_assert (dbus_g_type_is_collection (type));
- g_assert (dbus_g_type_get_collection_specialization (type) == G_TYPE_OBJECT);
- {
- GSList *instance, *tmp, *copy;
- GValue val = {0, };
- GValue copyval = {0, };
- DBusGTypeSpecializedAppendContext ctx;
- GObject *objects[3];
- int i;
-
- instance = dbus_g_type_specialized_construct (type);
- g_assert (instance == NULL);
-
- g_value_init (&val, type);
- g_value_take_boxed (&val, instance);
-
- dbus_g_type_specialized_init_append (&val, &ctx);
-
- for (i = 0; i < 3; i++)
- {
- GValue eltval = { 0, };
- GObject *obj = g_object_new (G_TYPE_OBJECT, NULL);
-
- g_assert (obj != NULL);
- objects[i] = obj;
- g_object_add_weak_pointer (obj, (gpointer) (objects + i));
-
- g_value_init (&eltval, G_TYPE_OBJECT);
- g_value_take_object (&eltval, obj);
- dbus_g_type_specialized_collection_append (&ctx, &eltval);
- }
-
- dbus_g_type_specialized_collection_end_append (&ctx);
-
- instance = g_value_get_boxed (&val);
- g_assert (g_slist_length (instance) == 3);
-
- for (tmp = instance; tmp; tmp = tmp->next)
- {
- GObject *obj = tmp->data;
- g_assert (G_IS_OBJECT (obj));
- g_assert (obj->ref_count == 1);
- }
-
- g_value_init (&copyval, type);
- g_value_copy (&val, &copyval);
-
- copy = g_value_get_boxed (&copyval);
- g_assert (g_slist_length (copy) == 3);
-
- for (tmp = copy; tmp; tmp = tmp->next)
- {
- GObject *obj = tmp->data;
- g_assert (G_IS_OBJECT (obj));
- g_assert (obj->ref_count == 2);
- }
-
- g_value_unset (&copyval);
-
- for (i = 0; i < 3; i++)
- {
- g_assert (objects[i] != NULL);
- }
-
- for (tmp = instance; tmp; tmp = tmp->next)
- {
- GObject *obj = tmp->data;
- g_assert (G_IS_OBJECT (obj));
- g_assert (obj->ref_count == 1);
- }
-
- g_value_unset (&val);
-
- for (i = 0; i < 3; i++)
- {
- g_assert (objects[i] == NULL);
- }
- }
-}
-
-static void
-test_as_ptrarray (Fixture *f G_GNUC_UNUSED,
- gconstpointer context G_GNUC_UNUSED)
-{
- GType type;
-
- type = dbus_g_type_get_collection ("GPtrArray", G_TYPE_STRING);
- g_assert (dbus_g_type_is_collection (type));
- g_assert (dbus_g_type_get_collection_specialization (type) == G_TYPE_STRING);
- {
- GPtrArray *instance;
- DBusGTypeSpecializedAppendContext ctx;
- GValue val = {0, };
- GValue eltval = {0, };
-
- instance = dbus_g_type_specialized_construct (type);
-
- g_assert (instance->len == 0);
-
- g_value_init (&val, type);
- g_value_take_boxed (&val, instance);
-
- dbus_g_type_specialized_init_append (&val, &ctx);
-
- g_value_init (&eltval, G_TYPE_STRING);
- g_value_set_static_string (&eltval, "foo");
- dbus_g_type_specialized_collection_append (&ctx, &eltval);
-
- g_value_reset (&eltval);
- g_value_set_static_string (&eltval, "bar");
- dbus_g_type_specialized_collection_append (&ctx, &eltval);
-
- g_value_reset (&eltval);
- g_value_set_static_string (&eltval, "baz");
- dbus_g_type_specialized_collection_append (&ctx, &eltval);
-
- dbus_g_type_specialized_collection_end_append (&ctx);
-
- g_assert (instance->len == 3);
-
- g_assert (!strcmp ("foo", g_ptr_array_index (instance, 0)));
- g_assert (!strcmp ("bar", g_ptr_array_index (instance, 1)));
- g_assert (!strcmp ("baz", g_ptr_array_index (instance, 2)));
-
- g_value_unset (&val);
- }
-}
-
-static void
-test_suo (Fixture *f G_GNUC_UNUSED,
- gconstpointer context G_GNUC_UNUSED)
-{
- GType type;
-
- type = dbus_g_type_get_struct ("GValueArray", G_TYPE_STRING, G_TYPE_UINT, DBUS_TYPE_G_OBJECT_PATH, G_TYPE_INVALID);
- g_assert (dbus_g_type_is_struct (type));
- g_assert (dbus_g_type_get_struct_size (type) == 3);
- g_assert (dbus_g_type_get_struct_member_type (type, 0) == G_TYPE_STRING);
- g_assert (dbus_g_type_get_struct_member_type (type, 1) == G_TYPE_UINT);
- g_assert (dbus_g_type_get_struct_member_type (type, 2) == DBUS_TYPE_G_OBJECT_PATH);
- {
- GValueArray *instance;
- GValue val = {0, };
- GValue memval = {0, };
-
- instance = dbus_g_type_specialized_construct (type);
-
- g_assert (instance->n_values == 3);
-
- g_value_init (&val, type);
- g_value_take_boxed (&val, instance);
-
- g_value_init (&memval, G_TYPE_STRING);
- g_value_set_static_string (&memval, "foo");
- dbus_g_type_struct_set_member (&val, 0, &memval);
- g_value_unset (&memval);
-
- g_value_init (&memval, G_TYPE_UINT);
- g_value_set_uint (&memval, 42);
- dbus_g_type_struct_set_member (&val, 1, &memval);
- g_value_unset (&memval);
-
- g_value_init (&memval, DBUS_TYPE_G_OBJECT_PATH);
- g_value_set_static_boxed (&memval, "/bar/moo/foo/baz");
- dbus_g_type_struct_set_member (&val, 2, &memval);
- g_value_unset (&memval);
-
- g_assert (instance->n_values == 3);
-
- g_value_init (&memval, G_TYPE_STRING);
- dbus_g_type_struct_get_member (&val, 0, &memval);
- g_assert (0 == strcmp (g_value_get_string (&memval), "foo"));
- g_value_unset (&memval);
-
- g_value_init (&memval, G_TYPE_UINT);
- dbus_g_type_struct_get_member (&val, 1, &memval);
- g_assert (g_value_get_uint (&memval) == 42);
- g_value_unset (&memval);
-
- g_value_init (&memval, DBUS_TYPE_G_OBJECT_PATH);
- dbus_g_type_struct_get_member (&val, 2, &memval);
- g_assert (0 == strcmp ((gchar*) g_value_get_boxed (&memval),
- "/bar/moo/foo/baz"));
- g_value_unset (&memval);
-
- g_value_unset (&val);
- }
-
- type = dbus_g_type_get_struct ("GValueArray", G_TYPE_STRING, G_TYPE_UINT, DBUS_TYPE_G_OBJECT_PATH, G_TYPE_INVALID);
- g_assert (dbus_g_type_is_struct (type));
- g_assert (dbus_g_type_get_struct_size (type) == 3);
- g_assert (dbus_g_type_get_struct_member_type (type, 0) == G_TYPE_STRING);
- g_assert (dbus_g_type_get_struct_member_type (type, 1) == G_TYPE_UINT);
- g_assert (dbus_g_type_get_struct_member_type (type, 2) == DBUS_TYPE_G_OBJECT_PATH);
- {
- GValueArray *instance;
- GValue val = {0, };
-
- instance = dbus_g_type_specialized_construct (type);
-
- g_assert (instance->n_values == 3);
-
- g_value_init (&val, type);
- g_value_take_boxed (&val, instance);
-
- dbus_g_type_struct_set (&val,
- 0,"foo",
- 1, 42,
- 2, "/bar/moo/foo/baz",
- G_MAXUINT);
-
- g_assert (instance->n_values == 3);
-
- {
- gchar *string;
- guint intval;
- gchar *path;
-
- dbus_g_type_struct_get (&val,
- 0, &string,
- 1, &intval,
- 2, &path,
- G_MAXUINT);
-
- g_assert (0 == strcmp (string, "foo"));
- g_assert (intval == 42);
- g_assert (0 == strcmp (path, "/bar/moo/foo/baz"));
- }
-
- g_value_unset (&val);
- }
-}
-
-static void
-teardown (Fixture *f G_GNUC_UNUSED,
- gconstpointer context G_GNUC_UNUSED)
-{
-}
-
-int
-main (int argc,
- char **argv)
-{
- g_test_init (&argc, &argv, NULL);
- g_type_init ();
-
- g_test_add ("/specialized-types/au/GArray", Fixture, NULL,
- setup, test_au, teardown);
-
- g_test_add ("/specialized-types/a{ss}/GHashTable", Fixture, NULL,
- setup, test_map_ss, teardown);
-
- g_test_add ("/specialized-types/a{sv}/GHashTable", Fixture, NULL,
- setup, test_map_sv, teardown);
-
- g_test_add ("/specialized-types/ao/GSList", Fixture, NULL,
- setup, test_ao_slist, teardown);
-
- g_test_add ("/specialized-types/as/GPtrArray", Fixture, NULL,
- setup, test_as_ptrarray, teardown);
-
- g_test_add ("/specialized-types/suo/GValueArray", Fixture, NULL,
- setup, test_suo, teardown);
-
- return g_test_run ();
-}
diff --git a/test/test-compile-nested.sh b/test/test-compile-nested.sh
deleted file mode 100755
index ebc209c..0000000
--- a/test/test-compile-nested.sh
+++ /dev/null
@@ -1,5 +0,0 @@
-#!/bin/sh
-
-# http://bugs.freedesktop.org/show_bug.cgi?id=19065
-echo ${DEBUG} ${top_builddir}/dbus/dbus-binding-tool --mode=glib-server --prefix=test ${srcdir}/data/nested-introspect.xml
-${DEBUG} ${top_builddir}/dbus/dbus-binding-tool --mode=glib-server --prefix=test ${srcdir}/data/nested-introspect.xml >/dev/null \ No newline at end of file
diff --git a/test/test-service.c b/test/test-service.c
deleted file mode 100644
index 10ef50a..0000000
--- a/test/test-service.c
+++ /dev/null
@@ -1,375 +0,0 @@
-#include <config.h>
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <dbus/dbus.h>
-
-static dbus_bool_t already_quit = FALSE;
-static dbus_bool_t hello_from_self_reply_recived = FALSE;
-
-static void
-quit (void)
-{
- if (!already_quit)
- already_quit = TRUE;
-}
-
-static void
-die (const char *message)
-{
- fprintf (stderr, "*** test-service: %s", message);
- exit (1);
-}
-
-static void
-check_hello_from_self_reply (DBusPendingCall *pcall,
- void *user_data)
-{
- DBusMessage *reply;
- DBusMessage *echo_message, *echo_reply;
- DBusError error;
- DBusConnection *connection;
-
- int type;
-
- dbus_error_init (&error);
-
- connection = dbus_bus_get (DBUS_BUS_STARTER, &error);
- if (connection == NULL)
- {
- fprintf (stderr, "*** Failed to open connection to activating message bus: %s\n",
- error.message);
- dbus_error_free (&error);
- die("no memory");
- }
-
-
- echo_message = (DBusMessage *)user_data;
-
- reply = dbus_pending_call_steal_reply (pcall);
-
- type = dbus_message_get_type (reply);
-
- if (type == DBUS_MESSAGE_TYPE_METHOD_RETURN)
- {
- const char *s;
- printf ("Reply from HelloFromSelf recived\n");
-
- if (!dbus_message_get_args (echo_message,
- &error,
- DBUS_TYPE_STRING, &s,
- DBUS_TYPE_INVALID))
- {
- echo_reply = dbus_message_new_error (echo_message,
- error.name,
- error.message);
-
- if (echo_reply == NULL)
- die ("No memory\n");
-
- }
- else
- {
- echo_reply = dbus_message_new_method_return (echo_message);
- if (echo_reply == NULL)
- die ("No memory\n");
-
- if (!dbus_message_append_args (echo_reply,
- DBUS_TYPE_STRING, &s,
- DBUS_TYPE_INVALID))
- die ("No memory");
- }
-
- if (!dbus_connection_send (connection, echo_reply, NULL))
- die ("No memory\n");
-
- dbus_message_unref (echo_reply);
- }
- else if (type == DBUS_MESSAGE_TYPE_ERROR)
- {
- dbus_set_error_from_message (&error, reply);
- printf ("Error type in reply: %s\n", error.message);
-
- if (strcmp (error.name, DBUS_ERROR_NO_MEMORY) != 0)
- {
- echo_reply = dbus_message_new_error (echo_message,
- error.name,
- error.message);
-
- if (echo_reply == NULL)
- die ("No memory\n");
-
- if (!dbus_connection_send (connection, echo_reply, NULL))
- die ("No memory\n");
-
- dbus_message_unref (echo_reply);
- }
- dbus_error_free (&error);
- }
-
- hello_from_self_reply_recived = TRUE;
-
- dbus_message_unref (reply);
- dbus_message_unref (echo_message);
- dbus_pending_call_unref (pcall);
-}
-
-static DBusHandlerResult
-handle_run_hello_from_self (DBusConnection *connection,
- DBusMessage *message)
-{
- DBusError error;
- DBusMessage *reply, *self_message;
- DBusPendingCall *pcall;
- char *s;
-
- dbus_error_init (&error);
-
- if (!dbus_message_get_args (message,
- &error,
- DBUS_TYPE_STRING, &s,
- DBUS_TYPE_INVALID))
- {
- reply = dbus_message_new_error (message,
- error.name,
- error.message);
-
- if (reply == NULL)
- die ("No memory\n");
-
- if (!dbus_connection_send (connection, reply, NULL))
- die ("No memory\n");
-
- dbus_message_unref (reply);
-
- return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
- }
- printf ("Sending HelloFromSelf\n");
-
- self_message = dbus_message_new_method_call ("org.freedesktop.DBus.GLib.TestEchoService",
- "/org/freedesktop/DBus/GLib/TestSuite",
- "org.freedesktop.DBus.GLib.TestSuite",
- "HelloFromSelf");
-
- if (self_message == NULL)
- die ("No memory");
-
- if (!dbus_connection_send_with_reply (connection, self_message, &pcall, -1))
- die("No memory");
-
- dbus_message_ref (message);
- if (!dbus_pending_call_set_notify (pcall, check_hello_from_self_reply, (void *)message, NULL))
- die("No memory");
-
- printf ("Sent HelloFromSelf\n");
- return DBUS_HANDLER_RESULT_HANDLED;
-}
-
-static DBusHandlerResult
-handle_echo (DBusConnection *connection,
- DBusMessage *message)
-{
- DBusError error;
- DBusMessage *reply;
- char *s;
-
- dbus_error_init (&error);
-
- if (!dbus_message_get_args (message,
- &error,
- DBUS_TYPE_STRING, &s,
- DBUS_TYPE_INVALID))
- {
- reply = dbus_message_new_error (message,
- error.name,
- error.message);
-
- if (reply == NULL)
- die ("No memory\n");
-
- if (!dbus_connection_send (connection, reply, NULL))
- die ("No memory\n");
-
- dbus_message_unref (reply);
-
- return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
- }
-
- reply = dbus_message_new_method_return (message);
- if (reply == NULL)
- die ("No memory\n");
-
- if (!dbus_message_append_args (reply,
- DBUS_TYPE_STRING, &s,
- DBUS_TYPE_INVALID))
- die ("No memory");
-
- if (!dbus_connection_send (connection, reply, NULL))
- die ("No memory\n");
-
- fprintf (stderr, "Echo service echoed string: \"%s\"\n", s);
-
- dbus_message_unref (reply);
-
- return DBUS_HANDLER_RESULT_HANDLED;
-}
-
-static void
-path_unregistered_func (DBusConnection *connection,
- void *user_data)
-{
- /* connection was finalized */
-}
-
-static DBusHandlerResult
-path_message_func (DBusConnection *connection,
- DBusMessage *message,
- void *user_data)
-{
- if (dbus_message_is_method_call (message,
- "org.freedesktop.DBus.GLib.TestSuite",
- "Echo"))
- return handle_echo (connection, message);
- else if (dbus_message_is_method_call (message,
- "org.freedesktop.DBus.GLib.TestSuite",
- "Exit"))
- {
- dbus_connection_close (connection);
- quit ();
- return DBUS_HANDLER_RESULT_HANDLED;
- }
- else if (dbus_message_is_method_call (message,
- "org.freedesktop.DBus.GLib.TestSuite",
- "EmitFoo"))
- {
- /* Emit the Foo signal */
- DBusMessage *signal;
- double v_DOUBLE;
-
- signal = dbus_message_new_signal ("/org/freedesktop/DBus/GLib/TestSuite",
- "org.freedesktop.DBus.GLib.TestSuite",
- "Foo");
- if (signal == NULL)
- die ("No memory\n");
-
- v_DOUBLE = 42.6;
- if (!dbus_message_append_args (signal,
- DBUS_TYPE_DOUBLE, &v_DOUBLE,
- DBUS_TYPE_INVALID))
- die ("No memory");
-
- if (!dbus_connection_send (connection, signal, NULL))
- die ("No memory\n");
-
- return DBUS_HANDLER_RESULT_HANDLED;
- }
-
- else if (dbus_message_is_method_call (message,
- "org.freedesktop.DBus.GLib.TestSuite",
- "RunHelloFromSelf"))
- {
- return handle_run_hello_from_self (connection, message);
- }
- else if (dbus_message_is_method_call (message,
- "org.freedesktop.DBus.GLib.TestSuite",
- "HelloFromSelf"))
- {
- DBusMessage *reply;
- printf ("Recived the HelloFromSelf message\n");
-
- reply = dbus_message_new_method_return (message);
- if (reply == NULL)
- die ("No memory");
-
- if (!dbus_connection_send (connection, reply, NULL))
- die ("No memory");
- }
-
- return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
-}
-
-static DBusObjectPathVTable
-echo_vtable = {
- path_unregistered_func,
- path_message_func,
- NULL,
-};
-
-
-static const char* echo_path = "/org/freedesktop/DBus/GLib/TestSuite" ;
-
-static DBusHandlerResult
-filter_func (DBusConnection *connection,
- DBusMessage *message,
- void *user_data)
-{
- if (dbus_message_is_signal (message,
- DBUS_INTERFACE_LOCAL,
- "Disconnected"))
- {
- dbus_connection_close (connection);
- quit ();
- return DBUS_HANDLER_RESULT_HANDLED;
- }
- else
- {
- return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
- }
-}
-
-int
-main (int argc,
- char **argv)
-{
- DBusError error;
- DBusConnection *connection;
-
- dbus_error_init (&error);
- connection = dbus_bus_get (DBUS_BUS_STARTER, &error);
- if (connection == NULL)
- {
- fprintf (stderr, "*** Failed to open connection to activating message bus: %s\n",
- error.message);
- dbus_error_free (&error);
- return 1;
- }
-
- if (!dbus_connection_add_filter (connection,
- filter_func, NULL, NULL))
- die ("No memory");
-
- if (!dbus_connection_register_object_path (connection,
- echo_path,
- &echo_vtable,
- (void*) 0xdeadbeef))
- die ("No memory");
-
- {
- void *d;
- if (!dbus_connection_get_object_path_data (connection, echo_path, &d))
- die ("No memory");
- if (d != (void*) 0xdeadbeef)
- die ("dbus_connection_get_object_path_data() doesn't seem to work right\n");
- }
-
- dbus_bus_request_name (connection, "org.freedesktop.DBus.GLib.TestEchoService",
- 0, &error);
- if (dbus_error_is_set (&error))
- {
- fprintf (stderr, "Error %s\n", error.message);
- dbus_error_free (&error);
- exit (1);
- }
-
- while (dbus_connection_read_write_dispatch (connection, -1) && !already_quit)
- ;
-
- dbus_connection_remove_filter (connection, filter_func, NULL);
-
- dbus_connection_unref (connection);
-
- dbus_shutdown ();
-
- return 0;
-}
diff --git a/tools/Makefile.am b/tools/Makefile.am
deleted file mode 100644
index 57ae527..0000000
--- a/tools/Makefile.am
+++ /dev/null
@@ -1,22 +0,0 @@
-AM_CPPFLAGS = \
- -I$(top_srcdir) \
- $(DBUS_CFLAGS) \
- $(DBUS_GLIB_CFLAGS) \
- $(DBUS_X_CFLAGS) \
- $(DBUS_GTK_THREADS_CFLAGS) \
- -DDBUS_COMPILATION \
- $(NULL)
-
-nodist_libdbus_glib_HEADERS = dbus-glib-bindings.h
-libdbus_glibdir = $(includedir)/dbus-1.0/dbus
-
-dbus-glib-bindings.h: $(top_srcdir)/dbus-bus-introspect.xml $(top_builddir)/dbus/dbus-binding-tool$(EXEEXT)
- $(DBUS_BINDING_TOOL) --mode=glib-client --prefix=dbus_bus --output=dbus-glib-bindings.h $(top_srcdir)/dbus-bus-introspect.xml
-
-BUILT_SOURCES = dbus-glib-bindings.h
-
-EXTRA_DIST = run-with-tmp-session-bus.sh session.conf
-
-CLEANFILES = \
- run-with-tmp-session-bus.conf \
- dbus-glib-bindings.h
diff --git a/tools/dbus-glib-tests.supp b/tools/dbus-glib-tests.supp
deleted file mode 100644
index 77a4593..0000000
--- a/tools/dbus-glib-tests.supp
+++ /dev/null
@@ -1,64 +0,0 @@
-# Valgrind error suppression file: dbus-glib regression tests
-
-{
- MyObject properties
- Memcheck:Leak
- ...
- fun:g_param_spec_string
- ...
- fun:my_object_class_intern_init
- fun:g_type_class_ref
-}
-
-{
- MyObject properties
- Memcheck:Leak
- ...
- fun:g_param_spec_internal
- ...
- fun:my_object_class_intern_init
- fun:g_type_class_ref
-}
-
-{
- MyObject signals
- Memcheck:Leak
- ...
- fun:g_signal_new
- fun:my_object_class_intern_init
- fun:g_type_class_ref
-}
-
-{
- MyObject qdata
- Memcheck:Leak
- ...
- fun:g_type_set_qdata
- fun:my_object_class_intern_init
- fun:g_type_class_ref
-}
-
-{
- shared-bus test
- Memcheck:Leak
- ...
- fun:dbus_g_bus_get
- fun:test_shared_bus
-}
-
-{
- object initialization
- Memcheck:Leak
- ...
- fun:g_signal_new
- fun:g_object_do_class_init
- fun:g_type_class_ref
-}
-
-{
- object interface initialization
- Memcheck:Leak
- ...
- fun:g_type_add_interface_check
- fun:g_type_class_ref
-}
diff --git a/tools/dbus-glib.supp b/tools/dbus-glib.supp
deleted file mode 100644
index 6868e81..0000000
--- a/tools/dbus-glib.supp
+++ /dev/null
@@ -1,297 +0,0 @@
-# Valgrind error suppression file
-
-# ============================= GLib ==================================
-
-{
- g_set_prgname copies its argument
- Memcheck:Leak
- ...
- fun:g_set_prgname
-}
-
-{
- one g_get_charset per child^Wprocess
- Memcheck:Leak
- ...
- fun:g_get_charset
-}
-
-{
- one g_get_home_dir per process
- Memcheck:Leak
- ...
- fun:g_get_home_dir
-}
-
-{
- GQuarks can't be freed
- Memcheck:Leak
- ...
- fun:g_quark_from_static_string
-}
-
-{
- GQuarks can't be freed
- Memcheck:Leak
- ...
- fun:g_quark_from_string
-}
-
-{
- interned strings can't be freed
- Memcheck:Leak
- ...
- fun:g_intern_string
-}
-
-{
- interned strings can't be freed
- Memcheck:Leak
- ...
- fun:g_intern_static_string
-}
-
-{
- shared global default g_main_context
- Memcheck:Leak
- ...
- fun:g_main_context_new
- fun:g_main_context_default
-}
-
-{
- GTest initialization
- Memcheck:Leak
- ...
- fun:g_test_init
- fun:main
-}
-
-{
- GTest admin
- Memcheck:Leak
- ...
- fun:g_test_add_vtable
-}
-
-{
- GTest pseudorandomness
- Memcheck:Leak
- ...
- fun:g_rand_new_with_seed_array
- fun:test_run_seed
- ...
- fun:g_test_run
-}
-
-{
- GTest pseudorandomness
- Memcheck:Leak
- ...
- fun:g_rand_new_with_seed_array
- fun:test_run_seed
- ...
- fun:g_test_run_suite
-}
-
-{
- GSLice initialization
- Memcheck:Leak
- ...
- fun:g_malloc0
- fun:g_slice_init_nomessage
- fun:g_slice_alloc
-}
-
-{
- GData initialization
- Memcheck:Leak
- ...
- fun:g_data_initialize
-}
-
-{
- GTest strings
- Memcheck:Leak
- ...
- fun:g_strdup
- fun:g_test_run_suite_internal
-}
-
-# ============================= GObject ===============================
-
-{
- g_type_init
- Memcheck:Leak
- ...
- fun:g_type_init
-}
-
-{
- g_type_init_with_debug_flags
- Memcheck:Leak
- ...
- fun:g_type_init_with_debug_flags
-}
-
-{
- g_type_register_static
- Memcheck:Leak
- ...
- fun:g_type_register_static
-}
-
-{
- g_type_add_interface_static
- Memcheck:Leak
- ...
- fun:g_type_add_interface_static
-}
-
-{
- initialization of interfaces
- Memcheck:Leak
- ...
- fun:type_iface_vtable_base_init_Wm
- fun:g_type_class_ref
-}
-
-{
- g_param_spec_pool_new in class_init
- Memcheck:Leak
- ...
- fun:g_param_spec_pool_new
- ...
- fun:g_type_class_ref
-}
-
-{
- class creation
- Memcheck:Leak
- ...
- fun:g_malloc0
- fun:g_type_class_ref
-}
-
-# ============================= GIO ===================================
-
-{
- GIO init
- Memcheck:Leak
- ...
- fun:g_inet_address_class_intern_init
-}
-
-{
- g_simple_async_result class
- Memcheck:Leak
- ...
- fun:g_type_class_ref
- ...
- fun:g_simple_async_result_new
-}
-
-# ============================= dbus-glib =============================
-
-{
- registering marshallers is permanent
- Memcheck:Leak
- ...
- fun:dbus_g_object_register_marshaller_array
- fun:dbus_g_object_register_marshaller
-}
-
-{
- dbus-glib specialized GTypes are permanent
- Memcheck:Leak
- ...
- fun:dbus_g_type_specialized_init
-}
-
-{
- dbus-glib specialized GTypes are permanent (inlined)
- Memcheck:Leak
- ...
- fun:register_container
- fun:specialized_init
- fun:g_once_impl
-}
-
-{
- dbus-glib specialized GTypes are permanent (inlined)
- Memcheck:Leak
- ...
- fun:g_hash_table_new_full
- fun:specialized_init
- fun:g_once_impl
-}
-
-{
- error registrations are for life, not just for Christmas
- Memcheck:Leak
- ...
- fun:dbus_g_error_domain_register
-}
-
-{
- DBusGProxy class initialization
- Memcheck:Leak
- ...
- fun:g_type_class_ref
- ...
- fun:dbus_g_proxy_new
-}
-
-{
- _dbus_g_type_specialized_builtins_init
- Memcheck:Leak
- ...
- fun:_dbus_g_type_specialized_builtins_init
-}
-
-{
- _dbus_g_value_types_init
- Memcheck:Leak
- ...
- fun:_dbus_g_value_types_init
-}
-
-{
- specialized maps are permanent
- Memcheck:Leak
- ...
- fun:lookup_or_register_specialized
- fun:dbus_g_type_get_map
-}
-
-{
- specialized collections are permanent
- Memcheck:Leak
- ...
- fun:lookup_or_register_specialized
- fun:dbus_g_type_get_collection
-}
-
-{
- specialized structs are permanent
- Memcheck:Leak
- ...
- fun:lookup_or_register_specialized
- fun:dbus_g_type_get_struct
-}
-
-{
- specialized structs are permanent (varargs)
- Memcheck:Leak
- ...
- fun:lookup_or_register_specialized
- fun:dbus_g_type_get_structv
-}
-
-{
- specialized structs are permanent (inlined)
- Memcheck:Leak
- ...
- fun:lookup_or_register_specialized
- fun:dbus_g_value_tuple_parse_variant
-}
diff --git a/tools/lcov.am b/tools/lcov.am
deleted file mode 100644
index 95c4393..0000000
--- a/tools/lcov.am
+++ /dev/null
@@ -1,47 +0,0 @@
-# Copyright © 2010 Collabora Ltd. <http://www.collabora.co.uk/>
-#
-# Licensed under the Academic Free License version 2.1
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# Alternatively, at your option, you can redistribute and/or modify
-# this single file under the terms of the GNU Lesser General Public License
-# as published by the Free Software Foundation; either version 2.1 of
-# that license, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-
-lcov-reset:
- lcov --directory @top_srcdir@ --zerocounters
-
-lcov-report:
- lcov --directory @top_srcdir@ --capture \
- --output-file @top_builddir@/lcov.info.tmp
- lcov --directory @top_srcdir@ --output-file @top_builddir@/lcov.info \
- --remove @top_builddir@/lcov.info.tmp '*-scan.c'
- rm @top_builddir@/lcov.info.tmp
- $(mkdir_p) @top_builddir@/lcov.html
- git_commit=`GIT_DIR=@top_srcdir@/.git git log -1 --pretty=format:%h 2>/dev/null`;\
- genhtml --title "@PACKAGE_STRING@ $$git_commit" \
- --output-directory @top_builddir@/lcov.html lcov.info
- @echo
- @echo 'lcov report can be found in:'
- @echo 'file://@abs_top_builddir@/lcov.html/index.html'
- @echo
-
-lcov-check:
- $(MAKE) lcov-reset
- $(MAKE) check $(LCOV_CHECK_ARGS)
- $(MAKE) lcov-report
-
-## vim:set ft=automake:
diff --git a/tools/run-with-tmp-session-bus.sh b/tools/run-with-tmp-session-bus.sh
deleted file mode 100755
index 594cb30..0000000
--- a/tools/run-with-tmp-session-bus.sh
+++ /dev/null
@@ -1,51 +0,0 @@
-#! /bin/sh
-
-SCRIPTNAME=$0
-WRAPPED_SCRIPT=$1
-shift
-
-die()
-{
- if ! test -z "$DBUS_SESSION_BUS_PID" ; then
- echo "killing message bus "$DBUS_SESSION_BUS_PID >&2
- kill -9 $DBUS_SESSION_BUS_PID
- fi
- echo $SCRIPTNAME: $* >&2
- exit 1
-}
-
-if test -z "$DBUS_TOP_BUILDDIR" ; then
- die "Must set DBUS_TOP_BUILDDIR"
-fi
-if test -z "$DBUS_TOP_SRCDIR" ; then
- die "Must set DBUS_TOP_SRCDIR"
-fi
-
-## convenient to be able to ctrl+C without leaking the message bus process
-trap 'die "Received SIGINT"' SIGINT
-
-CONFIG_FILE=./run-with-tmp-session-bus.conf
-SERVICE_DIR="$DBUS_TOP_BUILDDIR/test/data/valid-service-files"
-ESCAPED_SERVICE_DIR=`echo $SERVICE_DIR | sed -e 's/\//\\\\\\//g'`
-echo "escaped service dir is: $ESCAPED_SERVICE_DIR" >&2
-
-## create a configuration file based on the standard session.conf
-cat $DBUS_TOP_SRCDIR/tools/session.conf | \
- sed -e 's/<servicedir>.*$/<servicedir>'$ESCAPED_SERVICE_DIR'<\/servicedir>/g' | \
- sed -e 's/<include.*$//g' \
- > $CONFIG_FILE
-
-echo "Created configuration file $CONFIG_FILE" >&2
-
-PATH=$DBUS_TOP_BUILDDIR/bus:$PATH
-export PATH
-## the libtool script found by the path search should already do this, but
-LD_LIBRARY_PATH=$DBUS_TOP_BUILDDIR/dbus/.libs:$LD_LIBRARY_PATH
-export PATH
-unset DBUS_SESSION_BUS_ADDRESS
-unset DBUS_SESSION_BUS_PID
-
-# Execute wrapped script
-echo "Running dbus-run-session --config-file=$CONFIG_FILE -- $WRAPPED_SCRIPT $@" >&2
-dbus-run-session --config-file="$CONFIG_FILE" -- $WRAPPED_SCRIPT "$@"
-exit $?
diff --git a/tools/session.conf b/tools/session.conf
deleted file mode 100644
index 73a38f1..0000000
--- a/tools/session.conf
+++ /dev/null
@@ -1,24 +0,0 @@
-<!-- This configuration file controls the per-user-login-session message bus.
- Add a session-local.conf and edit that rather than changing this
- file directly. -->
-
-<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
- "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
-<busconfig>
- <!-- Our well-known bus type, don't change this -->
- <type>session</type>
-
- <listen>unix:tmpdir=./</listen>
-
- <servicedir></servicedir>
-
- <policy context="default">
- <!-- Allow everything to be sent -->
- <allow send_destination="*"/>
- <!-- Allow everything to be received -->
- <allow eavesdrop="true"/>
- <!-- Allow anyone to own anything -->
- <allow own="*"/>
- </policy>
-
-</busconfig>