diff -Nru dbus-sharp-0.7.0/INSTALL dbus-sharp-0.8.0/INSTALL --- dbus-sharp-0.7.0/INSTALL 2010-09-03 08:22:34.000000000 +0000 +++ dbus-sharp-0.8.0/INSTALL 2013-10-07 00:27:39.000000000 +0000 @@ -1,8 +1,8 @@ Installation Instructions ************************* -Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005, -2006, 2007, 2008, 2009 Free Software Foundation, Inc. +Copyright (C) 1994-1996, 1999-2002, 2004-2013 Free Software Foundation, +Inc. Copying and distribution of this file, with or without modification, are permitted in any medium without royalty provided the copyright @@ -226,6 +226,11 @@ and if that doesn't work, install pre-built binaries of GCC for HP-UX. + HP-UX `make' updates targets which have the same time stamps as +their prerequisites, which makes it generally unusable when shipped +generated files such as `configure' are involved. Use GNU `make' +instead. + On OSF/1 a.k.a. Tru64, some versions of the default C compiler cannot parse its `' header file. The option `-nodtk' can be used as a workaround. If GNU CC is not installed, it is therefore recommended @@ -304,9 +309,10 @@ overridden in the site shell script). Unfortunately, this technique does not work for `CONFIG_SHELL' due to -an Autoconf bug. Until the bug is fixed you can use this workaround: +an Autoconf limitation. Until the limitation is lifted, you can use +this workaround: - CONFIG_SHELL=/bin/bash /bin/bash ./configure CONFIG_SHELL=/bin/bash + CONFIG_SHELL=/bin/bash ./configure CONFIG_SHELL=/bin/bash `configure' Invocation ====================== @@ -362,4 +368,3 @@ `configure' also accepts some other, not widely useful, options. Run `configure --help' for more details. - diff -Nru dbus-sharp-0.7.0/Makefile.am dbus-sharp-0.8.0/Makefile.am --- dbus-sharp-0.7.0/Makefile.am 2010-09-14 09:17:49.000000000 +0000 +++ dbus-sharp-0.8.0/Makefile.am 2013-10-07 00:35:59.000000000 +0000 @@ -1,14 +1,18 @@ -SUBDIRS = src tools examples +SUBDIRS = src tools examples tests + +test: + $(MAKE) -C tests setup run pkgconfigdir = $(libdir)/pkgconfig -pkgconfig_DATA = dbus-sharp-1.0.pc +pkgconfig_DATA = dbus-sharp-2.0.pc EXTRA_DIST = \ - dbus-sharp-1.0.pc.in \ - dbus-sharp.snk + dbus-sharp-2.0.pc.in \ + dbus-sharp.snk \ + dbus-sharp.sln DISTCLEANFILES = \ - dbus-sharp-1.0.pc + dbus-sharp-2.0.pc MAINTAINERCLEANFILES = \ INSTALL \ diff -Nru dbus-sharp-0.7.0/Makefile.in dbus-sharp-0.8.0/Makefile.in --- dbus-sharp-0.7.0/Makefile.in 2010-09-14 09:18:28.000000000 +0000 +++ dbus-sharp-0.8.0/Makefile.in 2013-10-07 00:49:05.000000000 +0000 @@ -1,9 +1,8 @@ -# Makefile.in generated by automake 1.11.1 from Makefile.am. +# Makefile.in generated by automake 1.13.2 from Makefile.am. # @configure_input@ -# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, -# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, -# Inc. +# Copyright (C) 1994-2013 Free Software Foundation, Inc. + # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. @@ -16,6 +15,51 @@ @SET_MAKE@ VPATH = @srcdir@ +am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' +am__make_running_with_option = \ + case $${target_option-} in \ + ?) ;; \ + *) echo "am__make_running_with_option: internal error: invalid" \ + "target option '$${target_option-}' specified" >&2; \ + exit 1;; \ + esac; \ + has_opt=no; \ + sane_makeflags=$$MAKEFLAGS; \ + if $(am__is_gnu_make); then \ + sane_makeflags=$$MFLAGS; \ + else \ + case $$MAKEFLAGS in \ + *\\[\ \ ]*) \ + bs=\\; \ + sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ + | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ + esac; \ + fi; \ + skip_next=no; \ + strip_trailopt () \ + { \ + flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ + }; \ + for flg in $$sane_makeflags; do \ + test $$skip_next = yes && { skip_next=no; continue; }; \ + case $$flg in \ + *=*|--*) continue;; \ + -*I) strip_trailopt 'I'; skip_next=yes;; \ + -*I?*) strip_trailopt 'I';; \ + -*O) strip_trailopt 'O'; skip_next=yes;; \ + -*O?*) strip_trailopt 'O';; \ + -*l) strip_trailopt 'l'; skip_next=yes;; \ + -*l?*) strip_trailopt 'l';; \ + -[dEDm]) skip_next=yes;; \ + -[JT]) skip_next=yes;; \ + esac; \ + case $$flg in \ + *$$target_option*) has_opt=yes; break;; \ + esac; \ + done; \ + test $$has_opt = yes +am__make_dryrun = (target_option=n; $(am__make_running_with_option)) +am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ @@ -33,10 +77,10 @@ PRE_UNINSTALL = : POST_UNINSTALL = : subdir = . -DIST_COMMON = README $(am__configure_deps) $(srcdir)/Makefile.am \ - $(srcdir)/Makefile.in $(srcdir)/dbus-sharp-1.0.pc.in \ - $(top_srcdir)/configure AUTHORS COPYING ChangeLog INSTALL NEWS \ - install-sh missing +DIST_COMMON = INSTALL NEWS README AUTHORS ChangeLog \ + $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ + $(top_srcdir)/configure $(am__configure_deps) \ + $(srcdir)/dbus-sharp-2.0.pc.in COPYING install-sh missing ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ @@ -44,17 +88,35 @@ am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \ configure.lineno config.status.lineno mkinstalldirs = $(install_sh) -d -CONFIG_CLEAN_FILES = dbus-sharp-1.0.pc +CONFIG_CLEAN_FILES = dbus-sharp-2.0.pc CONFIG_CLEAN_VPATH_FILES = +AM_V_P = $(am__v_P_@AM_V@) +am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) +am__v_P_0 = false +am__v_P_1 = : +AM_V_GEN = $(am__v_GEN_@AM_V@) +am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) +am__v_GEN_0 = @echo " GEN " $@; +am__v_GEN_1 = +AM_V_at = $(am__v_at_@AM_V@) +am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) +am__v_at_0 = @ +am__v_at_1 = SOURCES = DIST_SOURCES = -RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \ - html-recursive info-recursive install-data-recursive \ - install-dvi-recursive install-exec-recursive \ - install-html-recursive install-info-recursive \ - install-pdf-recursive install-ps-recursive install-recursive \ - installcheck-recursive installdirs-recursive pdf-recursive \ - ps-recursive uninstall-recursive +RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \ + ctags-recursive dvi-recursive html-recursive info-recursive \ + install-data-recursive install-dvi-recursive \ + install-exec-recursive install-html-recursive \ + install-info-recursive install-pdf-recursive \ + install-ps-recursive install-recursive installcheck-recursive \ + installdirs-recursive pdf-recursive ps-recursive \ + tags-recursive uninstall-recursive +am__can_run_installinfo = \ + case $$AM_UPDATE_INFO_DIR in \ + n|no|NO) false;; \ + *) (install-info --version) >/dev/null 2>&1;; \ + esac am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ @@ -76,23 +138,53 @@ am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' +am__uninstall_files_from_dir = { \ + test -z "$$files" \ + || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ + || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ + $(am__cd) "$$dir" && rm -f $$files; }; \ + } am__installdirs = "$(DESTDIR)$(pkgconfigdir)" DATA = $(pkgconfig_DATA) RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ distclean-recursive maintainer-clean-recursive -AM_RECURSIVE_TARGETS = $(RECURSIVE_TARGETS:-recursive=) \ - $(RECURSIVE_CLEAN_TARGETS:-recursive=) tags TAGS ctags CTAGS \ - distdir dist dist-all distcheck +am__recursive_targets = \ + $(RECURSIVE_TARGETS) \ + $(RECURSIVE_CLEAN_TARGETS) \ + $(am__extra_recursive_targets) +AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \ + cscope distdir dist dist-all distcheck +am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) +# Read a list of newline-separated strings from the standard input, +# and print each of them once, without duplicates. Input order is +# *not* preserved. +am__uniquify_input = $(AWK) '\ + BEGIN { nonempty = 0; } \ + { items[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in items) print i; }; } \ +' +# Make sure the list of sources is unique. This is necessary because, +# e.g., the same source file might be shared among _SOURCES variables +# for different programs/libraries. +am__define_uniq_tagged_files = \ + list='$(am__tagged_files)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags +CSCOPE = cscope DIST_SUBDIRS = $(SUBDIRS) DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) distdir = $(PACKAGE)-$(VERSION) top_distdir = $(distdir) am__remove_distdir = \ - { test ! -d "$(distdir)" \ - || { find "$(distdir)" -type d ! -perm -200 -exec chmod u+w {} ';' \ - && rm -fr "$(distdir)"; }; } + if test -d "$(distdir)"; then \ + find "$(distdir)" -type d ! -perm -200 -exec chmod u+w {} ';' \ + && rm -rf "$(distdir)" \ + || { sleep 5 && rm -rf "$(distdir)"; }; \ + else :; fi +am__post_remove_distdir = $(am__remove_distdir) am__relativize = \ dir0=`pwd`; \ sed_first='s,^\([^/]*\)/.*$$,\1,'; \ @@ -120,10 +212,14 @@ reldir="$$dir2" DIST_ARCHIVES = $(distdir).tar.gz GZIP_ENV = --best +DIST_TARGETS = dist-gzip distuninstallcheck_listfiles = find . -type f -print +am__distuninstallcheck_listfiles = $(distuninstallcheck_listfiles) \ + | sed 's|^\./|$(prefix)/|' | grep -v '$(infodir)/dir$$' distcleancheck_listfiles = find . -type f -print ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ +AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ API_VERSION = @API_VERSION@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ @@ -149,6 +245,8 @@ MKDIR_P = @MKDIR_P@ MONO_CFLAGS = @MONO_CFLAGS@ MONO_LIBS = @MONO_LIBS@ +NUNIT_CFLAGS = @NUNIT_CFLAGS@ +NUNIT_LIBS = @NUNIT_LIBS@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ @@ -164,6 +262,7 @@ SHELL = @SHELL@ STRIP = @STRIP@ VERSION = @VERSION@ +XBUILD = @XBUILD@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ @@ -203,15 +302,16 @@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ -SUBDIRS = src tools examples +SUBDIRS = src tools examples tests pkgconfigdir = $(libdir)/pkgconfig -pkgconfig_DATA = dbus-sharp-1.0.pc +pkgconfig_DATA = dbus-sharp-2.0.pc EXTRA_DIST = \ - dbus-sharp-1.0.pc.in \ - dbus-sharp.snk + dbus-sharp-2.0.pc.in \ + dbus-sharp.snk \ + dbus-sharp.sln DISTCLEANFILES = \ - dbus-sharp-1.0.pc + dbus-sharp-2.0.pc MAINTAINERCLEANFILES = \ INSTALL \ @@ -226,7 +326,7 @@ all: all-recursive .SUFFIXES: -am--refresh: +am--refresh: Makefile @: $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ @@ -260,12 +360,15 @@ $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) $(am__cd) $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS) $(am__aclocal_m4_deps): -dbus-sharp-1.0.pc: $(top_builddir)/config.status $(srcdir)/dbus-sharp-1.0.pc.in +dbus-sharp-2.0.pc: $(top_builddir)/config.status $(srcdir)/dbus-sharp-2.0.pc.in cd $(top_builddir) && $(SHELL) ./config.status $@ install-pkgconfigDATA: $(pkgconfig_DATA) @$(NORMAL_INSTALL) - test -z "$(pkgconfigdir)" || $(MKDIR_P) "$(DESTDIR)$(pkgconfigdir)" @list='$(pkgconfig_DATA)'; test -n "$(pkgconfigdir)" || list=; \ + if test -n "$$list"; then \ + echo " $(MKDIR_P) '$(DESTDIR)$(pkgconfigdir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(pkgconfigdir)" || exit 1; \ + fi; \ for p in $$list; do \ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ echo "$$d$$p"; \ @@ -279,27 +382,28 @@ @$(NORMAL_UNINSTALL) @list='$(pkgconfig_DATA)'; test -n "$(pkgconfigdir)" || list=; \ files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ - test -n "$$files" || exit 0; \ - echo " ( cd '$(DESTDIR)$(pkgconfigdir)' && rm -f" $$files ")"; \ - cd "$(DESTDIR)$(pkgconfigdir)" && rm -f $$files + dir='$(DESTDIR)$(pkgconfigdir)'; $(am__uninstall_files_from_dir) # This directory's subdirectories are mostly independent; you can cd -# into them and run `make' without going through this Makefile. -# To change the values of `make' variables: instead of editing Makefiles, -# (1) if the variable is set in `config.status', edit `config.status' -# (which will cause the Makefiles to be regenerated when you run `make'); -# (2) otherwise, pass the desired values on the `make' command line. -$(RECURSIVE_TARGETS): - @fail= failcom='exit 1'; \ - for f in x $$MAKEFLAGS; do \ - case $$f in \ - *=* | --[!k]*);; \ - *k*) failcom='fail=yes';; \ - esac; \ - done; \ +# into them and run 'make' without going through this Makefile. +# To change the values of 'make' variables: instead of editing Makefiles, +# (1) if the variable is set in 'config.status', edit 'config.status' +# (which will cause the Makefiles to be regenerated when you run 'make'); +# (2) otherwise, pass the desired values on the 'make' command line. +$(am__recursive_targets): + @fail=; \ + if $(am__make_keepgoing); then \ + failcom='fail=yes'; \ + else \ + failcom='exit 1'; \ + fi; \ dot_seen=no; \ target=`echo $@ | sed s/-recursive//`; \ - list='$(SUBDIRS)'; for subdir in $$list; do \ + case "$@" in \ + distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ + *) list='$(SUBDIRS)' ;; \ + esac; \ + for subdir in $$list; do \ echo "Making $$target in $$subdir"; \ if test "$$subdir" = "."; then \ dot_seen=yes; \ @@ -314,57 +418,12 @@ $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ fi; test -z "$$fail" -$(RECURSIVE_CLEAN_TARGETS): - @fail= failcom='exit 1'; \ - for f in x $$MAKEFLAGS; do \ - case $$f in \ - *=* | --[!k]*);; \ - *k*) failcom='fail=yes';; \ - esac; \ - done; \ - dot_seen=no; \ - case "$@" in \ - distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ - *) list='$(SUBDIRS)' ;; \ - esac; \ - rev=''; for subdir in $$list; do \ - if test "$$subdir" = "."; then :; else \ - rev="$$subdir $$rev"; \ - fi; \ - done; \ - rev="$$rev ."; \ - target=`echo $@ | sed s/-recursive//`; \ - for subdir in $$rev; do \ - echo "Making $$target in $$subdir"; \ - if test "$$subdir" = "."; then \ - local_target="$$target-am"; \ - else \ - local_target="$$target"; \ - fi; \ - ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ - || eval $$failcom; \ - done && test -z "$$fail" -tags-recursive: - list='$(SUBDIRS)'; for subdir in $$list; do \ - test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \ - done -ctags-recursive: - list='$(SUBDIRS)'; for subdir in $$list; do \ - test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \ - done - -ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) - list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ - END { if (nonempty) { for (i in files) print i; }; }'`; \ - mkid -fID $$unique -tags: TAGS +ID: $(am__tagged_files) + $(am__define_uniq_tagged_files); mkid -fID $$unique +tags: tags-recursive +TAGS: tags -TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ - $(TAGS_FILES) $(LISP) +tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ @@ -380,12 +439,7 @@ set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \ fi; \ done; \ - list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ - END { if (nonempty) { for (i in files) print i; }; }'`; \ + $(am__define_uniq_tagged_files); \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ @@ -397,15 +451,11 @@ $$unique; \ fi; \ fi -ctags: CTAGS -CTAGS: ctags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ - $(TAGS_FILES) $(LISP) - list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ - END { if (nonempty) { for (i in files) print i; }; }'`; \ +ctags: ctags-recursive + +CTAGS: ctags +ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) + $(am__define_uniq_tagged_files); \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique @@ -414,9 +464,31 @@ here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" +cscope: cscope.files + test ! -s cscope.files \ + || $(CSCOPE) -b -q $(AM_CSCOPEFLAGS) $(CSCOPEFLAGS) -i cscope.files $(CSCOPE_ARGS) +clean-cscope: + -rm -f cscope.files +cscope.files: clean-cscope cscopelist +cscopelist: cscopelist-recursive + +cscopelist-am: $(am__tagged_files) + list='$(am__tagged_files)'; \ + case "$(srcdir)" in \ + [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ + *) sdir=$(subdir)/$(srcdir) ;; \ + esac; \ + for i in $$list; do \ + if test -f "$$i"; then \ + echo "$(subdir)/$$i"; \ + else \ + echo "$$sdir/$$i"; \ + fi; \ + done >> $(top_builddir)/cscope.files distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + -rm -f cscope.out cscope.in.out cscope.po.out cscope.files distdir: $(DISTFILES) $(am__remove_distdir) @@ -452,13 +524,10 @@ done @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ - test -d "$(distdir)/$$subdir" \ - || $(MKDIR_P) "$(distdir)/$$subdir" \ - || exit 1; \ - fi; \ - done - @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ - if test "$$subdir" = .; then :; else \ + $(am__make_dryrun) \ + || test -d "$(distdir)/$$subdir" \ + || $(MKDIR_P) "$(distdir)/$$subdir" \ + || exit 1; \ dir1=$$subdir; dir2="$(distdir)/$$subdir"; \ $(am__relativize); \ new_distdir=$$reldir; \ @@ -487,36 +556,36 @@ || chmod -R a+r "$(distdir)" dist-gzip: distdir tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz - $(am__remove_distdir) + $(am__post_remove_distdir) dist-bzip2: distdir - tardir=$(distdir) && $(am__tar) | bzip2 -9 -c >$(distdir).tar.bz2 - $(am__remove_distdir) + tardir=$(distdir) && $(am__tar) | BZIP2=$${BZIP2--9} bzip2 -c >$(distdir).tar.bz2 + $(am__post_remove_distdir) -dist-lzma: distdir - tardir=$(distdir) && $(am__tar) | lzma -9 -c >$(distdir).tar.lzma - $(am__remove_distdir) +dist-lzip: distdir + tardir=$(distdir) && $(am__tar) | lzip -c $${LZIP_OPT--9} >$(distdir).tar.lz + $(am__post_remove_distdir) dist-xz: distdir - tardir=$(distdir) && $(am__tar) | xz -c >$(distdir).tar.xz - $(am__remove_distdir) + tardir=$(distdir) && $(am__tar) | XZ_OPT=$${XZ_OPT--e} xz -c >$(distdir).tar.xz + $(am__post_remove_distdir) dist-tarZ: distdir tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z - $(am__remove_distdir) + $(am__post_remove_distdir) dist-shar: distdir shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz - $(am__remove_distdir) + $(am__post_remove_distdir) dist-zip: distdir -rm -f $(distdir).zip zip -rq $(distdir).zip $(distdir) - $(am__remove_distdir) + $(am__post_remove_distdir) -dist dist-all: distdir - tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz - $(am__remove_distdir) +dist dist-all: + $(MAKE) $(AM_MAKEFLAGS) $(DIST_TARGETS) am__post_remove_distdir='@:' + $(am__post_remove_distdir) # This target untars the dist file and tries a VPATH configuration. Then # it guarantees that the distribution is self-contained by making another @@ -527,8 +596,8 @@ GZIP=$(GZIP_ENV) gzip -dc $(distdir).tar.gz | $(am__untar) ;;\ *.tar.bz2*) \ bzip2 -dc $(distdir).tar.bz2 | $(am__untar) ;;\ - *.tar.lzma*) \ - lzma -dc $(distdir).tar.lzma | $(am__untar) ;;\ + *.tar.lz*) \ + lzip -dc $(distdir).tar.lz | $(am__untar) ;;\ *.tar.xz*) \ xz -dc $(distdir).tar.xz | $(am__untar) ;;\ *.tar.Z*) \ @@ -538,9 +607,9 @@ *.zip*) \ unzip $(distdir).zip ;;\ esac - chmod -R a-w $(distdir); chmod a+w $(distdir) - mkdir $(distdir)/_build - mkdir $(distdir)/_inst + chmod -R a-w $(distdir) + chmod u+w $(distdir) + mkdir $(distdir)/_build $(distdir)/_inst chmod a-w $(distdir) test -d $(distdir)/_build || exit 0; \ dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \ @@ -548,6 +617,7 @@ && am__cwd=`pwd` \ && $(am__cd) $(distdir)/_build \ && ../configure --srcdir=.. --prefix="$$dc_install_base" \ + $(AM_DISTCHECK_CONFIGURE_FLAGS) \ $(DISTCHECK_CONFIGURE_FLAGS) \ && $(MAKE) $(AM_MAKEFLAGS) \ && $(MAKE) $(AM_MAKEFLAGS) dvi \ @@ -571,13 +641,21 @@ && $(MAKE) $(AM_MAKEFLAGS) distcleancheck \ && cd "$$am__cwd" \ || exit 1 - $(am__remove_distdir) + $(am__post_remove_distdir) @(echo "$(distdir) archives ready for distribution: "; \ list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \ sed -e 1h -e 1s/./=/g -e 1p -e 1x -e '$$p' -e '$$x' distuninstallcheck: - @$(am__cd) '$(distuninstallcheck_dir)' \ - && test `$(distuninstallcheck_listfiles) | wc -l` -le 1 \ + @test -n '$(distuninstallcheck_dir)' || { \ + echo 'ERROR: trying to run $@ with an empty' \ + '$$(distuninstallcheck_dir)' >&2; \ + exit 1; \ + }; \ + $(am__cd) '$(distuninstallcheck_dir)' || { \ + echo 'ERROR: cannot chdir into $(distuninstallcheck_dir)' >&2; \ + exit 1; \ + }; \ + test `$(am__distuninstallcheck_listfiles) | wc -l` -eq 0 \ || { echo "ERROR: files left after uninstall:" ; \ if test -n "$(DESTDIR)"; then \ echo " (check DESTDIR support)"; \ @@ -611,10 +689,15 @@ installcheck: installcheck-recursive install-strip: - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - `test -z '$(STRIP)' || \ - echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install + if test -z '$(STRIP)'; then \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + install; \ + else \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ + fi mostlyclean-generic: clean-generic: @@ -697,25 +780,27 @@ uninstall-am: uninstall-pkgconfigDATA -.MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) ctags-recursive \ - install-am install-strip tags-recursive +.MAKE: $(am__recursive_targets) install-am install-strip + +.PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am \ + am--refresh check check-am clean clean-cscope clean-generic \ + cscope cscopelist-am ctags ctags-am dist dist-all dist-bzip2 \ + dist-gzip dist-lzip dist-shar dist-tarZ dist-xz dist-zip \ + distcheck distclean distclean-generic distclean-tags \ + distcleancheck distdir distuninstallcheck dvi dvi-am html \ + html-am info info-am install install-am install-data \ + install-data-am install-dvi install-dvi-am install-exec \ + install-exec-am install-html install-html-am install-info \ + install-info-am install-man install-pdf install-pdf-am \ + install-pkgconfigDATA install-ps install-ps-am install-strip \ + installcheck installcheck-am installdirs installdirs-am \ + maintainer-clean maintainer-clean-generic mostlyclean \ + mostlyclean-generic pdf pdf-am ps ps-am tags tags-am uninstall \ + uninstall-am uninstall-pkgconfigDATA -.PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \ - all all-am am--refresh check check-am clean clean-generic \ - ctags ctags-recursive dist dist-all dist-bzip2 dist-gzip \ - dist-lzma dist-shar dist-tarZ dist-xz dist-zip distcheck \ - distclean distclean-generic distclean-tags distcleancheck \ - distdir distuninstallcheck dvi dvi-am html html-am info \ - info-am install install-am install-data install-data-am \ - install-dvi install-dvi-am install-exec install-exec-am \ - install-html install-html-am install-info install-info-am \ - install-man install-pdf install-pdf-am install-pkgconfigDATA \ - install-ps install-ps-am install-strip installcheck \ - installcheck-am installdirs installdirs-am maintainer-clean \ - maintainer-clean-generic mostlyclean mostlyclean-generic pdf \ - pdf-am ps ps-am tags tags-recursive uninstall uninstall-am \ - uninstall-pkgconfigDATA +test: + $(MAKE) -C tests setup run # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. diff -Nru dbus-sharp-0.7.0/aclocal.m4 dbus-sharp-0.8.0/aclocal.m4 --- dbus-sharp-0.7.0/aclocal.m4 2010-09-14 09:18:27.000000000 +0000 +++ dbus-sharp-0.8.0/aclocal.m4 2013-10-07 00:49:04.000000000 +0000 @@ -1,7 +1,7 @@ -# generated automatically by aclocal 1.11.1 -*- Autoconf -*- +# generated automatically by aclocal 1.13.2 -*- Autoconf -*- + +# Copyright (C) 1996-2013 Free Software Foundation, Inc. -# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, -# 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc. # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. @@ -11,13 +11,14 @@ # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. +m4_ifndef([AC_CONFIG_MACRO_DIRS], [m4_defun([_AM_CONFIG_MACRO_DIRS], [])m4_defun([AC_CONFIG_MACRO_DIRS], [_AM_CONFIG_MACRO_DIRS($@)])]) m4_ifndef([AC_AUTOCONF_VERSION], [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl -m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.67],, -[m4_warning([this file was generated for autoconf 2.67. +m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.69],, +[m4_warning([this file was generated for autoconf 2.69. You have another version of autoconf. It may work, but is not guaranteed to. If you have problems, you may need to regenerate the build system entirely. -To do so, use the procedure documented by the package, typically `autoreconf'.])]) +To do so, use the procedure documented by the package, typically 'autoreconf'.])]) # pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*- # serial 1 (pkg-config-0.24) @@ -47,7 +48,8 @@ # ---------------------------------- AC_DEFUN([PKG_PROG_PKG_CONFIG], [m4_pattern_forbid([^_?PKG_[A-Z_]+$]) -m4_pattern_allow([^PKG_CONFIG(_PATH)?$]) +m4_pattern_allow([^PKG_CONFIG(_(PATH|LIBDIR|SYSROOT_DIR|ALLOW_SYSTEM_(CFLAGS|LIBS)))?$]) +m4_pattern_allow([^PKG_CONFIG_(DISABLE_UNINSTALLED|TOP_BUILD_DIR|DEBUG_SPEW)$]) AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility]) AC_ARG_VAR([PKG_CONFIG_PATH], [directories to add to pkg-config's search path]) AC_ARG_VAR([PKG_CONFIG_LIBDIR], [path overriding pkg-config's built-in search path]) @@ -93,7 +95,8 @@ pkg_cv_[]$1="$$1" elif test -n "$PKG_CONFIG"; then PKG_CHECK_EXISTS([$3], - [pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null`], + [pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes ], [pkg_failed=yes]) else pkg_failed=untried @@ -141,9 +144,9 @@ AC_MSG_RESULT([no]) _PKG_SHORT_ERRORS_SUPPORTED if test $_pkg_short_errors_supported = yes; then - $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "$2" 2>&1` + $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "$2" 2>&1` else - $1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors "$2" 2>&1` + $1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "$2" 2>&1` fi # Put the nasty error message in config.log where it belongs echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD @@ -167,7 +170,7 @@ _PKG_TEXT -To get pkg-config, see .])dnl +To get pkg-config, see .])[]dnl ]) else $1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS @@ -177,7 +180,62 @@ fi[]dnl ])# PKG_CHECK_MODULES -# Copyright (C) 2002, 2003, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. + +# PKG_INSTALLDIR(DIRECTORY) +# ------------------------- +# Substitutes the variable pkgconfigdir as the location where a module +# should install pkg-config .pc files. By default the directory is +# $libdir/pkgconfig, but the default can be changed by passing +# DIRECTORY. The user can override through the --with-pkgconfigdir +# parameter. +AC_DEFUN([PKG_INSTALLDIR], +[m4_pushdef([pkg_default], [m4_default([$1], ['${libdir}/pkgconfig'])]) +m4_pushdef([pkg_description], + [pkg-config installation directory @<:@]pkg_default[@:>@]) +AC_ARG_WITH([pkgconfigdir], + [AS_HELP_STRING([--with-pkgconfigdir], pkg_description)],, + [with_pkgconfigdir=]pkg_default) +AC_SUBST([pkgconfigdir], [$with_pkgconfigdir]) +m4_popdef([pkg_default]) +m4_popdef([pkg_description]) +]) dnl PKG_INSTALLDIR + + +# PKG_NOARCH_INSTALLDIR(DIRECTORY) +# ------------------------- +# Substitutes the variable noarch_pkgconfigdir as the location where a +# module should install arch-independent pkg-config .pc files. By +# default the directory is $datadir/pkgconfig, but the default can be +# changed by passing DIRECTORY. The user can override through the +# --with-noarch-pkgconfigdir parameter. +AC_DEFUN([PKG_NOARCH_INSTALLDIR], +[m4_pushdef([pkg_default], [m4_default([$1], ['${datadir}/pkgconfig'])]) +m4_pushdef([pkg_description], + [pkg-config arch-independent installation directory @<:@]pkg_default[@:>@]) +AC_ARG_WITH([noarch-pkgconfigdir], + [AS_HELP_STRING([--with-noarch-pkgconfigdir], pkg_description)],, + [with_noarch_pkgconfigdir=]pkg_default) +AC_SUBST([noarch_pkgconfigdir], [$with_noarch_pkgconfigdir]) +m4_popdef([pkg_default]) +m4_popdef([pkg_description]) +]) dnl PKG_NOARCH_INSTALLDIR + + +# PKG_CHECK_VAR(VARIABLE, MODULE, CONFIG-VARIABLE, +# [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) +# ------------------------------------------- +# Retrieves the value of the pkg-config variable for the given module. +AC_DEFUN([PKG_CHECK_VAR], +[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl +AC_ARG_VAR([$1], [value of $3 for $2, overriding pkg-config])dnl + +_PKG_CONFIG([$1], [variable="][$3]["], [$2]) +AS_VAR_COPY([$1], [pkg_cv_][$1]) + +AS_VAR_IF([$1], [""], [$5], [$4])dnl +])# PKG_CHECK_VAR + +# Copyright (C) 2002-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -189,10 +247,10 @@ # generated from the m4 files accompanying Automake X.Y. # (This private macro should not be called outside this file.) AC_DEFUN([AM_AUTOMAKE_VERSION], -[am__api_version='1.11' +[am__api_version='1.13' dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to dnl require some minimum version. Point them to the right macro. -m4_if([$1], [1.11.1], [], +m4_if([$1], [1.13.2], [], [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl ]) @@ -208,22 +266,22 @@ # Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced. # This function is AC_REQUIREd by AM_INIT_AUTOMAKE. AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION], -[AM_AUTOMAKE_VERSION([1.11.1])dnl +[AM_AUTOMAKE_VERSION([1.13.2])dnl m4_ifndef([AC_AUTOCONF_VERSION], [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl _AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))]) # AM_AUX_DIR_EXPAND -*- Autoconf -*- -# Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc. +# Copyright (C) 2001-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets -# $ac_aux_dir to `$srcdir/foo'. In other projects, it is set to -# `$srcdir', `$srcdir/..', or `$srcdir/../..'. +# $ac_aux_dir to '$srcdir/foo'. In other projects, it is set to +# '$srcdir', '$srcdir/..', or '$srcdir/../..'. # # Of course, Automake must honor this variable whenever it calls a # tool from the auxiliary directory. The problem is that $srcdir (and @@ -242,7 +300,7 @@ # # The reason of the latter failure is that $top_srcdir and $ac_aux_dir # are both prefixed by $srcdir. In an in-source build this is usually -# harmless because $srcdir is `.', but things will broke when you +# harmless because $srcdir is '.', but things will broke when you # start a VPATH build or use an absolute $srcdir. # # So we could use something similar to $top_srcdir/$ac_aux_dir/missing, @@ -268,22 +326,19 @@ # AM_CONDITIONAL -*- Autoconf -*- -# Copyright (C) 1997, 2000, 2001, 2003, 2004, 2005, 2006, 2008 -# Free Software Foundation, Inc. +# Copyright (C) 1997-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. -# serial 9 - # AM_CONDITIONAL(NAME, SHELL-CONDITION) # ------------------------------------- # Define a conditional. AC_DEFUN([AM_CONDITIONAL], -[AC_PREREQ(2.52)dnl - ifelse([$1], [TRUE], [AC_FATAL([$0: invalid condition: $1])], - [$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl +[AC_PREREQ([2.52])dnl + m4_if([$1], [TRUE], [AC_FATAL([$0: invalid condition: $1])], + [$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl AC_SUBST([$1_TRUE])dnl AC_SUBST([$1_FALSE])dnl _AM_SUBST_NOTMAKE([$1_TRUE])dnl @@ -304,15 +359,12 @@ # Do all the work for Automake. -*- Autoconf -*- -# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, -# 2005, 2006, 2008, 2009 Free Software Foundation, Inc. +# Copyright (C) 1996-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. -# serial 16 - # This macro actually does too much. Some checks are only needed if # your package does certain things. But this isn't really a big deal. @@ -328,7 +380,7 @@ # arguments mandatory, and then we can depend on a new Autoconf # release and drop the old call support. AC_DEFUN([AM_INIT_AUTOMAKE], -[AC_PREREQ([2.62])dnl +[AC_PREREQ([2.65])dnl dnl Autoconf wants to disallow AM_ names. We explicitly allow dnl the ones we care about. m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl @@ -357,31 +409,40 @@ # Define the identity of the package. dnl Distinguish between old-style and new-style calls. m4_ifval([$2], -[m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl +[AC_DIAGNOSE([obsolete], + [$0: two- and three-arguments forms are deprecated.]) +m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl AC_SUBST([PACKAGE], [$1])dnl AC_SUBST([VERSION], [$2])], [_AM_SET_OPTIONS([$1])dnl dnl Diagnose old-style AC_INIT with new-style AM_AUTOMAKE_INIT. -m4_if(m4_ifdef([AC_PACKAGE_NAME], 1)m4_ifdef([AC_PACKAGE_VERSION], 1), 11,, +m4_if( + m4_ifdef([AC_PACKAGE_NAME], [ok]):m4_ifdef([AC_PACKAGE_VERSION], [ok]), + [ok:ok],, [m4_fatal([AC_INIT should be called with package and version arguments])])dnl AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl AC_SUBST([VERSION], ['AC_PACKAGE_VERSION'])])dnl _AM_IF_OPTION([no-define],, -[AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package]) - AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package])])dnl +[AC_DEFINE_UNQUOTED([PACKAGE], ["$PACKAGE"], [Name of package]) + AC_DEFINE_UNQUOTED([VERSION], ["$VERSION"], [Version number of package])])dnl # Some tools Automake needs. AC_REQUIRE([AM_SANITY_CHECK])dnl AC_REQUIRE([AC_ARG_PROGRAM])dnl -AM_MISSING_PROG(ACLOCAL, aclocal-${am__api_version}) -AM_MISSING_PROG(AUTOCONF, autoconf) -AM_MISSING_PROG(AUTOMAKE, automake-${am__api_version}) -AM_MISSING_PROG(AUTOHEADER, autoheader) -AM_MISSING_PROG(MAKEINFO, makeinfo) +AM_MISSING_PROG([ACLOCAL], [aclocal-${am__api_version}]) +AM_MISSING_PROG([AUTOCONF], [autoconf]) +AM_MISSING_PROG([AUTOMAKE], [automake-${am__api_version}]) +AM_MISSING_PROG([AUTOHEADER], [autoheader]) +AM_MISSING_PROG([MAKEINFO], [makeinfo]) AC_REQUIRE([AM_PROG_INSTALL_SH])dnl AC_REQUIRE([AM_PROG_INSTALL_STRIP])dnl -AC_REQUIRE([AM_PROG_MKDIR_P])dnl +AC_REQUIRE([AC_PROG_MKDIR_P])dnl +# For better backward compatibility. To be removed once Automake 1.9.x +# dies out for good. For more background, see: +# +# +AC_SUBST([mkdir_p], ['$(MKDIR_P)']) # We need awk for the "check" target. The system "awk" is bad on # some platforms. AC_REQUIRE([AC_PROG_AWK])dnl @@ -392,28 +453,32 @@ [_AM_PROG_TAR([v7])])]) _AM_IF_OPTION([no-dependencies],, [AC_PROVIDE_IFELSE([AC_PROG_CC], - [_AM_DEPENDENCIES(CC)], - [define([AC_PROG_CC], - defn([AC_PROG_CC])[_AM_DEPENDENCIES(CC)])])dnl + [_AM_DEPENDENCIES([CC])], + [m4_define([AC_PROG_CC], + m4_defn([AC_PROG_CC])[_AM_DEPENDENCIES([CC])])])dnl AC_PROVIDE_IFELSE([AC_PROG_CXX], - [_AM_DEPENDENCIES(CXX)], - [define([AC_PROG_CXX], - defn([AC_PROG_CXX])[_AM_DEPENDENCIES(CXX)])])dnl + [_AM_DEPENDENCIES([CXX])], + [m4_define([AC_PROG_CXX], + m4_defn([AC_PROG_CXX])[_AM_DEPENDENCIES([CXX])])])dnl AC_PROVIDE_IFELSE([AC_PROG_OBJC], - [_AM_DEPENDENCIES(OBJC)], - [define([AC_PROG_OBJC], - defn([AC_PROG_OBJC])[_AM_DEPENDENCIES(OBJC)])])dnl + [_AM_DEPENDENCIES([OBJC])], + [m4_define([AC_PROG_OBJC], + m4_defn([AC_PROG_OBJC])[_AM_DEPENDENCIES([OBJC])])])dnl +AC_PROVIDE_IFELSE([AC_PROG_OBJCXX], + [_AM_DEPENDENCIES([OBJCXX])], + [m4_define([AC_PROG_OBJCXX], + m4_defn([AC_PROG_OBJCXX])[_AM_DEPENDENCIES([OBJCXX])])])dnl ]) -_AM_IF_OPTION([silent-rules], [AC_REQUIRE([AM_SILENT_RULES])])dnl -dnl The `parallel-tests' driver may need to know about EXEEXT, so add the -dnl `am__EXEEXT' conditional if _AM_COMPILER_EXEEXT was seen. This macro -dnl is hooked onto _AC_COMPILER_EXEEXT early, see below. +AC_REQUIRE([AM_SILENT_RULES])dnl +dnl The testsuite driver may need to know about EXEEXT, so add the +dnl 'am__EXEEXT' conditional if _AM_COMPILER_EXEEXT was seen. This +dnl macro is hooked onto _AC_COMPILER_EXEEXT early, see below. AC_CONFIG_COMMANDS_PRE(dnl [m4_provide_if([_AM_COMPILER_EXEEXT], [AM_CONDITIONAL([am__EXEEXT], [test -n "$EXEEXT"])])])dnl ]) -dnl Hook into `_AC_COMPILER_EXEEXT' early to learn its expansion. Do not +dnl Hook into '_AC_COMPILER_EXEEXT' early to learn its expansion. Do not dnl add the conditional right here, as _AC_COMPILER_EXEEXT may be further dnl mangled by Autoconf and run in a shell conditional statement. m4_define([_AC_COMPILER_EXEEXT], @@ -441,7 +506,7 @@ done echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count]) -# Copyright (C) 2001, 2003, 2005, 2008 Free Software Foundation, Inc. +# Copyright (C) 2001-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -460,16 +525,14 @@ install_sh="\${SHELL} $am_aux_dir/install-sh" esac fi -AC_SUBST(install_sh)]) +AC_SUBST([install_sh])]) -# Copyright (C) 2003, 2005 Free Software Foundation, Inc. +# Copyright (C) 2003-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. -# serial 2 - # Check whether the underlying file-system supports filenames # with a leading dot. For instance MS-DOS doesn't. AC_DEFUN([AM_SET_LEADING_DOT], @@ -486,20 +549,17 @@ # Add --enable-maintainer-mode option to configure. -*- Autoconf -*- # From Jim Meyering -# Copyright (C) 1996, 1998, 2000, 2001, 2002, 2003, 2004, 2005, 2008 -# Free Software Foundation, Inc. +# Copyright (C) 1996-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. -# serial 5 - # AM_MAINTAINER_MODE([DEFAULT-MODE]) # ---------------------------------- # Control maintainer-specific portions of Makefiles. -# Default is to disable them, unless `enable' is passed literally. -# For symmetry, `disable' may be passed as well. Anyway, the user +# Default is to disable them, unless 'enable' is passed literally. +# For symmetry, 'disable' may be passed as well. Anyway, the user # can override the default with the --enable/--disable switch. AC_DEFUN([AM_MAINTAINER_MODE], [m4_case(m4_default([$1], [disable]), @@ -507,13 +567,14 @@ [disable], [m4_define([am_maintainer_other], [enable])], [m4_define([am_maintainer_other], [enable]) m4_warn([syntax], [unexpected argument to AM@&t@_MAINTAINER_MODE: $1])]) -AC_MSG_CHECKING([whether to am_maintainer_other maintainer-specific portions of Makefiles]) +AC_MSG_CHECKING([whether to enable maintainer-specific portions of Makefiles]) dnl maintainer-mode's default is 'disable' unless 'enable' is passed AC_ARG_ENABLE([maintainer-mode], -[ --][am_maintainer_other][-maintainer-mode am_maintainer_other make rules and dependencies not useful - (and sometimes confusing) to the casual installer], - [USE_MAINTAINER_MODE=$enableval], - [USE_MAINTAINER_MODE=]m4_if(am_maintainer_other, [enable], [no], [yes])) + [AS_HELP_STRING([--]am_maintainer_other[-maintainer-mode], + am_maintainer_other[ make rules and dependencies not useful + (and sometimes confusing) to the casual installer])], + [USE_MAINTAINER_MODE=$enableval], + [USE_MAINTAINER_MODE=]m4_if(am_maintainer_other, [enable], [no], [yes])) AC_MSG_RESULT([$USE_MAINTAINER_MODE]) AM_CONDITIONAL([MAINTAINER_MODE], [test $USE_MAINTAINER_MODE = yes]) MAINT=$MAINTAINER_MODE_TRUE @@ -521,19 +582,14 @@ ] ) -AU_DEFUN([jm_MAINTAINER_MODE], [AM_MAINTAINER_MODE]) - # Fake the existence of programs that GNU maintainers use. -*- Autoconf -*- -# Copyright (C) 1997, 1999, 2000, 2001, 2003, 2004, 2005, 2008 -# Free Software Foundation, Inc. +# Copyright (C) 1997-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. -# serial 6 - # AM_MISSING_PROG(NAME, PROGRAM) # ------------------------------ AC_DEFUN([AM_MISSING_PROG], @@ -541,11 +597,10 @@ $1=${$1-"${am_missing_run}$2"} AC_SUBST($1)]) - # AM_MISSING_HAS_RUN # ------------------ -# Define MISSING if not defined so far and test if it supports --run. -# If it does, set am_missing_run to use it, otherwise, to nothing. +# Define MISSING if not defined so far and test if it is modern enough. +# If it is, set am_missing_run to use it, otherwise, to nothing. AC_DEFUN([AM_MISSING_HAS_RUN], [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl AC_REQUIRE_AUX_FILE([missing])dnl @@ -558,63 +613,35 @@ esac fi # Use eval to expand $SHELL -if eval "$MISSING --run true"; then - am_missing_run="$MISSING --run " +if eval "$MISSING --is-lightweight"; then + am_missing_run="$MISSING " else am_missing_run= - AC_MSG_WARN([`missing' script is too old or missing]) + AC_MSG_WARN(['missing' script is too old or missing]) fi ]) -# Copyright (C) 2003, 2004, 2005, 2006 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# AM_PROG_MKDIR_P -# --------------- -# Check for `mkdir -p'. -AC_DEFUN([AM_PROG_MKDIR_P], -[AC_PREREQ([2.60])dnl -AC_REQUIRE([AC_PROG_MKDIR_P])dnl -dnl Automake 1.8 to 1.9.6 used to define mkdir_p. We now use MKDIR_P, -dnl while keeping a definition of mkdir_p for backward compatibility. -dnl @MKDIR_P@ is magic: AC_OUTPUT adjusts its value for each Makefile. -dnl However we cannot define mkdir_p as $(MKDIR_P) for the sake of -dnl Makefile.ins that do not define MKDIR_P, so we do our own -dnl adjustment using top_builddir (which is defined more often than -dnl MKDIR_P). -AC_SUBST([mkdir_p], ["$MKDIR_P"])dnl -case $mkdir_p in - [[\\/$]]* | ?:[[\\/]]*) ;; - */*) mkdir_p="\$(top_builddir)/$mkdir_p" ;; -esac -]) - # Helper functions for option handling. -*- Autoconf -*- -# Copyright (C) 2001, 2002, 2003, 2005, 2008 Free Software Foundation, Inc. +# Copyright (C) 2001-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. -# serial 4 - # _AM_MANGLE_OPTION(NAME) # ----------------------- AC_DEFUN([_AM_MANGLE_OPTION], [[_AM_OPTION_]m4_bpatsubst($1, [[^a-zA-Z0-9_]], [_])]) # _AM_SET_OPTION(NAME) -# ------------------------------ +# -------------------- # Set option NAME. Presently that only means defining a flag for this option. AC_DEFUN([_AM_SET_OPTION], -[m4_define(_AM_MANGLE_OPTION([$1]), 1)]) +[m4_define(_AM_MANGLE_OPTION([$1]), [1])]) # _AM_SET_OPTIONS(OPTIONS) -# ---------------------------------- +# ------------------------ # OPTIONS is a space-separated list of Automake options. AC_DEFUN([_AM_SET_OPTIONS], [m4_foreach_w([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])]) @@ -627,22 +654,16 @@ # Check to make sure that the build environment is sane. -*- Autoconf -*- -# Copyright (C) 1996, 1997, 2000, 2001, 2003, 2005, 2008 -# Free Software Foundation, Inc. +# Copyright (C) 1996-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. -# serial 5 - # AM_SANITY_CHECK # --------------- AC_DEFUN([AM_SANITY_CHECK], [AC_MSG_CHECKING([whether build environment is sane]) -# Just in case -sleep 1 -echo timestamp > conftest.file # Reject unsafe characters in $srcdir or the absolute working directory # name. Accept space and tab only in the latter. am_lf=' @@ -653,32 +674,40 @@ esac case $srcdir in *[[\\\"\#\$\&\'\`$am_lf\ \ ]]*) - AC_MSG_ERROR([unsafe srcdir value: `$srcdir']);; + AC_MSG_ERROR([unsafe srcdir value: '$srcdir']);; esac -# Do `set' in a subshell so we don't clobber the current shell's +# Do 'set' in a subshell so we don't clobber the current shell's # arguments. Must try -L first in case configure is actually a # symlink; some systems play weird games with the mod time of symlinks # (eg FreeBSD returns the mod time of the symlink's containing # directory). if ( - set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null` - if test "$[*]" = "X"; then - # -L didn't work. - set X `ls -t "$srcdir/configure" conftest.file` - fi - rm -f conftest.file - if test "$[*]" != "X $srcdir/configure conftest.file" \ - && test "$[*]" != "X conftest.file $srcdir/configure"; then - - # If neither matched, then we have a broken ls. This can happen - # if, for instance, CONFIG_SHELL is bash and it inherits a - # broken ls alias from the environment. This has actually - # happened. Such a system could not be considered "sane". - AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken -alias in your environment]) - fi - + am_has_slept=no + for am_try in 1 2; do + echo "timestamp, slept: $am_has_slept" > conftest.file + set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null` + if test "$[*]" = "X"; then + # -L didn't work. + set X `ls -t "$srcdir/configure" conftest.file` + fi + if test "$[*]" != "X $srcdir/configure conftest.file" \ + && test "$[*]" != "X conftest.file $srcdir/configure"; then + + # If neither matched, then we have a broken ls. This can happen + # if, for instance, CONFIG_SHELL is bash and it inherits a + # broken ls alias from the environment. This has actually + # happened. Such a system could not be considered "sane". + AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken + alias in your environment]) + fi + if test "$[2]" = conftest.file || test $am_try -eq 2; then + break + fi + # Just in case. + sleep 1 + am_has_slept=yes + done test "$[2]" = conftest.file ) then @@ -688,9 +717,85 @@ AC_MSG_ERROR([newly created file is older than distributed files! Check your system clock]) fi -AC_MSG_RESULT(yes)]) +AC_MSG_RESULT([yes]) +# If we didn't sleep, we still need to ensure time stamps of config.status and +# generated files are strictly newer. +am_sleep_pid= +if grep 'slept: no' conftest.file >/dev/null 2>&1; then + ( sleep 1 ) & + am_sleep_pid=$! +fi +AC_CONFIG_COMMANDS_PRE( + [AC_MSG_CHECKING([that generated files are newer than configure]) + if test -n "$am_sleep_pid"; then + # Hide warnings about reused PIDs. + wait $am_sleep_pid 2>/dev/null + fi + AC_MSG_RESULT([done])]) +rm -f conftest.file +]) + +# Copyright (C) 2009-2013 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# AM_SILENT_RULES([DEFAULT]) +# -------------------------- +# Enable less verbose build rules; with the default set to DEFAULT +# ("yes" being less verbose, "no" or empty being verbose). +AC_DEFUN([AM_SILENT_RULES], +[AC_ARG_ENABLE([silent-rules], [dnl +AS_HELP_STRING( + [--enable-silent-rules], + [less verbose build output (undo: "make V=1")]) +AS_HELP_STRING( + [--disable-silent-rules], + [verbose build output (undo: "make V=0")])dnl +]) +case $enable_silent_rules in @%:@ ((( + yes) AM_DEFAULT_VERBOSITY=0;; + no) AM_DEFAULT_VERBOSITY=1;; + *) AM_DEFAULT_VERBOSITY=m4_if([$1], [yes], [0], [1]);; +esac +dnl +dnl A few 'make' implementations (e.g., NonStop OS and NextStep) +dnl do not support nested variable expansions. +dnl See automake bug#9928 and bug#10237. +am_make=${MAKE-make} +AC_CACHE_CHECK([whether $am_make supports nested variables], + [am_cv_make_support_nested_variables], + [if AS_ECHO([['TRUE=$(BAR$(V)) +BAR0=false +BAR1=true +V=1 +am__doit: + @$(TRUE) +.PHONY: am__doit']]) | $am_make -f - >/dev/null 2>&1; then + am_cv_make_support_nested_variables=yes +else + am_cv_make_support_nested_variables=no +fi]) +if test $am_cv_make_support_nested_variables = yes; then + dnl Using '$V' instead of '$(V)' breaks IRIX make. + AM_V='$(V)' + AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)' +else + AM_V=$AM_DEFAULT_VERBOSITY + AM_DEFAULT_V=$AM_DEFAULT_VERBOSITY +fi +AC_SUBST([AM_V])dnl +AM_SUBST_NOTMAKE([AM_V])dnl +AC_SUBST([AM_DEFAULT_V])dnl +AM_SUBST_NOTMAKE([AM_DEFAULT_V])dnl +AC_SUBST([AM_DEFAULT_VERBOSITY])dnl +AM_BACKSLASH='\' +AC_SUBST([AM_BACKSLASH])dnl +_AM_SUBST_NOTMAKE([AM_BACKSLASH])dnl +]) -# Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc. +# Copyright (C) 2001-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -698,34 +803,32 @@ # AM_PROG_INSTALL_STRIP # --------------------- -# One issue with vendor `install' (even GNU) is that you can't +# One issue with vendor 'install' (even GNU) is that you can't # specify the program used to strip binaries. This is especially # annoying in cross-compiling environments, where the build's strip # is unlikely to handle the host's binaries. # Fortunately install-sh will honor a STRIPPROG variable, so we -# always use install-sh in `make install-strip', and initialize +# always use install-sh in "make install-strip", and initialize # STRIPPROG with the value of the STRIP variable (set by the user). AC_DEFUN([AM_PROG_INSTALL_STRIP], [AC_REQUIRE([AM_PROG_INSTALL_SH])dnl -# Installed binaries are usually stripped using `strip' when the user -# run `make install-strip'. However `strip' might not be the right +# Installed binaries are usually stripped using 'strip' when the user +# run "make install-strip". However 'strip' might not be the right # tool to use in cross-compilation environments, therefore Automake -# will honor the `STRIP' environment variable to overrule this program. -dnl Don't test for $cross_compiling = yes, because it might be `maybe'. +# will honor the 'STRIP' environment variable to overrule this program. +dnl Don't test for $cross_compiling = yes, because it might be 'maybe'. if test "$cross_compiling" != no; then AC_CHECK_TOOL([STRIP], [strip], :) fi INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" AC_SUBST([INSTALL_STRIP_PROGRAM])]) -# Copyright (C) 2006, 2008 Free Software Foundation, Inc. +# Copyright (C) 2006-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. -# serial 2 - # _AM_SUBST_NOTMAKE(VARIABLE) # --------------------------- # Prevent Automake from outputting VARIABLE = @VARIABLE@ in Makefile.in. @@ -733,24 +836,22 @@ AC_DEFUN([_AM_SUBST_NOTMAKE]) # AM_SUBST_NOTMAKE(VARIABLE) -# --------------------------- +# -------------------------- # Public sister of _AM_SUBST_NOTMAKE. AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)]) # Check how to create a tarball. -*- Autoconf -*- -# Copyright (C) 2004, 2005 Free Software Foundation, Inc. +# Copyright (C) 2004-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. -# serial 2 - # _AM_PROG_TAR(FORMAT) # -------------------- # Check how to create a tarball in format FORMAT. -# FORMAT should be one of `v7', `ustar', or `pax'. +# FORMAT should be one of 'v7', 'ustar', or 'pax'. # # Substitute a variable $(am__tar) that is a command # writing to stdout a FORMAT-tarball containing the directory @@ -760,75 +861,114 @@ # Substitute a variable $(am__untar) that extract such # a tarball read from stdin. # $(am__untar) < result.tar +# AC_DEFUN([_AM_PROG_TAR], -[# Always define AMTAR for backward compatibility. -AM_MISSING_PROG([AMTAR], [tar]) -m4_if([$1], [v7], - [am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -'], - [m4_case([$1], [ustar],, [pax],, - [m4_fatal([Unknown tar format])]) -AC_MSG_CHECKING([how to create a $1 tar archive]) -# Loop over all known methods to create a tar archive until one works. +[# Always define AMTAR for backward compatibility. Yes, it's still used +# in the wild :-( We should find a proper way to deprecate it ... +AC_SUBST([AMTAR], ['$${TAR-tar}']) + +# We'll loop over all known methods to create a tar archive until one works. _am_tools='gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none' -_am_tools=${am_cv_prog_tar_$1-$_am_tools} -# Do not fold the above two line into one, because Tru64 sh and -# Solaris sh will not grok spaces in the rhs of `-'. -for _am_tool in $_am_tools -do - case $_am_tool in - gnutar) - for _am_tar in tar gnutar gtar; - do - AM_RUN_LOG([$_am_tar --version]) && break - done - am__tar="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$$tardir"' - am__tar_="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$tardir"' - am__untar="$_am_tar -xf -" - ;; - plaintar) - # Must skip GNU tar: if it does not support --format= it doesn't create - # ustar tarball either. - (tar --version) >/dev/null 2>&1 && continue - am__tar='tar chf - "$$tardir"' - am__tar_='tar chf - "$tardir"' - am__untar='tar xf -' - ;; - pax) - am__tar='pax -L -x $1 -w "$$tardir"' - am__tar_='pax -L -x $1 -w "$tardir"' - am__untar='pax -r' - ;; - cpio) - am__tar='find "$$tardir" -print | cpio -o -H $1 -L' - am__tar_='find "$tardir" -print | cpio -o -H $1 -L' - am__untar='cpio -i -H $1 -d' - ;; - none) - am__tar=false - am__tar_=false - am__untar=false - ;; - esac - # If the value was cached, stop now. We just wanted to have am__tar - # and am__untar set. - test -n "${am_cv_prog_tar_$1}" && break +m4_if([$1], [v7], + [am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -'], - # tar/untar a dummy directory, and stop if the command works + [m4_case([$1], + [ustar], + [# The POSIX 1988 'ustar' format is defined with fixed-size fields. + # There is notably a 21 bits limit for the UID and the GID. In fact, + # the 'pax' utility can hang on bigger UID/GID (see automake bug#8343 + # and bug#13588). + am_max_uid=2097151 # 2^21 - 1 + am_max_gid=$am_max_uid + # The $UID and $GID variables are not portable, so we need to resort + # to the POSIX-mandated id(1) utility. Errors in the 'id' calls + # below are definitely unexpected, so allow the users to see them + # (that is, avoid stderr redirection). + am_uid=`id -u || echo unknown` + am_gid=`id -g || echo unknown` + AC_MSG_CHECKING([whether UID '$am_uid' is supported by ustar format]) + if test $am_uid -le $am_max_uid; then + AC_MSG_RESULT([yes]) + else + AC_MSG_RESULT([no]) + _am_tools=none + fi + AC_MSG_CHECKING([whether GID '$am_gid' is supported by ustar format]) + if test $am_gid -le $am_max_gid; then + AC_MSG_RESULT([yes]) + else + AC_MSG_RESULT([no]) + _am_tools=none + fi], + + [pax], + [], + + [m4_fatal([Unknown tar format])]) + + AC_MSG_CHECKING([how to create a $1 tar archive]) + + # Go ahead even if we have the value already cached. We do so because we + # need to set the values for the 'am__tar' and 'am__untar' variables. + _am_tools=${am_cv_prog_tar_$1-$_am_tools} + + for _am_tool in $_am_tools; do + case $_am_tool in + gnutar) + for _am_tar in tar gnutar gtar; do + AM_RUN_LOG([$_am_tar --version]) && break + done + am__tar="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$$tardir"' + am__tar_="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$tardir"' + am__untar="$_am_tar -xf -" + ;; + plaintar) + # Must skip GNU tar: if it does not support --format= it doesn't create + # ustar tarball either. + (tar --version) >/dev/null 2>&1 && continue + am__tar='tar chf - "$$tardir"' + am__tar_='tar chf - "$tardir"' + am__untar='tar xf -' + ;; + pax) + am__tar='pax -L -x $1 -w "$$tardir"' + am__tar_='pax -L -x $1 -w "$tardir"' + am__untar='pax -r' + ;; + cpio) + am__tar='find "$$tardir" -print | cpio -o -H $1 -L' + am__tar_='find "$tardir" -print | cpio -o -H $1 -L' + am__untar='cpio -i -H $1 -d' + ;; + none) + am__tar=false + am__tar_=false + am__untar=false + ;; + esac + + # If the value was cached, stop now. We just wanted to have am__tar + # and am__untar set. + test -n "${am_cv_prog_tar_$1}" && break + + # tar/untar a dummy directory, and stop if the command works. + rm -rf conftest.dir + mkdir conftest.dir + echo GrepMe > conftest.dir/file + AM_RUN_LOG([tardir=conftest.dir && eval $am__tar_ >conftest.tar]) + rm -rf conftest.dir + if test -s conftest.tar; then + AM_RUN_LOG([$am__untar /dev/null 2>&1 && break + fi + done rm -rf conftest.dir - mkdir conftest.dir - echo GrepMe > conftest.dir/file - AM_RUN_LOG([tardir=conftest.dir && eval $am__tar_ >conftest.tar]) - rm -rf conftest.dir - if test -s conftest.tar; then - AM_RUN_LOG([$am__untar /dev/null 2>&1 && break - fi -done -rm -rf conftest.dir -AC_CACHE_VAL([am_cv_prog_tar_$1], [am_cv_prog_tar_$1=$_am_tool]) -AC_MSG_RESULT([$am_cv_prog_tar_$1])]) + AC_CACHE_VAL([am_cv_prog_tar_$1], [am_cv_prog_tar_$1=$_am_tool]) + AC_MSG_RESULT([$am_cv_prog_tar_$1])]) + AC_SUBST([am__tar]) AC_SUBST([am__untar]) ]) # _AM_PROG_TAR diff -Nru dbus-sharp-0.7.0/configure dbus-sharp-0.8.0/configure --- dbus-sharp-0.7.0/configure 2010-09-14 09:18:28.000000000 +0000 +++ dbus-sharp-0.8.0/configure 2013-10-07 00:49:05.000000000 +0000 @@ -1,11 +1,9 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.67. +# Generated by GNU Autoconf 2.69 for dbus-sharp 0.8.0. # # -# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, -# 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software -# Foundation, Inc. +# Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc. # # # This configure script is free software; the Free Software Foundation @@ -89,6 +87,7 @@ IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. +as_myself= case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR @@ -133,6 +132,31 @@ # CDPATH. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH +# Use a proper internal environment variable to ensure we don't fall + # into an infinite loop, continuously re-executing ourselves. + if test x"${_as_can_reexec}" != xno && test "x$CONFIG_SHELL" != x; then + _as_can_reexec=no; export _as_can_reexec; + # We cannot yet assume a decent shell, so we have to provide a +# neutralization value for shells without unset; and this also +# works around shells that cannot unset nonexistent variables. +# Preserve -v and -x to the replacement shell. +BASH_ENV=/dev/null +ENV=/dev/null +(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV +case $- in # (((( + *v*x* | *x*v* ) as_opts=-vx ;; + *v* ) as_opts=-v ;; + *x* ) as_opts=-x ;; + * ) as_opts= ;; +esac +exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} +# Admittedly, this is quite paranoid, since all the known shells bail +# out after a failed `exec'. +$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 +as_fn_exit 255 + fi + # We don't want this to propagate to other subprocesses. + { _as_can_reexec=; unset _as_can_reexec;} if test "x$CONFIG_SHELL" = x; then as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then : emulate sh @@ -166,7 +190,8 @@ else exitcode=1; echo positional parameters were not saved. fi -test x\$exitcode = x0 || exit 1" +test x\$exitcode = x0 || exit 1 +test -x / || exit 1" as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" && @@ -210,14 +235,25 @@ if test "x$CONFIG_SHELL" != x; then : - # We cannot yet assume a decent shell, so we have to provide a - # neutralization value for shells without unset; and this also - # works around shells that cannot unset nonexistent variables. - BASH_ENV=/dev/null - ENV=/dev/null - (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV - export CONFIG_SHELL - exec "$CONFIG_SHELL" "$as_myself" ${1+"$@"} + export CONFIG_SHELL + # We cannot yet assume a decent shell, so we have to provide a +# neutralization value for shells without unset; and this also +# works around shells that cannot unset nonexistent variables. +# Preserve -v and -x to the replacement shell. +BASH_ENV=/dev/null +ENV=/dev/null +(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV +case $- in # (((( + *v*x* | *x*v* ) as_opts=-vx ;; + *v* ) as_opts=-v ;; + *x* ) as_opts=-x ;; + * ) as_opts= ;; +esac +exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} +# Admittedly, this is quite paranoid, since all the known shells bail +# out after a failed `exec'. +$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 +exit 255 fi if test x$as_have_required = xno; then : @@ -319,6 +355,14 @@ } # as_fn_mkdir_p + +# as_fn_executable_p FILE +# ----------------------- +# Test if FILE is an executable regular file. +as_fn_executable_p () +{ + test -f "$1" && test -x "$1" +} # as_fn_executable_p # as_fn_append VAR VALUE # ---------------------- # Append the text in VALUE to the end of the definition contained in VAR. Take @@ -440,6 +484,10 @@ chmod +x "$as_me.lineno" || { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; } + # If we had to re-execute with $CONFIG_SHELL, we're ensured to have + # already done that, so ensure we don't try to do so again and fall + # in an infinite loop. This has already happened in practice. + _as_can_reexec=no; export _as_can_reexec # Don't try to exec as it changes $[0], causing all sort of problems # (the dirname of $[0] is not the place where we might find the # original and so on. Autoconf is especially sensitive to this). @@ -474,16 +522,16 @@ # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. - # In both cases, we have to default to `cp -p'. + # In both cases, we have to default to `cp -pR'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || - as_ln_s='cp -p' + as_ln_s='cp -pR' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else - as_ln_s='cp -p' + as_ln_s='cp -pR' fi else - as_ln_s='cp -p' + as_ln_s='cp -pR' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null @@ -495,28 +543,8 @@ as_mkdir_p=false fi -if test -x / >/dev/null 2>&1; then - as_test_x='test -x' -else - if ls -dL / >/dev/null 2>&1; then - as_ls_L_option=L - else - as_ls_L_option= - fi - as_test_x=' - eval sh -c '\'' - if test -d "$1"; then - test -d "$1/."; - else - case $1 in #( - -*)set "./$1";; - esac; - case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #(( - ???[sx]*):;;*)false;;esac;fi - '\'' sh - ' -fi -as_executable_p=$as_test_x +as_test_x='test -x' +as_executable_p=as_fn_executable_p # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" @@ -546,16 +574,21 @@ MAKEFLAGS= # Identity of this package. -PACKAGE_NAME= -PACKAGE_TARNAME= -PACKAGE_VERSION= -PACKAGE_STRING= -PACKAGE_BUGREPORT= -PACKAGE_URL= +PACKAGE_NAME='dbus-sharp' +PACKAGE_TARNAME='dbus-sharp' +PACKAGE_VERSION='0.8.0' +PACKAGE_STRING='dbus-sharp 0.8.0' +PACKAGE_BUGREPORT='' +PACKAGE_URL='' ac_unique_file="src/DBus.cs" ac_subst_vars='LTLIBOBJS LIBOBJS +NUNIT_LIBS +NUNIT_CFLAGS +ENABLE_TESTS_FALSE +ENABLE_TESTS_TRUE +XBUILD GACUTIL GMCS MONO_LIBS @@ -563,9 +596,14 @@ PKG_CONFIG_LIBDIR PKG_CONFIG_PATH PKG_CONFIG +API_VERSION MAINT MAINTAINER_MODE_FALSE MAINTAINER_MODE_TRUE +AM_BACKSLASH +AM_DEFAULT_VERBOSITY +AM_DEFAULT_V +AM_V am__untar am__tar AMTAR @@ -582,14 +620,13 @@ AUTOMAKE AUTOCONF ACLOCAL +VERSION PACKAGE CYGPATH_W am__isrc INSTALL_DATA INSTALL_SCRIPT INSTALL_PROGRAM -VERSION -API_VERSION target_alias host_alias build_alias @@ -631,7 +668,9 @@ ac_subst_files='' ac_user_opts=' enable_option_checking +enable_silent_rules enable_maintainer_mode +enable_tests ' ac_precious_vars='build_alias host_alias @@ -640,7 +679,9 @@ PKG_CONFIG_PATH PKG_CONFIG_LIBDIR MONO_CFLAGS -MONO_LIBS' +MONO_LIBS +NUNIT_CFLAGS +NUNIT_LIBS' # Initialize some variables set by options. @@ -681,7 +722,7 @@ localstatedir='${prefix}/var' includedir='${prefix}/include' oldincludedir='/usr/include' -docdir='${datarootdir}/doc/${PACKAGE}' +docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' infodir='${datarootdir}/info' htmldir='${docdir}' dvidir='${docdir}' @@ -1045,7 +1086,7 @@ $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2 expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2 - : ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option} + : "${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}" ;; esac @@ -1096,8 +1137,6 @@ if test "x$host_alias" != x; then if test "x$build_alias" = x; then cross_compiling=maybe - $as_echo "$as_me: WARNING: if you wanted to set the --build type, don't use --host. - If a cross compiler is detected then cross compile mode will be used" >&2 elif test "x$build_alias" != "x$host_alias"; then cross_compiling=yes fi @@ -1183,7 +1222,7 @@ # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures this package to adapt to many kinds of systems. +\`configure' configures dbus-sharp 0.8.0 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1231,7 +1270,7 @@ --infodir=DIR info documentation [DATAROOTDIR/info] --localedir=DIR locale-dependent data [DATAROOTDIR/locale] --mandir=DIR man documentation [DATAROOTDIR/man] - --docdir=DIR documentation root [DATAROOTDIR/doc/PACKAGE] + --docdir=DIR documentation root [DATAROOTDIR/doc/dbus-sharp] --htmldir=DIR html documentation [DOCDIR] --dvidir=DIR dvi documentation [DOCDIR] --pdfdir=DIR pdf documentation [DOCDIR] @@ -1248,15 +1287,21 @@ fi if test -n "$ac_init_help"; then - + case $ac_init_help in + short | recursive ) echo "Configuration of dbus-sharp 0.8.0:";; + esac cat <<\_ACEOF Optional Features: --disable-option-checking ignore unrecognized --enable/--with options --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) --enable-FEATURE[=ARG] include FEATURE [ARG=yes] - --enable-maintainer-mode enable make rules and dependencies not useful - (and sometimes confusing) to the casual installer + --enable-silent-rules less verbose build output (undo: "make V=1") + --disable-silent-rules verbose build output (undo: "make V=0") + --enable-maintainer-mode + enable make rules and dependencies not useful (and + sometimes confusing) to the casual installer + --enable-tests Enable NUnit tests Some influential environment variables: PKG_CONFIG path to pkg-config utility @@ -1266,6 +1311,9 @@ path overriding pkg-config's built-in search path MONO_CFLAGS C compiler flags for MONO, overriding pkg-config MONO_LIBS linker flags for MONO, overriding pkg-config + NUNIT_CFLAGS + C compiler flags for NUNIT, overriding pkg-config + NUNIT_LIBS linker flags for NUNIT, overriding pkg-config Use these variables to override the choices made by `configure' or to help it to find libraries and programs with nonstandard names/locations. @@ -1333,10 +1381,10 @@ test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -configure -generated by GNU Autoconf 2.67 +dbus-sharp configure 0.8.0 +generated by GNU Autoconf 2.69 -Copyright (C) 2010 Free Software Foundation, Inc. +Copyright (C) 2012 Free Software Foundation, Inc. This configure script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. _ACEOF @@ -1350,8 +1398,8 @@ This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by $as_me, which was -generated by GNU Autoconf 2.67. Invocation command line was +It was created by dbus-sharp $as_me 0.8.0, which was +generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -1699,16 +1747,7 @@ - - -API_VERSION=1.0 -#VERSION=$API_VERSION.0 -VERSION=0.7.0 - - - - -am__api_version='1.11' +am__api_version='1.13' ac_aux_dir= for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do @@ -1756,7 +1795,7 @@ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a BSD-compatible install" >&5 $as_echo_n "checking for a BSD-compatible install... " >&6; } if test -z "$INSTALL"; then -if test "${ac_cv_path_install+set}" = set; then : +if ${ac_cv_path_install+:} false; then : $as_echo_n "(cached) " >&6 else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR @@ -1776,7 +1815,7 @@ # by default. for ac_prog in ginstall scoinst install; do for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_prog$ac_exec_ext"; then if test $ac_prog = install && grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then # AIX install. It has an incompatible calling convention. @@ -1834,9 +1873,6 @@ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether build environment is sane" >&5 $as_echo_n "checking whether build environment is sane... " >&6; } -# Just in case -sleep 1 -echo timestamp > conftest.file # Reject unsafe characters in $srcdir or the absolute working directory # name. Accept space and tab only in the latter. am_lf=' @@ -1847,32 +1883,40 @@ esac case $srcdir in *[\\\"\#\$\&\'\`$am_lf\ \ ]*) - as_fn_error $? "unsafe srcdir value: \`$srcdir'" "$LINENO" 5;; + as_fn_error $? "unsafe srcdir value: '$srcdir'" "$LINENO" 5;; esac -# Do `set' in a subshell so we don't clobber the current shell's +# Do 'set' in a subshell so we don't clobber the current shell's # arguments. Must try -L first in case configure is actually a # symlink; some systems play weird games with the mod time of symlinks # (eg FreeBSD returns the mod time of the symlink's containing # directory). if ( - set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null` - if test "$*" = "X"; then - # -L didn't work. - set X `ls -t "$srcdir/configure" conftest.file` - fi - rm -f conftest.file - if test "$*" != "X $srcdir/configure conftest.file" \ - && test "$*" != "X conftest.file $srcdir/configure"; then - - # If neither matched, then we have a broken ls. This can happen - # if, for instance, CONFIG_SHELL is bash and it inherits a - # broken ls alias from the environment. This has actually - # happened. Such a system could not be considered "sane". - as_fn_error $? "ls -t appears to fail. Make sure there is not a broken -alias in your environment" "$LINENO" 5 - fi - + am_has_slept=no + for am_try in 1 2; do + echo "timestamp, slept: $am_has_slept" > conftest.file + set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null` + if test "$*" = "X"; then + # -L didn't work. + set X `ls -t "$srcdir/configure" conftest.file` + fi + if test "$*" != "X $srcdir/configure conftest.file" \ + && test "$*" != "X conftest.file $srcdir/configure"; then + + # If neither matched, then we have a broken ls. This can happen + # if, for instance, CONFIG_SHELL is bash and it inherits a + # broken ls alias from the environment. This has actually + # happened. Such a system could not be considered "sane". + as_fn_error $? "ls -t appears to fail. Make sure there is not a broken + alias in your environment" "$LINENO" 5 + fi + if test "$2" = conftest.file || test $am_try -eq 2; then + break + fi + # Just in case. + sleep 1 + am_has_slept=yes + done test "$2" = conftest.file ) then @@ -1884,6 +1928,16 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } +# If we didn't sleep, we still need to ensure time stamps of config.status and +# generated files are strictly newer. +am_sleep_pid= +if grep 'slept: no' conftest.file >/dev/null 2>&1; then + ( sleep 1 ) & + am_sleep_pid=$! +fi + +rm -f conftest.file + test "$program_prefix" != NONE && program_transform_name="s&^&$program_prefix&;$program_transform_name" # Use a double $ so make ignores it. @@ -1906,12 +1960,12 @@ esac fi # Use eval to expand $SHELL -if eval "$MISSING --run true"; then - am_missing_run="$MISSING --run " +if eval "$MISSING --is-lightweight"; then + am_missing_run="$MISSING " else am_missing_run= - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: \`missing' script is too old or missing" >&5 -$as_echo "$as_me: WARNING: \`missing' script is too old or missing" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: 'missing' script is too old or missing" >&5 +$as_echo "$as_me: WARNING: 'missing' script is too old or missing" >&2;} fi if test x"${install_sh}" != xset; then @@ -1923,17 +1977,17 @@ esac fi -# Installed binaries are usually stripped using `strip' when the user -# run `make install-strip'. However `strip' might not be the right +# Installed binaries are usually stripped using 'strip' when the user +# run "make install-strip". However 'strip' might not be the right # tool to use in cross-compilation environments, therefore Automake -# will honor the `STRIP' environment variable to overrule this program. +# will honor the 'STRIP' environment variable to overrule this program. if test "$cross_compiling" != no; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args. set dummy ${ac_tool_prefix}strip; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_STRIP+set}" = set; then : +if ${ac_cv_prog_STRIP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$STRIP"; then @@ -1945,7 +1999,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_STRIP="${ac_tool_prefix}strip" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -1973,7 +2027,7 @@ set dummy strip; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_STRIP+set}" = set; then : +if ${ac_cv_prog_ac_ct_STRIP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_STRIP"; then @@ -1985,7 +2039,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_STRIP="strip" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -2026,7 +2080,7 @@ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a thread-safe mkdir -p" >&5 $as_echo_n "checking for a thread-safe mkdir -p... " >&6; } if test -z "$MKDIR_P"; then - if test "${ac_cv_path_mkdir+set}" = set; then : + if ${ac_cv_path_mkdir+:} false; then : $as_echo_n "(cached) " >&6 else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR @@ -2036,7 +2090,7 @@ test -z "$as_dir" && as_dir=. for ac_prog in mkdir gmkdir; do for ac_exec_ext in '' $ac_executable_extensions; do - { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; } || continue + as_fn_executable_p "$as_dir/$ac_prog$ac_exec_ext" || continue case `"$as_dir/$ac_prog$ac_exec_ext" --version 2>&1` in #( 'mkdir (GNU coreutils) '* | \ 'mkdir (coreutils) '* | \ @@ -2065,19 +2119,13 @@ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MKDIR_P" >&5 $as_echo "$MKDIR_P" >&6; } -mkdir_p="$MKDIR_P" -case $mkdir_p in - [\\/$]* | ?:[\\/]*) ;; - */*) mkdir_p="\$(top_builddir)/$mkdir_p" ;; -esac - for ac_prog in gawk mawk nawk awk do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_AWK+set}" = set; then : +if ${ac_cv_prog_AWK+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$AWK"; then @@ -2089,7 +2137,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_AWK="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -2117,7 +2165,7 @@ $as_echo_n "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; } set x ${MAKE-make} ac_make=`$as_echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'` -if eval "test \"\${ac_cv_prog_make_${ac_make}_set+set}\"" = set; then : +if eval \${ac_cv_prog_make_${ac_make}_set+:} false; then : $as_echo_n "(cached) " >&6 else cat >conftest.make <<\_ACEOF @@ -2153,6 +2201,45 @@ fi rmdir .tst 2>/dev/null +# Check whether --enable-silent-rules was given. +if test "${enable_silent_rules+set}" = set; then : + enableval=$enable_silent_rules; +fi + +case $enable_silent_rules in # ((( + yes) AM_DEFAULT_VERBOSITY=0;; + no) AM_DEFAULT_VERBOSITY=1;; + *) AM_DEFAULT_VERBOSITY=1;; +esac +am_make=${MAKE-make} +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $am_make supports nested variables" >&5 +$as_echo_n "checking whether $am_make supports nested variables... " >&6; } +if ${am_cv_make_support_nested_variables+:} false; then : + $as_echo_n "(cached) " >&6 +else + if $as_echo 'TRUE=$(BAR$(V)) +BAR0=false +BAR1=true +V=1 +am__doit: + @$(TRUE) +.PHONY: am__doit' | $am_make -f - >/dev/null 2>&1; then + am_cv_make_support_nested_variables=yes +else + am_cv_make_support_nested_variables=no +fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_make_support_nested_variables" >&5 +$as_echo "$am_cv_make_support_nested_variables" >&6; } +if test $am_cv_make_support_nested_variables = yes; then + AM_V='$(V)' + AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)' +else + AM_V=$AM_DEFAULT_VERBOSITY + AM_DEFAULT_V=$AM_DEFAULT_VERBOSITY +fi +AM_BACKSLASH='\' + if test "`cd $srcdir && pwd`" != "`pwd`"; then # Use -I$(srcdir) only when $(srcdir) != ., so that make's output # is not polluted with repeated "-I." @@ -2174,8 +2261,8 @@ # Define the identity of the package. - PACKAGE=dbus-sharp - VERSION=$VERSION + PACKAGE='dbus-sharp' + VERSION='0.8.0' cat >>confdefs.h <<_ACEOF @@ -2203,13 +2290,24 @@ MAKEINFO=${MAKEINFO-"${am_missing_run}makeinfo"} +# For better backward compatibility. To be removed once Automake 1.9.x +# dies out for good. For more background, see: +# +# +mkdir_p='$(MKDIR_P)' + # We need awk for the "check" target. The system "awk" is bad on # some platforms. -# Always define AMTAR for backward compatibility. +# Always define AMTAR for backward compatibility. Yes, it's still used +# in the wild :-( We should find a proper way to deprecate it ... +AMTAR='$${TAR-tar}' + -AMTAR=${AMTAR-"${am_missing_run}tar"} +# We'll loop over all known methods to create a tar archive until one works. +_am_tools='gnutar pax cpio none' + +am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -' -am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -' @@ -2240,13 +2338,18 @@ +API_VERSION=2.0 + +VERSION=0.8.0 + + # Extract the first word of "pkg-config", so it can be a program name with args. set dummy pkg-config; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_PKG_CONFIG+set}" = set; then : +if ${ac_cv_path_PKG_CONFIG+:} false; then : $as_echo_n "(cached) " >&6 else case $PKG_CONFIG in @@ -2260,7 +2363,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_path_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -2295,13 +2398,14 @@ + if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}pkg-config", so it can be a program name with args. set dummy ${ac_tool_prefix}pkg-config; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_PKG_CONFIG+set}" = set; then : +if ${ac_cv_path_PKG_CONFIG+:} false; then : $as_echo_n "(cached) " >&6 else case $PKG_CONFIG in @@ -2315,7 +2419,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_path_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -2344,7 +2448,7 @@ set dummy pkg-config; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_ac_pt_PKG_CONFIG+set}" = set; then : +if ${ac_cv_path_ac_pt_PKG_CONFIG+:} false; then : $as_echo_n "(cached) " >&6 else case $ac_pt_PKG_CONFIG in @@ -2358,7 +2462,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_path_ac_pt_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -2423,6 +2527,7 @@ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_MONO_CFLAGS=`$PKG_CONFIG --cflags "mono >= $MONO_REQ_VERSION" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi @@ -2439,6 +2544,7 @@ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_MONO_LIBS=`$PKG_CONFIG --libs "mono >= $MONO_REQ_VERSION" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi @@ -2458,9 +2564,9 @@ _pkg_short_errors_supported=no fi if test $_pkg_short_errors_supported = yes; then - MONO_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "mono >= $MONO_REQ_VERSION" 2>&1` + MONO_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "mono >= $MONO_REQ_VERSION" 2>&1` else - MONO_PKG_ERRORS=`$PKG_CONFIG --print-errors "mono >= $MONO_REQ_VERSION" 2>&1` + MONO_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "mono >= $MONO_REQ_VERSION" 2>&1` fi # Put the nasty error message in config.log where it belongs echo "$MONO_PKG_ERRORS" >&5 @@ -2502,7 +2608,7 @@ set dummy gmcs; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_GMCS+set}" = set; then : +if ${ac_cv_path_GMCS+:} false; then : $as_echo_n "(cached) " >&6 else case $GMCS in @@ -2516,7 +2622,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_path_GMCS="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -2548,7 +2654,7 @@ set dummy gacutil; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_GACUTIL+set}" = set; then : +if ${ac_cv_path_GACUTIL+:} false; then : $as_echo_n "(cached) " >&6 else case $GACUTIL in @@ -2562,7 +2668,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_path_GACUTIL="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -2590,6 +2696,52 @@ fi +# Extract the first word of "xbuild", so it can be a program name with args. +set dummy xbuild; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_path_XBUILD+:} false; then : + $as_echo_n "(cached) " >&6 +else + case $XBUILD in + [\\/]* | ?:[\\/]*) + ac_cv_path_XBUILD="$XBUILD" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_path_XBUILD="$as_dir/$ac_word$ac_exec_ext" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + + test -z "$ac_cv_path_XBUILD" && ac_cv_path_XBUILD="no" + ;; +esac +fi +XBUILD=$ac_cv_path_XBUILD +if test -n "$XBUILD"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $XBUILD" >&5 +$as_echo "$XBUILD" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +if test "x$GACUTIL" = "xno"; then + as_fn_error $? "You need to install xbuild" "$LINENO" 5 +fi + + required_assemblies="Mono.Posix" for asm in $required_assemblies; do @@ -2605,7 +2757,200 @@ fi done -ac_config_files="$ac_config_files Makefile dbus-sharp-1.0.pc src/AssemblyInfo.cs src/Makefile tools/Makefile examples/Makefile" +NUNIT_REQUIRED=2.4.7 + +# Check whether --enable-tests was given. +if test "${enable_tests+set}" = set; then : + enableval=$enable_tests; enable_tests=$enableval +else + enable_tests="no" +fi + + +if test "x$enable_tests" = "xno"; then + do_tests=no + if false; then + ENABLE_TESTS_TRUE= + ENABLE_TESTS_FALSE='#' +else + ENABLE_TESTS_TRUE='#' + ENABLE_TESTS_FALSE= +fi + +else + +pkg_failed=no +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for NUNIT" >&5 +$as_echo_n "checking for NUNIT... " >&6; } + +if test -n "$NUNIT_CFLAGS"; then + pkg_cv_NUNIT_CFLAGS="$NUNIT_CFLAGS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"nunit >= \$NUNIT_REQUIRED\""; } >&5 + ($PKG_CONFIG --exists --print-errors "nunit >= $NUNIT_REQUIRED") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_NUNIT_CFLAGS=`$PKG_CONFIG --cflags "nunit >= $NUNIT_REQUIRED" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes +else + pkg_failed=yes +fi + else + pkg_failed=untried +fi +if test -n "$NUNIT_LIBS"; then + pkg_cv_NUNIT_LIBS="$NUNIT_LIBS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"nunit >= \$NUNIT_REQUIRED\""; } >&5 + ($PKG_CONFIG --exists --print-errors "nunit >= $NUNIT_REQUIRED") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_NUNIT_LIBS=`$PKG_CONFIG --libs "nunit >= $NUNIT_REQUIRED" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes +else + pkg_failed=yes +fi + else + pkg_failed=untried +fi + + + +if test $pkg_failed = yes; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + +if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then + _pkg_short_errors_supported=yes +else + _pkg_short_errors_supported=no +fi + if test $_pkg_short_errors_supported = yes; then + NUNIT_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "nunit >= $NUNIT_REQUIRED" 2>&1` + else + NUNIT_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "nunit >= $NUNIT_REQUIRED" 2>&1` + fi + # Put the nasty error message in config.log where it belongs + echo "$NUNIT_PKG_ERRORS" >&5 + + do_tests="no" +elif test $pkg_failed = untried; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + do_tests="no" +else + NUNIT_CFLAGS=$pkg_cv_NUNIT_CFLAGS + NUNIT_LIBS=$pkg_cv_NUNIT_LIBS + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + do_tests="yes" +fi + + + if test "x$do_tests" = "xyes"; then + ENABLE_TESTS_TRUE= + ENABLE_TESTS_FALSE='#' +else + ENABLE_TESTS_TRUE='#' + ENABLE_TESTS_FALSE= +fi + + + if test "x$do_tests" = "xno"; then + +pkg_failed=no +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for NUNIT" >&5 +$as_echo_n "checking for NUNIT... " >&6; } + +if test -n "$NUNIT_CFLAGS"; then + pkg_cv_NUNIT_CFLAGS="$NUNIT_CFLAGS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"mono-nunit >= 2.4\""; } >&5 + ($PKG_CONFIG --exists --print-errors "mono-nunit >= 2.4") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_NUNIT_CFLAGS=`$PKG_CONFIG --cflags "mono-nunit >= 2.4" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes +else + pkg_failed=yes +fi + else + pkg_failed=untried +fi +if test -n "$NUNIT_LIBS"; then + pkg_cv_NUNIT_LIBS="$NUNIT_LIBS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"mono-nunit >= 2.4\""; } >&5 + ($PKG_CONFIG --exists --print-errors "mono-nunit >= 2.4") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_NUNIT_LIBS=`$PKG_CONFIG --libs "mono-nunit >= 2.4" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes +else + pkg_failed=yes +fi + else + pkg_failed=untried +fi + + + +if test $pkg_failed = yes; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + +if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then + _pkg_short_errors_supported=yes +else + _pkg_short_errors_supported=no +fi + if test $_pkg_short_errors_supported = yes; then + NUNIT_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "mono-nunit >= 2.4" 2>&1` + else + NUNIT_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "mono-nunit >= 2.4" 2>&1` + fi + # Put the nasty error message in config.log where it belongs + echo "$NUNIT_PKG_ERRORS" >&5 + + do_tests="no" +elif test $pkg_failed = untried; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + do_tests="no" +else + NUNIT_CFLAGS=$pkg_cv_NUNIT_CFLAGS + NUNIT_LIBS=$pkg_cv_NUNIT_LIBS + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + do_tests="yes" +fi + + + if test "x$do_tests" = "xyes"; then + ENABLE_TESTS_TRUE= + ENABLE_TESTS_FALSE='#' +else + ENABLE_TESTS_TRUE='#' + ENABLE_TESTS_FALSE= +fi + + + if test "x$do_tests" = "xno"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Could not find nunit: tests will not be available" >&5 +$as_echo "$as_me: WARNING: Could not find nunit: tests will not be available" >&2;} + fi + fi +fi + +ac_config_files="$ac_config_files Makefile dbus-sharp-2.0.pc src/AssemblyInfo.cs src/Makefile tools/Makefile examples/Makefile tests/Makefile" cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure @@ -2671,10 +3016,21 @@ :end' >>confcache if diff "$cache_file" confcache >/dev/null 2>&1; then :; else if test -w "$cache_file"; then - test "x$cache_file" != "x/dev/null" && + if test "x$cache_file" != "x/dev/null"; then { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5 $as_echo "$as_me: updating cache $cache_file" >&6;} - cat confcache >$cache_file + if test ! -f "$cache_file" || test -h "$cache_file"; then + cat confcache >"$cache_file" + else + case $cache_file in #( + */* | ?:*) + mv -f confcache "$cache_file"$$ && + mv -f "$cache_file"$$ "$cache_file" ;; #( + *) + mv -f confcache "$cache_file" ;; + esac + fi + fi else { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5 $as_echo "$as_me: not updating unwritable cache $cache_file" >&6;} @@ -2741,13 +3097,33 @@ LTLIBOBJS=$ac_ltlibobjs +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking that generated files are newer than configure" >&5 +$as_echo_n "checking that generated files are newer than configure... " >&6; } + if test -n "$am_sleep_pid"; then + # Hide warnings about reused PIDs. + wait $am_sleep_pid 2>/dev/null + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: result: done" >&5 +$as_echo "done" >&6; } if test -z "${MAINTAINER_MODE_TRUE}" && test -z "${MAINTAINER_MODE_FALSE}"; then as_fn_error $? "conditional \"MAINTAINER_MODE\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi +if test -z "${ENABLE_TESTS_TRUE}" && test -z "${ENABLE_TESTS_FALSE}"; then + as_fn_error $? "conditional \"ENABLE_TESTS\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi +if test -z "${ENABLE_TESTS_TRUE}" && test -z "${ENABLE_TESTS_FALSE}"; then + as_fn_error $? "conditional \"ENABLE_TESTS\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi +if test -z "${ENABLE_TESTS_TRUE}" && test -z "${ENABLE_TESTS_FALSE}"; then + as_fn_error $? "conditional \"ENABLE_TESTS\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi -: ${CONFIG_STATUS=./config.status} +: "${CONFIG_STATUS=./config.status}" ac_write_fail=0 ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files $CONFIG_STATUS" @@ -2848,6 +3224,7 @@ IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. +as_myself= case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR @@ -3043,16 +3420,16 @@ # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. - # In both cases, we have to default to `cp -p'. + # In both cases, we have to default to `cp -pR'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || - as_ln_s='cp -p' + as_ln_s='cp -pR' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else - as_ln_s='cp -p' + as_ln_s='cp -pR' fi else - as_ln_s='cp -p' + as_ln_s='cp -pR' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null @@ -3112,28 +3489,16 @@ as_mkdir_p=false fi -if test -x / >/dev/null 2>&1; then - as_test_x='test -x' -else - if ls -dL / >/dev/null 2>&1; then - as_ls_L_option=L - else - as_ls_L_option= - fi - as_test_x=' - eval sh -c '\'' - if test -d "$1"; then - test -d "$1/."; - else - case $1 in #( - -*)set "./$1";; - esac; - case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #(( - ???[sx]*):;;*)false;;esac;fi - '\'' sh - ' -fi -as_executable_p=$as_test_x + +# as_fn_executable_p FILE +# ----------------------- +# Test if FILE is an executable regular file. +as_fn_executable_p () +{ + test -f "$1" && test -x "$1" +} # as_fn_executable_p +as_test_x='test -x' +as_executable_p=as_fn_executable_p # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" @@ -3154,8 +3519,8 @@ # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by $as_me, which was -generated by GNU Autoconf 2.67. Invocation command line was +This file was extended by dbus-sharp $as_me 0.8.0, which was +generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS @@ -3207,11 +3572,11 @@ cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -config.status -configured by $0, generated by GNU Autoconf 2.67, +dbus-sharp config.status 0.8.0 +configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" -Copyright (C) 2010 Free Software Foundation, Inc. +Copyright (C) 2012 Free Software Foundation, Inc. This config.status script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it." @@ -3291,7 +3656,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 if \$ac_cs_recheck; then - set X '$SHELL' '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion + set X $SHELL '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion shift \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6 CONFIG_SHELL='$SHELL' @@ -3321,11 +3686,12 @@ do case $ac_config_target in "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; - "dbus-sharp-1.0.pc") CONFIG_FILES="$CONFIG_FILES dbus-sharp-1.0.pc" ;; + "dbus-sharp-2.0.pc") CONFIG_FILES="$CONFIG_FILES dbus-sharp-2.0.pc" ;; "src/AssemblyInfo.cs") CONFIG_FILES="$CONFIG_FILES src/AssemblyInfo.cs" ;; "src/Makefile") CONFIG_FILES="$CONFIG_FILES src/Makefile" ;; "tools/Makefile") CONFIG_FILES="$CONFIG_FILES tools/Makefile" ;; "examples/Makefile") CONFIG_FILES="$CONFIG_FILES examples/Makefile" ;; + "tests/Makefile") CONFIG_FILES="$CONFIG_FILES tests/Makefile" ;; *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; esac @@ -3348,9 +3714,10 @@ # after its creation but before its name has been assigned to `$tmp'. $debug || { - tmp= + tmp= ac_tmp= trap 'exit_status=$? - { test -z "$tmp" || test ! -d "$tmp" || rm -fr "$tmp"; } && exit $exit_status + : "${ac_tmp:=$tmp}" + { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status ' 0 trap 'as_fn_exit 1' 1 2 13 15 } @@ -3358,12 +3725,13 @@ { tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && - test -n "$tmp" && test -d "$tmp" + test -d "$tmp" } || { tmp=./conf$$-$RANDOM (umask 077 && mkdir "$tmp") } || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5 +ac_tmp=$tmp # Set up the scripts for CONFIG_FILES section. # No need to generate them if there are no CONFIG_FILES. @@ -3385,7 +3753,7 @@ ac_cs_awk_cr=$ac_cr fi -echo 'BEGIN {' >"$tmp/subs1.awk" && +echo 'BEGIN {' >"$ac_tmp/subs1.awk" && _ACEOF @@ -3413,7 +3781,7 @@ rm -f conf$$subs.sh cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 -cat >>"\$tmp/subs1.awk" <<\\_ACAWK && +cat >>"\$ac_tmp/subs1.awk" <<\\_ACAWK && _ACEOF sed -n ' h @@ -3461,7 +3829,7 @@ rm -f conf$$subs.awk cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 _ACAWK -cat >>"\$tmp/subs1.awk" <<_ACAWK && +cat >>"\$ac_tmp/subs1.awk" <<_ACAWK && for (key in S) S_is_set[key] = 1 FS = "" @@ -3493,7 +3861,7 @@ sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g" else cat -fi < "$tmp/subs1.awk" > "$tmp/subs.awk" \ +fi < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \ || as_fn_error $? "could not setup config files machinery" "$LINENO" 5 _ACEOF @@ -3552,7 +3920,7 @@ for ac_f do case $ac_f in - -) ac_f="$tmp/stdin";; + -) ac_f="$ac_tmp/stdin";; *) # Look for the file first in the build tree, then in the source tree # (if the path is not absolute). The absolute path cannot be DOS-style, # because $ac_f cannot contain `:'. @@ -3587,7 +3955,7 @@ esac case $ac_tag in - *:-:* | *:-) cat >"$tmp/stdin" \ + *:-:* | *:-) cat >"$ac_tmp/stdin" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; esac ;; @@ -3724,21 +4092,22 @@ s&@MKDIR_P@&$ac_MKDIR_P&;t t $ac_datarootdir_hack " -eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$tmp/subs.awk" >$tmp/out \ - || as_fn_error $? "could not create $ac_file" "$LINENO" 5 +eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$ac_tmp/subs.awk" \ + >$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5 test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && - { ac_out=`sed -n '/\${datarootdir}/p' "$tmp/out"`; test -n "$ac_out"; } && - { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' "$tmp/out"`; test -z "$ac_out"; } && + { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } && + { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' \ + "$ac_tmp/out"`; test -z "$ac_out"; } && { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined" >&5 $as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined" >&2;} - rm -f "$tmp/stdin" + rm -f "$ac_tmp/stdin" case $ac_file in - -) cat "$tmp/out" && rm -f "$tmp/out";; - *) rm -f "$ac_file" && mv "$tmp/out" "$ac_file";; + -) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";; + *) rm -f "$ac_file" && mv "$ac_tmp/out" "$ac_file";; esac \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; diff -Nru dbus-sharp-0.7.0/configure.ac dbus-sharp-0.8.0/configure.ac --- dbus-sharp-0.7.0/configure.ac 2010-09-14 09:17:49.000000000 +0000 +++ dbus-sharp-0.8.0/configure.ac 2013-10-07 00:47:51.000000000 +0000 @@ -1,18 +1,17 @@ -AC_INIT(src/DBus.cs) +m4_define([api_version], [2.0]) +m4_define([lib_version], [0.8.0]) AC_PREREQ(2.13) -API_VERSION=1.0 -#VERSION=$API_VERSION.0 -VERSION=0.7.0 - -AC_SUBST(API_VERSION) -AC_SUBST(VERSION) - -AM_INIT_AUTOMAKE(dbus-sharp, $VERSION) +AC_INIT([dbus-sharp], lib_version) +AC_CONFIG_SRCDIR([src/DBus.cs]) +AM_INIT_AUTOMAKE AM_MAINTAINER_MODE +AC_SUBST([API_VERSION], [api_version]) +AC_SUBST([VERSION], [lib_version]) + AC_PROG_INSTALL AC_PATH_PROG(PKG_CONFIG, pkg-config, no) @@ -36,6 +35,12 @@ fi AC_SUBST(GACUTIL) +AC_PATH_PROG(XBUILD, xbuild, no) +if test "x$GACUTIL" = "xno"; then + AC_MSG_ERROR([You need to install xbuild]) +fi +AC_SUBST(XBUILD) + required_assemblies="Mono.Posix" for asm in $required_assemblies; do @@ -48,12 +53,41 @@ fi done +NUNIT_REQUIRED=2.4.7 + +AC_ARG_ENABLE(tests, AC_HELP_STRING([--enable-tests], [Enable NUnit tests]), + enable_tests=$enableval, enable_tests="no") + +if test "x$enable_tests" = "xno"; then + do_tests=no + AM_CONDITIONAL(ENABLE_TESTS, false) +else + PKG_CHECK_MODULES(NUNIT, nunit >= $NUNIT_REQUIRED, + do_tests="yes", do_tests="no") + + AC_SUBST(NUNIT_LIBS) + AM_CONDITIONAL(ENABLE_TESTS, test "x$do_tests" = "xyes") + + if test "x$do_tests" = "xno"; then + PKG_CHECK_MODULES(NUNIT, mono-nunit >= 2.4, + do_tests="yes", do_tests="no") + + AC_SUBST(NUNIT_LIBS) + AM_CONDITIONAL(ENABLE_TESTS, test "x$do_tests" = "xyes") + + if test "x$do_tests" = "xno"; then + AC_MSG_WARN([Could not find nunit: tests will not be available]) + fi + fi +fi + AC_OUTPUT([ Makefile -dbus-sharp-1.0.pc +dbus-sharp-2.0.pc src/AssemblyInfo.cs src/Makefile tools/Makefile examples/Makefile +tests/Makefile ]) diff -Nru dbus-sharp-0.7.0/dbus-sharp-1.0.pc.in dbus-sharp-0.8.0/dbus-sharp-1.0.pc.in --- dbus-sharp-0.7.0/dbus-sharp-1.0.pc.in 2014-01-21 10:51:18.000000000 +0000 +++ dbus-sharp-0.8.0/dbus-sharp-1.0.pc.in 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -prefix=@prefix@ -datadir=${prefix}/share -exec_prefix=${prefix} -libdir=${exec_prefix}/lib -session_bus_services_dir=${datadir}/dbus-1/services - -Name: Managed DBus -Description: Managed D-Bus IPC protocol library and CLR binding -Version: @VERSION@ -URL: http://mono.github.com/dbus-sharp/ -Libs: -r:${libdir}/cli/@PACKAGE@-@API_VERSION@/dbus-sharp.dll diff -Nru dbus-sharp-0.7.0/dbus-sharp-2.0.pc.in dbus-sharp-0.8.0/dbus-sharp-2.0.pc.in --- dbus-sharp-0.7.0/dbus-sharp-2.0.pc.in 1970-01-01 00:00:00.000000000 +0000 +++ dbus-sharp-0.8.0/dbus-sharp-2.0.pc.in 2013-10-06 23:56:21.000000000 +0000 @@ -0,0 +1,11 @@ +prefix=@prefix@ +datadir=${prefix}/share +exec_prefix=${prefix} +libdir=@libdir@ +session_bus_services_dir=${datadir}/dbus-1/services + +Name: Managed DBus +Description: Managed D-Bus IPC protocol library and CLR binding +Version: @VERSION@ +URL: http://mono.github.com/dbus-sharp/ +Libs: -r:${libdir}/mono/@PACKAGE@-@API_VERSION@/dbus-sharp.dll diff -Nru dbus-sharp-0.7.0/dbus-sharp.sln dbus-sharp-0.8.0/dbus-sharp.sln --- dbus-sharp-0.7.0/dbus-sharp.sln 1970-01-01 00:00:00.000000000 +0000 +++ dbus-sharp-0.8.0/dbus-sharp.sln 2013-09-27 15:29:57.000000000 +0000 @@ -0,0 +1,37 @@ + +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual Studio 2010 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "dbus-sharp", "src\dbus-sharp.csproj", "{09A0200F-F3AF-4BD6-9EC4-E7D80D273E4C}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "dbus-monitor", "tools\dbus-monitor.csproj", "{736160C3-844E-43D9-8106-E492D74D92CD}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "dbus-daemon", "src\dbus-daemon.csproj", "{41918B94-6DAD-4C05-9FDF-17D51EC85AF0}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "dbus-sharp-tests", "tests\dbus-sharp-tests.csproj", "{40AB91F9-BA2F-4C02-99F5-1F299CDBE86D}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {09A0200F-F3AF-4BD6-9EC4-E7D80D273E4C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {09A0200F-F3AF-4BD6-9EC4-E7D80D273E4C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {09A0200F-F3AF-4BD6-9EC4-E7D80D273E4C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {09A0200F-F3AF-4BD6-9EC4-E7D80D273E4C}.Release|Any CPU.Build.0 = Release|Any CPU + {40AB91F9-BA2F-4C02-99F5-1F299CDBE86D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {40AB91F9-BA2F-4C02-99F5-1F299CDBE86D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {40AB91F9-BA2F-4C02-99F5-1F299CDBE86D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {40AB91F9-BA2F-4C02-99F5-1F299CDBE86D}.Release|Any CPU.Build.0 = Release|Any CPU + {41918B94-6DAD-4C05-9FDF-17D51EC85AF0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {41918B94-6DAD-4C05-9FDF-17D51EC85AF0}.Release|Any CPU.ActiveCfg = Release|Any CPU + {736160C3-844E-43D9-8106-E492D74D92CD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {736160C3-844E-43D9-8106-E492D74D92CD}.Release|Any CPU.ActiveCfg = Release|Any CPU + EndGlobalSection + GlobalSection(MonoDevelopProperties) = preSolution + StartupItem = src\dbus-sharp.csproj + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff -Nru dbus-sharp-0.7.0/debian/changelog dbus-sharp-0.8.0/debian/changelog --- dbus-sharp-0.7.0/debian/changelog 2014-01-21 10:51:18.000000000 +0000 +++ dbus-sharp-0.8.0/debian/changelog 2014-01-21 10:48:39.000000000 +0000 @@ -1,3 +1,40 @@ +dbus-sharp (0.8.0-1~12.04~dockycore1) precise; urgency=medium + + * Copied from debian + + -- Rico Tzschichholz Tue, 21 Jan 2014 11:35:42 +0100 + +dbus-sharp (0.8.0-1) unstable; urgency=low + + [ Iain Lane ] + * [5e8b567] Stop using deprecated cli.make and use cli sequence explicitly + + [ Jo Shields ] + * [3db2062] Fix uscan URL + * [641d1c1] Imported Upstream version 0.8.0 + * [cb02373] Bump API to 0.8 and ABI to 2.0, renaming packages as required. + * [4a95479] Don't run test suite, it doesn't work. + * [b58dab6] Add patch to build against default framework, not v3.5 + + -- Jo Shields Fri, 11 Oct 2013 12:08:21 +0200 + +dbus-sharp (0.7.0-5) unstable; urgency=low + + [ Iain Lane ] + * Upload rebuild for CLR 4.0 transition + * [b7d3bda] Convert to 3.0 (quilt) + * [24a8a42] Standards-Version → 3.9.2, no changes required + * [b25dedb] Exclude libc moduleref from dh_clideps consideration. + Affected by bug #657242 in dh_clideps which causes the moduleref to fail + to be resolved. + + [ Jo Shields ] + * [ad1254b] Reverse the way the dllmap for libsocket is handled, by using + libc (mapped by /etc/mono/config) the default, and remapping this to + libsocket.so.1 on Solaris. (cherry picked from upstream commit 1561585) + + -- Iain Lane Tue, 24 Jan 2012 22:17:08 +0000 + dbus-sharp (0.7.0-4) unstable; urgency=low * Cherry-pick 608328b and 76f43e6c from upstream trunk. Fixes broken signal diff -Nru dbus-sharp-0.7.0/debian/control dbus-sharp-0.8.0/debian/control --- dbus-sharp-0.7.0/debian/control 2014-01-21 10:51:18.000000000 +0000 +++ dbus-sharp-0.8.0/debian/control 2013-10-11 09:50:38.000000000 +0000 @@ -8,12 +8,12 @@ mono-devel (>= 2.4.3), pkg-config, monodoc-base -Standards-Version: 3.9.1 +Standards-Version: 3.9.2 Homepage: http://github.com/mono/dbus-sharp Vcs-Git: git://git.debian.org/pkg-cli-libs/packages/dbus-sharp.git Vcs-Browser: http://git.debian.org/?p=pkg-cli-libs/packages/dbus-sharp.git -Package: libdbus1.0-cil +Package: libdbus2.0-cil Architecture: all Depends: ${cli:Depends}, ${misc:Depends} Description: CLI implementation of D-Bus @@ -27,9 +27,9 @@ . This package contains the dbus-sharp library itself. -Package: libdbus1.0-cil-dev +Package: libdbus2.0-cil-dev Architecture: all -Depends: libdbus1.0-cil (= ${binary:Version}), ${misc:Depends} +Depends: libdbus2.0-cil (= ${binary:Version}), ${misc:Depends} Description: CLI implementation of D-Bus - development files dbus-sharp is a fork of ndesk-dbus, which is a C# implementation of D-Bus. It's often referred to as "managed D-Bus" to avoid confusion diff -Nru dbus-sharp-0.7.0/debian/libdbus1.0-cil-dev.install dbus-sharp-0.8.0/debian/libdbus1.0-cil-dev.install --- dbus-sharp-0.7.0/debian/libdbus1.0-cil-dev.install 2014-01-21 10:51:18.000000000 +0000 +++ dbus-sharp-0.8.0/debian/libdbus1.0-cil-dev.install 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -/usr/lib/pkgconfig/ diff -Nru dbus-sharp-0.7.0/debian/libdbus1.0-cil.install dbus-sharp-0.8.0/debian/libdbus1.0-cil.install --- dbus-sharp-0.7.0/debian/libdbus1.0-cil.install 2014-01-21 10:51:18.000000000 +0000 +++ dbus-sharp-0.8.0/debian/libdbus1.0-cil.install 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -/usr/lib/cli/ diff -Nru dbus-sharp-0.7.0/debian/libdbus1.0-cil.installcligac dbus-sharp-0.8.0/debian/libdbus1.0-cil.installcligac --- dbus-sharp-0.7.0/debian/libdbus1.0-cil.installcligac 2014-01-21 10:51:18.000000000 +0000 +++ dbus-sharp-0.8.0/debian/libdbus1.0-cil.installcligac 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -/usr/lib/cli/dbus-sharp-1.0/dbus-sharp.dll diff -Nru dbus-sharp-0.7.0/debian/libdbus2.0-cil-dev.install dbus-sharp-0.8.0/debian/libdbus2.0-cil-dev.install --- dbus-sharp-0.7.0/debian/libdbus2.0-cil-dev.install 1970-01-01 00:00:00.000000000 +0000 +++ dbus-sharp-0.8.0/debian/libdbus2.0-cil-dev.install 2013-04-12 15:37:54.000000000 +0000 @@ -0,0 +1 @@ +/usr/lib/pkgconfig/ diff -Nru dbus-sharp-0.7.0/debian/libdbus2.0-cil.install dbus-sharp-0.8.0/debian/libdbus2.0-cil.install --- dbus-sharp-0.7.0/debian/libdbus2.0-cil.install 1970-01-01 00:00:00.000000000 +0000 +++ dbus-sharp-0.8.0/debian/libdbus2.0-cil.install 2013-04-12 15:37:54.000000000 +0000 @@ -0,0 +1 @@ +/usr/lib/cli/ diff -Nru dbus-sharp-0.7.0/debian/libdbus2.0-cil.installcligac dbus-sharp-0.8.0/debian/libdbus2.0-cil.installcligac --- dbus-sharp-0.7.0/debian/libdbus2.0-cil.installcligac 1970-01-01 00:00:00.000000000 +0000 +++ dbus-sharp-0.8.0/debian/libdbus2.0-cil.installcligac 2013-10-11 09:58:40.000000000 +0000 @@ -0,0 +1 @@ +/usr/lib/cli/dbus-sharp-2.0/dbus-sharp.dll diff -Nru dbus-sharp-0.7.0/debian/patches/debian-changes dbus-sharp-0.8.0/debian/patches/debian-changes --- dbus-sharp-0.7.0/debian/patches/debian-changes 1970-01-01 00:00:00.000000000 +0000 +++ dbus-sharp-0.8.0/debian/patches/debian-changes 2014-01-21 10:48:45.000000000 +0000 @@ -0,0 +1,9 @@ +Debian patches are maintained in Git: see Vcs-Git in debian/control. +--- dbus-sharp-0.8.0.orig/dbus-sharp-2.0.pc.in ++++ dbus-sharp-0.8.0/dbus-sharp-2.0.pc.in +@@ -8,4 +8,4 @@ Name: Managed DBus + Description: Managed D-Bus IPC protocol library and CLR binding + Version: @VERSION@ + URL: http://mono.github.com/dbus-sharp/ +-Libs: -r:${libdir}/mono/@PACKAGE@-@API_VERSION@/dbus-sharp.dll ++Libs: -r:${libdir}/cli/@PACKAGE@-@API_VERSION@/dbus-sharp.dll diff -Nru dbus-sharp-0.7.0/debian/patches/series dbus-sharp-0.8.0/debian/patches/series --- dbus-sharp-0.7.0/debian/patches/series 1970-01-01 00:00:00.000000000 +0000 +++ dbus-sharp-0.8.0/debian/patches/series 2013-10-11 10:09:28.000000000 +0000 @@ -0,0 +1,2 @@ +use_default_framework_version.patch +debian-changes diff -Nru dbus-sharp-0.7.0/debian/patches/use_default_framework_version.patch dbus-sharp-0.8.0/debian/patches/use_default_framework_version.patch --- dbus-sharp-0.7.0/debian/patches/use_default_framework_version.patch 1970-01-01 00:00:00.000000000 +0000 +++ dbus-sharp-0.8.0/debian/patches/use_default_framework_version.patch 2013-10-11 10:05:12.000000000 +0000 @@ -0,0 +1,12 @@ +diff --git a/src/dbus-sharp.csproj b/src/dbus-sharp.csproj +index 05e2228..09b7012 100644 +--- a/src/dbus-sharp.csproj ++++ b/src/dbus-sharp.csproj +@@ -13,7 +13,6 @@ + DBus + true + ..\dbus-sharp.snk +- v3.5 + + + True diff -Nru dbus-sharp-0.7.0/debian/rules dbus-sharp-0.8.0/debian/rules --- dbus-sharp-0.7.0/debian/rules 2014-01-21 10:51:18.000000000 +0000 +++ dbus-sharp-0.8.0/debian/rules 2013-10-11 09:58:43.000000000 +0000 @@ -1,10 +1,8 @@ #!/usr/bin/make -f export DH_VERBOSE=1 -include /usr/share/cli-common/cli.make - -DEB_API_VERSION = 0.7 -DEB_ABI_VERSION = 1.0 +DEB_API_VERSION = 0.8 +DEB_ABI_VERSION = 2.0 DEB_CLI_DIR = debian/tmp/usr/lib/cli/dbus-sharp-$(DEB_ABI_VERSION)/ DEB_DOC_DIR = $(CURDIR)/doc DEB_LIB_FILES = $(CURDIR)/src/dbus-sharp.dll @@ -39,8 +37,13 @@ dh_auto_clean rm -rf $(DEB_CLEAN_FILES) +override_dh_auto_test: + +override_dh_clideps: + dh_clideps --exclude-moduleref=libc + override_dh_makeclilibs: dh_makeclilibs -m$(DEB_API_VERSION) %: - dh $@ + dh $@ --with cli diff -Nru dbus-sharp-0.7.0/debian/source/format dbus-sharp-0.8.0/debian/source/format --- dbus-sharp-0.7.0/debian/source/format 1970-01-01 00:00:00.000000000 +0000 +++ dbus-sharp-0.8.0/debian/source/format 2014-01-21 10:51:19.020401833 +0000 @@ -0,0 +1 @@ +3.0 (quilt) diff -Nru dbus-sharp-0.7.0/debian/source/options dbus-sharp-0.8.0/debian/source/options --- dbus-sharp-0.7.0/debian/source/options 1970-01-01 00:00:00.000000000 +0000 +++ dbus-sharp-0.8.0/debian/source/options 2013-04-12 15:37:54.000000000 +0000 @@ -0,0 +1 @@ +single-debian-patch diff -Nru dbus-sharp-0.7.0/debian/source/patch-header dbus-sharp-0.8.0/debian/source/patch-header --- dbus-sharp-0.7.0/debian/source/patch-header 1970-01-01 00:00:00.000000000 +0000 +++ dbus-sharp-0.8.0/debian/source/patch-header 2013-04-12 15:37:54.000000000 +0000 @@ -0,0 +1 @@ +Debian patches are maintained in Git: see Vcs-Git in debian/control. diff -Nru dbus-sharp-0.7.0/debian/watch dbus-sharp-0.8.0/debian/watch --- dbus-sharp-0.7.0/debian/watch 2014-01-21 10:51:18.000000000 +0000 +++ dbus-sharp-0.8.0/debian/watch 2013-10-11 09:40:44.000000000 +0000 @@ -1,2 +1,2 @@ version=3 -http://github.com/mono/dbus-sharp/downloads .+/dbus-sharp-([\d\.]+)\.tar\.gz +http://github.com/mono/dbus-sharp/releases .+/dbus-sharp-([\d\.]+)\.tar\.gz diff -Nru dbus-sharp-0.7.0/examples/Makefile.in dbus-sharp-0.8.0/examples/Makefile.in --- dbus-sharp-0.7.0/examples/Makefile.in 2010-09-14 09:18:28.000000000 +0000 +++ dbus-sharp-0.8.0/examples/Makefile.in 2013-10-07 00:49:05.000000000 +0000 @@ -1,9 +1,8 @@ -# Makefile.in generated by automake 1.11.1 from Makefile.am. +# Makefile.in generated by automake 1.13.2 from Makefile.am. # @configure_input@ -# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, -# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, -# Inc. +# Copyright (C) 1994-2013 Free Software Foundation, Inc. + # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. @@ -15,6 +14,51 @@ @SET_MAKE@ VPATH = @srcdir@ +am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' +am__make_running_with_option = \ + case $${target_option-} in \ + ?) ;; \ + *) echo "am__make_running_with_option: internal error: invalid" \ + "target option '$${target_option-}' specified" >&2; \ + exit 1;; \ + esac; \ + has_opt=no; \ + sane_makeflags=$$MAKEFLAGS; \ + if $(am__is_gnu_make); then \ + sane_makeflags=$$MFLAGS; \ + else \ + case $$MAKEFLAGS in \ + *\\[\ \ ]*) \ + bs=\\; \ + sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ + | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ + esac; \ + fi; \ + skip_next=no; \ + strip_trailopt () \ + { \ + flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ + }; \ + for flg in $$sane_makeflags; do \ + test $$skip_next = yes && { skip_next=no; continue; }; \ + case $$flg in \ + *=*|--*) continue;; \ + -*I) strip_trailopt 'I'; skip_next=yes;; \ + -*I?*) strip_trailopt 'I';; \ + -*O) strip_trailopt 'O'; skip_next=yes;; \ + -*O?*) strip_trailopt 'O';; \ + -*l) strip_trailopt 'l'; skip_next=yes;; \ + -*l?*) strip_trailopt 'l';; \ + -[dEDm]) skip_next=yes;; \ + -[JT]) skip_next=yes;; \ + esac; \ + case $$flg in \ + *$$target_option*) has_opt=yes; break;; \ + esac; \ + done; \ + test $$has_opt = yes +am__make_dryrun = (target_option=n; $(am__make_running_with_option)) +am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ @@ -32,7 +76,7 @@ PRE_UNINSTALL = : POST_UNINSTALL = : subdir = examples -DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in +DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ @@ -40,11 +84,30 @@ mkinstalldirs = $(install_sh) -d CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = +AM_V_P = $(am__v_P_@AM_V@) +am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) +am__v_P_0 = false +am__v_P_1 = : +AM_V_GEN = $(am__v_GEN_@AM_V@) +am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) +am__v_GEN_0 = @echo " GEN " $@; +am__v_GEN_1 = +AM_V_at = $(am__v_at_@AM_V@) +am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) +am__v_at_0 = @ +am__v_at_1 = SOURCES = DIST_SOURCES = +am__can_run_installinfo = \ + case $$AM_UPDATE_INFO_DIR in \ + n|no|NO) false;; \ + *) (install-info --version) >/dev/null 2>&1;; \ + esac +am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ +AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ API_VERSION = @API_VERSION@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ @@ -70,6 +133,8 @@ MKDIR_P = @MKDIR_P@ MONO_CFLAGS = @MONO_CFLAGS@ MONO_LIBS = @MONO_LIBS@ +NUNIT_CFLAGS = @NUNIT_CFLAGS@ +NUNIT_LIBS = @NUNIT_LIBS@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ @@ -85,6 +150,7 @@ SHELL = @SHELL@ STRIP = @STRIP@ VERSION = @VERSION@ +XBUILD = @XBUILD@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ @@ -164,11 +230,11 @@ $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): -tags: TAGS -TAGS: +tags TAGS: + +ctags CTAGS: -ctags: CTAGS -CTAGS: +cscope cscopelist: distdir: $(DISTFILES) @@ -215,10 +281,15 @@ installcheck: installcheck-am install-strip: - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - `test -z '$(STRIP)' || \ - echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install + if test -z '$(STRIP)'; then \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + install; \ + else \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ + fi mostlyclean-generic: clean-generic: @@ -298,15 +369,16 @@ .MAKE: install-am install-strip -.PHONY: all all-am check check-am clean clean-generic distclean \ - distclean-generic distdir dvi dvi-am html html-am info info-am \ - install install-am install-data install-data-am install-dvi \ - install-dvi-am install-exec install-exec-am install-html \ - install-html-am install-info install-info-am install-man \ - install-pdf install-pdf-am install-ps install-ps-am \ - install-strip installcheck installcheck-am installdirs \ - maintainer-clean maintainer-clean-generic mostlyclean \ - mostlyclean-generic pdf pdf-am ps ps-am uninstall uninstall-am +.PHONY: all all-am check check-am clean clean-generic cscopelist-am \ + ctags-am distclean distclean-generic distdir dvi dvi-am html \ + html-am info info-am install install-am install-data \ + install-data-am install-dvi install-dvi-am install-exec \ + install-exec-am install-html install-html-am install-info \ + install-info-am install-man install-pdf install-pdf-am \ + install-ps install-ps-am install-strip installcheck \ + installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-generic pdf \ + pdf-am ps ps-am tags-am uninstall uninstall-am # Tell versions [3.59,3.63) of GNU make to not export all variables. diff -Nru dbus-sharp-0.7.0/examples/TestExportInterface.cs dbus-sharp-0.8.0/examples/TestExportInterface.cs --- dbus-sharp-0.7.0/examples/TestExportInterface.cs 2010-09-14 09:17:49.000000000 +0000 +++ dbus-sharp-0.8.0/examples/TestExportInterface.cs 2013-07-26 21:04:04.000000000 +0000 @@ -28,8 +28,8 @@ bus.Iterate (); } else { //import a remote to a local proxy - //demo = bus.GetObject (bus_name, path); - demo = bus.GetObject (bus_name, path); + demo = bus.GetObject (bus_name, path); + //demo = bus.GetObject (bus_name, path); } Console.WriteLine (); diff -Nru dbus-sharp-0.7.0/install-sh dbus-sharp-0.8.0/install-sh --- dbus-sharp-0.7.0/install-sh 2010-09-03 08:22:33.000000000 +0000 +++ dbus-sharp-0.8.0/install-sh 2013-10-07 00:27:39.000000000 +0000 @@ -1,7 +1,7 @@ #!/bin/sh # install - install a program, script, or datafile -scriptversion=2009-04-28.21; # UTC +scriptversion=2011-11-20.07; # UTC # This originates from X11R5 (mit/util/scripts/install.sh), which was # later released in X11R6 (xc/config/util/install.sh) with the @@ -35,7 +35,7 @@ # FSF changes to this file are in the public domain. # # Calling this script install-sh is preferred over install.sh, to prevent -# `make' implicit rules from creating a file called install from it +# 'make' implicit rules from creating a file called install from it # when there is no Makefile. # # This script is compatible with the BSD install script, but was written @@ -156,6 +156,10 @@ -s) stripcmd=$stripprog;; -t) dst_arg=$2 + # Protect names problematic for 'test' and other utilities. + case $dst_arg in + -* | [=\(\)!]) dst_arg=./$dst_arg;; + esac shift;; -T) no_target_directory=true;; @@ -186,6 +190,10 @@ fi shift # arg dst_arg=$arg + # Protect names problematic for 'test' and other utilities. + case $dst_arg in + -* | [=\(\)!]) dst_arg=./$dst_arg;; + esac done fi @@ -194,13 +202,17 @@ echo "$0: no input file specified." >&2 exit 1 fi - # It's OK to call `install-sh -d' without argument. + # It's OK to call 'install-sh -d' without argument. # This can happen when creating conditional directories. exit 0 fi if test -z "$dir_arg"; then - trap '(exit $?); exit' 1 2 13 15 + do_exit='(exit $ret); exit $ret' + trap "ret=129; $do_exit" 1 + trap "ret=130; $do_exit" 2 + trap "ret=141; $do_exit" 13 + trap "ret=143; $do_exit" 15 # Set umask so as not to create temps with too-generous modes. # However, 'strip' requires both read and write access to temps. @@ -228,9 +240,9 @@ for src do - # Protect names starting with `-'. + # Protect names problematic for 'test' and other utilities. case $src in - -*) src=./$src;; + -* | [=\(\)!]) src=./$src;; esac if test -n "$dir_arg"; then @@ -252,12 +264,7 @@ echo "$0: no destination specified." >&2 exit 1 fi - dst=$dst_arg - # Protect names starting with `-'. - case $dst in - -*) dst=./$dst;; - esac # If destination is a directory, append the input filename; won't work # if double slashes aren't ignored. @@ -347,7 +354,7 @@ if test -z "$dir_arg" || { # Check for POSIX incompatibilities with -m. # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or - # other-writeable bit of parent directory when it shouldn't. + # other-writable bit of parent directory when it shouldn't. # FreeBSD 6.1 mkdir -m -p sets mode of existing directory. ls_ld_tmpdir=`ls -ld "$tmpdir"` case $ls_ld_tmpdir in @@ -385,7 +392,7 @@ case $dstdir in /*) prefix='/';; - -*) prefix='./';; + [-=\(\)!]*) prefix='./';; *) prefix='';; esac @@ -403,7 +410,7 @@ for d do - test -z "$d" && continue + test X"$d" = X && continue prefix=$prefix$d if test -d "$prefix"; then diff -Nru dbus-sharp-0.7.0/missing dbus-sharp-0.8.0/missing --- dbus-sharp-0.7.0/missing 2010-09-03 08:22:34.000000000 +0000 +++ dbus-sharp-0.8.0/missing 2013-10-07 00:27:39.000000000 +0000 @@ -1,11 +1,10 @@ #! /bin/sh -# Common stub for a few missing GNU programs while installing. +# Common wrapper for a few potentially missing GNU programs. -scriptversion=2009-04-28.21; # UTC +scriptversion=2012-06-26.16; # UTC -# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006, -# 2008, 2009 Free Software Foundation, Inc. -# Originally by Fran,cois Pinard , 1996. +# Copyright (C) 1996-2013 Free Software Foundation, Inc. +# Originally written by Fran,cois Pinard , 1996. # 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 @@ -26,69 +25,40 @@ # the same distribution terms that you use for the rest of that program. if test $# -eq 0; then - echo 1>&2 "Try \`$0 --help' for more information" + echo 1>&2 "Try '$0 --help' for more information" exit 1 fi -run=: -sed_output='s/.* --output[ =]\([^ ]*\).*/\1/p' -sed_minuso='s/.* -o \([^ ]*\).*/\1/p' - -# In the cases where this matters, `missing' is being run in the -# srcdir already. -if test -f configure.ac; then - configure_ac=configure.ac -else - configure_ac=configure.in -fi +case $1 in -msg="missing on your system" + --is-lightweight) + # Used by our autoconf macros to check whether the available missing + # script is modern enough. + exit 0 + ;; -case $1 in ---run) - # Try to run requested program, and just exit if it succeeds. - run= - shift - "$@" && exit 0 - # Exit code 63 means version mismatch. This often happens - # when the user try to use an ancient version of a tool on - # a file that requires a minimum version. In this case we - # we should proceed has if the program had been absent, or - # if --run hadn't been passed. - if test $? = 63; then - run=: - msg="probably too old" - fi - ;; + --run) + # Back-compat with the calling convention used by older automake. + shift + ;; -h|--h|--he|--hel|--help) echo "\ $0 [OPTION]... PROGRAM [ARGUMENT]... -Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an -error status if there is no known handling for PROGRAM. +Run 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due +to PROGRAM being missing or too old. Options: -h, --help display this help and exit -v, --version output version information and exit - --run try to run the given command, and emulate it if it fails Supported PROGRAM values: - aclocal touch file \`aclocal.m4' - autoconf touch file \`configure' - autoheader touch file \`config.h.in' - autom4te touch the output file, or create a stub one - automake touch all \`Makefile.in' files - bison create \`y.tab.[ch]', if possible, from existing .[ch] - flex create \`lex.yy.c', if possible, from existing .c - help2man touch the output file - lex create \`lex.yy.c', if possible, from existing .c - makeinfo touch the output file - tar try tar, gnutar, gtar, then tar without non-portable flags - yacc create \`y.tab.[ch]', if possible, from existing .[ch] + aclocal autoconf autoheader autom4te automake makeinfo + bison yacc flex lex help2man -Version suffixes to PROGRAM as well as the prefixes \`gnu-', \`gnu', and -\`g' are ignored when checking the name. +Version suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and +'g' are ignored when checking the name. Send bug reports to ." exit $? @@ -100,272 +70,141 @@ ;; -*) - echo 1>&2 "$0: Unknown \`$1' option" - echo 1>&2 "Try \`$0 --help' for more information" + echo 1>&2 "$0: unknown '$1' option" + echo 1>&2 "Try '$0 --help' for more information" exit 1 ;; esac -# normalize program name to check for. -program=`echo "$1" | sed ' - s/^gnu-//; t - s/^gnu//; t - s/^g//; t'` - -# Now exit if we have it, but it failed. Also exit now if we -# don't have it and --version was passed (most likely to detect -# the program). This is about non-GNU programs, so use $1 not -# $program. -case $1 in - lex*|yacc*) - # Not GNU programs, they don't have --version. - ;; - - tar*) - if test -n "$run"; then - echo 1>&2 "ERROR: \`tar' requires --run" - exit 1 - elif test "x$2" = "x--version" || test "x$2" = "x--help"; then - exit 1 - fi - ;; +# Run the given program, remember its exit status. +"$@"; st=$? - *) - if test -z "$run" && ($1 --version) > /dev/null 2>&1; then - # We have it, but it failed. - exit 1 - elif test "x$2" = "x--version" || test "x$2" = "x--help"; then - # Could not run --version or --help. This is probably someone - # running `$TOOL --version' or `$TOOL --help' to check whether - # $TOOL exists and not knowing $TOOL uses missing. - exit 1 - fi - ;; -esac - -# If it does not exist, or fails to run (possibly an outdated version), -# try to emulate it. -case $program in - aclocal*) - echo 1>&2 "\ -WARNING: \`$1' is $msg. You should only need it if - you modified \`acinclude.m4' or \`${configure_ac}'. You might want - to install the \`Automake' and \`Perl' packages. Grab them from - any GNU archive site." - touch aclocal.m4 - ;; - - autoconf*) - echo 1>&2 "\ -WARNING: \`$1' is $msg. You should only need it if - you modified \`${configure_ac}'. You might want to install the - \`Autoconf' and \`GNU m4' packages. Grab them from any GNU - archive site." - touch configure - ;; - - autoheader*) - echo 1>&2 "\ -WARNING: \`$1' is $msg. You should only need it if - you modified \`acconfig.h' or \`${configure_ac}'. You might want - to install the \`Autoconf' and \`GNU m4' packages. Grab them - from any GNU archive site." - files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}` - test -z "$files" && files="config.h" - touch_files= - for f in $files; do - case $f in - *:*) touch_files="$touch_files "`echo "$f" | - sed -e 's/^[^:]*://' -e 's/:.*//'`;; - *) touch_files="$touch_files $f.in";; - esac - done - touch $touch_files - ;; - - automake*) - echo 1>&2 "\ -WARNING: \`$1' is $msg. You should only need it if - you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'. - You might want to install the \`Automake' and \`Perl' packages. - Grab them from any GNU archive site." - find . -type f -name Makefile.am -print | - sed 's/\.am$/.in/' | - while read f; do touch "$f"; done - ;; +# If it succeeded, we are done. +test $st -eq 0 && exit 0 - autom4te*) - echo 1>&2 "\ -WARNING: \`$1' is needed, but is $msg. - You might have modified some files without having the - proper tools for further handling them. - You can get \`$1' as part of \`Autoconf' from any GNU - archive site." - - file=`echo "$*" | sed -n "$sed_output"` - test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` - if test -f "$file"; then - touch $file - else - test -z "$file" || exec >$file - echo "#! /bin/sh" - echo "# Created by GNU Automake missing as a replacement of" - echo "# $ $@" - echo "exit 0" - chmod +x $file - exit 1 - fi - ;; - - bison*|yacc*) - echo 1>&2 "\ -WARNING: \`$1' $msg. You should only need it if - you modified a \`.y' file. You may need the \`Bison' package - in order for those modifications to take effect. You can get - \`Bison' from any GNU archive site." - rm -f y.tab.c y.tab.h - if test $# -ne 1; then - eval LASTARG="\${$#}" - case $LASTARG in - *.y) - SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'` - if test -f "$SRCFILE"; then - cp "$SRCFILE" y.tab.c - fi - SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'` - if test -f "$SRCFILE"; then - cp "$SRCFILE" y.tab.h - fi - ;; - esac - fi - if test ! -f y.tab.h; then - echo >y.tab.h - fi - if test ! -f y.tab.c; then - echo 'main() { return 0; }' >y.tab.c - fi - ;; - - lex*|flex*) - echo 1>&2 "\ -WARNING: \`$1' is $msg. You should only need it if - you modified a \`.l' file. You may need the \`Flex' package - in order for those modifications to take effect. You can get - \`Flex' from any GNU archive site." - rm -f lex.yy.c - if test $# -ne 1; then - eval LASTARG="\${$#}" - case $LASTARG in - *.l) - SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'` - if test -f "$SRCFILE"; then - cp "$SRCFILE" lex.yy.c - fi - ;; - esac - fi - if test ! -f lex.yy.c; then - echo 'main() { return 0; }' >lex.yy.c - fi - ;; - - help2man*) - echo 1>&2 "\ -WARNING: \`$1' is $msg. You should only need it if - you modified a dependency of a manual page. You may need the - \`Help2man' package in order for those modifications to take - effect. You can get \`Help2man' from any GNU archive site." - - file=`echo "$*" | sed -n "$sed_output"` - test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` - if test -f "$file"; then - touch $file - else - test -z "$file" || exec >$file - echo ".ab help2man is required to generate this page" - exit $? - fi - ;; - - makeinfo*) - echo 1>&2 "\ -WARNING: \`$1' is $msg. You should only need it if - you modified a \`.texi' or \`.texinfo' file, or any other file - indirectly affecting the aspect of the manual. The spurious - call might also be the consequence of using a buggy \`make' (AIX, - DU, IRIX). You might want to install the \`Texinfo' package or - the \`GNU make' package. Grab either from any GNU archive site." - # The file to touch is that specified with -o ... - file=`echo "$*" | sed -n "$sed_output"` - test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` - if test -z "$file"; then - # ... or it is the one specified with @setfilename ... - infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'` - file=`sed -n ' - /^@setfilename/{ - s/.* \([^ ]*\) *$/\1/ - p - q - }' $infile` - # ... or it is derived from the source name (dir/f.texi becomes f.info) - test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info - fi - # If the file does not exist, the user really needs makeinfo; - # let's fail without touching anything. - test -f $file || exit 1 - touch $file - ;; - - tar*) - shift - - # We have already tried tar in the generic part. - # Look for gnutar/gtar before invocation to avoid ugly error - # messages. - if (gnutar --version > /dev/null 2>&1); then - gnutar "$@" && exit 0 - fi - if (gtar --version > /dev/null 2>&1); then - gtar "$@" && exit 0 - fi - firstarg="$1" - if shift; then - case $firstarg in - *o*) - firstarg=`echo "$firstarg" | sed s/o//` - tar "$firstarg" "$@" && exit 0 - ;; - esac - case $firstarg in - *h*) - firstarg=`echo "$firstarg" | sed s/h//` - tar "$firstarg" "$@" && exit 0 - ;; - esac - fi - - echo 1>&2 "\ -WARNING: I can't seem to be able to run \`tar' with the given arguments. - You may want to install GNU tar or Free paxutils, or check the - command line arguments." - exit 1 - ;; - - *) - echo 1>&2 "\ -WARNING: \`$1' is needed, and is $msg. - You might have modified some files without having the - proper tools for further handling them. Check the \`README' file, - it often tells you about the needed prerequisites for installing - this package. You may also peek at any GNU archive site, in case - some other package would contain this missing \`$1' program." - exit 1 - ;; -esac +# Also exit now if we it failed (or wasn't found), and '--version' was +# passed; such an option is passed most likely to detect whether the +# program is present and works. +case $2 in --version|--help) exit $st;; esac + +# Exit code 63 means version mismatch. This often happens when the user +# tries to use an ancient version of a tool on a file that requires a +# minimum version. +if test $st -eq 63; then + msg="probably too old" +elif test $st -eq 127; then + # Program was missing. + msg="missing on your system" +else + # Program was found and executed, but failed. Give up. + exit $st +fi -exit 0 +perl_URL=http://www.perl.org/ +flex_URL=http://flex.sourceforge.net/ +gnu_software_URL=http://www.gnu.org/software + +program_details () +{ + case $1 in + aclocal|automake) + echo "The '$1' program is part of the GNU Automake package:" + echo "<$gnu_software_URL/automake>" + echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:" + echo "<$gnu_software_URL/autoconf>" + echo "<$gnu_software_URL/m4/>" + echo "<$perl_URL>" + ;; + autoconf|autom4te|autoheader) + echo "The '$1' program is part of the GNU Autoconf package:" + echo "<$gnu_software_URL/autoconf/>" + echo "It also requires GNU m4 and Perl in order to run:" + echo "<$gnu_software_URL/m4/>" + echo "<$perl_URL>" + ;; + esac +} + +give_advice () +{ + # Normalize program name to check for. + normalized_program=`echo "$1" | sed ' + s/^gnu-//; t + s/^gnu//; t + s/^g//; t'` + + printf '%s\n' "'$1' is $msg." + + configure_deps="'configure.ac' or m4 files included by 'configure.ac'" + case $normalized_program in + autoconf*) + echo "You should only need it if you modified 'configure.ac'," + echo "or m4 files included by it." + program_details 'autoconf' + ;; + autoheader*) + echo "You should only need it if you modified 'acconfig.h' or" + echo "$configure_deps." + program_details 'autoheader' + ;; + automake*) + echo "You should only need it if you modified 'Makefile.am' or" + echo "$configure_deps." + program_details 'automake' + ;; + aclocal*) + echo "You should only need it if you modified 'acinclude.m4' or" + echo "$configure_deps." + program_details 'aclocal' + ;; + autom4te*) + echo "You might have modified some maintainer files that require" + echo "the 'automa4te' program to be rebuilt." + program_details 'autom4te' + ;; + bison*|yacc*) + echo "You should only need it if you modified a '.y' file." + echo "You may want to install the GNU Bison package:" + echo "<$gnu_software_URL/bison/>" + ;; + lex*|flex*) + echo "You should only need it if you modified a '.l' file." + echo "You may want to install the Fast Lexical Analyzer package:" + echo "<$flex_URL>" + ;; + help2man*) + echo "You should only need it if you modified a dependency" \ + "of a man page." + echo "You may want to install the GNU Help2man package:" + echo "<$gnu_software_URL/help2man/>" + ;; + makeinfo*) + echo "You should only need it if you modified a '.texi' file, or" + echo "any other file indirectly affecting the aspect of the manual." + echo "You might want to install the Texinfo package:" + echo "<$gnu_software_URL/texinfo/>" + echo "The spurious makeinfo call might also be the consequence of" + echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might" + echo "want to install GNU make:" + echo "<$gnu_software_URL/make/>" + ;; + *) + echo "You might have modified some files without having the proper" + echo "tools for further handling them. Check the 'README' file, it" + echo "often tells you about the needed prerequisites for installing" + echo "this package. You may also peek at any GNU archive site, in" + echo "case some other package contains this missing '$1' program." + ;; + esac +} + +give_advice "$1" | sed -e '1s/^/WARNING: /' \ + -e '2,$s/^/ /' >&2 + +# Propagate the correct exit status (expected to be 127 for a program +# not found, 63 for a program that failed due to version mismatch). +exit $st # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) diff -Nru dbus-sharp-0.7.0/src/Address.cs dbus-sharp-0.8.0/src/Address.cs --- dbus-sharp-0.7.0/src/Address.cs 2010-09-15 10:16:28.000000000 +0000 +++ dbus-sharp-0.8.0/src/Address.cs 2013-07-26 16:37:41.000000000 +0000 @@ -23,118 +23,6 @@ public BadAddressException (string reason) : base (reason) {} } - class AddressEntry - { - public string Method; - public readonly IDictionary Properties = new Dictionary (); - public UUID GUID = UUID.Zero; - - public override string ToString () - { - StringBuilder sb = new StringBuilder (); - sb.Append (Method); - sb.Append (':'); - - bool first = true; - foreach (KeyValuePair prop in Properties) { - if (first) - first = false; - else - sb.Append (','); - - sb.Append (prop.Key); - sb.Append ('='); - sb.Append (Escape (prop.Value)); - } - - if (GUID != UUID.Zero) { - if (Properties.Count != 0) - sb.Append (','); - sb.Append ("guid"); - sb.Append ('='); - sb.Append (GUID.ToString ()); - } - - return sb.ToString (); - } - - static string Escape (string str) - { - if (str == null) - return String.Empty; - - StringBuilder sb = new StringBuilder (); - int len = str.Length; - - for (int i = 0 ; i != len ; i++) { - char c = str[i]; - - //everything other than the optionally escaped chars _must_ be escaped - if (Char.IsLetterOrDigit (c) || c == '-' || c == '_' || c == '/' || c == '\\' || c == '.') - sb.Append (c); - else - sb.Append (Uri.HexEscape (c)); - } - - return sb.ToString (); - } - - static string Unescape (string str) - { - if (str == null) - return String.Empty; - - StringBuilder sb = new StringBuilder (); - int len = str.Length; - int i = 0; - while (i != len) { - if (Uri.IsHexEncoding (str, i)) - sb.Append (Uri.HexUnescape (str, ref i)); - else - sb.Append (str[i++]); - } - - return sb.ToString (); - } - - - public static AddressEntry Parse (string s) - { - AddressEntry entry = new AddressEntry (); - - string[] parts = s.Split (':'); - - if (parts.Length < 2) - throw new InvalidAddressException ("No colon found"); - if (parts.Length > 2) - throw new InvalidAddressException ("Too many colons found"); - - entry.Method = parts[0]; - - foreach (string propStr in parts[1].Split (',')) { - parts = propStr.Split ('='); - - if (parts.Length < 2) - throw new InvalidAddressException ("No equals sign found"); - if (parts.Length > 2) - throw new InvalidAddressException ("Too many equals signs found"); - - if (parts[0] == "guid") { - try { - entry.GUID = UUID.Parse (parts[1]); - } catch { - throw new InvalidAddressException ("Invalid guid specified"); - } - continue; - } - - entry.Properties[parts[0]] = Unescape (parts[1]); - } - - return entry; - } - } - static class Address { //(unix:(path|abstract)=.*,guid=.*|tcp:host=.*(,port=.*)?);? ... diff -Nru dbus-sharp-0.7.0/src/AddressEntry.cs dbus-sharp-0.8.0/src/AddressEntry.cs --- dbus-sharp-0.7.0/src/AddressEntry.cs 1970-01-01 00:00:00.000000000 +0000 +++ dbus-sharp-0.8.0/src/AddressEntry.cs 2013-07-26 21:04:04.000000000 +0000 @@ -0,0 +1,124 @@ +// Copyright 2006 Alp Toker +// Copyright 2010 Alan McGovern +// This software is made available under the MIT License +// See COPYING for details + +using System; +using System.Text; +using System.Collections.Generic; + +namespace DBus +{ + class AddressEntry + { + public string Method; + public readonly IDictionary Properties = new Dictionary (); + public UUID GUID = UUID.Zero; + + public override string ToString () + { + StringBuilder sb = new StringBuilder (); + sb.Append (Method); + sb.Append (':'); + + bool first = true; + foreach (KeyValuePair prop in Properties) { + if (first) + first = false; + else + sb.Append (','); + + sb.Append (prop.Key); + sb.Append ('='); + sb.Append (Escape (prop.Value)); + } + + if (GUID != UUID.Zero) { + if (Properties.Count != 0) + sb.Append (','); + sb.Append ("guid"); + sb.Append ('='); + sb.Append (GUID.ToString ()); + } + + return sb.ToString (); + } + + static string Escape (string str) + { + if (str == null) + return String.Empty; + + StringBuilder sb = new StringBuilder (); + int len = str.Length; + + for (int i = 0 ; i != len ; i++) { + char c = str[i]; + + //everything other than the optionally escaped chars _must_ be escaped + if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9') + || c == '-' || c == '_' || c == '/' || c == '\\' || c == '.') + sb.Append (c); + else + sb.Append (Uri.HexEscape (c)); + } + + return sb.ToString (); + } + + static string Unescape (string str) + { + if (str == null) + return String.Empty; + + StringBuilder sb = new StringBuilder (); + int len = str.Length; + int i = 0; + while (i != len) { + if (Uri.IsHexEncoding (str, i)) + sb.Append (Uri.HexUnescape (str, ref i)); + else + sb.Append (str[i++]); + } + + return sb.ToString (); + } + + + public static AddressEntry Parse (string s) + { + AddressEntry entry = new AddressEntry (); + + string[] parts = s.Split (':'); + + if (parts.Length < 2) + throw new InvalidAddressException ("No colon found"); + if (parts.Length > 2) + throw new InvalidAddressException ("Too many colons found"); + + entry.Method = parts[0]; + + foreach (string propStr in parts[1].Split (',')) { + parts = propStr.Split ('='); + + if (parts.Length < 2) + throw new InvalidAddressException ("No equals sign found"); + if (parts.Length > 2) + throw new InvalidAddressException ("Too many equals signs found"); + + if (parts[0] == "guid") { + try { + entry.GUID = UUID.Parse (parts[1]); + } catch { + throw new InvalidAddressException ("Invalid guid specified"); + } + continue; + } + + entry.Properties[parts[0]] = Unescape (parts[1]); + } + + return entry; + } + } +} diff -Nru dbus-sharp-0.7.0/src/ArgDirection.cs dbus-sharp-0.8.0/src/ArgDirection.cs --- dbus-sharp-0.7.0/src/ArgDirection.cs 1970-01-01 00:00:00.000000000 +0000 +++ dbus-sharp-0.8.0/src/ArgDirection.cs 2013-07-26 16:37:41.000000000 +0000 @@ -0,0 +1,15 @@ +// Copyright 2006 Alp Toker +// Copyright 2010 Alan McGovern s +// This software is made available under the MIT License +// See COPYING for details + +using System; + +namespace DBus +{ + enum ArgDirection + { + In, + Out, + } +} diff -Nru dbus-sharp-0.7.0/src/AssemblyInfo.cs dbus-sharp-0.8.0/src/AssemblyInfo.cs --- dbus-sharp-0.7.0/src/AssemblyInfo.cs 1970-01-01 00:00:00.000000000 +0000 +++ dbus-sharp-0.8.0/src/AssemblyInfo.cs 2013-10-07 00:49:07.000000000 +0000 @@ -0,0 +1,27 @@ +// Copyright 2006 Alp Toker +// This software is made available under the MIT License +// See COPYING for details + +using System.Reflection; +using System.Runtime.CompilerServices; + +[assembly: AssemblyFileVersion("0.8.0")] +[assembly: AssemblyInformationalVersion("0.8.0")] +[assembly: AssemblyVersion("2.0")] +[assembly: AssemblyTitle ("dbus-sharp")] +[assembly: AssemblyDescription ("D-Bus IPC protocol library and CLR binding")] +[assembly: AssemblyCopyright ("Copyright (C) Alp Toker and others")] + +#if STRONG_NAME +[assembly: InternalsVisibleTo ("dbus-sharp-tests, PublicKey=0024000004800000940000000602000000240000525341310004000011000000931ae68c635866ff1dcc22547815bbfd67e3d6e80dbfdc9afe7d079670243b9af245eb9797e0766f8adf6afb5eae1d6716fb46ef25d82c37ac7303fe1d13b90780886e0f7a8208167f16dd4678682d4d793a56ccaf0a233411b7604128ae128e306c959fcd2a8038003b2830a326fda3cbbade2f285a9477f6ff8d194e20a2a5")] +[assembly: InternalsVisibleTo ("dbus-monitor, PublicKey=0024000004800000940000000602000000240000525341310004000011000000931ae68c635866ff1dcc22547815bbfd67e3d6e80dbfdc9afe7d079670243b9af245eb9797e0766f8adf6afb5eae1d6716fb46ef25d82c37ac7303fe1d13b90780886e0f7a8208167f16dd4678682d4d793a56ccaf0a233411b7604128ae128e306c959fcd2a8038003b2830a326fda3cbbade2f285a9477f6ff8d194e20a2a5")] +[assembly: InternalsVisibleTo ("dbus-daemon, PublicKey=0024000004800000940000000602000000240000525341310004000011000000931ae68c635866ff1dcc22547815bbfd67e3d6e80dbfdc9afe7d079670243b9af245eb9797e0766f8adf6afb5eae1d6716fb46ef25d82c37ac7303fe1d13b90780886e0f7a8208167f16dd4678682d4d793a56ccaf0a233411b7604128ae128e306c959fcd2a8038003b2830a326fda3cbbade2f285a9477f6ff8d194e20a2a5")] +[assembly: InternalsVisibleTo ("dbus-sharp-glib, PublicKey=0024000004800000940000000602000000240000525341310004000011000000931ae68c635866ff1dcc22547815bbfd67e3d6e80dbfdc9afe7d079670243b9af245eb9797e0766f8adf6afb5eae1d6716fb46ef25d82c37ac7303fe1d13b90780886e0f7a8208167f16dd4678682d4d793a56ccaf0a233411b7604128ae128e306c959fcd2a8038003b2830a326fda3cbbade2f285a9477f6ff8d194e20a2a5")] +[assembly: InternalsVisibleTo ("dbus-sharp-proxies, PublicKey=0024000004800000940000000602000000240000525341310004000011000000931ae68c635866ff1dcc22547815bbfd67e3d6e80dbfdc9afe7d079670243b9af245eb9797e0766f8adf6afb5eae1d6716fb46ef25d82c37ac7303fe1d13b90780886e0f7a8208167f16dd4678682d4d793a56ccaf0a233411b7604128ae128e306c959fcd2a8038003b2830a326fda3cbbade2f285a9477f6ff8d194e20a2a5")] +#else +[assembly: InternalsVisibleTo ("dbus-sharp-tests")] +[assembly: InternalsVisibleTo ("dbus-monitor")] +[assembly: InternalsVisibleTo ("dbus-daemon")] +[assembly: InternalsVisibleTo ("dbus-sharp-glib")] +[assembly: InternalsVisibleTo ("dbus-sharp-proxies")] +#endif diff -Nru dbus-sharp-0.7.0/src/Bus.cs dbus-sharp-0.8.0/src/Bus.cs --- dbus-sharp-0.7.0/src/Bus.cs 2010-09-14 09:17:49.000000000 +0000 +++ dbus-sharp-0.8.0/src/Bus.cs 2013-07-26 21:04:04.000000000 +0000 @@ -10,46 +10,33 @@ { public sealed class Bus : Connection { - static Bus systemBus = null; + static readonly string DBusName = "org.freedesktop.DBus"; + static readonly ObjectPath DBusPath = new ObjectPath ("/org/freedesktop/DBus"); + + static Dictionary buses = new Dictionary (); + + static Bus starterBus = null; + static Bus systemBus = Address.StarterBusType == "system" ? Starter : Bus.Open (Address.System); + static Bus sessionBus = Address.StarterBusType == "session" ? Starter : Bus.Open (Address.Session); + + IBus bus; + string address; + string uniqueName; + public static Bus System { get { - if (systemBus == null) { - try { - if (Address.StarterBusType == "system") - systemBus = Starter; - else - systemBus = Bus.Open (Address.System); - } catch (Exception e) { - throw new Exception ("Unable to open the system message bus.", e); - } - } - return systemBus; } } - static Bus sessionBus = null; public static Bus Session { get { - if (sessionBus == null) { - try { - if (Address.StarterBusType == "session") - sessionBus = Starter; - else - sessionBus = Bus.Open (Address.Session); - } catch (Exception e) { - throw new Exception ("Unable to open the session message bus.", e); - } - } - return sessionBus; } } - //TODO: parsing of starter bus type, or maybe do this another way - static Bus starterBus = null; public static Bus Starter { get { @@ -65,13 +52,6 @@ } } - //public static readonly Bus Session = null; - - //TODO: use the guid, not the whole address string - //TODO: consider what happens when a connection has been closed - static Dictionary buses = new Dictionary (); - - //public static Connection Open (string address) public static new Bus Open (string address) { if (address == null) @@ -87,20 +67,10 @@ return bus; } - IBus bus; - - static readonly string DBusName = "org.freedesktop.DBus"; - static readonly ObjectPath DBusPath = new ObjectPath ("/org/freedesktop/DBus"); - public Bus (string address) : base (address) { - bus = GetObject (DBusName, DBusPath); - - /* - bus.NameAcquired += delegate (string acquired_name) { - Console.WriteLine ("NameAcquired: " + acquired_name); - }; - */ + this.bus = GetObject (DBusName, DBusPath); + this.address = address; Register (); } @@ -108,10 +78,26 @@ //as long as Bus subclasses Connection, having a Register with a completely different meaning is bad void Register () { - if (unique_name != null) + if (uniqueName != null) throw new Exception ("Bus already has a unique name"); - unique_name = bus.Hello (); + uniqueName = bus.Hello (); + } + + protected override void CloseInternal () + { + /* In case the bus was opened with static method + * Open, clear it from buses dictionary + */ + if (buses.ContainsKey (address)) + buses.Remove (address); + } + + protected override bool CheckBusNameExists (string busName) + { + if (busName == DBusName) + return true; + return NameHasOwner (busName); } public ulong GetUnixUser (string name) @@ -164,15 +150,14 @@ return bus.GetId (); } - string unique_name = null; public string UniqueName { get { - return unique_name; + return uniqueName; } set { - if (unique_name != null) + if (uniqueName != null) throw new Exception ("Unique name can only be set once"); - unique_name = value; + uniqueName = value; } } } diff -Nru dbus-sharp-0.7.0/src/BusException.cs dbus-sharp-0.8.0/src/BusException.cs --- dbus-sharp-0.7.0/src/BusException.cs 1970-01-01 00:00:00.000000000 +0000 +++ dbus-sharp-0.8.0/src/BusException.cs 2013-07-26 16:37:41.000000000 +0000 @@ -0,0 +1,36 @@ +// Copyright 2006 Alp Toker +// Copyright 2010 Alan McGovern +// This software is made available under the MIT License +// See COPYING for details + +using System; + +namespace DBus +{ + class BusException : Exception + { + public BusException (string errorName, string errorMessage) + { + this.ErrorName = errorName; + this.ErrorMessage = errorMessage; + } + + public BusException (string errorName, string format, params object[] args) + { + this.ErrorName = errorName; + this.ErrorMessage = String.Format (format, args); + } + + public override string Message + { + get + { + return ErrorName + ": " + ErrorMessage; + } + } + + public readonly string ErrorName; + + public readonly string ErrorMessage; + } +} diff -Nru dbus-sharp-0.7.0/src/BusObject.cs dbus-sharp-0.8.0/src/BusObject.cs --- dbus-sharp-0.7.0/src/BusObject.cs 2014-01-21 10:51:18.000000000 +0000 +++ dbus-sharp-0.8.0/src/BusObject.cs 2013-09-27 15:30:45.000000000 +0000 @@ -9,14 +9,16 @@ namespace DBus { - class BusObject + using Protocol; + + public class BusObject { + static Dictionary boCache = new Dictionary(); + protected Connection conn; string bus_name; - string alt_bus_name; ObjectPath object_path; - //protected BusObject () public BusObject () { } @@ -59,7 +61,7 @@ // FIXME: Cause a regression compared to 0.6 as name wasn't matched before // the problem arises because busname is not used by DBus daemon and // instead it uses the canonical name of the sender (i.e. similar to ':1.13') - //rule.Fields.Add (FieldCode.Sender, new MatchTest (alt_bus_name ?? bus_name)); + // rule.Fields.Add (FieldCode.Sender, new MatchTest (bus_name)); if (adding) { if (conn.Handlers.ContainsKey (rule)) @@ -81,132 +83,45 @@ { exception = null; - //TODO: don't ignore retVal, exception etc. - Signature outSig = String.IsNullOrEmpty (inSigStr) ? Signature.Empty : new Signature (inSigStr); - Signal signal = new Signal (object_path, iface, member); - signal.message.Signature = outSig; + MessageContainer signal = new MessageContainer { + Type = MessageType.Signal, + Path = object_path, + Interface = iface, + Member = member, + Signature = outSig, + }; - Message signalMsg = signal.message; - signalMsg.Body = writer.ToArray (); + Message signalMsg = signal.Message; + signalMsg.AttachBodyTo (writer); conn.Send (signalMsg); } - public object SendMethodCallOld (string iface, string member, string inSigStr, MessageWriter writer, Type retType, out Exception exception) - { - exception = null; - - //TODO: don't ignore retVal, exception etc. - - Signature inSig = String.IsNullOrEmpty (inSigStr) ? Signature.Empty : new Signature (inSigStr); - - MethodCall method_call = new MethodCall (object_path, iface, member, bus_name, inSig); - - Message callMsg = method_call.message; - callMsg.Body = writer.ToArray (); - - //Invoke Code:: - - //TODO: complete out parameter support - /* - Type[] outParmTypes = Mapper.GetTypes (ArgDirection.Out, mi.GetParameters ()); - Signature outParmSig = Signature.GetSig (outParmTypes); - - if (outParmSig != Signature.Empty) - throw new Exception ("Out parameters not yet supported: out_signature='" + outParmSig.Value + "'"); - */ - - Type[] outTypes = new Type[1]; - outTypes[0] = retType; - - //we default to always requiring replies for now, even though unnecessary - //this is to make sure errors are handled synchronously - //TODO: don't hard code this - bool needsReply = true; - - //if (mi.ReturnType == typeof (void)) - // needsReply = false; - - callMsg.ReplyExpected = needsReply; - callMsg.Signature = inSig; - - if (!needsReply) { - conn.Send (callMsg); - return null; - } - -#if PROTO_REPLY_SIGNATURE - if (needsReply) { - Signature outSig = Signature.GetSig (outTypes); - callMsg.Header[FieldCode.ReplySignature] = outSig; - } -#endif - - Message retMsg = conn.SendWithReplyAndBlock (callMsg); - - object retVal = null; - - //handle the reply message - switch (retMsg.Header.MessageType) { - case MessageType.MethodReturn: - object[] retVals = MessageHelper.GetDynamicValues (retMsg, outTypes); - if (retVals.Length != 0) - retVal = retVals[retVals.Length - 1]; - break; - case MessageType.Error: - //TODO: typed exceptions - Error error = new Error (retMsg); - string errMsg = String.Empty; - if (retMsg.Signature.Value.StartsWith ("s")) { - MessageReader reader = new MessageReader (retMsg); - errMsg = reader.ReadString (); - } - exception = new Exception (error.ErrorName + ": " + errMsg); - break; - default: - throw new Exception ("Got unexpected message of type " + retMsg.Header.MessageType + " while waiting for a MethodReturn or Error"); - } - - return retVal; - } - public MessageReader SendMethodCall (string iface, string member, string inSigStr, MessageWriter writer, Type retType, out Exception exception) { - exception = null; - - //TODO: don't ignore retVal, exception etc. + if (string.IsNullOrEmpty (bus_name)) + throw new ArgumentNullException ("bus_name"); + if (object_path == null) + throw new ArgumentNullException ("object_path"); + exception = null; Signature inSig = String.IsNullOrEmpty (inSigStr) ? Signature.Empty : new Signature (inSigStr); - MethodCall method_call = new MethodCall (object_path, iface, member, bus_name, inSig); + MessageContainer method_call = new MessageContainer { + Path = object_path, + Interface = iface, + Member = member, + Destination = bus_name, + Signature = inSig + }; - Message callMsg = method_call.message; - callMsg.Body = writer.ToArray (); + Message callMsg = method_call.Message; + callMsg.AttachBodyTo (writer); - //Invoke Code:: - - //TODO: complete out parameter support - /* - Type[] outParmTypes = Mapper.GetTypes (ArgDirection.Out, mi.GetParameters ()); - Signature outParmSig = Signature.GetSig (outParmTypes); - - if (outParmSig != Signature.Empty) - throw new Exception ("Out parameters not yet supported: out_signature='" + outParmSig.Value + "'"); - */ - - Type[] outTypes = new Type[1]; - outTypes[0] = retType; - - //we default to always requiring replies for now, even though unnecessary - //this is to make sure errors are handled synchronously - //TODO: don't hard code this bool needsReply = true; - //if (mi.ReturnType == typeof (void)) - // needsReply = false; - callMsg.ReplyExpected = needsReply; callMsg.Signature = inSig; @@ -217,7 +132,7 @@ #if PROTO_REPLY_SIGNATURE if (needsReply) { - Signature outSig = Signature.GetSig (outTypes); + Signature outSig = Signature.GetSig (retType); callMsg.Header[FieldCode.ReplySignature] = outSig; } #endif @@ -228,14 +143,11 @@ //handle the reply message switch (retMsg.Header.MessageType) { - case MessageType.MethodReturn: - if ((string)retMsg.Header[FieldCode.Sender] != bus_name) - alt_bus_name = (string)retMsg.Header[FieldCode.Sender]; - retVal = new MessageReader (retMsg); + case MessageType.MethodReturn: + retVal = new MessageReader (retMsg); break; - case MessageType.Error: - //TODO: typed exceptions - Error error = new Error (retMsg); + case MessageType.Error: + MessageContainer error = MessageContainer.FromMessage (retMsg); string errMsg = String.Empty; if (retMsg.Signature.Value.StartsWith ("s")) { MessageReader reader = new MessageReader (retMsg); @@ -243,7 +155,7 @@ } exception = new Exception (error.ErrorName + ": " + errMsg); break; - default: + default: throw new Exception ("Got unexpected message of type " + retMsg.Header.MessageType + " while waiting for a MethodReturn or Error"); } @@ -271,105 +183,33 @@ Type[] inTypes = Mapper.GetTypes (ArgDirection.In, mi.GetParameters ()); Signature inSig = Signature.GetSig (inTypes); - MethodCall method_call; - Message callMsg; - - //build the outbound method call message - { - //this bit is error-prone (no null checking) and will need rewriting when DProxy is replaced - string iface = null; - if (mi != null) - iface = Mapper.GetInterfaceName (mi); - - //map property accessors - //TODO: this needs to be done properly, not with simple String.Replace - //note that IsSpecialName is also for event accessors, but we already handled those and returned - if (mi != null && mi.IsSpecialName) { - methodName = methodName.Replace ("get_", "Get"); - methodName = methodName.Replace ("set_", "Set"); - } - - method_call = new MethodCall (object_path, iface, methodName, bus_name, inSig); - - callMsg = method_call.message; + string iface = null; + if (mi != null) + iface = Mapper.GetInterfaceName (mi); - if (inArgs != null && inArgs.Length != 0) { - MessageWriter writer = new MessageWriter (Connection.NativeEndianness); - writer.connection = conn; - - for (int i = 0 ; i != inTypes.Length ; i++) - writer.Write (inTypes[i], inArgs[i]); - - callMsg.Body = writer.ToArray (); - } + if (mi != null && mi.IsSpecialName) { + methodName = methodName.Replace ("get_", "Get"); + methodName = methodName.Replace ("set_", "Set"); } - //TODO: complete out parameter support - /* - Type[] outParmTypes = Mapper.GetTypes (ArgDirection.Out, mi.GetParameters ()); - Signature outParmSig = Signature.GetSig (outParmTypes); - - if (outParmSig != Signature.Empty) - throw new Exception ("Out parameters not yet supported: out_signature='" + outParmSig.Value + "'"); - */ - - Type[] outTypes = new Type[1]; - outTypes[0] = mi.ReturnType; - - //we default to always requiring replies for now, even though unnecessary - //this is to make sure errors are handled synchronously - //TODO: don't hard code this - bool needsReply = true; - - //if (mi.ReturnType == typeof (void)) - // needsReply = false; - - callMsg.ReplyExpected = needsReply; - callMsg.Signature = inSig; - - if (!needsReply) { - conn.Send (callMsg); - return; - } + MessageWriter writer = new MessageWriter (conn); -#if PROTO_REPLY_SIGNATURE - if (needsReply) { - Signature outSig = Signature.GetSig (outTypes); - callMsg.Header[FieldCode.ReplySignature] = outSig; + if (inArgs != null && inArgs.Length != 0) { + for (int i = 0 ; i != inTypes.Length ; i++) + writer.Write (inTypes[i], inArgs[i]); } -#endif - - Message retMsg = conn.SendWithReplyAndBlock (callMsg); - //handle the reply message - switch (retMsg.Header.MessageType) { - case MessageType.MethodReturn: - object[] retVals = MessageHelper.GetDynamicValues (retMsg, outTypes); - if (retVals.Length != 0) - retVal = retVals[retVals.Length - 1]; - break; - case MessageType.Error: - //TODO: typed exceptions - Error error = new Error (retMsg); - string errMsg = String.Empty; - if (retMsg.Signature.Value.StartsWith ("s")) { - MessageReader reader = new MessageReader (retMsg); - errMsg = reader.ReadString (); - } - exception = new Exception (error.ErrorName + ": " + errMsg); - break; - default: - throw new Exception ("Got unexpected message of type " + retMsg.Header.MessageType + " while waiting for a MethodReturn or Error"); - } + MessageReader reader = SendMethodCall (iface, methodName, inSig.Value, writer, mi.ReturnType, out exception); + if (reader == null) + return; - return; + retVal = reader.ReadValue (mi.ReturnType); } public static object GetObject (Connection conn, string bus_name, ObjectPath object_path, Type declType) { Type proxyType = TypeImplementer.Root.GetImplementation (declType); - //BusObject inst = (BusObject)Activator.CreateInstance (proxyType); object instObj = Activator.CreateInstance (proxyType); BusObject inst = GetBusObject (instObj); inst.conn = conn; @@ -379,7 +219,6 @@ return instObj; } - static Dictionary boCache = new Dictionary(); public static BusObject GetBusObject (object instObj) { if (instObj is BusObject) diff -Nru dbus-sharp-0.7.0/src/Connection.cs dbus-sharp-0.8.0/src/Connection.cs --- dbus-sharp-0.7.0/src/Connection.cs 2014-01-21 10:51:18.000000000 +0000 +++ dbus-sharp-0.8.0/src/Connection.cs 2013-07-26 21:04:04.000000000 +0000 @@ -12,20 +12,36 @@ { using Authentication; using Transports; + using Protocol; - public partial class Connection + public class Connection { + // Maybe we should use XDG/basedir or check an env var for this? + const string machineUuidPath = @"/var/lib/dbus/machine-id"; + + internal static readonly EndianFlag NativeEndianness = + BitConverter.IsLittleEndian ? EndianFlag.Little : EndianFlag.Big; + internal static readonly UUID MachineId = + File.Exists (machineUuidPath) ? ReadMachineId (machineUuidPath) : UUID.Zero; + Transport transport; - internal Transport Transport { - get { - return transport; - } set { - transport = value; - transport.Connection = this; - } - } + bool isConnected = false; + bool isShared = false; + UUID Id = UUID.Zero; + bool isAuthenticated = false; + int serial = 0; + + // STRONG TODO: GET RID OF THAT SHIT + internal Thread mainThread = Thread.CurrentThread; + + Dictionary pendingCalls = new Dictionary (); + Queue inbound = new Queue (); + Dictionary registeredObjects = new Dictionary (); - protected Connection () {} + protected Connection () + { + + } internal Connection (Transport transport) { @@ -33,23 +49,37 @@ transport.Connection = this; } - //should this be public? internal Connection (string address) { OpenPrivate (address); Authenticate (); } - internal bool isConnected = false; - public bool IsConnected - { + public bool IsConnected { get { return isConnected; } + internal set { + isConnected = value; + } + } + + internal bool IsAuthenticated { + get { + return isAuthenticated; + } + } + + internal Transport Transport { + get { + return transport; + } set { + transport = value; + transport.Connection = this; + } } // TODO: Complete disconnection support - internal bool isShared = false; public void Close () { if (isShared) @@ -58,10 +88,16 @@ if (!IsConnected) return; + CloseInternal (); + transport.Disconnect (); isConnected = false; } + protected virtual void CloseInternal () + { + } + //should we do connection sharing here? public static Connection Open (string address) { @@ -72,7 +108,7 @@ return conn; } - internal void OpenPrivate (string address) + void OpenPrivate (string address) { if (address == null) throw new ArgumentNullException ("address"); @@ -81,16 +117,25 @@ if (entries.Length == 0) throw new Exception ("No addresses were found"); - //TODO: try alternative addresses if needed - AddressEntry entry = entries[0]; + int index = 0; + while (index < entries.Length) { + AddressEntry entry = entries[index++]; + + Id = entry.GUID; + try { + Transport = Transport.Create (entry); + } catch { + if (index < entries.Length) + continue; + throw; + } + + break; + } - Id = entry.GUID; - Transport = Transport.Create (entry); isConnected = true; } - internal UUID Id = UUID.Zero; - void Authenticate () { if (transport != null) @@ -116,16 +161,8 @@ isAuthenticated = true; } - internal bool isAuthenticated = false; - internal bool IsAuthenticated - { - get { - return isAuthenticated; - } - } - - //Interlocked.Increment() handles the overflow condition for uint correctly, so it's ok to store the value as an int but cast it to uint - int serial = 0; + // Interlocked.Increment() handles the overflow condition for uint correctly, + // so it's ok to store the value as an int but cast it to uint internal uint GenerateSerial () { return (uint)Interlocked.Increment (ref serial); @@ -165,41 +202,25 @@ return msg.Header.Serial; } - Queue Inbound = new Queue (); - //temporary hack internal void DispatchSignals () { - lock (Inbound) { - while (Inbound.Count != 0) { - Message msg = Inbound.Dequeue (); + lock (inbound) { + while (inbound.Count != 0) { + Message msg = inbound.Dequeue (); HandleSignal (msg); } } } - internal Thread mainThread = Thread.CurrentThread; - - //temporary hack public void Iterate () { - mainThread = Thread.CurrentThread; - Message msg = transport.ReadMessage (); HandleMessage (msg); DispatchSignals (); } - internal void Dispatch () - { - while (transport.Inbound.Count != 0) { - Message msg = transport.Inbound.Dequeue (); - HandleMessage (msg); - } - DispatchSignals (); - } - internal virtual void HandleMessage (Message msg) { if (msg == null) @@ -227,7 +248,7 @@ } //we discard reply messages with no corresponding PendingCall - if (Protocol.Verbose) + if (ProtocolInformation.Verbose) Console.Error.WriteLine ("Unexpected reply message received: MessageType='" + msg.Header.MessageType + "', ReplySerial=" + reply_serial); return; @@ -236,17 +257,17 @@ switch (msg.Header.MessageType) { case MessageType.MethodCall: - MethodCall method_call = new MethodCall (msg); + MessageContainer method_call = MessageContainer.FromMessage (msg); HandleMethodCall (method_call); break; case MessageType.Signal: //HandleSignal (msg); - lock (Inbound) - Inbound.Enqueue (msg); + lock (inbound) + inbound.Enqueue (msg); break; case MessageType.Error: //TODO: better exception handling - Error error = new Error (msg); + MessageContainer error = MessageContainer.FromMessage (msg); string errMsg = String.Empty; if (msg.Signature.Value.StartsWith ("s")) { MessageReader reader = new MessageReader (msg); @@ -260,12 +281,10 @@ } } - Dictionary pendingCalls = new Dictionary (); - //this might need reworking with MulticastDelegate internal void HandleSignal (Message msg) { - Signal signal = new Signal (msg); + var signal = MessageContainer.FromMessage (msg); //TODO: this is a hack, not necessary when MatchRule is complete MatchRule rule = new MatchRule (); @@ -287,7 +306,7 @@ compatible = true; if (!compatible) { - if (Protocol.Verbose) + if (ProtocolInformation.Verbose) Console.Error.WriteLine ("Signal argument mismatch: " + signal.Interface + '.' + signal.Member); return; } @@ -296,7 +315,7 @@ dlg.DynamicInvoke (MessageHelper.GetDynamicValues (msg, mi.GetParameters ())); } else { //TODO: how should we handle this condition? sending an Error may not be appropriate in this case - if (Protocol.Verbose) + if (ProtocolInformation.Verbose) Console.Error.WriteLine ("Warning: No signal handler for " + signal.Member); } } @@ -304,7 +323,7 @@ internal Dictionary Handlers = new Dictionary (); //very messy - internal void MaybeSendUnknownMethodError (MethodCall method_call) + internal void MaybeSendUnknownMethodError (MessageContainer method_call) { Message msg = MessageHelper.CreateUnknownMethodError (method_call); if (msg != null) @@ -312,7 +331,7 @@ } //not particularly efficient and needs to be generalized - internal void HandleMethodCall (MethodCall method_call) + internal void HandleMethodCall (MessageContainer method_call) { //TODO: Ping and Introspect need to be abstracted and moved somewhere more appropriate once message filter infrastructure is complete @@ -342,9 +361,9 @@ //this is messy and inefficient List linkNodes = new List (); int depth = method_call.Path.Decomposed.Length; - foreach (ObjectPath pth in RegisteredObjects.Keys) { + foreach (ObjectPath pth in registeredObjects.Keys) { if (pth.Value == (method_call.Path.Value)) { - ExportObject exo = (ExportObject)RegisteredObjects[pth]; + ExportObject exo = (ExportObject)registeredObjects[pth]; exo.WriteIntrospect (intro); } else { for (ObjectPath cur = pth ; cur != null ; cur = cur.Parent) { @@ -361,13 +380,13 @@ intro.WriteEnd (); - Message reply = MessageHelper.ConstructReply (method_call, intro.xml); + Message reply = MessageHelper.ConstructReply (method_call, intro.Xml); Send (reply); return; } BusObject bo; - if (RegisteredObjects.TryGetValue (method_call.Path, out bo)) { + if (registeredObjects.TryGetValue (method_call.Path, out bo)) { ExportObject eo = (ExportObject)bo; eo.HandleMethodCall (method_call); } else { @@ -375,22 +394,17 @@ } } - Dictionary RegisteredObjects = new Dictionary (); - - //FIXME: this shouldn't be part of the core API - //that also applies to much of the other object mapping code - public object GetObject (Type type, string bus_name, ObjectPath path) { - //if (type == null) - // return GetObject (bus_name, path); + if (!CheckBusNameExists (bus_name)) + return null; //if the requested type is an interface, we can implement it efficiently //otherwise we fall back to using a transparent proxy if (type.IsInterface || type.IsAbstract) { return BusObject.GetObject (this, bus_name, path, type); } else { - if (Protocol.Verbose) + if (ProtocolInformation.Verbose) Console.Error.WriteLine ("Warning: Note that MarshalByRefObject use is not recommended; for best performance, define interfaces"); BusObject busObject = new BusObject (this, bus_name, path); @@ -404,16 +418,9 @@ return (T)GetObject (typeof (T), bus_name, path); } - [Obsolete ("Use the overload of Register() which does not take a bus_name parameter")] - public void Register (string bus_name, ObjectPath path, object obj) + protected virtual bool CheckBusNameExists (string busName) { - Register (path, obj); - } - - [Obsolete ("Use the overload of Unregister() which does not take a bus_name parameter")] - public object Unregister (string bus_name, ObjectPath path) - { - return Unregister (path); + return true; } public void Register (ObjectPath path, object obj) @@ -422,22 +429,22 @@ eo.Registered = true; //TODO: implement some kind of tree data structure or internal object hierarchy. right now we are ignoring the name and putting all object paths in one namespace, which is bad - RegisteredObjects[path] = eo; + registeredObjects[path] = eo; } public object Unregister (ObjectPath path) { BusObject bo; - if (!RegisteredObjects.TryGetValue (path, out bo)) + if (!registeredObjects.TryGetValue (path, out bo)) throw new Exception ("Cannot unregister " + path + " as it isn't registered"); - RegisteredObjects.Remove (path); + registeredObjects.Remove (path); ExportObject eo = (ExportObject)bo; eo.Registered = false; - return eo.obj; + return eo.Object; } //these look out of place, but are useful @@ -449,59 +456,13 @@ { } - // Maybe we should use XDG/basedir or check an env var for this? - const string machineUuidFilename = @"/var/lib/dbus/machine-id"; - static UUID? machineId = null; - private static object idReadLock = new object (); - internal static UUID MachineId - { - get { - lock (idReadLock) { - if (machineId != null) - return (UUID)machineId; - try { - machineId = ReadMachineId (machineUuidFilename); - } catch { - machineId = UUID.Zero; - } - return (UUID)machineId; - } - } - } - static UUID ReadMachineId (string fname) { - using (FileStream fs = File.OpenRead (fname)) { - // Length is typically 33 (32 for the UUID, plus a linefeed) - //if (fs.Length < 32) - // return UUID.Zero; - - byte[] data = new byte[32]; - - int pos = 0; - while (pos < data.Length) { - int read = fs.Read (data, pos, data.Length - pos); - if (read == 0) - break; - pos += read; - } - - if (pos != data.Length) - //return UUID.Zero; - throw new Exception ("Insufficient data while reading GUID string"); + byte[] data = File.ReadAllBytes (fname); + if (data.Length < 33) + return UUID.Zero; - return UUID.Parse (System.Text.Encoding.ASCII.GetString (data)); - } + return UUID.Parse (System.Text.Encoding.ASCII.GetString (data, 0, 32)); } - - static Connection () - { - if (BitConverter.IsLittleEndian) - NativeEndianness = EndianFlag.Little; - else - NativeEndianness = EndianFlag.Big; - } - - internal static readonly EndianFlag NativeEndianness; } } diff -Nru dbus-sharp-0.7.0/src/DBus.cs dbus-sharp-0.8.0/src/DBus.cs --- dbus-sharp-0.7.0/src/DBus.cs 2010-09-14 09:17:49.000000000 +0000 +++ dbus-sharp-0.8.0/src/DBus.cs 2013-07-26 21:04:04.000000000 +0000 @@ -34,9 +34,9 @@ public enum StartReply : uint { - //The service was successfully started. + // The service was successfully started. Success = 1, - //A connection already owns the given name. + // A connection already owns the given name. AlreadyRunning, } diff -Nru dbus-sharp-0.7.0/src/DProxy.cs dbus-sharp-0.8.0/src/DProxy.cs --- dbus-sharp-0.7.0/src/DProxy.cs 2010-09-14 09:17:49.000000000 +0000 +++ dbus-sharp-0.8.0/src/DProxy.cs 2013-07-26 21:04:04.000000000 +0000 @@ -9,6 +9,8 @@ namespace DBus { + using Protocol; + //marked internal because this is really an implementation detail and needs to be replaced internal class DProxy : RealProxy { @@ -62,17 +64,10 @@ return returnMessage; } - /* - public override ObjRef CreateObjRef (Type ServerType) - { - throw new System.NotImplementedException (); - } - */ - ~DProxy () { //FIXME: remove handlers/match rules here - if (Protocol.Verbose) + if (ProtocolInformation.Verbose) Console.Error.WriteLine ("Warning: Finalization of " + busObject.Path + " not yet supported"); } } diff -Nru dbus-sharp-0.7.0/src/ExportObject.cs dbus-sharp-0.8.0/src/ExportObject.cs --- dbus-sharp-0.7.0/src/ExportObject.cs 2010-09-14 09:17:49.000000000 +0000 +++ dbus-sharp-0.8.0/src/ExportObject.cs 2013-07-26 21:04:04.000000000 +0000 @@ -3,6 +3,7 @@ // See COPYING for details using System; +using System.Linq; using System.Collections.Generic; using System.Reflection; using System.Reflection.Emit; @@ -11,19 +12,23 @@ namespace DBus { + using Protocol; + //TODO: perhaps ExportObject should not derive from BusObject - internal class ExportObject : BusObject, IDisposable //, Peer + internal class ExportObject : BusObject, IDisposable { - public object obj; + //maybe add checks to make sure this is not called more than once + //it's a bit silly as a property + bool isRegistered = false; + Dictionary methodInfoCache = new Dictionary (); + + static readonly Dictionary mCallers = new Dictionary (); public ExportObject (Connection conn, ObjectPath object_path, object obj) : base (conn, null, object_path) { - this.obj = obj; + Object = obj; } - //maybe add checks to make sure this is not called more than once - //it's a bit silly as a property - bool isRegistered = false; public virtual bool Registered { get { @@ -33,9 +38,10 @@ if (value == isRegistered) return; - Type type = obj.GetType (); + Type type = Object.GetType (); - foreach (MemberInfo mi in Mapper.GetPublicMembers (type)) { + foreach (var memberForType in Mapper.GetPublicMembers (type)) { + MemberInfo mi = memberForType.Value; EventInfo ei = mi as EventInfo; if (ei == null) @@ -44,9 +50,9 @@ Delegate dlg = GetHookupDelegate (ei); if (value) - ei.AddEventHandler (obj, dlg); + ei.AddEventHandler (Object, dlg); else - ei.RemoveEventHandler (obj, dlg); + ei.RemoveEventHandler (Object, dlg); } isRegistered = value; @@ -55,15 +61,14 @@ internal virtual void WriteIntrospect (Introspector intro) { - intro.WriteType (obj.GetType ()); + intro.WriteType (Object.GetType ()); } - internal static MethodCaller2 GetMCaller (MethodInfo mi) + internal static MethodCaller GetMCaller (MethodInfo mi) { - MethodCaller2 mCaller; + MethodCaller mCaller; if (!mCallers.TryGetValue (mi, out mCaller)) { - //mCaller = TypeImplementer.GenCaller (mi, obj); - mCaller = TypeImplementer.GenCaller2 (mi); + mCaller = TypeImplementer.GenCaller (mi); mCallers[mi] = mCaller; } return mCaller; @@ -71,56 +76,36 @@ public static ExportObject CreateExportObject (Connection conn, ObjectPath object_path, object obj) { -#if DLR - Type type = obj.GetType (); - if (type.Name == "RubyObject" || type.FullName == "IronPython.Runtime.Types.OldInstance") - return new DynamicExportObject (conn, object_path, obj); -#endif - return new ExportObject (conn, object_path, obj); } - static internal readonly Dictionary mCallers = new Dictionary (); - public virtual void HandleMethodCall (MethodCall method_call) + public virtual void HandleMethodCall (MessageContainer method_call) { - Type type = obj.GetType (); - - //object retObj = type.InvokeMember (msg.Member, BindingFlags.InvokeMethod, null, obj, MessageHelper.GetDynamicValues (msg)); - - //TODO: there is no member name mapping for properties etc. yet - - // FIXME: Inefficient to do this on every call - MethodInfo mi = Mapper.GetMethod (type, method_call); + MethodInfo mi; + if (!methodInfoCache.TryGetValue (method_call.Member, out mi)) + methodInfoCache[method_call.Member] = mi = Mapper.GetMethod (Object.GetType (), method_call); if (mi == null) { conn.MaybeSendUnknownMethodError (method_call); return; } - MethodCaller2 mCaller; + MethodCaller mCaller; if (!mCallers.TryGetValue (mi, out mCaller)) { - //mCaller = TypeImplementer.GenCaller (mi, obj); - mCaller = TypeImplementer.GenCaller2 (mi); + mCaller = TypeImplementer.GenCaller (mi); mCallers[mi] = mCaller; } Signature inSig, outSig; TypeImplementer.SigsForMethod (mi, out inSig, out outSig); - Message msg = method_call.message; - MessageReader msgReader = new MessageReader (method_call.message); + Message msg = method_call.Message; + MessageReader msgReader = new MessageReader (msg); MessageWriter retWriter = new MessageWriter (); - /* - MessageWriter retWriter = null; - if (msg.ReplyExpected) - retWriter = new MessageWriter (); - */ - Exception raisedException = null; try { - //mCaller (msgReader, method_call.message, retWriter); - mCaller (obj, msgReader, method_call.message, retWriter); + mCaller (Object, msgReader, msg, retWriter); } catch (Exception e) { raisedException = e; } @@ -131,26 +116,26 @@ Message replyMsg; if (raisedException == null) { - MethodReturn method_return = new MethodReturn (msg.Header.Serial); - replyMsg = method_return.message; - replyMsg.Body = retWriter.ToArray (); + MessageContainer method_return = new MessageContainer { + Type = MessageType.MethodReturn, + ReplySerial = msg.Header.Serial + }; + replyMsg = method_return.Message; + replyMsg.AttachBodyTo (retWriter); replyMsg.Signature = outSig; } else { - Error error; // BusException allows precisely formatted Error messages. BusException busException = raisedException as BusException; if (busException != null) - error = method_call.CreateError (busException.ErrorName, busException.ErrorMessage); + replyMsg = method_call.CreateError (busException.ErrorName, busException.ErrorMessage); else if (raisedException is ArgumentException && raisedException.TargetSite.Name == mi.Name) { // Name match trick above is a hack since we don't have the resolved MethodInfo. ArgumentException argException = (ArgumentException)raisedException; using (System.IO.StringReader sr = new System.IO.StringReader (argException.Message)) { - error = method_call.CreateError ("org.freedesktop.DBus.Error.InvalidArgs", sr.ReadLine ()); + replyMsg = method_call.CreateError ("org.freedesktop.DBus.Error.InvalidArgs", sr.ReadLine ()); } } else - error = method_call.CreateError (Mapper.GetInterfaceName (raisedException.GetType ()), raisedException.Message); - - replyMsg = error.message; + replyMsg = method_call.CreateError (Mapper.GetInterfaceName (raisedException.GetType ()), raisedException.Message); } if (method_call.Sender != null) @@ -159,19 +144,11 @@ conn.Send (replyMsg); } - /* - public void Ping () - { - } - - public string GetMachineId () - { - //TODO: implement this - return String.Empty; + public object Object { + get; + private set; } - */ -#region IDisposable public void Dispose () { Dispose (true); @@ -185,15 +162,12 @@ protected virtual void Dispose (bool disposing) { - if (disposing) - { - if (obj != null) - { + if (disposing) { + if (Object != null) { Registered = false; - obj = null; + Object = null; } } } -#endregion } } diff -Nru dbus-sharp-0.7.0/src/Introspection.cs dbus-sharp-0.8.0/src/Introspection.cs --- dbus-sharp-0.7.0/src/Introspection.cs 2010-09-14 09:17:49.000000000 +0000 +++ dbus-sharp-0.8.0/src/Introspection.cs 2013-07-26 21:04:04.000000000 +0000 @@ -11,6 +11,8 @@ namespace DBus { + using Protocol; + //TODO: complete this class class Introspector { @@ -19,7 +21,6 @@ const string SYSTEM_IDENTIFIER = "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd"; public StringBuilder sb; - public string xml; public ObjectPath root_path = ObjectPath.Root; public bool ExtendedAnnotations = false; @@ -37,6 +38,11 @@ writer = XmlWriter.Create (sb, settings); } + public string Xml { + get; + private set; + } + static string GetProductDescription () { String version; @@ -84,7 +90,7 @@ writer.WriteEndElement (); writer.Flush (); - xml = sb.ToString (); + Xml = sb.ToString (); } //public void WriteNode () diff -Nru dbus-sharp-0.7.0/src/Makefile.am dbus-sharp-0.8.0/src/Makefile.am --- dbus-sharp-0.7.0/src/Makefile.am 2010-09-15 10:16:28.000000000 +0000 +++ dbus-sharp-0.8.0/src/Makefile.am 2013-10-07 00:35:48.000000000 +0000 @@ -1,61 +1,74 @@ ASSEMBLY = dbus-sharp TARGET = $(ASSEMBLY).dll +XBUILD_Q = $(XBUILD) /nologo /verbosity:quiet -CSFLAGS = \ - -debug -target:library -unsafe -d:STRONG_NAME -keyfile:$(top_srcdir)/dbus-sharp.snk - -LIBFLAGS = \ - -r:Mono.Posix - -CSFILES = \ - $(srcdir)/Address.cs \ - $(srcdir)/Authentication.cs \ - $(srcdir)/Bus.cs \ - $(srcdir)/BusObject.cs \ - $(srcdir)/Connection.cs \ - $(srcdir)/DBus.cs \ - $(srcdir)/DProxy.cs \ - $(srcdir)/ExportObject.cs \ - $(srcdir)/Introspection.cs \ - $(srcdir)/Protocol.cs \ - $(srcdir)/Mapper.cs \ - $(srcdir)/MatchRule.cs \ - $(srcdir)/Message.cs \ - $(srcdir)/MessageFilter.cs \ - $(srcdir)/MessageReader.cs \ - $(srcdir)/MessageWriter.cs \ - $(srcdir)/PendingCall.cs \ - $(srcdir)/Signature.cs \ - $(srcdir)/SocketTransport.cs \ - $(srcdir)/Transport.cs \ - $(srcdir)/TypeImplementer.cs \ - $(srcdir)/TypeRental.cs \ - $(srcdir)/Unix.cs \ - $(srcdir)/UnixNativeTransport.cs \ - $(srcdir)/UnixTransport.cs \ - $(srcdir)/Wrapper.cs +# Use the gencssources script to generate this list +CSFILES = Address.cs \ + Authentication.cs \ + Bus.cs \ + BusObject.cs \ + Connection.cs \ + DBus.cs \ + DProxy.cs \ + ExportObject.cs \ + Introspection.cs \ + Mapper.cs \ + TypeImplementer.cs \ + ArgDirection.cs \ + ObjectPath.cs \ + BusException.cs \ + AddressEntry.cs \ + Protocol/DBusStruct.cs \ + Protocol/DType.cs \ + Protocol/DValue.cs \ + Protocol/EndianFlag.cs \ + Protocol/FieldCode.cs \ + Protocol/Header.cs \ + Protocol/HeaderFlag.cs \ + Protocol/MatchRule.cs \ + Protocol/Message.cs \ + Protocol/MessageContainer.cs \ + Protocol/MessageDumper.cs \ + Protocol/MessageFilter.cs \ + Protocol/MessageReader.cs \ + Protocol/MessageType.cs \ + Protocol/MessageWriter.cs \ + Protocol/PendingCall.cs \ + Protocol/ProtocolInformation.cs \ + Protocol/Signature.cs \ + Protocol/SocketTransport.cs \ + Protocol/Transport.cs \ + Transports/UnixNativeTransport.cs \ + Transports/UnixTransport.cs \ + Unix/UnixStream.cs \ + Unix/UnixError.cs \ + Unix/UnixSocket.cs \ + AssemblyInfo.cs all: $(TARGET) $(TARGET): $(CSFILES) AssemblyInfo.cs - $(GMCS) -out:$@ $(CSFLAGS) $(LIBFLAGS) $^ + $(XBUILD_Q) dbus-sharp.csproj install-data-local: $(TARGET) @if test -n '$(TARGET)'; then \ - echo "$(GACUTIL) /i $(TARGET) /f /gacdir $(DESTDIR)$(libdir)"; \ + echo "$(GACUTIL) /i $(TARGET) /package $(PACKAGE)-$(API_VERSION) /f /gacdir $(libdir) /root $(DESTDIR)$(libdir)"; \ $(GACUTIL) /i $(TARGET) /package $(PACKAGE)-$(API_VERSION) /f /gacdir $(libdir) /root $(DESTDIR)$(libdir) || exit 1; \ fi uninstall-local: @if test -n '$(TARGET)'; then \ - echo "$(GACUTIL) /u $(ASSEMBLY) /gacdir $(DESTDIR)$(libdir)"; \ + echo "$(GACUTIL) /u $(ASSEMBLY) /package $(PACKAGE)-$(API_VERSION) /gacdir $(libdir) /root $(DESTDIR)$(libdir)"; \ $(GACUTIL) /u $(ASSEMBLY) /package $(PACKAGE)-$(API_VERSION) /gacdir $(libdir) /root $(DESTDIR)$(libdir) || exit 1; \ fi +.PHONY: $(TARGET) + EXTRA_DIST = \ $(CSFILES) \ $(srcdir)/dbus-sharp.dll.config \ - $(srcdir)/AssemblyInfo.cs.in + $(srcdir)/AssemblyInfo.cs.in \ + $(srcdir)/dbus-sharp.csproj CLEANFILES = \ $(TARGET) \ diff -Nru dbus-sharp-0.7.0/src/Makefile.in dbus-sharp-0.8.0/src/Makefile.in --- dbus-sharp-0.7.0/src/Makefile.in 2010-09-15 10:16:32.000000000 +0000 +++ dbus-sharp-0.8.0/src/Makefile.in 2013-10-07 00:49:05.000000000 +0000 @@ -1,9 +1,8 @@ -# Makefile.in generated by automake 1.11.1 from Makefile.am. +# Makefile.in generated by automake 1.13.2 from Makefile.am. # @configure_input@ -# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, -# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, -# Inc. +# Copyright (C) 1994-2013 Free Software Foundation, Inc. + # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. @@ -15,6 +14,51 @@ @SET_MAKE@ VPATH = @srcdir@ +am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' +am__make_running_with_option = \ + case $${target_option-} in \ + ?) ;; \ + *) echo "am__make_running_with_option: internal error: invalid" \ + "target option '$${target_option-}' specified" >&2; \ + exit 1;; \ + esac; \ + has_opt=no; \ + sane_makeflags=$$MAKEFLAGS; \ + if $(am__is_gnu_make); then \ + sane_makeflags=$$MFLAGS; \ + else \ + case $$MAKEFLAGS in \ + *\\[\ \ ]*) \ + bs=\\; \ + sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ + | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ + esac; \ + fi; \ + skip_next=no; \ + strip_trailopt () \ + { \ + flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ + }; \ + for flg in $$sane_makeflags; do \ + test $$skip_next = yes && { skip_next=no; continue; }; \ + case $$flg in \ + *=*|--*) continue;; \ + -*I) strip_trailopt 'I'; skip_next=yes;; \ + -*I?*) strip_trailopt 'I';; \ + -*O) strip_trailopt 'O'; skip_next=yes;; \ + -*O?*) strip_trailopt 'O';; \ + -*l) strip_trailopt 'l'; skip_next=yes;; \ + -*l?*) strip_trailopt 'l';; \ + -[dEDm]) skip_next=yes;; \ + -[JT]) skip_next=yes;; \ + esac; \ + case $$flg in \ + *$$target_option*) has_opt=yes; break;; \ + esac; \ + done; \ + test $$has_opt = yes +am__make_dryrun = (target_option=n; $(am__make_running_with_option)) +am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ @@ -32,8 +76,8 @@ PRE_UNINSTALL = : POST_UNINSTALL = : subdir = src -DIST_COMMON = $(srcdir)/AssemblyInfo.cs.in $(srcdir)/Makefile.am \ - $(srcdir)/Makefile.in +DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ + $(srcdir)/AssemblyInfo.cs.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ @@ -41,11 +85,30 @@ mkinstalldirs = $(install_sh) -d CONFIG_CLEAN_FILES = AssemblyInfo.cs CONFIG_CLEAN_VPATH_FILES = +AM_V_P = $(am__v_P_@AM_V@) +am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) +am__v_P_0 = false +am__v_P_1 = : +AM_V_GEN = $(am__v_GEN_@AM_V@) +am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) +am__v_GEN_0 = @echo " GEN " $@; +am__v_GEN_1 = +AM_V_at = $(am__v_at_@AM_V@) +am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) +am__v_at_0 = @ +am__v_at_1 = SOURCES = DIST_SOURCES = +am__can_run_installinfo = \ + case $$AM_UPDATE_INFO_DIR in \ + n|no|NO) false;; \ + *) (install-info --version) >/dev/null 2>&1;; \ + esac +am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ +AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ API_VERSION = @API_VERSION@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ @@ -71,6 +134,8 @@ MKDIR_P = @MKDIR_P@ MONO_CFLAGS = @MONO_CFLAGS@ MONO_LIBS = @MONO_LIBS@ +NUNIT_CFLAGS = @NUNIT_CFLAGS@ +NUNIT_LIBS = @NUNIT_LIBS@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ @@ -86,6 +151,7 @@ SHELL = @SHELL@ STRIP = @STRIP@ VERSION = @VERSION@ +XBUILD = @XBUILD@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ @@ -127,44 +193,56 @@ top_srcdir = @top_srcdir@ ASSEMBLY = dbus-sharp TARGET = $(ASSEMBLY).dll -CSFLAGS = \ - -debug -target:library -unsafe -d:STRONG_NAME -keyfile:$(top_srcdir)/dbus-sharp.snk +XBUILD_Q = $(XBUILD) /nologo /verbosity:quiet -LIBFLAGS = \ - -r:Mono.Posix - -CSFILES = \ - $(srcdir)/Address.cs \ - $(srcdir)/Authentication.cs \ - $(srcdir)/Bus.cs \ - $(srcdir)/BusObject.cs \ - $(srcdir)/Connection.cs \ - $(srcdir)/DBus.cs \ - $(srcdir)/DProxy.cs \ - $(srcdir)/ExportObject.cs \ - $(srcdir)/Introspection.cs \ - $(srcdir)/Protocol.cs \ - $(srcdir)/Mapper.cs \ - $(srcdir)/MatchRule.cs \ - $(srcdir)/Message.cs \ - $(srcdir)/MessageFilter.cs \ - $(srcdir)/MessageReader.cs \ - $(srcdir)/MessageWriter.cs \ - $(srcdir)/PendingCall.cs \ - $(srcdir)/Signature.cs \ - $(srcdir)/SocketTransport.cs \ - $(srcdir)/Transport.cs \ - $(srcdir)/TypeImplementer.cs \ - $(srcdir)/TypeRental.cs \ - $(srcdir)/Unix.cs \ - $(srcdir)/UnixNativeTransport.cs \ - $(srcdir)/UnixTransport.cs \ - $(srcdir)/Wrapper.cs +# Use the gencssources script to generate this list +CSFILES = Address.cs \ + Authentication.cs \ + Bus.cs \ + BusObject.cs \ + Connection.cs \ + DBus.cs \ + DProxy.cs \ + ExportObject.cs \ + Introspection.cs \ + Mapper.cs \ + TypeImplementer.cs \ + ArgDirection.cs \ + ObjectPath.cs \ + BusException.cs \ + AddressEntry.cs \ + Protocol/DBusStruct.cs \ + Protocol/DType.cs \ + Protocol/DValue.cs \ + Protocol/EndianFlag.cs \ + Protocol/FieldCode.cs \ + Protocol/Header.cs \ + Protocol/HeaderFlag.cs \ + Protocol/MatchRule.cs \ + Protocol/Message.cs \ + Protocol/MessageContainer.cs \ + Protocol/MessageDumper.cs \ + Protocol/MessageFilter.cs \ + Protocol/MessageReader.cs \ + Protocol/MessageType.cs \ + Protocol/MessageWriter.cs \ + Protocol/PendingCall.cs \ + Protocol/ProtocolInformation.cs \ + Protocol/Signature.cs \ + Protocol/SocketTransport.cs \ + Protocol/Transport.cs \ + Transports/UnixNativeTransport.cs \ + Transports/UnixTransport.cs \ + Unix/UnixStream.cs \ + Unix/UnixError.cs \ + Unix/UnixSocket.cs \ + AssemblyInfo.cs EXTRA_DIST = \ $(CSFILES) \ $(srcdir)/dbus-sharp.dll.config \ - $(srcdir)/AssemblyInfo.cs.in + $(srcdir)/AssemblyInfo.cs.in \ + $(srcdir)/dbus-sharp.csproj CLEANFILES = \ $(TARGET) \ @@ -211,11 +289,11 @@ $(am__aclocal_m4_deps): AssemblyInfo.cs: $(top_builddir)/config.status $(srcdir)/AssemblyInfo.cs.in cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ -tags: TAGS -TAGS: +tags TAGS: + +ctags CTAGS: -ctags: CTAGS -CTAGS: +cscope cscopelist: distdir: $(DISTFILES) @@ -262,10 +340,15 @@ installcheck: installcheck-am install-strip: - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - `test -z '$(STRIP)' || \ - echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install + if test -z '$(STRIP)'; then \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + install; \ + else \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ + fi mostlyclean-generic: clean-generic: @@ -348,35 +431,37 @@ .MAKE: install-am install-strip -.PHONY: all all-am check check-am clean clean-generic distclean \ - distclean-generic distdir dvi dvi-am html html-am info info-am \ - install install-am install-data install-data-am \ - install-data-local install-dvi install-dvi-am install-exec \ - install-exec-am install-html install-html-am install-info \ - install-info-am install-man install-pdf install-pdf-am \ - install-ps install-ps-am install-strip installcheck \ - installcheck-am installdirs maintainer-clean \ +.PHONY: all all-am check check-am clean clean-generic cscopelist-am \ + ctags-am distclean distclean-generic distdir dvi dvi-am html \ + html-am info info-am install install-am install-data \ + install-data-am install-data-local install-dvi install-dvi-am \ + install-exec install-exec-am install-html install-html-am \ + install-info install-info-am install-man install-pdf \ + install-pdf-am install-ps install-ps-am install-strip \ + installcheck installcheck-am installdirs maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-generic pdf \ - pdf-am ps ps-am uninstall uninstall-am uninstall-local + pdf-am ps ps-am tags-am uninstall uninstall-am uninstall-local all: $(TARGET) $(TARGET): $(CSFILES) AssemblyInfo.cs - $(GMCS) -out:$@ $(CSFLAGS) $(LIBFLAGS) $^ + $(XBUILD_Q) dbus-sharp.csproj install-data-local: $(TARGET) @if test -n '$(TARGET)'; then \ - echo "$(GACUTIL) /i $(TARGET) /f /gacdir $(DESTDIR)$(libdir)"; \ + echo "$(GACUTIL) /i $(TARGET) /package $(PACKAGE)-$(API_VERSION) /f /gacdir $(libdir) /root $(DESTDIR)$(libdir)"; \ $(GACUTIL) /i $(TARGET) /package $(PACKAGE)-$(API_VERSION) /f /gacdir $(libdir) /root $(DESTDIR)$(libdir) || exit 1; \ fi uninstall-local: @if test -n '$(TARGET)'; then \ - echo "$(GACUTIL) /u $(ASSEMBLY) /gacdir $(DESTDIR)$(libdir)"; \ + echo "$(GACUTIL) /u $(ASSEMBLY) /package $(PACKAGE)-$(API_VERSION) /gacdir $(libdir) /root $(DESTDIR)$(libdir)"; \ $(GACUTIL) /u $(ASSEMBLY) /package $(PACKAGE)-$(API_VERSION) /gacdir $(libdir) /root $(DESTDIR)$(libdir) || exit 1; \ fi +.PHONY: $(TARGET) + # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: diff -Nru dbus-sharp-0.7.0/src/Mapper.cs dbus-sharp-0.8.0/src/Mapper.cs --- dbus-sharp-0.7.0/src/Mapper.cs 2010-09-15 10:16:28.000000000 +0000 +++ dbus-sharp-0.8.0/src/Mapper.cs 2013-07-26 21:04:04.000000000 +0000 @@ -3,11 +3,14 @@ // See COPYING for details using System; +using System.Linq; using System.Collections.Generic; using System.Reflection; namespace DBus { + using Protocol; + static class Mapper { //TODO: move these Get*Name helpers somewhere more appropriate @@ -32,37 +35,52 @@ return argName; } - //TODO: these two methods are quite messy and need review - public static IEnumerable GetPublicMembers (Type type) + public static IEnumerable> GetPublicMembers (Type type) { //note that Type.GetInterfaces() returns all interfaces with flattened hierarchy - foreach (Type ifType in type.GetInterfaces ()) - foreach (MemberInfo mi in GetDeclaredPublicMembers (ifType)) - yield return mi; + foreach (Type ifType in type.GetInterfaces ()) { + if (!IsPublic (ifType)) + continue; + foreach (MemberInfo mi in WalkInterfaceHierarchy (ifType)) + yield return new KeyValuePair (ifType, mi); + } if (IsPublic (type)) foreach (MemberInfo mi in GetDeclaredPublicMembers (type)) + yield return new KeyValuePair (type, mi); + } + + static IEnumerable WalkInterfaceHierarchy (Type iface) + { + foreach (MemberInfo mi in GetDeclaredPublicMembers (iface)) + yield return mi; + + // We recurse to get the method the interface inherited from other interface + var internalIfaces = iface.GetInterfaces (); + foreach (var internalIface in internalIfaces) + foreach (var mi in WalkInterfaceHierarchy (internalIface)) yield return mi; } static IEnumerable GetDeclaredPublicMembers (Type type) { - if (IsPublic (type)) - foreach (MemberInfo mi in type.GetMembers (BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly)) - yield return mi; + foreach (MemberInfo mi in type.GetMembers (BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly)) + yield return mi; } //this method walks the interface tree in an undefined manner and returns the first match, or if no matches are found, null //the logic needs review and cleanup //TODO: unify member name mapping as is already done with interfaces and args - public static MethodInfo GetMethod (Type type, MethodCall method_call) + public static MethodInfo GetMethod (Type type, MessageContainer method_call) { - foreach (MemberInfo member in Mapper.GetPublicMembers (type)) { + var mems = Mapper.GetPublicMembers (type).ToArray (); + foreach (var memberForType in mems) { //this could be made more efficient by using the given interface name earlier and avoiding walking through all public interfaces if (method_call.Interface != null) - if (GetInterfaceName (member) != method_call.Interface) + if (GetInterfaceName (memberForType.Key) != method_call.Interface) continue; + MemberInfo member = memberForType.Value; MethodInfo meth = null; Type[] inTypes = null; @@ -118,7 +136,8 @@ if (type.IsDefined (typeof (InterfaceAttribute), false)) return true; - if (type.IsSubclassOf (typeof (MarshalByRefObject))) + if (type.IsSubclassOf (typeof (MarshalByRefObject)) && + type.GetCustomAttributes (typeof (ExportInterfaceMembersOnlyAttribute), true).Length == 0) return true; return false; @@ -131,15 +150,11 @@ public static string GetInterfaceName (Type type) { - string interfaceName = type.FullName; - - //TODO: better fallbacks and namespace mangling when no InterfaceAttribute is available - - //TODO: no need for foreach - foreach (InterfaceAttribute ia in type.GetCustomAttributes (typeof (InterfaceAttribute), true)) - interfaceName = ia.Name; - - return interfaceName; + return type.GetCustomAttributes (typeof (InterfaceAttribute), true) + .Cast () + .Select (i => i.Name) + .DefaultIfEmpty (type.FullName) + .FirstOrDefault (); } public static Type[] GetTypes (ArgDirection dir, ParameterInfo[] parms) @@ -174,64 +189,43 @@ return attrProvider.IsDefined (typeof (ObsoleteAttribute), true); } - static bool AreEqual (Type[] a, Type[] b) - { - if (a.Length != b.Length) - return false; - - for (int i = 0 ; i != a.Length ; i++) - if (a[i] != b[i]) - return false; - - return true; - } - - //workaround for Mono bug #81035 (memory leak) - static List genTypes = new List (); internal static Type GetGenericType (Type defType, Type[] parms) { - lock (genTypes) { - foreach (Type genType in genTypes) { - if (genType.GetGenericTypeDefinition () != defType) - continue; - - Type[] genParms = genType.GetGenericArguments (); - - if (!AreEqual (genParms, parms)) - continue; - - return genType; - } - - Type type = defType.MakeGenericType (parms); - genTypes.Add (type); - return type; - } + Type type = defType.MakeGenericType (parms); + return type; } } //TODO: this class is messy, move the methods somewhere more appropriate static class MessageHelper { - public static Message CreateUnknownMethodError (MethodCall method_call) + public static Message CreateUnknownMethodError (MessageContainer method_call) { - if (!method_call.message.ReplyExpected) + Message msg = method_call.Message; + if (!msg.ReplyExpected) return null; - string errMsg = String.Format ("Method \"{0}\" with signature \"{1}\" on interface \"{2}\" doesn't exist", method_call.Member, method_call.Signature.Value, method_call.Interface); - - Error error = new Error ("org.freedesktop.DBus.Error.UnknownMethod", method_call.message.Header.Serial); - error.message.Signature = new Signature (DType.String); + string errMsg = String.Format ("Method \"{0}\" with signature \"{1}\" on interface \"{2}\" doesn't exist", + method_call.Member, + method_call.Signature.Value, + method_call.Interface); + + var error = new MessageContainer { + ErrorName = "org.freedesktop.DBus.Error.UnknownMethod", + Serial = msg.Header.Serial, + Signature = Signature.StringSig, + }; MessageWriter writer = new MessageWriter (Connection.NativeEndianness); writer.Write (errMsg); - error.message.Body = writer.ToArray (); + msg = error.Message; + msg.AttachBodyTo (writer); //TODO: we should be more strict here, but this fallback was added as a quick fix for p2p if (method_call.Sender != null) - error.message.Header[FieldCode.Destination] = method_call.Sender; + msg.Header[FieldCode.Destination] = method_call.Sender; - return error.message; + return msg; } public static void WriteDynamicValues (MessageWriter mw, ParameterInfo[] parms, object[] vals) @@ -275,7 +269,7 @@ public static object[] GetDynamicValues (Message msg, Type[] types) { //TODO: this validation check should provide better information, eg. message dump or a stack trace, or at least the interface/member - if (Protocol.Verbose) { + if (ProtocolInformation.Verbose) { Signature expected = Signature.GetSig (types); Signature actual = msg.Signature; if (actual != expected) @@ -300,10 +294,14 @@ return GetDynamicValues (msg, types); } - public static Message ConstructReply (MethodCall method_call, params object[] vals) + public static Message ConstructReply (MessageContainer method_call, params object[] vals) { - MethodReturn method_return = new MethodReturn (method_call.message.Header.Serial); - Message replyMsg = method_return.message; + var msg = method_call.Message; + MessageContainer method_return = new MessageContainer { + Type = MessageType.MethodReturn, + ReplySerial = msg.Header.Serial + }; + Message replyMsg = method_return.Message; Signature inSig = Signature.GetSig (vals); @@ -313,7 +311,7 @@ foreach (object arg in vals) writer.Write (arg.GetType (), arg); - replyMsg.Body = writer.ToArray (); + replyMsg.AttachBodyTo (writer); } //TODO: we should be more strict here, but this fallback was added as a quick fix for p2p @@ -327,12 +325,14 @@ return replyMsg; } - public static Message ConstructDynamicReply (MethodCall method_call, MethodInfo mi, object retVal, object[] vals) + public static Message ConstructDynamicReply (MessageContainer method_call, MethodInfo mi, object retVal, object[] vals) { Type retType = mi.ReturnType; - MethodReturn method_return = new MethodReturn (method_call.message.Header.Serial); - Message replyMsg = method_return.message; + MessageContainer method_return = new MessageContainer { + Serial = method_call.Serial, + }; + Message replyMsg = method_return.Message; Signature outSig = Signature.GetSig (retType); outSig += Signature.GetSig (Mapper.GetTypes (ArgDirection.Out, mi.GetParameters ())); @@ -347,7 +347,7 @@ //then write the out args WriteDynamicValues (writer, mi.GetParameters (), vals); - replyMsg.Body = writer.ToArray (); + replyMsg.AttachBodyTo (writer); } //TODO: we should be more strict here, but this fallback was added as a quick fix for p2p @@ -360,6 +360,11 @@ } } + [AttributeUsage (AttributeTargets.Class, AllowMultiple=false, Inherited=true)] + public class ExportInterfaceMembersOnlyAttribute : Attribute + { + } + [AttributeUsage (AttributeTargets.Interface | AttributeTargets.Class, AllowMultiple=false, Inherited=true)] public class InterfaceAttribute : Attribute { diff -Nru dbus-sharp-0.7.0/src/MatchRule.cs dbus-sharp-0.8.0/src/MatchRule.cs --- dbus-sharp-0.7.0/src/MatchRule.cs 2010-09-14 09:17:49.000000000 +0000 +++ dbus-sharp-0.8.0/src/MatchRule.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,319 +0,0 @@ -// Copyright 2007 Alp Toker -// This software is made available under the MIT License -// See COPYING for details - -using System; -using System.Text; -using System.Text.RegularExpressions; -using System.Collections.Generic; - -namespace DBus -{ - class MatchRule - { - public MessageType? MessageType; - public readonly SortedList Fields = new SortedList (); - //public readonly SortedList Args = new SortedList (); - public readonly HashSet Args = new HashSet (); - - public MatchRule () - { - } - - static void Append (StringBuilder sb, string key, object value) - { - Append (sb, key, value.ToString ()); - } - - static void Append (StringBuilder sb, string key, string value) - { - if (sb.Length != 0) - sb.Append (','); - - sb.Append (key); - sb.Append ("='"); - sb.Append (value.Replace (@"\", @"\\").Replace (@"'", @"\'")); - sb.Append ('\''); - } - - static void AppendArg (StringBuilder sb, int index, string value) - { - Append (sb, "arg" + index, value); - } - - static void AppendPathArg (StringBuilder sb, int index, ObjectPath value) - { - Append (sb, "arg" + index + "path", value.ToString ()); - } - - public override bool Equals (object o) - { - MatchRule r = o as MatchRule; - if (o == null) - return false; - - return ToString () == r.ToString (); - } - - public override int GetHashCode () - { - //FIXME: not at all optimal - return ToString ().GetHashCode (); - } - - public override string ToString () - { - StringBuilder sb = new StringBuilder (); - - if (MessageType != null) - Append (sb, "type", MessageFilter.MessageTypeToString ((MessageType)MessageType)); - - // Note that fdo D-Bus daemon sorts in a different order. - // It shouldn't matter though as long as we're consistent. - foreach (KeyValuePair pair in Fields) { - Append (sb, pair.Key.ToString ().ToLower (), pair.Value.Value); - } - - // Sorting the list here is not ideal - List tests = new List (Args); - tests.Sort ( delegate (ArgMatchTest aa, ArgMatchTest bb) { return aa.ArgNum - bb.ArgNum; } ); - - if (Args != null) - foreach (ArgMatchTest test in tests) - if (test.Signature == Signature.StringSig) - AppendArg (sb, test.ArgNum, (string)test.Value); - else if (test.Signature == Signature.ObjectPathSig) - AppendPathArg (sb, test.ArgNum, (ObjectPath)test.Value); - - return sb.ToString (); - } - - public static void Test (HashSet a, Message msg) - { - List sigs = new List (); - sigs.AddRange (msg.Signature.GetParts ()); - - if (sigs.Count == 0) { - a.Clear (); - return; - } - - a.RemoveWhere ( delegate (ArgMatchTest t) { return t.ArgNum >= sigs.Count || t.Signature != sigs[t.ArgNum]; } ); - - // Sorting the list here is not ideal - List tests = new List (a); - tests.Sort ( delegate (ArgMatchTest aa, ArgMatchTest bb) { return aa.ArgNum - bb.ArgNum; } ); - - if (tests.Count == 0) { - a.Clear (); - return; - } - - MessageReader reader = new MessageReader (msg); - - int argNum = 0; - foreach (ArgMatchTest test in tests) { - if (argNum > test.ArgNum) { - // This test cannot pass because a previous test already did. - // So we already know it will fail without even trying. - // This logic will need to be changed to support wildcards. - a.Remove (test); - continue; - } - - while (argNum != test.ArgNum) { - Signature sig = sigs[argNum]; - if (!reader.StepOver (sig)) - throw new Exception (); - argNum++; - } - - // TODO: Avoid re-reading values - int savedPos = reader.pos; - if (!reader.ReadValue (test.Signature[0]).Equals (test.Value)) { - a.Remove (test); - reader.pos = savedPos; - continue; - } - - argNum++; - } - } - - public bool MatchesHeader (Message msg) - { - if (MessageType != null) - if (msg.Header.MessageType != MessageType) - return false; - - foreach (KeyValuePair pair in Fields) { - object value; - if (!msg.Header.Fields.TryGetValue ((byte)pair.Key, out value)) - return false; - if (!pair.Value.Value.Equals (value)) - return false; - } - - return true; - } - - static Regex argNRegex = new Regex (@"^arg(\d+)(path)?$"); - static Regex matchRuleRegex = new Regex (@"(\w+)\s*=\s*'((\\\\|\\'|[^'\\])*)'", RegexOptions.Compiled); - public static MatchRule Parse (string text) - { - if (text.Length > Protocol.MaxMatchRuleLength) - throw new Exception ("Match rule length exceeds maximum " + Protocol.MaxMatchRuleLength + " characters"); - - MatchRule r = new MatchRule (); - - // TODO: Stricter validation. Tighten up the regex. - // It currently succeeds and silently drops malformed test parts. - - for (Match m = matchRuleRegex.Match (text) ; m.Success ; m = m.NextMatch ()) { - string key = m.Groups[1].Value; - string value = m.Groups[2].Value; - // This unescaping may not be perfect.. - value = value.Replace (@"\\", @"\"); - value = value.Replace (@"\'", @"'"); - - if (key.StartsWith ("arg")) { - Match mArg = argNRegex.Match (key); - if (!mArg.Success) - return null; - int argNum = (int)UInt32.Parse (mArg.Groups[1].Value); - - if (argNum < 0 || argNum >= Protocol.MaxMatchRuleArgs) - throw new Exception ("arg match must be between 0 and " + (Protocol.MaxMatchRuleArgs - 1) + " inclusive"); - - //if (r.Args.ContainsKey (argNum)) - // return null; - - string argType = mArg.Groups[2].Value; - - if (argType == "path") - r.Args.Add (new ArgMatchTest (argNum, new ObjectPath (value))); - else - r.Args.Add (new ArgMatchTest (argNum, value)); - - continue; - } - - //TODO: more consistent error handling - switch (key) { - case "type": - if (r.MessageType != null) - return null; - r.MessageType = MessageFilter.StringToMessageType (value); - break; - case "interface": - r.Fields[FieldCode.Interface] = new MatchTest (value); - break; - case "member": - r.Fields[FieldCode.Member] = new MatchTest (value); - break; - case "path": - r.Fields[FieldCode.Path] = new MatchTest (new ObjectPath (value)); - break; - case "sender": - r.Fields[FieldCode.Sender] = new MatchTest (value); - break; - case "destination": - r.Fields[FieldCode.Destination] = new MatchTest (value); - break; - default: - if (Protocol.Verbose) - Console.Error.WriteLine ("Warning: Unrecognized match rule key: " + key); - break; - } - } - - return r; - } - } - - class HeaderTest : MatchTest - { - public FieldCode Field; - public HeaderTest (FieldCode field, object value) - { - Field = field; - Signature = Signature.GetSig (value.GetType ()); - Value = value; - } - } - - struct ArgMatchTest - { - public int ArgNum; - public Signature Signature; - public object Value; - - public ArgMatchTest (int argNum, string value) - { - ArgNum = argNum; - Signature = Signature.StringSig; - Value = value; - } - - public ArgMatchTest (int argNum, ObjectPath value) - { - ArgNum = argNum; - Signature = Signature.ObjectPathSig; - Value = value; - } - - public override int GetHashCode () - { - return Signature.GetHashCode () ^ Value.GetHashCode () ^ ArgNum; - } - } - - /* - class ArgMatchTest : MatchTest - { - public int ArgNum; - - public ArgMatchTest (int argNum, string value) : base (value) - { - ArgNum = argNum; - } - - public ArgMatchTest (int argNum, ObjectPath value) : base (value) - { - ArgNum = argNum; - } - - public override int GetHashCode () - { - return base.GetHashCode () ^ ArgNum; - } - } - */ - - class MatchTest - { - public Signature Signature; - public object Value; - - public override int GetHashCode () - { - return Signature.GetHashCode () ^ Value.GetHashCode (); - } - - protected MatchTest () - { - } - - public MatchTest (string value) - { - Signature = Signature.StringSig; - Value = value; - } - - public MatchTest (ObjectPath value) - { - Signature = Signature.ObjectPathSig; - Value = value; - } - } -} diff -Nru dbus-sharp-0.7.0/src/Message.cs dbus-sharp-0.8.0/src/Message.cs --- dbus-sharp-0.7.0/src/Message.cs 2010-09-14 09:17:49.000000000 +0000 +++ dbus-sharp-0.8.0/src/Message.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,499 +0,0 @@ -// Copyright 2006 Alp Toker -// This software is made available under the MIT License -// See COPYING for details - -using System; -using System.Collections.Generic; -using System.IO; - -namespace DBus -{ - class Message - { - public Message () - { - Header.Endianness = Connection.NativeEndianness; - Header.MessageType = MessageType.MethodCall; - Header.Flags = HeaderFlag.NoReplyExpected; //TODO: is this the right place to do this? - Header.MajorVersion = Protocol.Version; - Header.Fields = new Dictionary (); - } - - public Header Header = new Header (); - - public Connection Connection; - - public Signature Signature - { - get { - object o = Header[FieldCode.Signature]; - if (o == null) - return Signature.Empty; - else - return (Signature)o; - } set { - if (value == Signature.Empty) - Header[FieldCode.Signature] = null; - else - Header[FieldCode.Signature] = value; - } - } - - public bool ReplyExpected - { - get { - return (Header.Flags & HeaderFlag.NoReplyExpected) == HeaderFlag.None; - } set { - if (value) - Header.Flags &= ~HeaderFlag.NoReplyExpected; //flag off - else - Header.Flags |= HeaderFlag.NoReplyExpected; //flag on - } - } - - //public HeaderField[] HeaderFields; - //public Dictionary; - - public byte[] Body; - - //TODO: make use of Locked - /* - protected bool locked = false; - public bool Locked - { - get { - return locked; - } - } - */ - - public void HandleHeader (Header headerIn) - { - Header = headerIn; - } - - static System.Reflection.MethodInfo hHandler = typeof (Message).GetMethod ("HandleHeader"); - public void SetHeaderData (byte[] data) - { - EndianFlag endianness = (EndianFlag)data[0]; - MessageReader reader = new MessageReader (endianness, data); - - MethodCaller2 mCaller = ExportObject.GetMCaller (hHandler); - mCaller (this, reader, null, new MessageWriter ()); - } - - //public HeaderField[] Fields; - - /* - public void SetHeaderData (byte[] data) - { - EndianFlag endianness = (EndianFlag)data[0]; - MessageReader reader = new MessageReader (endianness, data); - - Header = (Header)reader.ReadStruct (typeof (Header)); - } - */ - - //TypeWriter
headerWriter = TypeImplementer.GetTypeWriter
(); - public byte[] GetHeaderData () - { - if (Body != null) - Header.Length = (uint)Body.Length; - - MessageWriter writer = new MessageWriter (Header.Endianness); - - //writer.stream.Capacity = 512; - //headerWriter (writer, Header); - - writer.Write ((byte)Header.Endianness); - writer.Write ((byte)Header.MessageType); - writer.Write ((byte)Header.Flags); - writer.Write (Header.MajorVersion); - writer.Write (Header.Length); - writer.Write (Header.Serial); - writer.WriteHeaderFields (Header.Fields); - - writer.CloseWrite (); - - return writer.ToArray (); - } - - public void GetHeaderDataToStream (Stream stream) - { - if (Body != null) - Header.Length = (uint)Body.Length; - - MessageWriter writer = new MessageWriter (Header.Endianness); - - //headerWriter (writer, Header); - - writer.Write ((byte)Header.Endianness); - writer.Write ((byte)Header.MessageType); - writer.Write ((byte)Header.Flags); - writer.Write (Header.MajorVersion); - writer.Write (Header.Length); - writer.Write (Header.Serial); - writer.WriteHeaderFields (Header.Fields); - - writer.CloseWrite (); - - writer.ToStream (stream); - } - } - - // Allows conversion of complex variants via System.Convert - class DValue : IConvertible - { - // TODO: Note that we currently drop the originating Connection/Message details - // They may be useful later in conversion! - - internal EndianFlag endianness; - internal Signature signature; - internal byte[] data; - - public bool CanConvertTo (Type conversionType) - { - Signature typeSig = Signature.GetSig (conversionType); - return signature == typeSig; - } - - public TypeCode GetTypeCode () - { - return TypeCode.Object; - } - - public object ToType (Type conversionType) - { - return ToType (conversionType, null); - } - - public object ToType (Type conversionType, IFormatProvider provider) - { - Signature typeSig = Signature.GetSig (conversionType); - if (typeSig != signature) - throw new InvalidCastException (); - - MessageReader reader = new MessageReader (endianness, data); - return reader.ReadValue (conversionType); - } - - public override string ToString () - { - // Seems a reasonable way of providing the signature to the API layer - return signature.ToString (); - } - - // IConvertible implementation: - - /* - public TypeCode GetTypeCode () - { - throw new NotSupportedException (); - } - */ - - public bool ToBoolean (IFormatProvider provider) - { - throw new NotSupportedException (); - } - - public byte ToByte (IFormatProvider provider) - { - throw new NotSupportedException (); - } - - public char ToChar (IFormatProvider provider) - { - throw new NotSupportedException (); - } - - public DateTime ToDateTime (IFormatProvider provider) - { - throw new NotSupportedException (); - } - - public decimal ToDecimal (IFormatProvider provider) - { - throw new NotSupportedException (); - } - - public double ToDouble (IFormatProvider provider) - { - throw new NotSupportedException (); - } - - public short ToInt16 (IFormatProvider provider) - { - throw new NotSupportedException (); - } - - public int ToInt32 (IFormatProvider provider) - { - throw new NotSupportedException (); - } - - public long ToInt64 (IFormatProvider provider) - { - throw new NotSupportedException (); - } - - public sbyte ToSByte (IFormatProvider provider) - { - throw new NotSupportedException (); - } - - public float ToSingle (IFormatProvider provider) - { - throw new NotSupportedException (); - } - - public string ToString (IFormatProvider provider) - { - throw new NotSupportedException (); - } - - /* - public object ToType (Type conversionType, IFormatProvider provider) - { - throw new NotSupportedException (); - } - */ - - public ushort ToUInt16 (IFormatProvider provider) - { - throw new NotSupportedException (); - } - - public uint ToUInt32 (IFormatProvider provider) - { - throw new NotSupportedException (); - } - - public ulong ToUInt64 (IFormatProvider provider) - { - throw new NotSupportedException (); - } - } - - partial class MessageReader - { - // Note: This method doesn't support aggregate signatures - public bool StepOver (Signature sig) - { - if (sig == Signature.VariantSig) { - Signature valueSig = ReadSignature (); - return StepOver (valueSig); - } - - if (sig == Signature.StringSig) { - uint valueLength = ReadUInt32 (); - pos += (int)valueLength; - pos++; - return true; - } - - if (sig == Signature.ObjectPathSig) { - uint valueLength = ReadUInt32 (); - pos += (int)valueLength; - pos++; - return true; - } - - if (sig == Signature.SignatureSig) { - byte valueLength = ReadByte (); - pos += valueLength; - pos++; - return true; - } - - // No need to handle dicts specially. IsArray does the job - if (sig.IsArray) { - Signature elemSig = sig.GetElementSignature (); - uint ln = ReadUInt32 (); - pos = Protocol.Padded (pos, elemSig.Alignment); - pos += (int)ln; - return true; - } - - int endPos = pos; - if (sig.GetFixedSize (ref endPos)) { - pos = endPos; - return true; - } - - if (sig.IsDictEntry) { - pos = Protocol.Padded (pos, sig.Alignment); - Signature sigKey, sigValue; - sig.GetDictEntrySignatures (out sigKey, out sigValue); - if (!StepOver (sigKey)) - return false; - if (!StepOver (sigValue)) - return false; - return true; - } - - if (sig.IsStruct) { - pos = Protocol.Padded (pos, sig.Alignment); - foreach (Signature fieldSig in sig.GetFieldSignatures ()) - if (!StepOver (fieldSig)) - return false; - return true; - } - - throw new Exception ("Can't step over '" + sig + "'"); - //return false; - } - - public IEnumerable StepInto (Signature sig) - { - if (sig == Signature.VariantSig) { - Signature valueSig = ReadSignature (); - yield return valueSig; - yield break; - } - - // No need to handle dicts specially. IsArray does the job - if (sig.IsArray) { - Signature elemSig = sig.GetElementSignature (); - uint ln = ReadUInt32 (); - ReadPad (elemSig.Alignment); - int endPos = pos + (int)ln; - while (pos < endPos) - yield return elemSig; - yield break; - } - - if (sig.IsDictEntry) { - pos = Protocol.Padded (pos, sig.Alignment); - Signature sigKey, sigValue; - sig.GetDictEntrySignatures (out sigKey, out sigValue); - yield return sigKey; - yield return sigValue; - yield break; - } - - if (sig.IsStruct) { - pos = Protocol.Padded (pos, sig.Alignment); - foreach (Signature fieldSig in sig.GetFieldSignatures ()) - yield return fieldSig; - yield break; - } - - throw new Exception ("Can't step into '" + sig + "'"); - //yield break; - } - } - - class MessageDumper - { - public static byte[] ReadBlock (TextReader r) - { - //if (Body == null) - // return; - - MemoryStream ms = new MemoryStream (); - - while (true) { - string ln = r.ReadLine (); - if (ln == null) - break; - if (!ReadFromHex (ms, ln)) - break; - } - - if (ms.Length == 0) - return null; - - return ms.ToArray (); - } - - public static void WriteComment (string comment, TextWriter w) - { - w.WriteLine ("# " + comment); - } - - public static void WriteBlock (byte[] Body, TextWriter w) - { - //if (Body == null) - // return; - if (Body != null) - for (int i = 0 ; i != Body.Length ; i++) { - if (i == 0) {} - else if (i % 32 == 0) - w.WriteLine (); - else if (i % 4 == 0) - w.Write (' '); - - w.Write (Body[i].ToString ("x2", System.Globalization.CultureInfo.InvariantCulture)); - } - - w.Write ('.'); - w.WriteLine (); - w.Flush (); - } - - public static void WriteMessage (Message msg, TextWriter w) - { - w.WriteLine ("# Message"); - w.WriteLine ("# Header"); - MessageDumper.WriteBlock (msg.GetHeaderData (), w); - w.WriteLine ("# Body"); - MessageDumper.WriteBlock (msg.Body, w); - w.WriteLine (); - w.Flush (); - } - - public static Message ReadMessage (TextReader r) - { - byte[] header = MessageDumper.ReadBlock (r); - - if (header == null) - return null; - - byte[] body = MessageDumper.ReadBlock (r); - - Message msg = new Message (); - msg.SetHeaderData (header); - msg.Body = body; - - return msg; - } - - static byte FromHexChar (char c) - { - if ((c >= 'a') && (c <= 'f')) - return (byte) (c - 'a' + 10); - if ((c >= 'A') && (c <= 'F')) - return (byte) (c - 'A' + 10); - if ((c >= '0') && (c <= '9')) - return (byte) (c - '0'); - throw new ArgumentException ("Invalid hex char"); - } - - static bool ReadFromHex (Stream ms, string hex) - { - if (hex.StartsWith ("#")) - return true; - - int i = 0; - while (i < hex.Length) { - if (char.IsWhiteSpace (hex [i])) { - i++; - continue; - } - - if (hex [i] == '.') { - ms.Flush (); - return false; - } - - byte res = (byte) (FromHexChar (hex [i++]) << 4); - res += FromHexChar (hex [i++]); - ms.WriteByte (res); - } - - ms.Flush (); - return true; - } - } -} diff -Nru dbus-sharp-0.7.0/src/MessageFilter.cs dbus-sharp-0.8.0/src/MessageFilter.cs --- dbus-sharp-0.7.0/src/MessageFilter.cs 2010-09-14 09:17:49.000000000 +0000 +++ dbus-sharp-0.8.0/src/MessageFilter.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,58 +0,0 @@ -// Copyright 2006 Alp Toker -// This software is made available under the MIT License -// See COPYING for details - -using System; - -namespace DBus -{ - class MessageFilter - { - //this should probably be made to use HeaderField or similar - //this class is not generalized yet - - public static string MessageTypeToString (MessageType mtype) - { - switch (mtype) - { - case MessageType.MethodCall: - return "method_call"; - case MessageType.MethodReturn: - return "method_return"; - case MessageType.Error: - return "error"; - case MessageType.Signal: - return "signal"; - case MessageType.Invalid: - return "invalid"; - default: - throw new Exception ("Bad MessageType: " + mtype); - } - } - - public static MessageType StringToMessageType (string text) - { - switch (text) - { - case "method_call": - return MessageType.MethodCall; - case "method_return": - return MessageType.MethodReturn; - case "error": - return MessageType.Error; - case "signal": - return MessageType.Signal; - case "invalid": - return MessageType.Invalid; - default: - throw new Exception ("Bad MessageType: " + text); - } - } - - //TODO: remove this -- left here for the benefit of the monitor tool for now - public static string CreateMatchRule (MessageType mtype) - { - return "type='" + MessageTypeToString (mtype) + "'"; - } - } -} diff -Nru dbus-sharp-0.7.0/src/MessageReader.cs dbus-sharp-0.8.0/src/MessageReader.cs --- dbus-sharp-0.7.0/src/MessageReader.cs 2010-09-14 09:17:49.000000000 +0000 +++ dbus-sharp-0.8.0/src/MessageReader.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,494 +0,0 @@ -// Copyright 2006 Alp Toker -// This software is made available under the MIT License -// See COPYING for details - -using System; -using System.Text; -using System.Collections.Generic; -using System.IO; -using System.Reflection; - -namespace DBus -{ - partial class MessageReader - { - protected EndianFlag endianness; - //protected byte[] data; - public byte[] data; - //TODO: this should be uint or long to handle long messages - //internal int pos = 0; - public int pos = 0; - protected Message message; - - public MessageReader (EndianFlag endianness, byte[] data) - { - //if (data == null) - // throw new ArgumentNullException ("data"); - if (data == null) - data = new byte[0]; - - this.endianness = endianness; - this.IsNativeEndian = endianness == Connection.NativeEndianness; - this.data = data; - } - - public MessageReader (Message message) : this (message.Header.Endianness, message.Body) - { - if (message == null) - throw new ArgumentNullException ("message"); - - this.message = message; - } - - public readonly bool IsNativeEndian; - - public object ReadValue (Type type) - { - if (type == typeof (void)) - return null; - - if (type.IsArray) { - return ReadArray (type.GetElementType ()); - } else if (type == typeof (ObjectPath)) { - return ReadObjectPath (); - } else if (type == typeof (Signature)) { - return ReadSignature (); - } else if (type == typeof (object)) { - return ReadVariant (); - } else if (type == typeof (string)) { - return ReadString (); - } else if (type.IsGenericType && type.GetGenericTypeDefinition () == typeof (IDictionary<,>)) { - Type[] genArgs = type.GetGenericArguments (); - //Type dictType = typeof (Dictionary<,>).MakeGenericType (genArgs); - //workaround for Mono bug #81035 (memory leak) - Type dictType = Mapper.GetGenericType (typeof (Dictionary<,>), genArgs); - System.Collections.IDictionary idict = (System.Collections.IDictionary)Activator.CreateInstance(dictType, new object[0]); - GetValueToDict (genArgs[0], genArgs[1], idict); - return idict; - } else if (Mapper.IsPublic (type)) { - return GetObject (type); - } else if (!type.IsPrimitive && !type.IsEnum) { - return ReadStruct (type); - } else { - object val; - DType dtype = Signature.TypeToDType (type); - val = ReadValue (dtype); - - if (type.IsEnum) - val = Enum.ToObject (type, val); - - return val; - } - } - - //helper method, should not be used generally - public object ReadValue (DType dtype) - { - switch (dtype) - { - case DType.Byte: - return ReadByte (); - - case DType.Boolean: - return ReadBoolean (); - - case DType.Int16: - return ReadInt16 (); - - case DType.UInt16: - return ReadUInt16 (); - - case DType.Int32: - return ReadInt32 (); - - case DType.UInt32: - return ReadUInt32 (); - - case DType.Int64: - return ReadInt64 (); - - case DType.UInt64: - return ReadUInt64 (); - -#if !DISABLE_SINGLE - case DType.Single: - return ReadSingle (); -#endif - - case DType.Double: - return ReadDouble (); - - case DType.String: - return ReadString (); - - case DType.ObjectPath: - return ReadObjectPath (); - - case DType.Signature: - return ReadSignature (); - - case DType.Variant: - return ReadVariant (); - - default: - throw new Exception ("Unhandled D-Bus type: " + dtype); - } - } - - public object GetObject (Type type) - { - ObjectPath path = ReadObjectPath (); - - return message.Connection.GetObject (type, (string)message.Header[FieldCode.Sender], path); - } - - public byte ReadByte () - { - return data[pos++]; - } - - public bool ReadBoolean () - { - uint intval = ReadUInt32 (); - - switch (intval) { - case 0: - return false; - case 1: - return true; - default: - throw new Exception ("Read value " + intval + " at position " + pos + " while expecting boolean (0/1)"); - } - } - - unsafe protected void MarshalUShort (void* dstPtr) - { - ReadPad (2); - - if (data.Length < pos + 2) - throw new Exception ("Cannot read beyond end of data"); - - if (endianness == Connection.NativeEndianness) { - fixed (byte* p = &data[pos]) - *((ushort*)dstPtr) = *((ushort*)p); - } else { - byte* dst = (byte*)dstPtr; - dst[0] = data[pos + 1]; - dst[1] = data[pos + 0]; - } - - pos += 2; - } - - unsafe public short ReadInt16 () - { - short val; - - MarshalUShort (&val); - - return val; - } - - unsafe public ushort ReadUInt16 () - { - ushort val; - - MarshalUShort (&val); - - return val; - } - - unsafe protected void MarshalUInt (void* dstPtr) - { - ReadPad (4); - - if (data.Length < pos + 4) - throw new Exception ("Cannot read beyond end of data"); - - if (endianness == Connection.NativeEndianness) { - fixed (byte* p = &data[pos]) - *((uint*)dstPtr) = *((uint*)p); - } else { - byte* dst = (byte*)dstPtr; - dst[0] = data[pos + 3]; - dst[1] = data[pos + 2]; - dst[2] = data[pos + 1]; - dst[3] = data[pos + 0]; - } - - pos += 4; - } - - unsafe public int ReadInt32 () - { - int val; - - MarshalUInt (&val); - - return val; - } - - unsafe public uint ReadUInt32 () - { - uint val; - - MarshalUInt (&val); - - return val; - } - - unsafe protected void MarshalULong (void* dstPtr) - { - ReadPad (8); - - if (data.Length < pos + 8) - throw new Exception ("Cannot read beyond end of data"); - - if (endianness == Connection.NativeEndianness) { - fixed (byte* p = &data[pos]) - *((ulong*)dstPtr) = *((ulong*)p); - } else { - byte* dst = (byte*)dstPtr; - for (int i = 0; i < 8; ++i) - dst[i] = data[pos + (7 - i)]; - } - - pos += 8; - } - - unsafe public long ReadInt64 () - { - long val; - - MarshalULong (&val); - - return val; - } - - unsafe public ulong ReadUInt64 () - { - ulong val; - - MarshalULong (&val); - - return val; - } - -#if !DISABLE_SINGLE - unsafe public float ReadSingle () - { - float val; - - MarshalUInt (&val); - - return val; - } -#endif - - unsafe public double ReadDouble () - { - double val; - - MarshalULong (&val); - - return val; - } - - public string ReadString () - { - uint ln = ReadUInt32 (); - - string val = Encoding.UTF8.GetString (data, pos, (int)ln); - pos += (int)ln; - ReadNull (); - - return val; - } - - public ObjectPath ReadObjectPath () - { - //exactly the same as string - return new ObjectPath (ReadString ()); - } - - public Signature ReadSignature () - { - byte ln = ReadByte (); - - // Avoid an array allocation for small signatures - if (ln == 1) { - DType dtype = (DType)ReadByte (); - ReadNull (); - return new Signature (dtype); - } - - if (ln > Protocol.MaxSignatureLength) - throw new Exception ("Signature length " + ln + " exceeds maximum allowed " + Protocol.MaxSignatureLength + " bytes"); - - byte[] sigData = new byte[ln]; - Array.Copy (data, pos, sigData, 0, (int)ln); - pos += (int)ln; - ReadNull (); - - return Signature.Take (sigData); - } - - public object ReadVariant () - { - return ReadValue (ReadSignature ()); - } - - // Used primarily for reading variant values - object ReadValue (Signature sig) - { - if (sig.IsPrimitive) - return ReadValue (sig[0]); - - Type t = null; - try { - t = sig.ToType (); - } catch (NotSupportedException e) { - // We don't catch other exceptions as they indicate a malformed signature - if (Protocol.Verbose) - Console.Error.WriteLine (e.Message); - } - - /* - if (t == null) { - StepOver (sig); - return null; - } - */ - - if (t == null) { - ReadPad (sig.Alignment); - int startPos = pos; - StepOver (sig); - int ln = pos - startPos; - - DValue dv = new DValue(); - dv.endianness = endianness; - dv.signature = sig; - dv.data = new byte[ln]; - Array.Copy (data, startPos, dv.data, 0, ln); - return dv; - } - - return ReadValue (t); - } - - //not pretty or efficient but works - public void GetValueToDict (Type keyType, Type valType, System.Collections.IDictionary val) - { - uint ln = ReadUInt32 (); - - if (ln > Protocol.MaxArrayLength) - throw new Exception ("Dict length " + ln + " exceeds maximum allowed " + Protocol.MaxArrayLength + " bytes"); - - //advance to the alignment of the element - //ReadPad (Protocol.GetAlignment (Signature.TypeToDType (type))); - ReadPad (8); - - int endPos = pos + (int)ln; - - //while (stream.Position != endPos) - while (pos < endPos) - { - ReadPad (8); - - val.Add (ReadValue (keyType), ReadValue (valType)); - } - - if (pos != endPos) - throw new Exception ("Read pos " + pos + " != ep " + endPos); - } - - //this could be made generic to avoid boxing - public Array ReadArray (Type elemType) - { - uint ln = ReadUInt32 (); - - if (ln > Protocol.MaxArrayLength) - throw new Exception ("Array length " + ln + " exceeds maximum allowed " + Protocol.MaxArrayLength + " bytes"); - - //TODO: more fast paths for primitive arrays - if (elemType == typeof (byte)) { - byte[] valb = new byte[ln]; - Array.Copy (data, pos, valb, 0, (int)ln); - pos += (int)ln; - return valb; - } - - //advance to the alignment of the element - ReadPad (Protocol.GetAlignment (Signature.TypeToDType (elemType))); - - int endPos = pos + (int)ln; - - //List vals = new List (); - System.Collections.ArrayList vals = new System.Collections.ArrayList (); - - //while (stream.Position != endPos) - while (pos < endPos) - vals.Add (ReadValue (elemType)); - - if (pos != endPos) - throw new Exception ("Read pos " + pos + " != ep " + endPos); - - return vals.ToArray (elemType); - } - - //struct - //probably the wrong place for this - //there might be more elegant solutions - public object ReadStruct (Type type) - { - ReadPad (8); - - object val = Activator.CreateInstance (type); - - /* - if (type.IsGenericType && type.GetGenericTypeDefinition () == typeof (KeyValuePair<,>)) { - object elem; - - System.Reflection.PropertyInfo key_prop = type.GetProperty ("Key"); - GetValue (key_prop.PropertyType, out elem); - key_prop.SetValue (val, elem, null); - - System.Reflection.PropertyInfo val_prop = type.GetProperty ("Value"); - GetValue (val_prop.PropertyType, out elem); - val_prop.SetValue (val, elem, null); - - return; - } - */ - - FieldInfo[] fis = type.GetFields (BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance); - - foreach (System.Reflection.FieldInfo fi in fis) - fi.SetValue (val, ReadValue (fi.FieldType)); - - return val; - } - - public void ReadNull () - { - if (data[pos] != 0) - throw new Exception ("Read non-zero byte at position " + pos + " while expecting null terminator"); - pos++; - } - - /* - public void ReadPad (int alignment) - { - pos = Protocol.Padded (pos, alignment); - } - */ - - public void ReadPad (int alignment) - { - for (int endPos = Protocol.Padded (pos, alignment) ; pos != endPos ; pos++) - if (data[pos] != 0) - throw new Exception ("Read non-zero byte at position " + pos + " while expecting padding"); - } - } -} diff -Nru dbus-sharp-0.7.0/src/MessageWriter.cs dbus-sharp-0.8.0/src/MessageWriter.cs --- dbus-sharp-0.7.0/src/MessageWriter.cs 2010-09-14 09:17:49.000000000 +0000 +++ dbus-sharp-0.8.0/src/MessageWriter.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,570 +0,0 @@ -// Copyright 2006 Alp Toker -// This software is made available under the MIT License -// See COPYING for details - -using System; -using System.Text; -using System.Collections.Generic; -using System.IO; -using System.Reflection; -using System.Runtime.InteropServices; - -namespace DBus -{ - sealed class MessageWriter - { - EndianFlag endianness; - internal MemoryStream stream; - - public Connection connection; - - //a default constructor is a bad idea for now as we want to make sure the header and content-type match - public MessageWriter () : this (Connection.NativeEndianness) {} - - public MessageWriter (EndianFlag endianness) - { - this.endianness = endianness; - stream = new MemoryStream (); - } - - public byte[] ToArray () - { - //TODO: mark the writer locked or something here - return stream.ToArray (); - } - - public void ToStream (Stream dest) - { - stream.WriteTo (dest); - } - - public void CloseWrite () - { - WritePad (8); - } - - public void Write (byte val) - { - stream.WriteByte (val); - } - - public void Write (bool val) - { - Write ((uint) (val ? 1 : 0)); - } - - // Buffer for integer marshaling - byte[] dst = new byte[8]; - unsafe void MarshalUShort (void* dataPtr) - { - WritePad (2); - - if (endianness == Connection.NativeEndianness) { - fixed (byte* p = &dst[0]) - *((ushort*)p) = *((ushort*)dataPtr); - } else { - byte* data = (byte*)dataPtr; - dst[0] = data[1]; - dst[1] = data[0]; - } - - stream.Write (dst, 0, 2); - } - - unsafe public void Write (short val) - { - MarshalUShort (&val); - } - - unsafe public void Write (ushort val) - { - MarshalUShort (&val); - } - - unsafe void MarshalUInt (void* dataPtr) - { - WritePad (4); - - if (endianness == Connection.NativeEndianness) { - fixed (byte* p = &dst[0]) - *((uint*)p) = *((uint*)dataPtr); - } else { - byte* data = (byte*)dataPtr; - dst[0] = data[3]; - dst[1] = data[2]; - dst[2] = data[1]; - dst[3] = data[0]; - } - - stream.Write (dst, 0, 4); - } - - unsafe public void Write (int val) - { - MarshalUInt (&val); - } - - unsafe public void Write (uint val) - { - MarshalUInt (&val); - } - - unsafe void MarshalULong (void* dataPtr) - { - WritePad (8); - - if (endianness == Connection.NativeEndianness) { - fixed (byte* p = &dst[0]) - *((ulong*)p) = *((ulong*)dataPtr); - } else { - byte* data = (byte*)dataPtr; - for (int i = 0; i < 8; ++i) - dst[i] = data[7 - i]; - } - - stream.Write (dst, 0, 8); - } - - unsafe public void Write (long val) - { - MarshalULong (&val); - } - - unsafe public void Write (ulong val) - { - MarshalULong (&val); - } - -#if !DISABLE_SINGLE - unsafe public void Write (float val) - { - MarshalUInt (&val); - } -#endif - - unsafe public void Write (double val) - { - MarshalULong (&val); - } - - public void Write (string val) - { - byte[] utf8_data = Encoding.UTF8.GetBytes (val); - Write ((uint)utf8_data.Length); - stream.Write (utf8_data, 0, utf8_data.Length); - WriteNull (); - } - - public void Write (ObjectPath val) - { - Write (val.Value); - } - - public void Write (Signature val) - { - byte[] ascii_data = val.GetBuffer (); - - if (ascii_data.Length > Protocol.MaxSignatureLength) - throw new Exception ("Signature length " + ascii_data.Length + " exceeds maximum allowed " + Protocol.MaxSignatureLength + " bytes"); - - Write ((byte)ascii_data.Length); - stream.Write (ascii_data, 0, ascii_data.Length); - WriteNull (); - } - - [Obsolete] - public void WriteComplex (object val, Type type) - { - if (type == typeof (void)) - return; - - if (type.IsArray) { - MethodInfo miDict = typeof (MessageWriter).GetMethod ("WriteArray"); - MethodInfo mi = miDict.MakeGenericMethod (type.GetElementType ()); - mi.Invoke (this, new object[] {val}); - } else if (type.IsGenericType && (type.GetGenericTypeDefinition () == typeof (IDictionary<,>) || type.GetGenericTypeDefinition () == typeof (Dictionary<,>))) { - Type[] genArgs = type.GetGenericArguments (); - MethodInfo miDict = typeof (MessageWriter).GetMethod ("WriteFromDict"); - MethodInfo mi = miDict.MakeGenericMethod (genArgs); - mi.Invoke (this, new object[] {val}); - } else if (Mapper.IsPublic (type)) { - WriteObject (type, val); - } else if (!type.IsPrimitive && !type.IsEnum) { - WriteValueType (val, type); - /* - } else if (type.IsGenericType && type.GetGenericTypeDefinition () == typeof (Nullable<>)) { - //is it possible to support nullable types? - Type[] genArgs = type.GetGenericArguments (); - WriteVariant (genArgs[0], val); - */ - } else { - throw new Exception ("Can't write"); - } - } - - [Obsolete] - public void Write (Type type, object val) - { - if (type == typeof (void)) - return; - - if (type.IsArray) { - MethodInfo miDict = typeof (MessageWriter).GetMethod ("WriteArray"); - MethodInfo mi = miDict.MakeGenericMethod (type.GetElementType ()); - mi.Invoke (this, new object[] {val}); - } else if (type == typeof (ObjectPath)) { - Write ((ObjectPath)val); - } else if (type == typeof (Signature)) { - Write ((Signature)val); - } else if (type == typeof (object)) { - Write (val); - } else if (type == typeof (string)) { - Write ((string)val); - } else if (type.IsGenericType && (type.GetGenericTypeDefinition () == typeof (IDictionary<,>) || type.GetGenericTypeDefinition () == typeof (Dictionary<,>))) { - Type[] genArgs = type.GetGenericArguments (); - MethodInfo miDict = typeof (MessageWriter).GetMethod ("WriteFromDict"); - MethodInfo mi = miDict.MakeGenericMethod (genArgs); - mi.Invoke (this, new object[] {val}); - } else if (Mapper.IsPublic (type)) { - WriteObject (type, val); - } else if (!type.IsPrimitive && !type.IsEnum) { - WriteValueType (val, type); - } else { - Write (Signature.TypeToDType (type), val); - } - } - - //helper method, should not be used as it boxes needlessly - public void Write (DType dtype, object val) - { - switch (dtype) - { - case DType.Byte: - { - Write ((byte)val); - } - break; - case DType.Boolean: - { - Write ((bool)val); - } - break; - case DType.Int16: - { - Write ((short)val); - } - break; - case DType.UInt16: - { - Write ((ushort)val); - } - break; - case DType.Int32: - { - Write ((int)val); - } - break; - case DType.UInt32: - { - Write ((uint)val); - } - break; - case DType.Int64: - { - Write ((long)val); - } - break; - case DType.UInt64: - { - Write ((ulong)val); - } - break; -#if !DISABLE_SINGLE - case DType.Single: - { - Write ((float)val); - } - break; -#endif - case DType.Double: - { - Write ((double)val); - } - break; - case DType.String: - { - Write ((string)val); - } - break; - case DType.ObjectPath: - { - Write ((ObjectPath)val); - } - break; - case DType.Signature: - { - Write ((Signature)val); - } - break; - case DType.Variant: - { - Write ((object)val); - } - break; - default: - throw new Exception ("Unhandled D-Bus type: " + dtype); - } - } - - public void WriteObject (Type type, object val) - { - ObjectPath path; - - BusObject bobj = val as BusObject; - - if (bobj == null && val is MarshalByRefObject) { - bobj = ((MarshalByRefObject)val).GetLifetimeService () as BusObject; - } - - if (bobj == null) - throw new Exception ("No object reference to write"); - - path = bobj.Path; - - Write (path); - } - - //variant - public void Write (object val) - { - if (val == null) - throw new NotSupportedException ("Cannot send null variant"); - - if (val is DValue) { - DValue dv = (DValue)val; - - if (dv.endianness != endianness) - throw new NotImplementedException ("Writing opposite endian DValues not yet implemented."); - - Write (dv.signature); - WritePad (dv.signature.Alignment); - stream.Write (dv.data, 0, dv.data.Length); - return; - } - - Type type = val.GetType (); - - WriteVariant (type, val); - } - - public void WriteVariant (Type type, object val) - { - Signature sig = Signature.GetSig (type); - - Write (sig); - Write (type, val); - } - - //this requires a seekable stream for now - public unsafe void WriteArray (T[] val) - { - Type elemType = typeof (T); - - if (elemType == typeof (byte)) { - if (val.Length > Protocol.MaxArrayLength) - throw new Exception ("Array length " + val.Length + " exceeds maximum allowed " + Protocol.MaxArrayLength + " bytes"); - - Write ((uint)val.Length); - stream.Write ((byte[])(object)val, 0, val.Length); - return; - } - - if (elemType.IsEnum) - elemType = Enum.GetUnderlyingType (elemType); - - Signature sigElem = Signature.GetSig (elemType); - int fixedSize = 0; - if (endianness == Connection.NativeEndianness && elemType.IsValueType && !sigElem.IsStruct && sigElem.GetFixedSize (ref fixedSize)) { - int byteLength = fixedSize * val.Length; - if (byteLength > Protocol.MaxArrayLength) - throw new Exception ("Array length " + byteLength + " exceeds maximum allowed " + Protocol.MaxArrayLength + " bytes"); - Write ((uint)byteLength); - WritePad (sigElem.Alignment); - - GCHandle valHandle = GCHandle.Alloc (val, GCHandleType.Pinned); - IntPtr p = valHandle.AddrOfPinnedObject (); - byte[] data = new byte[byteLength]; - byte* bp = (byte*)p; - for (int i = 0 ; i != byteLength ; i++) - data[i] = bp[i]; - stream.Write (data, 0, data.Length); - valHandle.Free (); - return; - } - - long origPos = stream.Position; - Write ((uint)0); - - //advance to the alignment of the element - WritePad (sigElem.Alignment); - - long startPos = stream.Position; - - TypeWriter tWriter = TypeImplementer.GetTypeWriter (); - - foreach (T elem in val) - tWriter (this, elem); - - long endPos = stream.Position; - uint ln = (uint)(endPos - startPos); - stream.Position = origPos; - - if (ln > Protocol.MaxArrayLength) - throw new Exception ("Array length " + ln + " exceeds maximum allowed " + Protocol.MaxArrayLength + " bytes"); - - Write (ln); - stream.Position = endPos; - } - - public void WriteValueType (object val, Type type) - { - MethodInfo mi = TypeImplementer.GetWriteMethod (type); - mi.Invoke (null, new object[] {this, val}); - } - - public void WriteStructure (T value) - { - TypeWriter tWriter = TypeImplementer.GetTypeWriter (); - tWriter (this, value); - } - - public void WriteFromDict (IDictionary val) - { - long origPos = stream.Position; - Write ((uint)0); - - WritePad (8); - - long startPos = stream.Position; - - TypeWriter keyWriter = TypeImplementer.GetTypeWriter (); - TypeWriter valueWriter = TypeImplementer.GetTypeWriter (); - - foreach (KeyValuePair entry in val) - { - WritePad (8); - keyWriter (this, entry.Key); - valueWriter (this, entry.Value); - } - - long endPos = stream.Position; - uint ln = (uint)(endPos - startPos); - stream.Position = origPos; - - if (ln > Protocol.MaxArrayLength) - throw new Exception ("Dict length " + ln + " exceeds maximum allowed " + Protocol.MaxArrayLength + " bytes"); - - Write (ln); - stream.Position = endPos; - } - - /* - public void Write (IDictionary val) - { - WriteHeaderDict(val); - } - - public void Write (Dictionary val) - { - WriteHeaderDict (val); - } - */ - - /* - public void Write (Dictionary val) - { - long origPos = stream.Position; - Write ((uint)0); - - WritePad (8); - - long startPos = stream.Position; - - foreach (KeyValuePair entry in val) { - WritePad (8); - Write (entry.Key); - Write (entry.Value); - } - - long endPos = stream.Position; - uint ln = (uint)(endPos - startPos); - stream.Position = origPos; - - if (ln > Protocol.MaxArrayLength) - throw new Exception ("Dict length " + ln + " exceeds maximum allowed " + Protocol.MaxArrayLength + " bytes"); - - Write (ln); - stream.Position = endPos; - } - */ - - internal void WriteHeaderFields (Dictionary val) - { - long origPos = stream.Position; - Write ((uint)0); - - WritePad (8); - - long startPos = stream.Position; - - foreach (KeyValuePair entry in val) { - WritePad (8); - Write (entry.Key); - switch ((FieldCode)entry.Key) { - case FieldCode.Destination: - case FieldCode.ErrorName: - case FieldCode.Interface: - case FieldCode.Member: - case FieldCode.Sender: - Write (Signature.StringSig); - Write ((string)entry.Value); - break; - case FieldCode.Path: - Write (Signature.ObjectPathSig); - Write ((ObjectPath)entry.Value); - break; - case FieldCode.ReplySerial: - Write (Signature.UInt32Sig); - Write ((uint)entry.Value); - break; - default: - Write (entry.Value); - break; - } - } - - long endPos = stream.Position; - uint ln = (uint)(endPos - startPos); - stream.Position = origPos; - - if (ln > Protocol.MaxArrayLength) - throw new Exception ("Dict length " + ln + " exceeds maximum allowed " + Protocol.MaxArrayLength + " bytes"); - - Write (ln); - stream.Position = endPos; - } - - public void WriteNull () - { - stream.WriteByte (0); - } - - // Source buffer for zero-padding - static readonly byte[] nullBytes = new byte[8]; - public void WritePad (int alignment) - { - int needed = Protocol.PadNeeded ((int)stream.Position, alignment); - stream.Write (nullBytes, 0, needed); - } - } -} diff -Nru dbus-sharp-0.7.0/src/ObjectPath.cs dbus-sharp-0.8.0/src/ObjectPath.cs --- dbus-sharp-0.7.0/src/ObjectPath.cs 1970-01-01 00:00:00.000000000 +0000 +++ dbus-sharp-0.8.0/src/ObjectPath.cs 2013-07-26 16:37:41.000000000 +0000 @@ -0,0 +1,159 @@ +// Copyright 2006 Alp Toker +// Copyright 2010 Alan McGovern +// This software is made available under the MIT License +// See COPYING for details + +using System; +using System.Collections.Generic; + +namespace DBus +{ + public sealed class ObjectPath : IComparable, IComparable, IEquatable + { + public static readonly ObjectPath Root = new ObjectPath ("/"); + + internal readonly string Value; + + public ObjectPath (string value) + { + if (value == null) + throw new ArgumentNullException ("value"); + + Validate (value); + + this.Value = value; + } + + static void Validate (string value) + { + if (!value.StartsWith ("/")) + throw new ArgumentException ("value"); + if (value.EndsWith ("/") && value.Length > 1) + throw new ArgumentException ("ObjectPath cannot end in '/'"); + + bool multipleSlash = false; + + foreach (char c in value) { + bool valid = (c >= 'a' && c <='z') + || (c >= 'A' && c <= 'Z') + || (c >= '0' && c <= '9') + || c == '_' + || (!multipleSlash && c == '/'); + + if (!valid) { + var message = string.Format ("'{0}' is not a valid character in an ObjectPath", c); + throw new ArgumentException (message, "value"); + } + + multipleSlash = c == '/'; + } + + } + + public int CompareTo (ObjectPath other) + { + if (other == null) + return 1; + + return Value.CompareTo (other.Value); + } + + public int CompareTo (object otherObject) + { + ObjectPath other = otherObject as ObjectPath; + + if (other == null) + return 1; + + return Value.CompareTo (other.Value); + } + + public bool Equals (ObjectPath other) + { + if (other == null) + return false; + + return Value == other.Value; + } + + public override bool Equals (object o) + { + ObjectPath b = o as ObjectPath; + + if (b == null) + return false; + + return Value.Equals (b.Value); + } + + public static bool operator == (ObjectPath a, ObjectPath b) + { + object aa = a, bb = b; + if (aa == null && bb == null) + return true; + + if (aa == null || bb == null) + return false; + + return a.Value == b.Value; + } + + public static bool operator != (ObjectPath a, ObjectPath b) + { + return !(a == b); + } + + public override int GetHashCode () + { + return Value.GetHashCode (); + } + + public override string ToString () + { + return Value; + } + + //this may or may not prove useful + internal string[] Decomposed + { + get { + return Value.Split (new char[] {'/'}, StringSplitOptions.RemoveEmptyEntries); + /* + } set { + Value = String.Join ("/", value); + */ + } + } + + internal ObjectPath Parent + { + get { + if (Value == Root.Value) + return null; + + string par = Value.Substring (0, Value.LastIndexOf ('/')); + if (par == String.Empty) + par = "/"; + + return new ObjectPath (par); + } + } + + /* + public int CompareTo (object value) + { + return 1; + } + + public int CompareTo (ObjectPath value) + { + return 1; + } + + public bool Equals (ObjectPath value) + { + return false; + } + */ + } +} diff -Nru dbus-sharp-0.7.0/src/PendingCall.cs dbus-sharp-0.8.0/src/PendingCall.cs --- dbus-sharp-0.7.0/src/PendingCall.cs 2010-09-14 09:17:49.000000000 +0000 +++ dbus-sharp-0.8.0/src/PendingCall.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,111 +0,0 @@ -// Copyright 2007 Alp Toker -// This software is made available under the MIT License -// See COPYING for details - -using System; -using System.Threading; - -namespace DBus -{ - class PendingCall : IAsyncResult - { - Connection conn; - Message reply = null; - //AutoResetEvent waitHandle = new AutoResetEvent (false); - ManualResetEvent waitHandle; - - public PendingCall (Connection conn) - { - this.conn = conn; - } - - public Message Reply - { - get { - if (reply != null) - return reply; - - if (Thread.CurrentThread == conn.mainThread) { - /* - while (reply == null) - conn.Iterate (); - */ - - while (reply == null) - conn.HandleMessage (conn.Transport.ReadMessage ()); - - completedSync = true; - - conn.DispatchSignals (); - } else { - if (waitHandle == null) - waitHandle = new ManualResetEvent (false); - - // TODO: Possible race condition? - while (reply == null) - waitHandle.WaitOne (); - - completedSync = false; - } - - return reply; - } set { - if (reply != null) - throw new Exception ("Cannot handle reply more than once"); - - reply = value; - - if (waitHandle != null) - waitHandle.Set (); - - if (Completed != null) - Completed (reply); - } - } - - public event Action Completed; - bool completedSync; - - public void Cancel () - { - throw new NotImplementedException (); - } - - - - #region IAsyncResult Members - - object IAsyncResult.AsyncState - { - get { - return conn; - } - } - - WaitHandle IAsyncResult.AsyncWaitHandle - { - get { - if (waitHandle == null) - waitHandle = new ManualResetEvent (false); - - return waitHandle; - } - } - - bool IAsyncResult.CompletedSynchronously - { - get { - return reply != null && completedSync; - } - } - - bool IAsyncResult.IsCompleted - { - get { - return reply != null; - } - } - - #endregion - } -} diff -Nru dbus-sharp-0.7.0/src/Protocol/DBusStruct.cs dbus-sharp-0.8.0/src/Protocol/DBusStruct.cs --- dbus-sharp-0.7.0/src/Protocol/DBusStruct.cs 1970-01-01 00:00:00.000000000 +0000 +++ dbus-sharp-0.8.0/src/Protocol/DBusStruct.cs 2013-07-26 21:04:04.000000000 +0000 @@ -0,0 +1,102 @@ +using System; +using System.Collections.Generic; + +namespace DBus.Protocol +{ + /* We use these structs when we receive a struct from D-Bus without + * knowing which .NET type they are supposed to map to + * The case arises basically when a struct is inside a variant object + */ + public static class DBusStruct + { + public static Type FromInnerTypes (Type[] innerTypes) + { + // We only support up to 7 inner types + if (innerTypes == null || innerTypes.Length == 0 || innerTypes.Length > 7) + throw new NotSupportedException ("Can't create a valid type for the provided signature"); + + Type structType = null; + switch (innerTypes.Length) { + case 1: + structType = typeof (DBusStruct<>); + break; + case 2: + structType = typeof (DBusStruct<,>); + break; + case 3: + structType = typeof (DBusStruct<,,>); + break; + case 4: + structType = typeof (DBusStruct<,,,>); + break; + case 5: + structType = typeof (DBusStruct<,,,,>); + break; + case 6: + structType = typeof (DBusStruct<,,,,,>); + break; + case 7: + structType = typeof (DBusStruct<,,,,,,>); + break; + } + return structType.MakeGenericType (innerTypes); + } + } + + public struct DBusStruct + { + public T1 Item1; + } + + public struct DBusStruct + { + public T1 Item1; + public T2 Item2; + } + + public struct DBusStruct + { + public T1 Item1; + public T2 Item2; + public T3 Item3; + } + + public struct DBusStruct + { + public T1 Item1; + public T2 Item2; + public T3 Item3; + public T4 Item4; + } + + public struct DBusStruct + { + public T1 Item1; + public T2 Item2; + public T3 Item3; + public T4 Item4; + public T5 Item5; + } + + public struct DBusStruct + { + public T1 Item1; + public T2 Item2; + public T3 Item3; + public T4 Item4; + public T5 Item5; + public T6 Item6; + } + + public struct DBusStruct + { + public T1 Item1; + public T2 Item2; + public T3 Item3; + public T4 Item4; + public T5 Item5; + public T6 Item6; + public T7 Item7; + } +} + diff -Nru dbus-sharp-0.7.0/src/Protocol/DType.cs dbus-sharp-0.8.0/src/Protocol/DType.cs --- dbus-sharp-0.7.0/src/Protocol/DType.cs 1970-01-01 00:00:00.000000000 +0000 +++ dbus-sharp-0.8.0/src/Protocol/DType.cs 2013-07-26 21:04:04.000000000 +0000 @@ -0,0 +1,36 @@ +// Copyright 2006 Alp Toker +// Copyright 2010 Alan McGovern s +// This software is made available under the MIT License +// See COPYING for details + +using System; + +namespace DBus.Protocol +{ + public enum DType : byte + { + Invalid = (byte)'\0', + + Byte = (byte)'y', + Boolean = (byte)'b', + Int16 = (byte)'n', + UInt16 = (byte)'q', + Int32 = (byte)'i', + UInt32 = (byte)'u', + Int64 = (byte)'x', + UInt64 = (byte)'t', + Single = (byte)'f', //This is not yet supported! + Double = (byte)'d', + String = (byte)'s', + ObjectPath = (byte)'o', + Signature = (byte)'g', + + Array = (byte)'a', + Variant = (byte)'v', + + StructBegin = (byte)'(', + StructEnd = (byte)')', + DictEntryBegin = (byte)'{', + DictEntryEnd = (byte)'}', + } +} diff -Nru dbus-sharp-0.7.0/src/Protocol/DValue.cs dbus-sharp-0.8.0/src/Protocol/DValue.cs --- dbus-sharp-0.7.0/src/Protocol/DValue.cs 1970-01-01 00:00:00.000000000 +0000 +++ dbus-sharp-0.8.0/src/Protocol/DValue.cs 2013-07-26 21:04:04.000000000 +0000 @@ -0,0 +1,143 @@ +// Copyright 2006 Alp Toker +// This software is made available under the MIT License +// See COPYING for details + +using System; +using System.Collections.Generic; +using System.IO; + +namespace DBus.Protocol +{ + // Allows conversion of complex variants via System.Convert + class DValue : IConvertible + { + // TODO: Note that we currently drop the originating Connection/Message details + // They may be useful later in conversion! + + internal EndianFlag endianness; + internal Signature signature; + internal byte[] data; + + public DValue (EndianFlag endianness, byte[] data) + { + this.endianness = endianness; + this.data = data; + } + + public bool CanConvertTo (Type conversionType) + { + Signature typeSig = Signature.GetSig (conversionType); + return signature == typeSig; + } + + public TypeCode GetTypeCode () + { + return TypeCode.Object; + } + + public object ToType (Type conversionType) + { + return ToType (conversionType, null); + } + + public object ToType (Type conversionType, IFormatProvider provider) + { + Signature typeSig = Signature.GetSig (conversionType); + if (typeSig != signature) + throw new InvalidCastException (); + + MessageReader reader = new MessageReader (endianness, data); + return reader.ReadValue (conversionType); + } + + public override string ToString () + { + // Seems a reasonable way of providing the signature to the API layer + return signature.ToString (); + } + + // IConvertible implementation: + + /* + public TypeCode GetTypeCode () + { + throw new NotSupportedException (); + } + */ + + public bool ToBoolean (IFormatProvider provider) + { + throw new NotSupportedException (); + } + + public byte ToByte (IFormatProvider provider) + { + throw new NotSupportedException (); + } + + public char ToChar (IFormatProvider provider) + { + throw new NotSupportedException (); + } + + public DateTime ToDateTime (IFormatProvider provider) + { + throw new NotSupportedException (); + } + + public decimal ToDecimal (IFormatProvider provider) + { + throw new NotSupportedException (); + } + + public double ToDouble (IFormatProvider provider) + { + throw new NotSupportedException (); + } + + public short ToInt16 (IFormatProvider provider) + { + throw new NotSupportedException (); + } + + public int ToInt32 (IFormatProvider provider) + { + throw new NotSupportedException (); + } + + public long ToInt64 (IFormatProvider provider) + { + throw new NotSupportedException (); + } + + public sbyte ToSByte (IFormatProvider provider) + { + throw new NotSupportedException (); + } + + public float ToSingle (IFormatProvider provider) + { + throw new NotSupportedException (); + } + + public string ToString (IFormatProvider provider) + { + throw new NotSupportedException (); + } + + public ushort ToUInt16 (IFormatProvider provider) + { + throw new NotSupportedException (); + } + + public uint ToUInt32 (IFormatProvider provider) + { + throw new NotSupportedException (); + } + + public ulong ToUInt64 (IFormatProvider provider) + { + throw new NotSupportedException (); + } + } +} \ No newline at end of file diff -Nru dbus-sharp-0.7.0/src/Protocol/EndianFlag.cs dbus-sharp-0.8.0/src/Protocol/EndianFlag.cs --- dbus-sharp-0.7.0/src/Protocol/EndianFlag.cs 1970-01-01 00:00:00.000000000 +0000 +++ dbus-sharp-0.8.0/src/Protocol/EndianFlag.cs 2013-07-26 21:04:04.000000000 +0000 @@ -0,0 +1,15 @@ +// Copyright 2006 Alp Toker +// Copyright 2010 Alan McGovern +// This software is made available under the MIT License +// See COPYING for details + +using System; + +namespace DBus.Protocol +{ + public enum EndianFlag : byte + { + Little = (byte)'l', + Big = (byte)'B', + } +} diff -Nru dbus-sharp-0.7.0/src/Protocol/FieldCode.cs dbus-sharp-0.8.0/src/Protocol/FieldCode.cs --- dbus-sharp-0.7.0/src/Protocol/FieldCode.cs 1970-01-01 00:00:00.000000000 +0000 +++ dbus-sharp-0.8.0/src/Protocol/FieldCode.cs 2013-07-26 21:04:04.000000000 +0000 @@ -0,0 +1,25 @@ +// Copyright 2006 Alp Toker +// Copyright 2010 Alan McGovern +// This software is made available under the MIT License +// See COPYING for details + +using System; + +namespace DBus.Protocol +{ + public enum FieldCode : byte + { + Invalid, + Path, + Interface, + Member, + ErrorName, + ReplySerial, + Destination, + Sender, + Signature, +#if PROTO_REPLY_SIGNATURE + ReplySignature, //note: not supported in dbus +#endif + } +} diff -Nru dbus-sharp-0.7.0/src/Protocol/Header.cs dbus-sharp-0.8.0/src/Protocol/Header.cs --- dbus-sharp-0.7.0/src/Protocol/Header.cs 1970-01-01 00:00:00.000000000 +0000 +++ dbus-sharp-0.8.0/src/Protocol/Header.cs 2013-07-26 21:04:04.000000000 +0000 @@ -0,0 +1,130 @@ +// Copyright 2006 Alp Toker +// Copyright 2010 Alan McGovern +// This software is made available under the MIT License +// See COPYING for details + +using System; +using System.IO; +using System.Collections.Generic; + +namespace DBus.Protocol +{ + public class Header + { + public EndianFlag Endianness; + public MessageType MessageType; + public HeaderFlag Flags; + public byte MajorVersion; + public uint Length; + public uint Serial; + + Dictionary fields = new Dictionary (); + + public object this[FieldCode key] + { + get { + object value = null; + fields.TryGetValue ((byte)key, out value); + return value; + } + set { + if (value == null) + fields.Remove((byte)key); + else + fields[(byte)key] = value; + } + } + + public bool TryGetField (FieldCode code, out object value) + { + return fields.TryGetValue ((byte)code, out value); + } + + public int FieldsCount { + get { + return fields.Count; + } + } + + public static Header FromBytes (byte[] data) + { + Header header = new Header (); + EndianFlag endianness = (EndianFlag)data[0]; + + header.Endianness = endianness; + header.MessageType = (MessageType)data[1]; + header.Flags = (HeaderFlag)data[2]; + header.MajorVersion = data[3]; + + var reader = new MessageReader (endianness, data); + reader.Seek (4); + header.Length = reader.ReadUInt32 (); + header.Serial = reader.ReadUInt32 (); + + FieldCodeEntry[] fields = reader.ReadArray (); + foreach (var f in fields) { + header[(FieldCode)f.Code] = f.Value; + } + + return header; + } + + public void GetHeaderDataToStream (Stream stream) + { + MessageWriter writer = new MessageWriter (Endianness); + WriteHeaderToMessage (writer); + writer.ToStream (stream); + } + + internal void WriteHeaderToMessage (MessageWriter writer) + { + writer.Write ((byte)Endianness); + writer.Write ((byte)MessageType); + writer.Write ((byte)Flags); + writer.Write (MajorVersion); + writer.Write (Length); + writer.Write (Serial); + writer.WriteHeaderFields (fields); + + writer.CloseWrite (); + } + + struct FieldCodeEntry + { + public byte Code; + public object Value; + } + + /* + public static DType TypeForField (FieldCode f) + { + switch (f) { + case FieldCode.Invalid: + return DType.Invalid; + case FieldCode.Path: + return DType.ObjectPath; + case FieldCode.Interface: + return DType.String; + case FieldCode.Member: + return DType.String; + case FieldCode.ErrorName: + return DType.String; + case FieldCode.ReplySerial: + return DType.UInt32; + case FieldCode.Destination: + return DType.String; + case FieldCode.Sender: + return DType.String; + case FieldCode.Signature: + return DType.Signature; +#if PROTO_REPLY_SIGNATURE + case FieldCode.ReplySignature: //note: not supported in dbus + return DType.Signature; +#endif + default: + return DType.Invalid; + } + } + */ + } +} diff -Nru dbus-sharp-0.7.0/src/Protocol/HeaderFlag.cs dbus-sharp-0.8.0/src/Protocol/HeaderFlag.cs --- dbus-sharp-0.7.0/src/Protocol/HeaderFlag.cs 1970-01-01 00:00:00.000000000 +0000 +++ dbus-sharp-0.8.0/src/Protocol/HeaderFlag.cs 2013-07-26 21:04:04.000000000 +0000 @@ -0,0 +1,17 @@ +// Copyright 2006 Alp Toker +// Copyright 2010 Alan McGovern +// This software is made available under the MIT License +// See COPYING for details + +using System; + +namespace DBus.Protocol +{ + [Flags] + public enum HeaderFlag : byte + { + None = 0, + NoReplyExpected = 0x1, + NoAutoStart = 0x2, + } +} diff -Nru dbus-sharp-0.7.0/src/Protocol/MatchRule.cs dbus-sharp-0.8.0/src/Protocol/MatchRule.cs --- dbus-sharp-0.7.0/src/Protocol/MatchRule.cs 1970-01-01 00:00:00.000000000 +0000 +++ dbus-sharp-0.8.0/src/Protocol/MatchRule.cs 2013-07-26 21:04:04.000000000 +0000 @@ -0,0 +1,338 @@ +// Copyright 2007 Alp Toker +// This software is made available under the MIT License +// See COPYING for details + +using System; +using System.Text; +using System.Text.RegularExpressions; +using System.Collections.Generic; + +namespace DBus.Protocol +{ + public class MatchRule + { + static readonly Regex argNRegex = new Regex (@"^arg(\d+)(path)?$"); + static readonly Regex matchRuleRegex = new Regex (@"(\w+)\s*=\s*'((\\\\|\\'|[^'\\])*)'", RegexOptions.Compiled); + + MessageType messageType = MessageType.All; + readonly SortedList fields = new SortedList (); + readonly HashSet args = new HashSet (); + + public MatchRule () + { + } + + public HashSet Args { + get { + return this.args; + } + } + + public SortedList Fields { + get { + return this.fields; + } + } + + public MessageType MessageType { + get { + return this.messageType; + } + set { + this.messageType = value; + } + } + + static void Append (StringBuilder sb, string key, object value) + { + Append (sb, key, value.ToString ()); + } + + static void Append (StringBuilder sb, string key, string value) + { + if (sb.Length != 0) + sb.Append (','); + + sb.Append (key); + sb.Append ("='"); + sb.Append (value.Replace (@"\", @"\\").Replace (@"'", @"\'")); + sb.Append ('\''); + } + + static void AppendArg (StringBuilder sb, int index, string value) + { + Append (sb, "arg" + index, value); + } + + static void AppendPathArg (StringBuilder sb, int index, ObjectPath value) + { + Append (sb, "arg" + index + "path", value.ToString ()); + } + + public override bool Equals (object o) + { + MatchRule r = o as MatchRule; + if (o == null) + return false; + + return ToString () == r.ToString (); + } + + public override int GetHashCode () + { + //FIXME: not at all optimal + return ToString ().GetHashCode (); + } + + public override string ToString () + { + StringBuilder sb = new StringBuilder (); + + if (MessageType != MessageType.All) + Append (sb, "type", MessageFilter.MessageTypeToString ((MessageType)MessageType)); + + // Note that fdo D-Bus daemon sorts in a different order. + // It shouldn't matter though as long as we're consistent. + foreach (KeyValuePair pair in Fields) { + Append (sb, pair.Key.ToString ().ToLower (), pair.Value.Value); + } + + // Sorting the list here is not ideal + List tests = new List (Args); + tests.Sort ( delegate (ArgMatchTest aa, ArgMatchTest bb) { return aa.ArgNum - bb.ArgNum; } ); + + if (Args != null) + foreach (ArgMatchTest test in tests) + if (test.Signature == Signature.StringSig) + AppendArg (sb, test.ArgNum, (string)test.Value); + else if (test.Signature == Signature.ObjectPathSig) + AppendPathArg (sb, test.ArgNum, (ObjectPath)test.Value); + + return sb.ToString (); + } + + public static void Test (HashSet a, Message msg) + { + List sigs = new List (); + sigs.AddRange (msg.Signature.GetParts ()); + + if (sigs.Count == 0) { + a.Clear (); + return; + } + + a.RemoveWhere ( delegate (ArgMatchTest t) { return t.ArgNum >= sigs.Count || t.Signature != sigs[t.ArgNum]; } ); + + // Sorting the list here is not ideal + List tests = new List (a); + tests.Sort ( delegate (ArgMatchTest aa, ArgMatchTest bb) { return aa.ArgNum - bb.ArgNum; } ); + + if (tests.Count == 0) { + a.Clear (); + return; + } + + MessageReader reader = new MessageReader (msg); + + int argNum = 0; + foreach (ArgMatchTest test in tests) { + if (argNum > test.ArgNum) { + // This test cannot pass because a previous test already did. + // So we already know it will fail without even trying. + // This logic will need to be changed to support wildcards. + a.Remove (test); + continue; + } + + while (argNum != test.ArgNum) { + Signature sig = sigs[argNum]; + if (!reader.StepOver (sig)) + throw new Exception (); + argNum++; + } + + // TODO: Avoid re-reading values + if (!reader.PeekValue (test.Signature[0]).Equals (test.Value)) { + a.Remove (test); + continue; + } + + argNum++; + } + } + + public bool MatchesHeader (Message msg) + { + if (MessageType != MessageType.All) + if (msg.Header.MessageType != MessageType) + return false; + + foreach (KeyValuePair pair in Fields) { + object value; + if (!msg.Header.TryGetField (pair.Key, out value)) + return false; + if (!pair.Value.Value.Equals (value)) + return false; + } + + return true; + } + + public static MatchRule Parse (string text) + { + if (text.Length > ProtocolInformation.MaxMatchRuleLength) + throw new Exception ("Match rule length exceeds maximum " + ProtocolInformation.MaxMatchRuleLength + " characters"); + + MatchRule r = new MatchRule (); + + // TODO: Stricter validation. Tighten up the regex. + // It currently succeeds and silently drops malformed test parts. + + for (Match m = matchRuleRegex.Match (text) ; m.Success ; m = m.NextMatch ()) { + string key = m.Groups[1].Value; + string value = m.Groups[2].Value; + // This unescaping may not be perfect.. + value = value.Replace (@"\\", @"\"); + value = value.Replace (@"\'", @"'"); + + if (key.StartsWith ("arg")) { + Match mArg = argNRegex.Match (key); + if (!mArg.Success) + return null; + int argNum = (int)UInt32.Parse (mArg.Groups[1].Value); + + if (argNum < 0 || argNum >= ProtocolInformation.MaxMatchRuleArgs) + throw new Exception ("arg match must be between 0 and " + (ProtocolInformation.MaxMatchRuleArgs - 1) + " inclusive"); + + //if (r.Args.ContainsKey (argNum)) + // return null; + + string argType = mArg.Groups[2].Value; + + if (argType == "path") + r.Args.Add (new ArgMatchTest (argNum, new ObjectPath (value))); + else + r.Args.Add (new ArgMatchTest (argNum, value)); + + continue; + } + + //TODO: more consistent error handling + switch (key) { + case "type": + if (r.MessageType != MessageType.All) + return null; + r.MessageType = MessageFilter.StringToMessageType (value); + break; + case "interface": + r.Fields[FieldCode.Interface] = new MatchTest (value); + break; + case "member": + r.Fields[FieldCode.Member] = new MatchTest (value); + break; + case "path": + r.Fields[FieldCode.Path] = new MatchTest (new ObjectPath (value)); + break; + case "sender": + r.Fields[FieldCode.Sender] = new MatchTest (value); + break; + case "destination": + r.Fields[FieldCode.Destination] = new MatchTest (value); + break; + default: + if (ProtocolInformation.Verbose) + Console.Error.WriteLine ("Warning: Unrecognized match rule key: " + key); + break; + } + } + + return r; + } + } + + public class HeaderTest : MatchTest + { + public FieldCode Field; + public HeaderTest (FieldCode field, object value) + { + Field = field; + Signature = Signature.GetSig (value.GetType ()); + Value = value; + } + } + + public struct ArgMatchTest + { + public int ArgNum; + public Signature Signature; + public object Value; + + public ArgMatchTest (int argNum, string value) + { + ArgNum = argNum; + Signature = Signature.StringSig; + Value = value; + } + + public ArgMatchTest (int argNum, ObjectPath value) + { + ArgNum = argNum; + Signature = Signature.ObjectPathSig; + Value = value; + } + + public override int GetHashCode () + { + return Signature.GetHashCode () ^ Value.GetHashCode () ^ ArgNum; + } + } + + /* + class ArgMatchTest : MatchTest + { + public int ArgNum; + + public ArgMatchTest (int argNum, string value) : base (value) + { + ArgNum = argNum; + } + + public ArgMatchTest (int argNum, ObjectPath value) : base (value) + { + ArgNum = argNum; + } + + public override int GetHashCode () + { + return base.GetHashCode () ^ ArgNum; + } + } + */ + + public class MatchTest + { + public Signature Signature; + public object Value; + + public override int GetHashCode () + { + return Signature.GetHashCode () ^ Value.GetHashCode (); + } + + protected MatchTest () + { + } + + public MatchTest (string value) + { + Signature = Signature.StringSig; + Value = value; + } + + public MatchTest (ObjectPath value) + { + Signature = Signature.ObjectPathSig; + Value = value; + } + } +} diff -Nru dbus-sharp-0.7.0/src/Protocol/Message.cs dbus-sharp-0.8.0/src/Protocol/Message.cs --- dbus-sharp-0.7.0/src/Protocol/Message.cs 1970-01-01 00:00:00.000000000 +0000 +++ dbus-sharp-0.8.0/src/Protocol/Message.cs 2013-07-26 21:04:04.000000000 +0000 @@ -0,0 +1,104 @@ +// Copyright 2006 Alp Toker +// This software is made available under the MIT License +// See COPYING for details + +using System; +using System.Collections.Generic; +using System.IO; + +namespace DBus.Protocol +{ + public class Message + { + Header header = new Header (); + Connection connection; + byte[] body; + + public Message () + { + header.Endianness = Connection.NativeEndianness; + header.MessageType = MessageType.MethodCall; + header.Flags = HeaderFlag.NoReplyExpected; //TODO: is this the right place to do this? + header.MajorVersion = ProtocolInformation.Version; + } + + public static Message FromReceivedBytes (Connection connection, byte[] header, byte[] body) + { + Message message = new Message (); + message.connection = connection; + message.body = body; + message.SetHeaderData (header); + + return message; + } + + public byte[] Body { + get { + return body; + } + } + + public Header Header { + get { + return header; + } + } + + public Connection Connection { + get { + return connection; + } + } + + public Signature Signature { + get { + object o = Header[FieldCode.Signature]; + if (o == null) + return Signature.Empty; + else + return (Signature)o; + } + set { + if (value == Signature.Empty) + Header[FieldCode.Signature] = null; + else + Header[FieldCode.Signature] = value; + } + } + + public bool ReplyExpected { + get { + return (Header.Flags & HeaderFlag.NoReplyExpected) == HeaderFlag.None; + } + set { + if (value) + Header.Flags &= ~HeaderFlag.NoReplyExpected; //flag off + else + Header.Flags |= HeaderFlag.NoReplyExpected; //flag on + } + } + + public void AttachBodyTo (MessageWriter writer) + { + body = writer.ToArray (); + header.Length = (uint)body.Length; + } + + public void HandleHeader (Header headerIn) + { + header = headerIn; + } + + public void SetHeaderData (byte[] data) + { + header = Header.FromBytes (data); + } + + public byte[] GetHeaderData () + { + MessageWriter writer = new MessageWriter (header.Endianness); + header.WriteHeaderToMessage (writer); + return writer.ToArray (); + } + } +} diff -Nru dbus-sharp-0.7.0/src/Protocol/MessageContainer.cs dbus-sharp-0.8.0/src/Protocol/MessageContainer.cs --- dbus-sharp-0.7.0/src/Protocol/MessageContainer.cs 1970-01-01 00:00:00.000000000 +0000 +++ dbus-sharp-0.8.0/src/Protocol/MessageContainer.cs 2013-07-26 21:04:04.000000000 +0000 @@ -0,0 +1,189 @@ +// Copyright 2006 Alp Toker +// This software is made available under the MIT License +// See COPYING for details + +using System; +using System.Collections.Generic; +using System.IO; + +namespace DBus.Protocol +{ + public class MessageContainer + { + Message resultMessage; + + public MessageContainer () + { + Type = MessageType.MethodCall; + } + + MessageContainer (Message originalMessage) + { + this.resultMessage = originalMessage; + } + + public Message Message { + get { + if (resultMessage != null) + return resultMessage; + return resultMessage = ExportToMessage (); + } + } + + public Message CreateError (string errorName, string errorMessage) + { + var message = Message; + MessageContainer error = new MessageContainer { + Type = MessageType.Error, + ErrorName = errorName, + ReplySerial = message.Header.Serial, + Signature = Signature.StringSig, + }; + + MessageWriter writer = new MessageWriter (message.Header.Endianness); + writer.Write (errorMessage); + message = error.Message; + message.AttachBodyTo (writer); + + return message; + } + + public static MessageContainer FromMessage (Message message) + { + MessageContainer container = new MessageContainer (message) { + Path = (ObjectPath)message.Header[FieldCode.Path], + Interface = (string)message.Header[FieldCode.Interface], + Member = (string)message.Header[FieldCode.Member], + Destination = (string)message.Header[FieldCode.Destination], + //TODO: filled by the bus so reliable, but not the case for p2p + //so we make it optional here, but this needs some more thought + //if (message.Header.Fields.ContainsKey (FieldCode.Sender)) + Sender = (string)message.Header[FieldCode.Sender], + ErrorName = (string)message.Header[FieldCode.ErrorName], + ReplySerial = (uint?)message.Header[FieldCode.ReplySerial], + Signature = message.Signature, + Serial = message.Header.Serial, + Type = message.Header.MessageType, + }; +#if PROTO_REPLY_SIGNATURE + //TODO: note that an empty ReplySignature should really be treated differently to the field not existing! + if (message.Header.Fields.ContainsKey (FieldCode.ReplySignature)) + container.ReplySignature = (Signature)message.Header[FieldCode.ReplySignature]; + else + container.ReplySignature = Signature.Empty; +#endif + + return container; + } + + Message ExportToMessage () { + var message = new Message (); + message.Header.MessageType = Type; + if (Type == MessageType.MethodCall) + message.ReplyExpected = true; + else + message.Header.Flags = HeaderFlag.NoReplyExpected | HeaderFlag.NoAutoStart; + message.Header[FieldCode.Path] = Path; + message.Header[FieldCode.Interface] = Interface; + message.Header[FieldCode.Member] = Member; + message.Header[FieldCode.Destination] = Destination; + message.Header[FieldCode.ErrorName] = ErrorName; +#if PROTO_REPLY_SIGNATURE + //TODO +#endif + message.Signature = Signature; + if (ReplySerial != null) + message.Header[FieldCode.ReplySerial] = (uint)ReplySerial; + if (Serial != null) + message.Header.Serial = (uint)Serial; + + return message; + } + + public MessageType Type { + get; + set; + } + + public ObjectPath Path { + get; + set; + } + + public string Interface { + get; + set; + } + + public string Member { + get; + set; + } + + public string Destination { + get; + set; + } + + public string Sender { + get; + set; + } + +#if PROTO_REPLY_SIGNATURE + public Signature ReplySignature { + get; + set; + } +#endif + + public uint? ReplySerial { + get; + set; + } + + public uint? Serial { + get; + set; + } + + public Signature Signature { + get; + set; + } + + public string ErrorName { + get; + set; + } + + /*public override bool Equals (object other) + { + MessageContainer otherMethodCall = other as MessageContainer; + return otherMethodCall == null ? false : Equals (otherMethodCall); + } + + public bool Equals (MessageContainer other) + { + return (Path == other.Path || Path.Equals (other.Path)) + && Interface == other.Interface + && Member == other.Member + && Destination == other.Destination + && Sender == other.Destination + && ErrorName == other.ErrorName + && Signature.Equals (other.Signature) + && ReplySerial.Equals (other.ReplySerial); + } + + public override int GetHashCode () + { + return (Path == null ? 0 : Path.GetHashCode ()) + ^ (Interface == null ? 0 : Interface.GetHashCode ()) + ^ (Member == null ? 0 : Member.GetHashCode ()) + ^ (Destination == null ? 0 : Destination.GetHashCode ()) + ^ (Sender == null ? 0 : Sender.GetHashCode ()) + ^ (ErrorName == null ? 0 : ErrorName.GetHashCode ()) + ^ Signature.GetHashCode (); + }*/ + } +} diff -Nru dbus-sharp-0.7.0/src/Protocol/MessageDumper.cs dbus-sharp-0.8.0/src/Protocol/MessageDumper.cs --- dbus-sharp-0.7.0/src/Protocol/MessageDumper.cs 1970-01-01 00:00:00.000000000 +0000 +++ dbus-sharp-0.8.0/src/Protocol/MessageDumper.cs 2013-07-26 21:04:04.000000000 +0000 @@ -0,0 +1,119 @@ +// Copyright 2006 Alp Toker +// This software is made available under the MIT License +// See COPYING for details + +using System; +using System.Collections.Generic; +using System.IO; + +namespace DBus.Protocol +{ + public class MessageDumper + { + public static byte[] ReadBlock (TextReader r) + { + //if (Body == null) + // return; + + MemoryStream ms = new MemoryStream (); + + while (true) { + string ln = r.ReadLine (); + if (ln == null) + break; + if (!ReadFromHex (ms, ln)) + break; + } + + if (ms.Length == 0) + return null; + + return ms.ToArray (); + } + + public static void WriteComment (string comment, TextWriter w) + { + w.WriteLine ("# " + comment); + } + + public static void WriteBlock (byte[] Body, TextWriter w) + { + //if (Body == null) + // return; + if (Body != null) + for (int i = 0 ; i != Body.Length ; i++) { + if (i == 0) {} + else if (i % 32 == 0) + w.WriteLine (); + else if (i % 4 == 0) + w.Write (' '); + + w.Write (Body[i].ToString ("x2", System.Globalization.CultureInfo.InvariantCulture)); + } + + w.Write ('.'); + w.WriteLine (); + w.Flush (); + } + + public static void WriteMessage (Message msg, TextWriter w) + { + w.WriteLine ("# Message"); + w.WriteLine ("# Header"); + MessageDumper.WriteBlock (msg.GetHeaderData (), w); + w.WriteLine ("# Body"); + MessageDumper.WriteBlock (msg.Body, w); + w.WriteLine (); + w.Flush (); + } + + public static Message ReadMessage (TextReader r) + { + byte[] header = MessageDumper.ReadBlock (r); + + if (header == null) + return null; + + byte[] body = MessageDumper.ReadBlock (r); + + return Message.FromReceivedBytes (null, header, body); + } + + static byte FromHexChar (char c) + { + if ((c >= 'a') && (c <= 'f')) + return (byte) (c - 'a' + 10); + if ((c >= 'A') && (c <= 'F')) + return (byte) (c - 'A' + 10); + if ((c >= '0') && (c <= '9')) + return (byte) (c - '0'); + throw new ArgumentException ("Invalid hex char"); + } + + static bool ReadFromHex (Stream ms, string hex) + { + if (hex.StartsWith ("#")) + return true; + + int i = 0; + while (i < hex.Length) { + if (char.IsWhiteSpace (hex [i])) { + i++; + continue; + } + + if (hex [i] == '.') { + ms.Flush (); + return false; + } + + byte res = (byte) (FromHexChar (hex [i++]) << 4); + res += FromHexChar (hex [i++]); + ms.WriteByte (res); + } + + ms.Flush (); + return true; + } + } +} \ No newline at end of file diff -Nru dbus-sharp-0.7.0/src/Protocol/MessageFilter.cs dbus-sharp-0.8.0/src/Protocol/MessageFilter.cs --- dbus-sharp-0.7.0/src/Protocol/MessageFilter.cs 1970-01-01 00:00:00.000000000 +0000 +++ dbus-sharp-0.8.0/src/Protocol/MessageFilter.cs 2013-07-26 21:04:04.000000000 +0000 @@ -0,0 +1,58 @@ +// Copyright 2006 Alp Toker +// This software is made available under the MIT License +// See COPYING for details + +using System; + +namespace DBus.Protocol +{ + public class MessageFilter + { + //this should probably be made to use HeaderField or similar + //this class is not generalized yet + + public static string MessageTypeToString (MessageType mtype) + { + switch (mtype) + { + case MessageType.MethodCall: + return "method_call"; + case MessageType.MethodReturn: + return "method_return"; + case MessageType.Error: + return "error"; + case MessageType.Signal: + return "signal"; + case MessageType.Invalid: + return "invalid"; + default: + throw new Exception ("Bad MessageType: " + mtype); + } + } + + public static MessageType StringToMessageType (string text) + { + switch (text) + { + case "method_call": + return MessageType.MethodCall; + case "method_return": + return MessageType.MethodReturn; + case "error": + return MessageType.Error; + case "signal": + return MessageType.Signal; + case "invalid": + return MessageType.Invalid; + default: + throw new Exception ("Bad MessageType: " + text); + } + } + + //TODO: remove this -- left here for the benefit of the monitor tool for now + public static string CreateMatchRule (MessageType mtype) + { + return "type='" + MessageTypeToString (mtype) + "'"; + } + } +} diff -Nru dbus-sharp-0.7.0/src/Protocol/MessageReader.cs dbus-sharp-0.8.0/src/Protocol/MessageReader.cs --- dbus-sharp-0.7.0/src/Protocol/MessageReader.cs 1970-01-01 00:00:00.000000000 +0000 +++ dbus-sharp-0.8.0/src/Protocol/MessageReader.cs 2013-07-26 21:04:04.000000000 +0000 @@ -0,0 +1,725 @@ +// Copyright 2006 Alp Toker +// This software is made available under the MIT License +// See COPYING for details + +using System; +using System.Linq; +using System.Text; +using System.Collections.Generic; +using System.IO; +using System.Reflection; +using System.Runtime.InteropServices; +using System.Collections; + +namespace DBus.Protocol +{ + public class MessageReader + { + public class PaddingException : Exception + { + int position; + byte element; + + internal PaddingException (int position, byte element) + : base ("Read non-zero byte at position " + position + " while expecting padding. Value given: " + element) + { + this.position = position; + this.element = element; + } + + public int Position { + get { + return position; + } + } + + public byte Byte { + get { + return element; + } + } + } + + readonly EndianFlag endianness; + readonly byte[] data; + readonly Message message; + + int pos = 0; + static Dictionary isPrimitiveStruct = new Dictionary (); + static readonly Encoding stringEncoding = Encoding.UTF8; + Dictionary> readValueCache = new Dictionary> (); + + public MessageReader (EndianFlag endianness, byte[] data) + { + if (data == null) + data = new byte[0]; + + this.endianness = endianness; + this.data = data; + } + + public MessageReader (Message message) : this (message.Header.Endianness, message.Body) + { + if (message == null) + throw new ArgumentNullException ("message"); + + this.message = message; + } + + public bool DataAvailable { + get { + return pos < data.Length; + } + } + + public object ReadValue (Type type) + { + if (type == typeof (void)) + return null; + + Func fastAccess; + if (readValueCache.TryGetValue (type, out fastAccess)) + return fastAccess (); + + if (type.IsArray) { + readValueCache[type] = () => ReadArray (type.GetElementType ()); + return ReadArray (type.GetElementType ()); + } else if (type == typeof (ObjectPath)) { + readValueCache[type] = () => ReadObjectPath (); + return ReadObjectPath (); + } else if (type == typeof (Signature)) { + readValueCache[type] = () => ReadSignature (); + return ReadSignature (); + } else if (type == typeof (object)) { + readValueCache[type] = () => ReadVariant (); + return ReadVariant (); + } else if (type == typeof (string)) { + readValueCache[type] = () => ReadString (); + return ReadString (); + } else if (type.IsGenericType && type.GetGenericTypeDefinition () == typeof (Dictionary<,>)) { + Type[] genArgs = type.GetGenericArguments (); + readValueCache[type] = () => ReadDictionary (genArgs[0], genArgs[1]); + return ReadDictionary (genArgs[0], genArgs[1]); + } else if (Mapper.IsPublic (type)) { + readValueCache[type] = () => GetObject (type); + return GetObject (type); + } else if (!type.IsPrimitive && !type.IsEnum) { + readValueCache[type] = () => ReadStruct (type); + return ReadStruct (type); + } else { + object val; + DType dtype = Signature.TypeToDType (type); + val = ReadValue (dtype); + + if (type.IsEnum) + val = Enum.ToObject (type, val); + + return val; + } + } + + public object ReadValue (DType dtype) + { + switch (dtype) + { + case DType.Byte: + return ReadByte (); + + case DType.Boolean: + return ReadBoolean (); + + case DType.Int16: + return ReadInt16 (); + + case DType.UInt16: + return ReadUInt16 (); + + case DType.Int32: + return ReadInt32 (); + + case DType.UInt32: + return ReadUInt32 (); + + case DType.Int64: + return ReadInt64 (); + + case DType.UInt64: + return ReadUInt64 (); + +#if !DISABLE_SINGLE + case DType.Single: + return ReadSingle (); +#endif + + case DType.Double: + return ReadDouble (); + + case DType.String: + return ReadString (); + + case DType.ObjectPath: + return ReadObjectPath (); + + case DType.Signature: + return ReadSignature (); + + case DType.Variant: + return ReadVariant (); + + default: + throw new Exception ("Unhandled D-Bus type: " + dtype); + } + } + + public object PeekValue (DType sig) + { + int savedPos = pos; + object result = ReadValue (sig); + pos = savedPos; + + return result; + } + + public void Seek (int stride) + { + var check = pos + stride; + if (check < 0 || check > data.Length) + throw new ArgumentOutOfRangeException ("stride"); + pos = check; + } + + public object GetObject (Type type) + { + ObjectPath path = ReadObjectPath (); + + return message.Connection.GetObject (type, (string)message.Header[FieldCode.Sender], path); + } + + public byte ReadByte () + { + return data[pos++]; + } + + public bool ReadBoolean () + { + uint intval = ReadUInt32 (); + + switch (intval) { + case 0: + return false; + case 1: + return true; + default: + throw new Exception ("Read value " + intval + " at position " + pos + " while expecting boolean (0/1)"); + } + } + + unsafe protected void MarshalUShort (void* dstPtr) + { + ReadPad (2); + + if (data.Length < pos + 2) + throw new Exception ("Cannot read beyond end of data"); + + if (endianness == Connection.NativeEndianness) { + fixed (byte* p = &data[pos]) + *((ushort*)dstPtr) = *((ushort*)p); + } else { + byte* dst = (byte*)dstPtr; + dst[0] = data[pos + 1]; + dst[1] = data[pos + 0]; + } + + pos += 2; + } + + unsafe public short ReadInt16 () + { + short val; + + MarshalUShort (&val); + + return val; + } + + unsafe public ushort ReadUInt16 () + { + ushort val; + + MarshalUShort (&val); + + return val; + } + + unsafe protected void MarshalUInt (void* dstPtr) + { + ReadPad (4); + + if (data.Length < pos + 4) + throw new Exception ("Cannot read beyond end of data"); + + if (endianness == Connection.NativeEndianness) { + fixed (byte* p = &data[pos]) + *((uint*)dstPtr) = *((uint*)p); + } else { + byte* dst = (byte*)dstPtr; + dst[0] = data[pos + 3]; + dst[1] = data[pos + 2]; + dst[2] = data[pos + 1]; + dst[3] = data[pos + 0]; + } + + pos += 4; + } + + unsafe public int ReadInt32 () + { + int val; + + MarshalUInt (&val); + + return val; + } + + unsafe public uint ReadUInt32 () + { + uint val; + + MarshalUInt (&val); + + return val; + } + + unsafe protected void MarshalULong (void* dstPtr) + { + ReadPad (8); + + if (data.Length < pos + 8) + throw new Exception ("Cannot read beyond end of data"); + + if (endianness == Connection.NativeEndianness) { + fixed (byte* p = &data[pos]) + *((ulong*)dstPtr) = *((ulong*)p); + } else { + byte* dst = (byte*)dstPtr; + for (int i = 0; i < 8; ++i) + dst[i] = data[pos + (7 - i)]; + } + + pos += 8; + } + + unsafe public long ReadInt64 () + { + long val; + + MarshalULong (&val); + + return val; + } + + unsafe public ulong ReadUInt64 () + { + ulong val; + + MarshalULong (&val); + + return val; + } + +#if !DISABLE_SINGLE + unsafe public float ReadSingle () + { + float val; + + MarshalUInt (&val); + + return val; + } +#endif + + unsafe public double ReadDouble () + { + double val; + + MarshalULong (&val); + + return val; + } + + public string ReadString () + { + uint ln = ReadUInt32 (); + + string val = stringEncoding.GetString (data, pos, (int)ln); + pos += (int)ln; + ReadNull (); + + return val; + } + + public ObjectPath ReadObjectPath () + { + //exactly the same as string + return new ObjectPath (ReadString ()); + } + + public Signature ReadSignature () + { + byte ln = ReadByte (); + + // Avoid an array allocation for small signatures + if (ln == 1) { + DType dtype = (DType)ReadByte (); + ReadNull (); + return new Signature (dtype); + } + + if (ln > ProtocolInformation.MaxSignatureLength) + throw new Exception ("Signature length " + ln + " exceeds maximum allowed " + ProtocolInformation.MaxSignatureLength + " bytes"); + + byte[] sigData = new byte[ln]; + Array.Copy (data, pos, sigData, 0, (int)ln); + pos += (int)ln; + ReadNull (); + + return Signature.Take (sigData); + } + + public object ReadVariant () + { + var sig = ReadSignature (); + if (!sig.IsSingleCompleteType) + throw new InvalidOperationException (string.Format ("ReadVariant need a single complete type signature, {0} was given", sig.ToString ())); + return ReadValue (sig); + } + + // Used primarily for reading variant values + public object ReadValue (Signature sig) + { + if (!sig.IsSingleCompleteType) + throw new ArgumentException (string.Format ("ReadVariant need a single complete type signature, {0} was given", sig.ToString ())); + + var val = ReadValue (sig.ToType ()); + return val; + } + + public IDictionary ReadDictionary (Type keyType, Type valType) + { + MethodInfo mi = this.GetType ().GetMethod ("ReadDictionary", Type.EmptyTypes).MakeGenericMethod (new [] { keyType, valType }); + return (IDictionary)mi.Invoke (this, null); + } + + public Dictionary ReadDictionary () + { + uint ln = ReadUInt32 (); + + if (ln > ProtocolInformation.MaxArrayLength) + throw new Exception ("Dict length " + ln + " exceeds maximum allowed " + ProtocolInformation.MaxArrayLength + " bytes"); + + var val = new Dictionary ((int)(ln / 8)); + ReadPad (8); + + int endPos = pos + (int)ln; + + while (pos < endPos) { + ReadPad (8); + TKey k = (TKey)ReadValue (typeof (TKey)); + TValue v = (TValue)ReadValue (typeof (TValue)); + val.Add (k, v); + } + + if (pos != endPos) + throw new Exception ("Read pos " + pos + " != ep " + endPos); + + return val; + } + + public Array ReadArray (Type elemType) + { + MethodInfo mi = this.GetType ().GetMethod ("ReadArray", Type.EmptyTypes).MakeGenericMethod (new [] { elemType }); + return (Array)mi.Invoke (this, null); + } + + public TArray[] ReadArray () + { + uint ln = ReadUInt32 (); + Type elemType = typeof (TArray); + + if (ln > ProtocolInformation.MaxArrayLength) + throw new Exception ("Array length " + ln + " exceeds maximum allowed " + ProtocolInformation.MaxArrayLength + " bytes"); + + //advance to the alignment of the element + ReadPad (ProtocolInformation.GetAlignment (Signature.TypeToDType (elemType))); + + if (elemType.IsPrimitive) { + // Fast path for primitive types (except bool which isn't blittable and take another path) + if (elemType != typeof (bool)) + return MarshalArray (ln); + else + return (TArray[])(Array)MarshalBoolArray (ln); + } + + var list = new List (); + int endPos = pos + (int)ln; + + while (pos < endPos) + list.Add ((TArray)ReadValue (elemType)); + + if (pos != endPos) + throw new Exception ("Read pos " + pos + " != ep " + endPos); + + return list.ToArray (); + } + + TArray[] MarshalArray (uint length) + { + int sof = Marshal.SizeOf (typeof (TArray)); + TArray[] array = new TArray[(int)(length / sof)]; + + if (endianness == Connection.NativeEndianness) { + Buffer.BlockCopy (data, pos, array, 0, (int)length); + pos += (int)length; + } else { + GCHandle handle = GCHandle.Alloc (array, GCHandleType.Pinned); + DirectCopy (sof, length, handle); + handle.Free (); + } + + return array; + } + + void DirectCopy (int sof, uint length, GCHandle handle) + { + DirectCopy (sof, length, handle.AddrOfPinnedObject ()); + } + + unsafe void DirectCopy (int sof, uint length, IntPtr handle) + { + if (endianness == Connection.NativeEndianness) { + Marshal.Copy (data, pos, handle, (int)length); + } else { + byte* ptr = (byte*)(void*)handle; + for (int i = pos; i < pos + length; i += sof) + for (int j = i; j < i + sof; j++) + ptr[2 * i - pos + (sof - 1) - j] = data[j]; + } + + pos += (int)length * sof; + } + + bool[] MarshalBoolArray (uint length) + { + bool[] array = new bool [length]; + for (int i = 0; i < length; i++) + array[i] = ReadBoolean (); + + return array; + } + + public object ReadStruct (Type type) + { + ReadPad (8); + + FieldInfo[] fis = type.GetFields (BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance); + + // Empty struct? No need for processing + if (fis.Length == 0) + return Activator.CreateInstance (type); + + if (IsEligibleStruct (type, fis)) + return MarshalStruct (type, fis); + + object val = Activator.CreateInstance (type); + + foreach (System.Reflection.FieldInfo fi in fis) + fi.SetValue (val, ReadValue (fi.FieldType)); + + return val; + } + + public T ReadStruct () where T : struct + { + ReadPad (8); + + FieldInfo[] fis = typeof (T).GetFields (BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance); + + // Empty struct? No need for processing + if (fis.Length == 0) + return default (T); + + if (IsEligibleStruct (typeof (T), fis)) + return NewMarshalStruct (fis); + + object val = Activator.CreateInstance (); + + foreach (System.Reflection.FieldInfo fi in fis) + fi.SetValue (val, ReadValue (fi.FieldType)); + + return (T)val; + } + + object MarshalStruct (Type structType, FieldInfo[] fis) + { + object strct = Activator.CreateInstance (structType); + int sof = Marshal.SizeOf (fis[0].FieldType); + GCHandle handle = GCHandle.Alloc (strct, GCHandleType.Pinned); + DirectCopy (sof, (uint)(fis.Length * sof), handle); + handle.Free (); + + return strct; + } + + T NewMarshalStruct (FieldInfo[] fis) where T : struct + { + T val = default (T); + int sof = Marshal.SizeOf (fis[0].FieldType); + + unsafe { + byte* pVal = (byte*)&val; + DirectCopy (sof, (uint)(fis.Length * sof), (IntPtr)pVal); + } + + return val; + } + + public void ReadNull () + { + if (data[pos] != 0) + throw new Exception ("Read non-zero byte at position " + pos + " while expecting null terminator"); + pos++; + } + + public void ReadPad (int alignment) + { + for (int endPos = ProtocolInformation.Padded (pos, alignment) ; pos != endPos ; pos++) + if (data[pos] != 0) + throw new PaddingException (pos, data[pos]); + } + + // Note: This method doesn't support aggregate signatures + public bool StepOver (Signature sig) + { + if (sig == Signature.VariantSig) { + Signature valueSig = ReadSignature (); + return StepOver (valueSig); + } + + if (sig == Signature.StringSig) { + uint valueLength = ReadUInt32 (); + pos += (int)valueLength; + pos++; + return true; + } + + if (sig == Signature.ObjectPathSig) { + uint valueLength = ReadUInt32 (); + pos += (int)valueLength; + pos++; + return true; + } + + if (sig == Signature.SignatureSig) { + byte valueLength = ReadByte (); + pos += valueLength; + pos++; + return true; + } + + // No need to handle dicts specially. IsArray does the job + if (sig.IsArray) { + Signature elemSig = sig.GetElementSignature (); + uint ln = ReadUInt32 (); + pos = ProtocolInformation.Padded (pos, elemSig.Alignment); + pos += (int)ln; + return true; + } + + int endPos = pos; + if (sig.GetFixedSize (ref endPos)) { + pos = endPos; + return true; + } + + if (sig.IsDictEntry) { + pos = ProtocolInformation.Padded (pos, sig.Alignment); + Signature sigKey, sigValue; + sig.GetDictEntrySignatures (out sigKey, out sigValue); + if (!StepOver (sigKey)) + return false; + if (!StepOver (sigValue)) + return false; + return true; + } + + if (sig.IsStruct) { + pos = ProtocolInformation.Padded (pos, sig.Alignment); + foreach (Signature fieldSig in sig.GetFieldSignatures ()) + if (!StepOver (fieldSig)) + return false; + return true; + } + + throw new Exception ("Can't step over '" + sig + "'"); + } + + public IEnumerable StepInto (Signature sig) + { + if (sig == Signature.VariantSig) { + Signature valueSig = ReadSignature (); + yield return valueSig; + yield break; + } + + // No need to handle dicts specially. IsArray does the job + if (sig.IsArray) { + Signature elemSig = sig.GetElementSignature (); + uint ln = ReadUInt32 (); + ReadPad (elemSig.Alignment); + int endPos = pos + (int)ln; + while (pos < endPos) + yield return elemSig; + yield break; + } + + if (sig.IsDictEntry) { + pos = ProtocolInformation.Padded (pos, sig.Alignment); + Signature sigKey, sigValue; + sig.GetDictEntrySignatures (out sigKey, out sigValue); + yield return sigKey; + yield return sigValue; + yield break; + } + + if (sig.IsStruct) { + pos = ProtocolInformation.Padded (pos, sig.Alignment); + foreach (Signature fieldSig in sig.GetFieldSignatures ()) + yield return fieldSig; + yield break; + } + + throw new Exception ("Can't step into '" + sig + "'"); + } + + // If a struct is only composed of primitive type fields (i.e. blittable types) + // then this method return true. Result is cached in isPrimitiveStruct dictionary. + internal static bool IsEligibleStruct (Type structType, FieldInfo[] fields) + { + bool result; + if (isPrimitiveStruct.TryGetValue (structType, out result)) + return result; + + if (!(isPrimitiveStruct[structType] = fields.All ((f) => f.FieldType.IsPrimitive && f.FieldType != typeof (bool)))) + return false; + + int alignement = GetAlignmentFromPrimitiveType (fields[0].FieldType); + + return isPrimitiveStruct[structType] = !fields.Any ((f) => GetAlignmentFromPrimitiveType (f.FieldType) != alignement); + } + + static int GetAlignmentFromPrimitiveType (Type type) + { + return ProtocolInformation.GetAlignment (Signature.TypeCodeToDType (Type.GetTypeCode (type))); + } + } +} diff -Nru dbus-sharp-0.7.0/src/Protocol/MessageType.cs dbus-sharp-0.8.0/src/Protocol/MessageType.cs --- dbus-sharp-0.7.0/src/Protocol/MessageType.cs 1970-01-01 00:00:00.000000000 +0000 +++ dbus-sharp-0.8.0/src/Protocol/MessageType.cs 2013-07-26 21:04:04.000000000 +0000 @@ -0,0 +1,25 @@ +// Copyright 2006 Alp Toker +// Copyright 2010 Alan McGovern +// This software is made available under the MIT License +// See COPYING for details + +using System; + +namespace DBus.Protocol +{ + public enum MessageType : byte + { + //This is an invalid type. + Invalid, + //Method call. + MethodCall, + //Method reply with returned data. + MethodReturn, + //Error reply. If the first argument exists and is a string, it is an error message. + Error, + //Signal emission. + Signal, + All + // Correspond to all types + } +} diff -Nru dbus-sharp-0.7.0/src/Protocol/MessageWriter.cs dbus-sharp-0.8.0/src/Protocol/MessageWriter.cs --- dbus-sharp-0.7.0/src/Protocol/MessageWriter.cs 1970-01-01 00:00:00.000000000 +0000 +++ dbus-sharp-0.8.0/src/Protocol/MessageWriter.cs 2013-07-26 21:04:04.000000000 +0000 @@ -0,0 +1,532 @@ +// Copyright 2006 Alp Toker +// This software is made available under the MIT License +// See COPYING for details + +using System; +using System.Text; +using System.Collections.Generic; +using System.IO; +using System.Reflection; +using System.Runtime.InteropServices; + +namespace DBus.Protocol +{ + public sealed class MessageWriter + { + EndianFlag endianness; + MemoryStream stream; + Connection connection; + + static readonly MethodInfo arrayWriter = typeof (MessageWriter).GetMethod ("WriteArray"); + static readonly MethodInfo dictWriter = typeof (MessageWriter).GetMethod ("WriteFromDict"); + static readonly MethodInfo structWriter = typeof (MessageWriter).GetMethod ("WriteStructure"); + + static readonly Encoding stringEncoding = Encoding.UTF8; + + //a default constructor is a bad idea for now as we want to make sure the header and content-type match + public MessageWriter () : this (Connection.NativeEndianness) {} + + public MessageWriter (Connection connection) : this(Connection.NativeEndianness) + { + this.connection = connection; + } + + public MessageWriter (EndianFlag endianness) + { + this.endianness = endianness; + stream = new MemoryStream (); + } + + public Connection Connection { + get { + return connection; + } + set { + connection = value; + } + } + + public byte[] ToArray () + { + //TODO: mark the writer locked or something here + return stream.ToArray (); + } + + public void ToStream (Stream dest) + { + stream.WriteTo (dest); + } + + public void CloseWrite () + { + WritePad (8); + } + + public void Write (byte val) + { + stream.WriteByte (val); + } + + public void Write (bool val) + { + Write ((uint) (val ? 1 : 0)); + } + + // Buffer for integer marshaling + byte[] dst = new byte[8]; + unsafe void MarshalUShort (void* dataPtr) + { + WritePad (2); + + if (endianness == Connection.NativeEndianness) { + fixed (byte* p = &dst[0]) + *((ushort*)p) = *((ushort*)dataPtr); + } else { + byte* data = (byte*)dataPtr; + dst[0] = data[1]; + dst[1] = data[0]; + } + + stream.Write (dst, 0, 2); + } + + unsafe public void Write (short val) + { + MarshalUShort (&val); + } + + unsafe public void Write (ushort val) + { + MarshalUShort (&val); + } + + unsafe void MarshalUInt (void* dataPtr) + { + WritePad (4); + + if (endianness == Connection.NativeEndianness) { + fixed (byte* p = &dst[0]) + *((uint*)p) = *((uint*)dataPtr); + } else { + byte* data = (byte*)dataPtr; + dst[0] = data[3]; + dst[1] = data[2]; + dst[2] = data[1]; + dst[3] = data[0]; + } + + stream.Write (dst, 0, 4); + } + + unsafe public void Write (int val) + { + MarshalUInt (&val); + } + + unsafe public void Write (uint val) + { + MarshalUInt (&val); + } + + unsafe void MarshalULong (void* dataPtr) + { + WritePad (8); + + if (endianness == Connection.NativeEndianness) { + fixed (byte* p = &dst[0]) + *((ulong*)p) = *((ulong*)dataPtr); + } else { + byte* data = (byte*)dataPtr; + for (int i = 0; i < 8; ++i) + dst[i] = data[7 - i]; + } + + stream.Write (dst, 0, 8); + } + + unsafe public void Write (long val) + { + MarshalULong (&val); + } + + unsafe public void Write (ulong val) + { + MarshalULong (&val); + } + +#if !DISABLE_SINGLE + unsafe public void Write (float val) + { + MarshalUInt (&val); + } +#endif + + unsafe public void Write (double val) + { + MarshalULong (&val); + } + + public void Write (string val) + { + byte[] utf8_data = stringEncoding.GetBytes (val); + Write ((uint)utf8_data.Length); + stream.Write (utf8_data, 0, utf8_data.Length); + WriteNull (); + } + + public void Write (ObjectPath val) + { + Write (val.Value); + } + + public void Write (Signature val) + { + byte[] ascii_data = val.GetBuffer (); + + if (ascii_data.Length > ProtocolInformation.MaxSignatureLength) + throw new Exception ("Signature length " + ascii_data.Length + " exceeds maximum allowed " + ProtocolInformation.MaxSignatureLength + " bytes"); + + Write ((byte)ascii_data.Length); + stream.Write (ascii_data, 0, ascii_data.Length); + WriteNull (); + } + + public void Write (Type type, object val) + { + if (type == typeof (void)) + return; + + if (type.IsArray) { + MethodInfo mi = arrayWriter.MakeGenericMethod (type.GetElementType ()); + mi.Invoke (this, new object[] {val}); + } else if (type == typeof (ObjectPath)) { + Write ((ObjectPath)val); + } else if (type == typeof (Signature)) { + Write ((Signature)val); + } else if (type == typeof (object)) { + Write (val); + } else if (type == typeof (string)) { + Write ((string)val); + } else if (type.IsGenericType && (type.GetGenericTypeDefinition () == typeof (IDictionary<,>) || type.GetGenericTypeDefinition () == typeof (Dictionary<,>))) { + Type[] genArgs = type.GetGenericArguments (); + MethodInfo mi = dictWriter.MakeGenericMethod (genArgs); + mi.Invoke (this, new object[] {val}); + } else if (Mapper.IsPublic (type)) { + WriteObject (type, val); + } else if (!type.IsPrimitive && !type.IsEnum) { + MethodInfo mi = structWriter.MakeGenericMethod (type); + mi.Invoke (this, new[] { val }); + } else { + Write (Signature.TypeToDType (type), val); + } + } + + //helper method, should not be used as it boxes needlessly + public void Write (DType dtype, object val) + { + switch (dtype) + { + case DType.Byte: + { + Write ((byte)val); + } + break; + case DType.Boolean: + { + Write ((bool)val); + } + break; + case DType.Int16: + { + Write ((short)val); + } + break; + case DType.UInt16: + { + Write ((ushort)val); + } + break; + case DType.Int32: + { + Write ((int)val); + } + break; + case DType.UInt32: + { + Write ((uint)val); + } + break; + case DType.Int64: + { + Write ((long)val); + } + break; + case DType.UInt64: + { + Write ((ulong)val); + } + break; +#if !DISABLE_SINGLE + case DType.Single: + { + Write ((float)val); + } + break; +#endif + case DType.Double: + { + Write ((double)val); + } + break; + case DType.String: + { + Write ((string)val); + } + break; + case DType.ObjectPath: + { + Write ((ObjectPath)val); + } + break; + case DType.Signature: + { + Write ((Signature)val); + } + break; + case DType.Variant: + { + Write ((object)val); + } + break; + default: + throw new Exception ("Unhandled D-Bus type: " + dtype); + } + } + + public void WriteObject (Type type, object val) + { + ObjectPath path; + + BusObject bobj = val as BusObject; + + if (bobj == null && val is MarshalByRefObject) { + bobj = ((MarshalByRefObject)val).GetLifetimeService () as BusObject; + } + + if (bobj == null) + throw new Exception ("No object reference to write"); + + path = bobj.Path; + + Write (path); + } + + //variant + public void Write (object val) + { + if (val == null) + throw new NotSupportedException ("Cannot send null variant"); + + if (val is DValue) { + DValue dv = (DValue)val; + + if (dv.endianness != endianness) + throw new NotImplementedException ("Writing opposite endian DValues not yet implemented."); + + Write (dv.signature); + WritePad (dv.signature.Alignment); + stream.Write (dv.data, 0, dv.data.Length); + return; + } + + Type type = val.GetType (); + + WriteVariant (type, val); + } + + public void WriteVariant (Type type, object val) + { + Signature sig = Signature.GetSig (type); + + Write (sig); + Write (type, val); + } + + //this requires a seekable stream for now + public void WriteArray (T[] val) + { + Type elemType = typeof (T); + + if (elemType == typeof (byte)) { + if (val.Length > ProtocolInformation.MaxArrayLength) + ThrowArrayLengthException ((uint)val.Length); + + Write ((uint)val.Length); + stream.Write ((byte[])(object)val, 0, val.Length); + return; + } + + if (elemType.IsEnum) + elemType = Enum.GetUnderlyingType (elemType); + + Signature sigElem = Signature.GetSig (elemType); + int fixedSize = 0; + + if (endianness == Connection.NativeEndianness && elemType.IsValueType && !sigElem.IsStruct && elemType != typeof(bool) && sigElem.GetFixedSize (ref fixedSize)) { + int byteLength = fixedSize * val.Length; + if (byteLength > ProtocolInformation.MaxArrayLength) + ThrowArrayLengthException ((uint)byteLength); + + Write ((uint)byteLength); + WritePad (sigElem.Alignment); + + byte[] data = new byte[byteLength]; + Buffer.BlockCopy (val, 0, data, 0, data.Length); + stream.Write (data, 0, data.Length); + + return; + } + + long origPos = stream.Position; + Write ((uint)0); + + //advance to the alignment of the element + WritePad (sigElem.Alignment); + + long startPos = stream.Position; + + TypeWriter tWriter = TypeImplementer.GetTypeWriter (); + + foreach (T elem in val) + tWriter (this, elem); + + long endPos = stream.Position; + uint ln = (uint)(endPos - startPos); + stream.Position = origPos; + + if (ln > ProtocolInformation.MaxArrayLength) + ThrowArrayLengthException (ln); + + Write (ln); + stream.Position = endPos; + } + + static void ThrowArrayLengthException (uint ln) + { + throw new Exception ("Array length " + ln.ToString () + " exceeds maximum allowed " + ProtocolInformation.MaxArrayLength + " bytes"); + } + + public void WriteStructure (T value) where T : struct + { + FieldInfo[] fis = typeof (T).GetFields (BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance); + + if (fis.Length == 0) + return; + + WritePad (8); + + if (MessageReader.IsEligibleStruct (typeof (T), fis)) { + byte[] buffer = new byte[Marshal.SizeOf (fis[0].FieldType) * fis.Length]; + unsafe { + byte* pVal = (byte*)&value; + Marshal.Copy ((IntPtr)pVal, buffer, 0, buffer.Length); + } + stream.Write (buffer, 0, buffer.Length); + return; + } + + object boxed = value; + foreach (var fi in fis) + Write (fi.FieldType, fi.GetValue (boxed)); + } + + public void WriteFromDict (IDictionary val) + { + long origPos = stream.Position; + // Pre-write array length field, we overwrite it at the end with the correct value + Write ((uint)0); + WritePad (8); + long startPos = stream.Position; + + TypeWriter keyWriter = TypeImplementer.GetTypeWriter (); + TypeWriter valueWriter = TypeImplementer.GetTypeWriter (); + + foreach (KeyValuePair entry in val) { + WritePad (8); + keyWriter (this, entry.Key); + valueWriter (this, entry.Value); + } + + long endPos = stream.Position; + uint ln = (uint)(endPos - startPos); + stream.Position = origPos; + + if (ln > ProtocolInformation.MaxArrayLength) + throw new Exception ("Dict length " + ln + " exceeds maximum allowed " + ProtocolInformation.MaxArrayLength + " bytes"); + + Write (ln); + stream.Position = endPos; + } + + internal void WriteHeaderFields (Dictionary val) + { + long origPos = stream.Position; + Write ((uint)0); + + WritePad (8); + + long startPos = stream.Position; + + foreach (KeyValuePair entry in val) { + WritePad (8); + Write (entry.Key); + switch ((FieldCode)entry.Key) { + case FieldCode.Destination: + case FieldCode.ErrorName: + case FieldCode.Interface: + case FieldCode.Member: + case FieldCode.Sender: + Write (Signature.StringSig); + Write ((string)entry.Value); + break; + case FieldCode.Path: + Write (Signature.ObjectPathSig); + Write ((ObjectPath)entry.Value); + break; + case FieldCode.ReplySerial: + Write (Signature.UInt32Sig); + Write ((uint)entry.Value); + break; + default: + Write (entry.Value); + break; + } + } + + long endPos = stream.Position; + uint ln = (uint)(endPos - startPos); + stream.Position = origPos; + + if (ln > ProtocolInformation.MaxArrayLength) + throw new Exception ("Dict length " + ln + " exceeds maximum allowed " + ProtocolInformation.MaxArrayLength + " bytes"); + + Write (ln); + stream.Position = endPos; + } + + public void WriteNull () + { + stream.WriteByte (0); + } + + // Source buffer for zero-padding + static readonly byte[] nullBytes = new byte[8]; + public void WritePad (int alignment) + { + int needed = ProtocolInformation.PadNeeded ((int)stream.Position, alignment); + if (needed == 0) + return; + stream.Write (nullBytes, 0, needed); + } + } +} diff -Nru dbus-sharp-0.7.0/src/Protocol/PendingCall.cs dbus-sharp-0.8.0/src/Protocol/PendingCall.cs --- dbus-sharp-0.7.0/src/Protocol/PendingCall.cs 1970-01-01 00:00:00.000000000 +0000 +++ dbus-sharp-0.8.0/src/Protocol/PendingCall.cs 2013-07-26 21:04:04.000000000 +0000 @@ -0,0 +1,98 @@ +// Copyright 2007 Alp Toker +// This software is made available under the MIT License +// See COPYING for details + +using System; +using System.Threading; + +namespace DBus.Protocol +{ + public class PendingCall : IAsyncResult + { + Connection conn; + Message reply; + ManualResetEvent waitHandle; + bool completedSync; + + public event Action Completed; + + public PendingCall (Connection conn) + { + this.conn = conn; + } + + public Message Reply { + get { + if (reply != null) + return reply; + + if (Thread.CurrentThread == conn.mainThread) { + while (reply == null) + conn.HandleMessage (conn.Transport.ReadMessage ()); + + completedSync = true; + + conn.DispatchSignals (); + } else { + if (waitHandle == null) + Interlocked.CompareExchange (ref waitHandle, new ManualResetEvent (false), null); + + while (reply == null) + waitHandle.WaitOne (); + + completedSync = false; + } + + return reply; + } + set { + if (reply != null) + throw new Exception ("Cannot handle reply more than once"); + + reply = value; + + if (waitHandle != null) + waitHandle.Set (); + + if (Completed != null) + Completed (reply); + } + } + + public void Cancel () + { + throw new NotImplementedException (); + } + + #region IAsyncResult Members + + object IAsyncResult.AsyncState { + get { + return conn; + } + } + + WaitHandle IAsyncResult.AsyncWaitHandle { + get { + if (waitHandle == null) + waitHandle = new ManualResetEvent (false); + + return waitHandle; + } + } + + bool IAsyncResult.CompletedSynchronously { + get { + return reply != null && completedSync; + } + } + + bool IAsyncResult.IsCompleted { + get { + return reply != null; + } + } + + #endregion + } +} diff -Nru dbus-sharp-0.7.0/src/Protocol/ProtocolInformation.cs dbus-sharp-0.8.0/src/Protocol/ProtocolInformation.cs --- dbus-sharp-0.7.0/src/Protocol/ProtocolInformation.cs 1970-01-01 00:00:00.000000000 +0000 +++ dbus-sharp-0.8.0/src/Protocol/ProtocolInformation.cs 2013-07-26 21:04:04.000000000 +0000 @@ -0,0 +1,123 @@ +// Copyright 2006 Alp Toker +// This software is made available under the MIT License +// See COPYING for details + +using System; +using System.Collections.Generic; + +namespace DBus.Protocol +{ + static class ProtocolInformation + { + //protocol versions that we support + public const byte MinVersion = 0; + public const byte Version = 1; + public const byte MaxVersion = Version + 1; + + public const uint MaxMessageLength = 134217728; //2 to the 27th power + public const uint MaxArrayLength = 67108864; //2 to the 26th power + public const uint MaxSignatureLength = 255; + public const uint MaxArrayDepth = 32; + public const uint MaxStructDepth = 32; + + //this is not strictly related to Protocol since names are passed around as strings + internal const uint MaxNameLength = 255; + internal const uint MaxMatchRuleLength = 1024; + internal const uint MaxMatchRuleArgs = 64; + + public static int PadNeeded (int pos, int alignment) + { + int pad = pos % alignment; + return pad == 0 ? 0 : alignment - pad; + } + + public static int Padded (int pos, int alignment) + { + int pad = pos % alignment; + if (pad != 0) + pos += alignment - pad; + + return pos; + } + + public static int GetAlignment (DType dtype) + { + switch (dtype) { + case DType.Byte: + return 1; + case DType.Boolean: + return 4; + case DType.Int16: + case DType.UInt16: + return 2; + case DType.Int32: + case DType.UInt32: + return 4; + case DType.Int64: + case DType.UInt64: + return 8; +#if !DISABLE_SINGLE + case DType.Single: //Not yet supported! + return 4; +#endif + case DType.Double: + return 8; + case DType.String: + return 4; + case DType.ObjectPath: + return 4; + case DType.Signature: + return 1; + case DType.Array: + return 4; + case DType.StructBegin: + return 8; + case DType.Variant: + return 1; + case DType.DictEntryBegin: + return 8; + case DType.Invalid: + default: + throw new Exception ("Cannot determine alignment of " + dtype); + } + } + + //this class may not be the best place for Verbose + public readonly static bool Verbose = !String.IsNullOrEmpty (Environment.GetEnvironmentVariable ("DBUS_VERBOSE")); + } + +#if UNDOCUMENTED_IN_SPEC +/* +"org.freedesktop.DBus.Error.Failed" +"org.freedesktop.DBus.Error.NoMemory" +"org.freedesktop.DBus.Error.ServiceUnknown" +"org.freedesktop.DBus.Error.NameHasNoOwner" +"org.freedesktop.DBus.Error.NoReply" +"org.freedesktop.DBus.Error.IOError" +"org.freedesktop.DBus.Error.BadAddress" +"org.freedesktop.DBus.Error.NotSupported" +"org.freedesktop.DBus.Error.LimitsExceeded" +"org.freedesktop.DBus.Error.AccessDenied" +"org.freedesktop.DBus.Error.AuthFailed" +"org.freedesktop.DBus.Error.NoServer" +"org.freedesktop.DBus.Error.Timeout" +"org.freedesktop.DBus.Error.NoNetwork" +"org.freedesktop.DBus.Error.AddressInUse" +"org.freedesktop.DBus.Error.Disconnected" +"org.freedesktop.DBus.Error.InvalidArgs" +"org.freedesktop.DBus.Error.FileNotFound" +"org.freedesktop.DBus.Error.UnknownMethod" +"org.freedesktop.DBus.Error.TimedOut" +"org.freedesktop.DBus.Error.MatchRuleNotFound" +"org.freedesktop.DBus.Error.MatchRuleInvalid" +"org.freedesktop.DBus.Error.Spawn.ExecFailed" +"org.freedesktop.DBus.Error.Spawn.ForkFailed" +"org.freedesktop.DBus.Error.Spawn.ChildExited" +"org.freedesktop.DBus.Error.Spawn.ChildSignaled" +"org.freedesktop.DBus.Error.Spawn.Failed" +"org.freedesktop.DBus.Error.UnixProcessIdUnknown" +"org.freedesktop.DBus.Error.InvalidSignature" +"org.freedesktop.DBus.Error.SELinuxSecurityContextUnknown" +*/ +#endif +} diff -Nru dbus-sharp-0.7.0/src/Protocol/Signature.cs dbus-sharp-0.8.0/src/Protocol/Signature.cs --- dbus-sharp-0.7.0/src/Protocol/Signature.cs 1970-01-01 00:00:00.000000000 +0000 +++ dbus-sharp-0.8.0/src/Protocol/Signature.cs 2013-07-26 21:04:04.000000000 +0000 @@ -0,0 +1,968 @@ +// Copyright 2006 Alp Toker +// This software is made available under the MIT License +// See COPYING for details + +using System; +using System.Text; + +using System.Collections.Generic; +//TODO: Reflection should be done at a higher level than this class +using System.Reflection; + +namespace DBus.Protocol +{ + //maybe this should be nullable? + public struct Signature + { + static readonly byte [] EmptyArray = new byte [0]; + + public static readonly Signature Empty = new Signature (String.Empty); + public static readonly Signature ArraySig = Allocate (DType.Array); + public static readonly Signature ByteSig = Allocate (DType.Byte); + public static readonly Signature DictEntryBegin = Allocate (DType.DictEntryBegin); + public static readonly Signature DictEntryEnd = Allocate (DType.DictEntryEnd); + public static readonly Signature Int32Sig = Allocate (DType.Int32); + public static readonly Signature UInt16Sig = Allocate (DType.UInt16); + public static readonly Signature UInt32Sig = Allocate (DType.UInt32); + public static readonly Signature StringSig = Allocate (DType.String); + public static readonly Signature StructBegin = Allocate (DType.StructBegin); + public static readonly Signature StructEnd = Allocate (DType.StructEnd); + public static readonly Signature ObjectPathSig = Allocate (DType.ObjectPath); + public static readonly Signature SignatureSig = Allocate (DType.Signature); + public static readonly Signature VariantSig = Allocate (DType.Variant); + + public static bool operator == (Signature a, Signature b) + { + if (a.data == b.data) + return true; + + if (a.data == null) + return false; + + if (b.data == null) + return false; + + if (a.data.Length != b.data.Length) + return false; + + for (int i = 0 ; i != a.data.Length ; i++) + if (a.data[i] != b.data[i]) + return false; + + return true; + } + + public static bool operator != (Signature a, Signature b) + { + return !(a == b); + } + + public override bool Equals (object o) + { + if (o == null) + return false; + + if (!(o is Signature)) + return false; + + return this == (Signature)o; + } + + public override int GetHashCode () + { + // TODO: Avoid string conversion + return Value.GetHashCode (); + } + + public static Signature operator + (Signature s1, Signature s2) + { + return Concat (s1, s2); + } + + public static Signature Concat (Signature s1, Signature s2) + { + if (s1.data == null && s2.data == null) + return Signature.Empty; + + if (s1.data == null) + return s2; + + if (s2.data == null) + return s1; + + if (s1.Length + s2.Length == 0) + return Signature.Empty; + + byte[] data = new byte[s1.data.Length + s2.data.Length]; + s1.data.CopyTo (data, 0); + s2.data.CopyTo (data, s1.data.Length); + return Signature.Take (data); + } + + public Signature (string value) + { + if (value == null) + throw new ArgumentNullException ("value"); + if (!IsValid (value)) + throw new ArgumentException (string.Format ("'{0}' is not a valid signature", value), "value"); + + foreach (var c in value) + if (!Enum.IsDefined (typeof (DType), (byte) c)) + throw new ArgumentException (string.Format ("{0} is not a valid dbus type", c)); + + if (value.Length == 0) { + data = EmptyArray; + } else if (value.Length == 1) { + data = DataForDType ((DType)value[0]); + } else { + data = Encoding.ASCII.GetBytes (value); + } + } + + // Basic validity is to check that every "opening" DType has a corresponding closing DType + static bool IsValid (string strSig) + { + int structCount = 0; + int dictCount = 0; + + foreach (char c in strSig) { + switch ((DType)c) { + case DType.StructBegin: + structCount++; + break; + case DType.StructEnd: + structCount--; + break; + case DType.DictEntryBegin: + dictCount++; + break; + case DType.DictEntryEnd: + dictCount--; + break; + } + } + + return structCount == 0 && dictCount == 0; + } + + internal static Signature Take (byte[] value) + { + Signature sig; + + if (value.Length == 0) { + sig.data = Empty.data; + return sig; + } + + if (value.Length == 1) { + sig.data = DataForDType ((DType)value[0]); + return sig; + } + + sig.data = value; + return sig; + } + + static byte[] DataForDType (DType value) + { + // Reduce heap allocations. + // For now, we only cache the most common protocol signatures. + switch (value) { + case DType.Byte: + return ByteSig.data; + case DType.UInt16: + return UInt16Sig.data; + case DType.UInt32: + return UInt32Sig.data; + case DType.String: + return StringSig.data; + case DType.ObjectPath: + return ObjectPathSig.data; + case DType.Signature: + return SignatureSig.data; + case DType.Variant: + return VariantSig.data; + default: + return new byte[] {(byte)value}; + } + } + + private static Signature Allocate (DType value) + { + Signature sig; + sig.data = new byte[] {(byte)value}; + return sig; + } + + internal Signature (DType value) + { + this.data = DataForDType (value); + } + + internal Signature (DType[] value) + { + if (value == null) + throw new ArgumentNullException ("value"); + + if (value.Length == 0) { + this.data = Empty.data; + return; + } + + if (value.Length == 1) { + this.data = DataForDType (value[0]); + return; + } + + this.data = new byte[value.Length]; + + for (int i = 0 ; i != value.Length ; i++) + this.data[i] = (byte)value[i]; + } + + byte[] data; + + //TODO: this should be private, but MessageWriter and Monitor still use it + //[Obsolete] + public byte[] GetBuffer () + { + return data; + } + + internal DType this[int index] + { + get { + return (DType)data[index]; + } + } + + public int Length + { + get { + return data.Length; + } + } + + public string Value + { + get { + //FIXME: hack to handle bad case when Data is null + if (data == null) + return String.Empty; + + return Encoding.ASCII.GetString (data); + } + } + + public override string ToString () + { + return Value; + } + + public static Signature MakeArray (Signature signature) + { + if (!signature.IsSingleCompleteType) + throw new ArgumentException ("The type of an array must be a single complete type", "signature"); + return Signature.ArraySig + signature; + } + + public static Signature MakeStruct (Signature signature) + { + if (signature == Signature.Empty) + throw new ArgumentException ("Cannot create a struct with no fields", "signature"); + + return Signature.StructBegin + signature + Signature.StructEnd; + } + + public static Signature MakeDictEntry (Signature keyType, Signature valueType) + { + if (!keyType.IsSingleCompleteType) + throw new ArgumentException ("Signature must be a single complete type", "keyType"); + if (!valueType.IsSingleCompleteType) + throw new ArgumentException ("Signature must be a single complete type", "valueType"); + + return Signature.DictEntryBegin + + keyType + + valueType + + Signature.DictEntryEnd; + } + + public static Signature MakeDict (Signature keyType, Signature valueType) + { + return MakeArray (MakeDictEntry (keyType, valueType)); + } + + public int Alignment + { + get { + if (data.Length == 0) + return 0; + + return ProtocolInformation.GetAlignment (this[0]); + } + } + + static int GetSize (DType dtype) + { + switch (dtype) { + case DType.Byte: + return 1; + case DType.Boolean: + return 4; + case DType.Int16: + case DType.UInt16: + return 2; + case DType.Int32: + case DType.UInt32: + return 4; + case DType.Int64: + case DType.UInt64: + return 8; +#if !DISABLE_SINGLE + case DType.Single: //Not yet supported! + return 4; +#endif + case DType.Double: + return 8; + case DType.String: + case DType.ObjectPath: + case DType.Signature: + case DType.Array: + case DType.StructBegin: + case DType.Variant: + case DType.DictEntryBegin: + return -1; + case DType.Invalid: + default: + throw new Exception ("Cannot determine size of " + dtype); + } + } + + public bool GetFixedSize (ref int size) + { + if (size < 0) + return false; + + if (data.Length == 0) + return true; + + // Sensible? + size = ProtocolInformation.Padded (size, Alignment); + + if (data.Length == 1) { + int valueSize = GetSize (this[0]); + + if (valueSize == -1) + return false; + + size += valueSize; + return true; + } + + if (IsStructlike) { + foreach (Signature sig in GetParts ()) + if (!sig.GetFixedSize (ref size)) + return false; + return true; + } + + if (IsArray || IsDict) + return false; + + if (IsStruct) { + foreach (Signature sig in GetFieldSignatures ()) + if (!sig.GetFixedSize (ref size)) + return false; + return true; + } + + // Any other cases? + throw new Exception (); + } + + public bool IsFixedSize + { + get { + if (data.Length == 0) + return true; + + if (data.Length == 1) { + int size = GetSize (this[0]); + return size != -1; + } + + if (IsStructlike) { + foreach (Signature sig in GetParts ()) + if (!sig.IsFixedSize) + return false; + return true; + } + + if (IsArray || IsDict) + return false; + + if (IsStruct) { + foreach (Signature sig in GetFieldSignatures ()) + if (!sig.IsFixedSize) + return false; + return true; + } + + // Any other cases? + throw new Exception (); + } + } + + //TODO: complete this + public bool IsPrimitive + { + get { + if (data.Length != 1) + return false; + + if (this[0] == DType.Variant) + return false; + + if (this[0] == DType.Invalid) + return false; + + return true; + } + } + + public bool IsSingleCompleteType + { + get { + if (data.Length == 0) + return true; + var checker = new SignatureChecker (data); + return checker.CheckSignature (); + } + } + + public bool IsStruct + { + get { + if (Length < 2) + return false; + + if (this[0] != DType.StructBegin) + return false; + + // FIXME: Incorrect! What if this is in fact a Structlike starting and finishing with structs? + if (this[Length - 1] != DType.StructEnd) + return false; + + return true; + } + } + + public bool IsDictEntry + { + get { + if (Length < 2) + return false; + + if (this[0] != DType.DictEntryBegin) + return false; + + // FIXME: Incorrect! What if this is in fact a Structlike starting and finishing with structs? + if (this[Length - 1] != DType.DictEntryEnd) + return false; + + return true; + } + } + + public bool IsStructlike + { + get { + if (Length < 2) + return false; + + if (IsArray) + return false; + + if (IsDict) + return false; + + if (IsStruct) + return false; + + return true; + } + } + + public bool IsDict + { + get { + if (Length < 3) + return false; + + if (!IsArray) + return false; + + // 0 is 'a' + if (this[1] != DType.DictEntryBegin) + return false; + + return true; + } + } + + public bool IsArray + { + get { + if (Length < 2) + return false; + + if (this[0] != DType.Array) + return false; + + return true; + } + } + + public Signature GetElementSignature () + { + if (!IsArray) + throw new Exception ("Cannot get the element signature of a non-array (signature was '" + this + "')"); + + //TODO: improve this + //if (IsDict) + // throw new NotSupportedException ("Parsing dict signature is not supported (signature was '" + this + "')"); + + // Skip over 'a' + int pos = 1; + return GetNextSignature (ref pos); + } + + public Type[] ToTypes () + { + // TODO: Find a way to avoid these null checks everywhere. + if (data == null) + return Type.EmptyTypes; + + List types = new List (); + for (int i = 0 ; i != data.Length ; types.Add (ToType (ref i))); + return types.ToArray (); + } + + public Type ToType () + { + int pos = 0; + Type ret = ToType (ref pos); + if (pos != data.Length) + throw new Exception ("Signature '" + Value + "' is not a single complete type"); + return ret; + } + + internal static DType TypeCodeToDType (TypeCode typeCode) + { + switch (typeCode) + { + case TypeCode.Empty: + return DType.Invalid; + case TypeCode.Object: + return DType.Invalid; + case TypeCode.DBNull: + return DType.Invalid; + case TypeCode.Boolean: + return DType.Boolean; + case TypeCode.Char: + return DType.UInt16; + case TypeCode.SByte: + return DType.Byte; + case TypeCode.Byte: + return DType.Byte; + case TypeCode.Int16: + return DType.Int16; + case TypeCode.UInt16: + return DType.UInt16; + case TypeCode.Int32: + return DType.Int32; + case TypeCode.UInt32: + return DType.UInt32; + case TypeCode.Int64: + return DType.Int64; + case TypeCode.UInt64: + return DType.UInt64; + case TypeCode.Single: + return DType.Single; + case TypeCode.Double: + return DType.Double; + case TypeCode.Decimal: + return DType.Invalid; + case TypeCode.DateTime: + return DType.Invalid; + case TypeCode.String: + return DType.String; + default: + return DType.Invalid; + } + } + + //FIXME: this method is bad, get rid of it + internal static DType TypeToDType (Type type) + { + if (type == typeof (void)) + return DType.Invalid; + + if (type == typeof (string)) + return DType.String; + + if (type == typeof (ObjectPath)) + return DType.ObjectPath; + + if (type == typeof (Signature)) + return DType.Signature; + + if (type == typeof (object)) + return DType.Variant; + + if (type.IsPrimitive) + return TypeCodeToDType (Type.GetTypeCode (type)); + + if (type.IsEnum) + return TypeToDType (Enum.GetUnderlyingType (type)); + + //needs work + if (type.IsArray) + return DType.Array; + + //if (type.UnderlyingSystemType != null) + // return TypeToDType (type.UnderlyingSystemType); + if (Mapper.IsPublic (type)) + return DType.ObjectPath; + + if (!type.IsPrimitive && !type.IsEnum) + return DType.StructBegin; + + //TODO: maybe throw an exception here + return DType.Invalid; + } + + /* + public static DType TypeToDType (Type type) + { + if (type == null) + return DType.Invalid; + else if (type == typeof (byte)) + return DType.Byte; + else if (type == typeof (bool)) + return DType.Boolean; + else if (type == typeof (short)) + return DType.Int16; + else if (type == typeof (ushort)) + return DType.UInt16; + else if (type == typeof (int)) + return DType.Int32; + else if (type == typeof (uint)) + return DType.UInt32; + else if (type == typeof (long)) + return DType.Int64; + else if (type == typeof (ulong)) + return DType.UInt64; + else if (type == typeof (float)) //not supported by libdbus at time of writing + return DType.Single; + else if (type == typeof (double)) + return DType.Double; + else if (type == typeof (string)) + return DType.String; + else if (type == typeof (ObjectPath)) + return DType.ObjectPath; + else if (type == typeof (Signature)) + return DType.Signature; + else + return DType.Invalid; + } + */ + + public IEnumerable GetFieldSignatures () + { + if (this == Signature.Empty || this[0] != DType.StructBegin) + throw new Exception ("Not a struct"); + + for (int pos = 1 ; pos < data.Length - 1 ;) + yield return GetNextSignature (ref pos); + } + + public void GetDictEntrySignatures (out Signature sigKey, out Signature sigValue) + { + if (this == Signature.Empty || this[0] != DType.DictEntryBegin) + throw new Exception ("Not a DictEntry"); + + int pos = 1; + sigKey = GetNextSignature (ref pos); + sigValue = GetNextSignature (ref pos); + } + + public IEnumerable GetParts () + { + if (data == null) + yield break; + for (int pos = 0 ; pos < data.Length ;) { + yield return GetNextSignature (ref pos); + } + } + + public Signature GetNextSignature (ref int pos) + { + if (data == null) + return Signature.Empty; + + DType dtype = (DType)data[pos++]; + + switch (dtype) { + //case DType.Invalid: + // return typeof (void); + case DType.Array: + //peek to see if this is in fact a dictionary + if ((DType)data[pos] == DType.DictEntryBegin) { + //skip over the { + pos++; + Signature keyType = GetNextSignature (ref pos); + Signature valueType = GetNextSignature (ref pos); + //skip over the } + pos++; + return Signature.MakeDict (keyType, valueType); + } else { + Signature elementType = GetNextSignature (ref pos); + return MakeArray (elementType); + } + //case DType.DictEntryBegin: // FIXME: DictEntries should be handled separately. + case DType.StructBegin: + //List fieldTypes = new List (); + Signature fieldsSig = Signature.Empty; + while ((DType)data[pos] != DType.StructEnd) + fieldsSig += GetNextSignature (ref pos); + //skip over the ) + pos++; + return Signature.MakeStruct (fieldsSig); + //return fieldsSig; + case DType.DictEntryBegin: + Signature sigKey = GetNextSignature (ref pos); + Signature sigValue = GetNextSignature (ref pos); + //skip over the } + pos++; + return Signature.MakeDictEntry (sigKey, sigValue); + default: + return new Signature (dtype); + } + } + + public Type ToType (ref int pos) + { + // TODO: Find a way to avoid these null checks everywhere. + if (data == null) + return typeof (void); + + DType dtype = (DType)data[pos++]; + + switch (dtype) { + case DType.Invalid: + return typeof (void); + case DType.Byte: + return typeof (byte); + case DType.Boolean: + return typeof (bool); + case DType.Int16: + return typeof (short); + case DType.UInt16: + return typeof (ushort); + case DType.Int32: + return typeof (int); + case DType.UInt32: + return typeof (uint); + case DType.Int64: + return typeof (long); + case DType.UInt64: + return typeof (ulong); + case DType.Single: ////not supported by libdbus at time of writing + return typeof (float); + case DType.Double: + return typeof (double); + case DType.String: + return typeof (string); + case DType.ObjectPath: + return typeof (ObjectPath); + case DType.Signature: + return typeof (Signature); + case DType.Array: + //peek to see if this is in fact a dictionary + if ((DType)data[pos] == DType.DictEntryBegin) { + //skip over the { + pos++; + Type keyType = ToType (ref pos); + Type valueType = ToType (ref pos); + //skip over the } + pos++; + return typeof(Dictionary<,>).MakeGenericType (new [] { keyType, valueType}); + } else { + return ToType (ref pos).MakeArrayType (); + } + case DType.StructBegin: + List innerTypes = new List (); + while (((DType)data[pos]) != DType.StructEnd) + innerTypes.Add (ToType (ref pos)); + // go over the struct end + pos++; + return DBusStruct.FromInnerTypes (innerTypes.ToArray ()); + case DType.DictEntryBegin: + return typeof (System.Collections.Generic.KeyValuePair<,>); + case DType.Variant: + return typeof (object); + default: + throw new NotSupportedException ("Parsing or converting this signature is not yet supported (signature was '" + this + "'), at DType." + dtype); + } + } + + public static Signature GetSig (object[] objs) + { + return GetSig (Type.GetTypeArray (objs)); + } + + public static Signature GetSig (Type[] types) + { + if (types == null) + throw new ArgumentNullException ("types"); + + Signature sig = Signature.Empty; + + foreach (Type type in types) + sig += GetSig (type); + + return sig; + } + + public static Signature GetSig (Type type) + { + if (type == null) + throw new ArgumentNullException ("type"); + + //this is inelegant, but works for now + if (type == typeof (Signature)) + return Signature.SignatureSig; + + if (type == typeof (ObjectPath)) + return Signature.ObjectPathSig; + + if (type == typeof (void)) + return Signature.Empty; + + if (type == typeof (string)) + return Signature.StringSig; + + if (type == typeof (object)) + return Signature.VariantSig; + + if (type.IsArray) + return MakeArray (GetSig (type.GetElementType ())); + + if (type.IsGenericType && (type.GetGenericTypeDefinition () == typeof (IDictionary<,>) || type.GetGenericTypeDefinition () == typeof (Dictionary<,>))) { + + Type[] genArgs = type.GetGenericArguments (); + return Signature.MakeDict (GetSig (genArgs[0]), GetSig (genArgs[1])); + } + + if (Mapper.IsPublic (type)) { + return Signature.ObjectPathSig; + } + + if (!type.IsPrimitive && !type.IsEnum) { + Signature sig = Signature.Empty; + + foreach (FieldInfo fi in type.GetFields (BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance)) + sig += GetSig (fi.FieldType); + + return Signature.MakeStruct (sig); + } + + DType dtype = Signature.TypeToDType (type); + return new Signature (dtype); + } + + class SignatureChecker + { + byte[] data; + int pos; + + internal SignatureChecker (byte[] data) + { + this.data = data; + } + + internal bool CheckSignature () + { + return SingleType () ? pos == data.Length : false; + } + + bool SingleType () + { + if (pos >= data.Length) + return false; + + //Console.WriteLine ((DType)data[pos]); + + switch ((DType)data[pos]) { + // Simple Type + case DType.Byte: + case DType.Boolean: + case DType.Int16: + case DType.UInt16: + case DType.Int32: + case DType.UInt32: + case DType.Int64: + case DType.UInt64: + case DType.Single: + case DType.Double: + case DType.String: + case DType.ObjectPath: + case DType.Signature: + case DType.Variant: + pos += 1; + return true; + case DType.Array: + pos += 1; + return ArrayType (); + case DType.StructBegin: + pos += 1; + return StructType (); + case DType.DictEntryBegin: + pos += 1; + return DictType (); + } + + return false; + } + + bool ArrayType () + { + return SingleType (); + } + + bool DictType () + { + bool result = SingleType () && SingleType () && ((DType)data[pos]) == DType.DictEntryEnd; + if (result) + pos += 1; + return result; + } + + bool StructType () + { + if (pos >= data.Length) + return false; + while (((DType)data[pos]) != DType.StructEnd) { + if (!SingleType ()) + return false; + if (pos >= data.Length) + return false; + } + pos += 1; + + return true; + } + } + } +} diff -Nru dbus-sharp-0.7.0/src/Protocol/SocketTransport.cs dbus-sharp-0.8.0/src/Protocol/SocketTransport.cs --- dbus-sharp-0.7.0/src/Protocol/SocketTransport.cs 1970-01-01 00:00:00.000000000 +0000 +++ dbus-sharp-0.8.0/src/Protocol/SocketTransport.cs 2013-07-26 16:37:41.000000000 +0000 @@ -0,0 +1,70 @@ +// Copyright 2006 Alp Toker +// This software is made available under the MIT License +// See COPYING for details + +using System; +using System.IO; +using System.Net; +using System.Net.Sockets; + +namespace DBus.Transports +{ + class SocketTransport : Transport + { + internal Socket socket; + + public override void Open (AddressEntry entry) + { + string host, portStr, family; + int port; + + if (!entry.Properties.TryGetValue ("host", out host)) + host = "localhost"; + + if (!entry.Properties.TryGetValue ("port", out portStr)) + throw new Exception ("No port specified"); + + if (!Int32.TryParse (portStr, out port)) + throw new Exception ("Invalid port: \"" + port + "\""); + + if (!entry.Properties.TryGetValue ("family", out family)) + family = null; + + Open (host, port, family); + } + + public void Open (string host, int port, string family) + { + //TODO: use Socket directly + TcpClient client = new TcpClient (host, port); + /* + client.NoDelay = true; + client.ReceiveBufferSize = (int)Protocol.MaxMessageLength; + client.SendBufferSize = (int)Protocol.MaxMessageLength; + */ + this.socket = client.Client; + SocketHandle = (long)client.Client.Handle; + Stream = client.GetStream (); + } + + public void Open (Socket socket) + { + this.socket = socket; + + socket.Blocking = true; + SocketHandle = (long)socket.Handle; + //Stream = new UnixStream ((int)socket.Handle); + Stream = new NetworkStream (socket); + } + + public override void WriteCred () + { + Stream.WriteByte (0); + } + + public override string AuthString () + { + return String.Empty; + } + } +} diff -Nru dbus-sharp-0.7.0/src/Protocol/Transport.cs dbus-sharp-0.8.0/src/Protocol/Transport.cs --- dbus-sharp-0.7.0/src/Protocol/Transport.cs 1970-01-01 00:00:00.000000000 +0000 +++ dbus-sharp-0.8.0/src/Protocol/Transport.cs 2013-07-26 21:04:04.000000000 +0000 @@ -0,0 +1,216 @@ +// Copyright 2006 Alp Toker +// This software is made available under the MIT License +// See COPYING for details + +using System; +using System.Collections.Generic; +using System.IO; +using System.Threading; +using DBus.Protocol; + +namespace DBus.Transports +{ + abstract class Transport + { + readonly object writeLock = new object (); + + [ThreadStatic] + static byte[] readBuffer; + + protected Connection connection; + + public Stream stream; + public long socketHandle; + + public event EventHandler WakeUp; + + public static Transport Create (AddressEntry entry) + { + switch (entry.Method) { + case "tcp": + { + Transport transport = new SocketTransport (); + transport.Open (entry); + return transport; + } +#if !PORTABLE + case "unix": + { + Transport transport = new UnixNativeTransport (); + transport.Open (entry); + return transport; + } +#endif +#if ENABLE_PIPES + case "win": { + Transport transport = new PipeTransport (); + transport.Open (entry); + return transport; + } +#endif + default: + throw new NotSupportedException ("Transport method \"" + entry.Method + "\" not supported"); + } + } + + public abstract void Open (AddressEntry entry); + public abstract string AuthString (); + public abstract void WriteCred (); + + public Connection Connection + { + get { + return connection; + } set { + connection = value; + } + } + + public Stream Stream { + get { + return stream; + } + set { + stream = value; + } + } + + public long SocketHandle { + get { + return socketHandle; + } + set { + socketHandle = value; + } + } + + public virtual bool TryGetPeerPid (out uint pid) + { + pid = 0; + return false; + } + + + public virtual void Disconnect () + { + stream.Dispose (); + } + + protected void FireWakeUp () + { + if (WakeUp != null) + WakeUp (this, EventArgs.Empty); + } + + internal Message ReadMessage () + { + try { + return ReadMessageReal (); + } catch (IOException e) { + if (ProtocolInformation.Verbose) + Console.Error.WriteLine (e.Message); + connection.IsConnected = false; + return null; + } + } + + int Read (byte[] buffer, int offset, int count) + { + int read = 0; + while (read < count) { + int nread = stream.Read (buffer, offset + read, count - read); + if (nread == 0) + break; + read += nread; + } + + if (read > count) + throw new Exception (); + + return read; + } + + Message ReadMessageReal () + { + byte[] header = null; + byte[] body = null; + + int read; + + //16 bytes is the size of the fixed part of the header + if (readBuffer == null) + readBuffer = new byte[16]; + byte[] hbuf = readBuffer; + + read = Read (hbuf, 0, 16); + + if (read == 0) + return null; + + if (read != 16) + throw new Exception ("Header read length mismatch: " + read + " of expected " + "16"); + + EndianFlag endianness = (EndianFlag)hbuf[0]; + MessageReader reader = new MessageReader (endianness, hbuf); + + //discard endian byte, message type and flags, which we don't care about here + reader.Seek (3); + + byte version = reader.ReadByte (); + + if (version < ProtocolInformation.MinVersion || version > ProtocolInformation.MaxVersion) + throw new NotSupportedException ("Protocol version '" + version.ToString () + "' is not supported"); + + if (ProtocolInformation.Verbose) + if (version != ProtocolInformation.Version) + Console.Error.WriteLine ("Warning: Protocol version '" + version.ToString () + "' is not explicitly supported but may be compatible"); + + uint bodyLength = reader.ReadUInt32 (); + //discard serial + reader.ReadUInt32 (); + uint headerLength = reader.ReadUInt32 (); + + int bodyLen = (int)bodyLength; + int toRead = (int)headerLength; + + //we fixup to include the padding following the header + toRead = ProtocolInformation.Padded (toRead, 8); + + long msgLength = toRead + bodyLen; + if (msgLength > ProtocolInformation.MaxMessageLength) + throw new Exception ("Message length " + msgLength + " exceeds maximum allowed " + ProtocolInformation.MaxMessageLength + " bytes"); + + header = new byte[16 + toRead]; + Array.Copy (hbuf, header, 16); + + read = Read (header, 16, toRead); + + if (read != toRead) + throw new Exception ("Message header length mismatch: " + read + " of expected " + toRead); + + //read the body + if (bodyLen != 0) { + body = new byte[bodyLen]; + + read = Read (body, 0, bodyLen); + + if (read != bodyLen) + throw new Exception ("Message body length mismatch: " + read + " of expected " + bodyLen); + } + + Message msg = Message.FromReceivedBytes (Connection, header, body); + + return msg; + } + + internal virtual void WriteMessage (Message msg) + { + lock (writeLock) { + msg.Header.GetHeaderDataToStream (stream); + if (msg.Body != null && msg.Body.Length != 0) + stream.Write (msg.Body, 0, msg.Body.Length); + stream.Flush (); + } + } + } +} diff -Nru dbus-sharp-0.7.0/src/Protocol.cs dbus-sharp-0.8.0/src/Protocol.cs --- dbus-sharp-0.7.0/src/Protocol.cs 2010-09-15 10:16:28.000000000 +0000 +++ dbus-sharp-0.8.0/src/Protocol.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,525 +0,0 @@ -// Copyright 2006 Alp Toker -// This software is made available under the MIT License -// See COPYING for details - -using System; -using System.Collections.Generic; - -namespace DBus -{ - //yyyyuua{yv} - //struct Header - class Header - { - public EndianFlag Endianness; - public MessageType MessageType; - public HeaderFlag Flags; - public byte MajorVersion; - public uint Length; - public uint Serial; - //public HeaderField[] Fields; - - // Dictionary keyed by Enum has performance issues on .NET - // So we key by byte and use an indexer instead. - public Dictionary Fields; - public object this[FieldCode key] - { - get - { - object value = null; - Fields.TryGetValue ((byte)key, out value); - return value; - } set { - if (value == null) - Fields.Remove((byte)key); - else - Fields[(byte)key] = value; - } - } - - /* - public static DType TypeForField (FieldCode f) - { - switch (f) { - case FieldCode.Invalid: - return DType.Invalid; - case FieldCode.Path: - return DType.ObjectPath; - case FieldCode.Interface: - return DType.String; - case FieldCode.Member: - return DType.String; - case FieldCode.ErrorName: - return DType.String; - case FieldCode.ReplySerial: - return DType.UInt32; - case FieldCode.Destination: - return DType.String; - case FieldCode.Sender: - return DType.String; - case FieldCode.Signature: - return DType.Signature; -#if PROTO_REPLY_SIGNATURE - case FieldCode.ReplySignature: //note: not supported in dbus - return DType.Signature; -#endif - default: - return DType.Invalid; - } - } - */ - } - - /* - public struct HeaderField - { - //public HeaderField (FieldCode code, object value) - //{ - // this.Code = code; - // this.Value = value; - //} - - public static HeaderField Create (FieldCode code, object value) - { - HeaderField hf; - - hf.Code = code; - hf.Value = value; - - return hf; - } - - public FieldCode Code; - public object Value; - } - */ - - /* - struct HeaderFieldSet - { - public ObjectPath Path; - public string Interface; - public string Member; - public string ErrorName; - public uint ReplySerial; - public string Destination; - public string Sender; - //public Signature Signature; - public Signature Sig; - -#if PROTO_REPLY_SIGNATURE - public Signature ReplySignature; -#endif - - public void Read (MessageReader reader) - { - FieldCode code = (FieldCode)reader.ReadByte (); - } - - public void Write (MessageWriter writer) - { - // TODO: Write overall length - - if (Path != null) { - writer.WritePad (8); - writer.Write ((byte)FieldCode.Path); - writer.Write (Signature.ObjectPathSig); - writer.Write (Path); - } - - if (Interface != null) { - writer.WritePad (8); - writer.Write ((byte)FieldCode.Interface); - writer.Write (Signature.StringSig); - writer.Write (Interface); - } - - if (Member != null) { - writer.WritePad (8); - writer.Write ((byte)FieldCode.Member); - writer.Write (Signature.StringSig); - writer.Write (Member); - } - - if (ErrorName != null) { - writer.WritePad (8); - writer.Write ((byte)FieldCode.ErrorName); - writer.Write (Signature.StringSig); - writer.Write (ErrorName); - } - - if (ReplySerial != 0) { - writer.WritePad (8); - writer.Write ((byte)FieldCode.ReplySerial); - writer.Write (Signature.UInt32Sig); - writer.Write (ReplySerial); - } - - if (Destination != null) { - writer.WritePad (8); - writer.Write ((byte)FieldCode.Destination); - writer.Write (Signature.StringSig); - writer.Write (Destination); - } - - if (Sender != null) { - writer.WritePad (8); - writer.Write ((byte)FieldCode.Sender); - writer.Write (Signature.StringSig); - writer.Write (Sender); - } - - if (Sig != Signature.Empty) { - writer.WritePad (8); - writer.Write ((byte)FieldCode.Signature); - writer.Write (Signature.SignatureSig); - writer.Write (Sig); - } - } - } - */ - - enum MessageType : byte - { - //This is an invalid type. - Invalid, - //Method call. - MethodCall, - //Method reply with returned data. - MethodReturn, - //Error reply. If the first argument exists and is a string, it is an error message. - Error, - //Signal emission. - Signal, - } - - enum FieldCode : byte - { - Invalid, - Path, - Interface, - Member, - ErrorName, - ReplySerial, - Destination, - Sender, - Signature, -#if PROTO_REPLY_SIGNATURE - ReplySignature, //note: not supported in dbus -#endif - } - - enum EndianFlag : byte - { - Little = (byte)'l', - Big = (byte)'B', - } - - [Flags] - enum HeaderFlag : byte - { - None = 0, - NoReplyExpected = 0x1, - NoAutoStart = 0x2, - } - - public sealed class ObjectPath : IComparable, IComparable, IEquatable - { - public static readonly ObjectPath Root = new ObjectPath ("/"); - - internal readonly string Value; - - public ObjectPath (string value) - { - if (value == null) - throw new ArgumentNullException ("value"); - - Validate (value); - - this.Value = value; - } - - static void Validate (string value) - { - if (!value.StartsWith ("/")) - throw new ArgumentException ("value"); - if (value.EndsWith ("/") && value.Length > 1) - throw new ArgumentException ("ObjectPath cannot end in '/'"); - - bool multipleSlash = false; - - foreach (char c in value) { - bool valid = (c >= 'a' && c <='z') - || (c >= 'A' && c <= 'Z') - || (c >= '0' && c <= '9') - || c == '_' - || (!multipleSlash && c == '/'); - - if (!valid) { - var message = string.Format ("'{0}' is not a valid character in an ObjectPath", c); - throw new ArgumentException (message, "value"); - } - - multipleSlash = c == '/'; - } - - } - - public int CompareTo (ObjectPath other) - { - if (other == null) - return 1; - - return Value.CompareTo (other.Value); - } - - public int CompareTo (object otherObject) - { - ObjectPath other = otherObject as ObjectPath; - - if (other == null) - return 1; - - return Value.CompareTo (other.Value); - } - - public bool Equals (ObjectPath other) - { - if (other == null) - return false; - - return Value == other.Value; - } - - public override bool Equals (object o) - { - ObjectPath b = o as ObjectPath; - - if (b == null) - return false; - - return Value.Equals (b.Value); - } - - public static bool operator == (ObjectPath a, ObjectPath b) - { - object aa = a, bb = b; - if (aa == null && bb == null) - return true; - - if (aa == null || bb == null) - return false; - - return a.Value == b.Value; - } - - public static bool operator != (ObjectPath a, ObjectPath b) - { - return !(a == b); - } - - public override int GetHashCode () - { - return Value.GetHashCode (); - } - - public override string ToString () - { - return Value; - } - - //this may or may not prove useful - internal string[] Decomposed - { - get { - return Value.Split (new char[] {'/'}, StringSplitOptions.RemoveEmptyEntries); - /* - } set { - Value = String.Join ("/", value); - */ - } - } - - internal ObjectPath Parent - { - get { - if (Value == Root.Value) - return null; - - string par = Value.Substring (0, Value.LastIndexOf ('/')); - if (par == String.Empty) - par = "/"; - - return new ObjectPath (par); - } - } - - /* - public int CompareTo (object value) - { - return 1; - } - - public int CompareTo (ObjectPath value) - { - return 1; - } - - public bool Equals (ObjectPath value) - { - return false; - } - */ - } - - static class Protocol - { - //protocol versions that we support - public const byte MinVersion = 0; - public const byte Version = 1; - public const byte MaxVersion = Version + 1; - - public const uint MaxMessageLength = 134217728; //2 to the 27th power - public const uint MaxArrayLength = 67108864; //2 to the 26th power - public const uint MaxSignatureLength = 255; - public const uint MaxArrayDepth = 32; - public const uint MaxStructDepth = 32; - - //this is not strictly related to Protocol since names are passed around as strings - internal const uint MaxNameLength = 255; - internal const uint MaxMatchRuleLength = 1024; - internal const uint MaxMatchRuleArgs = 64; - - public static int PadNeeded (int pos, int alignment) - { - int pad = pos % alignment; - pad = pad == 0 ? 0 : alignment - pad; - - return pad; - } - - public static int Padded (int pos, int alignment) - { - int pad = pos % alignment; - if (pad != 0) - pos += alignment - pad; - - return pos; - } - - public static int GetAlignment (DType dtype) - { - switch (dtype) { - case DType.Byte: - return 1; - case DType.Boolean: - return 4; - case DType.Int16: - case DType.UInt16: - return 2; - case DType.Int32: - case DType.UInt32: - return 4; - case DType.Int64: - case DType.UInt64: - return 8; -#if !DISABLE_SINGLE - case DType.Single: //Not yet supported! - return 4; -#endif - case DType.Double: - return 8; - case DType.String: - return 4; - case DType.ObjectPath: - return 4; - case DType.Signature: - return 1; - case DType.Array: - return 4; - case DType.Struct: - case DType.StructBegin: - return 8; - case DType.Variant: - return 1; - case DType.DictEntry: - case DType.DictEntryBegin: - return 8; - case DType.Invalid: - default: - throw new Exception ("Cannot determine alignment of " + dtype); - } - } - - //this class may not be the best place for Verbose - public readonly static bool Verbose; - - static Protocol () - { - Verbose = !String.IsNullOrEmpty (Environment.GetEnvironmentVariable ("DBUS_VERBOSE")); - } - } - - // Currently only for internal use on exported objects - class BusException : Exception - { - public BusException (string errorName, string errorMessage) - { - this.ErrorName = errorName; - this.ErrorMessage = errorMessage; - } - - public BusException (string errorName, string format, params object[] args) - { - this.ErrorName = errorName; - this.ErrorMessage = String.Format (format, args); - } - - public override string Message - { - get - { - return ErrorName + ": " + ErrorMessage; - } - } - - public readonly string ErrorName; - - public readonly string ErrorMessage; - } - -#if UNDOCUMENTED_IN_SPEC -/* -"org.freedesktop.DBus.Error.Failed" -"org.freedesktop.DBus.Error.NoMemory" -"org.freedesktop.DBus.Error.ServiceUnknown" -"org.freedesktop.DBus.Error.NameHasNoOwner" -"org.freedesktop.DBus.Error.NoReply" -"org.freedesktop.DBus.Error.IOError" -"org.freedesktop.DBus.Error.BadAddress" -"org.freedesktop.DBus.Error.NotSupported" -"org.freedesktop.DBus.Error.LimitsExceeded" -"org.freedesktop.DBus.Error.AccessDenied" -"org.freedesktop.DBus.Error.AuthFailed" -"org.freedesktop.DBus.Error.NoServer" -"org.freedesktop.DBus.Error.Timeout" -"org.freedesktop.DBus.Error.NoNetwork" -"org.freedesktop.DBus.Error.AddressInUse" -"org.freedesktop.DBus.Error.Disconnected" -"org.freedesktop.DBus.Error.InvalidArgs" -"org.freedesktop.DBus.Error.FileNotFound" -"org.freedesktop.DBus.Error.UnknownMethod" -"org.freedesktop.DBus.Error.TimedOut" -"org.freedesktop.DBus.Error.MatchRuleNotFound" -"org.freedesktop.DBus.Error.MatchRuleInvalid" -"org.freedesktop.DBus.Error.Spawn.ExecFailed" -"org.freedesktop.DBus.Error.Spawn.ForkFailed" -"org.freedesktop.DBus.Error.Spawn.ChildExited" -"org.freedesktop.DBus.Error.Spawn.ChildSignaled" -"org.freedesktop.DBus.Error.Spawn.Failed" -"org.freedesktop.DBus.Error.UnixProcessIdUnknown" -"org.freedesktop.DBus.Error.InvalidSignature" -"org.freedesktop.DBus.Error.SELinuxSecurityContextUnknown" -*/ -#endif -} diff -Nru dbus-sharp-0.7.0/src/Signature.cs dbus-sharp-0.8.0/src/Signature.cs --- dbus-sharp-0.7.0/src/Signature.cs 2010-09-15 10:16:28.000000000 +0000 +++ dbus-sharp-0.8.0/src/Signature.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,897 +0,0 @@ -// Copyright 2006 Alp Toker -// This software is made available under the MIT License -// See COPYING for details - -using System; -using System.Text; - -using System.Collections.Generic; -//TODO: Reflection should be done at a higher level than this class -using System.Reflection; - -namespace DBus -{ - //maybe this should be nullable? - struct Signature - { - //TODO: this class needs some work - //Data should probably include the null terminator - - public static readonly Signature Empty = new Signature (String.Empty); - public static readonly Signature ByteSig = Allocate (DType.Byte); - public static readonly Signature UInt16Sig = Allocate (DType.UInt16); - public static readonly Signature UInt32Sig = Allocate (DType.UInt32); - public static readonly Signature StringSig = Allocate (DType.String); - public static readonly Signature ObjectPathSig = Allocate (DType.ObjectPath); - public static readonly Signature SignatureSig = Allocate (DType.Signature); - public static readonly Signature VariantSig = Allocate (DType.Variant); - - public static bool operator == (Signature a, Signature b) - { - if (a.data == b.data) - return true; - - if (a.data == null) - return false; - - if (b.data == null) - return false; - - if (a.data.Length != b.data.Length) - return false; - - for (int i = 0 ; i != a.data.Length ; i++) - if (a.data[i] != b.data[i]) - return false; - - return true; - } - - public static bool operator != (Signature a, Signature b) - { - return !(a == b); - } - - public override bool Equals (object o) - { - if (o == null) - return false; - - if (!(o is Signature)) - return false; - - return this == (Signature)o; - } - - public override int GetHashCode () - { - // TODO: Avoid string conversion - return Value.GetHashCode (); - } - - public static Signature operator + (Signature s1, Signature s2) - { - return Concat (s1, s2); - } - - public static Signature Concat (Signature s1, Signature s2) - { - if (s1.data == null && s2.data == null) - return Signature.Empty; - - if (s1.data == null) - return s2; - - if (s2.data == null) - return s1; - - if (s1.Length + s2.Length == 0) - return Signature.Empty; - - byte[] data = new byte[s1.data.Length + s2.data.Length]; - s1.data.CopyTo (data, 0); - s2.data.CopyTo (data, s1.data.Length); - return Signature.Take (data); - } - - public Signature (string value) - { - if (value.Length == 0) { - this.data = Empty.data; - return; - } - - if (value.Length == 1) { - this.data = DataForDType ((DType)value[0]); - return; - } - - this.data = Encoding.ASCII.GetBytes (value); - } - - internal static Signature Take (byte[] value) - { - Signature sig; - - if (value.Length == 0) { - sig.data = Empty.data; - return sig; - } - - if (value.Length == 1) { - sig.data = DataForDType ((DType)value[0]); - return sig; - } - - sig.data = value; - return sig; - } - - static byte[] DataForDType (DType value) - { - // Reduce heap allocations. - // For now, we only cache the most common protocol signatures. - switch (value) { - case DType.Byte: - return ByteSig.data; - case DType.UInt16: - return UInt16Sig.data; - case DType.UInt32: - return UInt32Sig.data; - case DType.String: - return StringSig.data; - case DType.ObjectPath: - return ObjectPathSig.data; - case DType.Signature: - return SignatureSig.data; - case DType.Variant: - return VariantSig.data; - default: - return new byte[] {(byte)value}; - } - } - - private static Signature Allocate (DType value) - { - Signature sig; - sig.data = new byte[] {(byte)value}; - return sig; - } - - internal Signature (DType value) - { - this.data = DataForDType (value); - } - - internal Signature (DType[] value) - { - if (value.Length == 0) { - this.data = Empty.data; - return; - } - - if (value.Length == 1) { - this.data = DataForDType (value[0]); - return; - } - - this.data = new byte[value.Length]; - - for (int i = 0 ; i != value.Length ; i++) - this.data[i] = (byte)value[i]; - } - - byte[] data; - - //TODO: this should be private, but MessageWriter and Monitor still use it - //[Obsolete] - public byte[] GetBuffer () - { - return data; - } - - internal DType this[int index] - { - get { - return (DType)data[index]; - } - } - - public int Length - { - get { - return data.Length; - } - } - - //[Obsolete] - public string Value - { - get { - //FIXME: hack to handle bad case when Data is null - if (data == null) - return String.Empty; - - return Encoding.ASCII.GetString (data); - } - } - - public override string ToString () - { - return Value; - - /* - StringBuilder sb = new StringBuilder (); - - foreach (DType t in data) { - //we shouldn't rely on object mapping here, but it's an easy way to get string representations for now - Type type = DTypeToType (t); - if (type != null) { - sb.Append (type.Name); - } else { - char c = (char)t; - if (!Char.IsControl (c)) - sb.Append (c); - else - sb.Append (@"\" + (int)c); - } - sb.Append (" "); - } - - return sb.ToString (); - */ - } - - public Signature MakeArraySignature () - { - return new Signature (DType.Array) + this; - } - - public static Signature MakeStruct (params Signature[] elems) - { - Signature sig = Signature.Empty; - - sig += new Signature (DType.StructBegin); - - foreach (Signature elem in elems) - sig += elem; - - sig += new Signature (DType.StructEnd); - - return sig; - } - - public static Signature MakeDictEntry (Signature keyType, Signature valueType) - { - Signature sig = Signature.Empty; - - sig += new Signature (DType.DictEntryBegin); - - sig += keyType; - sig += valueType; - - sig += new Signature (DType.DictEntryEnd); - - return sig; - } - - public static Signature MakeDict (Signature keyType, Signature valueType) - { - return MakeDictEntry (keyType, valueType).MakeArraySignature (); - } - - public int Alignment - { - get { - if (data.Length == 0) - return 0; - - return Protocol.GetAlignment (this[0]); - } - } - - static int GetSize (DType dtype) - { - switch (dtype) { - case DType.Byte: - return 1; - case DType.Boolean: - return 4; - case DType.Int16: - case DType.UInt16: - return 2; - case DType.Int32: - case DType.UInt32: - return 4; - case DType.Int64: - case DType.UInt64: - return 8; -#if !DISABLE_SINGLE - case DType.Single: //Not yet supported! - return 4; -#endif - case DType.Double: - return 8; - case DType.String: - case DType.ObjectPath: - case DType.Signature: - case DType.Array: - case DType.StructBegin: - case DType.Variant: - case DType.DictEntryBegin: - return -1; - case DType.Invalid: - default: - throw new Exception ("Cannot determine size of " + dtype); - } - } - - public bool GetFixedSize (ref int size) - { - if (size < 0) - return false; - - if (data.Length == 0) - return true; - - // Sensible? - size = Protocol.Padded (size, Alignment); - - if (data.Length == 1) { - int valueSize = GetSize (this[0]); - - if (valueSize == -1) - return false; - - size += valueSize; - return true; - } - - if (IsStructlike) { - foreach (Signature sig in GetParts ()) - if (!sig.GetFixedSize (ref size)) - return false; - return true; - } - - if (IsArray || IsDict) - return false; - - if (IsStruct) { - foreach (Signature sig in GetFieldSignatures ()) - if (!sig.GetFixedSize (ref size)) - return false; - return true; - } - - // Any other cases? - throw new Exception (); - } - - public bool IsFixedSize - { - get { - if (data.Length == 0) - return true; - - if (data.Length == 1) { - int size = GetSize (this[0]); - return size != -1; - } - - if (IsStructlike) { - foreach (Signature sig in GetParts ()) - if (!sig.IsFixedSize) - return false; - return true; - } - - if (IsArray || IsDict) - return false; - - if (IsStruct) { - foreach (Signature sig in GetFieldSignatures ()) - if (!sig.IsFixedSize) - return false; - return true; - } - - // Any other cases? - throw new Exception (); - } - } - - //TODO: complete this - public bool IsPrimitive - { - get { - if (data.Length != 1) - return false; - - if (this[0] == DType.Variant) - return false; - - if (this[0] == DType.Invalid) - return false; - - return true; - } - } - - public bool IsStruct - { - get { - if (Length < 2) - return false; - - if (this[0] != DType.StructBegin) - return false; - - // FIXME: Incorrect! What if this is in fact a Structlike starting and finishing with structs? - if (this[Length - 1] != DType.StructEnd) - return false; - - return true; - } - } - - public bool IsDictEntry - { - get { - if (Length < 2) - return false; - - if (this[0] != DType.DictEntryBegin) - return false; - - // FIXME: Incorrect! What if this is in fact a Structlike starting and finishing with structs? - if (this[Length - 1] != DType.DictEntryEnd) - return false; - - return true; - } - } - - public bool IsStructlike - { - get { - if (Length < 2) - return false; - - if (IsArray) - return false; - - if (IsDict) - return false; - - if (IsStruct) - return false; - - return true; - } - } - - public bool IsDict - { - get { - if (Length < 3) - return false; - - if (!IsArray) - return false; - - // 0 is 'a' - if (this[1] != DType.DictEntryBegin) - return false; - - return true; - } - } - - public bool IsArray - { - get { - if (Length < 2) - return false; - - if (this[0] != DType.Array) - return false; - - return true; - } - } - - public Signature GetElementSignature () - { - if (!IsArray) - throw new Exception ("Cannot get the element signature of a non-array (signature was '" + this + "')"); - - //TODO: improve this - //if (IsDict) - // throw new NotSupportedException ("Parsing dict signature is not supported (signature was '" + this + "')"); - - // Skip over 'a' - int pos = 1; - return GetNextSignature (ref pos); - } - - public Type[] ToTypes () - { - // TODO: Find a way to avoid these null checks everywhere. - if (data == null) - return Type.EmptyTypes; - - List types = new List (); - for (int i = 0 ; i != data.Length ; types.Add (ToType (ref i))); - return types.ToArray (); - } - - public Type ToType () - { - int pos = 0; - Type ret = ToType (ref pos); - if (pos != data.Length) - throw new Exception ("Signature '" + Value + "' is not a single complete type"); - return ret; - } - - internal static DType TypeCodeToDType (TypeCode typeCode) - { - switch (typeCode) - { - case TypeCode.Empty: - return DType.Invalid; - case TypeCode.Object: - return DType.Invalid; - case TypeCode.DBNull: - return DType.Invalid; - case TypeCode.Boolean: - return DType.Boolean; - case TypeCode.Char: - return DType.UInt16; - case TypeCode.SByte: - return DType.Byte; - case TypeCode.Byte: - return DType.Byte; - case TypeCode.Int16: - return DType.Int16; - case TypeCode.UInt16: - return DType.UInt16; - case TypeCode.Int32: - return DType.Int32; - case TypeCode.UInt32: - return DType.UInt32; - case TypeCode.Int64: - return DType.Int64; - case TypeCode.UInt64: - return DType.UInt64; - case TypeCode.Single: - return DType.Single; - case TypeCode.Double: - return DType.Double; - case TypeCode.Decimal: - return DType.Invalid; - case TypeCode.DateTime: - return DType.Invalid; - case TypeCode.String: - return DType.String; - default: - return DType.Invalid; - } - } - - //FIXME: this method is bad, get rid of it - internal static DType TypeToDType (Type type) - { - if (type == typeof (void)) - return DType.Invalid; - - if (type == typeof (string)) - return DType.String; - - if (type == typeof (ObjectPath)) - return DType.ObjectPath; - - if (type == typeof (Signature)) - return DType.Signature; - - if (type == typeof (object)) - return DType.Variant; - - if (type.IsPrimitive) - return TypeCodeToDType (Type.GetTypeCode (type)); - - if (type.IsEnum) - return TypeToDType (Enum.GetUnderlyingType (type)); - - //needs work - if (type.IsArray) - return DType.Array; - - //if (type.UnderlyingSystemType != null) - // return TypeToDType (type.UnderlyingSystemType); - if (Mapper.IsPublic (type)) - return DType.ObjectPath; - - if (!type.IsPrimitive && !type.IsEnum) - return DType.Struct; - - //TODO: maybe throw an exception here - return DType.Invalid; - } - - /* - public static DType TypeToDType (Type type) - { - if (type == null) - return DType.Invalid; - else if (type == typeof (byte)) - return DType.Byte; - else if (type == typeof (bool)) - return DType.Boolean; - else if (type == typeof (short)) - return DType.Int16; - else if (type == typeof (ushort)) - return DType.UInt16; - else if (type == typeof (int)) - return DType.Int32; - else if (type == typeof (uint)) - return DType.UInt32; - else if (type == typeof (long)) - return DType.Int64; - else if (type == typeof (ulong)) - return DType.UInt64; - else if (type == typeof (float)) //not supported by libdbus at time of writing - return DType.Single; - else if (type == typeof (double)) - return DType.Double; - else if (type == typeof (string)) - return DType.String; - else if (type == typeof (ObjectPath)) - return DType.ObjectPath; - else if (type == typeof (Signature)) - return DType.Signature; - else - return DType.Invalid; - } - */ - - public IEnumerable GetFieldSignatures () - { - if (this == Signature.Empty || this[0] != DType.StructBegin) - throw new Exception ("Not a struct"); - - for (int pos = 1 ; pos < data.Length - 1 ;) - yield return GetNextSignature (ref pos); - } - - public void GetDictEntrySignatures (out Signature sigKey, out Signature sigValue) - { - if (this == Signature.Empty || this[0] != DType.DictEntryBegin) - throw new Exception ("Not a DictEntry"); - - int pos = 1; - sigKey = GetNextSignature (ref pos); - sigValue = GetNextSignature (ref pos); - } - - public IEnumerable GetParts () - { - if (data == null) - yield break; - for (int pos = 0 ; pos < data.Length ;) { - yield return GetNextSignature (ref pos); - } - } - - public Signature GetNextSignature (ref int pos) - { - if (data == null) - return Signature.Empty; - - DType dtype = (DType)data[pos++]; - - switch (dtype) { - //case DType.Invalid: - // return typeof (void); - case DType.Array: - //peek to see if this is in fact a dictionary - if ((DType)data[pos] == DType.DictEntryBegin) { - //skip over the { - pos++; - Signature keyType = GetNextSignature (ref pos); - Signature valueType = GetNextSignature (ref pos); - //skip over the } - pos++; - return Signature.MakeDict (keyType, valueType); - } else { - Signature elementType = GetNextSignature (ref pos); - return elementType.MakeArraySignature (); - } - //case DType.DictEntryBegin: // FIXME: DictEntries should be handled separately. - case DType.StructBegin: - //List fieldTypes = new List (); - Signature fieldsSig = Signature.Empty; - while ((DType)data[pos] != DType.StructEnd) - fieldsSig += GetNextSignature (ref pos); - //skip over the ) - pos++; - return Signature.MakeStruct (fieldsSig); - //return fieldsSig; - case DType.DictEntryBegin: - Signature sigKey = GetNextSignature (ref pos); - Signature sigValue = GetNextSignature (ref pos); - //skip over the } - pos++; - return Signature.MakeDictEntry (sigKey, sigValue); - default: - return new Signature (dtype); - } - } - - public Type ToType (ref int pos) - { - // TODO: Find a way to avoid these null checks everywhere. - if (data == null) - return typeof (void); - - DType dtype = (DType)data[pos++]; - - switch (dtype) { - case DType.Invalid: - return typeof (void); - case DType.Byte: - return typeof (byte); - case DType.Boolean: - return typeof (bool); - case DType.Int16: - return typeof (short); - case DType.UInt16: - return typeof (ushort); - case DType.Int32: - return typeof (int); - case DType.UInt32: - return typeof (uint); - case DType.Int64: - return typeof (long); - case DType.UInt64: - return typeof (ulong); - case DType.Single: ////not supported by libdbus at time of writing - return typeof (float); - case DType.Double: - return typeof (double); - case DType.String: - return typeof (string); - case DType.ObjectPath: - return typeof (ObjectPath); - case DType.Signature: - return typeof (Signature); - case DType.Array: - //peek to see if this is in fact a dictionary - if ((DType)data[pos] == DType.DictEntryBegin) { - //skip over the { - pos++; - Type keyType = ToType (ref pos); - Type valueType = ToType (ref pos); - //skip over the } - pos++; - //return typeof (IDictionary<,>).MakeGenericType (new Type[] {keyType, valueType}); - //workaround for Mono bug #81035 (memory leak) - return Mapper.GetGenericType (typeof (IDictionary<,>), new Type[] {keyType, valueType}); - } else { - return ToType (ref pos).MakeArrayType (); - } - case DType.Struct: - return typeof (ValueType); - case DType.DictEntry: - return typeof (System.Collections.Generic.KeyValuePair<,>); - case DType.Variant: - return typeof (object); - default: - throw new NotSupportedException ("Parsing or converting this signature is not yet supported (signature was '" + this + "'), at DType." + dtype); - } - } - - public static Signature GetSig (object[] objs) - { - return GetSig (Type.GetTypeArray (objs)); - } - - public static Signature GetSig (Type[] types) - { - if (types == null) - throw new ArgumentNullException ("types"); - - Signature sig = Signature.Empty; - - foreach (Type type in types) - sig += GetSig (type); - - return sig; - } - - public static Signature GetSig (Type type) - { - if (type == null) - throw new ArgumentNullException ("type"); - - //this is inelegant, but works for now - if (type == typeof (Signature)) - return new Signature (DType.Signature); - - if (type == typeof (ObjectPath)) - return new Signature (DType.ObjectPath); - - if (type == typeof (void)) - return Signature.Empty; - - if (type == typeof (string)) - return new Signature (DType.String); - - if (type == typeof (object)) - return new Signature (DType.Variant); - - if (type.IsArray) - return GetSig (type.GetElementType ()).MakeArraySignature (); - - if (type.IsGenericType && (type.GetGenericTypeDefinition () == typeof (IDictionary<,>) || type.GetGenericTypeDefinition () == typeof (Dictionary<,>))) { - - Type[] genArgs = type.GetGenericArguments (); - return Signature.MakeDict (GetSig (genArgs[0]), GetSig (genArgs[1])); - } - - if (Mapper.IsPublic (type)) { - return new Signature (DType.ObjectPath); - } - - if (!type.IsPrimitive && !type.IsEnum) { - Signature sig = Signature.Empty; - - foreach (FieldInfo fi in type.GetFields (BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance)) - sig += GetSig (fi.FieldType); - - return Signature.MakeStruct (sig); - } - - DType dtype = Signature.TypeToDType (type); - return new Signature (dtype); - } - } - - enum ArgDirection - { - In, - Out, - } - - enum DType : byte - { - Invalid = (byte)'\0', - - Byte = (byte)'y', - Boolean = (byte)'b', - Int16 = (byte)'n', - UInt16 = (byte)'q', - Int32 = (byte)'i', - UInt32 = (byte)'u', - Int64 = (byte)'x', - UInt64 = (byte)'t', - Single = (byte)'f', //This is not yet supported! - Double = (byte)'d', - String = (byte)'s', - ObjectPath = (byte)'o', - Signature = (byte)'g', - - Array = (byte)'a', - [Obsolete ("Not in protocol")] - Struct = (byte)'r', - [Obsolete ("Not in protocol")] - DictEntry = (byte)'e', - Variant = (byte)'v', - - StructBegin = (byte)'(', - StructEnd = (byte)')', - DictEntryBegin = (byte)'{', - DictEntryEnd = (byte)'}', - } -} diff -Nru dbus-sharp-0.7.0/src/SocketTransport.cs dbus-sharp-0.8.0/src/SocketTransport.cs --- dbus-sharp-0.7.0/src/SocketTransport.cs 2010-09-14 09:17:50.000000000 +0000 +++ dbus-sharp-0.8.0/src/SocketTransport.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,70 +0,0 @@ -// Copyright 2006 Alp Toker -// This software is made available under the MIT License -// See COPYING for details - -using System; -using System.IO; -using System.Net; -using System.Net.Sockets; - -namespace DBus.Transports -{ - class SocketTransport : Transport - { - internal Socket socket; - - public override void Open (AddressEntry entry) - { - string host, portStr, family; - int port; - - if (!entry.Properties.TryGetValue ("host", out host)) - host = "localhost"; - - if (!entry.Properties.TryGetValue ("port", out portStr)) - throw new Exception ("No port specified"); - - if (!Int32.TryParse (portStr, out port)) - throw new Exception ("Invalid port: \"" + port + "\""); - - if (!entry.Properties.TryGetValue ("family", out family)) - family = null; - - Open (host, port, family); - } - - public void Open (string host, int port, string family) - { - //TODO: use Socket directly - TcpClient client = new TcpClient (host, port); - /* - client.NoDelay = true; - client.ReceiveBufferSize = (int)Protocol.MaxMessageLength; - client.SendBufferSize = (int)Protocol.MaxMessageLength; - */ - this.socket = client.Client; - SocketHandle = (long)client.Client.Handle; - Stream = client.GetStream (); - } - - public void Open (Socket socket) - { - this.socket = socket; - - socket.Blocking = true; - SocketHandle = (long)socket.Handle; - //Stream = new UnixStream ((int)socket.Handle); - Stream = new NetworkStream (socket); - } - - public override void WriteCred () - { - Stream.WriteByte (0); - } - - public override string AuthString () - { - return String.Empty; - } - } -} diff -Nru dbus-sharp-0.7.0/src/Transport.cs dbus-sharp-0.8.0/src/Transport.cs --- dbus-sharp-0.7.0/src/Transport.cs 2010-09-14 09:17:50.000000000 +0000 +++ dbus-sharp-0.8.0/src/Transport.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,383 +0,0 @@ -// Copyright 2006 Alp Toker -// This software is made available under the MIT License -// See COPYING for details - -using System; -using System.Collections.Generic; -using System.IO; -using System.Threading; - -namespace DBus.Transports -{ - abstract class Transport - { - public static Transport Create (AddressEntry entry) - { - switch (entry.Method) { - case "tcp": - { - Transport transport = new SocketTransport (); - transport.Open (entry); - return transport; - } -#if !PORTABLE - case "unix": - { - Transport transport = new UnixNativeTransport (); - transport.Open (entry); - return transport; - } -#endif -#if ENABLE_PIPES - case "win": { - Transport transport = new PipeTransport (); - transport.Open (entry); - return transport; - } -#endif - default: - throw new NotSupportedException ("Transport method \"" + entry.Method + "\" not supported"); - } - } - - protected Connection connection; - - public Connection Connection - { - get { - return connection; - } set { - connection = value; - } - } - - //TODO: design this properly - - //this is just a temporary solution - public Stream Stream; - public long SocketHandle; - public abstract void Open (AddressEntry entry); - public abstract string AuthString (); - public abstract void WriteCred (); - - public virtual bool TryGetPeerPid (out uint pid) - { - pid = 0; - return false; - } - - Stream ns { - get { - return this.Stream; - } - } - - public virtual void Disconnect () - { - ns.Dispose (); - } - - internal Queue Inbound = new Queue (); - - public event EventHandler WakeUp; - protected void FireWakeUp () - { - if (WakeUp != null) - WakeUp (this, EventArgs.Empty); - } - - internal Message TryReadMessage () - { - GetData (); - if (Inbound.Count > 0) - return Inbound.Dequeue (); - return null; - } - - public void Iterate () - { - GetData (); - } - - internal Message ReadMessage () - { - // Hack to complete pending async reads in progress. - while (msgRdr != null) - GetData (); - - try { - return ReadMessageReal (); - } catch (IOException e) { - if (Protocol.Verbose) - Console.Error.WriteLine (e.Message); - connection.isConnected = false; - return null; - } - } - - int Read (byte[] buffer, int offset, int count) - { - int read = 0; - //System.Net.Sockets.NetworkStream nns = ns as System.Net.Sockets.NetworkStream; - //SocketTransport st = this as SocketTransport; - while (read < count) { - // FIXME: Remove this hack to support non-blocking sockets on Windows - //if (st != null && st.socket.Blocking == false && nns != null && !nns.DataAvailable) { - /* - if (nns != null && !nns.DataAvailable) { - System.Threading.Thread.Sleep (10); - continue; - } - */ - int nread = ns.Read (buffer, offset + read, count - read); - if (nread == 0) - break; - read += nread; - } - - //if (read < count) - // throw new Exception (); - - if (read > count) - throw new Exception (); - - return read; - } - - byte[] mmbuf = null; - - int mmpos = 0; - int mmneeded = 16; - IEnumerator msgRdr; - - public void GetData () - { - if (msgRdr == null) { - msgRdr = ReadMessageReal2 (); - } - - SocketTransport st = this as SocketTransport; - - int avail = st.socket.Available; - if (mmneeded == 0) - throw new Exception (); - - if (avail == 0) - return; - - avail = Math.Min (avail, mmneeded); - int nread = st.socket.Receive (mmbuf, mmpos, avail, System.Net.Sockets.SocketFlags.None); - mmpos += nread; - mmneeded -= nread; - if (!msgRdr.MoveNext ()) - throw new Exception (); - - MsgState state = msgRdr.Current; - if (state != MsgState.Done) - return; - - mmpos = 0; - mmneeded = 16; - - msgRdr = null; - } - - enum MsgState - { - Wait16, - WaitHeader, - WaitBody, - Done, - } - - IEnumerator ReadMessageReal2 () - { - byte[] body = null; - mmneeded = 16; - while (mmpos < 16) - yield return MsgState.Wait16; - - EndianFlag endianness = (EndianFlag)mmbuf[0]; - MessageReader reader = new MessageReader (endianness, mmbuf); - - //discard the endian byte as we've already read it - reader.ReadByte (); - - //discard message type and flags, which we don't care about here - reader.ReadByte (); - reader.ReadByte (); - - byte version = reader.ReadByte (); - - if (version < Protocol.MinVersion || version > Protocol.MaxVersion) - throw new NotSupportedException ("Protocol version '" + version.ToString () + "' is not supported"); - - if (Protocol.Verbose) - if (version != Protocol.Version) - Console.Error.WriteLine ("Warning: Protocol version '" + version.ToString () + "' is not explicitly supported but may be compatible"); - - uint bodyLength = reader.ReadUInt32 (); - //discard serial - reader.ReadUInt32 (); - uint headerLength = reader.ReadUInt32 (); - - //this check may become relevant if a future version of the protocol allows larger messages - /* - if (bodyLength > Int32.MaxValue || headerLength > Int32.MaxValue) - throw new NotImplementedException ("Long messages are not yet supported"); - */ - - int bodyLen = (int)bodyLength; - int toRead = (int)headerLength; - - //we fixup to include the padding following the header - toRead = Protocol.Padded (toRead, 8); - - long msgLength = toRead + bodyLen; - if (msgLength > Protocol.MaxMessageLength) - throw new Exception ("Message length " + msgLength + " exceeds maximum allowed " + Protocol.MaxMessageLength + " bytes"); - - byte[] header = new byte[16 + toRead]; - Array.Copy (mmbuf, header, 16); - - mmneeded = toRead; - while (mmpos < 16 + toRead) - yield return MsgState.WaitHeader; - - Array.Copy (mmbuf, 16, header, 16, toRead); - - //if (read != toRead) - // throw new Exception ("Message header length mismatch: " + read + " of expected " + toRead); - - mmneeded = bodyLen; - while (mmpos < 16 + toRead + bodyLen) - yield return MsgState.WaitBody; - - //read the body - if (bodyLen != 0) { - body = new byte[bodyLen]; - - Array.Copy (mmbuf, 16 + toRead, body, 0, bodyLen); - - //if (read != bodyLen) - // throw new Exception ("Message body length mismatch: " + read + " of expected " + bodyLen); - } - - Message msg = new Message (); - msg.Connection = this.Connection; - msg.Body = body; - msg.SetHeaderData (header); - - Inbound.Enqueue (msg); - - mmneeded = 16; - - yield return MsgState.Done; - } - - Message ReadMessageReal () - { - byte[] header; - byte[] body = null; - - int read; - - //16 bytes is the size of the fixed part of the header - byte[] hbuf = new byte[16]; - - read = Read (hbuf, 0, 16); - - if (read == 0) - return null; - - if (read != 16) - throw new Exception ("Header read length mismatch: " + read + " of expected " + "16"); - - EndianFlag endianness = (EndianFlag)hbuf[0]; - MessageReader reader = new MessageReader (endianness, hbuf); - - //discard the endian byte as we've already read it - reader.ReadByte (); - - //discard message type and flags, which we don't care about here - reader.ReadByte (); - reader.ReadByte (); - - byte version = reader.ReadByte (); - - if (version < Protocol.MinVersion || version > Protocol.MaxVersion) - throw new NotSupportedException ("Protocol version '" + version.ToString () + "' is not supported"); - - if (Protocol.Verbose) - if (version != Protocol.Version) - Console.Error.WriteLine ("Warning: Protocol version '" + version.ToString () + "' is not explicitly supported but may be compatible"); - - uint bodyLength = reader.ReadUInt32 (); - //discard serial - reader.ReadUInt32 (); - uint headerLength = reader.ReadUInt32 (); - - //this check may become relevant if a future version of the protocol allows larger messages - /* - if (bodyLength > Int32.MaxValue || headerLength > Int32.MaxValue) - throw new NotImplementedException ("Long messages are not yet supported"); - */ - - int bodyLen = (int)bodyLength; - int toRead = (int)headerLength; - - //we fixup to include the padding following the header - toRead = Protocol.Padded (toRead, 8); - - long msgLength = toRead + bodyLen; - if (msgLength > Protocol.MaxMessageLength) - throw new Exception ("Message length " + msgLength + " exceeds maximum allowed " + Protocol.MaxMessageLength + " bytes"); - - header = new byte[16 + toRead]; - Array.Copy (hbuf, header, 16); - - read = Read (header, 16, toRead); - - if (read != toRead) - throw new Exception ("Message header length mismatch: " + read + " of expected " + toRead); - - //read the body - if (bodyLen != 0) { - body = new byte[bodyLen]; - - read = Read (body, 0, bodyLen); - - if (read != bodyLen) - throw new Exception ("Message body length mismatch: " + read + " of expected " + bodyLen); - } - - Message msg = new Message (); - msg.Connection = this.Connection; - msg.Body = body; - msg.SetHeaderData (header); - - return msg; - } - - readonly object writeLock = new object (); - internal virtual void WriteMessage (Message msg) - { - /* - byte[] HeaderData = msg.GetHeaderData (); - - long msgLength = HeaderData.Length + (msg.Body != null ? msg.Body.Length : 0); - if (msgLength > Protocol.MaxMessageLength) - throw new Exception ("Message length " + msgLength + " exceeds maximum allowed " + Protocol.MaxMessageLength + " bytes"); - */ - - lock (writeLock) { - //ns.Write (HeaderData, 0, HeaderData.Length); - msg.GetHeaderDataToStream (ns); - if (msg.Body != null && msg.Body.Length != 0) - ns.Write (msg.Body, 0, msg.Body.Length); - ns.Flush (); - } - - } - } -} diff -Nru dbus-sharp-0.7.0/src/Transports/UnixNativeTransport.cs dbus-sharp-0.8.0/src/Transports/UnixNativeTransport.cs --- dbus-sharp-0.7.0/src/Transports/UnixNativeTransport.cs 1970-01-01 00:00:00.000000000 +0000 +++ dbus-sharp-0.8.0/src/Transports/UnixNativeTransport.cs 2013-07-26 21:04:04.000000000 +0000 @@ -0,0 +1,181 @@ +// Copyright 2006 Alp Toker +// This software is made available under the MIT License +// See COPYING for details + +//We send BSD-style credentials on all platforms +//Doesn't seem to break Linux (but is redundant there) +//This may turn out to be a bad idea +#define HAVE_CMSGCRED + +using System; +using System.IO; +using System.Text; +using System.Runtime.InteropServices; +using DBus.Unix; +using DBus.Protocol; + +namespace DBus.Transports +{ + class UnixNativeTransport : UnixTransport + { + internal UnixSocket socket; + + public override string AuthString () + { + long uid = Mono.Unix.Native.Syscall.geteuid (); + return uid.ToString (); + } + + public override void Open (string path, bool @abstract) + { + if (String.IsNullOrEmpty (path)) + throw new ArgumentException ("path"); + + if (@abstract) + socket = OpenAbstractUnix (path); + else + socket = OpenUnix (path); + + //socket.Blocking = true; + SocketHandle = (long)socket.Handle; + //Stream = new UnixStream ((int)socket.Handle); + Stream = new UnixStream (socket); + } + + //send peer credentials null byte + //different platforms do this in different ways +#if HAVE_CMSGCRED + unsafe void WriteBsdCred () + { + //null credentials byte + byte buf = 0; + + IOVector iov = new IOVector (); + //iov.Base = (IntPtr)(&buf); + iov.Base = &buf; + iov.Length = 1; + + msghdr msg = new msghdr (); + msg.msg_iov = &iov; + msg.msg_iovlen = 1; + + cmsg cm = new cmsg (); + msg.msg_control = (IntPtr)(&cm); + msg.msg_controllen = (uint)sizeof (cmsg); + cm.hdr.cmsg_len = (uint)sizeof (cmsg); + cm.hdr.cmsg_level = 0xffff; //SOL_SOCKET + cm.hdr.cmsg_type = 0x03; //SCM_CREDS + + int written = socket.SendMsg (&msg, 0); + if (written != 1) + throw new Exception ("Failed to write credentials"); + } +#endif + + public override void WriteCred () + { +#if HAVE_CMSGCRED + try { + WriteBsdCred (); + return; + } catch { + if (ProtocolInformation.Verbose) + Console.Error.WriteLine ("Warning: WriteBsdCred() failed; falling back to ordinary WriteCred()"); + } +#endif + //null credentials byte + byte buf = 0; + Stream.WriteByte (buf); + } + + public static byte[] GetSockAddr (string path) + { + byte[] p = Encoding.Default.GetBytes (path); + + byte[] sa = new byte[2 + p.Length + 1]; + + //we use BitConverter to stay endian-safe + byte[] afData = BitConverter.GetBytes (UnixSocket.AF_UNIX); + sa[0] = afData[0]; + sa[1] = afData[1]; + + for (int i = 0 ; i != p.Length ; i++) + sa[2 + i] = p[i]; + sa[2 + p.Length] = 0; //null suffix for domain socket addresses, see unix(7) + + return sa; + } + + public static byte[] GetSockAddrAbstract (string path) + { + byte[] p = Encoding.Default.GetBytes (path); + + byte[] sa = new byte[2 + 1 + p.Length]; + + //we use BitConverter to stay endian-safe + byte[] afData = BitConverter.GetBytes (UnixSocket.AF_UNIX); + sa[0] = afData[0]; + sa[1] = afData[1]; + + sa[2] = 0; //null prefix for abstract domain socket addresses, see unix(7) + for (int i = 0 ; i != p.Length ; i++) + sa[3 + i] = p[i]; + + return sa; + } + + internal UnixSocket OpenUnix (string path) + { + byte[] sa = GetSockAddr (path); + UnixSocket client = new UnixSocket (); + client.Connect (sa); + return client; + } + + internal UnixSocket OpenAbstractUnix (string path) + { + byte[] sa = GetSockAddrAbstract (path); + UnixSocket client = new UnixSocket (); + client.Connect (sa); + return client; + } + } + +#if HAVE_CMSGCRED + unsafe struct msghdr + { + public IntPtr msg_name; //optional address + public uint msg_namelen; //size of address + public IOVector *msg_iov; //scatter/gather array + public int msg_iovlen; //# elements in msg_iov + public IntPtr msg_control; //ancillary data, see below + public uint msg_controllen; //ancillary data buffer len + public int msg_flags; //flags on received message + } + + struct cmsghdr + { + public uint cmsg_len; //data byte count, including header + public int cmsg_level; //originating protocol + public int cmsg_type; //protocol-specific type + } + + unsafe struct cmsgcred + { + const int CMGROUP_MAX = 16; + + public int cmcred_pid; //PID of sending process + public uint cmcred_uid; //real UID of sending process + public uint cmcred_euid; //effective UID of sending process + public uint cmcred_gid; //real GID of sending process + public short cmcred_ngroups; //number or groups + public fixed uint cmcred_groups[CMGROUP_MAX]; //groups + } + + struct cmsg + { + public cmsghdr hdr; + public cmsgcred cred; + } +#endif +} diff -Nru dbus-sharp-0.7.0/src/Transports/UnixTransport.cs dbus-sharp-0.8.0/src/Transports/UnixTransport.cs --- dbus-sharp-0.7.0/src/Transports/UnixTransport.cs 1970-01-01 00:00:00.000000000 +0000 +++ dbus-sharp-0.8.0/src/Transports/UnixTransport.cs 2013-07-26 21:04:04.000000000 +0000 @@ -0,0 +1,29 @@ +// Copyright 2006 Alp Toker +// This software is made available under the MIT License +// See COPYING for details + +using System; +using System.IO; + +namespace DBus.Transports +{ + abstract class UnixTransport : Transport + { + public override void Open (AddressEntry entry) + { + string path; + bool abstr; + + if (entry.Properties.TryGetValue ("path", out path)) + abstr = false; + else if (entry.Properties.TryGetValue ("abstract", out path)) + abstr = true; + else + throw new ArgumentException ("No path specified for UNIX transport"); + + Open (path, abstr); + } + + public abstract void Open (string path, bool @abstract); + } +} diff -Nru dbus-sharp-0.7.0/src/TypeImplementer.cs dbus-sharp-0.8.0/src/TypeImplementer.cs --- dbus-sharp-0.7.0/src/TypeImplementer.cs 2010-09-14 09:17:50.000000000 +0000 +++ dbus-sharp-0.8.0/src/TypeImplementer.cs 2013-09-27 15:30:45.000000000 +0000 @@ -9,6 +9,8 @@ namespace DBus { + using Protocol; + class TypeImplementer { public static readonly TypeImplementer Root = new TypeImplementer ("DBus.Proxies", false); @@ -16,14 +18,36 @@ ModuleBuilder modB; static readonly object getImplLock = new Object (); + Dictionary map = new Dictionary (); + + static MethodInfo getTypeFromHandleMethod = typeof (Type).GetMethod ("GetTypeFromHandle", new Type[] {typeof (RuntimeTypeHandle)}); + static ConstructorInfo argumentNullExceptionConstructor = typeof (ArgumentNullException).GetConstructor (new Type[] {typeof (string)}); + static ConstructorInfo messageWriterConstructor = typeof (MessageWriter).GetConstructor (Type.EmptyTypes); + static MethodInfo messageWriterWriteArray = typeof (MessageWriter).GetMethod ("WriteArray"); + static MethodInfo messageWriterWriteDict = typeof (MessageWriter).GetMethod ("WriteFromDict"); + static MethodInfo messageWriterWriteStruct = typeof (MessageWriter).GetMethod ("WriteStructure"); + static MethodInfo messageReaderReadValue = typeof (MessageReader).GetMethod ("ReadValue", new Type[] { typeof (System.Type) }); + static MethodInfo messageReaderReadArray = typeof (MessageReader).GetMethod ("ReadArray", Type.EmptyTypes); + static MethodInfo messageReaderReadDictionary = typeof (MessageReader).GetMethod ("ReadDictionary", Type.EmptyTypes); + static MethodInfo messageReaderReadStruct = typeof (MessageReader).GetMethod ("ReadStruct", Type.EmptyTypes); + + static Dictionary writeMethods = new Dictionary (); + static Dictionary typeWriters = new Dictionary (); + + static MethodInfo sendMethodCallMethod = typeof (BusObject).GetMethod ("SendMethodCall"); + static MethodInfo sendSignalMethod = typeof (BusObject).GetMethod ("SendSignal"); + static MethodInfo toggleSignalMethod = typeof (BusObject).GetMethod ("ToggleSignal"); + + static Dictionary hookup_methods = new Dictionary (); + static Dictionary readMethods = new Dictionary (); + public TypeImplementer (string name, bool canSave) { - asmB = AppDomain.CurrentDomain.DefineDynamicAssembly (new AssemblyName (name), canSave ? AssemblyBuilderAccess.RunAndSave : AssemblyBuilderAccess.Run); + asmB = AppDomain.CurrentDomain.DefineDynamicAssembly (new AssemblyName (name), + canSave ? AssemblyBuilderAccess.RunAndSave : AssemblyBuilderAccess.Run); modB = asmB.DefineDynamicModule (name); } - Dictionary map = new Dictionary (); - public Type GetImplementation (Type declType) { Type retT; @@ -43,11 +67,12 @@ TypeBuilder typeB = modB.DefineType (proxyName, TypeAttributes.Class | TypeAttributes.Public, parentType); + string interfaceName = null; if (declType.IsInterface) - Implement (typeB, declType); + Implement (typeB, declType, interfaceName = Mapper.GetInterfaceName (declType)); foreach (Type iface in declType.GetInterfaces ()) - Implement (typeB, iface); + Implement (typeB, iface, interfaceName == null ? Mapper.GetInterfaceName (iface) : interfaceName); retT = typeB.CreateType (); @@ -57,7 +82,7 @@ return retT; } - static void Implement (TypeBuilder typeB, Type iface) + static void Implement (TypeBuilder typeB, Type iface, string interfaceName) { typeB.AddInterfaceImplementation (iface); @@ -81,7 +106,7 @@ method_builder.DefineParameter (i + 1, parms[i].Attributes, parms[i].Name); ILGenerator ilg = method_builder.GetILGenerator (); - GenHookupMethod (ilg, declMethod, sendMethodCallMethod, Mapper.GetInterfaceName (iface), declMethod.Name); + GenHookupMethod (ilg, declMethod, sendMethodCallMethod, interfaceName, declMethod.Name); if (declMethod.IsSpecialName) builders[declMethod.Name] = method_builder; @@ -109,11 +134,6 @@ } } - static MethodInfo sendMethodCallMethod = typeof (BusObject).GetMethod ("SendMethodCall"); - static MethodInfo sendSignalMethod = typeof (BusObject).GetMethod ("SendSignal"); - static MethodInfo toggleSignalMethod = typeof (BusObject).GetMethod ("ToggleSignal"); - - static Dictionary hookup_methods = new Dictionary (); public static DynamicMethod GetHookupMethod (EventInfo ei) { DynamicMethod hookupMethod; @@ -137,8 +157,8 @@ ParameterInfo[] delegateParms = declMethod.GetParameters (); Type[] hookupParms = new Type[delegateParms.Length+1]; hookupParms[0] = typeof (BusObject); - for (int i = 0; i < delegateParms.Length ; i++) - hookupParms[i+1] = delegateParms[i].ParameterType; + for (int i = 0; i < delegateParms.Length; ++i) + hookupParms[i + 1] = delegateParms[i].ParameterType; DynamicMethod hookupMethod = new DynamicMethod ("Handle" + member, declMethod.ReturnType, hookupParms, typeof (MessageWriter)); @@ -149,14 +169,6 @@ return hookupMethod; } - static MethodInfo getTypeFromHandleMethod = typeof (Type).GetMethod ("GetTypeFromHandle", new Type[] {typeof (RuntimeTypeHandle)}); - static ConstructorInfo argumentNullExceptionConstructor = typeof (ArgumentNullException).GetConstructor (new Type[] {typeof (string)}); - static ConstructorInfo messageWriterConstructor = typeof (MessageWriter).GetConstructor (Type.EmptyTypes); - static MethodInfo messageWriterWritePad = typeof (MessageWriter).GetMethod ("WritePad", new Type[] {typeof (int)}); - static MethodInfo messageReaderReadPad = typeof (MessageReader).GetMethod ("ReadPad", new Type[] {typeof (int)}); - - static Dictionary writeMethods = new Dictionary (); - public static MethodInfo GetWriteMethod (Type t) { MethodInfo meth; @@ -181,7 +193,6 @@ return meth; } - static Dictionary typeWriters = new Dictionary (); public static TypeWriter GetTypeWriter () { Type t = typeof (T); @@ -205,30 +216,25 @@ { Type tUnder = t; - if (t.IsEnum) { + if (t.IsEnum) tUnder = Enum.GetUnderlyingType (t); - //imprecise = true; - } Type type = t; - //MethodInfo exactWriteMethod = typeof (MessageWriter).GetMethod ("Write", new Type[] {tUnder}); MethodInfo exactWriteMethod = typeof (MessageWriter).GetMethod ("Write", BindingFlags.ExactBinding | BindingFlags.Instance | BindingFlags.Public, null, new Type[] {tUnder}, null); - //ExactBinding InvokeMethod if (exactWriteMethod != null) { - ilg.Emit (exactWriteMethod.IsFinal ? OpCodes.Call : OpCodes.Callvirt, exactWriteMethod); + ilg.Emit (OpCodes.Call, exactWriteMethod); } else if (t.IsArray) { - MethodInfo mi = typeof (MessageWriter).GetMethod ("WriteArray"); - exactWriteMethod = mi.MakeGenericMethod (type.GetElementType ()); - ilg.Emit (exactWriteMethod.IsFinal ? OpCodes.Call : OpCodes.Callvirt, exactWriteMethod); + exactWriteMethod = messageWriterWriteArray.MakeGenericMethod (type.GetElementType ()); + ilg.Emit (OpCodes.Call, exactWriteMethod); } else if (type.IsGenericType && (type.GetGenericTypeDefinition () == typeof (IDictionary<,>) || type.GetGenericTypeDefinition () == typeof (Dictionary<,>))) { Type[] genArgs = type.GetGenericArguments (); - MethodInfo mi = typeof (MessageWriter).GetMethod ("WriteFromDict"); - exactWriteMethod = mi.MakeGenericMethod (genArgs); - ilg.Emit (exactWriteMethod.IsFinal ? OpCodes.Call : OpCodes.Callvirt, exactWriteMethod); + exactWriteMethod = messageWriterWriteDict.MakeGenericMethod (genArgs); + ilg.Emit (OpCodes.Call, exactWriteMethod); } else { - GenStructWriter (ilg, t); + MethodInfo mi = messageWriterWriteStruct.MakeGenericMethod (t); + ilg.Emit (OpCodes.Call, mi); } } @@ -238,95 +244,6 @@ return type.GetFields (BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance); } - //takes a writer and a reference to an object off the stack - public static void GenStructWriter (ILGenerator ilg, Type type) - { - LocalBuilder val = ilg.DeclareLocal (type); - ilg.Emit (OpCodes.Stloc, val); - - LocalBuilder writer = ilg.DeclareLocal (typeof (MessageWriter)); - ilg.Emit (OpCodes.Stloc, writer); - - //align to 8 for structs - ilg.Emit (OpCodes.Ldloc, writer); - ilg.Emit (OpCodes.Ldc_I4, 8); - ilg.Emit (OpCodes.Call, messageWriterWritePad); - - foreach (FieldInfo fi in GetMarshalFields (type)) { - Type t = fi.FieldType; - - // null checking of fields - if (!t.IsValueType) { - Label notNull = ilg.DefineLabel (); - - //if the value is null... - //ilg.Emit (OpCodes.Ldarg, i); - ilg.Emit (OpCodes.Ldloc, val); - ilg.Emit (OpCodes.Ldfld, fi); - - ilg.Emit (OpCodes.Brtrue_S, notNull); - - //...throw Exception - string paramName = fi.Name; - ilg.Emit (OpCodes.Ldstr, paramName); - // TODO: Should not really be argumentNullException - ilg.Emit (OpCodes.Newobj, argumentNullExceptionConstructor); - ilg.Emit (OpCodes.Throw); - - //was not null, so all is well - ilg.MarkLabel (notNull); - } - - //the Writer to write to - ilg.Emit (OpCodes.Ldloc, writer); - - //the object to read from - ilg.Emit (OpCodes.Ldloc, val); - ilg.Emit (OpCodes.Ldfld, fi); - - GenWriter (ilg, t); - } - } - - //takes a reader and a reference to an object off the stack - public static void GenStructReader (ILGenerator ilg, Type type) - { - // FIXME: Newobj fails if type has no default ctor! - - LocalBuilder val = ilg.DeclareLocal (type); - ConstructorInfo ctor = type.GetConstructor (Type.EmptyTypes); - ilg.Emit (OpCodes.Newobj, ctor); - ilg.Emit (OpCodes.Stloc, val); - - LocalBuilder reader = ilg.DeclareLocal (typeof (MessageReader)); - ilg.Emit (OpCodes.Stloc, reader); - - //align to 8 for structs - ilg.Emit (OpCodes.Ldloc, reader); - ilg.Emit (OpCodes.Ldc_I4, 8); - ilg.Emit (OpCodes.Call, messageReaderReadPad); - - foreach (FieldInfo fi in GetMarshalFields (type)) { - Type t = fi.FieldType; - - //the object to read into - ilg.Emit (OpCodes.Ldloc, val); - - //the Reader to read from - ilg.Emit (OpCodes.Ldloc, reader); - - GenReader (ilg, t); - - ilg.Emit (OpCodes.Stfld, fi); - } - - ilg.Emit (OpCodes.Ldloc, val); - //if (type.IsValueType) - // ilg.Emit (OpCodes.Box, type); - } - - static MethodInfo getBusObject = typeof(BusObject).GetMethod("GetBusObject"); - public static void GenHookupMethod (ILGenerator ilg, MethodInfo declMethod, MethodInfo invokeMethod, string @interface, string member) { ParameterInfo[] parms = declMethod.GetParameters (); @@ -335,9 +252,7 @@ //the BusObject instance ilg.Emit (OpCodes.Ldarg_0); - ilg.Emit (OpCodes.Call, getBusObject); - - //MethodInfo + ilg.Emit (OpCodes.Castclass, typeof (BusObject)); //interface ilg.Emit (OpCodes.Ldstr, @interface); @@ -346,7 +261,7 @@ if (declMethod.IsSpecialName && (declMethod.Name.StartsWith ("add_") || declMethod.Name.StartsWith ("remove_"))) { string[] parts = declMethod.Name.Split (new char[]{'_'}, 2); string ename = parts[1]; - //Delegate dlg = (Delegate)inArgs[0]; + bool adding = parts[0] == "add"; ilg.Emit (OpCodes.Ldstr, ename); @@ -373,8 +288,8 @@ ilg.Emit (OpCodes.Ldstr, member); //signature - Signature inSig = Signature.Empty; - Signature outSig = Signature.Empty; + Signature inSig; + Signature outSig; SigsForMethod (declMethod, out inSig, out outSig); ilg.Emit (OpCodes.Ldstr, inSig.Value); @@ -421,14 +336,13 @@ ilg.Emit (OpCodes.Ldloc, writer); //the expected return Type - ilg.Emit (OpCodes.Ldtoken, retType); - ilg.Emit (OpCodes.Call, getTypeFromHandleMethod); + GenTypeOf (ilg, retType); LocalBuilder exc = ilg.DeclareLocal (typeof (Exception)); ilg.Emit (OpCodes.Ldloca_S, exc); //make the call - ilg.Emit (invokeMethod.IsFinal ? OpCodes.Call : OpCodes.Callvirt, invokeMethod); + ilg.Emit (OpCodes.Callvirt, invokeMethod); //define a label we'll use to deal with a non-null Exception Label noErr = ilg.DefineLabel (); @@ -505,7 +419,6 @@ return true; } - static Dictionary readMethods = new Dictionary (); static void InitReaders () { foreach (MethodInfo mi in typeof (MessageReader).GetMethods (BindingFlags.Instance | BindingFlags.Public)) { @@ -532,17 +445,10 @@ return null; } - internal static MethodCaller2 GenCaller2 (MethodInfo target) + internal static MethodCaller GenCaller (MethodInfo target) { DynamicMethod hookupMethod = GenReadMethod (target); - MethodCaller2 caller = hookupMethod.CreateDelegate (typeof (MethodCaller2)) as MethodCaller2; - return caller; - } - - internal static MethodCaller GenCaller (MethodInfo target, object targetInstance) - { - DynamicMethod hookupMethod = GenReadMethod (target); - MethodCaller caller = hookupMethod.CreateDelegate (typeof (MethodCaller), targetInstance) as MethodCaller; + MethodCaller caller = hookupMethod.CreateDelegate (typeof (MethodCaller)) as MethodCaller; return caller; } @@ -604,36 +510,34 @@ ilg.Emit (OpCodes.Ldarg_3); // writer ilg.Emit (OpCodes.Ldloc, retLocal); GenWriter (ilg, retType); - } ilg.Emit (OpCodes.Ret); } - //takes the Reader instance off the stack, puts value of type t on the stack public static void GenReader (ILGenerator ilg, Type t) { - // TODO: Cache generated methods - // TODO: Generate methods with the correct module/type permissions - Type tUnder = t; if (t.IsEnum) tUnder = Enum.GetUnderlyingType (t); + Type gDef = t.IsGenericType ? t.GetGenericTypeDefinition () : null; + MethodInfo exactMethod = GetReadMethod (tUnder); - if (exactMethod != null) - ilg.Emit (exactMethod.IsFinal ? OpCodes.Call : OpCodes.Callvirt, exactMethod); - else if (t.IsArray) - GenReadCollection (ilg, t); - else if (t.IsGenericType && (t.GetGenericTypeDefinition () == typeof (IList<>))) - GenReadCollection (ilg, t); - else if (t.IsGenericType && (t.GetGenericTypeDefinition () == typeof (IDictionary<,>) || t.GetGenericTypeDefinition () == typeof (Dictionary<,>))) - GenReadCollection (ilg, t); - else if (t.IsInterface) + if (exactMethod != null) { + ilg.Emit (OpCodes.Callvirt, exactMethod); + } else if (t.IsArray) { + var tarray = t.GetElementType (); + ilg.Emit (OpCodes.Call, messageReaderReadArray.MakeGenericMethod (new[] { tarray })); + } else if (gDef != null && (gDef == typeof (IDictionary<,>) || gDef == typeof (Dictionary<,>))) { + var tmpTypes = t.GetGenericArguments (); + MethodInfo mi = messageReaderReadDictionary.MakeGenericMethod (new[] { tmpTypes[0], tmpTypes[1] }); + ilg.Emit (OpCodes.Callvirt, mi); + } else if (t.IsInterface) GenFallbackReader (ilg, tUnder); else if (!tUnder.IsValueType) { - GenStructReader (ilg, tUnder); + ilg.Emit (OpCodes.Callvirt, messageReaderReadStruct.MakeGenericMethod (tUnder)); } else GenFallbackReader (ilg, tUnder); } @@ -641,17 +545,12 @@ public static void GenFallbackReader (ILGenerator ilg, Type t) { // TODO: do we want non-tUnder here for Castclass use? - if (Protocol.Verbose) + if (ProtocolInformation.Verbose) Console.Error.WriteLine ("Bad! Generating fallback reader for " + t); - MethodInfo exactMethod; - exactMethod = typeof (MessageReader).GetMethod ("ReadValue", new Type[] { typeof (System.Type) }); - // The Type parameter - ilg.Emit (OpCodes.Ldtoken, t); - ilg.Emit (OpCodes.Call, getTypeFromHandleMethod); - - ilg.Emit (exactMethod.IsFinal ? OpCodes.Call : OpCodes.Callvirt, exactMethod); + GenTypeOf (ilg, t); + ilg.Emit (OpCodes.Callvirt, messageReaderReadValue); if (t.IsValueType) ilg.Emit (OpCodes.Unbox_Any, t); @@ -659,251 +558,14 @@ ilg.Emit (OpCodes.Castclass, t); } - public static void GenReadArrayFixed (ILGenerator ilg, Type t, int knownElemSize) - { - LocalBuilder readerLocal = ilg.DeclareLocal (typeof (MessageReader)); - ilg.Emit (OpCodes.Stloc, readerLocal); - - Type tElem = t.GetElementType (); - Signature sigElem = Signature.GetSig (tElem); - int alignElem = sigElem.Alignment; - int knownElemSizePadded = Protocol.Padded (knownElemSize, sigElem.Alignment); - Type tUnder = tElem.IsEnum ? Enum.GetUnderlyingType (tElem) : tElem; - int managedElemSize = System.Runtime.InteropServices.Marshal.SizeOf (tUnder); - - // Read the array's byte length - ilg.Emit (OpCodes.Ldloc, readerLocal); - MethodInfo exactMethod = GetReadMethod (typeof (uint)); - ilg.Emit (exactMethod.IsFinal ? OpCodes.Call : OpCodes.Callvirt, exactMethod); - LocalBuilder sizeLocal = ilg.DeclareLocal (typeof (uint)); - ilg.Emit (OpCodes.Stloc, sizeLocal); - - // Create a new array of the correct element length - ilg.Emit (OpCodes.Ldloc, sizeLocal); - if (knownElemSizePadded > 1) { - ilg.Emit (OpCodes.Ldc_I4, alignElem); - MethodInfo paddedMethod = typeof (Protocol).GetMethod ("Padded"); - ilg.Emit (OpCodes.Call, paddedMethod); - // Divide by the known element size - ilg.Emit (OpCodes.Ldc_I4, knownElemSizePadded); - ilg.Emit (OpCodes.Div_Un); - } - ilg.Emit (OpCodes.Newarr, tElem); - LocalBuilder aryLocal = ilg.DeclareLocal (t); - ilg.Emit (OpCodes.Stloc, aryLocal); - - Label nonBlitLabel = ilg.DefineLabel (); - Label endLabel = ilg.DefineLabel (); - - // Skip read or blit for zero-length arrays. - ilg.Emit (OpCodes.Ldloc, sizeLocal); - ilg.Emit (OpCodes.Brfalse, endLabel); - - // WARNING: This may skew pos when we later increment it! - if (alignElem > 4) { - // Align to element if alignment requirement is higher than 4 (since we just read a uint) - ilg.Emit (OpCodes.Ldloc, readerLocal); - ilg.Emit (OpCodes.Ldc_I4, alignElem); - ilg.Emit (OpCodes.Call, messageReaderReadPad); - } - - // Blit where possible - - // shouldBlit: Blit if endian is native - // mustBlit: Blit regardless of endian (ie. byte or structs containing only bytes) - - bool shouldBlit = tElem.IsValueType && knownElemSizePadded == managedElemSize && !sigElem.IsStruct; - - // bool and char are not reliably blittable, so we don't allow blitting in these cases. - // Their exact layout varies between runtimes, platforms and even data types. - shouldBlit &= tElem != typeof (bool) && tElem != typeof (char); - - bool mustBlit = shouldBlit && knownElemSizePadded == 1; - - if (shouldBlit) { - if (!mustBlit) { - // Check to see if we can blit the data structures - FieldInfo nativeEndianField = typeof (MessageReader).GetField ("IsNativeEndian"); - ilg.Emit (OpCodes.Ldloc, readerLocal); - ilg.Emit (OpCodes.Ldfld, nativeEndianField); - ilg.Emit (OpCodes.Brfalse_S, nonBlitLabel); - } - - // Get the destination address - ilg.Emit (OpCodes.Ldloc, aryLocal); - ilg.Emit (OpCodes.Ldc_I4_0); - ilg.Emit (OpCodes.Ldelema, tElem); - - // Get the source address - FieldInfo dataField = typeof (MessageReader).GetField ("data"); - FieldInfo posField = typeof (MessageReader).GetField ("pos"); - ilg.Emit (OpCodes.Ldloc, readerLocal); - ilg.Emit (OpCodes.Ldfld, dataField); - { - ilg.Emit (OpCodes.Ldloc, readerLocal); - ilg.Emit (OpCodes.Ldfld, posField); - } - ilg.Emit (OpCodes.Ldelema, typeof (byte)); - - // The number of bytes to copy - ilg.Emit (OpCodes.Ldloc, sizeLocal); - - // Blit the array - ilg.Emit (OpCodes.Cpblk); - - // pos += bytesRead - ilg.Emit (OpCodes.Ldloc, readerLocal); - ilg.Emit (OpCodes.Ldloc, readerLocal); - ilg.Emit (OpCodes.Ldfld, posField); - ilg.Emit (OpCodes.Ldloc, sizeLocal); - ilg.Emit (OpCodes.Add); - ilg.Emit (OpCodes.Stfld, posField); - - ilg.Emit (OpCodes.Br, endLabel); - } - - if (!mustBlit) { - ilg.MarkLabel (nonBlitLabel); - - // for (int i = 0 ; i < ary.Length ; i++) - LocalBuilder indexLocal = ilg.DeclareLocal (typeof (int)); - ilg.Emit (OpCodes.Ldc_I4_0); - ilg.Emit (OpCodes.Stloc, indexLocal); - - Label loopStartLabel = ilg.DefineLabel (); - Label loopEndLabel = ilg.DefineLabel (); - - ilg.Emit (OpCodes.Br, loopEndLabel); - - ilg.MarkLabel (loopStartLabel); - - { - // Read and store an element to the array - ilg.Emit (OpCodes.Ldloc, aryLocal); - ilg.Emit (OpCodes.Ldloc, indexLocal); - - ilg.Emit (OpCodes.Ldloc, readerLocal); - GenReader (ilg, tElem); - - ilg.Emit (OpCodes.Stelem, tElem); - } - - // i++ - ilg.Emit (OpCodes.Ldloc, indexLocal); - ilg.Emit (OpCodes.Ldc_I4_1); - ilg.Emit (OpCodes.Add); - ilg.Emit (OpCodes.Stloc, indexLocal); - - ilg.MarkLabel (loopEndLabel); - ilg.Emit (OpCodes.Ldloc, indexLocal); - ilg.Emit (OpCodes.Ldloc, aryLocal); - ilg.Emit (OpCodes.Ldlen); - ilg.Emit (OpCodes.Blt, loopStartLabel); - } - - ilg.MarkLabel (endLabel); - - // Return the new array - ilg.Emit (OpCodes.Ldloc, aryLocal); - } - - public static void GenReadCollection (ILGenerator ilg, Type type) + static void GenTypeOf (ILGenerator ilg, Type t) { - int fixedSize = 0; - if (type.IsArray && Signature.GetSig (type.GetElementType ()).GetFixedSize (ref fixedSize)) { - GenReadArrayFixed (ilg, type, fixedSize); - return; - } - - LocalBuilder readerLocal = ilg.DeclareLocal (typeof (MessageReader)); - ilg.Emit (OpCodes.Stloc, readerLocal); - - Type[] genArgs = type.IsArray ? new Type[] { type.GetElementType () } : type.GetGenericArguments (); - - Type collType = Mapper.GetGenericType (genArgs.Length == 2 ? typeof (Dictionary<,>) : typeof (List<>), genArgs); - - ConstructorInfo ctor = collType.GetConstructor (Type.EmptyTypes); - ilg.Emit (OpCodes.Newobj, ctor); - - LocalBuilder collLocal = ilg.DeclareLocal (collType); - ilg.Emit (OpCodes.Stloc, collLocal); - - MethodInfo addMethod = collType.GetMethod ("Add", genArgs); - - - // Read the array's byte length - MethodInfo readUInt32Method = GetReadMethod (typeof (uint)); - ilg.Emit (OpCodes.Ldloc, readerLocal); - ilg.Emit (readUInt32Method.IsFinal ? OpCodes.Call : OpCodes.Callvirt, readUInt32Method); - - { - // Align to 8 for structs - ilg.Emit (OpCodes.Ldloc, readerLocal); - // TODO: This padding logic is sketchy - ilg.Emit (OpCodes.Ldc_I4, genArgs.Length > 1 ? 8 : Signature.GetSig (genArgs[0]).Alignment); - ilg.Emit (OpCodes.Call, messageReaderReadPad); - } - - // Similar to the fixed array loop code - - FieldInfo posField = typeof (MessageReader).GetField ("pos"); - LocalBuilder endPosLocal = ilg.DeclareLocal (typeof (int)); - ilg.Emit (OpCodes.Ldloc, readerLocal); - ilg.Emit (OpCodes.Ldfld, posField); - - // Add the current position and byte length to determine endPos - // TODO: Consider padding? - ilg.Emit (OpCodes.Add); - ilg.Emit (OpCodes.Stloc, endPosLocal); - - { - Label loopStartLabel = ilg.DefineLabel (); - Label loopEndLabel = ilg.DefineLabel (); - - ilg.Emit (OpCodes.Br, loopEndLabel); - - ilg.MarkLabel (loopStartLabel); - - { - if (genArgs.Length > 1) { - // Align to 8 for structs - ilg.Emit (OpCodes.Ldloc, readerLocal); - ilg.Emit (OpCodes.Ldc_I4, 8); - ilg.Emit (OpCodes.Call, messageReaderReadPad); - } - - // Read and store an element to the array - ilg.Emit (OpCodes.Ldloc, collLocal); - - foreach (Type genArg in genArgs) { - ilg.Emit (OpCodes.Ldloc, readerLocal); - GenReader (ilg, genArg); - } - - ilg.Emit (OpCodes.Call, addMethod); - } - - ilg.MarkLabel (loopEndLabel); - - ilg.Emit (OpCodes.Ldloc, readerLocal); - ilg.Emit (OpCodes.Ldfld, posField); - - ilg.Emit (OpCodes.Ldloc, endPosLocal); - ilg.Emit (OpCodes.Blt, loopStartLabel); - } - - // Return the new collection - ilg.Emit (OpCodes.Ldloc, collLocal); - - if (type.IsArray) { - MethodInfo toArrayMethod = collType.GetMethod ("ToArray", Type.EmptyTypes); - ilg.Emit (OpCodes.Call, toArrayMethod); - } + ilg.Emit (OpCodes.Ldtoken, t); + ilg.Emit (OpCodes.Call, getTypeFromHandleMethod); } } internal delegate void TypeWriter (MessageWriter writer, T value); - internal delegate void MethodCaller (MessageReader rdr, Message msg, MessageWriter ret); - internal delegate void MethodCaller2 (object instance, MessageReader rdr, Message msg, MessageWriter ret); + internal delegate void MethodCaller (object instance, MessageReader rdr, Message msg, MessageWriter ret); } diff -Nru dbus-sharp-0.7.0/src/TypeRental.cs dbus-sharp-0.8.0/src/TypeRental.cs --- dbus-sharp-0.7.0/src/TypeRental.cs 2010-09-14 09:17:50.000000000 +0000 +++ dbus-sharp-0.8.0/src/TypeRental.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,504 +0,0 @@ -// Copyright 2009 Alp Toker -// This software is made available under the MIT License -// See COPYING for details - -using System; -using System.Reflection; -using System.Reflection.Emit; -using System.Collections.Generic; - -namespace DBus -{ - public class ILReader2 - { - public byte[] m_byteArray; - Int32 m_position; - MethodBase m_enclosingMethod; - - static OpCode[] s_OneByteOpCodes = new OpCode[0x100]; - static OpCode[] s_TwoByteOpCodes = new OpCode[0x100]; - static ILReader2() - { - foreach (FieldInfo fi in typeof(OpCodes).GetFields(BindingFlags.Public | BindingFlags.Static)) - { - OpCode opCode = (OpCode)fi.GetValue(null); - UInt16 value = (UInt16)opCode.Value; - if (value < 0x100) - s_OneByteOpCodes[value] = opCode; - else if ((value & 0xff00) == 0xfe00) - s_TwoByteOpCodes[value & 0xff] = opCode; - } - } - - /* - public ILReader(MethodBase enclosingMethod) - { - this.m_enclosingMethod = enclosingMethod; - MethodBody methodBody = m_enclosingMethod.GetMethodBody(); - this.m_byteArray = (methodBody == null) ? new Byte[0] : methodBody.GetILAsByteArray(); - this.m_position = 0; - } - */ - - public ILReader2(MethodBase enclosingMethod) - { - this.m_enclosingMethod = enclosingMethod; - MethodBody methodBody = m_enclosingMethod.GetMethodBody(); - this.m_byteArray = (methodBody == null) ? new Byte[0] : methodBody.GetILAsByteArray(); - this.m_position = 0; - } - - public ILOp[] Iterate() - { - List data = new List(); - - while (m_position < m_byteArray.Length) { - Next(); - - if (current.operandType == null) - current.operandType = String.Empty; - - if (current.operand == null) - current.operand = String.Empty; - - data.Add(current); - } - - //Console.WriteLine("dataCount: " + data.Count); - m_position = 0; - - return data.ToArray(); - } - - public struct ILOp - { - /* - public ILOp(OpCodeType opType, string operandType) - { - this.opType = opType; - this.operandType = operandType; - this.operand = String.Empty; - } - */ - - public OpCode opCode; - - //public OpCodeType opType; - public string operandType; - public object operand; - - /* - public string operandType - { - get { - //return String.Empty; - return String.Empty; - } set { - } - } - */ - public Type operandTypeT - { - get { - //return String.Empty; - if (operandType == String.Empty) - return null; - return Type.GetType("System" + Type.Delimiter + operandType); - } - } - - /* - public string operand - { - get { - return String.Empty; - } set { - } - } - */ - - - /* - public OpCode _opCode - { - get { - //UInt16 value = (UInt16)opCode.Value; - UInt16 value = (UInt16)opCodeValue; - if (value < 0x100) - s_OneByteOpCodes[value] = opCode; - else if ((value & 0xff00) == 0xfe00) - s_TwoByteOpCodes[value & 0xff] = opCode; - } - } - */ - - static Type ilgType = typeof(ILGenerator); - - public bool Emit(ILGenerator ilg) - { - Type t = operandTypeT; - - if (t == null) { - //Console.WriteLine("emitsimple: " + opCode); - if (ilg != null) - ilg.Emit(opCode); - return true; - } - - MethodInfo emitmi = ilgType.GetMethod("Emit", new Type[] {typeof(OpCode), t}); - //Console.WriteLine("emitmi: " + opCode + " " + emitmi); - - object operandObj = null; - - //if (t == typeof(MethodInfo)) { - if (typeof(MemberInfo).IsAssignableFrom(t)) { - string operandStr = (string)operand; - int idx = operandStr.LastIndexOf(Type.Delimiter); - if (idx < 0) - return false; - string ifaceName = operandStr.Remove(idx); - string methName = operandStr.Substring(idx + 1); - - //Console.WriteLine("ifacename: " + ifaceName); - //Console.WriteLine("methname: " + methName); - - Type declType = Type.GetType(ifaceName); - if (declType == null) - declType = Assembly.GetExecutingAssembly().GetType(ifaceName, false); - if (declType == null) - declType = Assembly.GetCallingAssembly().GetType(ifaceName, false); - - if (declType == null) - return false; - - //MethodInfo mi = declType.GetMethod(methName); - //if (mi == null) - // return false; - MemberInfo[] mis = declType.GetMember(methName); - if (mis.Length == 0) - return false; - - MemberInfo mi = mis[0]; - - //Console.WriteLine("good!: " + mi); - - operandObj = mi; - } else if (t == typeof(string)) - operandObj = (string)operand; - else - operandObj = Convert.ChangeType(operand, t); - - //Console.WriteLine("operandObj: " + operandObj); - if (ilg != null) - emitmi.Invoke(ilg, new object[] { opCode, operandObj }); - - /* - switch (operandType) { - case nu: - ilg.Emit(opCode); - return true; - case "MethodInfo": - MethodInfo mi = null; - ilg.Emit(opCode, mi); - return true; - } - */ - - return true; - } - } - - public static bool TryGetType(string ifaceName, out Type declType) - { - declType = Type.GetType(ifaceName); - if (declType == null) - declType = Assembly.GetExecutingAssembly().GetType(ifaceName, false); - if (declType == null) - declType = Assembly.GetCallingAssembly().GetType(ifaceName, false); - return declType != null; - } - - - ILOp current; - - void Next() - { - Int32 offset = m_position; - OpCode opCode = OpCodes.Nop; - int token = 0; - - // read first 1 or 2 bytes as opCode - Byte code = ReadByte(); - if (code != 0xFE) - opCode = s_OneByteOpCodes[code]; - else - { - code = ReadByte(); - opCode = s_TwoByteOpCodes[code]; - } - - //Console.WriteLine("opcode: " + opCode); - - current = new ILOp(); - //current.opType = opCode.OpCodeType; - current.opCode = opCode; - //current.opType = opCode.OperandType; - - switch (opCode.OperandType) - { - case OperandType.InlineNone: - //ilg.Emit(opCode); - break; - case OperandType.ShortInlineBrTarget: - SByte shortDelta = ReadSByte(); - //ilg.Emit(opCode, shortDelta); - break; - case OperandType.InlineBrTarget: - Int32 delta = ReadInt32(); - //ilg.Emit(opCode, delta); - break; - case OperandType.ShortInlineI: - byte int8 = ReadByte(); - //ilg.Emit(opCode, int8); - break; - case OperandType.InlineI: - Int32 int32 = ReadInt32(); - //ilg.Emit(opCode, int32); - break; - case OperandType.InlineI8: - Int64 int64 = ReadInt64(); - //ilg.Emit(opCode, int64); - break; - case OperandType.ShortInlineR: - Single float32 = ReadSingle(); - //ilg.Emit(opCode, float32); - break; - case OperandType.InlineR: - Double float64 = ReadDouble(); - //ilg.Emit(opCode, float64); - break; - case OperandType.ShortInlineVar: - Byte index8 = ReadByte(); - //ilg.Emit(opCode, index8); - break; - case OperandType.InlineVar: - UInt16 index16 = ReadUInt16(); - //ilg.Emit(opCode, index16); - break; - case OperandType.InlineString: - token = ReadInt32(); - current.operandType = "String"; - current.operand = m_enclosingMethod.Module.ResolveString(token); - //ilg.Emit(opCode, m_enclosingMethod.Module.ResolveString(token)); - break; - case OperandType.InlineSig: - token = ReadInt32(); - //ilg.Emit(opCode, m_enclosingMethod.Module.ResolveSignature(token)); - throw new NotImplementedException(); - break; - case OperandType.InlineField: - token = ReadInt32(); - FieldInfo fi = m_enclosingMethod.Module.ResolveField(token); - current.operandType = "Reflection.FieldInfo"; - current.operand = fi.DeclaringType.FullName + Type.Delimiter + fi.Name; - //ilg.Emit(opCode, m_enclosingMethod.Module.ResolveField(token)); - break; - case OperandType.InlineType: - token = ReadInt32(); - current.operandType = "Type"; - Type t = m_enclosingMethod.Module.ResolveType(token); - current.operand = t.FullName; - //ilg.Emit(opCode, m_enclosingMethod.Module.ResolveType(token)); - break; - case OperandType.InlineTok: - token = ReadInt32(); - //ilg.Emit(opCode, token); - break; - case OperandType.InlineMethod: - token = ReadInt32(); - MethodInfo mi = (MethodInfo)m_enclosingMethod.Module.ResolveMethod(token); - current.operandType = "Reflection.MethodInfo"; - current.operand = mi.DeclaringType.FullName + Type.Delimiter + mi.Name; - //ilg.Emit(opCode, mi); - break; - case OperandType.InlineSwitch: - - throw new NotImplementedException(); - - Int32 cases = ReadInt32(); - Int32[] deltas = new Int32[cases]; - for (Int32 i = 0; i < cases; i++) deltas[i] = ReadInt32(); - break; - - default: - throw new BadImageFormatException("unexpected OperandType " + opCode.OperandType); - } - } - - Byte ReadByte() - { - current.operandType = "Byte"; - Byte ret = (Byte)m_byteArray[m_position++]; - current.operand = ret; - return ret; - } - - SByte ReadSByte() - { - current.operandType = "SByte"; - SByte ret = (SByte)ReadByte(); - current.operand = ret; - return ret; - } - - UInt16 ReadUInt16() { - current.operandType = "UInt16"; - m_position += 2; - UInt16 ret = BitConverter.ToUInt16(m_byteArray, m_position - 2); - current.operand = ret; - return ret; - } - - UInt32 ReadUInt32() { - current.operandType = "UInt32"; - m_position += 4; - UInt32 ret = BitConverter.ToUInt32(m_byteArray, m_position - 4); - current.operand = ret; - return ret; - } - - UInt64 ReadUInt64() { - current.operandType = "UInt64"; - m_position += 8; - UInt64 ret = BitConverter.ToUInt64(m_byteArray, m_position - 8); - current.operand = ret; - return ret; - } - - Int32 ReadInt32() { - current.operandType = "Int32"; - m_position += 4; - Int32 ret = BitConverter.ToInt32(m_byteArray, m_position - 4); - current.operand = ret; - return ret; - } - - Int64 ReadInt64() { - current.operandType = "Int64"; - m_position += 8; - Int64 ret = BitConverter.ToInt64(m_byteArray, m_position - 8); - current.operand = ret; - return ret; - } - - Single ReadSingle() { - current.operandType = "UInt16"; - m_position += 4; - Single ret = BitConverter.ToSingle(m_byteArray, m_position - 4); - current.operand = ret; - return ret; - } - - Double ReadDouble() { - current.operandType = "Double"; - m_position += 8; - Double ret = BitConverter.ToDouble(m_byteArray, m_position - 8); - current.operand = ret; - return ret; - } - } - -#if RENTAL_STUFF_FROM_DAEMON - - /* - public string MyMeth (uint val1, string val2) - { - Console.WriteLine ("MyMeth " + val1 + " " + val2); - return "WEE!"; - } - */ - - /* - public struct MethData - { - public int A; - public int B; - public int C; - } - */ - - public class MethDataBase - { - public int A; - } - - public class MethData : MethDataBase - { - public int B; - public int C; - //public MethData[] Children; - public long[] Children; - } - - public void MyMeth0 () - { - } - - public string MyMeth (MethData d, int[] ary, IDictionary dict) - { - Console.WriteLine ("MyMeth struct " + d.A + " " + d.B + " " + d.C); - foreach (int i in ary) - Console.WriteLine (i); - Console.WriteLine ("Children: " + d.Children.Length); - Console.WriteLine ("Dict entries: " + dict.Count); - Console.WriteLine ("321: " + dict[321]); - return "WEE!"; - } - - // From HandleMessage(): - //if (msg.Signature == new Signature ("u")) - if (false) { - System.Reflection.MethodInfo target = typeof (ServerBus).GetMethod ("MyMeth"); - //System.Reflection.MethodInfo target = typeof (ServerBus).GetMethod ("MyMeth0"); - Signature inSig, outSig; - TypeImplementer.SigsForMethod (target, out inSig, out outSig); - Console.WriteLine ("inSig: " + inSig); - - if (msg.Signature == inSig) { - MethodCaller caller = TypeImplementer.GenCaller (target, this); - //caller (new MessageReader (msg), msg); - - MessageWriter retWriter = new MessageWriter (); - caller (new MessageReader (msg), msg, retWriter); - - if (msg.ReplyExpected) { - MethodReturn method_return = new MethodReturn (msg.Header.Serial); - Message replyMsg = method_return.message; - replyMsg.Body = retWriter.ToArray (); - Console.WriteLine ("replyMsg body: " + replyMsg.Body.Length); - /* - try { - replyMsg.Header[FieldCode.Destination] = msg.Header[FieldCode.Sender]; - replyMsg.Header[FieldCode.Sender] = Caller.UniqueName; - } catch (Exception e) { - Console.Error.WriteLine (e); - } - */ - replyMsg.Header[FieldCode.Destination] = Caller.UniqueName; - replyMsg.Header[FieldCode.Sender] = "org.freedesktop.DBus"; - replyMsg.Signature = outSig; - { - Caller.Send (replyMsg); - - /* - replyMsg.Header.Serial = Caller.GenerateSerial (); - MessageDumper.WriteMessage (replyMsg, Console.Out); - Caller.SendReal (replyMsg); - */ - return; - } - } - } - } -#endif -} diff -Nru dbus-sharp-0.7.0/src/Unix/UnixError.cs dbus-sharp-0.8.0/src/Unix/UnixError.cs --- dbus-sharp-0.7.0/src/Unix/UnixError.cs 1970-01-01 00:00:00.000000000 +0000 +++ dbus-sharp-0.8.0/src/Unix/UnixError.cs 2013-09-27 15:42:29.000000000 +0000 @@ -0,0 +1,46 @@ +// Copyright 2008 Alp Toker +// This software is made available under the MIT License +// See COPYING for details + +using System; +using System.IO; +using System.Runtime.InteropServices; + +namespace DBus +{ + static class UnixError + { + internal const string LIBC = "libc"; + + [DllImport (LIBC, CallingConvention=CallingConvention.Cdecl, SetLastError=false)] + static extern IntPtr strerror (int errnum); + + static string GetErrorString (int errnum) + { + IntPtr strPtr = strerror (errnum); + + if (strPtr == IntPtr.Zero) + return "Unknown Unix error"; + + return Marshal.PtrToStringAnsi (strPtr); + } + + // FIXME: Don't hard-code this. + const int EINTR = 4; + + public static bool ShouldRetry + { + get { + int errno = System.Runtime.InteropServices.Marshal.GetLastWin32Error (); + return errno == EINTR; + } + } + + public static Exception GetLastUnixException () + { + int errno = System.Runtime.InteropServices.Marshal.GetLastWin32Error (); + return new Exception (String.Format ("Error {0}: {1}", errno, GetErrorString (errno))); + } + } +} + diff -Nru dbus-sharp-0.7.0/src/Unix/UnixSocket.cs dbus-sharp-0.8.0/src/Unix/UnixSocket.cs --- dbus-sharp-0.7.0/src/Unix/UnixSocket.cs 1970-01-01 00:00:00.000000000 +0000 +++ dbus-sharp-0.8.0/src/Unix/UnixSocket.cs 2013-09-27 15:42:29.000000000 +0000 @@ -0,0 +1,331 @@ +// Copyright 2008 Alp Toker +// This software is made available under the MIT License +// See COPYING for details + +using System; +using System.IO; +using System.Runtime.InteropServices; + +namespace DBus.Unix +{ + // size_t + using SizeT = System.UIntPtr; + // ssize_t + using SSizeT = System.IntPtr; + // socklen_t: assumed to be 4 bytes + // uid_t: assumed to be 4 bytes + + //[StructLayout(LayoutKind.Sequential, Pack=1)] + unsafe struct IOVector + { + public IOVector (IntPtr bbase, int length) + { + this.Base = (void*)bbase; + this.length = (SizeT)length; + } + + //public IntPtr Base; + public void* Base; + + public SizeT length; + public int Length + { + get { + return (int)length; + } set { + length = (SizeT)value; + } + } + } + + unsafe class UnixSocket + { + internal const string LIBC = "libc"; + + // Solaris provides socket functionality in libsocket rather than libc. + // We use a dllmap in the .config to deal with this. + internal const string LIBSOCKET = "libc"; + + public const short AF_UNIX = 1; + // FIXME: SOCK_STREAM is 2 on Solaris + public const short SOCK_STREAM = 1; + + [DllImport (LIBC, CallingConvention = CallingConvention.Cdecl, SetLastError = true)] + internal static extern IntPtr fork (); + + [DllImport (LIBC, CallingConvention = CallingConvention.Cdecl, SetLastError = true)] + internal static extern int dup2 (int fd, int fd2); + + [DllImport (LIBC, CallingConvention = CallingConvention.Cdecl, SetLastError = true)] + internal static extern int open ([MarshalAs(UnmanagedType.LPStr)] string path, int oflag); + + [DllImport (LIBC, CallingConvention = CallingConvention.Cdecl, SetLastError = true)] + internal static extern IntPtr setsid (); + + + [DllImport (LIBC, CallingConvention=CallingConvention.Cdecl, SetLastError=true)] + internal static extern int close (int fd); + + [DllImport (LIBSOCKET, CallingConvention=CallingConvention.Cdecl, SetLastError=true)] + protected static extern int socket (int domain, int type, int protocol); + + [DllImport (LIBSOCKET, CallingConvention=CallingConvention.Cdecl, SetLastError=true)] + protected static extern int connect (int sockfd, byte[] serv_addr, uint addrlen); + + [DllImport (LIBSOCKET, CallingConvention=CallingConvention.Cdecl, SetLastError=true)] + protected static extern int bind (int sockfd, byte[] my_addr, uint addrlen); + + [DllImport (LIBSOCKET, CallingConvention=CallingConvention.Cdecl, SetLastError=true)] + protected static extern int listen (int sockfd, int backlog); + + //TODO: this prototype is probably wrong, fix it + [DllImport (LIBSOCKET, CallingConvention=CallingConvention.Cdecl, SetLastError=true)] + protected static extern int accept (int sockfd, void* addr, ref uint addrlen); + + //TODO: confirm and make use of these functions + [DllImport (LIBSOCKET, CallingConvention=CallingConvention.Cdecl, SetLastError=true)] + protected static extern int getsockopt (int s, int optname, IntPtr optval, ref uint optlen); + + [DllImport (LIBSOCKET, CallingConvention=CallingConvention.Cdecl, SetLastError=true)] + protected static extern int setsockopt (int s, int optname, IntPtr optval, uint optlen); + + [DllImport (LIBC, CallingConvention=CallingConvention.Cdecl, SetLastError=true)] + unsafe static extern SSizeT read (int fd, byte* buf, SizeT count); + + [DllImport (LIBC, CallingConvention=CallingConvention.Cdecl, SetLastError=true)] + unsafe static extern SSizeT write (int fd, byte* buf, SizeT count); + + [DllImport (LIBC, CallingConvention=CallingConvention.Cdecl, SetLastError=true)] + unsafe static extern SSizeT readv (int fd, IOVector* iov, int iovcnt); + + [DllImport (LIBC, CallingConvention=CallingConvention.Cdecl, SetLastError=true)] + unsafe static extern SSizeT writev (int fd, IOVector* iov, int iovcnt); + + // Linux + //[DllImport (LIBC, CallingConvention=CallingConvention.Cdecl, SetLastError=true)] + //static extern int vmsplice (int fd, IOVector* iov, uint nr_segs, uint flags); + + [DllImport (LIBSOCKET, CallingConvention=CallingConvention.Cdecl, SetLastError=true)] + public static extern SSizeT recvmsg (int s, void* msg, int flags); + + [DllImport (LIBSOCKET, CallingConvention=CallingConvention.Cdecl, SetLastError=true)] + public static extern SSizeT sendmsg (int s, void* msg, int flags); + + public int Handle; + bool ownsHandle = false; + + public UnixSocket (int handle) : this (handle, false) + { + } + + public UnixSocket (int handle, bool ownsHandle) + { + this.Handle = handle; + this.ownsHandle = ownsHandle; + // TODO: SafeHandle? + } + + public UnixSocket () + { + //TODO: don't hard-code PF_UNIX and SOCK_STREAM or SocketType.Stream + //AddressFamily family, SocketType type, ProtocolType proto + + int r = socket (AF_UNIX, SOCK_STREAM, 0); + if (r < 0) + throw UnixError.GetLastUnixException (); + + Handle = r; + ownsHandle = true; + } + + ~UnixSocket () + { + if (ownsHandle && Handle > 0) + Close (); + } + + protected bool connected = false; + + //TODO: consider memory management + public void Close () + { + int r = 0; + + do { + r = close (Handle); + } while (r < 0 && UnixError.ShouldRetry); + + if (r < 0) + throw UnixError.GetLastUnixException (); + + Handle = -1; + connected = false; + } + + //TODO: consider memory management + public void Connect (byte[] remote_end) + { + int r = 0; + + do { + r = connect (Handle, remote_end, (uint)remote_end.Length); + } while (r < 0 && UnixError.ShouldRetry); + + if (r < 0) + throw UnixError.GetLastUnixException (); + + connected = true; + } + + //assigns a name to the socket + public void Bind (byte[] local_end) + { + int r = bind (Handle, local_end, (uint)local_end.Length); + if (r < 0) + throw UnixError.GetLastUnixException (); + } + + public void Listen (int backlog) + { + int r = listen (Handle, backlog); + if (r < 0) + throw UnixError.GetLastUnixException (); + } + + public UnixSocket Accept () + { + byte[] addr = new byte[110]; + uint addrlen = (uint)addr.Length; + + fixed (byte* addrP = addr) { + int r = 0; + + do { + r = accept (Handle, addrP, ref addrlen); + } while (r < 0 && UnixError.ShouldRetry); + + if (r < 0) + throw UnixError.GetLastUnixException (); + + //TODO: use the returned addr + //string str = Encoding.Default.GetString (addr, 0, (int)addrlen); + return new UnixSocket (r, true); + } + } + + unsafe public int Read (byte[] buf, int offset, int count) + { + fixed (byte* bufP = buf) + return Read (bufP + offset, count); + } + + public int Write (byte[] buf, int offset, int count) + { + fixed (byte* bufP = buf) + return Write (bufP + offset, count); + } + + unsafe public int Read (byte* bufP, int count) + { + int r = 0; + + do { + r = (int)read (Handle, bufP, (SizeT)count); + } while (r < 0 && UnixError.ShouldRetry); + + if (r < 0) + throw UnixError.GetLastUnixException (); + + return r; + } + + public int Write (byte* bufP, int count) + { + int r = 0; + + do { + r = (int)write (Handle, bufP, (SizeT)count); + } while (r < 0 && UnixError.ShouldRetry); + + if (r < 0) + throw UnixError.GetLastUnixException (); + + return r; + } + + public int RecvMsg (void* bufP, int flags) + { + int r = 0; + + do { + r = (int)recvmsg (Handle, bufP, flags); + } while (r < 0 && UnixError.ShouldRetry); + + if (r < 0) + throw UnixError.GetLastUnixException (); + + return r; + } + + public int SendMsg (void* bufP, int flags) + { + int r = 0; + + do { + r = (int)sendmsg (Handle, bufP, flags); + } while (r < 0 && UnixError.ShouldRetry); + + if (r < 0) + throw UnixError.GetLastUnixException (); + + return r; + } + + public int ReadV (IOVector* iov, int count) + { + //FIXME: Handle EINTR here or elsewhere + //FIXME: handle r != count + //TODO: check offset correctness + + int r = (int)readv (Handle, iov, count); + if (r < 0) + throw UnixError.GetLastUnixException (); + + return r; + } + + public int WriteV (IOVector* iov, int count) + { + //FIXME: Handle EINTR here or elsewhere + //FIXME: handle r != count + //TODO: check offset correctness + + int r = (int)writev (Handle, iov, count); + if (r < 0) + throw UnixError.GetLastUnixException (); + + return r; + } + + public int Write (IOVector[] iov, int offset, int count) + { + //FIXME: Handle EINTR here or elsewhere + //FIXME: handle r != count + //TODO: check offset correctness + + fixed (IOVector* bufP = &iov[offset]) { + int r = (int)writev (Handle, bufP + offset, count); + if (r < 0) + throw UnixError.GetLastUnixException (); + + return r; + } + } + + public int Write (IOVector[] iov) + { + return Write (iov, 0, iov.Length); + } + + } +} diff -Nru dbus-sharp-0.7.0/src/Unix/UnixStream.cs dbus-sharp-0.8.0/src/Unix/UnixStream.cs --- dbus-sharp-0.7.0/src/Unix/UnixStream.cs 1970-01-01 00:00:00.000000000 +0000 +++ dbus-sharp-0.8.0/src/Unix/UnixStream.cs 2013-09-27 15:42:29.000000000 +0000 @@ -0,0 +1,106 @@ +// Copyright 2008 Alp Toker +// This software is made available under the MIT License +// See COPYING for details + +using System; +using System.IO; +using System.Runtime.InteropServices; + +namespace DBus.Unix +{ + // size_t + using SizeT = System.UIntPtr; + // ssize_t + using SSizeT = System.IntPtr; + // socklen_t: assumed to be 4 bytes + // uid_t: assumed to be 4 bytes + + sealed class UnixStream : Stream //, IDisposable + { + public readonly UnixSocket usock; + + public UnixStream (int fd) + { + this.usock = new UnixSocket (fd); + } + + public UnixStream (UnixSocket usock) + { + this.usock = usock; + } + + public override bool CanRead + { + get { + return true; + } + } + + public override bool CanSeek + { + get { + return false; + } + } + + public override bool CanWrite + { + get { + return true; + } + } + + public override long Length + { + get { + throw new NotImplementedException ("Seeking is not implemented"); + } + } + + public override long Position + { + get { + throw new NotImplementedException ("Seeking is not implemented"); + } set { + throw new NotImplementedException ("Seeking is not implemented"); + } + } + + public override long Seek (long offset, SeekOrigin origin) + { + throw new NotImplementedException ("Seeking is not implemented"); + } + + public override void SetLength (long value) + { + throw new NotImplementedException ("Not implemented"); + } + + public override void Flush () + { + } + + public override int Read ([In, Out] byte[] buffer, int offset, int count) + { + return usock.Read (buffer, offset, count); + } + + public override void Write (byte[] buffer, int offset, int count) + { + usock.Write (buffer, offset, count); + } + + unsafe public override int ReadByte () + { + byte value; + usock.Read (&value, 1); + return value; + } + + unsafe public override void WriteByte (byte value) + { + usock.Write (&value, 1); + } + } +} + diff -Nru dbus-sharp-0.7.0/src/Unix.cs dbus-sharp-0.8.0/src/Unix.cs --- dbus-sharp-0.7.0/src/Unix.cs 2010-09-14 09:17:50.000000000 +0000 +++ dbus-sharp-0.8.0/src/Unix.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,484 +0,0 @@ -// Copyright 2008 Alp Toker -// This software is made available under the MIT License -// See COPYING for details - -using System; -using System.IO; -using System.Runtime.InteropServices; - -namespace DBus.Unix -{ - // size_t - using SizeT = System.UIntPtr; - // ssize_t - using SSizeT = System.IntPtr; - // socklen_t: assumed to be 4 bytes - // uid_t: assumed to be 4 bytes - - sealed class UnixStream : Stream //, IDisposable - { - public readonly UnixSocket usock; - - public UnixStream (int fd) - { - this.usock = new UnixSocket (fd); - } - - public UnixStream (UnixSocket usock) - { - this.usock = usock; - } - - public override bool CanRead - { - get { - return true; - } - } - - public override bool CanSeek - { - get { - return false; - } - } - - public override bool CanWrite - { - get { - return true; - } - } - - public override long Length - { - get { - throw new NotImplementedException ("Seeking is not implemented"); - } - } - - public override long Position - { - get { - throw new NotImplementedException ("Seeking is not implemented"); - } set { - throw new NotImplementedException ("Seeking is not implemented"); - } - } - - public override long Seek (long offset, SeekOrigin origin) - { - throw new NotImplementedException ("Seeking is not implemented"); - } - - public override void SetLength (long value) - { - throw new NotImplementedException ("Not implemented"); - } - - public override void Flush () - { - } - - public override int Read ([In, Out] byte[] buffer, int offset, int count) - { - return usock.Read (buffer, offset, count); - } - - public override void Write (byte[] buffer, int offset, int count) - { - usock.Write (buffer, offset, count); - } - - unsafe public override int ReadByte () - { - byte value; - usock.Read (&value, 1); - return value; - } - - unsafe public override void WriteByte (byte value) - { - usock.Write (&value, 1); - } - } - - static class UnixUid - { - internal const string LIBC = "libc"; - - [DllImport (LIBC, CallingConvention=CallingConvention.Cdecl, SetLastError=false)] - static extern uint getuid (); - - [DllImport (LIBC, CallingConvention=CallingConvention.Cdecl, SetLastError=false)] - static extern uint geteuid (); - - public static long GetUID () - { - long uid = getuid (); - return uid; - } - - public static long GetEUID () - { - long euid = geteuid (); - return euid; - } - } - - static class UnixError - { - internal const string LIBC = "libc"; - - [DllImport (LIBC, CallingConvention=CallingConvention.Cdecl, SetLastError=false)] - static extern IntPtr strerror (int errnum); - - static string GetErrorString (int errnum) - { - IntPtr strPtr = strerror (errnum); - - if (strPtr == IntPtr.Zero) - return "Unknown Unix error"; - - return Marshal.PtrToStringAnsi (strPtr); - } - - // FIXME: Don't hard-code this. - const int EINTR = 4; - - public static bool ShouldRetry - { - get { - int errno = System.Runtime.InteropServices.Marshal.GetLastWin32Error (); - return errno == EINTR; - } - } - - public static Exception GetLastUnixException () - { - int errno = System.Runtime.InteropServices.Marshal.GetLastWin32Error (); - return new Exception (String.Format ("Error {0}: {1}", errno, GetErrorString (errno))); - } - } - - //[StructLayout(LayoutKind.Sequential, Pack=1)] - unsafe struct IOVector - { - public IOVector (IntPtr bbase, int length) - { - this.Base = (void*)bbase; - this.length = (SizeT)length; - } - - //public IntPtr Base; - public void* Base; - - public SizeT length; - public int Length - { - get { - return (int)length; - } set { - length = (SizeT)value; - } - } - } - - /* - unsafe class SockAddr - { - byte[] data; - } - */ - - unsafe class UnixSocket - { - internal const string LIBC = "libc"; - - // Solaris provides socket functionality in libsocket rather than libc. - // We use a dllmap in the .config to deal with this. - internal const string LIBSOCKET = "libsocket"; - - public const short AF_UNIX = 1; - // FIXME: SOCK_STREAM is 2 on Solaris - public const short SOCK_STREAM = 1; - - [DllImport (LIBC, CallingConvention = CallingConvention.Cdecl, SetLastError = true)] - internal static extern IntPtr fork (); - - [DllImport (LIBC, CallingConvention = CallingConvention.Cdecl, SetLastError = true)] - internal static extern int dup2 (int fd, int fd2); - - [DllImport (LIBC, CallingConvention = CallingConvention.Cdecl, SetLastError = true)] - internal static extern int open ([MarshalAs(UnmanagedType.LPStr)] string path, int oflag); - - [DllImport (LIBC, CallingConvention = CallingConvention.Cdecl, SetLastError = true)] - internal static extern IntPtr setsid (); - - - [DllImport (LIBC, CallingConvention=CallingConvention.Cdecl, SetLastError=true)] - internal static extern int close (int fd); - - [DllImport (LIBSOCKET, CallingConvention=CallingConvention.Cdecl, SetLastError=true)] - protected static extern int socket (int domain, int type, int protocol); - - [DllImport (LIBSOCKET, CallingConvention=CallingConvention.Cdecl, SetLastError=true)] - protected static extern int connect (int sockfd, byte[] serv_addr, uint addrlen); - - [DllImport (LIBSOCKET, CallingConvention=CallingConvention.Cdecl, SetLastError=true)] - protected static extern int bind (int sockfd, byte[] my_addr, uint addrlen); - - [DllImport (LIBSOCKET, CallingConvention=CallingConvention.Cdecl, SetLastError=true)] - protected static extern int listen (int sockfd, int backlog); - - //TODO: this prototype is probably wrong, fix it - [DllImport (LIBSOCKET, CallingConvention=CallingConvention.Cdecl, SetLastError=true)] - protected static extern int accept (int sockfd, void* addr, ref uint addrlen); - - //TODO: confirm and make use of these functions - [DllImport (LIBSOCKET, CallingConvention=CallingConvention.Cdecl, SetLastError=true)] - protected static extern int getsockopt (int s, int optname, IntPtr optval, ref uint optlen); - - [DllImport (LIBSOCKET, CallingConvention=CallingConvention.Cdecl, SetLastError=true)] - protected static extern int setsockopt (int s, int optname, IntPtr optval, uint optlen); - - [DllImport (LIBC, CallingConvention=CallingConvention.Cdecl, SetLastError=true)] - unsafe static extern SSizeT read (int fd, byte* buf, SizeT count); - - [DllImport (LIBC, CallingConvention=CallingConvention.Cdecl, SetLastError=true)] - unsafe static extern SSizeT write (int fd, byte* buf, SizeT count); - - [DllImport (LIBC, CallingConvention=CallingConvention.Cdecl, SetLastError=true)] - unsafe static extern SSizeT readv (int fd, IOVector* iov, int iovcnt); - - [DllImport (LIBC, CallingConvention=CallingConvention.Cdecl, SetLastError=true)] - unsafe static extern SSizeT writev (int fd, IOVector* iov, int iovcnt); - - // Linux - //[DllImport (LIBC, CallingConvention=CallingConvention.Cdecl, SetLastError=true)] - //static extern int vmsplice (int fd, IOVector* iov, uint nr_segs, uint flags); - - [DllImport (LIBSOCKET, CallingConvention=CallingConvention.Cdecl, SetLastError=true)] - public static extern SSizeT recvmsg (int s, void* msg, int flags); - - [DllImport (LIBSOCKET, CallingConvention=CallingConvention.Cdecl, SetLastError=true)] - public static extern SSizeT sendmsg (int s, void* msg, int flags); - - public int Handle; - bool ownsHandle = false; - - public UnixSocket (int handle) : this (handle, false) - { - } - - public UnixSocket (int handle, bool ownsHandle) - { - this.Handle = handle; - this.ownsHandle = ownsHandle; - // TODO: SafeHandle? - } - - public UnixSocket () - { - //TODO: don't hard-code PF_UNIX and SOCK_STREAM or SocketType.Stream - //AddressFamily family, SocketType type, ProtocolType proto - - int r = socket (AF_UNIX, SOCK_STREAM, 0); - if (r < 0) - throw UnixError.GetLastUnixException (); - - Handle = r; - ownsHandle = true; - } - - ~UnixSocket () - { - if (ownsHandle && Handle > 0) - Close (); - } - - protected bool connected = false; - - //TODO: consider memory management - public void Close () - { - int r = 0; - - do { - r = close (Handle); - } while (r < 0 && UnixError.ShouldRetry); - - if (r < 0) - throw UnixError.GetLastUnixException (); - - Handle = -1; - connected = false; - } - - //TODO: consider memory management - public void Connect (byte[] remote_end) - { - int r = 0; - - do { - r = connect (Handle, remote_end, (uint)remote_end.Length); - } while (r < 0 && UnixError.ShouldRetry); - - if (r < 0) - throw UnixError.GetLastUnixException (); - - connected = true; - } - - //assigns a name to the socket - public void Bind (byte[] local_end) - { - int r = bind (Handle, local_end, (uint)local_end.Length); - if (r < 0) - throw UnixError.GetLastUnixException (); - } - - public void Listen (int backlog) - { - int r = listen (Handle, backlog); - if (r < 0) - throw UnixError.GetLastUnixException (); - } - - public UnixSocket Accept () - { - byte[] addr = new byte[110]; - uint addrlen = (uint)addr.Length; - - fixed (byte* addrP = addr) { - int r = 0; - - do { - r = accept (Handle, addrP, ref addrlen); - } while (r < 0 && UnixError.ShouldRetry); - - if (r < 0) - throw UnixError.GetLastUnixException (); - - //TODO: use the returned addr - //string str = Encoding.Default.GetString (addr, 0, (int)addrlen); - return new UnixSocket (r, true); - } - } - - unsafe public int Read (byte[] buf, int offset, int count) - { - fixed (byte* bufP = buf) - return Read (bufP + offset, count); - } - - public int Write (byte[] buf, int offset, int count) - { - fixed (byte* bufP = buf) - return Write (bufP + offset, count); - } - - unsafe public int Read (byte* bufP, int count) - { - int r = 0; - - do { - r = (int)read (Handle, bufP, (SizeT)count); - } while (r < 0 && UnixError.ShouldRetry); - - if (r < 0) - throw UnixError.GetLastUnixException (); - - return r; - } - - public int Write (byte* bufP, int count) - { - int r = 0; - - do { - r = (int)write (Handle, bufP, (SizeT)count); - } while (r < 0 && UnixError.ShouldRetry); - - if (r < 0) - throw UnixError.GetLastUnixException (); - - return r; - } - - public int RecvMsg (void* bufP, int flags) - { - int r = 0; - - do { - r = (int)recvmsg (Handle, bufP, flags); - } while (r < 0 && UnixError.ShouldRetry); - - if (r < 0) - throw UnixError.GetLastUnixException (); - - return r; - } - - public int SendMsg (void* bufP, int flags) - { - int r = 0; - - do { - r = (int)sendmsg (Handle, bufP, flags); - } while (r < 0 && UnixError.ShouldRetry); - - if (r < 0) - throw UnixError.GetLastUnixException (); - - return r; - } - - public int ReadV (IOVector* iov, int count) - { - //FIXME: Handle EINTR here or elsewhere - //FIXME: handle r != count - //TODO: check offset correctness - - int r = (int)readv (Handle, iov, count); - if (r < 0) - throw UnixError.GetLastUnixException (); - - return r; - } - - public int WriteV (IOVector* iov, int count) - { - //FIXME: Handle EINTR here or elsewhere - //FIXME: handle r != count - //TODO: check offset correctness - - int r = (int)writev (Handle, iov, count); - if (r < 0) - throw UnixError.GetLastUnixException (); - - return r; - } - - public int Write (IOVector[] iov, int offset, int count) - { - //FIXME: Handle EINTR here or elsewhere - //FIXME: handle r != count - //TODO: check offset correctness - - fixed (IOVector* bufP = &iov[offset]) { - int r = (int)writev (Handle, bufP + offset, count); - if (r < 0) - throw UnixError.GetLastUnixException (); - - return r; - } - } - - public int Write (IOVector[] iov) - { - return Write (iov, 0, iov.Length); - } - - } -} diff -Nru dbus-sharp-0.7.0/src/UnixNativeTransport.cs dbus-sharp-0.8.0/src/UnixNativeTransport.cs --- dbus-sharp-0.7.0/src/UnixNativeTransport.cs 2010-09-14 09:17:50.000000000 +0000 +++ dbus-sharp-0.8.0/src/UnixNativeTransport.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,180 +0,0 @@ -// Copyright 2006 Alp Toker -// This software is made available under the MIT License -// See COPYING for details - -//We send BSD-style credentials on all platforms -//Doesn't seem to break Linux (but is redundant there) -//This may turn out to be a bad idea -#define HAVE_CMSGCRED - -using System; -using System.IO; -using System.Text; -using System.Runtime.InteropServices; -using DBus.Unix; - -namespace DBus.Transports -{ - class UnixNativeTransport : UnixTransport - { - internal UnixSocket socket; - - public override string AuthString () - { - long uid = UnixUid.GetEUID (); - return uid.ToString (); - } - - public override void Open (string path, bool @abstract) - { - if (String.IsNullOrEmpty (path)) - throw new ArgumentException ("path"); - - if (@abstract) - socket = OpenAbstractUnix (path); - else - socket = OpenUnix (path); - - //socket.Blocking = true; - SocketHandle = (long)socket.Handle; - //Stream = new UnixStream ((int)socket.Handle); - Stream = new UnixStream (socket); - } - - //send peer credentials null byte - //different platforms do this in different ways -#if HAVE_CMSGCRED - unsafe void WriteBsdCred () - { - //null credentials byte - byte buf = 0; - - IOVector iov = new IOVector (); - //iov.Base = (IntPtr)(&buf); - iov.Base = &buf; - iov.Length = 1; - - msghdr msg = new msghdr (); - msg.msg_iov = &iov; - msg.msg_iovlen = 1; - - cmsg cm = new cmsg (); - msg.msg_control = (IntPtr)(&cm); - msg.msg_controllen = (uint)sizeof (cmsg); - cm.hdr.cmsg_len = (uint)sizeof (cmsg); - cm.hdr.cmsg_level = 0xffff; //SOL_SOCKET - cm.hdr.cmsg_type = 0x03; //SCM_CREDS - - int written = socket.SendMsg (&msg, 0); - if (written != 1) - throw new Exception ("Failed to write credentials"); - } -#endif - - public override void WriteCred () - { -#if HAVE_CMSGCRED - try { - WriteBsdCred (); - return; - } catch { - if (Protocol.Verbose) - Console.Error.WriteLine ("Warning: WriteBsdCred() failed; falling back to ordinary WriteCred()"); - } -#endif - //null credentials byte - byte buf = 0; - Stream.WriteByte (buf); - } - - public static byte[] GetSockAddr (string path) - { - byte[] p = Encoding.Default.GetBytes (path); - - byte[] sa = new byte[2 + p.Length + 1]; - - //we use BitConverter to stay endian-safe - byte[] afData = BitConverter.GetBytes (UnixSocket.AF_UNIX); - sa[0] = afData[0]; - sa[1] = afData[1]; - - for (int i = 0 ; i != p.Length ; i++) - sa[2 + i] = p[i]; - sa[2 + p.Length] = 0; //null suffix for domain socket addresses, see unix(7) - - return sa; - } - - public static byte[] GetSockAddrAbstract (string path) - { - byte[] p = Encoding.Default.GetBytes (path); - - byte[] sa = new byte[2 + 1 + p.Length]; - - //we use BitConverter to stay endian-safe - byte[] afData = BitConverter.GetBytes (UnixSocket.AF_UNIX); - sa[0] = afData[0]; - sa[1] = afData[1]; - - sa[2] = 0; //null prefix for abstract domain socket addresses, see unix(7) - for (int i = 0 ; i != p.Length ; i++) - sa[3 + i] = p[i]; - - return sa; - } - - internal UnixSocket OpenUnix (string path) - { - byte[] sa = GetSockAddr (path); - UnixSocket client = new UnixSocket (); - client.Connect (sa); - return client; - } - - internal UnixSocket OpenAbstractUnix (string path) - { - byte[] sa = GetSockAddrAbstract (path); - UnixSocket client = new UnixSocket (); - client.Connect (sa); - return client; - } - } - -#if HAVE_CMSGCRED - unsafe struct msghdr - { - public IntPtr msg_name; //optional address - public uint msg_namelen; //size of address - public IOVector *msg_iov; //scatter/gather array - public int msg_iovlen; //# elements in msg_iov - public IntPtr msg_control; //ancillary data, see below - public uint msg_controllen; //ancillary data buffer len - public int msg_flags; //flags on received message - } - - struct cmsghdr - { - public uint cmsg_len; //data byte count, including header - public int cmsg_level; //originating protocol - public int cmsg_type; //protocol-specific type - } - - unsafe struct cmsgcred - { - const int CMGROUP_MAX = 16; - - public int cmcred_pid; //PID of sending process - public uint cmcred_uid; //real UID of sending process - public uint cmcred_euid; //effective UID of sending process - public uint cmcred_gid; //real GID of sending process - public short cmcred_ngroups; //number or groups - public fixed uint cmcred_groups[CMGROUP_MAX]; //groups - } - - struct cmsg - { - public cmsghdr hdr; - public cmsgcred cred; - } -#endif -} diff -Nru dbus-sharp-0.7.0/src/UnixTransport.cs dbus-sharp-0.8.0/src/UnixTransport.cs --- dbus-sharp-0.7.0/src/UnixTransport.cs 2010-09-14 09:17:50.000000000 +0000 +++ dbus-sharp-0.8.0/src/UnixTransport.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,29 +0,0 @@ -// Copyright 2006 Alp Toker -// This software is made available under the MIT License -// See COPYING for details - -using System; -using System.IO; - -namespace DBus.Transports -{ - abstract class UnixTransport : Transport - { - public override void Open (AddressEntry entry) - { - string path; - bool abstr; - - if (entry.Properties.TryGetValue ("path", out path)) - abstr = false; - else if (entry.Properties.TryGetValue ("abstract", out path)) - abstr = true; - else - throw new Exception ("No path specified for UNIX transport"); - - Open (path, abstr); - } - - public abstract void Open (string path, bool @abstract); - } -} diff -Nru dbus-sharp-0.7.0/src/Wrapper.cs dbus-sharp-0.8.0/src/Wrapper.cs --- dbus-sharp-0.7.0/src/Wrapper.cs 2010-09-15 10:16:28.000000000 +0000 +++ dbus-sharp-0.8.0/src/Wrapper.cs 1970-01-01 00:00:00.000000000 +0000 @@ -1,158 +0,0 @@ -// Copyright 2006 Alp Toker -// This software is made available under the MIT License -// See COPYING for details - -using System; -using System.Collections.Generic; -using System.IO; - -namespace DBus -{ - //TODO: complete and use these wrapper classes - //not sure exactly what I'm thinking but there seems to be sense here - - //FIXME: signature sending/receiving is currently ambiguous in this code - //FIXME: in fact, these classes are totally broken and end up doing no-op, do not use without understanding the problem - class MethodCall - { - public Message message = new Message (); - - public MethodCall (ObjectPath path, string @interface, string member, string destination, Signature signature) - { - message.Header.MessageType = MessageType.MethodCall; - message.ReplyExpected = true; - message.Header[FieldCode.Path] = path; - message.Header[FieldCode.Interface] = @interface; - message.Header[FieldCode.Member] = member; - message.Header[FieldCode.Destination] = destination; - //TODO: consider setting Sender here for p2p situations - //this will allow us to remove the p2p hacks in MethodCall and Message -#if PROTO_REPLY_SIGNATURE - //TODO -#endif - message.Signature = signature; - } - - public MethodCall (Message message) - { - this.message = message; - Path = (ObjectPath)message.Header[FieldCode.Path]; - Interface = (string)message.Header[FieldCode.Interface]; - Member = (string)message.Header[FieldCode.Member]; - Destination = (string)message.Header[FieldCode.Destination]; - //TODO: filled by the bus so reliable, but not the case for p2p - //so we make it optional here, but this needs some more thought - //if (message.Header.Fields.ContainsKey (FieldCode.Sender)) - Sender = (string)message.Header[FieldCode.Sender]; -#if PROTO_REPLY_SIGNATURE - //TODO: note that an empty ReplySignature should really be treated differently to the field not existing! - if (message.Header.Fields.ContainsKey (FieldCode.ReplySignature)) - ReplySignature = (Signature)message.Header[FieldCode.ReplySignature]; - else - ReplySignature = Signature.Empty; -#endif - Signature = message.Signature; - } - - public ObjectPath Path; - public string Interface; - public string Member; - public string Destination; - public string Sender; -#if PROTO_REPLY_SIGNATURE - public Signature ReplySignature; -#endif - public Signature Signature; - - public Error CreateError (string errorName, string errorMessage) - { - Error error = new Error (errorName, message.Header.Serial); - error.message.Signature = Signature.StringSig; - - MessageWriter writer = new MessageWriter (message.Header.Endianness); - //writer.connection = conn; - writer.Write (errorMessage); - error.message.Body = writer.ToArray (); - - //if (method_call.Sender != null) - // replyMsg.Header[FieldCode.Destination] = method_call.Sender; - - return error; - } - } - - class MethodReturn - { - public Message message = new Message (); - - public MethodReturn (uint reply_serial) - { - message.Header.MessageType = MessageType.MethodReturn; - message.Header.Flags = HeaderFlag.NoReplyExpected | HeaderFlag.NoAutoStart; - message.Header[FieldCode.ReplySerial] = reply_serial; - //signature optional? - //message.Header[FieldCode.Signature] = signature; - } - - public MethodReturn (Message message) - { - this.message = message; - ReplySerial = (uint)message.Header[FieldCode.ReplySerial]; - } - - public uint ReplySerial; - } - - class Error - { - public Message message = new Message (); - - public Error (string error_name, uint reply_serial) - { - message.Header.MessageType = MessageType.Error; - message.Header.Flags = HeaderFlag.NoReplyExpected | HeaderFlag.NoAutoStart; - message.Header[FieldCode.ErrorName] = error_name; - message.Header[FieldCode.ReplySerial] = reply_serial; - } - - public Error (Message message) - { - this.message = message; - ErrorName = (string)message.Header[FieldCode.ErrorName]; - ReplySerial = (uint)message.Header[FieldCode.ReplySerial]; - //Signature = (Signature)message.Header[FieldCode.Signature]; - } - - public string ErrorName; - public uint ReplySerial; - //public Signature Signature; - } - - class Signal - { - public Message message = new Message (); - - public Signal (ObjectPath path, string @interface, string member) - { - message.Header.MessageType = MessageType.Signal; - message.Header.Flags = HeaderFlag.NoReplyExpected | HeaderFlag.NoAutoStart; - message.Header[FieldCode.Path] = path; - message.Header[FieldCode.Interface] = @interface; - message.Header[FieldCode.Member] = member; - } - - public Signal (Message message) - { - this.message = message; - Path = (ObjectPath)message.Header[FieldCode.Path]; - Interface = (string)message.Header[FieldCode.Interface]; - Member = (string)message.Header[FieldCode.Member]; - Sender = (string)message.Header[FieldCode.Sender]; - } - - public ObjectPath Path; - public string Interface; - public string Member; - public string Sender; - } -} diff -Nru dbus-sharp-0.7.0/src/dbus-sharp.csproj dbus-sharp-0.8.0/src/dbus-sharp.csproj --- dbus-sharp-0.7.0/src/dbus-sharp.csproj 1970-01-01 00:00:00.000000000 +0000 +++ dbus-sharp-0.8.0/src/dbus-sharp.csproj 2013-10-06 23:56:21.000000000 +0000 @@ -0,0 +1,101 @@ + + + + Debug + AnyCPU + {09A0200F-F3AF-4BD6-9EC4-E7D80D273E4C} + 9.0.30729 + 2.0 + Library + false + dbus-sharp + 512 + DBus + true + ..\dbus-sharp.snk + v3.5 + + + True + full + False + . + DEBUG;TRACE;STRONG_NAME + prompt + 4 + True + + + pdbonly + True + . + TRACE;STRONG_NAME + prompt + 4 + True + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + PreserveNewest + + + + + + + + diff -Nru dbus-sharp-0.7.0/src/dbus-sharp.dll.config dbus-sharp-0.8.0/src/dbus-sharp.dll.config --- dbus-sharp-0.7.0/src/dbus-sharp.dll.config 2010-09-14 09:17:50.000000000 +0000 +++ dbus-sharp-0.8.0/src/dbus-sharp.dll.config 2013-07-26 20:01:51.000000000 +0000 @@ -1,3 +1,13 @@ - + + + + + + + + + + + diff -Nru dbus-sharp-0.7.0/tests/AddressTest.cs dbus-sharp-0.8.0/tests/AddressTest.cs --- dbus-sharp-0.7.0/tests/AddressTest.cs 1970-01-01 00:00:00.000000000 +0000 +++ dbus-sharp-0.8.0/tests/AddressTest.cs 2013-07-26 16:37:41.000000000 +0000 @@ -0,0 +1,80 @@ +// Copyright 2009 Alp Toker +// This software is made available under the MIT License +// See COPYING for details + +using System; +using NUnit.Framework; +using DBus; +using System.Collections.Generic; + +namespace DBus.Tests +{ + [TestFixture] + public class AddressTest + { + [Test] + [ExpectedException (typeof (InvalidAddressException))] + public void ParseBad () + { + Address.Parse ("lala"); + } + + [Test] + public void ParseUnix () + { + string addressText = @"unix:path=/var/run/dbus/system_bus_socket"; + + AddressEntry[] addrs = Address.Parse (addressText); + Assert.AreEqual (1, addrs.Length); + + AddressEntry entry = addrs[0]; + Assert.AreEqual (addressText, entry.ToString ()); + + Assert.AreEqual ("unix", entry.Method); + Assert.AreEqual (1, entry.Properties.Count); + Assert.AreEqual ("/var/run/dbus/system_bus_socket", entry.Properties["path"]); + Assert.AreEqual (UUID.Zero, entry.GUID); + } + + [Test] + public void ParseMany () + { + string addressText = @"unix:path=/var/run/dbus/system_bus_socket;unix:path=/var/run/dbus/system_bus_socket"; + + AddressEntry[] addrs = Address.Parse (addressText); + Assert.AreEqual (2, addrs.Length); + // TODO: Improve this test. + } + + [Test] + public void ParseGuid () + { + string addressText = @"unix:abstract=/tmp/dbus-A4EzCUcGvg,guid=50ab33155e2cdd289e58c42a497ded1e"; + + AddressEntry[] addrs = Address.Parse (addressText); + Assert.AreEqual (1, addrs.Length); + + AddressEntry entry = addrs[0]; + Assert.AreEqual (addressText, entry.ToString ()); + + Assert.AreEqual ("unix", entry.Method); + Assert.AreEqual (1, entry.Properties.Count); + + UUID expectedId = UUID.Parse ("50ab33155e2cdd289e58c42a497ded1e"); + uint expectedTimestamp = 1232989470; + Assert.AreEqual (expectedTimestamp, expectedId.UnixTimestamp); + Assert.AreEqual (expectedId, entry.GUID); + } + + [Test] + public void UUIDEntropy () + { + int n = 10000; + DateTime dt = DateTime.MinValue; + + HashSet hs = new HashSet (); + for (int i = 0 ; i != n ; i++) + Assert.IsTrue (hs.Add (UUID.Generate (dt).GetHashCode ())); + } + } +} diff -Nru dbus-sharp-0.7.0/tests/AuthenticationTest.cs dbus-sharp-0.8.0/tests/AuthenticationTest.cs --- dbus-sharp-0.7.0/tests/AuthenticationTest.cs 1970-01-01 00:00:00.000000000 +0000 +++ dbus-sharp-0.8.0/tests/AuthenticationTest.cs 2013-07-26 16:37:41.000000000 +0000 @@ -0,0 +1,32 @@ +// Copyright 2009 Alp Toker +// This software is made available under the MIT License +// See COPYING for details + +using System; +using System.Collections.Generic; +using NUnit.Framework; +using DBus; +using DBus.Authentication; + +namespace DBus.Tests +{ + [TestFixture] + public class AuthenticationTest + { + [Test] + public void AuthSelf () + { + SaslServer server = new SaslServer (); + SaslClient client = new SaslClient (); + + server.Peer = client; + client.Peer = server; + + client.Identity = "1000"; + server.Guid = UUID.Generate (); + + Assert.IsTrue (client.AuthenticateSelf ()); + Assert.AreEqual (server.Guid, client.ActualId); + } + } +} diff -Nru dbus-sharp-0.7.0/tests/BusTests.cs dbus-sharp-0.8.0/tests/BusTests.cs --- dbus-sharp-0.7.0/tests/BusTests.cs 1970-01-01 00:00:00.000000000 +0000 +++ dbus-sharp-0.8.0/tests/BusTests.cs 2013-07-26 21:04:04.000000000 +0000 @@ -0,0 +1,45 @@ +using System; +using NUnit.Framework; +using DBus; + +namespace DBus.Tests +{ + [TestFixture] + public class BusTests + { + /// + /// Tests that re-opening a bus with the same address works (in other words that closing a connection works) + /// + [Test] + public void ReopenedBusIsConnected() + { + var address = Environment.GetEnvironmentVariable ("DBUS_SESSION_BUS_ADDRESS"); + var bus = Bus.Open (address); + Assert.IsTrue (bus.IsConnected); + bus.Close (); + bus = Bus.Open (address); + Assert.IsTrue (bus.IsConnected); + } + + [Test] + public void GetIdFromBusTest () + { + var sessionID = Bus.Session.GetId (); + var systemID = Bus.System.GetId (); + Assert.IsNotNull (sessionID); + Assert.IsNotNull (systemID); + Assert.AreNotEqual (systemID, sessionID); + } + + [Test] + public void DefaultBusesHaveUniqueName () + { + var name = Bus.Session.UniqueName; + Assert.IsNotNull (name); + Assert.IsNotEmpty (name); + name = Bus.System.UniqueName; + Assert.IsNotNull (name); + Assert.IsNotEmpty (name); + } + } +} diff -Nru dbus-sharp-0.7.0/tests/ExportInterfaceTest.cs dbus-sharp-0.8.0/tests/ExportInterfaceTest.cs --- dbus-sharp-0.7.0/tests/ExportInterfaceTest.cs 1970-01-01 00:00:00.000000000 +0000 +++ dbus-sharp-0.8.0/tests/ExportInterfaceTest.cs 2013-07-26 21:04:04.000000000 +0000 @@ -0,0 +1,344 @@ +// Copyright 2007 Alp Toker +// 2011 Bertrand Lorentz +// This software is made available under the MIT License +// See COPYING for details + +using System; +using System.Collections.Generic; +using System.Threading; + +using NUnit.Framework; +using DBus; +using DBus.Protocol; +using org.freedesktop.DBus; + +namespace DBus.Tests +{ + [TestFixture] + public class ExportInterfaceTest + { + ITestOne test; + Test test_server; + + string bus_name = "org.dbussharp.test"; + ObjectPath path = new ObjectPath ("/org/dbussharp/test"); + + int event_a_count = 0; + + [TestFixtureSetUp] + public void Setup () + { + test_server = new Test (); + Bus.Session.Register (path, test_server); + Assert.AreEqual (Bus.Session.RequestName (bus_name), RequestNameReply.PrimaryOwner); + + Assert.AreNotEqual (Bus.Session.RequestName (bus_name), RequestNameReply.PrimaryOwner); + test = Bus.Session.GetObject (bus_name, path); + } + + /// + /// + /// + [Test] + public void VoidMethods () + { + test.VoidObject (1); + Assert.IsTrue (test_server.void_object_called); + + test.VoidEnums (TestEnum.Bar, TestEnum.Foo); + Assert.IsTrue (test_server.void_enums_called); + + test.VoidString ("foo"); + Assert.IsTrue (test_server.void_enums_called); + } + + /// + /// + /// + [Test] + public void FireEvent () + { + test.SomeEvent += HandleSomeEventA; + test.FireSomeEvent (); + Assert.AreEqual (1, event_a_count); + + test.SomeEvent -= HandleSomeEventA; + test.FireSomeEvent (); + + Assert.AreEqual (1, event_a_count); + } + + private void HandleSomeEventA (string arg1, object arg2, double arg3, MyTuple mt) + { + event_a_count++; + } + + /// + /// + /// + [Test] + public void GetVariant () + { + Assert.IsInstanceOfType (typeof (byte []), test.GetSomeVariant ()); + } + + /// + /// + /// + [Test] + public void WithOutParameters () + { + uint n; + string istr = "21"; + string ostr; + test.WithOutParameters (out n, istr, out ostr); + Assert.AreEqual (UInt32.Parse (istr), n); + Assert.AreEqual ("." + istr + ".", ostr); + + uint[] a1, a2, a3; + test.WithOutParameters2 (out a1, out a2, out a3); + Assert.AreEqual (new uint[] { }, a1); + Assert.AreEqual (new uint[] { 21, 23, 16 }, a2); + Assert.AreEqual (new uint[] { 21, 23 }, a3); + } + + /// + /// + /// + [Test] + public void GetPresences () + { + uint[] @contacts = new uint[] { 2 }; + IDictionary presences; + test.GetPresences (contacts, out presences); + presences[2] = new SimplePresence { Type = ConnectionPresenceType.Offline, Status = "offline", StatusMessage = "" }; + var presence = presences[2]; + Assert.AreEqual (ConnectionPresenceType.Offline, presence.Type); + Assert.AreEqual ("offline", presence.Status); + Assert.AreEqual ("", presence.StatusMessage); + } + + /// + /// + /// + [Test] + public void ReturnValues () + { + string str = "abcd"; + Assert.AreEqual (str.Length, test.StringLength (str)); + } + + /// + /// + /// + [Test] + public void ComplexAsVariant () + { + MyTuple2 cpx = new MyTuple2 (); + cpx.A = "a"; + cpx.B = "b"; + cpx.C = new Dictionary (); + cpx.C[3] = new MyTuple("foo", "bar"); + object cpxRet = test.ComplexAsVariant (cpx, 12); + //MyTuple2 mt2ret = (MyTuple2)Convert.ChangeType (cpxRet, typeof (MyTuple2)); + var mt2ret = (DBusStruct>>)cpxRet; + Assert.AreEqual (cpx.A, mt2ret.Item1); + Assert.AreEqual (cpx.B, mt2ret.Item2); + Assert.AreEqual (cpx.C[3].A, mt2ret.Item3[3].Item1); + Assert.AreEqual (cpx.C[3].B, mt2ret.Item3[3].Item2); + } + + /// + /// + /// + [Test] + public void Property () + { + int i = 99; + test.SomeProp = i; + Assert.AreEqual (i, test.SomeProp); + test.SomeProp = i + 1; + Assert.AreEqual (i + 1, test.SomeProp); + } + + /// + /// + /// + [Test] + public void CatchException () + { + try { + test.ThrowSomeException (); + Assert.Fail ("An exception should be thrown before getting here"); + } catch (Exception ex) { + Assert.IsTrue (ex.Message.Contains ("Some exception")); + } + } + + /* Locks up ? + /// + /// + /// + [Test] + public void ObjectArray () + { + string str = "The best of times"; + ITestOne[] objs = test.GetObjectArray (); + foreach (ITestOne obj in objs) { + Assert.AreEqual (str.Length, obj.StringLength (str)); + } + }*/ + } + + public delegate void SomeEventHandler (string arg1, object arg2, double arg3, MyTuple mt); + + [Interface ("org.dbussharp.test")] + public interface ITestOne + { + event SomeEventHandler SomeEvent; + void FireSomeEvent (); + void VoidObject (object obj); + int StringLength (string str); + void VoidEnums (TestEnum a, TestEnum b); + void VoidString (string str); + object GetSomeVariant (); + void ThrowSomeException (); + void WithOutParameters (out uint n, string str, out string ostr); + void WithOutParameters2 (out uint[] a1, out uint[] a2, out uint[] a3); + void GetPresences (uint[] @contacts, out IDictionary @presence); + object ComplexAsVariant (object v, int num); + + ITestOne[] GetEmptyObjectArray (); + ITestOne[] GetObjectArray (); + int SomeProp { get; set; } + } + + public class Test : ITestOne + { + public event SomeEventHandler SomeEvent; + + public bool void_enums_called = false; + public bool void_object_called = false; + public bool void_string_called = false; + + public void VoidObject (object var) + { + void_object_called = true; + } + + public int StringLength (string str) + { + return str.Length; + } + + public void VoidEnums (TestEnum a, TestEnum b) + { + void_enums_called = true; + } + + public virtual void VoidString (string str) + { + void_string_called = true; + } + + /*void IDemoTwo.Say2 (string str) + { + Console.WriteLine ("IDemoTwo.Say2: " + str); + }*/ + + public void FireSomeEvent () + { + MyTuple mt; + mt.A = "a"; + mt.B = "b"; + + if (SomeEvent != null) { + SomeEvent ("some string", 21, 19.84, mt); + } + } + + public object GetSomeVariant () + { + return new byte[0]; + } + + public void ThrowSomeException () + { + throw new Exception ("Some exception"); + } + + public void WithOutParameters (out uint n, string str, out string ostr) + { + n = UInt32.Parse (str); + ostr = "." + str + "."; + } + + public void WithOutParameters2 (out uint[] a1, out uint[] a2, out uint[] a3) + { + a1 = new uint[] { }; + a2 = new uint[] { 21, 23, 16 }; + a3 = new uint[] { 21, 23 }; + } + + public void GetPresences (uint[] @contacts, out IDictionary @presence) + { + Dictionary presences = new Dictionary(); + presences[2] = new SimplePresence { Type = ConnectionPresenceType.Offline, Status = "offline", StatusMessage = "" }; + presence = presences; + } + + public object ComplexAsVariant (object v, int num) + { + return v; + } + + public ITestOne[] GetEmptyObjectArray () + { + return new Test[] {}; + } + + public ITestOne[] GetObjectArray () + { + return new ITestOne[] {this}; + } + + public int SomeProp { get; set; } + } + + public enum TestEnum : byte + { + Foo, + Bar, + } + + public struct MyTuple + { + public MyTuple (string a, string b) + { + A = a; + B = b; + } + + public string A; + public string B; + } + + public struct MyTuple2 + { + public string A; + public string B; + public IDictionary C; + } + + public enum ConnectionPresenceType : uint + { + Unset = 0, Offline = 1, Available = 2, Away = 3, ExtendedAway = 4, Hidden = 5, Busy = 6, Unknown = 7, Error = 8, + } + + public struct SimplePresence + { + public ConnectionPresenceType Type; + public string Status; + public string StatusMessage; + } +} diff -Nru dbus-sharp-0.7.0/tests/IntrospectorTest.cs dbus-sharp-0.8.0/tests/IntrospectorTest.cs --- dbus-sharp-0.7.0/tests/IntrospectorTest.cs 1970-01-01 00:00:00.000000000 +0000 +++ dbus-sharp-0.8.0/tests/IntrospectorTest.cs 2013-10-07 00:48:27.000000000 +0000 @@ -0,0 +1,120 @@ +using System; +using System.Linq; +using System.Xml.Linq; +using System.Collections.Generic; + +using DBus; +using DBus.Protocol; + +using NUnit; +using NUnit.Framework; + +using org.freedesktop.DBus; + +namespace DBus.Tests +{ + [TestFixture] + public class IntrospectorTest + { + Introspector intro; + + [SetUp] + public void Setup () + { + intro = new Introspector (); + } + + [Interface ("org.dbussharp.IntrospectableTest")] + interface IObjectIntrospected + { + string Method1 (int foo); + [Obsolete] + void Method2 (out long value); + Dictionary Dict { get; } + } + + public class ObjectIntrospectedImpl : IObjectIntrospected + { + public string Method1 (int foo) + { + return string.Empty; + } + + public void Method2 (out long value) + { + value = 0; + } + + public Dictionary Dict { + get { return null; } + } + } + + const string expectedOutputSimpleInterface = @" + + + + + + + + + + + + + + + + + + + "; + + [Test] + public void SimpleInterfaceTest () + { + intro.WriteStart (); + intro.WriteType (typeof (ObjectIntrospectedImpl)); + intro.WriteEnd (); + Assert.IsTrue (XNode.DeepEquals (XDocument.Parse (expectedOutputSimpleInterface), + XDocument.Parse (intro.Xml))); + } + + [Test] + public void InterfaceThroughWireTest () + { + ObjectIntrospectedImpl impl = new ObjectIntrospectedImpl (); + ObjectPath path = new ObjectPath ("/org/dbussharp/test"); + Bus.Session.Register (path, impl); + + const string ServiceName = "org.dbussharp.testservice"; + Bus.Session.RequestName (ServiceName); + var iface = Bus.Session.GetObject ("org.dbussharp.testservice", path); + + Assert.IsTrue (XNode.DeepEquals (XDocument.Parse (expectedOutputSimpleInterface), + XDocument.Parse (iface.Introspect ()))); + } + + [Test] + public void TestIntrospectable () + { + var introspectable = Bus.Session.GetObject ("org.freedesktop.DBus", ObjectPath.Root); + var xml = introspectable.Introspect (); + Assert.IsNotNull (xml); + Assert.IsNotEmpty (xml); + + var doc = XDocument.Parse (xml); + Assert.AreEqual ((XName)"node", doc.Root.Name); + // the main dbus object has two interfaces, the dbus interface and the introspectable one + Assert.AreEqual (2, doc.Root.Elements ("interface").Count ()); + var iface = doc.Root.Elements ("interface") + .FirstOrDefault (e => ((string)e.Attribute ("name")) == "org.freedesktop.DBus.Introspectable"); + Assert.IsNotNull (iface); + Assert.AreEqual (1, iface.Elements ("method").Count ()); + Assert.AreEqual ("Introspect", iface.Element ("method").Attribute ("name").Value); + Assert.AreEqual (1, iface.Element ("method").Elements ("arg").Count ()); + } + } +} + diff -Nru dbus-sharp-0.7.0/tests/Makefile.am dbus-sharp-0.8.0/tests/Makefile.am --- dbus-sharp-0.7.0/tests/Makefile.am 1970-01-01 00:00:00.000000000 +0000 +++ dbus-sharp-0.8.0/tests/Makefile.am 2013-10-07 00:42:44.000000000 +0000 @@ -0,0 +1,53 @@ +ASSEMBLY = dbus-sharp-tests +TARGET = $(ASSEMBLY).dll +XBUILD_Q = $(XBUILD) /nologo /verbosity:quiet + +NUNIT_CONSOLE = $$(echo $$(which nunit-console2 || which nunit-console)) +RUNNER = $(NUNIT_CONSOLE) -nologo + +CSFILES = AddressTest.cs \ + AuthenticationTest.cs \ + MatchRuleTest.cs \ + ObjectPathTest.cs \ + SignatureTest.cs \ + BusTests.cs \ + ExportInterfaceTest.cs \ + RenamedInterfaceTest.cs \ + MessageReaderTest.cs \ + MessageWriterTest.cs \ + IntrospectorTest.cs + +if ENABLE_TESTS + +all: $(TARGET) + +$(TARGET): + $(XBUILD_Q) dbus-sharp-tests.csproj + +test: $(TARGET) + if test -z "$$DBUS_SESSION_BUS_ADDRESS" ; then \ + eval `dbus-launch --sh-syntax` ; \ + echo "D-Bus per-session daemon address is: $$DBUS_SESSION_BUS_ADDRESS" ; \ + fi; $(RUNNER) $$TEST_HARNESS_FLAGS $(TARGET); + +check: test + +# This is not needed on that branch +# it's for compat with wrench +setup: ; +run: check + +.PHONY: $(TARGET) + +endif + +EXTRA_DIST = \ + $(CSFILES) \ + dbus-sharp-tests.csproj + +CLEANFILES = \ + $(TARGET) \ + $(TARGET).mdb + +MAINTAINERCLEANFILES = \ + Makefile.in diff -Nru dbus-sharp-0.7.0/tests/Makefile.in dbus-sharp-0.8.0/tests/Makefile.in --- dbus-sharp-0.7.0/tests/Makefile.in 1970-01-01 00:00:00.000000000 +0000 +++ dbus-sharp-0.8.0/tests/Makefile.in 2013-10-07 00:49:05.000000000 +0000 @@ -0,0 +1,429 @@ +# Makefile.in generated by automake 1.13.2 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994-2013 Free Software Foundation, Inc. + +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ +VPATH = @srcdir@ +am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' +am__make_running_with_option = \ + case $${target_option-} in \ + ?) ;; \ + *) echo "am__make_running_with_option: internal error: invalid" \ + "target option '$${target_option-}' specified" >&2; \ + exit 1;; \ + esac; \ + has_opt=no; \ + sane_makeflags=$$MAKEFLAGS; \ + if $(am__is_gnu_make); then \ + sane_makeflags=$$MFLAGS; \ + else \ + case $$MAKEFLAGS in \ + *\\[\ \ ]*) \ + bs=\\; \ + sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ + | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ + esac; \ + fi; \ + skip_next=no; \ + strip_trailopt () \ + { \ + flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ + }; \ + for flg in $$sane_makeflags; do \ + test $$skip_next = yes && { skip_next=no; continue; }; \ + case $$flg in \ + *=*|--*) continue;; \ + -*I) strip_trailopt 'I'; skip_next=yes;; \ + -*I?*) strip_trailopt 'I';; \ + -*O) strip_trailopt 'O'; skip_next=yes;; \ + -*O?*) strip_trailopt 'O';; \ + -*l) strip_trailopt 'l'; skip_next=yes;; \ + -*l?*) strip_trailopt 'l';; \ + -[dEDm]) skip_next=yes;; \ + -[JT]) skip_next=yes;; \ + esac; \ + case $$flg in \ + *$$target_option*) has_opt=yes; break;; \ + esac; \ + done; \ + test $$has_opt = yes +am__make_dryrun = (target_option=n; $(am__make_running_with_option)) +am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) +pkgdatadir = $(datadir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkglibexecdir = $(libexecdir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +subdir = tests +DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_CLEAN_FILES = +CONFIG_CLEAN_VPATH_FILES = +AM_V_P = $(am__v_P_@AM_V@) +am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) +am__v_P_0 = false +am__v_P_1 = : +AM_V_GEN = $(am__v_GEN_@AM_V@) +am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) +am__v_GEN_0 = @echo " GEN " $@; +am__v_GEN_1 = +AM_V_at = $(am__v_at_@AM_V@) +am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) +am__v_at_0 = @ +am__v_at_1 = +SOURCES = +DIST_SOURCES = +am__can_run_installinfo = \ + case $$AM_UPDATE_INFO_DIR in \ + n|no|NO) false;; \ + *) (install-info --version) >/dev/null 2>&1;; \ + esac +am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +AMTAR = @AMTAR@ +AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ +API_VERSION = @API_VERSION@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +GACUTIL = @GACUTIL@ +GMCS = @GMCS@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LTLIBOBJS = @LTLIBOBJS@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MKDIR_P = @MKDIR_P@ +MONO_CFLAGS = @MONO_CFLAGS@ +MONO_LIBS = @MONO_LIBS@ +NUNIT_CFLAGS = @NUNIT_CFLAGS@ +NUNIT_LIBS = @NUNIT_LIBS@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_URL = @PACKAGE_URL@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PKG_CONFIG = @PKG_CONFIG@ +PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ +PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +VERSION = @VERSION@ +XBUILD = @XBUILD@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +am__leading_dot = @am__leading_dot@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build_alias = @build_alias@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host_alias = @host_alias@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +ASSEMBLY = dbus-sharp-tests +TARGET = $(ASSEMBLY).dll +XBUILD_Q = $(XBUILD) /nologo /verbosity:quiet +NUNIT_CONSOLE = $$(echo $$(which nunit-console2 || which nunit-console)) +RUNNER = $(NUNIT_CONSOLE) -nologo +CSFILES = AddressTest.cs \ + AuthenticationTest.cs \ + MatchRuleTest.cs \ + ObjectPathTest.cs \ + SignatureTest.cs \ + BusTests.cs \ + ExportInterfaceTest.cs \ + RenamedInterfaceTest.cs \ + MessageReaderTest.cs \ + MessageWriterTest.cs \ + IntrospectorTest.cs + +EXTRA_DIST = \ + $(CSFILES) \ + dbus-sharp-tests.csproj + +CLEANFILES = \ + $(TARGET) \ + $(TARGET).mdb + +MAINTAINERCLEANFILES = \ + Makefile.in + +all: all-am + +.SUFFIXES: +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu tests/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --gnu tests/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(am__aclocal_m4_deps): +tags TAGS: + +ctags CTAGS: + +cscope cscopelist: + + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d "$(distdir)/$$file"; then \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ + else \ + test -f "$(distdir)/$$file" \ + || cp -p $$d/$$file "$(distdir)/$$file" \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile +installdirs: +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + if test -z '$(STRIP)'; then \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + install; \ + else \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ + fi +mostlyclean-generic: + +clean-generic: + -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." + -test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES) +clean: clean-am + +clean-am: clean-generic mostlyclean-am + +distclean: distclean-am + -rm -f Makefile +distclean-am: clean-am distclean-generic + +dvi: dvi-am + +dvi-am: + +html: html-am + +html-am: + +info: info-am + +info-am: + +install-data-am: + +install-dvi: install-dvi-am + +install-dvi-am: + +install-exec-am: + +install-html: install-html-am + +install-html-am: + +install-info: install-info-am + +install-info-am: + +install-man: + +install-pdf: install-pdf-am + +install-pdf-am: + +install-ps: install-ps-am + +install-ps-am: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-generic + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: + +.MAKE: install-am install-strip + +.PHONY: all all-am check check-am clean clean-generic cscopelist-am \ + ctags-am distclean distclean-generic distdir dvi dvi-am html \ + html-am info info-am install install-am install-data \ + install-data-am install-dvi install-dvi-am install-exec \ + install-exec-am install-html install-html-am install-info \ + install-info-am install-man install-pdf install-pdf-am \ + install-ps install-ps-am install-strip installcheck \ + installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-generic pdf \ + pdf-am ps ps-am tags-am uninstall uninstall-am + + +@ENABLE_TESTS_TRUE@all: $(TARGET) + +@ENABLE_TESTS_TRUE@$(TARGET): +@ENABLE_TESTS_TRUE@ $(XBUILD_Q) dbus-sharp-tests.csproj + +@ENABLE_TESTS_TRUE@test: $(TARGET) +@ENABLE_TESTS_TRUE@ if test -z "$$DBUS_SESSION_BUS_ADDRESS" ; then \ +@ENABLE_TESTS_TRUE@ eval `dbus-launch --sh-syntax` ; \ +@ENABLE_TESTS_TRUE@ echo "D-Bus per-session daemon address is: $$DBUS_SESSION_BUS_ADDRESS" ; \ +@ENABLE_TESTS_TRUE@ fi; $(RUNNER) $$TEST_HARNESS_FLAGS $(TARGET); + +@ENABLE_TESTS_TRUE@check: test + +# This is not needed on that branch +# it's for compat with wrench +@ENABLE_TESTS_TRUE@setup: ; +@ENABLE_TESTS_TRUE@run: check + +@ENABLE_TESTS_TRUE@.PHONY: $(TARGET) + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff -Nru dbus-sharp-0.7.0/tests/MatchRuleTest.cs dbus-sharp-0.8.0/tests/MatchRuleTest.cs --- dbus-sharp-0.7.0/tests/MatchRuleTest.cs 1970-01-01 00:00:00.000000000 +0000 +++ dbus-sharp-0.8.0/tests/MatchRuleTest.cs 2013-07-26 21:04:04.000000000 +0000 @@ -0,0 +1,106 @@ +// Copyright 2009 Alp Toker +// This software is made available under the MIT License +// See COPYING for details + +using System; +using NUnit.Framework; +using DBus; +using DBus.Protocol; + +namespace DBus.Tests +{ + [TestFixture] + public class MatchRuleTest + { + [Test] + public void Parse () + { + string ruleText = @"member='Lala'"; + MatchRule rule = MatchRule.Parse (ruleText); + + Assert.AreEqual (MessageType.All, rule.MessageType); + Assert.AreEqual (0, rule.Args.Count); + Assert.AreEqual (ruleText, rule.ToString ()); + } + + [Test] + public void ParsePathArgs () + { + string ruleText = @"arg0='La',arg1path='/Foo'"; + MatchRule rule = MatchRule.Parse (ruleText); + Assert.AreEqual (ruleText, rule.ToString ()); + } + + [Test] + public void CanonicalOrdering () + { + string ruleText = @"arg0='La',arg5path='/bar',arg2='Fa',destination='org.ndesk.Recipient',interface='org.ndesk.ITest',arg1path='/foo'"; + string sortedRuleText = @"interface='org.ndesk.ITest',destination='org.ndesk.Recipient',arg0='La',arg1path='/foo',arg2='Fa',arg5path='/bar'"; + MatchRule rule = MatchRule.Parse (ruleText); + Assert.AreEqual (4, rule.Args.Count); + Assert.AreEqual (sortedRuleText, rule.ToString ()); + } + + // TODO: Should fail + /* + [Test] + public void ParseArgsPartiallyBad () + { + string ruleText = @"arg0='A',arg4='Foo\'"; + MatchRule.Parse (ruleText); + } + */ + + // TODO: Should fail + /* + [Test] + [ExpectedException] + public void ParseRepeated () + { + string ruleText = @"interface='org.ndesk.ITest',interface='org.ndesk.ITest2'"; + MatchRule.Parse (ruleText); + } + */ + + // TODO: Should fail + /* + [Test] + //[ExpectedException] + public void ParseArgsRepeated () + { + string ruleText = @"arg0='A',arg0='A'"; + MatchRule.Parse (ruleText); + } + */ + + [Test] + public void ParseArgsMaxAllowed () + { + string ruleText = @"arg63='Foo'"; + MatchRule.Parse (ruleText); + } + + [Test] + [ExpectedException] + public void ParseArgsMoreThanAllowed () + { + string ruleText = @"arg64='Foo'"; + MatchRule.Parse (ruleText); + } + + [Test] + public void ParseArgs () + { + string ruleText = @"arg5='F,o\'o\\\'\\',arg8=''"; + MatchRule rule = MatchRule.Parse (ruleText); + + Assert.AreEqual (MessageType.All, rule.MessageType); + Assert.AreEqual (2, rule.Args.Count); + + //Assert.AreEqual (@"F,o'o\'\", rule.Args[5].Value); + //Assert.AreEqual (@"", rule.Args[8].Value); + + Assert.AreEqual (ruleText, rule.ToString ()); + } + } +} diff -Nru dbus-sharp-0.7.0/tests/MessageReaderTest.cs dbus-sharp-0.8.0/tests/MessageReaderTest.cs --- dbus-sharp-0.7.0/tests/MessageReaderTest.cs 1970-01-01 00:00:00.000000000 +0000 +++ dbus-sharp-0.8.0/tests/MessageReaderTest.cs 2013-07-26 21:04:04.000000000 +0000 @@ -0,0 +1,193 @@ + +using System; +using System.Runtime.InteropServices; +using NUnit.Framework; +using DBus; +using DBus.Protocol; + +namespace DBus.Tests +{ + [TestFixture] + public class MessageReaderTest + { + [Test] + public void ReadIntLittleEndian () + { + MessageReader reader = new MessageReader (EndianFlag.Little, new byte[] { 8, 8, 0, 0}); + Assert.AreEqual (0x808, reader.ReadInt32 ()); + Assert.IsFalse (reader.DataAvailable); + } + + [Test] + public void ReadIntBigEndian () + { + MessageReader reader = new MessageReader (EndianFlag.Big, new byte[] { 0, 0, 8, 8}); + Assert.AreEqual (0x808, reader.ReadInt32 ()); + Assert.IsFalse (reader.DataAvailable); + } + + [Test] + public void ReadIntArrayLittleEndian () + { + byte[] data = new byte[] { 16, 0, 0, 0, 8, 8, 0, 0, 8, 8, 0, 0, 8, 8, 0, 0, 8, 8, 0, 0 }; + MessageReader reader = new MessageReader (EndianFlag.Little, data); + + int[] array = (int[])reader.ReadArray (typeof (int)); + Assert.IsNotNull (array); + Assert.AreEqual (4, array.Length, "length"); + CollectionAssert.AreEqual (new int[] { 0x808, 0x808, 0x808, 0x808}, array, "elements"); + Assert.IsFalse (reader.DataAvailable); + } + + [Test] + public void ReadIntArrayBigEndian () + { + byte[] data = new byte[] { 0, 0, 0, 16, 0, 0, 8, 8, 0, 0, 8, 8, 0, 0, 8, 8, 0, 0, 8, 8 }; + MessageReader reader = new MessageReader (EndianFlag.Big, data); + + int[] array = (int[])reader.ReadArray (typeof (int)); + Assert.IsNotNull (array); + Assert.AreEqual (4, array.Length, "length"); + CollectionAssert.AreEqual (new int[] { 0x808, 0x808, 0x808, 0x808}, array, "elements"); + Assert.IsFalse (reader.DataAvailable); + } + + [Test] + public void ReadBooleanArrayLittleEndian () + { + byte[] data = new byte[] { 4, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 }; + MessageReader reader = new MessageReader (EndianFlag.Little, data); + + bool[] array = (bool[])reader.ReadArray (typeof (bool)); + Assert.IsNotNull (array); + Assert.AreEqual (4, array.Length, "length"); + CollectionAssert.AreEqual (new bool[] { true, false, true, true}, array, "elements"); + Assert.IsFalse (reader.DataAvailable); + } + + [Test] + public void ReadBooleanArrayBigEndian () + { + byte[] data = new byte[] { 0, 0, 0, 4, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1 }; + MessageReader reader = new MessageReader (EndianFlag.Big, data); + + bool[] array = (bool[])reader.ReadArray (typeof (bool)); + Assert.IsNotNull (array); + Assert.AreEqual (4, array.Length, "length"); + CollectionAssert.AreEqual (new bool[] { true, false, true, true}, array, "elements"); + Assert.IsFalse (reader.DataAvailable); + } + + [StructLayout (LayoutKind.Sequential)] + struct TestStruct { + public int Item1; + public long Item2; + public int Item3; + } + + [Test] + public void ReadIntLongIntStructLittleEndian () + { + // (ixi) and (1, 2, 3) + byte[] data = new byte[] { 1, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0 }; + MessageReader reader = new MessageReader (EndianFlag.Little, data); + + TestStruct stct = (TestStruct)reader.ReadStruct (typeof (TestStruct)); + Assert.AreEqual (1, stct.Item1); + Assert.AreEqual (2, stct.Item2); + Assert.AreEqual (3, stct.Item3); + } + + [Test, ExpectedException (typeof (MessageReader.PaddingException))] + public void ReadIntLongIntStructNonAlignedLittleEndian () + { + // (ixi) and (1, 2, 3) + byte[] data = new byte[] { 1, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0 }; + MessageReader reader = new MessageReader (EndianFlag.Little, data); + + TestStruct stct = (TestStruct)reader.ReadStruct (typeof (TestStruct)); + } + + [StructLayout (LayoutKind.Sequential)] + struct TestStruct2 { + public int Item1; + public int Item2; + public int Item3; + } + + [Test] + public void ReadIntIntIntStructLittleEndian () + { + // Will test the fast path + byte[] data = new byte[] { 1, 0, 0, 0, 2, 0, 0, 0, 3, 0, 0, 0 }; + MessageReader reader = new MessageReader (EndianFlag.Little, data); + + TestStruct2 stct = (TestStruct2)reader.ReadStruct (typeof (TestStruct2)); + Assert.AreEqual (1, stct.Item1); + Assert.AreEqual (2, stct.Item2); + Assert.AreEqual (3, stct.Item3); + } + + [Test] + public void ReadIntIntIntStructLittleEndianGeneric () + { + // Will test the fast path + byte[] data = new byte[] { 1, 0, 0, 0, 2, 0, 0, 0, 3, 0, 0, 0 }; + MessageReader reader = new MessageReader (EndianFlag.Little, data); + + TestStruct2 stct = reader.ReadStruct (); + Assert.AreEqual (1, stct.Item1); + Assert.AreEqual (2, stct.Item2); + Assert.AreEqual (3, stct.Item3); + } + + [StructLayout (LayoutKind.Sequential)] + struct TestStruct3 { + public long Item1; + public ulong Item2; + public double Item3; + } + + [Test] + public void ReadSameAlignementStructNativeEndian () + { + // Will test the fast path with mixed types but same alignement + byte[] data = new byte[8 * 3]; + Array.Copy (BitConverter.GetBytes ((long)1), 0, data, 0, 8); + Array.Copy (BitConverter.GetBytes (ulong.MaxValue), 0, data, 8, 8); + Array.Copy (BitConverter.GetBytes ((double)3.3), 0, data, 16, 8); + + MessageReader reader = new MessageReader (BitConverter.IsLittleEndian ? EndianFlag.Little : EndianFlag.Big, data); + + TestStruct3 stct = (TestStruct3)reader.ReadStruct (typeof (TestStruct3)); + Assert.AreEqual (1, stct.Item1); + Assert.AreEqual (ulong.MaxValue, stct.Item2); + Assert.AreEqual (3.3, stct.Item3); + } + + [Test] + public void ReadSameAlignementStructNonNativeEndian () + { + // Will test the fast path with mixed types but same alignement + byte[] data = new byte[8 * 3]; + Array.Copy (BitConverter.GetBytes ((long)1), 0, data, 0, 8); + Array.Copy (BitConverter.GetBytes (ulong.MaxValue), 0, data, 8, 8); + Array.Copy (BitConverter.GetBytes ((double)3.3), 0, data, 16, 8); + // Swap value to simulate other endianess + for (int i = 0; i < data.Length; i += 8) { + for (int j = 0; j < 4; j++) { + data[i + j] = (byte)(data[i + j] ^ data[i + 7 - j]); + data[i + 7 - j] = (byte)(data[i + j] ^ data[i + 7 - j]); + data[i + j] = (byte)(data[i + j] ^ data[i + 7 - j]); + } + } + + MessageReader reader = new MessageReader (!BitConverter.IsLittleEndian ? EndianFlag.Little : EndianFlag.Big, data); + + TestStruct3 stct = (TestStruct3)reader.ReadStruct (typeof (TestStruct3)); + Assert.AreEqual (1, stct.Item1); + Assert.AreEqual (ulong.MaxValue, stct.Item2); + Assert.AreEqual (3.3, stct.Item3); + } + } +} diff -Nru dbus-sharp-0.7.0/tests/MessageWriterTest.cs dbus-sharp-0.8.0/tests/MessageWriterTest.cs --- dbus-sharp-0.7.0/tests/MessageWriterTest.cs 1970-01-01 00:00:00.000000000 +0000 +++ dbus-sharp-0.8.0/tests/MessageWriterTest.cs 2013-07-26 21:04:04.000000000 +0000 @@ -0,0 +1,57 @@ + +using System; +using System.Runtime.InteropServices; +using NUnit.Framework; +using DBus; +using DBus.Protocol; + +namespace DBus.Tests +{ + [TestFixture] + public class MessageWriterTest + { + DBus.Protocol.MessageWriter writer; + + [SetUp] + public void Setup () + { + writer = new DBus.Protocol.MessageWriter (); + } + + [Test] + public void WriteIntArrayTest () + { + var initial = new int[] { 1, 2, 3, 4 }; + writer.WriteArray (initial); + byte[] result = writer.ToArray (); + + Assert.AreEqual (4 + initial.Length * 4, result.Length); + uint length = BitConverter.ToUInt32 (result, 0); + Assert.AreEqual (initial.Length * 4, length); + for (int i = 0; i < initial.Length; i++) + Assert.AreEqual (i + 1, BitConverter.ToInt32 (result, 4 + 4 * i), "#" + i); + } + + struct TestStruct + { + public int bleh; + public uint bloup; + public float blop; + } + + [Test] + public void WriteStructTest () + { + TestStruct stct = new TestStruct (); + stct.bleh = 5; + stct.bloup = 3; + stct.blop = 5.5f; + + writer.WriteStructure (stct); + byte[] result = writer.ToArray (); + Assert.AreEqual (5, BitConverter.ToInt32 (result, 0)); + Assert.AreEqual ((uint)3, BitConverter.ToUInt32 (result, 4)); + Assert.AreEqual (5.5f, BitConverter.ToSingle (result, 8)); + } + } +} \ No newline at end of file diff -Nru dbus-sharp-0.7.0/tests/ObjectPathTest.cs dbus-sharp-0.8.0/tests/ObjectPathTest.cs --- dbus-sharp-0.7.0/tests/ObjectPathTest.cs 1970-01-01 00:00:00.000000000 +0000 +++ dbus-sharp-0.8.0/tests/ObjectPathTest.cs 2013-07-26 16:37:41.000000000 +0000 @@ -0,0 +1,89 @@ +// Copyright 2009 Alp Toker +// Copyright 2010 Alan McGovern +// This software is made available under the MIT License +// See COPYING for details + +using System; +using NUnit.Framework; +using DBus; + +namespace DBus.Tests +{ + [TestFixture] + public class ObjectPathTest + { + [Test] + [ExpectedException (typeof (ArgumentException))] + public void InvalidStartingCharacter () + { + // Paths must start with "/" + new ObjectPath ("no_starting_slash"); + } + + [Test] + [ExpectedException (typeof (ArgumentException))] + public void InvalidEndingCharacter () + { + // Paths must not end with "/" + new ObjectPath ("/ends_with_slash/"); + } + + [Test] + [ExpectedException (typeof (ArgumentException))] + public void MultipleConsecutiveSlash () + { + // Paths must not contains consecutive "/" + new ObjectPath ("/foo//bar"); + } + + [Test] + [ExpectedException (typeof (ArgumentException))] + public void InvalidCharacters () + { + // Paths must be in the range "[A-Z][a-z][0-9]_" + new ObjectPath ("/?valid/path/invalid?/character.^"); + } + + [Test] + public void ConstructorTest () + { + var x = new ObjectPath ("/"); + Assert.AreEqual (x.ToString (), "/", "#1"); + Assert.AreEqual (x, ObjectPath.Root, "#2"); + + x = new ObjectPath ("/this/01234567890/__Test__"); + Assert.AreEqual ("/this/01234567890/__Test__", x.ToString (), "#3"); + } + + [Test] + public void Equality () + { + string pathText = "/org/freedesktop/DBus"; + + ObjectPath a = new ObjectPath (pathText); + ObjectPath b = new ObjectPath (pathText); + + Assert.IsTrue (a.Equals (b)); + Assert.AreEqual (String.Empty.CompareTo (null), a.CompareTo (null)); + Assert.IsTrue (a == b); + Assert.IsFalse (a != b); + + ObjectPath c = new ObjectPath (pathText + "/foo"); + Assert.IsFalse (a == c); + } + + [Test] + [ExpectedException (typeof (ArgumentNullException))] + public void NullConstructor () + { + new ObjectPath (null); + } + + [Test] + [ExpectedException (typeof (ArgumentException))] + public void EmptyStringConstructor () + { + new ObjectPath (""); + } + } +} diff -Nru dbus-sharp-0.7.0/tests/RenamedInterfaceTest.cs dbus-sharp-0.8.0/tests/RenamedInterfaceTest.cs --- dbus-sharp-0.7.0/tests/RenamedInterfaceTest.cs 1970-01-01 00:00:00.000000000 +0000 +++ dbus-sharp-0.8.0/tests/RenamedInterfaceTest.cs 2013-07-26 21:04:04.000000000 +0000 @@ -0,0 +1,79 @@ +// Copyright 2011 Bertrand Lorentz +// This software is made available under the MIT License +// See COPYING for details + +using System; +using NUnit.Framework; +using DBus; +using org.freedesktop.DBus; + +namespace DBus.Tests +{ + [TestFixture] + public class RenamedInterfaceTest + { + string bus_name = "org.dbussharp.restaurant"; + ObjectPath path = new ObjectPath ("/org/dbussharp/restaurant"); + + [Test] + public void FirstInterface () + { + var restaurant = new StandingRestaurant (); + Assert.AreEqual (Bus.Session.RequestName (bus_name), RequestNameReply.PrimaryOwner); + Bus.Session.Register (path, restaurant); + + try { + Assert.AreEqual ("cheese", GetFood (false)); + } finally { + Bus.Session.ReleaseName (bus_name); + Bus.Session.Unregister (path); + } + } + + [Test] + public void SecondInterface () + { + var restaurant = new SeatedRestaurant (); + Bus.Session.Register (path, restaurant); + Assert.AreEqual (Bus.Session.RequestName (bus_name), RequestNameReply.PrimaryOwner); + + try { + Assert.AreEqual ("bacon", GetFood (true)); + } finally { + Bus.Session.ReleaseName (bus_name); + Bus.Session.Unregister (path); + } + } + + string GetFood (bool second) + { + IRestaurantBase restaurant = null; + if (second) + restaurant = Bus.Session.GetObject (bus_name, path); + else + restaurant = Bus.Session.GetObject (bus_name, path); + return restaurant.Food (); + } + } + + interface IRestaurantBase { string Food (); } + [Interface ("org.dbussharp.restaurant")] interface IRestaurant : IRestaurantBase { } + [Interface ("org.dbussharp.restaurant.table")] interface IRestaurantv2 : IRestaurantBase { } + + public class StandingRestaurant : IRestaurant + { + public string Food () + { + return "cheese"; + } + } + + public class SeatedRestaurant : IRestaurantv2 + { + public string Food () + { + return "bacon"; + } + } +} + diff -Nru dbus-sharp-0.7.0/tests/SignatureTest.cs dbus-sharp-0.8.0/tests/SignatureTest.cs --- dbus-sharp-0.7.0/tests/SignatureTest.cs 1970-01-01 00:00:00.000000000 +0000 +++ dbus-sharp-0.8.0/tests/SignatureTest.cs 2013-07-26 21:04:04.000000000 +0000 @@ -0,0 +1,219 @@ +// Copyright 2009 Alp Toker +// This software is made available under the MIT License +// See COPYING for details + +using System; +using System.Linq; +using System.Collections.Generic; + +using NUnit.Framework; +using DBus; +using DBus.Protocol; + +namespace DBus.Tests +{ + [TestFixture] + public class SignatureTest + { + [Test] + [ExpectedException (typeof (ArgumentNullException))] + public void Parse_NullString () + { + new Signature ((string) null); + } + + [Test] + [ExpectedException (typeof (ArgumentNullException))] + public void Parse_NullArray () + { + new Signature ((DType []) null); + } + + [Test] + public void Parse_Empty () + { + var x = new Signature (""); + Assert.AreEqual (Signature.Empty, x, "#1"); + } + + [Test] + public void ParseStruct () + { + var sig = new Signature ("(iu)"); + Assert.IsTrue (sig.IsStruct, "#1"); + + var elements = sig.GetFieldSignatures ().ToArray (); + Assert.AreEqual (2, elements.Length, "#2"); + Assert.AreEqual (Signature.Int32Sig, elements [0], "#3"); + Assert.AreEqual (Signature.UInt32Sig, elements [1], "#4"); + } + + [Test] + [ExpectedException (typeof (ArgumentException))] + public void ParseInvalid_TypeCode () + { + // Use an invalid type code + new Signature ("z"); + } + + [Test] + [ExpectedException (typeof (ArgumentException))] + public void ParseInvalid_MissingClosingBrace () + { + // Use an invalid type code + new Signature ("(i"); + } + + [Test] + [ExpectedException (typeof (ArgumentException))] + public void ParseInvalid_MissingOpeningBrace () + { + // Use an invalid type code + new Signature ("i)"); + } + + [Test] + public void Parse_ArrayOfString () + { + string sigText = "as"; + Signature sig = new Signature (sigText); + + Assert.IsTrue (sig.IsArray); + Assert.IsFalse (sig.IsDict); + Assert.IsFalse (sig.IsPrimitive); + } + + [Test] + public void Equality () + { + string sigText = "as"; + Signature a = new Signature (sigText); + Signature b = new Signature (sigText); + + Assert.IsTrue (a == b); + Assert.IsTrue (a.GetElementSignature () == Signature.StringSig); + + Assert.AreEqual (Signature.ArraySig + Signature.StringSig + Signature.Empty, new Signature ("as")); + } + + [Test] + public void FixedSize () + { + Signature sig; + + sig = new Signature ("s"); + Assert.IsFalse (sig.IsFixedSize); + + sig = new Signature ("as"); + Assert.IsFalse (sig.IsFixedSize); + + sig = new Signature ("u"); + Assert.IsTrue (sig.IsFixedSize); + + sig = new Signature ("u(ub)"); + Assert.IsTrue (sig.IsFixedSize); + + sig = new Signature ("u(uvb)"); + Assert.IsFalse (sig.IsFixedSize); + } + + [Test] + public void CombineSignatures () + { + var x = Signature.ByteSig + Signature.StringSig; + Assert.AreEqual ("ys", x.Value, "#1"); + } + + [Test] + public void MakeArray () + { + var x = Signature.MakeArray (Signature.Int32Sig); + Assert.AreEqual ("ai", x.Value, "#1"); + } + + [Test] + public void MakeArrayOfStruct () + { + var type = Signature.MakeStruct (Signature.Int32Sig + Signature.Int32Sig); + var x = Signature.MakeArray (type); + Assert.AreEqual ("a(ii)", x.Value, "#1"); + } + + [Test] + public void MakeArrayOfArray () + { + var x = Signature.MakeArray (Signature.Int32Sig); + x = Signature.MakeArray (x); + Assert.AreEqual ("aai", x.Value, "#1"); + } + + [Test] + [ExpectedException (typeof (ArgumentException))] + public void MakeArray_NotSingleCompleteType () + { + Signature.MakeArray (Signature.Int32Sig + Signature.UInt16Sig); + } + + [Test] + public void MakeStruct () + { + // 'r' isn't used, just brackets. + var x = Signature.MakeStruct (Signature.ByteSig + Signature.StringSig); + Assert.AreEqual ("(ys)", x.Value, "#1"); + } + + [Test] + [ExpectedException (typeof (ArgumentException))] + public void MakeStruct_Empty () + { + Signature.MakeStruct (Signature.Empty); + } + + [Test] + public void MakeDictionaryEntry () + { + // Make a valid dictionary entry, should appear as an array of dict_entries + var x = Signature.MakeDictEntry (Signature.StringSig, Signature.Int32Sig); + Assert.AreEqual ("{si}", x.Value, "#1"); + } + + [Test] + public void MakeDictionary () + { + // 'r' isn't used, just brackets. + var x = Signature.MakeDict (Signature.StringSig, Signature.Int32Sig); + Assert.AreEqual ("a{si}", x.Value, "#1"); + } + + [Test] + [ExpectedException (typeof (ArgumentException))] + public void MakeDictionary_TwoCompleteTypes_Key () + { + // They key is not a single complete type + Signature.MakeDictEntry (Signature.StringSig + Signature.Int32Sig, Signature.Int32Sig); + } + + [Test] + [ExpectedException (typeof (ArgumentException))] + public void MakeDictionary_TwoCompleteTypes_Value () + { + // They value is not a single complete type + Signature.MakeDictEntry (Signature.StringSig, Signature.Int32Sig + Signature.Int32Sig); + } + + [Test] + public void ComplexSignatureIsSingleTypeTest () + { + string sig = "(ssa{i(ss)})"; + Assert.IsTrue (new Signature (sig).IsSingleCompleteType); + } + + [Test] + public void AssertComplexTypeToTypeTest () + { + var sig = new Signature ("(ssa{i(ss)})"); + Assert.AreEqual (typeof (DBusStruct>>), + sig.ToType ()); + } + } +} diff -Nru dbus-sharp-0.7.0/tests/dbus-sharp-tests.csproj dbus-sharp-0.8.0/tests/dbus-sharp-tests.csproj --- dbus-sharp-0.7.0/tests/dbus-sharp-tests.csproj 1970-01-01 00:00:00.000000000 +0000 +++ dbus-sharp-0.8.0/tests/dbus-sharp-tests.csproj 2013-09-27 15:29:57.000000000 +0000 @@ -0,0 +1,68 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {40AB91F9-BA2F-4C02-99F5-1F299CDBE86D} + Library + DBus.Tests + dbus-sharp-tests + v3.5 + true + ..\dbus-sharp.snk + + + True + full + False + . + DEBUG + prompt + 4 + False + + + none + False + . + prompt + 4 + False + + + + + + False + False + + + False + False + + + + + + + + + + + + + + + + + + + + + {09A0200F-F3AF-4BD6-9EC4-E7D80D273E4C} + dbus-sharp + + + diff -Nru dbus-sharp-0.7.0/tools/Makefile.in dbus-sharp-0.8.0/tools/Makefile.in --- dbus-sharp-0.7.0/tools/Makefile.in 2010-09-14 09:18:28.000000000 +0000 +++ dbus-sharp-0.8.0/tools/Makefile.in 2013-10-07 00:49:05.000000000 +0000 @@ -1,9 +1,8 @@ -# Makefile.in generated by automake 1.11.1 from Makefile.am. +# Makefile.in generated by automake 1.13.2 from Makefile.am. # @configure_input@ -# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, -# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, -# Inc. +# Copyright (C) 1994-2013 Free Software Foundation, Inc. + # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. @@ -15,6 +14,51 @@ @SET_MAKE@ VPATH = @srcdir@ +am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' +am__make_running_with_option = \ + case $${target_option-} in \ + ?) ;; \ + *) echo "am__make_running_with_option: internal error: invalid" \ + "target option '$${target_option-}' specified" >&2; \ + exit 1;; \ + esac; \ + has_opt=no; \ + sane_makeflags=$$MAKEFLAGS; \ + if $(am__is_gnu_make); then \ + sane_makeflags=$$MFLAGS; \ + else \ + case $$MAKEFLAGS in \ + *\\[\ \ ]*) \ + bs=\\; \ + sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ + | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ + esac; \ + fi; \ + skip_next=no; \ + strip_trailopt () \ + { \ + flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ + }; \ + for flg in $$sane_makeflags; do \ + test $$skip_next = yes && { skip_next=no; continue; }; \ + case $$flg in \ + *=*|--*) continue;; \ + -*I) strip_trailopt 'I'; skip_next=yes;; \ + -*I?*) strip_trailopt 'I';; \ + -*O) strip_trailopt 'O'; skip_next=yes;; \ + -*O?*) strip_trailopt 'O';; \ + -*l) strip_trailopt 'l'; skip_next=yes;; \ + -*l?*) strip_trailopt 'l';; \ + -[dEDm]) skip_next=yes;; \ + -[JT]) skip_next=yes;; \ + esac; \ + case $$flg in \ + *$$target_option*) has_opt=yes; break;; \ + esac; \ + done; \ + test $$has_opt = yes +am__make_dryrun = (target_option=n; $(am__make_running_with_option)) +am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ @@ -32,7 +76,7 @@ PRE_UNINSTALL = : POST_UNINSTALL = : subdir = tools -DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in +DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ @@ -40,11 +84,30 @@ mkinstalldirs = $(install_sh) -d CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = +AM_V_P = $(am__v_P_@AM_V@) +am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) +am__v_P_0 = false +am__v_P_1 = : +AM_V_GEN = $(am__v_GEN_@AM_V@) +am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) +am__v_GEN_0 = @echo " GEN " $@; +am__v_GEN_1 = +AM_V_at = $(am__v_at_@AM_V@) +am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) +am__v_at_0 = @ +am__v_at_1 = SOURCES = DIST_SOURCES = +am__can_run_installinfo = \ + case $$AM_UPDATE_INFO_DIR in \ + n|no|NO) false;; \ + *) (install-info --version) >/dev/null 2>&1;; \ + esac +am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ +AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ API_VERSION = @API_VERSION@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ @@ -70,6 +133,8 @@ MKDIR_P = @MKDIR_P@ MONO_CFLAGS = @MONO_CFLAGS@ MONO_LIBS = @MONO_LIBS@ +NUNIT_CFLAGS = @NUNIT_CFLAGS@ +NUNIT_LIBS = @NUNIT_LIBS@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ @@ -85,6 +150,7 @@ SHELL = @SHELL@ STRIP = @STRIP@ VERSION = @VERSION@ +XBUILD = @XBUILD@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ @@ -161,11 +227,11 @@ $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): -tags: TAGS -TAGS: +tags TAGS: + +ctags CTAGS: -ctags: CTAGS -CTAGS: +cscope cscopelist: distdir: $(DISTFILES) @@ -212,10 +278,15 @@ installcheck: installcheck-am install-strip: - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - `test -z '$(STRIP)' || \ - echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install + if test -z '$(STRIP)'; then \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + install; \ + else \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ + fi mostlyclean-generic: clean-generic: @@ -295,15 +366,16 @@ .MAKE: install-am install-strip -.PHONY: all all-am check check-am clean clean-generic distclean \ - distclean-generic distdir dvi dvi-am html html-am info info-am \ - install install-am install-data install-data-am install-dvi \ - install-dvi-am install-exec install-exec-am install-html \ - install-html-am install-info install-info-am install-man \ - install-pdf install-pdf-am install-ps install-ps-am \ - install-strip installcheck installcheck-am installdirs \ - maintainer-clean maintainer-clean-generic mostlyclean \ - mostlyclean-generic pdf pdf-am ps ps-am uninstall uninstall-am +.PHONY: all all-am check check-am clean clean-generic cscopelist-am \ + ctags-am distclean distclean-generic distdir dvi dvi-am html \ + html-am info info-am install install-am install-data \ + install-data-am install-dvi install-dvi-am install-exec \ + install-exec-am install-html install-html-am install-info \ + install-info-am install-man install-pdf install-pdf-am \ + install-ps install-ps-am install-strip installcheck \ + installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-generic pdf \ + pdf-am ps ps-am tags-am uninstall uninstall-am # Tell versions [3.59,3.63) of GNU make to not export all variables.