diff -Nru smuxi-0.8/aclocal.m4 smuxi-0.8.9.1/aclocal.m4 --- smuxi-0.8/aclocal.m4 2010-09-02 19:03:44.000000000 +0000 +++ smuxi-0.8.9.1/aclocal.m4 2012-01-03 09:00:58.000000000 +0000 @@ -13,8 +13,8 @@ m4_ifndef([AC_AUTOCONF_VERSION], [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl -m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.65],, -[m4_warning([this file was generated for autoconf 2.65. +m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.68],, +[m4_warning([this file was generated for autoconf 2.68. 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'.])]) @@ -1842,7 +1842,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]) @@ -1888,7 +1889,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 @@ -1936,9 +1938,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 @@ -1951,7 +1953,7 @@ Consider adjusting the PKG_CONFIG_PATH environment variable if you installed software in a non-standard prefix. -_PKG_TEXT])dnl +_PKG_TEXT])[]dnl ]) elif test $pkg_failed = untried; then AC_MSG_RESULT([no]) @@ -1962,7 +1964,7 @@ _PKG_TEXT -To get pkg-config, see .])dnl +To get pkg-config, see .])[]dnl ]) else $1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS @@ -3504,5 +3506,10 @@ m4_include([expansions.m4]) m4_include([intltool.m4]) +m4_include([libtool.m4]) +m4_include([ltoptions.m4]) +m4_include([ltsugar.m4]) +m4_include([ltversion.m4]) +m4_include([lt~obsolete.m4]) m4_include([mono.m4]) m4_include([programs.m4]) diff -Nru smuxi-0.8/config.guess smuxi-0.8.9.1/config.guess --- smuxi-0.8/config.guess 2008-07-07 23:41:25.000000000 +0000 +++ smuxi-0.8.9.1/config.guess 2011-05-11 07:48:52.000000000 +0000 @@ -1,10 +1,10 @@ #! /bin/sh # Attempt to guess a canonical system name. # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, -# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 -# Free Software Foundation, Inc. +# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, +# 2011 Free Software Foundation, Inc. -timestamp='2008-01-23' +timestamp='2011-05-11' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by @@ -27,16 +27,16 @@ # the same distribution terms that you use for the rest of that program. -# Originally written by Per Bothner . -# Please send patches to . Submit a context -# diff and a properly formatted ChangeLog entry. +# Originally written by Per Bothner. Please send patches (context +# diff format) to and include a ChangeLog +# entry. # # This script attempts to guess a canonical system name similar to # config.sub. If it succeeds, it prints the system name on stdout, and # exits with 0. Otherwise, it exits with 1. # -# The plan is that this can be called by configure scripts if you -# don't specify an explicit build system type. +# You can get the latest version of this script from: +# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD me=`echo "$0" | sed -e 's,.*/,,'` @@ -56,8 +56,9 @@ GNU config.guess ($timestamp) Originally written by Per Bothner. -Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, -2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. +Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, +2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free +Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." @@ -170,7 +171,7 @@ arm*|i386|m68k|ns32k|sh3*|sparc|vax) eval $set_cc_for_build if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ - | grep __ELF__ >/dev/null + | grep -q __ELF__ then # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). # Return netbsd for either. FIX? @@ -180,7 +181,7 @@ fi ;; *) - os=netbsd + os=netbsd ;; esac # The OS release @@ -223,7 +224,7 @@ UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` ;; *5.*) - UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'` + UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'` ;; esac # According to Compaq, /usr/sbin/psrinfo has been available on @@ -269,7 +270,10 @@ # A Xn.n version is an unreleased experimental baselevel. # 1.2 uses "1.2" for uname -r. echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` - exit ;; + # Reset EXIT trap before exiting to avoid spurious non-zero exit code. + exitcode=$? + trap '' 0 + exit $exitcode ;; Alpha\ *:Windows_NT*:*) # How do we know it's Interix rather than the generic POSIX subsystem? # Should we change UNAME_MACHINE based on the output of uname instead @@ -295,7 +299,7 @@ echo s390-ibm-zvmoe exit ;; *:OS400:*:*) - echo powerpc-ibm-os400 + echo powerpc-ibm-os400 exit ;; arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) echo arm-acorn-riscix${UNAME_RELEASE} @@ -324,14 +328,33 @@ case `/usr/bin/uname -p` in sparc) echo sparc-icl-nx7; exit ;; esac ;; + s390x:SunOS:*:*) + echo ${UNAME_MACHINE}-ibm-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; sun4H:SunOS:5.*:*) echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; + i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*) + echo i386-pc-auroraux${UNAME_RELEASE} + exit ;; i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*) - echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + eval $set_cc_for_build + SUN_ARCH="i386" + # If there is a compiler, see if it is configured for 64-bit objects. + # Note that the Sun cc does not turn __LP64__ into 1 like gcc does. + # This test works for both compilers. + if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then + if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \ + (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ + grep IS_64BIT_ARCH >/dev/null + then + SUN_ARCH="x86_64" + fi + fi + echo ${SUN_ARCH}-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4*:SunOS:6*:*) # According to config.sub, this is the proper way to canonicalize @@ -375,23 +398,23 @@ # MiNT. But MiNT is downward compatible to TOS, so this should # be no problem. atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} + echo m68k-atari-mint${UNAME_RELEASE} exit ;; atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} - exit ;; + exit ;; *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} + echo m68k-atari-mint${UNAME_RELEASE} exit ;; milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) - echo m68k-milan-mint${UNAME_RELEASE} - exit ;; + echo m68k-milan-mint${UNAME_RELEASE} + exit ;; hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) - echo m68k-hades-mint${UNAME_RELEASE} - exit ;; + echo m68k-hades-mint${UNAME_RELEASE} + exit ;; *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) - echo m68k-unknown-mint${UNAME_RELEASE} - exit ;; + echo m68k-unknown-mint${UNAME_RELEASE} + exit ;; m68k:machten:*:*) echo m68k-apple-machten${UNAME_RELEASE} exit ;; @@ -461,8 +484,8 @@ echo m88k-motorola-sysv3 exit ;; AViiON:dgux:*:*) - # DG/UX returns AViiON for all architectures - UNAME_PROCESSOR=`/usr/bin/uname -p` + # DG/UX returns AViiON for all architectures + UNAME_PROCESSOR=`/usr/bin/uname -p` if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] then if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ @@ -475,7 +498,7 @@ else echo i586-dg-dgux${UNAME_RELEASE} fi - exit ;; + exit ;; M88*:DolphinOS:*:*) # DolphinOS (SVR3) echo m88k-dolphin-sysv3 exit ;; @@ -532,7 +555,7 @@ echo rs6000-ibm-aix3.2 fi exit ;; - *:AIX:*:[456]) + *:AIX:*:[4567]) IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then IBM_ARCH=rs6000 @@ -575,52 +598,52 @@ 9000/[678][0-9][0-9]) if [ -x /usr/bin/getconf ]; then sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` - sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` - case "${sc_cpu_version}" in - 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 - 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1 - 532) # CPU_PA_RISC2_0 - case "${sc_kernel_bits}" in - 32) HP_ARCH="hppa2.0n" ;; - 64) HP_ARCH="hppa2.0w" ;; + sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` + case "${sc_cpu_version}" in + 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 + 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1 + 532) # CPU_PA_RISC2_0 + case "${sc_kernel_bits}" in + 32) HP_ARCH="hppa2.0n" ;; + 64) HP_ARCH="hppa2.0w" ;; '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20 - esac ;; - esac + esac ;; + esac fi if [ "${HP_ARCH}" = "" ]; then eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c + sed 's/^ //' << EOF >$dummy.c + + #define _HPUX_SOURCE + #include + #include + + int main () + { + #if defined(_SC_KERNEL_BITS) + long bits = sysconf(_SC_KERNEL_BITS); + #endif + long cpu = sysconf (_SC_CPU_VERSION); - #define _HPUX_SOURCE - #include - #include - - int main () - { - #if defined(_SC_KERNEL_BITS) - long bits = sysconf(_SC_KERNEL_BITS); - #endif - long cpu = sysconf (_SC_CPU_VERSION); - - switch (cpu) - { - case CPU_PA_RISC1_0: puts ("hppa1.0"); break; - case CPU_PA_RISC1_1: puts ("hppa1.1"); break; - case CPU_PA_RISC2_0: - #if defined(_SC_KERNEL_BITS) - switch (bits) - { - case 64: puts ("hppa2.0w"); break; - case 32: puts ("hppa2.0n"); break; - default: puts ("hppa2.0"); break; - } break; - #else /* !defined(_SC_KERNEL_BITS) */ - puts ("hppa2.0"); break; - #endif - default: puts ("hppa1.0"); break; - } - exit (0); - } + switch (cpu) + { + case CPU_PA_RISC1_0: puts ("hppa1.0"); break; + case CPU_PA_RISC1_1: puts ("hppa1.1"); break; + case CPU_PA_RISC2_0: + #if defined(_SC_KERNEL_BITS) + switch (bits) + { + case 64: puts ("hppa2.0w"); break; + case 32: puts ("hppa2.0n"); break; + default: puts ("hppa2.0"); break; + } break; + #else /* !defined(_SC_KERNEL_BITS) */ + puts ("hppa2.0"); break; + #endif + default: puts ("hppa1.0"); break; + } + exit (0); + } EOF (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy` test -z "$HP_ARCH" && HP_ARCH=hppa @@ -640,7 +663,7 @@ # => hppa64-hp-hpux11.23 if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | - grep __LP64__ >/dev/null + grep -q __LP64__ then HP_ARCH="hppa2.0w" else @@ -711,22 +734,22 @@ exit ;; C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) echo c1-convex-bsd - exit ;; + exit ;; C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) if getsysinfo -f scalar_acc then echo c32-convex-bsd else echo c2-convex-bsd fi - exit ;; + exit ;; C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) echo c34-convex-bsd - exit ;; + exit ;; C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) echo c38-convex-bsd - exit ;; + exit ;; C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) echo c4-convex-bsd - exit ;; + exit ;; CRAY*Y-MP:*:*:*) echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; @@ -750,14 +773,14 @@ exit ;; F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` - FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` - FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` - echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" - exit ;; + FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` + FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` + echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" + exit ;; 5000:UNIX_System_V:4.*:*) - FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` - FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'` - echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" + FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` + FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'` + echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" exit ;; i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} @@ -785,18 +808,18 @@ echo ${UNAME_MACHINE}-pc-mingw32 exit ;; i*:windows32*:*) - # uname -m includes "-pc" on this system. - echo ${UNAME_MACHINE}-mingw32 + # uname -m includes "-pc" on this system. + echo ${UNAME_MACHINE}-mingw32 exit ;; i*:PW*:*) echo ${UNAME_MACHINE}-pc-pw32 exit ;; - *:Interix*:[3456]*) - case ${UNAME_MACHINE} in + *:Interix*:*) + case ${UNAME_MACHINE} in x86) echo i586-pc-interix${UNAME_RELEASE} exit ;; - EM64T | authenticamd) + authenticamd | genuineintel | EM64T) echo x86_64-unknown-interix${UNAME_RELEASE} exit ;; IA64) @@ -806,6 +829,9 @@ [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*) echo i${UNAME_MACHINE}-pc-mks exit ;; + 8664:Windows_NT:*) + echo x86_64-pc-mks + exit ;; i*:Windows_NT*:* | Pentium*:Windows_NT*:*) # How do we know it's Interix rather than the generic POSIX subsystem? # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we @@ -835,6 +861,20 @@ i*86:Minix:*:*) echo ${UNAME_MACHINE}-pc-minix exit ;; + alpha:Linux:*:*) + case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in + EV5) UNAME_MACHINE=alphaev5 ;; + EV56) UNAME_MACHINE=alphaev56 ;; + PCA56) UNAME_MACHINE=alphapca56 ;; + PCA57) UNAME_MACHINE=alphapca56 ;; + EV6) UNAME_MACHINE=alphaev6 ;; + EV67) UNAME_MACHINE=alphaev67 ;; + EV68*) UNAME_MACHINE=alphaev68 ;; + esac + objdump --private-headers /bin/sh | grep -q ld.so.1 + if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi + echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} + exit ;; arm*:Linux:*:*) eval $set_cc_for_build if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \ @@ -842,7 +882,13 @@ then echo ${UNAME_MACHINE}-unknown-linux-gnu else - echo ${UNAME_MACHINE}-unknown-linux-gnueabi + if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \ + | grep -q __ARM_PCS_VFP + then + echo ${UNAME_MACHINE}-unknown-linux-gnueabi + else + echo ${UNAME_MACHINE}-unknown-linux-gnueabihf + fi fi exit ;; avr32*:Linux:*:*) @@ -855,7 +901,18 @@ echo crisv32-axis-linux-gnu exit ;; frv:Linux:*:*) - echo frv-unknown-linux-gnu + echo frv-unknown-linux-gnu + exit ;; + i*86:Linux:*:*) + LIBC=gnu + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #ifdef __dietlibc__ + LIBC=dietlibc + #endif +EOF + eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC'` + echo "${UNAME_MACHINE}-pc-linux-${LIBC}" exit ;; ia64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu @@ -866,74 +923,33 @@ m68*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; - mips:Linux:*:*) - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c - #undef CPU - #undef mips - #undef mipsel - #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) - CPU=mipsel - #else - #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) - CPU=mips - #else - CPU= - #endif - #endif -EOF - eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n ' - /^CPU/{ - s: ::g - p - }'`" - test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; } - ;; - mips64:Linux:*:*) + mips:Linux:*:* | mips64:Linux:*:*) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #undef CPU - #undef mips64 - #undef mips64el + #undef ${UNAME_MACHINE} + #undef ${UNAME_MACHINE}el #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) - CPU=mips64el + CPU=${UNAME_MACHINE}el #else #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) - CPU=mips64 + CPU=${UNAME_MACHINE} #else CPU= #endif #endif EOF - eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n ' - /^CPU/{ - s: ::g - p - }'`" + eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'` test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; } ;; or32:Linux:*:*) echo or32-unknown-linux-gnu exit ;; - ppc:Linux:*:*) - echo powerpc-unknown-linux-gnu - exit ;; - ppc64:Linux:*:*) - echo powerpc64-unknown-linux-gnu + padre:Linux:*:*) + echo sparc-unknown-linux-gnu exit ;; - alpha:Linux:*:*) - case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in - EV5) UNAME_MACHINE=alphaev5 ;; - EV56) UNAME_MACHINE=alphaev56 ;; - PCA56) UNAME_MACHINE=alphapca56 ;; - PCA57) UNAME_MACHINE=alphapca56 ;; - EV6) UNAME_MACHINE=alphaev6 ;; - EV67) UNAME_MACHINE=alphaev67 ;; - EV68*) UNAME_MACHINE=alphaev68 ;; - esac - objdump --private-headers /bin/sh | grep ld.so.1 >/dev/null - if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi - echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} + parisc64:Linux:*:* | hppa64:Linux:*:*) + echo hppa64-unknown-linux-gnu exit ;; parisc:Linux:*:* | hppa:Linux:*:*) # Look for CPU level @@ -943,14 +959,17 @@ *) echo hppa-unknown-linux-gnu ;; esac exit ;; - parisc64:Linux:*:* | hppa64:Linux:*:*) - echo hppa64-unknown-linux-gnu + ppc64:Linux:*:*) + echo powerpc64-unknown-linux-gnu + exit ;; + ppc:Linux:*:*) + echo powerpc-unknown-linux-gnu exit ;; s390:Linux:*:* | s390x:Linux:*:*) echo ${UNAME_MACHINE}-ibm-linux exit ;; sh64*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu + echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; sh*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu @@ -958,6 +977,9 @@ sparc:Linux:*:* | sparc64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; + tile*:Linux:*:*) + echo ${UNAME_MACHINE}-tilera-linux-gnu + exit ;; vax:Linux:*:*) echo ${UNAME_MACHINE}-dec-linux-gnu exit ;; @@ -965,71 +987,8 @@ echo x86_64-unknown-linux-gnu exit ;; xtensa*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu + echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; - i*86:Linux:*:*) - # The BFD linker knows what the default object file format is, so - # first see if it will tell us. cd to the root directory to prevent - # problems with other programs or directories called `ld' in the path. - # Set LC_ALL=C to ensure ld outputs messages in English. - ld_supported_targets=`cd /; LC_ALL=C ld --help 2>&1 \ - | sed -ne '/supported targets:/!d - s/[ ][ ]*/ /g - s/.*supported targets: *// - s/ .*// - p'` - case "$ld_supported_targets" in - elf32-i386) - TENTATIVE="${UNAME_MACHINE}-pc-linux-gnu" - ;; - a.out-i386-linux) - echo "${UNAME_MACHINE}-pc-linux-gnuaout" - exit ;; - coff-i386) - echo "${UNAME_MACHINE}-pc-linux-gnucoff" - exit ;; - "") - # Either a pre-BFD a.out linker (linux-gnuoldld) or - # one that does not give us useful --help. - echo "${UNAME_MACHINE}-pc-linux-gnuoldld" - exit ;; - esac - # Determine whether the default compiler is a.out or elf - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c - #include - #ifdef __ELF__ - # ifdef __GLIBC__ - # if __GLIBC__ >= 2 - LIBC=gnu - # else - LIBC=gnulibc1 - # endif - # else - LIBC=gnulibc1 - # endif - #else - #if defined(__INTEL_COMPILER) || defined(__PGI) || defined(__SUNPRO_C) || defined(__SUNPRO_CC) - LIBC=gnu - #else - LIBC=gnuaout - #endif - #endif - #ifdef __dietlibc__ - LIBC=dietlibc - #endif -EOF - eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n ' - /^LIBC/{ - s: ::g - p - }'`" - test x"${LIBC}" != x && { - echo "${UNAME_MACHINE}-pc-linux-${LIBC}" - exit - } - test x"${TENTATIVE}" != x && { echo "${TENTATIVE}"; exit; } - ;; i*86:DYNIX/ptx:4*:*) # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. # earlier versions are messed up and put the nodename in both @@ -1037,11 +996,11 @@ echo i386-sequent-sysv4 exit ;; i*86:UNIX_SV:4.2MP:2.*) - # Unixware is an offshoot of SVR4, but it has its own version - # number series starting with 2... - # I am not positive that other SVR4 systems won't match this, + # Unixware is an offshoot of SVR4, but it has its own version + # number series starting with 2... + # I am not positive that other SVR4 systems won't match this, # I just have to hope. -- rms. - # Use sysv4.2uw... so that sysv4* matches it. + # Use sysv4.2uw... so that sysv4* matches it. echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} exit ;; i*86:OS/2:*:*) @@ -1058,7 +1017,7 @@ i*86:syllable:*:*) echo ${UNAME_MACHINE}-pc-syllable exit ;; - i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*) + i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*) echo i386-unknown-lynxos${UNAME_RELEASE} exit ;; i*86:*DOS:*:*) @@ -1073,7 +1032,7 @@ fi exit ;; i*86:*:5:[678]*) - # UnixWare 7.x, OpenUNIX and OpenServer 6. + # UnixWare 7.x, OpenUNIX and OpenServer 6. case `/bin/uname -X | grep "^Machine"` in *486*) UNAME_MACHINE=i486 ;; *Pentium) UNAME_MACHINE=i586 ;; @@ -1101,10 +1060,13 @@ exit ;; pc:*:*:*) # Left here for compatibility: - # uname -m prints for DJGPP always 'pc', but it prints nothing about - # the processor, so we play safe by assuming i386. - echo i386-pc-msdosdjgpp - exit ;; + # uname -m prints for DJGPP always 'pc', but it prints nothing about + # the processor, so we play safe by assuming i586. + # Note: whatever this is, it MUST be the same as what config.sub + # prints for the "djgpp" host, or else GDB configury will decide that + # this is a cross-build. + echo i586-pc-msdosdjgpp + exit ;; Intel:Mach:3*:*) echo i386-pc-mach3 exit ;; @@ -1139,8 +1101,18 @@ /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) - /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ - && { echo i486-ncr-sysv4; exit; } ;; + /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ + && { echo i486-ncr-sysv4; exit; } ;; + NCR*:*:4.2:* | MPRAS*:*:4.2:*) + OS_REL='.3' + test -r /etc/.relid \ + && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` + /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ + && { echo i486-ncr-sysv4.3${OS_REL}; exit; } + /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ + && { echo i586-ncr-sysv4.3${OS_REL}; exit; } + /bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \ + && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) echo m68k-unknown-lynxos${UNAME_RELEASE} exit ;; @@ -1153,7 +1125,7 @@ rs6000:LynxOS:2.*:*) echo rs6000-unknown-lynxos${UNAME_RELEASE} exit ;; - PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.0*:*) + PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*) echo powerpc-unknown-lynxos${UNAME_RELEASE} exit ;; SM[BE]S:UNIX_SV:*:*) @@ -1173,10 +1145,10 @@ echo ns32k-sni-sysv fi exit ;; - PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort - # says - echo i586-unisys-sysv4 - exit ;; + PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort + # says + echo i586-unisys-sysv4 + exit ;; *:UNIX_System_V:4*:FTX*) # From Gerald Hewes . # How about differentiating between stratus architectures? -djm @@ -1202,11 +1174,11 @@ exit ;; R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) if [ -d /usr/nec ]; then - echo mips-nec-sysv${UNAME_RELEASE} + echo mips-nec-sysv${UNAME_RELEASE} else - echo mips-unknown-sysv${UNAME_RELEASE} + echo mips-unknown-sysv${UNAME_RELEASE} fi - exit ;; + exit ;; BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. echo powerpc-be-beos exit ;; @@ -1216,6 +1188,9 @@ BePC:BeOS:*:*) # BeOS running on Intel PC compatible. echo i586-pc-beos exit ;; + BePC:Haiku:*:*) # Haiku running on Intel PC compatible. + echo i586-pc-haiku + exit ;; SX-4:SUPER-UX:*:*) echo sx4-nec-superux${UNAME_RELEASE} exit ;; @@ -1243,6 +1218,16 @@ *:Darwin:*:*) UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown case $UNAME_PROCESSOR in + i386) + eval $set_cc_for_build + if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then + if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \ + (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ + grep IS_64BIT_ARCH >/dev/null + then + UNAME_PROCESSOR="x86_64" + fi + fi ;; unknown) UNAME_PROCESSOR=powerpc ;; esac echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE} @@ -1258,6 +1243,9 @@ *:QNX:*:4*) echo i386-pc-qnx exit ;; + NEO-?:NONSTOP_KERNEL:*:*) + echo neo-tandem-nsk${UNAME_RELEASE} + exit ;; NSE-?:NONSTOP_KERNEL:*:*) echo nse-tandem-nsk${UNAME_RELEASE} exit ;; @@ -1303,13 +1291,13 @@ echo pdp10-unknown-its exit ;; SEI:*:*:SEIUX) - echo mips-sei-seiux${UNAME_RELEASE} + echo mips-sei-seiux${UNAME_RELEASE} exit ;; *:DragonFly:*:*) echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` exit ;; *:*VMS:*:*) - UNAME_MACHINE=`(uname -p) 2>/dev/null` + UNAME_MACHINE=`(uname -p) 2>/dev/null` case "${UNAME_MACHINE}" in A*) echo alpha-dec-vms ; exit ;; I*) echo ia64-dec-vms ; exit ;; @@ -1324,6 +1312,9 @@ i*86:rdos:*:*) echo ${UNAME_MACHINE}-pc-rdos exit ;; + i*86:AROS:*:*) + echo ${UNAME_MACHINE}-pc-aros + exit ;; esac #echo '(No uname command or uname output not recognized.)' 1>&2 @@ -1346,11 +1337,11 @@ #include printf ("m68k-sony-newsos%s\n", #ifdef NEWSOS4 - "4" + "4" #else - "" + "" #endif - ); exit (0); + ); exit (0); #endif #endif diff -Nru smuxi-0.8/config.sub smuxi-0.8.9.1/config.sub --- smuxi-0.8/config.sub 2008-07-07 23:41:25.000000000 +0000 +++ smuxi-0.8.9.1/config.sub 2011-05-11 07:48:52.000000000 +0000 @@ -1,10 +1,10 @@ #! /bin/sh # Configuration validation subroutine script. # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, -# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 -# Free Software Foundation, Inc. +# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, +# 2011 Free Software Foundation, Inc. -timestamp='2008-01-16' +timestamp='2011-03-23' # This file is (in principle) common to ALL GNU software. # The presence of a machine in this file suggests that SOME GNU software @@ -32,13 +32,16 @@ # Please send patches to . Submit a context -# diff and a properly formatted ChangeLog entry. +# diff and a properly formatted GNU ChangeLog entry. # # Configuration subroutine to validate and canonicalize a configuration type. # Supply the specified configuration type as an argument. # If it is invalid, we print an error message on stderr and exit with code 1. # Otherwise, we print the canonical config type on stdout and succeed. +# You can get the latest version of this script from: +# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD + # This file is supposed to be the same for all GNU packages # and recognize all the CPU types, system types and aliases # that are meaningful with *any* GNU software. @@ -72,8 +75,9 @@ version="\ GNU config.sub ($timestamp) -Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, -2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. +Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, +2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free +Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." @@ -120,8 +124,10 @@ # Here we must recognize all the valid KERNEL-OS combinations. maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` case $maybe_os in - nto-qnx* | linux-gnu* | linux-dietlibc | linux-newlib* | linux-uclibc* | \ - uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | \ + nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \ + linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \ + knetbsd*-gnu* | netbsd*-gnu* | \ + kopensolaris*-gnu* | \ storm-chaos* | os2-emx* | rtmk-nova*) os=-$maybe_os basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` @@ -148,10 +154,13 @@ -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ - -apple | -axis | -knuth | -cray) + -apple | -axis | -knuth | -cray | -microblaze) os= basic_machine=$1 ;; + -bluegene*) + os=-cnk + ;; -sim | -cisco | -oki | -wec | -winbond) os= basic_machine=$1 @@ -166,10 +175,10 @@ os=-chorusos basic_machine=$1 ;; - -chorusrdb) - os=-chorusrdb + -chorusrdb) + os=-chorusrdb basic_machine=$1 - ;; + ;; -hiux*) os=-hiuxwe2 ;; @@ -249,13 +258,16 @@ | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ | i370 | i860 | i960 | ia64 \ | ip2k | iq2000 \ + | lm32 \ | m32c | m32r | m32rle | m68000 | m68k | m88k \ - | maxq | mb | microblaze | mcore | mep \ + | maxq | mb | microblaze | mcore | mep | metag \ | mips | mipsbe | mipseb | mipsel | mipsle \ | mips16 \ | mips64 | mips64el \ - | mips64vr | mips64vrel \ + | mips64octeon | mips64octeonel \ | mips64orion | mips64orionel \ + | mips64r5900 | mips64r5900el \ + | mips64vr | mips64vrel \ | mips64vr4100 | mips64vr4100el \ | mips64vr4300 | mips64vr4300el \ | mips64vr5000 | mips64vr5000el \ @@ -268,28 +280,42 @@ | mipsisa64sr71k | mipsisa64sr71kel \ | mipstx39 | mipstx39el \ | mn10200 | mn10300 \ + | moxie \ | mt \ | msp430 \ + | nds32 | nds32le | nds32be \ | nios | nios2 \ | ns16k | ns32k \ + | open8 \ | or32 \ | pdp10 | pdp11 | pj | pjl \ - | powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \ + | powerpc | powerpc64 | powerpc64le | powerpcle \ | pyramid \ + | rx \ | score \ - | sh | sh[1234] | sh[24]a | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \ + | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \ | sh64 | sh64le \ | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \ | sparcv8 | sparcv9 | sparcv9b | sparcv9v \ - | spu | strongarm \ - | tahoe | thumb | tic4x | tic80 | tron \ + | spu \ + | tahoe | tic4x | tic54x | tic55x | tic6x | tic80 | tron \ + | ubicom32 \ | v850 | v850e \ | we32k \ - | x86 | xc16x | xscale | xscalee[bl] | xstormy16 | xtensa \ - | z8k) + | x86 | xc16x | xstormy16 | xtensa \ + | z8k | z80) basic_machine=$basic_machine-unknown ;; - m6811 | m68hc11 | m6812 | m68hc12) + c54x) + basic_machine=tic54x-unknown + ;; + c55x) + basic_machine=tic55x-unknown + ;; + c6x) + basic_machine=tic6x-unknown + ;; + m6811 | m68hc11 | m6812 | m68hc12 | picochip) # Motorola 68HC11/12. basic_machine=$basic_machine-unknown os=-none @@ -300,6 +326,18 @@ basic_machine=mt-unknown ;; + strongarm | thumb | xscale) + basic_machine=arm-unknown + ;; + + xscaleeb) + basic_machine=armeb-unknown + ;; + + xscaleel) + basic_machine=armel-unknown + ;; + # We use `pc' rather than `unknown' # because (1) that's what they normally are, and # (2) the word "unknown" tends to confuse beginning users. @@ -320,7 +358,7 @@ | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ | avr-* | avr32-* \ | bfin-* | bs2000-* \ - | c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \ + | c[123]* | c30-* | [cjt]90-* | c4x-* \ | clipper-* | craynv-* | cydra-* \ | d10v-* | d30v-* | dlx-* \ | elxsi-* \ @@ -329,14 +367,17 @@ | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ | i*86-* | i860-* | i960-* | ia64-* \ | ip2k-* | iq2000-* \ + | lm32-* \ | m32c-* | m32r-* | m32rle-* \ | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ - | m88110-* | m88k-* | maxq-* | mcore-* \ + | m88110-* | m88k-* | maxq-* | mcore-* | metag-* | microblaze-* \ | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ | mips16-* \ | mips64-* | mips64el-* \ - | mips64vr-* | mips64vrel-* \ + | mips64octeon-* | mips64octeonel-* \ | mips64orion-* | mips64orionel-* \ + | mips64r5900-* | mips64r5900el-* \ + | mips64vr-* | mips64vrel-* \ | mips64vr4100-* | mips64vr4100el-* \ | mips64vr4300-* | mips64vr4300el-* \ | mips64vr5000-* | mips64vr5000el-* \ @@ -351,27 +392,31 @@ | mmix-* \ | mt-* \ | msp430-* \ + | nds32-* | nds32le-* | nds32be-* \ | nios-* | nios2-* \ | none-* | np1-* | ns16k-* | ns32k-* \ + | open8-* \ | orion-* \ | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ - | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \ + | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \ | pyramid-* \ - | romp-* | rs6000-* \ - | sh-* | sh[1234]-* | sh[24]a-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \ + | romp-* | rs6000-* | rx-* \ + | sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \ | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \ | sparclite-* \ - | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | strongarm-* | sv1-* | sx?-* \ - | tahoe-* | thumb-* \ + | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx?-* \ + | tahoe-* \ | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ + | tile-* | tilegx-* \ | tron-* \ + | ubicom32-* \ | v850-* | v850e-* | vax-* \ | we32k-* \ - | x86-* | x86_64-* | xc16x-* | xps100-* | xscale-* | xscalee[bl]-* \ + | x86-* | x86_64-* | xc16x-* | xps100-* \ | xstormy16-* | xtensa*-* \ | ymp-* \ - | z8k-*) + | z8k-* | z80-*) ;; # Recognize the basic CPU types without company name, with glob match. xtensa*) @@ -393,7 +438,7 @@ basic_machine=a29k-amd os=-udi ;; - abacus) + abacus) basic_machine=abacus-unknown ;; adobe68k) @@ -439,6 +484,10 @@ basic_machine=m68k-apollo os=-bsd ;; + aros) + basic_machine=i386-pc + os=-aros + ;; aux) basic_machine=m68k-apple os=-aux @@ -455,10 +504,27 @@ basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'` os=-linux ;; + bluegene*) + basic_machine=powerpc-ibm + os=-cnk + ;; + c54x-*) + basic_machine=tic54x-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + c55x-*) + basic_machine=tic55x-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + c6x-*) + basic_machine=tic6x-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; c90) basic_machine=c90-cray os=-unicos ;; + cegcc) + basic_machine=arm-unknown + os=-cegcc + ;; convex-c1) basic_machine=c1-convex os=-bsd @@ -487,7 +553,7 @@ basic_machine=craynv-cray os=-unicosmp ;; - cr16) + cr16 | cr16-*) basic_machine=cr16-unknown os=-elf ;; @@ -526,6 +592,10 @@ basic_machine=m88k-motorola os=-sysv3 ;; + dicos) + basic_machine=i686-pc + os=-dicos + ;; djgpp) basic_machine=i586-pc os=-msdosdjgpp @@ -699,6 +769,9 @@ basic_machine=ns32k-utek os=-sysv ;; + microblaze) + basic_machine=microblaze-xilinx + ;; mingw32) basic_machine=i386-pc os=-mingw32 @@ -803,6 +876,12 @@ np1) basic_machine=np1-gould ;; + neo-tandem) + basic_machine=neo-tandem + ;; + nse-tandem) + basic_machine=nse-tandem + ;; nsr-tandem) basic_machine=nsr-tandem ;; @@ -885,9 +964,10 @@ ;; power) basic_machine=power-ibm ;; - ppc) basic_machine=powerpc-unknown + ppc | ppcbe) basic_machine=powerpc-unknown ;; - ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` + ppc-* | ppcbe-*) + basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppcle | powerpclittle | ppc-le | powerpc-little) basic_machine=powerpcle-unknown @@ -981,6 +1061,9 @@ basic_machine=i860-stratus os=-sysv4 ;; + strongarm-* | thumb-*) + basic_machine=arm-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; sun2) basic_machine=m68000-sun ;; @@ -1037,17 +1120,10 @@ basic_machine=t90-cray os=-unicos ;; - tic54x | c54x*) - basic_machine=tic54x-unknown - os=-coff - ;; - tic55x | c55x*) - basic_machine=tic55x-unknown - os=-coff - ;; - tic6x | c6x*) - basic_machine=tic6x-unknown - os=-coff + # This must be matched before tile*. + tilegx*) + basic_machine=tilegx-unknown + os=-linux-gnu ;; tile*) basic_machine=tile-unknown @@ -1120,6 +1196,9 @@ xps | xps100) basic_machine=xps100-honeywell ;; + xscale-* | xscalee[bl]-*) + basic_machine=`echo $basic_machine | sed 's/^xscale/arm/'` + ;; ymp) basic_machine=ymp-cray os=-unicos @@ -1128,6 +1207,10 @@ basic_machine=z8k-unknown os=-sim ;; + z80-*-coff) + basic_machine=z80-unknown + os=-sim + ;; none) basic_machine=none-none os=-none @@ -1166,7 +1249,7 @@ we32k) basic_machine=we32k-att ;; - sh[1234] | sh[24]a | sh[34]eb | sh[1234]le | sh[23]ele) + sh[1234] | sh[24]a | sh[24]aeb | sh[34]eb | sh[1234]le | sh[23]ele) basic_machine=sh-unknown ;; sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v) @@ -1213,9 +1296,12 @@ if [ x"$os" != x"" ] then case $os in - # First match some system type aliases - # that might get confused with valid system types. + # First match some system type aliases + # that might get confused with valid system types. # -solaris* is a basic system type, with this one exception. + -auroraux) + os=-auroraux + ;; -solaris1 | -solaris1.*) os=`echo $os | sed -e 's|solaris1|sunos4|'` ;; @@ -1236,10 +1322,11 @@ # Each alternative MUST END IN A *, to match a version number. # -sysv* is not here because it comes later, after sysvr4. -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ - | -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\ - | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \ + | -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\ + | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \ + | -sym* | -kopensolaris* \ | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ - | -aos* \ + | -aos* | -aros* \ | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ @@ -1248,9 +1335,10 @@ | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ - | -chorusos* | -chorusrdb* \ + | -chorusos* | -chorusrdb* | -cegcc* \ | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ - | -mingw32* | -linux-gnu* | -linux-newlib* | -linux-uclibc* \ + | -mingw32* | -linux-gnu* | -linux-android* \ + | -linux-newlib* | -linux-uclibc* \ | -uxpv* | -beos* | -mpeix* | -udk* \ | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ @@ -1258,7 +1346,7 @@ | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \ - | -skyos* | -haiku* | -rdos* | -toppers* | -drops*) + | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es*) # Remember, each alternative MUST END IN *, to match a version number. ;; -qnx*) @@ -1297,7 +1385,7 @@ -opened*) os=-openedition ;; - -os400*) + -os400*) os=-os400 ;; -wince*) @@ -1346,7 +1434,7 @@ -sinix*) os=-sysv4 ;; - -tpf*) + -tpf*) os=-tpf ;; -triton*) @@ -1388,6 +1476,11 @@ -zvmoe) os=-zvmoe ;; + -dicos*) + os=-dicos + ;; + -nacl*) + ;; -none) ;; *) @@ -1410,10 +1503,10 @@ # system, and we'll never get to this point. case $basic_machine in - score-*) + score-*) os=-elf ;; - spu-*) + spu-*) os=-elf ;; *-acorn) @@ -1425,8 +1518,17 @@ arm*-semi) os=-aout ;; - c4x-* | tic4x-*) - os=-coff + c4x-* | tic4x-*) + os=-coff + ;; + tic54x-*) + os=-coff + ;; + tic55x-*) + os=-coff + ;; + tic6x-*) + os=-coff ;; # This must come before the *-dec entry. pdp10-*) @@ -1453,7 +1555,7 @@ m68*-cisco) os=-aout ;; - mep-*) + mep-*) os=-elf ;; mips*-cisco) @@ -1480,7 +1582,7 @@ *-ibm) os=-aix ;; - *-knuth) + *-knuth) os=-mmixware ;; *-wec) @@ -1585,7 +1687,7 @@ -sunos*) vendor=sun ;; - -aix*) + -cnk*|-aix*) vendor=ibm ;; -beos*) diff -Nru smuxi-0.8/configure smuxi-0.8.9.1/configure --- smuxi-0.8/configure 2010-09-02 19:03:46.000000000 +0000 +++ smuxi-0.8.9.1/configure 2012-01-03 09:01:02.000000000 +0000 @@ -1,13 +1,13 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.65 for smuxi 0.8. +# Generated by GNU Autoconf 2.68 for smuxi 0.8.9.1. # # Report bugs to . # # # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, -# 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, -# Inc. +# 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software +# Foundation, Inc. # # # This configure script is free software; the Free Software Foundation @@ -91,6 +91,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 @@ -173,6 +174,14 @@ 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'\" && test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1 + + test -n \"\${ZSH_VERSION+set}\${BASH_VERSION+set}\" || ( + ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' + ECHO=\$ECHO\$ECHO\$ECHO\$ECHO\$ECHO + ECHO=\$ECHO\$ECHO\$ECHO\$ECHO\$ECHO\$ECHO + PATH=/empty FPATH=/empty; export PATH FPATH + test \"X\`printf %s \$ECHO\`\" = \"X\$ECHO\" \\ + || test \"X\`print -r -- \$ECHO\`\" = \"X\$ECHO\" ) || exit 1 test \$(( 1 + 1 )) = 2 || exit 1" if (eval "$as_required") 2>/dev/null; then : as_have_required=yes @@ -216,11 +225,18 @@ # 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 export CONFIG_SHELL - exec "$CONFIG_SHELL" "$as_myself" ${1+"$@"} + 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+"$@"} fi if test x$as_have_required = xno; then : @@ -319,7 +335,7 @@ test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" - } || test -d "$as_dir" || as_fn_error "cannot create directory $as_dir" + } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" } # as_fn_mkdir_p @@ -359,19 +375,19 @@ fi # as_fn_arith -# as_fn_error ERROR [LINENO LOG_FD] -# --------------------------------- +# as_fn_error STATUS ERROR [LINENO LOG_FD] +# ---------------------------------------- # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are # provided, also output the error to LOG_FD, referencing LINENO. Then exit the -# script with status $?, using 1 if that was 0. +# script with STATUS, using 1 if that was 0. as_fn_error () { - as_status=$?; test $as_status -eq 0 && as_status=1 - if test "$3"; then - as_lineno=${as_lineno-"$2"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - $as_echo "$as_me:${as_lineno-$LINENO}: error: $1" >&$3 + as_status=$1; test $as_status -eq 0 && as_status=1 + if test "$4"; then + as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 fi - $as_echo "$as_me: error: $1" >&2 + $as_echo "$as_me: error: $2" >&2 as_fn_exit $as_status } # as_fn_error @@ -528,12 +544,14 @@ # Sed expression to map a string onto a valid variable name. as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" +SHELL=${CONFIG_SHELL-/bin/sh} + test -n "$DJDIR" || exec 7<&0 &1 # Name of the host. -# hostname on some systems (SVR3.2, Linux) returns a bogus exit status, +# hostname on some systems (SVR3.2, old GNU/Linux) returns a bogus exit status, # so uname gets run too. ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` @@ -552,11 +570,47 @@ # Identity of this package. PACKAGE_NAME='smuxi' PACKAGE_TARNAME='smuxi' -PACKAGE_VERSION='0.8' -PACKAGE_STRING='smuxi 0.8' +PACKAGE_VERSION='0.8.9.1' +PACKAGE_STRING='smuxi 0.8.9.1' PACKAGE_BUGREPORT='http://www.smuxi.org/issues/new' PACKAGE_URL='' +# Factoring default headers for most tests. +ac_includes_default="\ +#include +#ifdef HAVE_SYS_TYPES_H +# include +#endif +#ifdef HAVE_SYS_STAT_H +# include +#endif +#ifdef STDC_HEADERS +# include +# include +#else +# ifdef HAVE_STDLIB_H +# include +# endif +#endif +#ifdef HAVE_STRING_H +# if !defined STDC_HEADERS && defined HAVE_MEMORY_H +# include +# endif +# include +#endif +#ifdef HAVE_STRINGS_H +# include +#endif +#ifdef HAVE_INTTYPES_H +# include +#endif +#ifdef HAVE_STDINT_H +# include +#endif +#ifdef HAVE_UNISTD_H +# include +#endif" + gt_needs= enable_option_checking=no ac_subst_vars='am__EXEEXT_FALSE @@ -573,6 +627,10 @@ ENABLE_FRONTEND_CURSES_TRUE ENABLE_FRONTEND_STFL_FALSE ENABLE_FRONTEND_STFL_TRUE +ENABLE_STATIC_STFL_FALSE +ENABLE_STATIC_STFL_TRUE +STFL_LIBS +STFL_CFLAGS ENABLE_FRONTEND_GNOME_XMPP_FALSE ENABLE_FRONTEND_GNOME_XMPP_TRUE ENABLE_FRONTEND_GNOME_IRC_FALSE @@ -586,18 +644,16 @@ GTK_SHARP_20_CFLAGS GLIB_SHARP_20_LIBS GLIB_SHARP_20_CFLAGS +SERVER_COMPILER_FLAGS twitter_api_key ENABLE_ENGINE_TWITTER_FALSE ENABLE_ENGINE_TWITTER_TRUE -XBUILD ENABLE_ENGINE_MSNP_FALSE ENABLE_ENGINE_MSNP_TRUE MSNPSHARP_LIBS MSNPSHARP_CFLAGS ENABLE_ENGINE_XMPP_FALSE ENABLE_ENGINE_XMPP_TRUE -JABBER_NET_LIBS -JABBER_NET_CFLAGS ENABLE_ENGINE_OSCAR_FALSE ENABLE_ENGINE_OSCAR_TRUE OSCARLIB_LIBS @@ -606,16 +662,32 @@ ENABLE_ENGINE_IRC_TRUE SMARTIRC4NET_FILES subdirs +NDESK_DBUS_GLIB_LIBS +NDESK_DBUS_GLIB_CFLAGS +NDESK_DBUS_LIBS +NDESK_DBUS_CFLAGS +DBUS_LIBS +DBUS_SHARP_GLIB_LIBS +DBUS_SHARP_GLIB_CFLAGS +DBUS_SHARP_LIBS +DBUS_SHARP_CFLAGS NOTIFY_SHARP_LIBS NOTIFY_SHARP_CFLAGS INDICATE_SHARP_LIBS INDICATE_SHARP_CFLAGS +DB4O_FILES +XBUILD +BUNDLE_DB4O_FALSE +BUNDLE_DB4O_TRUE +DB4O_LIBS +DB4O_CFLAGS NINI_LIBS NINI_CFLAGS BUNDLE_NINI_FALSE BUNDLE_NINI_TRUE LOG4NET_LIBS LOG4NET_CFLAGS +XBUILD_FLAGS CSC_FLAGS CSC PROFILE @@ -630,23 +702,16 @@ PKG_CONFIG_LIBDIR PKG_CONFIG_PATH expanded_libdir +dist_version +DEV_VERSION_SUFFIX +git_commit_hash +git_branch LTLIBINTL LIBINTL INTLLIBS LTLIBICONV LIBICONV INTL_MACOSX_LIBS -EGREP -GREP -CPP -host_os -host_vendor -host_cpu -host -build_os -build_vendor -build_cpu -build XGETTEXT_EXTRA_OPTIONS XGETTEXT_015 GMSGFMT_015 @@ -670,22 +735,6 @@ GETTEXT_PACKAGE POSUB DATADIRNAME -am__fastdepCC_FALSE -am__fastdepCC_TRUE -CCDEPMODE -AMDEPBACKSLASH -AMDEP_FALSE -AMDEP_TRUE -am__quote -am__include -DEPDIR -OBJEXT -EXEEXT -ac_ct_CC -CPPFLAGS -LDFLAGS -CFLAGS -CC ALL_LINGUAS INTLTOOL_PERL GMSGFMT @@ -715,6 +764,52 @@ INTLTOOL_MERGE INTLTOOL_UPDATE USE_NLS +CPP +OTOOL64 +OTOOL +LIPO +NMEDIT +DSYMUTIL +MANIFEST_TOOL +RANLIB +ac_ct_AR +AR +DLLTOOL +OBJDUMP +LN_S +NM +ac_ct_DUMPBIN +DUMPBIN +LD +FGREP +EGREP +GREP +SED +am__fastdepCC_FALSE +am__fastdepCC_TRUE +CCDEPMODE +AMDEPBACKSLASH +AMDEP_FALSE +AMDEP_TRUE +am__quote +am__include +DEPDIR +OBJEXT +EXEEXT +ac_ct_CC +CPPFLAGS +LDFLAGS +CFLAGS +CC +host_os +host_vendor +host_cpu +host +build_os +build_vendor +build_cpu +build +LIBTOOL PKG_CONFIG MAINT MAINTAINER_MODE_FALSE @@ -784,16 +879,25 @@ ac_user_opts=' enable_option_checking enable_maintainer_mode -enable_nls +enable_static +enable_shared +with_pic +enable_fast_install enable_dependency_tracking with_gnu_ld +with_sysroot +enable_libtool_lock +enable_nls enable_rpath with_libiconv_prefix with_libintl_prefix +with_vendor_package_version enable_release enable_debug +with_db4o with_indicate with_notify +with_dbus enable_engine_irc enable_engine_oscar enable_engine_xmpp @@ -825,14 +929,22 @@ LOG4NET_LIBS NINI_CFLAGS NINI_LIBS +DB4O_CFLAGS +DB4O_LIBS INDICATE_SHARP_CFLAGS INDICATE_SHARP_LIBS NOTIFY_SHARP_CFLAGS NOTIFY_SHARP_LIBS +DBUS_SHARP_CFLAGS +DBUS_SHARP_LIBS +DBUS_SHARP_GLIB_CFLAGS +DBUS_SHARP_GLIB_LIBS +NDESK_DBUS_CFLAGS +NDESK_DBUS_LIBS +NDESK_DBUS_GLIB_CFLAGS +NDESK_DBUS_GLIB_LIBS OSCARLIB_CFLAGS OSCARLIB_LIBS -JABBER_NET_CFLAGS -JABBER_NET_LIBS MSNPSHARP_CFLAGS MSNPSHARP_LIBS GLIB_SHARP_20_CFLAGS @@ -840,7 +952,9 @@ GTK_SHARP_20_CFLAGS GTK_SHARP_20_LIBS GLADE_SHARP_20_CFLAGS -GLADE_SHARP_20_LIBS' +GLADE_SHARP_20_LIBS +STFL_CFLAGS +STFL_LIBS' ac_subdirs_all='lib/SmartIrc4net' # Initialize some variables set by options. @@ -903,8 +1017,9 @@ fi case $ac_option in - *=*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; - *) ac_optarg=yes ;; + *=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; + *=) ac_optarg= ;; + *) ac_optarg=yes ;; esac # Accept the important Cygnus configure options, so we can diagnose typos. @@ -949,7 +1064,7 @@ ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && - as_fn_error "invalid feature name: $ac_useropt" + as_fn_error $? "invalid feature name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in @@ -975,7 +1090,7 @@ ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && - as_fn_error "invalid feature name: $ac_useropt" + as_fn_error $? "invalid feature name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in @@ -1179,7 +1294,7 @@ ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && - as_fn_error "invalid package name: $ac_useropt" + as_fn_error $? "invalid package name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in @@ -1195,7 +1310,7 @@ ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && - as_fn_error "invalid package name: $ac_useropt" + as_fn_error $? "invalid package name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in @@ -1225,8 +1340,8 @@ | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) x_libraries=$ac_optarg ;; - -*) as_fn_error "unrecognized option: \`$ac_option' -Try \`$0 --help' for more information." + -*) as_fn_error $? "unrecognized option: \`$ac_option' +Try \`$0 --help' for more information" ;; *=*) @@ -1234,7 +1349,7 @@ # Reject names that are not valid shell variable names. case $ac_envvar in #( '' | [0-9]* | *[!_$as_cr_alnum]* ) - as_fn_error "invalid variable name: \`$ac_envvar'" ;; + as_fn_error $? "invalid variable name: \`$ac_envvar'" ;; esac eval $ac_envvar=\$ac_optarg export $ac_envvar ;; @@ -1244,7 +1359,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 @@ -1252,13 +1367,13 @@ if test -n "$ac_prev"; then ac_option=--`echo $ac_prev | sed 's/_/-/g'` - as_fn_error "missing argument to $ac_option" + as_fn_error $? "missing argument to $ac_option" fi if test -n "$ac_unrecognized_opts"; then case $enable_option_checking in no) ;; - fatal) as_fn_error "unrecognized options: $ac_unrecognized_opts" ;; + fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;; *) $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;; esac fi @@ -1281,7 +1396,7 @@ [\\/$]* | ?:[\\/]* ) continue;; NONE | '' ) case $ac_var in *prefix ) continue;; esac;; esac - as_fn_error "expected an absolute directory name for --$ac_var: $ac_val" + as_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val" done # There might be people who depend on the old broken behavior: `$host' @@ -1295,8 +1410,8 @@ 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 + $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 @@ -1311,9 +1426,9 @@ ac_pwd=`pwd` && test -n "$ac_pwd" && ac_ls_di=`ls -di .` && ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` || - as_fn_error "working directory cannot be determined" + as_fn_error $? "working directory cannot be determined" test "X$ac_ls_di" = "X$ac_pwd_ls_di" || - as_fn_error "pwd does not report name of working directory" + as_fn_error $? "pwd does not report name of working directory" # Find the source files, if location was not specified. @@ -1352,11 +1467,11 @@ fi if test ! -r "$srcdir/$ac_unique_file"; then test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." - as_fn_error "cannot find sources ($ac_unique_file) in $srcdir" + as_fn_error $? "cannot find sources ($ac_unique_file) in $srcdir" fi ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" ac_abs_confdir=`( - cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error "$ac_msg" + cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error $? "$ac_msg" pwd)` # When building in place, set srcdir=. if test "$ac_abs_confdir" = "$ac_pwd"; then @@ -1382,7 +1497,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 smuxi 0.8 to adapt to many kinds of systems. +\`configure' configures smuxi 0.8.9.1 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1396,7 +1511,7 @@ --help=short display options specific to this package --help=recursive display the short help of all the included packages -V, --version display version information and exit - -q, --quiet, --silent do not print \`checking...' messages + -q, --quiet, --silent do not print \`checking ...' messages --cache-file=FILE cache test results in FILE [disabled] -C, --config-cache alias for \`--cache-file=config.cache' -n, --no-create do not create output files @@ -1452,7 +1567,7 @@ if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of smuxi 0.8:";; + short | recursive ) echo "Configuration of smuxi 0.8.9.1:";; esac cat <<\_ACEOF @@ -1462,15 +1577,20 @@ --enable-FEATURE[=ARG] include FEATURE [ARG=yes] --enable-maintainer-mode enable make rules and dependencies not useful (and sometimes confusing) to the casual installer - --disable-nls do not use Native Language Support + --enable-static[=PKGS] build static libraries [default=no] + --enable-shared[=PKGS] build shared libraries [default=yes] + --enable-fast-install[=PKGS] + optimize for fast installation [default=yes] --disable-dependency-tracking speeds up one-time build --enable-dependency-tracking do not reject slow dependency extractors + --disable-libtool-lock avoid locking (might break parallel builds) + --disable-nls do not use Native Language Support --disable-rpath do not hardcode runtime library paths --enable-release Use 'RELEASE' Configuration [default=NO] --enable-debug Use 'DEBUG' Configuration [default=YES] --enable-engine-irc Enable IRC protocol support (default yes) --enable-engine-oscar Enable OSCAR (AIM/ICQ) protocol support (default no) - --enable-engine-xmpp Enable XMPP (Jabber) protocol support (default no) + --enable-engine-xmpp Enable XMPP (Jabber) protocol support (default yes) --enable-engine-msnp Enable MSNP protocol support (default no) --enable-engine-twitter Enable Twitter support (default yes) --enable-frontend-gnome Enable GNOME frontend (default yes) @@ -1485,13 +1605,24 @@ Optional Packages: --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) + --with-pic[=PKGS] try to use only PIC/non-PIC objects [default=use + both] + --with-gnu-ld assume the C compiler uses GNU ld [default=no] + --with-sysroot=DIR Search for dependent libraries within DIR + (or the compiler's sysroot if not specified). --with-gnu-ld assume the C compiler uses GNU ld default=no --with-libiconv-prefix[=DIR] search for libiconv in DIR/include and DIR/lib --without-libiconv-prefix don't search for libiconv in includedir and libdir --with-libintl-prefix[=DIR] search for libintl in DIR/include and DIR/lib --without-libintl-prefix don't search for libintl in includedir and libdir + --with-vendor-package-version="DISTRO_NAME PACKAGE_VERSION" + Set the distro name and package version, e.g. + "Debian 0.8-1" + --with-db4o=auto|system|included + Use system or included db4o [default=auto] --with-indicate Support Messaging Menu [default=auto] --with-notify Support Desktop Notifications [default=auto] + --with-dbus Support D-Bus [default=auto] --with-twitter-api-key Specify custom Twitter API key Some influential environment variables: @@ -1518,6 +1649,8 @@ linker flags for LOG4NET, overriding pkg-config NINI_CFLAGS C compiler flags for NINI, overriding pkg-config NINI_LIBS linker flags for NINI, overriding pkg-config + DB4O_CFLAGS C compiler flags for DB4O, overriding pkg-config + DB4O_LIBS linker flags for DB4O, overriding pkg-config INDICATE_SHARP_CFLAGS C compiler flags for INDICATE_SHARP, overriding pkg-config INDICATE_SHARP_LIBS @@ -1526,14 +1659,26 @@ C compiler flags for NOTIFY_SHARP, overriding pkg-config NOTIFY_SHARP_LIBS linker flags for NOTIFY_SHARP, overriding pkg-config + DBUS_SHARP_CFLAGS + C compiler flags for DBUS_SHARP, overriding pkg-config + DBUS_SHARP_LIBS + linker flags for DBUS_SHARP, overriding pkg-config + DBUS_SHARP_GLIB_CFLAGS + C compiler flags for DBUS_SHARP_GLIB, overriding pkg-config + DBUS_SHARP_GLIB_LIBS + linker flags for DBUS_SHARP_GLIB, overriding pkg-config + NDESK_DBUS_CFLAGS + C compiler flags for NDESK_DBUS, overriding pkg-config + NDESK_DBUS_LIBS + linker flags for NDESK_DBUS, overriding pkg-config + NDESK_DBUS_GLIB_CFLAGS + C compiler flags for NDESK_DBUS_GLIB, overriding pkg-config + NDESK_DBUS_GLIB_LIBS + linker flags for NDESK_DBUS_GLIB, overriding pkg-config OSCARLIB_CFLAGS C compiler flags for OSCARLIB, overriding pkg-config OSCARLIB_LIBS linker flags for OSCARLIB, overriding pkg-config - JABBER_NET_CFLAGS - C compiler flags for JABBER_NET, overriding pkg-config - JABBER_NET_LIBS - linker flags for JABBER_NET, overriding pkg-config MSNPSHARP_CFLAGS C compiler flags for MSNPSHARP, overriding pkg-config MSNPSHARP_LIBS @@ -1550,6 +1695,8 @@ C compiler flags for GLADE_SHARP_20, overriding pkg-config GLADE_SHARP_20_LIBS linker flags for GLADE_SHARP_20, overriding pkg-config + STFL_CFLAGS C compiler flags for STFL, overriding pkg-config + STFL_LIBS linker flags for STFL, 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. @@ -1617,10 +1764,10 @@ test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -smuxi configure 0.8 -generated by GNU Autoconf 2.65 +smuxi configure 0.8.9.1 +generated by GNU Autoconf 2.68 -Copyright (C) 2009 Free Software Foundation, Inc. +Copyright (C) 2010 Free Software Foundation, Inc. This configure script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. _ACEOF @@ -1664,7 +1811,7 @@ ac_retval=1 fi - eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_compile @@ -1710,77 +1857,41 @@ # interfere with the next link command; also delete a directory that is # left behind by Apple's compiler. We do this before executing the actions. rm -rf conftest.dSYM conftest_ipa8_conftest.oo - eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_link -# ac_fn_c_check_func LINENO FUNC VAR -# ---------------------------------- -# Tests whether FUNC exists, setting the cache variable VAR accordingly -ac_fn_c_check_func () +# ac_fn_c_check_header_compile LINENO HEADER VAR INCLUDES +# ------------------------------------------------------- +# Tests whether HEADER exists and can be compiled using the include files in +# INCLUDES, setting the cache variable VAR accordingly. +ac_fn_c_check_header_compile () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } -if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then : +if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ -/* Define $2 to an innocuous variant, in case declares $2. - For example, HP-UX 11i declares gettimeofday. */ -#define $2 innocuous_$2 - -/* System header to define __stub macros and hopefully few prototypes, - which can conflict with char $2 (); below. - Prefer to if __STDC__ is defined, since - exists even on freestanding compilers. */ - -#ifdef __STDC__ -# include -#else -# include -#endif - -#undef $2 - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char $2 (); -/* The GNU C library defines this for functions which it implements - to always fail with ENOSYS. Some functions are actually named - something starting with __ and the normal name is an alias. */ -#if defined __stub_$2 || defined __stub___$2 -choke me -#endif - -int -main () -{ -return $2 (); - ; - return 0; -} +$4 +#include <$2> _ACEOF -if ac_fn_c_try_link "$LINENO"; then : +if ac_fn_c_try_compile "$LINENO"; then : eval "$3=yes" else eval "$3=no" fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } - eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno -} # ac_fn_c_check_func +} # ac_fn_c_check_header_compile # ac_fn_c_try_cpp LINENO # ---------------------- @@ -1803,7 +1914,7 @@ mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } >/dev/null && { + test $ac_status = 0; } > conftest.i && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then : @@ -1814,7 +1925,7 @@ ac_retval=1 fi - eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_cpp @@ -1856,16 +1967,83 @@ ac_retval=$ac_status fi rm -rf conftest.dSYM conftest_ipa8_conftest.oo - eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_run + +# ac_fn_c_check_func LINENO FUNC VAR +# ---------------------------------- +# Tests whether FUNC exists, setting the cache variable VAR accordingly +ac_fn_c_check_func () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 +$as_echo_n "checking for $2... " >&6; } +if eval \${$3+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +/* Define $2 to an innocuous variant, in case declares $2. + For example, HP-UX 11i declares gettimeofday. */ +#define $2 innocuous_$2 + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $2 (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include +#else +# include +#endif + +#undef $2 + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char $2 (); +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined __stub_$2 || defined __stub___$2 +choke me +#endif + +int +main () +{ +return $2 (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + eval "$3=yes" +else + eval "$3=no" +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + +} # ac_fn_c_check_func cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by smuxi $as_me 0.8, which was -generated by GNU Autoconf 2.65. Invocation command line was +It was created by smuxi $as_me 0.8.9.1, which was +generated by GNU Autoconf 2.68. Invocation command line was $ $0 $@ @@ -1975,11 +2153,9 @@ { echo - cat <<\_ASBOX -## ---------------- ## + $as_echo "## ---------------- ## ## Cache variables. ## -## ---------------- ## -_ASBOX +## ---------------- ##" echo # The following way of writing the cache mishandles newlines in values, ( @@ -2013,11 +2189,9 @@ ) echo - cat <<\_ASBOX -## ----------------- ## + $as_echo "## ----------------- ## ## Output variables. ## -## ----------------- ## -_ASBOX +## ----------------- ##" echo for ac_var in $ac_subst_vars do @@ -2030,11 +2204,9 @@ echo if test -n "$ac_subst_files"; then - cat <<\_ASBOX -## ------------------- ## + $as_echo "## ------------------- ## ## File substitutions. ## -## ------------------- ## -_ASBOX +## ------------------- ##" echo for ac_var in $ac_subst_files do @@ -2048,11 +2220,9 @@ fi if test -s confdefs.h; then - cat <<\_ASBOX -## ----------- ## + $as_echo "## ----------- ## ## confdefs.h. ## -## ----------- ## -_ASBOX +## ----------- ##" echo cat confdefs.h echo @@ -2107,7 +2277,12 @@ ac_site_file1=NONE ac_site_file2=NONE if test -n "$CONFIG_SITE"; then - ac_site_file1=$CONFIG_SITE + # We do not want a PATH search for config.site. + case $CONFIG_SITE in #(( + -*) ac_site_file1=./$CONFIG_SITE;; + */*) ac_site_file1=$CONFIG_SITE;; + *) ac_site_file1=./$CONFIG_SITE;; + esac elif test "x$prefix" != xNONE; then ac_site_file1=$prefix/share/config.site ac_site_file2=$prefix/etc/config.site @@ -2122,7 +2297,11 @@ { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5 $as_echo "$as_me: loading site script $ac_site_file" >&6;} sed 's/^/| /' "$ac_site_file" >&5 - . "$ac_site_file" + . "$ac_site_file" \ + || { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "failed to load site script $ac_site_file +See \`config.log' for more details" "$LINENO" 5; } fi done @@ -2199,7 +2378,7 @@ $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5 $as_echo "$as_me: error: changes in the environment can compromise the build" >&2;} - as_fn_error "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5 + as_fn_error $? "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5 fi ## -------------------- ## ## Main body of script. ## @@ -2218,16 +2397,22 @@ ac_aux_dir= for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do - for ac_t in install-sh install.sh shtool; do - if test -f "$ac_dir/$ac_t"; then - ac_aux_dir=$ac_dir - ac_install_sh="$ac_aux_dir/$ac_t -c" - break 2 - fi - done + if test -f "$ac_dir/install-sh"; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/install-sh -c" + break + elif test -f "$ac_dir/install.sh"; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/install.sh -c" + break + elif test -f "$ac_dir/shtool"; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/shtool install -c" + break + fi done if test -z "$ac_aux_dir"; then - as_fn_error "cannot find install-sh, install.sh, or shtool in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" "$LINENO" 5 + as_fn_error $? "cannot find install-sh, install.sh, or shtool in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" "$LINENO" 5 fi # These three variables are undocumented and unsupported, @@ -2256,7 +2441,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 @@ -2343,11 +2528,11 @@ ' case `pwd` in *[\\\"\#\$\&\'\`$am_lf]*) - as_fn_error "unsafe absolute working directory name" "$LINENO" 5;; + as_fn_error $? "unsafe absolute working directory name" "$LINENO" 5;; 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 @@ -2369,7 +2554,7 @@ # 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 + as_fn_error $? "ls -t appears to fail. Make sure there is not a broken alias in your environment" "$LINENO" 5 fi @@ -2379,7 +2564,7 @@ # Ok. : else - as_fn_error "newly created file is older than distributed files! + as_fn_error $? "newly created file is older than distributed files! Check your system clock" "$LINENO" 5 fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 @@ -2433,7 +2618,7 @@ 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 @@ -2473,7 +2658,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 @@ -2526,7 +2711,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 @@ -2577,7 +2762,7 @@ 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 @@ -2617,7 +2802,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 { as_var=ac_cv_prog_make_${ac_make}_set; eval "test \"\${$as_var+set}\" = set"; }; then : +if eval \${ac_cv_prog_make_${ac_make}_set+:} false; then : $as_echo_n "(cached) " >&6 else cat >conftest.make <<\_ACEOF @@ -2625,7 +2810,7 @@ all: @echo '@@@%%%=$(MAKE)=@@@%%%' _ACEOF -# GNU make sometimes prints "make[1]: Entering...", which would confuse us. +# GNU make sometimes prints "make[1]: Entering ...", which would confuse us. case `${MAKE-make} -f conftest.make 2>/dev/null` in *@@@%%%=?*=@@@%%%*) eval ac_cv_prog_make_${ac_make}_set=yes;; @@ -2659,7 +2844,7 @@ am__isrc=' -I$(srcdir)' # test to see if srcdir already configured if test -f $srcdir/config.status; then - as_fn_error "source directory already configured; run \"make distclean\" there first" "$LINENO" 5 + as_fn_error $? "source directory already configured; run \"make distclean\" there first" "$LINENO" 5 fi fi @@ -2675,7 +2860,7 @@ # Define the identity of the package. PACKAGE='smuxi' - VERSION='0.8' + VERSION='0.8.9.1' cat >>confdefs.h <<_ACEOF @@ -2783,7 +2968,7 @@ done rm -rf conftest.dir -if test "${am_cv_prog_tar_ustar+set}" = set; then : +if ${am_cv_prog_tar_ustar+:} false; then : $as_echo_n "(cached) " >&6 else am_cv_prog_tar_ustar=$_am_tool @@ -2824,7 +3009,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_PKG_CONFIG+set}" = set; then : +if ${ac_cv_path_PKG_CONFIG+:} false; then : $as_echo_n "(cached) " >&6 else case $PKG_CONFIG in @@ -2862,71 +3047,252 @@ if test "x$PKG_CONFIG" = "xno"; then - as_fn_error "You need to install pkg-config" "$LINENO" 5 + as_fn_error $? "You need to install pkg-config" "$LINENO" 5 fi -# I18N - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether NLS is requested" >&5 -$as_echo_n "checking whether NLS is requested... " >&6; } - # Check whether --enable-nls was given. -if test "${enable_nls+set}" = set; then : - enableval=$enable_nls; USE_NLS=$enableval +# Check whether --enable-static was given. +if test "${enable_static+set}" = set; then : + enableval=$enable_static; p=${PACKAGE-default} + case $enableval in + yes) enable_static=yes ;; + no) enable_static=no ;; + *) + enable_static=no + # Look at the argument we got. We use all the common list separators. + lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," + for pkg in $enableval; do + IFS="$lt_save_ifs" + if test "X$pkg" = "X$p"; then + enable_static=yes + fi + done + IFS="$lt_save_ifs" + ;; + esac else - USE_NLS=yes + enable_static=no fi - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $USE_NLS" >&5 -$as_echo "$USE_NLS" >&6; } -DEPDIR="${am__leading_dot}deps" -ac_config_commands="$ac_config_commands depfiles" -am_make=${MAKE-make} -cat > confinc << 'END' -am__doit: - @echo this is the am__doit target -.PHONY: am__doit -END -# If we don't find an include directive, just comment out the code. -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for style of include used by $am_make" >&5 -$as_echo_n "checking for style of include used by $am_make... " >&6; } -am__include="#" -am__quote= -_am_result=none -# First try GNU make style include. -echo "include confinc" > confmf -# Ignore all kinds of additional output from `make'. -case `$am_make -s -f confmf 2> /dev/null` in #( -*the\ am__doit\ target*) - am__include=include - am__quote= - _am_result=GNU - ;; -esac -# Now try BSD make style include. -if test "$am__include" = "#"; then - echo '.include "confinc"' > confmf - case `$am_make -s -f confmf 2> /dev/null` in #( - *the\ am__doit\ target*) - am__include=.include - am__quote="\"" - _am_result=BSD - ;; - esac -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $_am_result" >&5 -$as_echo "$_am_result" >&6; } -rm -f confinc confmf -# Check whether --enable-dependency-tracking was given. +case `pwd` in + *\ * | *\ *) + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Libtool does not cope well with whitespace in \`pwd\`" >&5 +$as_echo "$as_me: WARNING: Libtool does not cope well with whitespace in \`pwd\`" >&2;} ;; +esac + + + +macro_version='2.4.2' +macro_revision='1.3337' + + + + + + + + + + + + + +ltmain="$ac_aux_dir/ltmain.sh" + +# Make sure we can run config.sub. +$SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 || + as_fn_error $? "cannot run $SHELL $ac_aux_dir/config.sub" "$LINENO" 5 + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking build system type" >&5 +$as_echo_n "checking build system type... " >&6; } +if ${ac_cv_build+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_build_alias=$build_alias +test "x$ac_build_alias" = x && + ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"` +test "x$ac_build_alias" = x && + as_fn_error $? "cannot guess build type; you must specify one" "$LINENO" 5 +ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` || + as_fn_error $? "$SHELL $ac_aux_dir/config.sub $ac_build_alias failed" "$LINENO" 5 + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_build" >&5 +$as_echo "$ac_cv_build" >&6; } +case $ac_cv_build in +*-*-*) ;; +*) as_fn_error $? "invalid value of canonical build" "$LINENO" 5;; +esac +build=$ac_cv_build +ac_save_IFS=$IFS; IFS='-' +set x $ac_cv_build +shift +build_cpu=$1 +build_vendor=$2 +shift; shift +# Remember, the first character of IFS is used to create $*, +# except with old shells: +build_os=$* +IFS=$ac_save_IFS +case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking host system type" >&5 +$as_echo_n "checking host system type... " >&6; } +if ${ac_cv_host+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test "x$host_alias" = x; then + ac_cv_host=$ac_cv_build +else + ac_cv_host=`$SHELL "$ac_aux_dir/config.sub" $host_alias` || + as_fn_error $? "$SHELL $ac_aux_dir/config.sub $host_alias failed" "$LINENO" 5 +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_host" >&5 +$as_echo "$ac_cv_host" >&6; } +case $ac_cv_host in +*-*-*) ;; +*) as_fn_error $? "invalid value of canonical host" "$LINENO" 5;; +esac +host=$ac_cv_host +ac_save_IFS=$IFS; IFS='-' +set x $ac_cv_host +shift +host_cpu=$1 +host_vendor=$2 +shift; shift +# Remember, the first character of IFS is used to create $*, +# except with old shells: +host_os=$* +IFS=$ac_save_IFS +case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac + + +# Backslashify metacharacters that are still active within +# double-quoted strings. +sed_quote_subst='s/\(["`$\\]\)/\\\1/g' + +# Same as above, but do not quote variable references. +double_quote_subst='s/\(["`\\]\)/\\\1/g' + +# Sed substitution to delay expansion of an escaped shell variable in a +# double_quote_subst'ed string. +delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g' + +# Sed substitution to delay expansion of an escaped single quote. +delay_single_quote_subst='s/'\''/'\'\\\\\\\'\''/g' + +# Sed substitution to avoid accidental globbing in evaled expressions +no_glob_subst='s/\*/\\\*/g' + +ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' +ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO +ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO$ECHO + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to print strings" >&5 +$as_echo_n "checking how to print strings... " >&6; } +# Test print first, because it will be a builtin if present. +if test "X`( print -r -- -n ) 2>/dev/null`" = X-n && \ + test "X`print -r -- $ECHO 2>/dev/null`" = "X$ECHO"; then + ECHO='print -r --' +elif test "X`printf %s $ECHO 2>/dev/null`" = "X$ECHO"; then + ECHO='printf %s\n' +else + # Use this function as a fallback that always works. + func_fallback_echo () + { + eval 'cat <<_LTECHO_EOF +$1 +_LTECHO_EOF' + } + ECHO='func_fallback_echo' +fi + +# func_echo_all arg... +# Invoke $ECHO with all args, space-separated. +func_echo_all () +{ + $ECHO "" +} + +case "$ECHO" in + printf*) { $as_echo "$as_me:${as_lineno-$LINENO}: result: printf" >&5 +$as_echo "printf" >&6; } ;; + print*) { $as_echo "$as_me:${as_lineno-$LINENO}: result: print -r" >&5 +$as_echo "print -r" >&6; } ;; + *) { $as_echo "$as_me:${as_lineno-$LINENO}: result: cat" >&5 +$as_echo "cat" >&6; } ;; +esac + + + + + + + + + + + + + + +DEPDIR="${am__leading_dot}deps" + +ac_config_commands="$ac_config_commands depfiles" + + +am_make=${MAKE-make} +cat > confinc << 'END' +am__doit: + @echo this is the am__doit target +.PHONY: am__doit +END +# If we don't find an include directive, just comment out the code. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for style of include used by $am_make" >&5 +$as_echo_n "checking for style of include used by $am_make... " >&6; } +am__include="#" +am__quote= +_am_result=none +# First try GNU make style include. +echo "include confinc" > confmf +# Ignore all kinds of additional output from `make'. +case `$am_make -s -f confmf 2> /dev/null` in #( +*the\ am__doit\ target*) + am__include=include + am__quote= + _am_result=GNU + ;; +esac +# Now try BSD make style include. +if test "$am__include" = "#"; then + echo '.include "confinc"' > confmf + case `$am_make -s -f confmf 2> /dev/null` in #( + *the\ am__doit\ target*) + am__include=.include + am__quote="\"" + _am_result=BSD + ;; + esac +fi + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $_am_result" >&5 +$as_echo "$_am_result" >&6; } +rm -f confinc confmf + +# Check whether --enable-dependency-tracking was given. if test "${enable_dependency_tracking+set}" = set; then : enableval=$enable_dependency_tracking; fi @@ -2954,7 +3320,7 @@ set dummy ${ac_tool_prefix}gcc; 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_CC+set}" = set; then : +if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then @@ -2994,7 +3360,7 @@ set dummy gcc; 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_CC+set}" = set; then : +if ${ac_cv_prog_ac_ct_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then @@ -3047,7 +3413,7 @@ set dummy ${ac_tool_prefix}cc; 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_CC+set}" = set; then : +if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then @@ -3087,7 +3453,7 @@ set dummy cc; 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_CC+set}" = set; then : +if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then @@ -3146,7 +3512,7 @@ set dummy $ac_tool_prefix$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_CC+set}" = set; then : +if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then @@ -3190,7 +3556,7 @@ 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_ac_ct_CC+set}" = set; then : +if ${ac_cv_prog_ac_ct_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then @@ -3244,8 +3610,8 @@ test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error "no acceptable C compiler found in \$PATH -See \`config.log' for more details." "$LINENO" 5; } +as_fn_error $? "no acceptable C compiler found in \$PATH +See \`config.log' for more details" "$LINENO" 5; } # Provide some information about the compiler. $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 @@ -3359,9 +3725,8 @@ { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -{ as_fn_set_status 77 -as_fn_error "C compiler cannot create executables -See \`config.log' for more details." "$LINENO" 5; }; } +as_fn_error 77 "C compiler cannot create executables +See \`config.log' for more details" "$LINENO" 5; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } @@ -3403,8 +3768,8 @@ else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error "cannot compute suffix of executables: cannot compile and link -See \`config.log' for more details." "$LINENO" 5; } +as_fn_error $? "cannot compute suffix of executables: cannot compile and link +See \`config.log' for more details" "$LINENO" 5; } fi rm -f conftest conftest$ac_cv_exeext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5 @@ -3461,9 +3826,9 @@ else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error "cannot run C compiled programs. +as_fn_error $? "cannot run C compiled programs. If you meant to cross compile, use \`--host'. -See \`config.log' for more details." "$LINENO" 5; } +See \`config.log' for more details" "$LINENO" 5; } fi fi fi @@ -3474,7 +3839,7 @@ ac_clean_files=$ac_clean_files_save { $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5 $as_echo_n "checking for suffix of object files... " >&6; } -if test "${ac_cv_objext+set}" = set; then : +if ${ac_cv_objext+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -3514,8 +3879,8 @@ { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error "cannot compute suffix of object files: cannot compile -See \`config.log' for more details." "$LINENO" 5; } +as_fn_error $? "cannot compute suffix of object files: cannot compile +See \`config.log' for more details" "$LINENO" 5; } fi rm -f conftest.$ac_cv_objext conftest.$ac_ext fi @@ -3525,7 +3890,7 @@ ac_objext=$OBJEXT { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5 $as_echo_n "checking whether we are using the GNU C compiler... " >&6; } -if test "${ac_cv_c_compiler_gnu+set}" = set; then : +if ${ac_cv_c_compiler_gnu+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -3562,7 +3927,7 @@ ac_save_CFLAGS=$CFLAGS { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 $as_echo_n "checking whether $CC accepts -g... " >&6; } -if test "${ac_cv_prog_cc_g+set}" = set; then : +if ${ac_cv_prog_cc_g+:} false; then : $as_echo_n "(cached) " >&6 else ac_save_c_werror_flag=$ac_c_werror_flag @@ -3640,7 +4005,7 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 $as_echo_n "checking for $CC option to accept ISO C89... " >&6; } -if test "${ac_cv_prog_cc_c89+set}" = set; then : +if ${ac_cv_prog_cc_c89+:} false; then : $as_echo_n "(cached) " >&6 else ac_cv_prog_cc_c89=no @@ -3739,7 +4104,7 @@ { $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5 $as_echo_n "checking dependency style of $depcc... " >&6; } -if test "${am_cv_CC_dependencies_compiler_type+set}" = set; then : +if ${am_cv_CC_dependencies_compiler_type+:} false; then : $as_echo_n "(cached) " >&6 else if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then @@ -3862,193 +4227,286 @@ fi - - - -case "$am__api_version" in - 1.01234) - as_fn_error "Automake 1.5 or newer is required to use intltool" "$LINENO" 5 - ;; - *) - ;; -esac - -if test -n "0.25"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for intltool >= 0.25" >&5 -$as_echo_n "checking for intltool >= 0.25... " >&6; } - - INTLTOOL_REQUIRED_VERSION_AS_INT=`echo 0.25 | awk -F. '{ print $ 1 * 1000 + $ 2 * 100 + $ 3; }'` - INTLTOOL_APPLIED_VERSION=`intltool-update --version | head -1 | cut -d" " -f3` - INTLTOOL_APPLIED_VERSION_AS_INT=`echo $INTLTOOL_APPLIED_VERSION | awk -F. '{ print $ 1 * 1000 + $ 2 * 100 + $ 3; }'` - - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $INTLTOOL_APPLIED_VERSION found" >&5 -$as_echo "$INTLTOOL_APPLIED_VERSION found" >&6; } - test "$INTLTOOL_APPLIED_VERSION_AS_INT" -ge "$INTLTOOL_REQUIRED_VERSION_AS_INT" || - as_fn_error "Your intltool is too old. You need intltool 0.25 or later." "$LINENO" 5 -fi - -# Extract the first word of "intltool-update", so it can be a program name with args. -set dummy intltool-update; 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_INTLTOOL_UPDATE+set}" = set; then : +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a sed that does not truncate output" >&5 +$as_echo_n "checking for a sed that does not truncate output... " >&6; } +if ${ac_cv_path_SED+:} false; then : $as_echo_n "(cached) " >&6 else - case $INTLTOOL_UPDATE in - [\\/]* | ?:[\\/]*) - ac_cv_path_INTLTOOL_UPDATE="$INTLTOOL_UPDATE" # Let the user override the test with a path. - ;; - *) + ac_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/ + for ac_i in 1 2 3 4 5 6 7; do + ac_script="$ac_script$as_nl$ac_script" + done + echo "$ac_script" 2>/dev/null | sed 99q >conftest.sed + { ac_script=; unset ac_script;} + if test -z "$SED"; then + ac_path_SED_found=false + # Loop through the user's path and test for each of PROGNAME-LIST 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_prog in sed gsed; do 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 - ac_cv_path_INTLTOOL_UPDATE="$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 + ac_path_SED="$as_dir/$ac_prog$ac_exec_ext" + { test -f "$ac_path_SED" && $as_test_x "$ac_path_SED"; } || continue +# Check for GNU ac_path_SED and select it if it is found. + # Check for GNU $ac_path_SED +case `"$ac_path_SED" --version 2>&1` in +*GNU*) + ac_cv_path_SED="$ac_path_SED" ac_path_SED_found=:;; +*) + ac_count=0 + $as_echo_n 0123456789 >"conftest.in" + while : + do + cat "conftest.in" "conftest.in" >"conftest.tmp" + mv "conftest.tmp" "conftest.in" + cp "conftest.in" "conftest.nl" + $as_echo '' >> "conftest.nl" + "$ac_path_SED" -f conftest.sed < "conftest.nl" >"conftest.out" 2>/dev/null || break + diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break + as_fn_arith $ac_count + 1 && ac_count=$as_val + if test $ac_count -gt ${ac_path_SED_max-0}; then + # Best one so far, save it but keep looking for a better one + ac_cv_path_SED="$ac_path_SED" + ac_path_SED_max=$ac_count + fi + # 10*(2^10) chars as input seems more than enough + test $ac_count -gt 10 && break done -IFS=$as_save_IFS - - ;; + rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac -fi -INTLTOOL_UPDATE=$ac_cv_path_INTLTOOL_UPDATE -if test -n "$INTLTOOL_UPDATE"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $INTLTOOL_UPDATE" >&5 -$as_echo "$INTLTOOL_UPDATE" >&6; } + + $ac_path_SED_found && break 3 + done + done + done +IFS=$as_save_IFS + if test -z "$ac_cv_path_SED"; then + as_fn_error $? "no acceptable sed could be found in \$PATH" "$LINENO" 5 + fi else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } + ac_cv_path_SED=$SED fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_SED" >&5 +$as_echo "$ac_cv_path_SED" >&6; } + SED="$ac_cv_path_SED" + rm -f conftest.sed -# Extract the first word of "intltool-merge", so it can be a program name with args. -set dummy intltool-merge; 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_INTLTOOL_MERGE+set}" = set; then : +test -z "$SED" && SED=sed +Xsed="$SED -e 1s/^X//" + + + + + + + + + + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5 +$as_echo_n "checking for grep that handles long lines and -e... " >&6; } +if ${ac_cv_path_GREP+:} false; then : $as_echo_n "(cached) " >&6 else - case $INTLTOOL_MERGE in - [\\/]* | ?:[\\/]*) - ac_cv_path_INTLTOOL_MERGE="$INTLTOOL_MERGE" # Let the user override the test with a path. - ;; - *) + if test -z "$GREP"; then + ac_path_GREP_found=false + # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH +for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. + for ac_prog in grep ggrep; do 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 - ac_cv_path_INTLTOOL_MERGE="$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 + ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" + { test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue +# Check for GNU ac_path_GREP and select it if it is found. + # Check for GNU $ac_path_GREP +case `"$ac_path_GREP" --version 2>&1` in +*GNU*) + ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;; +*) + ac_count=0 + $as_echo_n 0123456789 >"conftest.in" + while : + do + cat "conftest.in" "conftest.in" >"conftest.tmp" + mv "conftest.tmp" "conftest.in" + cp "conftest.in" "conftest.nl" + $as_echo 'GREP' >> "conftest.nl" + "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break + diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break + as_fn_arith $ac_count + 1 && ac_count=$as_val + if test $ac_count -gt ${ac_path_GREP_max-0}; then + # Best one so far, save it but keep looking for a better one + ac_cv_path_GREP="$ac_path_GREP" + ac_path_GREP_max=$ac_count + fi + # 10*(2^10) chars as input seems more than enough + test $ac_count -gt 10 && break done -IFS=$as_save_IFS - - ;; + rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac -fi -INTLTOOL_MERGE=$ac_cv_path_INTLTOOL_MERGE -if test -n "$INTLTOOL_MERGE"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $INTLTOOL_MERGE" >&5 -$as_echo "$INTLTOOL_MERGE" >&6; } + + $ac_path_GREP_found && break 3 + done + done + done +IFS=$as_save_IFS + if test -z "$ac_cv_path_GREP"; then + as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 + fi else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } + ac_cv_path_GREP=$GREP +fi + fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5 +$as_echo "$ac_cv_path_GREP" >&6; } + GREP="$ac_cv_path_GREP" -# Extract the first word of "intltool-extract", so it can be a program name with args. -set dummy intltool-extract; 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_INTLTOOL_EXTRACT+set}" = set; then : +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5 +$as_echo_n "checking for egrep... " >&6; } +if ${ac_cv_path_EGREP+:} false; then : $as_echo_n "(cached) " >&6 else - case $INTLTOOL_EXTRACT in - [\\/]* | ?:[\\/]*) - ac_cv_path_INTLTOOL_EXTRACT="$INTLTOOL_EXTRACT" # Let the user override the test with a path. - ;; - *) + if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 + then ac_cv_path_EGREP="$GREP -E" + else + if test -z "$EGREP"; then + ac_path_EGREP_found=false + # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH +for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. + for ac_prog in egrep; do 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 - ac_cv_path_INTLTOOL_EXTRACT="$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 + ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" + { test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue +# Check for GNU ac_path_EGREP and select it if it is found. + # Check for GNU $ac_path_EGREP +case `"$ac_path_EGREP" --version 2>&1` in +*GNU*) + ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;; +*) + ac_count=0 + $as_echo_n 0123456789 >"conftest.in" + while : + do + cat "conftest.in" "conftest.in" >"conftest.tmp" + mv "conftest.tmp" "conftest.in" + cp "conftest.in" "conftest.nl" + $as_echo 'EGREP' >> "conftest.nl" + "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break + diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break + as_fn_arith $ac_count + 1 && ac_count=$as_val + if test $ac_count -gt ${ac_path_EGREP_max-0}; then + # Best one so far, save it but keep looking for a better one + ac_cv_path_EGREP="$ac_path_EGREP" + ac_path_EGREP_max=$ac_count + fi + # 10*(2^10) chars as input seems more than enough + test $ac_count -gt 10 && break done -IFS=$as_save_IFS - - ;; + rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac -fi -INTLTOOL_EXTRACT=$ac_cv_path_INTLTOOL_EXTRACT -if test -n "$INTLTOOL_EXTRACT"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $INTLTOOL_EXTRACT" >&5 -$as_echo "$INTLTOOL_EXTRACT" >&6; } + + $ac_path_EGREP_found && break 3 + done + done + done +IFS=$as_save_IFS + if test -z "$ac_cv_path_EGREP"; then + as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 + fi else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } + ac_cv_path_EGREP=$EGREP fi - -if test -z "$INTLTOOL_UPDATE" -o -z "$INTLTOOL_MERGE" -o -z "$INTLTOOL_EXTRACT"; then - as_fn_error "The intltool scripts were not found. Please install intltool." "$LINENO" 5 + fi fi - - INTLTOOL_DESKTOP_RULE='%.desktop: %.desktop.in $(INTLTOOL_MERGE) $(wildcard $(top_srcdir)/po/*.po) ; LC_ALL=C $(INTLTOOL_MERGE) -d -u -c $(top_builddir)/po/.intltool-merge-cache $(top_srcdir)/po $< $@' -INTLTOOL_DIRECTORY_RULE='%.directory: %.directory.in $(INTLTOOL_MERGE) $(wildcard $(top_srcdir)/po/*.po) ; LC_ALL=C $(INTLTOOL_MERGE) -d -u -c $(top_builddir)/po/.intltool-merge-cache $(top_srcdir)/po $< $@' - INTLTOOL_KEYS_RULE='%.keys: %.keys.in $(INTLTOOL_MERGE) $(wildcard $(top_srcdir)/po/*.po) ; LC_ALL=C $(INTLTOOL_MERGE) -k -u -c $(top_builddir)/po/.intltool-merge-cache $(top_srcdir)/po $< $@' - INTLTOOL_PROP_RULE='%.prop: %.prop.in $(INTLTOOL_MERGE) $(wildcard $(top_srcdir)/po/*.po) ; LC_ALL=C $(INTLTOOL_MERGE) -d -u -c $(top_builddir)/po/.intltool-merge-cache $(top_srcdir)/po $< $@' - INTLTOOL_OAF_RULE='%.oaf: %.oaf.in $(INTLTOOL_MERGE) $(wildcard $(top_srcdir)/po/*.po) ; LC_ALL=C $(INTLTOOL_MERGE) -o -p $(top_srcdir)/po $< $@' - INTLTOOL_PONG_RULE='%.pong: %.pong.in $(INTLTOOL_MERGE) $(wildcard $(top_srcdir)/po/*.po) ; LC_ALL=C $(INTLTOOL_MERGE) -x -u -c $(top_builddir)/po/.intltool-merge-cache $(top_srcdir)/po $< $@' - INTLTOOL_SERVER_RULE='%.server: %.server.in $(INTLTOOL_MERGE) $(wildcard $(top_srcdir)/po/*.po) ; LC_ALL=C $(INTLTOOL_MERGE) -o -u -c $(top_builddir)/po/.intltool-merge-cache $(top_srcdir)/po $< $@' - INTLTOOL_SHEET_RULE='%.sheet: %.sheet.in $(INTLTOOL_MERGE) $(wildcard $(top_srcdir)/po/*.po) ; LC_ALL=C $(INTLTOOL_MERGE) -x -u -c $(top_builddir)/po/.intltool-merge-cache $(top_srcdir)/po $< $@' -INTLTOOL_SOUNDLIST_RULE='%.soundlist: %.soundlist.in $(INTLTOOL_MERGE) $(wildcard $(top_srcdir)/po/*.po) ; LC_ALL=C $(INTLTOOL_MERGE) -d -u -c $(top_builddir)/po/.intltool-merge-cache $(top_srcdir)/po $< $@' - INTLTOOL_UI_RULE='%.ui: %.ui.in $(INTLTOOL_MERGE) $(wildcard $(top_srcdir)/po/*.po) ; LC_ALL=C $(INTLTOOL_MERGE) -x -u -c $(top_builddir)/po/.intltool-merge-cache $(top_srcdir)/po $< $@' - INTLTOOL_XML_RULE='%.xml: %.xml.in $(INTLTOOL_MERGE) $(wildcard $(top_srcdir)/po/*.po) ; LC_ALL=C $(INTLTOOL_MERGE) -x -u -c $(top_builddir)/po/.intltool-merge-cache $(top_srcdir)/po $< $@' - INTLTOOL_XML_NOMERGE_RULE='%.xml: %.xml.in $(INTLTOOL_MERGE) ; LC_ALL=C $(INTLTOOL_MERGE) -x -u /tmp $< $@' - INTLTOOL_XAM_RULE='%.xam: %.xml.in $(INTLTOOL_MERGE) $(wildcard $(top_srcdir)/po/*.po) ; LC_ALL=C $(INTLTOOL_MERGE) -x -u -c $(top_builddir)/po/.intltool-merge-cache $(top_srcdir)/po $< $@' - INTLTOOL_KBD_RULE='%.kbd: %.kbd.in $(INTLTOOL_MERGE) $(wildcard $(top_srcdir)/po/*.po) ; LC_ALL=C $(INTLTOOL_MERGE) -x -u -m -c $(top_builddir)/po/.intltool-merge-cache $(top_srcdir)/po $< $@' - INTLTOOL_CAVES_RULE='%.caves: %.caves.in $(INTLTOOL_MERGE) $(wildcard $(top_srcdir)/po/*.po) ; LC_ALL=C $(INTLTOOL_MERGE) -d -u -c $(top_builddir)/po/.intltool-merge-cache $(top_srcdir)/po $< $@' - INTLTOOL_SCHEMAS_RULE='%.schemas: %.schemas.in $(INTLTOOL_MERGE) $(wildcard $(top_srcdir)/po/*.po) ; LC_ALL=C $(INTLTOOL_MERGE) -s -u -c $(top_builddir)/po/.intltool-merge-cache $(top_srcdir)/po $< $@' - INTLTOOL_THEME_RULE='%.theme: %.theme.in $(INTLTOOL_MERGE) $(wildcard $(top_srcdir)/po/*.po) ; LC_ALL=C $(INTLTOOL_MERGE) -d -u -c $(top_builddir)/po/.intltool-merge-cache $(top_srcdir)/po $< $@' - INTLTOOL_SERVICE_RULE='%.service: %.service.in $(INTLTOOL_MERGE) $(wildcard $(top_srcdir)/po/*.po) ; LC_ALL=C $(INTLTOOL_MERGE) -d -u -c $(top_builddir)/po/.intltool-merge-cache $(top_srcdir)/po $< $@' - INTLTOOL_POLICY_RULE='%.policy: %.policy.in $(INTLTOOL_MERGE) $(wildcard $(top_srcdir)/po/*.po) ; LC_ALL=C $(INTLTOOL_MERGE) -x -u -c $(top_builddir)/po/.intltool-merge-cache $(top_srcdir)/po $< $@' - - - - - - - - - - - - - +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5 +$as_echo "$ac_cv_path_EGREP" >&6; } + EGREP="$ac_cv_path_EGREP" +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for fgrep" >&5 +$as_echo_n "checking for fgrep... " >&6; } +if ${ac_cv_path_FGREP+:} false; then : + $as_echo_n "(cached) " >&6 +else + if echo 'ab*c' | $GREP -F 'ab*c' >/dev/null 2>&1 + then ac_cv_path_FGREP="$GREP -F" + else + if test -z "$FGREP"; then + ac_path_FGREP_found=false + # Loop through the user's path and test for each of PROGNAME-LIST + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_prog in fgrep; do + for ac_exec_ext in '' $ac_executable_extensions; do + ac_path_FGREP="$as_dir/$ac_prog$ac_exec_ext" + { test -f "$ac_path_FGREP" && $as_test_x "$ac_path_FGREP"; } || continue +# Check for GNU ac_path_FGREP and select it if it is found. + # Check for GNU $ac_path_FGREP +case `"$ac_path_FGREP" --version 2>&1` in +*GNU*) + ac_cv_path_FGREP="$ac_path_FGREP" ac_path_FGREP_found=:;; +*) + ac_count=0 + $as_echo_n 0123456789 >"conftest.in" + while : + do + cat "conftest.in" "conftest.in" >"conftest.tmp" + mv "conftest.tmp" "conftest.in" + cp "conftest.in" "conftest.nl" + $as_echo 'FGREP' >> "conftest.nl" + "$ac_path_FGREP" FGREP < "conftest.nl" >"conftest.out" 2>/dev/null || break + diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break + as_fn_arith $ac_count + 1 && ac_count=$as_val + if test $ac_count -gt ${ac_path_FGREP_max-0}; then + # Best one so far, save it but keep looking for a better one + ac_cv_path_FGREP="$ac_path_FGREP" + ac_path_FGREP_max=$ac_count + fi + # 10*(2^10) chars as input seems more than enough + test $ac_count -gt 10 && break + done + rm -f conftest.in conftest.tmp conftest.nl conftest.out;; +esac + $ac_path_FGREP_found && break 3 + done + done + done +IFS=$as_save_IFS + if test -z "$ac_cv_path_FGREP"; then + as_fn_error $? "no acceptable fgrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 + fi +else + ac_cv_path_FGREP=$FGREP +fi + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_FGREP" >&5 +$as_echo "$ac_cv_path_FGREP" >&6; } + FGREP="$ac_cv_path_FGREP" +test -z "$GREP" && GREP=grep @@ -4068,33 +4526,524 @@ +# Check whether --with-gnu-ld was given. +if test "${with_gnu_ld+set}" = set; then : + withval=$with_gnu_ld; test "$withval" = no || with_gnu_ld=yes +else + with_gnu_ld=no +fi +ac_prog=ld +if test "$GCC" = yes; then + # Check if gcc -print-prog-name=ld gives a path. + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ld used by $CC" >&5 +$as_echo_n "checking for ld used by $CC... " >&6; } + case $host in + *-*-mingw*) + # gcc leaves a trailing carriage return which upsets mingw + ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; + *) + ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; + esac + case $ac_prog in + # Accept absolute paths. + [\\/]* | ?:[\\/]*) + re_direlt='/[^/][^/]*/\.\./' + # Canonicalize the pathname of ld + ac_prog=`$ECHO "$ac_prog"| $SED 's%\\\\%/%g'` + while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do + ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"` + done + test -z "$LD" && LD="$ac_prog" + ;; + "") + # If it fails, then pretend we aren't using GCC. + ac_prog=ld + ;; + *) + # If it is relative, then search for the first ld in PATH. + with_gnu_ld=unknown + ;; + esac +elif test "$with_gnu_ld" = yes; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU ld" >&5 +$as_echo_n "checking for GNU ld... " >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for non-GNU ld" >&5 +$as_echo_n "checking for non-GNU ld... " >&6; } +fi +if ${lt_cv_path_LD+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -z "$LD"; then + lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR + for ac_dir in $PATH; do + IFS="$lt_save_ifs" + test -z "$ac_dir" && ac_dir=. + if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then + lt_cv_path_LD="$ac_dir/$ac_prog" + # Check to see if the program is GNU ld. I'd rather use --version, + # but apparently some variants of GNU ld only accept -v. + # Break only if it was the GNU/non-GNU ld that we prefer. + case `"$lt_cv_path_LD" -v 2>&1 &5 +$as_echo "$LD" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi +test -z "$LD" && as_fn_error $? "no acceptable ld found in \$PATH" "$LINENO" 5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if the linker ($LD) is GNU ld" >&5 +$as_echo_n "checking if the linker ($LD) is GNU ld... " >&6; } +if ${lt_cv_prog_gnu_ld+:} false; then : + $as_echo_n "(cached) " >&6 +else + # I'd rather use --version here, but apparently some GNU lds only accept -v. +case `$LD -v 2>&1 &5 +$as_echo "$lt_cv_prog_gnu_ld" >&6; } +with_gnu_ld=$lt_cv_prog_gnu_ld + + + + + + + + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for BSD- or MS-compatible name lister (nm)" >&5 +$as_echo_n "checking for BSD- or MS-compatible name lister (nm)... " >&6; } +if ${lt_cv_path_NM+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$NM"; then + # Let the user override the test. + lt_cv_path_NM="$NM" +else + lt_nm_to_check="${ac_tool_prefix}nm" + if test -n "$ac_tool_prefix" && test "$build" = "$host"; then + lt_nm_to_check="$lt_nm_to_check nm" + fi + for lt_tmp_nm in $lt_nm_to_check; do + lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR + for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do + IFS="$lt_save_ifs" + test -z "$ac_dir" && ac_dir=. + tmp_nm="$ac_dir/$lt_tmp_nm" + if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then + # Check to see if the nm accepts a BSD-compat flag. + # Adding the `sed 1q' prevents false positives on HP-UX, which says: + # nm: unknown option "B" ignored + # Tru64's nm complains that /dev/null is an invalid object file + case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in + */dev/null* | *'Invalid file or object type'*) + lt_cv_path_NM="$tmp_nm -B" + break + ;; + *) + case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in + */dev/null*) + lt_cv_path_NM="$tmp_nm -p" + break + ;; + *) + lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but + continue # so that we can try to find one that supports BSD flags + ;; + esac + ;; + esac + fi + done + IFS="$lt_save_ifs" + done + : ${lt_cv_path_NM=no} +fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_path_NM" >&5 +$as_echo "$lt_cv_path_NM" >&6; } +if test "$lt_cv_path_NM" != "no"; then + NM="$lt_cv_path_NM" +else + # Didn't find any BSD compatible name lister, look for dumpbin. + if test -n "$DUMPBIN"; then : + # Let the user override the test. + else + if test -n "$ac_tool_prefix"; then + for ac_prog in dumpbin "link -dump" + do + # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. +set dummy $ac_tool_prefix$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 ${ac_cv_prog_DUMPBIN+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$DUMPBIN"; then + ac_cv_prog_DUMPBIN="$DUMPBIN" # Let the user override the test. +else +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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_DUMPBIN="$ac_tool_prefix$ac_prog" + $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 + +fi +fi +DUMPBIN=$ac_cv_prog_DUMPBIN +if test -n "$DUMPBIN"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DUMPBIN" >&5 +$as_echo "$DUMPBIN" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$DUMPBIN" && break + done +fi +if test -z "$DUMPBIN"; then + ac_ct_DUMPBIN=$DUMPBIN + for ac_prog in dumpbin "link -dump" +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 ${ac_cv_prog_ac_ct_DUMPBIN+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_DUMPBIN"; then + ac_cv_prog_ac_ct_DUMPBIN="$ac_ct_DUMPBIN" # Let the user override the test. +else +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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_ac_ct_DUMPBIN="$ac_prog" + $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 + +fi +fi +ac_ct_DUMPBIN=$ac_cv_prog_ac_ct_DUMPBIN +if test -n "$ac_ct_DUMPBIN"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DUMPBIN" >&5 +$as_echo "$ac_ct_DUMPBIN" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$ac_ct_DUMPBIN" && break +done + + if test "x$ac_ct_DUMPBIN" = x; then + DUMPBIN=":" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + DUMPBIN=$ac_ct_DUMPBIN + fi +fi + + case `$DUMPBIN -symbols /dev/null 2>&1 | sed '1q'` in + *COFF*) + DUMPBIN="$DUMPBIN -symbols" + ;; + *) + DUMPBIN=: + ;; + esac + fi + + if test "$DUMPBIN" != ":"; then + NM="$DUMPBIN" + fi +fi +test -z "$NM" && NM=nm + + + + + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking the name lister ($NM) interface" >&5 +$as_echo_n "checking the name lister ($NM) interface... " >&6; } +if ${lt_cv_nm_interface+:} false; then : + $as_echo_n "(cached) " >&6 +else + lt_cv_nm_interface="BSD nm" + echo "int some_variable = 0;" > conftest.$ac_ext + (eval echo "\"\$as_me:$LINENO: $ac_compile\"" >&5) + (eval "$ac_compile" 2>conftest.err) + cat conftest.err >&5 + (eval echo "\"\$as_me:$LINENO: $NM \\\"conftest.$ac_objext\\\"\"" >&5) + (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out) + cat conftest.err >&5 + (eval echo "\"\$as_me:$LINENO: output\"" >&5) + cat conftest.out >&5 + if $GREP 'External.*some_variable' conftest.out > /dev/null; then + lt_cv_nm_interface="MS dumpbin" + fi + rm -f conftest* +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_nm_interface" >&5 +$as_echo "$lt_cv_nm_interface" >&6; } + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ln -s works" >&5 +$as_echo_n "checking whether ln -s works... " >&6; } +LN_S=$as_ln_s +if test "$LN_S" = "ln -s"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no, using $LN_S" >&5 +$as_echo "no, using $LN_S" >&6; } +fi + +# find the maximum length of command line arguments +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking the maximum length of command line arguments" >&5 +$as_echo_n "checking the maximum length of command line arguments... " >&6; } +if ${lt_cv_sys_max_cmd_len+:} false; then : + $as_echo_n "(cached) " >&6 +else + i=0 + teststring="ABCD" + + case $build_os in + msdosdjgpp*) + # On DJGPP, this test can blow up pretty badly due to problems in libc + # (any single argument exceeding 2000 bytes causes a buffer overrun + # during glob expansion). Even if it were fixed, the result of this + # check would be larger than it should be. + lt_cv_sys_max_cmd_len=12288; # 12K is about right + ;; + + gnu*) + # Under GNU Hurd, this test is not required because there is + # no limit to the length of command line arguments. + # Libtool will interpret -1 as no limit whatsoever + lt_cv_sys_max_cmd_len=-1; + ;; + cygwin* | mingw* | cegcc*) + # On Win9x/ME, this test blows up -- it succeeds, but takes + # about 5 minutes as the teststring grows exponentially. + # Worse, since 9x/ME are not pre-emptively multitasking, + # you end up with a "frozen" computer, even though with patience + # the test eventually succeeds (with a max line length of 256k). + # Instead, let's just punt: use the minimum linelength reported by + # all of the supported platforms: 8192 (on NT/2K/XP). + lt_cv_sys_max_cmd_len=8192; + ;; + mint*) + # On MiNT this can take a long time and run out of memory. + lt_cv_sys_max_cmd_len=8192; + ;; + amigaos*) + # On AmigaOS with pdksh, this test takes hours, literally. + # So we just punt and use a minimum line length of 8192. + lt_cv_sys_max_cmd_len=8192; + ;; + netbsd* | freebsd* | openbsd* | darwin* | dragonfly*) + # This has been around since 386BSD, at least. Likely further. + if test -x /sbin/sysctl; then + lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax` + elif test -x /usr/sbin/sysctl; then + lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax` + else + lt_cv_sys_max_cmd_len=65536 # usable default for all BSDs + fi + # And add a safety zone + lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` + lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` + ;; + interix*) + # We know the value 262144 and hardcode it with a safety zone (like BSD) + lt_cv_sys_max_cmd_len=196608 + ;; + os2*) + # The test takes a long time on OS/2. + lt_cv_sys_max_cmd_len=8192 + ;; + osf*) + # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure + # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not + # nice to cause kernel panics so lets avoid the loop below. + # First set a reasonable default. + lt_cv_sys_max_cmd_len=16384 + # + if test -x /sbin/sysconfig; then + case `/sbin/sysconfig -q proc exec_disable_arg_limit` in + *1*) lt_cv_sys_max_cmd_len=-1 ;; + esac + fi + ;; + sco3.2v5*) + lt_cv_sys_max_cmd_len=102400 + ;; + sysv5* | sco5v6* | sysv4.2uw2*) + kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null` + if test -n "$kargmax"; then + lt_cv_sys_max_cmd_len=`echo $kargmax | sed 's/.*[ ]//'` + else + lt_cv_sys_max_cmd_len=32768 + fi + ;; + *) + lt_cv_sys_max_cmd_len=`(getconf ARG_MAX) 2> /dev/null` + if test -n "$lt_cv_sys_max_cmd_len"; then + lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` + lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` + else + # Make teststring a little bigger before we do anything with it. + # a 1K string should be a reasonable start. + for i in 1 2 3 4 5 6 7 8 ; do + teststring=$teststring$teststring + done + SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}} + # If test is not a shell built-in, we'll probably end up computing a + # maximum length that is only half of the actual maximum length, but + # we can't tell. + while { test "X"`env echo "$teststring$teststring" 2>/dev/null` \ + = "X$teststring$teststring"; } >/dev/null 2>&1 && + test $i != 17 # 1/2 MB should be enough + do + i=`expr $i + 1` + teststring=$teststring$teststring + done + # Only check the string length outside the loop. + lt_cv_sys_max_cmd_len=`expr "X$teststring" : ".*" 2>&1` + teststring= + # Add a significant safety factor because C++ compilers can tack on + # massive amounts of additional arguments before passing them to the + # linker. It appears as though 1/2 is a usable value. + lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2` + fi + ;; + esac +fi +if test -n $lt_cv_sys_max_cmd_len ; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_sys_max_cmd_len" >&5 +$as_echo "$lt_cv_sys_max_cmd_len" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: none" >&5 +$as_echo "none" >&6; } +fi +max_cmd_len=$lt_cv_sys_max_cmd_len +: ${CP="cp -f"} +: ${MV="mv -f"} +: ${RM="rm -f"} +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the shell understands some XSI constructs" >&5 +$as_echo_n "checking whether the shell understands some XSI constructs... " >&6; } +# Try some XSI features +xsi_shell=no +( _lt_dummy="a/b/c" + test "${_lt_dummy##*/},${_lt_dummy%/*},${_lt_dummy#??}"${_lt_dummy%"$_lt_dummy"}, \ + = c,a/b,b/c, \ + && eval 'test $(( 1 + 1 )) -eq 2 \ + && test "${#_lt_dummy}" -eq 5' ) >/dev/null 2>&1 \ + && xsi_shell=yes +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $xsi_shell" >&5 +$as_echo "$xsi_shell" >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the shell understands \"+=\"" >&5 +$as_echo_n "checking whether the shell understands \"+=\"... " >&6; } +lt_shell_append=no +( foo=bar; set foo baz; eval "$1+=\$2" && test "$foo" = barbaz ) \ + >/dev/null 2>&1 \ + && lt_shell_append=yes +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_shell_append" >&5 +$as_echo "$lt_shell_append" >&6; } +if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then + lt_unset=unset +else + lt_unset=false +fi +# test EBCDIC or ASCII +case `echo X|tr X '\101'` in + A) # ASCII based system + # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr + lt_SP2NL='tr \040 \012' + lt_NL2SP='tr \015\012 \040\040' + ;; + *) # EBCDIC based system + lt_SP2NL='tr \100 \n' + lt_NL2SP='tr \r\n \100\100' + ;; +esac @@ -4104,20 +5053,109 @@ +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to convert $build file names to $host format" >&5 +$as_echo_n "checking how to convert $build file names to $host format... " >&6; } +if ${lt_cv_to_host_file_cmd+:} false; then : + $as_echo_n "(cached) " >&6 +else + case $host in + *-*-mingw* ) + case $build in + *-*-mingw* ) # actually msys + lt_cv_to_host_file_cmd=func_convert_file_msys_to_w32 + ;; + *-*-cygwin* ) + lt_cv_to_host_file_cmd=func_convert_file_cygwin_to_w32 + ;; + * ) # otherwise, assume *nix + lt_cv_to_host_file_cmd=func_convert_file_nix_to_w32 + ;; + esac + ;; + *-*-cygwin* ) + case $build in + *-*-mingw* ) # actually msys + lt_cv_to_host_file_cmd=func_convert_file_msys_to_cygwin + ;; + *-*-cygwin* ) + lt_cv_to_host_file_cmd=func_convert_file_noop + ;; + * ) # otherwise, assume *nix + lt_cv_to_host_file_cmd=func_convert_file_nix_to_cygwin + ;; + esac + ;; + * ) # unhandled hosts (and "normal" native builds) + lt_cv_to_host_file_cmd=func_convert_file_noop + ;; +esac +fi +to_host_file_cmd=$lt_cv_to_host_file_cmd +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_to_host_file_cmd" >&5 +$as_echo "$lt_cv_to_host_file_cmd" >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to convert $build file names to toolchain format" >&5 +$as_echo_n "checking how to convert $build file names to toolchain format... " >&6; } +if ${lt_cv_to_tool_file_cmd+:} false; then : + $as_echo_n "(cached) " >&6 +else + #assume ordinary cross tools, or native build. +lt_cv_to_tool_file_cmd=func_convert_file_noop +case $host in + *-*-mingw* ) + case $build in + *-*-mingw* ) # actually msys + lt_cv_to_tool_file_cmd=func_convert_file_msys_to_w32 + ;; + esac + ;; +esac +fi +to_tool_file_cmd=$lt_cv_to_tool_file_cmd +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_to_tool_file_cmd" >&5 +$as_echo "$lt_cv_to_tool_file_cmd" >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $LD option to reload object files" >&5 +$as_echo_n "checking for $LD option to reload object files... " >&6; } +if ${lt_cv_ld_reload_flag+:} false; then : + $as_echo_n "(cached) " >&6 +else + lt_cv_ld_reload_flag='-r' +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_reload_flag" >&5 +$as_echo "$lt_cv_ld_reload_flag" >&6; } +reload_flag=$lt_cv_ld_reload_flag +case $reload_flag in +"" | " "*) ;; +*) reload_flag=" $reload_flag" ;; +esac +reload_cmds='$LD$reload_flag -o $output$reload_objs' +case $host_os in + cygwin* | mingw* | pw32* | cegcc*) + if test "$GCC" != yes; then + reload_cmds=false + fi + ;; + darwin*) + if test "$GCC" = yes; then + reload_cmds='$LTCC $LTCFLAGS -nostdlib ${wl}-r -o $output$reload_objs' + else + reload_cmds='$LD$reload_flag -o $output$reload_objs' + fi + ;; +esac @@ -4127,27 +5165,25 @@ -# Check the gettext tools to make sure they are GNU -# Extract the first word of "xgettext", so it can be a program name with args. -set dummy xgettext; ac_word=$2 +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}objdump", so it can be a program name with args. +set dummy ${ac_tool_prefix}objdump; 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_XGETTEXT+set}" = set; then : +if ${ac_cv_prog_OBJDUMP+:} false; then : $as_echo_n "(cached) " >&6 else - case $XGETTEXT in - [\\/]* | ?:[\\/]*) - ac_cv_path_XGETTEXT="$XGETTEXT" # Let the user override the test with a path. - ;; - *) - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR + if test -n "$OBJDUMP"; then + ac_cv_prog_OBJDUMP="$OBJDUMP" # Let the user override the test. +else +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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_path_XGETTEXT="$as_dir/$ac_word$ac_exec_ext" + ac_cv_prog_OBJDUMP="${ac_tool_prefix}objdump" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi @@ -4155,39 +5191,39 @@ done IFS=$as_save_IFS - ;; -esac fi -XGETTEXT=$ac_cv_path_XGETTEXT -if test -n "$XGETTEXT"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $XGETTEXT" >&5 -$as_echo "$XGETTEXT" >&6; } +fi +OBJDUMP=$ac_cv_prog_OBJDUMP +if test -n "$OBJDUMP"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OBJDUMP" >&5 +$as_echo "$OBJDUMP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi -# Extract the first word of "msgmerge", so it can be a program name with args. -set dummy msgmerge; ac_word=$2 +fi +if test -z "$ac_cv_prog_OBJDUMP"; then + ac_ct_OBJDUMP=$OBJDUMP + # Extract the first word of "objdump", so it can be a program name with args. +set dummy objdump; 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_MSGMERGE+set}" = set; then : +if ${ac_cv_prog_ac_ct_OBJDUMP+:} false; then : $as_echo_n "(cached) " >&6 else - case $MSGMERGE in - [\\/]* | ?:[\\/]*) - ac_cv_path_MSGMERGE="$MSGMERGE" # Let the user override the test with a path. - ;; - *) - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR + if test -n "$ac_ct_OBJDUMP"; then + ac_cv_prog_ac_ct_OBJDUMP="$ac_ct_OBJDUMP" # Let the user override the test. +else +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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_path_MSGMERGE="$as_dir/$ac_word$ac_exec_ext" + ac_cv_prog_ac_ct_OBJDUMP="objdump" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi @@ -4195,39 +5231,305 @@ done IFS=$as_save_IFS - ;; -esac fi -MSGMERGE=$ac_cv_path_MSGMERGE -if test -n "$MSGMERGE"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MSGMERGE" >&5 -$as_echo "$MSGMERGE" >&6; } +fi +ac_ct_OBJDUMP=$ac_cv_prog_ac_ct_OBJDUMP +if test -n "$ac_ct_OBJDUMP"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OBJDUMP" >&5 +$as_echo "$ac_ct_OBJDUMP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi + if test "x$ac_ct_OBJDUMP" = x; then + OBJDUMP="false" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + OBJDUMP=$ac_ct_OBJDUMP + fi +else + OBJDUMP="$ac_cv_prog_OBJDUMP" +fi -# Extract the first word of "msgfmt", so it can be a program name with args. -set dummy msgfmt; 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_MSGFMT+set}" = set; then : +test -z "$OBJDUMP" && OBJDUMP=objdump + + + + + + + + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to recognize dependent libraries" >&5 +$as_echo_n "checking how to recognize dependent libraries... " >&6; } +if ${lt_cv_deplibs_check_method+:} false; then : $as_echo_n "(cached) " >&6 else - case $MSGFMT in - [\\/]* | ?:[\\/]*) - ac_cv_path_MSGFMT="$MSGFMT" # Let the user override the test with a path. + lt_cv_file_magic_cmd='$MAGIC_CMD' +lt_cv_file_magic_test_file= +lt_cv_deplibs_check_method='unknown' +# Need to set the preceding variable on all platforms that support +# interlibrary dependencies. +# 'none' -- dependencies not supported. +# `unknown' -- same as none, but documents that we really don't know. +# 'pass_all' -- all dependencies passed with no checks. +# 'test_compile' -- check by making test program. +# 'file_magic [[regex]]' -- check by looking for files in library path +# which responds to the $file_magic_cmd with a given extended regex. +# If you have `file' or equivalent on your system and you're not sure +# whether `pass_all' will *always* work, you probably want this one. + +case $host_os in +aix[4-9]*) + lt_cv_deplibs_check_method=pass_all + ;; + +beos*) + lt_cv_deplibs_check_method=pass_all + ;; + +bsdi[45]*) + lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib)' + lt_cv_file_magic_cmd='/usr/bin/file -L' + lt_cv_file_magic_test_file=/shlib/libc.so + ;; + +cygwin*) + # func_win32_libid is a shell function defined in ltmain.sh + lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL' + lt_cv_file_magic_cmd='func_win32_libid' + ;; + +mingw* | pw32*) + # Base MSYS/MinGW do not provide the 'file' command needed by + # func_win32_libid shell function, so use a weaker test based on 'objdump', + # unless we find 'file', for example because we are cross-compiling. + # func_win32_libid assumes BSD nm, so disallow it if using MS dumpbin. + if ( test "$lt_cv_nm_interface" = "BSD nm" && file / ) >/dev/null 2>&1; then + lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL' + lt_cv_file_magic_cmd='func_win32_libid' + else + # Keep this pattern in sync with the one in func_win32_libid. + lt_cv_deplibs_check_method='file_magic file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' + lt_cv_file_magic_cmd='$OBJDUMP -f' + fi + ;; + +cegcc*) + # use the weaker test based on 'objdump'. See mingw*. + lt_cv_deplibs_check_method='file_magic file format pe-arm-.*little(.*architecture: arm)?' + lt_cv_file_magic_cmd='$OBJDUMP -f' + ;; + +darwin* | rhapsody*) + lt_cv_deplibs_check_method=pass_all + ;; + +freebsd* | dragonfly*) + if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then + case $host_cpu in + i*86 ) + # Not sure whether the presence of OpenBSD here was a mistake. + # Let's accept both of them until this is cleared up. + lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[3-9]86 (compact )?demand paged shared library' + lt_cv_file_magic_cmd=/usr/bin/file + lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*` + ;; + esac + else + lt_cv_deplibs_check_method=pass_all + fi + ;; + +gnu*) + lt_cv_deplibs_check_method=pass_all + ;; + +haiku*) + lt_cv_deplibs_check_method=pass_all ;; + +hpux10.20* | hpux11*) + lt_cv_file_magic_cmd=/usr/bin/file + case $host_cpu in + ia64*) + lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - IA64' + lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so + ;; + hppa*64*) + lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF[ -][0-9][0-9])(-bit)?( [LM]SB)? shared object( file)?[, -]* PA-RISC [0-9]\.[0-9]' + lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl + ;; *) - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR + lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|PA-RISC[0-9]\.[0-9]) shared library' + lt_cv_file_magic_test_file=/usr/lib/libc.sl + ;; + esac + ;; + +interix[3-9]*) + # PIC code is broken on Interix 3.x, that's why |\.a not |_pic\.a here + lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so|\.a)$' + ;; + +irix5* | irix6* | nonstopux*) + case $LD in + *-32|*"-32 ") libmagic=32-bit;; + *-n32|*"-n32 ") libmagic=N32;; + *-64|*"-64 ") libmagic=64-bit;; + *) libmagic=never-match;; + esac + lt_cv_deplibs_check_method=pass_all + ;; + +# This must be glibc/ELF. +linux* | k*bsd*-gnu | kopensolaris*-gnu) + lt_cv_deplibs_check_method=pass_all + ;; + +netbsd* | netbsdelf*-gnu) + if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then + lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$' + else + lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so|_pic\.a)$' + fi + ;; + +newos6*) + lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (executable|dynamic lib)' + lt_cv_file_magic_cmd=/usr/bin/file + lt_cv_file_magic_test_file=/usr/lib/libnls.so + ;; + +*nto* | *qnx*) + lt_cv_deplibs_check_method=pass_all + ;; + +openbsd*) + if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then + lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|\.so|_pic\.a)$' + else + lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$' + fi + ;; + +osf3* | osf4* | osf5*) + lt_cv_deplibs_check_method=pass_all + ;; + +rdos*) + lt_cv_deplibs_check_method=pass_all + ;; + +solaris*) + lt_cv_deplibs_check_method=pass_all + ;; + +sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) + lt_cv_deplibs_check_method=pass_all + ;; + +sysv4 | sysv4.3*) + case $host_vendor in + motorola) + lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib) M[0-9][0-9]* Version [0-9]' + lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*` + ;; + ncr) + lt_cv_deplibs_check_method=pass_all + ;; + sequent) + lt_cv_file_magic_cmd='/bin/file' + lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [LM]SB (shared object|dynamic lib )' + ;; + sni) + lt_cv_file_magic_cmd='/bin/file' + lt_cv_deplibs_check_method="file_magic ELF [0-9][0-9]*-bit [LM]SB dynamic lib" + lt_cv_file_magic_test_file=/lib/libc.so + ;; + siemens) + lt_cv_deplibs_check_method=pass_all + ;; + pc) + lt_cv_deplibs_check_method=pass_all + ;; + esac + ;; + +tpf*) + lt_cv_deplibs_check_method=pass_all + ;; +esac + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_deplibs_check_method" >&5 +$as_echo "$lt_cv_deplibs_check_method" >&6; } + +file_magic_glob= +want_nocaseglob=no +if test "$build" = "$host"; then + case $host_os in + mingw* | pw32*) + if ( shopt | grep nocaseglob ) >/dev/null 2>&1; then + want_nocaseglob=yes + else + file_magic_glob=`echo aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ | $SED -e "s/\(..\)/s\/[\1]\/[\1]\/g;/g"` + fi + ;; + esac +fi + +file_magic_cmd=$lt_cv_file_magic_cmd +deplibs_check_method=$lt_cv_deplibs_check_method +test -z "$deplibs_check_method" && deplibs_check_method=unknown + + + + + + + + + + + + + + + + + + + + + + +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}dlltool", so it can be a program name with args. +set dummy ${ac_tool_prefix}dlltool; 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_prog_DLLTOOL+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$DLLTOOL"; then + ac_cv_prog_DLLTOOL="$DLLTOOL" # Let the user override the test. +else +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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_path_MSGFMT="$as_dir/$ac_word$ac_exec_ext" + ac_cv_prog_DLLTOOL="${ac_tool_prefix}dlltool" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi @@ -4235,39 +5537,39 @@ done IFS=$as_save_IFS - ;; -esac fi -MSGFMT=$ac_cv_path_MSGFMT -if test -n "$MSGFMT"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MSGFMT" >&5 -$as_echo "$MSGFMT" >&6; } +fi +DLLTOOL=$ac_cv_prog_DLLTOOL +if test -n "$DLLTOOL"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DLLTOOL" >&5 +$as_echo "$DLLTOOL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi -# Extract the first word of "gmsgfmt", so it can be a program name with args. -set dummy gmsgfmt; ac_word=$2 +fi +if test -z "$ac_cv_prog_DLLTOOL"; then + ac_ct_DLLTOOL=$DLLTOOL + # Extract the first word of "dlltool", so it can be a program name with args. +set dummy dlltool; 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_GMSGFMT+set}" = set; then : +if ${ac_cv_prog_ac_ct_DLLTOOL+:} false; then : $as_echo_n "(cached) " >&6 else - case $GMSGFMT in - [\\/]* | ?:[\\/]*) - ac_cv_path_GMSGFMT="$GMSGFMT" # Let the user override the test with a path. - ;; - *) - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR + if test -n "$ac_ct_DLLTOOL"; then + ac_cv_prog_ac_ct_DLLTOOL="$ac_ct_DLLTOOL" # Let the user override the test. +else +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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_path_GMSGFMT="$as_dir/$ac_word$ac_exec_ext" + ac_cv_prog_ac_ct_DLLTOOL="dlltool" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi @@ -4275,50 +5577,103 @@ done IFS=$as_save_IFS - test -z "$ac_cv_path_GMSGFMT" && ac_cv_path_GMSGFMT="$MSGFMT" - ;; -esac fi -GMSGFMT=$ac_cv_path_GMSGFMT -if test -n "$GMSGFMT"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $GMSGFMT" >&5 -$as_echo "$GMSGFMT" >&6; } +fi +ac_ct_DLLTOOL=$ac_cv_prog_ac_ct_DLLTOOL +if test -n "$ac_ct_DLLTOOL"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DLLTOOL" >&5 +$as_echo "$ac_ct_DLLTOOL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi - -if test -z "$XGETTEXT" -o -z "$MSGMERGE" -o -z "$MSGFMT"; then - as_fn_error "GNU gettext tools not found; required for intltool" "$LINENO" 5 + if test "x$ac_ct_DLLTOOL" = x; then + DLLTOOL="false" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + DLLTOOL=$ac_ct_DLLTOOL + fi +else + DLLTOOL="$ac_cv_prog_DLLTOOL" fi -xgversion="`$XGETTEXT --version|grep '(GNU ' 2> /dev/null`" -mmversion="`$MSGMERGE --version|grep '(GNU ' 2> /dev/null`" -mfversion="`$MSGFMT --version|grep '(GNU ' 2> /dev/null`" -if test -z "$xgversion" -o -z "$mmversion" -o -z "$mfversion"; then - as_fn_error "GNU gettext tools not found; required for intltool" "$LINENO" 5 + +test -z "$DLLTOOL" && DLLTOOL=dlltool + + + + + + + + + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to associate runtime and link libraries" >&5 +$as_echo_n "checking how to associate runtime and link libraries... " >&6; } +if ${lt_cv_sharedlib_from_linklib_cmd+:} false; then : + $as_echo_n "(cached) " >&6 +else + lt_cv_sharedlib_from_linklib_cmd='unknown' + +case $host_os in +cygwin* | mingw* | pw32* | cegcc*) + # two different shell functions defined in ltmain.sh + # decide which to use based on capabilities of $DLLTOOL + case `$DLLTOOL --help 2>&1` in + *--identify-strict*) + lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib + ;; + *) + lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib_fallback + ;; + esac + ;; +*) + # fallback: assume linklib IS sharedlib + lt_cv_sharedlib_from_linklib_cmd="$ECHO" + ;; +esac + fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_sharedlib_from_linklib_cmd" >&5 +$as_echo "$lt_cv_sharedlib_from_linklib_cmd" >&6; } +sharedlib_from_linklib_cmd=$lt_cv_sharedlib_from_linklib_cmd +test -z "$sharedlib_from_linklib_cmd" && sharedlib_from_linklib_cmd=$ECHO -# Extract the first word of "perl", so it can be a program name with args. -set dummy perl; ac_word=$2 + + + + + + + +if test -n "$ac_tool_prefix"; then + for ac_prog in ar + do + # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. +set dummy $ac_tool_prefix$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_path_INTLTOOL_PERL+set}" = set; then : +if ${ac_cv_prog_AR+:} false; then : $as_echo_n "(cached) " >&6 else - case $INTLTOOL_PERL in - [\\/]* | ?:[\\/]*) - ac_cv_path_INTLTOOL_PERL="$INTLTOOL_PERL" # Let the user override the test with a path. - ;; - *) - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR + if test -n "$AR"; then + ac_cv_prog_AR="$AR" # Let the user override the test. +else +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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_path_INTLTOOL_PERL="$as_dir/$ac_word$ac_exec_ext" + ac_cv_prog_AR="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi @@ -4326,1076 +5681,1518 @@ done IFS=$as_save_IFS - ;; -esac fi -INTLTOOL_PERL=$ac_cv_path_INTLTOOL_PERL -if test -n "$INTLTOOL_PERL"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $INTLTOOL_PERL" >&5 -$as_echo "$INTLTOOL_PERL" >&6; } +fi +AR=$ac_cv_prog_AR +if test -n "$AR"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AR" >&5 +$as_echo "$AR" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi -if test -z "$INTLTOOL_PERL"; then - as_fn_error "perl not found" "$LINENO" 5 + test -n "$AR" && break + done fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for perl >= 5.8.1" >&5 -$as_echo_n "checking for perl >= 5.8.1... " >&6; } -$INTLTOOL_PERL -e "use 5.8.1;" > /dev/null 2>&1 -if test $? -ne 0; then - as_fn_error "perl 5.8.1 is required for intltool" "$LINENO" 5 +if test -z "$AR"; then + ac_ct_AR=$AR + for ac_prog in ar +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 ${ac_cv_prog_ac_ct_AR+:} false; then : + $as_echo_n "(cached) " >&6 else - IT_PERL_VERSION="`$INTLTOOL_PERL -e \"printf '%vd', $^V\"`" - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $IT_PERL_VERSION" >&5 -$as_echo "$IT_PERL_VERSION" >&6; } + if test -n "$ac_ct_AR"; then + ac_cv_prog_ac_ct_AR="$ac_ct_AR" # Let the user override the test. +else +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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_ac_ct_AR="$ac_prog" + $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 + fi -if test "x" != "xno-xml"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for XML::Parser" >&5 -$as_echo_n "checking for XML::Parser... " >&6; } - if `$INTLTOOL_PERL -e "require XML::Parser" 2>/dev/null`; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5 -$as_echo "ok" >&6; } - else - as_fn_error "XML::Parser perl module is required for intltool" "$LINENO" 5 - fi +fi +ac_ct_AR=$ac_cv_prog_ac_ct_AR +if test -n "$ac_ct_AR"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_AR" >&5 +$as_echo "$ac_ct_AR" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } fi -# Substitute ALL_LINGUAS so we can use it in po/Makefile + test -n "$ac_ct_AR" && break +done -# Set DATADIRNAME correctly if it is not set yet -# (copied from glib-gettext.m4) -if test -z "$DATADIRNAME"; then - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + if test "x$ac_ct_AR" = x; then + AR="false" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + AR=$ac_ct_AR + fi +fi + +: ${AR=ar} +: ${AR_FLAGS=cru} + + + + + + + + + + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for archiver @FILE support" >&5 +$as_echo_n "checking for archiver @FILE support... " >&6; } +if ${lt_cv_ar_at_file+:} false; then : + $as_echo_n "(cached) " >&6 +else + lt_cv_ar_at_file=no + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { -extern int _nl_msg_cat_cntr; - return _nl_msg_cat_cntr + ; return 0; } _ACEOF -if ac_fn_c_try_link "$LINENO"; then : - DATADIRNAME=share -else - case $host in - *-*-solaris*) - ac_fn_c_check_func "$LINENO" "bind_textdomain_codeset" "ac_cv_func_bind_textdomain_codeset" -if test "x$ac_cv_func_bind_textdomain_codeset" = x""yes; then : - DATADIRNAME=share -else - DATADIRNAME=lib -fi +if ac_fn_c_try_compile "$LINENO"; then : + echo conftest.$ac_objext > conftest.lst + lt_ar_try='$AR $AR_FLAGS libconftest.a @conftest.lst >&5' + { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$lt_ar_try\""; } >&5 + (eval $lt_ar_try) 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } + if test "$ac_status" -eq 0; then + # Ensure the archiver fails upon bogus file names. + rm -f conftest.$ac_objext libconftest.a + { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$lt_ar_try\""; } >&5 + (eval $lt_ar_try) 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } + if test "$ac_status" -ne 0; then + lt_cv_ar_at_file=@ + fi + fi + rm -f conftest.* libconftest.a - ;; - *) - DATADIRNAME=lib - ;; - esac fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ar_at_file" >&5 +$as_echo "$lt_cv_ar_at_file" >&6; } +if test "x$lt_cv_ar_at_file" = xno; then + archiver_list_spec= +else + archiver_list_spec=$lt_cv_ar_at_file +fi -POSUB=" - po - po-Engine - po-Engine-IRC - po-Engine-XMPP - po-Engine-OSCAR - po-Engine-MSNP - po-Server - po-Frontend - po-Frontend-GNOME - po-Frontend-GNOME-IRC - po-Frontend-GNOME-XMPP - po-Frontend-SWF -" -GETTEXT_PACKAGE=smuxi +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 ${ac_cv_prog_STRIP+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$STRIP"; then + ac_cv_prog_STRIP="$STRIP" # Let the user override the test. +else +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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$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 + fi +done + done +IFS=$as_save_IFS -GETTEXT_PACKAGE_ENGINE=smuxi-engine +fi +fi +STRIP=$ac_cv_prog_STRIP +if test -n "$STRIP"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $STRIP" >&5 +$as_echo "$STRIP" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi -cat >>confdefs.h <<_ACEOF -#define GETTEXT_PACKAGE_ENGINE "$GETTEXT_PACKAGE_ENGINE" -_ACEOF +fi +if test -z "$ac_cv_prog_STRIP"; then + ac_ct_STRIP=$STRIP + # Extract the first word of "strip", so it can be a program name with args. +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 ${ac_cv_prog_ac_ct_STRIP+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_STRIP"; then + ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test. +else +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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$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 + fi +done + done +IFS=$as_save_IFS +fi +fi +ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP +if test -n "$ac_ct_STRIP"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_STRIP" >&5 +$as_echo "$ac_ct_STRIP" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi -GETTEXT_PACKAGE_ENGINE_IRC=smuxi-engine-irc + if test "x$ac_ct_STRIP" = x; then + STRIP=":" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + STRIP=$ac_ct_STRIP + fi +else + STRIP="$ac_cv_prog_STRIP" +fi +test -z "$STRIP" && STRIP=: -cat >>confdefs.h <<_ACEOF -#define GETTEXT_PACKAGE_ENGINE_IRC "$GETTEXT_PACKAGE_ENGINE_IRC" -_ACEOF -GETTEXT_PACKAGE_ENGINE_XMPP=smuxi-engine-xmpp -cat >>confdefs.h <<_ACEOF -#define GETTEXT_PACKAGE_ENGINE_XMPP "$GETTEXT_PACKAGE_ENGINE_XMPP" -_ACEOF +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args. +set dummy ${ac_tool_prefix}ranlib; 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_prog_RANLIB+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$RANLIB"; then + ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. +else +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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib" + $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 -GETTEXT_PACKAGE_ENGINE_OSCAR=smuxi-engine-oscar +fi +fi +RANLIB=$ac_cv_prog_RANLIB +if test -n "$RANLIB"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $RANLIB" >&5 +$as_echo "$RANLIB" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi -cat >>confdefs.h <<_ACEOF -#define GETTEXT_PACKAGE_ENGINE_OSCAR "$GETTEXT_PACKAGE_ENGINE_OSCAR" -_ACEOF +fi +if test -z "$ac_cv_prog_RANLIB"; then + ac_ct_RANLIB=$RANLIB + # Extract the first word of "ranlib", so it can be a program name with args. +set dummy ranlib; 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_prog_ac_ct_RANLIB+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_RANLIB"; then + ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test. +else +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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_ac_ct_RANLIB="ranlib" + $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 +fi +fi +ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB +if test -n "$ac_ct_RANLIB"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_RANLIB" >&5 +$as_echo "$ac_ct_RANLIB" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi -GETTEXT_PACKAGE_ENGINE_MSNP=smuxi-engine-msnp + if test "x$ac_ct_RANLIB" = x; then + RANLIB=":" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + RANLIB=$ac_ct_RANLIB + fi +else + RANLIB="$ac_cv_prog_RANLIB" +fi +test -z "$RANLIB" && RANLIB=: -cat >>confdefs.h <<_ACEOF -#define GETTEXT_PACKAGE_ENGINE_MSNP "$GETTEXT_PACKAGE_ENGINE_MSNP" -_ACEOF -GETTEXT_PACKAGE_ENGINE_TWITTER=smuxi-engine-twitter -cat >>confdefs.h <<_ACEOF -#define GETTEXT_PACKAGE_ENGINE_TWITTER "$GETTEXT_PACKAGE_ENGINE_TWITTER" -_ACEOF +# Determine commands to create old-style static archives. +old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs' +old_postinstall_cmds='chmod 644 $oldlib' +old_postuninstall_cmds= -GETTEXT_PACKAGE_SERVER=smuxi-server +if test -n "$RANLIB"; then + case $host_os in + openbsd*) + old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$tool_oldlib" + ;; + *) + old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$tool_oldlib" + ;; + esac + old_archive_cmds="$old_archive_cmds~\$RANLIB \$tool_oldlib" +fi +case $host_os in + darwin*) + lock_old_archive_extraction=yes ;; + *) + lock_old_archive_extraction=no ;; +esac -cat >>confdefs.h <<_ACEOF -#define GETTEXT_PACKAGE_SERVER "$GETTEXT_PACKAGE_SERVER" -_ACEOF -GETTEXT_PACKAGE_FRONTEND=smuxi-frontend -cat >>confdefs.h <<_ACEOF -#define GETTEXT_PACKAGE_FRONTEND "$GETTEXT_PACKAGE_FRONTEND" -_ACEOF -GETTEXT_PACKAGE_FRONTEND_GNOME=smuxi-frontend-gnome -cat >>confdefs.h <<_ACEOF -#define GETTEXT_PACKAGE_FRONTEND_GNOME "$GETTEXT_PACKAGE_FRONTEND_GNOME" -_ACEOF -GETTEXT_PACKAGE_FRONTEND_GNOME_IRC=smuxi-frontend-gnome-irc -cat >>confdefs.h <<_ACEOF -#define GETTEXT_PACKAGE_FRONTEND_GNOME_IRC "$GETTEXT_PACKAGE_FRONTEND_GNOME_IRC" -_ACEOF -GETTEXT_PACKAGE_FRONTEND_GNOME_XMPP=smuxi-frontend-gnome-xmpp -cat >>confdefs.h <<_ACEOF -#define GETTEXT_PACKAGE_FRONTEND_GNOME_XMPP "$GETTEXT_PACKAGE_FRONTEND_GNOME_XMPP" -_ACEOF -GETTEXT_PACKAGE_FRONTEND_STFL=smuxi-frontend-stfl -cat >>confdefs.h <<_ACEOF -#define GETTEXT_PACKAGE_FRONTEND_STFL "$GETTEXT_PACKAGE_FRONTEND_STFL" -_ACEOF -GETTEXT_PACKAGE_FRONTEND_CURSES=smuxi-frontend-curses -cat >>confdefs.h <<_ACEOF -#define GETTEXT_PACKAGE_FRONTEND_CURSES "$GETTEXT_PACKAGE_FRONTEND_CURSES" -_ACEOF -GETTEXT_PACKAGE_FRONTEND_SWF=smuxi-frontend-swf -cat >>confdefs.h <<_ACEOF -#define GETTEXT_PACKAGE_FRONTEND_SWF "$GETTEXT_PACKAGE_FRONTEND_SWF" -_ACEOF -GETTEXT_PACKAGE_FRONTEND_WPF=smuxi-frontend-wpf -cat >>confdefs.h <<_ACEOF -#define GETTEXT_PACKAGE_FRONTEND_WPF "$GETTEXT_PACKAGE_FRONTEND_WPF" -_ACEOF - GETTEXT_MACRO_VERSION=0.18 +# If no C compiler was specified, use CC. +LTCC=${LTCC-"$CC"} +# If no C compiler flags were specified, use CFLAGS. +LTCFLAGS=${LTCFLAGS-"$CFLAGS"} -# Prepare PATH_SEPARATOR. -# The user is always right. -if test "${PATH_SEPARATOR+set}" != set; then - echo "#! /bin/sh" >conf$$.sh - echo "exit 0" >>conf$$.sh - chmod +x conf$$.sh - if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then - PATH_SEPARATOR=';' - else - PATH_SEPARATOR=: - fi - rm -f conf$$.sh -fi +# Allow CC to be a program name with arguments. +compiler=$CC -# Find out how to test for executable files. Don't use a zero-byte file, -# as systems may use methods other than mode bits to determine executability. -cat >conf$$.file <<_ASEOF -#! /bin/sh -exit 0 -_ASEOF -chmod +x conf$$.file -if test -x conf$$.file >/dev/null 2>&1; then - ac_executable_p="test -x" -else - ac_executable_p="test -f" -fi -rm -f conf$$.file -# Extract the first word of "msgfmt", so it can be a program name with args. -set dummy msgfmt; 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_MSGFMT+set}" = set; then : +# Check for command to grab the raw symbol name followed by C symbol from nm. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking command to parse $NM output from $compiler object" >&5 +$as_echo_n "checking command to parse $NM output from $compiler object... " >&6; } +if ${lt_cv_sys_global_symbol_pipe+:} false; then : $as_echo_n "(cached) " >&6 else - case "$MSGFMT" in - [\\/]* | ?:[\\/]*) - ac_cv_path_MSGFMT="$MSGFMT" # Let the user override the test with a path. - ;; - *) - ac_save_IFS="$IFS"; IFS=$PATH_SEPARATOR - for ac_dir in $PATH; do - IFS="$ac_save_IFS" - test -z "$ac_dir" && ac_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if $ac_executable_p "$ac_dir/$ac_word$ac_exec_ext"; then - echo "$as_me: trying $ac_dir/$ac_word..." >&5 - if $ac_dir/$ac_word --statistics /dev/null >&5 2>&1 && - (if $ac_dir/$ac_word --statistics /dev/null 2>&1 >/dev/null | grep usage >/dev/null; then exit 1; else exit 0; fi); then - ac_cv_path_MSGFMT="$ac_dir/$ac_word$ac_exec_ext" - break 2 - fi - fi - done - done - IFS="$ac_save_IFS" - test -z "$ac_cv_path_MSGFMT" && ac_cv_path_MSGFMT=":" - ;; -esac -fi -MSGFMT="$ac_cv_path_MSGFMT" -if test "$MSGFMT" != ":"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MSGFMT" >&5 -$as_echo "$MSGFMT" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - # Extract the first word of "gmsgfmt", so it can be a program name with args. -set dummy gmsgfmt; 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_GMSGFMT+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - case $GMSGFMT in - [\\/]* | ?:[\\/]*) - ac_cv_path_GMSGFMT="$GMSGFMT" # Let the user override the test with a path. +# These are sane defaults that work on at least a few old systems. +# [They come from Ultrix. What could be older than Ultrix?!! ;)] + +# Character class describing NM global symbol codes. +symcode='[BCDEGRST]' + +# Regexp to match symbols that can be accessed directly from C. +sympat='\([_A-Za-z][_A-Za-z0-9]*\)' + +# Define system-specific variables. +case $host_os in +aix*) + symcode='[BCDT]' ;; - *) - 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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_path_GMSGFMT="$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 +cygwin* | mingw* | pw32* | cegcc*) + symcode='[ABCDGISTW]' + ;; +hpux*) + if test "$host_cpu" = ia64; then + symcode='[ABCDEGRST]' fi -done - done -IFS=$as_save_IFS + ;; +irix* | nonstopux*) + symcode='[BCDEGRST]' + ;; +osf*) + symcode='[BCDEGQRST]' + ;; +solaris*) + symcode='[BDRT]' + ;; +sco3.2v5*) + symcode='[DT]' + ;; +sysv4.2uw2*) + symcode='[DT]' + ;; +sysv5* | sco5v6* | unixware* | OpenUNIX*) + symcode='[ABDT]' + ;; +sysv4) + symcode='[DFNSTU]' + ;; +esac - test -z "$ac_cv_path_GMSGFMT" && ac_cv_path_GMSGFMT="$MSGFMT" +# If we're using GNU nm, then use its standard symbol codes. +case `$NM -V 2>&1` in +*GNU* | *'with BFD'*) + symcode='[ABCDGIRSTW]' ;; +esac + +# Transform an extracted symbol line into a proper C declaration. +# Some systems (esp. on ia64) link data and code symbols differently, +# so use this general approach. +lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'" + +# Transform an extracted symbol line into symbol name and symbol address +lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([^ ]*\)[ ]*$/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([^ ]*\) \([^ ]*\)$/ {\"\2\", (void *) \&\2},/p'" +lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n -e 's/^: \([^ ]*\)[ ]*$/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([^ ]*\) \(lib[^ ]*\)$/ {\"\2\", (void *) \&\2},/p' -e 's/^$symcode* \([^ ]*\) \([^ ]*\)$/ {\"lib\2\", (void *) \&\2},/p'" + +# Handle CRLF in mingw tool chain +opt_cr= +case $build_os in +mingw*) + opt_cr=`$ECHO 'x\{0,1\}' | tr x '\015'` # option cr in regexp ;; esac -fi -GMSGFMT=$ac_cv_path_GMSGFMT -if test -n "$GMSGFMT"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $GMSGFMT" >&5 -$as_echo "$GMSGFMT" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi +# Try without a prefix underscore, then with it. +for ac_symprfx in "" "_"; do + # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol. + symxfrm="\\1 $ac_symprfx\\2 \\2" - case `$MSGFMT --version | sed 1q | sed -e 's,^[^0-9]*,,'` in - '' | 0.[0-9] | 0.[0-9].* | 0.1[0-4] | 0.1[0-4].*) MSGFMT_015=: ;; - *) MSGFMT_015=$MSGFMT ;; - esac + # Write the raw and C identifiers. + if test "$lt_cv_nm_interface" = "MS dumpbin"; then + # Fake it for dumpbin and say T for any non-static function + # and D for any global variable. + # Also find C++ and __fastcall symbols from MSVC++, + # which start with @ or ?. + lt_cv_sys_global_symbol_pipe="$AWK '"\ +" {last_section=section; section=\$ 3};"\ +" /^COFF SYMBOL TABLE/{for(i in hide) delete hide[i]};"\ +" /Section length .*#relocs.*(pick any)/{hide[last_section]=1};"\ +" \$ 0!~/External *\|/{next};"\ +" / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next};"\ +" {if(hide[section]) next};"\ +" {f=0}; \$ 0~/\(\).*\|/{f=1}; {printf f ? \"T \" : \"D \"};"\ +" {split(\$ 0, a, /\||\r/); split(a[2], s)};"\ +" s[1]~/^[@?]/{print s[1], s[1]; next};"\ +" s[1]~prfx {split(s[1],t,\"@\"); print t[1], substr(t[1],length(prfx))}"\ +" ' prfx=^$ac_symprfx" + else + lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[ ]\($symcode$symcode*\)[ ][ ]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'" + fi + lt_cv_sys_global_symbol_pipe="$lt_cv_sys_global_symbol_pipe | sed '/ __gnu_lto/d'" - case `$GMSGFMT --version | sed 1q | sed -e 's,^[^0-9]*,,'` in - '' | 0.[0-9] | 0.[0-9].* | 0.1[0-4] | 0.1[0-4].*) GMSGFMT_015=: ;; - *) GMSGFMT_015=$GMSGFMT ;; - esac + # Check to see that the pipe works correctly. + pipe_works=no + rm -f conftest* + cat > conftest.$ac_ext <<_LT_EOF +#ifdef __cplusplus +extern "C" { +#endif +char nm_test_var; +void nm_test_func(void); +void nm_test_func(void){} +#ifdef __cplusplus +} +#endif +int main(){nm_test_var='a';nm_test_func();return(0);} +_LT_EOF + if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + # Now try to grab the symbols. + nlist=conftest.nm + if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$NM conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist\""; } >&5 + (eval $NM conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist) 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && test -s "$nlist"; then + # Try sorting and uniquifying the output. + if sort "$nlist" | uniq > "$nlist"T; then + mv -f "$nlist"T "$nlist" + else + rm -f "$nlist"T + fi -# Prepare PATH_SEPARATOR. -# The user is always right. -if test "${PATH_SEPARATOR+set}" != set; then - echo "#! /bin/sh" >conf$$.sh - echo "exit 0" >>conf$$.sh - chmod +x conf$$.sh - if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then - PATH_SEPARATOR=';' + # Make sure that we snagged all the symbols we need. + if $GREP ' nm_test_var$' "$nlist" >/dev/null; then + if $GREP ' nm_test_func$' "$nlist" >/dev/null; then + cat <<_LT_EOF > conftest.$ac_ext +/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ +#if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE) +/* DATA imports from DLLs on WIN32 con't be const, because runtime + relocations are performed -- see ld's documentation on pseudo-relocs. */ +# define LT_DLSYM_CONST +#elif defined(__osf__) +/* This system does not cope well with relocations in const data. */ +# define LT_DLSYM_CONST +#else +# define LT_DLSYM_CONST const +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +_LT_EOF + # Now generate the symbol file. + eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | $GREP -v main >> conftest.$ac_ext' + + cat <<_LT_EOF >> conftest.$ac_ext + +/* The mapping between symbol names and symbols. */ +LT_DLSYM_CONST struct { + const char *name; + void *address; +} +lt__PROGRAM__LTX_preloaded_symbols[] = +{ + { "@PROGRAM@", (void *) 0 }, +_LT_EOF + $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/ {\"\2\", (void *) \&\2},/" < "$nlist" | $GREP -v main >> conftest.$ac_ext + cat <<\_LT_EOF >> conftest.$ac_ext + {0, (void *) 0} +}; + +/* This works around a problem in FreeBSD linker */ +#ifdef FREEBSD_WORKAROUND +static const void *lt_preloaded_setup() { + return lt__PROGRAM__LTX_preloaded_symbols; +} +#endif + +#ifdef __cplusplus +} +#endif +_LT_EOF + # Now try linking the two files. + mv conftest.$ac_objext conftstm.$ac_objext + lt_globsym_save_LIBS=$LIBS + lt_globsym_save_CFLAGS=$CFLAGS + LIBS="conftstm.$ac_objext" + CFLAGS="$CFLAGS$lt_prog_compiler_no_builtin_flag" + if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5 + (eval $ac_link) 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && test -s conftest${ac_exeext}; then + pipe_works=yes + fi + LIBS=$lt_globsym_save_LIBS + CFLAGS=$lt_globsym_save_CFLAGS + else + echo "cannot find nm_test_func in $nlist" >&5 + fi + else + echo "cannot find nm_test_var in $nlist" >&5 + fi + else + echo "cannot run $lt_cv_sys_global_symbol_pipe" >&5 + fi else - PATH_SEPARATOR=: + echo "$progname: failed program was:" >&5 + cat conftest.$ac_ext >&5 fi - rm -f conf$$.sh + rm -rf conftest* conftst* + + # Do not use the global_symbol_pipe unless it works. + if test "$pipe_works" = yes; then + break + else + lt_cv_sys_global_symbol_pipe= + fi +done + fi -# Find out how to test for executable files. Don't use a zero-byte file, -# as systems may use methods other than mode bits to determine executability. -cat >conf$$.file <<_ASEOF -#! /bin/sh -exit 0 -_ASEOF -chmod +x conf$$.file -if test -x conf$$.file >/dev/null 2>&1; then - ac_executable_p="test -x" +if test -z "$lt_cv_sys_global_symbol_pipe"; then + lt_cv_sys_global_symbol_to_cdecl= +fi +if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: failed" >&5 +$as_echo "failed" >&6; } else - ac_executable_p="test -f" + { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5 +$as_echo "ok" >&6; } fi -rm -f conf$$.file -# Extract the first word of "xgettext", so it can be a program name with args. -set dummy xgettext; 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_XGETTEXT+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - case "$XGETTEXT" in - [\\/]* | ?:[\\/]*) - ac_cv_path_XGETTEXT="$XGETTEXT" # Let the user override the test with a path. - ;; - *) - ac_save_IFS="$IFS"; IFS=$PATH_SEPARATOR - for ac_dir in $PATH; do - IFS="$ac_save_IFS" - test -z "$ac_dir" && ac_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if $ac_executable_p "$ac_dir/$ac_word$ac_exec_ext"; then - echo "$as_me: trying $ac_dir/$ac_word..." >&5 - if $ac_dir/$ac_word --omit-header --copyright-holder= --msgid-bugs-address= /dev/null >&5 2>&1 && - (if $ac_dir/$ac_word --omit-header --copyright-holder= --msgid-bugs-address= /dev/null 2>&1 >/dev/null | grep usage >/dev/null; then exit 1; else exit 0; fi); then - ac_cv_path_XGETTEXT="$ac_dir/$ac_word$ac_exec_ext" - break 2 - fi - fi - done - done - IFS="$ac_save_IFS" - test -z "$ac_cv_path_XGETTEXT" && ac_cv_path_XGETTEXT=":" - ;; -esac -fi -XGETTEXT="$ac_cv_path_XGETTEXT" -if test "$XGETTEXT" != ":"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $XGETTEXT" >&5 -$as_echo "$XGETTEXT" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } +# Response file support. +if test "$lt_cv_nm_interface" = "MS dumpbin"; then + nm_file_list_spec='@' +elif $NM --help 2>/dev/null | grep '[@]FILE' >/dev/null; then + nm_file_list_spec='@' fi - rm -f messages.po - case `$XGETTEXT --version | sed 1q | sed -e 's,^[^0-9]*,,'` in - '' | 0.[0-9] | 0.[0-9].* | 0.1[0-4] | 0.1[0-4].*) XGETTEXT_015=: ;; - *) XGETTEXT_015=$XGETTEXT ;; - esac -# Prepare PATH_SEPARATOR. -# The user is always right. -if test "${PATH_SEPARATOR+set}" != set; then - echo "#! /bin/sh" >conf$$.sh - echo "exit 0" >>conf$$.sh - chmod +x conf$$.sh - if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then - PATH_SEPARATOR=';' - else - PATH_SEPARATOR=: - fi - rm -f conf$$.sh -fi -# Find out how to test for executable files. Don't use a zero-byte file, -# as systems may use methods other than mode bits to determine executability. -cat >conf$$.file <<_ASEOF -#! /bin/sh -exit 0 -_ASEOF -chmod +x conf$$.file -if test -x conf$$.file >/dev/null 2>&1; then - ac_executable_p="test -x" -else - ac_executable_p="test -f" -fi -rm -f conf$$.file -# Extract the first word of "msgmerge", so it can be a program name with args. -set dummy msgmerge; 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_MSGMERGE+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - case "$MSGMERGE" in - [\\/]* | ?:[\\/]*) - ac_cv_path_MSGMERGE="$MSGMERGE" # Let the user override the test with a path. - ;; - *) - ac_save_IFS="$IFS"; IFS=$PATH_SEPARATOR - for ac_dir in $PATH; do - IFS="$ac_save_IFS" - test -z "$ac_dir" && ac_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if $ac_executable_p "$ac_dir/$ac_word$ac_exec_ext"; then - echo "$as_me: trying $ac_dir/$ac_word..." >&5 - if $ac_dir/$ac_word --update -q /dev/null /dev/null >&5 2>&1; then - ac_cv_path_MSGMERGE="$ac_dir/$ac_word$ac_exec_ext" - break 2 - fi - fi - done - done - IFS="$ac_save_IFS" - test -z "$ac_cv_path_MSGMERGE" && ac_cv_path_MSGMERGE=":" - ;; -esac -fi -MSGMERGE="$ac_cv_path_MSGMERGE" -if test "$MSGMERGE" != ":"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MSGMERGE" >&5 -$as_echo "$MSGMERGE" >&6; } + + + + + + + + + + + + + + + + + + + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for sysroot" >&5 +$as_echo_n "checking for sysroot... " >&6; } + +# Check whether --with-sysroot was given. +if test "${with_sysroot+set}" = set; then : + withval=$with_sysroot; else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } + with_sysroot=no fi - test -n "$localedir" || localedir='${datadir}/locale' +lt_sysroot= +case ${with_sysroot} in #( + yes) + if test "$GCC" = yes; then + lt_sysroot=`$CC --print-sysroot 2>/dev/null` + fi + ;; #( + /*) + lt_sysroot=`echo "$with_sysroot" | sed -e "$sed_quote_subst"` + ;; #( + no|'') + ;; #( + *) + { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${with_sysroot}" >&5 +$as_echo "${with_sysroot}" >&6; } + as_fn_error $? "The sysroot must be an absolute path." "$LINENO" 5 + ;; +esac + { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${lt_sysroot:-no}" >&5 +$as_echo "${lt_sysroot:-no}" >&6; } - test -n "${XGETTEXT_EXTRA_OPTIONS+set}" || XGETTEXT_EXTRA_OPTIONS= - ac_config_commands="$ac_config_commands po-directories" +# Check whether --enable-libtool-lock was given. +if test "${enable_libtool_lock+set}" = set; then : + enableval=$enable_libtool_lock; +fi - if test "X$prefix" = "XNONE"; then - acl_final_prefix="$ac_default_prefix" - else - acl_final_prefix="$prefix" +test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes + +# Some flags need to be propagated to the compiler or linker for good +# libtool support. +case $host in +ia64-*-hpux*) + # Find out which ABI we are using. + echo 'int i;' > conftest.$ac_ext + if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + case `/usr/bin/file conftest.$ac_objext` in + *ELF-32*) + HPUX_IA64_MODE="32" + ;; + *ELF-64*) + HPUX_IA64_MODE="64" + ;; + esac fi - if test "X$exec_prefix" = "XNONE"; then - acl_final_exec_prefix='${prefix}' - else - acl_final_exec_prefix="$exec_prefix" + rm -rf conftest* + ;; +*-*-irix6*) + # Find out which ABI we are using. + echo '#line '$LINENO' "configure"' > conftest.$ac_ext + if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + if test "$lt_cv_prog_gnu_ld" = yes; then + case `/usr/bin/file conftest.$ac_objext` in + *32-bit*) + LD="${LD-ld} -melf32bsmip" + ;; + *N32*) + LD="${LD-ld} -melf32bmipn32" + ;; + *64-bit*) + LD="${LD-ld} -melf64bmip" + ;; + esac + else + case `/usr/bin/file conftest.$ac_objext` in + *32-bit*) + LD="${LD-ld} -32" + ;; + *N32*) + LD="${LD-ld} -n32" + ;; + *64-bit*) + LD="${LD-ld} -64" + ;; + esac + fi fi - acl_save_prefix="$prefix" - prefix="$acl_final_prefix" - eval acl_final_exec_prefix=\"$acl_final_exec_prefix\" - prefix="$acl_save_prefix" + rm -rf conftest* + ;; -# Make sure we can run config.sub. -$SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 || - as_fn_error "cannot run $SHELL $ac_aux_dir/config.sub" "$LINENO" 5 +x86_64-*kfreebsd*-gnu|x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*| \ +s390*-*linux*|s390*-*tpf*|sparc*-*linux*) + # Find out which ABI we are using. + echo 'int i;' > conftest.$ac_ext + if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + case `/usr/bin/file conftest.o` in + *32-bit*) + case $host in + x86_64-*kfreebsd*-gnu) + LD="${LD-ld} -m elf_i386_fbsd" + ;; + x86_64-*linux*) + LD="${LD-ld} -m elf_i386" + ;; + ppc64-*linux*|powerpc64-*linux*) + LD="${LD-ld} -m elf32ppclinux" + ;; + s390x-*linux*) + LD="${LD-ld} -m elf_s390" + ;; + sparc64-*linux*) + LD="${LD-ld} -m elf32_sparc" + ;; + esac + ;; + *64-bit*) + case $host in + x86_64-*kfreebsd*-gnu) + LD="${LD-ld} -m elf_x86_64_fbsd" + ;; + x86_64-*linux*) + LD="${LD-ld} -m elf_x86_64" + ;; + ppc*-*linux*|powerpc*-*linux*) + LD="${LD-ld} -m elf64ppc" + ;; + s390*-*linux*|s390*-*tpf*) + LD="${LD-ld} -m elf64_s390" + ;; + sparc*-*linux*) + LD="${LD-ld} -m elf64_sparc" + ;; + esac + ;; + esac + fi + rm -rf conftest* + ;; -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking build system type" >&5 -$as_echo_n "checking build system type... " >&6; } -if test "${ac_cv_build+set}" = set; then : +*-*-sco3.2v5*) + # On SCO OpenServer 5, we need -belf to get full-featured binaries. + SAVE_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS -belf" + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler needs -belf" >&5 +$as_echo_n "checking whether the C compiler needs -belf... " >&6; } +if ${lt_cv_cc_needs_belf+:} false; then : $as_echo_n "(cached) " >&6 else - ac_build_alias=$build_alias -test "x$ac_build_alias" = x && - ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"` -test "x$ac_build_alias" = x && - as_fn_error "cannot guess build type; you must specify one" "$LINENO" 5 -ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` || - as_fn_error "$SHELL $ac_aux_dir/config.sub $ac_build_alias failed" "$LINENO" 5 + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_build" >&5 -$as_echo "$ac_cv_build" >&6; } -case $ac_cv_build in -*-*-*) ;; -*) as_fn_error "invalid value of canonical build" "$LINENO" 5;; -esac -build=$ac_cv_build -ac_save_IFS=$IFS; IFS='-' -set x $ac_cv_build -shift -build_cpu=$1 -build_vendor=$2 -shift; shift -# Remember, the first character of IFS is used to create $*, -# except with old shells: -build_os=$* -IFS=$ac_save_IFS -case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +int +main () +{ -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking host system type" >&5 -$as_echo_n "checking host system type... " >&6; } -if test "${ac_cv_host+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test "x$host_alias" = x; then - ac_cv_host=$ac_cv_build + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + lt_cv_cc_needs_belf=yes else - ac_cv_host=`$SHELL "$ac_aux_dir/config.sub" $host_alias` || - as_fn_error "$SHELL $ac_aux_dir/config.sub $host_alias failed" "$LINENO" 5 + lt_cv_cc_needs_belf=no fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_host" >&5 -$as_echo "$ac_cv_host" >&6; } -case $ac_cv_host in -*-*-*) ;; -*) as_fn_error "invalid value of canonical host" "$LINENO" 5;; +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_cc_needs_belf" >&5 +$as_echo "$lt_cv_cc_needs_belf" >&6; } + if test x"$lt_cv_cc_needs_belf" != x"yes"; then + # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf + CFLAGS="$SAVE_CFLAGS" + fi + ;; +*-*solaris*) + # Find out which ABI we are using. + echo 'int i;' > conftest.$ac_ext + if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + case `/usr/bin/file conftest.o` in + *64-bit*) + case $lt_cv_prog_gnu_ld in + yes*) + case $host in + i?86-*-solaris*) + LD="${LD-ld} -m elf_x86_64" + ;; + sparc*-*-solaris*) + LD="${LD-ld} -m elf64_sparc" + ;; + esac + # GNU ld 2.21 introduced _sol2 emulations. Use them if available. + if ${LD-ld} -V | grep _sol2 >/dev/null 2>&1; then + LD="${LD-ld}_sol2" + fi + ;; + *) + if ${LD-ld} -64 -r -o conftest2.o conftest.o >/dev/null 2>&1; then + LD="${LD-ld} -64" + fi + ;; + esac + ;; + esac + fi + rm -rf conftest* + ;; esac -host=$ac_cv_host -ac_save_IFS=$IFS; IFS='-' -set x $ac_cv_host -shift -host_cpu=$1 -host_vendor=$2 -shift; shift -# Remember, the first character of IFS is used to create $*, -# except with old shells: -host_os=$* -IFS=$ac_save_IFS -case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac +need_locks="$enable_libtool_lock" - -# Check whether --with-gnu-ld was given. -if test "${with_gnu_ld+set}" = set; then : - withval=$with_gnu_ld; test "$withval" = no || with_gnu_ld=yes +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}mt", so it can be a program name with args. +set dummy ${ac_tool_prefix}mt; 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_prog_MANIFEST_TOOL+:} false; then : + $as_echo_n "(cached) " >&6 else - with_gnu_ld=no -fi - -# Prepare PATH_SEPARATOR. -# The user is always right. -if test "${PATH_SEPARATOR+set}" != set; then - echo "#! /bin/sh" >conf$$.sh - echo "exit 0" >>conf$$.sh - chmod +x conf$$.sh - if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then - PATH_SEPARATOR=';' - else - PATH_SEPARATOR=: + if test -n "$MANIFEST_TOOL"; then + ac_cv_prog_MANIFEST_TOOL="$MANIFEST_TOOL" # Let the user override the test. +else +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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_MANIFEST_TOOL="${ac_tool_prefix}mt" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 fi - rm -f conf$$.sh +done + done +IFS=$as_save_IFS + fi -ac_prog=ld -if test "$GCC" = yes; then - # Check if gcc -print-prog-name=ld gives a path. - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ld used by GCC" >&5 -$as_echo_n "checking for ld used by GCC... " >&6; } - case $host in - *-*-mingw*) - # gcc leaves a trailing carriage return which upsets mingw - ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; - *) - ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; - esac - case $ac_prog in - # Accept absolute paths. - [\\/]* | [A-Za-z]:[\\/]*) - re_direlt='/[^/][^/]*/\.\./' - # Canonicalize the path of ld - ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'` - while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do - ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"` - done - test -z "$LD" && LD="$ac_prog" - ;; - "") - # If it fails, then pretend we aren't using GCC. - ac_prog=ld - ;; - *) - # If it is relative, then search for the first ld in PATH. - with_gnu_ld=unknown - ;; - esac -elif test "$with_gnu_ld" = yes; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU ld" >&5 -$as_echo_n "checking for GNU ld... " >&6; } +fi +MANIFEST_TOOL=$ac_cv_prog_MANIFEST_TOOL +if test -n "$MANIFEST_TOOL"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MANIFEST_TOOL" >&5 +$as_echo "$MANIFEST_TOOL" >&6; } else - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for non-GNU ld" >&5 -$as_echo_n "checking for non-GNU ld... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } fi -if test "${acl_cv_path_LD+set}" = set; then : + + +fi +if test -z "$ac_cv_prog_MANIFEST_TOOL"; then + ac_ct_MANIFEST_TOOL=$MANIFEST_TOOL + # Extract the first word of "mt", so it can be a program name with args. +set dummy mt; 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_prog_ac_ct_MANIFEST_TOOL+:} false; then : $as_echo_n "(cached) " >&6 else - if test -z "$LD"; then - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}" - for ac_dir in $PATH; do - test -z "$ac_dir" && ac_dir=. - if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then - acl_cv_path_LD="$ac_dir/$ac_prog" - # Check to see if the program is GNU ld. I'd rather use --version, - # but apparently some GNU ld's only accept -v. - # Break only if it was the GNU/non-GNU ld that we prefer. - case `"$acl_cv_path_LD" -v 2>&1 < /dev/null` in - *GNU* | *'with BFD'*) - test "$with_gnu_ld" != no && break ;; - *) - test "$with_gnu_ld" != yes && break ;; - esac - fi - done - IFS="$ac_save_ifs" + if test -n "$ac_ct_MANIFEST_TOOL"; then + ac_cv_prog_ac_ct_MANIFEST_TOOL="$ac_ct_MANIFEST_TOOL" # Let the user override the test. else - acl_cv_path_LD="$LD" # 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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_ac_ct_MANIFEST_TOOL="mt" + $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 + fi fi - -LD="$acl_cv_path_LD" -if test -n "$LD"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LD" >&5 -$as_echo "$LD" >&6; } +ac_ct_MANIFEST_TOOL=$ac_cv_prog_ac_ct_MANIFEST_TOOL +if test -n "$ac_ct_MANIFEST_TOOL"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_MANIFEST_TOOL" >&5 +$as_echo "$ac_ct_MANIFEST_TOOL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi -test -z "$LD" && as_fn_error "no acceptable ld found in \$PATH" "$LINENO" 5 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if the linker ($LD) is GNU ld" >&5 -$as_echo_n "checking if the linker ($LD) is GNU ld... " >&6; } -if test "${acl_cv_prog_gnu_ld+set}" = set; then : + + if test "x$ac_ct_MANIFEST_TOOL" = x; then + MANIFEST_TOOL=":" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + MANIFEST_TOOL=$ac_ct_MANIFEST_TOOL + fi +else + MANIFEST_TOOL="$ac_cv_prog_MANIFEST_TOOL" +fi + +test -z "$MANIFEST_TOOL" && MANIFEST_TOOL=mt +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if $MANIFEST_TOOL is a manifest tool" >&5 +$as_echo_n "checking if $MANIFEST_TOOL is a manifest tool... " >&6; } +if ${lt_cv_path_mainfest_tool+:} false; then : $as_echo_n "(cached) " >&6 else - # I'd rather use --version here, but apparently some GNU ld's only accept -v. -case `$LD -v 2>&1 &5 + $MANIFEST_TOOL '-?' 2>conftest.err > conftest.out + cat conftest.err >&5 + if $GREP 'Manifest Tool' conftest.out > /dev/null; then + lt_cv_path_mainfest_tool=yes + fi + rm -f conftest* +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_path_mainfest_tool" >&5 +$as_echo "$lt_cv_path_mainfest_tool" >&6; } +if test "x$lt_cv_path_mainfest_tool" != xyes; then + MANIFEST_TOOL=: fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $acl_cv_prog_gnu_ld" >&5 -$as_echo "$acl_cv_prog_gnu_ld" >&6; } -with_gnu_ld=$acl_cv_prog_gnu_ld - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for shared library run path origin" >&5 -$as_echo_n "checking for shared library run path origin... " >&6; } -if test "${acl_cv_rpath+set}" = set; then : + + + case $host_os in + rhapsody* | darwin*) + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}dsymutil", so it can be a program name with args. +set dummy ${ac_tool_prefix}dsymutil; 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_prog_DSYMUTIL+:} false; then : $as_echo_n "(cached) " >&6 else - - CC="$CC" GCC="$GCC" LDFLAGS="$LDFLAGS" LD="$LD" with_gnu_ld="$with_gnu_ld" \ - ${CONFIG_SHELL-/bin/sh} "$ac_aux_dir/config.rpath" "$host" > conftest.sh - . ./conftest.sh - rm -f ./conftest.sh - acl_cv_rpath=done + if test -n "$DSYMUTIL"; then + ac_cv_prog_DSYMUTIL="$DSYMUTIL" # Let the user override the test. +else +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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_DSYMUTIL="${ac_tool_prefix}dsymutil" + $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 fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $acl_cv_rpath" >&5 -$as_echo "$acl_cv_rpath" >&6; } - wl="$acl_cv_wl" - acl_libext="$acl_cv_libext" - acl_shlibext="$acl_cv_shlibext" - acl_libname_spec="$acl_cv_libname_spec" - acl_library_names_spec="$acl_cv_library_names_spec" - acl_hardcode_libdir_flag_spec="$acl_cv_hardcode_libdir_flag_spec" - acl_hardcode_libdir_separator="$acl_cv_hardcode_libdir_separator" - acl_hardcode_direct="$acl_cv_hardcode_direct" - acl_hardcode_minus_L="$acl_cv_hardcode_minus_L" - # Check whether --enable-rpath was given. -if test "${enable_rpath+set}" = set; then : - enableval=$enable_rpath; : +fi +DSYMUTIL=$ac_cv_prog_DSYMUTIL +if test -n "$DSYMUTIL"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DSYMUTIL" >&5 +$as_echo "$DSYMUTIL" >&6; } else - enable_rpath=yes + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } fi -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5 -$as_echo_n "checking how to run the C preprocessor... " >&6; } -# On Suns, sometimes $CPP names a directory. -if test -n "$CPP" && test -d "$CPP"; then - CPP= fi -if test -z "$CPP"; then - if test "${ac_cv_prog_CPP+set}" = set; then : +if test -z "$ac_cv_prog_DSYMUTIL"; then + ac_ct_DSYMUTIL=$DSYMUTIL + # Extract the first word of "dsymutil", so it can be a program name with args. +set dummy dsymutil; 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_prog_ac_ct_DSYMUTIL+:} false; then : $as_echo_n "(cached) " >&6 else - # Double quotes because CPP needs to be expanded - for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" - do - ac_preproc_ok=false -for ac_c_preproc_warn_flag in '' yes + if test -n "$ac_ct_DSYMUTIL"; then + ac_cv_prog_ac_ct_DSYMUTIL="$ac_ct_DSYMUTIL" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH do - # Use a header file that comes with gcc, so configuring glibc - # with a fresh cross-compiler works. - # Prefer to if __STDC__ is defined, since - # exists even on freestanding compilers. - # On the NeXT, cc -E runs the code through the compiler's parser, - # not just through cpp. "Syntax error" is here to catch this case. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#ifdef __STDC__ -# include -#else -# include -#endif - Syntax error -_ACEOF -if ac_fn_c_try_cpp "$LINENO"; then : + 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 + ac_cv_prog_ac_ct_DSYMUTIL="dsymutil" + $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 -else - # Broken: fails on valid input. -continue fi -rm -f conftest.err conftest.$ac_ext - - # OK, works on sane cases. Now check whether nonexistent headers - # can be detected and how. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -_ACEOF -if ac_fn_c_try_cpp "$LINENO"; then : - # Broken: success on invalid input. -continue +fi +ac_ct_DSYMUTIL=$ac_cv_prog_ac_ct_DSYMUTIL +if test -n "$ac_ct_DSYMUTIL"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DSYMUTIL" >&5 +$as_echo "$ac_ct_DSYMUTIL" >&6; } else - # Passes both tests. -ac_preproc_ok=: -break + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } fi -rm -f conftest.err conftest.$ac_ext -done -# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. -rm -f conftest.err conftest.$ac_ext -if $ac_preproc_ok; then : - break + if test "x$ac_ct_DSYMUTIL" = x; then + DSYMUTIL=":" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + DSYMUTIL=$ac_ct_DSYMUTIL + fi +else + DSYMUTIL="$ac_cv_prog_DSYMUTIL" fi - done - ac_cv_prog_CPP=$CPP - -fi - CPP=$ac_cv_prog_CPP + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}nmedit", so it can be a program name with args. +set dummy ${ac_tool_prefix}nmedit; 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_prog_NMEDIT+:} false; then : + $as_echo_n "(cached) " >&6 else - ac_cv_prog_CPP=$CPP + if test -n "$NMEDIT"; then + ac_cv_prog_NMEDIT="$NMEDIT" # Let the user override the test. +else +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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_NMEDIT="${ac_tool_prefix}nmedit" + $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 + fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5 -$as_echo "$CPP" >&6; } -ac_preproc_ok=false -for ac_c_preproc_warn_flag in '' yes +fi +NMEDIT=$ac_cv_prog_NMEDIT +if test -n "$NMEDIT"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $NMEDIT" >&5 +$as_echo "$NMEDIT" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_NMEDIT"; then + ac_ct_NMEDIT=$NMEDIT + # Extract the first word of "nmedit", so it can be a program name with args. +set dummy nmedit; 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_prog_ac_ct_NMEDIT+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_NMEDIT"; then + ac_cv_prog_ac_ct_NMEDIT="$ac_ct_NMEDIT" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH do - # Use a header file that comes with gcc, so configuring glibc - # with a fresh cross-compiler works. - # Prefer to if __STDC__ is defined, since - # exists even on freestanding compilers. - # On the NeXT, cc -E runs the code through the compiler's parser, - # not just through cpp. "Syntax error" is here to catch this case. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#ifdef __STDC__ -# include -#else -# include -#endif - Syntax error -_ACEOF -if ac_fn_c_try_cpp "$LINENO"; then : + 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 + ac_cv_prog_ac_ct_NMEDIT="nmedit" + $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 +fi +fi +ac_ct_NMEDIT=$ac_cv_prog_ac_ct_NMEDIT +if test -n "$ac_ct_NMEDIT"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_NMEDIT" >&5 +$as_echo "$ac_ct_NMEDIT" >&6; } else - # Broken: fails on valid input. -continue + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } fi -rm -f conftest.err conftest.$ac_ext - # OK, works on sane cases. Now check whether nonexistent headers - # can be detected and how. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -_ACEOF -if ac_fn_c_try_cpp "$LINENO"; then : - # Broken: success on invalid input. -continue + if test "x$ac_ct_NMEDIT" = x; then + NMEDIT=":" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + NMEDIT=$ac_ct_NMEDIT + fi else - # Passes both tests. -ac_preproc_ok=: -break + NMEDIT="$ac_cv_prog_NMEDIT" fi -rm -f conftest.err conftest.$ac_ext + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}lipo", so it can be a program name with args. +set dummy ${ac_tool_prefix}lipo; 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_prog_LIPO+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$LIPO"; then + ac_cv_prog_LIPO="$LIPO" # Let the user override the test. +else +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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_LIPO="${ac_tool_prefix}lipo" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi done -# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. -rm -f conftest.err conftest.$ac_ext -if $ac_preproc_ok; then : + done +IFS=$as_save_IFS +fi +fi +LIPO=$ac_cv_prog_LIPO +if test -n "$LIPO"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LIPO" >&5 +$as_echo "$LIPO" >&6; } else - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error "C preprocessor \"$CPP\" fails sanity check -See \`config.log' for more details." "$LINENO" 5; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } fi -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5 -$as_echo_n "checking for grep that handles long lines and -e... " >&6; } -if test "${ac_cv_path_GREP+set}" = set; then : +fi +if test -z "$ac_cv_prog_LIPO"; then + ac_ct_LIPO=$LIPO + # Extract the first word of "lipo", so it can be a program name with args. +set dummy lipo; 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_prog_ac_ct_LIPO+:} false; then : $as_echo_n "(cached) " >&6 else - if test -z "$GREP"; then - ac_path_GREP_found=false - # Loop through the user's path and test for each of PROGNAME-LIST - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin + if test -n "$ac_ct_LIPO"; then + ac_cv_prog_ac_ct_LIPO="$ac_ct_LIPO" # Let the user override the test. +else +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_prog in grep ggrep; do for ac_exec_ext in '' $ac_executable_extensions; do - ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" - { test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue -# Check for GNU ac_path_GREP and select it if it is found. - # Check for GNU $ac_path_GREP -case `"$ac_path_GREP" --version 2>&1` in -*GNU*) - ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;; -*) - ac_count=0 - $as_echo_n 0123456789 >"conftest.in" - while : - do - cat "conftest.in" "conftest.in" >"conftest.tmp" - mv "conftest.tmp" "conftest.in" - cp "conftest.in" "conftest.nl" - $as_echo 'GREP' >> "conftest.nl" - "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break - diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break - as_fn_arith $ac_count + 1 && ac_count=$as_val - if test $ac_count -gt ${ac_path_GREP_max-0}; then - # Best one so far, save it but keep looking for a better one - ac_cv_path_GREP="$ac_path_GREP" - ac_path_GREP_max=$ac_count - fi - # 10*(2^10) chars as input seems more than enough - test $ac_count -gt 10 && break - done - rm -f conftest.in conftest.tmp conftest.nl conftest.out;; -esac - - $ac_path_GREP_found && break 3 - done - done + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_ac_ct_LIPO="lipo" + $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 - if test -z "$ac_cv_path_GREP"; then - as_fn_error "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 - fi + +fi +fi +ac_ct_LIPO=$ac_cv_prog_ac_ct_LIPO +if test -n "$ac_ct_LIPO"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_LIPO" >&5 +$as_echo "$ac_ct_LIPO" >&6; } else - ac_cv_path_GREP=$GREP + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } fi + if test "x$ac_ct_LIPO" = x; then + LIPO=":" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + LIPO=$ac_ct_LIPO + fi +else + LIPO="$ac_cv_prog_LIPO" fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5 -$as_echo "$ac_cv_path_GREP" >&6; } - GREP="$ac_cv_path_GREP" - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5 -$as_echo_n "checking for egrep... " >&6; } -if test "${ac_cv_path_EGREP+set}" = set; then : + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}otool", so it can be a program name with args. +set dummy ${ac_tool_prefix}otool; 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_prog_OTOOL+:} false; then : $as_echo_n "(cached) " >&6 else - if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 - then ac_cv_path_EGREP="$GREP -E" - else - if test -z "$EGREP"; then - ac_path_EGREP_found=false - # Loop through the user's path and test for each of PROGNAME-LIST - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin + if test -n "$OTOOL"; then + ac_cv_prog_OTOOL="$OTOOL" # Let the user override the test. +else +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_prog in egrep; do for ac_exec_ext in '' $ac_executable_extensions; do - ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" - { test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue -# Check for GNU ac_path_EGREP and select it if it is found. - # Check for GNU $ac_path_EGREP -case `"$ac_path_EGREP" --version 2>&1` in -*GNU*) - ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;; -*) - ac_count=0 - $as_echo_n 0123456789 >"conftest.in" - while : - do - cat "conftest.in" "conftest.in" >"conftest.tmp" - mv "conftest.tmp" "conftest.in" - cp "conftest.in" "conftest.nl" - $as_echo 'EGREP' >> "conftest.nl" - "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break - diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break - as_fn_arith $ac_count + 1 && ac_count=$as_val - if test $ac_count -gt ${ac_path_EGREP_max-0}; then - # Best one so far, save it but keep looking for a better one - ac_cv_path_EGREP="$ac_path_EGREP" - ac_path_EGREP_max=$ac_count - fi - # 10*(2^10) chars as input seems more than enough - test $ac_count -gt 10 && break - done - rm -f conftest.in conftest.tmp conftest.nl conftest.out;; -esac - - $ac_path_EGREP_found && break 3 - done - done + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_OTOOL="${ac_tool_prefix}otool" + $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 - if test -z "$ac_cv_path_EGREP"; then - as_fn_error "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 - fi + +fi +fi +OTOOL=$ac_cv_prog_OTOOL +if test -n "$OTOOL"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OTOOL" >&5 +$as_echo "$OTOOL" >&6; } else - ac_cv_path_EGREP=$EGREP + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } fi - fi + fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5 -$as_echo "$ac_cv_path_EGREP" >&6; } - EGREP="$ac_cv_path_EGREP" +if test -z "$ac_cv_prog_OTOOL"; then + ac_ct_OTOOL=$OTOOL + # Extract the first word of "otool", so it can be a program name with args. +set dummy otool; 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_prog_ac_ct_OTOOL+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_OTOOL"; then + ac_cv_prog_ac_ct_OTOOL="$ac_ct_OTOOL" # Let the user override the test. +else +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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_ac_ct_OTOOL="otool" + $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 +fi +fi +ac_ct_OTOOL=$ac_cv_prog_ac_ct_OTOOL +if test -n "$ac_ct_OTOOL"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OTOOL" >&5 +$as_echo "$ac_ct_OTOOL" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + if test "x$ac_ct_OTOOL" = x; then + OTOOL=":" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + OTOOL=$ac_ct_OTOOL + fi +else + OTOOL="$ac_cv_prog_OTOOL" +fi + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}otool64", so it can be a program name with args. +set dummy ${ac_tool_prefix}otool64; 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_prog_OTOOL64+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$OTOOL64"; then + ac_cv_prog_OTOOL64="$OTOOL64" # Let the user override the test. +else +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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_OTOOL64="${ac_tool_prefix}otool64" + $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 - acl_libdirstem=lib - acl_libdirstem2= - case "$host_os" in - solaris*) - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for 64-bit host" >&5 -$as_echo_n "checking for 64-bit host... " >&6; } -if test "${gl_cv_solaris_64bit+set}" = set; then : +fi +fi +OTOOL64=$ac_cv_prog_OTOOL64 +if test -n "$OTOOL64"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OTOOL64" >&5 +$as_echo "$OTOOL64" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_OTOOL64"; then + ac_ct_OTOOL64=$OTOOL64 + # Extract the first word of "otool64", so it can be a program name with args. +set dummy otool64; 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_prog_ac_ct_OTOOL64+:} false; then : $as_echo_n "(cached) " >&6 else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ + if test -n "$ac_ct_OTOOL64"; then + ac_cv_prog_ac_ct_OTOOL64="$ac_ct_OTOOL64" # Let the user override the test. +else +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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_ac_ct_OTOOL64="otool64" + $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 -#ifdef _LP64 -sixtyfour bits -#endif +fi +fi +ac_ct_OTOOL64=$ac_cv_prog_ac_ct_OTOOL64 +if test -n "$ac_ct_OTOOL64"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OTOOL64" >&5 +$as_echo "$ac_ct_OTOOL64" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi -_ACEOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "sixtyfour bits" >/dev/null 2>&1; then : - gl_cv_solaris_64bit=yes + if test "x$ac_ct_OTOOL64" = x; then + OTOOL64=":" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + OTOOL64=$ac_ct_OTOOL64 + fi else - gl_cv_solaris_64bit=no + OTOOL64="$ac_cv_prog_OTOOL64" fi -rm -f conftest* -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_solaris_64bit" >&5 -$as_echo "$gl_cv_solaris_64bit" >&6; } - if test $gl_cv_solaris_64bit = yes; then - acl_libdirstem=lib/64 - case "$host_cpu" in - sparc*) acl_libdirstem2=lib/sparcv9 ;; - i*86 | x86_64) acl_libdirstem2=lib/amd64 ;; - esac - fi - ;; - *) - searchpath=`(LC_ALL=C $CC -print-search-dirs) 2>/dev/null | sed -n -e 's,^libraries: ,,p' | sed -e 's,^=,,'` - if test -n "$searchpath"; then - acl_save_IFS="${IFS= }"; IFS=":" - for searchdir in $searchpath; do - if test -d "$searchdir"; then - case "$searchdir" in - */lib64/ | */lib64 ) acl_libdirstem=lib64 ;; - */../ | */.. ) - # Better ignore directories of this form. They are misleading. - ;; - *) searchdir=`cd "$searchdir" && pwd` - case "$searchdir" in - */lib64 ) acl_libdirstem=lib64 ;; - esac ;; - esac - fi - done - IFS="$acl_save_IFS" - fi - ;; - esac - test -n "$acl_libdirstem2" || acl_libdirstem2="$acl_libdirstem" @@ -5408,60 +7205,6559 @@ - use_additional=yes - acl_save_prefix="$prefix" - prefix="$acl_final_prefix" - acl_save_exec_prefix="$exec_prefix" - exec_prefix="$acl_final_exec_prefix" - eval additional_includedir=\"$includedir\" - eval additional_libdir=\"$libdir\" - exec_prefix="$acl_save_exec_prefix" - prefix="$acl_save_prefix" -# Check whether --with-libiconv-prefix was given. -if test "${with_libiconv_prefix+set}" = set; then : - withval=$with_libiconv_prefix; - if test "X$withval" = "Xno"; then - use_additional=no - else - if test "X$withval" = "X"; then - acl_save_prefix="$prefix" - prefix="$acl_final_prefix" - acl_save_exec_prefix="$exec_prefix" - exec_prefix="$acl_final_exec_prefix" - eval additional_includedir=\"$includedir\" - eval additional_libdir=\"$libdir\" - exec_prefix="$acl_save_exec_prefix" - prefix="$acl_save_prefix" + + + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -single_module linker flag" >&5 +$as_echo_n "checking for -single_module linker flag... " >&6; } +if ${lt_cv_apple_cc_single_mod+:} false; then : + $as_echo_n "(cached) " >&6 +else + lt_cv_apple_cc_single_mod=no + if test -z "${LT_MULTI_MODULE}"; then + # By default we will add the -single_module flag. You can override + # by either setting the environment variable LT_MULTI_MODULE + # non-empty at configure time, or by adding -multi_module to the + # link flags. + rm -rf libconftest.dylib* + echo "int foo(void){return 1;}" > conftest.c + echo "$LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ +-dynamiclib -Wl,-single_module conftest.c" >&5 + $LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ + -dynamiclib -Wl,-single_module conftest.c 2>conftest.err + _lt_result=$? + # If there is a non-empty error log, and "single_module" + # appears in it, assume the flag caused a linker warning + if test -s conftest.err && $GREP single_module conftest.err; then + cat conftest.err >&5 + # Otherwise, if the output was created with a 0 exit code from + # the compiler, it worked. + elif test -f libconftest.dylib && test $_lt_result -eq 0; then + lt_cv_apple_cc_single_mod=yes + else + cat conftest.err >&5 + fi + rm -rf libconftest.dylib* + rm -f conftest.* + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_apple_cc_single_mod" >&5 +$as_echo "$lt_cv_apple_cc_single_mod" >&6; } + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -exported_symbols_list linker flag" >&5 +$as_echo_n "checking for -exported_symbols_list linker flag... " >&6; } +if ${lt_cv_ld_exported_symbols_list+:} false; then : + $as_echo_n "(cached) " >&6 +else + lt_cv_ld_exported_symbols_list=no + save_LDFLAGS=$LDFLAGS + echo "_main" > conftest.sym + LDFLAGS="$LDFLAGS -Wl,-exported_symbols_list,conftest.sym" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + lt_cv_ld_exported_symbols_list=yes +else + lt_cv_ld_exported_symbols_list=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + LDFLAGS="$save_LDFLAGS" + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_exported_symbols_list" >&5 +$as_echo "$lt_cv_ld_exported_symbols_list" >&6; } + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -force_load linker flag" >&5 +$as_echo_n "checking for -force_load linker flag... " >&6; } +if ${lt_cv_ld_force_load+:} false; then : + $as_echo_n "(cached) " >&6 +else + lt_cv_ld_force_load=no + cat > conftest.c << _LT_EOF +int forced_loaded() { return 2;} +_LT_EOF + echo "$LTCC $LTCFLAGS -c -o conftest.o conftest.c" >&5 + $LTCC $LTCFLAGS -c -o conftest.o conftest.c 2>&5 + echo "$AR cru libconftest.a conftest.o" >&5 + $AR cru libconftest.a conftest.o 2>&5 + echo "$RANLIB libconftest.a" >&5 + $RANLIB libconftest.a 2>&5 + cat > conftest.c << _LT_EOF +int main() { return 0;} +_LT_EOF + echo "$LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a" >&5 + $LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a 2>conftest.err + _lt_result=$? + if test -s conftest.err && $GREP force_load conftest.err; then + cat conftest.err >&5 + elif test -f conftest && test $_lt_result -eq 0 && $GREP forced_load conftest >/dev/null 2>&1 ; then + lt_cv_ld_force_load=yes else - additional_includedir="$withval/include" - additional_libdir="$withval/$acl_libdirstem" - if test "$acl_libdirstem2" != "$acl_libdirstem" \ - && ! test -d "$withval/$acl_libdirstem"; then - additional_libdir="$withval/$acl_libdirstem2" - fi + cat conftest.err >&5 fi + rm -f conftest.err libconftest.a conftest conftest.c + rm -rf conftest.dSYM + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_force_load" >&5 +$as_echo "$lt_cv_ld_force_load" >&6; } + case $host_os in + rhapsody* | darwin1.[012]) + _lt_dar_allow_undefined='${wl}-undefined ${wl}suppress' ;; + darwin1.*) + _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;; + darwin*) # darwin 5.x on + # if running on 10.5 or later, the deployment target defaults + # to the OS version, if on x86, and 10.4, the deployment + # target defaults to 10.4. Don't you love it? + case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in + 10.0,*86*-darwin8*|10.0,*-darwin[91]*) + _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;; + 10.[012]*) + _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;; + 10.*) + _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;; + esac + ;; + esac + if test "$lt_cv_apple_cc_single_mod" = "yes"; then + _lt_dar_single_mod='$single_module' + fi + if test "$lt_cv_ld_exported_symbols_list" = "yes"; then + _lt_dar_export_syms=' ${wl}-exported_symbols_list,$output_objdir/${libname}-symbols.expsym' + else + _lt_dar_export_syms='~$NMEDIT -s $output_objdir/${libname}-symbols.expsym ${lib}' + fi + if test "$DSYMUTIL" != ":" && test "$lt_cv_ld_force_load" = "no"; then + _lt_dsymutil='~$DSYMUTIL $lib || :' + else + _lt_dsymutil= fi + ;; + esac +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5 +$as_echo_n "checking how to run the C preprocessor... " >&6; } +# On Suns, sometimes $CPP names a directory. +if test -n "$CPP" && test -d "$CPP"; then + CPP= fi +if test -z "$CPP"; then + if ${ac_cv_prog_CPP+:} false; then : + $as_echo_n "(cached) " >&6 +else + # Double quotes because CPP needs to be expanded + for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" + do + ac_preproc_ok=false +for ac_c_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # Prefer to if __STDC__ is defined, since + # exists even on freestanding compilers. + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. "Syntax error" is here to catch this case. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#ifdef __STDC__ +# include +#else +# include +#endif + Syntax error +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : - LIBICONV= - LTLIBICONV= +else + # Broken: fails on valid input. +continue +fi +rm -f conftest.err conftest.i conftest.$ac_ext + + # OK, works on sane cases. Now check whether nonexistent headers + # can be detected and how. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + # Broken: success on invalid input. +continue +else + # Passes both tests. +ac_preproc_ok=: +break +fi +rm -f conftest.err conftest.i conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.i conftest.err conftest.$ac_ext +if $ac_preproc_ok; then : + break +fi + + done + ac_cv_prog_CPP=$CPP + +fi + CPP=$ac_cv_prog_CPP +else + ac_cv_prog_CPP=$CPP +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5 +$as_echo "$CPP" >&6; } +ac_preproc_ok=false +for ac_c_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # Prefer to if __STDC__ is defined, since + # exists even on freestanding compilers. + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. "Syntax error" is here to catch this case. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#ifdef __STDC__ +# include +#else +# include +#endif + Syntax error +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + +else + # Broken: fails on valid input. +continue +fi +rm -f conftest.err conftest.i conftest.$ac_ext + + # OK, works on sane cases. Now check whether nonexistent headers + # can be detected and how. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + # Broken: success on invalid input. +continue +else + # Passes both tests. +ac_preproc_ok=: +break +fi +rm -f conftest.err conftest.i conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.i conftest.err conftest.$ac_ext +if $ac_preproc_ok; then : + +else + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "C preprocessor \"$CPP\" fails sanity check +See \`config.log' for more details" "$LINENO" 5; } +fi + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 +$as_echo_n "checking for ANSI C header files... " >&6; } +if ${ac_cv_header_stdc+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include +#include +#include + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_header_stdc=yes +else + ac_cv_header_stdc=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +if test $ac_cv_header_stdc = yes; then + # SunOS 4.x string.h does not declare mem*, contrary to ANSI. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "memchr" >/dev/null 2>&1; then : + +else + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "free" >/dev/null 2>&1; then : + +else + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. + if test "$cross_compiling" = yes; then : + : +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include +#if ((' ' & 0x0FF) == 0x020) +# define ISLOWER(c) ('a' <= (c) && (c) <= 'z') +# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) +#else +# define ISLOWER(c) \ + (('a' <= (c) && (c) <= 'i') \ + || ('j' <= (c) && (c) <= 'r') \ + || ('s' <= (c) && (c) <= 'z')) +# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) +#endif + +#define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) +int +main () +{ + int i; + for (i = 0; i < 256; i++) + if (XOR (islower (i), ISLOWER (i)) + || toupper (i) != TOUPPER (i)) + return 2; + return 0; +} +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + +else + ac_cv_header_stdc=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + +fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5 +$as_echo "$ac_cv_header_stdc" >&6; } +if test $ac_cv_header_stdc = yes; then + +$as_echo "#define STDC_HEADERS 1" >>confdefs.h + +fi + +# On IRIX 5.3, sys/types and inttypes.h are conflicting. +for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ + inttypes.h stdint.h unistd.h +do : + as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default +" +if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + + +for ac_header in dlfcn.h +do : + ac_fn_c_check_header_compile "$LINENO" "dlfcn.h" "ac_cv_header_dlfcn_h" "$ac_includes_default +" +if test "x$ac_cv_header_dlfcn_h" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_DLFCN_H 1 +_ACEOF + +fi + +done + + + + + +# Set options + + + + enable_dlopen=no + + + enable_win32_dll=no + + + # Check whether --enable-shared was given. +if test "${enable_shared+set}" = set; then : + enableval=$enable_shared; p=${PACKAGE-default} + case $enableval in + yes) enable_shared=yes ;; + no) enable_shared=no ;; + *) + enable_shared=no + # Look at the argument we got. We use all the common list separators. + lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," + for pkg in $enableval; do + IFS="$lt_save_ifs" + if test "X$pkg" = "X$p"; then + enable_shared=yes + fi + done + IFS="$lt_save_ifs" + ;; + esac +else + enable_shared=yes +fi + + + + + + + + + + + +# Check whether --with-pic was given. +if test "${with_pic+set}" = set; then : + withval=$with_pic; lt_p=${PACKAGE-default} + case $withval in + yes|no) pic_mode=$withval ;; + *) + pic_mode=default + # Look at the argument we got. We use all the common list separators. + lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," + for lt_pkg in $withval; do + IFS="$lt_save_ifs" + if test "X$lt_pkg" = "X$lt_p"; then + pic_mode=yes + fi + done + IFS="$lt_save_ifs" + ;; + esac +else + pic_mode=default +fi + + +test -z "$pic_mode" && pic_mode=default + + + + + + + + # Check whether --enable-fast-install was given. +if test "${enable_fast_install+set}" = set; then : + enableval=$enable_fast_install; p=${PACKAGE-default} + case $enableval in + yes) enable_fast_install=yes ;; + no) enable_fast_install=no ;; + *) + enable_fast_install=no + # Look at the argument we got. We use all the common list separators. + lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," + for pkg in $enableval; do + IFS="$lt_save_ifs" + if test "X$pkg" = "X$p"; then + enable_fast_install=yes + fi + done + IFS="$lt_save_ifs" + ;; + esac +else + enable_fast_install=yes +fi + + + + + + + + + + + +# This can be used to rebuild libtool when needed +LIBTOOL_DEPS="$ltmain" + +# Always use our own libtool. +LIBTOOL='$(SHELL) $(top_builddir)/libtool' + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +test -z "$LN_S" && LN_S="ln -s" + + + + + + + + + + + + + + +if test -n "${ZSH_VERSION+set}" ; then + setopt NO_GLOB_SUBST +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for objdir" >&5 +$as_echo_n "checking for objdir... " >&6; } +if ${lt_cv_objdir+:} false; then : + $as_echo_n "(cached) " >&6 +else + rm -f .libs 2>/dev/null +mkdir .libs 2>/dev/null +if test -d .libs; then + lt_cv_objdir=.libs +else + # MS-DOS does not allow filenames that begin with a dot. + lt_cv_objdir=_libs +fi +rmdir .libs 2>/dev/null +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_objdir" >&5 +$as_echo "$lt_cv_objdir" >&6; } +objdir=$lt_cv_objdir + + + + + +cat >>confdefs.h <<_ACEOF +#define LT_OBJDIR "$lt_cv_objdir/" +_ACEOF + + + + +case $host_os in +aix3*) + # AIX sometimes has problems with the GCC collect2 program. For some + # reason, if we set the COLLECT_NAMES environment variable, the problems + # vanish in a puff of smoke. + if test "X${COLLECT_NAMES+set}" != Xset; then + COLLECT_NAMES= + export COLLECT_NAMES + fi + ;; +esac + +# Global variables: +ofile=libtool +can_build_shared=yes + +# All known linkers require a `.a' archive for static linking (except MSVC, +# which needs '.lib'). +libext=a + +with_gnu_ld="$lt_cv_prog_gnu_ld" + +old_CC="$CC" +old_CFLAGS="$CFLAGS" + +# Set sane defaults for various variables +test -z "$CC" && CC=cc +test -z "$LTCC" && LTCC=$CC +test -z "$LTCFLAGS" && LTCFLAGS=$CFLAGS +test -z "$LD" && LD=ld +test -z "$ac_objext" && ac_objext=o + +for cc_temp in $compiler""; do + case $cc_temp in + compile | *[\\/]compile | ccache | *[\\/]ccache ) ;; + distcc | *[\\/]distcc | purify | *[\\/]purify ) ;; + \-*) ;; + *) break;; + esac +done +cc_basename=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"` + + +# Only perform the check for file, if the check method requires it +test -z "$MAGIC_CMD" && MAGIC_CMD=file +case $deplibs_check_method in +file_magic*) + if test "$file_magic_cmd" = '$MAGIC_CMD'; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ${ac_tool_prefix}file" >&5 +$as_echo_n "checking for ${ac_tool_prefix}file... " >&6; } +if ${lt_cv_path_MAGIC_CMD+:} false; then : + $as_echo_n "(cached) " >&6 +else + case $MAGIC_CMD in +[\\/*] | ?:[\\/]*) + lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path. + ;; +*) + lt_save_MAGIC_CMD="$MAGIC_CMD" + lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR + ac_dummy="/usr/bin$PATH_SEPARATOR$PATH" + for ac_dir in $ac_dummy; do + IFS="$lt_save_ifs" + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/${ac_tool_prefix}file; then + lt_cv_path_MAGIC_CMD="$ac_dir/${ac_tool_prefix}file" + if test -n "$file_magic_test_file"; then + case $deplibs_check_method in + "file_magic "*) + file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"` + MAGIC_CMD="$lt_cv_path_MAGIC_CMD" + if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | + $EGREP "$file_magic_regex" > /dev/null; then + : + else + cat <<_LT_EOF 1>&2 + +*** Warning: the command libtool uses to detect shared libraries, +*** $file_magic_cmd, produces output that libtool cannot recognize. +*** The result is that libtool may fail to recognize shared libraries +*** as such. This will affect the creation of libtool libraries that +*** depend on shared libraries, but programs linked with such libtool +*** libraries will work regardless of this problem. Nevertheless, you +*** may want to report the problem to your system manager and/or to +*** bug-libtool@gnu.org + +_LT_EOF + fi ;; + esac + fi + break + fi + done + IFS="$lt_save_ifs" + MAGIC_CMD="$lt_save_MAGIC_CMD" + ;; +esac +fi + +MAGIC_CMD="$lt_cv_path_MAGIC_CMD" +if test -n "$MAGIC_CMD"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MAGIC_CMD" >&5 +$as_echo "$MAGIC_CMD" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + + + +if test -z "$lt_cv_path_MAGIC_CMD"; then + if test -n "$ac_tool_prefix"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for file" >&5 +$as_echo_n "checking for file... " >&6; } +if ${lt_cv_path_MAGIC_CMD+:} false; then : + $as_echo_n "(cached) " >&6 +else + case $MAGIC_CMD in +[\\/*] | ?:[\\/]*) + lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path. + ;; +*) + lt_save_MAGIC_CMD="$MAGIC_CMD" + lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR + ac_dummy="/usr/bin$PATH_SEPARATOR$PATH" + for ac_dir in $ac_dummy; do + IFS="$lt_save_ifs" + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/file; then + lt_cv_path_MAGIC_CMD="$ac_dir/file" + if test -n "$file_magic_test_file"; then + case $deplibs_check_method in + "file_magic "*) + file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"` + MAGIC_CMD="$lt_cv_path_MAGIC_CMD" + if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | + $EGREP "$file_magic_regex" > /dev/null; then + : + else + cat <<_LT_EOF 1>&2 + +*** Warning: the command libtool uses to detect shared libraries, +*** $file_magic_cmd, produces output that libtool cannot recognize. +*** The result is that libtool may fail to recognize shared libraries +*** as such. This will affect the creation of libtool libraries that +*** depend on shared libraries, but programs linked with such libtool +*** libraries will work regardless of this problem. Nevertheless, you +*** may want to report the problem to your system manager and/or to +*** bug-libtool@gnu.org + +_LT_EOF + fi ;; + esac + fi + break + fi + done + IFS="$lt_save_ifs" + MAGIC_CMD="$lt_save_MAGIC_CMD" + ;; +esac +fi + +MAGIC_CMD="$lt_cv_path_MAGIC_CMD" +if test -n "$MAGIC_CMD"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MAGIC_CMD" >&5 +$as_echo "$MAGIC_CMD" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + else + MAGIC_CMD=: + fi +fi + + fi + ;; +esac + +# Use C for the default configuration in the libtool script + +lt_save_CC="$CC" +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + +# Source file extension for C test sources. +ac_ext=c + +# Object file extension for compiled C test sources. +objext=o +objext=$objext + +# Code to be used in simple compile tests +lt_simple_compile_test_code="int some_variable = 0;" + +# Code to be used in simple link tests +lt_simple_link_test_code='int main(){return(0);}' + + + + + + + +# If no C compiler was specified, use CC. +LTCC=${LTCC-"$CC"} + +# If no C compiler flags were specified, use CFLAGS. +LTCFLAGS=${LTCFLAGS-"$CFLAGS"} + +# Allow CC to be a program name with arguments. +compiler=$CC + +# Save the default compiler, since it gets overwritten when the other +# tags are being tested, and _LT_TAGVAR(compiler, []) is a NOP. +compiler_DEFAULT=$CC + +# save warnings/boilerplate of simple test code +ac_outfile=conftest.$ac_objext +echo "$lt_simple_compile_test_code" >conftest.$ac_ext +eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err +_lt_compiler_boilerplate=`cat conftest.err` +$RM conftest* + +ac_outfile=conftest.$ac_objext +echo "$lt_simple_link_test_code" >conftest.$ac_ext +eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err +_lt_linker_boilerplate=`cat conftest.err` +$RM -r conftest* + + +## CAVEAT EMPTOR: +## There is no encapsulation within the following macros, do not change +## the running order or otherwise move them around unless you know exactly +## what you are doing... +if test -n "$compiler"; then + +lt_prog_compiler_no_builtin_flag= + +if test "$GCC" = yes; then + case $cc_basename in + nvcc*) + lt_prog_compiler_no_builtin_flag=' -Xcompiler -fno-builtin' ;; + *) + lt_prog_compiler_no_builtin_flag=' -fno-builtin' ;; + esac + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -fno-rtti -fno-exceptions" >&5 +$as_echo_n "checking if $compiler supports -fno-rtti -fno-exceptions... " >&6; } +if ${lt_cv_prog_compiler_rtti_exceptions+:} false; then : + $as_echo_n "(cached) " >&6 +else + lt_cv_prog_compiler_rtti_exceptions=no + ac_outfile=conftest.$ac_objext + echo "$lt_simple_compile_test_code" > conftest.$ac_ext + lt_compiler_flag="-fno-rtti -fno-exceptions" + # Insert the option either (1) after the last *FLAGS variable, or + # (2) before a word containing "conftest.", or (3) at the end. + # Note that $ac_compile itself does not contain backslashes and begins + # with a dollar sign (not a hyphen), so the echo should work correctly. + # The option is referenced via a variable to avoid confusing sed. + lt_compile=`echo "$ac_compile" | $SED \ + -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ + -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ + -e 's:$: $lt_compiler_flag:'` + (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5) + (eval "$lt_compile" 2>conftest.err) + ac_status=$? + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + if (exit $ac_status) && test -s "$ac_outfile"; then + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings other than the usual output. + $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' >conftest.exp + $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 + if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then + lt_cv_prog_compiler_rtti_exceptions=yes + fi + fi + $RM conftest* + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_rtti_exceptions" >&5 +$as_echo "$lt_cv_prog_compiler_rtti_exceptions" >&6; } + +if test x"$lt_cv_prog_compiler_rtti_exceptions" = xyes; then + lt_prog_compiler_no_builtin_flag="$lt_prog_compiler_no_builtin_flag -fno-rtti -fno-exceptions" +else + : +fi + +fi + + + + + + + lt_prog_compiler_wl= +lt_prog_compiler_pic= +lt_prog_compiler_static= + + + if test "$GCC" = yes; then + lt_prog_compiler_wl='-Wl,' + lt_prog_compiler_static='-static' + + case $host_os in + aix*) + # All AIX code is PIC. + if test "$host_cpu" = ia64; then + # AIX 5 now supports IA64 processor + lt_prog_compiler_static='-Bstatic' + fi + ;; + + amigaos*) + case $host_cpu in + powerpc) + # see comment about AmigaOS4 .so support + lt_prog_compiler_pic='-fPIC' + ;; + m68k) + # FIXME: we need at least 68020 code to build shared libraries, but + # adding the `-m68020' flag to GCC prevents building anything better, + # like `-m68040'. + lt_prog_compiler_pic='-m68020 -resident32 -malways-restore-a4' + ;; + esac + ;; + + beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) + # PIC is the default for these OSes. + ;; + + mingw* | cygwin* | pw32* | os2* | cegcc*) + # This hack is so that the source file can tell whether it is being + # built for inclusion in a dll (and should export symbols for example). + # Although the cygwin gcc ignores -fPIC, still need this for old-style + # (--disable-auto-import) libraries + lt_prog_compiler_pic='-DDLL_EXPORT' + ;; + + darwin* | rhapsody*) + # PIC is the default on this platform + # Common symbols not allowed in MH_DYLIB files + lt_prog_compiler_pic='-fno-common' + ;; + + haiku*) + # PIC is the default for Haiku. + # The "-static" flag exists, but is broken. + lt_prog_compiler_static= + ;; + + hpux*) + # PIC is the default for 64-bit PA HP-UX, but not for 32-bit + # PA HP-UX. On IA64 HP-UX, PIC is the default but the pic flag + # sets the default TLS model and affects inlining. + case $host_cpu in + hppa*64*) + # +Z the default + ;; + *) + lt_prog_compiler_pic='-fPIC' + ;; + esac + ;; + + interix[3-9]*) + # Interix 3.x gcc -fpic/-fPIC options generate broken code. + # Instead, we relocate shared libraries at runtime. + ;; + + msdosdjgpp*) + # Just because we use GCC doesn't mean we suddenly get shared libraries + # on systems that don't support them. + lt_prog_compiler_can_build_shared=no + enable_shared=no + ;; + + *nto* | *qnx*) + # QNX uses GNU C++, but need to define -shared option too, otherwise + # it will coredump. + lt_prog_compiler_pic='-fPIC -shared' + ;; + + sysv4*MP*) + if test -d /usr/nec; then + lt_prog_compiler_pic=-Kconform_pic + fi + ;; + + *) + lt_prog_compiler_pic='-fPIC' + ;; + esac + + case $cc_basename in + nvcc*) # Cuda Compiler Driver 2.2 + lt_prog_compiler_wl='-Xlinker ' + if test -n "$lt_prog_compiler_pic"; then + lt_prog_compiler_pic="-Xcompiler $lt_prog_compiler_pic" + fi + ;; + esac + else + # PORTME Check for flag to pass linker flags through the system compiler. + case $host_os in + aix*) + lt_prog_compiler_wl='-Wl,' + if test "$host_cpu" = ia64; then + # AIX 5 now supports IA64 processor + lt_prog_compiler_static='-Bstatic' + else + lt_prog_compiler_static='-bnso -bI:/lib/syscalls.exp' + fi + ;; + + mingw* | cygwin* | pw32* | os2* | cegcc*) + # This hack is so that the source file can tell whether it is being + # built for inclusion in a dll (and should export symbols for example). + lt_prog_compiler_pic='-DDLL_EXPORT' + ;; + + hpux9* | hpux10* | hpux11*) + lt_prog_compiler_wl='-Wl,' + # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but + # not for PA HP-UX. + case $host_cpu in + hppa*64*|ia64*) + # +Z the default + ;; + *) + lt_prog_compiler_pic='+Z' + ;; + esac + # Is there a better lt_prog_compiler_static that works with the bundled CC? + lt_prog_compiler_static='${wl}-a ${wl}archive' + ;; + + irix5* | irix6* | nonstopux*) + lt_prog_compiler_wl='-Wl,' + # PIC (with -KPIC) is the default. + lt_prog_compiler_static='-non_shared' + ;; + + linux* | k*bsd*-gnu | kopensolaris*-gnu) + case $cc_basename in + # old Intel for x86_64 which still supported -KPIC. + ecc*) + lt_prog_compiler_wl='-Wl,' + lt_prog_compiler_pic='-KPIC' + lt_prog_compiler_static='-static' + ;; + # icc used to be incompatible with GCC. + # ICC 10 doesn't accept -KPIC any more. + icc* | ifort*) + lt_prog_compiler_wl='-Wl,' + lt_prog_compiler_pic='-fPIC' + lt_prog_compiler_static='-static' + ;; + # Lahey Fortran 8.1. + lf95*) + lt_prog_compiler_wl='-Wl,' + lt_prog_compiler_pic='--shared' + lt_prog_compiler_static='--static' + ;; + nagfor*) + # NAG Fortran compiler + lt_prog_compiler_wl='-Wl,-Wl,,' + lt_prog_compiler_pic='-PIC' + lt_prog_compiler_static='-Bstatic' + ;; + pgcc* | pgf77* | pgf90* | pgf95* | pgfortran*) + # Portland Group compilers (*not* the Pentium gcc compiler, + # which looks to be a dead project) + lt_prog_compiler_wl='-Wl,' + lt_prog_compiler_pic='-fpic' + lt_prog_compiler_static='-Bstatic' + ;; + ccc*) + lt_prog_compiler_wl='-Wl,' + # All Alpha code is PIC. + lt_prog_compiler_static='-non_shared' + ;; + xl* | bgxl* | bgf* | mpixl*) + # IBM XL C 8.0/Fortran 10.1, 11.1 on PPC and BlueGene + lt_prog_compiler_wl='-Wl,' + lt_prog_compiler_pic='-qpic' + lt_prog_compiler_static='-qstaticlink' + ;; + *) + case `$CC -V 2>&1 | sed 5q` in + *Sun\ Ceres\ Fortran* | *Sun*Fortran*\ [1-7].* | *Sun*Fortran*\ 8.[0-3]*) + # Sun Fortran 8.3 passes all unrecognized flags to the linker + lt_prog_compiler_pic='-KPIC' + lt_prog_compiler_static='-Bstatic' + lt_prog_compiler_wl='' + ;; + *Sun\ F* | *Sun*Fortran*) + lt_prog_compiler_pic='-KPIC' + lt_prog_compiler_static='-Bstatic' + lt_prog_compiler_wl='-Qoption ld ' + ;; + *Sun\ C*) + # Sun C 5.9 + lt_prog_compiler_pic='-KPIC' + lt_prog_compiler_static='-Bstatic' + lt_prog_compiler_wl='-Wl,' + ;; + *Intel*\ [CF]*Compiler*) + lt_prog_compiler_wl='-Wl,' + lt_prog_compiler_pic='-fPIC' + lt_prog_compiler_static='-static' + ;; + *Portland\ Group*) + lt_prog_compiler_wl='-Wl,' + lt_prog_compiler_pic='-fpic' + lt_prog_compiler_static='-Bstatic' + ;; + esac + ;; + esac + ;; + + newsos6) + lt_prog_compiler_pic='-KPIC' + lt_prog_compiler_static='-Bstatic' + ;; + + *nto* | *qnx*) + # QNX uses GNU C++, but need to define -shared option too, otherwise + # it will coredump. + lt_prog_compiler_pic='-fPIC -shared' + ;; + + osf3* | osf4* | osf5*) + lt_prog_compiler_wl='-Wl,' + # All OSF/1 code is PIC. + lt_prog_compiler_static='-non_shared' + ;; + + rdos*) + lt_prog_compiler_static='-non_shared' + ;; + + solaris*) + lt_prog_compiler_pic='-KPIC' + lt_prog_compiler_static='-Bstatic' + case $cc_basename in + f77* | f90* | f95* | sunf77* | sunf90* | sunf95*) + lt_prog_compiler_wl='-Qoption ld ';; + *) + lt_prog_compiler_wl='-Wl,';; + esac + ;; + + sunos4*) + lt_prog_compiler_wl='-Qoption ld ' + lt_prog_compiler_pic='-PIC' + lt_prog_compiler_static='-Bstatic' + ;; + + sysv4 | sysv4.2uw2* | sysv4.3*) + lt_prog_compiler_wl='-Wl,' + lt_prog_compiler_pic='-KPIC' + lt_prog_compiler_static='-Bstatic' + ;; + + sysv4*MP*) + if test -d /usr/nec ;then + lt_prog_compiler_pic='-Kconform_pic' + lt_prog_compiler_static='-Bstatic' + fi + ;; + + sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) + lt_prog_compiler_wl='-Wl,' + lt_prog_compiler_pic='-KPIC' + lt_prog_compiler_static='-Bstatic' + ;; + + unicos*) + lt_prog_compiler_wl='-Wl,' + lt_prog_compiler_can_build_shared=no + ;; + + uts4*) + lt_prog_compiler_pic='-pic' + lt_prog_compiler_static='-Bstatic' + ;; + + *) + lt_prog_compiler_can_build_shared=no + ;; + esac + fi + +case $host_os in + # For platforms which do not support PIC, -DPIC is meaningless: + *djgpp*) + lt_prog_compiler_pic= + ;; + *) + lt_prog_compiler_pic="$lt_prog_compiler_pic -DPIC" + ;; +esac + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $compiler option to produce PIC" >&5 +$as_echo_n "checking for $compiler option to produce PIC... " >&6; } +if ${lt_cv_prog_compiler_pic+:} false; then : + $as_echo_n "(cached) " >&6 +else + lt_cv_prog_compiler_pic=$lt_prog_compiler_pic +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic" >&5 +$as_echo "$lt_cv_prog_compiler_pic" >&6; } +lt_prog_compiler_pic=$lt_cv_prog_compiler_pic + +# +# Check to make sure the PIC flag actually works. +# +if test -n "$lt_prog_compiler_pic"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler PIC flag $lt_prog_compiler_pic works" >&5 +$as_echo_n "checking if $compiler PIC flag $lt_prog_compiler_pic works... " >&6; } +if ${lt_cv_prog_compiler_pic_works+:} false; then : + $as_echo_n "(cached) " >&6 +else + lt_cv_prog_compiler_pic_works=no + ac_outfile=conftest.$ac_objext + echo "$lt_simple_compile_test_code" > conftest.$ac_ext + lt_compiler_flag="$lt_prog_compiler_pic -DPIC" + # Insert the option either (1) after the last *FLAGS variable, or + # (2) before a word containing "conftest.", or (3) at the end. + # Note that $ac_compile itself does not contain backslashes and begins + # with a dollar sign (not a hyphen), so the echo should work correctly. + # The option is referenced via a variable to avoid confusing sed. + lt_compile=`echo "$ac_compile" | $SED \ + -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ + -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ + -e 's:$: $lt_compiler_flag:'` + (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5) + (eval "$lt_compile" 2>conftest.err) + ac_status=$? + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + if (exit $ac_status) && test -s "$ac_outfile"; then + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings other than the usual output. + $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' >conftest.exp + $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 + if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then + lt_cv_prog_compiler_pic_works=yes + fi + fi + $RM conftest* + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic_works" >&5 +$as_echo "$lt_cv_prog_compiler_pic_works" >&6; } + +if test x"$lt_cv_prog_compiler_pic_works" = xyes; then + case $lt_prog_compiler_pic in + "" | " "*) ;; + *) lt_prog_compiler_pic=" $lt_prog_compiler_pic" ;; + esac +else + lt_prog_compiler_pic= + lt_prog_compiler_can_build_shared=no +fi + +fi + + + + + + + + + + + +# +# Check to make sure the static flag actually works. +# +wl=$lt_prog_compiler_wl eval lt_tmp_static_flag=\"$lt_prog_compiler_static\" +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler static flag $lt_tmp_static_flag works" >&5 +$as_echo_n "checking if $compiler static flag $lt_tmp_static_flag works... " >&6; } +if ${lt_cv_prog_compiler_static_works+:} false; then : + $as_echo_n "(cached) " >&6 +else + lt_cv_prog_compiler_static_works=no + save_LDFLAGS="$LDFLAGS" + LDFLAGS="$LDFLAGS $lt_tmp_static_flag" + echo "$lt_simple_link_test_code" > conftest.$ac_ext + if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then + # The linker can only warn and ignore the option if not recognized + # So say no if there are warnings + if test -s conftest.err; then + # Append any errors to the config.log. + cat conftest.err 1>&5 + $ECHO "$_lt_linker_boilerplate" | $SED '/^$/d' > conftest.exp + $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 + if diff conftest.exp conftest.er2 >/dev/null; then + lt_cv_prog_compiler_static_works=yes + fi + else + lt_cv_prog_compiler_static_works=yes + fi + fi + $RM -r conftest* + LDFLAGS="$save_LDFLAGS" + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_static_works" >&5 +$as_echo "$lt_cv_prog_compiler_static_works" >&6; } + +if test x"$lt_cv_prog_compiler_static_works" = xyes; then + : +else + lt_prog_compiler_static= +fi + + + + + + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5 +$as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; } +if ${lt_cv_prog_compiler_c_o+:} false; then : + $as_echo_n "(cached) " >&6 +else + lt_cv_prog_compiler_c_o=no + $RM -r conftest 2>/dev/null + mkdir conftest + cd conftest + mkdir out + echo "$lt_simple_compile_test_code" > conftest.$ac_ext + + lt_compiler_flag="-o out/conftest2.$ac_objext" + # Insert the option either (1) after the last *FLAGS variable, or + # (2) before a word containing "conftest.", or (3) at the end. + # Note that $ac_compile itself does not contain backslashes and begins + # with a dollar sign (not a hyphen), so the echo should work correctly. + lt_compile=`echo "$ac_compile" | $SED \ + -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ + -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ + -e 's:$: $lt_compiler_flag:'` + (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5) + (eval "$lt_compile" 2>out/conftest.err) + ac_status=$? + cat out/conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + if (exit $ac_status) && test -s out/conftest2.$ac_objext + then + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings + $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp + $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 + if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then + lt_cv_prog_compiler_c_o=yes + fi + fi + chmod u+w . 2>&5 + $RM conftest* + # SGI C++ compiler will create directory out/ii_files/ for + # template instantiation + test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files + $RM out/* && rmdir out + cd .. + $RM -r conftest + $RM conftest* + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o" >&5 +$as_echo "$lt_cv_prog_compiler_c_o" >&6; } + + + + + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5 +$as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; } +if ${lt_cv_prog_compiler_c_o+:} false; then : + $as_echo_n "(cached) " >&6 +else + lt_cv_prog_compiler_c_o=no + $RM -r conftest 2>/dev/null + mkdir conftest + cd conftest + mkdir out + echo "$lt_simple_compile_test_code" > conftest.$ac_ext + + lt_compiler_flag="-o out/conftest2.$ac_objext" + # Insert the option either (1) after the last *FLAGS variable, or + # (2) before a word containing "conftest.", or (3) at the end. + # Note that $ac_compile itself does not contain backslashes and begins + # with a dollar sign (not a hyphen), so the echo should work correctly. + lt_compile=`echo "$ac_compile" | $SED \ + -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ + -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ + -e 's:$: $lt_compiler_flag:'` + (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5) + (eval "$lt_compile" 2>out/conftest.err) + ac_status=$? + cat out/conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + if (exit $ac_status) && test -s out/conftest2.$ac_objext + then + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings + $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp + $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 + if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then + lt_cv_prog_compiler_c_o=yes + fi + fi + chmod u+w . 2>&5 + $RM conftest* + # SGI C++ compiler will create directory out/ii_files/ for + # template instantiation + test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files + $RM out/* && rmdir out + cd .. + $RM -r conftest + $RM conftest* + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o" >&5 +$as_echo "$lt_cv_prog_compiler_c_o" >&6; } + + + + +hard_links="nottested" +if test "$lt_cv_prog_compiler_c_o" = no && test "$need_locks" != no; then + # do not overwrite the value of need_locks provided by the user + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if we can lock with hard links" >&5 +$as_echo_n "checking if we can lock with hard links... " >&6; } + hard_links=yes + $RM conftest* + ln conftest.a conftest.b 2>/dev/null && hard_links=no + touch conftest.a + ln conftest.a conftest.b 2>&5 || hard_links=no + ln conftest.a conftest.b 2>/dev/null && hard_links=no + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $hard_links" >&5 +$as_echo "$hard_links" >&6; } + if test "$hard_links" = no; then + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5 +$as_echo "$as_me: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2;} + need_locks=warn + fi +else + need_locks=no +fi + + + + + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the $compiler linker ($LD) supports shared libraries" >&5 +$as_echo_n "checking whether the $compiler linker ($LD) supports shared libraries... " >&6; } + + runpath_var= + allow_undefined_flag= + always_export_symbols=no + archive_cmds= + archive_expsym_cmds= + compiler_needs_object=no + enable_shared_with_static_runtimes=no + export_dynamic_flag_spec= + export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' + hardcode_automatic=no + hardcode_direct=no + hardcode_direct_absolute=no + hardcode_libdir_flag_spec= + hardcode_libdir_separator= + hardcode_minus_L=no + hardcode_shlibpath_var=unsupported + inherit_rpath=no + link_all_deplibs=unknown + module_cmds= + module_expsym_cmds= + old_archive_from_new_cmds= + old_archive_from_expsyms_cmds= + thread_safe_flag_spec= + whole_archive_flag_spec= + # include_expsyms should be a list of space-separated symbols to be *always* + # included in the symbol list + include_expsyms= + # exclude_expsyms can be an extended regexp of symbols to exclude + # it will be wrapped by ` (' and `)$', so one must not match beginning or + # end of line. Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc', + # as well as any symbol that contains `d'. + exclude_expsyms='_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*' + # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out + # platforms (ab)use it in PIC code, but their linkers get confused if + # the symbol is explicitly referenced. Since portable code cannot + # rely on this symbol name, it's probably fine to never include it in + # preloaded symbol tables. + # Exclude shared library initialization/finalization symbols. + extract_expsyms_cmds= + + case $host_os in + cygwin* | mingw* | pw32* | cegcc*) + # FIXME: the MSVC++ port hasn't been tested in a loooong time + # When not using gcc, we currently assume that we are using + # Microsoft Visual C++. + if test "$GCC" != yes; then + with_gnu_ld=no + fi + ;; + interix*) + # we just hope/assume this is gcc and not c89 (= MSVC++) + with_gnu_ld=yes + ;; + openbsd*) + with_gnu_ld=no + ;; + linux* | k*bsd*-gnu | gnu*) + link_all_deplibs=no + ;; + esac + + ld_shlibs=yes + + # On some targets, GNU ld is compatible enough with the native linker + # that we're better off using the native interface for both. + lt_use_gnu_ld_interface=no + if test "$with_gnu_ld" = yes; then + case $host_os in + aix*) + # The AIX port of GNU ld has always aspired to compatibility + # with the native linker. However, as the warning in the GNU ld + # block says, versions before 2.19.5* couldn't really create working + # shared libraries, regardless of the interface used. + case `$LD -v 2>&1` in + *\ \(GNU\ Binutils\)\ 2.19.5*) ;; + *\ \(GNU\ Binutils\)\ 2.[2-9]*) ;; + *\ \(GNU\ Binutils\)\ [3-9]*) ;; + *) + lt_use_gnu_ld_interface=yes + ;; + esac + ;; + *) + lt_use_gnu_ld_interface=yes + ;; + esac + fi + + if test "$lt_use_gnu_ld_interface" = yes; then + # If archive_cmds runs LD, not CC, wlarc should be empty + wlarc='${wl}' + + # Set some defaults for GNU ld with shared library support. These + # are reset later if shared libraries are not supported. Putting them + # here allows them to be overridden if necessary. + runpath_var=LD_RUN_PATH + hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' + export_dynamic_flag_spec='${wl}--export-dynamic' + # ancient GNU ld didn't support --whole-archive et. al. + if $LD --help 2>&1 | $GREP 'no-whole-archive' > /dev/null; then + whole_archive_flag_spec="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' + else + whole_archive_flag_spec= + fi + supports_anon_versioning=no + case `$LD -v 2>&1` in + *GNU\ gold*) supports_anon_versioning=yes ;; + *\ [01].* | *\ 2.[0-9].* | *\ 2.10.*) ;; # catch versions < 2.11 + *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ... + *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ... + *\ 2.11.*) ;; # other 2.11 versions + *) supports_anon_versioning=yes ;; + esac + + # See if GNU ld supports shared libraries. + case $host_os in + aix[3-9]*) + # On AIX/PPC, the GNU linker is very broken + if test "$host_cpu" != ia64; then + ld_shlibs=no + cat <<_LT_EOF 1>&2 + +*** Warning: the GNU linker, at least up to release 2.19, is reported +*** to be unable to reliably create shared libraries on AIX. +*** Therefore, libtool is disabling shared libraries support. If you +*** really care for shared libraries, you may want to install binutils +*** 2.20 or above, or modify your PATH so that a non-GNU linker is found. +*** You will then need to restart the configuration process. + +_LT_EOF + fi + ;; + + amigaos*) + case $host_cpu in + powerpc) + # see comment about AmigaOS4 .so support + archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + archive_expsym_cmds='' + ;; + m68k) + archive_cmds='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' + hardcode_libdir_flag_spec='-L$libdir' + hardcode_minus_L=yes + ;; + esac + ;; + + beos*) + if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then + allow_undefined_flag=unsupported + # Joseph Beckenbach says some releases of gcc + # support --undefined. This deserves some investigation. FIXME + archive_cmds='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + else + ld_shlibs=no + fi + ;; + + cygwin* | mingw* | pw32* | cegcc*) + # _LT_TAGVAR(hardcode_libdir_flag_spec, ) is actually meaningless, + # as there is no search path for DLLs. + hardcode_libdir_flag_spec='-L$libdir' + export_dynamic_flag_spec='${wl}--export-all-symbols' + allow_undefined_flag=unsupported + always_export_symbols=no + enable_shared_with_static_runtimes=yes + export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1 DATA/;s/^.*[ ]__nm__\([^ ]*\)[ ][^ ]*/\1 DATA/;/^I[ ]/d;/^[AITW][ ]/s/.* //'\'' | sort | uniq > $export_symbols' + exclude_expsyms='[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname' + + if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then + archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' + # If the export-symbols file already is a .def file (1st line + # is EXPORTS), use it as is; otherwise, prepend... + archive_expsym_cmds='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then + cp $export_symbols $output_objdir/$soname.def; + else + echo EXPORTS > $output_objdir/$soname.def; + cat $export_symbols >> $output_objdir/$soname.def; + fi~ + $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' + else + ld_shlibs=no + fi + ;; + + haiku*) + archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + link_all_deplibs=yes + ;; + + interix[3-9]*) + hardcode_direct=no + hardcode_shlibpath_var=no + hardcode_libdir_flag_spec='${wl}-rpath,$libdir' + export_dynamic_flag_spec='${wl}-E' + # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. + # Instead, shared libraries are loaded at an image base (0x10000000 by + # default) and relocated if they conflict, which is a slow very memory + # consuming and fragmenting process. To avoid this, we pick a random, + # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link + # time. Moving up from 0x10000000 also allows more sbrk(2) space. + archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' + archive_expsym_cmds='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' + ;; + + gnu* | linux* | tpf* | k*bsd*-gnu | kopensolaris*-gnu) + tmp_diet=no + if test "$host_os" = linux-dietlibc; then + case $cc_basename in + diet\ *) tmp_diet=yes;; # linux-dietlibc with static linking (!diet-dyn) + esac + fi + if $LD --help 2>&1 | $EGREP ': supported targets:.* elf' > /dev/null \ + && test "$tmp_diet" = no + then + tmp_addflag=' $pic_flag' + tmp_sharedflag='-shared' + case $cc_basename,$host_cpu in + pgcc*) # Portland Group C compiler + whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' + tmp_addflag=' $pic_flag' + ;; + pgf77* | pgf90* | pgf95* | pgfortran*) + # Portland Group f77 and f90 compilers + whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' + tmp_addflag=' $pic_flag -Mnomain' ;; + ecc*,ia64* | icc*,ia64*) # Intel C compiler on ia64 + tmp_addflag=' -i_dynamic' ;; + efc*,ia64* | ifort*,ia64*) # Intel Fortran compiler on ia64 + tmp_addflag=' -i_dynamic -nofor_main' ;; + ifc* | ifort*) # Intel Fortran compiler + tmp_addflag=' -nofor_main' ;; + lf95*) # Lahey Fortran 8.1 + whole_archive_flag_spec= + tmp_sharedflag='--shared' ;; + xl[cC]* | bgxl[cC]* | mpixl[cC]*) # IBM XL C 8.0 on PPC (deal with xlf below) + tmp_sharedflag='-qmkshrobj' + tmp_addflag= ;; + nvcc*) # Cuda Compiler Driver 2.2 + whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' + compiler_needs_object=yes + ;; + esac + case `$CC -V 2>&1 | sed 5q` in + *Sun\ C*) # Sun C 5.9 + whole_archive_flag_spec='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' + compiler_needs_object=yes + tmp_sharedflag='-G' ;; + *Sun\ F*) # Sun Fortran 8.3 + tmp_sharedflag='-G' ;; + esac + archive_cmds='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + + if test "x$supports_anon_versioning" = xyes; then + archive_expsym_cmds='echo "{ global:" > $output_objdir/$libname.ver~ + cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ + echo "local: *; };" >> $output_objdir/$libname.ver~ + $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib' + fi + + case $cc_basename in + xlf* | bgf* | bgxlf* | mpixlf*) + # IBM XL Fortran 10.1 on PPC cannot create shared libs itself + whole_archive_flag_spec='--whole-archive$convenience --no-whole-archive' + hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' + archive_cmds='$LD -shared $libobjs $deplibs $linker_flags -soname $soname -o $lib' + if test "x$supports_anon_versioning" = xyes; then + archive_expsym_cmds='echo "{ global:" > $output_objdir/$libname.ver~ + cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ + echo "local: *; };" >> $output_objdir/$libname.ver~ + $LD -shared $libobjs $deplibs $linker_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib' + fi + ;; + esac + else + ld_shlibs=no + fi + ;; + + netbsd* | netbsdelf*-gnu) + if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then + archive_cmds='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib' + wlarc= + else + archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + fi + ;; + + solaris*) + if $LD -v 2>&1 | $GREP 'BFD 2\.8' > /dev/null; then + ld_shlibs=no + cat <<_LT_EOF 1>&2 + +*** Warning: The releases 2.8.* of the GNU linker cannot reliably +*** create shared libraries on Solaris systems. Therefore, libtool +*** is disabling shared libraries support. We urge you to upgrade GNU +*** binutils to release 2.9.1 or newer. Another option is to modify +*** your PATH or compiler configuration so that the native linker is +*** used, and then restart. + +_LT_EOF + elif $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then + archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + else + ld_shlibs=no + fi + ;; + + sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*) + case `$LD -v 2>&1` in + *\ [01].* | *\ 2.[0-9].* | *\ 2.1[0-5].*) + ld_shlibs=no + cat <<_LT_EOF 1>&2 + +*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not +*** reliably create shared libraries on SCO systems. Therefore, libtool +*** is disabling shared libraries support. We urge you to upgrade GNU +*** binutils to release 2.16.91.0.3 or newer. Another option is to modify +*** your PATH or compiler configuration so that the native linker is +*** used, and then restart. + +_LT_EOF + ;; + *) + # For security reasons, it is highly recommended that you always + # use absolute paths for naming shared libraries, and exclude the + # DT_RUNPATH tag from executables and libraries. But doing so + # requires that you compile everything twice, which is a pain. + if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then + hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' + archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + else + ld_shlibs=no + fi + ;; + esac + ;; + + sunos4*) + archive_cmds='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags' + wlarc= + hardcode_direct=yes + hardcode_shlibpath_var=no + ;; + + *) + if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then + archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + else + ld_shlibs=no + fi + ;; + esac + + if test "$ld_shlibs" = no; then + runpath_var= + hardcode_libdir_flag_spec= + export_dynamic_flag_spec= + whole_archive_flag_spec= + fi + else + # PORTME fill in a description of your system's linker (not GNU ld) + case $host_os in + aix3*) + allow_undefined_flag=unsupported + always_export_symbols=yes + archive_expsym_cmds='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname' + # Note: this linker hardcodes the directories in LIBPATH if there + # are no directories specified by -L. + hardcode_minus_L=yes + if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then + # Neither direct hardcoding nor static linking is supported with a + # broken collect2. + hardcode_direct=unsupported + fi + ;; + + aix[4-9]*) + if test "$host_cpu" = ia64; then + # On IA64, the linker does run time linking by default, so we don't + # have to do anything special. + aix_use_runtimelinking=no + exp_sym_flag='-Bexport' + no_entry_flag="" + else + # If we're using GNU nm, then we don't want the "-C" option. + # -C means demangle to AIX nm, but means don't demangle with GNU nm + # Also, AIX nm treats weak defined symbols like other global + # defined symbols, whereas GNU nm marks them as "W". + if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then + export_symbols_cmds='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' + else + export_symbols_cmds='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' + fi + aix_use_runtimelinking=no + + # Test if we are trying to use run time linking or normal + # AIX style linking. If -brtl is somewhere in LDFLAGS, we + # need to do runtime linking. + case $host_os in aix4.[23]|aix4.[23].*|aix[5-9]*) + for ld_flag in $LDFLAGS; do + if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then + aix_use_runtimelinking=yes + break + fi + done + ;; + esac + + exp_sym_flag='-bexport' + no_entry_flag='-bnoentry' + fi + + # When large executables or shared objects are built, AIX ld can + # have problems creating the table of contents. If linking a library + # or program results in "error TOC overflow" add -mminimal-toc to + # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not + # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. + + archive_cmds='' + hardcode_direct=yes + hardcode_direct_absolute=yes + hardcode_libdir_separator=':' + link_all_deplibs=yes + file_list_spec='${wl}-f,' + + if test "$GCC" = yes; then + case $host_os in aix4.[012]|aix4.[012].*) + # We only want to do this on AIX 4.2 and lower, the check + # below for broken collect2 doesn't work under 4.3+ + collect2name=`${CC} -print-prog-name=collect2` + if test -f "$collect2name" && + strings "$collect2name" | $GREP resolve_lib_name >/dev/null + then + # We have reworked collect2 + : + else + # We have old collect2 + hardcode_direct=unsupported + # It fails to find uninstalled libraries when the uninstalled + # path is not listed in the libpath. Setting hardcode_minus_L + # to unsupported forces relinking + hardcode_minus_L=yes + hardcode_libdir_flag_spec='-L$libdir' + hardcode_libdir_separator= + fi + ;; + esac + shared_flag='-shared' + if test "$aix_use_runtimelinking" = yes; then + shared_flag="$shared_flag "'${wl}-G' + fi + link_all_deplibs=no + else + # not using gcc + if test "$host_cpu" = ia64; then + # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release + # chokes on -Wl,-G. The following line is correct: + shared_flag='-G' + else + if test "$aix_use_runtimelinking" = yes; then + shared_flag='${wl}-G' + else + shared_flag='${wl}-bM:SRE' + fi + fi + fi + + export_dynamic_flag_spec='${wl}-bexpall' + # It seems that -bexpall does not export symbols beginning with + # underscore (_), so it is better to generate a list of symbols to export. + always_export_symbols=yes + if test "$aix_use_runtimelinking" = yes; then + # Warning - without using the other runtime loading flags (-brtl), + # -berok will link without error, but may produce a broken library. + allow_undefined_flag='-berok' + # Determine the default libpath from the value encoded in an + # empty executable. + if test "${lt_cv_aix_libpath+set}" = set; then + aix_libpath=$lt_cv_aix_libpath +else + if ${lt_cv_aix_libpath_+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + + lt_aix_libpath_sed=' + /Import File Strings/,/^$/ { + /^0/ { + s/^0 *\([^ ]*\) *$/\1/ + p + } + }' + lt_cv_aix_libpath_=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` + # Check for a 64-bit object if we didn't find anything. + if test -z "$lt_cv_aix_libpath_"; then + lt_cv_aix_libpath_=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` + fi +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + if test -z "$lt_cv_aix_libpath_"; then + lt_cv_aix_libpath_="/usr/lib:/lib" + fi + +fi + + aix_libpath=$lt_cv_aix_libpath_ +fi + + hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath" + archive_expsym_cmds='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then func_echo_all "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag" + else + if test "$host_cpu" = ia64; then + hardcode_libdir_flag_spec='${wl}-R $libdir:/usr/lib:/lib' + allow_undefined_flag="-z nodefs" + archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols" + else + # Determine the default libpath from the value encoded in an + # empty executable. + if test "${lt_cv_aix_libpath+set}" = set; then + aix_libpath=$lt_cv_aix_libpath +else + if ${lt_cv_aix_libpath_+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + + lt_aix_libpath_sed=' + /Import File Strings/,/^$/ { + /^0/ { + s/^0 *\([^ ]*\) *$/\1/ + p + } + }' + lt_cv_aix_libpath_=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` + # Check for a 64-bit object if we didn't find anything. + if test -z "$lt_cv_aix_libpath_"; then + lt_cv_aix_libpath_=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` + fi +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + if test -z "$lt_cv_aix_libpath_"; then + lt_cv_aix_libpath_="/usr/lib:/lib" + fi + +fi + + aix_libpath=$lt_cv_aix_libpath_ +fi + + hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath" + # Warning - without using the other run time loading flags, + # -berok will link without error, but may produce a broken library. + no_undefined_flag=' ${wl}-bernotok' + allow_undefined_flag=' ${wl}-berok' + if test "$with_gnu_ld" = yes; then + # We only use this code for GNU lds that support --whole-archive. + whole_archive_flag_spec='${wl}--whole-archive$convenience ${wl}--no-whole-archive' + else + # Exported symbols can be pulled into shared objects from archives + whole_archive_flag_spec='$convenience' + fi + archive_cmds_need_lc=yes + # This is similar to how AIX traditionally builds its shared libraries. + archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' + fi + fi + ;; + + amigaos*) + case $host_cpu in + powerpc) + # see comment about AmigaOS4 .so support + archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + archive_expsym_cmds='' + ;; + m68k) + archive_cmds='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' + hardcode_libdir_flag_spec='-L$libdir' + hardcode_minus_L=yes + ;; + esac + ;; + + bsdi[45]*) + export_dynamic_flag_spec=-rdynamic + ;; + + cygwin* | mingw* | pw32* | cegcc*) + # When not using gcc, we currently assume that we are using + # Microsoft Visual C++. + # hardcode_libdir_flag_spec is actually meaningless, as there is + # no search path for DLLs. + case $cc_basename in + cl*) + # Native MSVC + hardcode_libdir_flag_spec=' ' + allow_undefined_flag=unsupported + always_export_symbols=yes + file_list_spec='@' + # Tell ltmain to make .lib files, not .a files. + libext=lib + # Tell ltmain to make .dll files, not .so files. + shrext_cmds=".dll" + # FIXME: Setting linknames here is a bad hack. + archive_cmds='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-dll~linknames=' + archive_expsym_cmds='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then + sed -n -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' -e '1\\\!p' < $export_symbols > $output_objdir/$soname.exp; + else + sed -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' < $export_symbols > $output_objdir/$soname.exp; + fi~ + $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~ + linknames=' + # The linker will not automatically build a static lib if we build a DLL. + # _LT_TAGVAR(old_archive_from_new_cmds, )='true' + enable_shared_with_static_runtimes=yes + exclude_expsyms='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*' + export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1,DATA/'\'' | $SED -e '\''/^[AITW][ ]/s/.*[ ]//'\'' | sort | uniq > $export_symbols' + # Don't use ranlib + old_postinstall_cmds='chmod 644 $oldlib' + postlink_cmds='lt_outputfile="@OUTPUT@"~ + lt_tool_outputfile="@TOOL_OUTPUT@"~ + case $lt_outputfile in + *.exe|*.EXE) ;; + *) + lt_outputfile="$lt_outputfile.exe" + lt_tool_outputfile="$lt_tool_outputfile.exe" + ;; + esac~ + if test "$MANIFEST_TOOL" != ":" && test -f "$lt_outputfile.manifest"; then + $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1; + $RM "$lt_outputfile.manifest"; + fi' + ;; + *) + # Assume MSVC wrapper + hardcode_libdir_flag_spec=' ' + allow_undefined_flag=unsupported + # Tell ltmain to make .lib files, not .a files. + libext=lib + # Tell ltmain to make .dll files, not .so files. + shrext_cmds=".dll" + # FIXME: Setting linknames here is a bad hack. + archive_cmds='$CC -o $lib $libobjs $compiler_flags `func_echo_all "$deplibs" | $SED '\''s/ -lc$//'\''` -link -dll~linknames=' + # The linker will automatically build a .lib file if we build a DLL. + old_archive_from_new_cmds='true' + # FIXME: Should let the user specify the lib program. + old_archive_cmds='lib -OUT:$oldlib$oldobjs$old_deplibs' + enable_shared_with_static_runtimes=yes + ;; + esac + ;; + + darwin* | rhapsody*) + + + archive_cmds_need_lc=no + hardcode_direct=no + hardcode_automatic=yes + hardcode_shlibpath_var=unsupported + if test "$lt_cv_ld_force_load" = "yes"; then + whole_archive_flag_spec='`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience ${wl}-force_load,$conv\"; done; func_echo_all \"$new_convenience\"`' + + else + whole_archive_flag_spec='' + fi + link_all_deplibs=yes + allow_undefined_flag="$_lt_dar_allow_undefined" + case $cc_basename in + ifort*) _lt_dar_can_shared=yes ;; + *) _lt_dar_can_shared=$GCC ;; + esac + if test "$_lt_dar_can_shared" = "yes"; then + output_verbose_link_cmd=func_echo_all + archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}" + module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}" + archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}" + module_expsym_cmds="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}" + + else + ld_shlibs=no + fi + + ;; + + dgux*) + archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_libdir_flag_spec='-L$libdir' + hardcode_shlibpath_var=no + ;; + + # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor + # support. Future versions do this automatically, but an explicit c++rt0.o + # does not break anything, and helps significantly (at the cost of a little + # extra space). + freebsd2.2*) + archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o' + hardcode_libdir_flag_spec='-R$libdir' + hardcode_direct=yes + hardcode_shlibpath_var=no + ;; + + # Unfortunately, older versions of FreeBSD 2 do not have this feature. + freebsd2.*) + archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' + hardcode_direct=yes + hardcode_minus_L=yes + hardcode_shlibpath_var=no + ;; + + # FreeBSD 3 and greater uses gcc -shared to do shared libraries. + freebsd* | dragonfly*) + archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' + hardcode_libdir_flag_spec='-R$libdir' + hardcode_direct=yes + hardcode_shlibpath_var=no + ;; + + hpux9*) + if test "$GCC" = yes; then + archive_cmds='$RM $output_objdir/$soname~$CC -shared $pic_flag ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' + else + archive_cmds='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' + fi + hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' + hardcode_libdir_separator=: + hardcode_direct=yes + + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + hardcode_minus_L=yes + export_dynamic_flag_spec='${wl}-E' + ;; + + hpux10*) + if test "$GCC" = yes && test "$with_gnu_ld" = no; then + archive_cmds='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' + else + archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' + fi + if test "$with_gnu_ld" = no; then + hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' + hardcode_libdir_separator=: + hardcode_direct=yes + hardcode_direct_absolute=yes + export_dynamic_flag_spec='${wl}-E' + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + hardcode_minus_L=yes + fi + ;; + + hpux11*) + if test "$GCC" = yes && test "$with_gnu_ld" = no; then + case $host_cpu in + hppa*64*) + archive_cmds='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' + ;; + ia64*) + archive_cmds='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' + ;; + *) + archive_cmds='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' + ;; + esac + else + case $host_cpu in + hppa*64*) + archive_cmds='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' + ;; + ia64*) + archive_cmds='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' + ;; + *) + + # Older versions of the 11.00 compiler do not understand -b yet + # (HP92453-01 A.11.01.20 doesn't, HP92453-01 B.11.X.35175-35176.GP does) + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $CC understands -b" >&5 +$as_echo_n "checking if $CC understands -b... " >&6; } +if ${lt_cv_prog_compiler__b+:} false; then : + $as_echo_n "(cached) " >&6 +else + lt_cv_prog_compiler__b=no + save_LDFLAGS="$LDFLAGS" + LDFLAGS="$LDFLAGS -b" + echo "$lt_simple_link_test_code" > conftest.$ac_ext + if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then + # The linker can only warn and ignore the option if not recognized + # So say no if there are warnings + if test -s conftest.err; then + # Append any errors to the config.log. + cat conftest.err 1>&5 + $ECHO "$_lt_linker_boilerplate" | $SED '/^$/d' > conftest.exp + $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 + if diff conftest.exp conftest.er2 >/dev/null; then + lt_cv_prog_compiler__b=yes + fi + else + lt_cv_prog_compiler__b=yes + fi + fi + $RM -r conftest* + LDFLAGS="$save_LDFLAGS" + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler__b" >&5 +$as_echo "$lt_cv_prog_compiler__b" >&6; } + +if test x"$lt_cv_prog_compiler__b" = xyes; then + archive_cmds='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' +else + archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' +fi + + ;; + esac + fi + if test "$with_gnu_ld" = no; then + hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' + hardcode_libdir_separator=: + + case $host_cpu in + hppa*64*|ia64*) + hardcode_direct=no + hardcode_shlibpath_var=no + ;; + *) + hardcode_direct=yes + hardcode_direct_absolute=yes + export_dynamic_flag_spec='${wl}-E' + + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + hardcode_minus_L=yes + ;; + esac + fi + ;; + + irix5* | irix6* | nonstopux*) + if test "$GCC" = yes; then + archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + # Try to use the -exported_symbol ld option, if it does not + # work, assume that -exports_file does not work either and + # implicitly export all symbols. + # This should be the same for all languages, so no per-tag cache variable. + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the $host_os linker accepts -exported_symbol" >&5 +$as_echo_n "checking whether the $host_os linker accepts -exported_symbol... " >&6; } +if ${lt_cv_irix_exported_symbol+:} false; then : + $as_echo_n "(cached) " >&6 +else + save_LDFLAGS="$LDFLAGS" + LDFLAGS="$LDFLAGS -shared ${wl}-exported_symbol ${wl}foo ${wl}-update_registry ${wl}/dev/null" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +int foo (void) { return 0; } +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + lt_cv_irix_exported_symbol=yes +else + lt_cv_irix_exported_symbol=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + LDFLAGS="$save_LDFLAGS" +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_irix_exported_symbol" >&5 +$as_echo "$lt_cv_irix_exported_symbol" >&6; } + if test "$lt_cv_irix_exported_symbol" = yes; then + archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations ${wl}-exports_file ${wl}$export_symbols -o $lib' + fi + else + archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' + archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -exports_file $export_symbols -o $lib' + fi + archive_cmds_need_lc='no' + hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' + hardcode_libdir_separator=: + inherit_rpath=yes + link_all_deplibs=yes + ;; + + netbsd* | netbsdelf*-gnu) + if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then + archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out + else + archive_cmds='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF + fi + hardcode_libdir_flag_spec='-R$libdir' + hardcode_direct=yes + hardcode_shlibpath_var=no + ;; + + newsos6) + archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_direct=yes + hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' + hardcode_libdir_separator=: + hardcode_shlibpath_var=no + ;; + + *nto* | *qnx*) + ;; + + openbsd*) + if test -f /usr/libexec/ld.so; then + hardcode_direct=yes + hardcode_shlibpath_var=no + hardcode_direct_absolute=yes + if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then + archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' + archive_expsym_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols' + hardcode_libdir_flag_spec='${wl}-rpath,$libdir' + export_dynamic_flag_spec='${wl}-E' + else + case $host_os in + openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*) + archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' + hardcode_libdir_flag_spec='-R$libdir' + ;; + *) + archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' + hardcode_libdir_flag_spec='${wl}-rpath,$libdir' + ;; + esac + fi + else + ld_shlibs=no + fi + ;; + + os2*) + hardcode_libdir_flag_spec='-L$libdir' + hardcode_minus_L=yes + allow_undefined_flag=unsupported + archive_cmds='$ECHO "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~echo DATA >> $output_objdir/$libname.def~echo " SINGLE NONSHARED" >> $output_objdir/$libname.def~echo EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def' + old_archive_from_new_cmds='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def' + ;; + + osf3*) + if test "$GCC" = yes; then + allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*' + archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + else + allow_undefined_flag=' -expect_unresolved \*' + archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' + fi + archive_cmds_need_lc='no' + hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' + hardcode_libdir_separator=: + ;; + + osf4* | osf5*) # as osf3* with the addition of -msym flag + if test "$GCC" = yes; then + allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*' + archive_cmds='$CC -shared${allow_undefined_flag} $pic_flag $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' + else + allow_undefined_flag=' -expect_unresolved \*' + archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' + archive_expsym_cmds='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; printf "%s\\n" "-hidden">> $lib.exp~ + $CC -shared${allow_undefined_flag} ${wl}-input ${wl}$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib~$RM $lib.exp' + + # Both c and cxx compiler support -rpath directly + hardcode_libdir_flag_spec='-rpath $libdir' + fi + archive_cmds_need_lc='no' + hardcode_libdir_separator=: + ;; + + solaris*) + no_undefined_flag=' -z defs' + if test "$GCC" = yes; then + wlarc='${wl}' + archive_cmds='$CC -shared $pic_flag ${wl}-z ${wl}text ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' + archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ + $CC -shared $pic_flag ${wl}-z ${wl}text ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' + else + case `$CC -V 2>&1` in + *"Compilers 5.0"*) + wlarc='' + archive_cmds='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags' + archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ + $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$RM $lib.exp' + ;; + *) + wlarc='${wl}' + archive_cmds='$CC -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $compiler_flags' + archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ + $CC -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' + ;; + esac + fi + hardcode_libdir_flag_spec='-R$libdir' + hardcode_shlibpath_var=no + case $host_os in + solaris2.[0-5] | solaris2.[0-5].*) ;; + *) + # The compiler driver will combine and reorder linker options, + # but understands `-z linker_flag'. GCC discards it without `$wl', + # but is careful enough not to reorder. + # Supported since Solaris 2.6 (maybe 2.5.1?) + if test "$GCC" = yes; then + whole_archive_flag_spec='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract' + else + whole_archive_flag_spec='-z allextract$convenience -z defaultextract' + fi + ;; + esac + link_all_deplibs=yes + ;; + + sunos4*) + if test "x$host_vendor" = xsequent; then + # Use $CC to link under sequent, because it throws in some extra .o + # files that make .init and .fini sections work. + archive_cmds='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags' + else + archive_cmds='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags' + fi + hardcode_libdir_flag_spec='-L$libdir' + hardcode_direct=yes + hardcode_minus_L=yes + hardcode_shlibpath_var=no + ;; + + sysv4) + case $host_vendor in + sni) + archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_direct=yes # is this really true??? + ;; + siemens) + ## LD is ld it makes a PLAMLIB + ## CC just makes a GrossModule. + archive_cmds='$LD -G -o $lib $libobjs $deplibs $linker_flags' + reload_cmds='$CC -r -o $output$reload_objs' + hardcode_direct=no + ;; + motorola) + archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_direct=no #Motorola manual says yes, but my tests say they lie + ;; + esac + runpath_var='LD_RUN_PATH' + hardcode_shlibpath_var=no + ;; + + sysv4.3*) + archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_shlibpath_var=no + export_dynamic_flag_spec='-Bexport' + ;; + + sysv4*MP*) + if test -d /usr/nec; then + archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_shlibpath_var=no + runpath_var=LD_RUN_PATH + hardcode_runpath_var=yes + ld_shlibs=yes + fi + ;; + + sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7* | sco3.2v5.0.[024]*) + no_undefined_flag='${wl}-z,text' + archive_cmds_need_lc=no + hardcode_shlibpath_var=no + runpath_var='LD_RUN_PATH' + + if test "$GCC" = yes; then + archive_cmds='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + archive_expsym_cmds='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + else + archive_cmds='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + archive_expsym_cmds='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + fi + ;; + + sysv5* | sco3.2v5* | sco5v6*) + # Note: We can NOT use -z defs as we might desire, because we do not + # link with -lc, and that would cause any symbols used from libc to + # always be unresolved, which means just about no library would + # ever link correctly. If we're not using GNU ld we use -z text + # though, which does catch some bad symbols but isn't as heavy-handed + # as -z defs. + no_undefined_flag='${wl}-z,text' + allow_undefined_flag='${wl}-z,nodefs' + archive_cmds_need_lc=no + hardcode_shlibpath_var=no + hardcode_libdir_flag_spec='${wl}-R,$libdir' + hardcode_libdir_separator=':' + link_all_deplibs=yes + export_dynamic_flag_spec='${wl}-Bexport' + runpath_var='LD_RUN_PATH' + + if test "$GCC" = yes; then + archive_cmds='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + archive_expsym_cmds='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + else + archive_cmds='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + archive_expsym_cmds='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + fi + ;; + + uts4*) + archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_libdir_flag_spec='-L$libdir' + hardcode_shlibpath_var=no + ;; + + *) + ld_shlibs=no + ;; + esac + + if test x$host_vendor = xsni; then + case $host in + sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) + export_dynamic_flag_spec='${wl}-Blargedynsym' + ;; + esac + fi + fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ld_shlibs" >&5 +$as_echo "$ld_shlibs" >&6; } +test "$ld_shlibs" = no && can_build_shared=no + +with_gnu_ld=$with_gnu_ld + + + + + + + + + + + + + + + +# +# Do we need to explicitly link libc? +# +case "x$archive_cmds_need_lc" in +x|xyes) + # Assume -lc should be added + archive_cmds_need_lc=yes + + if test "$enable_shared" = yes && test "$GCC" = yes; then + case $archive_cmds in + *'~'*) + # FIXME: we may have to deal with multi-command sequences. + ;; + '$CC '*) + # Test whether the compiler implicitly links with -lc since on some + # systems, -lgcc has to come before -lc. If gcc already passes -lc + # to ld, don't add -lc before -lgcc. + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -lc should be explicitly linked in" >&5 +$as_echo_n "checking whether -lc should be explicitly linked in... " >&6; } +if ${lt_cv_archive_cmds_need_lc+:} false; then : + $as_echo_n "(cached) " >&6 +else + $RM conftest* + echo "$lt_simple_compile_test_code" > conftest.$ac_ext + + if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } 2>conftest.err; then + soname=conftest + lib=conftest + libobjs=conftest.$ac_objext + deplibs= + wl=$lt_prog_compiler_wl + pic_flag=$lt_prog_compiler_pic + compiler_flags=-v + linker_flags=-v + verstring= + output_objdir=. + libname=conftest + lt_save_allow_undefined_flag=$allow_undefined_flag + allow_undefined_flag= + if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$archive_cmds 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1\""; } >&5 + (eval $archive_cmds 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1) 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } + then + lt_cv_archive_cmds_need_lc=no + else + lt_cv_archive_cmds_need_lc=yes + fi + allow_undefined_flag=$lt_save_allow_undefined_flag + else + cat conftest.err 1>&5 + fi + $RM conftest* + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_archive_cmds_need_lc" >&5 +$as_echo "$lt_cv_archive_cmds_need_lc" >&6; } + archive_cmds_need_lc=$lt_cv_archive_cmds_need_lc + ;; + esac + fi + ;; +esac + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking dynamic linker characteristics" >&5 +$as_echo_n "checking dynamic linker characteristics... " >&6; } + +if test "$GCC" = yes; then + case $host_os in + darwin*) lt_awk_arg="/^libraries:/,/LR/" ;; + *) lt_awk_arg="/^libraries:/" ;; + esac + case $host_os in + mingw* | cegcc*) lt_sed_strip_eq="s,=\([A-Za-z]:\),\1,g" ;; + *) lt_sed_strip_eq="s,=/,/,g" ;; + esac + lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e $lt_sed_strip_eq` + case $lt_search_path_spec in + *\;*) + # if the path contains ";" then we assume it to be the separator + # otherwise default to the standard path separator (i.e. ":") - it is + # assumed that no part of a normal pathname contains ";" but that should + # okay in the real world where ";" in dirpaths is itself problematic. + lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED 's/;/ /g'` + ;; + *) + lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED "s/$PATH_SEPARATOR/ /g"` + ;; + esac + # Ok, now we have the path, separated by spaces, we can step through it + # and add multilib dir if necessary. + lt_tmp_lt_search_path_spec= + lt_multi_os_dir=`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null` + for lt_sys_path in $lt_search_path_spec; do + if test -d "$lt_sys_path/$lt_multi_os_dir"; then + lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path/$lt_multi_os_dir" + else + test -d "$lt_sys_path" && \ + lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path" + fi + done + lt_search_path_spec=`$ECHO "$lt_tmp_lt_search_path_spec" | awk ' +BEGIN {RS=" "; FS="/|\n";} { + lt_foo=""; + lt_count=0; + for (lt_i = NF; lt_i > 0; lt_i--) { + if ($lt_i != "" && $lt_i != ".") { + if ($lt_i == "..") { + lt_count++; + } else { + if (lt_count == 0) { + lt_foo="/" $lt_i lt_foo; + } else { + lt_count--; + } + } + } + } + if (lt_foo != "") { lt_freq[lt_foo]++; } + if (lt_freq[lt_foo] == 1) { print lt_foo; } +}'` + # AWK program above erroneously prepends '/' to C:/dos/paths + # for these hosts. + case $host_os in + mingw* | cegcc*) lt_search_path_spec=`$ECHO "$lt_search_path_spec" |\ + $SED 's,/\([A-Za-z]:\),\1,g'` ;; + esac + sys_lib_search_path_spec=`$ECHO "$lt_search_path_spec" | $lt_NL2SP` +else + sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" +fi +library_names_spec= +libname_spec='lib$name' +soname_spec= +shrext_cmds=".so" +postinstall_cmds= +postuninstall_cmds= +finish_cmds= +finish_eval= +shlibpath_var= +shlibpath_overrides_runpath=unknown +version_type=none +dynamic_linker="$host_os ld.so" +sys_lib_dlsearch_path_spec="/lib /usr/lib" +need_lib_prefix=unknown +hardcode_into_libs=no + +# when you set need_version to no, make sure it does not cause -set_version +# flags to be left without arguments +need_version=unknown + +case $host_os in +aix3*) + version_type=linux # correct to gnu/linux during the next big refactor + library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a' + shlibpath_var=LIBPATH + + # AIX 3 has no versioning support, so we append a major version to the name. + soname_spec='${libname}${release}${shared_ext}$major' + ;; + +aix[4-9]*) + version_type=linux # correct to gnu/linux during the next big refactor + need_lib_prefix=no + need_version=no + hardcode_into_libs=yes + if test "$host_cpu" = ia64; then + # AIX 5 supports IA64 + library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}' + shlibpath_var=LD_LIBRARY_PATH + else + # With GCC up to 2.95.x, collect2 would create an import file + # for dependence libraries. The import file would start with + # the line `#! .'. This would cause the generated library to + # depend on `.', always an invalid library. This was fixed in + # development snapshots of GCC prior to 3.0. + case $host_os in + aix4 | aix4.[01] | aix4.[01].*) + if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)' + echo ' yes ' + echo '#endif'; } | ${CC} -E - | $GREP yes > /dev/null; then + : + else + can_build_shared=no + fi + ;; + esac + # AIX (on Power*) has no versioning support, so currently we can not hardcode correct + # soname into executable. Probably we can add versioning support to + # collect2, so additional links can be useful in future. + if test "$aix_use_runtimelinking" = yes; then + # If using run time linking (on AIX 4.2 or later) use lib.so + # instead of lib.a to let people know that these are not + # typical AIX shared libraries. + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + else + # We preserve .a as extension for shared libraries through AIX4.2 + # and later when we are not doing run time linking. + library_names_spec='${libname}${release}.a $libname.a' + soname_spec='${libname}${release}${shared_ext}$major' + fi + shlibpath_var=LIBPATH + fi + ;; + +amigaos*) + case $host_cpu in + powerpc) + # Since July 2007 AmigaOS4 officially supports .so libraries. + # When compiling the executable, add -use-dynld -Lsobjs: to the compileline. + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + ;; + m68k) + library_names_spec='$libname.ixlibrary $libname.a' + # Create ${libname}_ixlibrary.a entries in /sys/libs. + finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`func_echo_all "$lib" | $SED '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done' + ;; + esac + ;; + +beos*) + library_names_spec='${libname}${shared_ext}' + dynamic_linker="$host_os ld.so" + shlibpath_var=LIBRARY_PATH + ;; + +bsdi[45]*) + version_type=linux # correct to gnu/linux during the next big refactor + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir' + shlibpath_var=LD_LIBRARY_PATH + sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib" + sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib" + # the default ld.so.conf also contains /usr/contrib/lib and + # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow + # libtool to hard-code these into programs + ;; + +cygwin* | mingw* | pw32* | cegcc*) + version_type=windows + shrext_cmds=".dll" + need_version=no + need_lib_prefix=no + + case $GCC,$cc_basename in + yes,*) + # gcc + library_names_spec='$libname.dll.a' + # DLL is installed to $(libdir)/../bin by postinstall_cmds + postinstall_cmds='base_file=`basename \${file}`~ + dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~ + dldir=$destdir/`dirname \$dlpath`~ + test -d \$dldir || mkdir -p \$dldir~ + $install_prog $dir/$dlname \$dldir/$dlname~ + chmod a+x \$dldir/$dlname~ + if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then + eval '\''$striplib \$dldir/$dlname'\'' || exit \$?; + fi' + postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ + dlpath=$dir/\$dldll~ + $RM \$dlpath' + shlibpath_overrides_runpath=yes + + case $host_os in + cygwin*) + # Cygwin DLLs use 'cyg' prefix rather than 'lib' + soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' + + sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/lib/w32api" + ;; + mingw* | cegcc*) + # MinGW DLLs use traditional 'lib' prefix + soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' + ;; + pw32*) + # pw32 DLLs use 'pw' prefix rather than 'lib' + library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' + ;; + esac + dynamic_linker='Win32 ld.exe' + ;; + + *,cl*) + # Native MSVC + libname_spec='$name' + soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' + library_names_spec='${libname}.dll.lib' + + case $build_os in + mingw*) + sys_lib_search_path_spec= + lt_save_ifs=$IFS + IFS=';' + for lt_path in $LIB + do + IFS=$lt_save_ifs + # Let DOS variable expansion print the short 8.3 style file name. + lt_path=`cd "$lt_path" 2>/dev/null && cmd //C "for %i in (".") do @echo %~si"` + sys_lib_search_path_spec="$sys_lib_search_path_spec $lt_path" + done + IFS=$lt_save_ifs + # Convert to MSYS style. + sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | sed -e 's|\\\\|/|g' -e 's| \\([a-zA-Z]\\):| /\\1|g' -e 's|^ ||'` + ;; + cygwin*) + # Convert to unix form, then to dos form, then back to unix form + # but this time dos style (no spaces!) so that the unix form looks + # like /cygdrive/c/PROGRA~1:/cygdr... + sys_lib_search_path_spec=`cygpath --path --unix "$LIB"` + sys_lib_search_path_spec=`cygpath --path --dos "$sys_lib_search_path_spec" 2>/dev/null` + sys_lib_search_path_spec=`cygpath --path --unix "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` + ;; + *) + sys_lib_search_path_spec="$LIB" + if $ECHO "$sys_lib_search_path_spec" | $GREP ';[c-zC-Z]:/' >/dev/null; then + # It is most probably a Windows format PATH. + sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` + else + sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` + fi + # FIXME: find the short name or the path components, as spaces are + # common. (e.g. "Program Files" -> "PROGRA~1") + ;; + esac + + # DLL is installed to $(libdir)/../bin by postinstall_cmds + postinstall_cmds='base_file=`basename \${file}`~ + dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~ + dldir=$destdir/`dirname \$dlpath`~ + test -d \$dldir || mkdir -p \$dldir~ + $install_prog $dir/$dlname \$dldir/$dlname' + postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ + dlpath=$dir/\$dldll~ + $RM \$dlpath' + shlibpath_overrides_runpath=yes + dynamic_linker='Win32 link.exe' + ;; + + *) + # Assume MSVC wrapper + library_names_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext} $libname.lib' + dynamic_linker='Win32 ld.exe' + ;; + esac + # FIXME: first we should search . and the directory the executable is in + shlibpath_var=PATH + ;; + +darwin* | rhapsody*) + dynamic_linker="$host_os dyld" + version_type=darwin + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${major}$shared_ext ${libname}$shared_ext' + soname_spec='${libname}${release}${major}$shared_ext' + shlibpath_overrides_runpath=yes + shlibpath_var=DYLD_LIBRARY_PATH + shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`' + + sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/local/lib" + sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib' + ;; + +dgux*) + version_type=linux # correct to gnu/linux during the next big refactor + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + ;; + +freebsd* | dragonfly*) + # DragonFly does not have aout. When/if they implement a new + # versioning mechanism, adjust this. + if test -x /usr/bin/objformat; then + objformat=`/usr/bin/objformat` + else + case $host_os in + freebsd[23].*) objformat=aout ;; + *) objformat=elf ;; + esac + fi + version_type=freebsd-$objformat + case $version_type in + freebsd-elf*) + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' + need_version=no + need_lib_prefix=no + ;; + freebsd-*) + library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix' + need_version=yes + ;; + esac + shlibpath_var=LD_LIBRARY_PATH + case $host_os in + freebsd2.*) + shlibpath_overrides_runpath=yes + ;; + freebsd3.[01]* | freebsdelf3.[01]*) + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + ;; + freebsd3.[2-9]* | freebsdelf3.[2-9]* | \ + freebsd4.[0-5] | freebsdelf4.[0-5] | freebsd4.1.1 | freebsdelf4.1.1) + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + ;; + *) # from 4.6 on, and DragonFly + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + ;; + esac + ;; + +gnu*) + version_type=linux # correct to gnu/linux during the next big refactor + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + ;; + +haiku*) + version_type=linux # correct to gnu/linux during the next big refactor + need_lib_prefix=no + need_version=no + dynamic_linker="$host_os runtime_loader" + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LIBRARY_PATH + shlibpath_overrides_runpath=yes + sys_lib_dlsearch_path_spec='/boot/home/config/lib /boot/common/lib /boot/system/lib' + hardcode_into_libs=yes + ;; + +hpux9* | hpux10* | hpux11*) + # Give a soname corresponding to the major version so that dld.sl refuses to + # link against other versions. + version_type=sunos + need_lib_prefix=no + need_version=no + case $host_cpu in + ia64*) + shrext_cmds='.so' + hardcode_into_libs=yes + dynamic_linker="$host_os dld.so" + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + if test "X$HPUX_IA64_MODE" = X32; then + sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib" + else + sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64" + fi + sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec + ;; + hppa*64*) + shrext_cmds='.sl' + hardcode_into_libs=yes + dynamic_linker="$host_os dld.sl" + shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH + shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64" + sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec + ;; + *) + shrext_cmds='.sl' + dynamic_linker="$host_os dld.sl" + shlibpath_var=SHLIB_PATH + shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + ;; + esac + # HP-UX runs *really* slowly unless shared libraries are mode 555, ... + postinstall_cmds='chmod 555 $lib' + # or fails outright, so override atomically: + install_override_mode=555 + ;; + +interix[3-9]*) + version_type=linux # correct to gnu/linux during the next big refactor + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + ;; + +irix5* | irix6* | nonstopux*) + case $host_os in + nonstopux*) version_type=nonstopux ;; + *) + if test "$lt_cv_prog_gnu_ld" = yes; then + version_type=linux # correct to gnu/linux during the next big refactor + else + version_type=irix + fi ;; + esac + need_lib_prefix=no + need_version=no + soname_spec='${libname}${release}${shared_ext}$major' + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}' + case $host_os in + irix5* | nonstopux*) + libsuff= shlibsuff= + ;; + *) + case $LD in # libtool.m4 will add one of these switches to LD + *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") + libsuff= shlibsuff= libmagic=32-bit;; + *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") + libsuff=32 shlibsuff=N32 libmagic=N32;; + *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") + libsuff=64 shlibsuff=64 libmagic=64-bit;; + *) libsuff= shlibsuff= libmagic=never-match;; + esac + ;; + esac + shlibpath_var=LD_LIBRARY${shlibsuff}_PATH + shlibpath_overrides_runpath=no + sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}" + sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}" + hardcode_into_libs=yes + ;; + +# No shared lib support for Linux oldld, aout, or coff. +linux*oldld* | linux*aout* | linux*coff*) + dynamic_linker=no + ;; + +# This must be glibc/ELF. +linux* | k*bsd*-gnu | kopensolaris*-gnu) + version_type=linux # correct to gnu/linux during the next big refactor + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + + # Some binutils ld are patched to set DT_RUNPATH + if ${lt_cv_shlibpath_overrides_runpath+:} false; then : + $as_echo_n "(cached) " >&6 +else + lt_cv_shlibpath_overrides_runpath=no + save_LDFLAGS=$LDFLAGS + save_libdir=$libdir + eval "libdir=/foo; wl=\"$lt_prog_compiler_wl\"; \ + LDFLAGS=\"\$LDFLAGS $hardcode_libdir_flag_spec\"" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + if ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null; then : + lt_cv_shlibpath_overrides_runpath=yes +fi +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + LDFLAGS=$save_LDFLAGS + libdir=$save_libdir + +fi + + shlibpath_overrides_runpath=$lt_cv_shlibpath_overrides_runpath + + # This implies no fast_install, which is unacceptable. + # Some rework will be needed to allow for fast_install + # before this can be enabled. + hardcode_into_libs=yes + + # Append ld.so.conf contents to the search path + if test -f /etc/ld.so.conf; then + lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '` + sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra" + fi + + # We used to test for /lib/ld.so.1 and disable shared libraries on + # powerpc, because MkLinux only supported shared libraries with the + # GNU dynamic linker. Since this was broken with cross compilers, + # most powerpc-linux boxes support dynamic linking these days and + # people can always --disable-shared, the test was removed, and we + # assume the GNU/Linux dynamic linker is in use. + dynamic_linker='GNU/Linux ld.so' + ;; + +netbsdelf*-gnu) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + dynamic_linker='NetBSD ld.elf_so' + ;; + +netbsd*) + version_type=sunos + need_lib_prefix=no + need_version=no + if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' + dynamic_linker='NetBSD (a.out) ld.so' + else + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + dynamic_linker='NetBSD ld.elf_so' + fi + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + ;; + +newsos6) + version_type=linux # correct to gnu/linux during the next big refactor + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + ;; + +*nto* | *qnx*) + version_type=qnx + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + dynamic_linker='ldqnx.so' + ;; + +openbsd*) + version_type=sunos + sys_lib_dlsearch_path_spec="/usr/lib" + need_lib_prefix=no + # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs. + case $host_os in + openbsd3.3 | openbsd3.3.*) need_version=yes ;; + *) need_version=no ;; + esac + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' + shlibpath_var=LD_LIBRARY_PATH + if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then + case $host_os in + openbsd2.[89] | openbsd2.[89].*) + shlibpath_overrides_runpath=no + ;; + *) + shlibpath_overrides_runpath=yes + ;; + esac + else + shlibpath_overrides_runpath=yes + fi + ;; + +os2*) + libname_spec='$name' + shrext_cmds=".dll" + need_lib_prefix=no + library_names_spec='$libname${shared_ext} $libname.a' + dynamic_linker='OS/2 ld.exe' + shlibpath_var=LIBPATH + ;; + +osf3* | osf4* | osf5*) + version_type=osf + need_lib_prefix=no + need_version=no + soname_spec='${libname}${release}${shared_ext}$major' + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + shlibpath_var=LD_LIBRARY_PATH + sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib" + sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec" + ;; + +rdos*) + dynamic_linker=no + ;; + +solaris*) + version_type=linux # correct to gnu/linux during the next big refactor + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + # ldd complains unless libraries are executable + postinstall_cmds='chmod +x $lib' + ;; + +sunos4*) + version_type=sunos + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' + finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + if test "$with_gnu_ld" = yes; then + need_lib_prefix=no + fi + need_version=yes + ;; + +sysv4 | sysv4.3*) + version_type=linux # correct to gnu/linux during the next big refactor + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + case $host_vendor in + sni) + shlibpath_overrides_runpath=no + need_lib_prefix=no + runpath_var=LD_RUN_PATH + ;; + siemens) + need_lib_prefix=no + ;; + motorola) + need_lib_prefix=no + need_version=no + shlibpath_overrides_runpath=no + sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib' + ;; + esac + ;; + +sysv4*MP*) + if test -d /usr/nec ;then + version_type=linux # correct to gnu/linux during the next big refactor + library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}' + soname_spec='$libname${shared_ext}.$major' + shlibpath_var=LD_LIBRARY_PATH + fi + ;; + +sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) + version_type=freebsd-elf + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + if test "$with_gnu_ld" = yes; then + sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib' + else + sys_lib_search_path_spec='/usr/ccs/lib /usr/lib' + case $host_os in + sco3.2v5*) + sys_lib_search_path_spec="$sys_lib_search_path_spec /lib" + ;; + esac + fi + sys_lib_dlsearch_path_spec='/usr/lib' + ;; + +tpf*) + # TPF is a cross-target only. Preferred cross-host = GNU/Linux. + version_type=linux # correct to gnu/linux during the next big refactor + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + ;; + +uts4*) + version_type=linux # correct to gnu/linux during the next big refactor + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + ;; + +*) + dynamic_linker=no + ;; +esac +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $dynamic_linker" >&5 +$as_echo "$dynamic_linker" >&6; } +test "$dynamic_linker" = no && can_build_shared=no + +variables_saved_for_relink="PATH $shlibpath_var $runpath_var" +if test "$GCC" = yes; then + variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" +fi + +if test "${lt_cv_sys_lib_search_path_spec+set}" = set; then + sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec" +fi +if test "${lt_cv_sys_lib_dlsearch_path_spec+set}" = set; then + sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec" +fi + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to hardcode library paths into programs" >&5 +$as_echo_n "checking how to hardcode library paths into programs... " >&6; } +hardcode_action= +if test -n "$hardcode_libdir_flag_spec" || + test -n "$runpath_var" || + test "X$hardcode_automatic" = "Xyes" ; then + + # We can hardcode non-existent directories. + if test "$hardcode_direct" != no && + # If the only mechanism to avoid hardcoding is shlibpath_var, we + # have to relink, otherwise we might link with an installed library + # when we should be linking with a yet-to-be-installed one + ## test "$_LT_TAGVAR(hardcode_shlibpath_var, )" != no && + test "$hardcode_minus_L" != no; then + # Linking always hardcodes the temporary library directory. + hardcode_action=relink + else + # We can link without hardcoding, and we can hardcode nonexisting dirs. + hardcode_action=immediate + fi +else + # We cannot hardcode anything, or else we can only hardcode existing + # directories. + hardcode_action=unsupported +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $hardcode_action" >&5 +$as_echo "$hardcode_action" >&6; } + +if test "$hardcode_action" = relink || + test "$inherit_rpath" = yes; then + # Fast installation is not supported + enable_fast_install=no +elif test "$shlibpath_overrides_runpath" = yes || + test "$enable_shared" = no; then + # Fast installation is not necessary + enable_fast_install=needless +fi + + + + + + + if test "x$enable_dlopen" != xyes; then + enable_dlopen=unknown + enable_dlopen_self=unknown + enable_dlopen_self_static=unknown +else + lt_cv_dlopen=no + lt_cv_dlopen_libs= + + case $host_os in + beos*) + lt_cv_dlopen="load_add_on" + lt_cv_dlopen_libs= + lt_cv_dlopen_self=yes + ;; + + mingw* | pw32* | cegcc*) + lt_cv_dlopen="LoadLibrary" + lt_cv_dlopen_libs= + ;; + + cygwin*) + lt_cv_dlopen="dlopen" + lt_cv_dlopen_libs= + ;; + + darwin*) + # if libdl is installed we need to link against it + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5 +$as_echo_n "checking for dlopen in -ldl... " >&6; } +if ${ac_cv_lib_dl_dlopen+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-ldl $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char dlopen (); +int +main () +{ +return dlopen (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_dl_dlopen=yes +else + ac_cv_lib_dl_dlopen=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5 +$as_echo "$ac_cv_lib_dl_dlopen" >&6; } +if test "x$ac_cv_lib_dl_dlopen" = xyes; then : + lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl" +else + + lt_cv_dlopen="dyld" + lt_cv_dlopen_libs= + lt_cv_dlopen_self=yes + +fi + + ;; + + *) + ac_fn_c_check_func "$LINENO" "shl_load" "ac_cv_func_shl_load" +if test "x$ac_cv_func_shl_load" = xyes; then : + lt_cv_dlopen="shl_load" +else + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for shl_load in -ldld" >&5 +$as_echo_n "checking for shl_load in -ldld... " >&6; } +if ${ac_cv_lib_dld_shl_load+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-ldld $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char shl_load (); +int +main () +{ +return shl_load (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_dld_shl_load=yes +else + ac_cv_lib_dld_shl_load=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_shl_load" >&5 +$as_echo "$ac_cv_lib_dld_shl_load" >&6; } +if test "x$ac_cv_lib_dld_shl_load" = xyes; then : + lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-ldld" +else + ac_fn_c_check_func "$LINENO" "dlopen" "ac_cv_func_dlopen" +if test "x$ac_cv_func_dlopen" = xyes; then : + lt_cv_dlopen="dlopen" +else + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5 +$as_echo_n "checking for dlopen in -ldl... " >&6; } +if ${ac_cv_lib_dl_dlopen+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-ldl $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char dlopen (); +int +main () +{ +return dlopen (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_dl_dlopen=yes +else + ac_cv_lib_dl_dlopen=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5 +$as_echo "$ac_cv_lib_dl_dlopen" >&6; } +if test "x$ac_cv_lib_dl_dlopen" = xyes; then : + lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl" +else + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -lsvld" >&5 +$as_echo_n "checking for dlopen in -lsvld... " >&6; } +if ${ac_cv_lib_svld_dlopen+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lsvld $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char dlopen (); +int +main () +{ +return dlopen (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_svld_dlopen=yes +else + ac_cv_lib_svld_dlopen=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_svld_dlopen" >&5 +$as_echo "$ac_cv_lib_svld_dlopen" >&6; } +if test "x$ac_cv_lib_svld_dlopen" = xyes; then : + lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld" +else + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dld_link in -ldld" >&5 +$as_echo_n "checking for dld_link in -ldld... " >&6; } +if ${ac_cv_lib_dld_dld_link+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-ldld $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char dld_link (); +int +main () +{ +return dld_link (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_dld_dld_link=yes +else + ac_cv_lib_dld_dld_link=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_dld_link" >&5 +$as_echo "$ac_cv_lib_dld_dld_link" >&6; } +if test "x$ac_cv_lib_dld_dld_link" = xyes; then : + lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-ldld" +fi + + +fi + + +fi + + +fi + + +fi + + +fi + + ;; + esac + + if test "x$lt_cv_dlopen" != xno; then + enable_dlopen=yes + else + enable_dlopen=no + fi + + case $lt_cv_dlopen in + dlopen) + save_CPPFLAGS="$CPPFLAGS" + test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H" + + save_LDFLAGS="$LDFLAGS" + wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\" + + save_LIBS="$LIBS" + LIBS="$lt_cv_dlopen_libs $LIBS" + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether a program can dlopen itself" >&5 +$as_echo_n "checking whether a program can dlopen itself... " >&6; } +if ${lt_cv_dlopen_self+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test "$cross_compiling" = yes; then : + lt_cv_dlopen_self=cross +else + lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 + lt_status=$lt_dlunknown + cat > conftest.$ac_ext <<_LT_EOF +#line $LINENO "configure" +#include "confdefs.h" + +#if HAVE_DLFCN_H +#include +#endif + +#include + +#ifdef RTLD_GLOBAL +# define LT_DLGLOBAL RTLD_GLOBAL +#else +# ifdef DL_GLOBAL +# define LT_DLGLOBAL DL_GLOBAL +# else +# define LT_DLGLOBAL 0 +# endif +#endif + +/* We may have to define LT_DLLAZY_OR_NOW in the command line if we + find out it does not work in some platform. */ +#ifndef LT_DLLAZY_OR_NOW +# ifdef RTLD_LAZY +# define LT_DLLAZY_OR_NOW RTLD_LAZY +# else +# ifdef DL_LAZY +# define LT_DLLAZY_OR_NOW DL_LAZY +# else +# ifdef RTLD_NOW +# define LT_DLLAZY_OR_NOW RTLD_NOW +# else +# ifdef DL_NOW +# define LT_DLLAZY_OR_NOW DL_NOW +# else +# define LT_DLLAZY_OR_NOW 0 +# endif +# endif +# endif +# endif +#endif + +/* When -fvisbility=hidden is used, assume the code has been annotated + correspondingly for the symbols needed. */ +#if defined(__GNUC__) && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3)) +int fnord () __attribute__((visibility("default"))); +#endif + +int fnord () { return 42; } +int main () +{ + void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); + int status = $lt_dlunknown; + + if (self) + { + if (dlsym (self,"fnord")) status = $lt_dlno_uscore; + else + { + if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; + else puts (dlerror ()); + } + /* dlclose (self); */ + } + else + puts (dlerror ()); + + return status; +} +_LT_EOF + if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5 + (eval $ac_link) 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && test -s conftest${ac_exeext} 2>/dev/null; then + (./conftest; exit; ) >&5 2>/dev/null + lt_status=$? + case x$lt_status in + x$lt_dlno_uscore) lt_cv_dlopen_self=yes ;; + x$lt_dlneed_uscore) lt_cv_dlopen_self=yes ;; + x$lt_dlunknown|x*) lt_cv_dlopen_self=no ;; + esac + else : + # compilation failed + lt_cv_dlopen_self=no + fi +fi +rm -fr conftest* + + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_dlopen_self" >&5 +$as_echo "$lt_cv_dlopen_self" >&6; } + + if test "x$lt_cv_dlopen_self" = xyes; then + wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\" + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether a statically linked program can dlopen itself" >&5 +$as_echo_n "checking whether a statically linked program can dlopen itself... " >&6; } +if ${lt_cv_dlopen_self_static+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test "$cross_compiling" = yes; then : + lt_cv_dlopen_self_static=cross +else + lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 + lt_status=$lt_dlunknown + cat > conftest.$ac_ext <<_LT_EOF +#line $LINENO "configure" +#include "confdefs.h" + +#if HAVE_DLFCN_H +#include +#endif + +#include + +#ifdef RTLD_GLOBAL +# define LT_DLGLOBAL RTLD_GLOBAL +#else +# ifdef DL_GLOBAL +# define LT_DLGLOBAL DL_GLOBAL +# else +# define LT_DLGLOBAL 0 +# endif +#endif + +/* We may have to define LT_DLLAZY_OR_NOW in the command line if we + find out it does not work in some platform. */ +#ifndef LT_DLLAZY_OR_NOW +# ifdef RTLD_LAZY +# define LT_DLLAZY_OR_NOW RTLD_LAZY +# else +# ifdef DL_LAZY +# define LT_DLLAZY_OR_NOW DL_LAZY +# else +# ifdef RTLD_NOW +# define LT_DLLAZY_OR_NOW RTLD_NOW +# else +# ifdef DL_NOW +# define LT_DLLAZY_OR_NOW DL_NOW +# else +# define LT_DLLAZY_OR_NOW 0 +# endif +# endif +# endif +# endif +#endif + +/* When -fvisbility=hidden is used, assume the code has been annotated + correspondingly for the symbols needed. */ +#if defined(__GNUC__) && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3)) +int fnord () __attribute__((visibility("default"))); +#endif + +int fnord () { return 42; } +int main () +{ + void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); + int status = $lt_dlunknown; + + if (self) + { + if (dlsym (self,"fnord")) status = $lt_dlno_uscore; + else + { + if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; + else puts (dlerror ()); + } + /* dlclose (self); */ + } + else + puts (dlerror ()); + + return status; +} +_LT_EOF + if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5 + (eval $ac_link) 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && test -s conftest${ac_exeext} 2>/dev/null; then + (./conftest; exit; ) >&5 2>/dev/null + lt_status=$? + case x$lt_status in + x$lt_dlno_uscore) lt_cv_dlopen_self_static=yes ;; + x$lt_dlneed_uscore) lt_cv_dlopen_self_static=yes ;; + x$lt_dlunknown|x*) lt_cv_dlopen_self_static=no ;; + esac + else : + # compilation failed + lt_cv_dlopen_self_static=no + fi +fi +rm -fr conftest* + + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_dlopen_self_static" >&5 +$as_echo "$lt_cv_dlopen_self_static" >&6; } + fi + + CPPFLAGS="$save_CPPFLAGS" + LDFLAGS="$save_LDFLAGS" + LIBS="$save_LIBS" + ;; + esac + + case $lt_cv_dlopen_self in + yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;; + *) enable_dlopen_self=unknown ;; + esac + + case $lt_cv_dlopen_self_static in + yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;; + *) enable_dlopen_self_static=unknown ;; + esac +fi + + + + + + + + + + + + + + + + + +striplib= +old_striplib= +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether stripping libraries is possible" >&5 +$as_echo_n "checking whether stripping libraries is possible... " >&6; } +if test -n "$STRIP" && $STRIP -V 2>&1 | $GREP "GNU strip" >/dev/null; then + test -z "$old_striplib" && old_striplib="$STRIP --strip-debug" + test -z "$striplib" && striplib="$STRIP --strip-unneeded" + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } +else +# FIXME - insert some real tests, host_os isn't really good enough + case $host_os in + darwin*) + if test -n "$STRIP" ; then + striplib="$STRIP -x" + old_striplib="$STRIP -S" + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + fi + ;; + *) + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + ;; + esac +fi + + + + + + + + + + + + + # Report which library types will actually be built + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if libtool supports shared libraries" >&5 +$as_echo_n "checking if libtool supports shared libraries... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $can_build_shared" >&5 +$as_echo "$can_build_shared" >&6; } + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build shared libraries" >&5 +$as_echo_n "checking whether to build shared libraries... " >&6; } + test "$can_build_shared" = "no" && enable_shared=no + + # On AIX, shared libraries and static libraries use the same namespace, and + # are all built from PIC. + case $host_os in + aix3*) + test "$enable_shared" = yes && enable_static=no + if test -n "$RANLIB"; then + archive_cmds="$archive_cmds~\$RANLIB \$lib" + postinstall_cmds='$RANLIB $lib' + fi + ;; + + aix[4-9]*) + if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then + test "$enable_shared" = yes && enable_static=no + fi + ;; + esac + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_shared" >&5 +$as_echo "$enable_shared" >&6; } + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build static libraries" >&5 +$as_echo_n "checking whether to build static libraries... " >&6; } + # Make sure either enable_shared or enable_static is yes. + test "$enable_shared" = yes || enable_static=yes + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_static" >&5 +$as_echo "$enable_static" >&6; } + + + + +fi +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + +CC="$lt_save_CC" + + + + + + + + + + + + + + + + ac_config_commands="$ac_config_commands libtool" + + + + +# Only expand once: + + +#LT_INIT([disable-static]) + +# I18N + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether NLS is requested" >&5 +$as_echo_n "checking whether NLS is requested... " >&6; } + # Check whether --enable-nls was given. +if test "${enable_nls+set}" = set; then : + enableval=$enable_nls; USE_NLS=$enableval +else + USE_NLS=yes +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $USE_NLS" >&5 +$as_echo "$USE_NLS" >&6; } + + + + +case "$am__api_version" in + 1.01234) + as_fn_error $? "Automake 1.5 or newer is required to use intltool" "$LINENO" 5 + ;; + *) + ;; +esac + +if test -n "0.25"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for intltool >= 0.25" >&5 +$as_echo_n "checking for intltool >= 0.25... " >&6; } + + INTLTOOL_REQUIRED_VERSION_AS_INT=`echo 0.25 | awk -F. '{ print $ 1 * 1000 + $ 2 * 100 + $ 3; }'` + INTLTOOL_APPLIED_VERSION=`intltool-update --version | head -1 | cut -d" " -f3` + INTLTOOL_APPLIED_VERSION_AS_INT=`echo $INTLTOOL_APPLIED_VERSION | awk -F. '{ print $ 1 * 1000 + $ 2 * 100 + $ 3; }'` + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $INTLTOOL_APPLIED_VERSION found" >&5 +$as_echo "$INTLTOOL_APPLIED_VERSION found" >&6; } + test "$INTLTOOL_APPLIED_VERSION_AS_INT" -ge "$INTLTOOL_REQUIRED_VERSION_AS_INT" || + as_fn_error $? "Your intltool is too old. You need intltool 0.25 or later." "$LINENO" 5 +fi + +# Extract the first word of "intltool-update", so it can be a program name with args. +set dummy intltool-update; 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_INTLTOOL_UPDATE+:} false; then : + $as_echo_n "(cached) " >&6 +else + case $INTLTOOL_UPDATE in + [\\/]* | ?:[\\/]*) + ac_cv_path_INTLTOOL_UPDATE="$INTLTOOL_UPDATE" # 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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_path_INTLTOOL_UPDATE="$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 + + ;; +esac +fi +INTLTOOL_UPDATE=$ac_cv_path_INTLTOOL_UPDATE +if test -n "$INTLTOOL_UPDATE"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $INTLTOOL_UPDATE" >&5 +$as_echo "$INTLTOOL_UPDATE" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +# Extract the first word of "intltool-merge", so it can be a program name with args. +set dummy intltool-merge; 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_INTLTOOL_MERGE+:} false; then : + $as_echo_n "(cached) " >&6 +else + case $INTLTOOL_MERGE in + [\\/]* | ?:[\\/]*) + ac_cv_path_INTLTOOL_MERGE="$INTLTOOL_MERGE" # 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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_path_INTLTOOL_MERGE="$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 + + ;; +esac +fi +INTLTOOL_MERGE=$ac_cv_path_INTLTOOL_MERGE +if test -n "$INTLTOOL_MERGE"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $INTLTOOL_MERGE" >&5 +$as_echo "$INTLTOOL_MERGE" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +# Extract the first word of "intltool-extract", so it can be a program name with args. +set dummy intltool-extract; 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_INTLTOOL_EXTRACT+:} false; then : + $as_echo_n "(cached) " >&6 +else + case $INTLTOOL_EXTRACT in + [\\/]* | ?:[\\/]*) + ac_cv_path_INTLTOOL_EXTRACT="$INTLTOOL_EXTRACT" # 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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_path_INTLTOOL_EXTRACT="$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 + + ;; +esac +fi +INTLTOOL_EXTRACT=$ac_cv_path_INTLTOOL_EXTRACT +if test -n "$INTLTOOL_EXTRACT"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $INTLTOOL_EXTRACT" >&5 +$as_echo "$INTLTOOL_EXTRACT" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +if test -z "$INTLTOOL_UPDATE" -o -z "$INTLTOOL_MERGE" -o -z "$INTLTOOL_EXTRACT"; then + as_fn_error $? "The intltool scripts were not found. Please install intltool." "$LINENO" 5 +fi + + INTLTOOL_DESKTOP_RULE='%.desktop: %.desktop.in $(INTLTOOL_MERGE) $(wildcard $(top_srcdir)/po/*.po) ; LC_ALL=C $(INTLTOOL_MERGE) -d -u -c $(top_builddir)/po/.intltool-merge-cache $(top_srcdir)/po $< $@' +INTLTOOL_DIRECTORY_RULE='%.directory: %.directory.in $(INTLTOOL_MERGE) $(wildcard $(top_srcdir)/po/*.po) ; LC_ALL=C $(INTLTOOL_MERGE) -d -u -c $(top_builddir)/po/.intltool-merge-cache $(top_srcdir)/po $< $@' + INTLTOOL_KEYS_RULE='%.keys: %.keys.in $(INTLTOOL_MERGE) $(wildcard $(top_srcdir)/po/*.po) ; LC_ALL=C $(INTLTOOL_MERGE) -k -u -c $(top_builddir)/po/.intltool-merge-cache $(top_srcdir)/po $< $@' + INTLTOOL_PROP_RULE='%.prop: %.prop.in $(INTLTOOL_MERGE) $(wildcard $(top_srcdir)/po/*.po) ; LC_ALL=C $(INTLTOOL_MERGE) -d -u -c $(top_builddir)/po/.intltool-merge-cache $(top_srcdir)/po $< $@' + INTLTOOL_OAF_RULE='%.oaf: %.oaf.in $(INTLTOOL_MERGE) $(wildcard $(top_srcdir)/po/*.po) ; LC_ALL=C $(INTLTOOL_MERGE) -o -p $(top_srcdir)/po $< $@' + INTLTOOL_PONG_RULE='%.pong: %.pong.in $(INTLTOOL_MERGE) $(wildcard $(top_srcdir)/po/*.po) ; LC_ALL=C $(INTLTOOL_MERGE) -x -u -c $(top_builddir)/po/.intltool-merge-cache $(top_srcdir)/po $< $@' + INTLTOOL_SERVER_RULE='%.server: %.server.in $(INTLTOOL_MERGE) $(wildcard $(top_srcdir)/po/*.po) ; LC_ALL=C $(INTLTOOL_MERGE) -o -u -c $(top_builddir)/po/.intltool-merge-cache $(top_srcdir)/po $< $@' + INTLTOOL_SHEET_RULE='%.sheet: %.sheet.in $(INTLTOOL_MERGE) $(wildcard $(top_srcdir)/po/*.po) ; LC_ALL=C $(INTLTOOL_MERGE) -x -u -c $(top_builddir)/po/.intltool-merge-cache $(top_srcdir)/po $< $@' +INTLTOOL_SOUNDLIST_RULE='%.soundlist: %.soundlist.in $(INTLTOOL_MERGE) $(wildcard $(top_srcdir)/po/*.po) ; LC_ALL=C $(INTLTOOL_MERGE) -d -u -c $(top_builddir)/po/.intltool-merge-cache $(top_srcdir)/po $< $@' + INTLTOOL_UI_RULE='%.ui: %.ui.in $(INTLTOOL_MERGE) $(wildcard $(top_srcdir)/po/*.po) ; LC_ALL=C $(INTLTOOL_MERGE) -x -u -c $(top_builddir)/po/.intltool-merge-cache $(top_srcdir)/po $< $@' + INTLTOOL_XML_RULE='%.xml: %.xml.in $(INTLTOOL_MERGE) $(wildcard $(top_srcdir)/po/*.po) ; LC_ALL=C $(INTLTOOL_MERGE) -x -u -c $(top_builddir)/po/.intltool-merge-cache $(top_srcdir)/po $< $@' + INTLTOOL_XML_NOMERGE_RULE='%.xml: %.xml.in $(INTLTOOL_MERGE) ; LC_ALL=C $(INTLTOOL_MERGE) -x -u /tmp $< $@' + INTLTOOL_XAM_RULE='%.xam: %.xml.in $(INTLTOOL_MERGE) $(wildcard $(top_srcdir)/po/*.po) ; LC_ALL=C $(INTLTOOL_MERGE) -x -u -c $(top_builddir)/po/.intltool-merge-cache $(top_srcdir)/po $< $@' + INTLTOOL_KBD_RULE='%.kbd: %.kbd.in $(INTLTOOL_MERGE) $(wildcard $(top_srcdir)/po/*.po) ; LC_ALL=C $(INTLTOOL_MERGE) -x -u -m -c $(top_builddir)/po/.intltool-merge-cache $(top_srcdir)/po $< $@' + INTLTOOL_CAVES_RULE='%.caves: %.caves.in $(INTLTOOL_MERGE) $(wildcard $(top_srcdir)/po/*.po) ; LC_ALL=C $(INTLTOOL_MERGE) -d -u -c $(top_builddir)/po/.intltool-merge-cache $(top_srcdir)/po $< $@' + INTLTOOL_SCHEMAS_RULE='%.schemas: %.schemas.in $(INTLTOOL_MERGE) $(wildcard $(top_srcdir)/po/*.po) ; LC_ALL=C $(INTLTOOL_MERGE) -s -u -c $(top_builddir)/po/.intltool-merge-cache $(top_srcdir)/po $< $@' + INTLTOOL_THEME_RULE='%.theme: %.theme.in $(INTLTOOL_MERGE) $(wildcard $(top_srcdir)/po/*.po) ; LC_ALL=C $(INTLTOOL_MERGE) -d -u -c $(top_builddir)/po/.intltool-merge-cache $(top_srcdir)/po $< $@' + INTLTOOL_SERVICE_RULE='%.service: %.service.in $(INTLTOOL_MERGE) $(wildcard $(top_srcdir)/po/*.po) ; LC_ALL=C $(INTLTOOL_MERGE) -d -u -c $(top_builddir)/po/.intltool-merge-cache $(top_srcdir)/po $< $@' + INTLTOOL_POLICY_RULE='%.policy: %.policy.in $(INTLTOOL_MERGE) $(wildcard $(top_srcdir)/po/*.po) ; LC_ALL=C $(INTLTOOL_MERGE) -x -u -c $(top_builddir)/po/.intltool-merge-cache $(top_srcdir)/po $< $@' + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +# Check the gettext tools to make sure they are GNU +# Extract the first word of "xgettext", so it can be a program name with args. +set dummy xgettext; 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_XGETTEXT+:} false; then : + $as_echo_n "(cached) " >&6 +else + case $XGETTEXT in + [\\/]* | ?:[\\/]*) + ac_cv_path_XGETTEXT="$XGETTEXT" # 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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_path_XGETTEXT="$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 + + ;; +esac +fi +XGETTEXT=$ac_cv_path_XGETTEXT +if test -n "$XGETTEXT"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $XGETTEXT" >&5 +$as_echo "$XGETTEXT" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +# Extract the first word of "msgmerge", so it can be a program name with args. +set dummy msgmerge; 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_MSGMERGE+:} false; then : + $as_echo_n "(cached) " >&6 +else + case $MSGMERGE in + [\\/]* | ?:[\\/]*) + ac_cv_path_MSGMERGE="$MSGMERGE" # 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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_path_MSGMERGE="$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 + + ;; +esac +fi +MSGMERGE=$ac_cv_path_MSGMERGE +if test -n "$MSGMERGE"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MSGMERGE" >&5 +$as_echo "$MSGMERGE" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +# Extract the first word of "msgfmt", so it can be a program name with args. +set dummy msgfmt; 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_MSGFMT+:} false; then : + $as_echo_n "(cached) " >&6 +else + case $MSGFMT in + [\\/]* | ?:[\\/]*) + ac_cv_path_MSGFMT="$MSGFMT" # 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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_path_MSGFMT="$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 + + ;; +esac +fi +MSGFMT=$ac_cv_path_MSGFMT +if test -n "$MSGFMT"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MSGFMT" >&5 +$as_echo "$MSGFMT" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +# Extract the first word of "gmsgfmt", so it can be a program name with args. +set dummy gmsgfmt; 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_GMSGFMT+:} false; then : + $as_echo_n "(cached) " >&6 +else + case $GMSGFMT in + [\\/]* | ?:[\\/]*) + ac_cv_path_GMSGFMT="$GMSGFMT" # 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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_path_GMSGFMT="$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_GMSGFMT" && ac_cv_path_GMSGFMT="$MSGFMT" + ;; +esac +fi +GMSGFMT=$ac_cv_path_GMSGFMT +if test -n "$GMSGFMT"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $GMSGFMT" >&5 +$as_echo "$GMSGFMT" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +if test -z "$XGETTEXT" -o -z "$MSGMERGE" -o -z "$MSGFMT"; then + as_fn_error $? "GNU gettext tools not found; required for intltool" "$LINENO" 5 +fi +xgversion="`$XGETTEXT --version|grep '(GNU ' 2> /dev/null`" +mmversion="`$MSGMERGE --version|grep '(GNU ' 2> /dev/null`" +mfversion="`$MSGFMT --version|grep '(GNU ' 2> /dev/null`" +if test -z "$xgversion" -o -z "$mmversion" -o -z "$mfversion"; then + as_fn_error $? "GNU gettext tools not found; required for intltool" "$LINENO" 5 +fi + +# Extract the first word of "perl", so it can be a program name with args. +set dummy perl; 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_INTLTOOL_PERL+:} false; then : + $as_echo_n "(cached) " >&6 +else + case $INTLTOOL_PERL in + [\\/]* | ?:[\\/]*) + ac_cv_path_INTLTOOL_PERL="$INTLTOOL_PERL" # 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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_path_INTLTOOL_PERL="$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 + + ;; +esac +fi +INTLTOOL_PERL=$ac_cv_path_INTLTOOL_PERL +if test -n "$INTLTOOL_PERL"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $INTLTOOL_PERL" >&5 +$as_echo "$INTLTOOL_PERL" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +if test -z "$INTLTOOL_PERL"; then + as_fn_error $? "perl not found" "$LINENO" 5 +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for perl >= 5.8.1" >&5 +$as_echo_n "checking for perl >= 5.8.1... " >&6; } +$INTLTOOL_PERL -e "use 5.8.1;" > /dev/null 2>&1 +if test $? -ne 0; then + as_fn_error $? "perl 5.8.1 is required for intltool" "$LINENO" 5 +else + IT_PERL_VERSION="`$INTLTOOL_PERL -e \"printf '%vd', $^V\"`" + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $IT_PERL_VERSION" >&5 +$as_echo "$IT_PERL_VERSION" >&6; } +fi +if test "x" != "xno-xml"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for XML::Parser" >&5 +$as_echo_n "checking for XML::Parser... " >&6; } + if `$INTLTOOL_PERL -e "require XML::Parser" 2>/dev/null`; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5 +$as_echo "ok" >&6; } + else + as_fn_error $? "XML::Parser perl module is required for intltool" "$LINENO" 5 + fi +fi + +# Substitute ALL_LINGUAS so we can use it in po/Makefile + + +# Set DATADIRNAME correctly if it is not set yet +# (copied from glib-gettext.m4) +if test -z "$DATADIRNAME"; then + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ +extern int _nl_msg_cat_cntr; + return _nl_msg_cat_cntr + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + DATADIRNAME=share +else + case $host in + *-*-solaris*) + ac_fn_c_check_func "$LINENO" "bind_textdomain_codeset" "ac_cv_func_bind_textdomain_codeset" +if test "x$ac_cv_func_bind_textdomain_codeset" = xyes; then : + DATADIRNAME=share +else + DATADIRNAME=lib +fi + + ;; + *) + DATADIRNAME=lib + ;; + esac +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi + + + + + + +POSUB=" + po + po-Engine + po-Engine-IRC + po-Engine-XMPP + po-Engine-OSCAR + po-Engine-MSNP + po-Server + po-Frontend + po-Frontend-GNOME + po-Frontend-GNOME-IRC + po-Frontend-GNOME-XMPP + po-Frontend-SWF +" + +GETTEXT_PACKAGE=smuxi + + +GETTEXT_PACKAGE_ENGINE=smuxi-engine + + +cat >>confdefs.h <<_ACEOF +#define GETTEXT_PACKAGE_ENGINE "$GETTEXT_PACKAGE_ENGINE" +_ACEOF + + +GETTEXT_PACKAGE_ENGINE_IRC=smuxi-engine-irc + + +cat >>confdefs.h <<_ACEOF +#define GETTEXT_PACKAGE_ENGINE_IRC "$GETTEXT_PACKAGE_ENGINE_IRC" +_ACEOF + + +GETTEXT_PACKAGE_ENGINE_XMPP=smuxi-engine-xmpp + + +cat >>confdefs.h <<_ACEOF +#define GETTEXT_PACKAGE_ENGINE_XMPP "$GETTEXT_PACKAGE_ENGINE_XMPP" +_ACEOF + + +GETTEXT_PACKAGE_ENGINE_OSCAR=smuxi-engine-oscar + + +cat >>confdefs.h <<_ACEOF +#define GETTEXT_PACKAGE_ENGINE_OSCAR "$GETTEXT_PACKAGE_ENGINE_OSCAR" +_ACEOF + + +GETTEXT_PACKAGE_ENGINE_MSNP=smuxi-engine-msnp + + +cat >>confdefs.h <<_ACEOF +#define GETTEXT_PACKAGE_ENGINE_MSNP "$GETTEXT_PACKAGE_ENGINE_MSNP" +_ACEOF + + +GETTEXT_PACKAGE_ENGINE_TWITTER=smuxi-engine-twitter + + +cat >>confdefs.h <<_ACEOF +#define GETTEXT_PACKAGE_ENGINE_TWITTER "$GETTEXT_PACKAGE_ENGINE_TWITTER" +_ACEOF + + +GETTEXT_PACKAGE_SERVER=smuxi-server + + +cat >>confdefs.h <<_ACEOF +#define GETTEXT_PACKAGE_SERVER "$GETTEXT_PACKAGE_SERVER" +_ACEOF + + +GETTEXT_PACKAGE_FRONTEND=smuxi-frontend + + +cat >>confdefs.h <<_ACEOF +#define GETTEXT_PACKAGE_FRONTEND "$GETTEXT_PACKAGE_FRONTEND" +_ACEOF + + +GETTEXT_PACKAGE_FRONTEND_GNOME=smuxi-frontend-gnome + + +cat >>confdefs.h <<_ACEOF +#define GETTEXT_PACKAGE_FRONTEND_GNOME "$GETTEXT_PACKAGE_FRONTEND_GNOME" +_ACEOF + + +GETTEXT_PACKAGE_FRONTEND_GNOME_IRC=smuxi-frontend-gnome-irc + + +cat >>confdefs.h <<_ACEOF +#define GETTEXT_PACKAGE_FRONTEND_GNOME_IRC "$GETTEXT_PACKAGE_FRONTEND_GNOME_IRC" +_ACEOF + + +GETTEXT_PACKAGE_FRONTEND_GNOME_XMPP=smuxi-frontend-gnome-xmpp + + +cat >>confdefs.h <<_ACEOF +#define GETTEXT_PACKAGE_FRONTEND_GNOME_XMPP "$GETTEXT_PACKAGE_FRONTEND_GNOME_XMPP" +_ACEOF + + +GETTEXT_PACKAGE_FRONTEND_STFL=smuxi-frontend-stfl + + +cat >>confdefs.h <<_ACEOF +#define GETTEXT_PACKAGE_FRONTEND_STFL "$GETTEXT_PACKAGE_FRONTEND_STFL" +_ACEOF + + +GETTEXT_PACKAGE_FRONTEND_CURSES=smuxi-frontend-curses + + +cat >>confdefs.h <<_ACEOF +#define GETTEXT_PACKAGE_FRONTEND_CURSES "$GETTEXT_PACKAGE_FRONTEND_CURSES" +_ACEOF + + +GETTEXT_PACKAGE_FRONTEND_SWF=smuxi-frontend-swf + + +cat >>confdefs.h <<_ACEOF +#define GETTEXT_PACKAGE_FRONTEND_SWF "$GETTEXT_PACKAGE_FRONTEND_SWF" +_ACEOF + + +GETTEXT_PACKAGE_FRONTEND_WPF=smuxi-frontend-wpf + + +cat >>confdefs.h <<_ACEOF +#define GETTEXT_PACKAGE_FRONTEND_WPF "$GETTEXT_PACKAGE_FRONTEND_WPF" +_ACEOF + + + + + GETTEXT_MACRO_VERSION=0.18 + + + + +# Prepare PATH_SEPARATOR. +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + echo "#! /bin/sh" >conf$$.sh + echo "exit 0" >>conf$$.sh + chmod +x conf$$.sh + if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then + PATH_SEPARATOR=';' + else + PATH_SEPARATOR=: + fi + rm -f conf$$.sh +fi + +# Find out how to test for executable files. Don't use a zero-byte file, +# as systems may use methods other than mode bits to determine executability. +cat >conf$$.file <<_ASEOF +#! /bin/sh +exit 0 +_ASEOF +chmod +x conf$$.file +if test -x conf$$.file >/dev/null 2>&1; then + ac_executable_p="test -x" +else + ac_executable_p="test -f" +fi +rm -f conf$$.file + +# Extract the first word of "msgfmt", so it can be a program name with args. +set dummy msgfmt; 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_MSGFMT+:} false; then : + $as_echo_n "(cached) " >&6 +else + case "$MSGFMT" in + [\\/]* | ?:[\\/]*) + ac_cv_path_MSGFMT="$MSGFMT" # Let the user override the test with a path. + ;; + *) + ac_save_IFS="$IFS"; IFS=$PATH_SEPARATOR + for ac_dir in $PATH; do + IFS="$ac_save_IFS" + test -z "$ac_dir" && ac_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $ac_executable_p "$ac_dir/$ac_word$ac_exec_ext"; then + echo "$as_me: trying $ac_dir/$ac_word..." >&5 + if $ac_dir/$ac_word --statistics /dev/null >&5 2>&1 && + (if $ac_dir/$ac_word --statistics /dev/null 2>&1 >/dev/null | grep usage >/dev/null; then exit 1; else exit 0; fi); then + ac_cv_path_MSGFMT="$ac_dir/$ac_word$ac_exec_ext" + break 2 + fi + fi + done + done + IFS="$ac_save_IFS" + test -z "$ac_cv_path_MSGFMT" && ac_cv_path_MSGFMT=":" + ;; +esac +fi +MSGFMT="$ac_cv_path_MSGFMT" +if test "$MSGFMT" != ":"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MSGFMT" >&5 +$as_echo "$MSGFMT" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + # Extract the first word of "gmsgfmt", so it can be a program name with args. +set dummy gmsgfmt; 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_GMSGFMT+:} false; then : + $as_echo_n "(cached) " >&6 +else + case $GMSGFMT in + [\\/]* | ?:[\\/]*) + ac_cv_path_GMSGFMT="$GMSGFMT" # 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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_path_GMSGFMT="$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_GMSGFMT" && ac_cv_path_GMSGFMT="$MSGFMT" + ;; +esac +fi +GMSGFMT=$ac_cv_path_GMSGFMT +if test -n "$GMSGFMT"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $GMSGFMT" >&5 +$as_echo "$GMSGFMT" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + + case `$MSGFMT --version | sed 1q | sed -e 's,^[^0-9]*,,'` in + '' | 0.[0-9] | 0.[0-9].* | 0.1[0-4] | 0.1[0-4].*) MSGFMT_015=: ;; + *) MSGFMT_015=$MSGFMT ;; + esac + + case `$GMSGFMT --version | sed 1q | sed -e 's,^[^0-9]*,,'` in + '' | 0.[0-9] | 0.[0-9].* | 0.1[0-4] | 0.1[0-4].*) GMSGFMT_015=: ;; + *) GMSGFMT_015=$GMSGFMT ;; + esac + + + +# Prepare PATH_SEPARATOR. +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + echo "#! /bin/sh" >conf$$.sh + echo "exit 0" >>conf$$.sh + chmod +x conf$$.sh + if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then + PATH_SEPARATOR=';' + else + PATH_SEPARATOR=: + fi + rm -f conf$$.sh +fi + +# Find out how to test for executable files. Don't use a zero-byte file, +# as systems may use methods other than mode bits to determine executability. +cat >conf$$.file <<_ASEOF +#! /bin/sh +exit 0 +_ASEOF +chmod +x conf$$.file +if test -x conf$$.file >/dev/null 2>&1; then + ac_executable_p="test -x" +else + ac_executable_p="test -f" +fi +rm -f conf$$.file + +# Extract the first word of "xgettext", so it can be a program name with args. +set dummy xgettext; 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_XGETTEXT+:} false; then : + $as_echo_n "(cached) " >&6 +else + case "$XGETTEXT" in + [\\/]* | ?:[\\/]*) + ac_cv_path_XGETTEXT="$XGETTEXT" # Let the user override the test with a path. + ;; + *) + ac_save_IFS="$IFS"; IFS=$PATH_SEPARATOR + for ac_dir in $PATH; do + IFS="$ac_save_IFS" + test -z "$ac_dir" && ac_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $ac_executable_p "$ac_dir/$ac_word$ac_exec_ext"; then + echo "$as_me: trying $ac_dir/$ac_word..." >&5 + if $ac_dir/$ac_word --omit-header --copyright-holder= --msgid-bugs-address= /dev/null >&5 2>&1 && + (if $ac_dir/$ac_word --omit-header --copyright-holder= --msgid-bugs-address= /dev/null 2>&1 >/dev/null | grep usage >/dev/null; then exit 1; else exit 0; fi); then + ac_cv_path_XGETTEXT="$ac_dir/$ac_word$ac_exec_ext" + break 2 + fi + fi + done + done + IFS="$ac_save_IFS" + test -z "$ac_cv_path_XGETTEXT" && ac_cv_path_XGETTEXT=":" + ;; +esac +fi +XGETTEXT="$ac_cv_path_XGETTEXT" +if test "$XGETTEXT" != ":"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $XGETTEXT" >&5 +$as_echo "$XGETTEXT" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + rm -f messages.po + + case `$XGETTEXT --version | sed 1q | sed -e 's,^[^0-9]*,,'` in + '' | 0.[0-9] | 0.[0-9].* | 0.1[0-4] | 0.1[0-4].*) XGETTEXT_015=: ;; + *) XGETTEXT_015=$XGETTEXT ;; + esac + + + +# Prepare PATH_SEPARATOR. +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + echo "#! /bin/sh" >conf$$.sh + echo "exit 0" >>conf$$.sh + chmod +x conf$$.sh + if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then + PATH_SEPARATOR=';' + else + PATH_SEPARATOR=: + fi + rm -f conf$$.sh +fi + +# Find out how to test for executable files. Don't use a zero-byte file, +# as systems may use methods other than mode bits to determine executability. +cat >conf$$.file <<_ASEOF +#! /bin/sh +exit 0 +_ASEOF +chmod +x conf$$.file +if test -x conf$$.file >/dev/null 2>&1; then + ac_executable_p="test -x" +else + ac_executable_p="test -f" +fi +rm -f conf$$.file + +# Extract the first word of "msgmerge", so it can be a program name with args. +set dummy msgmerge; 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_MSGMERGE+:} false; then : + $as_echo_n "(cached) " >&6 +else + case "$MSGMERGE" in + [\\/]* | ?:[\\/]*) + ac_cv_path_MSGMERGE="$MSGMERGE" # Let the user override the test with a path. + ;; + *) + ac_save_IFS="$IFS"; IFS=$PATH_SEPARATOR + for ac_dir in $PATH; do + IFS="$ac_save_IFS" + test -z "$ac_dir" && ac_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $ac_executable_p "$ac_dir/$ac_word$ac_exec_ext"; then + echo "$as_me: trying $ac_dir/$ac_word..." >&5 + if $ac_dir/$ac_word --update -q /dev/null /dev/null >&5 2>&1; then + ac_cv_path_MSGMERGE="$ac_dir/$ac_word$ac_exec_ext" + break 2 + fi + fi + done + done + IFS="$ac_save_IFS" + test -z "$ac_cv_path_MSGMERGE" && ac_cv_path_MSGMERGE=":" + ;; +esac +fi +MSGMERGE="$ac_cv_path_MSGMERGE" +if test "$MSGMERGE" != ":"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MSGMERGE" >&5 +$as_echo "$MSGMERGE" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$localedir" || localedir='${datadir}/locale' + + + test -n "${XGETTEXT_EXTRA_OPTIONS+set}" || XGETTEXT_EXTRA_OPTIONS= + + + ac_config_commands="$ac_config_commands po-directories" + + + + if test "X$prefix" = "XNONE"; then + acl_final_prefix="$ac_default_prefix" + else + acl_final_prefix="$prefix" + fi + if test "X$exec_prefix" = "XNONE"; then + acl_final_exec_prefix='${prefix}' + else + acl_final_exec_prefix="$exec_prefix" + fi + acl_save_prefix="$prefix" + prefix="$acl_final_prefix" + eval acl_final_exec_prefix=\"$acl_final_exec_prefix\" + prefix="$acl_save_prefix" + + +# Check whether --with-gnu-ld was given. +if test "${with_gnu_ld+set}" = set; then : + withval=$with_gnu_ld; test "$withval" = no || with_gnu_ld=yes +else + with_gnu_ld=no +fi + +# Prepare PATH_SEPARATOR. +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + echo "#! /bin/sh" >conf$$.sh + echo "exit 0" >>conf$$.sh + chmod +x conf$$.sh + if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then + PATH_SEPARATOR=';' + else + PATH_SEPARATOR=: + fi + rm -f conf$$.sh +fi +ac_prog=ld +if test "$GCC" = yes; then + # Check if gcc -print-prog-name=ld gives a path. + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ld used by GCC" >&5 +$as_echo_n "checking for ld used by GCC... " >&6; } + case $host in + *-*-mingw*) + # gcc leaves a trailing carriage return which upsets mingw + ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; + *) + ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; + esac + case $ac_prog in + # Accept absolute paths. + [\\/]* | [A-Za-z]:[\\/]*) + re_direlt='/[^/][^/]*/\.\./' + # Canonicalize the path of ld + ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'` + while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do + ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"` + done + test -z "$LD" && LD="$ac_prog" + ;; + "") + # If it fails, then pretend we aren't using GCC. + ac_prog=ld + ;; + *) + # If it is relative, then search for the first ld in PATH. + with_gnu_ld=unknown + ;; + esac +elif test "$with_gnu_ld" = yes; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU ld" >&5 +$as_echo_n "checking for GNU ld... " >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for non-GNU ld" >&5 +$as_echo_n "checking for non-GNU ld... " >&6; } +fi +if ${acl_cv_path_LD+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -z "$LD"; then + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}" + for ac_dir in $PATH; do + test -z "$ac_dir" && ac_dir=. + if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then + acl_cv_path_LD="$ac_dir/$ac_prog" + # Check to see if the program is GNU ld. I'd rather use --version, + # but apparently some GNU ld's only accept -v. + # Break only if it was the GNU/non-GNU ld that we prefer. + case `"$acl_cv_path_LD" -v 2>&1 < /dev/null` in + *GNU* | *'with BFD'*) + test "$with_gnu_ld" != no && break ;; + *) + test "$with_gnu_ld" != yes && break ;; + esac + fi + done + IFS="$ac_save_ifs" +else + acl_cv_path_LD="$LD" # Let the user override the test with a path. +fi +fi + +LD="$acl_cv_path_LD" +if test -n "$LD"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LD" >&5 +$as_echo "$LD" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi +test -z "$LD" && as_fn_error $? "no acceptable ld found in \$PATH" "$LINENO" 5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if the linker ($LD) is GNU ld" >&5 +$as_echo_n "checking if the linker ($LD) is GNU ld... " >&6; } +if ${acl_cv_prog_gnu_ld+:} false; then : + $as_echo_n "(cached) " >&6 +else + # I'd rather use --version here, but apparently some GNU ld's only accept -v. +case `$LD -v 2>&1 &5 +$as_echo "$acl_cv_prog_gnu_ld" >&6; } +with_gnu_ld=$acl_cv_prog_gnu_ld + + + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for shared library run path origin" >&5 +$as_echo_n "checking for shared library run path origin... " >&6; } +if ${acl_cv_rpath+:} false; then : + $as_echo_n "(cached) " >&6 +else + + CC="$CC" GCC="$GCC" LDFLAGS="$LDFLAGS" LD="$LD" with_gnu_ld="$with_gnu_ld" \ + ${CONFIG_SHELL-/bin/sh} "$ac_aux_dir/config.rpath" "$host" > conftest.sh + . ./conftest.sh + rm -f ./conftest.sh + acl_cv_rpath=done + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $acl_cv_rpath" >&5 +$as_echo "$acl_cv_rpath" >&6; } + wl="$acl_cv_wl" + acl_libext="$acl_cv_libext" + acl_shlibext="$acl_cv_shlibext" + acl_libname_spec="$acl_cv_libname_spec" + acl_library_names_spec="$acl_cv_library_names_spec" + acl_hardcode_libdir_flag_spec="$acl_cv_hardcode_libdir_flag_spec" + acl_hardcode_libdir_separator="$acl_cv_hardcode_libdir_separator" + acl_hardcode_direct="$acl_cv_hardcode_direct" + acl_hardcode_minus_L="$acl_cv_hardcode_minus_L" + # Check whether --enable-rpath was given. +if test "${enable_rpath+set}" = set; then : + enableval=$enable_rpath; : +else + enable_rpath=yes +fi + + + + + acl_libdirstem=lib + acl_libdirstem2= + case "$host_os" in + solaris*) + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for 64-bit host" >&5 +$as_echo_n "checking for 64-bit host... " >&6; } +if ${gl_cv_solaris_64bit+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#ifdef _LP64 +sixtyfour bits +#endif + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "sixtyfour bits" >/dev/null 2>&1; then : + gl_cv_solaris_64bit=yes +else + gl_cv_solaris_64bit=no +fi +rm -f conftest* + + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_solaris_64bit" >&5 +$as_echo "$gl_cv_solaris_64bit" >&6; } + if test $gl_cv_solaris_64bit = yes; then + acl_libdirstem=lib/64 + case "$host_cpu" in + sparc*) acl_libdirstem2=lib/sparcv9 ;; + i*86 | x86_64) acl_libdirstem2=lib/amd64 ;; + esac + fi + ;; + *) + searchpath=`(LC_ALL=C $CC -print-search-dirs) 2>/dev/null | sed -n -e 's,^libraries: ,,p' | sed -e 's,^=,,'` + if test -n "$searchpath"; then + acl_save_IFS="${IFS= }"; IFS=":" + for searchdir in $searchpath; do + if test -d "$searchdir"; then + case "$searchdir" in + */lib64/ | */lib64 ) acl_libdirstem=lib64 ;; + */../ | */.. ) + # Better ignore directories of this form. They are misleading. + ;; + *) searchdir=`cd "$searchdir" && pwd` + case "$searchdir" in + */lib64 ) acl_libdirstem=lib64 ;; + esac ;; + esac + fi + done + IFS="$acl_save_IFS" + fi + ;; + esac + test -n "$acl_libdirstem2" || acl_libdirstem2="$acl_libdirstem" + + + + + + + + + + + + + use_additional=yes + + acl_save_prefix="$prefix" + prefix="$acl_final_prefix" + acl_save_exec_prefix="$exec_prefix" + exec_prefix="$acl_final_exec_prefix" + + eval additional_includedir=\"$includedir\" + eval additional_libdir=\"$libdir\" + + exec_prefix="$acl_save_exec_prefix" + prefix="$acl_save_prefix" + + +# Check whether --with-libiconv-prefix was given. +if test "${with_libiconv_prefix+set}" = set; then : + withval=$with_libiconv_prefix; + if test "X$withval" = "Xno"; then + use_additional=no + else + if test "X$withval" = "X"; then + + acl_save_prefix="$prefix" + prefix="$acl_final_prefix" + acl_save_exec_prefix="$exec_prefix" + exec_prefix="$acl_final_exec_prefix" + + eval additional_includedir=\"$includedir\" + eval additional_libdir=\"$libdir\" + + exec_prefix="$acl_save_exec_prefix" + prefix="$acl_save_prefix" + + else + additional_includedir="$withval/include" + additional_libdir="$withval/$acl_libdirstem" + if test "$acl_libdirstem2" != "$acl_libdirstem" \ + && ! test -d "$withval/$acl_libdirstem"; then + additional_libdir="$withval/$acl_libdirstem2" + fi + fi + fi + +fi + + LIBICONV= + LTLIBICONV= INCICONV= LIBICONV_PREFIX= HAVE_LIBICONV= rpathdirs= ltrpathdirs= names_already_handled= - names_next_round='iconv ' + names_next_round='iconv ' + while test -n "$names_next_round"; do + names_this_round="$names_next_round" + names_next_round= + for name in $names_this_round; do + already_handled= + for n in $names_already_handled; do + if test "$n" = "$name"; then + already_handled=yes + break + fi + done + if test -z "$already_handled"; then + names_already_handled="$names_already_handled $name" + uppername=`echo "$name" | sed -e 'y|abcdefghijklmnopqrstuvwxyz./-|ABCDEFGHIJKLMNOPQRSTUVWXYZ___|'` + eval value=\"\$HAVE_LIB$uppername\" + if test -n "$value"; then + if test "$value" = yes; then + eval value=\"\$LIB$uppername\" + test -z "$value" || LIBICONV="${LIBICONV}${LIBICONV:+ }$value" + eval value=\"\$LTLIB$uppername\" + test -z "$value" || LTLIBICONV="${LTLIBICONV}${LTLIBICONV:+ }$value" + else + : + fi + else + found_dir= + found_la= + found_so= + found_a= + eval libname=\"$acl_libname_spec\" # typically: libname=lib$name + if test -n "$acl_shlibext"; then + shrext=".$acl_shlibext" # typically: shrext=.so + else + shrext= + fi + if test $use_additional = yes; then + dir="$additional_libdir" + if test -n "$acl_shlibext"; then + if test -f "$dir/$libname$shrext"; then + found_dir="$dir" + found_so="$dir/$libname$shrext" + else + if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then + ver=`(cd "$dir" && \ + for f in "$libname$shrext".*; do echo "$f"; done \ + | sed -e "s,^$libname$shrext\\\\.,," \ + | sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \ + | sed 1q ) 2>/dev/null` + if test -n "$ver" && test -f "$dir/$libname$shrext.$ver"; then + found_dir="$dir" + found_so="$dir/$libname$shrext.$ver" + fi + else + eval library_names=\"$acl_library_names_spec\" + for f in $library_names; do + if test -f "$dir/$f"; then + found_dir="$dir" + found_so="$dir/$f" + break + fi + done + fi + fi + fi + if test "X$found_dir" = "X"; then + if test -f "$dir/$libname.$acl_libext"; then + found_dir="$dir" + found_a="$dir/$libname.$acl_libext" + fi + fi + if test "X$found_dir" != "X"; then + if test -f "$dir/$libname.la"; then + found_la="$dir/$libname.la" + fi + fi + fi + if test "X$found_dir" = "X"; then + for x in $LDFLAGS $LTLIBICONV; do + + acl_save_prefix="$prefix" + prefix="$acl_final_prefix" + acl_save_exec_prefix="$exec_prefix" + exec_prefix="$acl_final_exec_prefix" + eval x=\"$x\" + exec_prefix="$acl_save_exec_prefix" + prefix="$acl_save_prefix" + + case "$x" in + -L*) + dir=`echo "X$x" | sed -e 's/^X-L//'` + if test -n "$acl_shlibext"; then + if test -f "$dir/$libname$shrext"; then + found_dir="$dir" + found_so="$dir/$libname$shrext" + else + if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then + ver=`(cd "$dir" && \ + for f in "$libname$shrext".*; do echo "$f"; done \ + | sed -e "s,^$libname$shrext\\\\.,," \ + | sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \ + | sed 1q ) 2>/dev/null` + if test -n "$ver" && test -f "$dir/$libname$shrext.$ver"; then + found_dir="$dir" + found_so="$dir/$libname$shrext.$ver" + fi + else + eval library_names=\"$acl_library_names_spec\" + for f in $library_names; do + if test -f "$dir/$f"; then + found_dir="$dir" + found_so="$dir/$f" + break + fi + done + fi + fi + fi + if test "X$found_dir" = "X"; then + if test -f "$dir/$libname.$acl_libext"; then + found_dir="$dir" + found_a="$dir/$libname.$acl_libext" + fi + fi + if test "X$found_dir" != "X"; then + if test -f "$dir/$libname.la"; then + found_la="$dir/$libname.la" + fi + fi + ;; + esac + if test "X$found_dir" != "X"; then + break + fi + done + fi + if test "X$found_dir" != "X"; then + LTLIBICONV="${LTLIBICONV}${LTLIBICONV:+ }-L$found_dir -l$name" + if test "X$found_so" != "X"; then + if test "$enable_rpath" = no \ + || test "X$found_dir" = "X/usr/$acl_libdirstem" \ + || test "X$found_dir" = "X/usr/$acl_libdirstem2"; then + LIBICONV="${LIBICONV}${LIBICONV:+ }$found_so" + else + haveit= + for x in $ltrpathdirs; do + if test "X$x" = "X$found_dir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + ltrpathdirs="$ltrpathdirs $found_dir" + fi + if test "$acl_hardcode_direct" = yes; then + LIBICONV="${LIBICONV}${LIBICONV:+ }$found_so" + else + if test -n "$acl_hardcode_libdir_flag_spec" && test "$acl_hardcode_minus_L" = no; then + LIBICONV="${LIBICONV}${LIBICONV:+ }$found_so" + haveit= + for x in $rpathdirs; do + if test "X$x" = "X$found_dir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + rpathdirs="$rpathdirs $found_dir" + fi + else + haveit= + for x in $LDFLAGS $LIBICONV; do + + acl_save_prefix="$prefix" + prefix="$acl_final_prefix" + acl_save_exec_prefix="$exec_prefix" + exec_prefix="$acl_final_exec_prefix" + eval x=\"$x\" + exec_prefix="$acl_save_exec_prefix" + prefix="$acl_save_prefix" + + if test "X$x" = "X-L$found_dir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + LIBICONV="${LIBICONV}${LIBICONV:+ }-L$found_dir" + fi + if test "$acl_hardcode_minus_L" != no; then + LIBICONV="${LIBICONV}${LIBICONV:+ }$found_so" + else + LIBICONV="${LIBICONV}${LIBICONV:+ }-l$name" + fi + fi + fi + fi + else + if test "X$found_a" != "X"; then + LIBICONV="${LIBICONV}${LIBICONV:+ }$found_a" + else + LIBICONV="${LIBICONV}${LIBICONV:+ }-L$found_dir -l$name" + fi + fi + additional_includedir= + case "$found_dir" in + */$acl_libdirstem | */$acl_libdirstem/) + basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem/"'*$,,'` + if test "$name" = 'iconv'; then + LIBICONV_PREFIX="$basedir" + fi + additional_includedir="$basedir/include" + ;; + */$acl_libdirstem2 | */$acl_libdirstem2/) + basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem2/"'*$,,'` + if test "$name" = 'iconv'; then + LIBICONV_PREFIX="$basedir" + fi + additional_includedir="$basedir/include" + ;; + esac + if test "X$additional_includedir" != "X"; then + if test "X$additional_includedir" != "X/usr/include"; then + haveit= + if test "X$additional_includedir" = "X/usr/local/include"; then + if test -n "$GCC"; then + case $host_os in + linux* | gnu* | k*bsd*-gnu) haveit=yes;; + esac + fi + fi + if test -z "$haveit"; then + for x in $CPPFLAGS $INCICONV; do + + acl_save_prefix="$prefix" + prefix="$acl_final_prefix" + acl_save_exec_prefix="$exec_prefix" + exec_prefix="$acl_final_exec_prefix" + eval x=\"$x\" + exec_prefix="$acl_save_exec_prefix" + prefix="$acl_save_prefix" + + if test "X$x" = "X-I$additional_includedir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + if test -d "$additional_includedir"; then + INCICONV="${INCICONV}${INCICONV:+ }-I$additional_includedir" + fi + fi + fi + fi + fi + if test -n "$found_la"; then + save_libdir="$libdir" + case "$found_la" in + */* | *\\*) . "$found_la" ;; + *) . "./$found_la" ;; + esac + libdir="$save_libdir" + for dep in $dependency_libs; do + case "$dep" in + -L*) + additional_libdir=`echo "X$dep" | sed -e 's/^X-L//'` + if test "X$additional_libdir" != "X/usr/$acl_libdirstem" \ + && test "X$additional_libdir" != "X/usr/$acl_libdirstem2"; then + haveit= + if test "X$additional_libdir" = "X/usr/local/$acl_libdirstem" \ + || test "X$additional_libdir" = "X/usr/local/$acl_libdirstem2"; then + if test -n "$GCC"; then + case $host_os in + linux* | gnu* | k*bsd*-gnu) haveit=yes;; + esac + fi + fi + if test -z "$haveit"; then + haveit= + for x in $LDFLAGS $LIBICONV; do + + acl_save_prefix="$prefix" + prefix="$acl_final_prefix" + acl_save_exec_prefix="$exec_prefix" + exec_prefix="$acl_final_exec_prefix" + eval x=\"$x\" + exec_prefix="$acl_save_exec_prefix" + prefix="$acl_save_prefix" + + if test "X$x" = "X-L$additional_libdir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + if test -d "$additional_libdir"; then + LIBICONV="${LIBICONV}${LIBICONV:+ }-L$additional_libdir" + fi + fi + haveit= + for x in $LDFLAGS $LTLIBICONV; do + + acl_save_prefix="$prefix" + prefix="$acl_final_prefix" + acl_save_exec_prefix="$exec_prefix" + exec_prefix="$acl_final_exec_prefix" + eval x=\"$x\" + exec_prefix="$acl_save_exec_prefix" + prefix="$acl_save_prefix" + + if test "X$x" = "X-L$additional_libdir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + if test -d "$additional_libdir"; then + LTLIBICONV="${LTLIBICONV}${LTLIBICONV:+ }-L$additional_libdir" + fi + fi + fi + fi + ;; + -R*) + dir=`echo "X$dep" | sed -e 's/^X-R//'` + if test "$enable_rpath" != no; then + haveit= + for x in $rpathdirs; do + if test "X$x" = "X$dir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + rpathdirs="$rpathdirs $dir" + fi + haveit= + for x in $ltrpathdirs; do + if test "X$x" = "X$dir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + ltrpathdirs="$ltrpathdirs $dir" + fi + fi + ;; + -l*) + names_next_round="$names_next_round "`echo "X$dep" | sed -e 's/^X-l//'` + ;; + *.la) + names_next_round="$names_next_round "`echo "X$dep" | sed -e 's,^X.*/,,' -e 's,^lib,,' -e 's,\.la$,,'` + ;; + *) + LIBICONV="${LIBICONV}${LIBICONV:+ }$dep" + LTLIBICONV="${LTLIBICONV}${LTLIBICONV:+ }$dep" + ;; + esac + done + fi + else + LIBICONV="${LIBICONV}${LIBICONV:+ }-l$name" + LTLIBICONV="${LTLIBICONV}${LTLIBICONV:+ }-l$name" + fi + fi + fi + done + done + if test "X$rpathdirs" != "X"; then + if test -n "$acl_hardcode_libdir_separator"; then + alldirs= + for found_dir in $rpathdirs; do + alldirs="${alldirs}${alldirs:+$acl_hardcode_libdir_separator}$found_dir" + done + acl_save_libdir="$libdir" + libdir="$alldirs" + eval flag=\"$acl_hardcode_libdir_flag_spec\" + libdir="$acl_save_libdir" + LIBICONV="${LIBICONV}${LIBICONV:+ }$flag" + else + for found_dir in $rpathdirs; do + acl_save_libdir="$libdir" + libdir="$found_dir" + eval flag=\"$acl_hardcode_libdir_flag_spec\" + libdir="$acl_save_libdir" + LIBICONV="${LIBICONV}${LIBICONV:+ }$flag" + done + fi + fi + if test "X$ltrpathdirs" != "X"; then + for found_dir in $ltrpathdirs; do + LTLIBICONV="${LTLIBICONV}${LTLIBICONV:+ }-R$found_dir" + done + fi + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for CFPreferencesCopyAppValue" >&5 +$as_echo_n "checking for CFPreferencesCopyAppValue... " >&6; } +if ${gt_cv_func_CFPreferencesCopyAppValue+:} false; then : + $as_echo_n "(cached) " >&6 +else + gt_save_LIBS="$LIBS" + LIBS="$LIBS -Wl,-framework -Wl,CoreFoundation" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +int +main () +{ +CFPreferencesCopyAppValue(NULL, NULL) + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + gt_cv_func_CFPreferencesCopyAppValue=yes +else + gt_cv_func_CFPreferencesCopyAppValue=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + LIBS="$gt_save_LIBS" +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gt_cv_func_CFPreferencesCopyAppValue" >&5 +$as_echo "$gt_cv_func_CFPreferencesCopyAppValue" >&6; } + if test $gt_cv_func_CFPreferencesCopyAppValue = yes; then + +$as_echo "#define HAVE_CFPREFERENCESCOPYAPPVALUE 1" >>confdefs.h + + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for CFLocaleCopyCurrent" >&5 +$as_echo_n "checking for CFLocaleCopyCurrent... " >&6; } +if ${gt_cv_func_CFLocaleCopyCurrent+:} false; then : + $as_echo_n "(cached) " >&6 +else + gt_save_LIBS="$LIBS" + LIBS="$LIBS -Wl,-framework -Wl,CoreFoundation" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +int +main () +{ +CFLocaleCopyCurrent(); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + gt_cv_func_CFLocaleCopyCurrent=yes +else + gt_cv_func_CFLocaleCopyCurrent=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + LIBS="$gt_save_LIBS" +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gt_cv_func_CFLocaleCopyCurrent" >&5 +$as_echo "$gt_cv_func_CFLocaleCopyCurrent" >&6; } + if test $gt_cv_func_CFLocaleCopyCurrent = yes; then + +$as_echo "#define HAVE_CFLOCALECOPYCURRENT 1" >>confdefs.h + + fi + INTL_MACOSX_LIBS= + if test $gt_cv_func_CFPreferencesCopyAppValue = yes || test $gt_cv_func_CFLocaleCopyCurrent = yes; then + INTL_MACOSX_LIBS="-Wl,-framework -Wl,CoreFoundation" + fi + + + + + + + LIBINTL= + LTLIBINTL= + POSUB= + + case " $gt_needs " in + *" need-formatstring-macros "*) gt_api_version=3 ;; + *" need-ngettext "*) gt_api_version=2 ;; + *) gt_api_version=1 ;; + esac + gt_func_gnugettext_libc="gt_cv_func_gnugettext${gt_api_version}_libc" + gt_func_gnugettext_libintl="gt_cv_func_gnugettext${gt_api_version}_libintl" + + if test "$USE_NLS" = "yes"; then + gt_use_preinstalled_gnugettext=no + + + if test $gt_api_version -ge 3; then + gt_revision_test_code=' +#ifndef __GNU_GETTEXT_SUPPORTED_REVISION +#define __GNU_GETTEXT_SUPPORTED_REVISION(major) ((major) == 0 ? 0 : -1) +#endif +typedef int array [2 * (__GNU_GETTEXT_SUPPORTED_REVISION(0) >= 1) - 1]; +' + else + gt_revision_test_code= + fi + if test $gt_api_version -ge 2; then + gt_expression_test_code=' + * ngettext ("", "", 0)' + else + gt_expression_test_code= + fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU gettext in libc" >&5 +$as_echo_n "checking for GNU gettext in libc... " >&6; } +if eval \${$gt_func_gnugettext_libc+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +$gt_revision_test_code +extern int _nl_msg_cat_cntr; +extern int *_nl_domain_bindings; +int +main () +{ +bindtextdomain ("", ""); +return * gettext ("")$gt_expression_test_code + _nl_msg_cat_cntr + *_nl_domain_bindings + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + eval "$gt_func_gnugettext_libc=yes" +else + eval "$gt_func_gnugettext_libc=no" +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi +eval ac_res=\$$gt_func_gnugettext_libc + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + + if { eval "gt_val=\$$gt_func_gnugettext_libc"; test "$gt_val" != "yes"; }; then + + + + + + am_save_CPPFLAGS="$CPPFLAGS" + + for element in $INCICONV; do + haveit= + for x in $CPPFLAGS; do + + acl_save_prefix="$prefix" + prefix="$acl_final_prefix" + acl_save_exec_prefix="$exec_prefix" + exec_prefix="$acl_final_exec_prefix" + eval x=\"$x\" + exec_prefix="$acl_save_exec_prefix" + prefix="$acl_save_prefix" + + if test "X$x" = "X$element"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }$element" + fi + done + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for iconv" >&5 +$as_echo_n "checking for iconv... " >&6; } +if ${am_cv_func_iconv+:} false; then : + $as_echo_n "(cached) " >&6 +else + + am_cv_func_iconv="no, consider installing GNU libiconv" + am_cv_lib_iconv=no + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include +int +main () +{ +iconv_t cd = iconv_open("",""); + iconv(cd,NULL,NULL,NULL,NULL); + iconv_close(cd); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + am_cv_func_iconv=yes +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + if test "$am_cv_func_iconv" != yes; then + am_save_LIBS="$LIBS" + LIBS="$LIBS $LIBICONV" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include +int +main () +{ +iconv_t cd = iconv_open("",""); + iconv(cd,NULL,NULL,NULL,NULL); + iconv_close(cd); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + am_cv_lib_iconv=yes + am_cv_func_iconv=yes +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + LIBS="$am_save_LIBS" + fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_func_iconv" >&5 +$as_echo "$am_cv_func_iconv" >&6; } + if test "$am_cv_func_iconv" = yes; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for working iconv" >&5 +$as_echo_n "checking for working iconv... " >&6; } +if ${am_cv_func_iconv_works+:} false; then : + $as_echo_n "(cached) " >&6 +else + + am_save_LIBS="$LIBS" + if test $am_cv_lib_iconv = yes; then + LIBS="$LIBS $LIBICONV" + fi + if test "$cross_compiling" = yes; then : + case "$host_os" in + aix* | hpux*) am_cv_func_iconv_works="guessing no" ;; + *) am_cv_func_iconv_works="guessing yes" ;; + esac +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include +#include +int main () +{ + /* Test against AIX 5.1 bug: Failures are not distinguishable from successful + returns. */ + { + iconv_t cd_utf8_to_88591 = iconv_open ("ISO8859-1", "UTF-8"); + if (cd_utf8_to_88591 != (iconv_t)(-1)) + { + static const char input[] = "\342\202\254"; /* EURO SIGN */ + char buf[10]; + const char *inptr = input; + size_t inbytesleft = strlen (input); + char *outptr = buf; + size_t outbytesleft = sizeof (buf); + size_t res = iconv (cd_utf8_to_88591, + (char **) &inptr, &inbytesleft, + &outptr, &outbytesleft); + if (res == 0) + return 1; + } + } + /* Test against Solaris 10 bug: Failures are not distinguishable from + successful returns. */ + { + iconv_t cd_ascii_to_88591 = iconv_open ("ISO8859-1", "646"); + if (cd_ascii_to_88591 != (iconv_t)(-1)) + { + static const char input[] = "\263"; + char buf[10]; + const char *inptr = input; + size_t inbytesleft = strlen (input); + char *outptr = buf; + size_t outbytesleft = sizeof (buf); + size_t res = iconv (cd_ascii_to_88591, + (char **) &inptr, &inbytesleft, + &outptr, &outbytesleft); + if (res == 0) + return 1; + } + } +#if 0 /* This bug could be worked around by the caller. */ + /* Test against HP-UX 11.11 bug: Positive return value instead of 0. */ + { + iconv_t cd_88591_to_utf8 = iconv_open ("utf8", "iso88591"); + if (cd_88591_to_utf8 != (iconv_t)(-1)) + { + static const char input[] = "\304rger mit b\366sen B\374bchen ohne Augenma\337"; + char buf[50]; + const char *inptr = input; + size_t inbytesleft = strlen (input); + char *outptr = buf; + size_t outbytesleft = sizeof (buf); + size_t res = iconv (cd_88591_to_utf8, + (char **) &inptr, &inbytesleft, + &outptr, &outbytesleft); + if ((int)res > 0) + return 1; + } + } +#endif + /* Test against HP-UX 11.11 bug: No converter from EUC-JP to UTF-8 is + provided. */ + if (/* Try standardized names. */ + iconv_open ("UTF-8", "EUC-JP") == (iconv_t)(-1) + /* Try IRIX, OSF/1 names. */ + && iconv_open ("UTF-8", "eucJP") == (iconv_t)(-1) + /* Try AIX names. */ + && iconv_open ("UTF-8", "IBM-eucJP") == (iconv_t)(-1) + /* Try HP-UX names. */ + && iconv_open ("utf8", "eucJP") == (iconv_t)(-1)) + return 1; + return 0; +} +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + am_cv_func_iconv_works=yes +else + am_cv_func_iconv_works=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + + LIBS="$am_save_LIBS" + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_func_iconv_works" >&5 +$as_echo "$am_cv_func_iconv_works" >&6; } + case "$am_cv_func_iconv_works" in + *no) am_func_iconv=no am_cv_lib_iconv=no ;; + *) am_func_iconv=yes ;; + esac + else + am_func_iconv=no am_cv_lib_iconv=no + fi + if test "$am_func_iconv" = yes; then + +$as_echo "#define HAVE_ICONV 1" >>confdefs.h + + fi + if test "$am_cv_lib_iconv" = yes; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to link with libiconv" >&5 +$as_echo_n "checking how to link with libiconv... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LIBICONV" >&5 +$as_echo "$LIBICONV" >&6; } + else + CPPFLAGS="$am_save_CPPFLAGS" + LIBICONV= + LTLIBICONV= + fi + + + + + + + + + + + + use_additional=yes + + acl_save_prefix="$prefix" + prefix="$acl_final_prefix" + acl_save_exec_prefix="$exec_prefix" + exec_prefix="$acl_final_exec_prefix" + + eval additional_includedir=\"$includedir\" + eval additional_libdir=\"$libdir\" + + exec_prefix="$acl_save_exec_prefix" + prefix="$acl_save_prefix" + + +# Check whether --with-libintl-prefix was given. +if test "${with_libintl_prefix+set}" = set; then : + withval=$with_libintl_prefix; + if test "X$withval" = "Xno"; then + use_additional=no + else + if test "X$withval" = "X"; then + + acl_save_prefix="$prefix" + prefix="$acl_final_prefix" + acl_save_exec_prefix="$exec_prefix" + exec_prefix="$acl_final_exec_prefix" + + eval additional_includedir=\"$includedir\" + eval additional_libdir=\"$libdir\" + + exec_prefix="$acl_save_exec_prefix" + prefix="$acl_save_prefix" + + else + additional_includedir="$withval/include" + additional_libdir="$withval/$acl_libdirstem" + if test "$acl_libdirstem2" != "$acl_libdirstem" \ + && ! test -d "$withval/$acl_libdirstem"; then + additional_libdir="$withval/$acl_libdirstem2" + fi + fi + fi + +fi + + LIBINTL= + LTLIBINTL= + INCINTL= + LIBINTL_PREFIX= + HAVE_LIBINTL= + rpathdirs= + ltrpathdirs= + names_already_handled= + names_next_round='intl ' while test -n "$names_next_round"; do names_this_round="$names_next_round" names_next_round= @@ -5480,9 +13776,9 @@ if test -n "$value"; then if test "$value" = yes; then eval value=\"\$LIB$uppername\" - test -z "$value" || LIBICONV="${LIBICONV}${LIBICONV:+ }$value" + test -z "$value" || LIBINTL="${LIBINTL}${LIBINTL:+ }$value" eval value=\"\$LTLIB$uppername\" - test -z "$value" || LTLIBICONV="${LTLIBICONV}${LTLIBICONV:+ }$value" + test -z "$value" || LTLIBINTL="${LTLIBINTL}${LTLIBINTL:+ }$value" else : fi @@ -5539,7 +13835,7 @@ fi fi if test "X$found_dir" = "X"; then - for x in $LDFLAGS $LTLIBICONV; do + for x in $LDFLAGS $LTLIBINTL; do acl_save_prefix="$prefix" prefix="$acl_final_prefix" @@ -5598,12 +13894,12 @@ done fi if test "X$found_dir" != "X"; then - LTLIBICONV="${LTLIBICONV}${LTLIBICONV:+ }-L$found_dir -l$name" + LTLIBINTL="${LTLIBINTL}${LTLIBINTL:+ }-L$found_dir -l$name" if test "X$found_so" != "X"; then if test "$enable_rpath" = no \ || test "X$found_dir" = "X/usr/$acl_libdirstem" \ || test "X$found_dir" = "X/usr/$acl_libdirstem2"; then - LIBICONV="${LIBICONV}${LIBICONV:+ }$found_so" + LIBINTL="${LIBINTL}${LIBINTL:+ }$found_so" else haveit= for x in $ltrpathdirs; do @@ -5616,10 +13912,10 @@ ltrpathdirs="$ltrpathdirs $found_dir" fi if test "$acl_hardcode_direct" = yes; then - LIBICONV="${LIBICONV}${LIBICONV:+ }$found_so" + LIBINTL="${LIBINTL}${LIBINTL:+ }$found_so" else if test -n "$acl_hardcode_libdir_flag_spec" && test "$acl_hardcode_minus_L" = no; then - LIBICONV="${LIBICONV}${LIBICONV:+ }$found_so" + LIBINTL="${LIBINTL}${LIBINTL:+ }$found_so" haveit= for x in $rpathdirs; do if test "X$x" = "X$found_dir"; then @@ -5632,7 +13928,7 @@ fi else haveit= - for x in $LDFLAGS $LIBICONV; do + for x in $LDFLAGS $LIBINTL; do acl_save_prefix="$prefix" prefix="$acl_final_prefix" @@ -5648,36 +13944,36 @@ fi done if test -z "$haveit"; then - LIBICONV="${LIBICONV}${LIBICONV:+ }-L$found_dir" + LIBINTL="${LIBINTL}${LIBINTL:+ }-L$found_dir" fi if test "$acl_hardcode_minus_L" != no; then - LIBICONV="${LIBICONV}${LIBICONV:+ }$found_so" + LIBINTL="${LIBINTL}${LIBINTL:+ }$found_so" else - LIBICONV="${LIBICONV}${LIBICONV:+ }-l$name" + LIBINTL="${LIBINTL}${LIBINTL:+ }-l$name" fi fi fi fi else if test "X$found_a" != "X"; then - LIBICONV="${LIBICONV}${LIBICONV:+ }$found_a" + LIBINTL="${LIBINTL}${LIBINTL:+ }$found_a" else - LIBICONV="${LIBICONV}${LIBICONV:+ }-L$found_dir -l$name" + LIBINTL="${LIBINTL}${LIBINTL:+ }-L$found_dir -l$name" fi fi additional_includedir= case "$found_dir" in */$acl_libdirstem | */$acl_libdirstem/) basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem/"'*$,,'` - if test "$name" = 'iconv'; then - LIBICONV_PREFIX="$basedir" + if test "$name" = 'intl'; then + LIBINTL_PREFIX="$basedir" fi additional_includedir="$basedir/include" ;; */$acl_libdirstem2 | */$acl_libdirstem2/) basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem2/"'*$,,'` - if test "$name" = 'iconv'; then - LIBICONV_PREFIX="$basedir" + if test "$name" = 'intl'; then + LIBINTL_PREFIX="$basedir" fi additional_includedir="$basedir/include" ;; @@ -5693,7 +13989,7 @@ fi fi if test -z "$haveit"; then - for x in $CPPFLAGS $INCICONV; do + for x in $CPPFLAGS $INCINTL; do acl_save_prefix="$prefix" prefix="$acl_final_prefix" @@ -5710,7 +14006,7 @@ done if test -z "$haveit"; then if test -d "$additional_includedir"; then - INCICONV="${INCICONV}${INCICONV:+ }-I$additional_includedir" + INCINTL="${INCINTL}${INCINTL:+ }-I$additional_includedir" fi fi fi @@ -5740,7 +14036,7 @@ fi if test -z "$haveit"; then haveit= - for x in $LDFLAGS $LIBICONV; do + for x in $LDFLAGS $LIBINTL; do acl_save_prefix="$prefix" prefix="$acl_final_prefix" @@ -5757,11 +14053,11 @@ done if test -z "$haveit"; then if test -d "$additional_libdir"; then - LIBICONV="${LIBICONV}${LIBICONV:+ }-L$additional_libdir" + LIBINTL="${LIBINTL}${LIBINTL:+ }-L$additional_libdir" fi fi haveit= - for x in $LDFLAGS $LTLIBICONV; do + for x in $LDFLAGS $LTLIBINTL; do acl_save_prefix="$prefix" prefix="$acl_final_prefix" @@ -5778,7 +14074,7 @@ done if test -z "$haveit"; then if test -d "$additional_libdir"; then - LTLIBICONV="${LTLIBICONV}${LTLIBICONV:+ }-L$additional_libdir" + LTLIBINTL="${LTLIBINTL}${LTLIBINTL:+ }-L$additional_libdir" fi fi fi @@ -5816,15 +14112,15 @@ names_next_round="$names_next_round "`echo "X$dep" | sed -e 's,^X.*/,,' -e 's,^lib,,' -e 's,\.la$,,'` ;; *) - LIBICONV="${LIBICONV}${LIBICONV:+ }$dep" - LTLIBICONV="${LTLIBICONV}${LTLIBICONV:+ }$dep" + LIBINTL="${LIBINTL}${LIBINTL:+ }$dep" + LTLIBINTL="${LTLIBINTL}${LTLIBINTL:+ }$dep" ;; esac done fi else - LIBICONV="${LIBICONV}${LIBICONV:+ }-l$name" - LTLIBICONV="${LTLIBICONV}${LTLIBICONV:+ }-l$name" + LIBINTL="${LIBINTL}${LIBINTL:+ }-l$name" + LTLIBINTL="${LTLIBINTL}${LTLIBINTL:+ }-l$name" fi fi fi @@ -5840,204 +14136,162 @@ libdir="$alldirs" eval flag=\"$acl_hardcode_libdir_flag_spec\" libdir="$acl_save_libdir" - LIBICONV="${LIBICONV}${LIBICONV:+ }$flag" + LIBINTL="${LIBINTL}${LIBINTL:+ }$flag" else for found_dir in $rpathdirs; do acl_save_libdir="$libdir" libdir="$found_dir" eval flag=\"$acl_hardcode_libdir_flag_spec\" libdir="$acl_save_libdir" - LIBICONV="${LIBICONV}${LIBICONV:+ }$flag" + LIBINTL="${LIBINTL}${LIBINTL:+ }$flag" done fi fi if test "X$ltrpathdirs" != "X"; then for found_dir in $ltrpathdirs; do - LTLIBICONV="${LTLIBICONV}${LTLIBICONV:+ }-R$found_dir" + LTLIBINTL="${LTLIBINTL}${LTLIBINTL:+ }-R$found_dir" done fi - - - - - - - - - - - - - - - - - - - - - - - - - - - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for CFPreferencesCopyAppValue" >&5 -$as_echo_n "checking for CFPreferencesCopyAppValue... " >&6; } -if test "${gt_cv_func_CFPreferencesCopyAppValue+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - gt_save_LIBS="$LIBS" - LIBS="$LIBS -Wl,-framework -Wl,CoreFoundation" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -int -main () -{ -CFPreferencesCopyAppValue(NULL, NULL) - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - gt_cv_func_CFPreferencesCopyAppValue=yes -else - gt_cv_func_CFPreferencesCopyAppValue=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext - LIBS="$gt_save_LIBS" -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gt_cv_func_CFPreferencesCopyAppValue" >&5 -$as_echo "$gt_cv_func_CFPreferencesCopyAppValue" >&6; } - if test $gt_cv_func_CFPreferencesCopyAppValue = yes; then - -$as_echo "#define HAVE_CFPREFERENCESCOPYAPPVALUE 1" >>confdefs.h - - fi - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for CFLocaleCopyCurrent" >&5 -$as_echo_n "checking for CFLocaleCopyCurrent... " >&6; } -if test "${gt_cv_func_CFLocaleCopyCurrent+set}" = set; then : + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU gettext in libintl" >&5 +$as_echo_n "checking for GNU gettext in libintl... " >&6; } +if eval \${$gt_func_gnugettext_libintl+:} false; then : $as_echo_n "(cached) " >&6 else - gt_save_LIBS="$LIBS" - LIBS="$LIBS -Wl,-framework -Wl,CoreFoundation" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + gt_save_CPPFLAGS="$CPPFLAGS" + CPPFLAGS="$CPPFLAGS $INCINTL" + gt_save_LIBS="$LIBS" + LIBS="$LIBS $LIBINTL" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ -#include +#include +$gt_revision_test_code +extern int _nl_msg_cat_cntr; +extern +#ifdef __cplusplus +"C" +#endif +const char *_nl_expand_alias (const char *); int main () { -CFLocaleCopyCurrent(); +bindtextdomain ("", ""); +return * gettext ("")$gt_expression_test_code + _nl_msg_cat_cntr + *_nl_expand_alias ("") ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : - gt_cv_func_CFLocaleCopyCurrent=yes + eval "$gt_func_gnugettext_libintl=yes" else - gt_cv_func_CFLocaleCopyCurrent=no + eval "$gt_func_gnugettext_libintl=no" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext - LIBS="$gt_save_LIBS" -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gt_cv_func_CFLocaleCopyCurrent" >&5 -$as_echo "$gt_cv_func_CFLocaleCopyCurrent" >&6; } - if test $gt_cv_func_CFLocaleCopyCurrent = yes; then - -$as_echo "#define HAVE_CFLOCALECOPYCURRENT 1" >>confdefs.h - - fi - INTL_MACOSX_LIBS= - if test $gt_cv_func_CFPreferencesCopyAppValue = yes || test $gt_cv_func_CFLocaleCopyCurrent = yes; then - INTL_MACOSX_LIBS="-Wl,-framework -Wl,CoreFoundation" - fi - - - - - - - LIBINTL= - LTLIBINTL= - POSUB= - - case " $gt_needs " in - *" need-formatstring-macros "*) gt_api_version=3 ;; - *" need-ngettext "*) gt_api_version=2 ;; - *) gt_api_version=1 ;; - esac - gt_func_gnugettext_libc="gt_cv_func_gnugettext${gt_api_version}_libc" - gt_func_gnugettext_libintl="gt_cv_func_gnugettext${gt_api_version}_libintl" - - if test "$USE_NLS" = "yes"; then - gt_use_preinstalled_gnugettext=no - - - if test $gt_api_version -ge 3; then - gt_revision_test_code=' -#ifndef __GNU_GETTEXT_SUPPORTED_REVISION -#define __GNU_GETTEXT_SUPPORTED_REVISION(major) ((major) == 0 ? 0 : -1) -#endif -typedef int array [2 * (__GNU_GETTEXT_SUPPORTED_REVISION(0) >= 1) - 1]; -' - else - gt_revision_test_code= - fi - if test $gt_api_version -ge 2; then - gt_expression_test_code=' + * ngettext ("", "", 0)' - else - gt_expression_test_code= - fi - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU gettext in libc" >&5 -$as_echo_n "checking for GNU gettext in libc... " >&6; } -if { as_var=$gt_func_gnugettext_libc; eval "test \"\${$as_var+set}\" = set"; }; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + if { eval "gt_val=\$$gt_func_gnugettext_libintl"; test "$gt_val" != yes; } && test -n "$LIBICONV"; then + LIBS="$LIBS $LIBICONV" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include $gt_revision_test_code extern int _nl_msg_cat_cntr; -extern int *_nl_domain_bindings; +extern +#ifdef __cplusplus +"C" +#endif +const char *_nl_expand_alias (const char *); int main () { bindtextdomain ("", ""); -return * gettext ("")$gt_expression_test_code + _nl_msg_cat_cntr + *_nl_domain_bindings +return * gettext ("")$gt_expression_test_code + _nl_msg_cat_cntr + *_nl_expand_alias ("") ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : - eval "$gt_func_gnugettext_libc=yes" -else - eval "$gt_func_gnugettext_libc=no" + LIBINTL="$LIBINTL $LIBICONV" + LTLIBINTL="$LTLIBINTL $LTLIBICONV" + eval "$gt_func_gnugettext_libintl=yes" + fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext + fi + CPPFLAGS="$gt_save_CPPFLAGS" + LIBS="$gt_save_LIBS" fi -eval ac_res=\$$gt_func_gnugettext_libc +eval ac_res=\$$gt_func_gnugettext_libintl { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } + fi - if { eval "gt_val=\$$gt_func_gnugettext_libc"; test "$gt_val" != "yes"; }; then + if { eval "gt_val=\$$gt_func_gnugettext_libc"; test "$gt_val" = "yes"; } \ + || { { eval "gt_val=\$$gt_func_gnugettext_libintl"; test "$gt_val" = "yes"; } \ + && test "$PACKAGE" != gettext-runtime \ + && test "$PACKAGE" != gettext-tools; }; then + gt_use_preinstalled_gnugettext=yes + else + LIBINTL= + LTLIBINTL= + INCINTL= + fi + + + + if test -n "$INTL_MACOSX_LIBS"; then + if test "$gt_use_preinstalled_gnugettext" = "yes" \ + || test "$nls_cv_use_gnu_gettext" = "yes"; then + LIBINTL="$LIBINTL $INTL_MACOSX_LIBS" + LTLIBINTL="$LTLIBINTL $INTL_MACOSX_LIBS" + fi + fi + if test "$gt_use_preinstalled_gnugettext" = "yes" \ + || test "$nls_cv_use_gnu_gettext" = "yes"; then +$as_echo "#define ENABLE_NLS 1" >>confdefs.h + else + USE_NLS=no + fi + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to use NLS" >&5 +$as_echo_n "checking whether to use NLS... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $USE_NLS" >&5 +$as_echo "$USE_NLS" >&6; } + if test "$USE_NLS" = "yes"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking where the gettext function comes from" >&5 +$as_echo_n "checking where the gettext function comes from... " >&6; } + if test "$gt_use_preinstalled_gnugettext" = "yes"; then + if { eval "gt_val=\$$gt_func_gnugettext_libintl"; test "$gt_val" = "yes"; }; then + gt_source="external libintl" + else + gt_source="libc" + fi + else + gt_source="included intl directory" + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gt_source" >&5 +$as_echo "$gt_source" >&6; } + fi - am_save_CPPFLAGS="$CPPFLAGS" + if test "$USE_NLS" = "yes"; then - for element in $INCICONV; do + if test "$gt_use_preinstalled_gnugettext" = "yes"; then + if { eval "gt_val=\$$gt_func_gnugettext_libintl"; test "$gt_val" = "yes"; }; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to link with libintl" >&5 +$as_echo_n "checking how to link with libintl... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LIBINTL" >&5 +$as_echo "$LIBINTL" >&6; } + + for element in $INCINTL; do haveit= for x in $CPPFLAGS; do @@ -6059,1006 +14313,870 @@ fi done + fi + + +$as_echo "#define HAVE_GETTEXT 1" >>confdefs.h + + +$as_echo "#define HAVE_DCGETTEXT 1" >>confdefs.h + + fi + + POSUB=po + fi + + + + INTLLIBS="$LIBINTL" + + + + + + + +# doesn't support multiple po directories :( +#AM_GLIB_GNU_GETTEXT + + +# Check whether --with-vendor-package-version was given. +if test "${with_vendor_package_version+set}" = set; then : + withval=$with_vendor_package_version; +else + with_vendor_package_version= + +fi + +WITH_VENDOR_PACKAGE_VERSION=$with_vendor_package_version +if test "x$WITH_VENDOR_PACKAGE_VERSION" = "x"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for git version" >&5 +$as_echo_n "checking for git version... " >&6; } + if git log --oneline 295b37c8ac4939829a3c7f9150943dba8fff07f0 > /dev/null 2>&1; then + GIT_BRANCH=$(git branch | grep '^\*' | cut -d ' ' -f 2) + GIT_COMMIT_HASH=$(git log --no-color --first-parent -n1 --pretty=format:%h) + DIST_VERSION=$GIT_BRANCH/$GIT_COMMIT_HASH + DEV_VERSION_SUFFIX="-dev" + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + else + DIST_VERSION=tarball + DEV_VERSION_SUFFIX= + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + fi +else + DIST_VERSION=$WITH_VENDOR_PACKAGE_VERSION +fi +git_branch="$GIT_BRANCH" + +git_commit_hash="$GIT_COMMIT_HASH" + + +dist_version="$DIST_VERSION" + + + + expanded_libdir=`( + case $prefix in + NONE) prefix=$ac_default_prefix ;; + *) ;; + esac + case $exec_prefix in + NONE) exec_prefix=$prefix ;; + *) ;; + esac + eval echo $libdir + )` + + + + + + + + + +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 ${ac_cv_path_PKG_CONFIG+:} false; then : + $as_echo_n "(cached) " >&6 +else + case $PKG_CONFIG in + [\\/]* | ?:[\\/]*) + ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # 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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$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 + fi +done + done +IFS=$as_save_IFS + + ;; +esac +fi +PKG_CONFIG=$ac_cv_path_PKG_CONFIG +if test -n "$PKG_CONFIG"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PKG_CONFIG" >&5 +$as_echo "$PKG_CONFIG" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for iconv" >&5 -$as_echo_n "checking for iconv... " >&6; } -if test "${am_cv_func_iconv+set}" = set; then : +fi +if test -z "$ac_cv_path_PKG_CONFIG"; then + ac_pt_PKG_CONFIG=$PKG_CONFIG + # 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 ${ac_cv_path_ac_pt_PKG_CONFIG+:} false; then : $as_echo_n "(cached) " >&6 else + case $ac_pt_PKG_CONFIG in + [\\/]* | ?:[\\/]*) + ac_cv_path_ac_pt_PKG_CONFIG="$ac_pt_PKG_CONFIG" # 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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$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 + fi +done + done +IFS=$as_save_IFS - am_cv_func_iconv="no, consider installing GNU libiconv" - am_cv_lib_iconv=no - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -#include -int -main () -{ -iconv_t cd = iconv_open("",""); - iconv(cd,NULL,NULL,NULL,NULL); - iconv_close(cd); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - am_cv_func_iconv=yes + ;; +esac fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext - if test "$am_cv_func_iconv" != yes; then - am_save_LIBS="$LIBS" - LIBS="$LIBS $LIBICONV" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -#include -int -main () -{ -iconv_t cd = iconv_open("",""); - iconv(cd,NULL,NULL,NULL,NULL); - iconv_close(cd); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - am_cv_lib_iconv=yes - am_cv_func_iconv=yes +ac_pt_PKG_CONFIG=$ac_cv_path_ac_pt_PKG_CONFIG +if test -n "$ac_pt_PKG_CONFIG"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_pt_PKG_CONFIG" >&5 +$as_echo "$ac_pt_PKG_CONFIG" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext - LIBS="$am_save_LIBS" - fi -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_func_iconv" >&5 -$as_echo "$am_cv_func_iconv" >&6; } - if test "$am_cv_func_iconv" = yes; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for working iconv" >&5 -$as_echo_n "checking for working iconv... " >&6; } -if test "${am_cv_func_iconv_works+set}" = set; then : - $as_echo_n "(cached) " >&6 + if test "x$ac_pt_PKG_CONFIG" = x; then + PKG_CONFIG="" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + PKG_CONFIG=$ac_pt_PKG_CONFIG + fi else + PKG_CONFIG="$ac_cv_path_PKG_CONFIG" +fi - am_save_LIBS="$LIBS" - if test $am_cv_lib_iconv = yes; then - LIBS="$LIBS $LIBICONV" - fi - if test "$cross_compiling" = yes; then : - case "$host_os" in - aix* | hpux*) am_cv_func_iconv_works="guessing no" ;; - *) am_cv_func_iconv_works="guessing yes" ;; - esac -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ +fi +if test -n "$PKG_CONFIG"; then + _pkg_min_version=0.9.0 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking pkg-config is at least version $_pkg_min_version" >&5 +$as_echo_n "checking pkg-config is at least version $_pkg_min_version... " >&6; } + if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + PKG_CONFIG="" + fi +fi -#include -#include -int main () -{ - /* Test against AIX 5.1 bug: Failures are not distinguishable from successful - returns. */ - { - iconv_t cd_utf8_to_88591 = iconv_open ("ISO8859-1", "UTF-8"); - if (cd_utf8_to_88591 != (iconv_t)(-1)) - { - static const char input[] = "\342\202\254"; /* EURO SIGN */ - char buf[10]; - const char *inptr = input; - size_t inbytesleft = strlen (input); - char *outptr = buf; - size_t outbytesleft = sizeof (buf); - size_t res = iconv (cd_utf8_to_88591, - (char **) &inptr, &inbytesleft, - &outptr, &outbytesleft); - if (res == 0) - return 1; - } - } - /* Test against Solaris 10 bug: Failures are not distinguishable from - successful returns. */ - { - iconv_t cd_ascii_to_88591 = iconv_open ("ISO8859-1", "646"); - if (cd_ascii_to_88591 != (iconv_t)(-1)) - { - static const char input[] = "\263"; - char buf[10]; - const char *inptr = input; - size_t inbytesleft = strlen (input); - char *outptr = buf; - size_t outbytesleft = sizeof (buf); - size_t res = iconv (cd_ascii_to_88591, - (char **) &inptr, &inbytesleft, - &outptr, &outbytesleft); - if (res == 0) - return 1; - } - } -#if 0 /* This bug could be worked around by the caller. */ - /* Test against HP-UX 11.11 bug: Positive return value instead of 0. */ - { - iconv_t cd_88591_to_utf8 = iconv_open ("utf8", "iso88591"); - if (cd_88591_to_utf8 != (iconv_t)(-1)) - { - static const char input[] = "\304rger mit b\366sen B\374bchen ohne Augenma\337"; - char buf[50]; - const char *inptr = input; - size_t inbytesleft = strlen (input); - char *outptr = buf; - size_t outbytesleft = sizeof (buf); - size_t res = iconv (cd_88591_to_utf8, - (char **) &inptr, &inbytesleft, - &outptr, &outbytesleft); - if ((int)res > 0) - return 1; - } - } -#endif - /* Test against HP-UX 11.11 bug: No converter from EUC-JP to UTF-8 is - provided. */ - if (/* Try standardized names. */ - iconv_open ("UTF-8", "EUC-JP") == (iconv_t)(-1) - /* Try IRIX, OSF/1 names. */ - && iconv_open ("UTF-8", "eucJP") == (iconv_t)(-1) - /* Try AIX names. */ - && iconv_open ("UTF-8", "IBM-eucJP") == (iconv_t)(-1) - /* Try HP-UX names. */ - && iconv_open ("utf8", "eucJP") == (iconv_t)(-1)) - return 1; - return 0; -} -_ACEOF -if ac_fn_c_try_run "$LINENO"; then : - am_cv_func_iconv_works=yes + +pkg_failed=no +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for MONO_MODULE" >&5 +$as_echo_n "checking for MONO_MODULE... " >&6; } + +if test -n "$MONO_MODULE_CFLAGS"; then + pkg_cv_MONO_MODULE_CFLAGS="$MONO_MODULE_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 >= 1.9.1\""; } >&5 + ($PKG_CONFIG --exists --print-errors "mono >= 1.9.1") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_MONO_MODULE_CFLAGS=`$PKG_CONFIG --cflags "mono >= 1.9.1" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes else - am_cv_func_iconv_works=no + pkg_failed=yes +fi + else + pkg_failed=untried +fi +if test -n "$MONO_MODULE_LIBS"; then + pkg_cv_MONO_MODULE_LIBS="$MONO_MODULE_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 >= 1.9.1\""; } >&5 + ($PKG_CONFIG --exists --print-errors "mono >= 1.9.1") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_MONO_MODULE_LIBS=`$PKG_CONFIG --libs "mono >= 1.9.1" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes +else + pkg_failed=yes fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext + else + pkg_failed=untried fi - LIBS="$am_save_LIBS" -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_func_iconv_works" >&5 -$as_echo "$am_cv_func_iconv_works" >&6; } - case "$am_cv_func_iconv_works" in - *no) am_func_iconv=no am_cv_lib_iconv=no ;; - *) am_func_iconv=yes ;; - esac - else - am_func_iconv=no am_cv_lib_iconv=no - fi - if test "$am_func_iconv" = yes; then -$as_echo "#define HAVE_ICONV 1" >>confdefs.h +if test $pkg_failed = yes; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } - fi - if test "$am_cv_lib_iconv" = yes; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to link with libiconv" >&5 -$as_echo_n "checking how to link with libiconv... " >&6; } - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LIBICONV" >&5 -$as_echo "$LIBICONV" >&6; } - else - CPPFLAGS="$am_save_CPPFLAGS" - LIBICONV= - LTLIBICONV= - fi +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 + MONO_MODULE_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "mono >= 1.9.1" 2>&1` + else + MONO_MODULE_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "mono >= 1.9.1" 2>&1` + fi + # Put the nasty error message in config.log where it belongs + echo "$MONO_MODULE_PKG_ERRORS" >&5 + as_fn_error $? "Package requirements (mono >= 1.9.1) were not met: +$MONO_MODULE_PKG_ERRORS +Consider adjusting the PKG_CONFIG_PATH environment variable if you +installed software in a non-standard prefix. +Alternatively, you may set the environment variables MONO_MODULE_CFLAGS +and MONO_MODULE_LIBS to avoid the need to call pkg-config. +See the pkg-config man page for more details." "$LINENO" 5 +elif test $pkg_failed = untried; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "The pkg-config script could not be found or is too old. Make sure it +is in your PATH or set the PKG_CONFIG environment variable to the full +path to pkg-config. +Alternatively, you may set the environment variables MONO_MODULE_CFLAGS +and MONO_MODULE_LIBS to avoid the need to call pkg-config. +See the pkg-config man page for more details. +To get pkg-config, see . +See \`config.log' for more details" "$LINENO" 5; } +else + MONO_MODULE_CFLAGS=$pkg_cv_MONO_MODULE_CFLAGS + MONO_MODULE_LIBS=$pkg_cv_MONO_MODULE_LIBS + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } +fi - use_additional=yes + # Extract the first word of "mono", so it can be a program name with args. +set dummy mono; 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_MONO+:} false; then : + $as_echo_n "(cached) " >&6 +else + case $MONO in + [\\/]* | ?:[\\/]*) + ac_cv_path_MONO="$MONO" # 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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_path_MONO="$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 - acl_save_prefix="$prefix" - prefix="$acl_final_prefix" - acl_save_exec_prefix="$exec_prefix" - exec_prefix="$acl_final_exec_prefix" + test -z "$ac_cv_path_MONO" && ac_cv_path_MONO="no" + ;; +esac +fi +MONO=$ac_cv_path_MONO +if test -n "$MONO"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MONO" >&5 +$as_echo "$MONO" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi - eval additional_includedir=\"$includedir\" - eval additional_libdir=\"$libdir\" - exec_prefix="$acl_save_exec_prefix" - prefix="$acl_save_prefix" -# Check whether --with-libintl-prefix was given. -if test "${with_libintl_prefix+set}" = set; then : - withval=$with_libintl_prefix; - if test "X$withval" = "Xno"; then - use_additional=no - else - if test "X$withval" = "X"; then + if test "x$MONO" = "xno"; then + as_fn_error $? "You need to install 'mono'" "$LINENO" 5 + fi - acl_save_prefix="$prefix" - prefix="$acl_final_prefix" - acl_save_exec_prefix="$exec_prefix" - exec_prefix="$acl_final_exec_prefix" - eval additional_includedir=\"$includedir\" - eval additional_libdir=\"$libdir\" - exec_prefix="$acl_save_exec_prefix" - prefix="$acl_save_prefix" - else - additional_includedir="$withval/include" - additional_libdir="$withval/$acl_libdirstem" - if test "$acl_libdirstem2" != "$acl_libdirstem" \ - && ! test -d "$withval/$acl_libdirstem"; then - additional_libdir="$withval/$acl_libdirstem2" - fi - fi - fi -fi + # Extract the first word of "gmcs", so it can be a program name with args. +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 ${ac_cv_path_MCS+:} false; then : + $as_echo_n "(cached) " >&6 +else + case $MCS in + [\\/]* | ?:[\\/]*) + ac_cv_path_MCS="$MCS" # 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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_path_MCS="$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 - LIBINTL= - LTLIBINTL= - INCINTL= - LIBINTL_PREFIX= - HAVE_LIBINTL= - rpathdirs= - ltrpathdirs= - names_already_handled= - names_next_round='intl ' - while test -n "$names_next_round"; do - names_this_round="$names_next_round" - names_next_round= - for name in $names_this_round; do - already_handled= - for n in $names_already_handled; do - if test "$n" = "$name"; then - already_handled=yes - break - fi - done - if test -z "$already_handled"; then - names_already_handled="$names_already_handled $name" - uppername=`echo "$name" | sed -e 'y|abcdefghijklmnopqrstuvwxyz./-|ABCDEFGHIJKLMNOPQRSTUVWXYZ___|'` - eval value=\"\$HAVE_LIB$uppername\" - if test -n "$value"; then - if test "$value" = yes; then - eval value=\"\$LIB$uppername\" - test -z "$value" || LIBINTL="${LIBINTL}${LIBINTL:+ }$value" - eval value=\"\$LTLIB$uppername\" - test -z "$value" || LTLIBINTL="${LTLIBINTL}${LTLIBINTL:+ }$value" - else - : - fi - else - found_dir= - found_la= - found_so= - found_a= - eval libname=\"$acl_libname_spec\" # typically: libname=lib$name - if test -n "$acl_shlibext"; then - shrext=".$acl_shlibext" # typically: shrext=.so - else - shrext= - fi - if test $use_additional = yes; then - dir="$additional_libdir" - if test -n "$acl_shlibext"; then - if test -f "$dir/$libname$shrext"; then - found_dir="$dir" - found_so="$dir/$libname$shrext" - else - if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then - ver=`(cd "$dir" && \ - for f in "$libname$shrext".*; do echo "$f"; done \ - | sed -e "s,^$libname$shrext\\\\.,," \ - | sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \ - | sed 1q ) 2>/dev/null` - if test -n "$ver" && test -f "$dir/$libname$shrext.$ver"; then - found_dir="$dir" - found_so="$dir/$libname$shrext.$ver" - fi - else - eval library_names=\"$acl_library_names_spec\" - for f in $library_names; do - if test -f "$dir/$f"; then - found_dir="$dir" - found_so="$dir/$f" - break - fi - done - fi - fi - fi - if test "X$found_dir" = "X"; then - if test -f "$dir/$libname.$acl_libext"; then - found_dir="$dir" - found_a="$dir/$libname.$acl_libext" - fi - fi - if test "X$found_dir" != "X"; then - if test -f "$dir/$libname.la"; then - found_la="$dir/$libname.la" - fi - fi - fi - if test "X$found_dir" = "X"; then - for x in $LDFLAGS $LTLIBINTL; do + test -z "$ac_cv_path_MCS" && ac_cv_path_MCS="no" + ;; +esac +fi +MCS=$ac_cv_path_MCS +if test -n "$MCS"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MCS" >&5 +$as_echo "$MCS" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi - acl_save_prefix="$prefix" - prefix="$acl_final_prefix" - acl_save_exec_prefix="$exec_prefix" - exec_prefix="$acl_final_exec_prefix" - eval x=\"$x\" - exec_prefix="$acl_save_exec_prefix" - prefix="$acl_save_prefix" - case "$x" in - -L*) - dir=`echo "X$x" | sed -e 's/^X-L//'` - if test -n "$acl_shlibext"; then - if test -f "$dir/$libname$shrext"; then - found_dir="$dir" - found_so="$dir/$libname$shrext" - else - if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then - ver=`(cd "$dir" && \ - for f in "$libname$shrext".*; do echo "$f"; done \ - | sed -e "s,^$libname$shrext\\\\.,," \ - | sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \ - | sed 1q ) 2>/dev/null` - if test -n "$ver" && test -f "$dir/$libname$shrext.$ver"; then - found_dir="$dir" - found_so="$dir/$libname$shrext.$ver" - fi - else - eval library_names=\"$acl_library_names_spec\" - for f in $library_names; do - if test -f "$dir/$f"; then - found_dir="$dir" - found_so="$dir/$f" - break - fi - done - fi - fi - fi - if test "X$found_dir" = "X"; then - if test -f "$dir/$libname.$acl_libext"; then - found_dir="$dir" - found_a="$dir/$libname.$acl_libext" - fi - fi - if test "X$found_dir" != "X"; then - if test -f "$dir/$libname.la"; then - found_la="$dir/$libname.la" - fi - fi - ;; - esac - if test "X$found_dir" != "X"; then - break - fi - done - fi - if test "X$found_dir" != "X"; then - LTLIBINTL="${LTLIBINTL}${LTLIBINTL:+ }-L$found_dir -l$name" - if test "X$found_so" != "X"; then - if test "$enable_rpath" = no \ - || test "X$found_dir" = "X/usr/$acl_libdirstem" \ - || test "X$found_dir" = "X/usr/$acl_libdirstem2"; then - LIBINTL="${LIBINTL}${LIBINTL:+ }$found_so" - else - haveit= - for x in $ltrpathdirs; do - if test "X$x" = "X$found_dir"; then - haveit=yes - break - fi - done - if test -z "$haveit"; then - ltrpathdirs="$ltrpathdirs $found_dir" - fi - if test "$acl_hardcode_direct" = yes; then - LIBINTL="${LIBINTL}${LIBINTL:+ }$found_so" - else - if test -n "$acl_hardcode_libdir_flag_spec" && test "$acl_hardcode_minus_L" = no; then - LIBINTL="${LIBINTL}${LIBINTL:+ }$found_so" - haveit= - for x in $rpathdirs; do - if test "X$x" = "X$found_dir"; then - haveit=yes - break - fi - done - if test -z "$haveit"; then - rpathdirs="$rpathdirs $found_dir" - fi - else - haveit= - for x in $LDFLAGS $LIBINTL; do - acl_save_prefix="$prefix" - prefix="$acl_final_prefix" - acl_save_exec_prefix="$exec_prefix" - exec_prefix="$acl_final_exec_prefix" - eval x=\"$x\" - exec_prefix="$acl_save_exec_prefix" - prefix="$acl_save_prefix" - if test "X$x" = "X-L$found_dir"; then - haveit=yes - break - fi - done - if test -z "$haveit"; then - LIBINTL="${LIBINTL}${LIBINTL:+ }-L$found_dir" - fi - if test "$acl_hardcode_minus_L" != no; then - LIBINTL="${LIBINTL}${LIBINTL:+ }$found_so" - else - LIBINTL="${LIBINTL}${LIBINTL:+ }-l$name" - fi - fi - fi - fi - else - if test "X$found_a" != "X"; then - LIBINTL="${LIBINTL}${LIBINTL:+ }$found_a" - else - LIBINTL="${LIBINTL}${LIBINTL:+ }-L$found_dir -l$name" - fi - fi - additional_includedir= - case "$found_dir" in - */$acl_libdirstem | */$acl_libdirstem/) - basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem/"'*$,,'` - if test "$name" = 'intl'; then - LIBINTL_PREFIX="$basedir" - fi - additional_includedir="$basedir/include" - ;; - */$acl_libdirstem2 | */$acl_libdirstem2/) - basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem2/"'*$,,'` - if test "$name" = 'intl'; then - LIBINTL_PREFIX="$basedir" - fi - additional_includedir="$basedir/include" - ;; - esac - if test "X$additional_includedir" != "X"; then - if test "X$additional_includedir" != "X/usr/include"; then - haveit= - if test "X$additional_includedir" = "X/usr/local/include"; then - if test -n "$GCC"; then - case $host_os in - linux* | gnu* | k*bsd*-gnu) haveit=yes;; - esac - fi - fi - if test -z "$haveit"; then - for x in $CPPFLAGS $INCINTL; do + if test "x$MCS" = "xno"; then + as_fn_error $? "You need to install 'gmcs'" "$LINENO" 5 + fi - acl_save_prefix="$prefix" - prefix="$acl_final_prefix" - acl_save_exec_prefix="$exec_prefix" - exec_prefix="$acl_final_exec_prefix" - eval x=\"$x\" - exec_prefix="$acl_save_exec_prefix" - prefix="$acl_save_prefix" - if test "X$x" = "X-I$additional_includedir"; then - haveit=yes - break - fi - done - if test -z "$haveit"; then - if test -d "$additional_includedir"; then - INCINTL="${INCINTL}${INCINTL:+ }-I$additional_includedir" - fi - fi - fi - fi - fi - if test -n "$found_la"; then - save_libdir="$libdir" - case "$found_la" in - */* | *\\*) . "$found_la" ;; - *) . "./$found_la" ;; - esac - libdir="$save_libdir" - for dep in $dependency_libs; do - case "$dep" in - -L*) - additional_libdir=`echo "X$dep" | sed -e 's/^X-L//'` - if test "X$additional_libdir" != "X/usr/$acl_libdirstem" \ - && test "X$additional_libdir" != "X/usr/$acl_libdirstem2"; then - haveit= - if test "X$additional_libdir" = "X/usr/local/$acl_libdirstem" \ - || test "X$additional_libdir" = "X/usr/local/$acl_libdirstem2"; then - if test -n "$GCC"; then - case $host_os in - linux* | gnu* | k*bsd*-gnu) haveit=yes;; - esac - fi - fi - if test -z "$haveit"; then - haveit= - for x in $LDFLAGS $LIBINTL; do - acl_save_prefix="$prefix" - prefix="$acl_final_prefix" - acl_save_exec_prefix="$exec_prefix" - exec_prefix="$acl_final_exec_prefix" - eval x=\"$x\" - exec_prefix="$acl_save_exec_prefix" - prefix="$acl_save_prefix" - if test "X$x" = "X-L$additional_libdir"; then - haveit=yes - break - fi - done - if test -z "$haveit"; then - if test -d "$additional_libdir"; then - LIBINTL="${LIBINTL}${LIBINTL:+ }-L$additional_libdir" - fi - fi - haveit= - for x in $LDFLAGS $LTLIBINTL; do + for asm in $(echo "2.0,System + System.Core + System.Xml + System.Runtime.Remoting + Mono.Posix +" | cut -d, -f2- | sed 's/\,/ /g') + do + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Mono 2.0 GAC for $asm.dll" >&5 +$as_echo_n "checking for Mono 2.0 GAC for $asm.dll... " >&6; } + if test \ + -e "$($PKG_CONFIG --variable=libdir mono)/mono/2.0/$asm.dll" -o \ + -e "$($PKG_CONFIG --variable=prefix mono)/lib/mono/2.0/$asm.dll"; \ + then \ + { $as_echo "$as_me:${as_lineno-$LINENO}: result: found" >&5 +$as_echo "found" >&6; } + else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5 +$as_echo "not found" >&6; } + as_fn_error $? "missing reqired Mono 2.0 assembly: $asm.dll" "$LINENO" 5 + fi + done + + + +PROFILE=debug +# Check whether --enable-release was given. +if test "${enable_release+set}" = set; then : + enableval=$enable_release; enable_release=yes +else + enable_release=no +fi + + if test x$enable_release = xyes; then + ENABLE_RELEASE_TRUE= + ENABLE_RELEASE_FALSE='#' +else + ENABLE_RELEASE_TRUE='#' + ENABLE_RELEASE_FALSE= +fi + +if test "x$enable_release" = "xyes" ; then + PROFILE=release +fi +# Check whether --enable-debug was given. +if test "${enable_debug+set}" = set; then : + enableval=$enable_debug; enable_debug=yes +else + enable_debug=no +fi + + if test x$enable_debug = xyes; then + ENABLE_DEBUG_TRUE= + ENABLE_DEBUG_FALSE='#' +else + ENABLE_DEBUG_TRUE='#' + ENABLE_DEBUG_FALSE= +fi + +if test "x$enable_debug" = "xyes" ; then + PROFILE=debug +fi + - acl_save_prefix="$prefix" - prefix="$acl_final_prefix" - acl_save_exec_prefix="$exec_prefix" - exec_prefix="$acl_final_exec_prefix" - eval x=\"$x\" - exec_prefix="$acl_save_exec_prefix" - prefix="$acl_save_prefix" +CSC="$MCS" - if test "X$x" = "X-L$additional_libdir"; then - haveit=yes - break - fi - done - if test -z "$haveit"; then - if test -d "$additional_libdir"; then - LTLIBINTL="${LTLIBINTL}${LTLIBINTL:+ }-L$additional_libdir" - fi - fi - fi - fi - ;; - -R*) - dir=`echo "X$dep" | sed -e 's/^X-R//'` - if test "$enable_rpath" != no; then - haveit= - for x in $rpathdirs; do - if test "X$x" = "X$dir"; then - haveit=yes - break - fi - done - if test -z "$haveit"; then - rpathdirs="$rpathdirs $dir" - fi - haveit= - for x in $ltrpathdirs; do - if test "X$x" = "X$dir"; then - haveit=yes - break - fi - done - if test -z "$haveit"; then - ltrpathdirs="$ltrpathdirs $dir" - fi - fi - ;; - -l*) - names_next_round="$names_next_round "`echo "X$dep" | sed -e 's/^X-l//'` - ;; - *.la) - names_next_round="$names_next_round "`echo "X$dep" | sed -e 's,^X.*/,,' -e 's,^lib,,' -e 's,\.la$,,'` - ;; - *) - LIBINTL="${LIBINTL}${LIBINTL:+ }$dep" - LTLIBINTL="${LTLIBINTL}${LTLIBINTL:+ }$dep" - ;; - esac - done - fi - else - LIBINTL="${LIBINTL}${LIBINTL:+ }-l$name" - LTLIBINTL="${LTLIBINTL}${LTLIBINTL:+ }-l$name" - fi - fi - fi - done - done - if test "X$rpathdirs" != "X"; then - if test -n "$acl_hardcode_libdir_separator"; then - alldirs= - for found_dir in $rpathdirs; do - alldirs="${alldirs}${alldirs:+$acl_hardcode_libdir_separator}$found_dir" - done - acl_save_libdir="$libdir" - libdir="$alldirs" - eval flag=\"$acl_hardcode_libdir_flag_spec\" - libdir="$acl_save_libdir" - LIBINTL="${LIBINTL}${LIBINTL:+ }$flag" - else - for found_dir in $rpathdirs; do - acl_save_libdir="$libdir" - libdir="$found_dir" - eval flag=\"$acl_hardcode_libdir_flag_spec\" - libdir="$acl_save_libdir" - LIBINTL="${LIBINTL}${LIBINTL:+ }$flag" - done - fi - fi - if test "X$ltrpathdirs" != "X"; then - for found_dir in $ltrpathdirs; do - LTLIBINTL="${LTLIBINTL}${LTLIBINTL:+ }-R$found_dir" - done - fi +CSC_FLAGS= +if test "x$PROFILE" = "xdebug"; then + if true; then + ENABLE_DEBUG_TRUE= + ENABLE_DEBUG_FALSE='#' +else + ENABLE_DEBUG_TRUE='#' + ENABLE_DEBUG_FALSE= +fi + + CSC_FLAGS+=-define:DEBUG,TRACE,LOG4NET +else + if true; then + ENABLE_RELEASE_TRUE= + ENABLE_RELEASE_FALSE='#' +else + ENABLE_RELEASE_TRUE='#' + ENABLE_RELEASE_FALSE= +fi +fi +MCS_BASENAME=$(basename $MCS) +CLI_RUNTIME= +if test "$MCS_BASENAME" = "gmcs"; then + CLI_RUNTIME=2.0 +fi +if test "$MCS_BASENAME" = "dmcs"; then + CLI_RUNTIME=4.0 +fi +if test "$CLI_RUNTIME" = "2.0"; then + XBUILD_FLAGS="/toolsversion:3.5 /p:TargetFrameworkVersion=v3.5" +fi +if test "$CLI_RUNTIME" = "4.0"; then + XBUILD_FLAGS="/toolsversion:4.0 /p:TargetFrameworkVersion=v4.0" +fi +# Required Libraries - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU gettext in libintl" >&5 -$as_echo_n "checking for GNU gettext in libintl... " >&6; } -if { as_var=$gt_func_gnugettext_libintl; eval "test \"\${$as_var+set}\" = set"; }; then : - $as_echo_n "(cached) " >&6 -else - gt_save_CPPFLAGS="$CPPFLAGS" - CPPFLAGS="$CPPFLAGS $INCINTL" - gt_save_LIBS="$LIBS" - LIBS="$LIBS $LIBINTL" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -$gt_revision_test_code -extern int _nl_msg_cat_cntr; -extern -#ifdef __cplusplus -"C" -#endif -const char *_nl_expand_alias (const char *); -int -main () -{ -bindtextdomain ("", ""); -return * gettext ("")$gt_expression_test_code + _nl_msg_cat_cntr + *_nl_expand_alias ("") - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - eval "$gt_func_gnugettext_libintl=yes" +pkg_failed=no +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for LOG4NET" >&5 +$as_echo_n "checking for LOG4NET... " >&6; } + +if test -n "$LOG4NET_CFLAGS"; then + pkg_cv_LOG4NET_CFLAGS="$LOG4NET_CFLAGS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"log4net\""; } >&5 + ($PKG_CONFIG --exists --print-errors "log4net") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_LOG4NET_CFLAGS=`$PKG_CONFIG --cflags "log4net" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes else - eval "$gt_func_gnugettext_libintl=no" + pkg_failed=yes fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext - if { eval "gt_val=\$$gt_func_gnugettext_libintl"; test "$gt_val" != yes; } && test -n "$LIBICONV"; then - LIBS="$LIBS $LIBICONV" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -$gt_revision_test_code -extern int _nl_msg_cat_cntr; -extern -#ifdef __cplusplus -"C" -#endif -const char *_nl_expand_alias (const char *); -int -main () -{ -bindtextdomain ("", ""); -return * gettext ("")$gt_expression_test_code + _nl_msg_cat_cntr + *_nl_expand_alias ("") - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - LIBINTL="$LIBINTL $LIBICONV" - LTLIBINTL="$LTLIBINTL $LTLIBICONV" - eval "$gt_func_gnugettext_libintl=yes" - + else + pkg_failed=untried fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext - fi - CPPFLAGS="$gt_save_CPPFLAGS" - LIBS="$gt_save_LIBS" +if test -n "$LOG4NET_LIBS"; then + pkg_cv_LOG4NET_LIBS="$LOG4NET_LIBS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"log4net\""; } >&5 + ($PKG_CONFIG --exists --print-errors "log4net") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_LOG4NET_LIBS=`$PKG_CONFIG --libs "log4net" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes +else + pkg_failed=yes +fi + else + pkg_failed=untried fi -eval ac_res=\$$gt_func_gnugettext_libintl - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } - fi - if { eval "gt_val=\$$gt_func_gnugettext_libc"; test "$gt_val" = "yes"; } \ - || { { eval "gt_val=\$$gt_func_gnugettext_libintl"; test "$gt_val" = "yes"; } \ - && test "$PACKAGE" != gettext-runtime \ - && test "$PACKAGE" != gettext-tools; }; then - gt_use_preinstalled_gnugettext=yes + + +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 + LOG4NET_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "log4net" 2>&1` else - LIBINTL= - LTLIBINTL= - INCINTL= + LOG4NET_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "log4net" 2>&1` fi + # Put the nasty error message in config.log where it belongs + echo "$LOG4NET_PKG_ERRORS" >&5 + as_fn_error $? "Package requirements (log4net) were not met: +$LOG4NET_PKG_ERRORS - if test -n "$INTL_MACOSX_LIBS"; then - if test "$gt_use_preinstalled_gnugettext" = "yes" \ - || test "$nls_cv_use_gnu_gettext" = "yes"; then - LIBINTL="$LIBINTL $INTL_MACOSX_LIBS" - LTLIBINTL="$LTLIBINTL $INTL_MACOSX_LIBS" - fi - fi - - if test "$gt_use_preinstalled_gnugettext" = "yes" \ - || test "$nls_cv_use_gnu_gettext" = "yes"; then - -$as_echo "#define ENABLE_NLS 1" >>confdefs.h - - else - USE_NLS=no - fi - fi - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to use NLS" >&5 -$as_echo_n "checking whether to use NLS... " >&6; } - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $USE_NLS" >&5 -$as_echo "$USE_NLS" >&6; } - if test "$USE_NLS" = "yes"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking where the gettext function comes from" >&5 -$as_echo_n "checking where the gettext function comes from... " >&6; } - if test "$gt_use_preinstalled_gnugettext" = "yes"; then - if { eval "gt_val=\$$gt_func_gnugettext_libintl"; test "$gt_val" = "yes"; }; then - gt_source="external libintl" - else - gt_source="libc" - fi - else - gt_source="included intl directory" - fi - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gt_source" >&5 -$as_echo "$gt_source" >&6; } - fi +Consider adjusting the PKG_CONFIG_PATH environment variable if you +installed software in a non-standard prefix. - if test "$USE_NLS" = "yes"; then +Alternatively, you may set the environment variables LOG4NET_CFLAGS +and LOG4NET_LIBS to avoid the need to call pkg-config. +See the pkg-config man page for more details." "$LINENO" 5 +elif test $pkg_failed = untried; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "The pkg-config script could not be found or is too old. Make sure it +is in your PATH or set the PKG_CONFIG environment variable to the full +path to pkg-config. - if test "$gt_use_preinstalled_gnugettext" = "yes"; then - if { eval "gt_val=\$$gt_func_gnugettext_libintl"; test "$gt_val" = "yes"; }; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to link with libintl" >&5 -$as_echo_n "checking how to link with libintl... " >&6; } - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LIBINTL" >&5 -$as_echo "$LIBINTL" >&6; } +Alternatively, you may set the environment variables LOG4NET_CFLAGS +and LOG4NET_LIBS to avoid the need to call pkg-config. +See the pkg-config man page for more details. - for element in $INCINTL; do - haveit= - for x in $CPPFLAGS; do +To get pkg-config, see . +See \`config.log' for more details" "$LINENO" 5; } +else + LOG4NET_CFLAGS=$pkg_cv_LOG4NET_CFLAGS + LOG4NET_LIBS=$pkg_cv_LOG4NET_LIBS + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } - acl_save_prefix="$prefix" - prefix="$acl_final_prefix" - acl_save_exec_prefix="$exec_prefix" - exec_prefix="$acl_final_exec_prefix" - eval x=\"$x\" - exec_prefix="$acl_save_exec_prefix" - prefix="$acl_save_prefix" +fi - if test "X$x" = "X$element"; then - haveit=yes - break - fi - done - if test -z "$haveit"; then - CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }$element" - fi - done +if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"nini-1.1\""; } >&5 + ($PKG_CONFIG --exists --print-errors "nini-1.1") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + FOUND_NINI=yes +else + FOUND_NINI=no +fi +if test "x$FOUND_NINI" = "xyes"; then + nini_files=`pkg-config --variable=Libraries nini-1.1` + if test -n "$nini_files"; then + BUNDLE_NINI_TRUE= + BUNDLE_NINI_FALSE='#' +else + BUNDLE_NINI_TRUE='#' + BUNDLE_NINI_FALSE= +fi - fi + if test -z "$nini_files" ; then + # Debian-based distros place Nini into the GAC +pkg_failed=no +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for NINI" >&5 +$as_echo_n "checking for NINI... " >&6; } -$as_echo "#define HAVE_GETTEXT 1" >>confdefs.h +if test -n "$NINI_CFLAGS"; then + pkg_cv_NINI_CFLAGS="$NINI_CFLAGS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"nini-1.1\""; } >&5 + ($PKG_CONFIG --exists --print-errors "nini-1.1") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_NINI_CFLAGS=`$PKG_CONFIG --cflags "nini-1.1" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes +else + pkg_failed=yes +fi + else + pkg_failed=untried +fi +if test -n "$NINI_LIBS"; then + pkg_cv_NINI_LIBS="$NINI_LIBS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"nini-1.1\""; } >&5 + ($PKG_CONFIG --exists --print-errors "nini-1.1") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_NINI_LIBS=`$PKG_CONFIG --libs "nini-1.1" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes +else + pkg_failed=yes +fi + else + pkg_failed=untried +fi -$as_echo "#define HAVE_DCGETTEXT 1" >>confdefs.h - fi +if test $pkg_failed = yes; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } - POSUB=po - fi +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 + NINI_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "nini-1.1" 2>&1` + else + NINI_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "nini-1.1" 2>&1` + fi + # Put the nasty error message in config.log where it belongs + echo "$NINI_PKG_ERRORS" >&5 + as_fn_error $? "Package requirements (nini-1.1) were not met: +$NINI_PKG_ERRORS - INTLLIBS="$LIBINTL" +Consider adjusting the PKG_CONFIG_PATH environment variable if you +installed software in a non-standard prefix. +Alternatively, you may set the environment variables NINI_CFLAGS +and NINI_LIBS to avoid the need to call pkg-config. +See the pkg-config man page for more details." "$LINENO" 5 +elif test $pkg_failed = untried; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "The pkg-config script could not be found or is too old. Make sure it +is in your PATH or set the PKG_CONFIG environment variable to the full +path to pkg-config. +Alternatively, you may set the environment variables NINI_CFLAGS +and NINI_LIBS to avoid the need to call pkg-config. +See the pkg-config man page for more details. +To get pkg-config, see . +See \`config.log' for more details" "$LINENO" 5; } +else + NINI_CFLAGS=$pkg_cv_NINI_CFLAGS + NINI_LIBS=$pkg_cv_NINI_LIBS + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } +fi + else + # openSUSE has Nini as a private assembly; need to copy it. + NINI_LIBS="$nini_files" + fi +else +pkg_failed=no +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for NINI" >&5 +$as_echo_n "checking for NINI... " >&6; } -# doesn't support multiple po directories :( -#AM_GLIB_GNU_GETTEXT +if test -n "$NINI_CFLAGS"; then + pkg_cv_NINI_CFLAGS="$NINI_CFLAGS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"nini >= 1.1\""; } >&5 + ($PKG_CONFIG --exists --print-errors "nini >= 1.1") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_NINI_CFLAGS=`$PKG_CONFIG --cflags "nini >= 1.1" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes +else + pkg_failed=yes +fi + else + pkg_failed=untried +fi +if test -n "$NINI_LIBS"; then + pkg_cv_NINI_LIBS="$NINI_LIBS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"nini >= 1.1\""; } >&5 + ($PKG_CONFIG --exists --print-errors "nini >= 1.1") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_NINI_LIBS=`$PKG_CONFIG --libs "nini >= 1.1" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes +else + pkg_failed=yes +fi + else + pkg_failed=untried +fi - expanded_libdir=`( - case $prefix in - NONE) prefix=$ac_default_prefix ;; - *) ;; - esac - case $exec_prefix in - NONE) exec_prefix=$prefix ;; - *) ;; - esac - eval echo $libdir - )` +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 + NINI_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "nini >= 1.1" 2>&1` + else + NINI_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "nini >= 1.1" 2>&1` + fi + # Put the nasty error message in config.log where it belongs + echo "$NINI_PKG_ERRORS" >&5 + as_fn_error $? "Package requirements (nini >= 1.1) were not met: +$NINI_PKG_ERRORS +Consider adjusting the PKG_CONFIG_PATH environment variable if you +installed software in a non-standard prefix. +Alternatively, you may set the environment variables NINI_CFLAGS +and NINI_LIBS to avoid the need to call pkg-config. +See the pkg-config man page for more details." "$LINENO" 5 +elif test $pkg_failed = untried; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "The pkg-config script could not be found or is too old. Make sure it +is in your PATH or set the PKG_CONFIG environment variable to the full +path to pkg-config. +Alternatively, you may set the environment variables NINI_CFLAGS +and NINI_LIBS to avoid the need to call pkg-config. +See the pkg-config man page for more details. -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 : - $as_echo_n "(cached) " >&6 +To get pkg-config, see . +See \`config.log' for more details" "$LINENO" 5; } else - case $PKG_CONFIG in - [\\/]* | ?:[\\/]*) - ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # 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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$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 - fi -done - done -IFS=$as_save_IFS + NINI_CFLAGS=$pkg_cv_NINI_CFLAGS + NINI_LIBS=$pkg_cv_NINI_LIBS + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } - ;; -esac fi -PKG_CONFIG=$ac_cv_path_PKG_CONFIG -if test -n "$PKG_CONFIG"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PKG_CONFIG" >&5 -$as_echo "$PKG_CONFIG" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } fi -fi -if test -z "$ac_cv_path_PKG_CONFIG"; then - ac_pt_PKG_CONFIG=$PKG_CONFIG - # 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_ac_pt_PKG_CONFIG+set}" = set; then : - $as_echo_n "(cached) " >&6 +# Check whether --with-db4o was given. +if test "${with_db4o+set}" = set; then : + withval=$with_db4o; else - case $ac_pt_PKG_CONFIG in - [\\/]* | ?:[\\/]*) - ac_cv_path_ac_pt_PKG_CONFIG="$ac_pt_PKG_CONFIG" # 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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$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 - fi -done - done -IFS=$as_save_IFS + with_db4o=auto - ;; -esac -fi -ac_pt_PKG_CONFIG=$ac_cv_path_ac_pt_PKG_CONFIG -if test -n "$ac_pt_PKG_CONFIG"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_pt_PKG_CONFIG" >&5 -$as_echo "$ac_pt_PKG_CONFIG" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } fi - if test "x$ac_pt_PKG_CONFIG" = x; then - PKG_CONFIG="" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - PKG_CONFIG=$ac_pt_PKG_CONFIG - fi +WITH_DB4O=$with_db4o +if test "x$WITH_DB4O" = "xauto"; then + if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"db4o >= 8.0\""; } >&5 + ($PKG_CONFIG --exists --print-errors "db4o >= 8.0") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + FOUND_DB4O=yes else - PKG_CONFIG="$ac_cv_path_PKG_CONFIG" -fi - + FOUND_DB4O=no fi -if test -n "$PKG_CONFIG"; then - _pkg_min_version=0.9.0 - { $as_echo "$as_me:${as_lineno-$LINENO}: checking pkg-config is at least version $_pkg_min_version" >&5 -$as_echo_n "checking pkg-config is at least version $_pkg_min_version... " >&6; } - if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } + if test "x$FOUND_DB4O" = "xyes"; then + WITH_DB4O=system else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } - PKG_CONFIG="" + WITH_DB4O=included fi fi - +if test "x$WITH_DB4O" = "xsystem"; then pkg_failed=no -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for MONO_MODULE" >&5 -$as_echo_n "checking for MONO_MODULE... " >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for DB4O" >&5 +$as_echo_n "checking for DB4O... " >&6; } -if test -n "$MONO_MODULE_CFLAGS"; then - pkg_cv_MONO_MODULE_CFLAGS="$MONO_MODULE_CFLAGS" +if test -n "$DB4O_CFLAGS"; then + pkg_cv_DB4O_CFLAGS="$DB4O_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 >= 1.9.1\""; } >&5 - ($PKG_CONFIG --exists --print-errors "mono >= 1.9.1") 2>&5 + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"db4o >= 8.0\""; } >&5 + ($PKG_CONFIG --exists --print-errors "db4o >= 8.0") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then - pkg_cv_MONO_MODULE_CFLAGS=`$PKG_CONFIG --cflags "mono >= 1.9.1" 2>/dev/null` + pkg_cv_DB4O_CFLAGS=`$PKG_CONFIG --cflags "db4o >= 8.0" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi else pkg_failed=untried fi -if test -n "$MONO_MODULE_LIBS"; then - pkg_cv_MONO_MODULE_LIBS="$MONO_MODULE_LIBS" +if test -n "$DB4O_LIBS"; then + pkg_cv_DB4O_LIBS="$DB4O_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 >= 1.9.1\""; } >&5 - ($PKG_CONFIG --exists --print-errors "mono >= 1.9.1") 2>&5 + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"db4o >= 8.0\""; } >&5 + ($PKG_CONFIG --exists --print-errors "db4o >= 8.0") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then - pkg_cv_MONO_MODULE_LIBS=`$PKG_CONFIG --libs "mono >= 1.9.1" 2>/dev/null` + pkg_cv_DB4O_LIBS=`$PKG_CONFIG --libs "db4o >= 8.0" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi @@ -7078,59 +15196,69 @@ _pkg_short_errors_supported=no fi if test $_pkg_short_errors_supported = yes; then - MONO_MODULE_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "mono >= 1.9.1" 2>&1` + DB4O_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "db4o >= 8.0" 2>&1` else - MONO_MODULE_PKG_ERRORS=`$PKG_CONFIG --print-errors "mono >= 1.9.1" 2>&1` + DB4O_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "db4o >= 8.0" 2>&1` fi # Put the nasty error message in config.log where it belongs - echo "$MONO_MODULE_PKG_ERRORS" >&5 + echo "$DB4O_PKG_ERRORS" >&5 - as_fn_error "Package requirements (mono >= 1.9.1) were not met: + as_fn_error $? "Package requirements (db4o >= 8.0) were not met: -$MONO_MODULE_PKG_ERRORS +$DB4O_PKG_ERRORS Consider adjusting the PKG_CONFIG_PATH environment variable if you installed software in a non-standard prefix. -Alternatively, you may set the environment variables MONO_MODULE_CFLAGS -and MONO_MODULE_LIBS to avoid the need to call pkg-config. +Alternatively, you may set the environment variables DB4O_CFLAGS +and DB4O_LIBS to avoid the need to call pkg-config. See the pkg-config man page for more details." "$LINENO" 5 elif test $pkg_failed = untried; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error "The pkg-config script could not be found or is too old. Make sure it +as_fn_error $? "The pkg-config script could not be found or is too old. Make sure it is in your PATH or set the PKG_CONFIG environment variable to the full path to pkg-config. -Alternatively, you may set the environment variables MONO_MODULE_CFLAGS -and MONO_MODULE_LIBS to avoid the need to call pkg-config. +Alternatively, you may set the environment variables DB4O_CFLAGS +and DB4O_LIBS to avoid the need to call pkg-config. See the pkg-config man page for more details. To get pkg-config, see . -See \`config.log' for more details." "$LINENO" 5; } +See \`config.log' for more details" "$LINENO" 5; } else - MONO_MODULE_CFLAGS=$pkg_cv_MONO_MODULE_CFLAGS - MONO_MODULE_LIBS=$pkg_cv_MONO_MODULE_LIBS + DB4O_CFLAGS=$pkg_cv_DB4O_CFLAGS + DB4O_LIBS=$pkg_cv_DB4O_LIBS { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } fi + if false; then + BUNDLE_DB4O_TRUE= + BUNDLE_DB4O_FALSE='#' +else + BUNDLE_DB4O_TRUE='#' + BUNDLE_DB4O_FALSE= +fi +fi +if test "x$WITH_DB4O" = "xincluded"; then + if test ! -d "$srcdir/lib/db4o-net/Db4objects.Db4o"; then + as_fn_error $? "lib/db4o-net is empty!" "$LINENO" 5 + fi - - - # Extract the first word of "mono", so it can be a program name with args. -set dummy mono; ac_word=$2 + # 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 test "${ac_cv_path_MONO+set}" = set; then : +if ${ac_cv_path_XBUILD+:} false; then : $as_echo_n "(cached) " >&6 else - case $MONO in + case $XBUILD in [\\/]* | ?:[\\/]*) - ac_cv_path_MONO="$MONO" # Let the user override the test with a path. + ac_cv_path_XBUILD="$XBUILD" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR @@ -7140,7 +15268,7 @@ 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 - ac_cv_path_MONO="$as_dir/$ac_word$ac_exec_ext" + 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 @@ -7148,199 +15276,212 @@ done IFS=$as_save_IFS - test -z "$ac_cv_path_MONO" && ac_cv_path_MONO="no" + test -z "$ac_cv_path_XBUILD" && ac_cv_path_XBUILD="no" ;; esac fi -MONO=$ac_cv_path_MONO -if test -n "$MONO"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MONO" >&5 -$as_echo "$MONO" >&6; } +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$XBUILD" = "xno"; then + as_fn_error $? "You need to install xbuild" "$LINENO" 5 + fi + if true; then + BUNDLE_DB4O_TRUE= + BUNDLE_DB4O_FALSE='#' +else + BUNDLE_DB4O_TRUE='#' + BUNDLE_DB4O_FALSE= +fi - if test "xMONO" = "xno"; then - as_fn_error "You need to install 'mono'" "$LINENO" 5 - fi + #AC_SUBST([DB4O_FILES], "Db4objects.Db4o.dll Db4objects.Db4o.Instrumentation.dll Db4objects.Db4o.NativeQueries.dll") + DB4O_FILES="Db4objects.Db4o.dll" +fi +# Optional Libraries +# Check whether --with-indicate was given. +if test "${with_indicate+set}" = set; then : + withval=$with_indicate; +else + with_indicate=auto +fi - # Extract the first word of "gmcs", so it can be a program name with args. -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_MCS+set}" = set; then : - $as_echo_n "(cached) " >&6 +WITH_INDICATE=$with_indicate +if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"indicate-sharp-0.1\""; } >&5 + ($PKG_CONFIG --exists --print-errors "indicate-sharp-0.1") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + INDICATE_SHARP_SUPPORT=yes else - case $MCS in - [\\/]* | ?:[\\/]*) - ac_cv_path_MCS="$MCS" # 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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_path_MCS="$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 + INDICATE_SHARP_SUPPORT=no +fi +if test "x$WITH_INDICATE" = "xauto"; then + WITH_INDICATE=$INDICATE_SHARP_SUPPORT +fi +if test "x$WITH_INDICATE" = "xyes"; then - test -z "$ac_cv_path_MCS" && ac_cv_path_MCS="no" - ;; -esac +pkg_failed=no +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for INDICATE_SHARP" >&5 +$as_echo_n "checking for INDICATE_SHARP... " >&6; } + +if test -n "$INDICATE_SHARP_CFLAGS"; then + pkg_cv_INDICATE_SHARP_CFLAGS="$INDICATE_SHARP_CFLAGS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"indicate-sharp-0.1\""; } >&5 + ($PKG_CONFIG --exists --print-errors "indicate-sharp-0.1") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_INDICATE_SHARP_CFLAGS=`$PKG_CONFIG --cflags "indicate-sharp-0.1" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes +else + pkg_failed=yes fi -MCS=$ac_cv_path_MCS -if test -n "$MCS"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MCS" >&5 -$as_echo "$MCS" >&6; } + else + pkg_failed=untried +fi +if test -n "$INDICATE_SHARP_LIBS"; then + pkg_cv_INDICATE_SHARP_LIBS="$INDICATE_SHARP_LIBS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"indicate-sharp-0.1\""; } >&5 + ($PKG_CONFIG --exists --print-errors "indicate-sharp-0.1") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_INDICATE_SHARP_LIBS=`$PKG_CONFIG --libs "indicate-sharp-0.1" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } + 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 test "xMCS" = "xno"; then - as_fn_error "You need to install 'gmcs'" "$LINENO" 5 - fi - - - +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 + INDICATE_SHARP_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "indicate-sharp-0.1" 2>&1` + else + INDICATE_SHARP_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "indicate-sharp-0.1" 2>&1` + fi + # Put the nasty error message in config.log where it belongs + echo "$INDICATE_SHARP_PKG_ERRORS" >&5 - for asm in $(echo "2.0,System - System.Core - System.Runtime.Remoting - Mono.Posix -" | cut -d, -f2- | sed 's/\,/ /g') - do - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Mono 2.0 GAC for $asm.dll" >&5 -$as_echo_n "checking for Mono 2.0 GAC for $asm.dll... " >&6; } - if test \ - -e "$($PKG_CONFIG --variable=libdir mono)/mono/2.0/$asm.dll" -o \ - -e "$($PKG_CONFIG --variable=prefix mono)/lib/mono/2.0/$asm.dll"; \ - then \ - { $as_echo "$as_me:${as_lineno-$LINENO}: result: found" >&5 -$as_echo "found" >&6; } - else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5 -$as_echo "not found" >&6; } - as_fn_error "missing reqired Mono 2.0 assembly: $asm.dll" "$LINENO" 5 - fi - done + as_fn_error $? "Package requirements (indicate-sharp-0.1) were not met: +$INDICATE_SHARP_PKG_ERRORS +Consider adjusting the PKG_CONFIG_PATH environment variable if you +installed software in a non-standard prefix. -PROFILE=debug -# Check whether --enable-release was given. -if test "${enable_release+set}" = set; then : - enableval=$enable_release; enable_release=yes -else - enable_release=no -fi +Alternatively, you may set the environment variables INDICATE_SHARP_CFLAGS +and INDICATE_SHARP_LIBS to avoid the need to call pkg-config. +See the pkg-config man page for more details." "$LINENO" 5 +elif test $pkg_failed = untried; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "The pkg-config script could not be found or is too old. Make sure it +is in your PATH or set the PKG_CONFIG environment variable to the full +path to pkg-config. - if test x$enable_release = xyes; then - ENABLE_RELEASE_TRUE= - ENABLE_RELEASE_FALSE='#' -else - ENABLE_RELEASE_TRUE='#' - ENABLE_RELEASE_FALSE= -fi +Alternatively, you may set the environment variables INDICATE_SHARP_CFLAGS +and INDICATE_SHARP_LIBS to avoid the need to call pkg-config. +See the pkg-config man page for more details. -if test "x$enable_release" = "xyes" ; then - PROFILE=release -fi -# Check whether --enable-debug was given. -if test "${enable_debug+set}" = set; then : - enableval=$enable_debug; enable_debug=yes +To get pkg-config, see . +See \`config.log' for more details" "$LINENO" 5; } else - enable_debug=no -fi + INDICATE_SHARP_CFLAGS=$pkg_cv_INDICATE_SHARP_CFLAGS + INDICATE_SHARP_LIBS=$pkg_cv_INDICATE_SHARP_LIBS + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } - if test x$enable_debug = xyes; then - ENABLE_DEBUG_TRUE= - ENABLE_DEBUG_FALSE='#' -else - ENABLE_DEBUG_TRUE='#' - ENABLE_DEBUG_FALSE= fi - -if test "x$enable_debug" = "xyes" ; then - PROFILE=debug fi -CSC_FLAGS= -if test "x$PROFILE" = "xdebug"; then - if true; then - ENABLE_DEBUG_TRUE= - ENABLE_DEBUG_FALSE='#' +# Check whether --with-notify was given. +if test "${with_notify+set}" = set; then : + withval=$with_notify; else - ENABLE_DEBUG_TRUE='#' - ENABLE_DEBUG_FALSE= + with_notify=auto + fi - CSC_FLAGS+=-define:DEBUG,TRACE,LOG4NET -else - if true; then - ENABLE_RELEASE_TRUE= - ENABLE_RELEASE_FALSE='#' +WITH_NOTIFY=$with_notify +if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"notify-sharp\""; } >&5 + ($PKG_CONFIG --exists --print-errors "notify-sharp") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + NOTIFY_SHARP_SUPPORT=yes else - ENABLE_RELEASE_TRUE='#' - ENABLE_RELEASE_FALSE= + NOTIFY_SHARP_SUPPORT=no fi - +if test "x$WITH_NOTIFY" = "xauto"; then + WITH_NOTIFY=$NOTIFY_SHARP_SUPPORT fi -CSC="$MCS" - - - -# Required Libraries +if test "x$WITH_NOTIFY" = "xyes"; then pkg_failed=no -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for LOG4NET" >&5 -$as_echo_n "checking for LOG4NET... " >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for NOTIFY_SHARP" >&5 +$as_echo_n "checking for NOTIFY_SHARP... " >&6; } -if test -n "$LOG4NET_CFLAGS"; then - pkg_cv_LOG4NET_CFLAGS="$LOG4NET_CFLAGS" +if test -n "$NOTIFY_SHARP_CFLAGS"; then + pkg_cv_NOTIFY_SHARP_CFLAGS="$NOTIFY_SHARP_CFLAGS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ - { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"log4net\""; } >&5 - ($PKG_CONFIG --exists --print-errors "log4net") 2>&5 + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"notify-sharp\""; } >&5 + ($PKG_CONFIG --exists --print-errors "notify-sharp") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then - pkg_cv_LOG4NET_CFLAGS=`$PKG_CONFIG --cflags "log4net" 2>/dev/null` + pkg_cv_NOTIFY_SHARP_CFLAGS=`$PKG_CONFIG --cflags "notify-sharp" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi else pkg_failed=untried fi -if test -n "$LOG4NET_LIBS"; then - pkg_cv_LOG4NET_LIBS="$LOG4NET_LIBS" +if test -n "$NOTIFY_SHARP_LIBS"; then + pkg_cv_NOTIFY_SHARP_LIBS="$NOTIFY_SHARP_LIBS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ - { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"log4net\""; } >&5 - ($PKG_CONFIG --exists --print-errors "log4net") 2>&5 + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"notify-sharp\""; } >&5 + ($PKG_CONFIG --exists --print-errors "notify-sharp") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then - pkg_cv_LOG4NET_LIBS=`$PKG_CONFIG --libs "log4net" 2>/dev/null` + pkg_cv_NOTIFY_SHARP_LIBS=`$PKG_CONFIG --libs "notify-sharp" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi @@ -7360,99 +15501,119 @@ _pkg_short_errors_supported=no fi if test $_pkg_short_errors_supported = yes; then - LOG4NET_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "log4net" 2>&1` + NOTIFY_SHARP_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "notify-sharp" 2>&1` else - LOG4NET_PKG_ERRORS=`$PKG_CONFIG --print-errors "log4net" 2>&1` + NOTIFY_SHARP_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "notify-sharp" 2>&1` fi # Put the nasty error message in config.log where it belongs - echo "$LOG4NET_PKG_ERRORS" >&5 + echo "$NOTIFY_SHARP_PKG_ERRORS" >&5 - as_fn_error "Package requirements (log4net) were not met: + as_fn_error $? "Package requirements (notify-sharp) were not met: -$LOG4NET_PKG_ERRORS +$NOTIFY_SHARP_PKG_ERRORS Consider adjusting the PKG_CONFIG_PATH environment variable if you installed software in a non-standard prefix. -Alternatively, you may set the environment variables LOG4NET_CFLAGS -and LOG4NET_LIBS to avoid the need to call pkg-config. +Alternatively, you may set the environment variables NOTIFY_SHARP_CFLAGS +and NOTIFY_SHARP_LIBS to avoid the need to call pkg-config. See the pkg-config man page for more details." "$LINENO" 5 elif test $pkg_failed = untried; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error "The pkg-config script could not be found or is too old. Make sure it +as_fn_error $? "The pkg-config script could not be found or is too old. Make sure it is in your PATH or set the PKG_CONFIG environment variable to the full path to pkg-config. -Alternatively, you may set the environment variables LOG4NET_CFLAGS -and LOG4NET_LIBS to avoid the need to call pkg-config. +Alternatively, you may set the environment variables NOTIFY_SHARP_CFLAGS +and NOTIFY_SHARP_LIBS to avoid the need to call pkg-config. See the pkg-config man page for more details. To get pkg-config, see . -See \`config.log' for more details." "$LINENO" 5; } +See \`config.log' for more details" "$LINENO" 5; } else - LOG4NET_CFLAGS=$pkg_cv_LOG4NET_CFLAGS - LOG4NET_LIBS=$pkg_cv_LOG4NET_LIBS + NOTIFY_SHARP_CFLAGS=$pkg_cv_NOTIFY_SHARP_CFLAGS + NOTIFY_SHARP_LIBS=$pkg_cv_NOTIFY_SHARP_LIBS { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } fi +fi + + +# Check whether --with-dbus was given. +if test "${with_dbus+set}" = set; then : + withval=$with_dbus; +else + with_dbus=auto + +fi +WITH_DBUS=$with_dbus if test -n "$PKG_CONFIG" && \ - { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"nini-1.1\""; } >&5 - ($PKG_CONFIG --exists --print-errors "nini-1.1") 2>&5 + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"dbus-sharp-1.0\""; } >&5 + ($PKG_CONFIG --exists --print-errors "dbus-sharp-1.0") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then - FOUND_NINI=yes + DBUS_SHARP_SUPPORT=yes else - FOUND_NINI=no + DBUS_SHARP_SUPPORT=no fi -if test "x$FOUND_NINI" = "xyes"; then - nini_files=`pkg-config --variable=Libraries nini-1.1` - if test -n "$nini_files"; then - BUNDLE_NINI_TRUE= - BUNDLE_NINI_FALSE='#' +if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"ndesk-dbus-1.0\""; } >&5 + ($PKG_CONFIG --exists --print-errors "ndesk-dbus-1.0") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + NDESK_DBUS_SUPPORT=yes else - BUNDLE_NINI_TRUE='#' - BUNDLE_NINI_FALSE= + NDESK_DBUS_SUPPORT=no fi - - if test -z "$nini_files" ; then - # Debian-based distros place Nini into the GAC +if test "x$WITH_DBUS" = "xauto"; then + if test "x$DBUS_SHARP_SUPPORT" = "xyes"; then + WITH_DBUS=$DBUS_SHARP_SUPPORT + else + WITH_DBUS=$NDESK_DBUS_SUPPORT + fi +fi +if test "x$WITH_DBUS" = "xyes"; then + if test "x$DBUS_SHARP_SUPPORT" = "xyes"; then pkg_failed=no -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for NINI" >&5 -$as_echo_n "checking for NINI... " >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for DBUS_SHARP" >&5 +$as_echo_n "checking for DBUS_SHARP... " >&6; } -if test -n "$NINI_CFLAGS"; then - pkg_cv_NINI_CFLAGS="$NINI_CFLAGS" +if test -n "$DBUS_SHARP_CFLAGS"; then + pkg_cv_DBUS_SHARP_CFLAGS="$DBUS_SHARP_CFLAGS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ - { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"nini-1.1\""; } >&5 - ($PKG_CONFIG --exists --print-errors "nini-1.1") 2>&5 + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"dbus-sharp-1.0\""; } >&5 + ($PKG_CONFIG --exists --print-errors "dbus-sharp-1.0") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then - pkg_cv_NINI_CFLAGS=`$PKG_CONFIG --cflags "nini-1.1" 2>/dev/null` + pkg_cv_DBUS_SHARP_CFLAGS=`$PKG_CONFIG --cflags "dbus-sharp-1.0" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi else pkg_failed=untried fi -if test -n "$NINI_LIBS"; then - pkg_cv_NINI_LIBS="$NINI_LIBS" +if test -n "$DBUS_SHARP_LIBS"; then + pkg_cv_DBUS_SHARP_LIBS="$DBUS_SHARP_LIBS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ - { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"nini-1.1\""; } >&5 - ($PKG_CONFIG --exists --print-errors "nini-1.1") 2>&5 + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"dbus-sharp-1.0\""; } >&5 + ($PKG_CONFIG --exists --print-errors "dbus-sharp-1.0") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then - pkg_cv_NINI_LIBS=`$PKG_CONFIG --libs "nini-1.1" 2>/dev/null` + pkg_cv_DBUS_SHARP_LIBS=`$PKG_CONFIG --libs "dbus-sharp-1.0" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi @@ -7472,82 +15633,78 @@ _pkg_short_errors_supported=no fi if test $_pkg_short_errors_supported = yes; then - NINI_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "nini-1.1" 2>&1` + DBUS_SHARP_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "dbus-sharp-1.0" 2>&1` else - NINI_PKG_ERRORS=`$PKG_CONFIG --print-errors "nini-1.1" 2>&1` + DBUS_SHARP_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "dbus-sharp-1.0" 2>&1` fi # Put the nasty error message in config.log where it belongs - echo "$NINI_PKG_ERRORS" >&5 + echo "$DBUS_SHARP_PKG_ERRORS" >&5 - as_fn_error "Package requirements (nini-1.1) were not met: + as_fn_error $? "Package requirements (dbus-sharp-1.0) were not met: -$NINI_PKG_ERRORS +$DBUS_SHARP_PKG_ERRORS Consider adjusting the PKG_CONFIG_PATH environment variable if you installed software in a non-standard prefix. -Alternatively, you may set the environment variables NINI_CFLAGS -and NINI_LIBS to avoid the need to call pkg-config. +Alternatively, you may set the environment variables DBUS_SHARP_CFLAGS +and DBUS_SHARP_LIBS to avoid the need to call pkg-config. See the pkg-config man page for more details." "$LINENO" 5 elif test $pkg_failed = untried; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error "The pkg-config script could not be found or is too old. Make sure it +as_fn_error $? "The pkg-config script could not be found or is too old. Make sure it is in your PATH or set the PKG_CONFIG environment variable to the full path to pkg-config. -Alternatively, you may set the environment variables NINI_CFLAGS -and NINI_LIBS to avoid the need to call pkg-config. +Alternatively, you may set the environment variables DBUS_SHARP_CFLAGS +and DBUS_SHARP_LIBS to avoid the need to call pkg-config. See the pkg-config man page for more details. To get pkg-config, see . -See \`config.log' for more details." "$LINENO" 5; } +See \`config.log' for more details" "$LINENO" 5; } else - NINI_CFLAGS=$pkg_cv_NINI_CFLAGS - NINI_LIBS=$pkg_cv_NINI_LIBS + DBUS_SHARP_CFLAGS=$pkg_cv_DBUS_SHARP_CFLAGS + DBUS_SHARP_LIBS=$pkg_cv_DBUS_SHARP_LIBS { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } fi - else - # openSUSE has Nini as a private assembly; need to copy it. - NINI_LIBS="$nini_files" - - fi -else pkg_failed=no -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for NINI" >&5 -$as_echo_n "checking for NINI... " >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for DBUS_SHARP_GLIB" >&5 +$as_echo_n "checking for DBUS_SHARP_GLIB... " >&6; } -if test -n "$NINI_CFLAGS"; then - pkg_cv_NINI_CFLAGS="$NINI_CFLAGS" +if test -n "$DBUS_SHARP_GLIB_CFLAGS"; then + pkg_cv_DBUS_SHARP_GLIB_CFLAGS="$DBUS_SHARP_GLIB_CFLAGS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ - { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"nini >= 1.1\""; } >&5 - ($PKG_CONFIG --exists --print-errors "nini >= 1.1") 2>&5 + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"dbus-sharp-glib-1.0\""; } >&5 + ($PKG_CONFIG --exists --print-errors "dbus-sharp-glib-1.0") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then - pkg_cv_NINI_CFLAGS=`$PKG_CONFIG --cflags "nini >= 1.1" 2>/dev/null` + pkg_cv_DBUS_SHARP_GLIB_CFLAGS=`$PKG_CONFIG --cflags "dbus-sharp-glib-1.0" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi else pkg_failed=untried fi -if test -n "$NINI_LIBS"; then - pkg_cv_NINI_LIBS="$NINI_LIBS" +if test -n "$DBUS_SHARP_GLIB_LIBS"; then + pkg_cv_DBUS_SHARP_GLIB_LIBS="$DBUS_SHARP_GLIB_LIBS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ - { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"nini >= 1.1\""; } >&5 - ($PKG_CONFIG --exists --print-errors "nini >= 1.1") 2>&5 + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"dbus-sharp-glib-1.0\""; } >&5 + ($PKG_CONFIG --exists --print-errors "dbus-sharp-glib-1.0") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then - pkg_cv_NINI_LIBS=`$PKG_CONFIG --libs "nini >= 1.1" 2>/dev/null` + pkg_cv_DBUS_SHARP_GLIB_LIBS=`$PKG_CONFIG --libs "dbus-sharp-glib-1.0" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi @@ -7567,103 +15724,83 @@ _pkg_short_errors_supported=no fi if test $_pkg_short_errors_supported = yes; then - NINI_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "nini >= 1.1" 2>&1` + DBUS_SHARP_GLIB_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "dbus-sharp-glib-1.0" 2>&1` else - NINI_PKG_ERRORS=`$PKG_CONFIG --print-errors "nini >= 1.1" 2>&1` + DBUS_SHARP_GLIB_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "dbus-sharp-glib-1.0" 2>&1` fi # Put the nasty error message in config.log where it belongs - echo "$NINI_PKG_ERRORS" >&5 + echo "$DBUS_SHARP_GLIB_PKG_ERRORS" >&5 - as_fn_error "Package requirements (nini >= 1.1) were not met: + as_fn_error $? "Package requirements (dbus-sharp-glib-1.0) were not met: -$NINI_PKG_ERRORS +$DBUS_SHARP_GLIB_PKG_ERRORS Consider adjusting the PKG_CONFIG_PATH environment variable if you installed software in a non-standard prefix. -Alternatively, you may set the environment variables NINI_CFLAGS -and NINI_LIBS to avoid the need to call pkg-config. +Alternatively, you may set the environment variables DBUS_SHARP_GLIB_CFLAGS +and DBUS_SHARP_GLIB_LIBS to avoid the need to call pkg-config. See the pkg-config man page for more details." "$LINENO" 5 elif test $pkg_failed = untried; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error "The pkg-config script could not be found or is too old. Make sure it +as_fn_error $? "The pkg-config script could not be found or is too old. Make sure it is in your PATH or set the PKG_CONFIG environment variable to the full path to pkg-config. -Alternatively, you may set the environment variables NINI_CFLAGS -and NINI_LIBS to avoid the need to call pkg-config. +Alternatively, you may set the environment variables DBUS_SHARP_GLIB_CFLAGS +and DBUS_SHARP_GLIB_LIBS to avoid the need to call pkg-config. See the pkg-config man page for more details. To get pkg-config, see . -See \`config.log' for more details." "$LINENO" 5; } +See \`config.log' for more details" "$LINENO" 5; } else - NINI_CFLAGS=$pkg_cv_NINI_CFLAGS - NINI_LIBS=$pkg_cv_NINI_LIBS + DBUS_SHARP_GLIB_CFLAGS=$pkg_cv_DBUS_SHARP_GLIB_CFLAGS + DBUS_SHARP_GLIB_LIBS=$pkg_cv_DBUS_SHARP_GLIB_LIBS { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } - -fi -fi - -# Optional Libraries - -# Check whether --with-indicate was given. -if test "${with_indicate+set}" = set; then : - withval=$with_indicate; -else - with_indicate=auto +$as_echo "yes" >&6; } fi + DBUS_LIBS="$DBUS_SHARP_LIBS $DBUS_SHARP_GLIB_LIBS" -WITH_INDICATE=$with_indicate -if test -n "$PKG_CONFIG" && \ - { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"indicate-sharp-0.1\""; } >&5 - ($PKG_CONFIG --exists --print-errors "indicate-sharp-0.1") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; then - INDICATE_SHARP_SUPPORT=yes -else - INDICATE_SHARP_SUPPORT=no -fi -if test "x$WITH_INDICATE" = "xauto"; then - WITH_INDICATE=$INDICATE_SHARP_SUPPORT -fi -if test "x$WITH_INDICATE" = "xyes"; then + CSC_FLAGS+=" -define:IPC_DBUS -define:DBUS_SHARP" + else + # fallback to ndesk-dbus pkg_failed=no -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for INDICATE_SHARP" >&5 -$as_echo_n "checking for INDICATE_SHARP... " >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for NDESK_DBUS" >&5 +$as_echo_n "checking for NDESK_DBUS... " >&6; } -if test -n "$INDICATE_SHARP_CFLAGS"; then - pkg_cv_INDICATE_SHARP_CFLAGS="$INDICATE_SHARP_CFLAGS" +if test -n "$NDESK_DBUS_CFLAGS"; then + pkg_cv_NDESK_DBUS_CFLAGS="$NDESK_DBUS_CFLAGS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ - { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"indicate-sharp-0.1\""; } >&5 - ($PKG_CONFIG --exists --print-errors "indicate-sharp-0.1") 2>&5 + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"ndesk-dbus-1.0\""; } >&5 + ($PKG_CONFIG --exists --print-errors "ndesk-dbus-1.0") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then - pkg_cv_INDICATE_SHARP_CFLAGS=`$PKG_CONFIG --cflags "indicate-sharp-0.1" 2>/dev/null` + pkg_cv_NDESK_DBUS_CFLAGS=`$PKG_CONFIG --cflags "ndesk-dbus-1.0" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi else pkg_failed=untried fi -if test -n "$INDICATE_SHARP_LIBS"; then - pkg_cv_INDICATE_SHARP_LIBS="$INDICATE_SHARP_LIBS" +if test -n "$NDESK_DBUS_LIBS"; then + pkg_cv_NDESK_DBUS_LIBS="$NDESK_DBUS_LIBS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ - { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"indicate-sharp-0.1\""; } >&5 - ($PKG_CONFIG --exists --print-errors "indicate-sharp-0.1") 2>&5 + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"ndesk-dbus-1.0\""; } >&5 + ($PKG_CONFIG --exists --print-errors "ndesk-dbus-1.0") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then - pkg_cv_INDICATE_SHARP_LIBS=`$PKG_CONFIG --libs "indicate-sharp-0.1" 2>/dev/null` + pkg_cv_NDESK_DBUS_LIBS=`$PKG_CONFIG --libs "ndesk-dbus-1.0" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi @@ -7683,102 +15820,78 @@ _pkg_short_errors_supported=no fi if test $_pkg_short_errors_supported = yes; then - INDICATE_SHARP_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "indicate-sharp-0.1" 2>&1` + NDESK_DBUS_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "ndesk-dbus-1.0" 2>&1` else - INDICATE_SHARP_PKG_ERRORS=`$PKG_CONFIG --print-errors "indicate-sharp-0.1" 2>&1` + NDESK_DBUS_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "ndesk-dbus-1.0" 2>&1` fi # Put the nasty error message in config.log where it belongs - echo "$INDICATE_SHARP_PKG_ERRORS" >&5 + echo "$NDESK_DBUS_PKG_ERRORS" >&5 - as_fn_error "Package requirements (indicate-sharp-0.1) were not met: + as_fn_error $? "Package requirements (ndesk-dbus-1.0) were not met: -$INDICATE_SHARP_PKG_ERRORS +$NDESK_DBUS_PKG_ERRORS Consider adjusting the PKG_CONFIG_PATH environment variable if you installed software in a non-standard prefix. -Alternatively, you may set the environment variables INDICATE_SHARP_CFLAGS -and INDICATE_SHARP_LIBS to avoid the need to call pkg-config. +Alternatively, you may set the environment variables NDESK_DBUS_CFLAGS +and NDESK_DBUS_LIBS to avoid the need to call pkg-config. See the pkg-config man page for more details." "$LINENO" 5 elif test $pkg_failed = untried; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error "The pkg-config script could not be found or is too old. Make sure it +as_fn_error $? "The pkg-config script could not be found or is too old. Make sure it is in your PATH or set the PKG_CONFIG environment variable to the full path to pkg-config. -Alternatively, you may set the environment variables INDICATE_SHARP_CFLAGS -and INDICATE_SHARP_LIBS to avoid the need to call pkg-config. +Alternatively, you may set the environment variables NDESK_DBUS_CFLAGS +and NDESK_DBUS_LIBS to avoid the need to call pkg-config. See the pkg-config man page for more details. To get pkg-config, see . -See \`config.log' for more details." "$LINENO" 5; } +See \`config.log' for more details" "$LINENO" 5; } else - INDICATE_SHARP_CFLAGS=$pkg_cv_INDICATE_SHARP_CFLAGS - INDICATE_SHARP_LIBS=$pkg_cv_INDICATE_SHARP_LIBS + NDESK_DBUS_CFLAGS=$pkg_cv_NDESK_DBUS_CFLAGS + NDESK_DBUS_LIBS=$pkg_cv_NDESK_DBUS_LIBS { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } fi -fi - - -# Check whether --with-notify was given. -if test "${with_notify+set}" = set; then : - withval=$with_notify; -else - with_notify=auto - -fi - -WITH_NOTIFY=$with_notify -if test -n "$PKG_CONFIG" && \ - { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"notify-sharp\""; } >&5 - ($PKG_CONFIG --exists --print-errors "notify-sharp") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; then - NOTIFY_SHARP_SUPPORT=yes -else - NOTIFY_SHARP_SUPPORT=no -fi -if test "x$WITH_NOTIFY" = "xauto"; then - WITH_NOTIFY=$NOTIFY_SHARP_SUPPORT -fi -if test "x$WITH_NOTIFY" = "xyes"; then pkg_failed=no -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for NOTIFY_SHARP" >&5 -$as_echo_n "checking for NOTIFY_SHARP... " >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for NDESK_DBUS_GLIB" >&5 +$as_echo_n "checking for NDESK_DBUS_GLIB... " >&6; } -if test -n "$NOTIFY_SHARP_CFLAGS"; then - pkg_cv_NOTIFY_SHARP_CFLAGS="$NOTIFY_SHARP_CFLAGS" +if test -n "$NDESK_DBUS_GLIB_CFLAGS"; then + pkg_cv_NDESK_DBUS_GLIB_CFLAGS="$NDESK_DBUS_GLIB_CFLAGS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ - { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"notify-sharp\""; } >&5 - ($PKG_CONFIG --exists --print-errors "notify-sharp") 2>&5 + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"ndesk-dbus-glib-1.0\""; } >&5 + ($PKG_CONFIG --exists --print-errors "ndesk-dbus-glib-1.0") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then - pkg_cv_NOTIFY_SHARP_CFLAGS=`$PKG_CONFIG --cflags "notify-sharp" 2>/dev/null` + pkg_cv_NDESK_DBUS_GLIB_CFLAGS=`$PKG_CONFIG --cflags "ndesk-dbus-glib-1.0" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi else pkg_failed=untried fi -if test -n "$NOTIFY_SHARP_LIBS"; then - pkg_cv_NOTIFY_SHARP_LIBS="$NOTIFY_SHARP_LIBS" +if test -n "$NDESK_DBUS_GLIB_LIBS"; then + pkg_cv_NDESK_DBUS_GLIB_LIBS="$NDESK_DBUS_GLIB_LIBS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ - { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"notify-sharp\""; } >&5 - ($PKG_CONFIG --exists --print-errors "notify-sharp") 2>&5 + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"ndesk-dbus-glib-1.0\""; } >&5 + ($PKG_CONFIG --exists --print-errors "ndesk-dbus-glib-1.0") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then - pkg_cv_NOTIFY_SHARP_LIBS=`$PKG_CONFIG --libs "notify-sharp" 2>/dev/null` + pkg_cv_NDESK_DBUS_GLIB_LIBS=`$PKG_CONFIG --libs "ndesk-dbus-glib-1.0" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi @@ -7798,45 +15911,49 @@ _pkg_short_errors_supported=no fi if test $_pkg_short_errors_supported = yes; then - NOTIFY_SHARP_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "notify-sharp" 2>&1` + NDESK_DBUS_GLIB_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "ndesk-dbus-glib-1.0" 2>&1` else - NOTIFY_SHARP_PKG_ERRORS=`$PKG_CONFIG --print-errors "notify-sharp" 2>&1` + NDESK_DBUS_GLIB_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "ndesk-dbus-glib-1.0" 2>&1` fi # Put the nasty error message in config.log where it belongs - echo "$NOTIFY_SHARP_PKG_ERRORS" >&5 + echo "$NDESK_DBUS_GLIB_PKG_ERRORS" >&5 - as_fn_error "Package requirements (notify-sharp) were not met: + as_fn_error $? "Package requirements (ndesk-dbus-glib-1.0) were not met: -$NOTIFY_SHARP_PKG_ERRORS +$NDESK_DBUS_GLIB_PKG_ERRORS Consider adjusting the PKG_CONFIG_PATH environment variable if you installed software in a non-standard prefix. -Alternatively, you may set the environment variables NOTIFY_SHARP_CFLAGS -and NOTIFY_SHARP_LIBS to avoid the need to call pkg-config. +Alternatively, you may set the environment variables NDESK_DBUS_GLIB_CFLAGS +and NDESK_DBUS_GLIB_LIBS to avoid the need to call pkg-config. See the pkg-config man page for more details." "$LINENO" 5 elif test $pkg_failed = untried; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error "The pkg-config script could not be found or is too old. Make sure it +as_fn_error $? "The pkg-config script could not be found or is too old. Make sure it is in your PATH or set the PKG_CONFIG environment variable to the full path to pkg-config. -Alternatively, you may set the environment variables NOTIFY_SHARP_CFLAGS -and NOTIFY_SHARP_LIBS to avoid the need to call pkg-config. +Alternatively, you may set the environment variables NDESK_DBUS_GLIB_CFLAGS +and NDESK_DBUS_GLIB_LIBS to avoid the need to call pkg-config. See the pkg-config man page for more details. To get pkg-config, see . -See \`config.log' for more details." "$LINENO" 5; } +See \`config.log' for more details" "$LINENO" 5; } else - NOTIFY_SHARP_CFLAGS=$pkg_cv_NOTIFY_SHARP_CFLAGS - NOTIFY_SHARP_LIBS=$pkg_cv_NOTIFY_SHARP_LIBS + NDESK_DBUS_GLIB_CFLAGS=$pkg_cv_NDESK_DBUS_GLIB_CFLAGS + NDESK_DBUS_GLIB_LIBS=$pkg_cv_NDESK_DBUS_GLIB_LIBS { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } fi + DBUS_LIBS="$NDESK_DBUS_LIBS $NDESK_DBUS_GLIB_LIBS" + + CSC_FLAGS+=" -define:IPC_DBUS -define:NDESK_DBUS" + fi fi # Engines @@ -7850,7 +15967,7 @@ if test "x$ENABLE_ENGINE_IRC" != "xno"; then if test ! -f "$srcdir/lib/SmartIrc4net/configure.ac"; then - as_fn_error "lib/SmartIrc4net not found" "$LINENO" 5 + as_fn_error $? "lib/SmartIrc4net is empty!" "$LINENO" 5 fi ac_configure_args="$ac_configure_args --disable-pkg-config --disable-pkg-lib --disable-pkg-gac" @@ -7893,6 +16010,7 @@ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_OSCARLIB_CFLAGS=`$PKG_CONFIG --cflags "oscarlib" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi @@ -7909,6 +16027,7 @@ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_OSCARLIB_LIBS=`$PKG_CONFIG --libs "oscarlib" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi @@ -7928,9 +16047,9 @@ _pkg_short_errors_supported=no fi if test $_pkg_short_errors_supported = yes; then - OSCARLIB_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "oscarlib" 2>&1` + OSCARLIB_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "oscarlib" 2>&1` else - OSCARLIB_PKG_ERRORS=`$PKG_CONFIG --print-errors "oscarlib" 2>&1` + OSCARLIB_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "oscarlib" 2>&1` fi # Put the nasty error message in config.log where it belongs echo "$OSCARLIB_PKG_ERRORS" >&5 @@ -7949,7 +16068,7 @@ fi if test "x$ENABLE_ENGINE_OSCAR" = "xyes" -a "x$OSCAR_ENGINE_SUPPORT" != "xyes"; then - as_fn_error "OscarLib not found" "$LINENO" 5 + as_fn_error $? "OscarLib not found" "$LINENO" 5 else ENABLE_ENGINE_OSCARC=$OSCAR_SUPPORT fi @@ -7967,86 +16086,82 @@ if test "${enable_engine_xmpp+set}" = set; then : enableval=$enable_engine_xmpp; ENABLE_ENGINE_XMPP=$enableval else - ENABLE_ENGINE_XMPP=no + ENABLE_ENGINE_XMPP=yes fi if test "x$ENABLE_ENGINE_XMPP" != "xno"; then - -pkg_failed=no -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for JABBER_NET" >&5 -$as_echo_n "checking for JABBER_NET... " >&6; } - -if test -n "$JABBER_NET_CFLAGS"; then - pkg_cv_JABBER_NET_CFLAGS="$JABBER_NET_CFLAGS" - elif test -n "$PKG_CONFIG"; then - if test -n "$PKG_CONFIG" && \ - { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"jabber-net\""; } >&5 - ($PKG_CONFIG --exists --print-errors "jabber-net") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; then - pkg_cv_JABBER_NET_CFLAGS=`$PKG_CONFIG --cflags "jabber-net" 2>/dev/null` + # 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 - pkg_failed=yes -fi - else - pkg_failed=untried + 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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$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 -if test -n "$JABBER_NET_LIBS"; then - pkg_cv_JABBER_NET_LIBS="$JABBER_NET_LIBS" - elif test -n "$PKG_CONFIG"; then - if test -n "$PKG_CONFIG" && \ - { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"jabber-net\""; } >&5 - ($PKG_CONFIG --exists --print-errors "jabber-net") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; then - pkg_cv_JABBER_NET_LIBS=`$PKG_CONFIG --libs "jabber-net" 2>/dev/null` +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 - pkg_failed=yes -fi - else - pkg_failed=untried + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } fi + if test "x$XBUILD" = "xno"; then + as_fn_error $? "You need to install xbuild for XMPP support" "$LINENO" 5 + fi -if test $pkg_failed = yes; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } + if test ! -f "$srcdir/lib/jabber-net/2005-jabber-net.csproj"; then + as_fn_error $? "lib/jabber-net is empty!" "$LINENO" 5 + fi -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 - JABBER_NET_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "jabber-net" 2>&1` - else - JABBER_NET_PKG_ERRORS=`$PKG_CONFIG --print-errors "jabber-net" 2>&1` - fi - # Put the nasty error message in config.log where it belongs - echo "$JABBER_NET_PKG_ERRORS" >&5 - XMPP_SUPPORT=no -elif test $pkg_failed = untried; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } - XMPP_SUPPORT=no -else - JABBER_NET_CFLAGS=$pkg_cv_JABBER_NET_CFLAGS - JABBER_NET_LIBS=$pkg_cv_JABBER_NET_LIBS - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } - XMPP_SUPPORT=yes -fi + for asm in $(echo "2.0,System + System.Drawing + System.Xml + " | cut -d, -f2- | sed 's/\,/ /g') + do + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Mono 2.0 GAC for $asm.dll" >&5 +$as_echo_n "checking for Mono 2.0 GAC for $asm.dll... " >&6; } + if test \ + -e "$($PKG_CONFIG --variable=libdir mono)/mono/2.0/$asm.dll" -o \ + -e "$($PKG_CONFIG --variable=prefix mono)/lib/mono/2.0/$asm.dll"; \ + then \ + { $as_echo "$as_me:${as_lineno-$LINENO}: result: found" >&5 +$as_echo "found" >&6; } + else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5 +$as_echo "not found" >&6; } + as_fn_error $? "missing reqired Mono 2.0 assembly: $asm.dll" "$LINENO" 5 + fi + done + - if test "x$ENABLE_ENGINE_XMPP" = "xyes" -a "x$XMPP_SUPPORT" != "xyes"; then - as_fn_error "jabber-net not found" "$LINENO" 5 - else - ENABLE_ENGINE_XMPP=$XMPP_SUPPORT - fi fi if test "x$ENABLE_ENGINE_XMPP" = "xyes"; then ENABLE_ENGINE_XMPP_TRUE= @@ -8081,6 +16196,7 @@ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_MSNPSHARP_CFLAGS=`$PKG_CONFIG --cflags "msnp-sharp" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi @@ -8097,6 +16213,7 @@ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_MSNPSHARP_LIBS=`$PKG_CONFIG --libs "msnp-sharp" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi @@ -8116,9 +16233,9 @@ _pkg_short_errors_supported=no fi if test $_pkg_short_errors_supported = yes; then - MSNPSHARP_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "msnp-sharp" 2>&1` + MSNPSHARP_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "msnp-sharp" 2>&1` else - MSNPSHARP_PKG_ERRORS=`$PKG_CONFIG --print-errors "msnp-sharp" 2>&1` + MSNPSHARP_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "msnp-sharp" 2>&1` fi # Put the nasty error message in config.log where it belongs echo "$MSNPSHARP_PKG_ERRORS" >&5 @@ -8137,7 +16254,7 @@ fi if test "x$ENABLE_ENGINE_MSNP" = "xyes" -a "x$MSNP_SUPPORT" != "xyes"; then - as_fn_error "MSNPSharp not found" "$LINENO" 5 + as_fn_error $? "MSNPSharp not found" "$LINENO" 5 else ENABLE_ENGINE_MSNP=$MSNP_SUPPORT fi @@ -8164,7 +16281,7 @@ 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 test "${ac_cv_path_XBUILD+set}" = set; then : +if ${ac_cv_path_XBUILD+:} false; then : $as_echo_n "(cached) " >&6 else case $XBUILD in @@ -8202,7 +16319,7 @@ if test "x$XBUILD" = "xno"; then - as_fn_error "You need to install xbuild for Twitter support" "$LINENO" 5 + as_fn_error $? "You need to install xbuild for Twitter support" "$LINENO" 5 fi # compiling Json.NET with the C# compiler of Mono 2.4 will result in @@ -8215,11 +16332,11 @@ else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } - as_fn_error "You need Mono 2.6 or later for Twitter support" "$LINENO" 5 + as_fn_error $? "You need Mono 2.6 or later for Twitter support" "$LINENO" 5 fi if test ! -f "$srcdir/lib/Newtonsoft.Json/Src/Newtonsoft.Json/Newtonsoft.Json.csproj"; then - as_fn_error "lib/Newtonsoft.Json is empty! Used git submodule init; git submodule update?" "$LINENO" 5 + as_fn_error $? "lib/Newtonsoft.Json is empty!" "$LINENO" 5 fi @@ -8243,14 +16360,14 @@ else { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5 $as_echo "not found" >&6; } - as_fn_error "missing reqired Mono 2.0 assembly: $asm.dll" "$LINENO" 5 + as_fn_error $? "missing reqired Mono 2.0 assembly: $asm.dll" "$LINENO" 5 fi done if test ! -f "$srcdir/lib/Twitterizer/Twitterizer2/Twitterizer2.csproj"; then - as_fn_error "lib/Twitterizer is empty! Used git submodule init; git submodule update?" "$LINENO" 5 + as_fn_error $? "lib/Twitterizer is empty!" "$LINENO" 5 fi @@ -8276,7 +16393,7 @@ else { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5 $as_echo "not found" >&6; } - as_fn_error "missing reqired Mono 2.0 assembly: $asm.dll" "$LINENO" 5 + as_fn_error $? "missing reqired Mono 2.0 assembly: $asm.dll" "$LINENO" 5 fi done @@ -8295,13 +16412,19 @@ if test "${with_twitter_api_key+set}" = set; then : withval=$with_twitter_api_key; else - with_twitter_api_key="G0fxRfJqvcMPAuNat15YQ|j77MQDIuZJFa0CXehYzGPBZidF8DT3OXAi6sb5ucE" + with_twitter_api_key="60QV2qQx9cS7y1BJDbgAA|2VgD6qQKddsF5HYQ0TrRgs3tFTnCwDONBmRlTmG658" fi twitter_api_key=$with_twitter_api_key +# Server +if $PKG_CONFIG 'mono >= 2.6'; then + SERVER_COMPILER_FLAGS+=" -platform:x86" +fi + + # Frontends # Check whether --enable-frontend-gnome was given. if test "${enable_frontend_gnome+set}" = set; then : @@ -8327,6 +16450,7 @@ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_GLIB_SHARP_20_CFLAGS=`$PKG_CONFIG --cflags "glib-sharp-2.0 >= 2.8" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi @@ -8343,6 +16467,7 @@ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_GLIB_SHARP_20_LIBS=`$PKG_CONFIG --libs "glib-sharp-2.0 >= 2.8" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi @@ -8362,14 +16487,14 @@ _pkg_short_errors_supported=no fi if test $_pkg_short_errors_supported = yes; then - GLIB_SHARP_20_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "glib-sharp-2.0 >= 2.8" 2>&1` + GLIB_SHARP_20_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "glib-sharp-2.0 >= 2.8" 2>&1` else - GLIB_SHARP_20_PKG_ERRORS=`$PKG_CONFIG --print-errors "glib-sharp-2.0 >= 2.8" 2>&1` + GLIB_SHARP_20_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "glib-sharp-2.0 >= 2.8" 2>&1` fi # Put the nasty error message in config.log where it belongs echo "$GLIB_SHARP_20_PKG_ERRORS" >&5 - as_fn_error "Package requirements (glib-sharp-2.0 >= 2.8) were not met: + as_fn_error $? "Package requirements (glib-sharp-2.0 >= 2.8) were not met: $GLIB_SHARP_20_PKG_ERRORS @@ -8384,7 +16509,7 @@ $as_echo "no" >&6; } { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error "The pkg-config script could not be found or is too old. Make sure it +as_fn_error $? "The pkg-config script could not be found or is too old. Make sure it is in your PATH or set the PKG_CONFIG environment variable to the full path to pkg-config. @@ -8393,7 +16518,7 @@ See the pkg-config man page for more details. To get pkg-config, see . -See \`config.log' for more details." "$LINENO" 5; } +See \`config.log' for more details" "$LINENO" 5; } else GLIB_SHARP_20_CFLAGS=$pkg_cv_GLIB_SHARP_20_CFLAGS GLIB_SHARP_20_LIBS=$pkg_cv_GLIB_SHARP_20_LIBS @@ -8416,6 +16541,7 @@ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_GTK_SHARP_20_CFLAGS=`$PKG_CONFIG --cflags "gtk-sharp-2.0 >= 2.8" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi @@ -8432,6 +16558,7 @@ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_GTK_SHARP_20_LIBS=`$PKG_CONFIG --libs "gtk-sharp-2.0 >= 2.8" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi @@ -8451,14 +16578,14 @@ _pkg_short_errors_supported=no fi if test $_pkg_short_errors_supported = yes; then - GTK_SHARP_20_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "gtk-sharp-2.0 >= 2.8" 2>&1` + GTK_SHARP_20_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "gtk-sharp-2.0 >= 2.8" 2>&1` else - GTK_SHARP_20_PKG_ERRORS=`$PKG_CONFIG --print-errors "gtk-sharp-2.0 >= 2.8" 2>&1` + GTK_SHARP_20_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "gtk-sharp-2.0 >= 2.8" 2>&1` fi # Put the nasty error message in config.log where it belongs echo "$GTK_SHARP_20_PKG_ERRORS" >&5 - as_fn_error "Package requirements (gtk-sharp-2.0 >= 2.8) were not met: + as_fn_error $? "Package requirements (gtk-sharp-2.0 >= 2.8) were not met: $GTK_SHARP_20_PKG_ERRORS @@ -8473,7 +16600,7 @@ $as_echo "no" >&6; } { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error "The pkg-config script could not be found or is too old. Make sure it +as_fn_error $? "The pkg-config script could not be found or is too old. Make sure it is in your PATH or set the PKG_CONFIG environment variable to the full path to pkg-config. @@ -8482,7 +16609,7 @@ See the pkg-config man page for more details. To get pkg-config, see . -See \`config.log' for more details." "$LINENO" 5; } +See \`config.log' for more details" "$LINENO" 5; } else GTK_SHARP_20_CFLAGS=$pkg_cv_GTK_SHARP_20_CFLAGS GTK_SHARP_20_LIBS=$pkg_cv_GTK_SHARP_20_LIBS @@ -8505,6 +16632,7 @@ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_GLADE_SHARP_20_CFLAGS=`$PKG_CONFIG --cflags "glade-sharp-2.0 >= 2.8" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi @@ -8521,6 +16649,7 @@ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_GLADE_SHARP_20_LIBS=`$PKG_CONFIG --libs "glade-sharp-2.0 >= 2.8" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi @@ -8540,14 +16669,14 @@ _pkg_short_errors_supported=no fi if test $_pkg_short_errors_supported = yes; then - GLADE_SHARP_20_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "glade-sharp-2.0 >= 2.8" 2>&1` + GLADE_SHARP_20_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "glade-sharp-2.0 >= 2.8" 2>&1` else - GLADE_SHARP_20_PKG_ERRORS=`$PKG_CONFIG --print-errors "glade-sharp-2.0 >= 2.8" 2>&1` + GLADE_SHARP_20_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "glade-sharp-2.0 >= 2.8" 2>&1` fi # Put the nasty error message in config.log where it belongs echo "$GLADE_SHARP_20_PKG_ERRORS" >&5 - as_fn_error "Package requirements (glade-sharp-2.0 >= 2.8) were not met: + as_fn_error $? "Package requirements (glade-sharp-2.0 >= 2.8) were not met: $GLADE_SHARP_20_PKG_ERRORS @@ -8562,7 +16691,7 @@ $as_echo "no" >&6; } { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error "The pkg-config script could not be found or is too old. Make sure it +as_fn_error $? "The pkg-config script could not be found or is too old. Make sure it is in your PATH or set the PKG_CONFIG environment variable to the full path to pkg-config. @@ -8571,7 +16700,7 @@ See the pkg-config man page for more details. To get pkg-config, see . -See \`config.log' for more details." "$LINENO" 5; } +See \`config.log' for more details" "$LINENO" 5; } else GLADE_SHARP_20_CFLAGS=$pkg_cv_GLADE_SHARP_20_CFLAGS GLADE_SHARP_20_LIBS=$pkg_cv_GLADE_SHARP_20_LIBS @@ -8610,61 +16739,160 @@ else { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5 $as_echo "not found" >&6; } - as_fn_error "missing reqired Mono 2.0 assembly: $asm.dll" "$LINENO" 5 + as_fn_error $? "missing reqired Mono 2.0 assembly: $asm.dll" "$LINENO" 5 fi done - if test "x$WITH_INDICATE" = "xyes"; then - FRONTEND_GNOME_COMPILER_FLAGS+=" -define:INDICATE_SHARP" - fi - if test "x$WITH_NOTIFY" = "xyes"; then - FRONTEND_GNOME_COMPILER_FLAGS+=" -define:NOTIFY_SHARP" - fi + if test "x$WITH_INDICATE" = "xyes"; then + FRONTEND_GNOME_COMPILER_FLAGS+=" -define:INDICATE_SHARP" + fi + if test "x$WITH_NOTIFY" = "xyes"; then + FRONTEND_GNOME_COMPILER_FLAGS+=" -define:NOTIFY_SHARP" + fi + if $PKG_CONFIG 'mono >= 2.6'; then + FRONTEND_GNOME_COMPILER_FLAGS+=" -platform:x86" + fi + + + ENABLE_FRONTEND_GNOME_IRC=$ENABLE_ENGINE_IRC; + ENABLE_FRONTEND_GNOME_XMPP=$ENABLE_ENGINE_XMPP; +fi + if test "x$ENABLE_FRONTEND_GNOME" = "xyes"; then + ENABLE_FRONTEND_GNOME_TRUE= + ENABLE_FRONTEND_GNOME_FALSE='#' +else + ENABLE_FRONTEND_GNOME_TRUE='#' + ENABLE_FRONTEND_GNOME_FALSE= +fi + + if test "x$ENABLE_FRONTEND_GNOME_IRC" = "xyes"; then + ENABLE_FRONTEND_GNOME_IRC_TRUE= + ENABLE_FRONTEND_GNOME_IRC_FALSE='#' +else + ENABLE_FRONTEND_GNOME_IRC_TRUE='#' + ENABLE_FRONTEND_GNOME_IRC_FALSE= +fi + + if test "x$ENABLE_FRONTEND_GNOME_XMPP" = "xyes"; then + ENABLE_FRONTEND_GNOME_XMPP_TRUE= + ENABLE_FRONTEND_GNOME_XMPP_FALSE='#' +else + ENABLE_FRONTEND_GNOME_XMPP_TRUE='#' + ENABLE_FRONTEND_GNOME_XMPP_FALSE= +fi + + +# Check whether --enable-frontend-stfl was given. +if test "${enable_frontend_stfl+set}" = set; then : + enableval=$enable_frontend_stfl; ENABLE_FRONTEND_STFL=$enableval +else + ENABLE_FRONTEND_STFL=no + +fi + +if test "x$ENABLE_FRONTEND_STFL" != "xno"; then + +pkg_failed=no +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for STFL" >&5 +$as_echo_n "checking for STFL... " >&6; } + +if test -n "$STFL_CFLAGS"; then + pkg_cv_STFL_CFLAGS="$STFL_CFLAGS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"stfl >= 0.21\""; } >&5 + ($PKG_CONFIG --exists --print-errors "stfl >= 0.21") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_STFL_CFLAGS=`$PKG_CONFIG --cflags "stfl >= 0.21" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes +else + pkg_failed=yes +fi + else + pkg_failed=untried +fi +if test -n "$STFL_LIBS"; then + pkg_cv_STFL_LIBS="$STFL_LIBS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"stfl >= 0.21\""; } >&5 + ($PKG_CONFIG --exists --print-errors "stfl >= 0.21") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_STFL_LIBS=`$PKG_CONFIG --libs "stfl >= 0.21" 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; } - ENABLE_FRONTEND_GNOME_IRC=$ENABLE_ENGINE_IRC; - ENABLE_FRONTEND_GNOME_XMPP=$ENABLE_ENGINE_XMPP; -fi - if test "x$ENABLE_FRONTEND_GNOME" = "xyes"; then - ENABLE_FRONTEND_GNOME_TRUE= - ENABLE_FRONTEND_GNOME_FALSE='#' +if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then + _pkg_short_errors_supported=yes else - ENABLE_FRONTEND_GNOME_TRUE='#' - ENABLE_FRONTEND_GNOME_FALSE= + _pkg_short_errors_supported=no fi + if test $_pkg_short_errors_supported = yes; then + STFL_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "stfl >= 0.21" 2>&1` + else + STFL_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "stfl >= 0.21" 2>&1` + fi + # Put the nasty error message in config.log where it belongs + echo "$STFL_PKG_ERRORS" >&5 - if test "x$ENABLE_FRONTEND_GNOME_IRC" = "xyes"; then - ENABLE_FRONTEND_GNOME_IRC_TRUE= - ENABLE_FRONTEND_GNOME_IRC_FALSE='#' -else - ENABLE_FRONTEND_GNOME_IRC_TRUE='#' - ENABLE_FRONTEND_GNOME_IRC_FALSE= -fi + as_fn_error $? "Package requirements (stfl >= 0.21) were not met: - if test "x$ENABLE_FRONTEND_GNOME_XMPP" = "xyes"; then - ENABLE_FRONTEND_GNOME_XMPP_TRUE= - ENABLE_FRONTEND_GNOME_XMPP_FALSE='#' -else - ENABLE_FRONTEND_GNOME_XMPP_TRUE='#' - ENABLE_FRONTEND_GNOME_XMPP_FALSE= -fi +$STFL_PKG_ERRORS +Consider adjusting the PKG_CONFIG_PATH environment variable if you +installed software in a non-standard prefix. -# Check whether --enable-frontend-stfl was given. -if test "${enable_frontend_stfl+set}" = set; then : - enableval=$enable_frontend_stfl; ENABLE_FRONTEND_STFL=$enableval +Alternatively, you may set the environment variables STFL_CFLAGS +and STFL_LIBS to avoid the need to call pkg-config. +See the pkg-config man page for more details." "$LINENO" 5 +elif test $pkg_failed = untried; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "The pkg-config script could not be found or is too old. Make sure it +is in your PATH or set the PKG_CONFIG environment variable to the full +path to pkg-config. + +Alternatively, you may set the environment variables STFL_CFLAGS +and STFL_LIBS to avoid the need to call pkg-config. +See the pkg-config man page for more details. + +To get pkg-config, see . +See \`config.log' for more details" "$LINENO" 5; } else - ENABLE_FRONTEND_STFL=no + STFL_CFLAGS=$pkg_cv_STFL_CFLAGS + STFL_LIBS=$pkg_cv_STFL_LIBS + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } fi - -if test "x$ENABLE_FRONTEND_STFL" != "xno"; then - # TODO: check deps - as_fn_error "STFL frontend not supported (yet)" "$LINENO" 5 fi + if false; then + ENABLE_STATIC_STFL_TRUE= + ENABLE_STATIC_STFL_FALSE='#' +else + ENABLE_STATIC_STFL_TRUE='#' + ENABLE_STATIC_STFL_FALSE= +fi + if test "x$ENABLE_FRONTEND_STFL" = "xyes"; then ENABLE_FRONTEND_STFL_TRUE= ENABLE_FRONTEND_STFL_FALSE='#' @@ -8684,7 +16912,7 @@ if test "x$ENABLE_FRONTEND_CURSES" != "xno"; then # TODO: check deps - as_fn_error "Ncurses frontend not supported (yet)" "$LINENO" 5 + as_fn_error $? "Ncurses frontend not supported (yet)" "$LINENO" 5 fi if test "x$ENABLE_FRONTEND_CURSES" = "xyes"; then ENABLE_FRONTEND_CURSES_TRUE= @@ -8720,7 +16948,7 @@ else { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5 $as_echo "not found" >&6; } - as_fn_error "missing reqired Mono 2.0 assembly: $asm.dll" "$LINENO" 5 + as_fn_error $? "missing reqired Mono 2.0 assembly: $asm.dll" "$LINENO" 5 fi done @@ -8745,7 +16973,7 @@ if test "x$ENABLE_FRONTEND_WPF" != "xno"; then # TODO: check deps - as_fn_error "WPF frontend not supported (yet)" "$LINENO" 5 + as_fn_error $? "WPF frontend not supported (yet)" "$LINENO" 5 fi if test "x$ENABLE_FRONTEND_WPF" = "xyes"; then ENABLE_FRONTEND_WPF_TRUE= @@ -8773,7 +17001,7 @@ fi -ac_config_files="$ac_config_files Makefile src/Makefile src/AssemblyVersion.cs src/smuxi-win32.nsis src/Common/Makefile src/Common/Defines.cs src/Common/smuxi-common.pc src/Engine/Makefile src/Engine/smuxi-engine.pc src/Engine-IRC/Makefile src/Engine-IRC/smuxi-engine-irc.pc src/Engine-MSNP/Makefile src/Engine-MSNP/smuxi-engine-msnp.pc src/Engine-OSCAR/Makefile src/Engine-OSCAR/smuxi-engine-oscar.pc src/Engine-Twitter/Makefile src/Engine-XMPP/Makefile src/Engine-XMPP/smuxi-engine-xmpp.pc src/Server/Makefile src/Server/smuxi-server src/Frontend/Makefile src/Frontend/smuxi-frontend.pc src/Frontend-GNOME/Makefile src/Frontend-GNOME/smuxi-frontend-gnome src/Frontend-GNOME-IRC/Makefile src/Frontend-GNOME-XMPP/Makefile src/Frontend-Curses/Makefile src/Frontend-Curses/smuxi-frontend-curses src/Frontend-STFL/Makefile src/Frontend-STFL/smuxi-frontend-stfl src/Frontend-SWF/Makefile src/Frontend-SWF/smuxi-frontend-swf src/Frontend-Test/Makefile src/Frontend-Test/smuxi-frontend-test lib/Makefile po/Makefile.in po-Engine/Makefile.in po-Engine-IRC/Makefile.in po-Engine-Twitter/Makefile.in po-Server/Makefile.in po-Frontend/Makefile.in po-Frontend-GNOME/Makefile.in po-Frontend-GNOME-IRC/Makefile.in" +ac_config_files="$ac_config_files Makefile src/Makefile src/AssemblyVersion.cs src/smuxi-win32.nsis src/Common/Makefile src/Common/Defines.cs src/Common/smuxi-common.pc src/Engine/Makefile src/Engine/smuxi-engine.pc src/Engine-IRC/Makefile src/Engine-IRC/smuxi-engine-irc.pc src/Engine-MSNP/Makefile src/Engine-MSNP/smuxi-engine-msnp.pc src/Engine-OSCAR/Makefile src/Engine-OSCAR/smuxi-engine-oscar.pc src/Engine-Twitter/Makefile src/Engine-XMPP/Makefile src/Engine-XMPP/smuxi-engine-xmpp.pc src/Server/Makefile src/Server/smuxi-server src/Frontend/Makefile src/Frontend/smuxi-frontend.pc src/Frontend-GNOME/Makefile src/Frontend-GNOME/smuxi-frontend-gnome src/Frontend-GNOME-IRC/Makefile src/Frontend-GNOME-XMPP/Makefile src/Frontend-Curses/Makefile src/Frontend-Curses/smuxi-frontend-curses src/Frontend-STFL/Makefile src/Frontend-STFL/smuxi-frontend-stfl src/Frontend-STFL/STFL/Makefile src/Frontend-SWF/Makefile src/Frontend-SWF/smuxi-frontend-swf src/Frontend-Test/Makefile src/Frontend-Test/smuxi-frontend-test lib/Makefile lib/osx/Info.plist po/Makefile.in po-Engine/Makefile.in po-Engine-IRC/Makefile.in po-Engine-Twitter/Makefile.in po-Server/Makefile.in po-Frontend/Makefile.in po-Frontend-GNOME/Makefile.in po-Frontend-GNOME-IRC/Makefile.in" cat >confcache <<\_ACEOF @@ -8840,10 +17068,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;} @@ -8895,6 +17134,7 @@ ac_libobjs= ac_ltlibobjs= +U= for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue # 1. Remove the extension, and $U if already installed. ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' @@ -8918,15 +17158,15 @@ fi if test -z "${MAINTAINER_MODE_TRUE}" && test -z "${MAINTAINER_MODE_FALSE}"; then - as_fn_error "conditional \"MAINTAINER_MODE\" was never defined. + as_fn_error $? "conditional \"MAINTAINER_MODE\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${AMDEP_TRUE}" && test -z "${AMDEP_FALSE}"; then - as_fn_error "conditional \"AMDEP\" was never defined. + as_fn_error $? "conditional \"AMDEP\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then - as_fn_error "conditional \"am__fastdepCC\" was never defined. + as_fn_error $? "conditional \"am__fastdepCC\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi @@ -8934,79 +17174,91 @@ if test -z "${ENABLE_RELEASE_TRUE}" && test -z "${ENABLE_RELEASE_FALSE}"; then - as_fn_error "conditional \"ENABLE_RELEASE\" was never defined. + as_fn_error $? "conditional \"ENABLE_RELEASE\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${ENABLE_DEBUG_TRUE}" && test -z "${ENABLE_DEBUG_FALSE}"; then - as_fn_error "conditional \"ENABLE_DEBUG\" was never defined. + as_fn_error $? "conditional \"ENABLE_DEBUG\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${ENABLE_DEBUG_TRUE}" && test -z "${ENABLE_DEBUG_FALSE}"; then - as_fn_error "conditional \"ENABLE_DEBUG\" was never defined. + as_fn_error $? "conditional \"ENABLE_DEBUG\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${ENABLE_RELEASE_TRUE}" && test -z "${ENABLE_RELEASE_FALSE}"; then - as_fn_error "conditional \"ENABLE_RELEASE\" was never defined. + as_fn_error $? "conditional \"ENABLE_RELEASE\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${BUNDLE_NINI_TRUE}" && test -z "${BUNDLE_NINI_FALSE}"; then - as_fn_error "conditional \"BUNDLE_NINI\" was never defined. + as_fn_error $? "conditional \"BUNDLE_NINI\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi +if test -z "${BUNDLE_DB4O_TRUE}" && test -z "${BUNDLE_DB4O_FALSE}"; then + as_fn_error $? "conditional \"BUNDLE_DB4O\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi +if test -z "${BUNDLE_DB4O_TRUE}" && test -z "${BUNDLE_DB4O_FALSE}"; then + as_fn_error $? "conditional \"BUNDLE_DB4O\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${ENABLE_ENGINE_IRC_TRUE}" && test -z "${ENABLE_ENGINE_IRC_FALSE}"; then - as_fn_error "conditional \"ENABLE_ENGINE_IRC\" was never defined. + as_fn_error $? "conditional \"ENABLE_ENGINE_IRC\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${ENABLE_ENGINE_OSCAR_TRUE}" && test -z "${ENABLE_ENGINE_OSCAR_FALSE}"; then - as_fn_error "conditional \"ENABLE_ENGINE_OSCAR\" was never defined. + as_fn_error $? "conditional \"ENABLE_ENGINE_OSCAR\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${ENABLE_ENGINE_XMPP_TRUE}" && test -z "${ENABLE_ENGINE_XMPP_FALSE}"; then - as_fn_error "conditional \"ENABLE_ENGINE_XMPP\" was never defined. + as_fn_error $? "conditional \"ENABLE_ENGINE_XMPP\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${ENABLE_ENGINE_MSNP_TRUE}" && test -z "${ENABLE_ENGINE_MSNP_FALSE}"; then - as_fn_error "conditional \"ENABLE_ENGINE_MSNP\" was never defined. + as_fn_error $? "conditional \"ENABLE_ENGINE_MSNP\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${ENABLE_ENGINE_TWITTER_TRUE}" && test -z "${ENABLE_ENGINE_TWITTER_FALSE}"; then - as_fn_error "conditional \"ENABLE_ENGINE_TWITTER\" was never defined. + as_fn_error $? "conditional \"ENABLE_ENGINE_TWITTER\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${ENABLE_FRONTEND_GNOME_TRUE}" && test -z "${ENABLE_FRONTEND_GNOME_FALSE}"; then - as_fn_error "conditional \"ENABLE_FRONTEND_GNOME\" was never defined. + as_fn_error $? "conditional \"ENABLE_FRONTEND_GNOME\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${ENABLE_FRONTEND_GNOME_IRC_TRUE}" && test -z "${ENABLE_FRONTEND_GNOME_IRC_FALSE}"; then - as_fn_error "conditional \"ENABLE_FRONTEND_GNOME_IRC\" was never defined. + as_fn_error $? "conditional \"ENABLE_FRONTEND_GNOME_IRC\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${ENABLE_FRONTEND_GNOME_XMPP_TRUE}" && test -z "${ENABLE_FRONTEND_GNOME_XMPP_FALSE}"; then - as_fn_error "conditional \"ENABLE_FRONTEND_GNOME_XMPP\" was never defined. + as_fn_error $? "conditional \"ENABLE_FRONTEND_GNOME_XMPP\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi +if test -z "${ENABLE_STATIC_STFL_TRUE}" && test -z "${ENABLE_STATIC_STFL_FALSE}"; then + as_fn_error $? "conditional \"ENABLE_STATIC_STFL\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${ENABLE_FRONTEND_STFL_TRUE}" && test -z "${ENABLE_FRONTEND_STFL_FALSE}"; then - as_fn_error "conditional \"ENABLE_FRONTEND_STFL\" was never defined. + as_fn_error $? "conditional \"ENABLE_FRONTEND_STFL\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${ENABLE_FRONTEND_CURSES_TRUE}" && test -z "${ENABLE_FRONTEND_CURSES_FALSE}"; then - as_fn_error "conditional \"ENABLE_FRONTEND_CURSES\" was never defined. + as_fn_error $? "conditional \"ENABLE_FRONTEND_CURSES\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${ENABLE_FRONTEND_SWF_TRUE}" && test -z "${ENABLE_FRONTEND_SWF_FALSE}"; then - as_fn_error "conditional \"ENABLE_FRONTEND_SWF\" was never defined. + as_fn_error $? "conditional \"ENABLE_FRONTEND_SWF\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${ENABLE_FRONTEND_WPF_TRUE}" && test -z "${ENABLE_FRONTEND_WPF_FALSE}"; then - as_fn_error "conditional \"ENABLE_FRONTEND_WPF\" was never defined. + as_fn_error $? "conditional \"ENABLE_FRONTEND_WPF\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${ENABLE_FRONTEND_TEST_TRUE}" && test -z "${ENABLE_FRONTEND_TEST_FALSE}"; then - as_fn_error "conditional \"ENABLE_FRONTEND_TEST\" was never defined. + as_fn_error $? "conditional \"ENABLE_FRONTEND_TEST\" 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" @@ -9107,6 +17359,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 @@ -9152,19 +17405,19 @@ (unset CDPATH) >/dev/null 2>&1 && unset CDPATH -# as_fn_error ERROR [LINENO LOG_FD] -# --------------------------------- +# as_fn_error STATUS ERROR [LINENO LOG_FD] +# ---------------------------------------- # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are # provided, also output the error to LOG_FD, referencing LINENO. Then exit the -# script with status $?, using 1 if that was 0. +# script with STATUS, using 1 if that was 0. as_fn_error () { - as_status=$?; test $as_status -eq 0 && as_status=1 - if test "$3"; then - as_lineno=${as_lineno-"$2"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - $as_echo "$as_me:${as_lineno-$LINENO}: error: $1" >&$3 + as_status=$1; test $as_status -eq 0 && as_status=1 + if test "$4"; then + as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 fi - $as_echo "$as_me: error: $1" >&2 + $as_echo "$as_me: error: $2" >&2 as_fn_exit $as_status } # as_fn_error @@ -9360,7 +17613,7 @@ test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" - } || test -d "$as_dir" || as_fn_error "cannot create directory $as_dir" + } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" } # as_fn_mkdir_p @@ -9413,8 +17666,8 @@ # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by smuxi $as_me 0.8, which was -generated by GNU Autoconf 2.65. Invocation command line was +This file was extended by smuxi $as_me 0.8.9.1, which was +generated by GNU Autoconf 2.68. Invocation command line was CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS @@ -9470,11 +17723,11 @@ cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -smuxi config.status 0.8 -configured by $0, generated by GNU Autoconf 2.65, +smuxi config.status 0.8.9.1 +configured by $0, generated by GNU Autoconf 2.68, with options \\"\$ac_cs_config\\" -Copyright (C) 2009 Free Software Foundation, Inc. +Copyright (C) 2010 Free Software Foundation, Inc. This config.status script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it." @@ -9492,11 +17745,16 @@ while test $# != 0 do case $1 in - --*=*) + --*=?*) ac_option=`expr "X$1" : 'X\([^=]*\)='` ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` ac_shift=: ;; + --*=) + ac_option=`expr "X$1" : 'X\([^=]*\)='` + ac_optarg= + ac_shift=: + ;; *) ac_option=$1 ac_optarg=$2 @@ -9518,6 +17776,7 @@ $ac_shift case $ac_optarg in *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; + '') as_fn_error $? "missing file argument" ;; esac as_fn_append CONFIG_FILES " '$ac_optarg'" ac_need_defaults=false;; @@ -9528,7 +17787,7 @@ ac_cs_silent=: ;; # This is an error. - -*) as_fn_error "unrecognized option: \`$1' + -*) as_fn_error $? "unrecognized option: \`$1' Try \`$0 --help' for more information." ;; *) as_fn_append ac_config_targets " $1" @@ -9573,6 +17832,283 @@ # INIT-COMMANDS # AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir" + + +# The HP-UX ksh and POSIX shell print the target directory to stdout +# if CDPATH is set. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + +sed_quote_subst='$sed_quote_subst' +double_quote_subst='$double_quote_subst' +delay_variable_subst='$delay_variable_subst' +enable_static='`$ECHO "$enable_static" | $SED "$delay_single_quote_subst"`' +macro_version='`$ECHO "$macro_version" | $SED "$delay_single_quote_subst"`' +macro_revision='`$ECHO "$macro_revision" | $SED "$delay_single_quote_subst"`' +enable_shared='`$ECHO "$enable_shared" | $SED "$delay_single_quote_subst"`' +pic_mode='`$ECHO "$pic_mode" | $SED "$delay_single_quote_subst"`' +enable_fast_install='`$ECHO "$enable_fast_install" | $SED "$delay_single_quote_subst"`' +SHELL='`$ECHO "$SHELL" | $SED "$delay_single_quote_subst"`' +ECHO='`$ECHO "$ECHO" | $SED "$delay_single_quote_subst"`' +PATH_SEPARATOR='`$ECHO "$PATH_SEPARATOR" | $SED "$delay_single_quote_subst"`' +host_alias='`$ECHO "$host_alias" | $SED "$delay_single_quote_subst"`' +host='`$ECHO "$host" | $SED "$delay_single_quote_subst"`' +host_os='`$ECHO "$host_os" | $SED "$delay_single_quote_subst"`' +build_alias='`$ECHO "$build_alias" | $SED "$delay_single_quote_subst"`' +build='`$ECHO "$build" | $SED "$delay_single_quote_subst"`' +build_os='`$ECHO "$build_os" | $SED "$delay_single_quote_subst"`' +SED='`$ECHO "$SED" | $SED "$delay_single_quote_subst"`' +Xsed='`$ECHO "$Xsed" | $SED "$delay_single_quote_subst"`' +GREP='`$ECHO "$GREP" | $SED "$delay_single_quote_subst"`' +EGREP='`$ECHO "$EGREP" | $SED "$delay_single_quote_subst"`' +FGREP='`$ECHO "$FGREP" | $SED "$delay_single_quote_subst"`' +LD='`$ECHO "$LD" | $SED "$delay_single_quote_subst"`' +NM='`$ECHO "$NM" | $SED "$delay_single_quote_subst"`' +LN_S='`$ECHO "$LN_S" | $SED "$delay_single_quote_subst"`' +max_cmd_len='`$ECHO "$max_cmd_len" | $SED "$delay_single_quote_subst"`' +ac_objext='`$ECHO "$ac_objext" | $SED "$delay_single_quote_subst"`' +exeext='`$ECHO "$exeext" | $SED "$delay_single_quote_subst"`' +lt_unset='`$ECHO "$lt_unset" | $SED "$delay_single_quote_subst"`' +lt_SP2NL='`$ECHO "$lt_SP2NL" | $SED "$delay_single_quote_subst"`' +lt_NL2SP='`$ECHO "$lt_NL2SP" | $SED "$delay_single_quote_subst"`' +lt_cv_to_host_file_cmd='`$ECHO "$lt_cv_to_host_file_cmd" | $SED "$delay_single_quote_subst"`' +lt_cv_to_tool_file_cmd='`$ECHO "$lt_cv_to_tool_file_cmd" | $SED "$delay_single_quote_subst"`' +reload_flag='`$ECHO "$reload_flag" | $SED "$delay_single_quote_subst"`' +reload_cmds='`$ECHO "$reload_cmds" | $SED "$delay_single_quote_subst"`' +OBJDUMP='`$ECHO "$OBJDUMP" | $SED "$delay_single_quote_subst"`' +deplibs_check_method='`$ECHO "$deplibs_check_method" | $SED "$delay_single_quote_subst"`' +file_magic_cmd='`$ECHO "$file_magic_cmd" | $SED "$delay_single_quote_subst"`' +file_magic_glob='`$ECHO "$file_magic_glob" | $SED "$delay_single_quote_subst"`' +want_nocaseglob='`$ECHO "$want_nocaseglob" | $SED "$delay_single_quote_subst"`' +DLLTOOL='`$ECHO "$DLLTOOL" | $SED "$delay_single_quote_subst"`' +sharedlib_from_linklib_cmd='`$ECHO "$sharedlib_from_linklib_cmd" | $SED "$delay_single_quote_subst"`' +AR='`$ECHO "$AR" | $SED "$delay_single_quote_subst"`' +AR_FLAGS='`$ECHO "$AR_FLAGS" | $SED "$delay_single_quote_subst"`' +archiver_list_spec='`$ECHO "$archiver_list_spec" | $SED "$delay_single_quote_subst"`' +STRIP='`$ECHO "$STRIP" | $SED "$delay_single_quote_subst"`' +RANLIB='`$ECHO "$RANLIB" | $SED "$delay_single_quote_subst"`' +old_postinstall_cmds='`$ECHO "$old_postinstall_cmds" | $SED "$delay_single_quote_subst"`' +old_postuninstall_cmds='`$ECHO "$old_postuninstall_cmds" | $SED "$delay_single_quote_subst"`' +old_archive_cmds='`$ECHO "$old_archive_cmds" | $SED "$delay_single_quote_subst"`' +lock_old_archive_extraction='`$ECHO "$lock_old_archive_extraction" | $SED "$delay_single_quote_subst"`' +CC='`$ECHO "$CC" | $SED "$delay_single_quote_subst"`' +CFLAGS='`$ECHO "$CFLAGS" | $SED "$delay_single_quote_subst"`' +compiler='`$ECHO "$compiler" | $SED "$delay_single_quote_subst"`' +GCC='`$ECHO "$GCC" | $SED "$delay_single_quote_subst"`' +lt_cv_sys_global_symbol_pipe='`$ECHO "$lt_cv_sys_global_symbol_pipe" | $SED "$delay_single_quote_subst"`' +lt_cv_sys_global_symbol_to_cdecl='`$ECHO "$lt_cv_sys_global_symbol_to_cdecl" | $SED "$delay_single_quote_subst"`' +lt_cv_sys_global_symbol_to_c_name_address='`$ECHO "$lt_cv_sys_global_symbol_to_c_name_address" | $SED "$delay_single_quote_subst"`' +lt_cv_sys_global_symbol_to_c_name_address_lib_prefix='`$ECHO "$lt_cv_sys_global_symbol_to_c_name_address_lib_prefix" | $SED "$delay_single_quote_subst"`' +nm_file_list_spec='`$ECHO "$nm_file_list_spec" | $SED "$delay_single_quote_subst"`' +lt_sysroot='`$ECHO "$lt_sysroot" | $SED "$delay_single_quote_subst"`' +objdir='`$ECHO "$objdir" | $SED "$delay_single_quote_subst"`' +MAGIC_CMD='`$ECHO "$MAGIC_CMD" | $SED "$delay_single_quote_subst"`' +lt_prog_compiler_no_builtin_flag='`$ECHO "$lt_prog_compiler_no_builtin_flag" | $SED "$delay_single_quote_subst"`' +lt_prog_compiler_pic='`$ECHO "$lt_prog_compiler_pic" | $SED "$delay_single_quote_subst"`' +lt_prog_compiler_wl='`$ECHO "$lt_prog_compiler_wl" | $SED "$delay_single_quote_subst"`' +lt_prog_compiler_static='`$ECHO "$lt_prog_compiler_static" | $SED "$delay_single_quote_subst"`' +lt_cv_prog_compiler_c_o='`$ECHO "$lt_cv_prog_compiler_c_o" | $SED "$delay_single_quote_subst"`' +need_locks='`$ECHO "$need_locks" | $SED "$delay_single_quote_subst"`' +MANIFEST_TOOL='`$ECHO "$MANIFEST_TOOL" | $SED "$delay_single_quote_subst"`' +DSYMUTIL='`$ECHO "$DSYMUTIL" | $SED "$delay_single_quote_subst"`' +NMEDIT='`$ECHO "$NMEDIT" | $SED "$delay_single_quote_subst"`' +LIPO='`$ECHO "$LIPO" | $SED "$delay_single_quote_subst"`' +OTOOL='`$ECHO "$OTOOL" | $SED "$delay_single_quote_subst"`' +OTOOL64='`$ECHO "$OTOOL64" | $SED "$delay_single_quote_subst"`' +libext='`$ECHO "$libext" | $SED "$delay_single_quote_subst"`' +shrext_cmds='`$ECHO "$shrext_cmds" | $SED "$delay_single_quote_subst"`' +extract_expsyms_cmds='`$ECHO "$extract_expsyms_cmds" | $SED "$delay_single_quote_subst"`' +archive_cmds_need_lc='`$ECHO "$archive_cmds_need_lc" | $SED "$delay_single_quote_subst"`' +enable_shared_with_static_runtimes='`$ECHO "$enable_shared_with_static_runtimes" | $SED "$delay_single_quote_subst"`' +export_dynamic_flag_spec='`$ECHO "$export_dynamic_flag_spec" | $SED "$delay_single_quote_subst"`' +whole_archive_flag_spec='`$ECHO "$whole_archive_flag_spec" | $SED "$delay_single_quote_subst"`' +compiler_needs_object='`$ECHO "$compiler_needs_object" | $SED "$delay_single_quote_subst"`' +old_archive_from_new_cmds='`$ECHO "$old_archive_from_new_cmds" | $SED "$delay_single_quote_subst"`' +old_archive_from_expsyms_cmds='`$ECHO "$old_archive_from_expsyms_cmds" | $SED "$delay_single_quote_subst"`' +archive_cmds='`$ECHO "$archive_cmds" | $SED "$delay_single_quote_subst"`' +archive_expsym_cmds='`$ECHO "$archive_expsym_cmds" | $SED "$delay_single_quote_subst"`' +module_cmds='`$ECHO "$module_cmds" | $SED "$delay_single_quote_subst"`' +module_expsym_cmds='`$ECHO "$module_expsym_cmds" | $SED "$delay_single_quote_subst"`' +with_gnu_ld='`$ECHO "$with_gnu_ld" | $SED "$delay_single_quote_subst"`' +allow_undefined_flag='`$ECHO "$allow_undefined_flag" | $SED "$delay_single_quote_subst"`' +no_undefined_flag='`$ECHO "$no_undefined_flag" | $SED "$delay_single_quote_subst"`' +hardcode_libdir_flag_spec='`$ECHO "$hardcode_libdir_flag_spec" | $SED "$delay_single_quote_subst"`' +hardcode_libdir_separator='`$ECHO "$hardcode_libdir_separator" | $SED "$delay_single_quote_subst"`' +hardcode_direct='`$ECHO "$hardcode_direct" | $SED "$delay_single_quote_subst"`' +hardcode_direct_absolute='`$ECHO "$hardcode_direct_absolute" | $SED "$delay_single_quote_subst"`' +hardcode_minus_L='`$ECHO "$hardcode_minus_L" | $SED "$delay_single_quote_subst"`' +hardcode_shlibpath_var='`$ECHO "$hardcode_shlibpath_var" | $SED "$delay_single_quote_subst"`' +hardcode_automatic='`$ECHO "$hardcode_automatic" | $SED "$delay_single_quote_subst"`' +inherit_rpath='`$ECHO "$inherit_rpath" | $SED "$delay_single_quote_subst"`' +link_all_deplibs='`$ECHO "$link_all_deplibs" | $SED "$delay_single_quote_subst"`' +always_export_symbols='`$ECHO "$always_export_symbols" | $SED "$delay_single_quote_subst"`' +export_symbols_cmds='`$ECHO "$export_symbols_cmds" | $SED "$delay_single_quote_subst"`' +exclude_expsyms='`$ECHO "$exclude_expsyms" | $SED "$delay_single_quote_subst"`' +include_expsyms='`$ECHO "$include_expsyms" | $SED "$delay_single_quote_subst"`' +prelink_cmds='`$ECHO "$prelink_cmds" | $SED "$delay_single_quote_subst"`' +postlink_cmds='`$ECHO "$postlink_cmds" | $SED "$delay_single_quote_subst"`' +file_list_spec='`$ECHO "$file_list_spec" | $SED "$delay_single_quote_subst"`' +variables_saved_for_relink='`$ECHO "$variables_saved_for_relink" | $SED "$delay_single_quote_subst"`' +need_lib_prefix='`$ECHO "$need_lib_prefix" | $SED "$delay_single_quote_subst"`' +need_version='`$ECHO "$need_version" | $SED "$delay_single_quote_subst"`' +version_type='`$ECHO "$version_type" | $SED "$delay_single_quote_subst"`' +runpath_var='`$ECHO "$runpath_var" | $SED "$delay_single_quote_subst"`' +shlibpath_var='`$ECHO "$shlibpath_var" | $SED "$delay_single_quote_subst"`' +shlibpath_overrides_runpath='`$ECHO "$shlibpath_overrides_runpath" | $SED "$delay_single_quote_subst"`' +libname_spec='`$ECHO "$libname_spec" | $SED "$delay_single_quote_subst"`' +library_names_spec='`$ECHO "$library_names_spec" | $SED "$delay_single_quote_subst"`' +soname_spec='`$ECHO "$soname_spec" | $SED "$delay_single_quote_subst"`' +install_override_mode='`$ECHO "$install_override_mode" | $SED "$delay_single_quote_subst"`' +postinstall_cmds='`$ECHO "$postinstall_cmds" | $SED "$delay_single_quote_subst"`' +postuninstall_cmds='`$ECHO "$postuninstall_cmds" | $SED "$delay_single_quote_subst"`' +finish_cmds='`$ECHO "$finish_cmds" | $SED "$delay_single_quote_subst"`' +finish_eval='`$ECHO "$finish_eval" | $SED "$delay_single_quote_subst"`' +hardcode_into_libs='`$ECHO "$hardcode_into_libs" | $SED "$delay_single_quote_subst"`' +sys_lib_search_path_spec='`$ECHO "$sys_lib_search_path_spec" | $SED "$delay_single_quote_subst"`' +sys_lib_dlsearch_path_spec='`$ECHO "$sys_lib_dlsearch_path_spec" | $SED "$delay_single_quote_subst"`' +hardcode_action='`$ECHO "$hardcode_action" | $SED "$delay_single_quote_subst"`' +enable_dlopen='`$ECHO "$enable_dlopen" | $SED "$delay_single_quote_subst"`' +enable_dlopen_self='`$ECHO "$enable_dlopen_self" | $SED "$delay_single_quote_subst"`' +enable_dlopen_self_static='`$ECHO "$enable_dlopen_self_static" | $SED "$delay_single_quote_subst"`' +old_striplib='`$ECHO "$old_striplib" | $SED "$delay_single_quote_subst"`' +striplib='`$ECHO "$striplib" | $SED "$delay_single_quote_subst"`' + +LTCC='$LTCC' +LTCFLAGS='$LTCFLAGS' +compiler='$compiler_DEFAULT' + +# A function that is used when there is no print builtin or printf. +func_fallback_echo () +{ + eval 'cat <<_LTECHO_EOF +\$1 +_LTECHO_EOF' +} + +# Quote evaled strings. +for var in SHELL \ +ECHO \ +PATH_SEPARATOR \ +SED \ +GREP \ +EGREP \ +FGREP \ +LD \ +NM \ +LN_S \ +lt_SP2NL \ +lt_NL2SP \ +reload_flag \ +OBJDUMP \ +deplibs_check_method \ +file_magic_cmd \ +file_magic_glob \ +want_nocaseglob \ +DLLTOOL \ +sharedlib_from_linklib_cmd \ +AR \ +AR_FLAGS \ +archiver_list_spec \ +STRIP \ +RANLIB \ +CC \ +CFLAGS \ +compiler \ +lt_cv_sys_global_symbol_pipe \ +lt_cv_sys_global_symbol_to_cdecl \ +lt_cv_sys_global_symbol_to_c_name_address \ +lt_cv_sys_global_symbol_to_c_name_address_lib_prefix \ +nm_file_list_spec \ +lt_prog_compiler_no_builtin_flag \ +lt_prog_compiler_pic \ +lt_prog_compiler_wl \ +lt_prog_compiler_static \ +lt_cv_prog_compiler_c_o \ +need_locks \ +MANIFEST_TOOL \ +DSYMUTIL \ +NMEDIT \ +LIPO \ +OTOOL \ +OTOOL64 \ +shrext_cmds \ +export_dynamic_flag_spec \ +whole_archive_flag_spec \ +compiler_needs_object \ +with_gnu_ld \ +allow_undefined_flag \ +no_undefined_flag \ +hardcode_libdir_flag_spec \ +hardcode_libdir_separator \ +exclude_expsyms \ +include_expsyms \ +file_list_spec \ +variables_saved_for_relink \ +libname_spec \ +library_names_spec \ +soname_spec \ +install_override_mode \ +finish_eval \ +old_striplib \ +striplib; do + case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in + *[\\\\\\\`\\"\\\$]*) + eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED \\"\\\$sed_quote_subst\\"\\\`\\\\\\"" + ;; + *) + eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" + ;; + esac +done + +# Double-quote double-evaled strings. +for var in reload_cmds \ +old_postinstall_cmds \ +old_postuninstall_cmds \ +old_archive_cmds \ +extract_expsyms_cmds \ +old_archive_from_new_cmds \ +old_archive_from_expsyms_cmds \ +archive_cmds \ +archive_expsym_cmds \ +module_cmds \ +module_expsym_cmds \ +export_symbols_cmds \ +prelink_cmds \ +postlink_cmds \ +postinstall_cmds \ +postuninstall_cmds \ +finish_cmds \ +sys_lib_search_path_spec \ +sys_lib_dlsearch_path_spec; do + case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in + *[\\\\\\\`\\"\\\$]*) + eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\"" + ;; + *) + eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" + ;; + esac +done + +ac_aux_dir='$ac_aux_dir' +xsi_shell='$xsi_shell' +lt_shell_append='$lt_shell_append' + +# See if we are running on zsh, and set the options which allow our +# commands through without removal of \ escapes INIT. +if test -n "\${ZSH_VERSION+set}" ; then + setopt NO_GLOB_SUBST +fi + + + PACKAGE='$PACKAGE' + VERSION='$VERSION' + TIMESTAMP='$TIMESTAMP' + RM='$RM' + ofile='$ofile' + + + # Capture the value of obsolete ALL_LINGUAS because we need it to compute # POFILES, UPDATEPOFILES, DUMMYPOFILES, GMOFILES, CATALOGS. But hide it # from automake < 1.5. @@ -9590,6 +18126,7 @@ do case $ac_config_target in "depfiles") CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;; + "libtool") CONFIG_COMMANDS="$CONFIG_COMMANDS libtool" ;; "po-directories") CONFIG_COMMANDS="$CONFIG_COMMANDS po-directories" ;; "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; "src/Makefile") CONFIG_FILES="$CONFIG_FILES src/Makefile" ;; @@ -9621,11 +18158,13 @@ "src/Frontend-Curses/smuxi-frontend-curses") CONFIG_FILES="$CONFIG_FILES src/Frontend-Curses/smuxi-frontend-curses" ;; "src/Frontend-STFL/Makefile") CONFIG_FILES="$CONFIG_FILES src/Frontend-STFL/Makefile" ;; "src/Frontend-STFL/smuxi-frontend-stfl") CONFIG_FILES="$CONFIG_FILES src/Frontend-STFL/smuxi-frontend-stfl" ;; + "src/Frontend-STFL/STFL/Makefile") CONFIG_FILES="$CONFIG_FILES src/Frontend-STFL/STFL/Makefile" ;; "src/Frontend-SWF/Makefile") CONFIG_FILES="$CONFIG_FILES src/Frontend-SWF/Makefile" ;; "src/Frontend-SWF/smuxi-frontend-swf") CONFIG_FILES="$CONFIG_FILES src/Frontend-SWF/smuxi-frontend-swf" ;; "src/Frontend-Test/Makefile") CONFIG_FILES="$CONFIG_FILES src/Frontend-Test/Makefile" ;; "src/Frontend-Test/smuxi-frontend-test") CONFIG_FILES="$CONFIG_FILES src/Frontend-Test/smuxi-frontend-test" ;; "lib/Makefile") CONFIG_FILES="$CONFIG_FILES lib/Makefile" ;; + "lib/osx/Info.plist") CONFIG_FILES="$CONFIG_FILES lib/osx/Info.plist" ;; "po/Makefile.in") CONFIG_FILES="$CONFIG_FILES po/Makefile.in" ;; "po-Engine/Makefile.in") CONFIG_FILES="$CONFIG_FILES po-Engine/Makefile.in" ;; "po-Engine-IRC/Makefile.in") CONFIG_FILES="$CONFIG_FILES po-Engine-IRC/Makefile.in" ;; @@ -9636,7 +18175,7 @@ "po-Frontend-GNOME-IRC/Makefile.in") CONFIG_FILES="$CONFIG_FILES po-Frontend-GNOME-IRC/Makefile.in" ;; "po/stamp-it") CONFIG_COMMANDS="$CONFIG_COMMANDS po/stamp-it" ;; - *) as_fn_error "invalid argument: \`$ac_config_target'" "$LINENO" 5;; + *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; esac done @@ -9658,9 +18197,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 } @@ -9668,12 +18208,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 +} || 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. @@ -9690,12 +18231,12 @@ fi ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' /dev/null` if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then - ac_cs_awk_cr='\r' + ac_cs_awk_cr='\\r' else ac_cs_awk_cr=$ac_cr fi -echo 'BEGIN {' >"$tmp/subs1.awk" && +echo 'BEGIN {' >"$ac_tmp/subs1.awk" && _ACEOF @@ -9704,18 +18245,18 @@ echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' && echo "_ACEOF" } >conf$$subs.sh || - as_fn_error "could not make $CONFIG_STATUS" "$LINENO" 5 -ac_delim_num=`echo "$ac_subst_vars" | grep -c '$'` + as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 +ac_delim_num=`echo "$ac_subst_vars" | grep -c '^'` ac_delim='%!_!# ' for ac_last_try in false false false false false :; do . ./conf$$subs.sh || - as_fn_error "could not make $CONFIG_STATUS" "$LINENO" 5 + as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X` if test $ac_delim_n = $ac_delim_num; then break elif $ac_last_try; then - as_fn_error "could not make $CONFIG_STATUS" "$LINENO" 5 + as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi @@ -9723,7 +18264,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 @@ -9771,7 +18312,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 = "" @@ -9803,21 +18344,29 @@ sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g" else cat -fi < "$tmp/subs1.awk" > "$tmp/subs.awk" \ - || as_fn_error "could not setup config files machinery" "$LINENO" 5 +fi < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \ + || as_fn_error $? "could not setup config files machinery" "$LINENO" 5 _ACEOF -# VPATH may cause trouble with some makes, so we remove $(srcdir), -# ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and +# VPATH may cause trouble with some makes, so we remove sole $(srcdir), +# ${srcdir} and @srcdir@ entries from VPATH if srcdir is ".", strip leading and # trailing colons and then remove the whole line if VPATH becomes empty # (actually we leave an empty line to preserve line numbers). if test "x$srcdir" = x.; then - ac_vpsub='/^[ ]*VPATH[ ]*=/{ -s/:*\$(srcdir):*/:/ -s/:*\${srcdir}:*/:/ -s/:*@srcdir@:*/:/ -s/^\([^=]*=[ ]*\):*/\1/ + ac_vpsub='/^[ ]*VPATH[ ]*=[ ]*/{ +h +s/// +s/^/:/ +s/[ ]*$/:/ +s/:\$(srcdir):/:/g +s/:\${srcdir}:/:/g +s/:@srcdir@:/:/g +s/^:*// s/:*$// +x +s/\(=[ ]*\).*/\1/ +G +s/\n// s/^[^=]*=[ ]*$// }' fi @@ -9835,7 +18384,7 @@ esac case $ac_mode$ac_tag in :[FHL]*:*);; - :L* | :C*:*) as_fn_error "invalid tag \`$ac_tag'" "$LINENO" 5;; + :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;; :[FH]-) ac_tag=-:-;; :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; esac @@ -9854,7 +18403,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 `:'. @@ -9863,7 +18412,7 @@ [\\/$]*) false;; *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; esac || - as_fn_error "cannot find input file: \`$ac_f'" "$LINENO" 5;; + as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;; esac case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac as_fn_append ac_file_inputs " '$ac_f'" @@ -9889,8 +18438,8 @@ esac case $ac_tag in - *:-:* | *:-) cat >"$tmp/stdin" \ - || as_fn_error "could not create $ac_file" "$LINENO" 5 ;; + *:-:* | *:-) cat >"$ac_tmp/stdin" \ + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; esac ;; esac @@ -10026,23 +18575,24 @@ 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 +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;} +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 + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; @@ -10148,6 +18698,636 @@ done } ;; + "libtool":C) + + # See if we are running on zsh, and set the options which allow our + # commands through without removal of \ escapes. + if test -n "${ZSH_VERSION+set}" ; then + setopt NO_GLOB_SUBST + fi + + cfgfile="${ofile}T" + trap "$RM \"$cfgfile\"; exit 1" 1 2 15 + $RM "$cfgfile" + + cat <<_LT_EOF >> "$cfgfile" +#! $SHELL + +# `$ECHO "$ofile" | sed 's%^.*/%%'` - Provide generalized library-building support services. +# Generated automatically by $as_me ($PACKAGE$TIMESTAMP) $VERSION +# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`: +# NOTE: Changes made to this file will be lost: look at ltmain.sh. +# +# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, +# 2006, 2007, 2008, 2009, 2010, 2011 Free Software +# Foundation, Inc. +# Written by Gordon Matzigkeit, 1996 +# +# This file is part of GNU Libtool. +# +# GNU Libtool is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of +# the License, or (at your option) any later version. +# +# As a special exception to the GNU General Public License, +# if you distribute this file as part of a program or library that +# is built using GNU Libtool, you may include this file under the +# same distribution terms that you use for the rest of that program. +# +# GNU Libtool is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNU Libtool; see the file COPYING. If not, a copy +# can be downloaded from http://www.gnu.org/licenses/gpl.html, or +# obtained by writing to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + + +# The names of the tagged configurations supported by this script. +available_tags="" + +# ### BEGIN LIBTOOL CONFIG + +# Whether or not to build static libraries. +build_old_libs=$enable_static + +# Which release of libtool.m4 was used? +macro_version=$macro_version +macro_revision=$macro_revision + +# Whether or not to build shared libraries. +build_libtool_libs=$enable_shared + +# What type of objects to build. +pic_mode=$pic_mode + +# Whether or not to optimize for fast installation. +fast_install=$enable_fast_install + +# Shell to use when invoking shell scripts. +SHELL=$lt_SHELL + +# An echo program that protects backslashes. +ECHO=$lt_ECHO + +# The PATH separator for the build system. +PATH_SEPARATOR=$lt_PATH_SEPARATOR + +# The host system. +host_alias=$host_alias +host=$host +host_os=$host_os + +# The build system. +build_alias=$build_alias +build=$build +build_os=$build_os + +# A sed program that does not truncate output. +SED=$lt_SED + +# Sed that helps us avoid accidentally triggering echo(1) options like -n. +Xsed="\$SED -e 1s/^X//" + +# A grep program that handles long lines. +GREP=$lt_GREP + +# An ERE matcher. +EGREP=$lt_EGREP + +# A literal string matcher. +FGREP=$lt_FGREP + +# A BSD- or MS-compatible name lister. +NM=$lt_NM + +# Whether we need soft or hard links. +LN_S=$lt_LN_S + +# What is the maximum length of a command? +max_cmd_len=$max_cmd_len + +# Object file suffix (normally "o"). +objext=$ac_objext + +# Executable file suffix (normally ""). +exeext=$exeext + +# whether the shell understands "unset". +lt_unset=$lt_unset + +# turn spaces into newlines. +SP2NL=$lt_lt_SP2NL + +# turn newlines into spaces. +NL2SP=$lt_lt_NL2SP + +# convert \$build file names to \$host format. +to_host_file_cmd=$lt_cv_to_host_file_cmd + +# convert \$build files to toolchain format. +to_tool_file_cmd=$lt_cv_to_tool_file_cmd + +# An object symbol dumper. +OBJDUMP=$lt_OBJDUMP + +# Method to check whether dependent libraries are shared objects. +deplibs_check_method=$lt_deplibs_check_method + +# Command to use when deplibs_check_method = "file_magic". +file_magic_cmd=$lt_file_magic_cmd + +# How to find potential files when deplibs_check_method = "file_magic". +file_magic_glob=$lt_file_magic_glob + +# Find potential files using nocaseglob when deplibs_check_method = "file_magic". +want_nocaseglob=$lt_want_nocaseglob + +# DLL creation program. +DLLTOOL=$lt_DLLTOOL + +# Command to associate shared and link libraries. +sharedlib_from_linklib_cmd=$lt_sharedlib_from_linklib_cmd + +# The archiver. +AR=$lt_AR + +# Flags to create an archive. +AR_FLAGS=$lt_AR_FLAGS + +# How to feed a file listing to the archiver. +archiver_list_spec=$lt_archiver_list_spec + +# A symbol stripping program. +STRIP=$lt_STRIP + +# Commands used to install an old-style archive. +RANLIB=$lt_RANLIB +old_postinstall_cmds=$lt_old_postinstall_cmds +old_postuninstall_cmds=$lt_old_postuninstall_cmds + +# Whether to use a lock for old archive extraction. +lock_old_archive_extraction=$lock_old_archive_extraction + +# A C compiler. +LTCC=$lt_CC + +# LTCC compiler flags. +LTCFLAGS=$lt_CFLAGS + +# Take the output of nm and produce a listing of raw symbols and C names. +global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe + +# Transform the output of nm in a proper C declaration. +global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl + +# Transform the output of nm in a C name address pair. +global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address + +# Transform the output of nm in a C name address pair when lib prefix is needed. +global_symbol_to_c_name_address_lib_prefix=$lt_lt_cv_sys_global_symbol_to_c_name_address_lib_prefix + +# Specify filename containing input files for \$NM. +nm_file_list_spec=$lt_nm_file_list_spec + +# The root where to search for dependent libraries,and in which our libraries should be installed. +lt_sysroot=$lt_sysroot + +# The name of the directory that contains temporary libtool files. +objdir=$objdir + +# Used to examine libraries when file_magic_cmd begins with "file". +MAGIC_CMD=$MAGIC_CMD + +# Must we lock files when doing compilation? +need_locks=$lt_need_locks + +# Manifest tool. +MANIFEST_TOOL=$lt_MANIFEST_TOOL + +# Tool to manipulate archived DWARF debug symbol files on Mac OS X. +DSYMUTIL=$lt_DSYMUTIL + +# Tool to change global to local symbols on Mac OS X. +NMEDIT=$lt_NMEDIT + +# Tool to manipulate fat objects and archives on Mac OS X. +LIPO=$lt_LIPO + +# ldd/readelf like tool for Mach-O binaries on Mac OS X. +OTOOL=$lt_OTOOL + +# ldd/readelf like tool for 64 bit Mach-O binaries on Mac OS X 10.4. +OTOOL64=$lt_OTOOL64 + +# Old archive suffix (normally "a"). +libext=$libext + +# Shared library suffix (normally ".so"). +shrext_cmds=$lt_shrext_cmds + +# The commands to extract the exported symbol list from a shared archive. +extract_expsyms_cmds=$lt_extract_expsyms_cmds + +# Variables whose values should be saved in libtool wrapper scripts and +# restored at link time. +variables_saved_for_relink=$lt_variables_saved_for_relink + +# Do we need the "lib" prefix for modules? +need_lib_prefix=$need_lib_prefix + +# Do we need a version for libraries? +need_version=$need_version + +# Library versioning type. +version_type=$version_type + +# Shared library runtime path variable. +runpath_var=$runpath_var + +# Shared library path variable. +shlibpath_var=$shlibpath_var + +# Is shlibpath searched before the hard-coded library search path? +shlibpath_overrides_runpath=$shlibpath_overrides_runpath + +# Format of library name prefix. +libname_spec=$lt_libname_spec + +# List of archive names. First name is the real one, the rest are links. +# The last name is the one that the linker finds with -lNAME +library_names_spec=$lt_library_names_spec + +# The coded name of the library, if different from the real name. +soname_spec=$lt_soname_spec + +# Permission mode override for installation of shared libraries. +install_override_mode=$lt_install_override_mode + +# Command to use after installation of a shared archive. +postinstall_cmds=$lt_postinstall_cmds + +# Command to use after uninstallation of a shared archive. +postuninstall_cmds=$lt_postuninstall_cmds + +# Commands used to finish a libtool library installation in a directory. +finish_cmds=$lt_finish_cmds + +# As "finish_cmds", except a single script fragment to be evaled but +# not shown. +finish_eval=$lt_finish_eval + +# Whether we should hardcode library paths into libraries. +hardcode_into_libs=$hardcode_into_libs + +# Compile-time system search path for libraries. +sys_lib_search_path_spec=$lt_sys_lib_search_path_spec + +# Run-time system search path for libraries. +sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec + +# Whether dlopen is supported. +dlopen_support=$enable_dlopen + +# Whether dlopen of programs is supported. +dlopen_self=$enable_dlopen_self + +# Whether dlopen of statically linked programs is supported. +dlopen_self_static=$enable_dlopen_self_static + +# Commands to strip libraries. +old_striplib=$lt_old_striplib +striplib=$lt_striplib + + +# The linker used to build libraries. +LD=$lt_LD + +# How to create reloadable object files. +reload_flag=$lt_reload_flag +reload_cmds=$lt_reload_cmds + +# Commands used to build an old-style archive. +old_archive_cmds=$lt_old_archive_cmds + +# A language specific compiler. +CC=$lt_compiler + +# Is the compiler the GNU compiler? +with_gcc=$GCC + +# Compiler flag to turn off builtin functions. +no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag + +# Additional compiler flags for building library objects. +pic_flag=$lt_lt_prog_compiler_pic + +# How to pass a linker flag through the compiler. +wl=$lt_lt_prog_compiler_wl + +# Compiler flag to prevent dynamic linking. +link_static_flag=$lt_lt_prog_compiler_static + +# Does compiler simultaneously support -c and -o options? +compiler_c_o=$lt_lt_cv_prog_compiler_c_o + +# Whether or not to add -lc for building shared libraries. +build_libtool_need_lc=$archive_cmds_need_lc + +# Whether or not to disallow shared libs when runtime libs are static. +allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes + +# Compiler flag to allow reflexive dlopens. +export_dynamic_flag_spec=$lt_export_dynamic_flag_spec + +# Compiler flag to generate shared objects directly from archives. +whole_archive_flag_spec=$lt_whole_archive_flag_spec + +# Whether the compiler copes with passing no objects directly. +compiler_needs_object=$lt_compiler_needs_object + +# Create an old-style archive from a shared archive. +old_archive_from_new_cmds=$lt_old_archive_from_new_cmds + +# Create a temporary old-style archive to link instead of a shared archive. +old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds + +# Commands used to build a shared archive. +archive_cmds=$lt_archive_cmds +archive_expsym_cmds=$lt_archive_expsym_cmds + +# Commands used to build a loadable module if different from building +# a shared archive. +module_cmds=$lt_module_cmds +module_expsym_cmds=$lt_module_expsym_cmds + +# Whether we are building with GNU ld or not. +with_gnu_ld=$lt_with_gnu_ld + +# Flag that allows shared libraries with undefined symbols to be built. +allow_undefined_flag=$lt_allow_undefined_flag + +# Flag that enforces no undefined symbols. +no_undefined_flag=$lt_no_undefined_flag + +# Flag to hardcode \$libdir into a binary during linking. +# This must work even if \$libdir does not exist +hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec + +# Whether we need a single "-rpath" flag with a separated argument. +hardcode_libdir_separator=$lt_hardcode_libdir_separator + +# Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes +# DIR into the resulting binary. +hardcode_direct=$hardcode_direct + +# Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes +# DIR into the resulting binary and the resulting library dependency is +# "absolute",i.e impossible to change by setting \${shlibpath_var} if the +# library is relocated. +hardcode_direct_absolute=$hardcode_direct_absolute + +# Set to "yes" if using the -LDIR flag during linking hardcodes DIR +# into the resulting binary. +hardcode_minus_L=$hardcode_minus_L + +# Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR +# into the resulting binary. +hardcode_shlibpath_var=$hardcode_shlibpath_var + +# Set to "yes" if building a shared library automatically hardcodes DIR +# into the library and all subsequent libraries and executables linked +# against it. +hardcode_automatic=$hardcode_automatic + +# Set to yes if linker adds runtime paths of dependent libraries +# to runtime path list. +inherit_rpath=$inherit_rpath + +# Whether libtool must link a program against all its dependency libraries. +link_all_deplibs=$link_all_deplibs + +# Set to "yes" if exported symbols are required. +always_export_symbols=$always_export_symbols + +# The commands to list exported symbols. +export_symbols_cmds=$lt_export_symbols_cmds + +# Symbols that should not be listed in the preloaded symbols. +exclude_expsyms=$lt_exclude_expsyms + +# Symbols that must always be exported. +include_expsyms=$lt_include_expsyms + +# Commands necessary for linking programs (against libraries) with templates. +prelink_cmds=$lt_prelink_cmds + +# Commands necessary for finishing linking programs. +postlink_cmds=$lt_postlink_cmds + +# Specify filename containing input files. +file_list_spec=$lt_file_list_spec + +# How to hardcode a shared library path into an executable. +hardcode_action=$hardcode_action + +# ### END LIBTOOL CONFIG + +_LT_EOF + + case $host_os in + aix3*) + cat <<\_LT_EOF >> "$cfgfile" +# AIX sometimes has problems with the GCC collect2 program. For some +# reason, if we set the COLLECT_NAMES environment variable, the problems +# vanish in a puff of smoke. +if test "X${COLLECT_NAMES+set}" != Xset; then + COLLECT_NAMES= + export COLLECT_NAMES +fi +_LT_EOF + ;; + esac + + +ltmain="$ac_aux_dir/ltmain.sh" + + + # We use sed instead of cat because bash on DJGPP gets confused if + # if finds mixed CR/LF and LF-only lines. Since sed operates in + # text mode, it properly converts lines to CR/LF. This bash problem + # is reportedly fixed, but why not run on old versions too? + sed '$q' "$ltmain" >> "$cfgfile" \ + || (rm -f "$cfgfile"; exit 1) + + if test x"$xsi_shell" = xyes; then + sed -e '/^func_dirname ()$/,/^} # func_dirname /c\ +func_dirname ()\ +{\ +\ case ${1} in\ +\ */*) func_dirname_result="${1%/*}${2}" ;;\ +\ * ) func_dirname_result="${3}" ;;\ +\ esac\ +} # Extended-shell func_dirname implementation' "$cfgfile" > $cfgfile.tmp \ + && mv -f "$cfgfile.tmp" "$cfgfile" \ + || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") +test 0 -eq $? || _lt_function_replace_fail=: + + + sed -e '/^func_basename ()$/,/^} # func_basename /c\ +func_basename ()\ +{\ +\ func_basename_result="${1##*/}"\ +} # Extended-shell func_basename implementation' "$cfgfile" > $cfgfile.tmp \ + && mv -f "$cfgfile.tmp" "$cfgfile" \ + || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") +test 0 -eq $? || _lt_function_replace_fail=: + + + sed -e '/^func_dirname_and_basename ()$/,/^} # func_dirname_and_basename /c\ +func_dirname_and_basename ()\ +{\ +\ case ${1} in\ +\ */*) func_dirname_result="${1%/*}${2}" ;;\ +\ * ) func_dirname_result="${3}" ;;\ +\ esac\ +\ func_basename_result="${1##*/}"\ +} # Extended-shell func_dirname_and_basename implementation' "$cfgfile" > $cfgfile.tmp \ + && mv -f "$cfgfile.tmp" "$cfgfile" \ + || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") +test 0 -eq $? || _lt_function_replace_fail=: + + + sed -e '/^func_stripname ()$/,/^} # func_stripname /c\ +func_stripname ()\ +{\ +\ # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are\ +\ # positional parameters, so assign one to ordinary parameter first.\ +\ func_stripname_result=${3}\ +\ func_stripname_result=${func_stripname_result#"${1}"}\ +\ func_stripname_result=${func_stripname_result%"${2}"}\ +} # Extended-shell func_stripname implementation' "$cfgfile" > $cfgfile.tmp \ + && mv -f "$cfgfile.tmp" "$cfgfile" \ + || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") +test 0 -eq $? || _lt_function_replace_fail=: + + + sed -e '/^func_split_long_opt ()$/,/^} # func_split_long_opt /c\ +func_split_long_opt ()\ +{\ +\ func_split_long_opt_name=${1%%=*}\ +\ func_split_long_opt_arg=${1#*=}\ +} # Extended-shell func_split_long_opt implementation' "$cfgfile" > $cfgfile.tmp \ + && mv -f "$cfgfile.tmp" "$cfgfile" \ + || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") +test 0 -eq $? || _lt_function_replace_fail=: + + + sed -e '/^func_split_short_opt ()$/,/^} # func_split_short_opt /c\ +func_split_short_opt ()\ +{\ +\ func_split_short_opt_arg=${1#??}\ +\ func_split_short_opt_name=${1%"$func_split_short_opt_arg"}\ +} # Extended-shell func_split_short_opt implementation' "$cfgfile" > $cfgfile.tmp \ + && mv -f "$cfgfile.tmp" "$cfgfile" \ + || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") +test 0 -eq $? || _lt_function_replace_fail=: + + + sed -e '/^func_lo2o ()$/,/^} # func_lo2o /c\ +func_lo2o ()\ +{\ +\ case ${1} in\ +\ *.lo) func_lo2o_result=${1%.lo}.${objext} ;;\ +\ *) func_lo2o_result=${1} ;;\ +\ esac\ +} # Extended-shell func_lo2o implementation' "$cfgfile" > $cfgfile.tmp \ + && mv -f "$cfgfile.tmp" "$cfgfile" \ + || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") +test 0 -eq $? || _lt_function_replace_fail=: + + + sed -e '/^func_xform ()$/,/^} # func_xform /c\ +func_xform ()\ +{\ + func_xform_result=${1%.*}.lo\ +} # Extended-shell func_xform implementation' "$cfgfile" > $cfgfile.tmp \ + && mv -f "$cfgfile.tmp" "$cfgfile" \ + || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") +test 0 -eq $? || _lt_function_replace_fail=: + + + sed -e '/^func_arith ()$/,/^} # func_arith /c\ +func_arith ()\ +{\ + func_arith_result=$(( $* ))\ +} # Extended-shell func_arith implementation' "$cfgfile" > $cfgfile.tmp \ + && mv -f "$cfgfile.tmp" "$cfgfile" \ + || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") +test 0 -eq $? || _lt_function_replace_fail=: + + + sed -e '/^func_len ()$/,/^} # func_len /c\ +func_len ()\ +{\ + func_len_result=${#1}\ +} # Extended-shell func_len implementation' "$cfgfile" > $cfgfile.tmp \ + && mv -f "$cfgfile.tmp" "$cfgfile" \ + || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") +test 0 -eq $? || _lt_function_replace_fail=: + +fi + +if test x"$lt_shell_append" = xyes; then + sed -e '/^func_append ()$/,/^} # func_append /c\ +func_append ()\ +{\ + eval "${1}+=\\${2}"\ +} # Extended-shell func_append implementation' "$cfgfile" > $cfgfile.tmp \ + && mv -f "$cfgfile.tmp" "$cfgfile" \ + || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") +test 0 -eq $? || _lt_function_replace_fail=: + + + sed -e '/^func_append_quoted ()$/,/^} # func_append_quoted /c\ +func_append_quoted ()\ +{\ +\ func_quote_for_eval "${2}"\ +\ eval "${1}+=\\\\ \\$func_quote_for_eval_result"\ +} # Extended-shell func_append_quoted implementation' "$cfgfile" > $cfgfile.tmp \ + && mv -f "$cfgfile.tmp" "$cfgfile" \ + || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") +test 0 -eq $? || _lt_function_replace_fail=: + + + # Save a `func_append' function call where possible by direct use of '+=' + sed -e 's%func_append \([a-zA-Z_]\{1,\}\) "%\1+="%g' $cfgfile > $cfgfile.tmp \ + && mv -f "$cfgfile.tmp" "$cfgfile" \ + || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") + test 0 -eq $? || _lt_function_replace_fail=: +else + # Save a `func_append' function call even when '+=' is not available + sed -e 's%func_append \([a-zA-Z_]\{1,\}\) "%\1="$\1%g' $cfgfile > $cfgfile.tmp \ + && mv -f "$cfgfile.tmp" "$cfgfile" \ + || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") + test 0 -eq $? || _lt_function_replace_fail=: +fi + +if test x"$_lt_function_replace_fail" = x":"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Unable to substitute extended shell functions in $ofile" >&5 +$as_echo "$as_me: WARNING: Unable to substitute extended shell functions in $ofile" >&2;} +fi + + + mv -f "$cfgfile" "$ofile" || + (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile") + chmod +x "$ofile" + + ;; "po-directories":C) for ac_file in $CONFIG_FILES; do # Support "outfile[:infile[:infile...]]" @@ -10263,7 +19443,7 @@ done ;; "po/stamp-it":C) if ! grep "^# INTLTOOL_MAKEFILE$" "po/Makefile.in" > /dev/null ; then - as_fn_error "po/Makefile.in.in was not created by intltoolize." "$LINENO" 5 + as_fn_error $? "po/Makefile.in.in was not created by intltoolize." "$LINENO" 5 fi rm -f "po/stamp-it" "po/stamp-it.tmp" "po/POTFILES" "po/Makefile.tmp" >"po/stamp-it.tmp" @@ -10291,7 +19471,7 @@ ac_clean_files=$ac_clean_files_save test $ac_write_fail = 0 || - as_fn_error "write failure creating $CONFIG_STATUS" "$LINENO" 5 + as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5 # configure is writing to config.log, and then calls config.status. @@ -10312,7 +19492,7 @@ exec 5>>config.log # Use ||, not &&, to avoid exiting from the if with $? = 1, which # would make configure fail if this is the last instruction. - $ac_cs_success || as_fn_exit $? + $ac_cs_success || as_fn_exit 1 fi # @@ -10453,7 +19633,7 @@ # The eval makes quoting arguments work. eval "\$SHELL \"\$ac_sub_configure\" $ac_sub_configure_args \ --cache-file=\"\$ac_sub_cache_file\" --srcdir=\"\$ac_srcdir\"" || - as_fn_error "$ac_sub_configure failed for $ac_dir" "$LINENO" 5 + as_fn_error $? "$ac_sub_configure failed for $ac_dir" "$LINENO" 5 fi cd "$ac_popdir" @@ -10465,14 +19645,21 @@ fi +if test "x$CLI_RUNTIME" = "x"; then + CLI_RUNTIME=default +fi + { $as_echo "$as_me:${as_lineno-$LINENO}: result: - Configuration summary for $PACKAGE_NAME ($VERSION) + Configuration summary for $PACKAGE_NAME $VERSION ($DIST_VERSION) * Installation prefix: $prefix * Build profile: $PROFILE + * Compiler: $CSC + * Target CLI runtime: $CLI_RUNTIME * Engines ------- + Core: (db4o: $WITH_DB4O) IRC: $ENABLE_ENGINE_IRC XMPP: $ENABLE_ENGINE_XMPP OSCAR: $ENABLE_ENGINE_OSCAR @@ -10484,6 +19671,7 @@ GNOME: $ENABLE_FRONTEND_GNOME (IRC: $ENABLE_FRONTEND_GNOME_IRC XMPP: $ENABLE_FRONTEND_GNOME_XMPP) + Messaging Menu: $WITH_INDICATE + Notifications: $WITH_NOTIFY + + D-Bus: $WITH_DBUS Ncurses: $ENABLE_FRONTEND_CURSES STFL: $ENABLE_FRONTEND_STFL SWF (WinForms): $ENABLE_FRONTEND_SWF @@ -10491,13 +19679,16 @@ Test: $ENABLE_FRONTEND_TEST " >&5 $as_echo " - Configuration summary for $PACKAGE_NAME ($VERSION) + Configuration summary for $PACKAGE_NAME $VERSION ($DIST_VERSION) * Installation prefix: $prefix * Build profile: $PROFILE + * Compiler: $CSC + * Target CLI runtime: $CLI_RUNTIME * Engines ------- + Core: (db4o: $WITH_DB4O) IRC: $ENABLE_ENGINE_IRC XMPP: $ENABLE_ENGINE_XMPP OSCAR: $ENABLE_ENGINE_OSCAR @@ -10509,6 +19700,7 @@ GNOME: $ENABLE_FRONTEND_GNOME (IRC: $ENABLE_FRONTEND_GNOME_IRC XMPP: $ENABLE_FRONTEND_GNOME_XMPP) + Messaging Menu: $WITH_INDICATE + Notifications: $WITH_NOTIFY + + D-Bus: $WITH_DBUS Ncurses: $ENABLE_FRONTEND_CURSES STFL: $ENABLE_FRONTEND_STFL SWF (WinForms): $ENABLE_FRONTEND_SWF diff -Nru smuxi-0.8/configure.ac smuxi-0.8.9.1/configure.ac --- smuxi-0.8/configure.ac 2010-09-02 19:00:45.000000000 +0000 +++ smuxi-0.8.9.1/configure.ac 2012-01-03 09:00:51.000000000 +0000 @@ -1,5 +1,5 @@ AC_PREREQ([2.54]) -AC_INIT([smuxi], [0.8], [http://www.smuxi.org/issues/new]) +AC_INIT([smuxi], [0.8.9.1], [http://www.smuxi.org/issues/new]) # using the --foreign option makes automake less strict about GNU policy AC_CONFIG_MACRO_DIR([.]) AM_INIT_AUTOMAKE([foreign tar-ustar]) @@ -12,6 +12,10 @@ AC_PROG_INSTALL +AC_DISABLE_STATIC +AC_PROG_LIBTOOL +#LT_INIT([disable-static]) + # I18N IT_PROG_INTLTOOL([0.25]) @@ -98,6 +102,34 @@ # doesn't support multiple po directories :( #AM_GLIB_GNU_GETTEXT +AC_ARG_WITH([vendor-package-version], + AC_HELP_STRING([--with-vendor-package-version="DISTRO_NAME PACKAGE_VERSION"], + [Set the distro name and package version, e.g. "Debian 0.8-1"]), + [], + with_vendor_package_version= +) +WITH_VENDOR_PACKAGE_VERSION=$with_vendor_package_version +if test "x$WITH_VENDOR_PACKAGE_VERSION" = "x"; then + AC_MSG_CHECKING([for git version]) + if git log --oneline 295b37c8ac4939829a3c7f9150943dba8fff07f0 > /dev/null 2>&1; then + GIT_BRANCH=$(git branch | grep '^\*' | cut -d ' ' -f 2) + GIT_COMMIT_HASH=$(git log --no-color --first-parent -n1 --pretty=format:%h) + DIST_VERSION=$GIT_BRANCH/$GIT_COMMIT_HASH + DEV_VERSION_SUFFIX="-dev" + AC_MSG_RESULT(yes) + else + DIST_VERSION=tarball + DEV_VERSION_SUFFIX= + AC_MSG_RESULT(no) + fi +else + DIST_VERSION=$WITH_VENDOR_PACKAGE_VERSION +fi +AC_SUBST([git_branch], "$GIT_BRANCH") +AC_SUBST([git_commit_hash], "$GIT_COMMIT_HASH") +AC_SUBST([DEV_VERSION_SUFFIX]) +AC_SUBST([dist_version], "$DIST_VERSION") + SHAMROCK_EXPAND_LIBDIR SHAMROCK_CHECK_MONO_MODULE(1.9.1) SHAMROCK_FIND_MONO_RUNTIME @@ -105,6 +137,7 @@ SHAMROCK_CHECK_MONO_2_0_GAC_ASSEMBLIES([ System System.Core + System.Xml System.Runtime.Remoting Mono.Posix ]) @@ -128,6 +161,7 @@ fi AC_SUBST(PROFILE) +AC_SUBST(CSC, "$MCS") CSC_FLAGS= if test "x$PROFILE" = "xdebug"; then AM_CONDITIONAL(ENABLE_DEBUG, true) @@ -135,9 +169,24 @@ else AM_CONDITIONAL(ENABLE_RELEASE, true) fi -AC_SUBST(CSC, "$MCS") AC_SUBST(CSC_FLAGS) +MCS_BASENAME=$(basename $MCS) +CLI_RUNTIME= +if test "$MCS_BASENAME" = "gmcs"; then + CLI_RUNTIME=2.0 +fi +if test "$MCS_BASENAME" = "dmcs"; then + CLI_RUNTIME=4.0 +fi +if test "$CLI_RUNTIME" = "2.0"; then + XBUILD_FLAGS="/toolsversion:3.5 /p:TargetFrameworkVersion=v3.5" +fi +if test "$CLI_RUNTIME" = "4.0"; then + XBUILD_FLAGS="/toolsversion:4.0 /p:TargetFrameworkVersion=v4.0" +fi +AC_SUBST(XBUILD_FLAGS) + # Required Libraries PKG_CHECK_MODULES([LOG4NET], [log4net]) @@ -156,6 +205,39 @@ PKG_CHECK_MODULES([NINI], [nini >= 1.1]) fi +AC_ARG_WITH([db4o], + AC_HELP_STRING([--with-db4o=auto|system|included], [Use system or included db4o @<:@default=auto@:>@]), + [], + with_db4o=auto +) +WITH_DB4O=$with_db4o +if test "x$WITH_DB4O" = "xauto"; then + PKG_CHECK_EXISTS([db4o >= 8.0], FOUND_DB4O=yes, FOUND_DB4O=no) + if test "x$FOUND_DB4O" = "xyes"; then + WITH_DB4O=system + else + WITH_DB4O=included + fi +fi +if test "x$WITH_DB4O" = "xsystem"; then + PKG_CHECK_MODULES([DB4O], [db4o >= 8.0]) + AM_CONDITIONAL([BUNDLE_DB4O], false) +fi +if test "x$WITH_DB4O" = "xincluded"; then + if test ! -d "$srcdir/lib/db4o-net/Db4objects.Db4o"; then + AC_MSG_ERROR([lib/db4o-net is empty!]) + fi + + AC_PATH_PROG(XBUILD, xbuild, no) + if test "x$XBUILD" = "xno"; then + AC_MSG_ERROR([You need to install xbuild]) + fi + + AM_CONDITIONAL([BUNDLE_DB4O], true) + #AC_SUBST([DB4O_FILES], "Db4objects.Db4o.dll Db4objects.Db4o.Instrumentation.dll Db4objects.Db4o.NativeQueries.dll") + AC_SUBST([DB4O_FILES], "Db4objects.Db4o.dll") +fi + # Optional Libraries AC_ARG_WITH([indicate], AC_HELP_STRING([--with-indicate], [Support Messaging Menu @<:@default=auto@:>@]), @@ -185,6 +267,36 @@ PKG_CHECK_MODULES([NOTIFY_SHARP], [notify-sharp]) fi +AC_ARG_WITH([dbus], + AC_HELP_STRING([--with-dbus], [Support D-Bus @<:@default=auto@:>@]), + [], + with_dbus=auto +) +WITH_DBUS=$with_dbus +PKG_CHECK_EXISTS([dbus-sharp-1.0], DBUS_SHARP_SUPPORT=yes, DBUS_SHARP_SUPPORT=no) +PKG_CHECK_EXISTS([ndesk-dbus-1.0], NDESK_DBUS_SUPPORT=yes, NDESK_DBUS_SUPPORT=no) +if test "x$WITH_DBUS" = "xauto"; then + if test "x$DBUS_SHARP_SUPPORT" = "xyes"; then + WITH_DBUS=$DBUS_SHARP_SUPPORT + else + WITH_DBUS=$NDESK_DBUS_SUPPORT + fi +fi +if test "x$WITH_DBUS" = "xyes"; then + if test "x$DBUS_SHARP_SUPPORT" = "xyes"; then + PKG_CHECK_MODULES([DBUS_SHARP], [dbus-sharp-1.0]) + PKG_CHECK_MODULES([DBUS_SHARP_GLIB], [dbus-sharp-glib-1.0]) + AC_SUBST([DBUS_LIBS], "$DBUS_SHARP_LIBS $DBUS_SHARP_GLIB_LIBS") + CSC_FLAGS+=" -define:IPC_DBUS -define:DBUS_SHARP" + else + # fallback to ndesk-dbus + PKG_CHECK_MODULES([NDESK_DBUS], [ndesk-dbus-1.0]) + PKG_CHECK_MODULES([NDESK_DBUS_GLIB], [ndesk-dbus-glib-1.0]) + AC_SUBST([DBUS_LIBS], "$NDESK_DBUS_LIBS $NDESK_DBUS_GLIB_LIBS") + CSC_FLAGS+=" -define:IPC_DBUS -define:NDESK_DBUS" + fi +fi + # Engines AC_ARG_ENABLE([engine-irc], AC_HELP_STRING([--enable-engine-irc], [Enable IRC protocol support (default yes)]), @@ -193,7 +305,7 @@ ) if test "x$ENABLE_ENGINE_IRC" != "xno"; then if test ! -f "$srcdir/lib/SmartIrc4net/configure.ac"; then - AC_MSG_ERROR([lib/SmartIrc4net not found]) + AC_MSG_ERROR([lib/SmartIrc4net is empty!]) fi ac_configure_args="$ac_configure_args --disable-pkg-config --disable-pkg-lib --disable-pkg-gac" AC_CONFIG_SUBDIRS([lib/SmartIrc4net]) @@ -218,18 +330,24 @@ AM_CONDITIONAL(ENABLE_ENGINE_OSCAR, test "x$ENABLE_ENGINE_OSCAR" = "xyes") AC_ARG_ENABLE([engine-xmpp], - AC_HELP_STRING([--enable-engine-xmpp], [Enable XMPP (Jabber) protocol support (default no)]), + AC_HELP_STRING([--enable-engine-xmpp], [Enable XMPP (Jabber) protocol support (default yes)]), ENABLE_ENGINE_XMPP=$enableval, - ENABLE_ENGINE_XMPP=no + ENABLE_ENGINE_XMPP=yes ) if test "x$ENABLE_ENGINE_XMPP" != "xno"; then - PKG_CHECK_MODULES([JABBER_NET], [jabber-net], XMPP_SUPPORT=yes, XMPP_SUPPORT=no) - AC_SUBST(JABBER_NET_LIBS) - if test "x$ENABLE_ENGINE_XMPP" = "xyes" -a "x$XMPP_SUPPORT" != "xyes"; then - AC_MSG_ERROR([jabber-net not found]) - else - ENABLE_ENGINE_XMPP=$XMPP_SUPPORT + AC_PATH_PROG(XBUILD, xbuild, no) + if test "x$XBUILD" = "xno"; then + AC_MSG_ERROR([You need to install xbuild for XMPP support]) fi + + if test ! -f "$srcdir/lib/jabber-net/2005-jabber-net.csproj"; then + AC_MSG_ERROR([lib/jabber-net is empty!]) + fi + SHAMROCK_CHECK_MONO_2_0_GAC_ASSEMBLIES([ + System + System.Drawing + System.Xml + ]) fi AM_CONDITIONAL(ENABLE_ENGINE_XMPP, test "x$ENABLE_ENGINE_XMPP" = "xyes") @@ -271,7 +389,7 @@ fi if test ! -f "$srcdir/lib/Newtonsoft.Json/Src/Newtonsoft.Json/Newtonsoft.Json.csproj"; then - AC_MSG_ERROR([lib/Newtonsoft.Json is empty! Used git submodule init; git submodule update?]) + AC_MSG_ERROR([lib/Newtonsoft.Json is empty!]) fi SHAMROCK_CHECK_MONO_2_0_GAC_ASSEMBLIES([ System @@ -284,7 +402,7 @@ ]) if test ! -f "$srcdir/lib/Twitterizer/Twitterizer2/Twitterizer2.csproj"; then - AC_MSG_ERROR([lib/Twitterizer is empty! Used git submodule init; git submodule update?]) + AC_MSG_ERROR([lib/Twitterizer is empty!]) fi SHAMROCK_CHECK_MONO_2_0_GAC_ASSEMBLIES([ System @@ -302,10 +420,16 @@ AC_ARG_WITH([twitter-api-key], AC_HELP_STRING([--with-twitter-api-key], [Specify custom Twitter API key]), [], - with_twitter_api_key="G0fxRfJqvcMPAuNat15YQ|j77MQDIuZJFa0CXehYzGPBZidF8DT3OXAi6sb5ucE" + with_twitter_api_key="60QV2qQx9cS7y1BJDbgAA|2VgD6qQKddsF5HYQ0TrRgs3tFTnCwDONBmRlTmG658" ) AC_SUBST([twitter_api_key], $with_twitter_api_key) +# Server +if $PKG_CONFIG 'mono >= 2.6'; then + SERVER_COMPILER_FLAGS+=" -platform:x86" +fi +AC_SUBST(SERVER_COMPILER_FLAGS) + # Frontends AC_ARG_ENABLE([frontend-gnome], AC_HELP_STRING([--enable-frontend-gnome], [Enable GNOME frontend (default yes)]), @@ -336,7 +460,9 @@ if test "x$WITH_NOTIFY" = "xyes"; then FRONTEND_GNOME_COMPILER_FLAGS+=" -define:NOTIFY_SHARP" fi - + if $PKG_CONFIG 'mono >= 2.6'; then + FRONTEND_GNOME_COMPILER_FLAGS+=" -platform:x86" + fi AC_SUBST(FRONTEND_GNOME_COMPILER_FLAGS) ENABLE_FRONTEND_GNOME_IRC=$ENABLE_ENGINE_IRC; @@ -352,9 +478,9 @@ ENABLE_FRONTEND_STFL=no ) if test "x$ENABLE_FRONTEND_STFL" != "xno"; then - # TODO: check deps - AC_MSG_ERROR([STFL frontend not supported (yet)]) + PKG_CHECK_MODULES([STFL], [stfl >= 0.21]) fi +AM_CONDITIONAL(ENABLE_STATIC_STFL, false) AM_CONDITIONAL(ENABLE_FRONTEND_STFL, test "x$ENABLE_FRONTEND_STFL" = "xyes") AC_ARG_ENABLE([frontend-curses], @@ -429,11 +555,13 @@ src/Frontend-Curses/smuxi-frontend-curses src/Frontend-STFL/Makefile src/Frontend-STFL/smuxi-frontend-stfl + src/Frontend-STFL/STFL/Makefile src/Frontend-SWF/Makefile src/Frontend-SWF/smuxi-frontend-swf src/Frontend-Test/Makefile src/Frontend-Test/smuxi-frontend-test lib/Makefile + lib/osx/Info.plist po/Makefile.in po-Engine/Makefile.in po-Engine-IRC/Makefile.in @@ -446,14 +574,21 @@ AC_OUTPUT +if test "x$CLI_RUNTIME" = "x"; then + CLI_RUNTIME=default +fi + AC_MSG_RESULT([ - Configuration summary for $PACKAGE_NAME ($VERSION) + Configuration summary for $PACKAGE_NAME $VERSION ($DIST_VERSION) * Installation prefix: $prefix * Build profile: $PROFILE + * Compiler: $CSC + * Target CLI runtime: $CLI_RUNTIME * Engines ------- + Core: (db4o: $WITH_DB4O) IRC: $ENABLE_ENGINE_IRC XMPP: $ENABLE_ENGINE_XMPP OSCAR: $ENABLE_ENGINE_OSCAR @@ -465,6 +600,7 @@ GNOME: $ENABLE_FRONTEND_GNOME (IRC: $ENABLE_FRONTEND_GNOME_IRC XMPP: $ENABLE_FRONTEND_GNOME_XMPP) + Messaging Menu: $WITH_INDICATE + Notifications: $WITH_NOTIFY + + D-Bus: $WITH_DBUS Ncurses: $ENABLE_FRONTEND_CURSES STFL: $ENABLE_FRONTEND_STFL SWF (WinForms): $ENABLE_FRONTEND_SWF diff -Nru smuxi-0.8/debian/changelog smuxi-0.8.9.1/debian/changelog --- smuxi-0.8/debian/changelog 2011-08-06 12:13:33.000000000 +0000 +++ smuxi-0.8.9.1/debian/changelog 2012-01-07 11:13:27.000000000 +0000 @@ -1,3 +1,36 @@ +smuxi (0.8.9.1-3) unstable; urgency=low + + * [7cd3a08] Ignore secur32(.dll) ModuleRef for dh_clideps + * [0055fc3] Added missing ncurses dllmap for smuxi-frontend-stfl.exe + + -- Mirco Bauer Sat, 07 Jan 2012 12:13:22 +0100 + +smuxi (0.8.9.1-2) unstable; urgency=low + + * [d3a922c] Added new Db4objects.Db4o library to smuxi-engine package + + -- Mirco Bauer Wed, 04 Jan 2012 08:22:07 +0100 + +smuxi (0.8.9.1-1) unstable; urgency=low + + * [7525843] Imported Upstream version 0.8.9.1 + * [b492feb] Install new application icons + + -- Mirco Bauer Tue, 03 Jan 2012 10:21:20 +0100 + +smuxi (0.8.9-1) unstable; urgency=low + + * [0d666d8] Imported Upstream version 0.8.9 + * [9ce1498] Dropped patches that are already applied upstream + * [1d7d863] Updated patches to build with the system default compiler + * [c0f6d11] Enabled and added STFL frontend packages + * [b992bc2] Enabled and added XMPP engine package + * [ad44b32] Added dbus-sharp to build-deps + * [cb1f671] Pass debian package version to configure script + * [88dd531] Added libstfl-dev to build-deps + + -- Mirco Bauer Tue, 03 Jan 2012 09:31:38 +0100 + smuxi (0.8-8) unstable; urgency=low * [9290dca] Fix startup crash in smuxi-frontend-gnome when no notification diff -Nru smuxi-0.8/debian/control smuxi-0.8.9.1/debian/control --- smuxi-0.8/debian/control 2011-08-06 12:13:33.000000000 +0000 +++ smuxi-0.8.9.1/debian/control 2012-01-07 11:13:27.000000000 +0000 @@ -16,6 +16,9 @@ libart2.0-cil-dev (>= 2.8), libnotify-cil-dev, libindicate0.1-cil-dev, + libdbus1.0-cil-dev, + libdbus-glib1.0-cil-dev, + libstfl-dev (>= 0.21), lsb-release, pkg-config, gettext, @@ -34,7 +37,8 @@ Suggests: smuxi-server Depends: ${misc:Depends}, smuxi-frontend-gnome-irc (= ${source:Version}), - smuxi-engine-twitter (= ${source:Version}) + smuxi-engine-twitter (= ${source:Version}), + smuxi-engine-xmpp (= ${source:Version}) Description: graphical IRC client Smuxi is an irssi-inspired, flexible, user-friendly and cross-platform IRC client for sophisticated users, targeting the GNOME desktop. @@ -56,7 +60,8 @@ Architecture: all Replaces: smuxi (<< 0.5.25) Recommends: smuxi-engine-irc, - smuxi-engine-twitter + smuxi-engine-twitter, + smuxi-engine-xmpp Depends: ${shlibs:Depends}, ${misc:Depends}, ${cli:Depends} @@ -124,6 +129,29 @@ to receive and post tweets to the Twitter microblogging service. It supports the friends timeline, replies view, and direct messages. +Package: smuxi-engine-xmpp +Architecture: all +Depends: ${shlibs:Depends}, + ${misc:Depends}, + ${cli:Depends}, + smuxi-engine (= ${source:Version}) +Description: XMPP / Jabber / GTalk / Facebook Chat engine for Smuxi + Smuxi is an irssi-inspired, flexible, user-friendly and cross-platform IRC + client for sophisticated users, targeting the GNOME desktop. + . + Smuxi is based on the client-server model: The core application (engine) can + be placed onto a server which is connected to the Internet around-the-clock; + one or more frontends then connect to the core. This way, the connection to + IRC can be kept up even when all frontends have been closed. The combination + of screen and irssi served as example for this architecture. + . + Smuxi also supports the regular single application mode. This behaves like a + typical IRC client; it doesn't need separate core management and utilizes a + local engine that is used by the local frontend client. + . + This package contains the XMPP engine for Smuxi. This plugin allows you + to receive and send messages on XMPP, Jabber, GTalk and the Facebook chat. + Package: smuxi-server Architecture: all Replaces: smuxi (<< 0.5.25) @@ -224,3 +252,32 @@ local engine that is used by the local frontend client. . This package contains enhanced IRC support for the GNOME frontend of Smuxi. + +Package: smuxi-frontend-stfl +Architecture: all +Depends: ${shlibs:Depends}, + ${misc:Depends}, + ${cli:Depends}, + smuxi-engine (= ${source:Version}), + smuxi-frontend (= ${source:Version}) +Description: STFL frontend for Smuxi (experimental) + Smuxi is an irssi-inspired, flexible, user-friendly and cross-platform IRC + client for sophisticated users, targeting the GNOME desktop. + . + Smuxi is based on the client-server model: The core application (engine) can + be placed onto a server which is connected to the Internet around-the-clock; + one or more frontends then connect to the core. This way, the connection to + IRC can be kept up even when all frontends have been closed. The combination + of screen and irssi served as example for this architecture. + . + Smuxi also supports the regular single application mode. This behaves like a + typical IRC client; it doesn't need separate core management and utilizes a + local engine that is used by the local frontend client. + . + This package contains the experimental STFL frontend of Smuxi, it can run + either standalone using a local engine or connect to a running + remote engine (server). + . + STFL is a library that uses ncurses to draw text based user interface using + a markup language (like Glade for GTK+). This frontend is in early alpha state + and lacks a lot of interface features and likes to crash. diff -Nru smuxi-0.8/debian/patches/build_db4o_with_default_compiler.patch smuxi-0.8.9.1/debian/patches/build_db4o_with_default_compiler.patch --- smuxi-0.8/debian/patches/build_db4o_with_default_compiler.patch 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/debian/patches/build_db4o_with_default_compiler.patch 2012-01-07 11:13:27.000000000 +0000 @@ -0,0 +1,30 @@ +Index: smuxi/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o-2008.csproj +=================================================================== +--- smuxi.orig/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o-2008.csproj 2011-12-21 11:11:59.000000000 +0100 ++++ smuxi/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o-2008.csproj 2011-12-21 16:14:48.000000000 +0100 +@@ -1,5 +1,5 @@ + +- ++ + + Debug + AnyCPU +@@ -10,7 +10,6 @@ + Properties + Db4objects.Db4o + Db4objects.Db4o +- v3.5 + 512 + + +@@ -61,9 +60,7 @@ + + + +- +- 3.5 +- ++ + + + diff -Nru smuxi-0.8/debian/patches/build_jabber-net_with_default_compiler.patch smuxi-0.8.9.1/debian/patches/build_jabber-net_with_default_compiler.patch --- smuxi-0.8/debian/patches/build_jabber-net_with_default_compiler.patch 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/debian/patches/build_jabber-net_with_default_compiler.patch 2012-01-07 11:13:27.000000000 +0000 @@ -0,0 +1,18 @@ +Index: smuxi/lib/jabber-net/2005-jabber-net.csproj +=================================================================== +--- smuxi.orig/lib/jabber-net/2005-jabber-net.csproj 2011-12-19 08:02:59.000000000 +0100 ++++ smuxi/lib/jabber-net/2005-jabber-net.csproj 2011-12-21 08:16:36.000000000 +0100 +@@ -1,4 +1,4 @@ +- ++ + + Local + 8.0.50727 +@@ -27,7 +27,6 @@ + + + true +- v3.5 + + + bin5\Debug\ diff -Nru smuxi-0.8/debian/patches/build_Twitterizer2_with_default_compiler.patch smuxi-0.8.9.1/debian/patches/build_Twitterizer2_with_default_compiler.patch --- smuxi-0.8/debian/patches/build_Twitterizer2_with_default_compiler.patch 2011-08-06 12:13:33.000000000 +0000 +++ smuxi-0.8.9.1/debian/patches/build_Twitterizer2_with_default_compiler.patch 2012-01-07 11:13:27.000000000 +0000 @@ -1,12 +1,19 @@ Index: smuxi/lib/Twitterizer/Twitterizer2/Twitterizer2.csproj =================================================================== ---- smuxi.orig/lib/Twitterizer/Twitterizer2/Twitterizer2.csproj 2011-06-26 03:02:29.000000000 +0200 -+++ smuxi/lib/Twitterizer/Twitterizer2/Twitterizer2.csproj 2011-06-26 03:02:29.000000000 +0200 -@@ -10,7 +10,6 @@ - Properties - Twitterizer - Twitterizer2 -- v3.5 - 512 - Twitterizer2.snk +--- smuxi.orig/lib/Twitterizer/Twitterizer2/Twitterizer2.csproj 2011-12-19 07:51:13.000000000 +0100 ++++ smuxi/lib/Twitterizer/Twitterizer2/Twitterizer2.csproj 2011-12-21 08:13:11.000000000 +0100 +@@ -1,5 +1,5 @@ +  +- ++ + + Debug + AnyCPU +@@ -15,7 +15,6 @@ + + 3.5 +- v3.5 + + false + diff -Nru smuxi-0.8/debian/patches/debian_default_settings.patch smuxi-0.8.9.1/debian/patches/debian_default_settings.patch --- smuxi-0.8/debian/patches/debian_default_settings.patch 2011-08-06 12:13:33.000000000 +0000 +++ smuxi-0.8.9.1/debian/patches/debian_default_settings.patch 2012-01-07 11:13:27.000000000 +0000 @@ -1,8 +1,8 @@ -Index: git/src/Engine/Config/Config.cs +Index: smuxi/src/Engine/Config/Config.cs =================================================================== ---- git.orig/src/Engine/Config/Config.cs 2011-03-20 16:24:08.000000000 +0100 -+++ git/src/Engine/Config/Config.cs 2011-03-20 16:24:22.000000000 +0100 -@@ -315,6 +315,7 @@ +--- smuxi.orig/src/Engine/Config/Config.cs 2012-01-03 09:06:46.000000000 +0100 ++++ smuxi/src/Engine/Config/Config.cs 2012-01-03 09:06:55.000000000 +0100 +@@ -323,6 +323,7 @@ Get(prefix + "OnConnectCommands", new string[] { "/join #smuxi", diff -Nru smuxi-0.8/debian/patches/disable_notifications_on_error.patch smuxi-0.8.9.1/debian/patches/disable_notifications_on_error.patch --- smuxi-0.8/debian/patches/disable_notifications_on_error.patch 2011-08-06 12:13:33.000000000 +0000 +++ smuxi-0.8.9.1/debian/patches/disable_notifications_on_error.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,38 +0,0 @@ -commit 3b9f8b94251dd256659135da73b52b1652e74e65 -Author: Mirco Bauer -Date: Tue Feb 8 01:07:19 2011 +0100 - - When NotifyManager.Init() fails don't enable notifications - -diff --git a/src/Frontend-GNOME/NotifyManager.cs b/src/Frontend-GNOME/NotifyManager.cs -index f88580c..7e1005b 100644 ---- a/src/Frontend-GNOME/NotifyManager.cs -+++ b/src/Frontend-GNOME/NotifyManager.cs -@@ -43,6 +43,7 @@ namespace Smuxi.Frontend.Gnome - MainWindow MainWindow { get; set; } - ChatViewManager ChatViewManager { get; set; } - Dictionary HighlightEventHandlers { get; set; } -+ bool IsInitialized { get; set; } - bool IsEnabled { get; set; } - - static NotifyManager() -@@ -110,6 +111,10 @@ namespace Smuxi.Frontend.Gnome - throw new ArgumentNullException("userConfig"); - } - -+ if (!IsInitialized) { -+ return; -+ } -+ - IsEnabled = (bool) userConfig["Interface/Notification/PopupsEnabled"]; - } - -@@ -161,6 +166,8 @@ namespace Smuxi.Frontend.Gnome - - ChatViewManager.ChatAdded += OnChatViewManagerChatAdded; - ChatViewManager.ChatRemoved += OnChatViewManagerChatRemoved; -+ -+ IsInitialized = true; - } - - void OnChatViewManagerChatAdded(object sender, ChatViewManagerChatAddedEventArgs e) diff -Nru smuxi-0.8/debian/patches/dont_sign_Twitterizer2.patch smuxi-0.8.9.1/debian/patches/dont_sign_Twitterizer2.patch --- smuxi-0.8/debian/patches/dont_sign_Twitterizer2.patch 2011-08-06 12:13:33.000000000 +0000 +++ smuxi-0.8.9.1/debian/patches/dont_sign_Twitterizer2.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -From: Mirco Bauer -Date: Sat, 9 Apr 2011 19:57:59 +0000 (+0200) -Subject: Don't sign the assembly -X-Git-Url: http://git.qnetp.net/?p=twitterizer.git;a=commitdiff_plain;h=55c0ad812d0b00cca17734523539c87556c83a85 - -Don't sign the assembly ---- - -diff --git a/lib/Twitterizer/Twitterizer2/Twitterizer2.csproj b/Twitterizer2/Twitterizer2.csproj -index c87d4d3..abc55f7 100644 ---- a/lib/Twitterizer/Twitterizer2/Twitterizer2.csproj -+++ b/lib/Twitterizer/Twitterizer2/Twitterizer2.csproj -@@ -12,7 +12,6 @@ - Twitterizer2 - v3.5 - 512 -- true - Twitterizer2.snk - - diff -Nru smuxi-0.8/debian/patches/fix_IndicateManager.Init_crash.patch smuxi-0.8.9.1/debian/patches/fix_IndicateManager.Init_crash.patch --- smuxi-0.8/debian/patches/fix_IndicateManager.Init_crash.patch 2011-08-06 12:13:33.000000000 +0000 +++ smuxi-0.8.9.1/debian/patches/fix_IndicateManager.Init_crash.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,69 +0,0 @@ -commit 32ef6782202d860aaa3116d876fb4303ea007482 -Author: Mirco Bauer -Date: Tue Feb 8 01:05:24 2011 +0100 - - Guard IndicateManager.Init() to avoid potential crashes - -Index: smuxi/src/Frontend-GNOME/IndicateManager.cs -=================================================================== ---- smuxi.orig/src/Frontend-GNOME/IndicateManager.cs 2011-05-18 01:56:18.000000000 +0200 -+++ smuxi/src/Frontend-GNOME/IndicateManager.cs 2011-08-05 21:51:54.000000000 +0200 -@@ -43,6 +43,8 @@ - ChatViewManager ChatViewManager { get; set; } - Dictionary Indicators { get; set; } - Dictionary HighlightEventHandlers { get; set; } -+ bool IsInitialized { get; set; } -+ bool IsEnabled { get; set; } - - static IndicateManager() - { -@@ -73,7 +75,13 @@ - (); - -- Init(); -+ try { -+ Init(); -+ } catch (Exception ex) { -+#if LOG4NET -+ Logger.Error("IndicateManager(): initialization failed: ", ex); -+#endif -+ } - } - - public void Dispose() -@@ -98,10 +106,16 @@ - throw new ArgumentNullException("userConfig"); - } - -+ if (!IsInitialized) { -+ return; -+ } -+ - if ((bool) userConfig["Interface/Notification/MessagingMenuEnabled"]) { - Server.Show(); -+ IsEnabled = true; - } else { - Server.Hide(); -+ IsEnabled = false; - } - } - -@@ -138,6 +152,8 @@ - - ChatViewManager.ChatAdded += OnChatViewManagerChatAdded; - ChatViewManager.ChatRemoved += OnChatViewManagerChatRemoved; -+ -+ IsInitialized = true; - } - - void OnMainWindowFocusInEvent(object sender, Gtk.FocusInEventArgs e) -@@ -200,7 +216,7 @@ - { - Trace.Call(sender, e, chatView); - -- if (MainWindow.HasToplevelFocus) { -+ if (MainWindow.HasToplevelFocus || !IsEnabled) { - return; - } - diff -Nru smuxi-0.8/debian/patches/fix_Notification.Close_crash.patch smuxi-0.8.9.1/debian/patches/fix_Notification.Close_crash.patch --- smuxi-0.8/debian/patches/fix_Notification.Close_crash.patch 2011-08-06 12:13:33.000000000 +0000 +++ smuxi-0.8.9.1/debian/patches/fix_Notification.Close_crash.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,42 +0,0 @@ -Index: git/src/Frontend-GNOME/NotifyManager.cs -=================================================================== ---- git.orig/src/Frontend-GNOME/NotifyManager.cs 2011-03-20 15:54:58.000000000 +0100 -+++ git/src/Frontend-GNOME/NotifyManager.cs 2011-03-20 16:00:32.000000000 +0100 -@@ -290,6 +290,10 @@ - - void DisposeNotification(ChatView chatView) - { -+ if (chatView == null) { -+ return; -+ } -+ - Notification notification; - if (!Notifications.TryGetValue(chatView, out notification)) { - return; -@@ -299,7 +303,25 @@ - chatView.Name); - #endif - -- notification.Close(); -+ try { -+ // don't try to close already closed notifications (timeout) -+ if (notification.Id == 0) { -+#if LOG4NET -+ Logger.Debug("DisposeNotification(): notification already " + -+ "closed for: " + chatView.Name); -+#endif -+ return; -+ } -+ -+ notification.Close(); -+ } catch (Exception ex) { -+#if LOG4NET -+ Logger.Error("DisposeNotification(): " + -+ "notification.Close() thew exception", ex); -+#endif -+ } finally { -+ Notifications.Remove(chatView); -+ } - } - - private static string _(string msg) diff -Nru smuxi-0.8/debian/patches/fix_NotifyManager.Init_crash.patch smuxi-0.8.9.1/debian/patches/fix_NotifyManager.Init_crash.patch --- smuxi-0.8/debian/patches/fix_NotifyManager.Init_crash.patch 2011-08-06 12:13:33.000000000 +0000 +++ smuxi-0.8.9.1/debian/patches/fix_NotifyManager.Init_crash.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -commit 89fdfbaacaaee09effc7648f24e9b18e5676be9b -Author: Mirco Bauer -Date: Mon Feb 7 17:41:37 2011 +0100 - - Guard NotifyManager.Init() method for D-Bus issues. (closes: #561) - -diff --git a/src/Frontend-GNOME/NotifyManager.cs b/src/Frontend-GNOME/NotifyManager.cs -index 4861ce6..f88580c 100644 ---- a/src/Frontend-GNOME/NotifyManager.cs -+++ b/src/Frontend-GNOME/NotifyManager.cs -@@ -88,7 +88,13 @@ namespace Smuxi.Frontend.Gnome - (); - -- Init(); -+ try { -+ Init(); -+ } catch (Exception ex) { -+#if LOG4NET -+ Logger.Error("NotifyManager(): initialization failed: ", ex); -+#endif -+ } - } - - public void Dispose() diff -Nru smuxi-0.8/debian/patches/fix_smuxi-frontend-stfl_dllmap.patch smuxi-0.8.9.1/debian/patches/fix_smuxi-frontend-stfl_dllmap.patch --- smuxi-0.8/debian/patches/fix_smuxi-frontend-stfl_dllmap.patch 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/debian/patches/fix_smuxi-frontend-stfl_dllmap.patch 2012-01-07 11:13:27.000000000 +0000 @@ -0,0 +1,10 @@ +Index: smuxi/src/Frontend-STFL/smuxi-frontend-stfl.exe.config +=================================================================== +--- smuxi.orig/src/Frontend-STFL/smuxi-frontend-stfl.exe.config 2012-01-03 10:33:15.000000000 +0100 ++++ smuxi/src/Frontend-STFL/smuxi-frontend-stfl.exe.config 2012-01-07 12:09:53.000000000 +0100 +@@ -20,4 +20,5 @@ + + + ++ + diff -Nru smuxi-0.8/debian/patches/mono_2.10_compile_fix.patch smuxi-0.8.9.1/debian/patches/mono_2.10_compile_fix.patch --- smuxi-0.8/debian/patches/mono_2.10_compile_fix.patch 2011-08-06 12:13:33.000000000 +0000 +++ smuxi-0.8.9.1/debian/patches/mono_2.10_compile_fix.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -From: Mirco Bauer -Date: Sat, 9 Apr 2011 20:02:56 +0000 (+0200) -Subject: Mono 2.10 compile fix -X-Git-Url: http://git.qnetp.net/?p=twitterizer.git;a=commitdiff_plain;h=745d44696b1200de12cf2de4ebec3097ccd4d544 - -Mono 2.10 compile fix ---- - -diff --git a/lib/Twitterizer/Twitterizer2/Methods/User/TwitterUserCollection.cs b/Twitterizer2/Methods/User/TwitterUserCollection.cs -index 522bccf..d73cfef 100644 ---- a/lib/Twitterizer/Twitterizer2/Methods/User/TwitterUserCollection.cs -+++ b/lib/Twitterizer/Twitterizer2/Methods/User/TwitterUserCollection.cs -@@ -59,7 +59,7 @@ namespace Twitterizer - /// Gets or sets information about the user's rate usage. - /// - /// The rate limiting object. -- public new RateLimiting RateLimiting { get; internal set; } -+ public new RateLimiting RateLimiting { get; set; } - - /// - /// Gets or sets the paged command. diff -Nru smuxi-0.8/debian/patches/series smuxi-0.8.9.1/debian/patches/series --- smuxi-0.8/debian/patches/series 2011-08-06 12:13:33.000000000 +0000 +++ smuxi-0.8.9.1/debian/patches/series 2012-01-07 11:13:27.000000000 +0000 @@ -1,9 +1,6 @@ -fix_Notification.Close_crash.patch -fix_NotifyManager.Init_crash.patch -disable_notifications_on_error.patch -fix_IndicateManager.Init_crash.patch -mono_2.10_compile_fix.patch -dont_sign_Twitterizer2.patch +fix_smuxi-frontend-stfl_dllmap.patch build_Newtonsoft.Json_with_default_compiler.patch build_Twitterizer2_with_default_compiler.patch +build_db4o_with_default_compiler.patch +build_jabber-net_with_default_compiler.patch debian_default_settings.patch diff -Nru smuxi-0.8/debian/patches/ubuntu.series smuxi-0.8.9.1/debian/patches/ubuntu.series --- smuxi-0.8/debian/patches/ubuntu.series 2011-08-06 12:13:33.000000000 +0000 +++ smuxi-0.8.9.1/debian/patches/ubuntu.series 2012-01-07 11:13:27.000000000 +0000 @@ -1,9 +1,6 @@ -fix_Notification.Close_crash.patch -fix_NotifyManager.Init_crash.patch -disable_notifications_on_error.patch -fix_IndicateManager.Init_crash.patch -mono_2.10_compile_fix.patch -dont_sign_Twitterizer2.patch +fix_smuxi-frontend-stfl_dllmap.patch build_Newtonsoft.Json_with_default_compiler.patch build_Twitterizer2_with_default_compiler.patch +build_db4o_with_default_compiler.patch +build_jabber-net_with_default_compiler.patch ubuntu_default_settings.patch diff -Nru smuxi-0.8/debian/rules smuxi-0.8.9.1/debian/rules --- smuxi-0.8/debian/rules 2011-08-06 12:13:33.000000000 +0000 +++ smuxi-0.8.9.1/debian/rules 2012-01-07 11:13:27.000000000 +0000 @@ -3,8 +3,20 @@ include /usr/share/cli-common/cli.make +LSB_VENDOR = $(shell lsb_release -is) +LSB_CODENAME = $(shell lsb_release -cs) +DEB_VERSION = $(shell dpkg-parsechangelog -ldebian/changelog | grep ^Vers | cut -d\ -f2) + override_dh_auto_configure: - dh_auto_configure -- --enable-engine-irc --enable-frontend-gnome --with-notify --with-indicate GMCS=/usr/bin/mono-csc MCS=/usr/bin/mono-csc + dh_auto_configure -- \ + --with-vendor-package-version="Debian $(DEB_VERSION)" \ + --enable-engine-irc \ + --enable-engine-xmpp \ + --enable-frontend-gnome \ + --enable-frontend-stfl \ + --with-notify \ + --with-indicate \ + GMCS=/usr/bin/mono-csc MCS=/usr/bin/mono-csc # disable "make check" override_dh_auto_test: @@ -12,5 +24,8 @@ # disable stripping debugging symbols override_dh_clistrip: +override_dh_clideps: + dh_clideps --exclude-moduleref=i:secur32 --exclude-moduleref=i:secur32.dll + %: dh $@ diff -Nru smuxi-0.8/debian/smuxi-engine.install smuxi-0.8.9.1/debian/smuxi-engine.install --- smuxi-0.8/debian/smuxi-engine.install 2011-08-06 12:13:33.000000000 +0000 +++ smuxi-0.8.9.1/debian/smuxi-engine.install 2012-01-07 11:13:27.000000000 +0000 @@ -1,3 +1,4 @@ usr/lib/smuxi/smuxi-common.dll* usr/lib/smuxi/smuxi-engine.dll* +usr/lib/smuxi/Db4objects.Db4o.dll* usr/share/locale/*/LC_MESSAGES/smuxi-engine.mo diff -Nru smuxi-0.8/debian/smuxi-engine-xmpp.install smuxi-0.8.9.1/debian/smuxi-engine-xmpp.install --- smuxi-0.8/debian/smuxi-engine-xmpp.install 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/debian/smuxi-engine-xmpp.install 2012-01-07 11:13:27.000000000 +0000 @@ -0,0 +1,2 @@ +usr/lib/smuxi/smuxi-engine-xmpp.dll* +usr/lib/smuxi/jabber-net.dll* diff -Nru smuxi-0.8/debian/smuxi-frontend-gnome.install smuxi-0.8.9.1/debian/smuxi-frontend-gnome.install --- smuxi-0.8/debian/smuxi-frontend-gnome.install 2011-08-06 12:13:33.000000000 +0000 +++ smuxi-0.8.9.1/debian/smuxi-frontend-gnome.install 2012-01-07 11:13:27.000000000 +0000 @@ -1,5 +1,5 @@ usr/bin/smuxi-frontend-gnome usr/lib/smuxi/smuxi-frontend-gnome.exe* usr/share/applications/smuxi-frontend-gnome.desktop -usr/share/pixmaps/smuxi-frontend-gnome.svg +usr/share/icons/ usr/share/locale/*/LC_MESSAGES/smuxi-frontend-gnome.mo diff -Nru smuxi-0.8/debian/smuxi-frontend-gnome.menu smuxi-0.8.9.1/debian/smuxi-frontend-gnome.menu --- smuxi-0.8/debian/smuxi-frontend-gnome.menu 2011-08-06 12:13:33.000000000 +0000 +++ smuxi-0.8.9.1/debian/smuxi-frontend-gnome.menu 2012-01-07 11:13:27.000000000 +0000 @@ -1,3 +1,3 @@ ?package(smuxi-frontend-gnome):needs="X11" section="Applications/Network/Communication"\ title="Smuxi" command="/usr/bin/smuxi-frontend-gnome"\ - icon="/usr/share/pixmaps/smuxi-frontend-gnome.svg" + icon="/usr/share/icons/hicolor/scalable/apps/smuxi-frontend-gnome.svg" diff -Nru smuxi-0.8/debian/smuxi-frontend-stfl.install smuxi-0.8.9.1/debian/smuxi-frontend-stfl.install --- smuxi-0.8/debian/smuxi-frontend-stfl.install 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/debian/smuxi-frontend-stfl.install 2012-01-07 11:13:27.000000000 +0000 @@ -0,0 +1,2 @@ +usr/bin/smuxi-frontend-stfl +usr/lib/smuxi/smuxi-frontend-stfl.exe* diff -Nru smuxi-0.8/glade/smuxi-frontend-gnome.glade smuxi-0.8.9.1/glade/smuxi-frontend-gnome.glade --- smuxi-0.8/glade/smuxi-frontend-gnome.glade 2010-09-02 00:48:15.000000000 +0000 +++ smuxi-0.8.9.1/glade/smuxi-frontend-gnome.glade 2012-01-03 07:51:33.000000000 +0000 @@ -4,7 +4,7 @@ True - Smuxi - Preferences + Smuxi Preferences 700 600 dialog @@ -508,8 +508,7 @@ in - 152 - 168 + 100 True True word @@ -568,8 +567,7 @@ in - 152 - 168 + 100 True True word @@ -626,145 +624,158 @@ True + 5 vertical + 5 - + True - 5 - 3 - 2 - 5 - 5 - - - True - - - True - Timestamp Format: - - - False - False - 0 - - - - - True - - - 1 - - - - - GTK_FILL - GTK_FILL - - - - - True - - - True - Buffer Lines: - - - False - False - 0 - - - - - True - - - 1 - - - - - 1 - 2 - GTK_FILL - GTK_FILL - - + 0 + none - + True + 12 - - True - Engine Buffer Lines: - - - False - False - 0 - - - - + True - - - 1 - - - - - 2 - 3 - GTK_FILL - GTK_FILL - - - - - 60 - True - True - 200 1 9999 1 10 10 - 1 - True - - - - 1 - 2 - 1 - 2 - - - - - - 60 - True - True - 200 0 9999 1 10 10 - 1 - True - - - - 1 - 2 - 2 - 3 - - - - - - 60 - True - True - ss = seconds + 5 + 6 + 2 + 5 + 5 + + + True + + + True + Timestamp Format: + + + False + False + 0 + + + + + True + + + 1 + + + + + GTK_FILL + GTK_FILL + + + + + True + + + True + Buffer Lines: + + + False + False + 0 + + + + + True + + + 1 + + + + + 1 + 2 + GTK_FILL + GTK_FILL + + + + + True + + + True + Engine Buffer Lines: + + + False + False + 0 + + + + + True + + + 1 + + + + + 2 + 3 + GTK_FILL + GTK_FILL + + + + + 60 + True + True + + 200 1 9999 1 10 10 + 1 + True + + + + 1 + 2 + 1 + 2 + + + + + + 60 + True + True + + 200 0 9999 1 10 10 + 1 + True + + + + 1 + 2 + 2 + 3 + + + + + + 60 + True + True + ss = seconds mm = minutes hh = hours (01 - 12) HH = hours (00 - 23) @@ -773,92 +784,173 @@ dd = day MM = month yy/yyyy = year - HH:mm - - - - 1 - 2 - - - - - - False - False - 0 - - - - - True - True - False - True - - - - True - 0 - 0 - - - True - 2 + + HH:mm + + + + 1 + 2 + + + - + True - gtk-cut - False - False - 0 + 1 + 2 + 3 + 4 - + True - Strip Colors - True + 0 + Persistency Type: - False - False - 1 + 3 + 4 + + + + + True + 0 + Volatile Buffer Lines: + + + 4 + 5 + + + + + True + 0 + Persistent Buffer Lines: + + + 5 + 6 + + + + + 60 + True + True + + 200 0 10000 100 1000 10 + 1 + True + + + 1 + 2 + 4 + 5 + + + + + + 60 + True + True + + 50000 0 1000000000 100 1000 10 + 1 + True + + + 1 + 2 + 5 + 6 + + + + True + <b>Message Buffer</b> + True + + + label_item + + False False - 1 + 0 - + True - True - False - True - + 0 + none - + True - 0 - 0 + 12 - + True - 2 + vertical - + True - gtk-cut + True + False + True + + + + True + 0 + 0 + + + True + 2 + + + True + gtk-cut + + + False + False + 0 + + + + + True + Strip Colors + True + + + False + False + 1 + + + + + + False @@ -867,10 +959,48 @@ - + True - Strip Formattings - True + True + False + True + + + + True + 0 + 0 + + + True + 2 + + + True + gtk-cut + + + False + False + 0 + + + + + True + Strip Formattings + True + + + False + False + 1 + + + + + + False @@ -878,105 +1008,115 @@ 1 - - - - - - - False - False - 2 - - - - - True - False - True - False - True - - - - True - 0 - 0 - - - True - 2 - + True - gtk-cut + False + True + False + True + + + + True + 0 + 0 + + + True + 2 + + + True + gtk-cut + + + False + False + 0 + + + + + True + Strip UTF-8 + True + + + False + False + 1 + + + + + + False False - 0 + 2 - + True - Strip UTF-8 - True + True + False + 1 + True + + + + True + 2 + + + True + gtk-execute + + + 0 + + + + + True + Show Advanced Settings + + + 1 + + + + False False - 1 + 3 - - - False - False - 3 - - - - - True - True - False - 1 - True - - + True - 2 - - - True - gtk-execute - - - 0 - - - - - True - Show Advanced Settings - - - 1 - - + <b>Advanced</b> + True + + label_item + False False - 4 + 1 @@ -996,6 +1136,7 @@ True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 5 vertical 5 @@ -1418,6 +1559,7 @@ True + 5 0 @@ -1632,6 +1774,7 @@ True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 5 vertical @@ -2306,6 +2449,7 @@ True + 5 vertical 5 Binary files /tmp/l3kVLF4iNE/smuxi-0.8/images/128/smuxi-frontend-gnome.png and /tmp/jEQ8aotOZY/smuxi-0.8.9.1/images/128/smuxi-frontend-gnome.png differ Binary files /tmp/l3kVLF4iNE/smuxi-0.8/images/16/smuxi-frontend-gnome.png and /tmp/jEQ8aotOZY/smuxi-0.8.9.1/images/16/smuxi-frontend-gnome.png differ Binary files /tmp/l3kVLF4iNE/smuxi-0.8/images/22/smuxi-frontend-gnome.png and /tmp/jEQ8aotOZY/smuxi-0.8.9.1/images/22/smuxi-frontend-gnome.png differ Binary files /tmp/l3kVLF4iNE/smuxi-0.8/images/24/smuxi-frontend-gnome.png and /tmp/jEQ8aotOZY/smuxi-0.8.9.1/images/24/smuxi-frontend-gnome.png differ Binary files /tmp/l3kVLF4iNE/smuxi-0.8/images/256/smuxi-frontend-gnome.png and /tmp/jEQ8aotOZY/smuxi-0.8.9.1/images/256/smuxi-frontend-gnome.png differ Binary files /tmp/l3kVLF4iNE/smuxi-0.8/images/32/smuxi-frontend-gnome.png and /tmp/jEQ8aotOZY/smuxi-0.8.9.1/images/32/smuxi-frontend-gnome.png differ Binary files /tmp/l3kVLF4iNE/smuxi-0.8/images/48/smuxi-frontend-gnome.png and /tmp/jEQ8aotOZY/smuxi-0.8.9.1/images/48/smuxi-frontend-gnome.png differ diff -Nru smuxi-0.8/images/connect-button.svg smuxi-0.8.9.1/images/connect-button.svg --- smuxi-0.8/images/connect-button.svg 2010-09-02 00:48:15.000000000 +0000 +++ smuxi-0.8.9.1/images/connect-button.svg 1970-01-01 00:00:00.000000000 +0000 @@ -1,1015 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - Jakub Steiner - - - http://jimmac.musichall.cz - - Web Browser - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Binary files /tmp/l3kVLF4iNE/smuxi-0.8/images/group-chat_256x256.png and /tmp/jEQ8aotOZY/smuxi-0.8.9.1/images/group-chat_256x256.png differ diff -Nru smuxi-0.8/images/group-chat.svg smuxi-0.8.9.1/images/group-chat.svg --- smuxi-0.8/images/group-chat.svg 2010-09-02 00:48:15.000000000 +0000 +++ smuxi-0.8.9.1/images/group-chat.svg 1970-01-01 00:00:00.000000000 +0000 @@ -1,753 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - Person - - - Jakub Steiner - - - http://jimmac.musichall.cz - - - user - person - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Binary files /tmp/l3kVLF4iNE/smuxi-0.8/images/icon_256x256.png and /tmp/jEQ8aotOZY/smuxi-0.8.9.1/images/icon_256x256.png differ Binary files /tmp/l3kVLF4iNE/smuxi-0.8/images/icon.ico and /tmp/jEQ8aotOZY/smuxi-0.8.9.1/images/icon.ico differ diff -Nru smuxi-0.8/images/icon.svg smuxi-0.8.9.1/images/icon.svg --- smuxi-0.8/images/icon.svg 2010-09-02 00:48:15.000000000 +0000 +++ smuxi-0.8.9.1/images/icon.svg 1970-01-01 00:00:00.000000000 +0000 @@ -1,3460 +0,0 @@ - - - - - Smuxi IRC Client - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - Smuxi IRC Client - 2010-7-28 - - - Ahmed Abdellah - - - - - Jakub Steiner <jimmac@ximian.com> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Binary files /tmp/l3kVLF4iNE/smuxi-0.8/images/person-chat_256x256.png and /tmp/jEQ8aotOZY/smuxi-0.8.9.1/images/person-chat_256x256.png differ diff -Nru smuxi-0.8/images/person-chat.svg smuxi-0.8.9.1/images/person-chat.svg --- smuxi-0.8/images/person-chat.svg 2010-09-02 00:48:15.000000000 +0000 +++ smuxi-0.8.9.1/images/person-chat.svg 1970-01-01 00:00:00.000000000 +0000 @@ -1,317 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - Person - - - Jakub Steiner - - - http://jimmac.musichall.cz - - - user - person - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Binary files /tmp/l3kVLF4iNE/smuxi-0.8/images/protocol-chat_256x256.png and /tmp/jEQ8aotOZY/smuxi-0.8.9.1/images/protocol-chat_256x256.png differ diff -Nru smuxi-0.8/images/protocol-chat.svg smuxi-0.8.9.1/images/protocol-chat.svg --- smuxi-0.8/images/protocol-chat.svg 2010-09-02 00:48:15.000000000 +0000 +++ smuxi-0.8.9.1/images/protocol-chat.svg 1970-01-01 00:00:00.000000000 +0000 @@ -1,1056 +0,0 @@ - - - - - Server - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - Server - - - Ahmed Abdellah - - - http://www.gnome.org - - - network - workgroup - - - - - - Jakub Steiner -Andreas Nilsson -Lapo Calamandrei - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Binary files /tmp/l3kVLF4iNE/smuxi-0.8/images/session-chat_256x256.png and /tmp/jEQ8aotOZY/smuxi-0.8.9.1/images/session-chat_256x256.png differ diff -Nru smuxi-0.8/images/session-chat.svg smuxi-0.8.9.1/images/session-chat.svg --- smuxi-0.8/images/session-chat.svg 2010-09-02 00:48:15.000000000 +0000 +++ smuxi-0.8.9.1/images/session-chat.svg 1970-01-01 00:00:00.000000000 +0000 @@ -1,260 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - Go Home - - - go - seek - home - - - - - Rodney Dawes - - - - - Jakub Steiner - - - - - - - - - - - - - - - - - - - - - - - - diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Activation/ActivationPurpose.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Activation/ActivationPurpose.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Activation/ActivationPurpose.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Activation/ActivationPurpose.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,10 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +namespace Db4objects.Db4o.Activation +{ + public enum ActivationPurpose + { + Read, + Write + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Activation/IActivator.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Activation/IActivator.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Activation/IActivator.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Activation/IActivator.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,33 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Activation; + +namespace Db4objects.Db4o.Activation +{ + /// + /// Activator interface.
+ ///

+ /// Db4objects.Db4o.TA.IActivatable + /// objects need to have a reference to + /// an Activator implementation, which is called + /// by Transparent Activation, when a request is received to + /// activate the host object. + ///
+ /// Transparent Activation framework. + /// + public interface IActivator + { + /// Method to be called to activate the host object. + /// Method to be called to activate the host object. + /// + /// for which purpose is the object being activated? + /// ActivationPurpose.Write + /// will cause the object + /// to be saved on the next + /// Db4objects.Db4o.IObjectContainer.Commit() + /// + /// operation. + /// + void Activate(ActivationPurpose purpose); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Collections/ArrayDictionary4.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Collections/ArrayDictionary4.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Collections/ArrayDictionary4.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Collections/ArrayDictionary4.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,210 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using System.Collections.Generic; +using Db4objects.Db4o.Activation; +using Sharpen; +using Sharpen.Util; + +namespace Db4objects.Db4o.Collections +{ + /// Transparent activatable IDictionary implementation. + /// + /// + /// Transparent activatable IDictionary implementation. Implements IDictionary interface + /// using two arrays to store keys and values. + ///
+ ///
+ /// When instantiated as a result of a query, all the internal members + /// are NOT activated at all. When internal members are required to + /// perform an operation, the instance transparently activates all the + /// members. + ///
+ /// System.Collections.IDictionary + /// + /// Db4objects.Db4o.TA.IActivatable + /// + public partial class ArrayDictionary4 + { + private K[] _keys; + + private V[] _values; + + private int _size; + + [System.NonSerialized] + private IActivator _activator; + + /// + /// Initializes a new collection with the initial capacity = 16. + /// + public ArrayDictionary4() : this(16) + { + } + + /// + /// Initializes a collection of the specified initial capacity. + /// + public ArrayDictionary4(int initialCapacity) + { + InitializeBackingArray(initialCapacity); + } + + /// activate basic implementation. + /// activate basic implementation. + /// Db4objects.Db4o.TA.IActivatable + public virtual void Activate(ActivationPurpose purpose) + { + if (_activator != null) + { + _activator.Activate(purpose); + } + } + + /// bind basic implementation. + /// bind basic implementation. + /// Db4objects.Db4o.TA.IActivatable + public virtual void Bind(IActivator activator) + { + if (_activator == activator) + { + return; + } + if (activator != null && _activator != null) + { + throw new InvalidOperationException(); + } + _activator = activator; + } + + /// System.Collections.Generic.IDictionary implementation but transparently activates + /// the members as required. + /// System.Collections.Generic.IDictionary implementation but transparently activates + /// the members as required. + /// + /// Db4objects.Db4o.TA.IActivatable + /// + public virtual void Clear() + { + Activate(ActivationPurpose.Write); + _size = 0; + Arrays.Fill(_keys, DefaultKeyValue()); + Arrays.Fill(_values, DefaultValue()); + } + + private bool ContainsKeyImpl(K key) + { + Activate(ActivationPurpose.Read); + return IndexOfKey(key) != -1; + } + + private V ValueAt(int index) + { + return _values[index]; + } + + private K KeyAt(int i) + { + return _keys[i]; + } + + private V Replace(int index, V value) + { + V oldValue = ValueAt(index); + _values[index] = value; + return oldValue; + } + + /// Returns the number of elements in the collection. + /// Returns the number of elements in the collection. The collection gets activated. + /// + /// Db4objects.Db4o.TA.IActivatable + /// + public virtual int Count + { + get + { + Activate(ActivationPurpose.Read); + return _size; + } + } + + /// Returns the values of the collection. + /// Returns the values of the collection. The collection gets activated. + /// + /// Db4objects.Db4o.TA.IActivatable + /// + public virtual ICollection Values + { + get + { + Activate(ActivationPurpose.Read); + List list = new List(); + for (int i = 0; i < _size; i++) + { + list.Add(ValueAt(i)); + } + return list; + } + } + + /// Returns the hash code of the collection. + /// Returns the hash code of the collection. Collection members + /// get activated as required. + /// + /// Db4objects.Db4o.TA.IActivatable + /// + public override int GetHashCode() + { + int hashCode = 0; + foreach (KeyValuePair entry in this) + { + hashCode += entry.GetHashCode(); + } + return hashCode; + } + + private void InitializeBackingArray(int length) + { + _keys = AllocateKeyStorage(length); + _values = AllocateValueStorage(length); + } + + private void Insert(K key, V value) + { + EnsureCapacity(); + _keys[_size] = key; + _values[_size] = value; + _size++; + } + + private void EnsureCapacity() + { + if (_size == _keys.Length) + { + int count = _keys.Length * 2; + K[] newKeys = AllocateKeyStorage(count); + V[] newValues = AllocateValueStorage(count); + System.Array.Copy(_keys, 0, newKeys, 0, _size); + System.Array.Copy(_values, 0, newValues, 0, _size); + _keys = newKeys; + _values = newValues; + } + } + + private V Delete(int index) + { + Activate(ActivationPurpose.Write); + V value = ValueAt(index); + for (int i = index; i < _size - 1; i++) + { + _keys[i] = _keys[i + 1]; + _values[i] = _values[i + 1]; + } + _size--; + _keys[_size] = DefaultKeyValue(); + _values[_size] = DefaultValue(); + return value; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Collections/ArrayList4.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Collections/ArrayList4.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Collections/ArrayList4.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Collections/ArrayList4.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,280 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +#if !SILVERLIGHT +using System; +using System.Collections.Generic; +using Db4objects.Db4o.Activation; +using Sharpen; +using Sharpen.Util; + +namespace Db4objects.Db4o.Collections +{ + /// Transparent activatable ArrayList implementation. + /// + /// + /// Transparent activatable ArrayList implementation. Implements IList + /// interface using an array to store elements. Each ArrayList4 instance + /// has a capacity, which indicates the size of the internal array. + ///
+ ///
+ /// When instantiated as a result of a query, all the internal members + /// are NOT activated at all. When internal members are required to + /// perform an operation, the instance transparently activates all the + /// members. + ///
+ /// System.Collections.ArrayList + /// + /// Db4objects.Db4o.TA.IActivatable + /// + public partial class ArrayList4 + { + private E[] elements; + + private int listSize; + + [System.NonSerialized] + private IActivator _activator; + + /// activate basic implementation. + /// activate basic implementation. + /// Db4objects.Db4o.TA.IActivatable + public virtual void Activate(ActivationPurpose purpose) + { + if (_activator != null) + { + _activator.Activate(purpose); + } + } + + /// bind basic implementation. + /// bind basic implementation. + /// Db4objects.Db4o.TA.IActivatable + public virtual void Bind(IActivator activator) + { + if (_activator == activator) + { + return; + } + if (activator != null && _activator != null) + { + throw new InvalidOperationException(); + } + _activator = activator; + } + + /// + /// Initializes a new collection with the initial capacity = 10. + /// + public ArrayList4() : this(10) + { + } + + /// + /// Initializes a collection with the members of the parameter collection. + /// + public ArrayList4(ICollection c) + { + E[] data = CollectionToArray(c); + elements = AllocateStorage(data.Length); + listSize = data.Length; + System.Array.Copy(data, 0, elements, 0, data.Length); + } + + /// + /// Initializes a collection of the specified initial capacity. + /// + public ArrayList4(int initialCapacity) + { + if (initialCapacity < 0) + { + throw new ArgumentException(); + } + elements = AllocateStorage(initialCapacity); + listSize = 0; + } + + /// Inserts an element into the collection + /// at the specified index. + /// Inserts an element into the collection + /// at the specified index. + /// Db4objects.Db4o.TA.IActivatable + /// + internal virtual void Add(int index, E element) + { + CheckIndex(index, 0, Count); + EnsureCapacity(Count + 1); + ArrayCopyElements(index, index + 1, listSize - index); + elements[index] = element; + IncreaseSize(1); + MarkModified(); + } + + private void ArrayCopyElements(int sourceIndex, int targetIndex, int length) + { + ActivateForWrite(); + System.Array.Copy(elements, sourceIndex, elements, targetIndex, length); + } + + internal bool AddAllImpl(int index, E[] toBeAdded) + { + CheckIndex(index, 0, Count); + int length = toBeAdded.Length; + if (length == 0) + { + return false; + } + EnsureCapacity(Count + length); + ArrayCopyElements(index, index + length, Count - index); + System.Array.Copy(toBeAdded, 0, elements, index, length); + IncreaseSize(length); + MarkModified(); + return true; + } + + /// Removes all elements from the collection. + /// Removes all elements from the collection. + /// Db4objects.Db4o.TA.IActivatable + /// + public virtual void Clear() + { + int size = Count; + ActivateForWrite(); + Arrays.Fill(elements, 0, size, DefaultValue()); + SetSize(0); + MarkModified(); + } + + /// Resizes the collection capacity to the specified size if the + /// current capacity is less than the parameter value. + /// Resizes the collection capacity to the specified size if the + /// current capacity is less than the parameter value. + /// Db4objects.Db4o.TA.IActivatable + /// + public virtual void EnsureCapacity(int minCapacity) + { + Activate(ActivationPurpose.Read); + if (minCapacity <= Capacity()) + { + return; + } + Resize(minCapacity); + } + + private int Capacity() + { + return elements.Length; + } + + /// Returns the collection element at the specified index. + /// Returns the collection element at the specified index. + /// Db4objects.Db4o.TA.IActivatable + /// + public virtual E Get(int index) + { + CheckIndex(index, 0, Count - 1); + return elements[index]; + } + + /// Removes the collection element at the specified index. + /// Removes the collection element at the specified index. + /// Db4objects.Db4o.TA.IActivatable + /// + internal virtual E RemoveImpl(int index) + { + int size = Count; + E element = this[index]; + ArrayCopyElements(index + 1, index, size - index - 1); + elements[size - 1] = DefaultValue(); + DecreaseSize(1); + MarkModified(); + return element; + } + + private void RemoveRangeImpl(int fromIndex, int count) + { + int size = Count; + int toIndex = fromIndex + count; + if ((fromIndex < 0 || fromIndex >= size || toIndex > size || toIndex < fromIndex)) + { + throw new IndexOutOfRangeException(); + } + if (count == 0) + { + return; + } + System.Array.Copy(elements, toIndex, elements, fromIndex, size - toIndex); + Arrays.Fill(elements, size - count, size, DefaultValue()); + DecreaseSize(count); + MarkModified(); + } + + /// Replaces the collection element with the specified object at the specified index. + /// Replaces the collection element with the specified object at the specified index. + /// Db4objects.Db4o.TA.IActivatable + /// + internal virtual E Set(int index, E element) + { + E oldValue = this[index]; + ActivateForWrite(); + elements[index] = element; + return oldValue; + } + + /// Returns the size of the collection. + /// Returns the size of the collection. + /// Db4objects.Db4o.TA.IActivatable + /// + public virtual int Count + { + get + { + Activate(ActivationPurpose.Read); + return listSize; + } + } + + /// Resizes the collection to its actual size. + /// Resizes the collection to its actual size. + /// Db4objects.Db4o.TA.IActivatable + /// + public virtual void TrimExcess() + { + ActivateForWrite(); + Resize(Count); + } + + private void Resize(int minCapacity) + { + MarkModified(); + E[] temp = AllocateStorage(minCapacity); + System.Array.Copy(elements, 0, temp, 0, Count); + elements = temp; + } + + internal virtual void SetSize(int count) + { + listSize = count; + } + + internal virtual void IncreaseSize(int count) + { + listSize += count; + } + + internal virtual void DecreaseSize(int count) + { + listSize -= count; + } + + internal virtual void MarkModified() + { + ++modCount; + } + + private void ActivateForWrite() + { + Activate(ActivationPurpose.Write); + } + } +} +#endif // !SILVERLIGHT diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Collections/CollectionFactory.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Collections/CollectionFactory.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Collections/CollectionFactory.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Collections/CollectionFactory.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,66 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using Db4objects.Db4o; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Collections; + +namespace Db4objects.Db4o.Collections +{ + /// + /// Collection factory with methods to create collections with behaviour + /// that is optimized for db4o.

+ /// Example usage:
+ /// CollectionFactory.forObjectContainer(objectContainer).newBigSet(); + ///
+ public class CollectionFactory + { + private readonly IObjectContainer _objectContainer; + + private CollectionFactory(IObjectContainer objectContainer) + { + _objectContainer = objectContainer; + } + + /// returns a collection factory for an ObjectContainer + /// - the ObjectContainer + /// the CollectionFactory + public static Db4objects.Db4o.Collections.CollectionFactory ForObjectContainer(IObjectContainer + objectContainer) + { + if (IsClient(objectContainer)) + { + throw new NotSupportedException("CollectionFactory is not yet available for Client/Server." + ); + } + return new Db4objects.Db4o.Collections.CollectionFactory(objectContainer); + } + + /// + /// creates a new BigSet.

+ /// Characteristics of BigSet:
+ /// - It is optimized by using a BTree of IDs of persistent objects.
+ /// - It can only hold persistent first class objects (no primitives, no strings, no objects that are not persistent)
+ /// - Objects are activated upon getting them from the BigSet. + ///
+ /// + /// creates a new BigSet.

+ /// Characteristics of BigSet:
+ /// - It is optimized by using a BTree of IDs of persistent objects.
+ /// - It can only hold persistent first class objects (no primitives, no strings, no objects that are not persistent)
+ /// - Objects are activated upon getting them from the BigSet. + ///

+ /// BigSet is recommend whenever one object references a huge number of other objects and sorting is not required. + ///
+ /// + public virtual Db4objects.Db4o.Collections.ISet NewBigSet() + { + return new BigSet((LocalObjectContainer)_objectContainer); + } + + private static bool IsClient(IObjectContainer oc) + { + return ((IInternalObjectContainer)oc).IsClient; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/ConfigScope.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/ConfigScope.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/ConfigScope.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/ConfigScope.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,139 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Foundation; + +namespace Db4objects.Db4o.Config +{ + /// + /// Defines a scope of applicability of a config setting.

+ /// Some of the configuration settings can be either:

+ /// - enabled globally;
+ /// - enabled individually for a specified class;
+ /// - disabled.

+ ///
+ /// IConfiguration.GenerateUUIDs(ConfigScope) + /// + /// IConfiguration.GenerateVersionNumbers(ConfigScope) + /// + [System.Serializable] + public sealed class ConfigScope + { + public const int DisabledId = -1; + + public const int IndividuallyId = 1; + + public const int GloballyId = int.MaxValue; + + private static readonly string DisabledName = "disabled"; + + private static readonly string IndividuallyName = "individually"; + + private static readonly string GloballyName = "globally"; + + /// Marks a configuration feature as globally disabled. + /// Marks a configuration feature as globally disabled. + public static readonly Db4objects.Db4o.Config.ConfigScope Disabled = new Db4objects.Db4o.Config.ConfigScope + (DisabledId, DisabledName); + + /// Marks a configuration feature as individually configurable. + /// Marks a configuration feature as individually configurable. + public static readonly Db4objects.Db4o.Config.ConfigScope Individually = new Db4objects.Db4o.Config.ConfigScope + (IndividuallyId, IndividuallyName); + + /// Marks a configuration feature as globally enabled. + /// Marks a configuration feature as globally enabled. + public static readonly Db4objects.Db4o.Config.ConfigScope Globally = new Db4objects.Db4o.Config.ConfigScope + (GloballyId, GloballyName); + + private readonly int _value; + + private readonly string _name; + + private ConfigScope(int value, string name) + { + _value = value; + _name = name; + } + + /// + /// Checks if the current configuration scope is globally + /// enabled or disabled. + /// + /// + /// Checks if the current configuration scope is globally + /// enabled or disabled. + /// + /// - default result + /// + /// false if disabled, true if globally enabled, default + /// value otherwise + /// + public bool ApplyConfig(TernaryBool defaultValue) + { + switch (_value) + { + case DisabledId: + { + return false; + } + + case GloballyId: + { + return !defaultValue.DefiniteNo(); + } + + default: + { + return defaultValue.DefiniteYes(); + break; + } + } + } + + public override bool Equals(object obj) + { + if (this == obj) + { + return true; + } + if (obj == null || GetType() != obj.GetType()) + { + return false; + } + Db4objects.Db4o.Config.ConfigScope tb = (Db4objects.Db4o.Config.ConfigScope)obj; + return _value == tb._value; + } + + public override int GetHashCode() + { + return _value; + } + + private object ReadResolve() + { + switch (_value) + { + case DisabledId: + { + return Disabled; + } + + case IndividuallyId: + { + return Individually; + } + + default: + { + return Globally; + break; + } + } + } + + public override string ToString() + { + return _name; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/Encoding/IStringEncoding.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/Encoding/IStringEncoding.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/Encoding/IStringEncoding.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/Encoding/IStringEncoding.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,25 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +namespace Db4objects.Db4o.Config.Encoding +{ + /// + /// encodes a String to a byte array and decodes a String + /// from a part of a byte array + /// + public interface IStringEncoding + { + /// called when a string is to be encoded to a byte array. + /// called when a string is to be encoded to a byte array. + /// the string to encode + /// the encoded byte array + byte[] Encode(string str); + + /// called when a byte array is to be decoded to a string. + /// called when a byte array is to be decoded to a string. + /// the byte array + /// the start offset in the byte array + /// the length of the encoded string in the byte array + /// the string + string Decode(byte[] bytes, int start, int length); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/Encoding/StringEncodings.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/Encoding/StringEncodings.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/Encoding/StringEncodings.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/Encoding/StringEncodings.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,28 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Config.Encoding; +using Db4objects.Db4o.Internal.Encoding; + +namespace Db4objects.Db4o.Config.Encoding +{ + /// All built in String encodings + /// Db4objects.Db4o.Config.IConfiguration.StringEncoding(IStringEncoding) + public class StringEncodings + { + public static IStringEncoding Utf8() + { + return new UTF8StringEncoding(); + } + + public static IStringEncoding Unicode() + { + return new UnicodeStringEncoding(); + } + + public static IStringEncoding Latin() + { + return new LatinStringEncoding(); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/Entry.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/Entry.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/Entry.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/Entry.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,20 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o; +using Db4objects.Db4o.Config; + +namespace Db4objects.Db4o.Config +{ + /// + public class Entry : ICompare, IInternal4 + { + public object key; + + public object value; + + public virtual object Compare() + { + return key; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/GlobalOnlyConfigException.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/GlobalOnlyConfigException.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/GlobalOnlyConfigException.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/GlobalOnlyConfigException.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,26 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Ext; + +namespace Db4objects.Db4o.Config +{ + /// + /// db4o-specific exception.

+ /// This exception is thrown when a global configuration + /// setting is attempted on an open object container. + ///
+ /// + /// db4o-specific exception.

+ /// This exception is thrown when a global configuration + /// setting is attempted on an open object container. + ///
+ /// IConfiguration.BlockSize(int) + /// IConfiguration.Encrypt(bool) + /// IConfiguration.Io(Db4objects.Db4o.IO.IoAdapter) + /// + /// IConfiguration.Password(string) + [System.Serializable] + public class GlobalOnlyConfigException : Db4oRecoverableException + { + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/IAlias.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/IAlias.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/IAlias.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/IAlias.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,73 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +namespace Db4objects.Db4o.Config +{ + /// + /// Implement this interface when implementing special custom Aliases + /// for classes, packages or namespaces. + /// + /// + /// + /// Implement this interface when implementing special custom Aliases + /// for classes, packages or namespaces. + ///

Aliases can be used to persist classes in the running + /// application to different persistent classes in a database file + /// or on a db4o server. + ///

Two simple Alias implementations are supplied along with + /// db4o:
+ /// - + /// TypeAlias + /// provides an #equals() resolver to match + /// names directly.
+ /// - + /// WildcardAlias + /// allows simple pattern matching + /// with one single '*' wildcard character.
+ ///
+ /// It is possible to create + /// own complex + /// IAlias + /// constructs by creating own resolvers + /// that implement the + /// IAlias + /// interface. + ///

+ /// Examples of concrete usecases: + ///

+ /// + /// // Creating an Alias for a single class
+ /// ICommonConfiguration.AddAlias(
+ ///   new TypeAlias("Tutorial.Pilot", "Tutorial.Driver"));
+ ///

+ /// // Accessing a Java package from a .NET assembly
+ /// ICommonConfiguration.AddAlias(
+ ///   new WildcardAlias(
+ ///     "com.f1.*",
+ ///     "Tutorial.F1.*, Tutorial"));
+ ///

+ /// // Using a different local .NET assembly
+ /// ICommonConfiguration.AddAlias(
+ ///   new WildcardAlias(
+ ///     "Tutorial.F1.*, F1Race",
+ ///     "Tutorial.F1.*, Tutorial"));
+ ///

+ ///
+ ///

Aliases that translate the persistent name of a class to + /// a name that already exists as a persistent name in the database + /// (or on the server) are not permitted and will throw an exception + /// when the database file is opened. + ///

Aliases should be configured before opening a database file + /// or connecting to a server. + /// + ///
+ public interface IAlias + { + /// return the stored name for a runtime name or null if not handled. + /// return the stored name for a runtime name or null if not handled. + string ResolveRuntimeName(string runtimeTypeName); + + /// return the runtime name for a stored name or null if not handled. + /// return the runtime name for a stored name or null if not handled. + string ResolveStoredName(string storedTypeName); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/ICacheConfiguration.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/ICacheConfiguration.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/ICacheConfiguration.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/ICacheConfiguration.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,24 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +namespace Db4objects.Db4o.Config +{ + /// Interface to configure the cache configurations. + /// Interface to configure the cache configurations. + public interface ICacheConfiguration + { + /// + /// configures the size of the slot cache to hold a number of + /// slots in the cache. + /// + /// + /// configures the size of the slot cache to hold a number of + /// slots in the cache. + /// + /// the number of slots + [System.ObsoleteAttribute(@"since 7.14 BTrees have their own LRU cache now.")] + int SlotCacheSize + { + set; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/ICacheConfigurationProvider.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/ICacheConfigurationProvider.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/ICacheConfigurationProvider.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/ICacheConfigurationProvider.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,24 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Config; + +namespace Db4objects.Db4o.Config +{ + /// + /// A configuration provider that provides access + /// to the cache-related configuration methods. + /// + /// + /// A configuration provider that provides access + /// to the cache-related configuration methods. + /// + public interface ICacheConfigurationProvider + { + /// Access to the cache-related configuration methods. + /// Access to the cache-related configuration methods. + ICacheConfiguration Cache + { + get; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/IClientServerConfiguration.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/IClientServerConfiguration.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/IClientServerConfiguration.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/IClientServerConfiguration.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,152 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Messaging; + +namespace Db4objects.Db4o.Config +{ + /// Client/Server configuration interface. + /// Client/Server configuration interface. + public interface IClientServerConfiguration + { + /// + /// Sets the number of IDs to be pre-allocated in the database for new + /// objects created on the client. + /// + /// + /// Sets the number of IDs to be pre-allocated in the database for new + /// objects created on the client. + /// This setting should be used on the client side. In embedded mode this setting + /// has no effect. + /// + /// The number of IDs to be prefetched + void PrefetchIDCount(int prefetchIDCount); + + /// Sets the number of objects to be prefetched for an ObjectSet. + /// + /// Sets the number of objects to be prefetched for an ObjectSet. + /// This setting should be used on the server side. + /// + /// The number of objects to be prefetched + void PrefetchObjectCount(int prefetchObjectCount); + + /// Sets the depth to which prefetched objects are activated. + /// + /// Sets the depth to which prefetched objects are activated. + /// This setting should be used on the client side. + /// + /// + void PrefetchDepth(int prefetchDepth); + + /// Sets the slot cache size to the given value. + /// Sets the slot cache size to the given value. + /// + void PrefetchSlotCacheSize(int slotCacheSize); + + /// sets the MessageRecipient to receive Client Server messages. + /// + /// sets the MessageRecipient to receive Client Server messages.
+ ///
+ /// This setting should be used on the server side.

+ ///
+ /// the MessageRecipient to be used + void SetMessageRecipient(IMessageRecipient messageRecipient); + + /// returns the MessageSender for this Configuration context. + /// + /// returns the MessageSender for this Configuration context. + /// This setting should be used on the client side. + /// + /// MessageSender + IMessageSender GetMessageSender(); + + /// + /// configures the time a client waits for a message response + /// from the server. + /// + /// + /// configures the time a client waits for a message response + /// from the server.
+ ///
+ /// Default value: 600000ms (10 minutes)
+ ///
+ /// It is recommended to use the same values for + /// TimeoutClientSocket(int) + /// and + /// TimeoutServerSocket(int) + /// . + ///
+ /// This setting can be used on both client and server.

+ ///
+ /// time in milliseconds + void TimeoutClientSocket(int milliseconds); + + /// configures the timeout of the serverside socket. + /// + /// configures the timeout of the serverside socket.
+ ///
+ /// The serverside handler waits for messages to arrive from the client. + /// If no more messages arrive for the duration configured in this + /// setting, the client will be disconnected. + ///
+ /// Clients send PING messages to the server at an interval of + /// Math.min(timeoutClientSocket(), timeoutServerSocket()) / 2 + /// and the server will respond to keep connections alive. + ///
+ /// Decrease this setting if you want clients to disconnect faster. + ///
+ /// Increase this setting if you have a large number of clients and long + /// running queries and you are getting disconnected clients that you + /// would like to wait even longer for a response from the server. + ///
+ /// Default value: 600000ms (10 minutes)
+ ///
+ /// It is recommended to use the same values for + /// TimeoutClientSocket(int) + /// and + /// TimeoutServerSocket(int) + /// . + ///
+ /// This setting can be used on both client and server.

+ ///
+ /// time in milliseconds + void TimeoutServerSocket(int milliseconds); + + /// + /// configures the client messaging system to be single threaded + /// or multithreaded. + /// + /// + /// configures the client messaging system to be single threaded + /// or multithreaded. + ///

Recommended settings:
+ /// - true for low resource systems.
+ /// - false for best asynchronous performance and fast + /// GUI response. + ///

Default value:
+ /// - .NET Compactframework: true
+ /// - all other platforms: false

+ /// This setting can be used on both client and server.

+ ///
+ /// the desired setting + void SingleThreadedClient(bool flag); + + /// Configures to batch messages between client and server. + /// + /// Configures to batch messages between client and server. By default, batch + /// mode is enabled.

+ /// This setting can be used on both client and server.

+ ///
+ /// false, to turn message batching off. + void BatchMessages(bool flag); + + /// Configures the maximum memory buffer size for batched message. + /// + /// Configures the maximum memory buffer size for batched message. If the + /// size of batched messages is greater than maxSize, batched + /// messages will be sent to server.

+ /// This setting can be used on both client and server.

+ ///
+ /// + void MaxBatchQueueSize(int maxSize); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/ICommonConfiguration.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/ICommonConfiguration.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/ICommonConfiguration.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/ICommonConfiguration.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,656 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System.IO; +using Db4objects.Db4o.Config; +using Db4objects.Db4o.Config.Encoding; +using Db4objects.Db4o.Diagnostic; +using Db4objects.Db4o.Reflect; +using Db4objects.Db4o.Typehandlers; + +namespace Db4objects.Db4o.Config +{ + /// + /// Common configuration methods, applicable for + /// embedded, client and server use of db4o.

+ /// In Client/Server use it is good practice to configure the + /// client and the server in exactly the same way. + ///
+ /// + /// Common configuration methods, applicable for + /// embedded, client and server use of db4o.

+ /// In Client/Server use it is good practice to configure the + /// client and the server in exactly the same way. + ///
+ /// 7.5 + public interface ICommonConfiguration + { + /// adds a new Alias for a class, namespace or package. + /// + /// adds a new Alias for a class, namespace or package. + ///

Aliases can be used to persist classes in the running + /// application to different persistent classes in a database file + /// or on a db4o server. + ///

Two simple Alias implementations are supplied along with + /// db4o:
+ /// - + /// TypeAlias + /// provides an #equals() resolver to match + /// names directly.
+ /// - + /// WildcardAlias + /// allows simple pattern matching + /// with one single '*' wildcard character.
+ ///
+ /// It is possible to create + /// own complex + /// IAlias + /// constructs by creating own resolvers + /// that implement the + /// IAlias + /// interface. + ///

+ /// Examples of concrete usecases: + ///

+ /// + /// // Creating an Alias for a single class
+ /// Db4o.configure().addAlias(
+ ///   new TypeAlias("com.f1.Pilot", "com.f1.Driver"));
+ ///

+ /// // Accessing a .NET assembly from a Java package
+ /// Db4o.configure().addAlias(
+ ///   new WildcardAlias(
+ ///     "Tutorial.F1.*, Tutorial",
+ ///     "com.f1.*"));
+ ///

+ /// // Mapping a Java package onto another
+ /// Db4o.configure().addAlias(
+ ///   new WildcardAlias(
+ ///     "com.f1.*",
+ ///     "com.f1.client*"));
+ ///

Aliases that translate the persistent name of a class to + /// a name that already exists as a persistent name in the database + /// (or on the server) are not permitted and will throw an exception + /// when the database file is opened. + ///

Aliases should be configured before opening a database file + /// or connecting to a server.

+ /// In client/server environment it is good practice to configure the + /// client and the server in exactly the same way. + ///
+ void AddAlias(IAlias alias); + + /// + /// Removes an alias previously added with + /// IConfiguration.AddAlias(IAlias) + /// . + /// + /// the alias to remove + void RemoveAlias(IAlias alias); + + /// sets the activation depth to the specified value. + /// + /// sets the activation depth to the specified value. + ///

Why activation?
+ /// When objects are instantiated from the database, the instantiation of member + /// objects needs to be limited to a certain depth. Otherwise a single object + /// could lead to loading the complete database into memory, if all objects where + /// reachable from a single root object.

+ /// db4o uses the concept "depth", the number of field-to-field hops an object + /// is away from another object. The preconfigured "activation depth" db4o uses + /// in the default setting is 5. + ///

Whenever an application iterates through the + /// IObjectSet + /// of a query result, the result objects + /// will be activated to the configured activation depth.

+ /// A concrete example with the preconfigured activation depth of 5:
+ ///
+		/// // Object foo is the result of a query, it is delivered by the ObjectSet
+		/// object foo = objectSet.Next();
+ /// foo.member1.member2.member3.member4.member5 will be a valid object
+ /// foo, member1, member2, member3 and member4 will be activated
+ /// member5 will be deactivated, all of it's members will be null
+ /// member5 can be activated at any time by calling + /// IObjectContainer.Activate(member5, depth) + /// + /// . + ///

+ /// Note that raising the global activation depth will consume more memory and + /// have negative effects on the performance of first-time retrievals. Lowering + /// the global activation depth needs more individual activation work but can + /// increase performance of queries.

+ /// IObjectContainer.Deactivate(object, depth) + /// + /// can be used to manually free memory by deactivating objects.

+ /// In client/server environment it is good practice to configure the + /// client and the server in exactly the same way.

. + ///
+ /// configuring classes individually + /// + /// gets the configured activation depth. + /// sets the activation depth to the specified value. + /// + /// sets the activation depth to the specified value. + ///

Why activation?
+ /// When objects are instantiated from the database, the instantiation of member + /// objects needs to be limited to a certain depth. Otherwise a single object + /// could lead to loading the complete database into memory, if all objects where + /// reachable from a single root object.

+ /// db4o uses the concept "depth", the number of field-to-field hops an object + /// is away from another object. The preconfigured "activation depth" db4o uses + /// in the default setting is 5. + ///

Whenever an application iterates through the + /// IObjectSet + /// of a query result, the result objects + /// will be activated to the configured activation depth.

+ /// A concrete example with the preconfigured activation depth of 5:
+ ///
+		/// // Object foo is the result of a query, it is delivered by the ObjectSet
+		/// object foo = objectSet.Next();
+ /// foo.member1.member2.member3.member4.member5 will be a valid object
+ /// foo, member1, member2, member3 and member4 will be activated
+ /// member5 will be deactivated, all of it's members will be null
+ /// member5 can be activated at any time by calling + /// IObjectContainer.Activate(member5, depth) + /// + /// . + ///

+ /// Note that raising the global activation depth will consume more memory and + /// have negative effects on the performance of first-time retrievals. Lowering + /// the global activation depth needs more individual activation work but can + /// increase performance of queries.

+ /// IObjectContainer.Deactivate(object, depth) + /// + /// can be used to manually free memory by deactivating objects.

+ /// In client/server environment it is good practice to configure the + /// client and the server in exactly the same way.

. + ///
+ /// configuring classes individually + /// + /// gets the configured activation depth. + int ActivationDepth + { + get; + set; + } + + /// + /// adds ConfigurationItems to be applied when + /// an ObjectContainer or ObjectServer is opened. + /// + /// + /// adds ConfigurationItems to be applied when + /// an ObjectContainer or ObjectServer is opened. + /// + /// the ConfigurationItem + void Add(IConfigurationItem configurationItem); + + /// turns automatic database file format version updates on. + /// + /// turns automatic database file format version updates on. + ///

Upon db4o database file format version changes, + /// db4o can automatically update database files to the + /// current version. db4objects does not provide functionality + /// to reverse this process. It is not ensured that updated + /// database files can be read with older db4o versions. + /// In some cases (Example: using ObjectManager) it may not be + /// desirable to update database files automatically therefore + /// automatic updating is turned off by default for + /// security reasons. + ///

Call this method to turn automatic database file + /// version updating on. + ///

If automatic updating is turned off, db4o will refuse + /// to open database files that use an older database file format.

+ /// In client/server environment it is good practice to configure the + /// client and the server in exactly the same way. + ///
+ bool AllowVersionUpdates + { + set; + } + + /// turns automatic shutdown of the engine on and off. + /// + /// turns automatic shutdown of the engine on and off. + /// The default and recommended setting is true.

+ ///
+ bool AutomaticShutDown + { + set; + } + + /// configures the size of BTree nodes in indexes. + /// + /// configures the size of BTree nodes in indexes. + ///

Default setting: 100 + ///
Lower values will allow a lower memory footprint + /// and more efficient reading and writing of small slots. + ///
Higher values will reduce the overall number of + /// read and write operations and allow better performance + /// at the cost of more RAM use.

+ /// In client/server environment it is good practice to configure the + /// client and the server in exactly the same way. + ///
+ /// the number of elements held in one BTree node. + int BTreeNodeSize + { + set; + } + + /// turns callback methods on and off. + /// + /// turns callback methods on and off. + ///

Callbacks are turned on by default.

+ /// A tuning hint: If callbacks are not used, you can turn this feature off, to + /// prevent db4o from looking for callback methods in persistent classes. This will + /// increase the performance on system startup.

+ /// In a client/server environment it is good practice to configure the + /// client and the server in exactly the same way. + ///
+ /// false to turn callback methods off + /// Using callbacks + bool Callbacks + { + set; + } + + /// + /// advises db4o to try instantiating objects with/without calling + /// constructors. + /// + /// + /// advises db4o to try instantiating objects with/without calling + /// constructors. + ///

+ /// Not all .NET-environments support this feature. db4o will + /// attempt, to follow the setting as good as the enviroment supports. + /// This setting may also be overridden for individual classes in + /// Db4objects.Db4o.Config.IObjectClass.CallConstructor + /// + /// . + ///

The default setting depends on the features supported by your current environment.

+ /// In a client/server environment it is good practice to configure the + /// client and the server in exactly the same way. + ///

+ ///
+ /// Db4objects.Db4o.Config.IObjectClass.CallConstructor + /// + bool CallConstructors + { + set; + } + + /// + /// tuning feature: configures whether db4o checks all persistent classes upon system + /// startup, for added or removed fields. + /// + /// + /// tuning feature: configures whether db4o checks all persistent classes upon system + /// startup, for added or removed fields. + ///

If this configuration setting is set to false while a database is + /// being created, members of classes will not be detected and stored. + ///

This setting can be set to false in a production environment after + /// all persistent classes have been stored at least once and classes will not + /// be modified any further in the future.

+ /// In a client/server environment it is good practice to configure the + /// client and the server in exactly the same way. + ///

Default value:
+ /// true + ///
+ /// the desired setting + bool DetectSchemaChanges + { + set; + } + + /// returns the configuration interface for diagnostics. + /// returns the configuration interface for diagnostics. + /// the configuration interface for diagnostics. + IDiagnosticConfiguration Diagnostic + { + get; + } + + /// configures whether Exceptions are to be thrown, if objects can not be stored. + /// + /// + /// configures whether Exceptions are to be thrown, if objects can not be stored. + ///

db4o requires the presence of a constructor that can be used to + /// instantiate objects. If no default public constructor is present, all + /// available constructors are tested, whether an instance of the class can + /// be instantiated. Null is passed to all constructor parameters. + /// The first constructor that is successfully tested will + /// be used throughout the running db4o session. If an instance of the class + /// can not be instantiated, the object will not be stored. By default, + /// execution will be stopped with an Exception. This method can + /// be used to configure db4o to not throw an + /// ObjectNotStorableException + /// + /// if an object can not be stored. + ///

+ /// The default for this setting is true.

+ /// In a client/server environment it is good practice to configure the + /// client and the server in exactly the same way.

+ ///
+ /// true to throw Exceptions if objects can not be stored. + bool ExceptionsOnNotStorable + { + set; + } + + /// configures db4o to call Intern() on strings upon retrieval. + /// + /// configures db4o to call Intern on strings upon retrieval if set to true. + /// In client/server environment the setting should be used on both + /// client and server. + /// + bool InternStrings + { + set; + } + + // TODO: refactor to use provider? + /// allows to mark fields as transient with custom attributes. + /// + /// allows to mark fields as transient with custom attributes. + ///

.NET only: Call this method with the attribute name that you + /// wish to use to mark fields as transient. Multiple transient attributes + /// are possible by calling this method multiple times with different + /// attribute names.

+ /// In a client/server environment it is good practice to configure the + /// client and the server in exactly the same way.

+ ///
+ /// + /// - the fully qualified name of the attribute, including + /// it's namespace + /// TODO: can we provide meaningful java side semantics for this one? + /// TODO: USE A CLASS!!!!!! + /// + void MarkTransient(string attributeName); + + /// sets the detail level of db4o messages. + /// + /// sets the detail level of db4o messages. Messages will be output to the + /// configured output + /// TextWriter + /// . + ///

+ /// Level 0 - no messages
+ /// Level 1 - open and close messages
+ /// Level 2 - messages for new, update and delete
+ /// Level 3 - messages for activate and deactivate

+ /// When using client-server and the level is set to 0, the server will override this and set it to 1. To get around this you can set the level to -1. This has the effect of not returning any messages.

+ /// In client-server environment this setting can be used on client or on server + /// depending on which information do you want to track (server side provides more + /// detailed information).

+ ///
+ /// integer from 0 to 3 + /// TODO: replace int with enumeration + /// + int MessageLevel + { + set; + } + + /// + /// returns an + /// IObjectClass + /// object + /// to configure the specified class. + ///

+ /// The clazz parameter can be any of the following:
+ /// - a fully qualified classname as a String.
+ /// - a Class object.
+ /// - any other object to be used as a template.

+ ///
+ /// class name, Class object, or example object.

+ /// + /// an instance of an + /// IObjectClass + /// object for configuration. + /// + IObjectClass ObjectClass(object clazz); + + /// + /// If set to true, db4o will try to optimize native queries + /// dynamically at query execution time, otherwise it will + /// run native queries in unoptimized mode as SODA evaluations. + /// + /// + /// If set to true, db4o will try to optimize native queries + /// dynamically at query execution time, otherwise it will + /// run native queries in unoptimized mode as SODA evaluations. + /// The following assemblies should be available for native query switch to take effect: + /// Db4objects.Db4o.NativeQueries.dll, Db4objects.Db4o.Instrumentation.dll. + ///

The default setting is true.

+ /// In a client/server environment it is good practice to configure the + /// client and the server in exactly the same way.

+ ///
+ /// Db4objects.Db4o.Config.ICommonConfiguration.OptimizeNativeQueries + /// + /// If set to true, db4o will try to optimize native queries + /// dynamically at query execution time, otherwise it will + /// run native queries in unoptimized mode as SODA evaluations. + /// + /// + /// If set to true, db4o will try to optimize native queries + /// dynamically at query execution time, otherwise it will + /// run native queries in unoptimized mode as SODA evaluations. + /// The following assemblies should be available for native query switch to take effect: + /// Db4objects.Db4o.NativeQueries.dll, Db4objects.Db4o.Instrumentation.dll. + ///

The default setting is true.

+ /// In a client/server environment it is good practice to configure the + /// client and the server in exactly the same way.

+ ///
+ /// Db4objects.Db4o.Config.ICommonConfiguration.OptimizeNativeQueries + bool OptimizeNativeQueries + { + get; + set; + } + + /// returns the Query configuration interface. + /// returns the Query configuration interface. + IQueryConfiguration Queries + { + get; + } + + /// configures the use of a specially designed reflection implementation. + /// + /// configures the use of a specially designed reflection implementation. + ///

+ /// db4o internally uses java.lang.reflect.* by default. On platforms that + /// do not support this package, customized implementations may be written + /// to supply all the functionality of the interfaces in the com.db4o.reflect + /// package. This method can be used to install a custom reflection + /// implementation.

+ /// In client-server environment this setting should be used on both the client and + /// the server side (reflector class must be available)

+ ///
+ void ReflectWith(IReflector reflector); + + /// + /// Assigns a + /// TextWriter + /// where db4o is to print its event messages. + ///

Messages are useful for debugging purposes and for learning + /// to understand, how db4o works. The message level can be raised with + /// IConfiguration.MessageLevel(int) + /// to produce more detailed messages. + ///

Use outStream(System.out) to print messages to the + /// console.

+ /// In client-server environment this setting should be used on the same side + /// where + /// IConfiguration.MessageLevel(int) + /// is used.

+ ///
+ /// the new PrintStream for messages. + /// MessageLevel(int) + TextWriter OutStream + { + set; + } + + /// configures the string encoding to be used. + /// + /// configures the string encoding to be used. + ///

The string encoding can not be changed in the lifetime of a + /// database file. To set up the database with the correct string encoding, + /// this configuration needs to be set correctly before a database + /// file is created with the first call to + /// Db4objects.Db4o.Db4oFactory.OpenFile + /// + /// or + /// Db4objects.Db4o.Db4oFactory.OpenServer + /// + /// . + ///

For subsequent open calls, db4o remembers built-in + /// string encodings. If a custom encoding is used (an encoding that is + /// not supplied from within the db4o library), the correct encoding + /// needs to be configured correctly again for all subsequent calls + /// that open database files. + ///

+ /// In client-server mode, the server and all clients need to have the same string encoding.

+ /// Example:
+ /// config.StringEncoding = StringEncodings.Utf8(); + ///
+ /// Db4objects.Db4o.Config.Encoding.StringEncodings + /// + IStringEncoding StringEncoding + { + set; + } + + /// + /// tuning feature: configures whether db4o should try to instantiate one instance + /// of each persistent class on system startup. + /// + /// + /// tuning feature: configures whether db4o should try to instantiate one instance + /// of each persistent class on system startup. + ///

In a production environment this setting can be set to false, + /// if all persistent classes have public default constructors. + ///

+ /// In a client/server environment it is good practice to configure the + /// client and the server in exactly the same way.

+ /// Default value:
+ /// true + ///
+ /// the desired setting + bool TestConstructors + { + set; + } + + /// specifies the global updateDepth. + /// + /// specifies the global updateDepth. + ///

see the documentation of + /// + /// for further details.

+ /// The value be may be overridden for individual classes.

+ /// The default setting is 1: Only the object passed to + /// Db4objects.Db4o.IObjectContainer.Store(object) + /// + /// will be updated.

+ /// In a client/server environment it is good practice to configure the + /// client and the server in exactly the same way.

+ ///
+ /// the depth of the desired update. + /// IObjectClass.UpdateDepth(int) + /// IObjectClass.CascadeOnUpdate(bool) + /// + /// Using callbacks + int UpdateDepth + { + set; + } + + /// turns weak reference management on or off. + /// + /// turns weak reference management on or off. + ///

+ /// This method must be called before opening a database. + ///

+ /// Performance may be improved by running db4o without using weak + /// references durring memory management at the cost of higher + /// memory consumption or by alternatively implementing a manual + /// memory management scheme using + /// Db4objects.Db4o.Ext.IExtObjectContainer.Purge(object) + /// + ///

Setting the value to false causes db4o to use hard + /// references to objects, preventing the garbage collection process + /// from disposing of unused objects. + ///

The default setting is true. + ///

Ignored on JDKs before 1.2. + ///
+ bool WeakReferences + { + set; + } + + /// configures the timer for WeakReference collection. + /// + /// configures the timer for WeakReference collection. + ///

The default setting is 1000 milliseconds. + ///

Configure this setting to zero to turn WeakReference + /// collection off. + ///

Ignored on JDKs before 1.2.

+ ///
+ /// the time in milliseconds + int WeakReferenceCollectionInterval + { + set; + } + + /// + /// allows registering special TypeHandlers for customized marshalling + /// and customized comparisons. + /// + /// + /// allows registering special TypeHandlers for customized marshalling + /// and customized comparisons. + /// + /// + /// to specify for which classes and versions the + /// TypeHandler is to be used. + /// + /// to be used for the classes that match the predicate. + void RegisterTypeHandler(ITypeHandlerPredicate predicate, ITypeHandler4 typeHandler + ); + + /// Db4objects.Db4o.Foundation.IEnvironment + /// + IEnvironmentConfiguration Environment + { + get; + } + + /// + /// Registers a + /// INameProvider + /// that assigns a custom name to the database to be used in + /// object.ToString() + /// . + /// + void NameProvider(INameProvider provider); + + ///

Sets the max stack depth that will be used for recursive storing and activating an object. + ///

+ /// + ///

Sets the max stack depth that will be used for recursive storing and activating an object. + ///

The default value is set to + /// Db4objects.Db4o.Internal.Const4.DefaultMaxStackDepth + /// + ///

On Android platform, we recomend setting this to 2. + /// + /// the desired max stack depth. + ///

gets the configured max stack depth. + /// gets the configured max stack depth. + /// the configured max stack depth. + int MaxStackDepth + { + get; + set; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/ICommonConfigurationProvider.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/ICommonConfigurationProvider.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/ICommonConfigurationProvider.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/ICommonConfigurationProvider.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,27 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Config; + +namespace Db4objects.Db4o.Config +{ + /// + /// A configuration provider that provides access to + /// the common configuration methods that can be called + /// for embedded, server and client use of db4o. + /// + /// + /// A configuration provider that provides access to + /// the common configuration methods that can be called + /// for embedded, server and client use of db4o. + /// + /// 7.5 + public interface ICommonConfigurationProvider + { + /// Access to the common configuration methods. + /// Access to the common configuration methods. + ICommonConfiguration Common + { + get; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/ICompare.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/ICompare.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/ICompare.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/ICompare.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,18 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +namespace Db4objects.Db4o.Config +{ + /// allows special comparison behaviour during query evaluation. + /// + /// allows special comparison behaviour during query evaluation. + ///

db4o will use the Object returned by the + /// Compare() + /// method for all query comparisons. + ///
+ public interface ICompare + { + /// return the Object to be compared during query evaluation. + /// return the Object to be compared during query evaluation. + object Compare(); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/IConfiguration.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/IConfiguration.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/IConfiguration.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/IConfiguration.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,888 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System.IO; +using Db4objects.Db4o.Config; +using Db4objects.Db4o.Config.Encoding; +using Db4objects.Db4o.Diagnostic; +using Db4objects.Db4o.IO; +using Db4objects.Db4o.Reflect; +using Db4objects.Db4o.Typehandlers; + +namespace Db4objects.Db4o.Config +{ + /// configuration interface. + /// + /// configuration interface. + ///

This interface contains methods to configure db4o.

+ /// The global Configuration context is available with + /// Db4objects.Db4o.Db4oFactory.Configure() + /// + /// . + /// When an ObjectContainer or ObjectServer is opened, the global Configuration + /// context is cloned and copied into the ObjectContainer/ObjectServer. + /// That means every ObjectContainer/ObjectServer gets it's own copy of + /// configuration settings.

+ /// Most configuration settings should be set before opening an + /// ObjectContainer/ObjectServer. + ///

Some configuration settings can be modified on an open + /// ObjectContainer/ObjectServer. The local Configuration context is + /// available with + /// Db4objects.Db4o.Ext.IExtObjectContainer.Configure() + /// + /// and + /// Db4objects.Db4o.Ext.IExtObjectServer.Configure() + /// + /// . + ///
+ public interface IConfiguration + { + /// sets the activation depth to the specified value. + /// + /// sets the activation depth to the specified value. + ///

Why activation?
+ /// When objects are instantiated from the database, the instantiation of member + /// objects needs to be limited to a certain depth. Otherwise a single object + /// could lead to loading the complete database into memory, if all objects where + /// reachable from a single root object.

+ /// db4o uses the concept "depth", the number of field-to-field hops an object + /// is away from another object. The preconfigured "activation depth" db4o uses + /// in the default setting is 5. + ///

Whenever an application iterates through the + /// IObjectSet + /// of a query result, the result objects + /// will be activated to the configured activation depth.

+ /// A concrete example with the preconfigured activation depth of 5:
+ ///
+		/// // Object foo is the result of a query, it is delivered by the ObjectSet
+		/// object foo = objectSet.Next();
+ /// foo.member1.member2.member3.member4.member5 will be a valid object
+ /// foo, member1, member2, member3 and member4 will be activated
+ /// member5 will be deactivated, all of it's members will be null
+ /// member5 can be activated at any time by calling + /// IObjectContainer.Activate(member5, depth) + /// + /// . + ///

+ /// Note that raising the global activation depth will consume more memory and + /// have negative effects on the performance of first-time retrievals. Lowering + /// the global activation depth needs more individual activation work but can + /// increase performance of queries.

+ /// IObjectContainer.Deactivate(object, depth) + /// + /// can be used to manually free memory by deactivating objects.

+ /// In client/server environment the same setting should be used on both + /// client and server

. + ///
+ /// the desired global activation depth. + /// + /// configuring classes individually + /// + /// + /// gets the configured activation depth. + void ActivationDepth(int depth); + + /// gets the configured activation depth. + /// gets the configured activation depth. + /// the configured activation depth. + int ActivationDepth(); + + /// + /// adds ConfigurationItems to be applied when + /// an ObjectContainer or ObjectServer is opened. + /// + /// + /// adds ConfigurationItems to be applied when + /// an ObjectContainer or ObjectServer is opened. + /// + /// the ConfigurationItem + void Add(IConfigurationItem configurationItem); + + /// adds a new Alias for a class, namespace or package. + /// + /// + /// adds a new Alias for a class, namespace or package. + ///
+ ///
+ /// Aliases can be used to persist classes in the running application + /// to different persistent classes in a database file or on a db4o + /// server. + ///
+ ///
+ /// Two simple Alias implementations are supplied along with db4o: + ///
+ /// - + /// TypeAlias + /// provides an #equals() resolver to match names directly. + ///
+ /// - + /// WildcardAlias + /// allows simple pattern matching with one single '*' wildcard + /// character. + ///
+ ///
+ /// It is possible to create own complex + /// IAlias + /// constructs by creating own resolvers that implement the + /// IAlias + /// interface. + ///
+ ///
+ /// Four examples of concrete usecases: + ///
+ ///
+ /// + /// // Creating an Alias for a single class + ///
+ /// Db4oFactory.Configure().AddAlias( + ///
  new TypeAlias("Tutorial.F1.Pilot", "Tutorial.F1.Driver"));
+ ///

+ /// // Accessing a Java package from a .NET assembly
+ /// Db4o.configure().addAlias(
+ ///   new WildcardAlias(
+ ///     "com.f1.*",
+ ///     "Tutorial.F1.*, Tutorial"));
+ ///

+ /// // Using a different local .NET assembly
+ /// Db4o.configure().addAlias(
+ ///   new WildcardAlias(
+ ///     "Tutorial.F1.*, Tutorial",
+ ///     "Tutorial.F1.*, RaceClient"));
+ ///
+ ///

Aliases that translate the persistent name of a class to + /// a name that already exists as a persistent name in the database + /// (or on the server) are not permitted and will throw an exception + /// when the database file is opened. + ///

Aliases should be configured before opening a database file + /// or connecting to a server. + ///
+ void AddAlias(IAlias alias); + + /// + /// Removes an alias previously added with + /// AddAlias(IAlias) + /// . + /// + /// the alias to remove + void RemoveAlias(IAlias alias); + + /// turns automatic database file format version updates on. + /// + /// turns automatic database file format version updates on. + ///

Upon db4o database file format version changes, + /// db4o can automatically update database files to the + /// current version. db4objects does not provide functionality + /// to reverse this process. It is not ensured that updated + /// database files can be read with older db4o versions. + /// In some cases (Example: using ObjectManager) it may not be + /// desirable to update database files automatically therefore + /// automatic updating is turned off by default for + /// security reasons. + ///

Call this method to turn automatic database file + /// version updating on. + ///

If automatic updating is turned off, db4o will refuse + /// to open database files that use an older database file format.

+ /// In client-server environment this setting should be used on both client + /// and server. + ///
+ void AllowVersionUpdates(bool flag); + + /// turns automatic shutdown of the engine on and off. + /// + /// turns automatic shutdown of the engine on and off. + /// + /// whether db4o should shut down automatically. + void AutomaticShutDown(bool flag); + + /// sets the storage data blocksize for new ObjectContainers. + /// + /// sets the storage data blocksize for new ObjectContainers. + ///

The standard setting is 1 allowing for a maximum + /// database file size of 2GB. This value can be increased + /// to allow larger database files, although some space will + /// be lost to padding because the size of some stored objects + /// will not be an exact multiple of the block size. A + /// recommended setting for large database files is 8, since + /// internal pointers have this length.

+ /// This setting is only effective when the database is first created, in + /// client-server environment in most cases it means that the setting + /// should be used on the server side. + ///
+ /// the size in bytes from 1 to 127 + /// + void BlockSize(int bytes); + + /// configures the size of BTree nodes in indexes. + /// + /// configures the size of BTree nodes in indexes. + ///

Default setting: 100 + ///
Lower values will allow a lower memory footprint + /// and more efficient reading and writing of small slots. + ///
Higher values will reduce the overall number of + /// read and write operations and allow better performance + /// at the cost of more RAM use.

+ /// This setting should be used on both client and server in + /// client-server environment. + ///
+ /// the number of elements held in one BTree node. + void BTreeNodeSize(int size); + + /// configures caching of BTree nodes. + /// + /// configures caching of BTree nodes. + ///

Clean BTree nodes will be unloaded on #commit and + /// #rollback unless they are configured as cached here. + ///

Default setting: 0 + ///
Possible settings: 1, 2 or 3 + ///

The potential number of cached BTree nodes can be + /// calculated with the following formula:
+ /// maxCachedNodes = bTreeNodeSize ^ bTreeCacheHeight

+ /// This setting should be used on both client and server in + /// client-server environment. + ///
+ /// the height of the cache from the root + void BTreeCacheHeight(int height); + + /// returns the Cache configuration interface. + /// returns the Cache configuration interface. + ICacheConfiguration Cache(); + + /// turns callback methods on and off. + /// + /// turns callback methods on and off. + ///

Callbacks are turned on by default.

+ /// A tuning hint: If callbacks are not used, you can turn this feature off, to + /// prevent db4o from looking for callback methods in persistent classes. This will + /// increase the performance on system startup.

+ /// In client/server environment this setting should be used on both + /// client and server. + ///
+ /// false to turn callback methods off + /// Using callbacks + void Callbacks(bool flag); + + /// + /// advises db4o to try instantiating objects with/without calling + /// constructors. + /// + /// + /// advises db4o to try instantiating objects with/without calling + /// constructors. + ///

+ /// Not all .NET-environments support this feature. db4o will + /// attempt, to follow the setting as good as the enviroment supports. + /// This setting may also be overridden for individual classes in + /// Db4objects.Db4o.Config.IObjectClass.CallConstructor + /// + /// . + ///

The default setting depends on the features supported by your current environment.

+ /// In client/server environment this setting should be used on both + /// client and server. + ///

+ ///
+ /// + /// - specify true, to request calling constructors, specify + /// false to request not calling constructors. + /// + /// Db4objects.Db4o.Config.IObjectClass.CallConstructor + /// + void CallConstructors(bool flag); + + /// + /// turns + /// individual class activation depth configuration + /// + /// on + /// and off. + ///

This feature is turned on by default.

+ /// In client/server environment this setting should be used on both + /// client and server.

+ ///
+ /// + /// false to turn the possibility to individually configure class + /// activation depths off + /// + /// Why activation? + void ClassActivationDepthConfigurable(bool flag); + + /// returns client/server configuration interface. + /// returns client/server configuration interface. + IClientServerConfiguration ClientServer(); + + /// + /// configures the size database files should grow in bytes, when no + /// free slot is found within. + /// + /// + /// configures the size database files should grow in bytes, when no + /// free slot is found within. + ///

Tuning setting. + ///

Whenever no free slot of sufficient length can be found + /// within the current database file, the database file's length + /// is extended. This configuration setting configures by how much + /// it should be extended, in bytes.

+ /// This configuration setting is intended to reduce fragmentation. + /// Higher values will produce bigger database files and less + /// fragmentation.

+ /// To extend the database file, a single byte array is created + /// and written to the end of the file in one write operation. Be + /// aware that a high setting will require allocating memory for + /// this byte array. + ///
+ /// amount of bytes + void DatabaseGrowthSize(int bytes); + + /// + /// tuning feature: configures whether db4o checks all persistent classes upon system + /// startup, for added or removed fields. + /// + /// + /// tuning feature: configures whether db4o checks all persistent classes upon system + /// startup, for added or removed fields. + ///

If this configuration setting is set to false while a database is + /// being created, members of classes will not be detected and stored. + ///

This setting can be set to false in a production environment after + /// all persistent classes have been stored at least once and classes will not + /// be modified any further in the future.

+ /// In a client/server environment this setting should be configured both on the + /// client and and on the server. + ///

Default value:
+ /// true + ///
+ /// the desired setting + void DetectSchemaChanges(bool flag); + + /// returns the configuration interface for diagnostics. + /// returns the configuration interface for diagnostics. + /// the configuration interface for diagnostics. + IDiagnosticConfiguration Diagnostic(); + + /// turns commit recovery off. + /// + /// turns commit recovery off. + ///

db4o uses a two-phase commit algorithm. In a first step all intended + /// changes are written to a free place in the database file, the "transaction commit + /// record". In a second step the + /// actual changes are performed. If the system breaks down during commit, the + /// commit process is restarted when the database file is opened the next time. + /// On very rare occasions (possibilities: hardware failure or editing the database + /// file with an external tool) the transaction commit record may be broken. In this + /// case, this method can be used to try to open the database file without commit + /// recovery. The method should only be used in emergency situations after consulting + /// db4o support. + ///
+ void DisableCommitRecovery(); + + /// configures the use of encryption. + /// + /// configures the use of encryption. + ///

This method needs to be called before a database file + /// is created with the first + /// Db4objects.Db4o.Db4oFactory.OpenFile(string) + /// + /// . + ///

If encryption is set to true, + /// you need to supply a password to seed the encryption mechanism.

+ /// db4o database files keep their encryption format after creation.

+ ///
+ /// + /// true for turning encryption on, false for turning encryption + /// off. + /// + /// Password(string) + /// + [System.ObsoleteAttribute(@"use a custom encrypting instead")] + void Encrypt(bool flag); + + /// configures whether Exceptions are to be thrown, if objects can not be stored. + /// + /// + /// configures whether Exceptions are to be thrown, if objects can not be stored. + ///

db4o requires the presence of a constructor that can be used to + /// instantiate objects. If no default public constructor is present, all + /// available constructors are tested, whether an instance of the class can + /// be instantiated. Null is passed to all constructor parameters. + /// The first constructor that is successfully tested will + /// be used throughout the running db4o session. If an instance of the class + /// can not be instantiated, the object will not be stored. By default, + /// execution will continue without any message or error. This method can + /// be used to configure db4o to throw an + /// ObjectNotStorableException + /// + /// if an object can not be stored. + ///

+ /// The default for this setting is true.

+ /// In client/server environment this setting should be used on both + /// client and server.

+ ///
+ /// false to not throw Exceptions if objects can not be stored (fail silently). + /// + void ExceptionsOnNotStorable(bool flag); + + /// returns the freespace configuration interface. + /// returns the freespace configuration interface. + IFreespaceConfiguration Freespace(); + + /// configures db4o to generate UUIDs for stored objects. + /// + /// configures db4o to generate UUIDs for stored objects. + /// This setting should be used when the database is first created.

+ ///
+ /// the scope for UUID generation: disabled, generate for all classes, or configure individually + /// + void GenerateUUIDs(ConfigScope setting); + + /// configures db4o to generate version numbers for stored objects. + /// + /// configures db4o to generate version numbers for stored objects. + /// This setting should be used when the database is first created. + /// + /// the scope for version number generation: disabled, generate for all classes, or configure individually + /// + [System.ObsoleteAttribute(@"As of version 8.0 please use GenerateCommitTimestamps(bool) instead." + )] + void GenerateVersionNumbers(ConfigScope setting); + + /// + /// Configures db4o to generate commit timestamps for all stored objects.
+ ///
+ /// All the objects commited within a transaction will share the same commit timestamp. + ///
+ /// + /// Configures db4o to generate commit timestamps for all stored objects.
+ ///
+ /// All the objects commited within a transaction will share the same commit timestamp. + ///
+ /// This setting should be used when the database is first created.
+ ///
+ /// Afterwards you can access the object's commit timestamp like this:
+ ///
+ ///
+		/// ObjectContainer container = ...;
+		/// ObjectInfo objectInfo = container.ext().getObjectInfo(obj);
+		/// long commitTimestamp = objectInfo.getVersion();
+		/// 
+ ///
+ /// + /// if true, commit timetamps will be generated for all stored + /// objects. If you already have commit timestamps for stored + /// objects and later set this flag to false, although you wont be + /// able to access them, the commit timestamps will still be taking + /// space in your file container. The only way to free that space + /// is defragmenting the container. + /// + /// 8.0 + void GenerateCommitTimestamps(bool flag); + + /// configures db4o to call #intern() on strings upon retrieval. + /// + /// configures db4o to call #intern() on strings upon retrieval. + /// In client/server environment the setting should be used on both + /// client and server. + /// + /// true to intern strings + void InternStrings(bool flag); + + /// returns true if strings will be interned. + /// returns true if strings will be interned. + bool InternStrings(); + + /// allows to configure db4o to use a customized byte IO adapter. + /// + /// allows to configure db4o to use a customized byte IO adapter. + ///

Derive from the abstract class + /// Db4objects.Db4o.IO.IoAdapter + /// to + /// write your own. Possible usecases could be improved performance + /// with a native library, mirrored write to two files, encryption or + /// read-on-write fail-safety control.

An example of a custom + /// io adapter can be found in xtea_db4o community project:
+ /// http://developer.db4o.com/ProjectSpaces/view.aspx/XTEA

+ /// In client-server environment this setting should be used on the server + /// (adapter class must be available)

+ ///
+ /// - the IoAdapter + /// + [System.ObsoleteAttribute(@"Use Storage(Db4objects.Db4o.IO.IStorage) instead.")] + void Io(IoAdapter adapter); + + /// allows to configure db4o to use a customized byte IO storage mechanism. + /// + /// allows to configure db4o to use a customized byte IO storage mechanism. + ///

Implement the interface + /// Db4objects.Db4o.IO.IStorage + /// to + /// write your own. Possible usecases could be improved performance + /// with a native library, mirrored write to two files, encryption or + /// read-on-write fail-safety control.

+ ///
+ /// - the factory + /// Db4objects.Db4o.IO.CachingStorage + /// + /// Db4objects.Db4o.IO.MemoryStorage + /// + /// Db4objects.Db4o.IO.FileStorage + /// Db4objects.Db4o.IO.StorageDecorator + /// + /// + /// + /// returns the configured + /// Db4objects.Db4o.IO.IStorage + /// + IStorage Storage + { + get; + set; + } + + /// + /// returns the configured + /// Db4objects.Db4o.IO.IoAdapter + /// . + /// + /// + [System.ObsoleteAttribute(@"Use Storage() instead.")] + IoAdapter Io(); + + /// allows to mark fields as transient with custom attributes. + /// + /// allows to mark fields as transient with custom attributes. + ///

.NET only: Call this method with the attribute name that you + /// wish to use to mark fields as transient. Multiple transient attributes + /// are possible by calling this method multiple times with different + /// attribute names.

+ /// In client/server environment the setting should be used on both + /// client and server.

+ ///
+ /// + /// - the fully qualified name of the attribute, including + /// it's namespace + /// + void MarkTransient(string attributeName); + + /// sets the detail level of db4o messages. + /// + /// sets the detail level of db4o messages. Messages will be output to the + /// configured output + /// TextWriter + /// . + ///

+ /// Level 0 - no messages
+ /// Level 1 - open and close messages
+ /// Level 2 - messages for new, update and delete
+ /// Level 3 - messages for activate and deactivate

+ /// When using client-server and the level is set to 0, the server will override this and set it to 1. To get around this you can set the level to -1. This has the effect of not returning any messages.

+ /// In client-server environment this setting can be used on client or on server + /// depending on which information do you want to track (server side provides more + /// detailed information).

+ ///
+ /// integer from 0 to 3 + /// SetOut(System.IO.TextWriter) + void MessageLevel(int level); + + /// can be used to turn the database file locking thread off. + /// + /// false to turn database file locking off. + /// + void LockDatabaseFile(bool flag); + + /// + /// returns an + /// IObjectClass + /// object + /// to configure the specified class. + ///

+ /// The clazz parameter can be any of the following:
+ /// - a fully qualified classname as a String.
+ /// - a Class object.
+ /// - any other object to be used as a template.

+ ///
+ /// class name, Class object, or example object.

+ /// + /// an instance of an + /// IObjectClass + /// object for configuration. + /// + IObjectClass ObjectClass(object clazz); + + /// + /// If set to true, db4o will try to optimize native queries + /// dynamically at query execution time, otherwise it will + /// run native queries in unoptimized mode as SODA evaluations. + /// + /// + /// If set to true, db4o will try to optimize native queries + /// dynamically at query execution time, otherwise it will + /// run native queries in unoptimized mode as SODA evaluations. + /// The following assemblies should be available for native query switch to take effect: + /// Db4objects.Db4o.NativeQueries.dll, Db4objects.Db4o.Instrumentation.dll. + ///

The default setting is true.

+ /// In client-server environment this setting should be used on both client and server.

+ ///
+ /// + /// true, if db4o should try to optimize + /// native queries at query execution time, false otherwise + /// + /// + /// Db4objects.Db4o.Config.ICommonConfiguration.OptimizeNativeQueries + void OptimizeNativeQueries(bool optimizeNQ); + + /// indicates whether Native Queries will be optimized dynamically. + /// indicates whether Native Queries will be optimized dynamically. + /// + /// boolean true if Native Queries will be optimized + /// dynamically. + /// + /// OptimizeNativeQueries() + bool OptimizeNativeQueries(); + + /// protects the database file with a password. + /// + /// protects the database file with a password. + ///

To set a password for a database file, this method needs to be + /// called before a database file is created with the first + /// Db4objects.Db4o.Db4oFactory.OpenFile(string) + /// + /// . + ///

All further attempts to open + /// the file, are required to set the same password.

The password + /// is used to seed the encryption mechanism, which makes it impossible + /// to read the database file without knowing the password.

+ ///
+ /// the password to be used. + /// + [System.ObsoleteAttribute(@"use a custom encrypting instead")] + void Password(string pass); + + /// returns the Query configuration interface. + /// returns the Query configuration interface. + IQueryConfiguration Queries(); + + /// turns readOnly mode on and off. + /// + /// turns readOnly mode on and off. + ///

This method configures the mode in which subsequent calls to + /// Db4o.openFile() + /// will open files. + ///

Readonly mode allows to open an unlimited number of reading + /// processes on one database file. It is also convenient + /// for deploying db4o database files on CD-ROM.

+ /// In client-server environment this setting should be used on the server side + /// in embedded mode and ONLY on client side in networked mode.

+ ///
+ /// + /// true for configuring readOnly mode for subsequent + /// calls to + /// Db4o.openFile() + /// . + /// + void ReadOnly(bool flag); + + /// + /// turns recovery mode on and off.

+ /// Recovery mode can be used to try to retrieve as much as possible + /// out of an already corrupted database. + ///
+ /// + /// turns recovery mode on and off.

+ /// Recovery mode can be used to try to retrieve as much as possible + /// out of an already corrupted database. In recovery mode internal + /// checks are more relaxed. Null or invalid objects may be returned + /// instead of throwing exceptions.

+ /// Use this method with care as a last resort to get data out of a + /// corrupted database. + ///
+ /// true to turn recover mode on. + void RecoveryMode(bool flag); + + /// configures the use of a specially designed reflection implementation. + /// + /// configures the use of a specially designed reflection implementation. + ///

+ /// db4o internally uses System.Reflection by default. On platforms that + /// do not support this package, customized implementations may be written + /// to supply all the functionality of the interfaces in System.Reflection + /// namespace. This method can be used to install a custom reflection + /// implementation. + /// + ///
+ void ReflectWith(IReflector reflector); + + /// tuning feature only: reserves a number of bytes in database files. + /// + /// tuning feature only: reserves a number of bytes in database files. + ///

The global setting is used for the creation of new database + /// files. Continous calls on an ObjectContainer Configuration context + /// (see + /// Db4objects.Db4o.Ext.IExtObjectContainer.Configure() + /// + /// ) will + /// continually allocate space. + ///

The allocation of a fixed number of bytes at one time + /// makes it more likely that the database will be stored in one + /// chunk on the mass storage. Less read/write head movement can result + /// in improved performance.

+ /// Note:
Allocated space will be lost on abnormal termination + /// of the database engine (hardware crash, VM crash). A Defragment run + /// will recover the lost space. For the best possible performance, this + /// method should be called before the Defragment run to configure the + /// allocation of storage space to be slightly greater than the anticipated + /// database file size. + ///

+ /// In client-server environment this setting should be used on the server side.

+ /// Default configuration: 0

+ ///
+ /// the number of bytes to reserve + /// + /// + void ReserveStorageSpace(long byteCount); + + /// + /// configures the path to be used to store and read + /// Blob data. + /// + /// + /// configures the path to be used to store and read + /// Blob data. + ///

+ /// In client-server environment this setting should be used on the + /// server side.

+ ///
+ /// the path to be used + /// + void SetBlobPath(string path); + + /// + /// Assigns a + /// TextWriter + /// where db4o is to print its event messages. + ///

Messages are useful for debugging purposes and for learning + /// to understand, how db4o works. The message level can be raised with + /// MessageLevel(int) + /// to produce more detailed messages. + ///

Use setOut(System.out) to print messages to the + /// console.

+ /// In client-server environment this setting should be used on the same side + /// where + /// MessageLevel(int) + /// is used.

+ ///
+ /// the new PrintStream for messages. + /// MessageLevel(int) + void SetOut(TextWriter outStream); + + /// configures the string encoding to be used. + /// + /// configures the string encoding to be used. + ///

The string encoding can not be changed in the lifetime of a + /// database file. To set up the database with the correct string encoding, + /// this configuration needs to be set correctly before a database + /// file is created with the first call to + /// Db4objects.Db4o.Db4oFactory.OpenFile + /// + /// or + /// Db4objects.Db4o.Db4oFactory.OpenServer + /// + /// . + ///

For subsequent open calls, db4o remembers built-in + /// string encodings. If a custom encoding is used (an encoding that is + /// not supplied from within the db4o library), the correct encoding + /// needs to be configured correctly again for all subsequent calls + /// that open database files. + ///

Example:
+ /// config.StringEncoding(StringEncodings.Utf8()); + ///
+ /// Db4objects.Db4o.Config.Encoding.StringEncodings + /// + void StringEncoding(IStringEncoding encoding); + + /// + /// tuning feature: configures whether db4o should try to instantiate one instance + /// of each persistent class on system startup. + /// + /// + /// tuning feature: configures whether db4o should try to instantiate one instance + /// of each persistent class on system startup. + ///

In a production environment this setting can be set to false, + /// if all persistent classes have public default constructors. + ///

+ /// In client-server environment this setting should be used on both client and server + /// side.

+ /// Default value:
+ /// true + ///
+ /// the desired setting + void TestConstructors(bool flag); + + /// specifies the global updateDepth. + /// + /// specifies the global updateDepth. + ///

see the documentation of + /// + /// for further details.

+ /// The value be may be overridden for individual classes.

+ /// The default setting is 1: Only the object passed to + /// com.db4o.ObjectContainer#set + /// will be updated.

+ /// In client-server environment this setting should be used on both client and + /// server sides.

+ ///
+ /// the depth of the desired update. + /// IObjectClass.UpdateDepth(int) + /// IObjectClass.CascadeOnUpdate(bool) + /// + /// Using callbacks + void UpdateDepth(int depth); + + /// turns weak reference management on or off. + /// + /// turns weak reference management on or off. + ///

+ /// This method must be called before opening a database. + ///

+ /// Performance may be improved by running db4o without using weak + /// references durring memory management at the cost of higher + /// memory consumption or by alternatively implementing a manual + /// memory management scheme using + /// IExtObjectContainer.Purge + ///

Setting the value to false causes db4o to use hard + /// references to objects, preventing the garbage collection process + /// from disposing of unused objects. + ///

The default setting is true. + ///
+ void WeakReferences(bool flag); + + /// configures the timer for WeakReference collection. + /// + /// configures the timer for WeakReference collection. + ///

The default setting is 1000 milliseconds. + ///

Configure this setting to zero to turn WeakReference + /// collection off. + /// + ///
+ /// the time in milliseconds + void WeakReferenceCollectionInterval(int milliseconds); + + /// + /// allows registering special TypeHandlers for customized marshalling + /// and customized comparisons. + /// + /// + /// allows registering special TypeHandlers for customized marshalling + /// and customized comparisons. + /// + /// + /// to specify for which classes and versions the + /// TypeHandler is to be used. + /// + /// to be used for the classes that match the predicate. + void RegisterTypeHandler(ITypeHandlerPredicate predicate, ITypeHandler4 typeHandler + ); + + /// ICommonConfiguration.MaxStackDepth() + /// + int MaxStackDepth(); + + /// + void MaxStackDepth(int maxStackDepth); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/IConfigurationItem.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/IConfigurationItem.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/IConfigurationItem.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/IConfigurationItem.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,32 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Config; +using Db4objects.Db4o.Internal; + +namespace Db4objects.Db4o.Config +{ + /// + /// Implement this interface for configuration items that encapsulate + /// a batch of configuration settings or that need to be applied + /// to ObjectContainers after they are opened. + /// + /// + /// Implement this interface for configuration items that encapsulate + /// a batch of configuration settings or that need to be applied + /// to ObjectContainers after they are opened. + /// + public interface IConfigurationItem + { + /// Gives a chance for the item to augment the configuration. + /// Gives a chance for the item to augment the configuration. + /// the configuration that the item was added to + void Prepare(IConfiguration configuration); + + /// Gives a chance for the item to configure the just opened ObjectContainer. + /// + /// Gives a chance for the item to configure the just opened ObjectContainer. + /// + /// the ObjectContainer to configure + void Apply(IInternalObjectContainer container); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/IEmbeddedConfiguration.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/IEmbeddedConfiguration.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/IEmbeddedConfiguration.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/IEmbeddedConfiguration.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,26 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Config; + +namespace Db4objects.Db4o.Config +{ + /// Configuration interface for db4o in embedded use. + /// Configuration interface for db4o in embedded use. + /// 7.5 + public interface IEmbeddedConfiguration : IFileConfigurationProvider, ICommonConfigurationProvider + , ICacheConfigurationProvider, IIdSystemConfigurationProvider + { + /// + /// adds ConfigurationItems to be applied when + /// a networking + /// EmbeddedObjectContainer + /// is opened. + /// + /// + /// the + /// IEmbeddedConfigurationItem + /// + /// 7.12 + void AddConfigurationItem(IEmbeddedConfigurationItem configItem); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/IEmbeddedConfigurationItem.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/IEmbeddedConfigurationItem.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/IEmbeddedConfigurationItem.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/IEmbeddedConfigurationItem.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,33 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o; +using Db4objects.Db4o.Config; + +namespace Db4objects.Db4o.Config +{ + /// + /// Implement this interface for configuration items that encapsulate + /// a batch of configuration settings or that need to be applied + /// to EmbeddedObjectContainers after they are opened. + /// + /// + /// Implement this interface for configuration items that encapsulate + /// a batch of configuration settings or that need to be applied + /// to EmbeddedObjectContainers after they are opened. + /// + /// 7.12 + public interface IEmbeddedConfigurationItem + { + /// Gives a chance for the item to augment the configuration. + /// Gives a chance for the item to augment the configuration. + /// the configuration that the item was added to + void Prepare(IEmbeddedConfiguration configuration); + + /// Gives a chance for the item to configure the just opened ObjectContainer. + /// + /// Gives a chance for the item to configure the just opened ObjectContainer. + /// + /// the ObjectContainer to configure + void Apply(IEmbeddedObjectContainer db); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/IEnvironmentConfiguration.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/IEnvironmentConfiguration.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/IEnvironmentConfiguration.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/IEnvironmentConfiguration.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,18 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +namespace Db4objects.Db4o.Config +{ + /// Configures the environment (set of services) used by db4o. + /// Configures the environment (set of services) used by db4o. + /// Db4objects.Db4o.Foundation.IEnvironment + /// + /// Db4objects.Db4o.Foundation.Environments.My(System.Type<T>) + /// + public interface IEnvironmentConfiguration + { + /// Contributes a service to the db4o environment. + /// Contributes a service to the db4o environment. + /// + void Add(object service); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/IFileConfiguration.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/IFileConfiguration.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/IFileConfiguration.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/IFileConfiguration.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,316 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Config; +using Db4objects.Db4o.IO; + +namespace Db4objects.Db4o.Config +{ + /// + /// File-related configuration methods, applicable + /// for db4o embedded use and on the server in a + /// Client/Server setup. + /// + /// + /// File-related configuration methods, applicable + /// for db4o embedded use and on the server in a + /// Client/Server setup. + /// + /// 7.5 + /// IFileConfigurationProvider.File() + /// + public interface IFileConfiguration + { + /// sets the storage data blocksize for new ObjectContainers. + /// + /// sets the storage data blocksize for new ObjectContainers. + ///

The standard setting is 1 allowing for a maximum + /// database file size of 2GB. This value can be increased + /// to allow larger database files, although some space will + /// be lost to padding because the size of some stored objects + /// will not be an exact multiple of the block size. A + /// recommended setting for large database files is 8, since + /// internal pointers have this length.

+ /// This setting is only effective when the database is first created. + ///
+ /// the size in bytes from 1 to 127 + int BlockSize + { + set; + } + + /// + /// configures the size database files should grow in bytes, when no + /// free slot is found within. + /// + /// + /// configures the size database files should grow in bytes, when no + /// free slot is found within. + ///

Tuning setting. + ///

Whenever no free slot of sufficient length can be found + /// within the current database file, the database file's length + /// is extended. This configuration setting configures by how much + /// it should be extended, in bytes.

+ /// This configuration setting is intended to reduce fragmentation. + /// Higher values will produce bigger database files and less + /// fragmentation.

+ /// To extend the database file, a single byte array is created + /// and written to the end of the file in one write operation. Be + /// aware that a high setting will require allocating memory for + /// this byte array. + ///
+ /// amount of bytes + int DatabaseGrowthSize + { + set; + } + + /// turns commit recovery off. + /// + /// turns commit recovery off. + ///

db4o uses a two-phase commit algorithm. In a first step all intended + /// changes are written to a free place in the database file, the "transaction commit + /// record". In a second step the + /// actual changes are performed. If the system breaks down during commit, the + /// commit process is restarted when the database file is opened the next time. + /// On very rare occasions (possibilities: hardware failure or editing the database + /// file with an external tool) the transaction commit record may be broken. In this + /// case, this method can be used to try to open the database file without commit + /// recovery. The method should only be used in emergency situations after consulting + /// db4o support. + ///
+ void DisableCommitRecovery(); + + /// returns the freespace configuration interface. + /// returns the freespace configuration interface. + IFreespaceConfiguration Freespace + { + get; + } + + /// configures db4o to generate UUIDs for stored objects. + /// + /// configures db4o to generate UUIDs for stored objects. + /// This setting should be used when the database is first created.

+ ///
+ /// the scope for UUID generation: disabled, generate for all classes, or configure individually + /// + ConfigScope GenerateUUIDs + { + set; + } + + /// configures db4o to generate version numbers for stored objects. + /// + /// configures db4o to generate version numbers for stored objects. + /// This setting should be used when the database is first created. + /// + /// the scope for version number generation: disabled, generate for all classes, or configure individually + /// + [System.ObsoleteAttribute(@"As of version 8.0 please use GenerateCommitTimestamps(bool) instead." + )] + ConfigScope GenerateVersionNumbers + { + set; + } + + /// + /// Configures db4o to generate commit timestamps for all stored objects.
+ ///
+ /// All the objects commited within a transaction will share the same commit timestamp. + ///
+ /// + /// Configures db4o to generate commit timestamps for all stored objects.
+ ///
+ /// All the objects commited within a transaction will share the same commit timestamp. + ///
+ /// This setting should be used when the database is first created.
+ ///
+ /// Afterwards you can access the object's commit timestamp like this:
+ ///
+ ///
+		/// ObjectContainer container = ...;
+		/// ObjectInfo objectInfo = container.ext().getObjectInfo(obj);
+		/// long commitTimestamp = objectInfo.getVersion();
+		/// 
+ ///
+ /// + /// if true, commit timetamps will be generated for all stored + /// objects. If you already have commit timestamps for stored + /// objects and later set this flag to false, although you wont be + /// able to access them, the commit timestamps will still be taking + /// space in your file container. The only way to free that space + /// is defragmenting the container. + /// + /// 8.0 + bool GenerateCommitTimestamps + { + set; + } + + /// allows to configure db4o to use a customized byte IO storage mechanism. + /// + /// allows to configure db4o to use a customized byte IO storage mechanism. + ///

You can implement the interface + /// Db4objects.Db4o.IO.IStorage + /// to + /// write your own. Possible usecases could be improved performance + /// with a native library, mirrored write to two files, encryption or + /// read-on-write fail-safety control.

+ ///
+ /// - the storage + /// Db4objects.Db4o.IO.FileStorage + /// Db4objects.Db4o.IO.CachingStorage + /// + /// Db4objects.Db4o.IO.MemoryStorage + /// + /// + /// + /// returns the configured + /// Db4objects.Db4o.IO.IStorage + /// . + /// + /// + IStorage Storage + { + get; + set; + } + + /// can be used to turn the database file locking thread off. + /// + /// can be used to turn the database file locking thread off. + ///

Caution!
If database file + /// locking is turned off, concurrent write access to the same + /// database file from different sessions will corrupt the + /// database file immediately.

This method + /// has no effect on open ObjectContainers. It will only affect how + /// ObjectContainers are opened.

+ /// The default setting is true.

+ /// + ///
+ bool LockDatabaseFile + { + set; + } + + /// tuning feature only: reserves a number of bytes in database files. + /// + /// tuning feature only: reserves a number of bytes in database files. + ///

The global setting is used for the creation of new database + /// files. + ///

Without this setting, storage space will be allocated + /// continuously as required. However, allocation of a fixed number + /// of bytes at one time makes it more likely that the database will be + /// stored in one chunk on the mass storage. Less read/write head movement + /// can result in improved performance.

+ /// Note:
Allocated space will be lost on abnormal termination + /// of the database engine (hardware crash, VM crash). A Defragment run + /// will recover the lost space. For the best possible performance, this + /// method should be called before the Defragment run to configure the + /// allocation of storage space to be slightly greater than the anticipated + /// database file size. + ///

+ /// Default configuration: 0

+ ///
+ /// the number of bytes to reserve + /// + /// + long ReserveStorageSpace + { + set; + } + + /// + /// configures the path to be used to store and read + /// Blob data. + /// + /// + /// configures the path to be used to store and read + /// Blob data. + ///

+ ///
+ /// the path to be used + /// + string BlobPath + { + set; + } + + /// turns readOnly mode on and off. + /// + /// turns readOnly mode on and off. + ///

This method configures the mode in which subsequent calls to + /// Db4objects.Db4o.Db4oEmbedded.OpenFile(IEmbeddedConfiguration, string) + /// + /// will open files. + ///

Readonly mode allows to open an unlimited number of reading + /// processes on one database file. It is also convenient + /// for deploying db4o database files on CD-ROM.

+ ///
+ /// + /// true for configuring readOnly mode for subsequent + /// calls to + /// Db4o.openFile() + /// . + /// TODO: this is rather embedded + client than base? + /// + bool ReadOnly + { + set; + } + + /// + /// turns recovery mode on and off.

+ /// Recovery mode can be used to try to retrieve as much as possible + /// out of an already corrupted database. + ///
+ /// + /// turns recovery mode on and off.

+ /// Recovery mode can be used to try to retrieve as much as possible + /// out of an already corrupted database. In recovery mode internal + /// checks are more relaxed. Null or invalid objects may be returned + /// instead of throwing exceptions.

+ /// Use this method with care as a last resort to get data out of a + /// corrupted database. + ///
+ /// true to turn recover mode on. + bool RecoveryMode + { + set; + } + + /// + /// turns asynchronous sync on and off.

+ /// One of the most costly operations during commit is the call to + /// flush the buffers of the database file. + ///
+ /// + /// turns asynchronous sync on and off.

+ /// One of the most costly operations during commit is the call to + /// flush the buffers of the database file. In regular mode the + /// commit call has to wait until this operation has completed. + /// When asynchronous sync is turned on, the sync operation will + /// run in a dedicated thread, blocking all other file access + /// until it has completed. This way the commit call can return + /// immediately. This will allow db4o and other processes to + /// continue running side-by-side while the flush call executes. + /// Use this setting with care: It means that you can not be sure + /// when a commit call has actually made the changes of a + /// transaction durable (flushed through OS and file system + /// buffers). The latency time until flushing happens is extremely + /// short. The dedicated sync thread does nothing else + /// except for calling sync and writing the header of the database + /// file when needed. A setup with this option still guarantees + /// ACID transaction processing: A database file always will be + /// either in the state before commit or in the state after + /// commit. Corruption can not occur. You can just not rely + /// on the transaction already having been applied when the + /// commit() call returns. + ///
+ bool AsynchronousSync + { + set; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/IFileConfigurationProvider.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/IFileConfigurationProvider.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/IFileConfigurationProvider.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/IFileConfigurationProvider.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,24 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Config; + +namespace Db4objects.Db4o.Config +{ + /// + /// A configuration provider that provides access + /// to the file-related configuration methods. + /// + /// + /// A configuration provider that provides access + /// to the file-related configuration methods. + /// + public interface IFileConfigurationProvider + { + /// Access to the file-related configuration methods. + /// Access to the file-related configuration methods. + IFileConfiguration File + { + get; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/IFreespaceConfiguration.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/IFreespaceConfiguration.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/IFreespaceConfiguration.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/IFreespaceConfiguration.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,86 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Config; + +namespace Db4objects.Db4o.Config +{ + /// interface to configure the freespace system to be used. + /// + /// interface to configure the freespace system to be used. + ///

All methods should be called before opening database files. + /// If db4o is instructed to exchange the system + /// ( + /// UseBTreeSystem() + /// , + /// UseRamSystem() + /// ) + /// this will happen on opening the database file.

+ /// By default the ram based system will be used. + ///
+ public interface IFreespaceConfiguration + { + /// + /// tuning feature: configures the minimum size of free space slots in the database file + /// that are to be reused. + /// + /// + /// tuning feature: configures the minimum size of free space slots in the database file + /// that are to be reused. + ///

When objects are updated or deleted, the space previously occupied in the + /// database file is marked as "free", so it can be reused. db4o maintains two lists + /// in RAM, sorted by address and by size. Adjacent entries are merged. After a large + /// number of updates or deletes have been executed, the lists can become large, causing + /// RAM consumption and performance loss for maintenance. With this method you can + /// specify an upper bound for the byte slot size to discard. + ///

Pass Integer.MAX_VALUE to this method to discard all free slots for + /// the best possible startup time.

+ /// The downside of setting this value: Database files will necessarily grow faster. + ///

Default value:
+ /// 0 all space is reused + ///
+ /// Slots with this size or smaller will be lost. + void DiscardSmallerThan(int byteCount); + + /// + /// Configure a way to overwrite freed space in the database file with custom + /// (for example: random) bytes. + /// + /// + /// Configure a way to overwrite freed space in the database file with custom + /// (for example: random) bytes. Will slow down I/O operation. + /// The value of this setting may be cached internally and can thus not be + /// reliably set after an object container has been opened. + /// + /// The freespace overwriting callback to use + void FreespaceFiller(IFreespaceFiller freespaceFiller); + + /// configures db4o to use a BTree-based freespace system. + /// + /// configures db4o to use a BTree-based freespace system. + ///

Advantages
+ /// - ACID, no freespace is lost on abnormal system termination
+ /// - low memory consumption
+ ///
Disadvantages
+ /// - slower than the RAM-based system, since freespace information + /// is written during every commit
+ ///
+ void UseBTreeSystem(); + + /// discontinued freespace system, only available before db4o 7.0. + /// discontinued freespace system, only available before db4o 7.0. + [System.ObsoleteAttribute(@"Please use the BTree freespace system instead by calling UseBTreeSystem() ." + )] + void UseIndexSystem(); + + /// configures db4o to use a RAM-based freespace system. + /// + /// configures db4o to use a RAM-based freespace system. + ///

Advantages
+ /// - best performance
+ ///
Disadvantages
+ /// - upon abnormal system termination all freespace is lost
+ /// - memory consumption
+ ///
+ void UseRamSystem(); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/IFreespaceFiller.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/IFreespaceFiller.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/IFreespaceFiller.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/IFreespaceFiller.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,17 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.IO; + +namespace Db4objects.Db4o.Config +{ + /// Callback hook for overwriting freed space in the database file. + /// Callback hook for overwriting freed space in the database file. + public interface IFreespaceFiller + { + /// Called to overwrite freed space in the database file. + /// Called to overwrite freed space in the database file. + /// Handle for the freed slot + /// + void Fill(BlockAwareBinWindow io); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/IIdSystemConfiguration.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/IIdSystemConfiguration.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/IIdSystemConfiguration.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/IIdSystemConfiguration.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,59 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Config; + +namespace Db4objects.Db4o.Config +{ + /// Interface to configure the IdSystem. + /// Interface to configure the IdSystem. + public interface IIdSystemConfiguration + { + /// configures db4o to store IDs as pointers. + /// configures db4o to store IDs as pointers. + void UsePointerBasedSystem(); + + /// + /// configures db4o to use a stack of two BTreeIdSystems on + /// top of an InMemoryIdSystem. + /// + /// + /// configures db4o to use a stack of two BTreeIdSystems on + /// top of an InMemoryIdSystem. This setup is scalable for + /// large numbers of IDs. It is the default configuration + /// when new databases are created. + /// + void UseStackedBTreeSystem(); + + /// + /// configures db4o to use a single BTreeIdSystem on + /// top of an InMemoryIdSystem. + /// + /// + /// configures db4o to use a single BTreeIdSystem on + /// top of an InMemoryIdSystem. This setup is suitable for + /// smaller databases with a small number of IDs. + /// For larger numbers of IDs call + /// UseStackedBTreeSystem() + /// . + /// + void UseSingleBTreeSystem(); + + /// configures db4o to use an in-memory ID system. + /// + /// configures db4o to use an in-memory ID system. + /// All IDs get written to the database file on every commit. + /// + void UseInMemorySystem(); + + /// configures db4o to use a custom ID system. + /// + /// configures db4o to use a custom ID system. + /// Pass an + /// IIdSystemFactory + /// that creates the IdSystem. + /// Note that this factory has to be configured every time you + /// open a database that you configured to use a custom IdSystem. + /// + void UseCustomSystem(IIdSystemFactory factory); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/IIdSystemConfigurationProvider.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/IIdSystemConfigurationProvider.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/IIdSystemConfigurationProvider.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/IIdSystemConfigurationProvider.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,24 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Config; + +namespace Db4objects.Db4o.Config +{ + /// + /// A configuration provider that provides access + /// to the IdSystem-related configuration methods. + /// + /// + /// A configuration provider that provides access + /// to the IdSystem-related configuration methods. + /// + public interface IIdSystemConfigurationProvider + { + /// Access to the IdSystem-related configuration methods. + /// Access to the IdSystem-related configuration methods. + IIdSystemConfiguration IdSystem + { + get; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/IIdSystemFactory.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/IIdSystemFactory.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/IIdSystemFactory.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/IIdSystemFactory.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,18 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Ids; + +namespace Db4objects.Db4o.Config +{ + /// Factory interface to create a custom IdSystem. + /// Factory interface to create a custom IdSystem. + /// + public interface IIdSystemFactory + { + /// creates + /// + /// + IIdSystem NewInstance(LocalObjectContainer container); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/ILegacyClientServerFactory.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/ILegacyClientServerFactory.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/ILegacyClientServerFactory.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/ILegacyClientServerFactory.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,25 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o; +using Db4objects.Db4o.Config; + +namespace Db4objects.Db4o.Config +{ + /// + public interface ILegacyClientServerFactory + { + /// + /// + /// + IObjectContainer OpenClient(IConfiguration config, string hostName, int port, string + user, string password); + + /// + /// + /// + /// + /// + IObjectServer OpenServer(IConfiguration config, string databaseFileName, int port + ); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/INameProvider.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/INameProvider.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/INameProvider.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/INameProvider.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,25 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o; + +namespace Db4objects.Db4o.Config +{ + /// A provider for custom database names. + /// A provider for custom database names. + public interface INameProvider + { + /// + /// Derives a name for the given + /// Db4objects.Db4o.IObjectContainer + /// . This method will be called when + /// database startup has completed, i.e. the method will see a completely initialized + /// Db4objects.Db4o.IObjectContainer + /// . + /// Any code invoked during the startup process (for example + /// IConfigurationItem + /// instances) will still + /// see the default naming. + /// + string Name(IObjectContainer db); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/IObjectAttribute.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/IObjectAttribute.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/IObjectAttribute.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/IObjectAttribute.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,15 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +namespace Db4objects.Db4o.Config +{ + /// generic interface to allow returning an attribute of an object. + /// generic interface to allow returning an attribute of an object. + public interface IObjectAttribute + { + /// generic method to return an attribute of a parent object. + /// generic method to return an attribute of a parent object. + /// the parent object + /// Object - the attribute + object Attribute(object parent); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/IObjectClass.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/IObjectClass.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/IObjectClass.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/IObjectClass.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,347 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Config; + +namespace Db4objects.Db4o.Config +{ + /// configuration interface for classes. + /// + /// configuration interface for classes. + ///

+ /// Use the global + /// ICommonConfiguration.ObjectClass(object) + /// + /// to configure + /// object class settings. + ///
+ public interface IObjectClass + { + /// + /// advises db4o to try instantiating objects of this class with/without + /// calling constructors. + /// + /// + /// advises db4o to try instantiating objects of this class with/without + /// calling constructors. + ///

+ /// Not all .NET-environments support this feature. db4o will + /// attempt, to follow the setting as good as the enviroment supports. + ///

+ /// This setting may also be set globally for all classes in + /// Db4objects.Db4o.Config.IConfiguration.CallConstructors + /// + /// .

+ /// In client-server environment this setting should be used on both + /// client and server.

+ /// This setting can be applied to an open object container.

+ ///
+ /// + /// - specify true, to request calling constructors, specify + /// false to request not calling constructors. + /// + /// Db4objects.Db4o.Config.IConfiguration.CallConstructors + /// + void CallConstructor(bool flag); + + /// sets cascaded activation behaviour. + /// + /// sets cascaded activation behaviour. + ///

+ /// Setting cascadeOnActivate to true will result in the activation + /// of all member objects if an instance of this class is activated. + ///

+ /// The default setting is false.

+ /// In client-server environment this setting should be used on both + /// client and server.

+ /// Can be applied to an open ObjectContainer.

+ ///
+ /// whether activation is to be cascaded to member objects. + /// IObjectField.CascadeOnActivate(bool) + /// + /// Db4objects.Db4o.IObjectContainer.Activate(object, int) + /// + /// Using callbacks + /// Why activation? + void CascadeOnActivate(bool flag); + + /// sets cascaded delete behaviour. + /// + /// sets cascaded delete behaviour. + ///

+ /// Setting CascadeOnDelete to true will result in the deletion of + /// all member objects of instances of this class, if they are + /// passed to + /// Db4objects.Db4o.IObjectContainer.Delete + /// + /// . + ///

+ /// Caution !
+ /// This setting will also trigger deletion of old member objects, on + /// calls to + /// Db4objects.Db4o.IObjectContainer.Store + /// + /// .

+ /// An example of the behaviour:
+ /// + /// ObjectContainer con;
+ /// Bar bar1 = new Bar();
+ /// Bar bar2 = new Bar();
+ /// foo.bar = bar1;
+ /// con.Store(foo); // bar1 is stored as a member of foo
+ /// foo.bar = bar2;
+ /// con.Store(foo); // bar2 is stored as a member of foo + ///

The last statement will also delete bar1 from the + /// ObjectContainer, no matter how many other stored objects hold references + /// to bar1. + ///

+ /// The default setting is false.

+ /// In client-server environment this setting should be used on both + /// client and server.

+ /// This setting can be applied to an open object container.

+ ///
+ /// whether deletes are to be cascaded to member objects. + /// Db4objects.Db4o.Config.IObjectField.CascadeOnDelete + /// + /// Db4objects.Db4o.IObjectContainer.Delete + /// + /// Using callbacks + void CascadeOnDelete(bool flag); + + /// sets cascaded update behaviour. + /// + /// sets cascaded update behaviour. + ///

+ /// Setting cascadeOnUpdate to true will result in the update + /// of all member objects if a stored instance of this class is passed + /// to + /// Db4objects.Db4o.IObjectContainer.Store(object) + /// + /// .

+ /// The default setting is false. Setting it to true + /// may result in serious performance degradation.

+ /// In client-server environment this setting should be used on both + /// client and server.

+ /// This setting can be applied to an open object container.

+ ///
+ /// whether updates are to be cascaded to member objects. + /// IObjectField.CascadeOnUpdate(bool) + /// + /// com.db4o.ObjectContainer#set + /// Using callbacks + void CascadeOnUpdate(bool flag); + + /// registers an attribute provider for special query behavior. + /// + /// registers an attribute provider for special query behavior. + ///

The query processor will compare the object returned by the + /// attribute provider instead of the actual object, both for the constraint + /// and the candidate persistent object.

+ /// In client-server environment this setting should be used on both + /// client and server.

+ ///
+ /// the attribute provider to be used + [System.ObsoleteAttribute(@"since version 7.0")] + void Compare(IObjectAttribute attributeProvider); + + /// + /// Must be called before databases are created or opened + /// so that db4o will control versions and generate UUIDs + /// for objects of this class, which is required for using replication. + /// + /// + /// Must be called before databases are created or opened + /// so that db4o will control versions and generate UUIDs + /// for objects of this class, which is required for using replication. + /// + /// + [System.ObsoleteAttribute(@"As of version 8.0 please use GenerateUUIDs(bool) and IFileConfiguration.GenerateCommitTimestamps(bool) instead" + )] + void EnableReplication(bool setting); + + /// generate UUIDs for stored objects of this class. + /// + /// generate UUIDs for stored objects of this class. + /// This setting should be used before the database is first created.

+ ///
+ /// + void GenerateUUIDs(bool setting); + + /// generate version numbers for stored objects of this class. + /// + /// generate version numbers for stored objects of this class. + /// This setting should be used before the database is first created.

+ ///
+ /// + [System.ObsoleteAttribute(@"As of version 8.0 please use IFileConfiguration.GenerateCommitTimestamps(bool) instead" + )] + void GenerateVersionNumbers(bool setting); + + /// turns the class index on or off. + /// + /// turns the class index on or off. + ///

db4o maintains an index for each class to be able to + /// deliver all instances of a class in a query. If the class + /// index is never needed, it can be turned off with this method + /// to improve the performance to create and delete objects of + /// a class. + ///

Common cases where a class index is not needed:
+ /// - The application always works with sub classes or super classes.
+ /// - There are convenient field indexes that will always find instances + /// of a class.
+ /// - The application always works with IDs.

+ /// In client-server environment this setting should be used on both + /// client and server.

+ /// This setting can be applied to an open object container.

+ ///
+ void Indexed(bool flag); + + /// sets the maximum activation depth to the desired value. + /// + /// sets the maximum activation depth to the desired value. + ///

A class specific setting overrides the + /// global setting + ///

+ /// In client-server environment this setting should be used on both + /// client and server.

+ /// This setting can be applied to an open object container.

+ ///
+ /// the desired maximum activation depth + /// Why activation? + /// CascadeOnActivate(bool) + void MaximumActivationDepth(int depth); + + /// sets the minimum activation depth to the desired value. + /// + /// sets the minimum activation depth to the desired value. + ///

A class specific setting overrides the + /// global setting + ///

+ /// In client-server environment this setting should be used on both + /// client and server.

+ /// This setting can be applied to an open object container.

+ ///
+ /// the desired minimum activation depth + /// Why activation? + /// CascadeOnActivate(bool) + void MinimumActivationDepth(int depth); + + /// gets the configured minimum activation depth. + /// + /// gets the configured minimum activation depth. + /// In client-server environment this setting should be used on both + /// client and server.

+ ///
+ /// the configured minimum activation depth. + int MinimumActivationDepth(); + + /// + /// returns an + /// IObjectField + /// object + /// to configure the specified field. + ///

+ ///
+ /// the name of the field to be configured.

+ /// + /// an instance of an + /// IObjectField + /// object for configuration. + /// + IObjectField ObjectField(string fieldName); + + /// turns on storing static field values for this class. + /// + /// turns on storing static field values for this class. + ///

By default, static field values of classes are not stored + /// to the database file. By turning the setting on for a specific class + /// with this switch, all non-simple-typed static field values of this + /// class are stored the first time an object of the class is stored, and + /// restored, every time a database file is opened afterwards, after + /// class meta information is loaded for this class (which can happen + /// by querying for a class or by loading an instance of a class).

+ /// To update a static field value, once it is stored, you have to the following + /// in this order:
+ /// (1) open the database file you are working agains
+ /// (2) make sure the class metadata is loaded
+ /// objectContainer.Query().Constrain(typeof(Foo));
+ /// (3) change the static member
+ /// (4) store the static member explicitely
+ /// objectContainer.Store(Foo.staticMember); + ///

The setting will be ignored for simple types. + ///

Use this setting for constant static object members. + ///

This option will slow down the process of opening database + /// files and the stored objects will occupy space in the database file. + ///

In client-server environment this setting should be used on both + /// client and server.

+ /// This setting can NOT be applied to an open object container.

+ ///
+ void PersistStaticFieldValues(); + + /// renames a stored class. + /// + /// renames a stored class. + ///

Use this method to refactor classes. + ///

In client-server environment this setting should be used on both + /// client and server.

+ /// This setting can NOT be applied to an open object container.

+ ///
+ /// the new fully qualified class name. + void Rename(string newName); + + /// allows to specify if transient fields are to be stored. + /// + /// allows to specify if transient fields are to be stored. + ///
The default for every class is false.

+ /// In client-server environment this setting should be used on both + /// client and server.

+ /// This setting can be applied to an open object container.

+ ///
+ /// whether or not transient fields are to be stored. + void StoreTransientFields(bool flag); + + /// registers a translator for this class. + /// + /// registers a translator for this class. + ///

+ ///

The use of an + /// IObjectTranslator + /// is not + /// compatible with the use of an + /// internal class ObjectMarshaller.

+ /// In client-server environment this setting should be used on both + /// client and server.

+ /// This setting can be applied to an open object container.

+ ///
+ /// + /// this may be an + /// IObjectTranslator + /// or an + /// IObjectConstructor + /// + /// IObjectTranslator + /// IObjectConstructor + void Translate(IObjectTranslator translator); + + /// specifies the updateDepth for this class. + /// + /// specifies the updateDepth for this class. + ///

see the documentation of + /// Db4objects.Db4o.IObjectContainer.Store(object) + /// + /// for further details.

+ /// The default setting is 0: Only the object passed to + /// Db4objects.Db4o.IObjectContainer.Store(object) + /// + /// will be updated.

+ /// In client-server environment this setting should be used on both + /// client and server.

+ ///
+ /// the depth of the desired update for this class. + /// IConfiguration.UpdateDepth(int) + /// CascadeOnUpdate(bool) + /// IObjectField.CascadeOnUpdate(bool) + /// + /// Using callbacks + void UpdateDepth(int depth); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/IObjectConstructor.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/IObjectConstructor.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/IObjectConstructor.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/IObjectConstructor.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,46 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o; +using Db4objects.Db4o.Config; + +namespace Db4objects.Db4o.Config +{ + /// + /// interface to allow instantiating objects by calling specific constructors. + /// + /// + /// + /// interface to allow instantiating objects by calling specific constructors. + ///

+ /// By writing classes that implement this interface, it is possible to + /// define which constructor is to be used during the instantiation of a stored object. + ///

+ /// Before starting a db4o session, translator classes that implement the + /// ObjectConstructor or + /// IObjectTranslator + /// need to be registered.

+ /// Example:
+ /// + /// IConfiguration config = Db4oFactory.Configure();
+ /// IObjectClass oc = config.ObjectClass("Namespace.ClassName");
+ /// oc.Translate(new FooTranslator()); + ///


+ ///
+ public interface IObjectConstructor : IObjectTranslator + { + /// db4o calls this method when a stored object needs to be instantiated. + /// + /// db4o calls this method when a stored object needs to be instantiated. + ///

+ ///
+ /// the ObjectContainer used + /// + /// the object stored with + /// ObjectTranslator.onStore + /// + /// . + /// + /// the instantiated object. + object OnInstantiate(IObjectContainer container, object storedObject); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/IObjectField.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/IObjectField.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/IObjectField.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/IObjectField.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,130 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +namespace Db4objects.Db4o.Config +{ + /// configuration interface for fields of classes. + /// + /// configuration interface for fields of classes. + ///

+ /// Use + /// IObjectClass.ObjectField(string) + /// to access this setting.

+ ///
+ public interface IObjectField + { + /// sets cascaded activation behaviour. + /// + /// sets cascaded activation behaviour. + ///

+ /// Setting cascadeOnActivate to true will result in the activation + /// of the object attribute stored in this field if the parent object + /// is activated. + ///

+ /// The default setting is false.

+ /// In client-server environment this setting should be used on both + /// client and server.

+ /// This setting can be applied to an open object container.

+ ///
+ /// whether activation is to be cascaded to the member object. + /// Why activation? + /// IObjectClass.CascadeOnActivate(bool) + /// + /// Db4objects.Db4o.IObjectContainer.Activate(object, int) + /// + /// Using callbacks + void CascadeOnActivate(bool flag); + + /// sets cascaded delete behaviour. + /// + /// sets cascaded delete behaviour. + ///

+ /// Setting cascadeOnDelete to true will result in the deletion of + /// the object attribute stored in this field on the parent object + /// if the parent object is passed to + /// Db4objects.Db4o.IObjectContainer.Delete(object) + /// + /// . + ///

+ /// Caution !
+ /// This setting will also trigger deletion of the old member object, on + /// calls to + /// + /// . + /// An example of the behaviour can be found in + /// IObjectClass.CascadeOnDelete(bool) + /// + ///

+ /// The default setting is false.

+ /// In client-server environment this setting should be used on both + /// client and server.

+ /// This setting can be applied to an open object container.

+ ///
+ /// whether deletes are to be cascaded to the member object. + /// IObjectClass.CascadeOnDelete(bool) + /// + /// Db4objects.Db4o.IObjectContainer.Delete(object) + /// + /// Using callbacks + void CascadeOnDelete(bool flag); + + /// sets cascaded update behaviour. + /// + /// sets cascaded update behaviour. + ///

+ /// Setting cascadeOnUpdate to true will result in the update + /// of the object attribute stored in this field if the parent object + /// is passed to + /// Db4objects.Db4o.IObjectContainer.Store(object) + /// + /// . + ///

+ /// The default setting is false.

+ /// In client-server environment this setting should be used on both + /// client and server.

+ /// This setting can be applied to an open object container.

+ ///
+ /// whether updates are to be cascaded to the member object. + /// com.db4o.ObjectContainer#set + /// IObjectClass.CascadeOnUpdate(bool) + /// + /// IObjectClass.UpdateDepth(int) + /// Using callbacks + void CascadeOnUpdate(bool flag); + + /// turns indexing on or off. + /// + /// turns indexing on or off. + ///

Field indices dramatically improve query performance but they may + /// considerably reduce storage and update performance.
The best benchmark whether + /// or not an index on a field achieves the desired result is the completed application + /// - with a data load that is typical for it's use.

This configuration setting + /// is only checked when the + /// Db4objects.Db4o.IObjectContainer + /// is opened. If the + /// setting is set to true and an index does not exist, the index will be + /// created. If the setting is set to false and an index does exist the + /// index will be dropped.

+ /// In client-server environment this setting should be used on both + /// client and server.

+ /// If this setting is applied to an open ObjectContainer it will take an effect on the next + /// time ObjectContainer is opened.

+ ///
+ /// + /// specify true or false to turn indexing on for + /// this field + /// + void Indexed(bool flag); + + /// renames a field of a stored class. + /// + /// renames a field of a stored class. + ///

Use this method to refactor classes. + ///

+ /// In client-server environment this setting should be used on both + /// client and server.

+ /// This setting can NOT be applied to an open object container.

+ ///
+ /// the new field name. + void Rename(string newName); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/IObjectTranslator.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/IObjectTranslator.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/IObjectTranslator.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/IObjectTranslator.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,51 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using Db4objects.Db4o; + +namespace Db4objects.Db4o.Config +{ + /// translator interface to translate objects on storage and activation. + /// + /// translator interface to translate objects on storage and activation. + ///

+ /// By writing classes that implement this interface, it is possible to + /// define how application classes are to be converted to be stored more efficiently. + ///

+ /// Before starting a db4o session, translator classes need to be registered. An example:
+ /// + /// IObjectClass oc = config.ObjectClass("Namespace.ClassName");
+ /// oc.Translate(new FooTranslator()); + ///


+ ///
+ public interface IObjectTranslator + { + /// db4o calls this method during storage and query evaluation. + /// db4o calls this method during storage and query evaluation. + /// the ObjectContainer used + /// the Object to be translated + /// + /// return the object to store.
It needs to be of the class + /// StoredClass() + /// . + ///
+ object OnStore(IObjectContainer container, object applicationObject); + + /// db4o calls this method during activation. + /// db4o calls this method during activation. + /// the ObjectContainer used + /// the object to set the members on + /// the object that was stored + void OnActivate(IObjectContainer container, object applicationObject, object storedObject + ); + + /// return the Class you are converting to. + /// return the Class you are converting to. + /// + /// the Class of the object you are returning with the method + /// OnStore(Db4objects.Db4o.IObjectContainer, object) + /// + /// + Type StoredClass(); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/IQueryConfiguration.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/IQueryConfiguration.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/IQueryConfiguration.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/IQueryConfiguration.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,135 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Config; + +namespace Db4objects.Db4o.Config +{ + /// interface to configure the querying settings to be used by the query processor. + /// + /// + /// interface to configure the querying settings to be used by the query processor. + ///

All settings can be configured after opening an ObjectContainer. + /// In a Client/Server setup the client-side configuration will be used. + ///
+ public interface IQueryConfiguration + { + /// configures the query processor evaluation mode. + /// + /// configures the query processor evaluation mode. + ///

The db4o query processor can run in three modes:
+ /// - Immediate mode
+ /// - Snapshot mode
+ /// - Lazy mode

+ /// In Immediate mode, a query will be fully evaluated when + /// Db4objects.Db4o.Query.IQuery.Execute() + /// + /// + /// is called. The complete + /// Db4objects.Db4o.IObjectSet + /// of all matching IDs is + /// generated immediately.

+ /// In Snapshot mode, the + /// Db4objects.Db4o.Query.IQuery.Execute() + /// + /// call will trigger all index + /// processing immediately. A snapshot of the current state of all relevant indexes + /// is taken for further processing by the SODA query processor. All non-indexed + /// constraints and all evaluations will be run when the user application iterates + /// through the resulting + /// Db4objects.Db4o.IObjectSet + /// .

+ /// In Lazy mode, the + /// Db4objects.Db4o.Query.IQuery.Execute() + /// + /// call will only create an Iterator + /// against the best index found. Further query processing (including all index + /// processing) will happen when the user application iterates through the resulting + /// Db4objects.Db4o.IObjectSet + /// .

+ /// Advantages and disadvantages of the individual modes:

+ /// Immediate mode
+ /// + If the query is intended to iterate through the entire resulting + /// Db4objects.Db4o.IObjectSet + /// , + /// this mode will be slightly faster than the others.
+ /// + The query will process without intermediate side effects from changed + /// objects (by the caller or by other transactions).
+ /// - Query processing can block the server for a long time.
+ /// - In comparison to the other modes it will take longest until the first results + /// are returned.
+ /// - The ObjectSet will require a considerate amount of memory to hold the IDs of + /// all found objects.

+ /// Snapshot mode
+ /// + Index processing will happen without possible side effects from changes made + /// by the caller or by other transaction.
+ /// + Since index processing is fast, a server will not be blocked for a long time.
+ /// - The entire candidate index will be loaded into memory. It will stay there + /// until the query ObjectSet is garbage collected. In a C/S setup, the memory will + /// be used on the server side.

+ /// Lazy mode
+ /// + The call to + /// Db4objects.Db4o.Query.IQuery.Execute() + /// + /// will return very fast. First results can be + /// made available to the application before the query is fully processed.
+ /// + A query will consume hardly any memory at all because no intermediate ID + /// representation is ever created.
+ /// - Lazy queries check candidates when iterating through the resulting + /// Db4objects.Db4o.IObjectSet + /// . + /// In doing so the query processor takes changes into account that may have happened + /// since the Query#execute()call: committed changes from other transactions, and + /// uncommitted changes from the calling transaction. There is a wide range + /// of possible side effects. The underlying index may have changed. Objects themselves + /// may have changed in the meanwhile. There even is the chance of creating an endless + /// loop, if the caller of the iterates through the + /// Db4objects.Db4o.IObjectSet + /// and changes each + /// object in a way that it is placed at the end of the index: The same objects can be + /// revisited over and over. In lazy mode it can make sense to work in a way one would + /// work with collections to avoid concurrent modification exceptions. For instance one + /// could iterate through the + /// Db4objects.Db4o.IObjectSet + /// first and store all objects to a temporary + /// other collection representation before changing objects and storing them back to db4o.

+ /// Note: Some method calls against a lazy + /// Db4objects.Db4o.IObjectSet + /// will require the query + /// processor to create a snapshot or to evaluate the query fully. An example of such + /// a call is + /// Db4objects.Db4o.IObjectSet.Count() + /// + /// . + ///

+ /// The default query evaluation mode is Immediate mode. + ///

+ /// Recommendations:
+ /// - Lazy mode can be an excellent choice for single transaction read use, + /// to keep memory consumption as low as possible.
+ /// - Client/Server applications with the risk of concurrent modifications should prefer + /// Snapshot mode to avoid side effects from other transactions. + ///

+ /// To change the evaluationMode, pass any of the three static + /// QueryEvaluationMode + /// constants from the + /// QueryEvaluationMode + /// class to this method:
+ /// - + /// QueryEvaluationMode.Immediate + ///
+ /// - + /// QueryEvaluationMode.Snapshot + ///
+ /// - + /// QueryEvaluationMode.Lazy + ///

+ /// This setting must be issued from the client side. + ///
+ void EvaluationMode(QueryEvaluationMode mode); + + /// EvaluationMode(QueryEvaluationMode) + /// + /// the currently configured query evaluation mode + QueryEvaluationMode EvaluationMode(); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/QueryEvaluationMode.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/QueryEvaluationMode.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/QueryEvaluationMode.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/QueryEvaluationMode.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,113 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; + +namespace Db4objects.Db4o.Config +{ + /// + /// This class provides static constants for the query evaluation + /// modes that db4o supports. + /// + /// + /// This class provides static constants for the query evaluation + /// modes that db4o supports. + ///

For detailed documentation please see + /// IQueryConfiguration.EvaluationMode(QueryEvaluationMode) + /// + /// + ///
+ public class QueryEvaluationMode + { + private readonly string _id; + + private QueryEvaluationMode(string id) + { + _id = id; + } + + /// Constant for immediate query evaluation. + /// + /// Constant for immediate query evaluation. The query is executed fully + /// when + /// Db4objects.Db4o.Query.IQuery.Execute() + /// + /// is called. + ///

For detailed documentation please see + /// IQueryConfiguration.EvaluationMode(QueryEvaluationMode) + /// + /// + ///
+ public static readonly Db4objects.Db4o.Config.QueryEvaluationMode Immediate = new + Db4objects.Db4o.Config.QueryEvaluationMode("IMMEDIATE"); + + /// Constant for snapshot query evaluation. + /// + /// Constant for snapshot query evaluation. When + /// Db4objects.Db4o.Query.IQuery.Execute() + /// + /// is called, + /// the query processor chooses the best indexes, does all index processing + /// and creates a snapshot of the index at this point in time. Non-indexed + /// constraints are evaluated lazily when the application iterates through + /// the + /// Db4objects.Db4o.IObjectSet + /// resultset of the query. + ///

For detailed documentation please see + /// IQueryConfiguration.EvaluationMode(QueryEvaluationMode) + /// + /// + ///
+ public static readonly Db4objects.Db4o.Config.QueryEvaluationMode Snapshot = new + Db4objects.Db4o.Config.QueryEvaluationMode("SNAPSHOT"); + + /// Constant for lazy query evaluation. + /// + /// Constant for lazy query evaluation. When + /// Db4objects.Db4o.Query.IQuery.Execute() + /// + /// is called, the + /// query processor only chooses the best index and creates an iterator on + /// this index. Indexes and constraints are evaluated lazily when the + /// application iterates through the + /// Db4objects.Db4o.IObjectSet + /// resultset of the query. + ///

For detailed documentation please see + /// IQueryConfiguration.EvaluationMode(QueryEvaluationMode) + /// + /// + ///
+ public static readonly Db4objects.Db4o.Config.QueryEvaluationMode Lazy = new Db4objects.Db4o.Config.QueryEvaluationMode + ("LAZY"); + + private static readonly Db4objects.Db4o.Config.QueryEvaluationMode[] Modes = new + Db4objects.Db4o.Config.QueryEvaluationMode[] { Db4objects.Db4o.Config.QueryEvaluationMode + .Immediate, Db4objects.Db4o.Config.QueryEvaluationMode.Snapshot, Db4objects.Db4o.Config.QueryEvaluationMode + .Lazy }; + + /// internal method, ignore please. + /// internal method, ignore please. + public virtual int AsInt() + { + for (int i = 0; i < Modes.Length; i++) + { + if (Modes[i] == this) + { + return i; + } + } + throw new InvalidOperationException(); + } + + /// internal method, ignore please. + /// internal method, ignore please. + public static Db4objects.Db4o.Config.QueryEvaluationMode FromInt(int i) + { + return Modes[i]; + } + + public override string ToString() + { + return _id; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/SimpleNameProvider.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/SimpleNameProvider.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/SimpleNameProvider.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/SimpleNameProvider.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,27 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o; +using Db4objects.Db4o.Config; + +namespace Db4objects.Db4o.Config +{ + /// + /// Assigns a fixed, pre-defined name to the given + /// Db4objects.Db4o.IObjectContainer + /// . + /// + public class SimpleNameProvider : INameProvider + { + private readonly string _name; + + public SimpleNameProvider(string name) + { + _name = name; + } + + public virtual string Name(IObjectContainer db) + { + return _name; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/TNull.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/TNull.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/TNull.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/TNull.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,27 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using Db4objects.Db4o; +using Db4objects.Db4o.Config; + +namespace Db4objects.Db4o.Config +{ + /// + public class TNull : IObjectTranslator + { + public virtual object OnStore(IObjectContainer con, object @object) + { + return null; + } + + public virtual void OnActivate(IObjectContainer con, object @object, object members + ) + { + } + + public virtual Type StoredClass() + { + return typeof(object); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/TypeAlias.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/TypeAlias.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/TypeAlias.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/TypeAlias.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,63 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using Db4objects.Db4o.Config; +using Db4objects.Db4o.Internal; + +namespace Db4objects.Db4o.Config +{ + /// + /// a simple Alias for a single Class or Type, using equals on + /// the names in the resolve method. + /// + /// + /// a simple Alias for a single Class or Type, using equals on + /// the names in the resolve method. + ///

See + /// IAlias + /// for concrete examples. + ///
+ public class TypeAlias : IAlias + { + private readonly string _storedType; + + private readonly string _runtimeType; + + /// + /// pass the stored name as the first + /// parameter and the desired runtime name as the second parameter. + /// + /// + /// pass the stored name as the first + /// parameter and the desired runtime name as the second parameter. + /// + public TypeAlias(string storedType, string runtimeType) + { + if (null == storedType || null == runtimeType) + { + throw new ArgumentException(); + } + _storedType = storedType; + _runtimeType = runtimeType; + } + + public TypeAlias(Type storedClass, Type runtimeClass) : this(ReflectPlatform.FullyQualifiedName + (storedClass), ReflectPlatform.FullyQualifiedName(runtimeClass)) + { + } + + /// returns the stored type name if the alias was written for the passed runtime type name + /// + public virtual string ResolveRuntimeName(string runtimeTypeName) + { + return _runtimeType.Equals(runtimeTypeName) ? _storedType : null; + } + + /// returns the runtime type name if the alias was written for the passed stored type name + /// + public virtual string ResolveStoredName(string storedTypeName) + { + return _storedType.Equals(storedTypeName) ? _runtimeType : null; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/WildcardAlias.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/WildcardAlias.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/WildcardAlias.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Config/WildcardAlias.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,114 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using Db4objects.Db4o.Config; + +namespace Db4objects.Db4o.Config +{ + /// + /// Wildcard Alias functionality to create aliases for packages, + /// namespaces or multiple similar named classes. + /// + /// + /// Wildcard Alias functionality to create aliases for packages, + /// namespaces or multiple similar named classes. One single '*' + /// wildcard character is supported in the names. + ///

See + /// IAlias + /// for concrete examples. + ///
+ public class WildcardAlias : IAlias + { + private readonly WildcardAlias.WildcardPattern _storedPattern; + + private readonly WildcardAlias.WildcardPattern _runtimePattern; + + /// + /// Create a WildcardAlias with two patterns, the + /// stored pattern and the pattern that is to be used + /// at runtime. + /// + /// + /// Create a WildcardAlias with two patterns, the + /// stored pattern and the pattern that is to be used + /// at runtime. One single '*' is allowed as a wildcard + /// character. + /// + public WildcardAlias(string storedPattern, string runtimePattern) + { + if (null == storedPattern) + { + throw new ArgumentNullException("storedPattern"); + } + if (null == runtimePattern) + { + throw new ArgumentNullException("runtimePattern"); + } + _storedPattern = new WildcardAlias.WildcardPattern(storedPattern); + _runtimePattern = new WildcardAlias.WildcardPattern(runtimePattern); + } + + /// resolving is done through simple pattern matching + public virtual string ResolveRuntimeName(string runtimeTypeName) + { + return Resolve(_runtimePattern, _storedPattern, runtimeTypeName); + } + + /// resolving is done through simple pattern matching + public virtual string ResolveStoredName(string storedTypeName) + { + return Resolve(_storedPattern, _runtimePattern, storedTypeName); + } + + private string Resolve(WildcardAlias.WildcardPattern from, WildcardAlias.WildcardPattern + to, string typeName) + { + string match = from.Matches(typeName); + return match != null ? to.Inject(match) : null; + } + + internal class WildcardPattern + { + private string _head; + + private string _tail; + + public WildcardPattern(string pattern) + { + string[] parts = Split(pattern); + _head = parts[0]; + _tail = parts[1]; + } + + public virtual string Inject(string s) + { + return _head + s + _tail; + } + + public virtual string Matches(string s) + { + if (!s.StartsWith(_head) || !s.EndsWith(_tail)) + { + return null; + } + return Sharpen.Runtime.Substring(s, _head.Length, s.Length - _tail.Length); + } + + private void InvalidPattern() + { + throw new ArgumentException("only one '*' character"); + } + + internal virtual string[] Split(string pattern) + { + int index = pattern.IndexOf('*'); + if (-1 == index || index != pattern.LastIndexOf('*')) + { + InvalidPattern(); + } + return new string[] { Sharpen.Runtime.Substring(pattern, 0, index), Sharpen.Runtime.Substring + (pattern, index + 1) }; + } + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Constraints/ConstraintViolationException.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Constraints/ConstraintViolationException.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Constraints/ConstraintViolationException.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Constraints/ConstraintViolationException.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,25 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Ext; + +namespace Db4objects.Db4o.Constraints +{ + /// Base class for all constraint exceptions. + /// Base class for all constraint exceptions. + [System.Serializable] + public class ConstraintViolationException : Db4oRecoverableException + { + /// + /// ConstraintViolationException constructor with a specific + /// message. + /// + /// + /// ConstraintViolationException constructor with a specific + /// message. + /// + /// exception message + public ConstraintViolationException(string msg) : base(msg) + { + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Constraints/UniqueFieldValueConstraint.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Constraints/UniqueFieldValueConstraint.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Constraints/UniqueFieldValueConstraint.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Constraints/UniqueFieldValueConstraint.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,146 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using System.Collections; +using Db4objects.Db4o.Config; +using Db4objects.Db4o.Constraints; +using Db4objects.Db4o.Events; +using Db4objects.Db4o.Ext; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Btree; +using Db4objects.Db4o.Reflect; +using Db4objects.Db4o.Reflect.Core; + +namespace Db4objects.Db4o.Constraints +{ + /// configures a field of a class to allow unique values only. + /// configures a field of a class to allow unique values only. + public class UniqueFieldValueConstraint : IConfigurationItem + { + protected readonly object _clazz; + + protected readonly string _fieldName; + + /// constructor to create a UniqueFieldValueConstraint. + /// constructor to create a UniqueFieldValueConstraint. + /// can be a class (Java) / Type (.NET) / instance of the class / fully qualified class name + /// + /// the name of the field that is to be unique. + public UniqueFieldValueConstraint(object clazz, string fieldName) + { + _clazz = clazz; + _fieldName = fieldName; + } + + public virtual void Prepare(IConfiguration configuration) + { + } + + // Nothing to do... + /// internal method, public for implementation reasons. + /// internal method, public for implementation reasons. + public virtual void Apply(IInternalObjectContainer objectContainer) + { + if (objectContainer.IsClient) + { + throw new InvalidOperationException(GetType().FullName + " should be configured on the server." + ); + } + EventRegistryFactory.ForObjectContainer(objectContainer).Committing += new System.EventHandler + (new _IEventListener4_46(this, objectContainer).OnEvent); + } + + private sealed class _IEventListener4_46 + { + public _IEventListener4_46(UniqueFieldValueConstraint _enclosing, IInternalObjectContainer + objectContainer) + { + this._enclosing = _enclosing; + this.objectContainer = objectContainer; + } + + private FieldMetadata _fieldMetaData; + + private void EnsureSingleOccurence(Transaction trans, IObjectInfoCollection col) + { + IEnumerator i = col.GetEnumerator(); + while (i.MoveNext()) + { + IObjectInfo objectInfo = (IObjectInfo)i.Current; + if (this.ReflectClass() != this._enclosing.ReflectorFor(trans, objectInfo.GetObject + ())) + { + continue; + } + object obj = this.ObjectFor(trans, objectInfo); + object fieldValue = this.FieldMetadata().GetOn(trans, obj); + if (fieldValue == null) + { + continue; + } + IBTreeRange range = this.FieldMetadata().Search(trans, fieldValue); + if (range.Size() > 1) + { + throw new UniqueFieldValueConstraintViolationException(this.ClassMetadata().GetName + (), this.FieldMetadata().GetName()); + } + } + } + + private bool IsClassMetadataAvailable() + { + return null != this.ClassMetadata(); + } + + private FieldMetadata FieldMetadata() + { + if (this._fieldMetaData != null) + { + return this._fieldMetaData; + } + this._fieldMetaData = this.ClassMetadata().FieldMetadataForName(this._enclosing._fieldName + ); + return this._fieldMetaData; + } + + private ClassMetadata ClassMetadata() + { + return objectContainer.ClassMetadataForReflectClass(this.ReflectClass()); + } + + private IReflectClass ReflectClass() + { + return ReflectorUtils.ReflectClassFor(objectContainer.Reflector(), this._enclosing + ._clazz); + } + + public void OnEvent(object sender, Db4objects.Db4o.Events.CommitEventArgs args) + { + if (!this.IsClassMetadataAvailable()) + { + return; + } + CommitEventArgs commitEventArgs = (CommitEventArgs)args; + Transaction trans = (Transaction)commitEventArgs.Transaction(); + this.EnsureSingleOccurence(trans, commitEventArgs.Added); + this.EnsureSingleOccurence(trans, commitEventArgs.Updated); + } + + private object ObjectFor(Transaction trans, IObjectInfo info) + { + int id = (int)info.GetInternalID(); + HardObjectReference @ref = HardObjectReference.PeekPersisted(trans, id, 1); + return @ref._object; + } + + private readonly UniqueFieldValueConstraint _enclosing; + + private readonly IInternalObjectContainer objectContainer; + } + + private IReflectClass ReflectorFor(Transaction trans, object obj) + { + return trans.Container().Reflector().ForObject(obj); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Constraints/UniqueFieldValueConstraintViolationException.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Constraints/UniqueFieldValueConstraintViolationException.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Constraints/UniqueFieldValueConstraintViolationException.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Constraints/UniqueFieldValueConstraintViolationException.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,36 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Constraints; + +namespace Db4objects.Db4o.Constraints +{ + /// + /// db4o-specific exception.

+ /// This exception can be thrown by a + /// UniqueFieldValueConstraint + /// on commit. + ///
+ /// Db4objects.Db4o.Config.IObjectField.Indexed(bool) + /// + /// Db4objects.Db4o.Config.IConfiguration.Add(Db4objects.Db4o.Config.IConfigurationItem) + /// + [System.Serializable] + public class UniqueFieldValueConstraintViolationException : ConstraintViolationException + { + /// + /// Constructor with a message composed from the class and field + /// name of the entity causing the exception. + /// + /// + /// Constructor with a message composed from the class and field + /// name of the entity causing the exception. + /// + /// class, which caused the exception + /// field, which caused the exception + public UniqueFieldValueConstraintViolationException(string className, string fieldName + ) : base("class: " + className + " field: " + fieldName) + { + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/CorruptionException.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/CorruptionException.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/CorruptionException.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/CorruptionException.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,13 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; + +namespace Db4objects.Db4o +{ + /// + [System.Serializable] + public class CorruptionException : Exception + { + // TODO implement exception basics (message, etc.) + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Db4oEmbedded.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Db4oEmbedded.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Db4oEmbedded.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Db4oEmbedded.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,121 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using Db4objects.Db4o; +using Db4objects.Db4o.Config; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Config; + +namespace Db4objects.Db4o +{ + /// Factory class to open db4o instances in embedded + /// mode. + /// Factory class to open db4o instances in embedded mode. + /// + /// Db4objects.Db4o.CS.Db4oClientServer in + /// Db4objects.Db4o.CS.dll for methods to open db4o servers and db4o + /// clients. + /// 7.5 + public class Db4oEmbedded + { + /// + /// Creates a fresh + /// IEmbeddedConfiguration + /// instance. + /// + /// a fresh, independent configuration with all options set to their default values + /// + public static IEmbeddedConfiguration NewConfiguration() + { + return new EmbeddedConfigurationImpl(Db4oFactory.NewConfiguration()); + } + + /// + /// opens an + /// IObjectContainer + /// on the specified database file for local use. + ///
+ ///
+ /// A database file can only be opened once, subsequent attempts to + /// open another + /// IObjectContainer + /// against the same file will result in a + /// DatabaseFileLockedException + /// . + ///
+ ///
+ /// Database files can only be accessed for readwrite access from one + /// process at one time. All versions except for db4o mobile edition + /// use an internal mechanism to lock the database file for other + /// processes. + ///
+ ///
+ ///
+ /// + /// a custom + /// IConfiguration + /// instance to be obtained via + /// newConfiguration + /// + /// an absolute or relative path to the database + /// file + /// + /// an open + /// IObjectContainer + /// + /// + /// Db4objects.Db4o.Config.IConfiguration.ReadOnly + /// Db4objects.Db4o.Config.IConfiguration.Encrypt + /// + /// + /// Db4objects.Db4o.Config.IConfiguration.Password + /// I/O operation failed or was unexpectedly + /// interrupted. + /// the required database file is locked by + /// another process. + /// + /// runtime + /// configuration + /// is not compatible with the configuration of the database file. + /// + /// + /// open operation failed because the database file is in old format + /// and + /// + /// Db4objects.Db4o.Config.IConfiguration.AllowVersionUpdates + /// is set to false. + /// + /// database was configured as read-only. + /// + public static IEmbeddedObjectContainer OpenFile(IEmbeddedConfiguration config, string + databaseFileName) + { + if (null == config) + { + throw new ArgumentNullException(); + } + return ObjectContainerFactory.OpenObjectContainer(config, databaseFileName); + } + + /// + /// Same as calling + /// OpenFile(Db4objects.Db4o.Config.IEmbeddedConfiguration, string) + /// + /// with a fresh configuration ( + /// NewConfiguration() + /// ). + /// + /// an absolute or relative path to the database file + /// OpenFile(Db4objects.Db4o.Config.IEmbeddedConfiguration, string) + /// + /// + /// + /// + /// + /// + public static IEmbeddedObjectContainer OpenFile(string databaseFileName) + { + return OpenFile(NewConfiguration(), databaseFileName); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Db4oFactory.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Db4oFactory.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Db4oFactory.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Db4oFactory.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,554 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o; +using Db4objects.Db4o.Config; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Config; + +namespace Db4objects.Db4o +{ + /// factory class to start db4o database engines. + /// + /// factory class to start db4o database engines. + ///

This class provides static methods to
+ /// - open single-user databases + /// OpenFile(string) + ///
+ /// - open db4o servers + /// OpenServer(string, int) + ///
+ /// - connect to db4o servers + /// OpenClient(string, int, string, string) + /// + ///
+ /// - provide access to the global configuration context + /// Configure() + ///
+ /// - print the version number of this db4o version + /// Main(java.lang.String[]) + /// + ///
+ /// ExtDb4o for extended functionality. + public class Db4oFactory + { + internal static readonly Config4Impl i_config = new Config4Impl(); + + static Db4oFactory() + { + Platform4.GetDefaultConfiguration(i_config); + } + + /// prints the version name of this db4o version to System.out. + /// + /// prints the version name of this db4o version to System.out. + /// + public static void Main(string[] args) + { + Sharpen.Runtime.Out.WriteLine(Version()); + } + + /// + /// returns the global db4o + /// IConfiguration + /// context + /// for the running CLR session. + ///

+ /// The + /// IConfiguration + /// can be overriden in each + /// ObjectContainer + /// .

+ ///
+ /// + /// the global + /// configuration + /// context + /// + /// + public static IConfiguration Configure() + { + return i_config; + } + + /// + /// Creates a fresh + /// IConfiguration + /// instance. + /// + /// a fresh, independent configuration with all options set to their default values + /// + [System.ObsoleteAttribute(@"Use Db4oEmbedded.NewConfiguration() instead.")] + public static IConfiguration NewConfiguration() + { + Config4Impl config = new Config4Impl(); + Platform4.GetDefaultConfiguration(config); + return config; + } + + /// + /// Creates a clone of the global db4o + /// IConfiguration + /// . + /// + /// + /// a fresh configuration with all option values set to the values + /// currently configured for the global db4o configuration context + /// + [System.ObsoleteAttribute(@"use explicit configuration via Db4oEmbedded.NewConfiguration() instead" + )] + public static IConfiguration CloneConfiguration() + { + return (Config4Impl)((IDeepClone)Db4oFactory.Configure()).DeepClone(null); + } + + /// + /// Operates just like + /// + /// Db4objects.Db4o.Db4oFactory.OpenClient + /// , but uses + /// the global db4o + /// IConfiguration + /// context. + /// opens an + /// IObjectContainer + /// client and connects it to the specified named server and port. + ///

+ /// The server needs to + /// allow access + /// for the specified user and password. + ///

+ /// A client + /// IObjectContainer + /// can be cast to + /// IExtClient + /// to use extended + /// IExtObjectContainer + /// + /// and + /// IExtClient + /// methods. + ///

+ /// This method is obsolete, see the Db4objects.Db4o.CS.Db4oClientServer class in + /// Db4objects.Db4o.CS.dll for methods to open db4o servers and db4o clients. + ///
+ /// + /// a custom + /// IConfiguration + /// instance to be obtained via + /// + /// Db4objects.Db4o.Db4oEmbedded.NewConfiguration + /// + /// + /// the host name + /// the port the server is using + /// the user name + /// the user password + /// + /// an open + /// IObjectContainer + /// + /// + /// Db4objects.Db4o.IObjectServer.GrantAccess + /// + /// + /// I/O operation failed or was unexpectedly interrupted. + /// + /// + /// open operation failed because the database file + /// is in old format and + /// + /// Db4objects.Db4o.Config.IConfiguration.AllowVersionUpdates + /// + /// + /// is set to false. + /// + /// + /// password supplied for the connection is + /// invalid. + /// + public static IObjectContainer OpenClient(string hostName, int port, string user, + string password) + { + return OpenClient(Db4oFactory.CloneConfiguration(), hostName, port, user, password + ); + } + + /// + /// opens an + /// IObjectContainer + /// client and connects it to the specified named server and port. + ///

+ /// The server needs to + /// allow access + /// for the specified user and password. + ///

+ /// A client + /// IObjectContainer + /// can be cast to + /// IExtClient + /// to use extended + /// IExtObjectContainer + /// + /// and + /// IExtClient + /// methods. + ///

+ /// This method is obsolete, see the Db4objects.Db4o.CS.Db4oClientServer class in + /// Db4objects.Db4o.CS.dll for methods to open db4o servers and db4o clients. + ///
+ /// + /// a custom + /// IConfiguration + /// instance to be obtained via + /// + /// Db4objects.Db4o.Db4oEmbedded.NewConfiguration + /// + /// + /// the host name + /// the port the server is using + /// the user name + /// the user password + /// + /// an open + /// IObjectContainer + /// + /// + /// Db4objects.Db4o.IObjectServer.GrantAccess + /// + /// + /// I/O operation failed or was unexpectedly interrupted. + /// + /// + /// open operation failed because the database file + /// is in old format and + /// + /// Db4objects.Db4o.Config.IConfiguration.AllowVersionUpdates + /// + /// + /// is set to false. + /// + /// + /// password supplied for the connection is + /// invalid. + /// + public static IObjectContainer OpenClient(IConfiguration config, string hostName, + int port, string user, string password) + { + return ((Config4Impl)config).ClientServerFactory().OpenClient(config, hostName, port + , user, password); + } + + /// + /// Operates just like + /// Db4oFactory.OpenFile + /// , but uses + /// the global db4o + /// IConfiguration + /// context. + /// opens an + /// IObjectContainer + /// on the specified database file for local use. + ///

A database file can only be opened once, subsequent attempts to open + /// another + /// IObjectContainer + /// against the same file will result in + /// a + /// DatabaseFileLockedException + /// .

+ /// Database files can only be accessed for readwrite access from one process + /// at one time. All versions except for db4o mobile edition use an + /// internal mechanism to lock the database file for other processes. + ///

+ /// + ///
+ /// an absolute or relative path to the database file + /// + /// an open + /// IObjectContainer + /// + /// + /// IConfiguration.ReadOnly + /// IConfiguration.Encrypt + /// IConfiguration.Password + /// + /// I/O operation failed or was unexpectedly interrupted. + /// + /// + /// + /// the required database file is locked by + /// another process. + /// + /// + /// + /// runtime + /// configuration + /// is not compatible + /// with the configuration of the database file. + /// + /// + /// + /// open operation failed because the database file + /// is in old format and + /// + /// IConfiguration.AllowVersionUpdates + /// + /// is set to false. + /// + /// + /// database was configured as read-only. + /// + public static IObjectContainer OpenFile(string databaseFileName) + { + return Db4oFactory.OpenFile(CloneConfiguration(), databaseFileName); + } + + /// + /// opens an + /// IObjectContainer + /// on the specified database file for local use. + ///

A database file can only be opened once, subsequent attempts to open + /// another + /// IObjectContainer + /// against the same file will result in + /// a + /// DatabaseFileLockedException + /// .

+ /// Database files can only be accessed for readwrite access from one process + /// at one time. All versions except for db4o mobile edition use an + /// internal mechanism to lock the database file for other processes. + ///

+ /// + ///
+ /// + /// a custom + /// IConfiguration + /// instance to be obtained via + /// Db4oFactory.NewConfiguration + /// + /// + /// an absolute or relative path to the database file + /// + /// an open + /// IObjectContainer + /// + /// + /// IConfiguration.ReadOnly + /// IConfiguration.Encrypt + /// IConfiguration.Password + /// + /// I/O operation failed or was unexpectedly interrupted. + /// + /// + /// + /// the required database file is locked by + /// another process. + /// + /// + /// + /// runtime + /// configuration + /// is not compatible + /// with the configuration of the database file. + /// + /// + /// + /// open operation failed because the database file + /// is in old format and + /// + /// IConfiguration.AllowVersionUpdates + /// + /// + /// + /// is set to false. + /// + /// + /// + /// database was configured as read-only. + /// + /// + public static IObjectContainer OpenFile(IConfiguration config, string databaseFileName + ) + { + return ObjectContainerFactory.OpenObjectContainer(Db4oLegacyConfigurationBridge.AsEmbeddedConfiguration + (config), databaseFileName); + } + + /// + /// Operates just like + /// + /// Db4objects.Db4o.Db4oFactory.OpenServer + /// + /// , but uses + /// the global db4o + /// IConfiguration + /// context. + /// Opens an + /// IObjectServer + /// on the specified database file and port. + ///

+ /// If the server does not need to listen on a port because it will only be used + /// in embedded mode with + /// + /// Db4objects.Db4o.IObjectServer.OpenClient + /// + /// , specify '0' as the + /// port number. + ///

This method is obsolete, see the Db4objects.Db4o.CS.Db4oClientServer class in + /// Db4objects.Db4o.CS.dll for methods to open db4o servers and db4o clients. + ///
+ /// an absolute or relative path to the database file + /// + /// the port to be used, or 0, if the server should not open a port, + /// because it will only be used with + /// + /// Db4objects.Db4o.IObjectServer.OpenClient + /// + /// . + /// Specify a value < 0 if an arbitrary free port should be chosen - see + /// + /// Db4objects.Db4o.Ext.IExtObjectServer.Port + /// + /// . + /// + /// + /// an + /// IObjectServer + /// listening + /// on the specified port. + /// + /// + /// Db4objects.Db4o.Config.IConfiguration.ReadOnly + /// + /// + /// Db4objects.Db4o.Config.IConfiguration.Encrypt + /// + /// + /// Db4objects.Db4o.Config.IConfiguration.Password + /// + /// + /// I/O operation failed or was unexpectedly interrupted. + /// + /// + /// the required database file is locked by + /// another process. + /// + /// + /// runtime + /// configuration + /// is not compatible + /// with the configuration of the database file. + /// + /// + /// open operation failed because the database file + /// is in old format and + /// + /// Db4objects.Db4o.Config.IConfiguration.AllowVersionUpdates + /// + /// + /// is set to false. + /// + /// + /// database was configured as read-only. + /// + public static IObjectServer OpenServer(string databaseFileName, int port) + { + return OpenServer(CloneConfiguration(), databaseFileName, port); + } + + /// + /// opens an + /// IObjectServer + /// on the specified database file and port. + ///

+ /// If the server does not need to listen on a port because it will only be used + /// in embedded mode with + /// + /// Db4objects.Db4o.IObjectServer.OpenClient + /// + /// , specify '0' as the + /// port number. + ///

This method is obsolete, see the Db4objects.Db4o.CS.Db4oClientServer class in + /// Db4objects.Db4o.CS.dll for methods to open db4o servers and db4o clients. + ///
+ /// + /// a custom + /// IConfiguration + /// instance to be obtained via + /// + /// Db4objects.Db4o.Db4oEmbedded.NewConfiguration + /// + /// + /// an absolute or relative path to the database file + /// + /// the port to be used, or 0, if the server should not open a port, + /// because it will only be used with + /// + /// Db4objects.Db4o.IObjectServer.OpenClient + /// + /// . + /// Specify a value < 0 if an arbitrary free port should be chosen - see + /// + /// Db4objects.Db4o.Ext.IExtObjectServer.Port + /// + /// . + /// + /// + /// an + /// IObjectServer + /// listening + /// on the specified port. + /// + /// + /// Db4objects.Db4o.Config.IConfiguration.ReadOnly + /// + /// + /// Db4objects.Db4o.Config.IConfiguration.Encrypt + /// + /// + /// Db4objects.Db4o.Config.IConfiguration.Password + /// + /// + /// I/O operation failed or was unexpectedly interrupted. + /// + /// + /// the required database file is locked by + /// another process. + /// + /// + /// runtime + /// configuration + /// is not compatible + /// with the configuration of the database file. + /// + /// + /// open operation failed because the database file + /// is in old format and + /// + /// Db4objects.Db4o.Config.IConfiguration.AllowVersionUpdates + /// + /// + /// is set to false. + /// + /// + /// database was configured as read-only. + /// + public static IObjectServer OpenServer(IConfiguration config, string databaseFileName + , int port) + { + return ((Config4Impl)config).ClientServerFactory().OpenServer(config, databaseFileName + , port); + } + + /// returns the version name of the used db4o version. + /// + /// returns the version name of the used db4o version. + ///

+ ///
+ /// version information as a String. + public static string Version() + { + return "db4o " + Db4oVersion.Name; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Db4oVersion.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Db4oVersion.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Db4oVersion.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Db4oVersion.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,18 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +namespace Db4objects.Db4o +{ + /// + public class Db4oVersion + { + public static readonly string Name = "8.0.183.14430"; + + public const int Major = 8; + + public const int Minor = 0; + + public const int Iteration = 183; + + public const int Revision = 14430; + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Debug4.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Debug4.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Debug4.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Debug4.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,140 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using Db4objects.Db4o; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Marshall; +using Db4objects.Db4o.Marshall; + +namespace Db4objects.Db4o +{ + /// + public sealed class Debug4 + { + /// indexes all fields + public const bool indexAllFields = false; + + /// prints query graph information to the console + public const bool queries = false; + + /// + /// allows faking the Db4oDatabase identity object, so the first + /// stored object in the debugger is the actually persisted object + /// Changing this setting to true will fail some tests that expect + /// database files to have identity + /// + public const bool staticIdentity = queries; + + /// prints more stack traces + public const bool atHome = false; + + /// makes C/S timeouts longer, so C/S does not time out in the debugger + public const bool longTimeOuts = false; + + /// turns freespace debuggin on + public const bool freespace = Deploy.debug; + + /// + /// fills deleted slots with 'X' and overrides any configured + /// freespace filler + /// + public const bool xbytes = freespace; + + /// + /// checks monitor conditions to make sure only the thread + /// with the global monitor is allowed entry to the core + /// + public const bool checkSychronization = false; + + /// + /// makes sure a configuration entry is generated for each persistent + /// class + /// + public const bool configureAllClasses = indexAllFields; + + /// + /// makes sure a configuration entry is generated for each persistent + /// field + /// + public const bool configureAllFields = indexAllFields; + + /// allows turning weak references off + public const bool weakReferences = true; + + /// prints all communicated messages to the console + public const bool messages = false; + + /// allows turning NIO off on Java + public const bool nio = true; + + /// allows overriding the file locking mechanism to turn it off + public const bool lockFile = true; + + public static void Expect(bool cond) + { + if (!cond) + { + throw new Exception("Should never happen"); + } + } + + public static void EnsureLock(object obj) + { + } + + public static bool ExceedsMaximumBlockSize(int a_length) + { + if (a_length > Const4.MaximumBlockSize) + { + return true; + } + return false; + } + + public static bool ExceedsMaximumArrayEntries(int a_entries, bool a_primitive) + { + if (a_entries > (a_primitive ? Const4.MaximumArrayEntriesPrimitive : Const4.MaximumArrayEntries + )) + { + return true; + } + return false; + } + + public static void ReadBegin(IReadBuffer buffer, byte identifier) + { + } + + public static void ReadEnd(IReadBuffer buffer) + { + if (Deploy.debug && Deploy.brackets) + { + if (buffer.ReadByte() != Const4.Yapend) + { + throw new Exception("Debug.readEnd() YAPEND expected"); + } + } + } + + public static void WriteBegin(IWriteBuffer buffer, byte identifier) + { + } + + public static void WriteEnd(IWriteBuffer buffer) + { + if (Deploy.debug && Deploy.brackets) + { + if (buffer is MarshallingContext) + { + ((MarshallingContext)buffer).DebugWriteEnd(Const4.Yapend); + return; + } + buffer.WriteByte(Const4.Yapend); + } + } + + private Debug4() + { + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Defragment/AbstractIdMapping.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Defragment/AbstractIdMapping.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Defragment/AbstractIdMapping.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Defragment/AbstractIdMapping.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,57 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Defragment; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal.Slots; + +namespace Db4objects.Db4o.Defragment +{ + /// Base class for defragment ID mappings. + /// Base class for defragment ID mappings. + /// Defragment + public abstract class AbstractIdMapping : IIdMapping + { + private Hashtable4 _classIDs = new Hashtable4(); + + public void MapId(int origID, int mappedID, bool isClassID) + { + if (isClassID) + { + MapClassIDs(origID, mappedID); + return; + } + MapNonClassIDs(origID, mappedID); + } + + protected virtual int MappedClassID(int origID) + { + object obj = _classIDs.Get(origID); + if (obj == null) + { + return 0; + } + return ((int)obj); + } + + private void MapClassIDs(int oldID, int newID) + { + _classIDs.Put(oldID, newID); + } + + protected abstract void MapNonClassIDs(int origID, int mappedID); + + public abstract int AddressForId(int arg1); + + public abstract void Close(); + + public abstract void Commit(); + + public abstract void MapId(int arg1, Slot arg2); + + public abstract int MappedId(int arg1); + + public abstract void Open(); + + public abstract IVisitable SlotChanges(); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Defragment/DatabaseIdMapping.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Defragment/DatabaseIdMapping.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Defragment/DatabaseIdMapping.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Defragment/DatabaseIdMapping.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,222 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System.Collections; +using Db4objects.Db4o.Defragment; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Btree; +using Db4objects.Db4o.Internal.Ids; +using Db4objects.Db4o.Internal.Mapping; +using Db4objects.Db4o.Internal.Slots; + +namespace Db4objects.Db4o.Defragment +{ + /// Database based mapping for IDs during a defragmentation run. + /// + /// Database based mapping for IDs during a defragmentation run. + /// Use this mapping to keep memory consumption lower than when + /// using the + /// InMemoryIdMapping + /// . + /// + /// Defragment + public class DatabaseIdMapping : AbstractIdMapping + { + private string _fileName; + + private LocalObjectContainer _mappingDb; + + private BTree _idTree; + + private BTree _slotTree; + + private MappedIDPair _cache = new MappedIDPair(0, 0); + + private DatabaseIdMapping.BTreeSpec _treeSpec = null; + + private int _commitFrequency = 0; + + private int _idInsertCount = 0; + + private int _slotInsertCount = 0; + + /// Will maintain the ID mapping as a BTree in the file with the given path. + /// + /// + /// Will maintain the ID mapping as a BTree in the file with the given path. + /// If a file exists in this location, it will be DELETED. + /// Node size and cache height of the tree will be the default values used by + /// the BTree implementation. The tree will never commit. + /// + /// The location where the BTree file should be created. + public DatabaseIdMapping(string fileName) : this(fileName, null, 0) + { + } + + /// Will maintain the ID mapping as a BTree in the file with the given path. + /// + /// + /// Will maintain the ID mapping as a BTree in the file with the given path. + /// If a file exists in this location, it will be DELETED. + /// + /// The location where the BTree file should be created. + /// The size of a BTree node + /// The number of inserts after which a commit should be issued (<=0: never commit) + /// + public DatabaseIdMapping(string fileName, int nodeSize, int commitFrequency) : this + (fileName, new DatabaseIdMapping.BTreeSpec(nodeSize), commitFrequency) + { + } + + private DatabaseIdMapping(string fileName, DatabaseIdMapping.BTreeSpec treeSpec, + int commitFrequency) + { + // <=0 : never commit + _fileName = fileName; + _treeSpec = treeSpec; + _commitFrequency = commitFrequency; + } + + public override int MappedId(int oldID) + { + if (_cache.Orig() == oldID) + { + return _cache.Mapped(); + } + int classID = MappedClassID(oldID); + if (classID != 0) + { + return classID; + } + IBTreeRange range = _idTree.SearchRange(Trans(), new MappedIDPair(oldID, 0)); + IEnumerator pointers = range.Pointers(); + if (pointers.MoveNext()) + { + BTreePointer pointer = (BTreePointer)pointers.Current; + _cache = (MappedIDPair)pointer.Key(); + return _cache.Mapped(); + } + return 0; + } + + protected override void MapNonClassIDs(int origID, int mappedID) + { + _cache = new MappedIDPair(origID, mappedID); + _idTree.Add(Trans(), _cache); + if (_commitFrequency > 0) + { + _idInsertCount++; + if (_commitFrequency == _idInsertCount) + { + _idTree.Commit(Trans()); + _idInsertCount = 0; + } + } + } + + /// + public override void Open() + { + _mappingDb = DefragmentServicesImpl.FreshTempFile(_fileName, 1); + _idTree = (_treeSpec == null ? new BTree(Trans(), 0, new MappedIDPairHandler()) : + new BTree(Trans(), 0, new MappedIDPairHandler(), _treeSpec.NodeSize())); + _slotTree = (_treeSpec == null ? new BTree(Trans(), 0, new BTreeIdSystem.IdSlotMappingHandler + ()) : new BTree(Trans(), 0, new BTreeIdSystem.IdSlotMappingHandler(), _treeSpec. + NodeSize())); + } + + public override void Close() + { + _mappingDb.Close(); + } + + private Transaction Trans() + { + return _mappingDb.SystemTransaction(); + } + + private class BTreeSpec + { + private int _nodeSize; + + public BTreeSpec(int nodeSize) + { + _nodeSize = nodeSize; + } + + public virtual int NodeSize() + { + return _nodeSize; + } + } + + public override void MapId(int id, Slot slot) + { + _slotTree.Add(Trans(), new IdSlotMapping(id, slot.Address(), slot.Length())); + if (_commitFrequency > 0) + { + _slotInsertCount++; + if (_commitFrequency == _slotInsertCount) + { + _slotTree.Commit(Trans()); + _slotInsertCount = 0; + } + } + } + + public override IVisitable SlotChanges() + { + return new _IVisitable_137(this); + } + + private sealed class _IVisitable_137 : IVisitable + { + public _IVisitable_137(DatabaseIdMapping _enclosing) + { + this._enclosing = _enclosing; + } + + public void Accept(IVisitor4 outSideVisitor) + { + this._enclosing._slotTree.TraverseKeys(this._enclosing.Trans(), new _IVisitor4_139 + (outSideVisitor)); + } + + private sealed class _IVisitor4_139 : IVisitor4 + { + public _IVisitor4_139(IVisitor4 outSideVisitor) + { + this.outSideVisitor = outSideVisitor; + } + + public void Visit(object idSlotMapping) + { + SlotChange slotChange = new SlotChange(((IdSlotMapping)idSlotMapping)._id); + slotChange.NotifySlotCreated(((IdSlotMapping)idSlotMapping).Slot()); + outSideVisitor.Visit(slotChange); + } + + private readonly IVisitor4 outSideVisitor; + } + + private readonly DatabaseIdMapping _enclosing; + } + + public override int AddressForId(int id) + { + IBTreeRange range = _slotTree.SearchRange(Trans(), new IdSlotMapping(id, 0, 0)); + IEnumerator pointers = range.Pointers(); + if (pointers.MoveNext()) + { + BTreePointer pointer = (BTreePointer)pointers.Current; + return ((IdSlotMapping)pointer.Key())._address; + } + return 0; + } + + public override void Commit() + { + _mappingDb.Commit(); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Defragment/DefragmentConfig.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Defragment/DefragmentConfig.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Defragment/DefragmentConfig.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Defragment/DefragmentConfig.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,305 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o; +using Db4objects.Db4o.Config; +using Db4objects.Db4o.Defragment; +using Db4objects.Db4o.Ext; +using Db4objects.Db4o.IO; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Config; + +namespace Db4objects.Db4o.Defragment +{ + /// Configuration for a defragmentation run. + /// Configuration for a defragmentation run. + /// Defragment + public class DefragmentConfig + { + public const bool Debug = false; + + public static readonly string BackupSuffix = "backup"; + + private string _origPath; + + private string _backupPath; + + private string _tempPath; + + private IIdMapping _mapping; + + private IConfiguration _config; + + private IStoredClassFilter _storedClassFilter = null; + + private bool _forceBackupDelete = false; + + private bool _readOnly = true; + + private int _objectCommitFrequency; + + private IStorage _backupStorage; + + /// Creates a configuration for a defragmentation run. + /// + /// Creates a configuration for a defragmentation run. The backup and mapping + /// file paths are generated from the original path by appending the default + /// suffixes. All properties other than the provided paths are set to FALSE + /// by default. + /// + /// + /// The path to the file to be defragmented. Must exist and must be + /// a valid db4o file. + /// + public DefragmentConfig(string origPath) : this(origPath, origPath + "." + BackupSuffix + ) + { + } + + /// Creates a configuration for a defragmentation run with in-memory mapping. + /// + /// + /// Creates a configuration for a defragmentation run with in-memory mapping. + /// All properties other than the provided paths are set to FALSE by default. + /// + /// + /// The path to the file to be defragmented. Must exist and must be + /// a valid db4o file. + /// + /// + /// The path to the backup of the original file. No file should + /// exist at this position, otherwise it will be OVERWRITTEN if forceBackupDelete() + /// is set to true! + /// + public DefragmentConfig(string origPath, string backupPath) : this(origPath, backupPath + , new InMemoryIdMapping()) + { + } + + /// Creates a configuration for a defragmentation run. + /// + /// Creates a configuration for a defragmentation run. All properties other + /// than the provided paths are set to FALSE by default. + /// + /// + /// The path to the file to be defragmented. Must exist and must be + /// a valid db4o file. + /// + /// + /// The path to the backup of the original file. No file should + /// exist at this position, otherwise it will be OVERWRITTEN if forceBackupDelete() + /// is set to true! + /// + /// + /// The Id mapping to be used internally. Pass either a + /// InMemoryIdMapping + /// for fastest defragment or a + /// DatabaseIdMapping + /// for low memory consumption. + /// + public DefragmentConfig(string origPath, string backupPath, IIdMapping mapping) + { + _origPath = origPath; + _backupPath = backupPath; + _mapping = mapping; + } + + /// The path to the file to be defragmented. + public virtual string OrigPath() + { + return _origPath; + } + + /// The path to the backup of the original file. + public virtual string BackupPath() + { + return _backupPath; + } + + /// The temporary ID mapping used internally. For internal use only. + public virtual IIdMapping Mapping() + { + return _mapping; + } + + /// + /// The + /// IStoredClassFilter + /// used to select stored class extents to + /// be included into the defragmented file. + /// + public virtual IStoredClassFilter StoredClassFilter() + { + return (_storedClassFilter == null ? Nullfilter : _storedClassFilter); + } + + /// + /// The + /// IStoredClassFilter + /// used to select stored class extents to + /// be included into the defragmented file. + /// + public virtual void StoredClassFilter(IStoredClassFilter storedClassFilter) + { + _storedClassFilter = storedClassFilter; + } + + /// true, if an existing backup file should be deleted, false otherwise. + public virtual bool ForceBackupDelete() + { + return _forceBackupDelete; + } + + /// true, if an existing backup file should be deleted, false otherwise. + /// + public virtual void ForceBackupDelete(bool forceBackupDelete) + { + _forceBackupDelete = forceBackupDelete; + } + + /// + /// allows turning on and off readonly mode.

+ /// When changed classes are likely to be detected defragment, it may be required + /// to open the original database in read/write mode. + ///
+ /// + /// allows turning on and off readonly mode.

+ /// When changed classes are likely to be detected defragment, it may be required + /// to open the original database in read/write mode.

+ /// Readonly mode is the default setting. + ///
+ /// false, to turn off readonly mode. + public virtual void ReadOnly(bool flag) + { + _readOnly = flag; + } + + /// true, if the original database file is to be opened in readonly mode. + public virtual bool ReadOnly() + { + return _readOnly; + } + + /// + /// The db4o + /// IConfiguration + /// to be applied + /// during the defragment process. + /// + public virtual IConfiguration Db4oConfig() + { + if (_config == null) + { + _config = VanillaDb4oConfig(1); + } + return _config; + } + + /// + /// The db4o + /// IConfiguration + /// to be applied + /// during the defragment process. + /// + [System.ObsoleteAttribute(@"since 7.9: use Db4oConfig(Db4objects.Db4o.Config.IEmbeddedConfiguration) instead" + )] + public virtual void Db4oConfig(IConfiguration config) + { + _config = config; + } + + /// + /// The db4o + /// IEmbeddedConfiguration + /// to be applied + /// during the defragment process. + /// + /// 7.9 + public virtual void Db4oConfig(IEmbeddedConfiguration config) + { + _config = ((EmbeddedConfigurationImpl)config).Legacy(); + } + + public virtual int ObjectCommitFrequency() + { + return _objectCommitFrequency; + } + + /// + /// The number of processed object (slots) that should trigger an + /// intermediate commit of the target file. Default: 0, meaning: never. + /// + public virtual void ObjectCommitFrequency(int objectCommitFrequency) + { + _objectCommitFrequency = objectCommitFrequency; + } + + /// + /// Instruct the defragment process to upgrade the source file to the current db4o + /// version prior to defragmenting it. + /// + /// + /// Instruct the defragment process to upgrade the source file to the current db4o + /// version prior to defragmenting it. Use this option if your source file has been created + /// with an older db4o version than the one you are using. + /// + /// The location for an intermediate, upgraded version of the source file. + /// + public virtual void UpgradeFile(string tempPath) + { + _tempPath = tempPath; + } + + public virtual bool FileNeedsUpgrade() + { + return _tempPath != null; + } + + public virtual string TempPath() + { + return (_tempPath != null ? _tempPath : _backupPath); + } + + public virtual int BlockSize() + { + return ((Config4Impl)Db4oConfig()).BlockSize(); + } + + protected class NullFilter : IStoredClassFilter + { + public virtual bool Accept(IStoredClass storedClass) + { + return true; + } + } + + private static readonly IStoredClassFilter Nullfilter = new DefragmentConfig.NullFilter + (); + + public static IConfiguration VanillaDb4oConfig(int blockSize) + { + IConfiguration config = Db4oFactory.NewConfiguration(); + config.WeakReferences(false); + config.BlockSize(blockSize); + return config; + } + + public virtual IConfiguration ClonedDb4oConfig() + { + return (IConfiguration)((Config4Impl)Db4oConfig()).DeepClone(null); + } + + public virtual void BackupStorage(IStorage backupStorage) + { + _backupStorage = backupStorage; + } + + public virtual IStorage BackupStorage() + { + if (_backupStorage != null) + { + return _backupStorage; + } + return _config.Storage; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Defragment/Defragment.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Defragment/Defragment.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Defragment/Defragment.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Defragment/Defragment.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,447 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System.IO; +using Db4objects.Db4o; +using Db4objects.Db4o.Config; +using Db4objects.Db4o.Defragment; +using Db4objects.Db4o.Ext; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.IO; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Btree; +using Db4objects.Db4o.Internal.Classindex; +using Db4objects.Db4o.Internal.Mapping; + +namespace Db4objects.Db4o.Defragment +{ + /// defragments database files. + /// + /// defragments database files. + ///
+ ///
+ /// db4o structures storage inside database files as free and occupied + /// slots, very much like a file system - and just like a file system it + /// can be fragmented. + ///
+ ///
+ /// The simplest way to defragment a database file: + ///
+ ///
+ /// Defragment.Defrag("sample.yap"); + /// + ///
+ ///
+ /// This will move the file to "sample.yap.backup", then create a + /// defragmented version of this file in the original position, using a + /// temporary file "sample.yap.mapping". If the backup file already + /// exists, this will throw an exception and no action will be taken. + ///
+ ///
+ /// For more detailed configuration of the defragmentation process, + /// provide a DefragmentConfig instance: + ///
+ ///
+ /// + /// DefragmentConfig config=new + /// DefragmentConfig("sample.yap","sample.bap",new + /// BTreeIDMapping("sample.map")); + ///
+ /// config.ForceBackupDelete(true); + ///
+ /// config.StoredClassFilter(new AvailableClassFilter()); + ///
+ /// config.Db4oConfig(db4oConfig); + ///
+ /// Defragment.Defrag(config); + ///
+ ///
+ ///
+ /// This will move the file to "sample.bap", then create a defragmented + /// version of this file in the original position, using a temporary + /// file "sample.map" for BTree mapping. If the backup file already + /// exists, it will be deleted. The defragmentation process will skip + /// all classes that have instances stored within the yap file, but that + /// are not available on the class path (through the current + /// classloader). Custom db4o configuration options are read from the + /// IConfiguration + /// passed as db4oConfig. + /// Note: + /// For some specific, non-default configuration settings like UUID + /// generation, etc., you + /// must + /// pass an appropriate db4o configuration, just like you'd use it + /// within your application for normal database operation. + ///
+ public class Defragment + { + /// + /// Renames the file at the given original path to a backup file and then + /// builds a defragmented version of the file in the original place. + /// + /// + /// Renames the file at the given original path to a backup file and then + /// builds a defragmented version of the file in the original place. + /// + /// The path to the file to be defragmented. + /// if the original file cannot be moved to the backup location + /// + public static void Defrag(string origPath) + { + Defrag(new DefragmentConfig(origPath), new Defragment.NullListener()); + } + + /// + /// Renames the file at the given original path to the given backup file and + /// then builds a defragmented version of the file in the original place. + /// + /// + /// Renames the file at the given original path to the given backup file and + /// then builds a defragmented version of the file in the original place. + /// + /// The path to the file to be defragmented. + /// The path to the backup file to be created. + /// if the original file cannot be moved to the backup location + /// + public static void Defrag(string origPath, string backupPath) + { + Defrag(new DefragmentConfig(origPath, backupPath), new Defragment.NullListener()); + } + + /// + /// Renames the file at the configured original path to the configured backup + /// path and then builds a defragmented version of the file in the original + /// place. + /// + /// + /// Renames the file at the configured original path to the configured backup + /// path and then builds a defragmented version of the file in the original + /// place. + /// + /// The configuration for this defragmentation run. + /// if the original file cannot be moved to the backup location + /// + public static void Defrag(DefragmentConfig config) + { + Defrag(config, new Defragment.NullListener()); + } + + /// + /// Renames the file at the configured original path to the configured backup + /// path and then builds a defragmented version of the file in the original + /// place. + /// + /// + /// Renames the file at the configured original path to the configured backup + /// path and then builds a defragmented version of the file in the original + /// place. + /// + /// The configuration for this defragmentation run. + /// + /// A listener for status notifications during the defragmentation + /// process. + /// + /// if the original file cannot be moved to the backup location + /// + public static void Defrag(DefragmentConfig config, IDefragmentListener listener) + { + IStorage storage = config.Db4oConfig().Storage; + EnsureFileExists(storage, config.OrigPath()); + IStorage backupStorage = config.BackupStorage(); + if (backupStorage.Exists(config.BackupPath())) + { + if (!config.ForceBackupDelete()) + { + throw new IOException("Could not use '" + config.BackupPath() + "' as backup path - file exists." + ); + } + } + // Always delete, because !exists can indicate length == 0 + backupStorage.Delete(config.BackupPath()); + MoveToBackup(config); + if (config.FileNeedsUpgrade()) + { + UpgradeFile(config); + } + DefragmentServicesImpl services = new DefragmentServicesImpl(config, listener); + try + { + FirstPass(services, config); + services.CommitIds(); + SecondPass(services, config); + services.CommitIds(); + DefragUnindexed(services); + services.CommitIds(); + services.DefragIdToTimestampBtree(); + services.ReplaceClassMetadataRepository(); + } + catch (CorruptionException exc) + { + Sharpen.Runtime.PrintStackTrace(exc); + } + finally + { + services.Close(); + } + } + + /// + private static void MoveToBackup(DefragmentConfig config) + { + IStorage origStorage = config.Db4oConfig().Storage; + if (origStorage == config.BackupStorage()) + { + origStorage.Rename(config.OrigPath(), config.BackupPath()); + return; + } + CopyBin(origStorage, config.BackupStorage(), config.OrigPath(), config.BackupPath + ()); + origStorage.Delete(config.OrigPath()); + } + + /// + private static void CopyBin(IStorage sourceStorage, IStorage targetStorage, string + sourcePath, string targetPath) + { + IBin origBin = sourceStorage.Open(new BinConfiguration(sourcePath, true, 0, true) + ); + try + { + IBin backupBin = targetStorage.Open(new BinConfiguration(targetPath, true, origBin + .Length(), false)); + try + { + byte[] buffer = new byte[4096]; + int bytesRead = -1; + int pos = 0; + while ((bytesRead = origBin.Read(pos, buffer, buffer.Length)) >= 0) + { + backupBin.Write(pos, buffer, bytesRead); + pos += bytesRead; + } + } + finally + { + SyncAndClose(backupBin); + } + } + finally + { + SyncAndClose(origBin); + } + } + + private static void SyncAndClose(IBin bin) + { + try + { + bin.Sync(); + } + finally + { + bin.Close(); + } + } + + /// + private static void EnsureFileExists(IStorage storage, string origPath) + { + if (!storage.Exists(origPath)) + { + throw new IOException("Source database file '" + origPath + "' does not exist."); + } + } + + /// + private static void UpgradeFile(DefragmentConfig config) + { + CopyBin(config.BackupStorage(), config.BackupStorage(), config.BackupPath(), config + .TempPath()); + IConfiguration db4oConfig = (IConfiguration)((Config4Impl)config.Db4oConfig()).DeepClone + (null); + db4oConfig.Storage = config.BackupStorage(); + db4oConfig.AllowVersionUpdates(true); + IObjectContainer db = Db4oFactory.OpenFile(db4oConfig, config.TempPath()); + db.Close(); + } + + private static void DefragUnindexed(DefragmentServicesImpl services) + { + IdSource unindexedIDs = services.UnindexedIDs(); + while (unindexedIDs.HasMoreIds()) + { + int origID = unindexedIDs.NextId(); + DefragmentContextImpl.ProcessCopy(services, origID, new _ISlotCopyHandler_208()); + } + } + + private sealed class _ISlotCopyHandler_208 : ISlotCopyHandler + { + public _ISlotCopyHandler_208() + { + } + + public void ProcessCopy(DefragmentContextImpl context) + { + ClassMetadata.DefragObject(context); + } + } + + /// + /// + private static void FirstPass(DefragmentServicesImpl context, DefragmentConfig config + ) + { + // System.out.println("FIRST"); + Pass(context, config, new FirstPassCommand()); + } + + /// + /// + private static void SecondPass(DefragmentServicesImpl context, DefragmentConfig config + ) + { + // System.out.println("SECOND"); + Pass(context, config, new SecondPassCommand(config.ObjectCommitFrequency())); + } + + /// + /// + private static void Pass(DefragmentServicesImpl context, DefragmentConfig config, + IPassCommand command) + { + command.ProcessClassCollection(context); + IStoredClass[] classes = context.StoredClasses(DefragmentServicesImpl.Sourcedb); + for (int classIdx = 0; classIdx < classes.Length; classIdx++) + { + ClassMetadata classMetadata = (ClassMetadata)classes[classIdx]; + if (!config.StoredClassFilter().Accept(classMetadata)) + { + continue; + } + ProcessClass(context, classMetadata, command); + command.Flush(context); + if (config.ObjectCommitFrequency() > 0) + { + context.TargetCommit(); + } + } + BTree uuidIndex = context.SourceUuidIndex(); + if (uuidIndex != null) + { + command.ProcessBTree(context, uuidIndex); + } + command.Flush(context); + context.TargetCommit(); + } + + // TODO order of class index/object slot processing is crucial: + // - object slots before field indices (object slots register addresses for + // use by string indices) + // - class index before object slots, otherwise phantom btree entries from + // deletions appear in the source class index?!? + // reproducable with SelectiveCascadingDeleteTestCase and ObjectSetTestCase + // - investigate. + /// + /// + private static void ProcessClass(DefragmentServicesImpl context, ClassMetadata curClass + , IPassCommand command) + { + ProcessClassIndex(context, curClass, command); + if (!ParentHasIndex(curClass)) + { + ProcessObjectsForClass(context, curClass, command); + } + ProcessClassAndFieldIndices(context, curClass, command); + } + + private static bool ParentHasIndex(ClassMetadata curClass) + { + ClassMetadata parentClass = curClass.GetAncestor(); + while (parentClass != null) + { + if (parentClass.HasClassIndex()) + { + return true; + } + parentClass = parentClass.GetAncestor(); + } + return false; + } + + private static void ProcessObjectsForClass(DefragmentServicesImpl context, ClassMetadata + curClass, IPassCommand command) + { + context.TraverseAll(curClass, new _IVisitor4_284(command, context, curClass)); + } + + private sealed class _IVisitor4_284 : IVisitor4 + { + public _IVisitor4_284(IPassCommand command, DefragmentServicesImpl context, ClassMetadata + curClass) + { + this.command = command; + this.context = context; + this.curClass = curClass; + } + + public void Visit(object obj) + { + int id = ((int)obj); + try + { + // FIXME bubble up exceptions + command.ProcessObjectSlot(context, curClass, id); + } + catch (CorruptionException e) + { + Sharpen.Runtime.PrintStackTrace(e); + } + catch (IOException e) + { + Sharpen.Runtime.PrintStackTrace(e); + } + } + + private readonly IPassCommand command; + + private readonly DefragmentServicesImpl context; + + private readonly ClassMetadata curClass; + } + + /// + /// + private static void ProcessClassAndFieldIndices(DefragmentServicesImpl context, ClassMetadata + curClass, IPassCommand command) + { + int sourceClassIndexID = 0; + int targetClassIndexID = 0; + if (curClass.HasClassIndex()) + { + sourceClassIndexID = curClass.Index().Id(); + targetClassIndexID = context.MappedID(sourceClassIndexID, -1); + } + command.ProcessClass(context, curClass, curClass.GetID(), targetClassIndexID); + } + + /// + /// + private static void ProcessClassIndex(DefragmentServicesImpl context, ClassMetadata + curClass, IPassCommand command) + { + if (curClass.HasClassIndex()) + { + BTreeClassIndexStrategy indexStrategy = (BTreeClassIndexStrategy)curClass.Index(); + BTree btree = indexStrategy.Btree(); + command.ProcessBTree(context, btree); + } + } + + internal class NullListener : IDefragmentListener + { + public virtual void NotifyDefragmentInfo(DefragmentInfo info) + { + } + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Defragment/DefragmentInfo.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Defragment/DefragmentInfo.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Defragment/DefragmentInfo.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Defragment/DefragmentInfo.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,29 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +namespace Db4objects.Db4o.Defragment +{ + /// A message from the defragmentation process. + /// + /// A message from the defragmentation process. This is a stub only + /// and will be refined. + /// Currently instances of these class will only be created and sent + /// to registered listeners when invalid IDs are encountered during + /// the defragmentation process. These probably are harmless and the + /// result of a user-initiated delete operation. + /// + /// Defragment + public class DefragmentInfo + { + private string _msg; + + public DefragmentInfo(string msg) + { + _msg = msg; + } + + public override string ToString() + { + return _msg; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Defragment/DefragmentServicesImpl.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Defragment/DefragmentServicesImpl.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Defragment/DefragmentServicesImpl.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Defragment/DefragmentServicesImpl.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,560 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System.Collections; +using Db4objects.Db4o; +using Db4objects.Db4o.Config; +using Db4objects.Db4o.Defragment; +using Db4objects.Db4o.Ext; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.IO; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Btree; +using Db4objects.Db4o.Internal.Classindex; +using Db4objects.Db4o.Internal.Encoding; +using Db4objects.Db4o.Internal.Ids; +using Db4objects.Db4o.Internal.Mapping; +using Db4objects.Db4o.Internal.Marshall; +using Db4objects.Db4o.Internal.Slots; +using Db4objects.Db4o.Typehandlers; + +namespace Db4objects.Db4o.Defragment +{ + /// + public class DefragmentServicesImpl : IDefragmentServices + { + public abstract class DbSelector + { + internal DbSelector() + { + } + + internal abstract LocalObjectContainer Db(DefragmentServicesImpl context); + + internal virtual Db4objects.Db4o.Internal.Transaction Transaction(DefragmentServicesImpl + context) + { + return Db(context).SystemTransaction(); + } + } + + private sealed class _DbSelector_39 : DefragmentServicesImpl.DbSelector + { + public _DbSelector_39() + { + } + + internal override LocalObjectContainer Db(DefragmentServicesImpl context) + { + return context._sourceDb; + } + } + + public static readonly DefragmentServicesImpl.DbSelector Sourcedb = new _DbSelector_39 + (); + + private sealed class _DbSelector_45 : DefragmentServicesImpl.DbSelector + { + public _DbSelector_45() + { + } + + internal override LocalObjectContainer Db(DefragmentServicesImpl context) + { + return context._targetDb; + } + } + + public static readonly DefragmentServicesImpl.DbSelector Targetdb = new _DbSelector_45 + (); + + private readonly LocalObjectContainer _sourceDb; + + private readonly LocalObjectContainer _targetDb; + + private readonly IIdMapping _mapping; + + private IDefragmentListener _listener; + + private IQueue4 _unindexed = new NonblockingQueue(); + + private DefragmentConfig _defragConfig; + + /// + public DefragmentServicesImpl(DefragmentConfig defragConfig, IDefragmentListener + listener) + { + _listener = listener; + Config4Impl originalConfig = (Config4Impl)defragConfig.Db4oConfig(); + IStorage storage = defragConfig.BackupStorage(); + if (defragConfig.ReadOnly()) + { + storage = new NonFlushingStorage(storage); + } + Config4Impl sourceConfig = PrepareConfig(originalConfig, storage, defragConfig.ReadOnly + ()); + _sourceDb = (LocalObjectContainer)Db4oFactory.OpenFile(sourceConfig, defragConfig + .TempPath()).Ext(); + _sourceDb.ShowInternalClasses(true); + defragConfig.Db4oConfig().BlockSize(_sourceDb.BlockSize()); + if (!originalConfig.GenerateCommitTimestamps().DefiniteNo()) + { + defragConfig.Db4oConfig().GenerateCommitTimestamps(_sourceDb.Config().GenerateCommitTimestamps + ().DefiniteYes()); + } + _targetDb = FreshTargetFile(defragConfig); + _mapping = defragConfig.Mapping(); + _mapping.Open(); + _defragConfig = defragConfig; + } + + private Config4Impl PrepareConfig(Config4Impl originalConfig, IStorage storage, bool + readOnly) + { + Config4Impl sourceConfig = (Config4Impl)originalConfig.DeepClone(null); + sourceConfig.WeakReferences(false); + sourceConfig.Storage = storage; + sourceConfig.ReadOnly(readOnly); + return sourceConfig; + } + + /// + internal static LocalObjectContainer FreshTempFile(string fileName, int blockSize + ) + { + FileStorage storage = new FileStorage(); + storage.Delete(fileName); + IConfiguration db4oConfig = DefragmentConfig.VanillaDb4oConfig(blockSize); + db4oConfig.ObjectClass(typeof(IdSlotMapping)).ObjectField("_id").Indexed(true); + db4oConfig.Storage = storage; + return (LocalObjectContainer)Db4oFactory.OpenFile(db4oConfig, fileName).Ext(); + } + + /// + internal static LocalObjectContainer FreshTargetFile(DefragmentConfig config) + { + config.Db4oConfig().Storage.Delete(config.OrigPath()); + return (LocalObjectContainer)Db4oFactory.OpenFile(config.ClonedDb4oConfig(), config + .OrigPath()); + } + + public virtual int MappedID(int oldID, int defaultID) + { + int mapped = InternalMappedID(oldID); + return (mapped != 0 ? mapped : defaultID); + } + + /// + public virtual int StrictMappedID(int oldID) + { + int mapped = InternalMappedID(oldID); + if (mapped == 0) + { + throw new MappingNotFoundException(oldID); + } + return mapped; + } + + public virtual int MappedID(int id) + { + if (id == 0) + { + return 0; + } + int mapped = InternalMappedID(id); + if (mapped == 0) + { + _listener.NotifyDefragmentInfo(new DefragmentInfo("No mapping found for ID " + id + )); + return Const4.InvalidObjectId; + } + return mapped; + } + + /// + private int InternalMappedID(int oldID) + { + if (oldID == 0) + { + return 0; + } + int mappedId = _mapping.MappedId(oldID); + if (mappedId == 0 && _sourceDb.Handlers.IsSystemHandler(oldID)) + { + return oldID; + } + return mappedId; + } + + public virtual void MapIDs(int oldID, int newID, bool isClassID) + { + _mapping.MapId(oldID, newID, isClassID); + } + + public virtual void Close() + { + _sourceDb.Close(); + _targetDb.Close(); + _mapping.Close(); + } + + public virtual ByteArrayBuffer BufferByID(DefragmentServicesImpl.DbSelector selector + , int id) + { + Slot slot = CommittedSlot(selector, id); + return BufferByAddress(selector, slot.Address(), slot.Length()); + } + + private Slot CommittedSlot(DefragmentServicesImpl.DbSelector selector, int id) + { + return selector.Db(this).IdSystem().CommittedSlot(id); + } + + /// + public virtual ByteArrayBuffer SourceBufferByAddress(int address, int length) + { + return BufferByAddress(Sourcedb, address, length); + } + + /// + public virtual ByteArrayBuffer TargetBufferByAddress(int address, int length) + { + return BufferByAddress(Targetdb, address, length); + } + + public virtual ByteArrayBuffer BufferByAddress(DefragmentServicesImpl.DbSelector + selector, int address, int length) + { + return selector.Db(this).DecryptedBufferByAddress(address, length); + } + + /// + public virtual StatefulBuffer TargetStatefulBufferByAddress(int address, int length + ) + { + return _targetDb.ReadWriterByAddress(Targetdb.Transaction(this), address, length); + } + + public virtual Slot AllocateTargetSlot(int length) + { + return _targetDb.AllocateSlot(length); + } + + public virtual void TargetWriteBytes(DefragmentContextImpl context, int address) + { + context.Write(_targetDb, address); + } + + public virtual void TargetWriteBytes(ByteArrayBuffer reader, int address) + { + _targetDb.WriteBytes(reader, address, 0); + } + + public virtual IStoredClass[] StoredClasses(DefragmentServicesImpl.DbSelector selector + ) + { + LocalObjectContainer db = selector.Db(this); + db.ShowInternalClasses(true); + try + { + return db.ClassCollection().StoredClasses(); + } + finally + { + db.ShowInternalClasses(false); + } + } + + public virtual LatinStringIO StringIO() + { + return _sourceDb.StringIO(); + } + + public virtual void TargetCommit() + { + _targetDb.Commit(); + } + + public virtual ITypeHandler4 SourceHandler(int id) + { + return _sourceDb.TypeHandlerForClassMetadataID(id); + } + + public virtual int SourceClassCollectionID() + { + return _sourceDb.ClassCollection().GetID(); + } + + private Hashtable4 _classIndices = new Hashtable4(16); + + public virtual int ClassIndexID(ClassMetadata classMetadata) + { + return ClassIndex(classMetadata).Id(); + } + + public virtual void TraverseAll(ClassMetadata classMetadata, IVisitor4 command) + { + if (!classMetadata.HasClassIndex()) + { + return; + } + classMetadata.Index().TraverseAll(Sourcedb.Transaction(this), command); + } + + public virtual void TraverseAllIndexSlots(ClassMetadata classMetadata, IVisitor4 + command) + { + IEnumerator slotIDIter = classMetadata.Index().AllSlotIDs(Sourcedb.Transaction(this + )); + while (slotIDIter.MoveNext()) + { + command.Visit(slotIDIter.Current); + } + } + + public virtual void TraverseAllIndexSlots(BTree btree, IVisitor4 command) + { + IEnumerator slotIDIter = btree.AllNodeIds(Sourcedb.Transaction(this)); + while (slotIDIter.MoveNext()) + { + command.Visit(slotIDIter.Current); + } + } + + public virtual void RegisterBTreeIDs(BTree btree, IDMappingCollector collector) + { + collector.CreateIDMapping(this, btree.GetID(), false); + TraverseAllIndexSlots(btree, new _IVisitor4_244(this, collector)); + } + + private sealed class _IVisitor4_244 : IVisitor4 + { + public _IVisitor4_244(DefragmentServicesImpl _enclosing, IDMappingCollector collector + ) + { + this._enclosing = _enclosing; + this.collector = collector; + } + + public void Visit(object obj) + { + int id = ((int)obj); + collector.CreateIDMapping(this._enclosing, id, false); + } + + private readonly DefragmentServicesImpl _enclosing; + + private readonly IDMappingCollector collector; + } + + public virtual int DatabaseIdentityID(DefragmentServicesImpl.DbSelector selector) + { + LocalObjectContainer db = selector.Db(this); + Db4oDatabase identity = db.Identity(); + if (identity == null) + { + return 0; + } + return identity.GetID(selector.Transaction(this)); + } + + private IClassIndexStrategy ClassIndex(ClassMetadata classMetadata) + { + IClassIndexStrategy classIndex = (IClassIndexStrategy)_classIndices.Get(classMetadata + ); + if (classIndex == null) + { + classIndex = new BTreeClassIndexStrategy(classMetadata); + _classIndices.Put(classMetadata, classIndex); + classIndex.Initialize(_targetDb); + } + return classIndex; + } + + public virtual Db4objects.Db4o.Internal.Transaction SystemTrans() + { + return Sourcedb.Transaction(this); + } + + public virtual void CopyIdentity() + { + _targetDb.SetIdentity(_sourceDb.Identity()); + } + + public virtual void ReplaceClassMetadataRepository() + { + Db4objects.Db4o.Internal.Transaction systemTransaction = _targetDb.SystemTransaction + (); + // Can't use strictMappedID because the repository ID can + // be lower than HandlerRegisrtry _highestBuiltinTypeID and + // the ClassRepository ID would be treated as a system handler + // and the unmapped ID would be returned. + int newRepositoryId = _mapping.MappedId(SourceClassCollectionID()); + int sourceIdentityID = DatabaseIdentityID(DefragmentServicesImpl.Sourcedb); + int targetIdentityID = _mapping.MappedId(sourceIdentityID); + int targetUuidIndexID = _mapping.MappedId(SourceUuidIndexID()); + int oldIdentityId = _targetDb.SystemData().Identity().GetID(systemTransaction); + int oldRepositoryId = _targetDb.ClassCollection().GetID(); + ClassMetadataRepository oldRepository = _targetDb.ClassCollection(); + ClassMetadataRepository newRepository = new ClassMetadataRepository(systemTransaction + ); + newRepository.SetID(newRepositoryId); + newRepository.Read(systemTransaction); + newRepository.InitOnUp(systemTransaction); + _targetDb.SystemData().ClassCollectionID(newRepositoryId); + _targetDb.ReplaceClassMetadataRepository(newRepository); + _targetDb.SystemData().UuidIndexId(targetUuidIndexID); + Db4oDatabase identity = (Db4oDatabase)_targetDb.GetByID(systemTransaction, targetIdentityID + ); + _targetDb.SetIdentity(identity); + ClassMetadataIterator iterator = oldRepository.Iterator(); + while (iterator.MoveNext()) + { + ClassMetadata classMetadata = iterator.CurrentClass(); + BTreeClassIndexStrategy index = (BTreeClassIndexStrategy)classMetadata.Index(); + index.Btree().Free(_targetDb.LocalSystemTransaction()); + FreeById(classMetadata.GetID()); + } + FreeById(oldIdentityId); + FreeById(oldRepositoryId); + } + + public virtual void DefragIdToTimestampBtree() + { + if (_sourceDb.SystemData().IdToTimestampIndexId() == 0) + { + return; + } + LocalTransaction targetTransaction = (LocalTransaction)_targetDb.SystemTransaction + (); + LocalTransaction sourceTransaction = (LocalTransaction)_sourceDb.SystemTransaction + (); + CommitTimestampSupport target = targetTransaction.CommitTimestampSupport(); + CommitTimestampSupport source = sourceTransaction.CommitTimestampSupport(); + if (source.IdToTimestamp() == null) + { + return; + } + source.IdToTimestamp().TraverseKeys(sourceTransaction, new _IVisitor4_336(this, target + , targetTransaction)); + } + + private sealed class _IVisitor4_336 : IVisitor4 + { + public _IVisitor4_336(DefragmentServicesImpl _enclosing, CommitTimestampSupport target + , LocalTransaction targetTransaction) + { + this._enclosing = _enclosing; + this.target = target; + this.targetTransaction = targetTransaction; + } + + public void Visit(object te) + { + int mappedID = this._enclosing.MappedID(((CommitTimestampSupport.TimestampEntry)te + ).ParentID()); + target.Put(targetTransaction, mappedID, ((CommitTimestampSupport.TimestampEntry)te + ).GetCommitTimestamp()); + } + + private readonly DefragmentServicesImpl _enclosing; + + private readonly CommitTimestampSupport target; + + private readonly LocalTransaction targetTransaction; + } + + private void FreeById(int id) + { + _targetDb.SystemTransaction().IdSystem().NotifySlotDeleted(id, SlotChangeFactory. + SystemObjects); + } + + public virtual ByteArrayBuffer SourceBufferByID(int sourceID) + { + return BufferByID(Sourcedb, sourceID); + } + + public virtual BTree SourceUuidIndex() + { + if (SourceUuidIndexID() == 0) + { + return null; + } + return _sourceDb.UUIDIndex().GetIndex(SystemTrans()); + } + + public virtual void TargetUuidIndexID(int id) + { + _targetDb.SystemData().UuidIndexId(id); + } + + public virtual int SourceUuidIndexID() + { + return _sourceDb.SystemData().UuidIndexId(); + } + + public virtual int SourceIdToTimestampIndexID() + { + return _sourceDb.SystemData().IdToTimestampIndexId(); + } + + public virtual ClassMetadata ClassMetadataForId(int id) + { + return _sourceDb.ClassMetadataForID(id); + } + + public virtual void RegisterUnindexed(int id) + { + _unindexed.Add(id); + } + + public virtual IdSource UnindexedIDs() + { + return new IdSource(_unindexed); + } + + public virtual ObjectHeader SourceObjectHeader(ByteArrayBuffer buffer) + { + return new ObjectHeader(_sourceDb, buffer); + } + + public virtual int BlockSize() + { + return _sourceDb.BlockSize(); + } + + public virtual int SourceAddressByID(int sourceID) + { + return CommittedSlot(Sourcedb, sourceID).Address(); + } + + public virtual int TargetAddressByID(int sourceID) + { + return _mapping.AddressForId(sourceID); + } + + public virtual bool Accept(IStoredClass klass) + { + return this._defragConfig.StoredClassFilter().Accept(klass); + } + + public virtual int TargetNewId() + { + return _targetDb.IdSystem().NewId(); + } + + public virtual IIdMapping Mapping() + { + return _mapping; + } + + public virtual void CommitIds() + { + FreespaceCommitter freespaceCommitter = new FreespaceCommitter(_targetDb.FreespaceManager + ()); + freespaceCommitter.TransactionalIdSystem(SystemTrans().IdSystem()); + _targetDb.IdSystem().Commit(Mapping().SlotChanges(), freespaceCommitter); + freespaceCommitter.Commit(); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Defragment/FirstPassCommand.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Defragment/FirstPassCommand.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Defragment/FirstPassCommand.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Defragment/FirstPassCommand.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,76 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Defragment; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Btree; +using Db4objects.Db4o.Internal.Metadata; + +namespace Db4objects.Db4o.Defragment +{ + /// + /// First step in the defragmenting process: Allocates pointer slots in the target file for + /// each ID (but doesn't fill them in, yet) and registers the mapping from source pointer address + /// to target pointer address. + /// + /// + /// First step in the defragmenting process: Allocates pointer slots in the target file for + /// each ID (but doesn't fill them in, yet) and registers the mapping from source pointer address + /// to target pointer address. + /// + /// + public sealed class FirstPassCommand : IPassCommand + { + private IDMappingCollector _collector = new IDMappingCollector(); + + public void ProcessClass(DefragmentServicesImpl context, ClassMetadata classMetadata + , int id, int classIndexID) + { + _collector.CreateIDMapping(context, id, true); + classMetadata.TraverseAllAspects(new _TraverseFieldCommand_24(this, context)); + } + + private sealed class _TraverseFieldCommand_24 : TraverseFieldCommand + { + public _TraverseFieldCommand_24(FirstPassCommand _enclosing, DefragmentServicesImpl + context) + { + this._enclosing = _enclosing; + this.context = context; + } + + protected override void Process(FieldMetadata field) + { + if (!field.IsVirtual() && field.HasIndex()) + { + this._enclosing.ProcessBTree(context, field.GetIndex(context.SystemTrans())); + } + } + + private readonly FirstPassCommand _enclosing; + + private readonly DefragmentServicesImpl context; + } + + public void ProcessObjectSlot(DefragmentServicesImpl context, ClassMetadata classMetadata + , int sourceID) + { + _collector.CreateIDMapping(context, sourceID, false); + } + + /// + public void ProcessClassCollection(DefragmentServicesImpl context) + { + _collector.CreateIDMapping(context, context.SourceClassCollectionID(), false); + } + + public void ProcessBTree(DefragmentServicesImpl context, BTree btree) + { + context.RegisterBTreeIDs(btree, _collector); + } + + public void Flush(DefragmentServicesImpl context) + { + _collector.Flush(context); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Defragment/IDefragmentListener.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Defragment/IDefragmentListener.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Defragment/IDefragmentListener.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Defragment/IDefragmentListener.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,23 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Defragment; + +namespace Db4objects.Db4o.Defragment +{ + /// Listener for defragmentation process messages. + /// Listener for defragmentation process messages. + /// Defragment + public interface IDefragmentListener + { + /// + /// This method will be called when the defragment process encounters + /// file layout anomalies during the defragmentation process. + /// + /// + /// This method will be called when the defragment process encounters + /// file layout anomalies during the defragmentation process. + /// + /// The message from the defragmentation process. + void NotifyDefragmentInfo(DefragmentInfo info); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Defragment/IDefragmentServices.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Defragment/IDefragmentServices.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Defragment/IDefragmentServices.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Defragment/IDefragmentServices.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,57 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Defragment; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Btree; +using Db4objects.Db4o.Internal.Mapping; +using Db4objects.Db4o.Internal.Slots; + +namespace Db4objects.Db4o.Defragment +{ + /// Encapsulates services involving source and target database files during defragmenting. + /// + /// Encapsulates services involving source and target database files during defragmenting. + /// + /// + public interface IDefragmentServices : IIDMapping + { + /// + ByteArrayBuffer SourceBufferByAddress(int address, int length); + + /// + ByteArrayBuffer TargetBufferByAddress(int address, int length); + + ByteArrayBuffer SourceBufferByID(int sourceID); + + Slot AllocateTargetSlot(int targetLength); + + void TargetWriteBytes(ByteArrayBuffer targetPointerReader, int targetAddress); + + Transaction SystemTrans(); + + void TargetWriteBytes(DefragmentContextImpl context, int targetAddress); + + void TraverseAllIndexSlots(BTree tree, IVisitor4 visitor4); + + void RegisterBTreeIDs(BTree tree, IDMappingCollector collector); + + ClassMetadata ClassMetadataForId(int id); + + int MappedID(int id); + + void RegisterUnindexed(int id); + + IdSource UnindexedIDs(); + + int SourceAddressByID(int sourceID); + + int TargetAddressByID(int sourceID); + + int TargetNewId(); + + IIdMapping Mapping(); + + void CommitIds(); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Defragment/IDMappingCollector.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Defragment/IDMappingCollector.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Defragment/IDMappingCollector.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Defragment/IDMappingCollector.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,54 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System.Collections; +using Db4objects.Db4o.Defragment; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal; + +namespace Db4objects.Db4o.Defragment +{ + public class IDMappingCollector + { + private const int IdBatchSize = 4096; + + private TreeInt _ids; + + internal virtual void CreateIDMapping(DefragmentServicesImpl context, int objectID + , bool isClassID) + { + if (BatchFull()) + { + Flush(context); + } + _ids = TreeInt.Add(_ids, (isClassID ? -objectID : objectID)); + } + + private bool BatchFull() + { + return _ids != null && _ids.Size() == IdBatchSize; + } + + public virtual void Flush(DefragmentServicesImpl context) + { + if (_ids == null) + { + return; + } + IEnumerator idIter = new TreeKeyIterator(_ids); + while (idIter.MoveNext()) + { + int objectID = ((int)idIter.Current); + bool isClassID = false; + if (objectID < 0) + { + objectID = -objectID; + isClassID = true; + } + // seen object ids don't come by here anymore - any other candidates? + context.MapIDs(objectID, context.TargetNewId(), isClassID); + } + context.Mapping().Commit(); + _ids = null; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Defragment/IIdMapping.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Defragment/IIdMapping.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Defragment/IIdMapping.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Defragment/IIdMapping.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,53 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal.Slots; + +namespace Db4objects.Db4o.Defragment +{ + /// The ID mapping used internally during a defragmentation run. + /// The ID mapping used internally during a defragmentation run. + /// Defragment + public interface IIdMapping + { + /// Returns a previously registered mapping ID for the given ID if it exists. + /// + /// Returns a previously registered mapping ID for the given ID if it exists. + /// + /// The original ID + /// The mapping ID for the given original ID or 0, if none has been registered. + /// + int MappedId(int origId); + + /// Registers a mapping for the given IDs. + /// Registers a mapping for the given IDs. + /// The original ID + /// The ID to be mapped to the original ID. + /// true if the given original ID specifies a class slot, false otherwise. + /// + void MapId(int origId, int mappedId, bool isClassId); + + /// Maps an ID to a slot + /// + /// + void MapId(int id, Slot slot); + + /// provides a Visitable of all mappings of IDs to slots. + /// provides a Visitable of all mappings of IDs to slots. + IVisitable SlotChanges(); + + /// Prepares the mapping for use. + /// Prepares the mapping for use. + /// + void Open(); + + /// Shuts down the mapping after use. + /// Shuts down the mapping after use. + void Close(); + + /// returns the slot address for an ID + int AddressForId(int id); + + void Commit(); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Defragment/InMemoryIdMapping.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Defragment/InMemoryIdMapping.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Defragment/InMemoryIdMapping.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Defragment/InMemoryIdMapping.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,115 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using Db4objects.Db4o.Defragment; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Ids; +using Db4objects.Db4o.Internal.Slots; + +namespace Db4objects.Db4o.Defragment +{ + /// In-memory mapping for IDs during a defragmentation run. + /// + /// In-memory mapping for IDs during a defragmentation run. + /// This is faster than the + /// DatabaseIdMapping + /// but + /// it uses more memory. If you have OutOfMemory conditions + /// with this id mapping, use the + /// DatabaseIdMapping + /// instead. + /// + /// Defragment + public class InMemoryIdMapping : AbstractIdMapping + { + private IdSlotTree _idsToSlots; + + private Tree _tree; + + public override int MappedId(int oldID) + { + int classID = MappedClassID(oldID); + if (classID != 0) + { + return classID; + } + TreeIntObject res = (TreeIntObject)TreeInt.Find(_tree, oldID); + if (res != null) + { + return ((int)res._object); + } + return 0; + } + + public override void Open() + { + } + + public override void Close() + { + } + + protected override void MapNonClassIDs(int origID, int mappedID) + { + _tree = Tree.Add(_tree, new TreeIntObject(origID, mappedID)); + } + + public override int AddressForId(int id) + { + IdSlotTree node = (IdSlotTree)_idsToSlots.Find(id); + if (node == null) + { + throw new InvalidOperationException(); + } + return node.Slot().Address(); + } + + public override void MapId(int id, Slot slot) + { + IdSlotTree idSlotMapping = new IdSlotTree(id, slot); + _idsToSlots = ((IdSlotTree)Tree.Add(_idsToSlots, idSlotMapping)); + } + + public override IVisitable SlotChanges() + { + return new _IVisitable_62(this); + } + + private sealed class _IVisitable_62 : IVisitable + { + public _IVisitable_62(InMemoryIdMapping _enclosing) + { + this._enclosing = _enclosing; + } + + public void Accept(IVisitor4 outSideVisitor) + { + Tree.Traverse(this._enclosing._idsToSlots, new _IVisitor4_64(outSideVisitor)); + } + + private sealed class _IVisitor4_64 : IVisitor4 + { + public _IVisitor4_64(IVisitor4 outSideVisitor) + { + this.outSideVisitor = outSideVisitor; + } + + public void Visit(object idSlotMapping) + { + SlotChange slotChange = new SlotChange(((TreeInt)idSlotMapping)._key); + slotChange.NotifySlotCreated(((IdSlotTree)idSlotMapping).Slot()); + outSideVisitor.Visit(slotChange); + } + + private readonly IVisitor4 outSideVisitor; + } + + private readonly InMemoryIdMapping _enclosing; + } + + public override void Commit() + { + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Defragment/IStoredClassFilter.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Defragment/IStoredClassFilter.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Defragment/IStoredClassFilter.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Defragment/IStoredClassFilter.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,16 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Ext; + +namespace Db4objects.Db4o.Defragment +{ + /// Filter for StoredClass instances. + /// Filter for StoredClass instances. + public interface IStoredClassFilter + { + /// StoredClass instance to be checked + /// true, if the given StoredClass instance should be accepted, false otherwise. + /// + bool Accept(IStoredClass storedClass); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Defragment/PassCommand.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Defragment/PassCommand.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Defragment/PassCommand.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Defragment/PassCommand.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,34 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Defragment; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Btree; + +namespace Db4objects.Db4o.Defragment +{ + /// Implements one step in the defragmenting process. + /// Implements one step in the defragmenting process. + /// + internal interface IPassCommand + { + /// + /// + void ProcessObjectSlot(DefragmentServicesImpl context, ClassMetadata classMetadata + , int id); + + /// + /// + void ProcessClass(DefragmentServicesImpl context, ClassMetadata classMetadata, int + id, int classIndexID); + + /// + /// + void ProcessClassCollection(DefragmentServicesImpl context); + + /// + /// + void ProcessBTree(DefragmentServicesImpl context, BTree btree); + + void Flush(DefragmentServicesImpl context); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Defragment/SecondPassCommand.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Defragment/SecondPassCommand.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Defragment/SecondPassCommand.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Defragment/SecondPassCommand.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,169 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Defragment; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Btree; + +namespace Db4objects.Db4o.Defragment +{ + /// + /// Second step in the defragmenting process: Fills in target file pointer slots, copies + /// content slots from source to target and triggers ID remapping therein by calling the + /// appropriate db4o/marshaller defrag() implementations. + /// + /// + /// Second step in the defragmenting process: Fills in target file pointer slots, copies + /// content slots from source to target and triggers ID remapping therein by calling the + /// appropriate db4o/marshaller defrag() implementations. During the process, the actual address + /// mappings for the content slots are registered for use with string indices. + /// + /// + internal sealed class SecondPassCommand : IPassCommand + { + protected readonly int _objectCommitFrequency; + + protected int _objectCount = 0; + + public SecondPassCommand(int objectCommitFrequency) + { + _objectCommitFrequency = objectCommitFrequency; + } + + /// + /// + public void ProcessClass(DefragmentServicesImpl services, ClassMetadata classMetadata + , int id, int classIndexID) + { + if (services.MappedID(id, -1) == -1) + { + Sharpen.Runtime.Err.WriteLine("MAPPING NOT FOUND: " + id); + } + DefragmentContextImpl.ProcessCopy(services, id, new _ISlotCopyHandler_34(classMetadata + , classIndexID)); + } + + private sealed class _ISlotCopyHandler_34 : ISlotCopyHandler + { + public _ISlotCopyHandler_34(ClassMetadata classMetadata, int classIndexID) + { + this.classMetadata = classMetadata; + this.classIndexID = classIndexID; + } + + public void ProcessCopy(DefragmentContextImpl context) + { + classMetadata.DefragClass(context, classIndexID); + } + + private readonly ClassMetadata classMetadata; + + private readonly int classIndexID; + } + + /// + /// + public void ProcessObjectSlot(DefragmentServicesImpl services, ClassMetadata classMetadata + , int id) + { + ByteArrayBuffer sourceBuffer = services.SourceBufferByID(id); + DefragmentContextImpl.ProcessCopy(services, id, new _ISlotCopyHandler_43(this, services + ), sourceBuffer); + } + + private sealed class _ISlotCopyHandler_43 : ISlotCopyHandler + { + public _ISlotCopyHandler_43(SecondPassCommand _enclosing, DefragmentServicesImpl + services) + { + this._enclosing = _enclosing; + this.services = services; + } + + public void ProcessCopy(DefragmentContextImpl context) + { + ClassMetadata.DefragObject(context); + if (this._enclosing._objectCommitFrequency > 0) + { + this._enclosing._objectCount++; + if (this._enclosing._objectCount == this._enclosing._objectCommitFrequency) + { + services.TargetCommit(); + services.Mapping().Commit(); + this._enclosing._objectCount = 0; + } + } + } + + private readonly SecondPassCommand _enclosing; + + private readonly DefragmentServicesImpl services; + } + + /// + /// + public void ProcessClassCollection(DefragmentServicesImpl services) + { + DefragmentContextImpl.ProcessCopy(services, services.SourceClassCollectionID(), new + _ISlotCopyHandler_59(services)); + } + + private sealed class _ISlotCopyHandler_59 : ISlotCopyHandler + { + public _ISlotCopyHandler_59(DefragmentServicesImpl services) + { + this.services = services; + } + + public void ProcessCopy(DefragmentContextImpl context) + { + int acceptedClasses = 0; + int numClassesOffset = context.TargetBuffer().Offset(); + acceptedClasses = this.CopyAcceptedClasses(context, acceptedClasses); + this.WriteIntAt(context.TargetBuffer(), numClassesOffset, acceptedClasses); + } + + private int CopyAcceptedClasses(DefragmentContextImpl context, int acceptedClasses + ) + { + int numClasses = context.ReadInt(); + for (int classIdx = 0; classIdx < numClasses; classIdx++) + { + int classId = context.SourceBuffer().ReadInt(); + if (!this.Accept(classId)) + { + continue; + } + ++acceptedClasses; + context.WriteMappedID(classId); + } + return acceptedClasses; + } + + private void WriteIntAt(ByteArrayBuffer target, int offset, int value) + { + int currentOffset = target.Offset(); + target.Seek(offset); + target.WriteInt(value); + target.Seek(currentOffset); + } + + private bool Accept(int classId) + { + return services.Accept(services.ClassMetadataForId(classId)); + } + + private readonly DefragmentServicesImpl services; + } + + /// + /// + public void ProcessBTree(DefragmentServicesImpl context, BTree btree) + { + btree.DefragBTree(context); + } + + public void Flush(DefragmentServicesImpl context) + { + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Deploy.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Deploy.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Deploy.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Deploy.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,23 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +namespace Db4objects.Db4o +{ + /// + public sealed class Deploy + { + /// turning debug on makes the file format human readable + public const bool debug = false; + + public const bool overwrite = true; + + public const bool brackets = true; + + public const bool identifiers = true; + + public const bool flush = true; + + public const bool debugLong = true; + + public const bool csharp = true; + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Diagnostic/ClassHasNoFields.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Diagnostic/ClassHasNoFields.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Diagnostic/ClassHasNoFields.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Diagnostic/ClassHasNoFields.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,34 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Diagnostic; + +namespace Db4objects.Db4o.Diagnostic +{ + /// Diagnostic, if class has no fields. + /// Diagnostic, if class has no fields. + public class ClassHasNoFields : DiagnosticBase + { + private readonly string _className; + + public ClassHasNoFields(string className) + { + _className = className; + } + + public override object Reason() + { + return _className; + } + + public override string Problem() + { + return "Class does not contain any persistent fields"; + } + + public override string Solution() + { + return "Every class in the hierarchy requires overhead for the maintenance of a class index." + + " Consider removing this class from the hierarchy, if it is not needed."; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Diagnostic/DefragmentRecommendation.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Diagnostic/DefragmentRecommendation.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Diagnostic/DefragmentRecommendation.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Diagnostic/DefragmentRecommendation.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,48 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Diagnostic; + +namespace Db4objects.Db4o.Diagnostic +{ + /// Diagnostic to recommend Defragment when needed. + /// Diagnostic to recommend Defragment when needed. + public class DefragmentRecommendation : DiagnosticBase + { + private readonly DefragmentRecommendation.DefragmentRecommendationReason _reason; + + public DefragmentRecommendation(DefragmentRecommendation.DefragmentRecommendationReason + reason) + { + _reason = reason; + } + + public class DefragmentRecommendationReason + { + internal readonly string _message; + + public DefragmentRecommendationReason(string reason) + { + _message = reason; + } + + public static readonly DefragmentRecommendation.DefragmentRecommendationReason DeleteEmbeded + = new DefragmentRecommendation.DefragmentRecommendationReason("Delete Embedded not supported on old file format." + ); + } + + public override string Problem() + { + return "Database file format is old or database is highly fragmented."; + } + + public override object Reason() + { + return _reason._message; + } + + public override string Solution() + { + return "Defragment the database."; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Diagnostic/DeletionFailed.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Diagnostic/DeletionFailed.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Diagnostic/DeletionFailed.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Diagnostic/DeletionFailed.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,26 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Diagnostic; + +namespace Db4objects.Db4o.Diagnostic +{ + /// Diagnostic on failed delete. + /// Diagnostic on failed delete. + public class DeletionFailed : DiagnosticBase + { + public override string Problem() + { + return "Cascading delete to members failed. Possible reasons: db4o engine updates, corruption, changed class hierarchies."; + } + + public override object Reason() + { + return string.Empty; + } + + public override string Solution() + { + return "Running Defragment may fix."; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Diagnostic/DescendIntoTranslator.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Diagnostic/DescendIntoTranslator.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Diagnostic/DescendIntoTranslator.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Diagnostic/DescendIntoTranslator.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,42 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Diagnostic; + +namespace Db4objects.Db4o.Diagnostic +{ + /// + /// Query tries to descend into a field of a class that is configured to be translated + /// (and thus cannot be descended into). + /// + /// + /// Query tries to descend into a field of a class that is configured to be translated + /// (and thus cannot be descended into). + /// + public class DescendIntoTranslator : DiagnosticBase + { + private string className; + + private string fieldName; + + public DescendIntoTranslator(string className_, string fieldName_) + { + className = className_; + fieldName = fieldName_; + } + + public override string Problem() + { + return "Query descends into field(s) of translated class."; + } + + public override object Reason() + { + return className + "." + fieldName; + } + + public override string Solution() + { + return "Consider dropping the translator configuration or resort to evaluations/unoptimized NQs."; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Diagnostic/DiagnosticBase.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Diagnostic/DiagnosticBase.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Diagnostic/DiagnosticBase.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Diagnostic/DiagnosticBase.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,26 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o; +using Db4objects.Db4o.Diagnostic; + +namespace Db4objects.Db4o.Diagnostic +{ + /// base class for Diagnostic messages + public abstract class DiagnosticBase : IDiagnostic + { + /// returns the reason for the message + public abstract object Reason(); + + /// returns the potential problem that triggered the message + public abstract string Problem(); + + /// suggests a possible solution for the possible problem + public abstract string Solution(); + + public override string ToString() + { + return ":: db4o " + Db4oVersion.Name + " Diagnostics ::\n " + Reason() + " :: " + + Problem() + "\n " + Solution(); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Diagnostic/DiagnosticToConsole.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Diagnostic/DiagnosticToConsole.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Diagnostic/DiagnosticToConsole.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Diagnostic/DiagnosticToConsole.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,27 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Diagnostic; + +namespace Db4objects.Db4o.Diagnostic +{ + /// prints Diagnostic messsages to the Console. + /// + /// prints Diagnostic messages to the Console. + /// Install this + /// Db4objects.Db4o.Diagnostic.IDiagnosticListener + /// + /// with:
+ /// commonConfig.Diagnostic.AddListener(new DiagnosticToConsole());
+ ///
+ /// Db4objects.Db4o.Diagnostic.IDiagnosticConfiguration + /// + public class DiagnosticToConsole : IDiagnosticListener + { + /// redirects Diagnostic messages to the Console. + /// redirects Diagnostic messages to the Console. + public virtual void OnDiagnostic(IDiagnostic d) + { + Sharpen.Runtime.Out.WriteLine(d.ToString()); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Diagnostic/IDiagnosticConfiguration.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Diagnostic/IDiagnosticConfiguration.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Diagnostic/IDiagnosticConfiguration.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Diagnostic/IDiagnosticConfiguration.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,35 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Diagnostic; + +namespace Db4objects.Db4o.Diagnostic +{ + /// provides methods to configure the behaviour of db4o + /// diagnostics. + /// + /// provides methods to configure the behaviour of db4o diagnostics. + ///
+ ///
+ /// Diagnostic system can be enabled on a running db4o database to + /// notify a user about possible problems or misconfigurations. + /// Diagnostic listeners can be be added and removed with calls to this + /// interface. To install the most basic listener call: + ///
+ /// commonConfig.Diagnostic.AddListener(new + /// DiagnosticToConsole()); + ///
+ /// IConfiguration.Diagnostic + /// + /// IDiagnosticListener + /// + public interface IDiagnosticConfiguration + { + /// adds a DiagnosticListener to listen to Diagnostic messages. + /// adds a DiagnosticListener to listen to Diagnostic messages. + void AddListener(IDiagnosticListener listener); + + /// removes all DiagnosticListeners. + /// removes all DiagnosticListeners. + void RemoveAllListeners(); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Diagnostic/IDiagnostic.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Diagnostic/IDiagnostic.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Diagnostic/IDiagnostic.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Diagnostic/IDiagnostic.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,24 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +namespace Db4objects.Db4o.Diagnostic +{ + /// + /// Marker interface for Diagnostic messages

+ /// Diagnostic system can be enabled on a running db4o database + /// to notify a user about possible problems or misconfigurations. + ///
+ /// + /// Marker interface for Diagnostic messages

+ /// Diagnostic system can be enabled on a running db4o database + /// to notify a user about possible problems or misconfigurations. Diagnostic + /// messages must implement this interface and are usually derived from + /// DiagnosticBase + /// class. A separate Diagnostic implementation + /// should be used for each problem. + ///
+ /// DiagnosticBase + /// IDiagnosticConfiguration + public interface IDiagnostic + { + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Diagnostic/IDiagnosticListener.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Diagnostic/IDiagnosticListener.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Diagnostic/IDiagnosticListener.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Diagnostic/IDiagnosticListener.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,21 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Diagnostic; + +namespace Db4objects.Db4o.Diagnostic +{ + /// listens to Diagnostic messages. + /// + /// listens to Diagnostic messages. + ///

Create a class that implements this listener interface and add + /// the listener by calling commonConfig.Diagnostic.AddListener(). + ///
+ /// Db4objects.Db4o.Diagnostic.IDiagnosticConfiguration + /// + public interface IDiagnosticListener + { + /// this method will be called with Diagnostic messages. + /// this method will be called with Diagnostic messages. + void OnDiagnostic(IDiagnostic d); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Diagnostic/LoadedFromClassIndex.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Diagnostic/LoadedFromClassIndex.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Diagnostic/LoadedFromClassIndex.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Diagnostic/LoadedFromClassIndex.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,35 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Diagnostic; + +namespace Db4objects.Db4o.Diagnostic +{ + /// Diagnostic, if query was required to load candidate set from class index. + /// + /// Diagnostic, if query was required to load candidate set from class index. + /// + public class LoadedFromClassIndex : DiagnosticBase + { + private readonly string _className; + + public LoadedFromClassIndex(string className) + { + _className = className; + } + + public override object Reason() + { + return _className; + } + + public override string Problem() + { + return "Query candidate set could not be loaded from a field index"; + } + + public override string Solution() + { + return "Consider indexing fields that you query for: " + "Db4o.configure().objectClass([class]).objectField([fieldName]).indexed(true)"; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Diagnostic/MissingClass.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Diagnostic/MissingClass.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Diagnostic/MissingClass.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Diagnostic/MissingClass.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,32 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Diagnostic; + +namespace Db4objects.Db4o.Diagnostic +{ + /// Diagnostic if class not found + public class MissingClass : DiagnosticBase + { + public readonly string _className; + + public MissingClass(string className) + { + _className = className; + } + + public override string Problem() + { + return "Class not found in classpath."; + } + + public override object Reason() + { + return _className; + } + + public override string Solution() + { + return "Check your classpath."; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Diagnostic/NativeQueryNotOptimized.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Diagnostic/NativeQueryNotOptimized.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Diagnostic/NativeQueryNotOptimized.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Diagnostic/NativeQueryNotOptimized.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,46 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using Db4objects.Db4o.Diagnostic; +using Db4objects.Db4o.Query; + +namespace Db4objects.Db4o.Diagnostic +{ + /// Diagnostic, if Native Query can not be run optimized. + /// Diagnostic, if Native Query can not be run optimized. + public class NativeQueryNotOptimized : DiagnosticBase + { + private readonly Predicate _predicate; + + private readonly Exception _details; + + public NativeQueryNotOptimized(Predicate predicate, Exception details) + { + _predicate = predicate; + _details = details; + } + + public override object Reason() + { + if (_details == null) + { + return _predicate; + } + return _predicate != null ? _predicate.ToString() : string.Empty + "\n" + _details + .Message; + } + + public override string Problem() + { + return "Native Query Predicate could not be run optimized"; + } + + public override string Solution() + { + return "This Native Query was run by instantiating all objects of the candidate class. " + + "Consider simplifying the expression in the Native Query method. If you feel that " + + "the Native Query processor should understand your code better, you are invited to " + + "post yout query code to db4o forums at http://developer.db4o.com/forums"; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Diagnostic/NativeQueryOptimizerNotLoaded.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Diagnostic/NativeQueryOptimizerNotLoaded.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Diagnostic/NativeQueryOptimizerNotLoaded.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Diagnostic/NativeQueryOptimizerNotLoaded.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,65 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using Db4objects.Db4o.Diagnostic; + +namespace Db4objects.Db4o.Diagnostic +{ + public class NativeQueryOptimizerNotLoaded : DiagnosticBase + { + private int _reason; + + private readonly Exception _details; + + public const int NqNotPresent = 1; + + public const int NqConstructionFailed = 2; + + public NativeQueryOptimizerNotLoaded(int reason, Exception details) + { + _reason = reason; + _details = details; + } + + public override string Problem() + { + return "Native Query Optimizer could not be loaded"; + } + + public override object Reason() + { + switch (_reason) + { + case NqNotPresent: + { + return AppendDetails("Native query not present."); + } + + case NqConstructionFailed: + { + return AppendDetails("Native query couldn't be instantiated."); + } + + default: + { + return AppendDetails("Reason not specified."); + break; + } + } + } + + public override string Solution() + { + return "If you to have the native queries optimized, please check that the native query jar is present in the class-path."; + } + + private object AppendDetails(string reason) + { + if (_details == null) + { + return reason; + } + return reason + "\n" + _details.ToString(); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Diagnostic/ObjectFieldDoesNotExist.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Diagnostic/ObjectFieldDoesNotExist.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Diagnostic/ObjectFieldDoesNotExist.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Diagnostic/ObjectFieldDoesNotExist.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,41 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Diagnostic; + +namespace Db4objects.Db4o.Diagnostic +{ + /// + /// Diagnostic if + /// Db4objects.Db4o.Config.IObjectClass.ObjectField(string) + /// + /// was called on a + /// field that does not exist. + /// + public class ObjectFieldDoesNotExist : DiagnosticBase + { + public readonly string _className; + + public readonly string _fieldName; + + public ObjectFieldDoesNotExist(string className, string fieldName) + { + _className = className; + _fieldName = fieldName; + } + + public override string Problem() + { + return "ObjectField was configured but does not exist."; + } + + public override object Reason() + { + return _className + "." + _fieldName; + } + + public override string Solution() + { + return "Check your configuration."; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Diagnostic/UpdateDepthGreaterOne.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Diagnostic/UpdateDepthGreaterOne.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Diagnostic/UpdateDepthGreaterOne.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Diagnostic/UpdateDepthGreaterOne.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,35 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Diagnostic; + +namespace Db4objects.Db4o.Diagnostic +{ + /// Diagnostic, if update depth greater than 1. + /// Diagnostic, if update depth greater than 1. + public class UpdateDepthGreaterOne : DiagnosticBase + { + private readonly int _depth; + + public UpdateDepthGreaterOne(int depth) + { + _depth = depth; + } + + public override object Reason() + { + return "Db4o.configure().updateDepth(" + _depth + ")"; + } + + public override string Problem() + { + return "A global update depth greater than 1 is not recommended"; + } + + public override string Solution() + { + return "Increasing the global update depth to a value greater than 1 is only recommended for" + + " testing, not for production use. If individual deep updates are needed, consider using" + + " ExtObjectContainer#set(object, depth) and make sure to profile the performance of each call."; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/DTrace.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/DTrace.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/DTrace.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/DTrace.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,774 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System.IO; +using System.Text; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal.Encoding; +using Db4objects.Db4o.Internal.Handlers; +using Db4objects.Db4o.Internal.Slots; +using Sharpen.IO; + +namespace Db4objects.Db4o +{ + /// + public class DTrace + { + public static bool enabled = false; + + public static bool writeToLogFile = false; + + public static bool writeToConsole = true; + + private static readonly string logFilePath = "C://"; + + private static string logFileName; + + private static readonly object Lock = new object(); + + private static readonly LatinStringIO stringIO = new LatinStringIO(); + + public static RandomAccessFile _logFile; + + private static int Unused = -1; + + private static void BreakPoint() + { + if (enabled) + { + int xxx = 1; + } + } + + private static void Configure() + { + if (enabled) + { + } + } + + // addRange(15); + // breakOnEvent(540); + // + // addRangeWithEnd(448, 460); + // addRangeWithLength(770,53); + // breakOnEvent(125); + // trackEventsWithoutRange(); + // turnAllOffExceptFor(new DTrace[] {WRITE_BYTES}); + // turnAllOffExceptFor(new DTrace[] { + // PERSISTENT_OWN_LENGTH, + // }); + // turnAllOffExceptFor(new DTrace[] { + // GET_SLOT, + // FILE_FREE, + // TRANS_COMMIT, + // }); + // turnAllOffExceptFor(new DTrace[] {WRITE_BYTES}); + // turnAllOffExceptFor(new DTrace[] {BTREE_NODE_REMOVE, BTREE_NODE_COMMIT_OR_ROLLBACK YAPMETA_SET_ID}); + private static void Init() + { + if (enabled) + { + AddToClassIndex = new Db4objects.Db4o.DTrace(true, true, "add to class index tree" + , true); + BeginTopLevelCall = new Db4objects.Db4o.DTrace(true, true, "begin top level call" + , true); + Bind = new Db4objects.Db4o.DTrace(true, true, "bind", true); + BlockingQueueStoppedException = new Db4objects.Db4o.DTrace(true, true, "blocking queue stopped exception" + , true); + BtreeNodeRemove = new Db4objects.Db4o.DTrace(true, true, "btreenode remove", true + ); + BtreeNodeCommitOrRollback = new Db4objects.Db4o.DTrace(true, true, "btreenode commit or rollback" + , true); + BtreeProduceNode = new Db4objects.Db4o.DTrace(true, true, "btree produce node", true + ); + CandidateRead = new Db4objects.Db4o.DTrace(true, true, "candidate read", true); + ClassmetadataById = new Db4objects.Db4o.DTrace(true, true, "classmetadata by id", + true); + ClassmetadataInit = new Db4objects.Db4o.DTrace(true, true, "classmetadata init", + true); + ClientMessageLoopException = new Db4objects.Db4o.DTrace(true, true, "client message loop exception" + , true); + Close = new Db4objects.Db4o.DTrace(true, true, "close", true); + CloseCalled = new Db4objects.Db4o.DTrace(true, true, "close called", true); + CollectChildren = new Db4objects.Db4o.DTrace(true, true, "collect children", true + ); + Commit = new Db4objects.Db4o.DTrace(false, false, "commit", true); + Continueset = new Db4objects.Db4o.DTrace(true, true, "continueset", true); + CreateCandidate = new Db4objects.Db4o.DTrace(true, true, "create candidate", true + ); + Delete = new Db4objects.Db4o.DTrace(true, true, "delete", true); + Donotinclude = new Db4objects.Db4o.DTrace(true, true, "donotinclude", true); + EndTopLevelCall = new Db4objects.Db4o.DTrace(true, true, "end top level call", true + ); + EvaluateSelf = new Db4objects.Db4o.DTrace(true, true, "evaluate self", true); + FatalException = new Db4objects.Db4o.DTrace(true, true, "fatal exception", true); + Free = new Db4objects.Db4o.DTrace(true, true, "free", true); + FileFree = new Db4objects.Db4o.DTrace(true, true, "fileFree", true); + FileRead = new Db4objects.Db4o.DTrace(true, true, "fileRead", true); + FileWrite = new Db4objects.Db4o.DTrace(true, true, "fileWrite", true); + FreespacemanagerGetSlot = new Db4objects.Db4o.DTrace(true, true, "FreespaceManager getSlot" + , true); + FreespacemanagerRamFree = new Db4objects.Db4o.DTrace(true, true, "InMemoryfreespaceManager free" + , true); + FreespacemanagerBtreeFree = new Db4objects.Db4o.DTrace(true, true, "BTreeFreeSpaceManager free" + , true); + FreeOnCommit = new Db4objects.Db4o.DTrace(true, true, "trans freeOnCommit", true); + FreeOnRollback = new Db4objects.Db4o.DTrace(true, true, "trans freeOnRollback", true + ); + FreePointerOnRollback = new Db4objects.Db4o.DTrace(true, true, "freePointerOnRollback" + , true); + GetPointerSlot = new Db4objects.Db4o.DTrace(true, true, "getPointerSlot", true); + GetSlot = new Db4objects.Db4o.DTrace(true, true, "getSlot", true); + GetFreespaceRam = new Db4objects.Db4o.DTrace(true, true, "getFreespaceRam", true); + GetYapobject = new Db4objects.Db4o.DTrace(true, true, "get ObjectReference", true + ); + IdTreeAdd = new Db4objects.Db4o.DTrace(true, true, "id tree add", true); + IdTreeRemove = new Db4objects.Db4o.DTrace(true, true, "id tree remove", true); + IoCopy = new Db4objects.Db4o.DTrace(true, true, "io copy", true); + JustSet = new Db4objects.Db4o.DTrace(true, true, "just set", true); + NewInstance = new Db4objects.Db4o.DTrace(true, true, "newInstance", true); + NotifySlotCreated = new Db4objects.Db4o.DTrace(true, true, "notifySlotCreated", true + ); + NotifySlotUpdated = new Db4objects.Db4o.DTrace(true, true, "notify Slot updated", + true); + NotifySlotDeleted = new Db4objects.Db4o.DTrace(true, true, "notifySlotDeleted", true + ); + ObjectReferenceCreated = new Db4objects.Db4o.DTrace(true, true, "new ObjectReference" + , true); + PersistentBaseNewSlot = new Db4objects.Db4o.DTrace(true, true, "PersistentBase new slot" + , true); + PersistentOwnLength = new Db4objects.Db4o.DTrace(true, true, "Persistent own length" + , true); + PersistentbaseWrite = new Db4objects.Db4o.DTrace(true, true, "persistentbase write" + , true); + PersistentbaseSetId = new Db4objects.Db4o.DTrace(true, true, "persistentbase setid" + , true); + ProduceSlotChange = new Db4objects.Db4o.DTrace(true, true, "produce slot change", + true); + QueryProcess = new Db4objects.Db4o.DTrace(true, true, "query process", true); + ReadArrayWrapper = new Db4objects.Db4o.DTrace(true, true, "read array wrapper", true + ); + ReadBytes = new Db4objects.Db4o.DTrace(true, true, "readBytes", true); + ReadSlot = new Db4objects.Db4o.DTrace(true, true, "read slot", true); + ReferenceRemoved = new Db4objects.Db4o.DTrace(true, true, "reference removed", true + ); + RegularSeek = new Db4objects.Db4o.DTrace(true, true, "regular seek", true); + RemoveFromClassIndex = new Db4objects.Db4o.DTrace(true, true, "trans removeFromClassIndexTree" + , true); + RereadOldUuid = new Db4objects.Db4o.DTrace(true, true, "reread old uuid", true); + ServerMessageLoopException = new Db4objects.Db4o.DTrace(true, true, "server message loop exception" + , true); + SlotMapped = new Db4objects.Db4o.DTrace(true, true, "slot mapped", true); + SlotCommitted = new Db4objects.Db4o.DTrace(true, true, "slot committed", true); + SlotFreeOnCommit = new Db4objects.Db4o.DTrace(true, true, "slot free on commit", + true); + SlotFreeOnRollbackId = new Db4objects.Db4o.DTrace(true, true, "slot free on rollback id" + , true); + SlotFreeOnRollbackAddress = new Db4objects.Db4o.DTrace(true, true, "slot free on rollback address" + , true); + SlotRead = new Db4objects.Db4o.DTrace(true, true, "slot read", true); + TransCommit = new Db4objects.Db4o.DTrace(true, true, "trans commit", true); + TransDelete = new Db4objects.Db4o.DTrace(true, true, "trans delete", true); + TransDontDelete = new Db4objects.Db4o.DTrace(true, true, "trans dontDelete", true + ); + TransFlush = new Db4objects.Db4o.DTrace(true, true, "trans flush", true); + WriteBytes = new Db4objects.Db4o.DTrace(true, true, "writeBytes", true); + WritePointer = new Db4objects.Db4o.DTrace(true, true, "write pointer", true); + WriteUpdateAdjustIndexes = new Db4objects.Db4o.DTrace(true, true, "trans writeUpdateDeleteMembers" + , true); + WriteXbytes = new Db4objects.Db4o.DTrace(true, true, "writeXBytes", true); + Configure(); + } + } + + private static void TrackEventsWithoutRange() + { + _trackEventsWithoutRange = true; + } + + private DTrace(bool enabled_, bool break_, string tag_, bool log_) + { + if (enabled) + { + _enabled = enabled_; + _break = break_; + _tag = tag_; + _log = log_; + if (all == null) + { + all = new Db4objects.Db4o.DTrace[100]; + } + all[current++] = this; + } + } + + private bool _enabled; + + private bool _break; + + private bool _log; + + private string _tag; + + private static long[] _rangeStart; + + private static long[] _rangeEnd; + + private static int _rangeCount; + + public static long _eventNr; + + private static long[] _breakEventNrs; + + private static int _breakEventCount; + + private static bool _breakAfterEvent; + + private static bool _trackEventsWithoutRange; + + public static Db4objects.Db4o.DTrace AddToClassIndex; + + public static Db4objects.Db4o.DTrace BeginTopLevelCall; + + public static Db4objects.Db4o.DTrace Bind; + + public static Db4objects.Db4o.DTrace BlockingQueueStoppedException; + + public static Db4objects.Db4o.DTrace BtreeNodeCommitOrRollback; + + public static Db4objects.Db4o.DTrace BtreeNodeRemove; + + public static Db4objects.Db4o.DTrace BtreeProduceNode; + + public static Db4objects.Db4o.DTrace CandidateRead; + + public static Db4objects.Db4o.DTrace ClassmetadataById; + + public static Db4objects.Db4o.DTrace ClassmetadataInit; + + public static Db4objects.Db4o.DTrace ClientMessageLoopException; + + public static Db4objects.Db4o.DTrace Close; + + public static Db4objects.Db4o.DTrace CloseCalled; + + public static Db4objects.Db4o.DTrace CollectChildren; + + public static Db4objects.Db4o.DTrace Commit; + + public static Db4objects.Db4o.DTrace Continueset; + + public static Db4objects.Db4o.DTrace CreateCandidate; + + public static Db4objects.Db4o.DTrace Delete; + + public static Db4objects.Db4o.DTrace Donotinclude; + + public static Db4objects.Db4o.DTrace EndTopLevelCall; + + public static Db4objects.Db4o.DTrace EvaluateSelf; + + public static Db4objects.Db4o.DTrace FatalException; + + public static Db4objects.Db4o.DTrace FileFree; + + public static Db4objects.Db4o.DTrace FileRead; + + public static Db4objects.Db4o.DTrace FileWrite; + + public static Db4objects.Db4o.DTrace Free; + + public static Db4objects.Db4o.DTrace FreespacemanagerGetSlot; + + public static Db4objects.Db4o.DTrace FreespacemanagerRamFree; + + public static Db4objects.Db4o.DTrace FreespacemanagerBtreeFree; + + public static Db4objects.Db4o.DTrace FreeOnCommit; + + public static Db4objects.Db4o.DTrace FreeOnRollback; + + public static Db4objects.Db4o.DTrace FreePointerOnRollback; + + public static Db4objects.Db4o.DTrace GetSlot; + + public static Db4objects.Db4o.DTrace GetPointerSlot; + + public static Db4objects.Db4o.DTrace GetFreespaceRam; + + public static Db4objects.Db4o.DTrace GetYapobject; + + public static Db4objects.Db4o.DTrace IdTreeAdd; + + public static Db4objects.Db4o.DTrace IdTreeRemove; + + public static Db4objects.Db4o.DTrace IoCopy; + + public static Db4objects.Db4o.DTrace JustSet; + + public static Db4objects.Db4o.DTrace NewInstance; + + public static Db4objects.Db4o.DTrace NotifySlotCreated; + + public static Db4objects.Db4o.DTrace NotifySlotUpdated; + + public static Db4objects.Db4o.DTrace NotifySlotDeleted; + + public static Db4objects.Db4o.DTrace ObjectReferenceCreated; + + public static Db4objects.Db4o.DTrace PersistentBaseNewSlot; + + public static Db4objects.Db4o.DTrace PersistentOwnLength; + + public static Db4objects.Db4o.DTrace PersistentbaseSetId; + + public static Db4objects.Db4o.DTrace PersistentbaseWrite; + + public static Db4objects.Db4o.DTrace ProduceSlotChange; + + public static Db4objects.Db4o.DTrace QueryProcess; + + public static Db4objects.Db4o.DTrace ReadArrayWrapper; + + public static Db4objects.Db4o.DTrace ReadBytes; + + public static Db4objects.Db4o.DTrace ReadSlot; + + public static Db4objects.Db4o.DTrace ReferenceRemoved; + + public static Db4objects.Db4o.DTrace RegularSeek; + + public static Db4objects.Db4o.DTrace RemoveFromClassIndex; + + public static Db4objects.Db4o.DTrace RereadOldUuid; + + public static Db4objects.Db4o.DTrace ServerMessageLoopException; + + public static Db4objects.Db4o.DTrace SlotMapped; + + public static Db4objects.Db4o.DTrace SlotCommitted; + + public static Db4objects.Db4o.DTrace SlotFreeOnCommit; + + public static Db4objects.Db4o.DTrace SlotFreeOnRollbackId; + + public static Db4objects.Db4o.DTrace SlotFreeOnRollbackAddress; + + public static Db4objects.Db4o.DTrace SlotRead; + + public static Db4objects.Db4o.DTrace TransCommit; + + public static Db4objects.Db4o.DTrace TransDontDelete; + + public static Db4objects.Db4o.DTrace TransDelete; + + public static Db4objects.Db4o.DTrace TransFlush; + + public static Db4objects.Db4o.DTrace WriteBytes; + + public static Db4objects.Db4o.DTrace WritePointer; + + public static Db4objects.Db4o.DTrace WriteXbytes; + + public static Db4objects.Db4o.DTrace WriteUpdateAdjustIndexes; + + static DTrace() + { + Init(); + } + + private static Db4objects.Db4o.DTrace[] all; + + private static int current; + + public virtual void Log() + { + if (enabled) + { + Log(Unused); + } + } + + public virtual void Log(string msg) + { + if (enabled) + { + Log(Unused, msg); + } + } + + public virtual void Log(long p) + { + if (enabled) + { + LogLength(p, 1); + } + } + + public virtual void LogInfo(string info) + { + if (enabled) + { + LogEnd(Unused, Unused, 0, info); + } + } + + public virtual void Log(long p, string info) + { + if (enabled) + { + LogEnd(Unused, p, 0, info); + } + } + + public virtual void LogLength(long start, long length) + { + if (enabled) + { + LogLength(Unused, start, length); + } + } + + public virtual void LogLength(long id, long start, long length) + { + if (enabled) + { + LogEnd(id, start, start + length - 1); + } + } + + public virtual void LogLength(Slot slot) + { + if (enabled) + { + LogLength(Unused, slot); + } + } + + public virtual void LogLength(long id, Slot slot) + { + if (enabled) + { + if (slot == null) + { + return; + } + LogLength(id, slot.Address(), slot.Length()); + } + } + + public virtual void LogEnd(long start, long end) + { + if (enabled) + { + LogEnd(Unused, start, end); + } + } + + public virtual void LogEnd(long id, long start, long end) + { + if (enabled) + { + LogEnd(id, start, end, null); + } + } + + public virtual void LogEnd(long id, long start, long end, string info) + { + // if(! Deploy.log){ + // return; + // } + if (enabled) + { + if (!_enabled) + { + return; + } + bool inRange = false; + if (_rangeCount == 0) + { + inRange = true; + } + for (int i = 0; i < _rangeCount; i++) + { + // Case 0 ID in range + if (id >= _rangeStart[i] && id <= _rangeEnd[i]) + { + inRange = true; + break; + } + // Case 1 start in range + if (start >= _rangeStart[i] && start <= _rangeEnd[i]) + { + inRange = true; + break; + } + if (end != 0) + { + // Case 2 end in range + if (end >= _rangeStart[i] && end <= _rangeEnd[i]) + { + inRange = true; + break; + } + // Case 3 start before range, end after range + if (start <= _rangeStart[i] && end >= _rangeEnd[i]) + { + inRange = true; + break; + } + } + } + if (inRange || (_trackEventsWithoutRange && (start == Unused))) + { + if (_log) + { + _eventNr++; + StringBuilder sb = new StringBuilder(":"); + sb.Append(FormatInt(_eventNr, 6)); + sb.Append(":"); + sb.Append(FormatInt(id)); + sb.Append(":"); + sb.Append(FormatInt(start)); + sb.Append(":"); + if (end != 0 && start != end) + { + sb.Append(FormatInt(end)); + sb.Append(":"); + sb.Append(FormatInt(end - start + 1)); + } + else + { + sb.Append(FormatUnused()); + sb.Append(":"); + sb.Append(FormatUnused()); + } + sb.Append(":"); + if (info != null) + { + sb.Append(" " + info + " "); + sb.Append(":"); + } + sb.Append(" "); + sb.Append(_tag); + LogToOutput(sb.ToString()); + } + if (_break) + { + if (_breakEventCount > 0) + { + for (int i = 0; i < _breakEventCount; i++) + { + if (_breakEventNrs[i] == _eventNr) + { + BreakPoint(); + break; + } + } + if (_breakAfterEvent) + { + for (int i = 0; i < _breakEventCount; i++) + { + if (_breakEventNrs[i] <= _eventNr) + { + BreakPoint(); + break; + } + } + } + } + else + { + BreakPoint(); + } + } + } + } + } + + private string FormatUnused() + { + return FormatInt(Unused); + } + + private static void LogToOutput(string msg) + { + if (enabled) + { + LogToFile(msg); + LogToConsole(msg); + } + } + + private static void LogToConsole(string msg) + { + if (enabled) + { + if (writeToConsole) + { + Sharpen.Runtime.Out.WriteLine(msg); + } + } + } + + private static void LogToFile(string msg) + { + if (enabled) + { + if (!writeToLogFile) + { + return; + } + lock (Lock) + { + if (_logFile == null) + { + try + { + _logFile = new RandomAccessFile(LogFile(), "rw"); + LogToFile("\r\n\r\n ********** BEGIN LOG ********** \r\n\r\n "); + } + catch (IOException e) + { + Sharpen.Runtime.PrintStackTrace(e); + } + } + msg = DateHandlerBase.Now() + "\r\n" + msg + "\r\n"; + byte[] bytes = stringIO.Write(msg); + try + { + _logFile.Write(bytes); + } + catch (IOException e) + { + Sharpen.Runtime.PrintStackTrace(e); + } + } + } + } + + private static string LogFile() + { + if (enabled) + { + if (logFileName != null) + { + return logFileName; + } + logFileName = "db4oDTrace_" + DateHandlerBase.Now() + "_" + SignatureGenerator.GenerateSignature + () + ".log"; + logFileName = logFileName.Replace(' ', '_'); + logFileName = logFileName.Replace(':', '_'); + logFileName = logFileName.Replace('-', '_'); + return logFilePath + logFileName; + } + return null; + } + + public static void AddRange(long pos) + { + if (enabled) + { + AddRangeWithEnd(pos, pos); + } + } + + public static void AddRangeWithLength(long start, long length) + { + if (enabled) + { + AddRangeWithEnd(start, start + length - 1); + } + } + + public static void AddRangeWithEnd(long start, long end) + { + if (enabled) + { + if (_rangeStart == null) + { + _rangeStart = new long[1000]; + _rangeEnd = new long[1000]; + } + _rangeStart[_rangeCount] = start; + _rangeEnd[_rangeCount] = end; + _rangeCount++; + } + } + + // private static void breakFromEvent(long eventNr){ + // breakOnEvent(eventNr); + // _breakAfterEvent = true; + // } + private static void BreakOnEvent(long eventNr) + { + if (enabled) + { + if (_breakEventNrs == null) + { + _breakEventNrs = new long[100]; + } + _breakEventNrs[_breakEventCount] = eventNr; + _breakEventCount++; + } + } + + private string FormatInt(long i, int len) + { + if (enabled) + { + string str = " "; + if (i != Unused) + { + str += i + " "; + } + return Sharpen.Runtime.Substring(str, str.Length - len); + } + return null; + } + + private string FormatInt(long i) + { + if (enabled) + { + return FormatInt(i, 10); + } + return null; + } + + private static void TurnAllOffExceptFor(Db4objects.Db4o.DTrace[] these) + { + if (enabled) + { + for (int i = 0; i < all.Length; i++) + { + if (all[i] == null) + { + break; + } + bool turnOff = true; + for (int j = 0; j < these.Length; j++) + { + if (all[i] == these[j]) + { + turnOff = false; + break; + } + } + if (turnOff) + { + all[i]._break = false; + all[i]._enabled = false; + all[i]._log = false; + } + } + } + } + + public static void NoWarnings() + { + BreakOnEvent(0); + TrackEventsWithoutRange(); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Events/CancellableObjectEventArgs.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Events/CancellableObjectEventArgs.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Events/CancellableObjectEventArgs.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Events/CancellableObjectEventArgs.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,65 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using Db4objects.Db4o.Events; +using Db4objects.Db4o.Ext; +using Db4objects.Db4o.Internal; + +namespace Db4objects.Db4o.Events +{ + /// Argument for object related events which can be cancelled. + /// Argument for object related events which can be cancelled. + /// IEventRegistry + /// ICancellableEventArgs + public class CancellableObjectEventArgs : ObjectInfoEventArgs, ICancellableEventArgs + { + private bool _cancelled; + + private object _object; + + /// Creates a new instance for the specified object. + /// Creates a new instance for the specified object. + public CancellableObjectEventArgs(Transaction transaction, IObjectInfo objectInfo + , object obj) : base(transaction, objectInfo) + { + _object = obj; + } + + /// ICancellableEventArgs.Cancel() + public virtual void Cancel() + { + _cancelled = true; + } + + /// ICancellableEventArgs.IsCancelled() + /// + public virtual bool IsCancelled + { + get + { + return _cancelled; + } + } + + public override object Object + { + get + { + return _object; + } + } + + public override IObjectInfo Info + { + get + { + IObjectInfo info = base.Info; + if (null == info) + { + throw new InvalidOperationException(); + } + return info; + } + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Events/ClassEventArgs.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Events/ClassEventArgs.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Events/ClassEventArgs.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Events/ClassEventArgs.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,21 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; + +namespace Db4objects.Db4o.Events +{ + public class ClassEventArgs : EventArgs + { + private Db4objects.Db4o.Internal.ClassMetadata _clazz; + + public ClassEventArgs(Db4objects.Db4o.Internal.ClassMetadata clazz) + { + _clazz = clazz; + } + + public virtual Db4objects.Db4o.Internal.ClassMetadata ClassMetadata() + { + return _clazz; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Events/CommitEventArgs.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Events/CommitEventArgs.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Events/CommitEventArgs.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Events/CommitEventArgs.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,55 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Events; +using Db4objects.Db4o.Ext; +using Db4objects.Db4o.Internal; + +namespace Db4objects.Db4o.Events +{ + /// Arguments for commit time related events. + /// Arguments for commit time related events. + /// IEventRegistry + public class CommitEventArgs : TransactionalEventArgs + { + private readonly CallbackObjectInfoCollections _collections; + + private readonly bool _isOwnCommit; + + public CommitEventArgs(Transaction transaction, CallbackObjectInfoCollections collections + , bool isOwnCommit) : base(transaction) + { + _collections = collections; + _isOwnCommit = isOwnCommit; + } + + /// Returns a iteration + public virtual IObjectInfoCollection Added + { + get + { + return _collections.added; + } + } + + public virtual IObjectInfoCollection Deleted + { + get + { + return _collections.deleted; + } + } + + public virtual IObjectInfoCollection Updated + { + get + { + return _collections.updated; + } + } + + public virtual bool IsOwnCommit() + { + return _isOwnCommit; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Events/EventException.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Events/EventException.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Events/EventException.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Events/EventException.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,29 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using Db4objects.Db4o.Ext; + +namespace Db4objects.Db4o.Events +{ + /// + /// db4o-specific exception.

+ /// Exception thrown during event dispatching if a client + /// provided event handler throws.

+ /// The exception thrown by the client can be retrieved by + /// calling EventException.InnerException. + ///
+ /// + /// db4o-specific exception.

+ /// Exception thrown during event dispatching if a client + /// provided event handler throws.

+ /// The exception thrown by the client can be retrieved by + /// calling EventException.InnerException. + ///
+ [System.Serializable] + public class EventException : Db4oRecoverableException + { + public EventException(Exception exc) : base(exc) + { + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Events/EventRegistryFactory.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Events/EventRegistryFactory.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Events/EventRegistryFactory.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Events/EventRegistryFactory.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,49 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using Db4objects.Db4o; +using Db4objects.Db4o.Events; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Callbacks; +using Db4objects.Db4o.Internal.Events; + +namespace Db4objects.Db4o.Events +{ + /// + /// Provides an interface for getting an + /// IEventRegistry + /// from an + /// Db4objects.Db4o.IObjectContainer + /// . + /// + public class EventRegistryFactory + { + /// + /// Returns an + /// IEventRegistry + /// for registering events with the specified container. + /// + public static IEventRegistry ForObjectContainer(IObjectContainer objectContainer) + { + if (null == objectContainer) + { + throw new ArgumentNullException(); + } + IInternalObjectContainer container = ((IInternalObjectContainer)objectContainer); + ICallbacks callbacks = container.Callbacks(); + if (callbacks is IEventRegistry) + { + return (IEventRegistry)callbacks; + } + if (callbacks is NullCallbacks) + { + EventRegistryImpl impl = container.NewEventRegistry(); + container.Callbacks(impl); + return impl; + } + // TODO: create a MulticastingCallbacks and register both + // the current one and the new one + throw new ArgumentException(); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Events/ICancellableEventArgs.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Events/ICancellableEventArgs.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Events/ICancellableEventArgs.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Events/ICancellableEventArgs.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,25 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +namespace Db4objects.Db4o.Events +{ + /// Argument for events related to cancellable actions. + /// Argument for events related to cancellable actions. + /// IEventRegistry + public interface ICancellableEventArgs + { + /// Queries if the action was already cancelled by some event listener. + /// Queries if the action was already cancelled by some event listener. + bool IsCancelled + { + get; + } + + /// Cancels the action related to this event. + /// + /// Cancels the action related to this event. + /// Although the related action will be cancelled all the registered + /// listeners will still receive the event. + /// + void Cancel(); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Events/IEventRegistry.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Events/IEventRegistry.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Events/IEventRegistry.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Events/IEventRegistry.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,284 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +namespace Db4objects.Db4o.Events +{ + /// + /// Provides a way to register event handlers for specific IObjectContainer events.
+ /// EventRegistry methods represent events available for registering callbacks. + /// EventRegistry instance can be obtained from EventRegistryFactory. + /// EventRegistry registry = EventRegistryFactory.ForObjectContainer(container); + /// A new callback can be registered for an event with the following code: + /// + /// private static void OnCreated(object sender, ObjectInfoEventArgs args) + /// { + /// Object obj = args.Object; + /// if (obj is Pilot) + /// { + /// Console.WriteLine(obj.ToString()); + /// } + /// } + /// registry.Created+=new System.EventHandler<ObjectInfoEventArgs>(OnCreated); + /// + /// EventRegistryFactory + ///
+ public interface IEventRegistry + { + /// + /// This event is fired upon a query start and can be used to gather + /// query statistics. + /// + /// + /// This event is fired upon a query start and can be used to gather + /// query statistics. + /// The query object is available from + /// QueryEventArgs + /// event parameter.
+ ///
+ /// event + /// QueryEventArgs + event System.EventHandler QueryStarted; + + /// + /// This event is fired upon a query end and can be used to gather + /// query statistics. + /// + /// + /// This event is fired upon a query end and can be used to gather + /// query statistics. + /// The query object is available from + /// QueryEventArgs + /// event parameter.
+ ///
+ /// event + /// QueryEventArgs + event System.EventHandler QueryFinished; + + /// This event is fired before an object is saved for the first time. + /// + /// This event is fired before an object is saved for the first time. + /// The object can be obtained from + /// CancellableObjectEventArgs + /// event parameter. The action can be cancelled using + /// CancellableObjectEventArgs.Cancel() + /// + /// + /// event + /// CancellableObjectEventArgs + /// Db4objects.Db4o.IObjectContainer.Store(object) + /// + event System.EventHandler Creating; + + /// This event is fired before an object is activated. + /// + /// This event is fired before an object is activated. + /// The object can be obtained from + /// CancellableObjectEventArgs + /// event parameter. The action can be cancelled using + /// CancellableObjectEventArgs.Cancel() + /// + /// + /// event + /// CancellableObjectEventArgs + /// Db4objects.Db4o.IObjectContainer.Activate(object, int) + /// + event System.EventHandler Activating; + + /// This event is fired before an object is updated. + /// + /// This event is fired before an object is updated. + /// The object can be obtained from + /// CancellableObjectEventArgs + /// event parameter. The action can be cancelled using + /// CancellableObjectEventArgs.Cancel() + /// + /// + /// event + /// CancellableObjectEventArgs + /// Db4objects.Db4o.IObjectContainer.Store(object) + /// + event System.EventHandler Updating; + + /// This event is fired before an object is deleted. + /// + /// This event is fired before an object is deleted. + /// The object can be obtained from + /// CancellableObjectEventArgs + /// event parameter. The action can be cancelled using + /// CancellableObjectEventArgs.Cancel() + /// + ///

+ /// Note, that this event is not available in networked client/server + /// mode and will throw an exception when attached to a client ObjectContainer. + ///
+ /// event + /// CancellableObjectEventArgs + /// Db4objects.Db4o.IObjectContainer.Delete(object) + /// + event System.EventHandler Deleting; + + /// This event is fired before an object is deactivated. + /// + /// This event is fired before an object is deactivated. + /// The object can be obtained from + /// CancellableObjectEventArgs + /// event parameter. The action can be cancelled using + /// CancellableObjectEventArgs.Cancel() + /// + /// + /// event + /// CancellableObjectEventArgs + /// Db4objects.Db4o.IObjectContainer.Deactivate(object, int) + /// + event System.EventHandler Deactivating; + + /// This event is fired after an object is activated. + /// + /// This event is fired after an object is activated. + /// The object can be obtained from the + /// ObjectInfoEventArgs + /// event parameter.

+ /// The event can be used to trigger some post-activation + /// functionality. + ///
+ /// event + /// ObjectInfoEventArgs + /// Db4objects.Db4o.IObjectContainer.Activate(object, int) + /// + event System.EventHandler Activated; + + /// This event is fired after an object is created (saved for the first time). + /// + /// + /// This event is fired after an object is created (saved for the first time). + /// The object can be obtained from the + /// ObjectInfoEventArgs + /// event parameter.

+ /// The event can be used to trigger some post-creation + /// functionality. + ///
+ /// event + /// ObjectEventArgs + /// Db4objects.Db4o.IObjectContainer.Store(object) + /// + event System.EventHandler Created; + + /// This event is fired after an object is updated. + /// + /// This event is fired after an object is updated. + /// The object can be obtained from the + /// ObjectInfoEventArgs + /// event parameter.

+ /// The event can be used to trigger some post-update + /// functionality. + ///
+ /// event + /// ObjectInfoEventArgs + /// Db4objects.Db4o.IObjectContainer.Store(object) + /// + event System.EventHandler Updated; + + /// This event is fired after an object is deleted. + /// + /// This event is fired after an object is deleted. + /// The object can be obtained from the + /// ObjectInfoEventArgs + /// event parameter.

+ /// The event can be used to trigger some post-deletion + /// functionality.

+ /// Note, that this event is not available in networked client/server + /// mode and will throw an exception when attached to a client ObjectContainer. + ///
+ /// event + /// ObjectEventArgs + /// Db4objects.Db4o.IObjectContainer.Delete(object) + /// + event System.EventHandler Deleted; + + /// This event is fired after an object is deactivated. + /// + /// This event is fired after an object is deactivated. + /// The object can be obtained from the + /// ObjectInfoEventArgs + /// event parameter.

+ /// The event can be used to trigger some post-deactivation + /// functionality. + ///
+ /// event + /// ObjectEventArgs + /// Db4objects.Db4o.IObjectContainer.Delete(object) + /// + event System.EventHandler Deactivated; + + /// This event is fired just before a transaction is committed. + /// + /// This event is fired just before a transaction is committed. + /// The transaction and a list of the modified objects can + /// be obtained from the + /// CommitEventArgs + /// event parameter.

+ /// Committing event gives a user a chance to interrupt the commit + /// and rollback the transaction. + ///
+ /// event + /// CommitEventArgs + /// Db4objects.Db4o.IObjectContainer.Commit() + /// + event System.EventHandler Committing; + + /// This event is fired after a transaction has been committed. + /// + /// This event is fired after a transaction has been committed. + /// The transaction and a list of the modified objects can + /// be obtained from the + /// CommitEventArgs + /// event parameter.

+ /// The event can be used to trigger some post-commit functionality. + ///
+ /// event + /// CommitEventArgs + /// Db4objects.Db4o.IObjectContainer.Commit() + /// + event System.EventHandler Committed; + + /// This event is fired when a persistent object is instantiated. + /// + /// This event is fired when a persistent object is instantiated. + /// The object can be obtained from the + /// ObjectInfoEventArgs + /// event parameter. + /// + /// event + /// ObjectInfoEventArgs + event System.EventHandler Instantiated; + + /// This event is fired when a new class is registered with metadata. + /// + /// This event is fired when a new class is registered with metadata. + /// The class information can be obtained from + /// ClassEventArgs + /// event parameter. + /// + /// event + /// ClassEventArgs + event System.EventHandler ClassRegistered; + + /// + /// This event is fired when the + /// Db4objects.Db4o.IObjectContainer.Close() + /// + /// is + /// called. + /// + /// event + event System.EventHandler Closing; + + /// + /// This event is fired when the + /// Db4objects.Db4o.IObjectContainer + /// has + /// finished its startup procedure. + /// + /// event + event System.EventHandler Opened; + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Events/ObjectContainerEventArgs.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Events/ObjectContainerEventArgs.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Events/ObjectContainerEventArgs.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Events/ObjectContainerEventArgs.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,28 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using Db4objects.Db4o; + +namespace Db4objects.Db4o.Events +{ + /// Arguments for container related events. + /// Arguments for container related events. + /// IEventRegistry + public class ObjectContainerEventArgs : EventArgs + { + private readonly IObjectContainer _container; + + public ObjectContainerEventArgs(IObjectContainer container) + { + _container = container; + } + + public virtual IObjectContainer ObjectContainer + { + get + { + return _container; + } + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Events/ObjectEventArgs.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Events/ObjectEventArgs.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Events/ObjectEventArgs.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Events/ObjectEventArgs.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,26 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Events; +using Db4objects.Db4o.Internal; + +namespace Db4objects.Db4o.Events +{ + /// Arguments for object related events. + /// Arguments for object related events. + /// IEventRegistry + public abstract class ObjectEventArgs : TransactionalEventArgs + { + /// Creates a new instance for the specified object. + /// Creates a new instance for the specified object. + protected ObjectEventArgs(Transaction transaction) : base(transaction) + { + } + + /// The object that triggered this event. + /// The object that triggered this event. + public abstract object Object + { + get; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Events/ObjectInfoEventArgs.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Events/ObjectInfoEventArgs.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Events/ObjectInfoEventArgs.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Events/ObjectInfoEventArgs.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,35 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Events; +using Db4objects.Db4o.Ext; +using Db4objects.Db4o.Internal; + +namespace Db4objects.Db4o.Events +{ + public class ObjectInfoEventArgs : ObjectEventArgs + { + private readonly IObjectInfo _info; + + public ObjectInfoEventArgs(Transaction transaction, IObjectInfo info) : base(transaction + ) + { + _info = info; + } + + public override object Object + { + get + { + return _info.GetObject(); + } + } + + public virtual IObjectInfo Info + { + get + { + return _info; + } + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Events/QueryEventArgs.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Events/QueryEventArgs.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Events/QueryEventArgs.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Events/QueryEventArgs.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,42 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Events; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Query; + +namespace Db4objects.Db4o.Events +{ + /// + /// Arguments for + /// Db4objects.Db4o.Query.IQuery + /// related events. + /// + /// IEventRegistry + public class QueryEventArgs : TransactionalEventArgs + { + private IQuery _query; + + /// + /// Creates a new instance for the specified + /// Db4objects.Db4o.Query.IQuery + /// instance. + /// + public QueryEventArgs(Transaction transaction, IQuery q) : base(transaction) + { + _query = q; + } + + /// + /// The + /// Db4objects.Db4o.Query.IQuery + /// which triggered the event. + /// + public virtual IQuery Query + { + get + { + return _query; + } + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Events/StringEventArgs.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Events/StringEventArgs.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Events/StringEventArgs.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Events/StringEventArgs.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,25 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; + +namespace Db4objects.Db4o.Events +{ + /// 7.12 + public class StringEventArgs : EventArgs + { + public StringEventArgs(string message) + { + _message = message; + } + + public virtual string Message + { + get + { + return _message; + } + } + + private readonly string _message; + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Events/TransactionalEventArgs.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Events/TransactionalEventArgs.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Events/TransactionalEventArgs.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Events/TransactionalEventArgs.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,27 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using Db4objects.Db4o; + +namespace Db4objects.Db4o.Events +{ + public class TransactionalEventArgs : EventArgs + { + private readonly Db4objects.Db4o.Internal.Transaction _transaction; + + public TransactionalEventArgs(Db4objects.Db4o.Internal.Transaction transaction) + { + _transaction = transaction; + } + + public virtual object Transaction() + { + return _transaction; + } + + public virtual IObjectContainer ObjectContainer() + { + return _transaction.ObjectContainer(); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/BackupInProgressException.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/BackupInProgressException.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/BackupInProgressException.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/BackupInProgressException.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,18 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Ext; + +namespace Db4objects.Db4o.Ext +{ + /// db4o-specific exception. + /// + /// db4o-specific exception.

+ /// This exception is thrown when the current + /// backup + /// process encounters another backup process already running. + ///
+ [System.Serializable] + public class BackupInProgressException : Db4oRecoverableException + { + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/CompositeDb4oException.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/CompositeDb4oException.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/CompositeDb4oException.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/CompositeDb4oException.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,17 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; + +namespace Db4objects.Db4o.Ext +{ + [System.Serializable] + public partial class CompositeDb4oException : Exception + { + public readonly Exception[] _exceptions; + + public CompositeDb4oException(Exception[] exceptions) + { + _exceptions = exceptions; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/DatabaseClosedException.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/DatabaseClosedException.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/DatabaseClosedException.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/DatabaseClosedException.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,21 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Ext; + +namespace Db4objects.Db4o.Ext +{ + /// db4o-specific exception. + /// + /// db4o-specific exception.

+ /// This exception is thrown when the object container required for + /// the current operation was closed or failed to open. + ///
+ /// Db4objects.Db4o.Db4oFactory.OpenFile(string) + /// + /// Db4objects.Db4o.IObjectContainer.Close() + /// + [System.Serializable] + public class DatabaseClosedException : Db4oFatalException + { + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/DatabaseFileLockedException.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/DatabaseFileLockedException.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/DatabaseFileLockedException.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/DatabaseFileLockedException.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,39 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using Db4objects.Db4o.Ext; + +namespace Db4objects.Db4o.Ext +{ + /// + /// db4o-specific exception.

+ /// this Exception is thrown during any of the db4o open calls + /// if the database file is locked by another process. + ///
+ /// + /// db4o-specific exception.

+ /// this Exception is thrown during any of the db4o open calls + /// if the database file is locked by another process. + ///
+ /// Db4objects.Db4o.Db4oFactory.OpenFile(string) + /// + [System.Serializable] + public class DatabaseFileLockedException : Db4oFatalException + { + /// Constructor with a database description message + /// message, which can help to identify the database + /// + public DatabaseFileLockedException(string databaseDescription) : base(databaseDescription + ) + { + } + + /// Constructor with a database description and cause exception + /// database description + /// previous exception caused DatabaseFileLockedException + public DatabaseFileLockedException(string databaseDescription, Exception cause) : + base(databaseDescription, cause) + { + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/DatabaseMaximumSizeReachedException.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/DatabaseMaximumSizeReachedException.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/DatabaseMaximumSizeReachedException.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/DatabaseMaximumSizeReachedException.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,26 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Ext; + +namespace Db4objects.Db4o.Ext +{ + /// + /// db4o-specific exception.

+ /// This exception is thrown when the database file reaches the + /// maximum allowed size. + ///
+ /// + /// db4o-specific exception.

+ /// This exception is thrown when the database file reaches the + /// maximum allowed size. Upon throwing the exception the database is + /// switched to the read-only mode.
+ /// The maximum database size is configurable + /// and can reach up to 254GB. + ///
+ /// Db4objects.Db4o.Config.IConfiguration.BlockSize(int) + /// + [System.Serializable] + public class DatabaseMaximumSizeReachedException : Db4oRecoverableException + { + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/DatabaseReadOnlyException.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/DatabaseReadOnlyException.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/DatabaseReadOnlyException.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/DatabaseReadOnlyException.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,22 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Ext; + +namespace Db4objects.Db4o.Ext +{ + /// + /// db4o-specific exception.

+ /// This exception is thrown when a write operation is attempted + /// on a database in a read-only mode. + ///
+ /// + /// db4o-specific exception.

+ /// This exception is thrown when a write operation is attempted + /// on a database in a read-only mode. + ///
+ /// + [System.Serializable] + public class DatabaseReadOnlyException : Db4oRecoverableException + { + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/Db4oDatabase.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/Db4oDatabase.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/Db4oDatabase.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/Db4oDatabase.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,255 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using Db4objects.Db4o; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Activation; +using Db4objects.Db4o.Internal.Encoding; +using Db4objects.Db4o.Query; +using Db4objects.Db4o.Types; +using Sharpen; + +namespace Db4objects.Db4o.Ext +{ + /// Class to identify a database by it's signature. + /// + /// Class to identify a database by it's signature. + ///

db4o UUID handling uses a reference to the Db4oDatabase object, that + /// represents the database an object was created on. + ///
+ /// + /// + public class Db4oDatabase : IDb4oType, IInternal4 + { + public static readonly Db4objects.Db4o.Ext.Db4oDatabase StaticIdentity = Debug4.staticIdentity + ? new Db4objects.Db4o.Ext.Db4oDatabase(new byte[] { (byte)'d', (byte)'e', (byte + )'b', (byte)'u', (byte)'g' }, 1) : null; + + public const int StaticId = -1; + + /// Field is public for implementation reasons, DO NOT TOUCH! + public byte[] i_signature; + + /// + /// Field is public for implementation reasons, DO NOT TOUCH! + /// This field is badly named, it really is the creation time. + /// + /// + /// Field is public for implementation reasons, DO NOT TOUCH! + /// This field is badly named, it really is the creation time. + /// + public long i_uuid; + + private static readonly string CreationtimeField = "i_uuid"; + + /// cached ObjectContainer for getting the own ID. + /// cached ObjectContainer for getting the own ID. + [System.NonSerialized] + private ObjectContainerBase i_stream; + + /// cached ID, only valid in combination with i_objectContainer + [System.NonSerialized] + private int i_id; + + /// constructor for persistence + public Db4oDatabase() + { + } + + /// constructor for comparison and to store new ones + public Db4oDatabase(byte[] signature, long creationTime) + { + // TODO: change to _creationTime with PersistentFormatUpdater + // FIXME: make sure signature is null + i_signature = signature; + i_uuid = creationTime; + } + + /// generates a new Db4oDatabase object with a unique signature. + /// generates a new Db4oDatabase object with a unique signature. + public static Db4objects.Db4o.Ext.Db4oDatabase Generate() + { + StatefulBuffer writer = new StatefulBuffer(null, 300); + new LatinStringIO().Write(writer, SignatureGenerator.GenerateSignature()); + return new Db4objects.Db4o.Ext.Db4oDatabase(writer.GetWrittenBytes(), Runtime.CurrentTimeMillis + ()); + } + + /// comparison by signature. + /// comparison by signature. + public override bool Equals(object obj) + { + if (obj == this) + { + return true; + } + if (obj == null || this.GetType() != obj.GetType()) + { + return false; + } + Db4objects.Db4o.Ext.Db4oDatabase other = (Db4objects.Db4o.Ext.Db4oDatabase)obj; + if (null == other.i_signature || null == this.i_signature) + { + return false; + } + return Arrays4.Equals(other.i_signature, this.i_signature); + } + + public override int GetHashCode() + { + return i_signature.GetHashCode(); + } + + /// gets the db4o ID, and may cache it for performance reasons. + /// gets the db4o ID, and may cache it for performance reasons. + /// the db4o ID for the ObjectContainer + public virtual int GetID(Transaction trans) + { + ObjectContainerBase stream = trans.Container(); + if (stream != i_stream) + { + i_stream = stream; + i_id = Bind(trans); + } + return i_id; + } + + public virtual long GetCreationTime() + { + return i_uuid; + } + + /// returns the unique signature + public virtual byte[] GetSignature() + { + return i_signature; + } + + public override string ToString() + { + return "db " + i_signature; + } + + public virtual bool IsOlderThan(Db4objects.Db4o.Ext.Db4oDatabase peer) + { + if (peer == this) + { + throw new ArgumentException(); + } + if (i_uuid != peer.i_uuid) + { + return i_uuid < peer.i_uuid; + } + // the above logic has failed, both are the same + // age but we still want to distinguish in some + // way, to have an order in the ReplicationRecord + // The following is arbitrary, it only needs to + // be repeatable. + // Let's distinguish by signature length + if (i_signature.Length != peer.i_signature.Length) + { + return i_signature.Length < peer.i_signature.Length; + } + for (int i = 0; i < i_signature.Length; i++) + { + if (i_signature[i] != peer.i_signature[i]) + { + return i_signature[i] < peer.i_signature[i]; + } + } + // This should never happen. + // FIXME: Add a message and move to Messages. + // + throw new Exception(); + } + + /// make sure this Db4oDatabase is stored. + /// make sure this Db4oDatabase is stored. Return the ID. + public virtual int Bind(Transaction trans) + { + ObjectContainerBase stream = trans.Container(); + Db4objects.Db4o.Ext.Db4oDatabase stored = (Db4objects.Db4o.Ext.Db4oDatabase)stream + .Db4oTypeStored(trans, this); + if (stored == null) + { + return StoreAndGetId(trans); + } + if (stored == this) + { + return stream.GetID(trans, this); + } + if (i_uuid == 0) + { + i_uuid = stored.i_uuid; + } + stream.ShowInternalClasses(true); + try + { + int id = stream.GetID(trans, stored); + stream.Bind(trans, this, id); + return id; + } + finally + { + stream.ShowInternalClasses(false); + } + } + + private int StoreAndGetId(Transaction trans) + { + ObjectContainerBase stream = trans.Container(); + stream.ShowInternalClasses(true); + try + { + stream.Store2(trans, this, stream.UpdateDepthProvider().ForDepth(2), false); + return stream.GetID(trans, this); + } + finally + { + stream.ShowInternalClasses(false); + } + } + + /// find a Db4oDatabase with the same signature as this one + public virtual Db4objects.Db4o.Ext.Db4oDatabase Query(Transaction trans) + { + // showInternalClasses(true); has to be set for this method to be successful + if (i_uuid > 0) + { + // try fast query over uuid (creation time) first + Db4objects.Db4o.Ext.Db4oDatabase res = Query(trans, true); + if (res != null) + { + return res; + } + } + // if not found, try to find with signature + return Query(trans, false); + } + + private Db4objects.Db4o.Ext.Db4oDatabase Query(Transaction trans, bool constrainByUUID + ) + { + ObjectContainerBase stream = trans.Container(); + IQuery q = stream.Query(trans); + q.Constrain(GetType()); + if (constrainByUUID) + { + q.Descend(CreationtimeField).Constrain(i_uuid); + } + IObjectSet objectSet = q.Execute(); + while (objectSet.HasNext()) + { + Db4objects.Db4o.Ext.Db4oDatabase storedDatabase = (Db4objects.Db4o.Ext.Db4oDatabase + )objectSet.Next(); + stream.Activate(null, storedDatabase, new FixedActivationDepth(4)); + if (storedDatabase.Equals(this)) + { + return storedDatabase; + } + } + return null; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/Db4oException.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/Db4oException.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/Db4oException.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/Db4oException.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,59 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; + +namespace Db4objects.Db4o.Ext +{ + /// + /// db4o exception wrapper: Exceptions occurring during internal processing + /// will be proliferated to the client calling code encapsulated in an exception + /// of this type. + /// + /// + /// db4o exception wrapper: Exceptions occurring during internal processing + /// will be proliferated to the client calling code encapsulated in an exception + /// of this type. The original exception, if any, is available through + /// Db4oException#getCause(). + /// + [System.Serializable] + public class Db4oException : Exception + { + /// Simple constructor + public Db4oException() : this(null, null) + { + } + + /// Constructor with an exception message specified + /// exception message + public Db4oException(string msg) : this(msg, null) + { + } + + /// Constructor with an exception cause specified + /// exception cause + public Db4oException(Exception cause) : this(null, cause) + { + } + + /// + /// Constructor with an exception message selected + /// from the internal message collection. + /// + /// + /// Constructor with an exception message selected + /// from the internal message collection. + /// + /// internal db4o message number + public Db4oException(int messageConstant) : this(Db4objects.Db4o.Internal.Messages + .Get(messageConstant)) + { + } + + /// Constructor with an exception message and cause specified + /// exception message + /// exception cause + public Db4oException(string msg, Exception cause) : base(msg, cause) + { + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/Db4oFatalException.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/Db4oFatalException.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/Db4oFatalException.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/Db4oFatalException.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,31 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using Db4objects.Db4o.Ext; + +namespace Db4objects.Db4o.Ext +{ + [System.Serializable] + public class Db4oFatalException : Db4oException + { + public Db4oFatalException() : base() + { + } + + public Db4oFatalException(int messageConstant) : base(messageConstant) + { + } + + public Db4oFatalException(string msg, Exception cause) : base(msg, cause) + { + } + + public Db4oFatalException(string msg) : base(msg) + { + } + + public Db4oFatalException(Exception cause) : base(cause) + { + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/Db4oFileHeaderCorruptionException.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/Db4oFileHeaderCorruptionException.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/Db4oFileHeaderCorruptionException.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/Db4oFileHeaderCorruptionException.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,11 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Ext; + +namespace Db4objects.Db4o.Ext +{ + [System.Serializable] + public class Db4oFileHeaderCorruptionException : Db4oFatalException + { + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/Db4oIllegalStateException.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/Db4oIllegalStateException.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/Db4oIllegalStateException.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/Db4oIllegalStateException.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,27 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using Db4objects.Db4o.Ext; + +namespace Db4objects.Db4o.Ext +{ + /// + /// The requested operation is not valid in the current state but the database + /// continues to operate. + /// + /// + /// The requested operation is not valid in the current state but the database + /// continues to operate. + /// + [System.Serializable] + public class Db4oIllegalStateException : Db4oRecoverableException + { + public Db4oIllegalStateException(string message) : base(message) + { + } + + public Db4oIllegalStateException(Exception cause) : base(cause) + { + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/Db4oIOException.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/Db4oIOException.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/Db4oIOException.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/Db4oIOException.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,37 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using Db4objects.Db4o.Ext; + +namespace Db4objects.Db4o.Ext +{ + /// + /// db4o-specific exception.

+ /// This exception is thrown when a system IO exception + /// is encounted by db4o process. + ///
+ /// + /// db4o-specific exception.

+ /// This exception is thrown when a system IO exception + /// is encounted by db4o process. + ///
+ [System.Serializable] + public class Db4oIOException : Db4oFatalException + { + /// Constructor. + /// Constructor. + public Db4oIOException() : base() + { + } + + public Db4oIOException(string message) : base(message) + { + } + + /// Constructor allowing to specify the causing exception + /// exception cause + public Db4oIOException(Exception cause) : base(cause.Message, cause) + { + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/Db4oRecoverableException.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/Db4oRecoverableException.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/Db4oRecoverableException.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/Db4oRecoverableException.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,31 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using Db4objects.Db4o.Ext; + +namespace Db4objects.Db4o.Ext +{ + [System.Serializable] + public class Db4oRecoverableException : Db4oException + { + public Db4oRecoverableException() : base() + { + } + + public Db4oRecoverableException(int messageConstant) : base(messageConstant) + { + } + + public Db4oRecoverableException(string msg, Exception cause) : base(msg, cause) + { + } + + public Db4oRecoverableException(string msg) : base(msg) + { + } + + public Db4oRecoverableException(Exception cause) : base(cause) + { + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/Db4oUnexpectedException.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/Db4oUnexpectedException.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/Db4oUnexpectedException.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/Db4oUnexpectedException.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,16 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; + +namespace Db4objects.Db4o.Ext +{ + /// Unexpected fatal error is encountered. + /// Unexpected fatal error is encountered. + [System.Serializable] + public class Db4oUnexpectedException : Exception + { + public Db4oUnexpectedException(Exception cause) : base(cause.Message, cause) + { + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/Db4oUUID.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/Db4oUUID.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/Db4oUUID.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/Db4oUUID.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,112 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System.Text; + +namespace Db4objects.Db4o.Ext +{ + /// a unique universal identify for an object. + /// + /// a unique universal identify for an object.

The db4o UUID consists of + /// two parts:
- an indexed long for fast access,
- the signature of the + /// IObjectContainer + /// the object was created with. + ///

Db4oUUIDs are valid representations of objects over multiple + /// ObjectContainers + ///
+ public class Db4oUUID + { + private readonly long longPart; + + private readonly byte[] signaturePart; + + /// constructs a Db4oUUID from a long part and a signature part + /// the long part + /// the signature part + public Db4oUUID(long longPart_, byte[] signaturePart_) + { + longPart = longPart_; + signaturePart = signaturePart_; + } + + /// returns the long part of this UUID. + /// + /// returns the long part of this UUID.

To uniquely identify an object + /// universally, db4o uses an indexed long and a reference to the + /// Db4oDatabase object it was created on. + ///
+ /// the long part of this UUID. + public virtual long GetLongPart() + { + return longPart; + } + + /// returns the signature part of this UUID. + /// + /// returns the signature part of this UUID.



To uniquely + /// identify an object universally, db4o uses an indexed long and a reference to + /// the Db4oDatabase singleton object of the + /// IObjectContainer + /// it was created on. This method + /// returns the signature of the Db4oDatabase object of the ObjectContainer: the + /// signature of the origin ObjectContainer. + ///
+ /// the signature of the Db4oDatabase for this UUID. + public virtual byte[] GetSignaturePart() + { + return signaturePart; + } + + public override bool Equals(object o) + { + if (this == o) + { + return true; + } + if (o == null || GetType() != o.GetType()) + { + return false; + } + Db4objects.Db4o.Ext.Db4oUUID other = (Db4objects.Db4o.Ext.Db4oUUID)o; + if (longPart != other.longPart) + { + return false; + } + if (signaturePart == null) + { + return other.signaturePart == null; + } + if (signaturePart.Length != other.signaturePart.Length) + { + return false; + } + for (int i = 0; i < signaturePart.Length; i++) + { + if (signaturePart[i] != other.signaturePart[i]) + { + return false; + } + } + return true; + } + + public override int GetHashCode() + { + return (int)(longPart ^ ((longPart) >> (32 & 0x1f))); + } + + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append(GetType().FullName); + sb.Append(" sig: "); + for (int i = 0; i < signaturePart.Length; i++) + { + char c = (char)signaturePart[i]; + sb.Append(c); + } + sb.Append(" long: "); + sb.Append(longPart); + return sb.ToString(); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/EmergencyShutdownReadOnlyException.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/EmergencyShutdownReadOnlyException.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/EmergencyShutdownReadOnlyException.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/EmergencyShutdownReadOnlyException.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,19 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Ext; + +namespace Db4objects.Db4o.Ext +{ + /// + /// A previous IO exception has switched the database file + /// to read-only mode for controlled shutdown. + /// + /// + /// A previous IO exception has switched the database file + /// to read-only mode for controlled shutdown. + /// + [System.Serializable] + public class EmergencyShutdownReadOnlyException : Db4oIOException + { + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/IDb4oCallback.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/IDb4oCallback.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/IDb4oCallback.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/IDb4oCallback.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,13 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +namespace Db4objects.Db4o.Ext +{ + /// generic callback interface. + /// generic callback interface. + public interface IDb4oCallback + { + /// the callback method + /// the object passed to the callback method + void Callback(object obj); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/IExtClient.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/IExtClient.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/IExtClient.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/IExtClient.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,26 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Ext; + +namespace Db4objects.Db4o.Ext +{ + /// + /// extended client functionality for the + /// IExtObjectContainer + /// interface. + ///

Both + /// Db4o.openClient() + /// + /// methods always + /// return an ExtClient object so a cast is possible.

+ /// The ObjectContainer functionality is split into multiple interfaces to allow newcomers to + /// focus on the essential methods. + ///
+ public interface IExtClient : IExtObjectContainer + { + /// checks if the client is currently connected to a server. + /// checks if the client is currently connected to a server. + /// true if the client is alive. + bool IsAlive(); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/IExtObjectContainer.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/IExtObjectContainer.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/IExtObjectContainer.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/IExtObjectContainer.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,572 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o; +using Db4objects.Db4o.Config; +using Db4objects.Db4o.Ext; +using Db4objects.Db4o.IO; +using Db4objects.Db4o.Reflect; +using Db4objects.Db4o.Reflect.Generic; + +namespace Db4objects.Db4o.Ext +{ + /// + /// extended functionality for the + /// IObjectContainer + /// interface. + ///

Every db4o + /// IObjectContainer + /// always is an ExtObjectContainer so a cast is possible.

+ /// ObjectContainer.ext() + /// is a convenient method to perform the cast.

+ /// The ObjectContainer functionality is split to two interfaces to allow newcomers to + /// focus on the essential methods. + ///
+ public partial interface IExtObjectContainer : IObjectContainer + { + /// activates an object with the current activation strategy. + /// + /// activates an object with the current activation strategy. + /// In regular activation mode the object will be activated to the + /// global activation depth, ( see + /// Db4objects.Db4o.Config.IConfiguration.ActivationDepth() + /// + /// ) + /// and all configured settings for + /// Db4objects.Db4o.Config.IObjectClass.MaximumActivationDepth(int) + /// + /// + /// and + /// Db4objects.Db4o.Config.IObjectClass.MaximumActivationDepth(int) + /// + /// will be respected.

+ /// In Transparent Activation Mode ( see + /// Db4objects.Db4o.TA.TransparentActivationSupport + /// + /// ) + /// the parameter object will only be activated, if it does not implement + /// Db4objects.Db4o.TA.IActivatable + /// . All referenced members that do not implement + /// Db4objects.Db4o.TA.IActivatable + /// will also be activated. Any + /// Db4objects.Db4o.TA.IActivatable + /// objects + /// along the referenced graph will break cascading activation. + ///
+ /// + /// + void Activate(object obj); + + /// deactivates an object. + /// + /// deactivates an object. + /// Only the passed object will be deactivated, i.e, no object referenced by this + /// object will be deactivated. + /// + /// the object to be deactivated. + void Deactivate(object obj); + + /// backs up a database file of an open ObjectContainer. + /// + /// backs up a database file of an open ObjectContainer. + ///

While the backup is running, the ObjectContainer can continue to be + /// used. Changes that are made while the backup is in progress, will be applied to + /// the open ObjectContainer and to the backup.

+ /// While the backup is running, the ObjectContainer should not be closed.

+ /// If a file already exists at the specified path, it will be overwritten.

+ /// The + /// Db4objects.Db4o.IO.IStorage + /// used for backup is the one configured for this container. + ///
+ /// a fully qualified path + /// db4o database file was closed or failed to open. + /// + /// + /// is thrown when the operation is not supported in current + /// configuration/environment + /// + /// I/O operation failed or was unexpectedly interrupted. + /// + /// + /// + void Backup(string path); + + /// backs up a database file of an open ObjectContainer. + /// + /// backs up a database file of an open ObjectContainer. + ///

While the backup is running, the ObjectContainer can continue to be + /// used. Changes that are made while the backup is in progress, will be applied to + /// the open ObjectContainer and to the backup.

+ /// While the backup is running, the ObjectContainer should not be closed.

+ /// If a file already exists at the specified path, it will be overwritten.

+ /// This method is intended for cross-storage backups, i.e. backup from an in-memory + /// database to a file. + ///
+ /// + /// the + /// Db4objects.Db4o.IO.IStorage + /// to be used for backup + /// + /// a fully qualified path + /// db4o database file was closed or failed to open. + /// + /// + /// is thrown when the operation is not supported in current + /// configuration/environment + /// + /// I/O operation failed or was unexpectedly interrupted. + /// + /// + /// + void Backup(IStorage targetStorage, string path); + + /// binds an object to an internal object ID. + /// + /// binds an object to an internal object ID. + ///

This method uses the ID parameter to load the + /// corresponding stored object into memory and replaces this memory + /// reference with the object parameter. The method may be used to replace + /// objects or to reassociate an object with it's stored instance + /// after closing and opening a database file. A subsequent call to + /// set(Object) + /// is + /// necessary to update the stored object.

+ /// Requirements:
- The ID needs to be a valid internal object ID, + /// previously retrieved with + /// getID(Object) + /// .
+ /// - The object parameter needs to be of the same class as the stored object.

+ ///
+ /// GetID(object) + /// the object that is to be bound + /// the internal id the object is to be bound to + /// db4o database file was closed or failed to open. + /// + /// + /// when the provided id is outside the scope of the + /// database IDs. + /// + /// + /// + void Bind(object obj, long id); + + /// returns the Configuration context for this ObjectContainer. + /// + /// returns the Configuration context for this ObjectContainer. + ///

+ /// Upon opening an ObjectContainer with any of the factory methods in the + /// Db4o class + /// , the global + /// IConfiguration + /// context + /// is copied into the ObjectContainer. The + /// IConfiguration + /// can be modified individually for + /// each ObjectContainer without any effects on the global settings.

+ ///
+ /// + /// + /// IConfiguration + /// the Configuration + /// context for this ObjectContainer + /// + /// Db4objects.Db4o.Db4oFactory.Configure() + /// + IConfiguration Configure(); + + /// returns a member at the specific path without activating intermediate objects. + /// + /// + /// returns a member at the specific path without activating intermediate objects. + ///

+ /// This method allows navigating from a persistent object to it's members in a + /// performant way without activating or instantiating intermediate objects. + ///
+ /// the parent object that is to be used as the starting point. + /// an array of field names to navigate by + /// the object at the specified path or null if no object is found + object Descend(object obj, string[] path); + + /// returns the stored object for an internal ID. + /// + /// returns the stored object for an internal ID. + ///

This is the fastest method for direct access to objects. Internal + /// IDs can be obtained with + /// getID(Object) + /// . + /// Objects will not be activated by this method. They will be returned in the + /// activation state they are currently in, in the local cache.

+ /// Passing invalid id values to this method may result in all kinds of + /// exceptions being thrown. OutOfMemoryError and arithmetic exceptions + /// may occur. If an application is known to use invalid IDs, it is + /// recommended to call this method within a catch-all block. + ///
+ /// the internal ID + /// + /// the object associated with the passed ID or null, + /// if no object is associated with this ID in this ObjectContainer. + /// + /// Why activation? + /// + /// db4o database file was closed or failed to open. + /// + /// + /// when the provided id is outside the scope of the + /// file length. + /// + /// + /// + object GetByID(long Id); + + /// + /// returns a stored object for a + /// Db4oUUID + /// . + ///

+ /// This method is intended for replication and for long-term + /// external references to objects. To get a + /// Db4oUUID + /// for an + /// object use + /// GetObjectInfo(object) + /// and + /// IObjectInfo.GetUUID() + /// .

+ /// Objects will not be activated by this method. They will be returned in the + /// activation state they are currently in, in the local cache.

+ ///
+ /// the UUID + /// the object for the UUID + /// Why activation? + /// + /// I/O operation failed or was unexpectedly interrupted. + /// + /// db4o database file was closed or failed to open. + /// + /// + /// + object GetByUUID(Db4oUUID uuid); + + /// returns the internal unique object ID. + /// + /// returns the internal unique object ID. + ///

db4o assigns an internal ID to every object that is stored. IDs are + /// guaranteed to be unique within one ObjectContainer. + /// An object carries the same ID in every db4o session. Internal IDs can + /// be used to look up objects with the very fast + /// getByID + /// method.

+ /// Internal IDs will change when a database is defragmented. Use + /// GetObjectInfo(object) + /// , + /// IObjectInfo.GetUUID() + /// and + /// GetByUUID(Db4oUUID) + /// for long-term external references to + /// objects.

+ ///
+ /// any object + /// + /// the associated internal ID or 0, if the passed + /// object is not stored in this ObjectContainer. + /// + long GetID(object obj); + + /// + /// returns the + /// IObjectInfo + /// for a stored object. + ///

This method will return null, if the passed + /// object is not stored to this ObjectContainer.

+ ///
+ /// the stored object + /// + /// the + /// IObjectInfo + /// + /// + IObjectInfo GetObjectInfo(object obj); + + /// returns the Db4oDatabase object for this ObjectContainer. + /// returns the Db4oDatabase object for this ObjectContainer. + /// the Db4oDatabase identity object for this ObjectContainer. + Db4oDatabase Identity(); + + /// tests if an object is activated. + /// + /// tests if an object is activated. + ///

isActive returns false if an object is not + /// stored within the ObjectContainer.

+ ///
+ /// to be tested

+ /// true if the passed object is active. + bool IsActive(object obj); + + /// tests if an object with this ID is currently cached. + /// + /// tests if an object with this ID is currently cached. + ///

+ ///
+ /// the internal ID + bool IsCached(long Id); + + /// tests if this ObjectContainer is closed. + /// + /// tests if this ObjectContainer is closed. + ///

+ ///
+ /// true if this ObjectContainer is closed. + bool IsClosed(); + + /// tests if an object is stored in this ObjectContainer. + /// + /// tests if an object is stored in this ObjectContainer. + ///

+ ///
+ /// to be tested

+ /// true if the passed object is stored. + /// db4o database file was closed or failed to open. + /// + /// + bool IsStored(object obj); + + /// + /// returns all class representations that are known to this + /// ObjectContainer because they have been used or stored. + /// + /// + /// returns all class representations that are known to this + /// ObjectContainer because they have been used or stored. + /// + /// + /// all class representations that are known to this + /// ObjectContainer because they have been used or stored. + /// + IReflectClass[] KnownClasses(); + + /// returns the main synchronization lock. + /// + /// returns the main synchronization lock. + ///

+ /// Synchronize over this object to ensure exclusive access to + /// the ObjectContainer.

+ /// Handle the use of this functionality with extreme care, + /// since deadlocks can be produced with just two lines of code. + ///
+ /// Object the ObjectContainer lock object + object Lock(); + + /// opens a new ObjectContainer on top of this ObjectContainer. + /// + /// opens a new ObjectContainer on top of this ObjectContainer. + /// The ObjectContainer will have it's own transaction and + /// it's own reference system. + /// + /// the new ObjectContainer session. + /// 8.0 + IObjectContainer OpenSession(); + + /// + /// returns a transient copy of a persistent object with all members set + /// to the values that are currently stored to the database. + /// + /// + /// returns a transient copy of a persistent object with all members set + /// to the values that are currently stored to the database. + ///

+ /// The returned objects have no connection to the database.

+ /// With the committed parameter it is possible to specify, + /// whether the desired object should contain the committed values or the + /// values that were set by the running transaction with + /// Db4objects.Db4o.IObjectContainer.Store(object) + /// + /// . + ///

A possible use case for this feature:
+ /// An application might want to check all changes applied to an object + /// by the running transaction.

+ ///
+ /// the object that is to be cloned + /// the member depth to which the object is to be instantiated + /// whether committed or set values are to be returned + /// the object + object PeekPersisted(object @object, int depth, bool committed); + + /// unloads all clean indices from memory and frees unused objects. + /// + /// unloads all clean indices from memory and frees unused objects. + ///

Call commit() and purge() consecutively to achieve the best + /// result possible. This method can have a negative impact + /// on performance since indices will have to be reread before further + /// inserts, updates or queries can take place. + ///
+ void Purge(); + + /// unloads a specific object from the db4o reference mechanism. + /// + /// unloads a specific object from the db4o reference mechanism. + ///

db4o keeps references to all newly stored and + /// instantiated objects in memory, to be able to manage object identities. + ///

With calls to this method it is possible to remove an object from the + /// reference mechanism, to allow it to be garbage collected. You are not required to + /// call this method in the .NET and JDK 1.2 versions, since objects are + /// referred to by weak references and garbage collection happens + /// automatically.

An object removed with purge(Object) is not + /// "known" to the ObjectContainer afterwards, so this method may also be + /// used to create multiple copies of objects.

purge(Object) has + /// no influence on the persistence state of objects. "Purged" objects can be + /// reretrieved with queries.

+ ///
+ /// the object to be removed from the reference mechanism. + void Purge(object obj); + + /// Return the reflector currently being used by db4objects. + /// Return the reflector currently being used by db4objects. + /// the current Reflector. + GenericReflector Reflector(); + + /// refreshs all members on a stored object to the specified depth. + /// + /// refreshs all members on a stored object to the specified depth. + ///

If a member object is not activated, it will be activated by this method. + ///

The isolation used is READ COMMITTED. This method will read all objects + /// and values that have been committed by other transactions.

+ ///
+ /// the object to be refreshed. + /// + /// the member + /// depth + /// to which refresh is to cascade. + /// + void Refresh(object obj, int depth); + + /// releases a semaphore, if the calling transaction is the owner. + /// releases a semaphore, if the calling transaction is the owner. + /// the name of the semaphore to be released. + void ReleaseSemaphore(string name); + + /// deep update interface to store or update objects. + /// + /// deep update interface to store or update objects. + ///

In addition to the normal storage interface, + /// ObjectContainer#set(Object) + /// , + /// this method allows a manual specification of the depth, the passed object is to be updated.

+ ///
+ /// the object to be stored or updated. + /// the depth to which the object is to be updated + /// com.db4o.ObjectContainer#set + void Store(object obj, int depth); + + /// attempts to set a semaphore. + /// + /// attempts to set a semaphore. + ///

+ /// Semaphores are transient multi-purpose named flags for + /// ObjectContainers + /// . + ///

+ /// A transaction that successfully sets a semaphore becomes + /// the owner of the semaphore. Semaphores can only be owned + /// by a single transaction at one point in time.

+ /// This method returns true, if the transaction already owned + /// the semaphore before the method call or if it successfully + /// acquires ownership of the semaphore.

+ /// The waitForAvailability parameter allows to specify a time + /// in milliseconds to wait for other transactions to release + /// the semaphore, in case the semaphore is already owned by + /// another transaction.

+ /// Semaphores are released by the first occurrence of one of the + /// following:
+ /// - the transaction releases the semaphore with + /// ReleaseSemaphore(string) + ///
- the transaction is closed with + /// Db4objects.Db4o.IObjectContainer.Close() + /// + ///
- C/S only: the corresponding + /// Db4objects.Db4o.IObjectServer + /// is + /// closed.
- C/S only: the client + /// Db4objects.Db4o.IObjectContainer + /// looses the connection and is timed + /// out.

Semaphores are set immediately. They are independant of calling + /// Db4objects.Db4o.IObjectContainer.Commit() + /// + /// or + /// Db4objects.Db4o.IObjectContainer.Rollback() + /// + /// .

Possible use cases + /// for semaphores:
- prevent other clients from inserting a singleton at the same time. + /// A suggested name for the semaphore: "SINGLETON_" + Object#getClass().getName().
- lock + /// objects. A suggested name: "LOCK_" + + /// getID(Object) + ///
- + /// generate a unique client ID. A suggested name: "CLIENT_" + + /// System.currentTimeMillis().

+ ///
+ /// the name of the semaphore to be set + /// + /// the time in milliseconds to wait for other + /// transactions to release the semaphore. The parameter may be zero, if + /// the method is to return immediately. + /// + /// + /// boolean flag + ///
true, if the semaphore could be set or if the + /// calling transaction already owned the semaphore. + ///
false, if the semaphore is owned by another + /// transaction. + ///
+ bool SetSemaphore(string name, int waitForAvailability); + + /// + /// returns a + /// IStoredClass + /// meta information object. + ///

+ /// There are three options how to use this method.
+ /// Any of the following parameters are possible:
+ /// - a fully qualified class name.
+ /// - a Class object.
+ /// - any object to be used as a template.

+ ///
+ /// class name, Class object, or example object.

+ /// + /// an instance of an + /// IStoredClass + /// meta information object. + /// + IStoredClass StoredClass(object clazz); + + /// + /// returns an array of all + /// IStoredClass + /// meta information objects. + /// + IStoredClass[] StoredClasses(); + + /// + /// returns the + /// ISystemInfo + /// for this ObjectContainer. + ///

The + /// ISystemInfo + /// supplies methods that provide + /// information about system state and system settings of this + /// ObjectContainer. + ///
+ /// + /// the + /// ISystemInfo + /// for this ObjectContainer. + /// + ISystemInfo SystemInfo(); + + /// returns the current transaction serial number. + /// + /// returns the current transaction serial number. + ///

This serial number can be used to query for modified objects + /// and for replication purposes. + ///
+ /// the current transaction serial number. + long Version(); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/IExtObjectServer.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/IExtObjectServer.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/IExtObjectServer.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/IExtObjectServer.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,80 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o; +using Db4objects.Db4o.Config; + +namespace Db4objects.Db4o.Ext +{ + /// extended functionality for the ObjectServer interface. + /// + /// extended functionality for the ObjectServer interface. + ///

Every ObjectServer also always is an ExtObjectServer + /// so a cast is possible.

+ /// Db4objects.Db4o.IObjectServer.Ext() + /// + /// is a convenient method to perform the cast.

+ /// The functionality is split to two interfaces to allow newcomers to + /// focus on the essential methods. + ///
+ public interface IExtObjectServer : IObjectServer + { + /// backs up the database file used by the ObjectServer. + /// + /// backs up the database file used by the ObjectServer. + ///

While the backup is running, the ObjectServer can continue to be + /// used. Changes that are made while the backup is in progress, will be applied to + /// the open ObjectServer and to the backup.

+ /// While the backup is running, the ObjectContainer should not be closed.

+ /// If a file already exists at the specified path, it will be overwritten.

+ ///
+ /// a fully qualified path + /// + void Backup(string path); + + /// returns the number of connected clients. + /// returns the number of connected clients. + int ClientCount(); + + /// + /// returns the + /// Db4objects.Db4o.Config.IConfiguration + /// + /// context for this ObjectServer. + ///

+ /// Upon opening an ObjectServer with any of the factory methods in the + /// Db4objects.Db4o.Db4oFactory + /// class, the global + /// Db4objects.Db4o.Config.IConfiguration + /// + /// context + /// is copied into the ObjectServer. The + /// Db4objects.Db4o.Config.IConfiguration + /// + /// can be modified individually for + /// each ObjectServer without any effects on the global settings.

+ ///
+ /// the Configuration context for this ObjectServer + /// Db4objects.Db4o.Db4oFactory.Configure() + /// + IConfiguration Configure(); + + /// returns the ObjectContainer used by the server. + /// + /// returns the ObjectContainer used by the server. + ///

+ ///
+ /// the ObjectContainer used by the server + IObjectContainer ObjectContainer(); + + /// removes client access permissions for the specified user. + /// + /// removes client access permissions for the specified user. + ///

+ ///
+ /// the name of the user + void RevokeAccess(string userName); + + /// The local port this server uses, 0 if disconnected or in embedded mode + int Port(); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/IExtObjectSet.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/IExtObjectSet.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/IExtObjectSet.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/IExtObjectSet.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,43 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o; + +namespace Db4objects.Db4o.Ext +{ + /// + /// extended functionality for the + /// IObjectSet + /// interface. + ///

Every db4o + /// IObjectSet + /// always is an ExtObjectSet so a cast is possible.

+ /// Db4objects.Db4o.IObjectSet.Ext() + /// is a convenient method to perform the cast.

+ /// The ObjectSet functionality is split to two interfaces to allow newcomers to + /// focus on the essential methods. + ///
+ public interface IExtObjectSet : IObjectSet + { + /// returns an array of internal IDs that correspond to the contained objects. + /// + /// + /// returns an array of internal IDs that correspond to the contained objects. + ///

+ ///
+ /// IExtObjectContainer.GetID(object) + /// + /// IExtObjectContainer.GetByID(long) + /// + long[] GetIDs(); + + /// returns the item at position [index] in this ObjectSet. + /// + /// returns the item at position [index] in this ObjectSet. + ///

+ /// The object will be activated. + ///
+ /// the index position in this ObjectSet. + /// the activated object. + object Get(int index); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/IncompatibleFileFormatException.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/IncompatibleFileFormatException.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/IncompatibleFileFormatException.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/IncompatibleFileFormatException.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,28 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Ext; + +namespace Db4objects.Db4o.Ext +{ + /// + /// db4o-specific exception.

+ /// This exception is thrown when the database file format + /// is not compatible with the applied configuration. + ///
+ /// + /// db4o-specific exception.

+ /// This exception is thrown when the database file format + /// is not compatible with the applied configuration. + ///
+ [System.Serializable] + public class IncompatibleFileFormatException : Db4oFatalException + { + public IncompatibleFileFormatException() : base() + { + } + + public IncompatibleFileFormatException(string message) : base(message) + { + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/InvalidIDException.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/InvalidIDException.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/InvalidIDException.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/InvalidIDException.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,37 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using Db4objects.Db4o.Ext; + +namespace Db4objects.Db4o.Ext +{ + /// + /// db4o-specific exception.

+ /// This exception is thrown when the supplied object ID + /// is incorrect (outside the scope of the database IDs). + ///
+ /// + /// db4o-specific exception.

+ /// This exception is thrown when the supplied object ID + /// is incorrect (outside the scope of the database IDs). + ///
+ /// IExtObjectContainer.Bind(object, long) + /// + /// IExtObjectContainer.GetByID(long) + /// + [System.Serializable] + public class InvalidIDException : Db4oRecoverableException + { + /// Constructor allowing to specify the exception cause + /// cause exception + public InvalidIDException(Exception cause) : base(cause) + { + } + + /// Constructor allowing to specify the offending id + /// the offending id + public InvalidIDException(int id) : base("id: " + id) + { + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/InvalidPasswordException.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/InvalidPasswordException.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/InvalidPasswordException.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/InvalidPasswordException.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,21 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Ext; + +namespace Db4objects.Db4o.Ext +{ + /// + /// db4o-specific exception.

+ /// This exception is thrown when a client tries to connect + /// to a server with a wrong password or null password. + ///
+ /// + /// db4o-specific exception.

+ /// This exception is thrown when a client tries to connect + /// to a server with a wrong password or null password. + ///
+ [System.Serializable] + public class InvalidPasswordException : Db4oRecoverableException + { + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/InvalidSlotException.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/InvalidSlotException.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/InvalidSlotException.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/InvalidSlotException.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,37 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Ext; + +namespace Db4objects.Db4o.Ext +{ + /// + /// db4o-specific exception.

+ /// This exception is thrown when db4o reads slot + /// information which is not valid (length or address). + ///
+ /// + /// db4o-specific exception.

+ /// This exception is thrown when db4o reads slot + /// information which is not valid (length or address). + ///
+ [System.Serializable] + public class InvalidSlotException : Db4oRecoverableException + { + /// Constructor allowing to specify a detailed message. + /// Constructor allowing to specify a detailed message. + /// message + public InvalidSlotException(string msg) : base(msg) + { + } + + /// Constructor allowing to specify the address, length and id. + /// Constructor allowing to specify the address, length and id. + /// offending address + /// offending length + /// id where the address and length were read. + public InvalidSlotException(int address, int length, int id) : base("address: " + + address + ", length : " + length + ", id : " + id) + { + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/IObjectCallbacks.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/IObjectCallbacks.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/IObjectCallbacks.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/IObjectCallbacks.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,101 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o; + +namespace Db4objects.Db4o.Ext +{ + /// callback methods. + /// + /// callback methods. + ///

+ /// This interface only serves as a list of all available callback methods. + /// Every method is called individually, independantly of implementing this interface.

+ /// Using callbacks
+ /// Simply implement one or more of the listed methods in your application classes to + /// do tasks before activation, deactivation, delete, new or update, to cancel the + /// action about to be performed and to respond to the performed task. + ///

Callback methods are typically used for: + ///
- cascaded delete + ///
- cascaded update + ///
- cascaded activation + ///
- restoring transient members on instantiation + ///

Callback methods follow regular calling conventions. Methods in superclasses + /// need to be called explicitely. + ///

All method calls are implemented to occur only once, upon one event. + ///
+ public interface IObjectCallbacks + { + /// called before an Object is activated. + /// called before an Object is activated. + /// the ObjectContainer the object is stored in. + /// + /// false to prevent activation. + bool ObjectCanActivate(IObjectContainer container); + + /// called before an Object is deactivated. + /// called before an Object is deactivated. + /// the ObjectContainer the object is stored in. + /// + /// false to prevent deactivation. + bool ObjectCanDeactivate(IObjectContainer container); + + /// called before an Object is deleted. + /// + /// called before an Object is deleted. + ///

In a client/server setup this callback method will be executed on + /// the server. + ///
+ /// the ObjectContainer the object is stored in. + /// + /// false to prevent the object from being deleted. + bool ObjectCanDelete(IObjectContainer container); + + /// called before an Object is stored the first time. + /// called before an Object is stored the first time. + /// the ObjectContainer is about to be stored to. + /// + /// false to prevent the object from being stored. + bool ObjectCanNew(IObjectContainer container); + + /// called before a persisted Object is updated. + /// called before a persisted Object is updated. + /// the ObjectContainer the object is stored in. + /// + /// false to prevent the object from being updated. + bool ObjectCanUpdate(IObjectContainer container); + + /// called upon activation of an object. + /// called upon activation of an object. + /// the ObjectContainer the object is stored in. + /// + void ObjectOnActivate(IObjectContainer container); + + /// called upon deactivation of an object. + /// called upon deactivation of an object. + /// the ObjectContainer the object is stored in. + /// + void ObjectOnDeactivate(IObjectContainer container); + + /// called after an object was deleted. + /// + /// called after an object was deleted. + ///

In a client/server setup this callback method will be executed on + /// the server. + ///
+ /// the ObjectContainer the object was stored in. + /// + void ObjectOnDelete(IObjectContainer container); + + /// called after a new object was stored. + /// called after a new object was stored. + /// the ObjectContainer the object is stored to. + /// + void ObjectOnNew(IObjectContainer container); + + /// called after an object was updated. + /// called after an object was updated. + /// the ObjectContainer the object is stored in. + /// + void ObjectOnUpdate(IObjectContainer container); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/IObjectInfoCollection.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/IObjectInfoCollection.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/IObjectInfoCollection.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/IObjectInfoCollection.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,17 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System.Collections; + +namespace Db4objects.Db4o.Ext +{ + /// + /// Interface to an iterable collection + /// IObjectInfo + /// objects.

+ /// ObjectInfoCollection is used reference a number of stored objects. + ///
+ /// IObjectInfo + public interface IObjectInfoCollection : IEnumerable + { + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/IObjectInfo.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/IObjectInfo.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/IObjectInfo.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/IObjectInfo.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,87 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Ext; + +namespace Db4objects.Db4o.Ext +{ + /// + /// interface to the internal reference that an ObjectContainer + /// holds for a stored object. + /// + /// + /// interface to the internal reference that an ObjectContainer + /// holds for a stored object. + /// + public interface IObjectInfo + { + /// returns the internal db4o ID. + /// returns the internal db4o ID. + long GetInternalID(); + + /// returns the object that is referenced. + /// + /// returns the object that is referenced. + ///

This method may return null, if the object has + /// been garbage collected. + ///
+ /// + /// the referenced object or null, if the object has + /// been garbage collected. + /// + object GetObject(); + + /// returns a UUID representation of the referenced object. + /// + /// returns a UUID representation of the referenced object. + /// UUID generation has to be turned on, in order to be able + /// to use this feature: + /// Db4objects.Db4o.Config.IConfiguration.GenerateUUIDs(Db4objects.Db4o.Config.ConfigScope) + /// + /// + /// the UUID of the referenced object. + Db4oUUID GetUUID(); + + /// + /// returns the transaction serial number ("version") the referenced object + /// was stored with last. + /// + /// + /// returns the transaction serial number ("version") the referenced object + /// was stored with last. Version number generation has to be turned on, in + /// order to be able to use this feature: + /// Db4objects.Db4o.Config.IConfiguration.GenerateVersionNumbers(Db4objects.Db4o.Config.ConfigScope) + /// + ///
+ /// This feature was replaced by + /// GetCommitTimestamp() + /// . The main + /// difference is that the old version mechamism used to assign a serial + /// timestamp to the object upon storing time, and the new commiTimestamp + /// approach, assigns it upon commit time.
+ ///
+ /// the version number. + [System.ObsoleteAttribute(@"As of version 8.0 please use GetCommitTimestamp() instead." + )] + long GetVersion(); + + /// + /// The serial timestamp the object is assigned to when it is commited.
+ ///
+ /// You need to enable this feature before using it in + /// Db4objects.Db4o.Config.IFileConfiguration.GenerateCommitTimestamps(bool) + /// .
+ ///
+ /// All the objects commited within the same transaction will receive the same commitTimestamp.
+ ///
+ /// db4o replication system (dRS) relies on this feature.
+ ///
+ /// the serial timestamp that was given to the object upon commit. + /// Db4objects.Db4o.Config.IFileConfiguration.GenerateCommitTimestamps(bool) + /// 8.0 + long GetCommitTimestamp(); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/IStoredClass.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/IStoredClass.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/IStoredClass.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/IStoredClass.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,76 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Ext; + +namespace Db4objects.Db4o.Ext +{ + /// the internal representation of a stored class. + /// the internal representation of a stored class. + public interface IStoredClass + { + /// returns the name of this stored class. + /// returns the name of this stored class. + string GetName(); + + /// returns an array of IDs of all stored object instances of this stored class. + /// + /// returns an array of IDs of all stored object instances of this stored class. + /// + long[] GetIDs(); + + /// returns the StoredClass for the parent of the class, this StoredClass represents. + /// + /// returns the StoredClass for the parent of the class, this StoredClass represents. + /// + IStoredClass GetParentStoredClass(); + + /// returns all stored fields of this stored class. + /// returns all stored fields of this stored class. + IStoredField[] GetStoredFields(); + + /// returns true if this StoredClass has a class index. + /// returns true if this StoredClass has a class index. + bool HasClassIndex(); + + /// renames this stored class. + /// + /// renames this stored class. + ///

After renaming one or multiple classes the ObjectContainer has + /// to be closed and reopened to allow internal caches to be refreshed. + ///

.NET: As the name you should provide [Classname, Assemblyname]

+ ///
+ /// the new name + void Rename(string name); + + // TODO: add field creation + /// returns an existing stored field of this stored class. + /// returns an existing stored field of this stored class. + /// the name of the field + /// + /// the type of the field. + /// There are four possibilities how to supply the type:
+ /// - a Class object. (.NET: a Type object)
+ /// - a fully qualified classname.
+ /// - any object to be used as a template.

+ /// - null, if the first found field should be returned. + /// + /// + /// the + /// IStoredField + /// + IStoredField StoredField(string name, object type); + + /// + /// Returns the number of instances of this class that have been persisted to the + /// database, as seen by the transaction (container) that produces this StoredClass + /// instance. + /// + /// + /// Returns the number of instances of this class that have been persisted to the + /// database, as seen by the transaction (container) that produces this StoredClass + /// instance. + /// + /// The number of instances + int InstanceCount(); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/IStoredField.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/IStoredField.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/IStoredField.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/IStoredField.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,86 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Reflect; + +namespace Db4objects.Db4o.Ext +{ + /// the internal representation of a field on a stored class. + /// the internal representation of a field on a stored class. + public interface IStoredField + { + /// creates an index on this field at runtime. + /// creates an index on this field at runtime. + void CreateIndex(); + + /// drops an existing index on this field at runtime. + /// drops an existing index on this field at runtime. + void DropIndex(); + + /// returns the field value on the passed object. + /// + /// returns the field value on the passed object. + ///

This method will also work, if the field is not present in the current + /// version of the class. + ///

It is recommended to use this method for refactoring purposes, if fields + /// are removed and the field values need to be copied to other fields. + ///
+ object Get(object onObject); + + /// returns the name of the field. + /// returns the name of the field. + string GetName(); + + /// returns the Class (Java) / Type (.NET) of the field. + /// + /// returns the Class (Java) / Type (.NET) of the field. + ///

For array fields this method will return the type of the array. + /// Use + /// IsArray() + /// to detect arrays. + ///
+ IReflectClass GetStoredType(); + + /// returns true if the field is an array. + /// returns true if the field is an array. + bool IsArray(); + + /// modifies the name of this stored field. + /// + /// modifies the name of this stored field. + ///

After renaming one or multiple fields the ObjectContainer has + /// to be closed and reopened to allow internal caches to be refreshed.

+ ///
+ /// the new name + void Rename(string name); + + /// + /// specialized highspeed API to collect all values of a field for all instances + /// of a class, if the field is indexed. + /// + /// + /// specialized highspeed API to collect all values of a field for all instances + /// of a class, if the field is indexed. + ///

The field values will be taken directly from the index without the + /// detour through class indexes or object instantiation. + ///

+ /// If this method is used to get the values of a first class object index, + /// deactivated objects will be passed to the visitor. + ///
+ /// the visitor to be called with each index value. + void TraverseValues(IVisitor4 visitor); + + /// Returns whether this field has an index or not. + /// Returns whether this field has an index or not. + /// true if this field has an index. + bool HasIndex(); + // will need for replication. Requested for 3.0 + // + // /** + // * sets the field value on the passed object. + // * @param onObject + // * @param fieldValue + // */ + // public void set(Object onObject, Object fieldValue); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/ISystemInfo.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/ISystemInfo.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/ISystemInfo.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/ISystemInfo.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,38 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +namespace Db4objects.Db4o.Ext +{ + /// provides information about system state and system settings. + /// provides information about system state and system settings. + public interface ISystemInfo + { + /// returns the number of entries in the Freespace Manager. + /// + /// returns the number of entries in the Freespace Manager. + ///

A high value for the number of freespace entries + /// is an indication that the database is fragmented and + /// that defragment should be run. + ///
+ /// the number of entries in the Freespace Manager. + int FreespaceEntryCount(); + + /// returns the freespace size in the database in bytes. + /// + /// returns the freespace size in the database in bytes. + ///

When db4o stores modified objects, it allocates + /// a new slot for it. During commit the old slot is freed. + /// Free slots are collected in the freespace manager, so + /// they can be reused for other objects. + ///

This method returns a sum of the size of all + /// free slots in the database file. + ///

To reclaim freespace run defragment. + ///
+ /// the freespace size in the database in bytes. + long FreespaceSize(); + + /// Returns the total size of the database on disk. + /// Returns the total size of the database on disk. + /// total size of database on disk + long TotalSize(); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/ObjectNotStorableException.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/ObjectNotStorableException.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/ObjectNotStorableException.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/ObjectNotStorableException.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,30 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Ext; +using Db4objects.Db4o.Reflect; + +namespace Db4objects.Db4o.Ext +{ + /// + /// this Exception is thrown, if objects can not be stored and if + /// db4o is configured to throw Exceptions on storage failures. + /// + /// + /// this Exception is thrown, if objects can not be stored and if + /// db4o is configured to throw Exceptions on storage failures. + /// + /// Db4objects.Db4o.Config.IConfiguration.ExceptionsOnNotStorable(bool) + [System.Serializable] + public class ObjectNotStorableException : Db4oRecoverableException + { + public ObjectNotStorableException(IReflectClass a_class) : base(Db4objects.Db4o.Internal.Messages + .Get(a_class.IsPrimitive() ? 59 : 45, a_class.GetName())) + { + } + + public ObjectNotStorableException(string message) : base(message) + { + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/OldFormatException.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/OldFormatException.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/OldFormatException.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/OldFormatException.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,25 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Ext; + +namespace Db4objects.Db4o.Ext +{ + /// + /// db4o-specific exception.

+ /// This exception is thrown when an old file format was detected + /// and + /// Db4objects.Db4o.Config.IConfiguration.AllowVersionUpdates(bool) + /// + /// is set to false. + ///
+ [System.Serializable] + public class OldFormatException : Db4oFatalException + { + /// Constructor with the default message. + /// Constructor with the default message. + public OldFormatException() : base(Db4objects.Db4o.Internal.Messages.OldDatabaseFormat + ) + { + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/Status.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/Status.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/Status.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/Status.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,21 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +namespace Db4objects.Db4o.Ext +{ + /// Static constants to describe the status of objects. + /// Static constants to describe the status of objects. + public class Status + { + public const double Unused = -1.0; + + public const double Available = -2.0; + + public const double Queued = -3.0; + + public const double Completed = -4.0; + + public const double Processing = -5.0; + + public const double Error = -99.0; + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/UnsupportedOldFormatException.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/UnsupportedOldFormatException.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/UnsupportedOldFormatException.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/UnsupportedOldFormatException.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,19 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Ext; + +namespace Db4objects.Db4o.Ext +{ + /// + /// This exception is thrown while reading old database + /// files for which support has been dropped. + /// + /// + /// This exception is thrown while reading old database + /// files for which support has been dropped. + /// + [System.Serializable] + public class UnsupportedOldFormatException : Db4oFatalException + { + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/VirtualField.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/VirtualField.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/VirtualField.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Ext/VirtualField.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,27 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal; + +namespace Db4objects.Db4o.Ext +{ + /// intended for future virtual fields on classes. + /// + /// intended for future virtual fields on classes. Currently only + /// the constant for the virtual version field is found here. + /// + /// + public class VirtualField + { + /// + /// the field name of the virtual version field, to be used + /// for querying. + /// + /// + /// the field name of the virtual version field, to be used + /// for querying. + /// + public static readonly string Version = Const4.VirtualFieldPrefix + "version"; + + public static readonly string CommitTimestamp = Const4.VirtualFieldPrefix + "commitTimestamp"; + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/AbstractTreeIterator.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/AbstractTreeIterator.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/AbstractTreeIterator.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/AbstractTreeIterator.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,106 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using System.Collections; +using Db4objects.Db4o.Foundation; + +namespace Db4objects.Db4o.Foundation +{ + /// + public abstract class AbstractTreeIterator : IEnumerator + { + private readonly Tree _tree; + + private Stack4 _stack; + + public AbstractTreeIterator(Tree tree) + { + _tree = tree; + } + + public virtual object Current + { + get + { + if (_stack == null) + { + throw new InvalidOperationException(); + } + Tree tree = Peek(); + if (tree == null) + { + return null; + } + return CurrentValue(tree); + } + } + + private Tree Peek() + { + return (Tree)_stack.Peek(); + } + + public virtual void Reset() + { + _stack = null; + } + + public virtual bool MoveNext() + { + if (_stack == null) + { + InitStack(); + return _stack != null; + } + Tree current = Peek(); + if (current == null) + { + return false; + } + if (PushPreceding(((Tree)current._subsequent))) + { + return true; + } + while (true) + { + _stack.Pop(); + Tree parent = Peek(); + if (parent == null) + { + return false; + } + if (current == ((Tree)parent._preceding)) + { + return true; + } + current = parent; + } + } + + private void InitStack() + { + if (_tree == null) + { + return; + } + _stack = new Stack4(); + PushPreceding(_tree); + } + + private bool PushPreceding(Tree node) + { + if (node == null) + { + return false; + } + while (node != null) + { + _stack.Push(node); + node = ((Tree)node._preceding); + } + return true; + } + + protected abstract object CurrentValue(Tree tree); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/Algorithms4.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/Algorithms4.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/Algorithms4.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/Algorithms4.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,181 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using Db4objects.Db4o.Foundation; + +namespace Db4objects.Db4o.Foundation +{ + /// + public class Algorithms4 + { + private const int QsortLengthThreshold = 7; + + public static void Sort(ISortable4 sortable) + { + Sort(sortable, 0, sortable.Size()); + } + + public static void Sort(ISortable4 sortable, int start, int end) + { + int length = end - start; + if (length < QsortLengthThreshold) + { + InsertionSort(sortable, start, end); + return; + } + Qsort(sortable, start, end); + } + + public static void Qsort(ISortable4 sortable, int start, int end) + { + int length = end - start; + int middle = start + length / 2; + if (length > 7) + { + int bottom = start; + int top = end - 1; + if (length > 40) + { + length /= 8; + bottom = MiddleValueIndex(sortable, bottom, bottom + length, bottom + (2 * length + )); + middle = MiddleValueIndex(sortable, middle - length, middle, middle + length); + top = MiddleValueIndex(sortable, top - (2 * length), top - length, top); + } + middle = MiddleValueIndex(sortable, bottom, middle, top); + } + int a; + int b; + int c; + int d; + a = b = start; + c = d = end - 1; + while (true) + { + while (b <= c && sortable.Compare(b, middle) <= 0) + { + if (sortable.Compare(b, middle) == 0) + { + middle = NewPartionIndex(middle, a, b); + Swap(sortable, a++, b); + } + b++; + } + while (c >= b && sortable.Compare(c, middle) >= 0) + { + if (sortable.Compare(c, middle) == 0) + { + middle = NewPartionIndex(middle, c, d); + Swap(sortable, c, d--); + } + c--; + } + if (b > c) + { + break; + } + middle = NewPartionIndex(middle, b, c); + Swap(sortable, b++, c--); + } + length = Math.Min(a - start, b - a); + Swap(sortable, start, b - length, length); + length = Math.Min(d - c, end - 1 - d); + Swap(sortable, b, end - length, length); + length = b - a; + if (length > 0) + { + Sort(sortable, start, start + length); + } + length = d - c; + if (length > 0) + { + Sort(sortable, end - length, end); + } + } + + public static void InsertionSort(ISortable4 sortable, int start, int end) + { + for (int i = start + 1; i < end; i++) + { + for (int j = i; j > start && sortable.Compare(j - 1, j) > 0; j--) + { + Swap(sortable, j - 1, j); + } + } + } + + private static int NewPartionIndex(int oldPartionIndex, int leftSwapIndex, int rightSwapIndex + ) + { + if (leftSwapIndex == oldPartionIndex) + { + return rightSwapIndex; + } + else + { + if (rightSwapIndex == oldPartionIndex) + { + return leftSwapIndex; + } + } + return oldPartionIndex; + } + + private static int MiddleValueIndex(ISortable4 sortable, int a, int b, int c) + { + if (sortable.Compare(a, b) < 0) + { + if (sortable.Compare(b, c) < 0) + { + return b; + } + else + { + if (sortable.Compare(a, c) < 0) + { + return c; + } + else + { + return a; + } + } + } + else + { + if (sortable.Compare(b, c) > 0) + { + return b; + } + else + { + if (sortable.Compare(a, c) > 0) + { + return c; + } + else + { + return a; + } + } + } + } + + private static void Swap(ISortable4 sortable, int left, int right) + { + if (left == right) + { + return; + } + sortable.Swap(left, right); + } + + private static void Swap(ISortable4 sortable, int from, int to, int length) + { + while (length-- > 0) + { + Swap(sortable, from++, to++); + } + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/ArrayIterator4.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/ArrayIterator4.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/ArrayIterator4.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/ArrayIterator4.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,21 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Foundation; + +namespace Db4objects.Db4o.Foundation +{ + public class ArrayIterator4 : IndexedIterator + { + private readonly object[] _elements; + + public ArrayIterator4(object[] elements) : base(elements.Length) + { + _elements = elements; + } + + protected override object Get(int index) + { + return _elements[index]; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/Arrays4.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/Arrays4.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/Arrays4.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/Arrays4.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,150 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using Db4objects.Db4o.Foundation; +using Sharpen; + +namespace Db4objects.Db4o.Foundation +{ + /// + public class Arrays4 + { + public static int[] CopyOf(int[] src, int newLength) + { + int[] copy = new int[newLength]; + System.Array.Copy(src, 0, copy, 0, Math.Min(src.Length, newLength)); + return copy; + } + + public static int IndexOfIdentity(object[] array, object element) + { + for (int i = 0; i < array.Length; i++) + { + if (array[i] == element) + { + return i; + } + } + return -1; + } + + public static int IndexOfEquals(object[] array, object expected) + { + for (int i = 0; i < array.Length; ++i) + { + if (expected.Equals(array[i])) + { + return i; + } + } + return -1; + } + + public static int IndexOf(int[] array, int element) + { + for (int i = 0; i < array.Length; i++) + { + if (array[i] == element) + { + return i; + } + } + return -1; + } + + public static bool Equals(byte[] x, byte[] y) + { + if (x == y) + { + return true; + } + if (x == null) + { + return false; + } + if (x.Length != y.Length) + { + return false; + } + for (int i = 0; i < x.Length; i++) + { + if (y[i] != x[i]) + { + return false; + } + } + return true; + } + + public static bool Equals(object[] x, object[] y) + { + if (x == y) + { + return true; + } + if (x == null) + { + return false; + } + if (x.Length != y.Length) + { + return false; + } + for (int i = 0; i < x.Length; i++) + { + if (!ObjectsAreEqual(y[i], x[i])) + { + return false; + } + } + return true; + } + + private static bool ObjectsAreEqual(object x, object y) + { + if (x == y) + { + return true; + } + if (x == null || y == null) + { + return false; + } + return x.Equals(y); + } + + public static bool ContainsInstanceOf(object[] array, Type klass) + { + if (array == null) + { + return false; + } + for (int i = 0; i < array.Length; ++i) + { + if (klass.IsInstanceOfType(array[i])) + { + return true; + } + } + return false; + } + + public static void Fill(object[] array, object value) + { + for (int i = 0; i < array.Length; ++i) + { + array[i] = value; + } + } + + public static Collection4 AsList(object[] arr) + { + Collection4 coll = new Collection4(); + for (int arrIdx = 0; arrIdx < arr.Length; arrIdx++) + { + coll.Add(arr[arrIdx]); + } + return coll; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/AutoStopWatch.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/AutoStopWatch.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/AutoStopWatch.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/AutoStopWatch.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,14 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Foundation; + +namespace Db4objects.Db4o.Foundation +{ + public class AutoStopWatch : StopWatch + { + public AutoStopWatch() + { + Start(); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/BitMap4.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/BitMap4.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/BitMap4.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/BitMap4.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,100 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Sharpen; + +namespace Db4objects.Db4o.Foundation +{ + /// + public sealed class BitMap4 + { + private readonly byte[] _bits; + + public BitMap4(int numBits) + { + _bits = new byte[ByteCount(numBits)]; + } + + /// "readFrom buffer" constructor + public BitMap4(byte[] buffer, int pos, int numBits) : this(numBits) + { + System.Array.Copy(buffer, pos, _bits, 0, _bits.Length); + } + + public BitMap4(byte singleByte) + { + _bits = new byte[] { singleByte }; + } + + public bool IsTrue(int bit) + { + return (((_bits[ArrayOffset(bit)]) >> (ByteOffset(bit) & 0x1f)) & 1) != 0; + } + + public bool IsFalse(int bit) + { + return !IsTrue(bit); + } + + public int MarshalledLength() + { + return _bits.Length; + } + + public void SetFalse(int bit) + { + _bits[ArrayOffset(bit)] &= (byte)~BitMask(bit); + } + + public void Set(int bit, bool val) + { + if (val) + { + SetTrue(bit); + } + else + { + SetFalse(bit); + } + } + + public void SetTrue(int bit) + { + _bits[ArrayOffset(bit)] |= BitMask(bit); + } + + public void WriteTo(byte[] bytes, int pos) + { + System.Array.Copy(_bits, 0, bytes, pos, _bits.Length); + } + + private byte ByteOffset(int bit) + { + return (byte)(bit % 8); + } + + private int ArrayOffset(int bit) + { + return bit / 8; + } + + private byte BitMask(int bit) + { + return (byte)(1 << ByteOffset(bit)); + } + + private int ByteCount(int numBits) + { + return (numBits + 7) / 8; + } + + public byte GetByte(int index) + { + return _bits[index]; + } + + public byte[] Bytes() + { + return _bits; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/BlockingQueue.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/BlockingQueue.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/BlockingQueue.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/BlockingQueue.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,290 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using System.Collections; +using Db4objects.Db4o.Foundation; +using Sharpen; + +namespace Db4objects.Db4o.Foundation +{ + /// + public class BlockingQueue : IBlockingQueue4 + { + protected NonblockingQueue _queue = new NonblockingQueue(); + + protected Lock4 _lock = new Lock4(); + + protected bool _stopped; + + public virtual void Add(object obj) + { + if (obj == null) + { + throw new ArgumentException(); + } + _lock.Run(new _IClosure4_20(this, obj)); + } + + private sealed class _IClosure4_20 : IClosure4 + { + public _IClosure4_20(BlockingQueue _enclosing, object obj) + { + this._enclosing = _enclosing; + this.obj = obj; + } + + public object Run() + { + this._enclosing._queue.Add(obj); + this._enclosing._lock.Awake(); + return null; + } + + private readonly BlockingQueue _enclosing; + + private readonly object obj; + } + + public virtual bool HasNext() + { + return (((bool)_lock.Run(new _IClosure4_30(this)))); + } + + private sealed class _IClosure4_30 : IClosure4 + { + public _IClosure4_30(BlockingQueue _enclosing) + { + this._enclosing = _enclosing; + } + + public object Run() + { + return this._enclosing._queue.HasNext(); + } + + private readonly BlockingQueue _enclosing; + } + + public virtual IEnumerator Iterator() + { + return ((IEnumerator)_lock.Run(new _IClosure4_38(this))); + } + + private sealed class _IClosure4_38 : IClosure4 + { + public _IClosure4_38(BlockingQueue _enclosing) + { + this._enclosing = _enclosing; + } + + public object Run() + { + return this._enclosing._queue.Iterator(); + } + + private readonly BlockingQueue _enclosing; + } + + /// + public virtual object Next(long timeout) + { + return (object)_lock.Run(new _IClosure4_46(this, timeout)); + } + + private sealed class _IClosure4_46 : IClosure4 + { + public _IClosure4_46(BlockingQueue _enclosing, long timeout) + { + this._enclosing = _enclosing; + this.timeout = timeout; + } + + public object Run() + { + return this._enclosing.UnsafeWaitForNext(timeout) ? this._enclosing.UnsafeNext() : + null; + } + + private readonly BlockingQueue _enclosing; + + private readonly long timeout; + } + + public virtual int DrainTo(Collection4 target) + { + return (((int)_lock.Run(new _IClosure4_54(this, target)))); + } + + private sealed class _IClosure4_54 : IClosure4 + { + public _IClosure4_54(BlockingQueue _enclosing, Collection4 target) + { + this._enclosing = _enclosing; + this.target = target; + } + + public object Run() + { + this._enclosing.UnsafeWaitForNext(); + int i = 0; + while (this._enclosing.HasNext()) + { + i++; + target.Add(this._enclosing.UnsafeNext()); + } + return i; + } + + private readonly BlockingQueue _enclosing; + + private readonly Collection4 target; + } + + /// + public virtual bool WaitForNext(long timeout) + { + return (((bool)_lock.Run(new _IClosure4_68(this, timeout)))); + } + + private sealed class _IClosure4_68 : IClosure4 + { + public _IClosure4_68(BlockingQueue _enclosing, long timeout) + { + this._enclosing = _enclosing; + this.timeout = timeout; + } + + public object Run() + { + return this._enclosing.UnsafeWaitForNext(timeout); + } + + private readonly BlockingQueue _enclosing; + + private readonly long timeout; + } + + /// + public virtual object Next() + { + return (object)_lock.Run(new _IClosure4_76(this)); + } + + private sealed class _IClosure4_76 : IClosure4 + { + public _IClosure4_76(BlockingQueue _enclosing) + { + this._enclosing = _enclosing; + } + + public object Run() + { + this._enclosing.UnsafeWaitForNext(); + return this._enclosing.UnsafeNext(); + } + + private readonly BlockingQueue _enclosing; + } + + public virtual void Stop() + { + _lock.Run(new _IClosure4_85(this)); + } + + private sealed class _IClosure4_85 : IClosure4 + { + public _IClosure4_85(BlockingQueue _enclosing) + { + this._enclosing = _enclosing; + } + + public object Run() + { + this._enclosing._stopped = true; + this._enclosing._lock.Awake(); + return null; + } + + private readonly BlockingQueue _enclosing; + } + + public virtual object NextMatching(IPredicate4 condition) + { + return _lock.Run(new _IClosure4_95(this, condition)); + } + + private sealed class _IClosure4_95 : IClosure4 + { + public _IClosure4_95(BlockingQueue _enclosing, IPredicate4 condition) + { + this._enclosing = _enclosing; + this.condition = condition; + } + + public object Run() + { + return this._enclosing._queue.NextMatching(condition); + } + + private readonly BlockingQueue _enclosing; + + private readonly IPredicate4 condition; + } + + /// + public virtual void WaitForNext() + { + _lock.Run(new _IClosure4_103(this)); + } + + private sealed class _IClosure4_103 : IClosure4 + { + public _IClosure4_103(BlockingQueue _enclosing) + { + this._enclosing = _enclosing; + } + + public object Run() + { + this._enclosing.UnsafeWaitForNext(); + return null; + } + + private readonly BlockingQueue _enclosing; + } + + /// + protected virtual void UnsafeWaitForNext() + { + UnsafeWaitForNext(long.MaxValue); + } + + /// + protected virtual bool UnsafeWaitForNext(long timeout) + { + long timeLeft = timeout; + long now = Runtime.CurrentTimeMillis(); + while (timeLeft > 0) + { + if (_queue.HasNext()) + { + return true; + } + if (_stopped) + { + throw new BlockingQueueStoppedException(); + } + _lock.Snooze(timeLeft); + long l = now; + now = Runtime.CurrentTimeMillis(); + timeLeft -= now - l; + } + return false; + } + + private object UnsafeNext() + { + return _queue.Next(); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/BlockingQueueStoppedException.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/BlockingQueueStoppedException.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/BlockingQueueStoppedException.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/BlockingQueueStoppedException.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,20 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using Db4objects.Db4o; + +namespace Db4objects.Db4o.Foundation +{ + /// + [System.Serializable] + public class BlockingQueueStoppedException : Exception + { + public BlockingQueueStoppedException() : base() + { + if (DTrace.enabled) + { + DTrace.BlockingQueueStoppedException.Log(); + } + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/BooleanByRef.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/BooleanByRef.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/BooleanByRef.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/BooleanByRef.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,20 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +namespace Db4objects.Db4o.Foundation +{ + /// Useful as "out" or "by ref" function parameter. + /// Useful as "out" or "by ref" function parameter. + public class BooleanByRef + { + public bool value; + + public BooleanByRef() : this(false) + { + } + + public BooleanByRef(bool value_) + { + value = value_; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/ByRef.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/ByRef.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/ByRef.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/ByRef.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,25 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Foundation; + +namespace Db4objects.Db4o.Foundation +{ + /// Useful as "out" or "by reference" function parameter. + /// Useful as "out" or "by reference" function parameter. + public class ByRef + { + public static ByRef NewInstance(object initialValue) + { + ByRef instance = new ByRef(); + instance.value = initialValue; + return instance; + } + + public static ByRef NewInstance() + { + return new ByRef(); + } + + public object value; + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/CircularBuffer4.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/CircularBuffer4.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/CircularBuffer4.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/CircularBuffer4.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,205 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using System.Collections; +using Db4objects.Db4o.Foundation; + +namespace Db4objects.Db4o.Foundation +{ + /// A fixed size double ended queue with O(1) complexity for addFirst, removeFirst and removeLast operations. + /// + /// A fixed size double ended queue with O(1) complexity for addFirst, removeFirst and removeLast operations. + /// + public class CircularBuffer4 : IEnumerable + { + private readonly object[] _buffer; + + private int _head; + + private int _tail; + + public CircularBuffer4(int size) + { + _buffer = (object[])new object[size + 1]; + } + + public virtual int Size() + { + return Index(_tail - _head); + } + + public virtual void AddFirst(object value) + { + int newHead = CircularIndex(_head - 1); + if (newHead == _tail) + { + throw new InvalidOperationException(); + } + _head = newHead; + _buffer[Index(_head)] = value; + } + + private int CircularIndex(int index) + { + return index % _buffer.Length; + } + + private int Index(int i) + { + return i < 0 ? _buffer.Length + i : i; + } + + public virtual object RemoveLast() + { + AssertNotEmpty(); + _tail = CircularIndex(_tail - 1); + return Erase(_tail); + } + + private void AssertNotEmpty() + { + if (IsEmpty()) + { + throw new InvalidOperationException(); + } + } + + public virtual bool IsEmpty() + { + return Index(_head) == Index(_tail); + } + + public virtual bool IsFull() + { + return CircularIndex(_head - 1) == _tail; + } + + public virtual object RemoveFirst() + { + AssertNotEmpty(); + object erased = Erase(_head); + _head = CircularIndex(_head + 1); + return erased; + } + + private object Erase(int index) + { + int bufferIndex = Index(index); + object erasedValue = _buffer[bufferIndex]; + _buffer[bufferIndex] = null; + return erasedValue; + } + + public virtual bool Remove(object value) + { + int idx = IndexOf(value); + if (idx >= 0) + { + RemoveAt(idx); + return true; + } + return false; + } + + public virtual bool Contains(object value) + { + return IndexOf(value) >= 0; + } + + private int IndexOf(object value) + { + int current = Index(_head); + int tail = Index(_tail); + while (current != tail) + { + if (((object)value).Equals(_buffer[current])) + { + break; + } + current = CircularIndex(current + 1); + } + return (current == tail ? -1 : current); + } + + private void RemoveAt(int index) + { + if (Index(_tail - 1) == index) + { + RemoveLast(); + return; + } + if (index == Index(_head)) + { + RemoveFirst(); + return; + } + int current = index; + int tail = Index(_tail); + while (current != tail) + { + int next = CircularIndex(current + 1); + _buffer[current] = _buffer[next]; + current = next; + } + _tail = CircularIndex(_tail - 1); + } + + public virtual IEnumerator GetEnumerator() + { + int tail = Index(_tail); + int head = Index(_head); + // TODO: detect concurrent modification and throw IllegalStateException + return new _IEnumerator_121(this, head, tail); + } + + private sealed class _IEnumerator_121 : IEnumerator + { + public _IEnumerator_121(CircularBuffer4 _enclosing, int head, int tail) + { + this._enclosing = _enclosing; + this.head = head; + this.tail = tail; + this._index = head; + this._current = Iterators.NoElement; + } + + private int _index; + + private object _current; + + public object Current + { + get + { + if (this._current == Iterators.NoElement) + { + throw new InvalidOperationException(); + } + return this._current; + } + } + + public bool MoveNext() + { + if (this._index == tail) + { + return false; + } + this._current = this._enclosing._buffer[this._index]; + this._index = this._enclosing.CircularIndex(this._index + 1); + return true; + } + + public void Reset() + { + throw new NotImplementedException(); + } + + private readonly CircularBuffer4 _enclosing; + + private readonly int head; + + private readonly int tail; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/CircularIntBuffer4.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/CircularIntBuffer4.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/CircularIntBuffer4.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/CircularIntBuffer4.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,207 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using System.Collections; +using Db4objects.Db4o.Foundation; + +namespace Db4objects.Db4o.Foundation +{ + /// A fixed size double ended queue with O(1) complexity for addFirst, removeFirst and removeLast operations. + /// + /// A fixed size double ended queue with O(1) complexity for addFirst, removeFirst and removeLast operations. + /// + public class CircularIntBuffer4 : IEnumerable + { + private const int Empty = -1; + + private readonly int[] _buffer; + + private int _head; + + private int _tail; + + public CircularIntBuffer4(int size) + { + _buffer = new int[size + 1]; + } + + public virtual int Size() + { + return Index(_tail - _head); + } + + public virtual void AddFirst(int value) + { + int newHead = CircularIndex(_head - 1); + if (newHead == _tail) + { + throw new InvalidOperationException(); + } + _head = newHead; + _buffer[Index(_head)] = value; + } + + private int CircularIndex(int index) + { + return index % _buffer.Length; + } + + private int Index(int i) + { + return i < 0 ? _buffer.Length + i : i; + } + + public virtual int RemoveLast() + { + AssertNotEmpty(); + _tail = CircularIndex(_tail - 1); + return Erase(_tail); + } + + private void AssertNotEmpty() + { + if (IsEmpty()) + { + throw new InvalidOperationException(); + } + } + + public virtual bool IsEmpty() + { + return Index(_head) == Index(_tail); + } + + public virtual bool IsFull() + { + return CircularIndex(_head - 1) == _tail; + } + + public virtual int RemoveFirst() + { + AssertNotEmpty(); + int erased = Erase(_head); + _head = CircularIndex(_head + 1); + return erased; + } + + private int Erase(int index) + { + int bufferIndex = Index(index); + int erasedValue = _buffer[bufferIndex]; + _buffer[bufferIndex] = Empty; + return erasedValue; + } + + public virtual bool Remove(int value) + { + int idx = IndexOf(value); + if (idx >= 0) + { + RemoveAt(idx); + return true; + } + return false; + } + + public virtual bool Contains(int value) + { + return IndexOf(value) >= 0; + } + + private int IndexOf(int value) + { + int current = Index(_head); + int tail = Index(_tail); + while (current != tail) + { + if (value == _buffer[current]) + { + break; + } + current = CircularIndex(current + 1); + } + return (current == tail ? -1 : current); + } + + private void RemoveAt(int index) + { + if (Index(_tail - 1) == index) + { + RemoveLast(); + return; + } + if (index == Index(_head)) + { + RemoveFirst(); + return; + } + int current = index; + int tail = Index(_tail); + while (current != tail) + { + int next = CircularIndex(current + 1); + _buffer[current] = _buffer[next]; + current = next; + } + _tail = CircularIndex(_tail - 1); + } + + public virtual IEnumerator GetEnumerator() + { + int tail = Index(_tail); + int head = Index(_head); + // TODO: detect concurrent modification and throw IllegalStateException + return new _IEnumerator_123(this, head, tail); + } + + private sealed class _IEnumerator_123 : IEnumerator + { + public _IEnumerator_123(CircularIntBuffer4 _enclosing, int head, int tail) + { + this._enclosing = _enclosing; + this.head = head; + this.tail = tail; + this._index = head; + this._current = Iterators.NoElement; + } + + private int _index; + + private object _current; + + public object Current + { + get + { + if (this._current == Iterators.NoElement) + { + throw new InvalidOperationException(); + } + return this._current; + } + } + + public bool MoveNext() + { + if (this._index == tail) + { + return false; + } + this._current = this._enclosing._buffer[this._index]; + this._index = this._enclosing.CircularIndex(this._index + 1); + return true; + } + + public void Reset() + { + throw new NotImplementedException(); + } + + private readonly CircularIntBuffer4 _enclosing; + + private readonly int head; + + private readonly int tail; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/CircularLongBuffer4.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/CircularLongBuffer4.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/CircularLongBuffer4.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/CircularLongBuffer4.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,207 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using System.Collections; +using Db4objects.Db4o.Foundation; + +namespace Db4objects.Db4o.Foundation +{ + /// A fixed size double ended queue with O(1) complexity for addFirst, removeFirst and removeLast operations. + /// + /// A fixed size double ended queue with O(1) complexity for addFirst, removeFirst and removeLast operations. + /// + public class CircularLongBuffer4 : IEnumerable + { + private const int Empty = -1; + + private readonly long[] _buffer; + + private int _head; + + private int _tail; + + public CircularLongBuffer4(int size) + { + _buffer = new long[size + 1]; + } + + public virtual int Size() + { + return Index(_tail - _head); + } + + public virtual void AddFirst(long value) + { + int newHead = CircularIndex(_head - 1); + if (newHead == _tail) + { + throw new InvalidOperationException(); + } + _head = newHead; + _buffer[Index(_head)] = value; + } + + private int CircularIndex(int index) + { + return index % _buffer.Length; + } + + private int Index(int i) + { + return i < 0 ? _buffer.Length + i : i; + } + + public virtual long RemoveLast() + { + AssertNotEmpty(); + _tail = CircularIndex(_tail - 1); + return Erase(_tail); + } + + private void AssertNotEmpty() + { + if (IsEmpty()) + { + throw new InvalidOperationException(); + } + } + + public virtual bool IsEmpty() + { + return Index(_head) == Index(_tail); + } + + public virtual bool IsFull() + { + return CircularIndex(_head - 1) == _tail; + } + + public virtual long RemoveFirst() + { + AssertNotEmpty(); + long erased = Erase(_head); + _head = CircularIndex(_head + 1); + return erased; + } + + private long Erase(int index) + { + int bufferIndex = Index(index); + long erasedValue = _buffer[bufferIndex]; + _buffer[bufferIndex] = Empty; + return erasedValue; + } + + public virtual bool Remove(long value) + { + int idx = IndexOf(value); + if (idx >= 0) + { + RemoveAt(idx); + return true; + } + return false; + } + + public virtual bool Contains(long value) + { + return IndexOf(value) >= 0; + } + + private int IndexOf(long value) + { + int current = Index(_head); + int tail = Index(_tail); + while (current != tail) + { + if (value == _buffer[current]) + { + break; + } + current = CircularIndex(current + 1); + } + return (current == tail ? -1 : current); + } + + private void RemoveAt(int index) + { + if (Index(_tail - 1) == index) + { + RemoveLast(); + return; + } + if (index == Index(_head)) + { + RemoveFirst(); + return; + } + int current = index; + int tail = Index(_tail); + while (current != tail) + { + int next = CircularIndex(current + 1); + _buffer[current] = _buffer[next]; + current = next; + } + _tail = CircularIndex(_tail - 1); + } + + public virtual IEnumerator GetEnumerator() + { + int tail = Index(_tail); + int head = Index(_head); + // TODO: detect concurrent modification and throw IllegalStateException + return new _IEnumerator_122(this, head, tail); + } + + private sealed class _IEnumerator_122 : IEnumerator + { + public _IEnumerator_122(CircularLongBuffer4 _enclosing, int head, int tail) + { + this._enclosing = _enclosing; + this.head = head; + this.tail = tail; + this._index = head; + this._current = Iterators.NoElement; + } + + private int _index; + + private object _current; + + public object Current + { + get + { + if (this._current == Iterators.NoElement) + { + throw new InvalidOperationException(); + } + return this._current; + } + } + + public bool MoveNext() + { + if (this._index == tail) + { + return false; + } + this._current = this._enclosing._buffer[this._index]; + this._index = this._enclosing.CircularIndex(this._index + 1); + return true; + } + + public void Reset() + { + throw new NotImplementedException(); + } + + private readonly CircularLongBuffer4 _enclosing; + + private readonly int head; + + private readonly int tail; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/Collection4.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/Collection4.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/Collection4.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/Collection4.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,450 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using System.Collections; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Types; + +namespace Db4objects.Db4o.Foundation +{ + /// Fast linked list for all usecases. + /// Fast linked list for all usecases. + /// + public class Collection4 : ISequence4, IEnumerable, IDeepClone, IUnversioned + { + private List4 _first; + + private List4 _last; + + private int _size; + + private int _version; + + public Collection4() + { + } + + public Collection4(object[] elements) + { + AddAll(elements); + } + + public Collection4(IEnumerable other) + { + AddAll(other); + } + + public Collection4(IEnumerator iterator) + { + AddAll(iterator); + } + + public virtual object SingleElement() + { + if (Size() != 1) + { + throw new InvalidOperationException(); + } + return ((object)_first._element); + } + + /// Adds an element to the end of this collection. + /// Adds an element to the end of this collection. + /// + public bool Add(object element) + { + DoAdd(element); + Changed(); + return true; + } + + public void Prepend(object element) + { + DoPrepend(element); + Changed(); + } + + private void DoPrepend(object element) + { + if (_first == null) + { + DoAdd(element); + } + else + { + _first = new List4(_first, element); + _size++; + } + } + + private void DoAdd(object element) + { + if (_last == null) + { + _first = new List4(element); + _last = _first; + } + else + { + _last._next = new List4(element); + _last = ((List4)_last._next); + } + _size++; + } + + public void AddAll(object[] elements) + { + AssertNotNull(elements); + for (int i = 0; i < elements.Length; i++) + { + Add(elements[i]); + } + } + + public void AddAll(IEnumerable other) + { + AssertNotNull(other); + AddAll(other.GetEnumerator()); + } + + public void AddAll(IEnumerator iterator) + { + AssertNotNull(iterator); + while (iterator.MoveNext()) + { + Add(iterator.Current); + } + } + + public void Clear() + { + _first = null; + _last = null; + _size = 0; + Changed(); + } + + public bool Contains(object element) + { + return Find(element) != null; + } + + public virtual bool ContainsAll(IEnumerable iter) + { + return ContainsAll(iter.GetEnumerator()); + } + + public virtual bool ContainsAll(IEnumerator iter) + { + AssertNotNull(iter); + while (iter.MoveNext()) + { + if (!Contains(iter.Current)) + { + return false; + } + } + return true; + } + + /// tests if the object is in the Collection. + /// tests if the object is in the Collection. == comparison. + public bool ContainsByIdentity(object element) + { + IEnumerator i = InternalIterator(); + while (i.MoveNext()) + { + object current = i.Current; + if (current == element) + { + return true; + } + } + return false; + } + + private List4 Find(object obj) + { + List4 current = _first; + while (current != null) + { + if (current.Holds(obj)) + { + return current; + } + current = ((List4)current._next); + } + return null; + } + + private List4 FindByIdentity(object obj) + { + List4 current = _first; + while (current != null) + { + if (((object)current._element) == obj) + { + return current; + } + current = ((List4)current._next); + } + return null; + } + + /// + /// returns the first object found in the Collections that equals() the + /// passed object + /// + public object Get(object element) + { + List4 holder = Find(element); + return holder == null ? null : ((object)holder._element); + } + + public virtual object DeepClone(object newParent) + { + Db4objects.Db4o.Foundation.Collection4 col = new Db4objects.Db4o.Foundation.Collection4 + (); + object element = null; + IEnumerator i = InternalIterator(); + while (i.MoveNext()) + { + element = i.Current; + if (element is IDeepClone) + { + col.Add(((IDeepClone)element).DeepClone(newParent)); + } + else + { + col.Add(element); + } + } + return col; + } + + /// makes sure the passed object is in the Collection. + /// makes sure the passed object is in the Collection. equals() comparison. + public object Ensure(object element) + { + List4 list = Find(element); + if (list == null) + { + Add(element); + return element; + } + return ((object)list._element); + } + + /// + /// Iterates through the collection in reversed insertion order which happens + /// to be the fastest. + /// + /// + /// Iterates through the collection in reversed insertion order which happens + /// to be the fastest. + /// + /// + public IEnumerator GetEnumerator() + { + return _first == null ? Iterators.EmptyIterator : new Collection4Iterator(this, _first + ); + } + + public virtual object Get(int index) + { + if (index < 0) + { + throw new ArgumentException(); + } + List4 cur = _first; + while (index > 0 && cur != null) + { + cur = ((List4)cur._next); + index--; + } + if (cur == null) + { + throw new ArgumentException(); + } + return ((object)cur._element); + } + + /// + /// Removes all the elements from this collection that are returned by + /// iterable. + /// + /// + /// Removes all the elements from this collection that are returned by + /// iterable. + /// + /// + public virtual void RemoveAll(IEnumerable iterable) + { + RemoveAll(iterable.GetEnumerator()); + } + + /// + /// Removes all the elements from this collection that are returned by + /// iterator. + /// + /// + /// Removes all the elements from this collection that are returned by + /// iterator. + /// + public virtual void RemoveAll(IEnumerator iterator) + { + while (iterator.MoveNext()) + { + Remove(iterator.Current); + } + } + + /// + /// removes an object from the Collection equals() comparison returns the + /// removed object or null, if none found + /// + public virtual bool Remove(object a_object) + { + List4 previous = null; + List4 current = _first; + while (current != null) + { + if (current.Holds(a_object)) + { + _size--; + AdjustOnRemoval(previous, current); + Changed(); + return true; + } + previous = current; + current = ((List4)current._next); + } + return false; + } + + public virtual void Replace(object oldObject, object newObject) + { + List4 list = Find(oldObject); + if (list != null) + { + list._element = newObject; + } + } + + public virtual void ReplaceByIdentity(object oldObject, object newObject) + { + List4 list = FindByIdentity(oldObject); + if (list != null) + { + list._element = newObject; + } + } + + private void AdjustOnRemoval(List4 previous, List4 removed) + { + if (removed == _first) + { + _first = ((List4)removed._next); + } + else + { + previous._next = ((List4)removed._next); + } + if (removed == _last) + { + _last = previous; + } + } + + public int Size() + { + return _size; + } + + public virtual int IndexOf(object obj) + { + int index = 0; + List4 current = _first; + while (current != null) + { + if (current.Holds(obj)) + { + return index; + } + index++; + current = ((List4)current._next); + } + return -1; + } + + public bool IsEmpty() + { + return _size == 0; + } + + /// This is a non reflection implementation for more speed. + /// + /// This is a non reflection implementation for more speed. In contrast to + /// the JDK behaviour, the passed array has to be initialized to the right + /// length. + /// + public object[] ToArray(object[] array) + { + int j = 0; + IEnumerator i = InternalIterator(); + while (i.MoveNext()) + { + array[j++] = i.Current; + } + return array; + } + + public object[] ToArray() + { + int j = 0; + object[] array = new object[Size()]; + IEnumerator i = InternalIterator(); + while (i.MoveNext()) + { + array[j++] = i.Current; + } + return array; + } + + public override string ToString() + { + return Iterators.ToString(InternalIterator()); + } + + private void Changed() + { + ++_version; + } + + internal virtual int Version() + { + return _version; + } + + private void AssertNotNull(object element) + { + if (element == null) + { + throw new ArgumentNullException(); + } + } + + /// + /// Leaner iterator for faster iteration (but unprotected against + /// concurrent modifications). + /// + /// + /// Leaner iterator for faster iteration (but unprotected against + /// concurrent modifications). + /// + private IEnumerator InternalIterator() + { + return new Iterator4Impl(_first); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/Collection4Iterator.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/Collection4Iterator.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/Collection4Iterator.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/Collection4Iterator.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,49 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Foundation; + +namespace Db4objects.Db4o.Foundation +{ + /// + public class Collection4Iterator : Iterator4Impl + { + private readonly Collection4 _collection; + + private readonly int _initialVersion; + + public Collection4Iterator(Collection4 collection, List4 first) : base(first) + { + _collection = collection; + _initialVersion = CurrentVersion(); + } + + public override bool MoveNext() + { + Validate(); + return base.MoveNext(); + } + + public override object Current + { + get + { + Validate(); + return base.Current; + } + } + + private void Validate() + { + if (_initialVersion != CurrentVersion()) + { + // FIXME: change to ConcurrentModificationException + throw new InvalidIteratorException(); + } + } + + private int CurrentVersion() + { + return _collection.Version(); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/Collections4.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/Collections4.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/Collections4.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/Collections4.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,86 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using System.Collections; +using Db4objects.Db4o.Foundation; + +namespace Db4objects.Db4o.Foundation +{ + public class Collections4 + { + public static ISequence4 UnmodifiableList(ISequence4 orig) + { + return new Collections4.UnmodifiableSequence4(orig); + } + + private class UnmodifiableSequence4 : ISequence4 + { + private ISequence4 _sequence; + + public UnmodifiableSequence4(ISequence4 sequence) + { + _sequence = sequence; + } + + public virtual bool Add(object element) + { + throw new NotSupportedException(); + } + + public virtual void AddAll(IEnumerable iterable) + { + throw new NotSupportedException(); + } + + public virtual bool IsEmpty() + { + return _sequence.IsEmpty(); + } + + public virtual IEnumerator GetEnumerator() + { + return _sequence.GetEnumerator(); + } + + public virtual object Get(int index) + { + return _sequence.Get(index); + } + + public virtual int Size() + { + return _sequence.Size(); + } + + public virtual void Clear() + { + throw new NotSupportedException(); + } + + public virtual bool Remove(object obj) + { + throw new NotSupportedException(); + } + + public virtual bool Contains(object obj) + { + return _sequence.Contains(obj); + } + + public virtual bool ContainsAll(IEnumerable iter) + { + return _sequence.ContainsAll(iter); + } + + public virtual object[] ToArray() + { + return _sequence.ToArray(); + } + + public virtual object[] ToArray(object[] array) + { + return _sequence.ToArray(array); + } + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/CompositeIterable4.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/CompositeIterable4.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/CompositeIterable4.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/CompositeIterable4.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,34 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System.Collections; +using Db4objects.Db4o.Foundation; + +namespace Db4objects.Db4o.Foundation +{ + public class CompositeIterable4 : IEnumerable + { + private readonly IEnumerable _iterables; + + public CompositeIterable4(IEnumerable iterables) + { + _iterables = iterables; + } + + public virtual IEnumerator GetEnumerator() + { + return new _CompositeIterator4_15(_iterables.GetEnumerator()); + } + + private sealed class _CompositeIterator4_15 : CompositeIterator4 + { + public _CompositeIterator4_15(IEnumerator baseArg1) : base(baseArg1) + { + } + + protected override IEnumerator NextIterator(object current) + { + return ((IEnumerable)current).GetEnumerator(); + } + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/CompositeIterator4.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/CompositeIterator4.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/CompositeIterator4.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/CompositeIterator4.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,81 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using System.Collections; +using Db4objects.Db4o.Foundation; + +namespace Db4objects.Db4o.Foundation +{ + public class CompositeIterator4 : IEnumerator + { + protected readonly IEnumerator _iterators; + + protected IEnumerator _currentIterator; + + public CompositeIterator4(IEnumerator[] iterators) : this(new ArrayIterator4(iterators + )) + { + } + + public CompositeIterator4(IEnumerator iterators) + { + if (null == iterators) + { + throw new ArgumentNullException(); + } + _iterators = iterators; + } + + public virtual bool MoveNext() + { + if (null == _currentIterator) + { + if (!_iterators.MoveNext()) + { + return false; + } + _currentIterator = NextIterator(_iterators.Current); + } + if (!_currentIterator.MoveNext()) + { + _currentIterator = null; + return MoveNext(); + } + return true; + } + + public virtual void Reset() + { + ResetIterators(); + _currentIterator = null; + _iterators.Reset(); + } + + private void ResetIterators() + { + _iterators.Reset(); + while (_iterators.MoveNext()) + { + NextIterator(_iterators.Current).Reset(); + } + } + + public virtual IEnumerator CurrentIterator() + { + return _currentIterator; + } + + public virtual object Current + { + get + { + return _currentIterator.Current; + } + } + + protected virtual IEnumerator NextIterator(object current) + { + return (IEnumerator)current; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/DelegatingBlockingQueue.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/DelegatingBlockingQueue.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/DelegatingBlockingQueue.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/DelegatingBlockingQueue.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,58 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System.Collections; +using Db4objects.Db4o.Foundation; + +namespace Db4objects.Db4o.Foundation +{ + public class DelegatingBlockingQueue : IBlockingQueue4 + { + private IBlockingQueue4 queue; + + /// + public virtual object Next(long timeout) + { + return queue.Next(timeout); + } + + public virtual object Next() + { + return queue.Next(); + } + + public virtual void Add(object obj) + { + queue.Add(obj); + } + + public virtual bool HasNext() + { + return queue.HasNext(); + } + + public virtual object NextMatching(IPredicate4 condition) + { + return queue.NextMatching(condition); + } + + public virtual IEnumerator Iterator() + { + return queue.Iterator(); + } + + public DelegatingBlockingQueue(IBlockingQueue4 queue) + { + this.queue = queue; + } + + public virtual void Stop() + { + queue.Stop(); + } + + public virtual int DrainTo(Collection4 list) + { + return queue.DrainTo(list); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/DynamicVariable.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/DynamicVariable.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/DynamicVariable.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/DynamicVariable.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,71 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Foundation; +using Sharpen.Lang; + +namespace Db4objects.Db4o.Foundation +{ + /// A dynamic variable is a value associated to a specific thread and scope. + /// + /// + /// A dynamic variable is a value associated to a specific thread and scope. + /// The value is brought into scope with the + /// With(object, IClosure4) + /// method. + /// + public class DynamicVariable + { + public static DynamicVariable NewInstance() + { + return new DynamicVariable(); + } + + private readonly ThreadLocal _value = new ThreadLocal(); + + public virtual object Value + { + get + { + object value = _value.Get(); + return value == null ? DefaultValue() : value; + } + set + { + _value.Set(value); + } + } + + protected virtual object DefaultValue() + { + return null; + } + + public virtual object With(object value, IClosure4 block) + { + object previous = _value.Get(); + _value.Set(value); + try + { + return block.Run(); + } + finally + { + _value.Set(previous); + } + } + + public virtual void With(object value, IRunnable block) + { + object previous = _value.Get(); + _value.Set(value); + try + { + block.Run(); + } + finally + { + _value.Set(previous); + } + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/EnumerateIterator.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/EnumerateIterator.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/EnumerateIterator.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/EnumerateIterator.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,45 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System.Collections; +using Db4objects.Db4o.Foundation; + +namespace Db4objects.Db4o.Foundation +{ + public class EnumerateIterator : MappingIterator + { + public sealed class Tuple + { + public readonly int index; + + public readonly object value; + + public Tuple(int index_, object value_) + { + index = index_; + value = value_; + } + } + + private int _index; + + public EnumerateIterator(IEnumerator iterator) : base(iterator) + { + _index = 0; + } + + public override bool MoveNext() + { + if (base.MoveNext()) + { + ++_index; + return true; + } + return false; + } + + protected override object Map(object current) + { + return new EnumerateIterator.Tuple(_index, current); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/Environments.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/Environments.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/Environments.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/Environments.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,165 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using System.Collections; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal; +using Sharpen.Lang; + +namespace Db4objects.Db4o.Foundation +{ + public partial class Environments + { + private static readonly DynamicVariable _current = DynamicVariable.NewInstance(); + + public static object My(Type service) + { + IEnvironment environment = Current(); + if (null == environment) + { + throw new InvalidOperationException(); + } + return environment.Provide(service); + } + + private static IEnvironment Current() + { + return ((IEnvironment)_current.Value); + } + + public static void RunWith(IEnvironment environment, IRunnable runnable) + { + _current.With(environment, runnable); + } + + public static IEnvironment NewClosedEnvironment(object[] bindings) + { + return new _IEnvironment_32(bindings); + } + + private sealed class _IEnvironment_32 : IEnvironment + { + public _IEnvironment_32(object[] bindings) + { + this.bindings = bindings; + } + + public object Provide(Type service) + { + for (int bindingIndex = 0; bindingIndex < bindings.Length; ++bindingIndex) + { + object binding = bindings[bindingIndex]; + if (service.IsInstanceOfType(binding)) + { + return (object)binding; + } + } + return null; + } + + private readonly object[] bindings; + } + + public static IEnvironment NewCachingEnvironmentFor(IEnvironment environment) + { + return new _IEnvironment_48(environment); + } + + private sealed class _IEnvironment_48 : IEnvironment + { + public _IEnvironment_48(IEnvironment environment) + { + this.environment = environment; + this._bindings = new Hashtable(); + } + + private readonly IDictionary _bindings; + + public object Provide(Type service) + { + object existing = this._bindings[service]; + if (null != existing) + { + return (object)existing; + } + object binding = environment.Provide(service); + if (null == binding) + { + return null; + } + this._bindings[service] = binding; + return binding; + } + + private readonly IEnvironment environment; + } + + public static IEnvironment NewConventionBasedEnvironment(object[] bindings) + { + return NewCachingEnvironmentFor(Compose(new IEnvironment[] { NewClosedEnvironment + (bindings), new Environments.ConventionBasedEnvironment() })); + } + + public static IEnvironment NewConventionBasedEnvironment() + { + return NewCachingEnvironmentFor(new Environments.ConventionBasedEnvironment()); + } + + public static IEnvironment Compose(IEnvironment[] environments) + { + return new _IEnvironment_75(environments); + } + + private sealed class _IEnvironment_75 : IEnvironment + { + public _IEnvironment_75(IEnvironment[] environments) + { + this.environments = environments; + } + + public object Provide(Type service) + { + for (int eIndex = 0; eIndex < environments.Length; ++eIndex) + { + IEnvironment e = environments[eIndex]; + object binding = e.Provide(service); + if (null != binding) + { + return binding; + } + } + return null; + } + + private readonly IEnvironment[] environments; + } + + private sealed class ConventionBasedEnvironment : IEnvironment + { + public object Provide(Type service) + { + return Resolve(service); + } + + /// + /// Resolves a service interface to its default implementation using the + /// db4o namespace convention: + /// interface foo.bar.Baz + /// default implementation foo.internal.bar.BazImpl + /// + /// the convention based type name for the requested service + private object Resolve(Type service) + { + string className = DefaultImplementationFor(service); + object binding = ReflectPlatform.CreateInstance(className); + if (null == binding) + { + throw new ArgumentException("Cant find default implementation for " + service.ToString + () + ": " + className); + } + return (object)binding; + } + } + // ignore convention for internal types + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/FilteredIterator.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/FilteredIterator.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/FilteredIterator.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/FilteredIterator.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,23 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System.Collections; +using Db4objects.Db4o.Foundation; + +namespace Db4objects.Db4o.Foundation +{ + public class FilteredIterator : MappingIterator + { + private readonly IPredicate4 _filter; + + public FilteredIterator(IEnumerator iterator, IPredicate4 filter) : base(iterator + ) + { + _filter = filter; + } + + protected override object Map(object current) + { + return _filter.Match(current) ? current : Iterators.Skip; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/FlatteningIterator.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/FlatteningIterator.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/FlatteningIterator.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/FlatteningIterator.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,74 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System.Collections; +using Db4objects.Db4o.Foundation; + +namespace Db4objects.Db4o.Foundation +{ + public class FlatteningIterator : CompositeIterator4 + { + private class IteratorStack + { + public readonly IEnumerator iterator; + + public readonly FlatteningIterator.IteratorStack next; + + public IteratorStack(IEnumerator iterator_, FlatteningIterator.IteratorStack next_ + ) + { + iterator = iterator_; + next = next_; + } + } + + private FlatteningIterator.IteratorStack _stack; + + public FlatteningIterator(IEnumerator iterators) : base(iterators) + { + } + + public override bool MoveNext() + { + if (null == _currentIterator) + { + if (null == _stack) + { + _currentIterator = _iterators; + } + else + { + _currentIterator = Pop(); + } + } + if (!_currentIterator.MoveNext()) + { + if (_currentIterator == _iterators) + { + return false; + } + _currentIterator = null; + return MoveNext(); + } + object current = _currentIterator.Current; + if (current is IEnumerator) + { + Push(_currentIterator); + _currentIterator = NextIterator(current); + return MoveNext(); + } + return true; + } + + private void Push(IEnumerator currentIterator) + { + _stack = new FlatteningIterator.IteratorStack(currentIterator, _stack); + } + + private IEnumerator Pop() + { + IEnumerator iterator = _stack.iterator; + _stack = _stack.next; + return iterator; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/FunctionApplicationIterator.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/FunctionApplicationIterator.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/FunctionApplicationIterator.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/FunctionApplicationIterator.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,29 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using System.Collections; +using Db4objects.Db4o.Foundation; + +namespace Db4objects.Db4o.Foundation +{ + /// + public class FunctionApplicationIterator : MappingIterator + { + private readonly IFunction4 _function; + + public FunctionApplicationIterator(IEnumerator iterator, IFunction4 function) : base + (iterator) + { + if (null == function) + { + throw new ArgumentNullException(); + } + _function = function; + } + + protected override object Map(object current) + { + return _function.Apply(current); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/HashSet4.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/HashSet4.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/HashSet4.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/HashSet4.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,66 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System.Collections; +using Db4objects.Db4o.Foundation; + +namespace Db4objects.Db4o.Foundation +{ + public class HashSet4 : ISet4 + { + private Hashtable4 _map; + + public HashSet4() : this(1) + { + } + + public HashSet4(int count) + { + _map = new Hashtable4(count); + } + + public virtual bool Add(object obj) + { + if (_map.ContainsKey(obj)) + { + return false; + } + _map.Put(obj, obj); + return true; + } + + public virtual void Clear() + { + _map.Clear(); + } + + public virtual bool Contains(object obj) + { + return _map.ContainsKey(obj); + } + + public virtual bool IsEmpty() + { + return _map.Size() == 0; + } + + public virtual IEnumerator GetEnumerator() + { + return _map.Values().GetEnumerator(); + } + + public virtual bool Remove(object obj) + { + return _map.Remove(obj) != null; + } + + public virtual int Size() + { + return _map.Size(); + } + + public override string ToString() + { + return Iterators.Join(_map.Keys(), "{", "}", ", "); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/Hashtable4.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/Hashtable4.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/Hashtable4.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/Hashtable4.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,231 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using System.Collections; +using Db4objects.Db4o.Foundation; + +namespace Db4objects.Db4o.Foundation +{ + /// + public class Hashtable4 : HashtableBase, IDeepClone, IMap4 + { + public Hashtable4(int size) : base(size) + { + } + + public Hashtable4() : this(1) + { + } + + /// + protected Hashtable4(IDeepClone cloneOnlyCtor) : base(cloneOnlyCtor) + { + } + + public virtual object DeepClone(object obj) + { + return DeepCloneInternal(new Db4objects.Db4o.Foundation.Hashtable4((IDeepClone)null + ), obj); + } + + public virtual void ForEachKeyForIdentity(IVisitor4 visitor, object obj) + { + for (int i = 0; i < _table.Length; i++) + { + HashtableIntEntry entry = _table[i]; + while (entry != null) + { + if (entry._object == obj) + { + visitor.Visit(entry.Key()); + } + entry = entry._next; + } + } + } + + public virtual object Get(byte[] key) + { + int intKey = HashtableByteArrayEntry.Hash(key); + return GetFromObjectEntry(intKey, key); + } + + public virtual object Get(int key) + { + HashtableIntEntry entry = _table[key & _mask]; + while (entry != null) + { + if (entry._key == key) + { + return entry._object; + } + entry = entry._next; + } + return null; + } + + public virtual object Get(object key) + { + if (key == null) + { + return null; + } + return GetFromObjectEntry(key.GetHashCode(), key); + } + + public virtual object Get(long key) + { + return GetFromLongEntry((int)key, key); + } + + public virtual bool ContainsKey(object key) + { + if (null == key) + { + return false; + } + return null != GetObjectEntry(key.GetHashCode(), key); + } + + public virtual bool ContainsAllKeys(IEnumerable collection) + { + return ContainsAllKeys(collection.GetEnumerator()); + } + + public virtual bool ContainsAllKeys(IEnumerator iterator) + { + while (iterator.MoveNext()) + { + if (!ContainsKey(iterator.Current)) + { + return false; + } + } + return true; + } + + public virtual void Put(byte[] key, object value) + { + PutEntry(new HashtableByteArrayEntry(key, value)); + } + + public virtual void Put(int key, object value) + { + PutEntry(new HashtableIntEntry(key, value)); + } + + public virtual void Put(long key, object value) + { + PutEntry(new HashtableLongEntry(key, value)); + } + + public virtual void Put(object key, object value) + { + if (null == key) + { + throw new ArgumentNullException(); + } + PutEntry(new HashtableObjectEntry(key, value)); + } + + public virtual object Remove(object objectKey) + { + int intKey = objectKey.GetHashCode(); + return RemoveObjectEntry(intKey, objectKey); + } + + public virtual object Remove(long longKey) + { + return RemoveLongEntry((int)longKey, longKey); + } + + public virtual object Remove(byte[] key) + { + int intKey = HashtableByteArrayEntry.Hash(key); + return RemoveObjectEntry(intKey, key); + } + + public virtual object Remove(int key) + { + return RemoveIntEntry(key); + } + + /// + /// Iterates through all the + /// entries + /// . + /// + /// + /// + /// IEntry4 + /// iterator + /// + /// HashtableBase.Values() + /// + /// #see + /// HashtableBase.ValuesIterator() + /// + public virtual IEnumerator Iterator() + { + return HashtableIterator(); + } + + protected virtual Db4objects.Db4o.Foundation.Hashtable4 DeepCloneInternal(Db4objects.Db4o.Foundation.Hashtable4 + ret, object obj) + { + ret._mask = _mask; + ret._maximumSize = _maximumSize; + ret._size = _size; + ret._tableSize = _tableSize; + ret._table = new HashtableIntEntry[_tableSize]; + for (int i = 0; i < _tableSize; i++) + { + if (_table[i] != null) + { + ret._table[i] = (HashtableIntEntry)_table[i].DeepClone(obj); + } + } + return ret; + } + + private object GetFromObjectEntry(int intKey, object objectKey) + { + HashtableObjectEntry entry = GetObjectEntry(intKey, objectKey); + return entry == null ? null : entry._object; + } + + private HashtableObjectEntry GetObjectEntry(int intKey, object objectKey) + { + HashtableObjectEntry entry = (HashtableObjectEntry)_table[intKey & _mask]; + while (entry != null) + { + if (entry._key == intKey && entry.HasKey(objectKey)) + { + return entry; + } + entry = (HashtableObjectEntry)entry._next; + } + return null; + } + + private object GetFromLongEntry(int intKey, long longKey) + { + HashtableLongEntry entry = GetLongEntry(intKey, longKey); + return entry == null ? null : entry._object; + } + + private HashtableLongEntry GetLongEntry(int intKey, long longKey) + { + HashtableLongEntry entry = (HashtableLongEntry)_table[intKey & _mask]; + while (entry != null) + { + if (entry._key == intKey && entry._longKey == longKey) + { + return entry; + } + entry = (HashtableLongEntry)entry._next; + } + return null; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/HashtableBase.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/HashtableBase.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/HashtableBase.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/HashtableBase.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,284 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System.Collections; +using Db4objects.Db4o.Foundation; + +namespace Db4objects.Db4o.Foundation +{ + /// + public class HashtableBase + { + private const float Fill = 0.5F; + + public int _tableSize; + + public int _mask; + + public int _maximumSize; + + public int _size; + + public HashtableIntEntry[] _table; + + public HashtableBase(int size) + { + // FIELDS ARE PUBLIC SO THEY CAN BE REFLECTED ON IN JDKs <= 1.1 + size = NewSize(size); + // legacy for .NET conversion + _tableSize = 1; + while (_tableSize < size) + { + _tableSize = _tableSize << 1; + } + _mask = _tableSize - 1; + _maximumSize = (int)(_tableSize * Fill); + _table = new HashtableIntEntry[_tableSize]; + } + + public HashtableBase() : this(1) + { + } + + /// + protected HashtableBase(IDeepClone cloneOnlyCtor) + { + } + + public virtual void Clear() + { + _size = 0; + Arrays4.Fill(_table, null); + } + + private int NewSize(int size) + { + return (int)(size / Fill); + } + + public virtual int Size() + { + return _size; + } + + protected virtual HashtableIntEntry FindWithSameKey(HashtableIntEntry newEntry) + { + HashtableIntEntry existing = _table[EntryIndex(newEntry)]; + while (null != existing) + { + if (existing.SameKeyAs(newEntry)) + { + return existing; + } + existing = existing._next; + } + return null; + } + + protected virtual int EntryIndex(HashtableIntEntry entry) + { + return entry._key & _mask; + } + + protected virtual void PutEntry(HashtableIntEntry newEntry) + { + HashtableIntEntry existing = FindWithSameKey(newEntry); + if (null != existing) + { + Replace(existing, newEntry); + } + else + { + Insert(newEntry); + } + } + + private void Insert(HashtableIntEntry newEntry) + { + _size++; + if (_size > _maximumSize) + { + IncreaseSize(); + } + int index = EntryIndex(newEntry); + newEntry._next = _table[index]; + _table[index] = newEntry; + } + + private void Replace(HashtableIntEntry existing, HashtableIntEntry newEntry) + { + newEntry._next = existing._next; + HashtableIntEntry entry = _table[EntryIndex(existing)]; + if (entry == existing) + { + _table[EntryIndex(existing)] = newEntry; + } + else + { + while (entry._next != existing) + { + entry = entry._next; + } + entry._next = newEntry; + } + } + + private void IncreaseSize() + { + _tableSize = _tableSize << 1; + _maximumSize = _maximumSize << 1; + _mask = _tableSize - 1; + HashtableIntEntry[] temp = _table; + _table = new HashtableIntEntry[_tableSize]; + for (int i = 0; i < temp.Length; i++) + { + Reposition(temp[i]); + } + } + + protected virtual Db4objects.Db4o.Foundation.HashtableIterator HashtableIterator( + ) + { + return new Db4objects.Db4o.Foundation.HashtableIterator(_table); + } + + private void Reposition(HashtableIntEntry entry) + { + HashtableIntEntry currentEntry = entry; + HashtableIntEntry nextEntry = null; + while (currentEntry != null) + { + nextEntry = currentEntry._next; + currentEntry._next = _table[EntryIndex(currentEntry)]; + _table[EntryIndex(currentEntry)] = currentEntry; + currentEntry = nextEntry; + } + } + + public virtual IEnumerator Keys() + { + return Iterators.Map(HashtableIterator(), new _IFunction4_133()); + } + + private sealed class _IFunction4_133 : IFunction4 + { + public _IFunction4_133() + { + } + + public object Apply(object current) + { + return ((IEntry4)current).Key(); + } + } + + public virtual IEnumerable Values() + { + return new _IEnumerable_141(this); + } + + private sealed class _IEnumerable_141 : IEnumerable + { + public _IEnumerable_141(HashtableBase _enclosing) + { + this._enclosing = _enclosing; + } + + public IEnumerator GetEnumerator() + { + return this._enclosing.ValuesIterator(); + } + + private readonly HashtableBase _enclosing; + } + + /// Iterates through all the values. + /// Iterates through all the values. + /// value iterator + public virtual IEnumerator ValuesIterator() + { + return Iterators.Map(HashtableIterator(), new _IFunction4_154()); + } + + private sealed class _IFunction4_154 : IFunction4 + { + public _IFunction4_154() + { + } + + public object Apply(object current) + { + return ((IEntry4)current).Value(); + } + } + + public override string ToString() + { + return Iterators.Join(HashtableIterator(), "{", "}", ", "); + } + + protected virtual void RemoveEntry(HashtableIntEntry predecessor, HashtableIntEntry + entry) + { + if (predecessor != null) + { + predecessor._next = entry._next; + } + else + { + _table[EntryIndex(entry)] = entry._next; + } + _size--; + } + + protected virtual object RemoveObjectEntry(int intKey, object objectKey) + { + HashtableObjectEntry entry = (HashtableObjectEntry)_table[intKey & _mask]; + HashtableObjectEntry predecessor = null; + while (entry != null) + { + if (entry._key == intKey && entry.HasKey(objectKey)) + { + RemoveEntry(predecessor, entry); + return entry._object; + } + predecessor = entry; + entry = (HashtableObjectEntry)entry._next; + } + return null; + } + + protected virtual object RemoveLongEntry(int intKey, long longKey) + { + HashtableLongEntry entry = (HashtableLongEntry)_table[intKey & _mask]; + HashtableLongEntry predecessor = null; + while (entry != null) + { + if (entry._key == intKey && entry._longKey == longKey) + { + RemoveEntry(predecessor, entry); + return entry._object; + } + predecessor = entry; + entry = (HashtableLongEntry)entry._next; + } + return null; + } + + protected virtual object RemoveIntEntry(int key) + { + HashtableIntEntry entry = _table[key & _mask]; + HashtableIntEntry predecessor = null; + while (entry != null) + { + if (entry._key == key) + { + RemoveEntry(predecessor, entry); + return entry._object; + } + predecessor = entry; + entry = entry._next; + } + return null; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/HashtableByteArrayEntry.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/HashtableByteArrayEntry.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/HashtableByteArrayEntry.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/HashtableByteArrayEntry.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,59 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Foundation; + +namespace Db4objects.Db4o.Foundation +{ + internal class HashtableByteArrayEntry : HashtableObjectEntry + { + public HashtableByteArrayEntry(byte[] bytes, object value) : base(Hash(bytes), bytes + , value) + { + } + + public HashtableByteArrayEntry() : base() + { + } + + public override object DeepClone(object obj) + { + return DeepCloneInternal(new Db4objects.Db4o.Foundation.HashtableByteArrayEntry() + , obj); + } + + public override bool HasKey(object key) + { + if (key is byte[]) + { + return AreEqual((byte[])Key(), (byte[])key); + } + return false; + } + + internal static int Hash(byte[] bytes) + { + int ret = 0; + for (int i = 0; i < bytes.Length; i++) + { + ret = ret * 31 + bytes[i]; + } + return ret; + } + + internal static bool AreEqual(byte[] lhs, byte[] rhs) + { + if (rhs.Length != lhs.Length) + { + return false; + } + for (int i = 0; i < rhs.Length; i++) + { + if (rhs[i] != lhs[i]) + { + return false; + } + } + return true; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/HashtableIdentityEntry.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/HashtableIdentityEntry.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/HashtableIdentityEntry.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/HashtableIdentityEntry.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,25 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Foundation; +using Sharpen; + +namespace Db4objects.Db4o.Foundation +{ + /// + public class HashtableIdentityEntry : HashtableIntEntry + { + public HashtableIdentityEntry(object obj) : base(Runtime.IdentityHashCode(obj), obj + ) + { + } + + public override bool SameKeyAs(HashtableIntEntry other) + { + if (!base.SameKeyAs(other)) + { + return false; + } + return other._object == _object; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/HashtableIntEntry.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/HashtableIntEntry.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/HashtableIntEntry.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/HashtableIntEntry.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,72 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Foundation; + +namespace Db4objects.Db4o.Foundation +{ + /// + public class HashtableIntEntry : IEntry4, IDeepClone + { + public int _key; + + public object _object; + + public Db4objects.Db4o.Foundation.HashtableIntEntry _next; + + internal HashtableIntEntry(int key, object obj) + { + // FIELDS ARE PUBLIC SO THEY CAN BE REFLECTED ON IN JDKs <= 1.1 + _key = key; + _object = obj; + } + + public HashtableIntEntry() + { + } + + public virtual object Key() + { + return _key; + } + + public virtual object Value() + { + return _object; + } + + public virtual object DeepClone(object obj) + { + return DeepCloneInternal(new Db4objects.Db4o.Foundation.HashtableIntEntry(), obj); + } + + public virtual bool SameKeyAs(Db4objects.Db4o.Foundation.HashtableIntEntry other) + { + return _key == other._key; + } + + protected virtual Db4objects.Db4o.Foundation.HashtableIntEntry DeepCloneInternal( + Db4objects.Db4o.Foundation.HashtableIntEntry entry, object obj) + { + entry._key = _key; + entry._next = _next; + if (_object is IDeepClone) + { + entry._object = ((IDeepClone)_object).DeepClone(obj); + } + else + { + entry._object = _object; + } + if (_next != null) + { + entry._next = (Db4objects.Db4o.Foundation.HashtableIntEntry)_next.DeepClone(obj); + } + return entry; + } + + public override string ToString() + { + return string.Empty + _key + ": " + _object; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/HashtableIterator.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/HashtableIterator.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/HashtableIterator.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/HashtableIterator.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,83 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using System.Collections; +using Db4objects.Db4o.Foundation; + +namespace Db4objects.Db4o.Foundation +{ + /// + public class HashtableIterator : IEnumerator + { + private readonly HashtableIntEntry[] _table; + + private HashtableIntEntry _currentEntry; + + private int _currentIndex; + + public HashtableIterator(HashtableIntEntry[] table) + { + _table = table; + Reset(); + } + + private void CheckInvalidTable() + { + if (_table == null || _table.Length == 0) + { + PositionBeyondLast(); + } + } + + public virtual object Current + { + get + { + if (_currentEntry == null) + { + throw new InvalidOperationException(); + } + return _currentEntry; + } + } + + public virtual bool MoveNext() + { + if (IsBeyondLast()) + { + return false; + } + if (_currentEntry != null) + { + _currentEntry = _currentEntry._next; + } + while (_currentEntry == null) + { + if (_currentIndex >= _table.Length) + { + PositionBeyondLast(); + return false; + } + _currentEntry = _table[_currentIndex++]; + } + return true; + } + + public virtual void Reset() + { + _currentEntry = null; + _currentIndex = 0; + CheckInvalidTable(); + } + + private bool IsBeyondLast() + { + return _currentIndex == -1; + } + + private void PositionBeyondLast() + { + _currentIndex = -1; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/HashtableLongEntry.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/HashtableLongEntry.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/HashtableLongEntry.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/HashtableLongEntry.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,51 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Foundation; + +namespace Db4objects.Db4o.Foundation +{ + /// + public class HashtableLongEntry : HashtableIntEntry + { + public long _longKey; + + internal HashtableLongEntry(long key, object obj) : base((int)key, obj) + { + // FIELDS ARE PUBLIC SO THEY CAN BE REFLECTED ON IN JDKs <= 1.1 + _longKey = key; + } + + public HashtableLongEntry() : base() + { + } + + public override object Key() + { + return _longKey; + } + + public override object DeepClone(object obj) + { + return DeepCloneInternal(new Db4objects.Db4o.Foundation.HashtableLongEntry(), obj + ); + } + + protected override HashtableIntEntry DeepCloneInternal(HashtableIntEntry entry, object + obj) + { + ((Db4objects.Db4o.Foundation.HashtableLongEntry)entry)._longKey = _longKey; + return base.DeepCloneInternal(entry, obj); + } + + public override bool SameKeyAs(HashtableIntEntry other) + { + return other is Db4objects.Db4o.Foundation.HashtableLongEntry ? ((Db4objects.Db4o.Foundation.HashtableLongEntry + )other)._longKey == _longKey : false; + } + + public override string ToString() + { + return string.Empty + _longKey + ": " + _object; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/HashtableObjectEntry.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/HashtableObjectEntry.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/HashtableObjectEntry.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/HashtableObjectEntry.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,63 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Foundation; + +namespace Db4objects.Db4o.Foundation +{ + /// + public class HashtableObjectEntry : HashtableIntEntry + { + public object _objectKey; + + internal HashtableObjectEntry(int a_hash, object a_key, object a_object) : base(a_hash + , a_object) + { + // FIELDS ARE PUBLIC SO THEY CAN BE REFLECTED ON IN JDKs <= 1.1 + _objectKey = a_key; + } + + internal HashtableObjectEntry(object a_key, object a_object) : base(a_key.GetHashCode + (), a_object) + { + _objectKey = a_key; + } + + public HashtableObjectEntry() : base() + { + } + + public override object Key() + { + return _objectKey; + } + + public override object DeepClone(object obj) + { + return DeepCloneInternal(new Db4objects.Db4o.Foundation.HashtableObjectEntry(), obj + ); + } + + protected override HashtableIntEntry DeepCloneInternal(HashtableIntEntry entry, object + obj) + { + ((Db4objects.Db4o.Foundation.HashtableObjectEntry)entry)._objectKey = _objectKey; + return base.DeepCloneInternal(entry, obj); + } + + public virtual bool HasKey(object key) + { + return _objectKey.Equals(key); + } + + public override bool SameKeyAs(HashtableIntEntry other) + { + return other is Db4objects.Db4o.Foundation.HashtableObjectEntry ? HasKey(((Db4objects.Db4o.Foundation.HashtableObjectEntry + )other)._objectKey) : false; + } + + public override string ToString() + { + return string.Empty + _objectKey + ": " + _object; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IArrayFactory.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IArrayFactory.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IArrayFactory.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IArrayFactory.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,9 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +namespace Db4objects.Db4o.Foundation +{ + public interface IArrayFactory + { + object[] NewArray(int size); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IBlock4.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IBlock4.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IBlock4.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IBlock4.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,9 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +namespace Db4objects.Db4o.Foundation +{ + public interface IBlock4 + { + void Run(); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IBlockingQueue4.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IBlockingQueue4.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IBlockingQueue4.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IBlockingQueue4.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,57 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Foundation; + +namespace Db4objects.Db4o.Foundation +{ + public interface IBlockingQueue4 : IQueue4 + { + /// + ///

+ /// Returns the next queued item or waits for it to be available for the + /// maximum of timeout miliseconds. + ///

+ /// + ///

+ /// Returns the next queued item or waits for it to be available for the + /// maximum of timeout miliseconds. + /// + /// maximum time to wait for the next avilable item in miliseconds + /// + /// + /// the next item or null if timeout is + /// reached + /// + /// + /// if the + /// Stop() + /// is called. + /// + /// + object Next(long timeout); + + void Stop(); + + ///

+ ///

+ /// Removes all the available elements in the queue to the colletion passed + /// as argument. + ///

+ /// + ///

+ /// Removes all the available elements in the queue to the colletion passed + /// as argument. + ///

+ /// It will block until at least one element is available. + /// + /// + /// the number of elements added to the list. + /// + /// if the + /// Stop() + /// is called. + /// + /// + int DrainTo(Collection4 list); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/ICancellableVisitor4.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/ICancellableVisitor4.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/ICancellableVisitor4.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/ICancellableVisitor4.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,10 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +namespace Db4objects.Db4o.Foundation +{ + public interface ICancellableVisitor4 + { + /// true to continue traversal, false otherwise + bool Visit(object obj); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IClosure4.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IClosure4.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IClosure4.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IClosure4.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,9 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +namespace Db4objects.Db4o.Foundation +{ + public interface IClosure4 + { + object Run(); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IComparison4.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IComparison4.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IComparison4.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IComparison4.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,15 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +namespace Db4objects.Db4o.Foundation +{ + /// + public interface IComparison4 + { + ///

+ /// Returns negative number if x < y + /// Returns zero if x == y + /// Returns positive number if x > y + /// + int Compare(object x, object y); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IDeepClone.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IDeepClone.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IDeepClone.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IDeepClone.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,19 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +namespace Db4objects.Db4o.Foundation +{ + /// Deep clone + /// + public interface IDeepClone + { + /// + /// The parameter allows passing one new object so parent + /// references can be corrected on children. + /// + /// + /// The parameter allows passing one new object so parent + /// references can be corrected on children. + /// + object DeepClone(object context); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IdentityHashtable4.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IdentityHashtable4.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IdentityHashtable4.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IdentityHashtable4.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,75 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using Db4objects.Db4o.Foundation; +using Sharpen; + +namespace Db4objects.Db4o.Foundation +{ + public class IdentityHashtable4 : HashtableBase, IMap4 + { + public IdentityHashtable4() + { + } + + public IdentityHashtable4(int size) : base(size) + { + } + + public virtual bool Contains(object obj) + { + return GetEntry(obj) != null; + } + + public virtual object Remove(object obj) + { + if (null == obj) + { + throw new ArgumentNullException(); + } + return RemoveIntEntry(Runtime.IdentityHashCode(obj)); + } + + public virtual bool ContainsKey(object key) + { + return GetEntry(key) != null; + } + + public virtual object Get(object key) + { + HashtableIntEntry entry = GetEntry(key); + return (entry == null ? null : entry._object); + } + + private HashtableIntEntry GetEntry(object key) + { + return FindWithSameKey(new IdentityHashtable4.IdentityEntry(key)); + } + + public virtual void Put(object key, object value) + { + if (null == key) + { + throw new ArgumentNullException(); + } + PutEntry(new IdentityHashtable4.IdentityEntry(key, value)); + } + + public class IdentityEntry : HashtableObjectEntry + { + public IdentityEntry(object obj) : this(obj, null) + { + } + + public IdentityEntry(object key, object value) : base(Runtime.IdentityHashCode(key + ), key, value) + { + } + + public override bool HasKey(object key) + { + return _objectKey == key; + } + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IdentitySet4.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IdentitySet4.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IdentitySet4.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IdentitySet4.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,49 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using System.Collections; +using Db4objects.Db4o.Foundation; +using Sharpen; + +namespace Db4objects.Db4o.Foundation +{ + /// + public class IdentitySet4 : HashtableBase, IEnumerable + { + public IdentitySet4() + { + } + + public IdentitySet4(int size) : base(size) + { + } + + public virtual bool Contains(object obj) + { + return FindWithSameKey(new HashtableIdentityEntry(obj)) != null; + } + + public virtual void Add(object obj) + { + if (null == obj) + { + throw new ArgumentNullException(); + } + PutEntry(new HashtableIdentityEntry(obj)); + } + + public virtual void Remove(object obj) + { + if (null == obj) + { + throw new ArgumentNullException(); + } + RemoveIntEntry(Runtime.IdentityHashCode(obj)); + } + + public virtual IEnumerator GetEnumerator() + { + return ValuesIterator(); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IEntry4.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IEntry4.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IEntry4.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IEntry4.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,12 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +namespace Db4objects.Db4o.Foundation +{ + /// + public interface IEntry4 + { + object Key(); + + object Value(); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IEnvironment.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IEnvironment.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IEnvironment.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IEnvironment.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,11 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; + +namespace Db4objects.Db4o.Foundation +{ + public interface IEnvironment + { + object Provide(Type service); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IFixedSizeIntIterator4.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IFixedSizeIntIterator4.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IFixedSizeIntIterator4.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IFixedSizeIntIterator4.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,11 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Foundation; + +namespace Db4objects.Db4o.Foundation +{ + public interface IFixedSizeIntIterator4 : IIntIterator4 + { + int Size(); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IFunction4.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IFunction4.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IFunction4.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IFunction4.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,10 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +namespace Db4objects.Db4o.Foundation +{ + /// + public interface IFunction4 + { + object Apply(object arg); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IIntComparator.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IIntComparator.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IIntComparator.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IIntComparator.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,16 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +namespace Db4objects.Db4o.Foundation +{ + /// + /// Non boxing/unboxing version of + /// System.Collections.IComparer<T> + /// + /// for + /// faster id comparisons. + /// + public interface IIntComparator + { + int Compare(int x, int y); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IIntIterator4.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IIntIterator4.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IIntIterator4.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IIntIterator4.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,12 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System.Collections; + +namespace Db4objects.Db4o.Foundation +{ + /// + public interface IIntIterator4 : IEnumerator + { + int CurrentInt(); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IIntObjectVisitor.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IIntObjectVisitor.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IIntObjectVisitor.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IIntObjectVisitor.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,10 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +namespace Db4objects.Db4o.Foundation +{ + /// + public interface IIntObjectVisitor + { + void Visit(int anInt, object anObject); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IListener4.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IListener4.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IListener4.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IListener4.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,10 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +namespace Db4objects.Db4o.Foundation +{ + /// + public interface IListener4 + { + void OnEvent(object @event); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IMap4.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IMap4.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IMap4.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IMap4.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,24 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System.Collections; + +namespace Db4objects.Db4o.Foundation +{ + /// + public interface IMap4 + { + int Size(); + + object Get(object key); + + void Put(object key, object value); + + bool ContainsKey(object key); + + object Remove(object key); + + IEnumerable Values(); + + void Clear(); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IndexedIterator.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IndexedIterator.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IndexedIterator.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IndexedIterator.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,61 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System.Collections; + +namespace Db4objects.Db4o.Foundation +{ + /// + /// Basic functionality for implementing iterators for + /// fixed length structures whose elements can be efficiently + /// accessed by a numeric index. + /// + /// + /// Basic functionality for implementing iterators for + /// fixed length structures whose elements can be efficiently + /// accessed by a numeric index. + /// + public abstract class IndexedIterator : IEnumerator + { + private readonly int _length; + + private int _next; + + public IndexedIterator(int length) + { + _length = length; + _next = -1; + } + + public virtual bool MoveNext() + { + if (_next < LastIndex()) + { + ++_next; + return true; + } + // force exception on unexpected call to current + _next = _length; + return false; + } + + public virtual object Current + { + get + { + return Get(_next); + } + } + + public virtual void Reset() + { + _next = -1; + } + + protected abstract object Get(int index); + + private int LastIndex() + { + return _length - 1; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IntArrayByRef.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IntArrayByRef.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IntArrayByRef.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IntArrayByRef.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,18 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +namespace Db4objects.Db4o.Foundation +{ + public class IntArrayByRef + { + public int[] value; + + public IntArrayByRef(int[] initialValue) + { + value = initialValue; + } + + public IntArrayByRef() + { + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IntArrayList.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IntArrayList.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IntArrayList.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IntArrayList.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,106 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System.Collections; +using Db4objects.Db4o.Foundation; +using Sharpen; + +namespace Db4objects.Db4o.Foundation +{ + /// + public class IntArrayList : IEnumerable + { + protected int[] i_content; + + private int i_count; + + public IntArrayList() : this(10) + { + } + + public IntArrayList(int initialSize) + { + i_content = new int[initialSize]; + } + + public virtual void Add(int a_value) + { + EnsureCapacity(); + i_content[i_count++] = a_value; + } + + public virtual void Add(int index, int a_value) + { + EnsureCapacity(); + System.Array.Copy(i_content, index, i_content, index + 1, i_count - index); + i_content[index] = a_value; + i_count++; + } + + private void EnsureCapacity() + { + if (i_count >= i_content.Length) + { + int inc = i_content.Length / 2; + if (inc < 10) + { + inc = 10; + } + int[] temp = new int[i_content.Length + inc]; + System.Array.Copy(i_content, 0, temp, 0, i_content.Length); + i_content = temp; + } + } + + public virtual int IndexOf(int a_value) + { + for (int i = 0; i < i_count; i++) + { + if (i_content[i] == a_value) + { + return i; + } + } + return -1; + } + + public virtual int Size() + { + return i_count; + } + + public virtual long[] AsLong() + { + long[] longs = new long[i_count]; + for (int i = 0; i < i_count; i++) + { + longs[i] = i_content[i]; + } + return longs; + } + + public virtual IIntIterator4 IntIterator() + { + return IntIterators.ForInts(i_content, i_count); + } + + public virtual IEnumerator GetEnumerator() + { + return IntIterator(); + } + + public virtual int Get(int index) + { + return i_content[index]; + } + + public virtual void Swap(int left, int right) + { + if (left != right) + { + int swap = i_content[left]; + i_content[left] = i_content[right]; + i_content[right] = swap; + } + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IntByRef.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IntByRef.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IntByRef.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IntByRef.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,20 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +namespace Db4objects.Db4o.Foundation +{ + /// Useful as "out" or "by ref" function parameter. + /// Useful as "out" or "by ref" function parameter. + public sealed class IntByRef + { + public int value; + + public IntByRef(int initialValue) + { + value = initialValue; + } + + public IntByRef() + { + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IntIdGenerator.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IntIdGenerator.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IntIdGenerator.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IntIdGenerator.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,20 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +namespace Db4objects.Db4o.Foundation +{ + /// + public class IntIdGenerator + { + private int _current = 1; + + public virtual int Next() + { + _current++; + if (_current < 0) + { + _current = 1; + } + return _current; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IntIterator4Adaptor.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IntIterator4Adaptor.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IntIterator4Adaptor.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IntIterator4Adaptor.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,45 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System.Collections; +using Db4objects.Db4o.Foundation; + +namespace Db4objects.Db4o.Foundation +{ + /// + public class IntIterator4Adaptor : IIntIterator4 + { + private readonly IEnumerator _iterator; + + public IntIterator4Adaptor(IEnumerator iterator) + { + _iterator = iterator; + } + + public IntIterator4Adaptor(IEnumerable iterable) : this(iterable.GetEnumerator()) + { + } + + public virtual int CurrentInt() + { + return ((int)Current); + } + + public virtual object Current + { + get + { + return _iterator.Current; + } + } + + public virtual bool MoveNext() + { + return _iterator.MoveNext(); + } + + public virtual void Reset() + { + _iterator.Reset(); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IntIterator4Impl.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IntIterator4Impl.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IntIterator4Impl.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IntIterator4Impl.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,62 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using Db4objects.Db4o.Foundation; + +namespace Db4objects.Db4o.Foundation +{ + /// + public class IntIterator4Impl : IFixedSizeIntIterator4 + { + private readonly int _count; + + private int[] _content; + + private int _current; + + public IntIterator4Impl(int[] content, int count) + { + _content = content; + _count = count; + Reset(); + } + + public virtual int CurrentInt() + { + if (_content == null || _current == _count) + { + throw new InvalidOperationException(); + } + return _content[_current]; + } + + public virtual object Current + { + get + { + return CurrentInt(); + } + } + + public virtual bool MoveNext() + { + if (_current < _count - 1) + { + _current++; + return true; + } + _content = null; + return false; + } + + public virtual void Reset() + { + _current = -1; + } + + public virtual int Size() + { + return _count; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IntIterators.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IntIterators.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IntIterators.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IntIterators.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,64 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using Db4objects.Db4o.Foundation; + +namespace Db4objects.Db4o.Foundation +{ + public class IntIterators + { + public static IFixedSizeIntIterator4 ForInts(int[] array, int count) + { + return new IntIterator4Impl(array, count); + } + + public static IIntIterator4 ForLongs(long[] ids) + { + return new _IIntIterator4_10(ids); + } + + private sealed class _IIntIterator4_10 : IIntIterator4 + { + public _IIntIterator4_10(long[] ids) + { + this.ids = ids; + this._next = 0; + } + + internal int _next; + + internal int _current; + + public int CurrentInt() + { + return this._current; + } + + public object Current + { + get + { + return this._current; + } + } + + public bool MoveNext() + { + if (this._next < ids.Length) + { + this._current = (int)ids[this._next]; + ++this._next; + return true; + } + return false; + } + + public void Reset() + { + throw new NotImplementedException(); + } + + private readonly long[] ids; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/InvalidIteratorException.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/InvalidIteratorException.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/InvalidIteratorException.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/InvalidIteratorException.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,12 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; + +namespace Db4objects.Db4o.Foundation +{ + /// + [System.Serializable] + public class InvalidIteratorException : InvalidOperationException + { + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IObjectPool.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IObjectPool.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IObjectPool.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IObjectPool.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,11 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +namespace Db4objects.Db4o.Foundation +{ + public interface IObjectPool + { + object BorrowObject(); + + void ReturnObject(object o); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IPausableBlockingQueue4.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IPausableBlockingQueue4.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IPausableBlockingQueue4.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IPausableBlockingQueue4.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,48 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Foundation; + +namespace Db4objects.Db4o.Foundation +{ + public interface IPausableBlockingQueue4 : IBlockingQueue4 + { + /// + ///

+ /// Pauses the queue, making calls to + /// IQueue4.Next() + /// block + /// until + /// Resume() + /// is called. + ///

+ /// whether or not this call changed the state of the queue. + bool Pause(); + + /// + ///

+ /// Resumes the queue, releasing blocked calls to + /// IQueue4.Next() + /// that can reach a next queue item.. + ///

+ /// whether or not this call changed the state of the queue. + bool Resume(); + + bool IsPaused(); + + /// + ///

+ /// Returns the next element in queue if there is one available, returns null + /// otherwise. + ///

+ /// + ///

+ /// Returns the next element in queue if there is one available, returns null + /// otherwise. + ///

+ /// This method will not never block, regardless of the queue being paused or + /// no elements are available. + /// + /// next element, if available and queue not paused. + object TryNext(); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IPredicate4.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IPredicate4.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IPredicate4.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IPredicate4.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,10 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +namespace Db4objects.Db4o.Foundation +{ + /// + public interface IPredicate4 + { + bool Match(object candidate); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IPreparedComparison.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IPreparedComparison.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IPreparedComparison.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IPreparedComparison.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,23 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +namespace Db4objects.Db4o.Foundation +{ + ///

+ /// a prepared comparison, to compare multiple objects + /// with one single object. + /// + /// + /// a prepared comparison, to compare multiple objects + /// with one single object. + /// + public interface IPreparedComparison + { + /// + /// return a negative int, zero or a positive int if + /// the object being held in 'this' is smaller, equal + /// or greater than the passed object.

+ /// Typical implementation: return this.object - obj; + ///
+ int CompareTo(object obj); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IProcedure4.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IProcedure4.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IProcedure4.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IProcedure4.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,10 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +namespace Db4objects.Db4o.Foundation +{ + /// + public interface IProcedure4 + { + void Apply(object value); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IQueue4.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IQueue4.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IQueue4.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IQueue4.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,28 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System.Collections; +using Db4objects.Db4o.Foundation; + +namespace Db4objects.Db4o.Foundation +{ + public interface IQueue4 + { + void Add(object obj); + + object Next(); + + bool HasNext(); + + /// Returns the next object in the queue that matches the specified condition. + /// + /// + /// Returns the next object in the queue that matches the specified condition. + /// The operation is always NON-BLOCKING. + /// + /// the object must satisfy to be returned + /// the object satisfying the condition or null if none does + object NextMatching(IPredicate4 condition); + + IEnumerator Iterator(); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/ISequence4.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/ISequence4.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/ISequence4.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/ISequence4.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,32 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System.Collections; + +namespace Db4objects.Db4o.Foundation +{ + /// + public interface ISequence4 : IEnumerable + { + bool Add(object element); + + void AddAll(IEnumerable iterable); + + bool IsEmpty(); + + object Get(int index); + + int Size(); + + void Clear(); + + bool Remove(object obj); + + bool Contains(object obj); + + bool ContainsAll(IEnumerable iter); + + object[] ToArray(); + + object[] ToArray(object[] array); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/ISet4.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/ISet4.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/ISet4.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/ISet4.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,23 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System.Collections; + +namespace Db4objects.Db4o.Foundation +{ + public interface ISet4 : IEnumerable + { + bool Add(object obj); + + void Clear(); + + bool Contains(object obj); + + bool IsEmpty(); + + IEnumerator GetEnumerator(); + + bool Remove(object obj); + + int Size(); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IShallowClone.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IShallowClone.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IShallowClone.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IShallowClone.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,10 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +namespace Db4objects.Db4o.Foundation +{ + /// + public interface IShallowClone + { + object ShallowClone(); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/ISortable4.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/ISortable4.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/ISortable4.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/ISortable4.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,14 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +namespace Db4objects.Db4o.Foundation +{ + /// + public interface ISortable4 + { + int Size(); + + int Compare(int leftIndex, int rightIndex); + + void Swap(int leftIndex, int rightIndex); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/Iterable4Adaptor.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/Iterable4Adaptor.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/Iterable4Adaptor.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/Iterable4Adaptor.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,75 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using System.Collections; + +namespace Db4objects.Db4o.Foundation +{ + /// + /// Adapts Iterable4/Iterator4 iteration model (moveNext, current) to the old db4o + /// and jdk model (hasNext, next). + /// + /// + /// Adapts Iterable4/Iterator4 iteration model (moveNext, current) to the old db4o + /// and jdk model (hasNext, next). + /// + /// + public class Iterable4Adaptor + { + private static readonly object EofMarker = new object(); + + private static readonly object MoveNextMarker = new object(); + + private readonly IEnumerable _delegate; + + private IEnumerator _iterator; + + private object _current = MoveNextMarker; + + public Iterable4Adaptor(IEnumerable delegate_) + { + _delegate = delegate_; + } + + public virtual bool HasNext() + { + if (_current == MoveNextMarker) + { + return MoveNext(); + } + return _current != EofMarker; + } + + public virtual object Next() + { + if (!HasNext()) + { + throw new InvalidOperationException(); + } + object returnValue = _current; + _current = MoveNextMarker; + return returnValue; + } + + protected virtual bool MoveNext() + { + if (null == _iterator) + { + _iterator = _delegate.GetEnumerator(); + } + if (_iterator.MoveNext()) + { + _current = _iterator.Current; + return true; + } + _current = EofMarker; + return false; + } + + public virtual void Reset() + { + _iterator = null; + _current = MoveNextMarker; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/Iterator4Impl.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/Iterator4Impl.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/Iterator4Impl.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/Iterator4Impl.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,55 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using System.Collections; +using Db4objects.Db4o.Foundation; + +namespace Db4objects.Db4o.Foundation +{ + /// + public class Iterator4Impl : IEnumerator + { + private readonly List4 _first; + + private List4 _next; + + private object _current; + + public Iterator4Impl(List4 first) + { + _first = first; + _next = first; + _current = Iterators.NoElement; + } + + public virtual bool MoveNext() + { + if (_next == null) + { + _current = Iterators.NoElement; + return false; + } + _current = ((object)_next._element); + _next = ((List4)_next._next); + return true; + } + + public virtual object Current + { + get + { + if (Iterators.NoElement == _current) + { + throw new InvalidOperationException(); + } + return (object)_current; + } + } + + public virtual void Reset() + { + _next = _first; + _current = Iterators.NoElement; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/Iterators.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/Iterators.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/Iterators.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/Iterators.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,626 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using System.Collections; +using System.Text; +using Db4objects.Db4o.Foundation; + +namespace Db4objects.Db4o.Foundation +{ + /// Iterator primitives (concat, map, reduce, filter, etc...). + /// Iterator primitives (concat, map, reduce, filter, etc...). + /// + public partial class Iterators + { + /// + /// Constant indicating that the current element in a + /// Map(IEnumerator, IFunction4) + /// operation + /// should be skipped. + /// + public static readonly object Skip = new object(); + + private sealed class _IEnumerator_20 : IEnumerator + { + public _IEnumerator_20() + { + } + + public object Current + { + get + { + throw new InvalidOperationException(); + } + } + + public bool MoveNext() + { + return false; + } + + public void Reset() + { + } + } + + public static readonly IEnumerator EmptyIterator = new _IEnumerator_20(); + + private sealed class _IEnumerable_34 : IEnumerable + { + public _IEnumerable_34() + { + } + + // do nothing + public IEnumerator GetEnumerator() + { + return Iterators.EmptyIterator; + } + } + + public static readonly IEnumerable EmptyIterable = new _IEnumerable_34(); + + internal static readonly object NoElement = new object(); + + /// + /// Generates + /// Tuple + /// items with indexes starting at 0. + /// + /// the iterable to be enumerated + public static IEnumerable Enumerate(IEnumerable iterable) + { + return new _IEnumerable_48(iterable); + } + + private sealed class _IEnumerable_48 : IEnumerable + { + public _IEnumerable_48(IEnumerable iterable) + { + this.iterable = iterable; + } + + public IEnumerator GetEnumerator() + { + return new EnumerateIterator(iterable.GetEnumerator()); + } + + private readonly IEnumerable iterable; + } + + public static bool Any(IEnumerator iterator, IPredicate4 condition) + { + while (iterator.MoveNext()) + { + if (condition.Match(iterator.Current)) + { + return true; + } + } + return false; + } + + public static IEnumerator Concat(IEnumerator[] array) + { + return Concat(Iterate((object[])array)); + } + + public static IEnumerator Concat(IEnumerator iterators) + { + return new CompositeIterator4(iterators); + } + + public static IEnumerable Concat(IEnumerable[] iterables) + { + return Concat(Iterable(iterables)); + } + + public static IEnumerable Concat(IEnumerable iterables) + { + return new CompositeIterable4(iterables); + } + + public static IEnumerator Concat(IEnumerator first, IEnumerator second) + { + return Concat(new IEnumerator[] { first, second }); + } + + public static IEnumerable ConcatMap(IEnumerable iterable, IFunction4 function) + { + return Concat(Map(iterable, function)); + } + + /// + /// Returns a new iterator which yields the result of applying the function + /// to every element in the original iterator. + /// + /// + /// Returns a new iterator which yields the result of applying the function + /// to every element in the original iterator. + /// Skip + /// can be returned from function to indicate the current + /// element should be skipped. + /// + /// + /// + /// + public static IEnumerator Map(IEnumerator iterator, IFunction4 function) + { + return new FunctionApplicationIterator(iterator, function); + } + + public static IEnumerator Map(object[] array, IFunction4 function) + { + return Map(new ArrayIterator4(array), function); + } + + public static IEnumerator Filter(object[] array, IPredicate4 predicate) + { + return Filter(new ArrayIterator4(array), predicate); + } + + public static IEnumerable Filter(IEnumerable source, IPredicate4 predicate) + { + return new _IEnumerable_112(source, predicate); + } + + private sealed class _IEnumerable_112 : IEnumerable + { + public _IEnumerable_112(IEnumerable source, IPredicate4 predicate) + { + this.source = source; + this.predicate = predicate; + } + + public IEnumerator GetEnumerator() + { + return Iterators.Filter(source.GetEnumerator(), predicate); + } + + private readonly IEnumerable source; + + private readonly IPredicate4 predicate; + } + + public static IEnumerator Filter(IEnumerator iterator, IPredicate4 predicate) + { + return new FilteredIterator(iterator, predicate); + } + + public static IEnumerable SingletonIterable(object element) + { + return new _IEnumerable_124(element); + } + + private sealed class _IEnumerable_124 : IEnumerable + { + public _IEnumerable_124(object element) + { + this.element = element; + } + + public IEnumerator GetEnumerator() + { + return Iterators.SingletonIterator(element); + } + + private readonly object element; + } + + public static IEnumerable Append(IEnumerable front, object last) + { + return Concat(Iterable(new object[] { front, SingletonIterable(last) })); + } + + public static IEnumerator Iterator(IEnumerable iterable) + { + return iterable.GetEnumerator(); + } + + public static IEnumerator Iterate(object[] array) + { + return new ArrayIterator4(array); + } + + public static IEnumerator Revert(IEnumerator iterator) + { + iterator.Reset(); + List4 tail = null; + while (iterator.MoveNext()) + { + tail = new List4(tail, iterator.Current); + } + return Iterate(tail); + } + + public static IEnumerator Iterate(List4 list) + { + if (list == null) + { + return EmptyIterator; + } + Collection4 collection = new Collection4(); + while (list != null) + { + collection.Add(list._element); + list = ((List4)list._next); + } + return collection.GetEnumerator(); + } + + public static int Size(IEnumerable iterable) + { + return Size(iterable.GetEnumerator()); + } + + public static object Next(IEnumerator iterator) + { + if (!iterator.MoveNext()) + { + throw new InvalidOperationException(); + } + return iterator.Current; + } + + public static int Size(IEnumerator iterator) + { + int count = 0; + while (iterator.MoveNext()) + { + ++count; + } + return count; + } + + public static string ToString(IEnumerable i) + { + return ToString(i.GetEnumerator()); + } + + public static string ToString(IEnumerator i) + { + return Join(i, "[", "]", ", "); + } + + public static string Join(IEnumerable i, string separator) + { + return Join(i.GetEnumerator(), separator); + } + + public static string Join(IEnumerator i, string separator) + { + return Join(i, string.Empty, string.Empty, separator); + } + + public static string Join(IEnumerator i, string prefix, string suffix, string separator + ) + { + StringBuilder sb = new StringBuilder(); + sb.Append(prefix); + if (i.MoveNext()) + { + sb.Append(i.Current); + while (i.MoveNext()) + { + sb.Append(separator); + sb.Append(i.Current); + } + } + sb.Append(suffix); + return sb.ToString(); + } + + public static object[] ToArray(IEnumerator tests) + { + return ToArray(tests, new _IArrayFactory_230()); + } + + private sealed class _IArrayFactory_230 : IArrayFactory + { + public _IArrayFactory_230() + { + } + + public object[] NewArray(int size) + { + return new object[size]; + } + } + + public static object[] ToArray(IEnumerator tests, IArrayFactory factory) + { + Collection4 elements = new Collection4(tests); + return elements.ToArray(factory.NewArray(elements.Size())); + } + + /// Yields a flat sequence of elements. + /// + /// Yields a flat sequence of elements. Any + /// IEnumerable + /// or + /// IEnumerator + /// found in the original sequence is recursively flattened. + /// + /// original sequence + public static IEnumerator Flatten(IEnumerator iterator) + { + return new FlatteningIterator(iterator); + } + + public static IEnumerable Map(IEnumerable iterable, IFunction4 function) + { + return new _IEnumerable_253(iterable, function); + } + + private sealed class _IEnumerable_253 : IEnumerable + { + public _IEnumerable_253(IEnumerable iterable, IFunction4 function) + { + this.iterable = iterable; + this.function = function; + } + + public IEnumerator GetEnumerator() + { + return Iterators.Map(iterable.GetEnumerator(), function); + } + + private readonly IEnumerable iterable; + + private readonly IFunction4 function; + } + + public static IEnumerable CrossProduct(IEnumerable iterables) + { + return CrossProduct((IEnumerable[])ToArray(iterables.GetEnumerator(), new _IArrayFactory_261 + ())); + } + + private sealed class _IArrayFactory_261 : IArrayFactory + { + public _IArrayFactory_261() + { + } + + public object[] NewArray(int size) + { + return new IEnumerable[size]; + } + } + + public static IEnumerable CrossProduct(IEnumerable[] iterables) + { + return CrossProduct(iterables, 0, Iterators.EmptyIterable); + } + + private static IEnumerable CrossProduct(IEnumerable[] iterables, int level, IEnumerable + row) + { + if (level == iterables.Length - 1) + { + return Map(iterables[level], new _IFunction4_276(row)); + } + return ConcatMap(iterables[level], new _IFunction4_284(iterables, level, row)); + } + + private sealed class _IFunction4_276 : IFunction4 + { + public _IFunction4_276(IEnumerable row) + { + this.row = row; + } + + public object Apply(object arg) + { + return Iterators.Append(row, arg); + } + + private readonly IEnumerable row; + } + + private sealed class _IFunction4_284 : IFunction4 + { + public _IFunction4_284(IEnumerable[] iterables, int level, IEnumerable row) + { + this.iterables = iterables; + this.level = level; + this.row = row; + } + + public object Apply(object arg) + { + return Iterators.CrossProduct(iterables, level + 1, Iterators.Append(row, arg)); + } + + private readonly IEnumerable[] iterables; + + private readonly int level; + + private readonly IEnumerable row; + } + + public static IEnumerable Iterable(object[] objects) + { + return new _IEnumerable_292(objects); + } + + private sealed class _IEnumerable_292 : IEnumerable + { + public _IEnumerable_292(object[] objects) + { + this.objects = objects; + } + + public IEnumerator GetEnumerator() + { + return Iterators.Iterate(objects); + } + + private readonly object[] objects; + } + + public static IEnumerator SingletonIterator(object element) + { + return new SingleValueIterator(element); + } + + public static IEnumerable Iterable(IEnumerator iterator) + { + return new _IEnumerable_304(iterator); + } + + private sealed class _IEnumerable_304 : IEnumerable + { + public _IEnumerable_304(IEnumerator iterator) + { + this.iterator = iterator; + } + + public IEnumerator GetEnumerator() + { + return iterator; + } + + private readonly IEnumerator iterator; + } + + public static IEnumerator Copy(IEnumerator iterator) + { + return new Collection4(iterator).GetEnumerator(); + } + + public static IEnumerator Take(int count, IEnumerator iterator) + { + return new _IEnumerator_316(count, iterator); + } + + private sealed class _IEnumerator_316 : IEnumerator + { + public _IEnumerator_316(int count, IEnumerator iterator) + { + this.count = count; + this.iterator = iterator; + this._taken = 0; + } + + private int _taken; + + public object Current + { + get + { + if (this._taken > count) + { + throw new InvalidOperationException(); + } + return iterator.Current; + } + } + + public bool MoveNext() + { + if (this._taken < count) + { + if (!iterator.MoveNext()) + { + this._taken = count; + return false; + } + ++this._taken; + return true; + } + return false; + } + + public void Reset() + { + throw new NotImplementedException(); + } + + private readonly int count; + + private readonly IEnumerator iterator; + } + + public static IEnumerator Range(int fromInclusive, int toExclusive) + { + if (toExclusive < fromInclusive) + { + throw new ArgumentException(); + } + return Take(toExclusive - fromInclusive, Series(fromInclusive - 1, new _IFunction4_350 + ()).GetEnumerator()); + } + + private sealed class _IFunction4_350 : IFunction4 + { + public _IFunction4_350() + { + } + + public object Apply(object i) + { + return (((int)i)) + 1; + } + } + + public static IEnumerable Series(object seed, IFunction4 function) + { + return new _IEnumerable_356(seed, function); + } + + private sealed class _IEnumerable_356 : IEnumerable + { + public _IEnumerable_356(object seed, IFunction4 function) + { + this.seed = seed; + this.function = function; + } + + public IEnumerator GetEnumerator() + { + return new _IEnumerator_358(seed, function); + } + + private sealed class _IEnumerator_358 : IEnumerator + { + public _IEnumerator_358(object seed, IFunction4 function) + { + this.seed = seed; + this.function = function; + this._current = seed; + } + + private object _current; + + public object Current + { + get + { + return this._current; + } + } + + public bool MoveNext() + { + this._current = function.Apply(this._current); + return true; + } + + public void Reset() + { + this._current = seed; + } + + private readonly object seed; + + private readonly IFunction4 function; + } + + private readonly object seed; + + private readonly IFunction4 function; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/ITimeoutBlockingQueue4.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/ITimeoutBlockingQueue4.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/ITimeoutBlockingQueue4.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/ITimeoutBlockingQueue4.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,13 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Foundation; + +namespace Db4objects.Db4o.Foundation +{ + public interface ITimeoutBlockingQueue4 : IPausableBlockingQueue4 + { + void Check(); + + void Reset(); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IVisitable.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IVisitable.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IVisitable.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IVisitable.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,12 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Foundation; + +namespace Db4objects.Db4o.Foundation +{ + /// + public interface IVisitable + { + void Accept(IVisitor4 visitor); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IVisitor4.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IVisitor4.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IVisitor4.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/IVisitor4.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,10 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +namespace Db4objects.Db4o.Foundation +{ + /// + public interface IVisitor4 + { + void Visit(object obj); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/KeySpec.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/KeySpec.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/KeySpec.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/KeySpec.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,46 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Foundation; + +namespace Db4objects.Db4o.Foundation +{ + /// + public class KeySpec + { + public interface IDeferred + { + object Evaluate(); + } + + private object _defaultValue; + + public KeySpec(byte defaultValue) + { + _defaultValue = defaultValue; + } + + public KeySpec(int defaultValue) + { + _defaultValue = defaultValue; + } + + public KeySpec(bool defaultValue) + { + _defaultValue = defaultValue; + } + + public KeySpec(object defaultValue) + { + _defaultValue = defaultValue; + } + + public virtual object DefaultValue() + { + if (_defaultValue is KeySpec.IDeferred) + { + return ((KeySpec.IDeferred)_defaultValue).Evaluate(); + } + return _defaultValue; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/KeySpecHashtable4.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/KeySpecHashtable4.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/KeySpecHashtable4.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/KeySpecHashtable4.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,89 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Foundation; + +namespace Db4objects.Db4o.Foundation +{ + /// + public class KeySpecHashtable4 : IDeepClone + { + private SynchronizedHashtable4 _delegate; + + private KeySpecHashtable4(SynchronizedHashtable4 delegate_) + { + _delegate = delegate_; + } + + public KeySpecHashtable4(int size) : this(new SynchronizedHashtable4(size)) + { + } + + public virtual void Put(KeySpec spec, byte value) + { + _delegate.Put(spec, value); + } + + public virtual void Put(KeySpec spec, bool value) + { + _delegate.Put(spec, value); + } + + public virtual void Put(KeySpec spec, int value) + { + _delegate.Put(spec, value); + } + + public virtual void Put(KeySpec spec, object value) + { + _delegate.Put(spec, value); + } + + public virtual byte GetAsByte(KeySpec spec) + { + return ((byte)Get(spec)); + } + + public virtual bool GetAsBoolean(KeySpec spec) + { + return ((bool)Get(spec)); + } + + public virtual int GetAsInt(KeySpec spec) + { + return ((int)Get(spec)); + } + + public virtual TernaryBool GetAsTernaryBool(KeySpec spec) + { + return (TernaryBool)Get(spec); + } + + public virtual string GetAsString(KeySpec spec) + { + return (string)Get(spec); + } + + public virtual object Get(KeySpec spec) + { + lock (this) + { + object value = _delegate.Get(spec); + if (value == null) + { + value = spec.DefaultValue(); + if (value != null) + { + _delegate.Put(spec, value); + } + } + return value; + } + } + + public virtual object DeepClone(object obj) + { + return new Db4objects.Db4o.Foundation.KeySpecHashtable4((SynchronizedHashtable4)_delegate + .DeepClone(obj)); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/List4.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/List4.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/List4.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/List4.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,55 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Types; + +namespace Db4objects.Db4o.Foundation +{ + /// simplest possible linked list + /// + public sealed class List4 : IUnversioned + { + /// next element in list + public Db4objects.Db4o.Foundation.List4 _next; + + /// carried object + public object _element; + + /// db4o constructor to be able to store objects of this class + public List4() + { + } + + public List4(object element) + { + // TODO: encapsulate field access + _element = element; + } + + public List4(Db4objects.Db4o.Foundation.List4 next, object element) + { + _next = next; + _element = element; + } + + internal bool Holds(object obj) + { + if (obj == null) + { + return _element == null; + } + return ((object)obj).Equals(_element); + } + + public static int Size(Db4objects.Db4o.Foundation.List4 list) + { + int counter = 0; + Db4objects.Db4o.Foundation.List4 nextList = list; + while (nextList != null) + { + counter++; + nextList = ((Db4objects.Db4o.Foundation.List4)nextList._next); + } + return counter; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/ListenerRegistry.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/ListenerRegistry.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/ListenerRegistry.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/ListenerRegistry.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,49 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System.Collections; +using Db4objects.Db4o.Foundation; + +namespace Db4objects.Db4o.Foundation +{ + /// + public class ListenerRegistry + { + public static ListenerRegistry NewInstance() + { + return new ListenerRegistry(); + } + + private IdentitySet4 _listeners; + + public virtual void Register(IListener4 listener) + { + if (_listeners == null) + { + _listeners = new IdentitySet4(); + } + _listeners.Add(listener); + } + + public virtual void NotifyListeners(object @event) + { + if (_listeners == null) + { + return; + } + IEnumerator i = _listeners.GetEnumerator(); + while (i.MoveNext()) + { + ((IListener4)i.Current).OnEvent(@event); + } + } + + public virtual void Remove(IListener4 listener) + { + if (_listeners == null) + { + return; + } + _listeners.Remove(listener); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/LongByRef.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/LongByRef.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/LongByRef.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/LongByRef.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,20 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +namespace Db4objects.Db4o.Foundation +{ + /// Useful as "out" or "by ref" function parameter. + /// Useful as "out" or "by ref" function parameter. + public sealed class LongByRef + { + public long value; + + public LongByRef(long initialValue) + { + value = initialValue; + } + + public LongByRef() + { + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/MappingIterator.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/MappingIterator.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/MappingIterator.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/MappingIterator.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,61 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using System.Collections; +using Db4objects.Db4o.Foundation; + +namespace Db4objects.Db4o.Foundation +{ + /// + public abstract class MappingIterator : IEnumerator + { + private readonly IEnumerator _iterator; + + private object _current; + + public MappingIterator(IEnumerator iterator) + { + if (null == iterator) + { + throw new ArgumentNullException(); + } + _iterator = iterator; + _current = Iterators.NoElement; + } + + protected abstract object Map(object current); + + public virtual bool MoveNext() + { + do + { + if (!_iterator.MoveNext()) + { + _current = Iterators.NoElement; + return false; + } + _current = Map(_iterator.Current); + } + while (_current == Iterators.Skip); + return true; + } + + public virtual void Reset() + { + _current = Iterators.NoElement; + _iterator.Reset(); + } + + public virtual object Current + { + get + { + if (Iterators.NoElement == _current) + { + throw new InvalidOperationException(); + } + return _current; + } + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/NativeCollections.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/NativeCollections.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/NativeCollections.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/NativeCollections.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,24 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System.Collections; +using Db4objects.Db4o.Foundation; + +namespace Db4objects.Db4o.Foundation +{ + public class NativeCollections + { + public static IList Filter(IList items, IPredicate4 predicate) + { + IList filtered = new ArrayList(); + for (IEnumerator itemIter = items.GetEnumerator(); itemIter.MoveNext(); ) + { + object item = itemIter.Current; + if (predicate.Match(item)) + { + filtered.Add(item); + } + } + return filtered; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/No4.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/No4.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/No4.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/No4.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,12 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o; +using Db4objects.Db4o.Foundation; + +namespace Db4objects.Db4o.Foundation +{ + public class No4 : IInternal4 + { + public static readonly No4 Instance = new No4(); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/NoDuplicatesQueue.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/NoDuplicatesQueue.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/NoDuplicatesQueue.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/NoDuplicatesQueue.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,50 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System.Collections; +using Db4objects.Db4o.Foundation; + +namespace Db4objects.Db4o.Foundation +{ + public class NoDuplicatesQueue : IQueue4 + { + private IQueue4 _queue; + + private Hashtable4 _seen; + + public NoDuplicatesQueue(IQueue4 queue) + { + _queue = queue; + _seen = new Hashtable4(); + } + + public virtual void Add(object obj) + { + if (_seen.ContainsKey(obj)) + { + return; + } + _queue.Add(obj); + _seen.Put(obj, obj); + } + + public virtual bool HasNext() + { + return _queue.HasNext(); + } + + public virtual IEnumerator Iterator() + { + return _queue.Iterator(); + } + + public virtual object Next() + { + return _queue.Next(); + } + + public virtual object NextMatching(IPredicate4 condition) + { + return _queue.NextMatching(condition); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/NonblockingQueue.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/NonblockingQueue.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/NonblockingQueue.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/NonblockingQueue.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,120 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using System.Collections; +using Db4objects.Db4o.Foundation; + +namespace Db4objects.Db4o.Foundation +{ + /// Unbounded queue. + /// Unbounded queue. + /// + public class NonblockingQueue : IQueue4 + { + private List4 _insertionPoint; + + private List4 _next; + + public void Add(object obj) + { + List4 newNode = new List4(null, obj); + if (_insertionPoint == null) + { + _next = newNode; + } + else + { + _insertionPoint._next = newNode; + } + _insertionPoint = newNode; + } + + public object Next() + { + if (_next == null) + { + return null; + } + object ret = ((object)_next._element); + RemoveNext(); + return ret; + } + + private void RemoveNext() + { + _next = ((List4)_next._next); + if (_next == null) + { + _insertionPoint = null; + } + } + + public virtual object NextMatching(IPredicate4 condition) + { + if (null == condition) + { + throw new ArgumentNullException(); + } + List4 current = _next; + List4 previous = null; + while (null != current) + { + object element = ((object)current._element); + if (condition.Match(element)) + { + if (previous == null) + { + RemoveNext(); + } + else + { + previous._next = ((List4)current._next); + } + return element; + } + previous = current; + current = ((List4)current._next); + } + return null; + } + + public bool HasNext() + { + return _next != null; + } + + public virtual IEnumerator Iterator() + { + List4 origInsertionPoint = _insertionPoint; + List4 origNext = _next; + return new _Iterator4Impl_82(this, origInsertionPoint, origNext, _next); + } + + private sealed class _Iterator4Impl_82 : Iterator4Impl + { + public _Iterator4Impl_82(NonblockingQueue _enclosing, List4 origInsertionPoint, List4 + origNext, List4 baseArg1) : base(baseArg1) + { + this._enclosing = _enclosing; + this.origInsertionPoint = origInsertionPoint; + this.origNext = origNext; + } + + public override bool MoveNext() + { + if (origInsertionPoint != this._enclosing._insertionPoint || origNext != this._enclosing + ._next) + { + throw new InvalidOperationException(); + } + return base.MoveNext(); + } + + private readonly NonblockingQueue _enclosing; + + private readonly List4 origInsertionPoint; + + private readonly List4 origNext; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/ObjectByRef.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/ObjectByRef.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/ObjectByRef.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/ObjectByRef.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,20 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +namespace Db4objects.Db4o.Foundation +{ + /// Useful as "out" or "by ref" function parameter. + /// Useful as "out" or "by ref" function parameter. + public sealed class ObjectByRef + { + public object value; + + public ObjectByRef() + { + } + + public ObjectByRef(object value_) + { + value = value_; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/Pair.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/Pair.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/Pair.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/Pair.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,82 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +namespace Db4objects.Db4o.Foundation +{ + public class Pair + { + public static Db4objects.Db4o.Foundation.Pair Of(object first, object second) + { + return new Db4objects.Db4o.Foundation.Pair(first, second); + } + + public object first; + + public object second; + + public Pair(object first, object second) + { + this.first = first; + this.second = second; + } + + public override string ToString() + { + return "Pair.of(" + first + ", " + second + ")"; + } + + public override int GetHashCode() + { + int prime = 31; + int result = 1; + result = prime * result + ((first == null) ? 0 : first.GetHashCode()); + result = prime * result + ((second == null) ? 0 : second.GetHashCode()); + return result; + } + + public override bool Equals(object obj) + { + if (this == obj) + { + return true; + } + if (obj == null) + { + return false; + } + if (GetType() != obj.GetType()) + { + return false; + } + Db4objects.Db4o.Foundation.Pair other = (Db4objects.Db4o.Foundation.Pair)obj; + if (first == null) + { + if (other.first != null) + { + return false; + } + } + else + { + if (!first.Equals(other.first)) + { + return false; + } + } + if (second == null) + { + if (other.second != null) + { + return false; + } + } + else + { + if (!second.Equals(other.second)) + { + return false; + } + } + return true; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/PausableBlockingQueue.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/PausableBlockingQueue.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/PausableBlockingQueue.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/PausableBlockingQueue.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,88 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Foundation; + +namespace Db4objects.Db4o.Foundation +{ + public class PausableBlockingQueue : BlockingQueue, IPausableBlockingQueue4 + { + private volatile bool _paused = false; + + public virtual bool Pause() + { + if (_paused) + { + return false; + } + _paused = true; + return true; + } + + public virtual bool Resume() + { + return (((bool)_lock.Run(new _IClosure4_17(this)))); + } + + private sealed class _IClosure4_17 : IClosure4 + { + public _IClosure4_17(PausableBlockingQueue _enclosing) + { + this._enclosing = _enclosing; + } + + public object Run() + { + if (!this._enclosing._paused) + { + return false; + } + this._enclosing._paused = false; + this._enclosing._lock.Awake(); + return true; + } + + private readonly PausableBlockingQueue _enclosing; + } + + public virtual bool IsPaused() + { + return _paused; + } + + /// + protected override bool UnsafeWaitForNext(long timeout) + { + bool hasNext = base.UnsafeWaitForNext(timeout); + while (_paused && !_stopped) + { + _lock.Snooze(timeout); + } + if (_stopped) + { + throw new BlockingQueueStoppedException(); + } + return hasNext; + } + + public virtual object TryNext() + { + return _lock.Run(new _IClosure4_46(this)); + } + + private sealed class _IClosure4_46 : IClosure4 + { + public _IClosure4_46(PausableBlockingQueue _enclosing) + { + this._enclosing = _enclosing; + } + + public object Run() + { + return this._enclosing.IsPaused() ? null : this._enclosing.HasNext() ? this._enclosing + .Next() : null; + } + + private readonly PausableBlockingQueue _enclosing; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/PrimitiveCodec.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/PrimitiveCodec.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/PrimitiveCodec.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/PrimitiveCodec.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,84 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Sharpen.IO; + +namespace Db4objects.Db4o.Foundation +{ + public sealed class PrimitiveCodec + { + public const int IntLength = 4; + + public const int LongLength = 8; + + public static int ReadInt(byte[] buffer, int offset) + { + offset += 3; + return (buffer[offset] & 255) | (buffer[--offset] & 255) << 8 | (buffer[--offset] + & 255) << 16 | buffer[--offset] << 24; + } + + public static int ReadInt(ByteArrayInputStream @in) + { + return (@in.Read() << 24) | ((@in.Read() & 255) << 16) | ((@in.Read() & 255) << 8 + ) | (@in.Read() & 255); + } + + public static void WriteInt(byte[] buffer, int offset, int val) + { + offset += 3; + buffer[offset] = (byte)val; + buffer[--offset] = (byte)(val >>= 8); + buffer[--offset] = (byte)(val >>= 8); + buffer[--offset] = (byte)(val >> 8); + } + + public static void WriteInt(ByteArrayOutputStream @out, int val) + { + @out.Write((byte)(val >> 24)); + @out.Write((byte)(val >> 16)); + @out.Write((byte)(val >> 8)); + @out.Write((byte)val); + } + + public static void WriteLong(byte[] buffer, long val) + { + WriteLong(buffer, 0, val); + } + + public static void WriteLong(byte[] buffer, int offset, long val) + { + for (int i = 0; i < LongLength; i++) + { + buffer[offset++] = (byte)(val >> ((7 - i) * 8)); + } + } + + public static void WriteLong(ByteArrayOutputStream @out, long val) + { + for (int i = 0; i < LongLength; i++) + { + @out.Write((byte)(val >> ((7 - i) * 8))); + } + } + + public static long ReadLong(byte[] buffer, int offset) + { + long ret = 0; + for (int i = 0; i < LongLength; i++) + { + ret = (ret << 8) + (buffer[offset++] & unchecked((int)(0xff))); + } + return ret; + } + + public static long ReadLong(ByteArrayInputStream @in) + { + long ret = 0; + for (int i = 0; i < LongLength; i++) + { + ret = (ret << 8) + ((byte)@in.Read() & unchecked((int)(0xff))); + } + return ret; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/Runnable4.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/Runnable4.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/Runnable4.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/Runnable4.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,23 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Sharpen.Lang; + +namespace Db4objects.Db4o.Foundation +{ + /// + public class Runnable4 + { + private sealed class _IRunnable_10 : IRunnable + { + public _IRunnable_10() + { + } + + public void Run() + { + } + } + + public static readonly IRunnable DoNothing = new _IRunnable_10(); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/Runtime4.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/Runtime4.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/Runtime4.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/Runtime4.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,71 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using Db4objects.Db4o.Foundation; +using Sharpen.Lang; + +namespace Db4objects.Db4o.Foundation +{ + /// A collection of static methods that should be part of the runtime environment but are not. + /// + /// A collection of static methods that should be part of the runtime environment but are not. + /// + /// + public class Runtime4 + { + /// sleeps without checked exceptions + public static void Sleep(long millis) + { + try + { + Thread.Sleep(millis); + } + catch (Exception) + { + } + } + + /// sleeps with implicit exception + /// + public static void SleepThrowsOnInterrupt(long millis) + { + try + { + Thread.Sleep(millis); + } + catch (Exception e) + { + throw new RuntimeInterruptedException(e.ToString()); + } + } + + /// + /// Keeps executing a block of code until it either returns true or millisecondsTimeout + /// elapses. + /// + /// + /// Keeps executing a block of code until it either returns true or millisecondsTimeout + /// elapses. + /// + public static bool Retry(long millisecondsTimeout, IClosure4 block) + { + return Retry(millisecondsTimeout, 1, block); + } + + public static bool Retry(long millisecondsTimeout, int millisecondsBetweenRetries + , IClosure4 block) + { + StopWatch watch = new AutoStopWatch(); + do + { + if ((((bool)block.Run()))) + { + return true; + } + Sleep(millisecondsBetweenRetries); + } + while (watch.Peek() < millisecondsTimeout); + return false; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/RuntimeInterruptedException.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/RuntimeInterruptedException.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/RuntimeInterruptedException.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/RuntimeInterruptedException.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,14 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; + +namespace Db4objects.Db4o.Foundation +{ + [System.Serializable] + public class RuntimeInterruptedException : Exception + { + public RuntimeInterruptedException(string msg) : base(msg) + { + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/SimpleObjectPool.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/SimpleObjectPool.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/SimpleObjectPool.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/SimpleObjectPool.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,43 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using Db4objects.Db4o.Foundation; + +namespace Db4objects.Db4o.Foundation +{ + public class SimpleObjectPool : IObjectPool + { + private readonly object[] _objects; + + private int _available; + + public SimpleObjectPool(object[] objects) + { + int length = objects.Length; + _objects = new object[length]; + for (int i = 0; i < length; ++i) + { + _objects[length - i - 1] = objects[i]; + } + _available = length; + } + + public virtual object BorrowObject() + { + if (_available == 0) + { + throw new InvalidOperationException(); + } + return (object)_objects[--_available]; + } + + public virtual void ReturnObject(object o) + { + if (_available == _objects.Length) + { + throw new InvalidOperationException(); + } + _objects[_available++] = o; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/SimpleTimer.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/SimpleTimer.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/SimpleTimer.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/SimpleTimer.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,76 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Foundation; +using Sharpen.Lang; + +namespace Db4objects.Db4o.Foundation +{ + /// + public sealed class SimpleTimer : IRunnable + { + private readonly IRunnable _runnable; + + private readonly long _interval; + + private Lock4 _lock; + + public volatile bool stopped = false; + + public SimpleTimer(IRunnable runnable, long interval) + { + _runnable = runnable; + _interval = interval; + _lock = new Lock4(); + } + + public void Stop() + { + stopped = true; + _lock.Run(new _IClosure4_27(this)); + } + + private sealed class _IClosure4_27 : IClosure4 + { + public _IClosure4_27(SimpleTimer _enclosing) + { + this._enclosing = _enclosing; + } + + public object Run() + { + this._enclosing._lock.Awake(); + return null; + } + + private readonly SimpleTimer _enclosing; + } + + public void Run() + { + while (!stopped) + { + _lock.Run(new _IClosure4_37(this)); + if (!stopped) + { + _runnable.Run(); + } + } + } + + private sealed class _IClosure4_37 : IClosure4 + { + public _IClosure4_37(SimpleTimer _enclosing) + { + this._enclosing = _enclosing; + } + + public object Run() + { + this._enclosing._lock.Snooze(this._enclosing._interval); + return null; + } + + private readonly SimpleTimer _enclosing; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/SingleValueIterator.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/SingleValueIterator.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/SingleValueIterator.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/SingleValueIterator.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,48 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using System.Collections; +using Db4objects.Db4o.Foundation; + +namespace Db4objects.Db4o.Foundation +{ + public class SingleValueIterator : IEnumerator + { + private object _value; + + private bool _moved; + + public SingleValueIterator(object value) + { + _value = value; + } + + public virtual object Current + { + get + { + if (!_moved || _value == Iterators.NoElement) + { + throw new InvalidOperationException(); + } + return _value; + } + } + + public virtual bool MoveNext() + { + if (!_moved) + { + _moved = true; + return true; + } + _value = Iterators.NoElement; + return false; + } + + public virtual void Reset() + { + throw new NotImplementedException(); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/SortedCollection4.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/SortedCollection4.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/SortedCollection4.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/SortedCollection4.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,82 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using System.Collections; +using Db4objects.Db4o.Foundation; + +namespace Db4objects.Db4o.Foundation +{ + /// + public class SortedCollection4 + { + private readonly IComparison4 _comparison; + + private Tree _tree; + + public SortedCollection4(IComparison4 comparison) + { + if (null == comparison) + { + throw new ArgumentNullException(); + } + _comparison = comparison; + _tree = null; + } + + public virtual object SingleElement() + { + if (1 != Size()) + { + throw new InvalidOperationException(); + } + return _tree.Key(); + } + + public virtual void AddAll(IEnumerator iterator) + { + while (iterator.MoveNext()) + { + Add(iterator.Current); + } + } + + public virtual void Add(object element) + { + _tree = Tree.Add(_tree, new TreeObject(element, _comparison)); + } + + public virtual void Remove(object element) + { + _tree = Tree.RemoveLike(_tree, new TreeObject(element, _comparison)); + } + + public virtual object[] ToArray(object[] array) + { + Tree.Traverse(_tree, new _IVisitor4_43(array)); + return array; + } + + private sealed class _IVisitor4_43 : IVisitor4 + { + public _IVisitor4_43(object[] array) + { + this.array = array; + this.i = 0; + } + + internal int i; + + public void Visit(object obj) + { + array[this.i++] = ((TreeObject)obj).Key(); + } + + private readonly object[] array; + } + + public virtual int Size() + { + return Tree.Size(_tree); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/Stack4.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/Stack4.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/Stack4.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/Stack4.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,43 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using Db4objects.Db4o.Foundation; + +namespace Db4objects.Db4o.Foundation +{ + /// + public class Stack4 + { + private List4 _tail; + + public virtual void Push(object obj) + { + _tail = new List4(_tail, obj); + } + + public virtual object Peek() + { + if (_tail == null) + { + return null; + } + return _tail._element; + } + + public virtual object Pop() + { + if (_tail == null) + { + throw new InvalidOperationException(); + } + object res = _tail._element; + _tail = ((List4)_tail._next); + return res; + } + + public virtual bool IsEmpty() + { + return _tail == null; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/StopWatch.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/StopWatch.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/StopWatch.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/StopWatch.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,48 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Foundation; +using Sharpen; + +namespace Db4objects.Db4o.Foundation +{ + public class StopWatch + { + private long _started; + + private long _elapsed; + + public StopWatch() + { + } + + public virtual void Start() + { + _started = Runtime.CurrentTimeMillis(); + } + + public virtual void Stop() + { + _elapsed = Peek(); + } + + public virtual long Peek() + { + return Runtime.CurrentTimeMillis() - _started; + } + + public virtual long Elapsed() + { + return _elapsed; + } + + public static long Time(IBlock4 block) + { + Db4objects.Db4o.Foundation.StopWatch stopWatch = new Db4objects.Db4o.Foundation.StopWatch + (); + stopWatch.Start(); + block.Run(); + stopWatch.Stop(); + return stopWatch.Elapsed(); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/SubTypePredicate.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/SubTypePredicate.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/SubTypePredicate.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/SubTypePredicate.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,22 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using Db4objects.Db4o.Foundation; + +namespace Db4objects.Db4o.Foundation +{ + public class SubTypePredicate : IPredicate4 + { + private readonly Type _class; + + public SubTypePredicate(Type clazz) + { + _class = clazz; + } + + public virtual bool Match(object candidate) + { + return _class.IsInstanceOfType(candidate); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/SynchronizedHashtable4.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/SynchronizedHashtable4.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/SynchronizedHashtable4.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/SynchronizedHashtable4.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,46 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Foundation; + +namespace Db4objects.Db4o.Foundation +{ + /// + public class SynchronizedHashtable4 : IDeepClone + { + private readonly Hashtable4 _delegate; + + private SynchronizedHashtable4(Hashtable4 delegate_) + { + _delegate = delegate_; + } + + public SynchronizedHashtable4(int size) : this(new Hashtable4(size)) + { + } + + public virtual object DeepClone(object obj) + { + lock (this) + { + return new Db4objects.Db4o.Foundation.SynchronizedHashtable4((Hashtable4)_delegate + .DeepClone(obj)); + } + } + + public virtual void Put(object key, object value) + { + lock (this) + { + _delegate.Put(key, value); + } + } + + public virtual object Get(object key) + { + lock (this) + { + return _delegate.Get(key); + } + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/SynchronizedIterator4.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/SynchronizedIterator4.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/SynchronizedIterator4.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/SynchronizedIterator4.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,46 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System.Collections; + +namespace Db4objects.Db4o.Foundation +{ + public class SynchronizedIterator4 : IEnumerator + { + private readonly IEnumerator _delegate; + + private readonly object _lock; + + public SynchronizedIterator4(IEnumerator delegate_, object Lock) + { + _delegate = delegate_; + _lock = Lock; + } + + public virtual object Current + { + get + { + lock (_lock) + { + return _delegate.Current; + } + } + } + + public virtual bool MoveNext() + { + lock (_lock) + { + return _delegate.MoveNext(); + } + } + + public virtual void Reset() + { + lock (_lock) + { + _delegate.Reset(); + } + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/TernaryBool.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/TernaryBool.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/TernaryBool.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/TernaryBool.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,138 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +namespace Db4objects.Db4o.Foundation +{ + /// yes/no/dontknow data type + /// + [System.Serializable] + public sealed class TernaryBool + { + private const int NoId = -1; + + private const int YesId = 1; + + private const int UnspecifiedId = 0; + + public static readonly Db4objects.Db4o.Foundation.TernaryBool No = new Db4objects.Db4o.Foundation.TernaryBool + (NoId); + + public static readonly Db4objects.Db4o.Foundation.TernaryBool Yes = new Db4objects.Db4o.Foundation.TernaryBool + (YesId); + + public static readonly Db4objects.Db4o.Foundation.TernaryBool Unspecified = new Db4objects.Db4o.Foundation.TernaryBool + (UnspecifiedId); + + private readonly int _value; + + private TernaryBool(int value) + { + _value = value; + } + + public bool BooleanValue(bool defaultValue) + { + switch (_value) + { + case NoId: + { + return false; + } + + case YesId: + { + return true; + } + + default: + { + return defaultValue; + break; + } + } + } + + public bool IsUnspecified() + { + return this == Unspecified; + } + + public bool DefiniteYes() + { + return this == Yes; + } + + public bool DefiniteNo() + { + return this == No; + } + + public static Db4objects.Db4o.Foundation.TernaryBool ForBoolean(bool value) + { + return (value ? Yes : No); + } + + public override bool Equals(object obj) + { + if (this == obj) + { + return true; + } + if (obj == null || GetType() != obj.GetType()) + { + return false; + } + Db4objects.Db4o.Foundation.TernaryBool tb = (Db4objects.Db4o.Foundation.TernaryBool + )obj; + return _value == tb._value; + } + + public override int GetHashCode() + { + return _value; + } + + private object ReadResolve() + { + switch (_value) + { + case NoId: + { + return No; + } + + case YesId: + { + return Yes; + } + + default: + { + return Unspecified; + break; + } + } + } + + public override string ToString() + { + switch (_value) + { + case NoId: + { + return "NO"; + } + + case YesId: + { + return "YES"; + } + + default: + { + return "UNSPECIFIED"; + break; + } + } + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/ThreadLocal4.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/ThreadLocal4.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/ThreadLocal4.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/ThreadLocal4.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,57 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System.Collections; +using Sharpen.Lang; + +namespace Db4objects.Db4o.Foundation +{ + /// + /// ThreadLocal implementation for less capable platforms such as JRE 1.1 and + /// Silverlight. + /// + /// + /// ThreadLocal implementation for less capable platforms such as JRE 1.1 and + /// Silverlight. + /// This class is not intended to be used directly, use + /// DynamicVariable + /// . + /// WARNING: This implementation might leak Thread references unless + /// Set(object) + /// is called with null on the right thread to clean it up. This + /// behavior is currently guaranteed by + /// DynamicVariable + /// . + /// + public class ThreadLocal4 + { + private readonly IDictionary _values = new Hashtable(); + + public virtual void Set(object value) + { + lock (this) + { + if (value == null) + { + Sharpen.Collections.Remove(_values, Thread.CurrentThread()); + } + else + { + _values[Thread.CurrentThread()] = value; + } + } + } + + public virtual object Get() + { + lock (this) + { + return _values[Thread.CurrentThread()]; + } + } + + protected object InitialValue() + { + return null; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/TimeoutBlockingQueue.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/TimeoutBlockingQueue.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/TimeoutBlockingQueue.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/TimeoutBlockingQueue.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,39 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Foundation; +using Sharpen; + +namespace Db4objects.Db4o.Foundation +{ + public class TimeoutBlockingQueue : PausableBlockingQueue, ITimeoutBlockingQueue4 + { + private long expirationDate; + + private readonly long maxTimeToRemainPaused; + + public TimeoutBlockingQueue(long maxTimeToRemainPaused) + { + this.maxTimeToRemainPaused = maxTimeToRemainPaused; + } + + public override bool Pause() + { + Reset(); + return base.Pause(); + } + + public virtual void Check() + { + long now = Runtime.CurrentTimeMillis(); + if (now > expirationDate) + { + Resume(); + } + } + + public virtual void Reset() + { + expirationDate = Runtime.CurrentTimeMillis() + maxTimeToRemainPaused; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/TimeStampIdGenerator.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/TimeStampIdGenerator.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/TimeStampIdGenerator.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/TimeStampIdGenerator.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,91 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Sharpen; + +namespace Db4objects.Db4o.Foundation +{ + /// + public class TimeStampIdGenerator + { + public const int BitsReservedForCounter = 15; + + public const int CounterLimit = 64; + + private long _counter; + + private long _lastTime; + + public static long IdToMilliseconds(long id) + { + return id >> BitsReservedForCounter; + } + + public static long MillisecondsToId(long milliseconds) + { + return milliseconds << BitsReservedForCounter; + } + + public TimeStampIdGenerator(long minimumNext) + { + InternalSetMinimumNext(minimumNext); + } + + public TimeStampIdGenerator() : this(0) + { + } + + public virtual long Generate() + { + long t = Now(); + if (t > _lastTime) + { + _lastTime = t; + _counter = 0; + return MillisecondsToId(t); + } + UpdateTimeOnCounterLimitOverflow(); + _counter++; + UpdateTimeOnCounterLimitOverflow(); + return Last(); + } + + protected virtual long Now() + { + return Runtime.CurrentTimeMillis(); + } + + private void UpdateTimeOnCounterLimitOverflow() + { + if (_counter < CounterLimit) + { + return; + } + long timeIncrement = _counter / CounterLimit; + _lastTime += timeIncrement; + _counter -= (timeIncrement * CounterLimit); + } + + public virtual long Last() + { + return MillisecondsToId(_lastTime) + _counter; + } + + public virtual bool SetMinimumNext(long newMinimum) + { + if (newMinimum <= Last()) + { + return false; + } + InternalSetMinimumNext(newMinimum); + return true; + } + + private void InternalSetMinimumNext(long newNext) + { + _lastTime = IdToMilliseconds(newNext); + long timePart = MillisecondsToId(_lastTime); + _counter = newNext - timePart; + UpdateTimeOnCounterLimitOverflow(); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/Tree.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/Tree.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/Tree.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/Tree.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,694 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using Db4objects.Db4o.Foundation; + +namespace Db4objects.Db4o.Foundation +{ + /// + public abstract class Tree : IShallowClone, IDeepClone, IVisitable + { + public Tree _preceding; + + public int _size = 1; + + public Tree _subsequent; + + public static Tree Add(Tree oldTree, Tree newTree) + { + if (oldTree == null) + { + return newTree; + } + return (Tree)((Tree)oldTree).Add(newTree); + } + + public Tree Add(Tree newNode) + { + return Add(newNode, Compare(newNode)); + } + + /// + /// On adding a node to a tree, if it already exists, and if + /// Tree#duplicates() returns false, #isDuplicateOf() will be + /// called. + /// + /// + /// On adding a node to a tree, if it already exists, and if + /// Tree#duplicates() returns false, #isDuplicateOf() will be + /// called. The added node can then be asked for the node that + /// prevails in the tree using #duplicateOrThis(). This mechanism + /// allows doing find() and add() in one run. + /// + public virtual Tree Add(Tree newNode, int cmp) + { + if (cmp < 0) + { + if (_subsequent == null) + { + _subsequent = newNode; + _size++; + } + else + { + _subsequent = _subsequent.Add(newNode); + if (_preceding == null) + { + return (Tree)RotateLeft(); + } + return (Tree)Balance(); + } + } + else + { + if (cmp > 0 || ((Tree)newNode).Duplicates()) + { + if (_preceding == null) + { + _preceding = newNode; + _size++; + } + else + { + _preceding = _preceding.Add(newNode); + if (_subsequent == null) + { + return (Tree)RotateRight(); + } + return (Tree)Balance(); + } + } + else + { + return (Tree)((Tree)newNode).OnAttemptToAddDuplicate(this); + } + } + return (Tree)this; + } + + /// + /// On adding a node to a tree, if it already exists, and if + /// Tree#duplicates() returns false, #onAttemptToAddDuplicate() + /// will be called and the existing node will be stored in + /// this._preceding. + /// + /// + /// On adding a node to a tree, if it already exists, and if + /// Tree#duplicates() returns false, #onAttemptToAddDuplicate() + /// will be called and the existing node will be stored in + /// this._preceding. + /// This node node can then be asked for the node that prevails + /// in the tree on adding, using the #addedOrExisting() method. + /// This mechanism allows doing find() and add() in one run. + /// + public virtual Tree AddedOrExisting() + { + if (WasAddedToTree()) + { + return this; + } + return _preceding; + } + + public virtual bool WasAddedToTree() + { + return _size != 0; + } + + public Tree Balance() + { + int cmp = _subsequent.Nodes() - _preceding.Nodes(); + if (cmp < -2) + { + return RotateRight(); + } + else + { + if (cmp > 2) + { + return RotateLeft(); + } + else + { + SetSizeOwnPrecedingSubsequent(); + return this; + } + } + } + + public virtual Tree BalanceCheckNulls() + { + if (_subsequent == null) + { + if (_preceding == null) + { + SetSizeOwn(); + return this; + } + return RotateRight(); + } + else + { + if (_preceding == null) + { + return RotateLeft(); + } + } + return Balance(); + } + + public virtual void CalculateSize() + { + if (_preceding == null) + { + if (_subsequent == null) + { + SetSizeOwn(); + } + else + { + SetSizeOwnSubsequent(); + } + } + else + { + if (_subsequent == null) + { + SetSizeOwnPreceding(); + } + else + { + SetSizeOwnPrecedingSubsequent(); + } + } + } + + /// + /// returns 0, if keys are equal + /// uses this - other + /// returns positive if this is greater than a_to + /// returns negative if this is smaller than a_to + /// + public abstract int Compare(Tree a_to); + + public static Tree DeepClone(Tree a_tree, object a_param) + { + if (a_tree == null) + { + return null; + } + Tree newNode = (Tree)a_tree.DeepClone(a_param); + newNode._size = a_tree._size; + newNode._preceding = Tree.DeepClone(((Tree)a_tree._preceding), a_param); + newNode._subsequent = Tree.DeepClone(((Tree)a_tree._subsequent), a_param); + return newNode; + } + + public virtual object DeepClone(object a_param) + { + return ShallowClone(); + } + + public virtual bool Duplicates() + { + return true; + } + + public Tree Filter(IPredicate4 a_filter) + { + if (_preceding != null) + { + _preceding = _preceding.Filter(a_filter); + } + if (_subsequent != null) + { + _subsequent = _subsequent.Filter(a_filter); + } + if (!a_filter.Match(this)) + { + return Remove(); + } + return this; + } + + public static Tree Find(Tree inTree, Tree template) + { + if (inTree == null) + { + return null; + } + return inTree.Find(template); + } + + public Tree Find(Tree template) + { + Tree current = this; + while (true) + { + int comparisonResult = current.Compare(template); + if (comparisonResult == 0) + { + return current; + } + if (comparisonResult < 0) + { + current = ((Tree)current._subsequent); + } + else + { + current = ((Tree)current._preceding); + } + if (current == null) + { + return null; + } + } + } + + public static Tree FindGreaterOrEqual(Tree a_in, Tree a_finder) + { + if (a_in == null) + { + return null; + } + int cmp = a_in.Compare(a_finder); + if (cmp == 0) + { + return a_in; + } + // the highest node in the hierarchy !!! + if (cmp > 0) + { + Tree node = FindGreaterOrEqual(((Tree)a_in._preceding), a_finder); + if (node != null) + { + return node; + } + return a_in; + } + return FindGreaterOrEqual(((Tree)a_in._subsequent), a_finder); + } + + public static Tree FindSmaller(Tree a_in, Tree a_node) + { + if (a_in == null) + { + return null; + } + int cmp = a_in.Compare(a_node); + if (cmp < 0) + { + Tree node = FindSmaller(((Tree)a_in._subsequent), a_node); + if (node != null) + { + return node; + } + return a_in; + } + return FindSmaller(((Tree)a_in._preceding), a_node); + } + + public Tree First() + { + if (_preceding == null) + { + return this; + } + return _preceding.First(); + } + + public static Tree Last(Tree tree) + { + if (tree == null) + { + return null; + } + return tree.Last(); + } + + public Tree Last() + { + if (_subsequent == null) + { + return this; + } + return _subsequent.Last(); + } + + public virtual Tree OnAttemptToAddDuplicate(Tree oldNode) + { + _size = 0; + _preceding = oldNode; + return oldNode; + } + + /// the number of nodes in this tree for balancing + public virtual int Nodes() + { + return _size; + } + + public virtual int OwnSize() + { + return 1; + } + + public virtual Tree Remove() + { + if (_subsequent != null && _preceding != null) + { + _subsequent = _subsequent.RotateSmallestUp(); + _subsequent._preceding = _preceding; + _subsequent.CalculateSize(); + return _subsequent; + } + if (_subsequent != null) + { + return _subsequent; + } + return _preceding; + } + + public virtual void RemoveChildren() + { + _preceding = null; + _subsequent = null; + SetSizeOwn(); + } + + public virtual Tree RemoveFirst() + { + if (_preceding == null) + { + return _subsequent; + } + _preceding = _preceding.RemoveFirst(); + CalculateSize(); + return this; + } + + public static Tree RemoveLike(Tree from, Tree a_find) + { + if (from == null) + { + return null; + } + return from.RemoveLike(a_find); + } + + public Tree RemoveLike(Tree a_find) + { + int cmp = Compare(a_find); + if (cmp == 0) + { + return (Tree)Remove(); + } + if (cmp > 0) + { + if (_preceding != null) + { + _preceding = _preceding.RemoveLike(a_find); + } + } + else + { + if (_subsequent != null) + { + _subsequent = _subsequent.RemoveLike(a_find); + } + } + CalculateSize(); + return (Tree)this; + } + + public Tree RemoveNode(Tree a_tree) + { + if (this == a_tree) + { + return Remove(); + } + int cmp = Compare(a_tree); + if (cmp >= 0) + { + if (_preceding != null) + { + _preceding = _preceding.RemoveNode(a_tree); + } + } + if (cmp <= 0) + { + if (_subsequent != null) + { + _subsequent = _subsequent.RemoveNode(a_tree); + } + } + CalculateSize(); + return this; + } + + public Tree RotateLeft() + { + Tree tree = _subsequent; + _subsequent = ((Tree)tree._preceding); + CalculateSize(); + tree._preceding = this; + if (((Tree)tree._subsequent) == null) + { + tree.SetSizeOwnPlus(this); + } + else + { + tree.SetSizeOwnPlus(this, ((Tree)tree._subsequent)); + } + return tree; + } + + public Tree RotateRight() + { + Tree tree = _preceding; + _preceding = ((Tree)tree._subsequent); + CalculateSize(); + tree._subsequent = this; + if (((Tree)tree._preceding) == null) + { + tree.SetSizeOwnPlus(this); + } + else + { + tree.SetSizeOwnPlus(this, ((Tree)tree._preceding)); + } + return tree; + } + + private Tree RotateSmallestUp() + { + if (_preceding != null) + { + _preceding = _preceding.RotateSmallestUp(); + return RotateRight(); + } + return this; + } + + public void SetSizeOwn() + { + _size = OwnSize(); + } + + public void SetSizeOwnPrecedingSubsequent() + { + _size = OwnSize() + _preceding._size + _subsequent._size; + } + + public void SetSizeOwnPreceding() + { + _size = OwnSize() + _preceding._size; + } + + public void SetSizeOwnSubsequent() + { + _size = OwnSize() + _subsequent._size; + } + + public void SetSizeOwnPlus(Tree tree) + { + _size = OwnSize() + tree._size; + } + + public void SetSizeOwnPlus(Tree tree1, Tree tree2) + { + _size = OwnSize() + tree1._size + tree2._size; + } + + public static int Size(Tree a_tree) + { + if (a_tree == null) + { + return 0; + } + return a_tree.Size(); + } + + /// the number of objects represented. + public virtual int Size() + { + return _size; + } + + public static void Traverse(Tree tree, IVisitor4 visitor) + { + if (tree == null) + { + return; + } + tree.Traverse(visitor); + } + + /// Traverses a tree with a starting point node. + /// + /// Traverses a tree with a starting point node. + /// If there is no exact match for the starting node, the next higher will be taken. + /// + public static void Traverse(Tree tree, Tree startingNode, ICancellableVisitor4 visitor + ) + { + if (tree == null) + { + return; + } + tree.Traverse(startingNode, visitor); + } + + private bool Traverse(Tree startingNode, ICancellableVisitor4 visitor) + { + if (startingNode != null) + { + int cmp = Compare(startingNode); + if (cmp < 0) + { + if (_subsequent != null) + { + return _subsequent.Traverse(startingNode, visitor); + } + return true; + } + else + { + if (cmp > 0) + { + if (_preceding != null) + { + if (!_preceding.Traverse(startingNode, visitor)) + { + return false; + } + } + } + } + } + else + { + if (_preceding != null) + { + if (!_preceding.Traverse(null, visitor)) + { + return false; + } + } + } + if (!visitor.Visit(this)) + { + return false; + } + if (_subsequent != null) + { + if (!_subsequent.Traverse(null, visitor)) + { + return false; + } + } + return true; + } + + public void Traverse(IVisitor4 visitor) + { + if (_preceding != null) + { + _preceding.Traverse(visitor); + } + visitor.Visit((Tree)this); + if (_subsequent != null) + { + _subsequent.Traverse(visitor); + } + } + + public void TraverseFromLeaves(IVisitor4 a_visitor) + { + if (_preceding != null) + { + _preceding.TraverseFromLeaves(a_visitor); + } + if (_subsequent != null) + { + _subsequent.TraverseFromLeaves(a_visitor); + } + a_visitor.Visit(this); + } + + // Keep the debug method to debug the depth + // public final void debugLeafDepth(int currentDepth){ + // currentDepth++; + // if(_preceding == null && _subsequent == null){ + // System.out.println("" + currentDepth + " tree leaf depth."); + // return; + // } + // if (_preceding != null){ + // _preceding.debugLeafDepth(currentDepth); + // } + // if(_subsequent != null){ + // _subsequent.debugLeafDepth(currentDepth); + // } + // } + protected virtual Tree ShallowCloneInternal(Tree tree) + { + tree._preceding = _preceding; + tree._size = _size; + tree._subsequent = _subsequent; + return tree; + } + + public virtual object ShallowClone() + { + throw new NotImplementedException(); + } + + public abstract object Key(); + + public virtual object Root() + { + return this; + } + + public virtual void Accept(IVisitor4 visitor) + { + Traverse(new _IVisitor4_513(visitor)); + } + + private sealed class _IVisitor4_513 : IVisitor4 + { + public _IVisitor4_513(IVisitor4 visitor) + { + this.visitor = visitor; + } + + public void Visit(object obj) + { + Tree tree = (Tree)obj; + visitor.Visit(tree.Key()); + } + + private readonly IVisitor4 visitor; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/TreeKeyIterator.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/TreeKeyIterator.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/TreeKeyIterator.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/TreeKeyIterator.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,19 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Foundation; + +namespace Db4objects.Db4o.Foundation +{ + /// + public class TreeKeyIterator : AbstractTreeIterator + { + public TreeKeyIterator(Tree tree) : base(tree) + { + } + + protected override object CurrentValue(Tree tree) + { + return tree.Key(); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/TreeNodeIterator.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/TreeNodeIterator.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/TreeNodeIterator.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/TreeNodeIterator.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,19 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Foundation; + +namespace Db4objects.Db4o.Foundation +{ + /// + public class TreeNodeIterator : AbstractTreeIterator + { + public TreeNodeIterator(Tree tree) : base(tree) + { + } + + protected override object CurrentValue(Tree tree) + { + return tree.Root(); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/TreeObject.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/TreeObject.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/TreeObject.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Foundation/TreeObject.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,30 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Foundation; + +namespace Db4objects.Db4o.Foundation +{ + /// + public class TreeObject : Tree + { + private readonly object _object; + + private readonly IComparison4 _function; + + public TreeObject(object @object, IComparison4 function) + { + _object = @object; + _function = function; + } + + public override int Compare(Tree tree) + { + return _function.Compare(_object, tree.Key()); + } + + public override object Key() + { + return _object; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IBlobStatus.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IBlobStatus.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IBlobStatus.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IBlobStatus.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,11 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +namespace Db4objects.Db4o +{ + /// + /// com.db4o.internal.blobs + public interface IBlobStatus + { + double GetStatus(); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IBlobTransport.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IBlobTransport.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IBlobTransport.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IBlobTransport.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,20 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +#if !SILVERLIGHT +using Db4objects.Db4o.Internal; + +namespace Db4objects.Db4o +{ + /// + public interface IBlobTransport + { + /// + void WriteBlobTo(Transaction trans, BlobImpl blob); + + /// + void ReadBlobFrom(Transaction trans, BlobImpl blob); + + void DeleteBlobFile(Transaction trans, BlobImpl blob); + } +} +#endif // !SILVERLIGHT diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IEmbeddedObjectContainer.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IEmbeddedObjectContainer.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IEmbeddedObjectContainer.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IEmbeddedObjectContainer.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,41 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o; + +namespace Db4objects.Db4o +{ + /// + /// Represents a local ObjectContainer attached to a + /// database file. + /// + /// + /// Represents a local ObjectContainer attached to a + /// database file. + /// + /// 7.10 + public interface IEmbeddedObjectContainer : IObjectContainer + { + /// backs up a database file of an open ObjectContainer. + /// + /// backs up a database file of an open ObjectContainer. + ///

While the backup is running, the ObjectContainer can continue to be + /// used. Changes that are made while the backup is in progress, will be applied to + /// the open ObjectContainer and to the backup.

+ /// While the backup is running, the ObjectContainer should not be closed.

+ /// If a file already exists at the specified path, it will be overwritten.

+ /// The + /// Db4objects.Db4o.IO.IStorage + /// used for backup is the one configured for this container. + ///
+ /// a fully qualified path + /// db4o database file was closed or failed to open. + /// + /// + /// is thrown when the operation is not supported in current + /// configuration/environment + /// + /// I/O operation failed or was unexpectedly interrupted. + /// + void Backup(string path); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IInternal4.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IInternal4.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IInternal4.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IInternal4.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,11 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +namespace Db4objects.Db4o +{ + /// Marker interface to denote that a class is used for db4o internals. + /// Marker interface to denote that a class is used for db4o internals. + /// + public interface IInternal4 + { + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/AbstractBufferContext.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/AbstractBufferContext.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/AbstractBufferContext.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/AbstractBufferContext.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,100 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Marshall; +using Db4objects.Db4o.Marshall; + +namespace Db4objects.Db4o.Internal +{ + /// + public abstract class AbstractBufferContext : IBufferContext, IHandlerVersionContext + { + private IReadBuffer _buffer; + + private readonly Db4objects.Db4o.Internal.Transaction _transaction; + + public AbstractBufferContext(Db4objects.Db4o.Internal.Transaction transaction, IReadBuffer + buffer) + { + _transaction = transaction; + _buffer = buffer; + } + + public virtual IReadBuffer Buffer(IReadBuffer buffer) + { + IReadBuffer temp = _buffer; + _buffer = buffer; + return temp; + } + + public virtual IReadBuffer Buffer() + { + return _buffer; + } + + public virtual byte ReadByte() + { + return _buffer.ReadByte(); + } + + public virtual void ReadBytes(byte[] bytes) + { + _buffer.ReadBytes(bytes); + } + + public virtual int ReadInt() + { + return _buffer.ReadInt(); + } + + public virtual long ReadLong() + { + return _buffer.ReadLong(); + } + + public virtual int Offset() + { + return _buffer.Offset(); + } + + public virtual void Seek(int offset) + { + _buffer.Seek(offset); + } + + public virtual ObjectContainerBase Container() + { + return _transaction.Container(); + } + + public virtual IObjectContainer ObjectContainer() + { + return Container(); + } + + public virtual Db4objects.Db4o.Internal.Transaction Transaction() + { + return _transaction; + } + + public abstract int HandlerVersion(); + + public virtual bool IsLegacyHandlerVersion() + { + return HandlerVersion() == 0; + } + + public virtual BitMap4 ReadBitMap(int bitCount) + { + return _buffer.ReadBitMap(bitCount); + } + + public virtual Db4objects.Db4o.Internal.Marshall.SlotFormat SlotFormat() + { + return Db4objects.Db4o.Internal.Marshall.SlotFormat.ForHandlerVersion(HandlerVersion + ()); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/ActivatableBase.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/ActivatableBase.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/ActivatableBase.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/ActivatableBase.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,46 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using Db4objects.Db4o.Activation; +using Db4objects.Db4o.TA; + +namespace Db4objects.Db4o.Internal.Activation +{ + public abstract class ActivatableBase : IActivatable + { + [System.NonSerialized] + private IActivator _activator; + + public virtual void Bind(IActivator activator) + { + if (_activator == activator) + { + return; + } + if (activator != null && _activator != null) + { + throw new InvalidOperationException(); + } + _activator = activator; + } + + public virtual void Activate(ActivationPurpose purpose) + { + if (_activator == null) + { + return; + } + _activator.Activate(purpose); + } + + protected virtual void ActivateForRead() + { + Activate(ActivationPurpose.Read); + } + + protected virtual void ActivateForWrite() + { + Activate(ActivationPurpose.Write); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/ActivationContext4.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/ActivationContext4.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/ActivationContext4.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/ActivationContext4.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,123 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using Db4objects.Db4o; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Activation; +using Db4objects.Db4o.Typehandlers; + +namespace Db4objects.Db4o.Internal.Activation +{ + /// + public class ActivationContext4 : IActivationContext + { + private readonly Db4objects.Db4o.Internal.Transaction _transaction; + + private readonly object _targetObject; + + private readonly IActivationDepth _depth; + + public ActivationContext4(Db4objects.Db4o.Internal.Transaction transaction, object + obj, IActivationDepth depth) + { + if (null == obj) + { + throw new ArgumentNullException(); + } + _transaction = transaction; + _targetObject = obj; + _depth = depth; + } + + public virtual void CascadeActivationToTarget() + { + IActivationContext context = ClassMetadata().DescendOnCascadingActivation() ? Descend + () : this; + CascadeActivation(context); + } + + public virtual void CascadeActivationToChild(object obj) + { + if (obj == null) + { + return; + } + IActivationContext cascadingContext = ForObject(obj); + Db4objects.Db4o.Internal.ClassMetadata classMetadata = cascadingContext.ClassMetadata + (); + if (classMetadata == null || !classMetadata.HasIdentity()) + { + return; + } + CascadeActivation(cascadingContext.Descend()); + } + + private void CascadeActivation(IActivationContext context) + { + IActivationDepth depth = context.Depth(); + if (!depth.RequiresActivation()) + { + return; + } + if (depth.Mode().IsDeactivate()) + { + Container().StillToDeactivate(_transaction, context.TargetObject(), depth, false); + } + else + { + // FIXME: [TA] do we really need to check for isValueType here? + Db4objects.Db4o.Internal.ClassMetadata classMetadata = context.ClassMetadata(); + if (classMetadata.IsStruct()) + { + classMetadata.CascadeActivation(context); + } + else + { + Container().StillToActivate(context); + } + } + } + + public virtual ObjectContainerBase Container() + { + return _transaction.Container(); + } + + public virtual object TargetObject() + { + return _targetObject; + } + + public virtual Db4objects.Db4o.Internal.ClassMetadata ClassMetadata() + { + return Container().ClassMetadataForObject(_targetObject); + } + + public virtual IActivationDepth Depth() + { + return _depth; + } + + public virtual IObjectContainer ObjectContainer() + { + return Container(); + } + + public virtual Db4objects.Db4o.Internal.Transaction Transaction() + { + return _transaction; + } + + public virtual IActivationContext ForObject(object newTargetObject) + { + return new Db4objects.Db4o.Internal.Activation.ActivationContext4(Transaction(), + newTargetObject, Depth()); + } + + public virtual IActivationContext Descend() + { + return new Db4objects.Db4o.Internal.Activation.ActivationContext4(Transaction(), + TargetObject(), Depth().Descend(ClassMetadata())); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/ActivationDepthImpl.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/ActivationDepthImpl.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/ActivationDepthImpl.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/ActivationDepthImpl.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,26 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Activation; + +namespace Db4objects.Db4o.Internal.Activation +{ + public abstract class ActivationDepthImpl : IActivationDepth + { + protected readonly ActivationMode _mode; + + protected ActivationDepthImpl(ActivationMode mode) + { + _mode = mode; + } + + public virtual ActivationMode Mode() + { + return _mode; + } + + public abstract IActivationDepth Descend(ClassMetadata arg1); + + public abstract bool RequiresActivation(); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/ActivationMode.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/ActivationMode.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/ActivationMode.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/ActivationMode.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,72 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +namespace Db4objects.Db4o.Internal.Activation +{ + public sealed class ActivationMode + { + public static readonly Db4objects.Db4o.Internal.Activation.ActivationMode Activate + = new Db4objects.Db4o.Internal.Activation.ActivationMode(); + + public static readonly Db4objects.Db4o.Internal.Activation.ActivationMode Deactivate + = new Db4objects.Db4o.Internal.Activation.ActivationMode(); + + public static readonly Db4objects.Db4o.Internal.Activation.ActivationMode Peek = + new Db4objects.Db4o.Internal.Activation.ActivationMode(); + + public static readonly Db4objects.Db4o.Internal.Activation.ActivationMode Prefetch + = new Db4objects.Db4o.Internal.Activation.ActivationMode(); + + public static readonly Db4objects.Db4o.Internal.Activation.ActivationMode Refresh + = new Db4objects.Db4o.Internal.Activation.ActivationMode(); + + private ActivationMode() + { + } + + public override string ToString() + { + if (IsActivate()) + { + return "ACTIVATE"; + } + if (IsDeactivate()) + { + return "DEACTIVATE"; + } + if (IsPrefetch()) + { + return "PREFETCH"; + } + if (IsRefresh()) + { + return "REFRESH"; + } + return "PEEK"; + } + + public bool IsDeactivate() + { + return this == Deactivate; + } + + public bool IsActivate() + { + return this == Activate; + } + + public bool IsPeek() + { + return this == Peek; + } + + public bool IsPrefetch() + { + return this == Prefetch; + } + + public bool IsRefresh() + { + return this == Refresh; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/DepthUtil.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/DepthUtil.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/DepthUtil.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/DepthUtil.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,22 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +namespace Db4objects.Db4o.Internal.Activation +{ + public sealed class DepthUtil + { + public static int AdjustDepthToBorders(int depth) + { + int depthBorder = 2; + // TODO when can min value actually occur? + if (depth > int.MinValue && depth < depthBorder) + { + return depthBorder; + } + return depth; + } + + private DepthUtil() + { + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/DescendingActivationDepth.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/DescendingActivationDepth.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/DescendingActivationDepth.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/DescendingActivationDepth.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,28 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Activation; + +namespace Db4objects.Db4o.Internal.Activation +{ + public class DescendingActivationDepth : ActivationDepthImpl + { + private readonly IActivationDepthProvider _provider; + + public DescendingActivationDepth(IActivationDepthProvider provider, ActivationMode + mode) : base(mode) + { + _provider = provider; + } + + public override IActivationDepth Descend(ClassMetadata metadata) + { + return _provider.ActivationDepthFor(metadata, _mode); + } + + public override bool RequiresActivation() + { + return true; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/FixedActivationDepth.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/FixedActivationDepth.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/FixedActivationDepth.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/FixedActivationDepth.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,52 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Activation; + +namespace Db4objects.Db4o.Internal.Activation +{ + /// + /// Activates a fixed depth of the object graph regardless of + /// any existing activation depth configuration settings. + /// + /// + /// Activates a fixed depth of the object graph regardless of + /// any existing activation depth configuration settings. + /// + public class FixedActivationDepth : ActivationDepthImpl + { + private readonly int _depth; + + public FixedActivationDepth(int depth, ActivationMode mode) : base(mode) + { + _depth = depth; + } + + public FixedActivationDepth(int depth) : this(depth, ActivationMode.Activate) + { + } + + public override bool RequiresActivation() + { + return _depth > 0; + } + + public override IActivationDepth Descend(ClassMetadata metadata) + { + if (_depth < 1) + { + return this; + } + return new Db4objects.Db4o.Internal.Activation.FixedActivationDepth(_depth - 1, _mode + ); + } + + // TODO code duplication in fixed activation/update depth + public virtual Db4objects.Db4o.Internal.Activation.FixedActivationDepth AdjustDepthToBorders + () + { + return new Db4objects.Db4o.Internal.Activation.FixedActivationDepth(DepthUtil.AdjustDepthToBorders + (_depth)); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/FixedUpdateDepth.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/FixedUpdateDepth.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/FixedUpdateDepth.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/FixedUpdateDepth.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,105 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Activation; + +namespace Db4objects.Db4o.Internal.Activation +{ + public abstract class FixedUpdateDepth : IUpdateDepth + { + private int _depth; + + private bool _tpMode = false; + + public FixedUpdateDepth(int depth) + { + _depth = depth; + } + + public virtual void TpMode(bool tpMode) + { + _tpMode = tpMode; + } + + public virtual bool TpMode() + { + return _tpMode; + } + + public virtual bool SufficientDepth() + { + return _depth > 0; + } + + public virtual bool Negative() + { + // should never happen? + return _depth < 0; + } + + public override string ToString() + { + return GetType().FullName + ": " + _depth; + } + + public virtual IUpdateDepth Adjust(ClassMetadata clazz) + { + if (clazz.CascadesOnDeleteOrUpdate()) + { + return AdjustDepthToBorders().Descend(); + } + return Descend(); + } + + public virtual bool IsBroaderThan(Db4objects.Db4o.Internal.Activation.FixedUpdateDepth + other) + { + return _depth > other._depth; + } + + // TODO code duplication in fixed activation/update depth + public virtual Db4objects.Db4o.Internal.Activation.FixedUpdateDepth AdjustDepthToBorders + () + { + return ForDepth(DepthUtil.AdjustDepthToBorders(_depth)); + } + + public virtual IUpdateDepth AdjustUpdateDepthForCascade(bool isCollection) + { + int minimumUpdateDepth = isCollection ? 2 : 1; + if (_depth < minimumUpdateDepth) + { + return ForDepth(minimumUpdateDepth); + } + return this; + } + + public virtual IUpdateDepth Descend() + { + return ForDepth(_depth - 1); + } + + public override bool Equals(object other) + { + if (this == other) + { + return true; + } + if (other == null || GetType() != other.GetType()) + { + return false; + } + return _depth == ((Db4objects.Db4o.Internal.Activation.FixedUpdateDepth)other)._depth; + } + + public override int GetHashCode() + { + return _depth; + } + + protected abstract Db4objects.Db4o.Internal.Activation.FixedUpdateDepth ForDepth( + int depth); + + public abstract bool CanSkip(ObjectReference arg1); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/FullActivationDepth.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/FullActivationDepth.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/FullActivationDepth.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/FullActivationDepth.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,30 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Activation; + +namespace Db4objects.Db4o.Internal.Activation +{ + /// Activates the full object graph. + /// Activates the full object graph. + public class FullActivationDepth : ActivationDepthImpl + { + public FullActivationDepth(ActivationMode mode) : base(mode) + { + } + + public FullActivationDepth() : this(ActivationMode.Activate) + { + } + + public override IActivationDepth Descend(ClassMetadata metadata) + { + return this; + } + + public override bool RequiresActivation() + { + return true; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/IActivationDepth.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/IActivationDepth.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/IActivationDepth.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/IActivationDepth.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,18 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Activation; + +namespace Db4objects.Db4o.Internal.Activation +{ + /// Controls how deep an object graph is activated. + /// Controls how deep an object graph is activated. + public interface IActivationDepth + { + ActivationMode Mode(); + + bool RequiresActivation(); + + IActivationDepth Descend(ClassMetadata metadata); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/IActivationDepthProvider.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/IActivationDepthProvider.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/IActivationDepthProvider.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/IActivationDepthProvider.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,33 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Activation; + +namespace Db4objects.Db4o.Internal.Activation +{ + /// Factory for ActivationDepth strategies. + /// Factory for ActivationDepth strategies. + public interface IActivationDepthProvider + { + /// Returns an ActivationDepth suitable for the specified class and activation mode. + /// + /// Returns an ActivationDepth suitable for the specified class and activation mode. + /// + /// root class that's being activated + /// activation mode + /// an appropriate ActivationDepth for the class and activation mode + IActivationDepth ActivationDepthFor(ClassMetadata classMetadata, ActivationMode mode + ); + + /// Returns an ActivationDepth that will activate at most *depth* levels. + /// + /// Returns an ActivationDepth that will activate at most *depth* levels. + /// A special case is Integer.MAX_VALUE (int.MaxValue for .net) for which a + /// FullActivationDepth object must be returned. + /// + /// + /// + /// + IActivationDepth ActivationDepth(int depth, ActivationMode mode); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/IFixedDepth.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/IFixedDepth.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/IFixedDepth.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/IFixedDepth.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,11 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal.Activation; + +namespace Db4objects.Db4o.Internal.Activation +{ + public interface IFixedDepth + { + IFixedDepth AdjustDepthToBorders(); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/IModifiedObjectQuery.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/IModifiedObjectQuery.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/IModifiedObjectQuery.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/IModifiedObjectQuery.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,9 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +namespace Db4objects.Db4o.Internal.Activation +{ + public interface IModifiedObjectQuery + { + bool IsModified(object obj); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/ITransparentActivationDepthProvider.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/ITransparentActivationDepthProvider.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/ITransparentActivationDepthProvider.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/ITransparentActivationDepthProvider.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,19 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Activation; +using Db4objects.Db4o.TA; + +namespace Db4objects.Db4o.Internal.Activation +{ + /// + public interface ITransparentActivationDepthProvider : IActivationDepthProvider + { + void EnableTransparentPersistenceSupportFor(IInternalObjectContainer container, IRollbackStrategy + withRollbackStrategy); + + void AddModified(object @object, Transaction inTransaction); + + void RemoveModified(object @object, Transaction inTransaction); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/IUpdateDepth.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/IUpdateDepth.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/IUpdateDepth.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/IUpdateDepth.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,22 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Activation; + +namespace Db4objects.Db4o.Internal.Activation +{ + public interface IUpdateDepth + { + bool SufficientDepth(); + + bool Negative(); + + IUpdateDepth Adjust(ClassMetadata clazz); + + IUpdateDepth AdjustUpdateDepthForCascade(bool isCollection); + + IUpdateDepth Descend(); + + bool CanSkip(ObjectReference @ref); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/IUpdateDepthProvider.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/IUpdateDepthProvider.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/IUpdateDepthProvider.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/IUpdateDepthProvider.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,13 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal.Activation; + +namespace Db4objects.Db4o.Internal.Activation +{ + public interface IUpdateDepthProvider + { + UnspecifiedUpdateDepth Unspecified(IModifiedObjectQuery query); + + FixedUpdateDepth ForDepth(int depth); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/LegacyActivationDepth.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/LegacyActivationDepth.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/LegacyActivationDepth.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/LegacyActivationDepth.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,67 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Activation; + +namespace Db4objects.Db4o.Internal.Activation +{ + /// + /// Activates an object graph to a specific depth respecting any + /// activation configuration settings that might be in effect. + /// + /// + /// Activates an object graph to a specific depth respecting any + /// activation configuration settings that might be in effect. + /// + public class LegacyActivationDepth : ActivationDepthImpl + { + private readonly int _depth; + + public LegacyActivationDepth(int depth) : this(depth, ActivationMode.Activate) + { + } + + public LegacyActivationDepth(int depth, ActivationMode mode) : base(mode) + { + _depth = depth; + } + + public override IActivationDepth Descend(ClassMetadata metadata) + { + if (null == metadata) + { + return new Db4objects.Db4o.Internal.Activation.LegacyActivationDepth(_depth - 1, + _mode); + } + return new Db4objects.Db4o.Internal.Activation.LegacyActivationDepth(DescendDepth + (metadata), _mode); + } + + private int DescendDepth(ClassMetadata metadata) + { + int depth = ConfiguredActivationDepth(metadata) - 1; + if (metadata.IsStruct()) + { + // We also have to instantiate structs completely every time. + return Math.Max(1, depth); + } + return depth; + } + + private int ConfiguredActivationDepth(ClassMetadata metadata) + { + Config4Class config = metadata.ConfigOrAncestorConfig(); + if (config != null && _mode.IsActivate()) + { + return config.AdjustActivationDepth(_depth); + } + return _depth; + } + + public override bool RequiresActivation() + { + return _depth > 0; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/LegacyActivationDepthProvider.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/LegacyActivationDepthProvider.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/LegacyActivationDepthProvider.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/LegacyActivationDepthProvider.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,37 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Activation; + +namespace Db4objects.Db4o.Internal.Activation +{ + public class LegacyActivationDepthProvider : IActivationDepthProvider + { + public static readonly IActivationDepthProvider Instance = new LegacyActivationDepthProvider + (); + + public virtual IActivationDepth ActivationDepthFor(ClassMetadata classMetadata, ActivationMode + mode) + { + if (mode.IsPrefetch()) + { + return new LegacyActivationDepth(1, mode); + } + int globalLegacyActivationDepth = ConfigImpl(classMetadata).ActivationDepth(); + Config4Class config = classMetadata.ConfigOrAncestorConfig(); + int defaultDepth = null == config ? globalLegacyActivationDepth : config.AdjustActivationDepth + (globalLegacyActivationDepth); + return new LegacyActivationDepth(defaultDepth, mode); + } + + public virtual IActivationDepth ActivationDepth(int depth, ActivationMode mode) + { + return new LegacyActivationDepth(depth, mode); + } + + private Config4Impl ConfigImpl(ClassMetadata classMetadata) + { + return classMetadata.Container().ConfigImpl; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/LegacyFixedUpdateDepth.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/LegacyFixedUpdateDepth.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/LegacyFixedUpdateDepth.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/LegacyFixedUpdateDepth.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,24 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Activation; + +namespace Db4objects.Db4o.Internal.Activation +{ + public class LegacyFixedUpdateDepth : FixedUpdateDepth + { + public LegacyFixedUpdateDepth(int depth) : base(depth) + { + } + + public override bool CanSkip(ObjectReference @ref) + { + return false; + } + + protected override FixedUpdateDepth ForDepth(int depth) + { + return new Db4objects.Db4o.Internal.Activation.LegacyFixedUpdateDepth(depth); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/LegacyUnspecifiedUpdateDepth.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/LegacyUnspecifiedUpdateDepth.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/LegacyUnspecifiedUpdateDepth.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/LegacyUnspecifiedUpdateDepth.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,28 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Activation; + +namespace Db4objects.Db4o.Internal.Activation +{ + public class LegacyUnspecifiedUpdateDepth : UnspecifiedUpdateDepth + { + public static readonly Db4objects.Db4o.Internal.Activation.LegacyUnspecifiedUpdateDepth + Instance = new Db4objects.Db4o.Internal.Activation.LegacyUnspecifiedUpdateDepth + (); + + private LegacyUnspecifiedUpdateDepth() + { + } + + public override bool CanSkip(ObjectReference @ref) + { + return false; + } + + protected override FixedUpdateDepth ForDepth(int depth) + { + return new LegacyFixedUpdateDepth(depth); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/LegacyUpdateDepthProvider.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/LegacyUpdateDepthProvider.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/LegacyUpdateDepthProvider.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/LegacyUpdateDepthProvider.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,19 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal.Activation; + +namespace Db4objects.Db4o.Internal.Activation +{ + public class LegacyUpdateDepthProvider : IUpdateDepthProvider + { + public virtual FixedUpdateDepth ForDepth(int depth) + { + return new LegacyFixedUpdateDepth(depth); + } + + public virtual UnspecifiedUpdateDepth Unspecified(IModifiedObjectQuery query) + { + return LegacyUnspecifiedUpdateDepth.Instance; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/NonDescendingActivationDepth.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/NonDescendingActivationDepth.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/NonDescendingActivationDepth.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/NonDescendingActivationDepth.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,26 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Activation; + +namespace Db4objects.Db4o.Internal.Activation +{ + /// Transparent Activation strategy. + /// Transparent Activation strategy. + public class NonDescendingActivationDepth : ActivationDepthImpl + { + public NonDescendingActivationDepth(ActivationMode mode) : base(mode) + { + } + + public override IActivationDepth Descend(ClassMetadata metadata) + { + return this; + } + + public override bool RequiresActivation() + { + return false; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/NullModifiedObjectQuery.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/NullModifiedObjectQuery.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/NullModifiedObjectQuery.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/NullModifiedObjectQuery.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,21 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal.Activation; + +namespace Db4objects.Db4o.Internal.Activation +{ + public class NullModifiedObjectQuery : IModifiedObjectQuery + { + public static readonly IModifiedObjectQuery Instance = new Db4objects.Db4o.Internal.Activation.NullModifiedObjectQuery + (); + + private NullModifiedObjectQuery() + { + } + + public virtual bool IsModified(object @ref) + { + return false; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/TPFixedUpdateDepth.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/TPFixedUpdateDepth.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/TPFixedUpdateDepth.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/TPFixedUpdateDepth.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,30 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Activation; +using Db4objects.Db4o.TA; + +namespace Db4objects.Db4o.Internal.Activation +{ + public class TPFixedUpdateDepth : FixedUpdateDepth + { + private IModifiedObjectQuery _query; + + public TPFixedUpdateDepth(int depth, IModifiedObjectQuery query) : base(depth) + { + _query = query; + } + + public override bool CanSkip(ObjectReference @ref) + { + ClassMetadata clazz = @ref.ClassMetadata(); + return clazz.Reflector().ForClass(typeof(IActivatable)).IsAssignableFrom(clazz.ClassReflector + ()) && !_query.IsModified(@ref.GetObject()); + } + + protected override FixedUpdateDepth ForDepth(int depth) + { + return new Db4objects.Db4o.Internal.Activation.TPFixedUpdateDepth(depth, _query); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/TPUnspecifiedUpdateDepth.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/TPUnspecifiedUpdateDepth.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/TPUnspecifiedUpdateDepth.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/TPUnspecifiedUpdateDepth.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,30 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Activation; +using Db4objects.Db4o.TA; + +namespace Db4objects.Db4o.Internal.Activation +{ + public class TPUnspecifiedUpdateDepth : UnspecifiedUpdateDepth + { + private readonly IModifiedObjectQuery _query; + + internal TPUnspecifiedUpdateDepth(IModifiedObjectQuery query) + { + _query = query; + } + + public override bool CanSkip(ObjectReference @ref) + { + ClassMetadata clazz = @ref.ClassMetadata(); + return clazz.Reflector().ForClass(typeof(IActivatable)).IsAssignableFrom(clazz.ClassReflector + ()) && !_query.IsModified(@ref.GetObject()); + } + + protected override FixedUpdateDepth ForDepth(int depth) + { + return new TPFixedUpdateDepth(depth, _query); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/TPUpdateDepthProvider.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/TPUpdateDepthProvider.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/TPUpdateDepthProvider.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/TPUpdateDepthProvider.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,19 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal.Activation; + +namespace Db4objects.Db4o.Internal.Activation +{ + public class TPUpdateDepthProvider : IUpdateDepthProvider + { + public virtual FixedUpdateDepth ForDepth(int depth) + { + return new TPFixedUpdateDepth(depth, NullModifiedObjectQuery.Instance); + } + + public virtual UnspecifiedUpdateDepth Unspecified(IModifiedObjectQuery query) + { + return new TPUnspecifiedUpdateDepth(query); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/TransparentActivationDepthProviderImpl.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/TransparentActivationDepthProviderImpl.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/TransparentActivationDepthProviderImpl.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/TransparentActivationDepthProviderImpl.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,257 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using System.Collections; +using Db4objects.Db4o; +using Db4objects.Db4o.Events; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Activation; +using Db4objects.Db4o.Reflect.Generic; +using Db4objects.Db4o.TA; + +namespace Db4objects.Db4o.Internal.Activation +{ + public class TransparentActivationDepthProviderImpl : IActivationDepthProvider, ITransparentActivationDepthProvider + { + public virtual IActivationDepth ActivationDepth(int depth, ActivationMode mode) + { + if (int.MaxValue == depth) + { + return new FullActivationDepth(mode); + } + return new FixedActivationDepth(depth, mode); + } + + public virtual IActivationDepth ActivationDepthFor(ClassMetadata classMetadata, ActivationMode + mode) + { + if (IsTAAware(classMetadata)) + { + return new NonDescendingActivationDepth(mode); + } + if (mode.IsPrefetch()) + { + return new FixedActivationDepth(1, mode); + } + return new DescendingActivationDepth(this, mode); + } + + private bool IsTAAware(ClassMetadata classMetadata) + { + GenericReflector reflector = classMetadata.Reflector(); + return reflector.ForClass(typeof(IActivatable)).IsAssignableFrom(classMetadata.ClassReflector + ()); + } + + private IRollbackStrategy _rollbackStrategy; + + public bool _transparentPersistenceIsEnabled; + + public virtual void EnableTransparentPersistenceSupportFor(IInternalObjectContainer + container, IRollbackStrategy rollbackStrategy) + { + FlushOnQueryStarted(container); + _rollbackStrategy = rollbackStrategy; + _transparentPersistenceIsEnabled = true; + } + + private void FlushOnQueryStarted(IInternalObjectContainer container) + { + IEventRegistry registry = EventRegistryFactory.ForObjectContainer(container); + registry.QueryStarted += new System.EventHandler + (new _IEventListener4_46(this).OnEvent); + } + + private sealed class _IEventListener4_46 + { + public _IEventListener4_46(TransparentActivationDepthProviderImpl _enclosing) + { + this._enclosing = _enclosing; + } + + public void OnEvent(object sender, Db4objects.Db4o.Events.QueryEventArgs args) + { + this._enclosing.ObjectsModifiedIn(this._enclosing.TransactionFrom(args)).Flush(); + } + + private readonly TransparentActivationDepthProviderImpl _enclosing; + } + + protected virtual Transaction TransactionFrom(EventArgs args) + { + return (Transaction)((TransactionalEventArgs)args).Transaction(); + } + + public virtual void AddModified(object @object, Transaction transaction) + { + if (!_transparentPersistenceIsEnabled) + { + return; + } + ObjectsModifiedIn(transaction).Add(@object); + } + + public virtual void RemoveModified(object @object, Transaction transaction) + { + if (!_transparentPersistenceIsEnabled) + { + return; + } + ObjectsModifiedIn(transaction).Remove(@object); + } + + private sealed class _TransactionLocal_73 : TransactionLocal + { + public _TransactionLocal_73(TransparentActivationDepthProviderImpl _enclosing) + { + this._enclosing = _enclosing; + } + + public override object InitialValueFor(Transaction transaction) + { + TransparentActivationDepthProviderImpl.ObjectsModifiedInTransaction objectsModifiedInTransaction + = new TransparentActivationDepthProviderImpl.ObjectsModifiedInTransaction(transaction + ); + transaction.AddTransactionListener(new _ITransactionListener_77(this, objectsModifiedInTransaction + )); + return objectsModifiedInTransaction; + } + + private sealed class _ITransactionListener_77 : ITransactionListener + { + public _ITransactionListener_77(_TransactionLocal_73 _enclosing, TransparentActivationDepthProviderImpl.ObjectsModifiedInTransaction + objectsModifiedInTransaction) + { + this._enclosing = _enclosing; + this.objectsModifiedInTransaction = objectsModifiedInTransaction; + } + + public void PostRollback() + { + objectsModifiedInTransaction.Rollback(this._enclosing._enclosing._rollbackStrategy + ); + } + + public void PreCommit() + { + objectsModifiedInTransaction.Flush(); + } + + private readonly _TransactionLocal_73 _enclosing; + + private readonly TransparentActivationDepthProviderImpl.ObjectsModifiedInTransaction + objectsModifiedInTransaction; + } + + private readonly TransparentActivationDepthProviderImpl _enclosing; + } + + private readonly TransactionLocal _objectsModifiedInTransaction; + + private TransparentActivationDepthProviderImpl.ObjectsModifiedInTransaction ObjectsModifiedIn + (Transaction transaction) + { + return ((TransparentActivationDepthProviderImpl.ObjectsModifiedInTransaction)transaction + .Get(_objectsModifiedInTransaction).value); + } + + private sealed class ObjectsModifiedInTransaction + { + private readonly IdentitySet4 _removedAfterModified = new IdentitySet4(); + + private readonly IdentitySet4 _modified = new IdentitySet4(); + + private readonly Transaction _transaction; + + public ObjectsModifiedInTransaction(Transaction transaction) + { + _transaction = transaction; + } + + public void Add(object @object) + { + if (Contains(@object)) + { + return; + } + _modified.Add(@object); + } + + public void Remove(object @object) + { + if (!Contains(@object)) + { + return; + } + _modified.Remove(@object); + _removedAfterModified.Add(@object); + } + + private bool Contains(object @object) + { + return _modified.Contains(@object); + } + + public void Flush() + { + StoreModifiedObjects(); + _modified.Clear(); + } + + private void StoreModifiedObjects() + { + ObjectContainerBase container = _transaction.Container(); + container.StoreAll(_transaction, _modified.ValuesIterator(), container.UpdateDepthProvider + ().Unspecified(new _IModifiedObjectQuery_132(this))); + _transaction.ProcessDeletes(); + } + + private sealed class _IModifiedObjectQuery_132 : IModifiedObjectQuery + { + public _IModifiedObjectQuery_132(ObjectsModifiedInTransaction _enclosing) + { + this._enclosing = _enclosing; + } + + public bool IsModified(object obj) + { + return this._enclosing.Contains(obj); + } + + private readonly ObjectsModifiedInTransaction _enclosing; + } + + public void Rollback(IRollbackStrategy rollbackStrategy) + { + ApplyRollbackStrategy(rollbackStrategy); + _modified.Clear(); + } + + private void ApplyRollbackStrategy(IRollbackStrategy rollbackStrategy) + { + if (null == rollbackStrategy) + { + return; + } + ApplyRollbackStrategy(rollbackStrategy, _modified.ValuesIterator()); + ApplyRollbackStrategy(rollbackStrategy, _removedAfterModified.ValuesIterator()); + } + + private void ApplyRollbackStrategy(IRollbackStrategy rollbackStrategy, IEnumerator + values) + { + IObjectContainer objectContainer = _transaction.ObjectContainer(); + while (values.MoveNext()) + { + rollbackStrategy.Rollback(objectContainer, values.Current); + } + } + } + + public TransparentActivationDepthProviderImpl() + { + _objectsModifiedInTransaction = new _TransactionLocal_73(this); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/UnknownActivationDepth.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/UnknownActivationDepth.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/UnknownActivationDepth.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/UnknownActivationDepth.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,33 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Activation; + +namespace Db4objects.Db4o.Internal.Activation +{ + public class UnknownActivationDepth : IActivationDepth + { + public static readonly IActivationDepth Instance = new Db4objects.Db4o.Internal.Activation.UnknownActivationDepth + (); + + private UnknownActivationDepth() + { + } + + public virtual ActivationMode Mode() + { + throw new InvalidOperationException(); + } + + public virtual IActivationDepth Descend(ClassMetadata metadata) + { + throw new InvalidOperationException(); + } + + public virtual bool RequiresActivation() + { + throw new InvalidOperationException(); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/UnspecifiedUpdateDepth.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/UnspecifiedUpdateDepth.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/UnspecifiedUpdateDepth.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Activation/UnspecifiedUpdateDepth.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,51 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Activation; + +namespace Db4objects.Db4o.Internal.Activation +{ + public abstract class UnspecifiedUpdateDepth : IUpdateDepth + { + protected UnspecifiedUpdateDepth() + { + } + + public virtual bool SufficientDepth() + { + return true; + } + + public virtual bool Negative() + { + return true; + } + + public override string ToString() + { + return GetType().FullName; + } + + public virtual IUpdateDepth Adjust(ClassMetadata clazz) + { + FixedUpdateDepth depth = (FixedUpdateDepth)ForDepth(clazz.UpdateDepthFromConfig() + ).Descend(); + return depth; + } + + public virtual IUpdateDepth AdjustUpdateDepthForCascade(bool isCollection) + { + throw new InvalidOperationException(); + } + + public virtual IUpdateDepth Descend() + { + throw new InvalidOperationException(); + } + + protected abstract FixedUpdateDepth ForDepth(int depth); + + public abstract bool CanSkip(ObjectReference arg1); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/ArrayType.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/ArrayType.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/ArrayType.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/ArrayType.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,57 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; + +namespace Db4objects.Db4o.Internal +{ + /// + public class ArrayType + { + public static readonly Db4objects.Db4o.Internal.ArrayType None = new Db4objects.Db4o.Internal.ArrayType + (0); + + public static readonly Db4objects.Db4o.Internal.ArrayType PlainArray = new Db4objects.Db4o.Internal.ArrayType + (3); + + public static readonly Db4objects.Db4o.Internal.ArrayType MultidimensionalArray = + new Db4objects.Db4o.Internal.ArrayType(4); + + private ArrayType(int value) + { + _value = value; + } + + private readonly int _value; + + public virtual int Value() + { + return _value; + } + + public static Db4objects.Db4o.Internal.ArrayType ForValue(int value) + { + switch (value) + { + case 0: + { + return None; + } + + case 3: + { + return PlainArray; + } + + case 4: + { + return MultidimensionalArray; + } + + default: + { + throw new ArgumentException(); + } + } + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/BlobImpl.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/BlobImpl.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/BlobImpl.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/BlobImpl.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,321 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +#if !SILVERLIGHT +using System.IO; +using Db4objects.Db4o; +using Db4objects.Db4o.Ext; +using Db4objects.Db4o.Foundation.IO; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Activation; +using Db4objects.Db4o.Types; +using Sharpen; +using Sharpen.IO; + +namespace Db4objects.Db4o.Internal +{ + /// + /// Transfer of blobs to and from the db4o system, + /// if users use the Blob Db4oType. + /// + /// + /// Transfer of blobs to and from the db4o system, + /// if users use the Blob Db4oType. + /// + /// com.db4o.internal.blobs + /// + public class BlobImpl : IBlob, System.ICloneable, IDb4oTypeImpl + { + public const int CopybufferLength = 4096; + + public string fileName; + + public string i_ext; + + [System.NonSerialized] + private Sharpen.IO.File i_file; + + [System.NonSerialized] + private IBlobStatus i_getStatusFrom; + + public int i_length; + + [System.NonSerialized] + private double i_status = Status.Unused; + + [System.NonSerialized] + private ObjectContainerBase i_stream; + + [System.NonSerialized] + private Transaction i_trans; + + /// + public virtual int AdjustReadDepth(int depth) + { + return 1; + } + + private string CheckExt(Sharpen.IO.File file) + { + string name = file.GetName(); + int pos = name.LastIndexOf("."); + if (pos > 0) + { + i_ext = Sharpen.Runtime.Substring(name, pos); + return Sharpen.Runtime.Substring(name, 0, pos); + } + i_ext = string.Empty; + return name; + } + + /// + private static void Copy(Sharpen.IO.File from, Sharpen.IO.File to) + { + System.IO.File.Copy(from, to); + } + + public virtual object CreateDefault(Transaction a_trans) + { + BlobImpl bi = null; + bi = (BlobImpl)this.MemberwiseClone(); + bi.SetTrans(a_trans); + return bi; + } + + /// + public virtual FileInputStream GetClientInputStream() + { + return new FileInputStream(i_file); + } + + /// + public virtual FileOutputStream GetClientOutputStream() + { + return new FileOutputStream(i_file); + } + + public virtual string GetFileName() + { + return fileName; + } + + public virtual int GetLength() + { + return i_length; + } + + public virtual double GetStatus() + { + if (i_status == Status.Processing && i_getStatusFrom != null) + { + return i_getStatusFrom.GetStatus(); + } + if (i_status == Status.Unused) + { + if (i_length > 0) + { + i_status = Status.Available; + } + } + return i_status; + } + + public virtual void GetStatusFrom(IBlobStatus from) + { + i_getStatusFrom = from; + } + + public virtual bool HasClassIndex() + { + return false; + } + + /// + public virtual void ReadFrom(Sharpen.IO.File file) + { + if (!file.Exists()) + { + throw new IOException(Db4objects.Db4o.Internal.Messages.Get(41, file.GetAbsolutePath + ())); + } + i_length = (int)file.Length(); + CheckExt(file); + if (i_stream.IsClient) + { + i_file = file; + ((IBlobTransport)i_stream).ReadBlobFrom(i_trans, this); + } + else + { + ReadLocal(file); + } + } + + /// + public virtual void ReadLocal(Sharpen.IO.File file) + { + bool copied = false; + if (fileName == null) + { + Sharpen.IO.File newFile = new Sharpen.IO.File(ServerPath(), file.GetName()); + if (!newFile.Exists()) + { + Copy(file, newFile); + copied = true; + fileName = newFile.GetName(); + } + } + if (!copied) + { + Copy(file, ServerFile(CheckExt(file), true)); + } + lock (i_stream.Lock()) + { + i_stream.StoreInternal(i_trans, this, false); + } + i_status = Status.Completed; + } + + /// + public virtual Sharpen.IO.File ServerFile(string promptName, bool writeToServer) + { + lock (i_stream.Lock()) + { + i_stream.Activate(i_trans, this, new FixedActivationDepth(2)); + } + string path = ServerPath(); + i_stream.ConfigImpl.EnsureDirExists(path); + if (writeToServer) + { + if (fileName == null) + { + if (promptName != null) + { + fileName = promptName; + } + else + { + fileName = "b_" + Runtime.CurrentTimeMillis(); + } + string tryPath = fileName + i_ext; + int i = 0; + while (new Sharpen.IO.File(path, tryPath).Exists()) + { + tryPath = fileName + "_" + i++ + i_ext; + if (i == 99) + { + // should never happen + i_status = Status.Error; + throw new IOException(Db4objects.Db4o.Internal.Messages.Get(40)); + } + } + fileName = tryPath; + lock (i_stream.Lock()) + { + i_stream.StoreInternal(i_trans, this, false); + } + } + } + else + { + if (fileName == null) + { + throw new IOException(Db4objects.Db4o.Internal.Messages.Get(38)); + } + } + string lastTryPath = path + Sharpen.IO.File.separator + fileName; + if (!writeToServer) + { + if (!(new Sharpen.IO.File(lastTryPath).Exists())) + { + throw new IOException(Db4objects.Db4o.Internal.Messages.Get(39)); + } + } + return new Sharpen.IO.File(lastTryPath); + } + + /// + private string ServerPath() + { + string path = i_stream.ConfigImpl.BlobPath(); + if (path == null) + { + path = "blobs"; + } + i_stream.ConfigImpl.EnsureDirExists(path); + return path; + } + + public virtual void SetStatus(double status) + { + i_status = status; + } + + public virtual void SetTrans(Transaction a_trans) + { + i_trans = a_trans; + i_stream = a_trans.Container(); + } + + /// + public virtual void WriteLocal(Sharpen.IO.File file) + { + Copy(ServerFile(null, false), file); + i_status = Status.Completed; + } + + /// + public virtual void WriteTo(Sharpen.IO.File file) + { + if (GetStatus() == Status.Unused) + { + throw new IOException(Db4objects.Db4o.Internal.Messages.Get(43)); + } + if (i_stream.IsClient) + { + i_file = file; + i_status = Status.Queued; + ((IBlobTransport)i_stream).WriteBlobTo(i_trans, this); + } + else + { + WriteLocal(file); + } + } + + public virtual void SetObjectReference(ObjectReference objectReference) + { + } + + // not necessary + /// + public virtual void DeleteFile() + { + if (GetStatus() == Status.Unused) + { + throw new IOException(Db4objects.Db4o.Internal.Messages.Get(43)); + } + if (i_stream.IsClient) + { + ((IBlobTransport)i_stream).DeleteBlobFile(i_trans, this); + } + else + { + ServerFile(null, false).Delete(); + } + fileName = null; + i_ext = null; + i_length = 0; + SetStatus(Status.Unused); + lock (i_stream.Lock()) + { + i_stream.StoreInternal(i_trans, this, false); + } + } + + object System.ICloneable.Clone() + { + return MemberwiseClone(); + } + } +} +#endif // !SILVERLIGHT diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/BlockSizeBlockConverter.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/BlockSizeBlockConverter.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/BlockSizeBlockConverter.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/BlockSizeBlockConverter.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,43 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Slots; + +namespace Db4objects.Db4o.Internal +{ + /// + public sealed class BlockSizeBlockConverter : IBlockConverter + { + private readonly int _blockSize; + + public BlockSizeBlockConverter(int blockSize) + { + _blockSize = blockSize; + } + + public int BytesToBlocks(long bytes) + { + return (int)((bytes + _blockSize - 1) / _blockSize); + } + + public int BlockAlignedBytes(int bytes) + { + return BytesToBlocks(bytes) * _blockSize; + } + + public int BlocksToBytes(int blocks) + { + return blocks * _blockSize; + } + + public Slot ToBlockedLength(Slot slot) + { + return new Slot(slot.Address(), BytesToBlocks(slot.Length())); + } + + public Slot ToNonBlockedLength(Slot slot) + { + return new Slot(slot.Address(), BlocksToBytes(slot.Length())); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/AbstractBTreeRangeIterator.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/AbstractBTreeRangeIterator.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/AbstractBTreeRangeIterator.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/AbstractBTreeRangeIterator.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,67 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using System.Collections; +using Db4objects.Db4o.Internal.Btree; + +namespace Db4objects.Db4o.Internal.Btree +{ + public abstract class AbstractBTreeRangeIterator : IEnumerator + { + private readonly BTreeRangeSingle _range; + + private BTreePointer _cursor; + + private BTreePointer _current; + + public AbstractBTreeRangeIterator(BTreeRangeSingle range) + { + _range = range; + _cursor = range.First(); + } + + public virtual bool MoveNext() + { + if (ReachedEnd(_cursor)) + { + _current = null; + return false; + } + _current = _cursor; + _cursor = _cursor.Next(); + return true; + } + + public virtual void Reset() + { + _cursor = _range.First(); + } + + protected virtual BTreePointer CurrentPointer() + { + if (null == _current) + { + throw new InvalidOperationException(); + } + return _current; + } + + private bool ReachedEnd(BTreePointer cursor) + { + if (cursor == null) + { + return true; + } + if (_range.End() == null) + { + return false; + } + return _range.End().Equals(cursor); + } + + public abstract object Current + { + get; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/Algebra/BTreeAlgebra.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/Algebra/BTreeAlgebra.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/Algebra/BTreeAlgebra.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/Algebra/BTreeAlgebra.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,137 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System.Collections; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal.Btree; + +namespace Db4objects.Db4o.Internal.Btree.Algebra +{ + /// + internal class BTreeAlgebra + { + public static IBTreeRange Intersect(BTreeRangeUnion union, BTreeRangeSingle single + ) + { + SortedCollection4 collection = NewBTreeRangeSingleCollection(); + CollectIntersections(collection, union, single); + return ToRange(collection); + } + + public static IBTreeRange Intersect(BTreeRangeUnion union1, BTreeRangeUnion union2 + ) + { + SortedCollection4 collection = NewBTreeRangeSingleCollection(); + IEnumerator ranges = union1.Ranges(); + while (ranges.MoveNext()) + { + BTreeRangeSingle current = (BTreeRangeSingle)ranges.Current; + CollectIntersections(collection, union2, current); + } + return ToRange(collection); + } + + private static void CollectIntersections(SortedCollection4 collection, BTreeRangeUnion + union, BTreeRangeSingle single) + { + IEnumerator ranges = union.Ranges(); + while (ranges.MoveNext()) + { + BTreeRangeSingle current = (BTreeRangeSingle)ranges.Current; + if (single.Overlaps(current)) + { + collection.Add(single.Intersect(current)); + } + } + } + + public static IBTreeRange Intersect(BTreeRangeSingle single1, BTreeRangeSingle single2 + ) + { + BTreePointer first = BTreePointer.Max(single1.First(), single2.First()); + BTreePointer end = BTreePointer.Min(single1.End(), single2.End()); + return single1.NewBTreeRangeSingle(first, end); + } + + public static IBTreeRange Union(BTreeRangeUnion union1, BTreeRangeUnion union2) + { + IEnumerator ranges = union1.Ranges(); + IBTreeRange merged = union2; + while (ranges.MoveNext()) + { + merged = merged.Union((IBTreeRange)ranges.Current); + } + return merged; + } + + public static IBTreeRange Union(BTreeRangeUnion union, BTreeRangeSingle single) + { + if (single.IsEmpty()) + { + return union; + } + SortedCollection4 sorted = NewBTreeRangeSingleCollection(); + sorted.Add(single); + BTreeRangeSingle range = single; + IEnumerator ranges = union.Ranges(); + while (ranges.MoveNext()) + { + BTreeRangeSingle current = (BTreeRangeSingle)ranges.Current; + if (CanBeMerged(current, range)) + { + sorted.Remove(range); + range = Merge(current, range); + sorted.Add(range); + } + else + { + sorted.Add(current); + } + } + return ToRange(sorted); + } + + private static IBTreeRange ToRange(SortedCollection4 sorted) + { + if (1 == sorted.Size()) + { + return (IBTreeRange)sorted.SingleElement(); + } + return new BTreeRangeUnion(sorted); + } + + private static SortedCollection4 NewBTreeRangeSingleCollection() + { + return new SortedCollection4(BTreeRangeSingle.Comparison); + } + + public static IBTreeRange Union(BTreeRangeSingle single1, BTreeRangeSingle single2 + ) + { + if (single1.IsEmpty()) + { + return single2; + } + if (single2.IsEmpty()) + { + return single1; + } + if (CanBeMerged(single1, single2)) + { + return Merge(single1, single2); + } + return new BTreeRangeUnion(new BTreeRangeSingle[] { single1, single2 }); + } + + private static BTreeRangeSingle Merge(BTreeRangeSingle range1, BTreeRangeSingle range2 + ) + { + return range1.NewBTreeRangeSingle(BTreePointer.Min(range1.First(), range2.First() + ), BTreePointer.Max(range1.End(), range2.End())); + } + + private static bool CanBeMerged(BTreeRangeSingle range1, BTreeRangeSingle range2) + { + return range1.Overlaps(range2) || range1.Adjacent(range2); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/Algebra/BTreeRangeOperation.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/Algebra/BTreeRangeOperation.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/Algebra/BTreeRangeOperation.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/Algebra/BTreeRangeOperation.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,36 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal.Btree; + +namespace Db4objects.Db4o.Internal.Btree.Algebra +{ + /// + public abstract class BTreeRangeOperation : IBTreeRangeVisitor + { + private IBTreeRange _resultingRange; + + public BTreeRangeOperation() : base() + { + } + + public virtual IBTreeRange Dispatch(IBTreeRange range) + { + range.Accept(this); + return _resultingRange; + } + + public void Visit(BTreeRangeSingle single) + { + _resultingRange = Execute(single); + } + + public void Visit(BTreeRangeUnion union) + { + _resultingRange = Execute(union); + } + + protected abstract IBTreeRange Execute(BTreeRangeUnion union); + + protected abstract IBTreeRange Execute(BTreeRangeSingle single); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/Algebra/BTreeRangeSingleIntersect.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/Algebra/BTreeRangeSingleIntersect.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/Algebra/BTreeRangeSingleIntersect.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/Algebra/BTreeRangeSingleIntersect.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,25 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal.Btree; +using Db4objects.Db4o.Internal.Btree.Algebra; + +namespace Db4objects.Db4o.Internal.Btree.Algebra +{ + /// + public class BTreeRangeSingleIntersect : BTreeRangeSingleOperation + { + public BTreeRangeSingleIntersect(BTreeRangeSingle single) : base(single) + { + } + + protected override IBTreeRange Execute(BTreeRangeSingle single) + { + return BTreeAlgebra.Intersect(_single, single); + } + + protected override IBTreeRange Execute(BTreeRangeUnion union) + { + return BTreeAlgebra.Intersect(union, _single); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/Algebra/BTreeRangeSingleOperation.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/Algebra/BTreeRangeSingleOperation.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/Algebra/BTreeRangeSingleOperation.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/Algebra/BTreeRangeSingleOperation.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,18 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal.Btree; +using Db4objects.Db4o.Internal.Btree.Algebra; + +namespace Db4objects.Db4o.Internal.Btree.Algebra +{ + /// + public abstract class BTreeRangeSingleOperation : BTreeRangeOperation + { + protected readonly BTreeRangeSingle _single; + + public BTreeRangeSingleOperation(BTreeRangeSingle single) + { + _single = single; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/Algebra/BTreeRangeSingleUnion.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/Algebra/BTreeRangeSingleUnion.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/Algebra/BTreeRangeSingleUnion.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/Algebra/BTreeRangeSingleUnion.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,25 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal.Btree; +using Db4objects.Db4o.Internal.Btree.Algebra; + +namespace Db4objects.Db4o.Internal.Btree.Algebra +{ + /// + public class BTreeRangeSingleUnion : BTreeRangeSingleOperation + { + public BTreeRangeSingleUnion(BTreeRangeSingle single) : base(single) + { + } + + protected override IBTreeRange Execute(BTreeRangeSingle single) + { + return BTreeAlgebra.Union(_single, single); + } + + protected override IBTreeRange Execute(BTreeRangeUnion union) + { + return BTreeAlgebra.Union(union, _single); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/Algebra/BTreeRangeUnionIntersect.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/Algebra/BTreeRangeUnionIntersect.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/Algebra/BTreeRangeUnionIntersect.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/Algebra/BTreeRangeUnionIntersect.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,25 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal.Btree; +using Db4objects.Db4o.Internal.Btree.Algebra; + +namespace Db4objects.Db4o.Internal.Btree.Algebra +{ + /// + public class BTreeRangeUnionIntersect : BTreeRangeUnionOperation + { + public BTreeRangeUnionIntersect(BTreeRangeUnion union) : base(union) + { + } + + protected override IBTreeRange Execute(BTreeRangeSingle range) + { + return BTreeAlgebra.Intersect(_union, range); + } + + protected override IBTreeRange Execute(BTreeRangeUnion union) + { + return BTreeAlgebra.Intersect(_union, union); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/Algebra/BTreeRangeUnionOperation.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/Algebra/BTreeRangeUnionOperation.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/Algebra/BTreeRangeUnionOperation.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/Algebra/BTreeRangeUnionOperation.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,18 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal.Btree; +using Db4objects.Db4o.Internal.Btree.Algebra; + +namespace Db4objects.Db4o.Internal.Btree.Algebra +{ + /// + public abstract class BTreeRangeUnionOperation : BTreeRangeOperation + { + protected readonly BTreeRangeUnion _union; + + public BTreeRangeUnionOperation(BTreeRangeUnion union) + { + _union = union; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/Algebra/BTreeRangeUnionUnion.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/Algebra/BTreeRangeUnionUnion.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/Algebra/BTreeRangeUnionUnion.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/Algebra/BTreeRangeUnionUnion.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,25 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal.Btree; +using Db4objects.Db4o.Internal.Btree.Algebra; + +namespace Db4objects.Db4o.Internal.Btree.Algebra +{ + /// + public class BTreeRangeUnionUnion : BTreeRangeUnionOperation + { + public BTreeRangeUnionUnion(BTreeRangeUnion union) : base(union) + { + } + + protected override IBTreeRange Execute(BTreeRangeUnion union) + { + return BTreeAlgebra.Union(_union, union); + } + + protected override IBTreeRange Execute(BTreeRangeSingle single) + { + return BTreeAlgebra.Union(_union, single); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/BTreeAdd.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/BTreeAdd.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/BTreeAdd.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/BTreeAdd.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,73 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Btree; + +namespace Db4objects.Db4o.Internal.Btree +{ + /// + public class BTreeAdd : BTreePatch + { + public BTreeAdd(Transaction transaction, object obj) : base(transaction, obj) + { + } + + protected virtual object RolledBack(BTree btree) + { + btree.NotifyRemoveListener(new TransactionContext(_transaction, GetObject())); + return No4.Instance; + } + + public override string ToString() + { + return "(+) " + base.ToString(); + } + + public override object Commit(Transaction trans, BTree btree, BTreeNode node) + { + if (_transaction == trans) + { + return GetObject(); + } + return this; + } + + public override BTreePatch ForTransaction(Transaction trans) + { + if (_transaction == trans) + { + return this; + } + return null; + } + + public override object Key(Transaction trans) + { + if (_transaction != trans) + { + return No4.Instance; + } + return GetObject(); + } + + public override object Rollback(Transaction trans, BTree btree) + { + if (_transaction == trans) + { + return RolledBack(btree); + } + return this; + } + + public override bool IsAdd() + { + return true; + } + + public override int SizeDiff(Transaction trans) + { + return _transaction == trans ? 1 : 0; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/BTreeCancelledRemoval.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/BTreeCancelledRemoval.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/BTreeCancelledRemoval.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/BTreeCancelledRemoval.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,54 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Btree; + +namespace Db4objects.Db4o.Internal.Btree +{ + /// + public class BTreeCancelledRemoval : BTreeUpdate + { + private readonly object _newKey; + + public BTreeCancelledRemoval(Transaction transaction, object originalKey, object + newKey, BTreeUpdate existingPatches) : base(transaction, originalKey) + { + _newKey = newKey; + if (null != existingPatches) + { + Append(existingPatches); + } + } + + protected override void Committed(BTree btree) + { + } + + // do nothing + public override bool IsCancelledRemoval() + { + return true; + } + + public override string ToString() + { + return "(u) " + base.ToString(); + } + + protected override object GetCommittedObject() + { + return _newKey; + } + + protected override void AdjustSizeOnRemovalByOtherTransaction(BTree btree, BTreeNode + node) + { + } + + // The other transaction reduces the size, this entry ignores. + protected override int SizeDiff() + { + return 1; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/BTreeConfiguration.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/BTreeConfiguration.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/BTreeConfiguration.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/BTreeConfiguration.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,37 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal.Ids; +using Db4objects.Db4o.Internal.Slots; + +namespace Db4objects.Db4o.Internal.Btree +{ + /// + public class BTreeConfiguration + { + public static readonly Db4objects.Db4o.Internal.Btree.BTreeConfiguration Default = + new Db4objects.Db4o.Internal.Btree.BTreeConfiguration(null, 20, true); + + public readonly ITransactionalIdSystem _idSystem; + + public readonly SlotChangeFactory _slotChangeFactory; + + public readonly bool _canEnlistWithTransaction; + + public readonly int _cacheSize; + + public BTreeConfiguration(ITransactionalIdSystem idSystem, SlotChangeFactory slotChangeFactory + , int cacheSize, bool canEnlistWithTransaction) + { + _idSystem = idSystem; + _slotChangeFactory = slotChangeFactory; + _canEnlistWithTransaction = canEnlistWithTransaction; + _cacheSize = cacheSize; + } + + public BTreeConfiguration(ITransactionalIdSystem idSystem, int cacheSize, bool canEnlistWithTransaction + ) : this(idSystem, SlotChangeFactory.SystemObjects, cacheSize, canEnlistWithTransaction + ) + { + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/BTree.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/BTree.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/BTree.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/BTree.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,909 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using System.Collections; +using System.Text; +using Db4objects.Db4o; +using Db4objects.Db4o.Defragment; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Btree; +using Db4objects.Db4o.Internal.Caching; +using Db4objects.Db4o.Internal.Ids; +using Db4objects.Db4o.Marshall; + +namespace Db4objects.Db4o.Internal.Btree +{ + /// + public class BTree : LocalPersistentBase, ITransactionParticipant, IBTreeStructureListener + { + private readonly BTreeConfiguration _config; + + private const byte BtreeVersion = (byte)1; + + private const int DefragmentIncrementOffset = 1 + Const4.IntLength * 2; + + private readonly IIndexable4 _keyHandler; + + private BTreeNode _root; + + /// All instantiated nodes are held in this tree. + /// All instantiated nodes are held in this tree. + private TreeIntObject _nodes; + + private int _size; + + private IVisitor4 _removeListener; + + private sealed class _TransactionLocal_40 : TransactionLocal + { + public _TransactionLocal_40() + { + } + + // version byte + // size, node size + public override object InitialValueFor(Transaction transaction) + { + return 0; + } + } + + private readonly TransactionLocal _sizeDeltaInTransaction = new _TransactionLocal_40 + (); + + protected IQueue4 _processing; + + private int _nodeSize; + + internal int _halfNodeSize; + + private IBTreeStructureListener _structureListener; + + private readonly ICache4 _nodeCache; + + private TreeIntObject _evictedFromCache; + + private bool _disposed; + + public BTree(Transaction trans, BTreeConfiguration config, int id, IIndexable4 keyHandler + , int treeNodeSize) : base(config._idSystem) + { + _config = config; + if (null == keyHandler) + { + throw new ArgumentNullException(); + } + _nodeSize = treeNodeSize; + _nodeCache = CacheFactory.NewLRUIntCache(config._cacheSize); + _halfNodeSize = _nodeSize / 2; + _nodeSize = _halfNodeSize * 2; + _keyHandler = keyHandler; + SetID(id); + if (IsNew()) + { + SetStateDirty(); + _root = new BTreeNode(this, 0, true, 0, 0, 0); + _root.Write(trans.SystemTransaction()); + AddNode(_root); + Write(trans.SystemTransaction()); + } + else + { + SetStateDeactivated(); + } + } + + public BTree(Transaction trans, BTreeConfiguration config, IIndexable4 keyHandler + ) : this(trans, config, 0, keyHandler) + { + } + + public BTree(Transaction trans, BTreeConfiguration config, int id, IIndexable4 keyHandler + ) : this(trans, config, id, keyHandler, Config(trans).BTreeNodeSize()) + { + } + + public BTree(Transaction trans, int id, IIndexable4 keyHandler) : this(trans, BTreeConfiguration + .Default, id, keyHandler) + { + } + + public BTree(Transaction trans, int id, IIndexable4 keyHandler, int nodeSize) : this + (trans, BTreeConfiguration.Default, id, keyHandler, nodeSize) + { + } + + public virtual BTreeNode Root() + { + return _root; + } + + public virtual int NodeSize() + { + return _nodeSize; + } + + public virtual void Add(Transaction trans, object key) + { + KeyCantBeNull(key); + IPreparedComparison preparedComparison = _keyHandler.PrepareComparison(trans.Context + (), key); + Add(trans, preparedComparison, key); + } + + public virtual void Add(Transaction trans, IPreparedComparison preparedComparison + , object key) + { + EnsureActive(trans); + Enlist(trans); + BTreeNode rootOrSplit = _root.Add(trans, preparedComparison, key); + if (rootOrSplit != null && rootOrSplit != _root) + { + EnsureDirty(trans); + _root = new BTreeNode(trans, _root, rootOrSplit); + _root.Write(trans.SystemTransaction()); + AddNode(_root); + } + ConvertCacheEvictedNodesToReadMode(); + } + + public virtual object Remove(Transaction trans, object key) + { + BTreePointer bTreePointer = SearchPointer(trans, key); + if (bTreePointer == null) + { + return null; + } + object result = bTreePointer.Key(); + Enlist(trans); + IPreparedComparison preparedComparison = KeyHandler().PrepareComparison(trans.Context + (), key); + BTreeNode node = bTreePointer.Node(); + node.Remove(trans, preparedComparison, key, bTreePointer.Index()); + ConvertCacheEvictedNodesToReadMode(); + return result; + } + + public virtual IBTreeRange SearchRange(Transaction trans, object key) + { + KeyCantBeNull(key); + return SearchRange(trans, KeyHandler().PrepareComparison(trans.Context(), key)); + } + + public virtual BTreePointer SearchPointer(Transaction trans, object key) + { + EnsureActive(trans); + KeyCantBeNull(key); + IPreparedComparison preparedComparison = KeyHandler().PrepareComparison(trans.Context + (), key); + BTreeNodeSearchResult start = SearchLeaf(trans, preparedComparison, SearchTarget. + Lowest); + BTreePointer bTreePointer = start.FirstValidPointer(); + if (bTreePointer == null) + { + ConvertCacheEvictedNodesToReadMode(); + return null; + } + object found = bTreePointer.Key(); + ConvertCacheEvictedNodesToReadMode(); + if (preparedComparison.CompareTo(found) == 0) + { + return bTreePointer; + } + return null; + } + + public virtual object Search(Transaction trans, object key) + { + BTreePointer bTreePointer = SearchPointer(trans, key); + if (bTreePointer != null) + { + return bTreePointer.Key(); + } + return null; + } + + private IBTreeRange SearchRange(Transaction trans, IPreparedComparison preparedComparison + ) + { + EnsureActive(trans); + // TODO: Optimize the following. + // Part of the search operates against the same nodes. + // As long as the bounds are on one node, the search + // should walk the nodes in one go. + BTreeNodeSearchResult start = SearchLeaf(trans, preparedComparison, SearchTarget. + Lowest); + BTreeNodeSearchResult end = SearchLeaf(trans, preparedComparison, SearchTarget.Highest + ); + IBTreeRange range = start.CreateIncludingRange(end); + ConvertCacheEvictedNodesToReadMode(); + return range; + } + + private void KeyCantBeNull(object key) + { + if (null == key) + { + throw new ArgumentNullException(); + } + } + + public virtual IIndexable4 KeyHandler() + { + return _keyHandler; + } + + public virtual BTreeNodeSearchResult SearchLeaf(Transaction trans, object key, SearchTarget + target) + { + return SearchLeaf(trans, _keyHandler.PrepareComparison(trans.Context(), key), target + ); + } + + public virtual BTreeNodeSearchResult SearchLeaf(Transaction trans, IPreparedComparison + preparedComparison, SearchTarget target) + { + EnsureActive(trans); + BTreeNodeSearchResult result = _root.SearchLeaf(trans, preparedComparison, target + ); + ConvertCacheEvictedNodesToReadMode(); + return result; + } + + public virtual void Commit(Transaction transaction) + { + if (_disposed) + { + return; + } + UpdateSize(transaction); + CommitNodes(transaction); + FinishTransaction(transaction); + ConvertCacheEvictedNodesToReadMode(); + } + + private void UpdateSize(Transaction transaction) + { + ByRef sizeInTransaction = SizeIn(transaction); + int sizeModification = (((int)sizeInTransaction.value)); + if (sizeModification == 0) + { + return; + } + EnsureDirty(transaction); + _size += sizeModification; + sizeInTransaction.value = 0; + } + + private ByRef SizeIn(Transaction trans) + { + return trans.Get(_sizeDeltaInTransaction); + } + + private void CommitNodes(Transaction trans) + { + ProcessEachNode(new _IProcedure4_237(trans)); + } + + private sealed class _IProcedure4_237 : IProcedure4 + { + public _IProcedure4_237(Transaction trans) + { + this.trans = trans; + } + + public void Apply(object node) + { + ((BTreeNode)node).Commit(trans); + } + + private readonly Transaction trans; + } + + private void ProcessEachNode(IProcedure4 action) + { + if (_nodes == null) + { + return; + } + ProcessAllNodes(); + while (_processing.HasNext()) + { + action.Apply((BTreeNode)_processing.Next()); + } + _processing = null; + } + + public virtual void Rollback(Transaction trans) + { + RollbackNodes(trans); + FinishTransaction(trans); + ConvertCacheEvictedNodesToReadMode(); + } + + private void FinishTransaction(Transaction trans) + { + Transaction systemTransaction = trans.SystemTransaction(); + WriteAllNodes(systemTransaction); + Write(systemTransaction); + Purge(); + } + + private void RollbackNodes(Transaction trans) + { + ProcessEachNode(new _IProcedure4_266(trans)); + } + + private sealed class _IProcedure4_266 : IProcedure4 + { + public _IProcedure4_266(Transaction trans) + { + this.trans = trans; + } + + public void Apply(object node) + { + ((BTreeNode)node).Rollback(trans); + } + + private readonly Transaction trans; + } + + private void WriteAllNodes(Transaction systemTransaction) + { + if (_nodes == null) + { + return; + } + _nodes.Traverse(new _IVisitor4_275(systemTransaction)); + } + + private sealed class _IVisitor4_275 : IVisitor4 + { + public _IVisitor4_275(Transaction systemTransaction) + { + this.systemTransaction = systemTransaction; + } + + public void Visit(object obj) + { + ((BTreeNode)((TreeIntObject)obj).GetObject()).Write(systemTransaction); + } + + private readonly Transaction systemTransaction; + } + + private void Purge() + { + if (_nodes == null) + { + return; + } + Tree temp = _nodes; + _nodes = null; + _root.HoldChildrenAsIDs(); + AddNode(_root); + temp.Traverse(new _IVisitor4_294()); + for (IEnumerator entryIter = _nodeCache.GetEnumerator(); entryIter.MoveNext(); ) + { + BTreeNodeCacheEntry entry = ((BTreeNodeCacheEntry)entryIter.Current); + entry._node.HoldChildrenAsIDs(); + } + } + + private sealed class _IVisitor4_294 : IVisitor4 + { + public _IVisitor4_294() + { + } + + public void Visit(object obj) + { + BTreeNode node = (BTreeNode)((TreeIntObject)obj).GetObject(); + node.Purge(); + } + } + + private void ProcessAllNodes() + { + _processing = new NonblockingQueue(); + _nodes.Traverse(new _IVisitor4_311(this)); + } + + private sealed class _IVisitor4_311 : IVisitor4 + { + public _IVisitor4_311(BTree _enclosing) + { + this._enclosing = _enclosing; + } + + public void Visit(object node) + { + this._enclosing._processing.Add(((TreeIntObject)node).GetObject()); + } + + private readonly BTree _enclosing; + } + + private void EnsureActive(Transaction trans) + { + if (!IsActive()) + { + Read(trans.SystemTransaction()); + } + } + + private void EnsureDirty(Transaction trans) + { + EnsureActive(trans); + Enlist(trans); + SetStateDirty(); + } + + private void Enlist(Transaction trans) + { + if (CanEnlistWithTransaction()) + { + ((LocalTransaction)trans).Enlist(this); + } + } + + protected virtual bool CanEnlistWithTransaction() + { + return _config._canEnlistWithTransaction; + } + + public override byte GetIdentifier() + { + return Const4.Btree; + } + + public virtual void SetRemoveListener(IVisitor4 vis) + { + _removeListener = vis; + } + + public override int OwnLength() + { + return 1 + Const4.ObjectLength + (Const4.IntLength * 2) + Const4.IdLength; + } + + public virtual BTreeNode ProduceNode(int id) + { + if (DTrace.enabled) + { + DTrace.BtreeProduceNode.Log(id); + } + TreeIntObject addtio = new TreeIntObject(id); + _nodes = (TreeIntObject)((TreeIntObject)Tree.Add(_nodes, addtio)); + TreeIntObject tio = (TreeIntObject)addtio.AddedOrExisting(); + BTreeNode node = (BTreeNode)tio.GetObject(); + if (node == null) + { + node = CacheEntry(new BTreeNode(id, this))._node; + tio.SetObject(node); + AddToProcessing(node); + } + return node; + } + + internal virtual void AddNode(BTreeNode node) + { + _nodes = (TreeIntObject)((TreeIntObject)Tree.Add(_nodes, new TreeIntObject(node.GetID + (), node))); + AddToProcessing(node); + } + + internal virtual void AddToProcessing(BTreeNode node) + { + if (_processing != null) + { + _processing.Add(node); + } + } + + internal virtual void RemoveNode(BTreeNode node) + { + _nodes = (TreeIntObject)((TreeInt)_nodes.RemoveLike(new TreeInt(node.GetID()))); + } + + internal virtual void NotifyRemoveListener(object obj) + { + if (_removeListener != null) + { + _removeListener.Visit(obj); + } + } + + public override void ReadThis(Transaction a_trans, ByteArrayBuffer a_reader) + { + a_reader.IncrementOffset(1); + // first byte is version, for possible future format changes + _size = a_reader.ReadInt(); + _nodeSize = a_reader.ReadInt(); + _halfNodeSize = NodeSize() / 2; + _root = ProduceNode(a_reader.ReadInt()); + } + + public override void WriteThis(Transaction trans, ByteArrayBuffer a_writer) + { + a_writer.WriteByte(BtreeVersion); + a_writer.WriteInt(_size); + a_writer.WriteInt(NodeSize()); + a_writer.WriteIDOf(trans, _root); + } + + public virtual int Size(Transaction trans) + { + // This implementation of size will not work accurately for multiple + // transactions. If two transactions call clear and both commit, _size + // can end up negative. + // For multiple transactions the size patches only are an estimate. + EnsureActive(trans); + return _size + (((int)SizeIn(trans).value)); + } + + public virtual void TraverseKeys(Transaction trans, IVisitor4 visitor) + { + EnsureActive(trans); + if (_root == null) + { + return; + } + _root.TraverseKeys(trans, visitor); + ConvertCacheEvictedNodesToReadMode(); + } + + public virtual void SizeChanged(Transaction transaction, BTreeNode node, int changeBy + ) + { + NotifyCountChanged(transaction, node, changeBy); + ByRef sizeInTransaction = SizeIn(transaction); + sizeInTransaction.value = (((int)sizeInTransaction.value)) + changeBy; + } + + public virtual void Dispose(Transaction transaction) + { + } + + public virtual BTreePointer FirstPointer(Transaction trans) + { + EnsureActive(trans); + if (null == _root) + { + return null; + } + BTreePointer pointer = _root.FirstPointer(trans); + ConvertCacheEvictedNodesToReadMode(); + return pointer; + } + + public virtual BTreePointer LastPointer(Transaction trans) + { + EnsureActive(trans); + if (null == _root) + { + return null; + } + BTreePointer pointer = _root.LastPointer(trans); + ConvertCacheEvictedNodesToReadMode(); + return pointer; + } + + public virtual Db4objects.Db4o.Internal.Btree.BTree DebugLoadFully(Transaction trans + ) + { + EnsureActive(trans); + _root.DebugLoadFully(trans); + return this; + } + + private void TraverseAllNodes(Transaction trans, IVisitor4 command) + { + EnsureActive(trans); + _root.TraverseAllNodes(trans, command); + } + + public virtual void DefragIndex(DefragmentContextImpl context) + { + context.IncrementOffset(DefragmentIncrementOffset); + context.CopyID(); + } + + public virtual void DefragIndexNode(DefragmentContextImpl context) + { + BTreeNode.DefragIndex(context, _keyHandler); + } + + public virtual void DefragBTree(IDefragmentServices services) + { + DefragmentContextImpl.ProcessCopy(services, GetID(), new _ISlotCopyHandler_481(this + )); + services.TraverseAllIndexSlots(this, new _IVisitor4_486(this, services)); + ConvertCacheEvictedNodesToReadMode(); + } + + private sealed class _ISlotCopyHandler_481 : ISlotCopyHandler + { + public _ISlotCopyHandler_481(BTree _enclosing) + { + this._enclosing = _enclosing; + } + + public void ProcessCopy(DefragmentContextImpl context) + { + this._enclosing.DefragIndex(context); + } + + private readonly BTree _enclosing; + } + + private sealed class _IVisitor4_486 : IVisitor4 + { + public _IVisitor4_486(BTree _enclosing, IDefragmentServices services) + { + this._enclosing = _enclosing; + this.services = services; + } + + public void Visit(object obj) + { + int id = ((int)obj); + DefragmentContextImpl.ProcessCopy(services, id, new _ISlotCopyHandler_489(this)); + } + + private sealed class _ISlotCopyHandler_489 : ISlotCopyHandler + { + public _ISlotCopyHandler_489(_IVisitor4_486 _enclosing) + { + this._enclosing = _enclosing; + } + + public void ProcessCopy(DefragmentContextImpl context) + { + this._enclosing._enclosing.DefragIndexNode(context); + } + + private readonly _IVisitor4_486 _enclosing; + } + + private readonly BTree _enclosing; + + private readonly IDefragmentServices services; + } + + internal virtual int CompareKeys(IContext context, object key1, object key2) + { + IPreparedComparison preparedComparison = _keyHandler.PrepareComparison(context, key1 + ); + return preparedComparison.CompareTo(key2); + } + + private static Config4Impl Config(Transaction trans) + { + if (null == trans) + { + throw new ArgumentNullException(); + } + return trans.Container().ConfigImpl; + } + + public override void Free(LocalTransaction systemTrans) + { + _disposed = true; + FreeAllNodeIds(systemTrans, AllNodeIds(systemTrans)); + base.Free((LocalTransaction)systemTrans); + } + + private void FreeAllNodeIds(LocalTransaction systemTrans, IEnumerator allNodeIDs) + { + ITransactionalIdSystem idSystem = IdSystem(systemTrans); + while (allNodeIDs.MoveNext()) + { + int id = ((int)allNodeIDs.Current); + idSystem.NotifySlotDeleted(id, SlotChangeFactory()); + } + } + + public virtual IEnumerator AllNodeIds(Transaction systemTrans) + { + Collection4 allNodeIDs = new Collection4(); + TraverseAllNodes(systemTrans, new _IVisitor4_527(allNodeIDs)); + return allNodeIDs.GetEnumerator(); + } + + private sealed class _IVisitor4_527 : IVisitor4 + { + public _IVisitor4_527(Collection4 allNodeIDs) + { + this.allNodeIDs = allNodeIDs; + } + + public void Visit(object node) + { + allNodeIDs.Add(((BTreeNode)node).GetID()); + } + + private readonly Collection4 allNodeIDs; + } + + public virtual IBTreeRange AsRange(Transaction trans) + { + return new BTreeRangeSingle(trans, this, FirstPointer(trans), null); + } + + private void TraverseAllNodes(IVisitor4 visitor) + { + if (_nodes == null) + { + return; + } + _nodes.Traverse(new _IVisitor4_543(visitor)); + } + + private sealed class _IVisitor4_543 : IVisitor4 + { + public _IVisitor4_543(IVisitor4 visitor) + { + this.visitor = visitor; + } + + public void Visit(object obj) + { + visitor.Visit(((TreeIntObject)obj).GetObject()); + } + + private readonly IVisitor4 visitor; + } + + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("BTree "); + sb.Append(GetID()); + sb.Append(" Active Nodes: \n"); + TraverseAllNodes(new _IVisitor4_555(sb)); + return sb.ToString(); + } + + private sealed class _IVisitor4_555 : IVisitor4 + { + public _IVisitor4_555(StringBuilder sb) + { + this.sb = sb; + } + + public void Visit(object obj) + { + sb.Append(obj); + sb.Append("\n"); + } + + private readonly StringBuilder sb; + } + + public virtual void StructureListener(IBTreeStructureListener listener) + { + _structureListener = listener; + } + + public virtual void NotifySplit(Transaction trans, BTreeNode originalNode, BTreeNode + newRightNode) + { + if (_structureListener != null) + { + _structureListener.NotifySplit(trans, originalNode, newRightNode); + } + } + + public virtual void NotifyDeleted(Transaction trans, BTreeNode node) + { + if (_structureListener != null) + { + _structureListener.NotifyDeleted(trans, node); + } + } + + public virtual void NotifyCountChanged(Transaction trans, BTreeNode node, int diff + ) + { + if (_structureListener != null) + { + _structureListener.NotifyCountChanged(trans, node, diff); + } + } + + public virtual IEnumerator Iterator(Transaction trans) + { + return new BTreeIterator(trans, this); + } + + public virtual void Clear(Transaction transaction) + { + BTreePointer currentPointer = FirstPointer(transaction); + while (currentPointer != null && currentPointer.IsValid()) + { + BTreeNode node = currentPointer.Node(); + int index = currentPointer.Index(); + node.Remove(transaction, index); + currentPointer = currentPointer.Next(); + } + } + + public virtual ICache4 NodeCache() + { + return _nodeCache; + } + + internal virtual BTreeNodeCacheEntry CacheEntry(BTreeNode node) + { + return ((BTreeNodeCacheEntry)_nodeCache.Produce(node.GetID(), new _IFunction4_605 + (node), new _IProcedure4_609(this))); + } + + private sealed class _IFunction4_605 : IFunction4 + { + public _IFunction4_605(BTreeNode node) + { + this.node = node; + } + + public object Apply(object id) + { + return new BTreeNodeCacheEntry(node); + } + + private readonly BTreeNode node; + } + + private sealed class _IProcedure4_609 : IProcedure4 + { + public _IProcedure4_609(BTree _enclosing) + { + this._enclosing = _enclosing; + } + + public void Apply(object entry) + { + this._enclosing.EvictedFromCache(((BTreeNodeCacheEntry)entry)._node); + } + + private readonly BTree _enclosing; + } + + public override Db4objects.Db4o.Internal.Slots.SlotChangeFactory SlotChangeFactory + () + { + return _config._slotChangeFactory; + } + + public virtual void EvictedFromCache(BTreeNode node) + { + _evictedFromCache = ((TreeIntObject)Tree.Add(_evictedFromCache, new TreeIntObject + (node.GetID(), node))); + } + + public virtual void ConvertCacheEvictedNodesToReadMode() + { + if (_evictedFromCache == null) + { + return; + } + Tree.Traverse(_evictedFromCache, new _IVisitor4_628()); + _evictedFromCache = null; + } + + private sealed class _IVisitor4_628 : IVisitor4 + { + public _IVisitor4_628() + { + } + + public void Visit(object treeIntObject) + { + ((BTreeNode)((TreeIntObject)treeIntObject)._object).ToReadMode(); + } + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/BTreeIterator.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/BTreeIterator.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/BTreeIterator.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/BTreeIterator.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,67 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using System.Collections; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Btree; + +namespace Db4objects.Db4o.Internal.Btree +{ + /// + public class BTreeIterator : IEnumerator + { + private readonly Transaction _transaction; + + private readonly BTree _bTree; + + private BTreePointer _currentPointer; + + private bool _beyondEnd; + + public BTreeIterator(Transaction trans, BTree bTree) + { + _transaction = trans; + _bTree = bTree; + } + + public virtual object Current + { + get + { + if (_currentPointer == null) + { + throw new InvalidOperationException(); + } + return _currentPointer.Key(); + } + } + + public virtual bool MoveNext() + { + if (_beyondEnd) + { + return false; + } + if (BeforeFirst()) + { + _currentPointer = _bTree.FirstPointer(_transaction); + } + else + { + _currentPointer = _currentPointer.Next(); + } + _beyondEnd = (_currentPointer == null); + return !_beyondEnd; + } + + private bool BeforeFirst() + { + return _currentPointer == null; + } + + public virtual void Reset() + { + throw new NotSupportedException(); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/BTreeNodeCacheEntry.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/BTreeNodeCacheEntry.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/BTreeNodeCacheEntry.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/BTreeNodeCacheEntry.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,30 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Btree; + +namespace Db4objects.Db4o.Internal.Btree +{ + /// + public class BTreeNodeCacheEntry + { + public readonly BTreeNode _node; + + private ByteArrayBuffer _buffer; + + public BTreeNodeCacheEntry(BTreeNode node) + { + _node = node; + } + + public virtual ByteArrayBuffer Buffer() + { + return _buffer; + } + + public virtual void Buffer(ByteArrayBuffer buffer) + { + _buffer = buffer; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/BTreeNode.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/BTreeNode.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/BTreeNode.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/BTreeNode.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,1458 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using Db4objects.Db4o; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Btree; +using Db4objects.Db4o.Internal.Ids; +using Db4objects.Db4o.Marshall; +using Sharpen; + +namespace Db4objects.Db4o.Internal.Btree +{ + /// + /// We work with BTreeNode in two states: + /// - deactivated: never read, no valid members, ID correct or 0 if new + /// - write: real representation of keys, values and children in arrays + /// The write state can be detected with canWrite(). + /// + /// + /// We work with BTreeNode in two states: + /// - deactivated: never read, no valid members, ID correct or 0 if new + /// - write: real representation of keys, values and children in arrays + /// The write state can be detected with canWrite(). States can be changed + /// as needed with prepareRead() and prepareWrite(). + /// + /// + public sealed class BTreeNode : LocalPersistentBase + { + private const int CountLeafAnd3LinkLength = (Const4.IntLength * 4) + 1; + + private const int SlotLeadingLength = Const4.LeadingLength + CountLeafAnd3LinkLength; + + internal readonly BTree _btree; + + private int _count; + + private bool _isLeaf; + + private object[] _keys; + + /// Can contain BTreeNode or Integer for ID of BTreeNode + private object[] _children; + + private int _parentID; + + private int _previousID; + + private int _nextID; + + private bool _dead; + + public BTreeNode(BTree btree, int count, bool isLeaf, int parentID, int previousID + , int nextID) + { + _btree = btree; + _parentID = parentID; + _previousID = previousID; + _nextID = nextID; + _count = count; + _isLeaf = isLeaf; + PrepareArrays(); + } + + public BTreeNode(int id, BTree btree) + { + _btree = btree; + SetID(id); + SetStateDeactivated(); + } + + public BTreeNode(Transaction trans, Db4objects.Db4o.Internal.Btree.BTreeNode firstChild + , Db4objects.Db4o.Internal.Btree.BTreeNode secondChild) : this(firstChild._btree + , 2, false, 0, 0, 0) + { + _keys[0] = firstChild._keys[0]; + _children[0] = firstChild; + _keys[1] = secondChild._keys[0]; + _children[1] = secondChild; + Write(trans.SystemTransaction()); + firstChild.SetParentID(trans, GetID()); + secondChild.SetParentID(trans, GetID()); + } + + public BTree Btree() + { + return _btree; + } + + /// + /// the split node if this node is split + /// or this if the first key has changed + /// + public Db4objects.Db4o.Internal.Btree.BTreeNode Add(Transaction trans, IPreparedComparison + preparedComparison, object obj) + { + ByteArrayBuffer reader = PrepareRead(trans); + Searcher s = Search(trans, preparedComparison, reader); + if (_isLeaf) + { + PrepareWrite(trans); + SetStateDirty(); + if (WasRemoved(trans, s)) + { + CancelRemoval(trans, obj, s.Cursor()); + return null; + } + if (s.Count() > 0 && !s.BeforeFirst()) + { + s.MoveForward(); + } + PrepareInsert(s.Cursor()); + _keys[s.Cursor()] = ApplyNewAddPatch(trans, obj); + } + else + { + Db4objects.Db4o.Internal.Btree.BTreeNode childNode = Child(reader, s.Cursor()); + Db4objects.Db4o.Internal.Btree.BTreeNode childNodeOrSplit = childNode.Add(trans, + preparedComparison, obj); + if (childNodeOrSplit == null) + { + return null; + } + PrepareWrite(trans); + SetStateDirty(); + _keys[s.Cursor()] = childNode._keys[0]; + if (childNode != childNodeOrSplit) + { + int splitCursor = s.Cursor() + 1; + PrepareInsert(splitCursor); + _keys[splitCursor] = childNodeOrSplit._keys[0]; + _children[splitCursor] = childNodeOrSplit; + } + } + if (MustSplit()) + { + return Split(trans); + } + if (s.Cursor() == 0) + { + return this; + } + return null; + } + + private bool MustSplit() + { + return _count >= _btree.NodeSize(); + } + + private BTreeAdd ApplyNewAddPatch(Transaction trans, object obj) + { + SizeIncrement(trans); + return new BTreeAdd(trans, obj); + } + + private void CancelRemoval(Transaction trans, object obj, int index) + { + BTreeUpdate patch = (BTreeUpdate)KeyPatch(index); + BTreeUpdate nextPatch = patch.RemoveFor(trans); + _keys[index] = NewCancelledRemoval(trans, patch.GetObject(), obj, nextPatch); + SizeIncrement(trans); + } + + private BTreePatch NewCancelledRemoval(Transaction trans, object originalObject, + object currentObject, BTreeUpdate existingPatches) + { + return new BTreeCancelledRemoval(trans, originalObject, currentObject, existingPatches + ); + } + + private void SizeIncrement(Transaction trans) + { + _btree.SizeChanged(trans, this, 1); + } + + private bool WasRemoved(Transaction trans, Searcher s) + { + if (!s.FoundMatch()) + { + return false; + } + BTreePatch patch = KeyPatch(trans, s.Cursor()); + return patch != null && patch.IsRemove(); + } + + internal BTreeNodeSearchResult SearchLeaf(Transaction trans, IPreparedComparison + preparedComparison, SearchTarget target) + { + ByteArrayBuffer reader = PrepareRead(trans); + Searcher s = Search(trans, preparedComparison, reader, target); + if (!_isLeaf) + { + return Child(reader, s.Cursor()).SearchLeaf(trans, preparedComparison, target); + } + if (!s.FoundMatch() || target == SearchTarget.Any || target == SearchTarget.Highest) + { + return new BTreeNodeSearchResult(trans, reader, Btree(), s, this); + } + if (target == SearchTarget.Lowest) + { + BTreeNodeSearchResult res = FindLowestLeafMatch(trans, preparedComparison, s.Cursor + () - 1); + if (res != null) + { + return res; + } + return CreateMatchingSearchResult(trans, reader, s.Cursor()); + } + throw new InvalidOperationException(); + } + + private BTreeNodeSearchResult FindLowestLeafMatch(Transaction trans, IPreparedComparison + preparedComparison, int index) + { + return FindLowestLeafMatch(trans, preparedComparison, PrepareRead(trans), index); + } + + private BTreeNodeSearchResult FindLowestLeafMatch(Transaction trans, IPreparedComparison + preparedComparison, ByteArrayBuffer reader, int index) + { + if (index >= 0) + { + if (!CompareEquals(preparedComparison, trans, reader, index)) + { + return null; + } + if (index > 0) + { + BTreeNodeSearchResult res = FindLowestLeafMatch(trans, preparedComparison, reader + , index - 1); + if (res != null) + { + return res; + } + return CreateMatchingSearchResult(trans, reader, index); + } + } + Db4objects.Db4o.Internal.Btree.BTreeNode node = PreviousNode(); + if (node != null) + { + ByteArrayBuffer nodeReader = node.PrepareRead(trans); + BTreeNodeSearchResult res = node.FindLowestLeafMatch(trans, preparedComparison, nodeReader + , node.LastIndex()); + if (res != null) + { + return res; + } + } + if (index < 0) + { + return null; + } + return CreateMatchingSearchResult(trans, reader, index); + } + + private bool CompareEquals(IPreparedComparison preparedComparison, Transaction trans + , ByteArrayBuffer reader, int index) + { + if (CanWrite()) + { + return CompareInWriteMode(preparedComparison, index) == 0; + } + return CompareInReadMode(trans, preparedComparison, reader, index) == 0; + } + + private BTreeNodeSearchResult CreateMatchingSearchResult(Transaction trans, ByteArrayBuffer + reader, int index) + { + return new BTreeNodeSearchResult(trans, reader, Btree(), this, index, true); + } + + public bool CanWrite() + { + return _keys != null; + } + + internal Db4objects.Db4o.Internal.Btree.BTreeNode Child(int index) + { + if (_children[index] is Db4objects.Db4o.Internal.Btree.BTreeNode) + { + return (Db4objects.Db4o.Internal.Btree.BTreeNode)_children[index]; + } + return ProduceChild(index, ((int)_children[index])); + } + + internal Db4objects.Db4o.Internal.Btree.BTreeNode Child(ByteArrayBuffer reader, int + index) + { + if (ChildLoaded(index)) + { + return (Db4objects.Db4o.Internal.Btree.BTreeNode)_children[index]; + } + return ProduceChild(index, ChildID(reader, index)); + } + + private Db4objects.Db4o.Internal.Btree.BTreeNode ProduceChild(int index, int childID + ) + { + Db4objects.Db4o.Internal.Btree.BTreeNode child = _btree.ProduceNode(childID); + if (_children != null) + { + _children[index] = child; + } + return child; + } + + private int ChildID(ByteArrayBuffer reader, int index) + { + if (_children == null) + { + SeekChild(reader, index); + return reader.ReadInt(); + } + return ChildID(index); + } + + private int ChildID(int index) + { + if (ChildLoaded(index)) + { + return ((Db4objects.Db4o.Internal.Btree.BTreeNode)_children[index]).GetID(); + } + return ((int)_children[index]); + } + + private bool ChildLoaded(int index) + { + if (_children == null) + { + return false; + } + return _children[index] is Db4objects.Db4o.Internal.Btree.BTreeNode; + } + + private bool ChildCanSupplyFirstKey(int index) + { + if (!ChildLoaded(index)) + { + return false; + } + return ((Db4objects.Db4o.Internal.Btree.BTreeNode)_children[index]).CanWrite(); + } + + public void Commit(Transaction trans) + { + CommitOrRollback(trans, true); + } + + internal void CommitOrRollback(Transaction trans, bool isCommit) + { + if (DTrace.enabled) + { + DTrace.BtreeNodeCommitOrRollback.Log(GetID()); + } + if (_dead) + { + return; + } + if (!_isLeaf) + { + return; + } + if (!IsDirty(trans)) + { + return; + } + object keyZero = _keys[0]; + object[] tempKeys = new object[_btree.NodeSize()]; + int count = 0; + for (int i = 0; i < _count; i++) + { + object key = _keys[i]; + BTreePatch patch = KeyPatch(i); + if (patch != null) + { + key = isCommit ? patch.Commit(trans, _btree, this) : patch.Rollback(trans, _btree + ); + } + if (key != No4.Instance) + { + tempKeys[count] = key; + count++; + } + } + _keys = tempKeys; + _count = count; + if (FreeIfEmpty(trans)) + { + return; + } + SetStateDirty(); + // TODO: Merge nodes here on low _count value. + if (_keys[0] != keyZero) + { + TellParentAboutChangedKey(trans); + } + } + + private bool FreeIfEmpty(Transaction trans) + { + return FreeIfEmpty(trans, _count); + } + + private bool FreeIfEmpty(Transaction trans, int count) + { + if (count > 0) + { + return false; + } + if (IsRoot()) + { + return false; + } + Free((LocalTransaction)trans); + return true; + } + + private bool IsRoot() + { + return _btree.Root() == this; + } + + public override bool Equals(object obj) + { + if (this == obj) + { + return true; + } + if (!(obj is Db4objects.Db4o.Internal.Btree.BTreeNode)) + { + return false; + } + Db4objects.Db4o.Internal.Btree.BTreeNode other = (Db4objects.Db4o.Internal.Btree.BTreeNode + )obj; + return GetID() == other.GetID(); + } + + public override int GetHashCode() + { + return GetID(); + } + + public override void Free(LocalTransaction trans) + { + _dead = true; + if (!IsRoot()) + { + Db4objects.Db4o.Internal.Btree.BTreeNode parent = _btree.ProduceNode(_parentID); + parent.RemoveChild(trans, this); + } + PointPreviousTo(trans, _nextID); + PointNextTo(trans, _previousID); + base.Free((LocalTransaction)trans); + _btree.RemoveNode(this); + _btree.NotifyDeleted(trans, this); + } + + internal void HoldChildrenAsIDs() + { + if (_children == null) + { + return; + } + for (int i = 0; i < _count; i++) + { + if (_children[i] is Db4objects.Db4o.Internal.Btree.BTreeNode) + { + _children[i] = ((Db4objects.Db4o.Internal.Btree.BTreeNode)_children[i]).GetID(); + } + } + } + + private void RemoveChild(Transaction trans, Db4objects.Db4o.Internal.Btree.BTreeNode + child) + { + PrepareWrite(trans); + SetStateDirty(); + int id = child.GetID(); + for (int i = 0; i < _count; i++) + { + if (ChildID(i) == id) + { + if (FreeIfEmpty(trans, _count - 1)) + { + return; + } + Remove(i); + if (i < 1) + { + TellParentAboutChangedKey(trans); + } + if (_count == 0) + { + // root node empty case only, have to turn it into a leaf + _isLeaf = true; + } + return; + } + } + throw new InvalidOperationException("child not found"); + } + + private void KeyChanged(Transaction trans, Db4objects.Db4o.Internal.Btree.BTreeNode + child) + { + PrepareWrite(trans); + SetStateDirty(); + int id = child.GetID(); + for (int i = 0; i < _count; i++) + { + if (ChildID(i) == id) + { + _keys[i] = child._keys[0]; + _children[i] = child; + KeyChanged(trans, i); + return; + } + } + throw new InvalidOperationException("child not found"); + } + + private void TellParentAboutChangedKey(Transaction trans) + { + if (!IsRoot()) + { + Db4objects.Db4o.Internal.Btree.BTreeNode parent = _btree.ProduceNode(_parentID); + parent.KeyChanged(trans, this); + } + } + + private bool IsDirty(Transaction trans) + { + if (!CanWrite()) + { + return false; + } + for (int i = 0; i < _count; i++) + { + if (KeyPatch(trans, i) != null) + { + return true; + } + } + return false; + } + + private int CompareInWriteMode(IPreparedComparison preparedComparison, int index) + { + return -preparedComparison.CompareTo(Key(index)); + } + + private int CompareInReadMode(Transaction trans, IPreparedComparison preparedComparison + , ByteArrayBuffer reader, int index) + { + SeekKey(reader, index); + return -preparedComparison.CompareTo(KeyHandler().ReadIndexEntry(trans.Context(), + reader)); + } + + public int Count() + { + return _count; + } + + private int EntryLength() + { + int len = KeyHandler().LinkLength(); + if (!_isLeaf) + { + len += Const4.IdLength; + } + return len; + } + + public int FirstKeyIndex(Transaction trans) + { + for (int ix = 0; ix < _count; ix++) + { + if (IndexIsValid(trans, ix)) + { + return ix; + } + } + return -1; + } + + public int LastKeyIndex(Transaction trans) + { + for (int ix = _count - 1; ix >= 0; ix--) + { + if (IndexIsValid(trans, ix)) + { + return ix; + } + } + return -1; + } + + public bool IndexIsValid(Transaction trans, int index) + { + if (!CanWrite()) + { + return true; + } + BTreePatch patch = KeyPatch(index); + if (patch == null) + { + return true; + } + return patch.Key(trans) != No4.Instance; + } + + private object FirstKey(Transaction trans) + { + int index = FirstKeyIndex(trans); + if (-1 == index) + { + return No4.Instance; + } + return InternalKey(trans, index); + } + + public override byte GetIdentifier() + { + return Const4.BtreeNode; + } + + private void PrepareInsert(int pos) + { + if (pos > LastIndex()) + { + _count++; + return; + } + int len = _count - pos; + System.Array.Copy(_keys, pos, _keys, pos + 1, len); + if (_children != null) + { + System.Array.Copy(_children, pos, _children, pos + 1, len); + } + _count++; + } + + private void Remove(int pos) + { + if (DTrace.enabled) + { + DTrace.BtreeNodeRemove.Log(GetID()); + } + int len = _count - pos; + _count--; + System.Array.Copy(_keys, pos + 1, _keys, pos, len); + _keys[_count] = null; + if (_children != null) + { + System.Array.Copy(_children, pos + 1, _children, pos, len); + _children[_count] = null; + } + } + + internal object Key(int index) + { + object obj = _keys[index]; + if (obj is BTreePatch) + { + return ((BTreePatch)obj).GetObject(); + } + return obj; + } + + public object Key(Transaction trans, int index) + { + return Key(trans, PrepareRead(trans), index); + } + + internal object Key(Transaction trans, ByteArrayBuffer reader, int index) + { + if (CanWrite()) + { + return InternalKey(trans, index); + } + if (reader == null) + { + reader = PrepareRead(trans); + } + if (CanWrite()) + { + return InternalKey(trans, index); + } + SeekKey(reader, index); + return KeyHandler().ReadIndexEntry(trans.Context(), reader); + } + + private object InternalKey(Transaction trans, int index) + { + BTreePatch patch = KeyPatch(index); + if (patch == null) + { + return _keys[index]; + } + return patch.Key(trans); + } + + private BTreePatch KeyPatch(int index) + { + object obj = _keys[index]; + if (obj is BTreePatch) + { + return (BTreePatch)obj; + } + return null; + } + + internal BTreePatch KeyPatch(Transaction trans, int index) + { + object obj = _keys[index]; + if (obj is BTreePatch) + { + return ((BTreePatch)obj).ForTransaction(trans); + } + return null; + } + + private IIndexable4 KeyHandler() + { + return _btree.KeyHandler(); + } + + public override int OwnLength() + { + return SlotLeadingLength + (_count * EntryLength()) + Const4.BracketsBytes; + } + + internal ByteArrayBuffer PrepareRead(Transaction trans) + { + BTreeNodeCacheEntry cacheEntry = Btree().CacheEntry(this); + if (CanWrite()) + { + return null; + } + if (IsNew()) + { + return null; + } + Transaction systemTransaction = trans.SystemTransaction(); + ByteArrayBuffer buffer = cacheEntry.Buffer(); + if (buffer != null) + { + // Cache hit, still unread + buffer.Seek(0); + Read(systemTransaction, buffer); + cacheEntry.Buffer(null); + _btree.AddToProcessing(this); + return null; + } + buffer = ProduceReadBuffer(systemTransaction); + ReadNodeHeader(buffer); + cacheEntry.Buffer(buffer); + return buffer; + } + + internal void PrepareWrite(Transaction trans) + { + if (_dead) + { + return; + } + BTreeNodeCacheEntry cacheEntry = Btree().CacheEntry(this); + if (CanWrite()) + { + return; + } + ByteArrayBuffer buffer = cacheEntry.Buffer(); + if (buffer != null) + { + buffer.Seek(0); + Read(trans.SystemTransaction(), buffer); + cacheEntry.Buffer(null); + } + else + { + Read(trans.SystemTransaction()); + } + _btree.AddToProcessing(this); + } + + private void PrepareArrays() + { + if (CanWrite()) + { + return; + } + _keys = new object[_btree.NodeSize()]; + if (!_isLeaf) + { + _children = new object[_btree.NodeSize()]; + } + } + + private void ReadNodeHeader(ByteArrayBuffer reader) + { + _count = reader.ReadInt(); + byte leafByte = reader.ReadByte(); + _isLeaf = (leafByte == 1); + _parentID = reader.ReadInt(); + _previousID = reader.ReadInt(); + _nextID = reader.ReadInt(); + } + + public override void ReadThis(Transaction trans, ByteArrayBuffer reader) + { + ReadNodeHeader(reader); + PrepareArrays(); + bool isInner = !_isLeaf; + for (int i = 0; i < _count; i++) + { + _keys[i] = KeyHandler().ReadIndexEntry(trans.Context(), reader); + if (isInner) + { + _children[i] = reader.ReadInt(); + } + } + } + + public void Remove(Transaction trans, int index) + { + if (!_isLeaf) + { + throw new InvalidOperationException(); + } + PrepareWrite(trans); + SetStateDirty(); + object obj = null; + BTreePatch patch = KeyPatch(index); + if (patch == null) + { + obj = _keys[index]; + } + else + { + BTreePatch transPatch = patch.ForTransaction(trans); + if (transPatch != null) + { + obj = transPatch.GetObject(); + } + else + { + // There could be more than one patch with different object + // identities. We have no means to determine a "best" object + // so we just take any one. Could be problematic. + obj = patch.GetObject(); + } + } + Remove(trans, obj, index); + } + + public bool Remove(Transaction trans, object obj, int index) + { + if (!_isLeaf) + { + throw new InvalidOperationException(); + } + PrepareWrite(trans); + SetStateDirty(); + BTreePatch patch = KeyPatch(index); + // no patch, no problem, can remove + if (patch == null) + { + _keys[index] = ApplyNewRemovePatch(trans, obj); + KeyChanged(trans, index); + return true; + } + BTreePatch transPatch = patch.ForTransaction(trans); + if (transPatch != null) + { + if (transPatch.IsAdd()) + { + CancelAdding(trans, index); + return true; + } + if (transPatch.IsCancelledRemoval()) + { + BTreeRemove removePatch = ApplyNewRemovePatch(trans, transPatch.GetObject()); + _keys[index] = ((BTreeUpdate)patch).ReplacePatch(transPatch, removePatch); + KeyChanged(trans, index); + return true; + } + } + else + { + // If the patch is a removal of a cancelled removal for another + // transaction, we need one for this transaction also. + if (!patch.IsAdd()) + { + ((BTreeUpdate)patch).Append(ApplyNewRemovePatch(trans, obj)); + return true; + } + } + return false; + } + + public void Remove(Transaction trans, IPreparedComparison preparedComparison, object + obj, int index) + { + if (Remove(trans, obj, index)) + { + return; + } + // now we try if removal is OK for the next element in this node + if (index != LastIndex()) + { + if (CompareInWriteMode(preparedComparison, index + 1) != 0) + { + return; + } + Remove(trans, preparedComparison, obj, index + 1); + return; + } + // nothing else worked so far, move on to the next node, try there + Db4objects.Db4o.Internal.Btree.BTreeNode node = NextNode(); + if (node == null) + { + return; + } + node.PrepareWrite(trans); + if (node.CompareInWriteMode(preparedComparison, 0) != 0) + { + return; + } + node.Remove(trans, preparedComparison, obj, 0); + } + + private void CancelAdding(Transaction trans, int index) + { + _btree.NotifyRemoveListener(new TransactionContext(trans, KeyPatch(index).GetObject + ())); + if (FreeIfEmpty(trans, _count - 1)) + { + SizeDecrement(trans); + return; + } + Remove(index); + KeyChanged(trans, index); + SizeDecrement(trans); + } + + private void SizeDecrement(Transaction trans) + { + _btree.SizeChanged(trans, this, -1); + } + + private int LastIndex() + { + return _count - 1; + } + + private BTreeRemove ApplyNewRemovePatch(Transaction trans, object key) + { + SizeDecrement(trans); + return new BTreeRemove(trans, key); + } + + private void KeyChanged(Transaction trans, int index) + { + if (index == 0) + { + TellParentAboutChangedKey(trans); + } + } + + internal void Rollback(Transaction trans) + { + CommitOrRollback(trans, false); + } + + private Searcher Search(Transaction trans, IPreparedComparison preparedComparison + , ByteArrayBuffer reader) + { + return Search(trans, preparedComparison, reader, SearchTarget.Any); + } + + private Searcher Search(Transaction trans, IPreparedComparison preparedComparison + , ByteArrayBuffer reader, SearchTarget target) + { + Searcher s = new Searcher(target, _count); + if (CanWrite()) + { + while (s.Incomplete()) + { + s.ResultIs(CompareInWriteMode(preparedComparison, s.Cursor())); + } + } + else + { + while (s.Incomplete()) + { + s.ResultIs(CompareInReadMode(trans, preparedComparison, reader, s.Cursor())); + } + } + return s; + } + + private void SeekAfterKey(ByteArrayBuffer reader, int ix) + { + SeekKey(reader, ix); + reader._offset += KeyHandler().LinkLength(); + } + + private void SeekChild(ByteArrayBuffer reader, int ix) + { + SeekAfterKey(reader, ix); + } + + private void SeekKey(ByteArrayBuffer reader, int ix) + { + reader._offset = SlotLeadingLength + (EntryLength() * ix); + } + + private Db4objects.Db4o.Internal.Btree.BTreeNode Split(Transaction trans) + { + Db4objects.Db4o.Internal.Btree.BTreeNode res = new Db4objects.Db4o.Internal.Btree.BTreeNode + (_btree, _btree._halfNodeSize, _isLeaf, _parentID, GetID(), _nextID); + System.Array.Copy(_keys, _btree._halfNodeSize, res._keys, 0, _btree._halfNodeSize + ); + for (int i = _btree._halfNodeSize; i < _keys.Length; i++) + { + _keys[i] = null; + } + if (_children != null) + { + res._children = new object[_btree.NodeSize()]; + System.Array.Copy(_children, _btree._halfNodeSize, res._children, 0, _btree._halfNodeSize + ); + for (int i = _btree._halfNodeSize; i < _children.Length; i++) + { + _children[i] = null; + } + } + _count = _btree._halfNodeSize; + res.Write(trans.SystemTransaction()); + _btree.AddNode(res); + int splitID = res.GetID(); + PointNextTo(trans, splitID); + SetNextID(trans, splitID); + if (_children != null) + { + for (int i = 0; i < _btree._halfNodeSize; i++) + { + if (res._children[i] == null) + { + break; + } + res.Child(i).SetParentID(trans, splitID); + } + } + _btree.NotifySplit(trans, this, res); + return res; + } + + private void PointNextTo(Transaction trans, int id) + { + if (_nextID != 0) + { + NextNode().SetPreviousID(trans, id); + } + } + + private void PointPreviousTo(Transaction trans, int id) + { + if (_previousID != 0) + { + PreviousNode().SetNextID(trans, id); + } + } + + public Db4objects.Db4o.Internal.Btree.BTreeNode PreviousNode() + { + if (_previousID == 0) + { + return null; + } + return _btree.ProduceNode(_previousID); + } + + public Db4objects.Db4o.Internal.Btree.BTreeNode NextNode() + { + if (_nextID == 0) + { + return null; + } + return _btree.ProduceNode(_nextID); + } + + internal BTreePointer FirstPointer(Transaction trans) + { + ByteArrayBuffer reader = PrepareRead(trans); + if (_isLeaf) + { + return LeafFirstPointer(trans, reader); + } + return BranchFirstPointer(trans, reader); + } + + private BTreePointer BranchFirstPointer(Transaction trans, ByteArrayBuffer reader + ) + { + for (int i = 0; i < _count; i++) + { + BTreePointer childFirstPointer = Child(reader, i).FirstPointer(trans); + if (childFirstPointer != null) + { + return childFirstPointer; + } + } + return null; + } + + private BTreePointer LeafFirstPointer(Transaction trans, ByteArrayBuffer reader) + { + int index = FirstKeyIndex(trans); + if (index == -1) + { + return null; + } + return new BTreePointer(trans, reader, this, index); + } + + public BTreePointer LastPointer(Transaction trans) + { + ByteArrayBuffer reader = PrepareRead(trans); + if (_isLeaf) + { + return LeafLastPointer(trans, reader); + } + return BranchLastPointer(trans, reader); + } + + private BTreePointer BranchLastPointer(Transaction trans, ByteArrayBuffer reader) + { + for (int i = _count - 1; i >= 0; i--) + { + BTreePointer childLastPointer = Child(reader, i).LastPointer(trans); + if (childLastPointer != null) + { + return childLastPointer; + } + } + return null; + } + + private BTreePointer LeafLastPointer(Transaction trans, ByteArrayBuffer reader) + { + int index = LastKeyIndex(trans); + if (index == -1) + { + return null; + } + return new BTreePointer(trans, reader, this, index); + } + + public void Purge() + { + if (_dead) + { + _keys = null; + _children = null; + return; + } + if (!IsPatched()) + { + return; + } + HoldChildrenAsIDs(); + _btree.AddNode(this); + } + + private bool IsPatched() + { + if (_dead) + { + return false; + } + if (!CanWrite()) + { + return false; + } + for (int i = 0; i < _count; i++) + { + if (_keys[i] is BTreePatch) + { + return true; + } + } + return false; + } + + private void SetParentID(Transaction trans, int id) + { + PrepareWrite(trans); + SetStateDirty(); + _parentID = id; + } + + private void SetPreviousID(Transaction trans, int id) + { + PrepareWrite(trans); + SetStateDirty(); + _previousID = id; + } + + private void SetNextID(Transaction trans, int id) + { + PrepareWrite(trans); + SetStateDirty(); + _nextID = id; + } + + public void TraverseKeys(Transaction trans, IVisitor4 visitor) + { + ByteArrayBuffer reader = PrepareRead(trans); + if (_isLeaf) + { + for (int i = 0; i < _count; i++) + { + object obj = Key(trans, reader, i); + if (obj != No4.Instance) + { + visitor.Visit(obj); + } + } + } + else + { + for (int i = 0; i < _count; i++) + { + Child(reader, i).TraverseKeys(trans, visitor); + } + } + } + + public override bool WriteObjectBegin() + { + if (_dead) + { + return false; + } + if (!CanWrite()) + { + return false; + } + return base.WriteObjectBegin(); + } + + public override void WriteThis(Transaction trans, ByteArrayBuffer buffer) + { + int count = 0; + int startOffset = buffer._offset; + IContext context = trans.Context(); + buffer.IncrementOffset(CountLeafAnd3LinkLength); + if (_isLeaf) + { + for (int i = 0; i < _count; i++) + { + object obj = InternalKey(trans, i); + if (obj != No4.Instance) + { + count++; + KeyHandler().WriteIndexEntry(context, buffer, obj); + } + } + } + else + { + for (int i = 0; i < _count; i++) + { + if (ChildCanSupplyFirstKey(i)) + { + Db4objects.Db4o.Internal.Btree.BTreeNode child = (Db4objects.Db4o.Internal.Btree.BTreeNode + )_children[i]; + object childKey = child.FirstKey(trans); + if (childKey != No4.Instance) + { + count++; + KeyHandler().WriteIndexEntry(context, buffer, childKey); + buffer.WriteIDOf(trans, child); + } + } + else + { + count++; + KeyHandler().WriteIndexEntry(context, buffer, Key(i)); + buffer.WriteIDOf(trans, _children[i]); + } + } + } + int endOffset = buffer._offset; + buffer._offset = startOffset; + buffer.WriteInt(count); + buffer.WriteByte(_isLeaf ? (byte)1 : (byte)0); + buffer.WriteInt(_parentID); + buffer.WriteInt(_previousID); + buffer.WriteInt(_nextID); + buffer._offset = endOffset; + } + + public override string ToString() + { + if (_count == 0) + { + return "Node " + GetID() + " not loaded"; + } + string str = "\nBTreeNode"; + str += "\nid: " + GetID(); + str += "\nparent: " + _parentID; + str += "\nprevious: " + _previousID; + str += "\nnext: " + _nextID; + str += "\ncount:" + _count; + str += "\nleaf:" + _isLeaf + "\n"; + if (CanWrite()) + { + str += " { "; + bool first = true; + for (int i = 0; i < _count; i++) + { + if (_keys[i] != null) + { + if (!first) + { + str += ", "; + } + str += _keys[i].ToString(); + first = false; + } + } + str += " }"; + } + return str; + } + + public void DebugLoadFully(Transaction trans) + { + PrepareWrite(trans); + if (_isLeaf) + { + return; + } + for (int i = 0; i < _count; ++i) + { + if (_children[i] is int) + { + _children[i] = Btree().ProduceNode(((int)_children[i])); + } + ((Db4objects.Db4o.Internal.Btree.BTreeNode)_children[i]).DebugLoadFully(trans); + } + } + + public static void DefragIndex(DefragmentContextImpl context, IIndexable4 keyHandler + ) + { + // count + int count = context.ReadInt(); + // leafByte + byte leafByte = context.ReadByte(); + bool isLeaf = (leafByte == 1); + context.CopyID(); + // parent ID + context.CopyID(); + // previous ID + context.CopyID(); + // next ID + for (int i = 0; i < count; i++) + { + keyHandler.DefragIndexEntry(context); + if (!isLeaf) + { + context.CopyID(); + } + } + } + + public bool IsLeaf() + { + return _isLeaf; + } + + /// This traversal goes over all nodes, not just leafs + internal void TraverseAllNodes(Transaction trans, IVisitor4 command) + { + ByteArrayBuffer reader = PrepareRead(trans); + command.Visit(this); + if (_isLeaf) + { + return; + } + for (int childIdx = 0; childIdx < _count; childIdx++) + { + Child(reader, childIdx).TraverseAllNodes(trans, command); + } + } + + public int Size(Transaction trans) + { + PrepareRead(trans); + if (!CanWrite()) + { + return _count; + } + int size = 0; + for (int i = 0; i < _count; i++) + { + BTreePatch keyPatch = KeyPatch(i); + if (keyPatch != null) + { + size += keyPatch.SizeDiff(trans); + } + else + { + size++; + } + } + return size; + } + + public override Db4objects.Db4o.Internal.Slots.SlotChangeFactory SlotChangeFactory + () + { + return _btree.SlotChangeFactory(); + } + + public override ITransactionalIdSystem IdSystem(Transaction trans) + { + return _btree.IdSystem(trans); + } + + public void ToReadMode() + { + if (IsNew()) + { + return; + } + if (!CanWrite()) + { + return; + } + if (IsDirty()) + { + return; + } + if (IsPatched()) + { + return; + } + _keys = null; + _children = null; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/BTreeNodeSearchResult.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/BTreeNodeSearchResult.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/BTreeNodeSearchResult.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/BTreeNodeSearchResult.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,87 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Btree; + +namespace Db4objects.Db4o.Internal.Btree +{ + /// + public class BTreeNodeSearchResult + { + private readonly Transaction _transaction; + + private readonly BTree _btree; + + private readonly BTreePointer _pointer; + + private readonly bool _foundMatch; + + internal BTreeNodeSearchResult(Transaction transaction, BTree btree, BTreePointer + pointer, bool foundMatch) + { + if (null == transaction || null == btree) + { + throw new ArgumentNullException(); + } + _transaction = transaction; + _btree = btree; + _pointer = pointer; + _foundMatch = foundMatch; + } + + internal BTreeNodeSearchResult(Transaction trans, ByteArrayBuffer nodeReader, BTree + btree, BTreeNode node, int cursor, bool foundMatch) : this(trans, btree, PointerOrNull + (trans, nodeReader, node, cursor), foundMatch) + { + } + + internal BTreeNodeSearchResult(Transaction trans, ByteArrayBuffer nodeReader, BTree + btree, Searcher searcher, BTreeNode node) : this(trans, btree, NextPointerIf(PointerOrNull + (trans, nodeReader, node, searcher.Cursor()), searcher.IsGreater()), searcher.FoundMatch + ()) + { + } + + private static BTreePointer NextPointerIf(BTreePointer pointer, bool condition) + { + if (null == pointer) + { + return null; + } + if (condition) + { + return pointer.Next(); + } + return pointer; + } + + private static BTreePointer PointerOrNull(Transaction trans, ByteArrayBuffer nodeReader + , BTreeNode node, int cursor) + { + return node == null ? null : new BTreePointer(trans, nodeReader, node, cursor); + } + + public virtual IBTreeRange CreateIncludingRange(Db4objects.Db4o.Internal.Btree.BTreeNodeSearchResult + end) + { + BTreePointer firstPointer = FirstValidPointer(); + BTreePointer endPointer = end._foundMatch ? end._pointer.Next() : end.FirstValidPointer + (); + return new BTreeRangeSingle(_transaction, _btree, firstPointer, endPointer); + } + + public virtual BTreePointer FirstValidPointer() + { + if (null == _pointer) + { + return null; + } + if (_pointer.IsValid()) + { + return _pointer; + } + return _pointer.Next(); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/BTreePatch.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/BTreePatch.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/BTreePatch.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/BTreePatch.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,60 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Btree; + +namespace Db4objects.Db4o.Internal.Btree +{ + public abstract class BTreePatch + { + protected readonly Transaction _transaction; + + protected object _object; + + public BTreePatch(Transaction transaction, object obj) + { + _transaction = transaction; + _object = obj; + } + + public abstract object Commit(Transaction trans, BTree btree, BTreeNode node); + + public abstract Db4objects.Db4o.Internal.Btree.BTreePatch ForTransaction(Transaction + trans); + + public virtual object GetObject() + { + return _object; + } + + public virtual bool IsAdd() + { + return false; + } + + public virtual bool IsCancelledRemoval() + { + return false; + } + + public virtual bool IsRemove() + { + return false; + } + + public abstract object Key(Transaction trans); + + public abstract object Rollback(Transaction trans, BTree btree); + + public override string ToString() + { + if (_object == null) + { + return "[NULL]"; + } + return _object.ToString(); + } + + public abstract int SizeDiff(Transaction trans); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/BTreePointer.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/BTreePointer.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/BTreePointer.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/BTreePointer.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,212 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Btree; + +namespace Db4objects.Db4o.Internal.Btree +{ + /// + public sealed class BTreePointer + { + public static Db4objects.Db4o.Internal.Btree.BTreePointer Max(Db4objects.Db4o.Internal.Btree.BTreePointer + x, Db4objects.Db4o.Internal.Btree.BTreePointer y) + { + if (x == null) + { + return x; + } + if (y == null) + { + return y; + } + if (x.CompareTo(y) > 0) + { + return x; + } + return y; + } + + public static Db4objects.Db4o.Internal.Btree.BTreePointer Min(Db4objects.Db4o.Internal.Btree.BTreePointer + x, Db4objects.Db4o.Internal.Btree.BTreePointer y) + { + if (x == null) + { + return y; + } + if (y == null) + { + return x; + } + if (x.CompareTo(y) < 0) + { + return x; + } + return y; + } + + private readonly BTreeNode _node; + + private readonly int _index; + + private readonly Transaction _transaction; + + private readonly ByteArrayBuffer _nodeReader; + + public BTreePointer(Transaction transaction, ByteArrayBuffer nodeReader, BTreeNode + node, int index) + { + if (transaction == null || node == null) + { + throw new ArgumentNullException(); + } + _transaction = transaction; + _nodeReader = nodeReader; + _node = node; + _index = index; + } + + public int Index() + { + return _index; + } + + public BTreeNode Node() + { + return _node; + } + + public object Key() + { + return _node.Key(_transaction, _nodeReader, _index); + } + + public Db4objects.Db4o.Internal.Btree.BTreePointer Next() + { + int indexInMyNode = _index + 1; + while (indexInMyNode < _node.Count()) + { + if (_node.IndexIsValid(_transaction, indexInMyNode)) + { + return new Db4objects.Db4o.Internal.Btree.BTreePointer(_transaction, _nodeReader, + _node, indexInMyNode); + } + indexInMyNode++; + } + int newIndex = -1; + BTreeNode nextNode = _node; + ByteArrayBuffer nextReader = null; + while (newIndex == -1) + { + nextNode = nextNode.NextNode(); + if (nextNode == null) + { + return null; + } + nextReader = nextNode.PrepareRead(_transaction); + newIndex = nextNode.FirstKeyIndex(_transaction); + } + Btree().ConvertCacheEvictedNodesToReadMode(); + return new Db4objects.Db4o.Internal.Btree.BTreePointer(_transaction, nextReader, + nextNode, newIndex); + } + + public Db4objects.Db4o.Internal.Btree.BTreePointer Previous() + { + int indexInMyNode = _index - 1; + while (indexInMyNode >= 0) + { + if (_node.IndexIsValid(_transaction, indexInMyNode)) + { + return new Db4objects.Db4o.Internal.Btree.BTreePointer(_transaction, _nodeReader, + _node, indexInMyNode); + } + indexInMyNode--; + } + int newIndex = -1; + BTreeNode previousNode = _node; + ByteArrayBuffer previousReader = null; + while (newIndex == -1) + { + previousNode = previousNode.PreviousNode(); + if (previousNode == null) + { + return null; + } + previousReader = previousNode.PrepareRead(_transaction); + newIndex = previousNode.LastKeyIndex(_transaction); + } + return new Db4objects.Db4o.Internal.Btree.BTreePointer(_transaction, previousReader + , previousNode, newIndex); + } + + public override bool Equals(object obj) + { + if (this == obj) + { + return true; + } + if (!(obj is Db4objects.Db4o.Internal.Btree.BTreePointer)) + { + return false; + } + Db4objects.Db4o.Internal.Btree.BTreePointer other = (Db4objects.Db4o.Internal.Btree.BTreePointer + )obj; + if (_index != other._index) + { + return false; + } + return _node.Equals(other._node); + } + + public override int GetHashCode() + { + return _node.GetHashCode(); + } + + public override string ToString() + { + return "BTreePointer(index=" + _index + ", node=" + _node + ")"; + } + + public int CompareTo(Db4objects.Db4o.Internal.Btree.BTreePointer y) + { + if (null == y) + { + throw new ArgumentNullException(); + } + if (Btree() != y.Btree()) + { + throw new ArgumentException(); + } + return Btree().CompareKeys(_transaction.Context(), Key(), y.Key()); + } + + private BTree Btree() + { + return _node.Btree(); + } + + public static bool LessThan(Db4objects.Db4o.Internal.Btree.BTreePointer x, Db4objects.Db4o.Internal.Btree.BTreePointer + y) + { + return Db4objects.Db4o.Internal.Btree.BTreePointer.Min(x, y) == x && !Equals(x, y + ); + } + + public static bool Equals(Db4objects.Db4o.Internal.Btree.BTreePointer x, Db4objects.Db4o.Internal.Btree.BTreePointer + y) + { + if (x == null) + { + return y == null; + } + return x.Equals(y); + } + + public bool IsValid() + { + return _node.IndexIsValid(_transaction, _index); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/BTreeRangeKeyIterator.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/BTreeRangeKeyIterator.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/BTreeRangeKeyIterator.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/BTreeRangeKeyIterator.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,21 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal.Btree; + +namespace Db4objects.Db4o.Internal.Btree +{ + internal class BTreeRangeKeyIterator : AbstractBTreeRangeIterator + { + public BTreeRangeKeyIterator(BTreeRangeSingle range) : base(range) + { + } + + public override object Current + { + get + { + return CurrentPointer().Key(); + } + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/BTreeRangePointerIterator.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/BTreeRangePointerIterator.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/BTreeRangePointerIterator.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/BTreeRangePointerIterator.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,21 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal.Btree; + +namespace Db4objects.Db4o.Internal.Btree +{ + public class BTreeRangePointerIterator : AbstractBTreeRangeIterator + { + public BTreeRangePointerIterator(BTreeRangeSingle range) : base(range) + { + } + + public override object Current + { + get + { + return CurrentPointer(); + } + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/BTreeRangeSingle.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/BTreeRangeSingle.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/BTreeRangeSingle.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/BTreeRangeSingle.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,239 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using System.Collections; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal.Btree; +using Db4objects.Db4o.Internal.Btree.Algebra; + +namespace Db4objects.Db4o.Internal.Btree +{ + /// + public class BTreeRangeSingle : IBTreeRange + { + private sealed class _IComparison4_14 : IComparison4 + { + public _IComparison4_14() + { + } + + public int Compare(object x, object y) + { + Db4objects.Db4o.Internal.Btree.BTreeRangeSingle xRange = (Db4objects.Db4o.Internal.Btree.BTreeRangeSingle + )x; + Db4objects.Db4o.Internal.Btree.BTreeRangeSingle yRange = (Db4objects.Db4o.Internal.Btree.BTreeRangeSingle + )y; + return xRange.First().CompareTo(yRange.First()); + } + } + + public static readonly IComparison4 Comparison = new _IComparison4_14(); + + private readonly Db4objects.Db4o.Internal.Transaction _transaction; + + private readonly BTree _btree; + + private readonly BTreePointer _first; + + private readonly BTreePointer _end; + + public BTreeRangeSingle(Db4objects.Db4o.Internal.Transaction transaction, BTree btree + , BTreePointer first, BTreePointer end) + { + if (transaction == null || btree == null) + { + throw new ArgumentNullException(); + } + _transaction = transaction; + _btree = btree; + _first = first; + _end = end; + } + + public virtual void Accept(IBTreeRangeVisitor visitor) + { + visitor.Visit(this); + } + + public virtual bool IsEmpty() + { + return BTreePointer.Equals(_first, _end); + } + + public virtual int Size() + { + if (IsEmpty()) + { + return 0; + } + // TODO: This was an attempt to improve size calculation. + // Since all nodes are read, there is no improvement. + // BTreeNode currentNode = _first.node(); + // int sizeOnFirst = currentNode.count() - _first.index(); + // + // BTreeNode endNode = _end == null ? null : _end.node(); + // int substractForEnd = + // (endNode == null) ? 0 : (endNode.count() - _end.index()); + // + // int size = sizeOnFirst - substractForEnd; + // while(! currentNode.equals(endNode)){ + // currentNode = currentNode.nextNode(); + // if(currentNode == null){ + // break; + // } + // currentNode.prepareRead(transaction()); + // size += currentNode.count(); + // } + // return size; + int size = 0; + IEnumerator i = Keys(); + while (i.MoveNext()) + { + ++size; + } + return size; + } + + public virtual IEnumerator Pointers() + { + return new BTreeRangePointerIterator(this); + } + + public virtual IEnumerator Keys() + { + return new BTreeRangeKeyIterator(this); + } + + public BTreePointer End() + { + return _end; + } + + public virtual Db4objects.Db4o.Internal.Transaction Transaction() + { + return _transaction; + } + + public virtual BTreePointer First() + { + return _first; + } + + public virtual IBTreeRange Greater() + { + return NewBTreeRangeSingle(_end, null); + } + + public virtual IBTreeRange Union(IBTreeRange other) + { + if (null == other) + { + throw new ArgumentNullException(); + } + return new BTreeRangeSingleUnion(this).Dispatch(other); + } + + public virtual bool Adjacent(Db4objects.Db4o.Internal.Btree.BTreeRangeSingle range + ) + { + return BTreePointer.Equals(_end, range._first) || BTreePointer.Equals(range._end, + _first); + } + + public virtual bool Overlaps(Db4objects.Db4o.Internal.Btree.BTreeRangeSingle range + ) + { + return FirstOverlaps(this, range) || FirstOverlaps(range, this); + } + + private bool FirstOverlaps(Db4objects.Db4o.Internal.Btree.BTreeRangeSingle x, Db4objects.Db4o.Internal.Btree.BTreeRangeSingle + y) + { + return BTreePointer.LessThan(y._first, x._end) && BTreePointer.LessThan(x._first, + y._end); + } + + public virtual IBTreeRange ExtendToFirst() + { + return NewBTreeRangeSingle(FirstBTreePointer(), _end); + } + + public virtual IBTreeRange ExtendToLast() + { + return NewBTreeRangeSingle(_first, null); + } + + public virtual IBTreeRange Smaller() + { + return NewBTreeRangeSingle(FirstBTreePointer(), _first); + } + + public virtual Db4objects.Db4o.Internal.Btree.BTreeRangeSingle NewBTreeRangeSingle + (BTreePointer first, BTreePointer end) + { + return new Db4objects.Db4o.Internal.Btree.BTreeRangeSingle(Transaction(), _btree, + first, end); + } + + public virtual IBTreeRange NewEmptyRange() + { + return NewBTreeRangeSingle(null, null); + } + + private BTreePointer FirstBTreePointer() + { + return Btree().FirstPointer(Transaction()); + } + + private BTree Btree() + { + return _btree; + } + + public virtual IBTreeRange Intersect(IBTreeRange range) + { + if (null == range) + { + throw new ArgumentNullException(); + } + return new BTreeRangeSingleIntersect(this).Dispatch(range); + } + + public virtual IBTreeRange ExtendToLastOf(IBTreeRange range) + { + Db4objects.Db4o.Internal.Btree.BTreeRangeSingle rangeImpl = CheckRangeArgument(range + ); + return NewBTreeRangeSingle(_first, rangeImpl._end); + } + + public override string ToString() + { + return "BTreeRangeSingle(first=" + _first + ", end=" + _end + ")"; + } + + private Db4objects.Db4o.Internal.Btree.BTreeRangeSingle CheckRangeArgument(IBTreeRange + range) + { + if (null == range) + { + throw new ArgumentNullException(); + } + Db4objects.Db4o.Internal.Btree.BTreeRangeSingle rangeImpl = (Db4objects.Db4o.Internal.Btree.BTreeRangeSingle + )range; + if (Btree() != rangeImpl.Btree()) + { + throw new ArgumentException(); + } + return rangeImpl; + } + + public virtual BTreePointer LastPointer() + { + if (_end == null) + { + return Btree().LastPointer(Transaction()); + } + return _end.Previous(); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/BTreeRangeUnion.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/BTreeRangeUnion.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/BTreeRangeUnion.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/BTreeRangeUnion.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,167 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using System.Collections; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal.Btree; +using Db4objects.Db4o.Internal.Btree.Algebra; + +namespace Db4objects.Db4o.Internal.Btree +{ + public class BTreeRangeUnion : IBTreeRange + { + private readonly BTreeRangeSingle[] _ranges; + + public BTreeRangeUnion(BTreeRangeSingle[] ranges) : this(ToSortedCollection(ranges + )) + { + } + + public BTreeRangeUnion(SortedCollection4 sorted) + { + if (null == sorted) + { + throw new ArgumentNullException(); + } + _ranges = ToArray(sorted); + } + + public virtual void Accept(IBTreeRangeVisitor visitor) + { + visitor.Visit(this); + } + + public virtual bool IsEmpty() + { + for (int i = 0; i < _ranges.Length; i++) + { + if (!_ranges[i].IsEmpty()) + { + return false; + } + } + return true; + } + + private static SortedCollection4 ToSortedCollection(BTreeRangeSingle[] ranges) + { + if (null == ranges) + { + throw new ArgumentNullException(); + } + SortedCollection4 collection = new SortedCollection4(BTreeRangeSingle.Comparison); + for (int i = 0; i < ranges.Length; i++) + { + BTreeRangeSingle range = ranges[i]; + if (!range.IsEmpty()) + { + collection.Add(range); + } + } + return collection; + } + + private static BTreeRangeSingle[] ToArray(SortedCollection4 collection) + { + return (BTreeRangeSingle[])collection.ToArray(new BTreeRangeSingle[collection.Size + ()]); + } + + public virtual IBTreeRange ExtendToFirst() + { + throw new NotImplementedException(); + } + + public virtual IBTreeRange ExtendToLast() + { + throw new NotImplementedException(); + } + + public virtual IBTreeRange ExtendToLastOf(IBTreeRange upperRange) + { + throw new NotImplementedException(); + } + + public virtual IBTreeRange Greater() + { + throw new NotImplementedException(); + } + + public virtual IBTreeRange Intersect(IBTreeRange range) + { + if (null == range) + { + throw new ArgumentNullException(); + } + return new BTreeRangeUnionIntersect(this).Dispatch(range); + } + + public virtual IEnumerator Pointers() + { + return Iterators.Concat(Iterators.Map(_ranges, new _IFunction4_77())); + } + + private sealed class _IFunction4_77 : IFunction4 + { + public _IFunction4_77() + { + } + + public object Apply(object range) + { + return ((IBTreeRange)range).Pointers(); + } + } + + public virtual IEnumerator Keys() + { + return Iterators.Concat(Iterators.Map(_ranges, new _IFunction4_85())); + } + + private sealed class _IFunction4_85 : IFunction4 + { + public _IFunction4_85() + { + } + + public object Apply(object range) + { + return ((IBTreeRange)range).Keys(); + } + } + + public virtual int Size() + { + int size = 0; + for (int i = 0; i < _ranges.Length; i++) + { + size += _ranges[i].Size(); + } + return size; + } + + public virtual IBTreeRange Smaller() + { + throw new NotImplementedException(); + } + + public virtual IBTreeRange Union(IBTreeRange other) + { + if (null == other) + { + throw new ArgumentNullException(); + } + return new BTreeRangeUnionUnion(this).Dispatch(other); + } + + public virtual IEnumerator Ranges() + { + return new ArrayIterator4(_ranges); + } + + public virtual BTreePointer LastPointer() + { + throw new NotImplementedException(); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/BTreeRemove.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/BTreeRemove.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/BTreeRemove.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/BTreeRemove.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,48 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Btree; + +namespace Db4objects.Db4o.Internal.Btree +{ + /// + public class BTreeRemove : BTreeUpdate + { + public BTreeRemove(Transaction transaction, object obj) : base(transaction, obj) + { + } + + protected override void Committed(BTree btree) + { + btree.NotifyRemoveListener(new TransactionContext(_transaction, GetObject())); + } + + public override string ToString() + { + return "(-) " + base.ToString(); + } + + public override bool IsRemove() + { + return true; + } + + protected override object GetCommittedObject() + { + return No4.Instance; + } + + protected override void AdjustSizeOnRemovalByOtherTransaction(BTree btree, BTreeNode + node) + { + // The size was reduced for this entry, let's change back. + btree.SizeChanged(_transaction, node, +1); + } + + protected override int SizeDiff() + { + return 0; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/BTreeUpdate.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/BTreeUpdate.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/BTreeUpdate.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/BTreeUpdate.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,206 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Btree; + +namespace Db4objects.Db4o.Internal.Btree +{ + public abstract class BTreeUpdate : BTreePatch + { + protected Db4objects.Db4o.Internal.Btree.BTreeUpdate _next; + + public BTreeUpdate(Transaction transaction, object obj) : base(transaction, obj) + { + } + + protected virtual bool HasNext() + { + return _next != null; + } + + public override BTreePatch ForTransaction(Transaction trans) + { + if (_transaction == trans) + { + return this; + } + if (_next == null) + { + return null; + } + return _next.ForTransaction(trans); + } + + public virtual Db4objects.Db4o.Internal.Btree.BTreeUpdate RemoveFor(Transaction trans + ) + { + if (_transaction == trans) + { + return _next; + } + if (_next == null) + { + return this; + } + return _next.RemoveFor(trans); + } + + public virtual void Append(Db4objects.Db4o.Internal.Btree.BTreeUpdate patch) + { + if (_transaction == patch._transaction) + { + // don't allow two patches for the same transaction + throw new ArgumentException(); + } + if (!HasNext()) + { + _next = patch; + } + else + { + _next.Append(patch); + } + } + + protected virtual void ApplyKeyChange(object obj) + { + _object = obj; + if (HasNext()) + { + _next.ApplyKeyChange(obj); + } + } + + protected abstract void Committed(BTree btree); + + public override object Commit(Transaction trans, BTree btree, BTreeNode node) + { + Db4objects.Db4o.Internal.Btree.BTreeUpdate patch = (Db4objects.Db4o.Internal.Btree.BTreeUpdate + )ForTransaction(trans); + if (patch is BTreeCancelledRemoval) + { + object obj = patch.GetCommittedObject(); + ApplyKeyChange(obj); + } + else + { + if (patch is BTreeRemove) + { + RemovedBy(trans, btree, node); + patch.Committed(btree); + return No4.Instance; + } + } + return InternalCommit(trans, btree); + } + + protected object InternalCommit(Transaction trans, BTree btree) + { + if (_transaction == trans) + { + Committed(btree); + if (HasNext()) + { + return _next; + } + return GetCommittedObject(); + } + if (HasNext()) + { + SetNextIfPatch(_next.InternalCommit(trans, btree)); + } + return this; + } + + private void SetNextIfPatch(object newNext) + { + if (newNext is Db4objects.Db4o.Internal.Btree.BTreeUpdate) + { + _next = (Db4objects.Db4o.Internal.Btree.BTreeUpdate)newNext; + } + else + { + _next = null; + } + } + + protected abstract object GetCommittedObject(); + + public override object Rollback(Transaction trans, BTree btree) + { + if (_transaction == trans) + { + if (HasNext()) + { + return _next; + } + return GetObject(); + } + if (HasNext()) + { + SetNextIfPatch(_next.Rollback(trans, btree)); + } + return this; + } + + public override object Key(Transaction trans) + { + BTreePatch patch = ForTransaction(trans); + if (patch == null) + { + return GetObject(); + } + if (patch.IsRemove()) + { + return No4.Instance; + } + return patch.GetObject(); + } + + public virtual Db4objects.Db4o.Internal.Btree.BTreeUpdate ReplacePatch(BTreePatch + patch, Db4objects.Db4o.Internal.Btree.BTreeUpdate update) + { + if (patch == this) + { + update._next = _next; + return update; + } + if (_next == null) + { + throw new InvalidOperationException(); + } + _next = _next.ReplacePatch(patch, update); + return this; + } + + public virtual void RemovedBy(Transaction trans, BTree btree, BTreeNode node) + { + if (trans != _transaction) + { + AdjustSizeOnRemovalByOtherTransaction(btree, node); + } + if (HasNext()) + { + _next.RemovedBy(trans, btree, node); + } + } + + protected abstract void AdjustSizeOnRemovalByOtherTransaction(BTree btree, BTreeNode + node); + + public override int SizeDiff(Transaction trans) + { + Db4objects.Db4o.Internal.Btree.BTreeUpdate patchForTransaction = (Db4objects.Db4o.Internal.Btree.BTreeUpdate + )ForTransaction(trans); + if (patchForTransaction == null) + { + return 1; + } + return patchForTransaction.SizeDiff(); + } + + protected abstract int SizeDiff(); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/FieldIndexKeyHandler.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/FieldIndexKeyHandler.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/FieldIndexKeyHandler.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/FieldIndexKeyHandler.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,115 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Btree; +using Db4objects.Db4o.Marshall; + +namespace Db4objects.Db4o.Internal.Btree +{ + /// + public class FieldIndexKeyHandler : IIndexable4 + { + private readonly IIndexable4 _valueHandler; + + private readonly IDHandler _parentIdHandler; + + public FieldIndexKeyHandler(IIndexable4 delegate_) + { + _parentIdHandler = new IDHandler(); + _valueHandler = delegate_; + } + + public virtual int LinkLength() + { + return _valueHandler.LinkLength() + Const4.IntLength; + } + + public virtual object ReadIndexEntry(IContext context, ByteArrayBuffer a_reader) + { + // TODO: could read int directly here with a_reader.readInt() + int parentID = ReadParentID(context, a_reader); + object objPart = _valueHandler.ReadIndexEntry(context, a_reader); + if (parentID < 0) + { + objPart = null; + parentID = -parentID; + } + return new FieldIndexKeyImpl(parentID, objPart); + } + + private int ReadParentID(IContext context, ByteArrayBuffer a_reader) + { + return ((int)_parentIdHandler.ReadIndexEntry(context, a_reader)); + } + + public virtual void WriteIndexEntry(IContext context, ByteArrayBuffer writer, object + obj) + { + IFieldIndexKey composite = (IFieldIndexKey)obj; + int parentID = composite.ParentID(); + object value = composite.Value(); + if (value == null) + { + parentID = -parentID; + } + _parentIdHandler.Write(parentID, writer); + _valueHandler.WriteIndexEntry(context, writer, composite.Value()); + } + + public virtual IIndexable4 ValueHandler() + { + return _valueHandler; + } + + public virtual void DefragIndexEntry(DefragmentContextImpl context) + { + _parentIdHandler.DefragIndexEntry(context); + _valueHandler.DefragIndexEntry(context); + } + + public virtual IPreparedComparison PrepareComparison(IContext context, object fieldIndexKey + ) + { + IFieldIndexKey source = (IFieldIndexKey)fieldIndexKey; + IPreparedComparison preparedValueComparison = _valueHandler.PrepareComparison(context + , source.Value()); + IPreparedComparison preparedParentIdComparison = _parentIdHandler.NewPrepareCompare + (source.ParentID()); + return new _IPreparedComparison_67(preparedValueComparison, preparedParentIdComparison + ); + } + + private sealed class _IPreparedComparison_67 : IPreparedComparison + { + public _IPreparedComparison_67(IPreparedComparison preparedValueComparison, IPreparedComparison + preparedParentIdComparison) + { + this.preparedValueComparison = preparedValueComparison; + this.preparedParentIdComparison = preparedParentIdComparison; + } + + public int CompareTo(object obj) + { + IFieldIndexKey target = (IFieldIndexKey)obj; + try + { + int delegateResult = preparedValueComparison.CompareTo(target.Value()); + if (delegateResult != 0) + { + return delegateResult; + } + } + catch (IllegalComparisonException) + { + } + // can happen, is expected + return preparedParentIdComparison.CompareTo(target.ParentID()); + } + + private readonly IPreparedComparison preparedValueComparison; + + private readonly IPreparedComparison preparedParentIdComparison; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/FieldIndexKeyImpl.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/FieldIndexKeyImpl.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/FieldIndexKeyImpl.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/FieldIndexKeyImpl.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,54 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal.Btree; + +namespace Db4objects.Db4o.Internal.Btree +{ + /// + /// Composite key for field indexes, first compares on the actual + /// indexed field _value and then on the _parentID (which is a + /// reference to the containing object). + /// + /// + /// Composite key for field indexes, first compares on the actual + /// indexed field _value and then on the _parentID (which is a + /// reference to the containing object). + /// + /// + public class FieldIndexKeyImpl : IFieldIndexKey + { + private readonly object _value; + + private readonly int _parentID; + + public FieldIndexKeyImpl(int parentID, object value) + { + _parentID = parentID; + _value = value; + } + + public virtual int ParentID() + { + return _parentID; + } + + public virtual object Value() + { + return _value; + } + + public override string ToString() + { + return "FieldIndexKey(" + _parentID + ", " + SafeString(_value) + ")"; + } + + private string SafeString(object value) + { + if (null == value) + { + return "null"; + } + return value.ToString(); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/IBTreeRange.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/IBTreeRange.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/IBTreeRange.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/IBTreeRange.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,45 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System.Collections; +using Db4objects.Db4o.Internal.Btree; + +namespace Db4objects.Db4o.Internal.Btree +{ + public interface IBTreeRange + { + /// + /// Iterates through all the valid pointers in + /// this range. + /// + /// + /// Iterates through all the valid pointers in + /// this range. + /// + /// an Iterator4 over BTreePointer value + IEnumerator Pointers(); + + IEnumerator Keys(); + + int Size(); + + IBTreeRange Greater(); + + IBTreeRange Union(IBTreeRange other); + + IBTreeRange ExtendToLast(); + + IBTreeRange Smaller(); + + IBTreeRange ExtendToFirst(); + + IBTreeRange Intersect(IBTreeRange range); + + IBTreeRange ExtendToLastOf(IBTreeRange upperRange); + + bool IsEmpty(); + + void Accept(IBTreeRangeVisitor visitor); + + BTreePointer LastPointer(); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/IBTreeRangeVisitor.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/IBTreeRangeVisitor.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/IBTreeRangeVisitor.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/IBTreeRangeVisitor.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,14 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal.Btree; + +namespace Db4objects.Db4o.Internal.Btree +{ + /// + public interface IBTreeRangeVisitor + { + void Visit(BTreeRangeSingle range); + + void Visit(BTreeRangeUnion union); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/IBTreeStructureListener.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/IBTreeStructureListener.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/IBTreeStructureListener.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/IBTreeStructureListener.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,18 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Btree; + +namespace Db4objects.Db4o.Internal.Btree +{ + /// + public interface IBTreeStructureListener + { + void NotifySplit(Transaction trans, BTreeNode originalNode, BTreeNode newRightNode + ); + + void NotifyDeleted(Transaction trans, BTreeNode node); + + void NotifyCountChanged(Transaction trans, BTreeNode node, int diff); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/IFieldIndexKey.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/IFieldIndexKey.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/IFieldIndexKey.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/IFieldIndexKey.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,11 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +namespace Db4objects.Db4o.Internal.Btree +{ + public interface IFieldIndexKey + { + int ParentID(); + + object Value(); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/Searcher.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/Searcher.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/Searcher.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/Searcher.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,171 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using Db4objects.Db4o.Internal.Btree; + +namespace Db4objects.Db4o.Internal.Btree +{ + /// + public sealed class Searcher + { + private int _lower; + + private int _upper; + + private int _cursor; + + private int _cmp; + + private readonly SearchTarget _target; + + private readonly int _count; + + public Searcher(SearchTarget target, int count) + { + if (count < 0) + { + throw new ArgumentException(); + } + _target = target; + _count = count; + _cmp = -1; + if (count == 0) + { + Complete(); + return; + } + _cursor = -1; + _upper = count - 1; + AdjustCursor(); + } + + private void AdjustBounds() + { + if (_cmp > 0) + { + _upper = _cursor - 1; + if (_upper < _lower) + { + _upper = _lower; + } + return; + } + if (_cmp < 0) + { + if (_lower == _cursor && _lower < _upper) + { + _lower++; + } + else + { + _lower = _cursor; + } + return; + } + if (_target == SearchTarget.Any) + { + _lower = _cursor; + _upper = _cursor; + } + else + { + if (_target == SearchTarget.Highest) + { + _lower = _cursor; + } + else + { + if (_target == SearchTarget.Lowest) + { + _upper = _cursor; + } + else + { + throw new InvalidOperationException("Unknown target"); + } + } + } + } + + private void AdjustCursor() + { + int oldCursor = _cursor; + if (_upper - _lower <= 1) + { + if ((_target == SearchTarget.Lowest) && (_cmp == 0)) + { + _cursor = _lower; + } + else + { + _cursor = _upper; + } + } + else + { + _cursor = _lower + ((_upper - _lower) / 2); + } + if (_cursor == oldCursor) + { + Complete(); + } + } + + public bool AfterLast() + { + if (_count == 0) + { + return false; + } + // _cursor is 0: not after last + return (_cursor == _count - 1) && _cmp < 0; + } + + public bool BeforeFirst() + { + return (_cursor == 0) && (_cmp > 0); + } + + private void Complete() + { + _upper = -2; + } + + public int Count() + { + return _count; + } + + public int Cursor() + { + return _cursor; + } + + public bool FoundMatch() + { + return _cmp == 0; + } + + public bool Incomplete() + { + return _upper >= _lower; + } + + public void MoveForward() + { + _cursor++; + } + + public void ResultIs(int cmp) + { + _cmp = cmp; + AdjustBounds(); + AdjustCursor(); + } + + public bool IsGreater() + { + return _cmp < 0; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/SearchTarget.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/SearchTarget.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/SearchTarget.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Btree/SearchTarget.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,29 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +namespace Db4objects.Db4o.Internal.Btree +{ + /// + public sealed class SearchTarget + { + public static readonly Db4objects.Db4o.Internal.Btree.SearchTarget Lowest = new Db4objects.Db4o.Internal.Btree.SearchTarget + ("Lowest"); + + public static readonly Db4objects.Db4o.Internal.Btree.SearchTarget Any = new Db4objects.Db4o.Internal.Btree.SearchTarget + ("Any"); + + public static readonly Db4objects.Db4o.Internal.Btree.SearchTarget Highest = new + Db4objects.Db4o.Internal.Btree.SearchTarget("Highest"); + + private readonly string _target; + + public SearchTarget(string target) + { + _target = target; + } + + public override string ToString() + { + return _target; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/ByteArrayBuffer.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/ByteArrayBuffer.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/ByteArrayBuffer.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/ByteArrayBuffer.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,305 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using Db4objects.Db4o; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Handlers; +using Sharpen; +using Sharpen.Lang; + +namespace Db4objects.Db4o.Internal +{ + /// + public class ByteArrayBuffer : IReadWriteBuffer + { + private static readonly ThreadLocal _checkXBytes = Debug4.xbytes ? new ThreadLocal + () : null; + + public byte[] _buffer; + + public int _offset; + + internal ByteArrayBuffer() + { + } + + public ByteArrayBuffer(int length) : this() + { + // for coding convenience, we allow objects to grab into the buffer + _buffer = new byte[length]; + } + + public ByteArrayBuffer(byte[] buffer) : this() + { + _buffer = buffer; + } + + public virtual void Seek(int offset) + { + _offset = offset; + } + + public virtual void WriteBytes(byte[] bytes) + { + System.Array.Copy(bytes, 0, _buffer, _offset, bytes.Length); + _offset += bytes.Length; + } + + // TODO: Change all callers to call writeBytes directly. + public virtual void Append(byte[] bytes) + { + WriteBytes(bytes); + } + + public bool ContainsTheSame(Db4objects.Db4o.Internal.ByteArrayBuffer other) + { + if (other != null) + { + return Arrays4.Equals(_buffer, other._buffer); + } + return false; + } + + public virtual void CopyTo(Db4objects.Db4o.Internal.ByteArrayBuffer to, int fromOffset + , int toOffset, int length) + { + System.Array.Copy(_buffer, fromOffset, to._buffer, toOffset, length); + } + + public virtual int Length() + { + return _buffer.Length; + } + + public virtual void IncrementOffset(int a_by) + { + _offset += a_by; + } + + /// non-encrypted read, used for indexes + public virtual void Read(ObjectContainerBase stream, int address, int addressOffset + ) + { + stream.ReadBytes(_buffer, address, addressOffset, Length()); + } + + public void ReadBegin(byte identifier) + { + } + + public virtual BitMap4 ReadBitMap(int bitCount) + { + BitMap4 map = new BitMap4(_buffer, _offset, bitCount); + _offset += map.MarshalledLength(); + return map; + } + + public virtual byte ReadByte() + { + return _buffer[_offset++]; + } + + public virtual byte[] ReadBytes(int a_length) + { + byte[] bytes = new byte[a_length]; + ReadBytes(bytes); + return bytes; + } + + public virtual void ReadBytes(byte[] bytes) + { + int length = bytes.Length; + System.Array.Copy(_buffer, _offset, bytes, 0, length); + _offset += length; + } + + /// + public Db4objects.Db4o.Internal.ByteArrayBuffer ReadEmbeddedObject(Transaction trans + ) + { + int address = ReadInt(); + int length = ReadInt(); + if (address == 0) + { + return null; + } + return trans.Container().DecryptedBufferByAddress(address, length); + } + + /// + public virtual void ReadEncrypt(ObjectContainerBase stream, int address) + { + stream.ReadBytes(_buffer, address, Length()); + stream._handlers.Decrypt(this); + } + + public virtual void ReadEnd() + { + } + + public int ReadInt() + { + int o = (_offset += 4) - 1; + return (_buffer[o] & 255) | (_buffer[--o] & 255) << 8 | (_buffer[--o] & 255) << 16 + | _buffer[--o] << 24; + } + + public virtual long ReadLong() + { + return LongHandler.ReadLong(this); + } + + public virtual Db4objects.Db4o.Internal.ByteArrayBuffer ReadPayloadReader(int offset + , int length) + { + Db4objects.Db4o.Internal.ByteArrayBuffer payLoad = new Db4objects.Db4o.Internal.ByteArrayBuffer + (length); + System.Array.Copy(_buffer, offset, payLoad._buffer, 0, length); + return payLoad; + } + + internal virtual void ReplaceWith(byte[] a_bytes) + { + System.Array.Copy(a_bytes, 0, _buffer, 0, Length()); + } + + public override string ToString() + { + string str = string.Empty; + for (int i = 0; i < _buffer.Length; i++) + { + if (i > 0) + { + str += " , "; + } + str += _buffer[i]; + } + return str; + } + + public virtual void WriteBegin(byte a_identifier) + { + } + + public void WriteBitMap(BitMap4 nullBitMap) + { + nullBitMap.WriteTo(_buffer, _offset); + _offset += nullBitMap.MarshalledLength(); + } + + public void WriteByte(byte a_byte) + { + _buffer[_offset++] = a_byte; + } + + public virtual void WriteEnd() + { + if (Deploy.debug && Deploy.brackets) + { + WriteByte(Const4.Yapend); + } + } + + public void WriteInt(int a_int) + { + int o = _offset + 4; + _offset = o; + byte[] b = _buffer; + b[--o] = (byte)a_int; + b[--o] = (byte)(a_int >>= 8); + b[--o] = (byte)(a_int >>= 8); + b[--o] = (byte)(a_int >> 8); + } + + public virtual void WriteIDOf(Transaction trans, object obj) + { + if (obj == null) + { + WriteInt(0); + return; + } + if (obj is PersistentBase) + { + WriteIDOf(trans, (PersistentBase)obj); + return; + } + WriteInt(((int)obj)); + } + + public virtual void WriteIDOf(Transaction trans, PersistentBase persistent) + { + if (persistent == null) + { + WriteInt(0); + return; + } + if (CanWritePersistentBase()) + { + persistent.WriteOwnID(trans, this); + } + else + { + WriteInt(persistent.GetID()); + } + } + + protected virtual bool CanWritePersistentBase() + { + return true; + } + + public virtual void WriteShortString(Transaction trans, string a_string) + { + trans.Container()._handlers._stringHandler.WriteShort(trans, a_string, this); + } + + public virtual void WriteLong(long l) + { + LongHandler.WriteLong(this, l); + } + + public virtual void IncrementIntSize() + { + IncrementOffset(Const4.IntLength); + } + + public virtual int Offset() + { + return _offset; + } + + public virtual void EnsureSize(int size) + { + if (size == _buffer.Length) + { + return; + } + _buffer = new byte[size]; + } + + public virtual void Skip(int length) + { + Seek(_offset + length); + } + + public virtual void CheckXBytes(bool flag) + { + } + + public virtual bool CheckXBytes() + { + throw new InvalidOperationException(); + } + + public virtual bool Eof() + { + return _offset == _buffer.Length; + } + + public virtual int RemainingByteCount() + { + return _buffer.Length - _offset; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Caching/CacheFactory.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Caching/CacheFactory.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Caching/CacheFactory.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Caching/CacheFactory.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,40 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal.Caching; + +namespace Db4objects.Db4o.Internal.Caching +{ + /// + public class CacheFactory + { + public static ICache4 New2QCache(int size) + { + return new LRU2QCache(size); + } + + public static ICache4 New2QLongCache(int size) + { + return new LRU2QLongCache(size); + } + + public static ICache4 New2QXCache(int size) + { + return new LRU2QXCache(size); + } + + public static IPurgeableCache4 NewLRUCache(int size) + { + return new LRUCache(size); + } + + public static IPurgeableCache4 NewLRUIntCache(int size) + { + return new LRUIntCache(size); + } + + public static IPurgeableCache4 NewLRULongCache(int size) + { + return new LRULongCache(size); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Caching/CacheStatistics.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Caching/CacheStatistics.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Caching/CacheStatistics.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Caching/CacheStatistics.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,70 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System.Collections; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal.Caching; + +namespace Db4objects.Db4o.Internal.Caching +{ + /// + public class CacheStatistics : ICache4 + { + private readonly ICache4 _delegate; + + private int _calls; + + private int _misses; + + public CacheStatistics(ICache4 delegate_) + { + _delegate = delegate_; + } + + public virtual object Produce(object key, IFunction4 producer, IProcedure4 onDiscard + ) + { + _calls++; + IFunction4 delegateProducer = new _IFunction4_26(this, producer); + return _delegate.Produce(key, delegateProducer, onDiscard); + } + + private sealed class _IFunction4_26 : IFunction4 + { + public _IFunction4_26(CacheStatistics _enclosing, IFunction4 producer) + { + this._enclosing = _enclosing; + this.producer = producer; + } + + public object Apply(object arg) + { + this._enclosing._misses++; + return producer.Apply(arg); + } + + private readonly CacheStatistics _enclosing; + + private readonly IFunction4 producer; + } + + public virtual IEnumerator GetEnumerator() + { + return _delegate.GetEnumerator(); + } + + public virtual int Calls() + { + return _calls; + } + + public virtual int Misses() + { + return _misses; + } + + public override string ToString() + { + return "Cache statistics Calls:" + _calls + " Misses:" + _misses; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Caching/ICache4.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Caching/ICache4.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Caching/ICache4.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Caching/ICache4.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,29 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System.Collections; +using Db4objects.Db4o.Foundation; + +namespace Db4objects.Db4o.Internal.Caching +{ + /// + public interface ICache4 : IEnumerable + { + /// + /// Retrieves the value associated to the + /// key + /// from the cache. If the value is not yet + /// cached + /// producer + /// will be called to produce it. If the cache needs to discard a value + /// finalizer + /// will be given a chance to process it. + /// + /// the key for the value - must never change - cannot be null + /// will be called if value not yet in the cache - can only be null when the value is found in the cache + /// + /// will be called if a page needs to be discarded - can be null + /// + /// the cached value + object Produce(object key, IFunction4 producer, IProcedure4 finalizer); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Caching/IPurgeableCache4.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Caching/IPurgeableCache4.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Caching/IPurgeableCache4.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Caching/IPurgeableCache4.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,16 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal.Caching; + +namespace Db4objects.Db4o.Internal.Caching +{ + /// + public interface IPurgeableCache4 : ICache4 + { + /// Removes the cached value with the specified key from this cache. + /// Removes the cached value with the specified key from this cache. + /// + /// the purged value or null + object Purge(object key); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Caching/LRU2QCache.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Caching/LRU2QCache.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Caching/LRU2QCache.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Caching/LRU2QCache.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,103 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using System.Collections; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal.Caching; + +namespace Db4objects.Db4o.Internal.Caching +{ + /// + /// Simplified version of the algorithm taken from here: + /// http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.34.2641 + /// + internal class LRU2QCache : ICache4 + { + private readonly CircularBuffer4 _am; + + private readonly CircularBuffer4 _a1; + + private readonly IDictionary _slots; + + private readonly int _maxSize; + + private readonly int _a1_threshold; + + internal LRU2QCache(int maxSize) + { + _maxSize = maxSize; + _a1_threshold = _maxSize / 4; + _am = new CircularBuffer4(_maxSize); + _a1 = new CircularBuffer4(_maxSize); + _slots = new Hashtable(maxSize); + } + + public virtual object Produce(object key, IFunction4 producer, IProcedure4 finalizer + ) + { + if (key == null) + { + throw new ArgumentNullException(); + } + if (_am.Remove(key)) + { + _am.AddFirst(key); + return _slots[key]; + } + if (_a1.Remove(key)) + { + _am.AddFirst(key); + return _slots[key]; + } + if (_slots.Count >= _maxSize) + { + DiscardPage(finalizer); + } + object value = producer.Apply(key); + _slots[key] = value; + _a1.AddFirst(key); + return value; + } + + private void DiscardPage(IProcedure4 finalizer) + { + if (_a1.Size() >= _a1_threshold) + { + DiscardPageFrom(_a1, finalizer); + } + else + { + DiscardPageFrom(_am, finalizer); + } + } + + private void DiscardPageFrom(CircularBuffer4 list, IProcedure4 finalizer) + { + Discard(list.RemoveLast(), finalizer); + } + + private void Discard(object key, IProcedure4 finalizer) + { + if (null != finalizer) + { + finalizer.Apply(_slots[key]); + } + Sharpen.Collections.Remove(_slots, key); + } + + public override string ToString() + { + return "LRU2QCache(am=" + ToString(_am) + ", a1=" + ToString(_a1) + ")"; + } + + private string ToString(IEnumerable buffer) + { + return Iterators.ToString(buffer); + } + + public virtual IEnumerator GetEnumerator() + { + return _slots.Values.GetEnumerator(); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Caching/LRU2QLongCache.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Caching/LRU2QLongCache.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Caching/LRU2QLongCache.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Caching/LRU2QLongCache.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,98 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System.Collections; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal.Caching; + +namespace Db4objects.Db4o.Internal.Caching +{ + /// + /// Simplified version of the algorithm taken from here: + /// http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.34.2641 + /// + internal class LRU2QLongCache : ICache4 + { + private readonly CircularLongBuffer4 _am; + + private readonly CircularLongBuffer4 _a1; + + private readonly IDictionary _slots; + + private readonly int _maxSize; + + private readonly int _a1_threshold; + + internal LRU2QLongCache(int maxSize) + { + _maxSize = maxSize; + _a1_threshold = _maxSize / 4; + _am = new CircularLongBuffer4(_maxSize); + _a1 = new CircularLongBuffer4(_maxSize); + _slots = new Hashtable(maxSize); + } + + public virtual object Produce(object key, IFunction4 producer, IProcedure4 finalizer + ) + { + if (_am.Remove((((long)key)))) + { + _am.AddFirst((((long)key))); + return _slots[((long)key)]; + } + if (_a1.Remove((((long)key)))) + { + _am.AddFirst((((long)key))); + return _slots[((long)key)]; + } + if (_slots.Count >= _maxSize) + { + DiscardPage(finalizer); + } + object value = producer.Apply(((long)key)); + _slots[((long)key)] = value; + _a1.AddFirst((((long)key))); + return value; + } + + private void DiscardPage(IProcedure4 finalizer) + { + if (_a1.Size() >= _a1_threshold) + { + DiscardPageFrom(_a1, finalizer); + } + else + { + DiscardPageFrom(_am, finalizer); + } + } + + private void DiscardPageFrom(CircularLongBuffer4 list, IProcedure4 finalizer) + { + Discard(list.RemoveLast(), finalizer); + } + + private void Discard(long key, IProcedure4 finalizer) + { + if (null != finalizer) + { + finalizer.Apply(_slots[key]); + } + Sharpen.Collections.Remove(_slots, key); + } + + public override string ToString() + { + return "LRU2QCache(am=" + ToString(_am) + ", a1=" + ToString(_a1) + ")"; + } + + private string ToString(IEnumerable buffer) + { + return Iterators.ToString(buffer); + } + + public virtual IEnumerator GetEnumerator() + { + return _slots.Values.GetEnumerator(); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Caching/LRU2QXCache.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Caching/LRU2QXCache.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Caching/LRU2QXCache.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Caching/LRU2QXCache.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,119 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using System.Collections; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal.Caching; + +namespace Db4objects.Db4o.Internal.Caching +{ + /// + /// Full version of the algorithm taken from here: + /// http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.34.2641 + /// + internal class LRU2QXCache : ICache4 + { + private readonly IDictionary _slots; + + private readonly CircularBuffer4 _am; + + private readonly CircularBuffer4 _a1in; + + private readonly CircularBuffer4 _a1out; + + private readonly int _maxSize; + + private readonly int _inSize; + + public LRU2QXCache(int maxSize) + { + // 'eden': long-term lru queue + // 'nursery': short-term fifo queue, entry point for all new items + // 'backlog': fifo queue, elements may not be backed in _slots or may overlap with _am + // invariant: |_slots| = |_am| + |_a1in| <= _maxSize + _maxSize = maxSize; + _inSize = _maxSize / 4; + _slots = new Hashtable(_maxSize); + _am = new CircularBuffer4(_maxSize); + _a1in = new CircularBuffer4(_maxSize); + _a1out = new CircularBuffer4(_maxSize / 2); + } + + public virtual object Produce(object key, IFunction4 producer, IProcedure4 finalizer + ) + { + if (key == null) + { + throw new ArgumentNullException(); + } + if (_am.Remove(key)) + { + _am.AddFirst(key); + return _slots[key]; + } + if (_a1out.Contains(key)) + { + ReclaimFor(key, producer, finalizer); + _am.AddFirst(key); + return _slots[key]; + } + if (_a1in.Contains(key)) + { + return _slots[key]; + } + ReclaimFor(key, producer, finalizer); + _a1in.AddFirst(key); + return _slots[key]; + } + + private void ReclaimFor(object key, IFunction4 producer, IProcedure4 finalizer) + { + if (_slots.Count < _maxSize) + { + _slots[key] = producer.Apply(key); + return; + } + if (_a1in.Size() > _inSize) + { + object lastKey = _a1in.RemoveLast(); + Discard(lastKey, finalizer); + if (_a1out.IsFull()) + { + _a1out.RemoveLast(); + } + _a1out.AddFirst(lastKey); + } + else + { + object lastKey = _am.RemoveLast(); + Discard(lastKey, finalizer); + } + _slots[key] = producer.Apply(key); + } + + public virtual IEnumerator GetEnumerator() + { + return _slots.Values.GetEnumerator(); + } + + public override string ToString() + { + return "LRU2QXCache(am=" + ToString(_am) + ", a1in=" + ToString(_a1in) + ", a1out=" + + ToString(_a1out) + ")" + " - " + _slots.Count; + } + + private void Discard(object key, IProcedure4 finalizer) + { + object removed = Sharpen.Collections.Remove(_slots, key); + if (finalizer != null) + { + finalizer.Apply(removed); + } + } + + private string ToString(IEnumerable buffer) + { + return Iterators.ToString(buffer); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Caching/LRUCache.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Caching/LRUCache.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Caching/LRUCache.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Caching/LRUCache.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,70 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System.Collections; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal.Caching; + +namespace Db4objects.Db4o.Internal.Caching +{ + /// + internal class LRUCache : IPurgeableCache4 + { + private readonly IDictionary _slots; + + private readonly CircularBuffer4 _lru; + + private readonly int _maxSize; + + internal LRUCache(int size) + { + _maxSize = size; + _slots = new Hashtable(size); + _lru = new CircularBuffer4(size); + } + + public virtual object Produce(object key, IFunction4 producer, IProcedure4 finalizer + ) + { + object value = _slots[key]; + if (value == null) + { + object newValue = producer.Apply(key); + if (newValue == null) + { + return null; + } + if (_slots.Count >= _maxSize) + { + object discarded = Sharpen.Collections.Remove(_slots, _lru.RemoveLast()); + if (null != finalizer) + { + finalizer.Apply(discarded); + } + } + _slots[key] = newValue; + _lru.AddFirst(key); + return newValue; + } + _lru.Remove(key); + // O(N) + _lru.AddFirst(key); + return value; + } + + public virtual IEnumerator GetEnumerator() + { + return _slots.Values.GetEnumerator(); + } + + public virtual object Purge(object key) + { + object removed = Sharpen.Collections.Remove(_slots, key); + if (removed == null) + { + return null; + } + _lru.Remove(key); + return removed; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Caching/LRUIntCache.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Caching/LRUIntCache.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Caching/LRUIntCache.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Caching/LRUIntCache.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,191 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System.Collections; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal.Caching; + +namespace Db4objects.Db4o.Internal.Caching +{ + /// + internal class LRUIntCache : IPurgeableCache4 + { + private class Entry + { + internal readonly int _key; + + internal readonly object _value; + + internal LRUIntCache.Entry _previous; + + internal LRUIntCache.Entry _next; + + public Entry(int key, object value) + { + _key = key; + _value = value; + } + + public override string ToString() + { + return string.Empty + _key; + } + } + + private readonly Hashtable4 _slots; + + private readonly int _maxSize; + + private int _size; + + private LRUIntCache.Entry _first; + + private LRUIntCache.Entry _last; + + internal LRUIntCache(int size) + { + _maxSize = size; + _slots = new Hashtable4(size); + } + + public virtual object Produce(object key, IFunction4 producer, IProcedure4 finalizer + ) + { + int intKey = (((int)key)); + if (_last == null) + { + object lastValue = producer.Apply(((int)key)); + if (lastValue == null) + { + return null; + } + _size = 1; + LRUIntCache.Entry lastEntry = new LRUIntCache.Entry(intKey, lastValue); + _slots.Put(intKey, lastEntry); + _first = lastEntry; + _last = lastEntry; + return lastValue; + } + LRUIntCache.Entry entry = (LRUIntCache.Entry)_slots.Get(intKey); + if (entry == null) + { + if (_size >= _maxSize) + { + LRUIntCache.Entry oldEntry = (LRUIntCache.Entry)_slots.Remove(_last._key); + _last = oldEntry._previous; + _last._next = null; + if (null != finalizer) + { + finalizer.Apply((object)oldEntry._value); + } + _size--; + } + object newValue = producer.Apply(((int)key)); + if (newValue == null) + { + return null; + } + _size++; + LRUIntCache.Entry newEntry = new LRUIntCache.Entry(intKey, newValue); + _slots.Put(intKey, newEntry); + _first._previous = newEntry; + newEntry._next = _first; + _first = newEntry; + return newValue; + } + if (_first == entry) + { + return ((object)entry._value); + } + LRUIntCache.Entry previous = entry._previous; + entry._previous = null; + if (_last == entry) + { + _last = previous; + } + previous._next = entry._next; + if (previous._next != null) + { + previous._next._previous = previous; + } + _first._previous = entry; + entry._next = _first; + _first = entry; + return ((object)entry._value); + } + + public virtual IEnumerator GetEnumerator() + { + IEnumerator i = new _IEnumerator_108(this); + return i; + } + + private sealed class _IEnumerator_108 : IEnumerator + { + public _IEnumerator_108(LRUIntCache _enclosing) + { + this._enclosing = _enclosing; + this._cursor = this._enclosing._first; + } + + private LRUIntCache.Entry _cursor; + + private LRUIntCache.Entry _current; + + public object Current + { + get + { + return this._current._value; + } + } + + public bool MoveNext() + { + if (this._cursor == null) + { + this._current = null; + return false; + } + this._current = this._cursor; + this._cursor = this._cursor._next; + return true; + } + + public void Reset() + { + this._cursor = this._enclosing._first; + this._current = null; + } + + private readonly LRUIntCache _enclosing; + } + + public virtual object Purge(object key) + { + int intKey = (((int)key)); + LRUIntCache.Entry entry = (LRUIntCache.Entry)_slots.Remove(intKey); + if (entry == null) + { + return null; + } + _size--; + if (_first == entry) + { + _first = entry._next; + } + if (_last == entry) + { + _last = entry._previous; + } + if (entry._previous != null) + { + entry._previous._next = entry._next; + } + if (entry._next != null) + { + entry._next._previous = entry._previous; + } + return ((object)entry._value); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Caching/LRULongCache.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Caching/LRULongCache.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Caching/LRULongCache.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Caching/LRULongCache.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,191 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System.Collections; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal.Caching; + +namespace Db4objects.Db4o.Internal.Caching +{ + /// + internal class LRULongCache : IPurgeableCache4 + { + private class Entry + { + internal readonly long _key; + + internal readonly object _value; + + internal LRULongCache.Entry _previous; + + internal LRULongCache.Entry _next; + + public Entry(long key, object value) + { + _key = key; + _value = value; + } + + public override string ToString() + { + return string.Empty + _key; + } + } + + private readonly Hashtable4 _slots; + + private readonly int _maxSize; + + private int _size; + + private LRULongCache.Entry _first; + + private LRULongCache.Entry _last; + + internal LRULongCache(int size) + { + _maxSize = size; + _slots = new Hashtable4(size); + } + + public virtual object Produce(object key, IFunction4 producer, IProcedure4 finalizer + ) + { + long longKey = (((long)key)); + if (_last == null) + { + object lastValue = producer.Apply(((long)key)); + if (lastValue == null) + { + return null; + } + _size = 1; + LRULongCache.Entry lastEntry = new LRULongCache.Entry(longKey, lastValue); + _slots.Put(longKey, lastEntry); + _first = lastEntry; + _last = lastEntry; + return lastValue; + } + LRULongCache.Entry entry = (LRULongCache.Entry)_slots.Get(longKey); + if (entry == null) + { + if (_size >= _maxSize) + { + LRULongCache.Entry oldEntry = (LRULongCache.Entry)_slots.Remove(_last._key); + _last = oldEntry._previous; + _last._next = null; + if (null != finalizer) + { + finalizer.Apply((object)oldEntry._value); + } + _size--; + } + object newValue = producer.Apply(((long)key)); + if (newValue == null) + { + return null; + } + _size++; + LRULongCache.Entry newEntry = new LRULongCache.Entry(longKey, newValue); + _slots.Put(longKey, newEntry); + _first._previous = newEntry; + newEntry._next = _first; + _first = newEntry; + return newValue; + } + if (_first == entry) + { + return ((object)entry._value); + } + LRULongCache.Entry previous = entry._previous; + entry._previous = null; + if (_last == entry) + { + _last = previous; + } + previous._next = entry._next; + if (previous._next != null) + { + previous._next._previous = previous; + } + _first._previous = entry; + entry._next = _first; + _first = entry; + return ((object)entry._value); + } + + public virtual IEnumerator GetEnumerator() + { + IEnumerator i = new _IEnumerator_108(this); + return i; + } + + private sealed class _IEnumerator_108 : IEnumerator + { + public _IEnumerator_108(LRULongCache _enclosing) + { + this._enclosing = _enclosing; + this._cursor = this._enclosing._first; + } + + private LRULongCache.Entry _cursor; + + private LRULongCache.Entry _current; + + public object Current + { + get + { + return this._current._value; + } + } + + public bool MoveNext() + { + if (this._cursor == null) + { + this._current = null; + return false; + } + this._current = this._cursor; + this._cursor = this._cursor._next; + return true; + } + + public void Reset() + { + this._cursor = this._enclosing._first; + this._current = null; + } + + private readonly LRULongCache _enclosing; + } + + public virtual object Purge(object key) + { + long longKey = (((long)key)); + LRULongCache.Entry entry = (LRULongCache.Entry)_slots.Remove(longKey); + if (entry == null) + { + return null; + } + _size--; + if (_first == entry) + { + _first = entry._next; + } + if (_last == entry) + { + _last = entry._previous; + } + if (entry._previous != null) + { + entry._previous._next = entry._next; + } + if (entry._next != null) + { + entry._next._previous = entry._previous; + } + return ((object)entry._value); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Caching/NullCache4.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Caching/NullCache4.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Caching/NullCache4.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Caching/NullCache4.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,23 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System.Collections; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal.Caching; + +namespace Db4objects.Db4o.Internal.Caching +{ + /// + public class NullCache4 : ICache4 + { + public virtual object Produce(object key, IFunction4 producer, IProcedure4 onDiscard + ) + { + return producer.Apply(key); + } + + public virtual IEnumerator GetEnumerator() + { + return Iterators.EmptyIterator; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/CallBackMode.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/CallBackMode.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/CallBackMode.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/CallBackMode.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,28 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +namespace Db4objects.Db4o.Internal +{ + public sealed class CallBackMode + { + public static readonly Db4objects.Db4o.Internal.CallBackMode All = new Db4objects.Db4o.Internal.CallBackMode + ("ALL"); + + public static readonly Db4objects.Db4o.Internal.CallBackMode DeleteOnly = new Db4objects.Db4o.Internal.CallBackMode + ("DELETE_ONLY"); + + public static readonly Db4objects.Db4o.Internal.CallBackMode None = new Db4objects.Db4o.Internal.CallBackMode + ("NONE"); + + private string _desc; + + private CallBackMode(string desc) + { + _desc = desc; + } + + public override string ToString() + { + return _desc; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/CallbackObjectInfoCollections.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/CallbackObjectInfoCollections.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/CallbackObjectInfoCollections.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/CallbackObjectInfoCollections.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,34 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Ext; +using Db4objects.Db4o.Internal; + +namespace Db4objects.Db4o.Internal +{ + /// + public class CallbackObjectInfoCollections + { + public readonly IObjectInfoCollection added; + + public readonly IObjectInfoCollection updated; + + public readonly IObjectInfoCollection deleted; + + public static readonly Db4objects.Db4o.Internal.CallbackObjectInfoCollections Emtpy + = Empty(); + + public CallbackObjectInfoCollections(IObjectInfoCollection added_, IObjectInfoCollection + updated_, IObjectInfoCollection deleted_) + { + added = added_; + updated = updated_; + deleted = deleted_; + } + + private static Db4objects.Db4o.Internal.CallbackObjectInfoCollections Empty() + { + return new Db4objects.Db4o.Internal.CallbackObjectInfoCollections(ObjectInfoCollectionImpl + .Empty, ObjectInfoCollectionImpl.Empty, ObjectInfoCollectionImpl.Empty); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Callbacks/ICallbacks.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Callbacks/ICallbacks.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Callbacks/ICallbacks.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Callbacks/ICallbacks.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,58 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o; +using Db4objects.Db4o.Ext; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Query; + +namespace Db4objects.Db4o.Internal.Callbacks +{ + public interface ICallbacks + { + bool ObjectCanNew(Transaction transaction, object obj); + + bool ObjectCanActivate(Transaction transaction, object obj); + + bool ObjectCanUpdate(Transaction transaction, IObjectInfo objectInfo); + + bool ObjectCanDelete(Transaction transaction, IObjectInfo objectInfo); + + bool ObjectCanDeactivate(Transaction transaction, IObjectInfo objectInfo); + + void ObjectOnActivate(Transaction transaction, IObjectInfo obj); + + void ObjectOnNew(Transaction transaction, IObjectInfo obj); + + void ObjectOnUpdate(Transaction transaction, IObjectInfo obj); + + void ObjectOnDelete(Transaction transaction, IObjectInfo obj); + + void ObjectOnDeactivate(Transaction transaction, IObjectInfo obj); + + void ObjectOnInstantiate(Transaction transaction, IObjectInfo obj); + + void QueryOnStarted(Transaction transaction, IQuery query); + + void QueryOnFinished(Transaction transaction, IQuery query); + + bool CaresAboutCommitting(); + + bool CaresAboutCommitted(); + + void ClassOnRegistered(ClassMetadata clazz); + + void CommitOnStarted(Transaction transaction, CallbackObjectInfoCollections objectInfoCollections + ); + + void CommitOnCompleted(Transaction transaction, CallbackObjectInfoCollections objectInfoCollections + , bool isOwnCommit); + + bool CaresAboutDeleting(); + + bool CaresAboutDeleted(); + + void OpenOnFinished(IObjectContainer container); + + void CloseOnStarted(IObjectContainer container); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Callbacks/NullCallbacks.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Callbacks/NullCallbacks.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Callbacks/NullCallbacks.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Callbacks/NullCallbacks.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,115 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o; +using Db4objects.Db4o.Ext; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Callbacks; +using Db4objects.Db4o.Query; + +namespace Db4objects.Db4o.Internal.Callbacks +{ + public class NullCallbacks : ICallbacks + { + public virtual void QueryOnFinished(Transaction transaction, IQuery query) + { + } + + public virtual void QueryOnStarted(Transaction transaction, IQuery query) + { + } + + public virtual bool ObjectCanNew(Transaction transaction, object obj) + { + return true; + } + + public virtual bool ObjectCanActivate(Transaction transaction, object obj) + { + return true; + } + + public virtual bool ObjectCanUpdate(Transaction transaction, IObjectInfo objectInfo + ) + { + return true; + } + + public virtual bool ObjectCanDelete(Transaction transaction, IObjectInfo objectInfo + ) + { + return true; + } + + public virtual bool ObjectCanDeactivate(Transaction transaction, IObjectInfo objectInfo + ) + { + return true; + } + + public virtual void ObjectOnNew(Transaction transaction, IObjectInfo obj) + { + } + + public virtual void ObjectOnActivate(Transaction transaction, IObjectInfo obj) + { + } + + public virtual void ObjectOnUpdate(Transaction transaction, IObjectInfo obj) + { + } + + public virtual void ObjectOnDelete(Transaction transaction, IObjectInfo obj) + { + } + + public virtual void ObjectOnDeactivate(Transaction transaction, IObjectInfo obj) + { + } + + public virtual void ObjectOnInstantiate(Transaction transaction, IObjectInfo obj) + { + } + + public virtual void CommitOnStarted(Transaction transaction, CallbackObjectInfoCollections + objectInfoCollections) + { + } + + public virtual void CommitOnCompleted(Transaction transaction, CallbackObjectInfoCollections + objectInfoCollections, bool isOwnCommit) + { + } + + public virtual bool CaresAboutCommitting() + { + return false; + } + + public virtual bool CaresAboutCommitted() + { + return false; + } + + public virtual void ClassOnRegistered(ClassMetadata clazz) + { + } + + public virtual bool CaresAboutDeleting() + { + return false; + } + + public virtual bool CaresAboutDeleted() + { + return false; + } + + public virtual void CloseOnStarted(IObjectContainer container) + { + } + + public virtual void OpenOnFinished(IObjectContainer container) + { + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/ClassAspect.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/ClassAspect.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/ClassAspect.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/ClassAspect.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,79 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Delete; +using Db4objects.Db4o.Internal.Marshall; +using Db4objects.Db4o.Marshall; +using Db4objects.Db4o.Typehandlers; + +namespace Db4objects.Db4o.Internal +{ + /// + public abstract class ClassAspect + { + protected int _handle; + + private int _disabledFromAspectCountVersion = AspectVersionContextImpl.AlwaysEnabled + .DeclaredAspectCount(); + + // used for identification when sending in C/S mode + public abstract Db4objects.Db4o.Internal.Marshall.AspectType AspectType(); + + public abstract string GetName(); + + public abstract void CascadeActivation(IActivationContext context); + + public abstract int LinkLength(); + + public void IncrementOffset(IReadBuffer buffer) + { + buffer.Seek(buffer.Offset() + LinkLength()); + } + + public abstract void DefragAspect(IDefragmentContext context); + + public abstract void Marshall(MarshallingContext context, object child); + + public abstract void CollectIDs(CollectIdContext context); + + public virtual void SetHandle(int handle) + { + _handle = handle; + } + + public abstract void Activate(UnmarshallingContext context); + + public abstract void Delete(DeleteContextImpl context, bool isUpdate); + + public abstract bool CanBeDisabled(); + + protected virtual bool CheckEnabled(IAspectVersionContext context) + { + if (!IsEnabledOn(context)) + { + IncrementOffset((IReadBuffer)context); + return false; + } + return true; + } + + public virtual void DisableFromAspectCountVersion(int aspectCount) + { + if (!CanBeDisabled()) + { + return; + } + if (aspectCount < _disabledFromAspectCountVersion) + { + _disabledFromAspectCountVersion = aspectCount; + } + } + + public bool IsEnabledOn(IAspectVersionContext context) + { + return _disabledFromAspectCountVersion > context.DeclaredAspectCount(); + } + + public abstract void Deactivate(IActivationContext context); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Classindex/AbstractClassIndexStrategy.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Classindex/AbstractClassIndexStrategy.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Classindex/AbstractClassIndexStrategy.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Classindex/AbstractClassIndexStrategy.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,82 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System.Collections; +using Db4objects.Db4o; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Classindex; + +namespace Db4objects.Db4o.Internal.Classindex +{ + /// + public abstract class AbstractClassIndexStrategy : IClassIndexStrategy + { + protected readonly ClassMetadata _classMetadata; + + public AbstractClassIndexStrategy(ClassMetadata classMetadata) + { + _classMetadata = classMetadata; + } + + protected virtual int ClassMetadataID() + { + return _classMetadata.GetID(); + } + + public virtual int OwnLength() + { + return Const4.IdLength; + } + + protected abstract void InternalAdd(Transaction trans, int id); + + public void Add(Transaction trans, int id) + { + if (DTrace.enabled) + { + DTrace.AddToClassIndex.Log(id); + } + CheckId(id); + InternalAdd(trans, id); + } + + protected abstract void InternalRemove(Transaction ta, int id); + + public void Remove(Transaction ta, int id) + { + if (DTrace.enabled) + { + DTrace.RemoveFromClassIndex.Log(id); + } + CheckId(id); + InternalRemove(ta, id); + } + + private void CheckId(int id) + { + } + + public abstract IEnumerator AllSlotIDs(Transaction arg1); + + public abstract void DefragIndex(DefragmentContextImpl arg1); + + public abstract void DefragReference(ClassMetadata arg1, DefragmentContextImpl arg2 + , int arg3); + + public abstract void DontDelete(Transaction arg1, int arg2); + + public abstract int EntryCount(Transaction arg1); + + public abstract int Id(); + + public abstract void Initialize(ObjectContainerBase arg1); + + public abstract void Purge(); + + public abstract void Read(ObjectContainerBase arg1, int arg2); + + public abstract void TraverseAll(Transaction arg1, IVisitor4 arg2); + + public abstract int Write(Transaction arg1); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Classindex/BTreeClassIndexStrategy.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Classindex/BTreeClassIndexStrategy.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Classindex/BTreeClassIndexStrategy.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Classindex/BTreeClassIndexStrategy.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,160 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using System.Collections; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Btree; +using Db4objects.Db4o.Internal.Classindex; +using Db4objects.Db4o.Internal.References; + +namespace Db4objects.Db4o.Internal.Classindex +{ + /// + public class BTreeClassIndexStrategy : AbstractClassIndexStrategy + { + private BTree _btreeIndex; + + public BTreeClassIndexStrategy(ClassMetadata classMetadata) : base(classMetadata) + { + } + + public virtual BTree Btree() + { + return _btreeIndex; + } + + public override int EntryCount(Transaction ta) + { + return _btreeIndex != null ? _btreeIndex.Size(ta) : 0; + } + + public override void Initialize(ObjectContainerBase stream) + { + CreateBTreeIndex(stream, 0); + } + + public override void Purge() + { + } + + public override void Read(ObjectContainerBase stream, int indexID) + { + ReadBTreeIndex(stream, indexID); + } + + public override int Write(Transaction trans) + { + if (_btreeIndex == null) + { + return 0; + } + _btreeIndex.Write(trans); + return _btreeIndex.GetID(); + } + + public override void TraverseAll(Transaction ta, IVisitor4 command) + { + if (_btreeIndex != null) + { + _btreeIndex.TraverseKeys(ta, command); + } + } + + private void CreateBTreeIndex(ObjectContainerBase stream, int btreeID) + { + if (stream.IsClient) + { + return; + } + _btreeIndex = ((LocalObjectContainer)stream).CreateBTreeClassIndex(btreeID); + _btreeIndex.SetRemoveListener(new _IVisitor4_61(this)); + } + + private sealed class _IVisitor4_61 : IVisitor4 + { + public _IVisitor4_61(BTreeClassIndexStrategy _enclosing) + { + this._enclosing = _enclosing; + } + + public void Visit(object obj) + { + this._enclosing.RemoveId((TransactionContext)obj); + } + + private readonly BTreeClassIndexStrategy _enclosing; + } + + private void RemoveId(TransactionContext context) + { + IReferenceSystem referenceSystem = context._transaction.ReferenceSystem(); + ObjectReference reference = referenceSystem.ReferenceForId(((int)context._object) + ); + if (reference != null) + { + referenceSystem.RemoveReference(reference); + } + } + + private void ReadBTreeIndex(ObjectContainerBase stream, int indexId) + { + if (!stream.IsClient && _btreeIndex == null) + { + CreateBTreeIndex(stream, indexId); + } + } + + protected override void InternalAdd(Transaction trans, int id) + { + _btreeIndex.Add(trans, id); + } + + protected override void InternalRemove(Transaction ta, int id) + { + _btreeIndex.Remove(ta, id); + } + + public override void DontDelete(Transaction transaction, int id) + { + } + + public override void DefragReference(ClassMetadata classMetadata, DefragmentContextImpl + context, int classIndexID) + { + int newID = -classIndexID; + context.WriteInt(newID); + } + + public override int Id() + { + return _btreeIndex.GetID(); + } + + public override IEnumerator AllSlotIDs(Transaction trans) + { + return _btreeIndex.AllNodeIds(trans); + } + + public override void DefragIndex(DefragmentContextImpl context) + { + _btreeIndex.DefragIndex(context); + } + + public static BTree Btree(ClassMetadata clazz) + { + IClassIndexStrategy index = clazz.Index(); + if (!(index is Db4objects.Db4o.Internal.Classindex.BTreeClassIndexStrategy)) + { + throw new InvalidOperationException(); + } + return ((Db4objects.Db4o.Internal.Classindex.BTreeClassIndexStrategy)index).Btree + (); + } + + public static IEnumerator Iterate(ClassMetadata clazz, Transaction trans) + { + return Btree(clazz).AsRange(trans).Keys(); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Classindex/IClassIndexStrategy.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Classindex/IClassIndexStrategy.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Classindex/IClassIndexStrategy.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Classindex/IClassIndexStrategy.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,45 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System.Collections; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal; + +namespace Db4objects.Db4o.Internal.Classindex +{ + /// + public interface IClassIndexStrategy + { + void Initialize(ObjectContainerBase stream); + + void Read(ObjectContainerBase stream, int indexID); + + int Write(Transaction transaction); + + void Add(Transaction transaction, int id); + + void Remove(Transaction transaction, int id); + + int EntryCount(Transaction transaction); + + int OwnLength(); + + void Purge(); + + /// Traverses all index entries (java.lang.Integer references). + /// Traverses all index entries (java.lang.Integer references). + void TraverseAll(Transaction transaction, IVisitor4 command); + + void DontDelete(Transaction transaction, int id); + + IEnumerator AllSlotIDs(Transaction trans); + + // FIXME: Why is this never called? + void DefragReference(ClassMetadata classMetadata, DefragmentContextImpl context, + int classIndexID); + + int Id(); + + // FIXME: Why is this never called? + void DefragIndex(DefragmentContextImpl context); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/ClassMetadata.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/ClassMetadata.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/ClassMetadata.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/ClassMetadata.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,2735 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using System.Collections; +using Db4objects.Db4o; +using Db4objects.Db4o.Config; +using Db4objects.Db4o.Ext; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Activation; +using Db4objects.Db4o.Internal.Classindex; +using Db4objects.Db4o.Internal.Delete; +using Db4objects.Db4o.Internal.Diagnostic; +using Db4objects.Db4o.Internal.Encoding; +using Db4objects.Db4o.Internal.Handlers; +using Db4objects.Db4o.Internal.Handlers.Array; +using Db4objects.Db4o.Internal.Marshall; +using Db4objects.Db4o.Internal.Metadata; +using Db4objects.Db4o.Internal.Query.Processor; +using Db4objects.Db4o.Internal.Reflect; +using Db4objects.Db4o.Marshall; +using Db4objects.Db4o.Query; +using Db4objects.Db4o.Reflect; +using Db4objects.Db4o.Reflect.Core; +using Db4objects.Db4o.Reflect.Generic; +using Db4objects.Db4o.Typehandlers; + +namespace Db4objects.Db4o.Internal +{ + /// + public class ClassMetadata : PersistentBase, IStoredClass + { + /// + /// For reference types, _typeHandler always holds a StandardReferenceTypeHandler + /// that will use the _aspects of this class to take care of its business. + /// + /// + /// For reference types, _typeHandler always holds a StandardReferenceTypeHandler + /// that will use the _aspects of this class to take care of its business. A custom + /// type handler would appear as a TypeHandlerAspect in that case. + /// For value types, _typeHandler always holds the actual value type handler be it + /// a custom type handler or a builtin one. + /// + protected ITypeHandler4 _typeHandler; + + public Db4objects.Db4o.Internal.ClassMetadata _ancestor; + + private Config4Class _config; + + public ClassAspect[] _aspects; + + private IClassIndexStrategy _index; + + private string i_name; + + private readonly ObjectContainerBase _container; + + internal byte[] i_nameBytes; + + private ByteArrayBuffer i_reader; + + private bool _classIndexed; + + private IReflectClass _classReflector; + + private IEventDispatcher _eventDispatcher; + + private bool _internal; + + private bool _unversioned; + + private TernaryBool _canUpdateFast = TernaryBool.Unspecified; + + private TranslatedAspect _translator; + + private IModificationAware _modificationChecker = ClassMetadata.AlwaysModified.Instance; + + private IFieldAccessor _fieldAccessor; + + private IFunction4 _constructor; + + private TypeHandlerAspect _customTypeHandlerAspect; + + private IAspectTraversalStrategy _aspectTraversalStrategy; + + internal bool CanUpdateFast() + { + if (_canUpdateFast == TernaryBool.Unspecified) + { + _canUpdateFast = TernaryBool.ForBoolean(CheckCanUpdateFast()); + } + return _canUpdateFast.BooleanValue(false); + } + + private bool CheckCanUpdateFast() + { + if (_ancestor != null && !_ancestor.CanUpdateFast()) + { + return false; + } + if (_config != null && _config.CascadeOnDelete() == TernaryBool.Yes) + { + return false; + } + BooleanByRef hasIndex = new BooleanByRef(false); + TraverseDeclaredFields(new _IProcedure4_101(hasIndex)); + return !hasIndex.value; + } + + private sealed class _IProcedure4_101 : IProcedure4 + { + public _IProcedure4_101(BooleanByRef hasIndex) + { + this.hasIndex = hasIndex; + } + + public void Apply(object arg) + { + if (((FieldMetadata)arg).HasIndex()) + { + hasIndex.value = true; + } + } + + private readonly BooleanByRef hasIndex; + } + + public virtual bool IsInternal() + { + return _internal; + } + + private IClassIndexStrategy CreateIndexStrategy() + { + return new BTreeClassIndexStrategy(this); + } + + protected ClassMetadata(ObjectContainerBase container) + { + if (null == container) + { + throw new ArgumentNullException(); + } + _container = container; + _index = CreateIndexStrategy(); + _classIndexed = true; + _fieldAccessor = new StrictFieldAccessor(); + } + + public ClassMetadata(ObjectContainerBase container, IReflectClass classReflector) + { + if (null == container) + { + throw new ArgumentNullException(); + } + _container = container; + ClassReflector(classReflector); + _index = CreateIndexStrategy(); + _classIndexed = true; + if (_container.Config().ExceptionsOnNotStorable()) + { + _fieldAccessor = new StrictFieldAccessor(); + } + else + { + _fieldAccessor = new LenientFieldAccessor(); + } + } + + internal virtual IFieldAccessor FieldAccessor() + { + return _fieldAccessor; + } + + private ITypeHandler4 CreateDefaultTypeHandler() + { + // TODO: make sure initializeAspects has been executed + // before the actual type handler is required + // and remove this method + return new StandardReferenceTypeHandler(this); + } + + public virtual void CascadeActivation(IActivationContext context) + { + if (!ObjectCanActivate(context.Transaction(), context.TargetObject())) + { + return; + } + TraverseAllAspects(new _ITraverseAspectCommand_160(context)); + } + + private sealed class _ITraverseAspectCommand_160 : ITraverseAspectCommand + { + public _ITraverseAspectCommand_160(IActivationContext context) + { + this.context = context; + } + + public void ProcessAspectOnMissingClass(ClassAspect aspect, int currentSlot) + { + } + + // do nothing + public void ProcessAspect(ClassAspect aspect, int currentSlot) + { + aspect.CascadeActivation(context); + } + + public int DeclaredAspectCount(Db4objects.Db4o.Internal.ClassMetadata classMetadata + ) + { + return classMetadata.DeclaredAspectCount(); + } + + public bool Cancelled() + { + return false; + } + + private readonly IActivationContext context; + } + + public void AddFieldIndices(StatefulBuffer buffer) + { + if (!StandardReferenceTypeHandlerIsUsed()) + { + return; + } + if (HasClassIndex() || HasVirtualAttributes()) + { + ObjectHeader oh = new ObjectHeader(this, buffer); + ObjectIdContextImpl context = new ObjectIdContextImpl(buffer.Transaction(), buffer + , oh, buffer.GetID()); + Handlers4.FieldAwareTypeHandler(CorrectHandlerVersion(context)).AddFieldIndices(context + ); + } + } + + // FIXME: This method wants to be removed. + private bool StandardReferenceTypeHandlerIsUsed() + { + return _typeHandler is StandardReferenceTypeHandler; + } + + internal virtual void InitializeAspects() + { + BitTrue(Const4.CheckedChanges); + Collection4 aspects = new Collection4(); + if (null != _aspects) + { + aspects.AddAll(_aspects); + } + ITypeHandler4 customTypeHandler = Container().Handlers.ConfiguredTypeHandler(ClassReflector + ()); + bool dirty = IsDirty(); + if (InstallTranslator(aspects, customTypeHandler)) + { + dirty = true; + } + if (Container().DetectSchemaChanges()) + { + if (GenerateCommitTimestamps()) + { + if (!HasCommitTimestampField()) + { + aspects.Add(Container().CommitTimestampIndex()); + dirty = true; + } + } + if (GenerateUUIDs()) + { + if (!HasUUIDField()) + { + aspects.Add(Container().UUIDIndex()); + dirty = true; + } + } + } + if (InstallCustomTypehandler(aspects, customTypeHandler)) + { + dirty = true; + } + bool defaultFieldBehaviour = _translator == null && customTypeHandler == null; + if (Container().DetectSchemaChanges()) + { + if (defaultFieldBehaviour) + { + if (CollectReflectFields(aspects)) + { + dirty = true; + } + } + if (dirty) + { + _container.SetDirtyInSystemTransaction(this); + } + } + if (dirty || !defaultFieldBehaviour) + { + _aspects = ToClassAspectArray(aspects); + } + DiagnosticProcessor dp = _container._handlers.DiagnosticProcessor(); + if (dp.Enabled()) + { + dp.CheckClassHasFields(this); + } + if (_aspects == null) + { + _aspects = new FieldMetadata[0]; + } + InitializeConstructor(customTypeHandler); + if (StateDead()) + { + return; + } + _container.Callbacks().ClassOnRegistered(this); + SetStateOK(); + } + + private ClassAspect[] ToClassAspectArray(Collection4 aspects) + { + ClassAspect[] array = new ClassAspect[aspects.Size()]; + aspects.ToArray(array); + for (int i = 0; i < array.Length; i++) + { + array[i].SetHandle(i); + } + return array; + } + + private bool InstallCustomTypehandler(Collection4 aspects, ITypeHandler4 customTypeHandler + ) + { + if (customTypeHandler == null) + { + return false; + } + if (customTypeHandler is IModificationAware) + { + _modificationChecker = (IModificationAware)customTypeHandler; + } + if (Handlers4.IsStandaloneTypeHandler(customTypeHandler)) + { + _typeHandler = customTypeHandler; + return false; + } + bool dirty = false; + TypeHandlerAspect typeHandlerAspect = new TypeHandlerAspect(this, customTypeHandler + ); + if (!ReplaceAspectByName(aspects, typeHandlerAspect)) + { + aspects.Add(typeHandlerAspect); + dirty = true; + } + DisableAspectsBefore(aspects, typeHandlerAspect); + _customTypeHandlerAspect = typeHandlerAspect; + return dirty; + } + + private void DisableAspectsBefore(Collection4 aspects, TypeHandlerAspect typeHandlerAspect + ) + { + int disableFromVersion = aspects.IndexOf(typeHandlerAspect) + 1; + IEnumerator i = aspects.GetEnumerator(); + while (i.MoveNext()) + { + ClassAspect aspect = (ClassAspect)i.Current; + if (aspect == typeHandlerAspect) + { + break; + } + aspect.DisableFromAspectCountVersion(disableFromVersion); + } + } + + private bool InstallTranslator(Collection4 aspects, ITypeHandler4 customTypeHandler + ) + { + if (_config == null) + { + return false; + } + IObjectTranslator translator = _config.GetTranslator(); + if (translator == null) + { + return false; + } + ClassAspect existingAspect = AspectByName(aspects, TranslatedAspect.FieldNameFor( + translator)); + if (null != existingAspect) + { + return InstallTranslatorOnExistingAspect(translator, existingAspect, aspects); + } + if (customTypeHandler == null) + { + return InstallTranslatorOnNewAspect(translator, aspects); + } + return false; + } + + private bool InstallTranslatorOnNewAspect(IObjectTranslator translator, Collection4 + aspects) + { + TranslatedAspect translatedAspect = new TranslatedAspect(this, translator); + aspects.Add(translatedAspect); + _translator = translatedAspect; + return true; + } + + private bool InstallTranslatorOnExistingAspect(IObjectTranslator translator, ClassAspect + existingAspect, Collection4 aspects) + { + if (existingAspect is TranslatedAspect) + { + TranslatedAspect translatedAspect = (TranslatedAspect)existingAspect; + translatedAspect.InitializeTranslator(translator); + _translator = translatedAspect; + return false; + } + // older versions didn't store the aspect type properly + _translator = new TranslatedAspect(this, translator); + aspects.ReplaceByIdentity(existingAspect, _translator); + return true; + } + + private bool ReplaceAspectByName(Collection4 aspects, ClassAspect aspect) + { + ClassAspect existing = AspectByName(aspects, aspect.GetName()); + if (existing == null) + { + return false; + } + aspects.ReplaceByIdentity(existing, aspect); + return true; + } + + private ClassAspect AspectByName(Collection4 aspects, string aspectName) + { + IEnumerator i = aspects.GetEnumerator(); + while (i.MoveNext()) + { + ClassAspect current = (ClassAspect)i.Current; + if (current.GetName().Equals(aspectName)) + { + return current; + } + } + return null; + } + + public virtual bool AspectsAreInitialized() + { + if (_aspects == null) + { + return false; + } + if (_ancestor != null) + { + return _ancestor.AspectsAreInitialized(); + } + return true; + } + + private bool CollectReflectFields(Collection4 collectedAspects) + { + bool dirty = false; + IReflectField[] reflectFieldArray = ReflectFields(); + for (int reflectFieldIndex = 0; reflectFieldIndex < reflectFieldArray.Length; ++reflectFieldIndex) + { + IReflectField reflectField = reflectFieldArray[reflectFieldIndex]; + if (!StoreField(reflectField)) + { + continue; + } + Db4objects.Db4o.Internal.ClassMetadata classMetadata = Handlers4.ErasedFieldType( + Container(), reflectField.GetFieldType()); + if (classMetadata == null) + { + continue; + } + FieldMetadata field = new FieldMetadata(this, reflectField, classMetadata); + if (Contains(collectedAspects, field)) + { + continue; + } + dirty = true; + collectedAspects.Add(field); + } + return dirty; + } + + private bool Contains(Collection4 collectedAspects, FieldMetadata field) + { + IEnumerator aspectIterator = collectedAspects.GetEnumerator(); + while (aspectIterator.MoveNext()) + { + if (((ClassAspect)aspectIterator.Current).Equals(field)) + { + return true; + } + } + return false; + } + + internal virtual void AddToIndex(Transaction trans, int id) + { + if (!trans.Container().MaintainsIndices()) + { + return; + } + AddToIndex1(trans, id); + } + + internal void AddToIndex1(Transaction a_trans, int a_id) + { + if (_ancestor != null) + { + _ancestor.AddToIndex1(a_trans, a_id); + } + if (HasClassIndex()) + { + _index.Add(a_trans, a_id); + } + } + + internal virtual bool AllowsQueries() + { + return HasClassIndex(); + } + + public virtual bool DescendOnCascadingActivation() + { + return true; + } + + internal virtual void CheckChanges() + { + if (StateOK()) + { + if (!BitIsTrue(Const4.CheckedChanges)) + { + BitTrue(Const4.CheckedChanges); + if (_ancestor != null) + { + _ancestor.CheckChanges(); + } + // Ancestor first, so the object length calculates + // correctly + if (_classReflector != null) + { + InitializeAspects(); + if (!_container.IsClient && !IsReadOnlyContainer()) + { + Write(_container.SystemTransaction()); + } + } + } + } + } + + public virtual void CheckType() + { + IReflectClass claxx = ClassReflector(); + if (claxx == null) + { + return; + } + if (_container._handlers.IclassInternal.IsAssignableFrom(claxx)) + { + _internal = true; + } + if (_container._handlers.IclassUnversioned.IsAssignableFrom(claxx)) + { + _unversioned = true; + } + if (IsDb4oTypeImpl()) + { + IDb4oTypeImpl db4oTypeImpl = (IDb4oTypeImpl)claxx.NewInstance(); + _classIndexed = (db4oTypeImpl == null || db4oTypeImpl.HasClassIndex()); + } + else + { + if (_config != null) + { + _classIndexed = _config.Indexed(); + } + } + } + + public virtual bool IsDb4oTypeImpl() + { + return _container._handlers.IclassDb4otypeimpl.IsAssignableFrom(ClassReflector()); + } + + public IUpdateDepth AdjustUpdateDepth(Transaction trans, IUpdateDepth depth) + { + return depth.Adjust(this); + } + + public virtual bool CascadesOnDeleteOrUpdate() + { + Config4Class config = ConfigOrAncestorConfig(); + if (config == null) + { + return false; + } + bool cascadeOnDelete = config.CascadeOnDelete() == TernaryBool.Yes; + bool cascadeOnUpdate = config.CascadeOnUpdate() == TernaryBool.Yes; + return cascadeOnDelete || cascadeOnUpdate; + } + + public virtual FixedActivationDepth AdjustCollectionDepthToBorders(FixedActivationDepth + depth) + { + if (!ClassReflector().IsCollection()) + { + return depth; + } + return depth.AdjustDepthToBorders(); + } + + public int UpdateDepthFromConfig() + { + if (_config != null && _config.UpdateDepth() != Const4.Unspecified) + { + return _config.UpdateDepth(); + } + Config4Impl config = ConfigImpl(); + int depth = config.UpdateDepth(); + if (_ancestor != null) + { + int ancestordepth = _ancestor.UpdateDepthFromConfig(); + if (ancestordepth > depth) + { + return ancestordepth; + } + } + return depth; + } + + public virtual void CollectConstraints(Transaction trans, QConObject parentConstraint + , object obj, IVisitor4 visitor) + { + TraverseAllAspects(new _TraverseFieldCommand_534(trans, parentConstraint, obj, visitor + )); + } + + private sealed class _TraverseFieldCommand_534 : TraverseFieldCommand + { + public _TraverseFieldCommand_534(Transaction trans, QConObject parentConstraint, + object obj, IVisitor4 visitor) + { + this.trans = trans; + this.parentConstraint = parentConstraint; + this.obj = obj; + this.visitor = visitor; + } + + protected override void Process(FieldMetadata field) + { + if (field.IsEnabledOn(AspectVersionContextImpl.CheckAlwaysEnabled)) + { + field.CollectConstraints(trans, parentConstraint, obj, visitor); + } + } + + private readonly Transaction trans; + + private readonly QConObject parentConstraint; + + private readonly object obj; + + private readonly IVisitor4 visitor; + } + + public void CollectIDs(CollectIdContext context, string fieldName) + { + CollectIDs(context, new _IPredicate4_544(fieldName)); + } + + private sealed class _IPredicate4_544 : IPredicate4 + { + public _IPredicate4_544(string fieldName) + { + this.fieldName = fieldName; + } + + public bool Match(object candidate) + { + return fieldName.Equals(((ClassAspect)candidate).GetName()); + } + + private readonly string fieldName; + } + + public void CollectIDs(CollectIdContext context) + { + CollectIDs(context, new _IPredicate4_553()); + } + + private sealed class _IPredicate4_553 : IPredicate4 + { + public _IPredicate4_553() + { + } + + public bool Match(object candidate) + { + return true; + } + } + + private void CollectIDs(CollectIdContext context, IPredicate4 predicate) + { + if (!StandardReferenceTypeHandlerIsUsed()) + { + throw new InvalidOperationException(); + } + ((StandardReferenceTypeHandler)CorrectHandlerVersion(context)).CollectIDs(context + , predicate); + } + + public virtual void CollectIDs(QueryingReadContext context) + { + if (!StandardReferenceTypeHandlerIsUsed()) + { + throw new InvalidOperationException(); + } + Handlers4.CollectIDs(context, CorrectHandlerVersion(context)); + } + + public virtual Config4Class Config() + { + return _config; + } + + public virtual Config4Class ConfigOrAncestorConfig() + { + if (_config != null) + { + return _config; + } + if (_ancestor != null) + { + return _ancestor.ConfigOrAncestorConfig(); + } + return null; + } + + private void ResolveClassReflector(string className) + { + IReflectClass reflectClass = _container.Reflector().ForName(className); + if (null == reflectClass) + { + throw new InvalidOperationException("Cannot initialize ClassMetadata for '" + className + + "'."); + } + ClassReflector(reflectClass); + } + + private void InitializeConstructor(ITypeHandler4 customTypeHandler) + { + if (IsTransient()) + { + _container.LogMsg(23, GetName()); + SetStateDead(); + return; + } + if (IsInterface() || IsAbstract()) + { + return; + } + IFunction4 constructor = CreateConstructor(customTypeHandler); + if (constructor != null) + { + _constructor = constructor; + return; + } + NotStorable(); + } + + private bool IsAbstract() + { + return ClassReflector().IsAbstract(); + } + + private bool IsInterface() + { + return ClassReflector().IsInterface(); + } + + private IFunction4 CreateConstructor(ITypeHandler4 customTypeHandler) + { + if (customTypeHandler is IInstantiatingTypeHandler) + { + return new _IFunction4_632(this); + } + if (HasObjectConstructor()) + { + return new _IFunction4_640(this); + } + if (ClassReflector().EnsureCanBeInstantiated()) + { + return new _IFunction4_648(this); + } + return null; + } + + private sealed class _IFunction4_632 : IFunction4 + { + public _IFunction4_632(ClassMetadata _enclosing) + { + this._enclosing = _enclosing; + } + + public object Apply(object context) + { + return this._enclosing.InstantiateWithCustomTypeHandlerIfEnabled(((UnmarshallingContext + )context)); + } + + private readonly ClassMetadata _enclosing; + } + + private sealed class _IFunction4_640 : IFunction4 + { + public _IFunction4_640(ClassMetadata _enclosing) + { + this._enclosing = _enclosing; + } + + public object Apply(object context) + { + return this._enclosing._translator.Construct(((UnmarshallingContext)context)); + } + + private readonly ClassMetadata _enclosing; + } + + private sealed class _IFunction4_648 : IFunction4 + { + public _IFunction4_648(ClassMetadata _enclosing) + { + this._enclosing = _enclosing; + } + + public object Apply(object context) + { + return this._enclosing.InstantiateFromReflector(((UnmarshallingContext)context).Container + ()); + } + + private readonly ClassMetadata _enclosing; + } + + private void NotStorable() + { + _container.LogMsg(7, GetName()); + SetStateDead(); + } + + private bool IsTransient() + { + return _container._handlers.IsTransient(ClassReflector()); + } + + private void ClassReflector(IReflectClass claxx) + { + _classReflector = claxx; + if (claxx == null) + { + _typeHandler = null; + return; + } + _typeHandler = CreateDefaultTypeHandler(); + } + + public virtual void Deactivate(Transaction trans, IObjectInfo reference, IActivationDepth + depth) + { + object obj = reference.GetObject(); + if (ObjectCanDeactivate(trans, reference)) + { + ForceDeactivation(trans, depth, obj); + ObjectOnDeactivate(trans, reference); + } + } + + public virtual void ForceDeactivation(Transaction trans, IActivationDepth depth, + object obj) + { + DeactivateFields(trans.Container().ActivationContextFor(trans, obj, depth)); + } + + private void ObjectOnDeactivate(Transaction transaction, IObjectInfo obj) + { + ObjectContainerBase container = transaction.Container(); + container.Callbacks().ObjectOnDeactivate(transaction, obj); + DispatchEvent(transaction, obj.GetObject(), EventDispatchers.Deactivate); + } + + private bool ObjectCanDeactivate(Transaction transaction, IObjectInfo objectInfo) + { + ObjectContainerBase container = transaction.Container(); + return container.Callbacks().ObjectCanDeactivate(transaction, objectInfo) && DispatchEvent + (transaction, objectInfo.GetObject(), EventDispatchers.CanDeactivate); + } + + internal void DeactivateFields(IActivationContext context) + { + TraverseAllAspects(new _ITraverseAspectCommand_701(context)); + } + + private sealed class _ITraverseAspectCommand_701 : ITraverseAspectCommand + { + public _ITraverseAspectCommand_701(IActivationContext context) + { + this.context = context; + } + + public void ProcessAspectOnMissingClass(ClassAspect aspect, int currentSlot) + { + } + + // do nothing + public void ProcessAspect(ClassAspect aspect, int currentSlot) + { + if (aspect.IsEnabledOn(AspectVersionContextImpl.CheckAlwaysEnabled)) + { + aspect.Deactivate(context); + } + } + + public int DeclaredAspectCount(Db4objects.Db4o.Internal.ClassMetadata classMetadata + ) + { + return classMetadata.DeclaredAspectCount(); + } + + public bool Cancelled() + { + return false; + } + + private readonly IActivationContext context; + } + + internal void Delete(StatefulBuffer buffer, object obj) + { + RemoveFromIndex(buffer.Transaction(), buffer.GetID()); + CascadeDeletion(buffer, obj); + } + + private void CascadeDeletion(StatefulBuffer buffer, object obj) + { + ObjectHeader oh = new ObjectHeader(this, buffer); + DeleteContextImpl context = new DeleteContextImpl(buffer, oh, ClassReflector(), null + ); + DeleteMembers(context, ArrayTypeFor(buffer, obj), false); + } + + private ArrayType ArrayTypeFor(StatefulBuffer buffer, object obj) + { + return buffer.Transaction().Container()._handlers.ArrayType(obj); + } + + /// + public virtual void Delete(IDeleteContext context) + { + CorrectHandlerVersion(context).Delete(context); + } + + internal virtual void DeleteMembers(DeleteContextImpl context, ArrayType arrayType + , bool isUpdate) + { + StatefulBuffer buffer = (StatefulBuffer)context.Buffer(); + int preserveCascade = context.CascadeDeleteDepth(); + try + { + if (CascadeOnDelete()) + { + if (ClassReflector().IsCollection()) + { + buffer.SetCascadeDeletes(CollectionDeleteDepth(context)); + } + else + { + buffer.SetCascadeDeletes(1); + } + } + Handlers4.FieldAwareTypeHandler(CorrectHandlerVersion(context)).DeleteMembers(context + , isUpdate); + } + catch (Exception e) + { + // This a catch for changed class hierarchies. + // It's very ugly to catch all here but it does + // help to heal migration from earlier db4o + // versions. + DiagnosticProcessor dp = Container()._handlers.DiagnosticProcessor(); + if (dp.Enabled()) + { + dp.DeletionFailed(); + } + } + buffer.SetCascadeDeletes(preserveCascade); + } + + private int CollectionDeleteDepth(DeleteContextImpl context) + { + return 1; + } + + public virtual TernaryBool CascadeOnDeleteTernary() + { + Config4Class config = Config(); + TernaryBool cascadeOnDelete = TernaryBool.Unspecified; + if (config != null && (cascadeOnDelete = config.CascadeOnDelete()) != TernaryBool + .Unspecified) + { + return cascadeOnDelete; + } + if (_ancestor == null) + { + return cascadeOnDelete; + } + return _ancestor.CascadeOnDeleteTernary(); + } + + public virtual bool CascadeOnDelete() + { + return CascadeOnDeleteTernary() == TernaryBool.Yes; + } + + public bool DispatchEvent(Transaction trans, object obj, int message) + { + return EventDispatcher().Dispatch(trans, obj, message); + } + + public bool HasEventRegistered(Transaction trans, int eventID) + { + return EventDispatcher().HasEventRegistered(eventID); + } + + private IEventDispatcher EventDispatcher() + { + if (null != _eventDispatcher) + { + return _eventDispatcher; + } + _eventDispatcher = EventDispatchers.ForClass(_container, ClassReflector()); + return _eventDispatcher; + } + + public int DeclaredAspectCount() + { + if (_aspects == null) + { + return 0; + } + return _aspects.Length; + } + + public int AspectCount() + { + int count = DeclaredAspectCount(); + if (_ancestor != null) + { + count += _ancestor.AspectCount(); + } + return count; + } + + // Scrolls offset in passed reader to the offset the passed field should + // be read at. + public HandlerVersion SeekToField(Transaction trans, ByteArrayBuffer buffer, FieldMetadata + field) + { + if (buffer == null) + { + return HandlerVersion.Invalid; + } + if (!StandardReferenceTypeHandlerIsUsed()) + { + return HandlerVersion.Invalid; + } + buffer.Seek(0); + ObjectHeader oh = new ObjectHeader(_container, buffer); + bool res = oh.ClassMetadata().SeekToField(new ObjectHeaderContext(trans, buffer, + oh), field); + if (!res) + { + return HandlerVersion.Invalid; + } + return new HandlerVersion(oh.HandlerVersion()); + } + + public bool SeekToField(ObjectHeaderContext context, ClassAspect field) + { + if (!StandardReferenceTypeHandlerIsUsed()) + { + return false; + } + return Handlers4.FieldAwareTypeHandler(CorrectHandlerVersion(context)).SeekToField + (context, field); + } + + public virtual bool GenerateUUIDs() + { + if (!GenerateVirtual()) + { + return false; + } + TernaryBool configValue = (_config == null) ? TernaryBool.Unspecified : _config.GenerateUUIDs + (); + return Generate1(_container.Config().GenerateUUIDs(), configValue); + } + + public virtual bool GenerateCommitTimestamps() + { + return _container.Config().GenerateCommitTimestamps().DefiniteYes(); + } + + private bool GenerateVirtual() + { + if (_unversioned) + { + return false; + } + if (_internal) + { + return false; + } + return true; + } + + private bool Generate1(ConfigScope globalConfig, TernaryBool individualConfig) + { + return globalConfig.ApplyConfig(individualConfig); + } + + public virtual Db4objects.Db4o.Internal.ClassMetadata GetAncestor() + { + return _ancestor; + } + + public virtual object GetComparableObject(object forObject) + { + if (_config != null) + { + if (_config.QueryAttributeProvider() != null) + { + return _config.QueryAttributeProvider().Attribute(forObject); + } + } + return forObject; + } + + public virtual Db4objects.Db4o.Internal.ClassMetadata GetHigherHierarchy(Db4objects.Db4o.Internal.ClassMetadata + a_classMetadata) + { + Db4objects.Db4o.Internal.ClassMetadata yc = GetHigherHierarchy1(a_classMetadata); + if (yc != null) + { + return yc; + } + return a_classMetadata.GetHigherHierarchy1(this); + } + + private Db4objects.Db4o.Internal.ClassMetadata GetHigherHierarchy1(Db4objects.Db4o.Internal.ClassMetadata + a_classMetadata) + { + if (a_classMetadata == this) + { + return this; + } + if (_ancestor != null) + { + return _ancestor.GetHigherHierarchy1(a_classMetadata); + } + return null; + } + + public virtual Db4objects.Db4o.Internal.ClassMetadata GetHigherOrCommonHierarchy( + Db4objects.Db4o.Internal.ClassMetadata a_classMetadata) + { + Db4objects.Db4o.Internal.ClassMetadata yc = GetHigherHierarchy1(a_classMetadata); + if (yc != null) + { + return yc; + } + if (_ancestor != null) + { + yc = _ancestor.GetHigherOrCommonHierarchy(a_classMetadata); + if (yc != null) + { + return yc; + } + } + return a_classMetadata.GetHigherHierarchy1(this); + } + + public override byte GetIdentifier() + { + return Const4.Yapclass; + } + + public virtual long[] GetIDs() + { + lock (Lock()) + { + if (!StateOK()) + { + return new long[0]; + } + return GetIDs(_container.Transaction); + } + } + + public virtual long[] GetIDs(Transaction trans) + { + lock (Lock()) + { + if (!StateOK()) + { + return new long[0]; + } + if (!HasClassIndex()) + { + return new long[0]; + } + return trans.Container().GetIDsForClass(trans, this); + } + } + + public virtual bool HasClassIndex() + { + if (!_classIndexed) + { + return false; + } + return StandardReferenceTypeHandlerIsUsed() || !(Handlers4.IsValueType(_typeHandler + )); + } + + private bool AncestorHasUUIDField() + { + if (_ancestor == null) + { + return false; + } + return _ancestor.HasUUIDField(); + } + + private bool HasUUIDField() + { + if (AncestorHasUUIDField()) + { + return true; + } + return Arrays4.ContainsInstanceOf(_aspects, typeof(UUIDFieldMetadata)); + } + + private bool AncestorHasVersionField() + { + if (_ancestor == null) + { + return false; + } + return _ancestor.HasVersionField(); + } + + private bool AncestorHasCommitTimestampField() + { + if (_ancestor == null) + { + return false; + } + return _ancestor.HasCommitTimestampField(); + } + + public virtual bool HasVersionField() + { + if (AncestorHasVersionField()) + { + return true; + } + return Arrays4.ContainsInstanceOf(_aspects, typeof(VersionFieldMetadata)); + } + + private bool HasCommitTimestampField() + { + if (AncestorHasCommitTimestampField()) + { + return true; + } + return Arrays4.ContainsInstanceOf(_aspects, typeof(CommitTimestampFieldMetadata)); + } + + public virtual IClassIndexStrategy Index() + { + return _index; + } + + public virtual int IndexEntryCount(Transaction ta) + { + if (!StateOK()) + { + return 0; + } + return _index.EntryCount(ta); + } + + public virtual IReflectClass ClassReflector() + { + return _classReflector; + } + + public virtual string GetName() + { + if (i_name == null) + { + if (_classReflector != null) + { + SetName(_classReflector.GetName()); + } + } + return i_name; + } + + public virtual IStoredClass GetParentStoredClass() + { + return GetAncestor(); + } + + public virtual IStoredField[] GetStoredFields() + { + lock (Lock()) + { + if (_aspects == null) + { + return new IStoredField[0]; + } + Collection4 storedFields = new Collection4(); + TraverseDeclaredFields(new _IProcedure4_1037(storedFields)); + IStoredField[] fields = new IStoredField[storedFields.Size()]; + storedFields.ToArray(fields); + return fields; + } + } + + private sealed class _IProcedure4_1037 : IProcedure4 + { + public _IProcedure4_1037(Collection4 storedFields) + { + this.storedFields = storedFields; + } + + public void Apply(object field) + { + storedFields.Add(field); + } + + private readonly Collection4 storedFields; + } + + public ObjectContainerBase Container() + { + return _container; + } + + public virtual FieldMetadata FieldMetadataForName(string name) + { + ByRef byReference = new ByRef(); + TraverseAllAspects(new _TraverseFieldCommand_1054(name, byReference)); + return (FieldMetadata)byReference.value; + } + + private sealed class _TraverseFieldCommand_1054 : TraverseFieldCommand + { + public _TraverseFieldCommand_1054(string name, ByRef byReference) + { + this.name = name; + this.byReference = byReference; + } + + protected override void Process(FieldMetadata field) + { + if (name.Equals(field.GetName())) + { + byReference.value = field; + } + } + + private readonly string name; + + private readonly ByRef byReference; + } + + /// + public virtual bool HasField(ObjectContainerBase container, string fieldName) + { + if (ClassReflector().IsCollection()) + { + return true; + } + return FieldMetadataForName(fieldName) != null; + } + + internal virtual bool HasVirtualAttributes() + { + if (_internal) + { + return false; + } + return HasVersionField() || HasUUIDField(); + } + + public virtual bool HoldsAnyClass() + { + return ClassReflector().IsCollection(); + } + + internal virtual void IncrementFieldsOffset1(ByteArrayBuffer a_bytes) + { + int length = ReadAspectCount(a_bytes); + for (int i = 0; i < length; i++) + { + _aspects[i].IncrementOffset(a_bytes); + } + } + + internal bool Init(Db4objects.Db4o.Internal.ClassMetadata ancestor) + { + if (DTrace.enabled) + { + DTrace.ClassmetadataInit.Log(GetID()); + } + SetConfig(ConfigImpl().ConfigClass(GetName())); + SetAncestor(ancestor); + CheckType(); + if (AllowsQueries()) + { + _index.Initialize(_container); + } + BitTrue(Const4.CheckedChanges); + return true; + } + + internal void InitConfigOnUp(Transaction systemTrans) + { + Config4Class extendedConfig = Platform4.ExtendConfiguration(_classReflector, _container + .Configure(), _config); + if (extendedConfig != null) + { + _config = extendedConfig; + } + if (_config == null) + { + return; + } + if (!StateOK()) + { + return; + } + InitializeFieldsConfiguration(systemTrans, extendedConfig); + CheckAllConfiguredFieldsExist(extendedConfig); + } + + private void InitializeFieldsConfiguration(Transaction systemTrans, Config4Class + extendedConfig) + { + if (_aspects == null) + { + return; + } + for (int i = 0; i < _aspects.Length; i++) + { + if (_aspects[i] is FieldMetadata) + { + FieldMetadata field = (FieldMetadata)_aspects[i]; + string fieldName = field.GetName(); + if (!field.HasConfig() && extendedConfig != null && extendedConfig.ConfigField(fieldName + ) != null) + { + field.InitConfiguration(fieldName); + } + field.InitConfigOnUp(systemTrans); + } + } + } + + private void CheckAllConfiguredFieldsExist(Config4Class config) + { + Hashtable4 exceptionalFields = config.ExceptionalFieldsOrNull(); + if (exceptionalFields == null) + { + return; + } + IEnumerator i = exceptionalFields.ValuesIterator(); + while (i.MoveNext()) + { + Config4Field fieldConfig = (Config4Field)i.Current; + if (!fieldConfig.Used()) + { + ConfigImpl().DiagnosticProcessor().ObjectFieldDoesNotExist(GetName(), fieldConfig + .GetName()); + } + } + } + + internal virtual void InitOnUp(Transaction systemTrans) + { + if (!StateOK()) + { + return; + } + InitConfigOnUp(systemTrans); + StoreStaticFieldValues(systemTrans, false); + } + + public virtual object Instantiate(UnmarshallingContext context) + { + // overridden in PrimitiveTypeMetadata + // never called for primitive YapAny + // FIXME: [TA] no longer necessary? + // context.adjustInstantiationDepth(); + object obj = context.PersistentObject(); + bool instantiating = (obj == null); + if (instantiating) + { + obj = InstantiateObject(context); + if (obj == null) + { + return null; + } + ShareTransaction(obj, context.Transaction()); + ShareObjectReference(obj, context.ObjectReference()); + OnInstantiate(context, obj); + if (context.ActivationDepth().Mode().IsPrefetch()) + { + context.ObjectReference().SetStateDeactivated(); + return obj; + } + if (!context.ActivationDepth().RequiresActivation()) + { + context.ObjectReference().SetStateDeactivated(); + return obj; + } + return Activate(context); + } + if (ActivatingActiveObject(context.ActivationDepth().Mode(), context.ObjectReference + ())) + { + IActivationDepth child = context.ActivationDepth().Descend(this); + if (child.RequiresActivation()) + { + CascadeActivation(new ActivationContext4(context.Transaction(), obj, child)); + } + return obj; + } + return Activate(context); + } + + protected void OnInstantiate(UnmarshallingContext context, object obj) + { + context.SetObjectWeak(obj); + context.Transaction().ReferenceSystem().AddExistingReference(context.ObjectReference + ()); + ObjectOnInstantiate(context.Transaction(), context.ObjectReference()); + } + + public virtual object InstantiateTransient(UnmarshallingContext context) + { + // overridden in YapClassPrimitive + // never called for primitive YapAny + object obj = InstantiateObject(context); + if (obj == null) + { + return null; + } + context.Container().Peeked(context.ObjectId(), obj); + if (context.ActivationDepth().RequiresActivation()) + { + InstantiateFields(context); + } + return obj; + } + + private bool ActivatingActiveObject(ActivationMode mode, ObjectReference @ref) + { + return !mode.IsRefresh() && @ref.IsActive(); + } + + private object Activate(UnmarshallingContext context) + { + object obj = context.PersistentObject(); + ObjectReference objectReference = context.ObjectReference(); + if (!ObjectCanActivate(context.Transaction(), obj)) + { + objectReference.SetStateDeactivated(); + return obj; + } + objectReference.SetStateClean(); + if (context.ActivationDepth().RequiresActivation()) + { + InstantiateFields(context); + } + ObjectOnActivate(context.Transaction(), objectReference); + return obj; + } + + public virtual bool HasObjectConstructor() + { + return _translator != null && _translator.IsObjectConstructor(); + } + + public virtual bool IsTranslated() + { + return _translator != null; + } + + private object InstantiateObject(UnmarshallingContext context) + { + object obj = _constructor.Apply(context); + context.PersistentObject(obj); + return obj; + } + + private void ObjectOnInstantiate(Transaction transaction, IObjectInfo reference) + { + transaction.Container().Callbacks().ObjectOnInstantiate(transaction, reference); + } + + private object InstantiateFromReflector(ObjectContainerBase stream) + { + if (_classReflector == null) + { + throw new InvalidOperationException(); + } + try + { + return _classReflector.NewInstance(); + } + catch (MissingMethodException) + { + Container().LogMsg(7, ClassReflector().GetName()); + return null; + } + catch (Exception) + { + // TODO: be more helpful here + return null; + } + } + + private void ShareObjectReference(object obj, ObjectReference @ref) + { + if (obj is IDb4oTypeImpl) + { + ((IDb4oTypeImpl)obj).SetObjectReference(@ref); + } + } + + private void ShareTransaction(object obj, Transaction transaction) + { + if (obj is ITransactionAware) + { + ((ITransactionAware)obj).SetTrans(transaction); + } + } + + private void ObjectOnActivate(Transaction transaction, IObjectInfo obj) + { + ObjectContainerBase container = transaction.Container(); + container.Callbacks().ObjectOnActivate(transaction, obj); + DispatchEvent(transaction, obj.GetObject(), EventDispatchers.Activate); + } + + private bool ObjectCanActivate(Transaction transaction, object obj) + { + ObjectContainerBase container = transaction.Container(); + return container.Callbacks().ObjectCanActivate(transaction, obj) && DispatchEvent + (transaction, obj, EventDispatchers.CanActivate); + } + + internal virtual void InstantiateFields(UnmarshallingContext context) + { + ITypeHandler4 handler = CorrectHandlerVersion((IHandlerVersionContext)context); + Handlers4.Activate(context, handler); + } + + public virtual bool IsArray() + { + return ClassReflector().IsCollection(); + } + + internal virtual bool IsCollection(object obj) + { + return Reflector().ForObject(obj).IsCollection(); + } + + public override bool IsDirty() + { + if (!StateOK()) + { + return false; + } + return base.IsDirty(); + } + + internal virtual bool IsEnum() + { + return Platform4.IsJavaEnum(Reflector(), ClassReflector()); + } + + public virtual bool HasIdentity() + { + return true; + } + + /// no any, primitive, array or other tricks. + /// + /// no any, primitive, array or other tricks. overridden in YapClassAny and + /// YapClassPrimitive + /// + public virtual bool IsStronglyTyped() + { + return true; + } + + public virtual bool IsValueType() + { + return Handlers4.HoldsValueType(_typeHandler); + } + + private object Lock() + { + return _container.Lock(); + } + + public virtual string NameToWrite() + { + if (_config != null && _config.WriteAs() != null) + { + return _config.WriteAs(); + } + if (i_name == null) + { + return string.Empty; + } + return ConfigImpl().ResolveAliasRuntimeName(i_name); + } + + public bool CallConstructor() + { + TernaryBool specialized = CallConstructorSpecialized(); + // FIXME: If specified, return yes?!? + if (!specialized.IsUnspecified()) + { + return specialized.DefiniteYes(); + } + return ConfigImpl().CallConstructors().DefiniteYes(); + } + + private Config4Impl ConfigImpl() + { + return _container.ConfigImpl; + } + + private TernaryBool CallConstructorSpecialized() + { + if (_config != null) + { + TernaryBool res = _config.CallConstructor(); + if (!res.IsUnspecified()) + { + return res; + } + } + if (IsEnum()) + { + return TernaryBool.No; + } + if (_ancestor != null) + { + return _ancestor.CallConstructorSpecialized(); + } + return TernaryBool.Unspecified; + } + + public override int OwnLength() + { + return MarshallerFamily.Current()._class.MarshalledLength(_container, this); + } + + internal virtual void Purge() + { + _index.Purge(); + } + + // TODO: may want to add manual purge to Btree + // indexes here + public virtual ITypeHandler4 ReadCandidateHandler(QueryingReadContext context) + { + ITypeHandler4 typeHandler = CorrectHandlerVersion(context); + if (typeHandler is ICascadingTypeHandler) + { + return ((ICascadingTypeHandler)typeHandler).ReadCandidateHandler(context); + } + return null; + } + + public virtual ITypeHandler4 SeekCandidateHandler(QueryingReadContext context) + { + if (IsArray()) + { + if (Platform4.IsCollectionTranslator(this._config)) + { + context.Seek(context.Offset() + Const4.IntLength); + return new ArrayHandler(null, false); + } + IncrementFieldsOffset1((ByteArrayBuffer)context.Buffer()); + if (_ancestor != null) + { + return _ancestor.SeekCandidateHandler(context); + } + } + return null; + } + + public int ReadAspectCount(IReadBuffer buffer) + { + int count = buffer.ReadInt(); + if (count > _aspects.Length) + { + return _aspects.Length; + } + return count; + } + + internal virtual byte[] ReadName(Transaction a_trans) + { + i_reader = a_trans.Container().ReadBufferById(a_trans, GetID()); + return ReadName1(a_trans, i_reader); + } + + public byte[] ReadName1(Transaction trans, ByteArrayBuffer reader) + { + if (reader == null) + { + return null; + } + i_reader = reader; + bool ok = false; + try + { + ClassMarshaller marshaller = MarshallerFamily.Current()._class; + i_nameBytes = marshaller.ReadName(trans, reader); + marshaller.ReadMetaClassID(reader); + // never used ??? + SetStateUnread(); + BitFalse(Const4.CheckedChanges); + BitFalse(Const4.StaticFieldsStored); + ok = true; + return i_nameBytes; + } + finally + { + if (!ok) + { + SetStateDead(); + } + } + } + + public virtual void ReadVirtualAttributes(Transaction trans, ObjectReference @ref + , bool lastCommitted) + { + int id = @ref.GetID(); + ObjectContainerBase container = trans.Container(); + ByteArrayBuffer buffer = container.ReadBufferById(trans, id, lastCommitted); + ObjectHeader oh = new ObjectHeader(this, buffer); + ObjectReferenceContext context = new ObjectReferenceContext(trans, buffer, oh, @ref + ); + Handlers4.FieldAwareTypeHandler(CorrectHandlerVersion(context)).ReadVirtualAttributes + (context); + } + + public virtual GenericReflector Reflector() + { + return _container.Reflector(); + } + + public virtual void Rename(string newName) + { + if (_container.IsClient) + { + Exceptions4.ThrowRuntimeException(58); + } + int tempState = _state; + SetStateOK(); + SetName(newName); + i_nameBytes = AsBytes(i_name); + SetStateDirty(); + Write(_container.SystemTransaction()); + IReflectClass oldReflector = _classReflector; + ClassReflector(Container().Reflector().ForName(newName)); + Container().ClassCollection().RefreshClassCache(this, oldReflector); + Refresh(); + _state = tempState; + } + + //TODO: duplicates ClassMetadataRepository#asBytes + private byte[] AsBytes(string str) + { + return Container().StringIO().Write(str); + } + + internal void CreateConfigAndConstructor(Hashtable4 a_byteHashTable, IReflectClass + claxx) + { + SetName(ResolveName(claxx)); + SetConfig(ConfigImpl().ConfigClass(GetName())); + if (claxx == null) + { + ResolveClassReflector(GetName()); + } + else + { + ClassReflector(claxx); + } + // createConstructor(true); + if (i_nameBytes != null) + { + a_byteHashTable.Remove(i_nameBytes); + i_nameBytes = null; + } + } + + internal virtual string ResolveName(IReflectClass claxx) + { + if (claxx != null) + { + return claxx.GetName(); + } + if (i_nameBytes != null) + { + string name = _container.StringIO().Read(i_nameBytes); + return ConfigImpl().ResolveAliasStoredName(name); + } + throw new InvalidOperationException(); + } + + internal virtual bool ReadThis() + { + bool stateUnread = StateUnread(); + if (stateUnread) + { + SetStateOK(); + SetStateClean(); + } + if (stateUnread || StateDead()) + { + ForceRead(); + return true; + } + return false; + } + + internal void ForceRead() + { + if (i_reader == null || BitIsTrue(Const4.Reading)) + { + return; + } + BitTrue(Const4.Reading); + try + { + MarshallerFamily.ForConverterVersion(_container.ConverterVersion())._class.Read(_container + , this, i_reader); + i_nameBytes = null; + i_reader = null; + } + finally + { + BitFalse(Const4.Reading); + } + } + + public override void ReadThis(Transaction a_trans, ByteArrayBuffer a_reader) + { + throw Exceptions4.VirtualException(); + } + + public virtual void Refresh() + { + if (!StateUnread()) + { + ResolveClassReflector(i_name); + BitFalse(Const4.CheckedChanges); + CheckChanges(); + TraverseDeclaredFields(new _IProcedure4_1582()); + } + } + + private sealed class _IProcedure4_1582 : IProcedure4 + { + public _IProcedure4_1582() + { + } + + public void Apply(object arg) + { + ((FieldMetadata)arg).Refresh(); + } + } + + internal virtual void RemoveFromIndex(Transaction ta, int id) + { + if (HasClassIndex()) + { + _index.Remove(ta, id); + } + if (_ancestor != null) + { + _ancestor.RemoveFromIndex(ta, id); + } + } + + internal virtual bool RenameField(string oldName, string newName) + { + BooleanByRef renamed = new BooleanByRef(false); + for (int i = 0; i < _aspects.Length; i++) + { + if (_aspects[i].GetName().Equals(newName)) + { + _container.LogMsg(9, "class:" + GetName() + " field:" + newName); + return false; + } + } + TraverseDeclaredFields(new _IProcedure4_1607(oldName, newName, renamed)); + return renamed.value; + } + + private sealed class _IProcedure4_1607 : IProcedure4 + { + public _IProcedure4_1607(string oldName, string newName, BooleanByRef renamed) + { + this.oldName = oldName; + this.newName = newName; + this.renamed = renamed; + } + + public void Apply(object arg) + { + FieldMetadata field = (FieldMetadata)arg; + if (field.GetName().Equals(oldName)) + { + field.SetName(newName); + renamed.value = true; + } + } + + private readonly string oldName; + + private readonly string newName; + + private readonly BooleanByRef renamed; + } + + internal virtual void SetConfig(Config4Class config) + { + if (config == null) + { + return; + } + // The configuration can be set by a ObjectClass#readAs setting + // from YapClassCollection, right after reading the meta information + // for the first time. In that case we never change the setting + if (_config == null) + { + _config = config; + } + } + + internal virtual void SetName(string a_name) + { + i_name = a_name; + } + + internal void SetStateDead() + { + BitTrue(Const4.Dead); + BitFalse(Const4.Continue); + } + + private void SetStateUnread() + { + BitFalse(Const4.Dead); + BitTrue(Const4.Continue); + } + + internal void SetStateOK() + { + BitFalse(Const4.Dead); + BitFalse(Const4.Continue); + } + + internal virtual bool StateDead() + { + return BitIsTrue(Const4.Dead); + } + + internal bool StateOK() + { + return BitIsFalse(Const4.Continue) && BitIsFalse(Const4.Dead) && BitIsFalse(Const4 + .Reading); + } + + internal virtual bool StateUnread() + { + return BitIsTrue(Const4.Continue) && BitIsFalse(Const4.Dead) && BitIsFalse(Const4 + .Reading); + } + + internal virtual bool StoreField(IReflectField field) + { + if (field.IsStatic()) + { + return false; + } + if (IsTransient(field)) + { + if (!ShouldStoreTransientFields()) + { + return false; + } + } + return Platform4.CanSetAccessible() || field.IsPublic(); + } + + internal virtual bool ShouldStoreTransientFields() + { + Config4Class config = ConfigOrAncestorConfig(); + if (config == null) + { + return false; + } + return config.StoreTransientFields(); + } + + private bool IsTransient(IReflectField field) + { + return field.IsTransient() || Platform4.IsTransient(field.GetFieldType()); + } + + public virtual IStoredField StoredField(string fieldName, object fieldType) + { + lock (Lock()) + { + Db4objects.Db4o.Internal.ClassMetadata fieldTypeFilter = fieldType == null ? null + : _container.ClassMetadataForReflectClass(ReflectorUtils.ReflectClassFor(Reflector + (), fieldType)); + ByRef foundField = new ByRef(); + TraverseAllAspects(new _TraverseFieldCommand_1701(foundField, fieldName, fieldTypeFilter + )); + // TODO: implement field creation + return (IStoredField)foundField.value; + } + } + + private sealed class _TraverseFieldCommand_1701 : TraverseFieldCommand + { + public _TraverseFieldCommand_1701(ByRef foundField, string fieldName, Db4objects.Db4o.Internal.ClassMetadata + fieldTypeFilter) + { + this.foundField = foundField; + this.fieldName = fieldName; + this.fieldTypeFilter = fieldTypeFilter; + } + + protected override void Process(FieldMetadata field) + { + if (foundField.value != null) + { + return; + } + if (field.GetName().Equals(fieldName)) + { + if (fieldTypeFilter == null || fieldTypeFilter == field.FieldType()) + { + foundField.value = field; + } + } + } + + private readonly ByRef foundField; + + private readonly string fieldName; + + private readonly Db4objects.Db4o.Internal.ClassMetadata fieldTypeFilter; + } + + internal virtual void StoreStaticFieldValues(Transaction trans, bool force) + { + if (BitIsTrue(Const4.StaticFieldsStored) && !force) + { + return; + } + BitTrue(Const4.StaticFieldsStored); + if (!ShouldStoreStaticFields(trans)) + { + return; + } + ObjectContainerBase stream = trans.Container(); + stream.ShowInternalClasses(true); + try + { + StaticClass sc = QueryStaticClass(trans); + if (sc == null) + { + CreateStaticClass(trans); + } + else + { + UpdateStaticClass(trans, sc); + } + } + finally + { + stream.ShowInternalClasses(false); + } + } + + private bool ShouldStoreStaticFields(Transaction trans) + { + return !IsReadOnlyContainer() && (StaticFieldValuesArePersisted() || Platform4.StoreStaticFieldValues + (trans.Reflector(), ClassReflector())); + } + + private bool IsReadOnlyContainer() + { + return Container().Config().IsReadOnly(); + } + + private void UpdateStaticClass(Transaction trans, StaticClass sc) + { + ObjectContainerBase stream = trans.Container(); + stream.Activate(trans, sc, new FixedActivationDepth(4)); + StaticField[] existingFields = sc.fields; + IEnumerator staticFields = Iterators.Map(StaticReflectFields(), new _IFunction4_1761 + (this, existingFields, trans)); + sc.fields = ToStaticFieldArray(staticFields); + if (!stream.IsClient) + { + SetStaticClass(trans, sc); + } + } + + private sealed class _IFunction4_1761 : IFunction4 + { + public _IFunction4_1761(ClassMetadata _enclosing, StaticField[] existingFields, Transaction + trans) + { + this._enclosing = _enclosing; + this.existingFields = existingFields; + this.trans = trans; + } + + public object Apply(object arg) + { + IReflectField reflectField = (IReflectField)arg; + StaticField existingField = this._enclosing.FieldByName(existingFields, reflectField + .GetName()); + if (existingField != null) + { + this._enclosing.UpdateExistingStaticField(trans, existingField, reflectField); + return existingField; + } + return this._enclosing.ToStaticField(reflectField); + } + + private readonly ClassMetadata _enclosing; + + private readonly StaticField[] existingFields; + + private readonly Transaction trans; + } + + private void CreateStaticClass(Transaction trans) + { + if (trans.Container().IsClient) + { + return; + } + StaticClass sc = new StaticClass(GetName(), ToStaticFieldArray(StaticReflectFieldsToStaticFields + ())); + SetStaticClass(trans, sc); + } + + private IEnumerator StaticReflectFieldsToStaticFields() + { + return Iterators.Map(StaticReflectFields(), new _IFunction4_1789(this)); + } + + private sealed class _IFunction4_1789 : IFunction4 + { + public _IFunction4_1789(ClassMetadata _enclosing) + { + this._enclosing = _enclosing; + } + + public object Apply(object arg) + { + return this._enclosing.ToStaticField((IReflectField)arg); + } + + private readonly ClassMetadata _enclosing; + } + + protected virtual StaticField ToStaticField(IReflectField reflectField) + { + return new StaticField(reflectField.GetName(), StaticReflectFieldValue(reflectField + )); + } + + private object StaticReflectFieldValue(IReflectField reflectField) + { + return _fieldAccessor.Get(reflectField, null); + } + + private void SetStaticClass(Transaction trans, StaticClass sc) + { + // TODO: we should probably use a specific update depth here, 4? + trans.Container().StoreInternal(trans, sc, true); + } + + private StaticField[] ToStaticFieldArray(IEnumerator iterator4) + { + return ToStaticFieldArray(new Collection4(iterator4)); + } + + private StaticField[] ToStaticFieldArray(Collection4 fields) + { + return (StaticField[])fields.ToArray(new StaticField[fields.Size()]); + } + + private IEnumerator StaticReflectFields() + { + return Iterators.Filter(ReflectFields(), new _IPredicate4_1818()); + } + + private sealed class _IPredicate4_1818 : IPredicate4 + { + public _IPredicate4_1818() + { + } + + public bool Match(object candidate) + { + return ((IReflectField)candidate).IsStatic() && !((IReflectField)candidate).IsTransient + (); + } + } + + private IReflectField[] ReflectFields() + { + return ClassReflector().GetDeclaredFields(); + } + + protected virtual void UpdateExistingStaticField(Transaction trans, StaticField existingField + , IReflectField reflectField) + { + ObjectContainerBase stream = trans.Container(); + object newValue = StaticReflectFieldValue(reflectField); + if (existingField.value != null && newValue != null && existingField.value.GetType + () == newValue.GetType()) + { + int id = stream.GetID(trans, existingField.value); + if (id > 0) + { + if (existingField.value != newValue) + { + // This is the clue: + // Bind the current static member to it's old database identity, + // so constants and enums will work with '==' + stream.Bind(trans, newValue, id); + // This may produce unwanted side effects if the static field object + // was modified in the current session. TODO:Add documentation case. + stream.Refresh(trans, newValue, int.MaxValue); + existingField.value = newValue; + } + return; + } + } + if (newValue == null) + { + try + { + _fieldAccessor.Set(reflectField, null, existingField.value); + } + catch (Exception) + { + } + // fail silently + // TODO: why? + return; + } + existingField.value = newValue; + } + + private bool StaticFieldValuesArePersisted() + { + return (_config != null && _config.StaticFieldValuesArePersisted()); + } + + protected virtual StaticField FieldByName(StaticField[] fields, string fieldName) + { + for (int i = 0; i < fields.Length; i++) + { + StaticField field = fields[i]; + if (fieldName.Equals(field.name)) + { + return field; + } + } + return null; + } + + private StaticClass QueryStaticClass(Transaction trans) + { + IQuery q = trans.Container().Query(trans); + q.Constrain(Const4.ClassStaticclass); + q.Descend("name").Constrain(GetName()); + IObjectSet os = q.Execute(); + return os.Count > 0 ? (StaticClass)os.Next() : null; + } + + public override string ToString() + { + if (i_name != null) + { + return i_name; + } + if (i_nameBytes == null) + { + return "*CLASS NAME UNKNOWN*"; + } + LatinStringIO stringIO = _container == null ? Const4.stringIO : _container.StringIO + (); + return stringIO.Read(i_nameBytes); + } + + public override bool WriteObjectBegin() + { + if (!StateOK()) + { + return false; + } + return base.WriteObjectBegin(); + } + + public sealed override void WriteThis(Transaction trans, ByteArrayBuffer writer) + { + MarshallerFamily.Current()._class.Write(trans, this, writer); + } + + public virtual IPreparedComparison PrepareComparison(IContext context, object source + ) + { + return Handlers4.PrepareComparisonFor(_typeHandler, context, source); + } + + public static void DefragObject(DefragmentContextImpl context) + { + ObjectHeader header = ObjectHeader.Defrag(context); + DefragmentContextImpl childContext = new DefragmentContextImpl(context, header); + header.ClassMetadata().Defragment(childContext); + } + + public virtual void Defragment(IDefragmentContext context) + { + CorrectHandlerVersion(context).Defragment(context); + } + + public virtual void DefragClass(DefragmentContextImpl context, int classIndexID) + { + MarshallerFamily mf = MarshallerFamily.ForConverterVersion(Container().ConverterVersion + ()); + mf._class.Defrag(this, _container.StringIO(), context, classIndexID); + } + + public static Db4objects.Db4o.Internal.ClassMetadata ReadClass(ObjectContainerBase + stream, ByteArrayBuffer reader) + { + ObjectHeader oh = new ObjectHeader(stream, reader); + return oh.ClassMetadata(); + } + + public virtual bool IsAssignableFrom(Db4objects.Db4o.Internal.ClassMetadata other + ) + { + return ClassReflector().IsAssignableFrom(other.ClassReflector()); + } + + public virtual void SetAncestor(Db4objects.Db4o.Internal.ClassMetadata ancestor) + { + if (ancestor == this) + { + throw new InvalidOperationException(); + } + _ancestor = ancestor; + } + + public virtual object WrapWithTransactionContext(Transaction transaction, object + value) + { + if (value is int) + { + return value; + } + return new TransactionContext(transaction, value); + } + + public virtual ITypeHandler4 TypeHandler() + { + return _typeHandler; + } + + public virtual ITypeHandler4 DelegateTypeHandler(IContext context) + { + if (context is IHandlerVersionContext) + { + return CorrectHandlerVersion((IHandlerVersionContext)context); + } + return _typeHandler; + } + + protected virtual ITypeHandler4 CorrectHandlerVersion(IHandlerVersionContext context + ) + { + ITypeHandler4 typeHandler = HandlerRegistry.CorrectHandlerVersion(context, _typeHandler + ); + if (typeHandler != _typeHandler) + { + if (typeHandler is StandardReferenceTypeHandler) + { + ((StandardReferenceTypeHandler)typeHandler).ClassMetadata(this); + } + } + return typeHandler; + } + + public virtual void TraverseDeclaredFields(IProcedure4 procedure) + { + if (_aspects == null) + { + return; + } + for (int i = 0; i < _aspects.Length; i++) + { + if (_aspects[i] is FieldMetadata) + { + procedure.Apply(_aspects[i]); + } + } + } + + public virtual void TraverseDeclaredAspects(IProcedure4 procedure) + { + if (_aspects == null) + { + return; + } + for (int i = 0; i < _aspects.Length; i++) + { + procedure.Apply(_aspects[i]); + } + } + + public virtual bool AspectsAreNull() + { + return _aspects == null; + } + + private sealed class AlwaysModified : IModificationAware + { + internal static readonly ClassMetadata.AlwaysModified Instance = new ClassMetadata.AlwaysModified + (); + + public bool IsModified(object obj) + { + return true; + } + } + + public virtual bool IsModified(object obj) + { + return _modificationChecker.IsModified(obj); + } + + public virtual int InstanceCount() + { + return InstanceCount(_container.Transaction); + } + + public virtual int InstanceCount(Transaction trans) + { + return _container.InstanceCount(this, trans); + } + + public virtual bool IsStorable() + { + return !StateDead() && !IsTransient(); + } + + private object InstantiateWithCustomTypeHandlerIfEnabled(UnmarshallingContext context + ) + { + if (!_customTypeHandlerAspect.IsEnabledOn(context)) + { + return InstantiateForVersionWithoutCustomTypeHandler(context); + } + return InstantiateWithCustomTypeHandler(context); + } + + private object InstantiateForVersionWithoutCustomTypeHandler(UnmarshallingContext + context) + { + IFunction4 oldVersionConstructor = CreateConstructor(null); + if (null == oldVersionConstructor) + { + throw new InvalidOperationException(); + } + return oldVersionConstructor.Apply(context); + } + + private object InstantiateWithCustomTypeHandler(UnmarshallingContext context) + { + ContextState contextState = context.SaveState(); + try + { + bool fieldHasValue = SeekToField(context, _customTypeHandlerAspect); + if (!fieldHasValue) + { + context.RestoreState(contextState); + return InstantiateForVersionWithoutCustomTypeHandler(context); + } + IInstantiatingTypeHandler customTypeHandler = (IInstantiatingTypeHandler)_customTypeHandlerAspect + ._typeHandler; + return context.SlotFormat().DoWithSlotIndirection(context, new _IClosure4_2056(customTypeHandler + , context)); + } + finally + { + context.RestoreState(contextState); + } + } + + private sealed class _IClosure4_2056 : IClosure4 + { + public _IClosure4_2056(IInstantiatingTypeHandler customTypeHandler, UnmarshallingContext + context) + { + this.customTypeHandler = customTypeHandler; + this.context = context; + } + + public object Run() + { + return customTypeHandler.Instantiate(context); + } + + private readonly IInstantiatingTypeHandler customTypeHandler; + + private readonly UnmarshallingContext context; + } + + public virtual bool IsStruct() + { + return Platform4.IsStruct(ClassReflector()); + } + + public virtual void DropClassIndex() + { + if (Container().IsClient) + { + throw new InvalidOperationException(); + } + _index = CreateIndexStrategy(); + _index.Initialize(Container()); + Container().SetDirtyInSystemTransaction(this); + } + + public virtual void TraverseAllAspects(ITraverseAspectCommand command) + { + AspectTraversalStrategy().TraverseAllAspects(command); + } + + private IAspectTraversalStrategy AspectTraversalStrategy() + { + if (_aspectTraversalStrategy == null) + { + _aspectTraversalStrategy = DetectAspectTraversalStrategy(); + } + return _aspectTraversalStrategy; + } + + protected virtual IAspectTraversalStrategy DetectAspectTraversalStrategy() + { + IList ancestors = CompareAncestorHierarchy(); + for (IEnumerator diffIter = ancestors.GetEnumerator(); diffIter.MoveNext(); ) + { + HierarchyAnalyzer.Diff diff = ((HierarchyAnalyzer.Diff)diffIter.Current); + if (diff.IsRemoved()) + { + return CreateRemovedAspectTraversalStrategy(ancestors); + } + } + return new StandardAspectTraversalStrategy(this); + } + + private IAspectTraversalStrategy CreateRemovedAspectTraversalStrategy(IList ancestors + ) + { + return new ModifiedAspectTraversalStrategy(this, ancestors); + } + + private IList CompareAncestorHierarchy() + { + return new HierarchyAnalyzer(this, ClassReflector()).Analyze(); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/ClassMetadataIterator.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/ClassMetadataIterator.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/ClassMetadataIterator.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/ClassMetadataIterator.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,30 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System.Collections; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal; + +namespace Db4objects.Db4o.Internal +{ + /// TODO: remove this class or make it private to ClassMetadataRepository + public class ClassMetadataIterator : MappingIterator + { + private readonly ClassMetadataRepository i_collection; + + internal ClassMetadataIterator(ClassMetadataRepository a_collection, IEnumerator + iterator) : base(iterator) + { + i_collection = a_collection; + } + + public virtual ClassMetadata CurrentClass() + { + return (ClassMetadata)Current; + } + + protected override object Map(object current) + { + return i_collection.ReadClassMetadata((ClassMetadata)current, null); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/ClassMetadataRepository.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/ClassMetadataRepository.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/ClassMetadataRepository.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/ClassMetadataRepository.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,745 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using System.Collections; +using Db4objects.Db4o.Ext; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Metadata; +using Db4objects.Db4o.Reflect; + +namespace Db4objects.Db4o.Internal +{ + /// + public sealed class ClassMetadataRepository : PersistentBase + { + private Collection4 _classes; + + private Hashtable4 _creating; + + private readonly Transaction _systemTransaction; + + private Hashtable4 _classMetadataByBytes; + + private Hashtable4 _classMetadataByClass; + + private Hashtable4 _classMetadataByName; + + private Hashtable4 _classMetadataByID; + + private int _classMetadataCreationDepth; + + private IQueue4 _initClassMetadataOnUp; + + private readonly PendingClassInits _classInits; + + public ClassMetadataRepository(Transaction systemTransaction) + { + _systemTransaction = systemTransaction; + _initClassMetadataOnUp = new NonblockingQueue(); + _classInits = new PendingClassInits(_systemTransaction); + } + + public void AddClassMetadata(ClassMetadata clazz) + { + Container().SetDirtyInSystemTransaction(this); + _classes.Add(clazz); + if (clazz.StateUnread()) + { + _classMetadataByBytes.Put(clazz.i_nameBytes, clazz); + } + else + { + _classMetadataByClass.Put(clazz.ClassReflector(), clazz); + } + RegisterClassMetadataById(clazz); + } + + private void RegisterClassMetadataById(ClassMetadata clazz) + { + if (clazz.GetID() == 0) + { + clazz.Write(_systemTransaction); + } + _classMetadataByID.Put(clazz.GetID(), clazz); + } + + private byte[] AsBytes(string str) + { + return Container().StringIO().Write(str); + } + + public void AttachQueryNode(string fieldName, IVisitor4 visitor) + { + ClassMetadataIterator i = Iterator(); + while (i.MoveNext()) + { + ClassMetadata classMetadata = i.CurrentClass(); + if (!classMetadata.IsInternal()) + { + classMetadata.TraverseAllAspects(new _TraverseFieldCommand_65(fieldName, visitor, + classMetadata)); + } + } + } + + private sealed class _TraverseFieldCommand_65 : TraverseFieldCommand + { + public _TraverseFieldCommand_65(string fieldName, IVisitor4 visitor, ClassMetadata + classMetadata) + { + this.fieldName = fieldName; + this.visitor = visitor; + this.classMetadata = classMetadata; + } + + protected override void Process(FieldMetadata field) + { + if (field.CanAddToQuery(fieldName)) + { + visitor.Visit(new object[] { classMetadata, field }); + } + } + + private readonly string fieldName; + + private readonly IVisitor4 visitor; + + private readonly ClassMetadata classMetadata; + } + + public void IterateTopLevelClasses(IVisitor4 visitor) + { + ClassMetadataIterator i = Iterator(); + while (i.MoveNext()) + { + ClassMetadata classMetadata = i.CurrentClass(); + if (!classMetadata.IsInternal()) + { + if (classMetadata.GetAncestor() == null) + { + visitor.Visit(classMetadata); + } + } + } + } + + internal void CheckChanges() + { + IEnumerator i = _classes.GetEnumerator(); + while (i.MoveNext()) + { + ((ClassMetadata)i.Current).CheckChanges(); + } + } + + internal bool CreateClassMetadata(ClassMetadata clazz, IReflectClass reflectClazz + ) + { + bool result = false; + _classMetadataCreationDepth++; + try + { + IReflectClass parentReflectClazz = reflectClazz.GetSuperclass(); + ClassMetadata parentClazz = null; + if (parentReflectClazz != null && !parentReflectClazz.Equals(Container()._handlers + .IclassObject)) + { + parentClazz = ProduceClassMetadata(parentReflectClazz); + } + result = Container().CreateClassMetadata(clazz, reflectClazz, parentClazz); + } + finally + { + _classMetadataCreationDepth--; + } + InitClassMetadataOnUp(); + return result; + } + + private void EnsureAllClassesRead() + { + bool allClassesRead = false; + while (!allClassesRead) + { + Collection4 unreadClasses = new Collection4(); + int numClasses = _classes.Size(); + IEnumerator classIter = _classes.GetEnumerator(); + while (classIter.MoveNext()) + { + ClassMetadata clazz = (ClassMetadata)classIter.Current; + if (clazz.StateUnread()) + { + unreadClasses.Add(clazz); + } + } + IEnumerator unreadIter = unreadClasses.GetEnumerator(); + while (unreadIter.MoveNext()) + { + ClassMetadata clazz = (ClassMetadata)unreadIter.Current; + clazz = ReadClassMetadata(clazz, null); + if (clazz.ClassReflector() == null) + { + clazz.ForceRead(); + } + } + allClassesRead = (_classes.Size() == numClasses); + } + ApplyReadAs(); + } + + internal bool FieldExists(string field) + { + ClassMetadataIterator i = Iterator(); + while (i.MoveNext()) + { + if (i.CurrentClass().FieldMetadataForName(field) != null) + { + return true; + } + } + return false; + } + + public Collection4 ForInterface(IReflectClass claxx) + { + Collection4 col = new Collection4(); + ClassMetadataIterator i = Iterator(); + while (i.MoveNext()) + { + ClassMetadata clazz = i.CurrentClass(); + IReflectClass candidate = clazz.ClassReflector(); + if (!candidate.IsInterface()) + { + if (claxx.IsAssignableFrom(candidate)) + { + col.Add(clazz); + IEnumerator j = new Collection4(col).GetEnumerator(); + while (j.MoveNext()) + { + ClassMetadata existing = (ClassMetadata)j.Current; + if (existing != clazz) + { + ClassMetadata higher = clazz.GetHigherHierarchy(existing); + if (higher != null) + { + if (higher == clazz) + { + col.Remove(existing); + } + else + { + col.Remove(clazz); + } + } + } + } + } + } + } + return col; + } + + public override byte GetIdentifier() + { + return Const4.Yapclasscollection; + } + + internal ClassMetadata GetActiveClassMetadata(IReflectClass reflectClazz) + { + return (ClassMetadata)_classMetadataByClass.Get(reflectClazz); + } + + internal ClassMetadata ClassMetadataForReflectClass(IReflectClass reflectClazz) + { + ClassMetadata cached = (ClassMetadata)_classMetadataByClass.Get(reflectClazz); + if (cached != null) + { + return cached; + } + return ReadClassMetadata(reflectClazz); + } + + private ClassMetadata ReadClassMetadata(IReflectClass reflectClazz) + { + ClassMetadata clazz = (ClassMetadata)_classMetadataByBytes.Remove(GetNameBytes(reflectClazz + .GetName())); + if (clazz == null) + { + return null; + } + return ReadClassMetadata(clazz, reflectClazz); + } + + internal ClassMetadata ProduceClassMetadata(IReflectClass reflectClazz) + { + ClassMetadata classMetadata = ClassMetadataForReflectClass(reflectClazz); + if (classMetadata != null) + { + return classMetadata; + } + ClassMetadata classBeingCreated = (ClassMetadata)_creating.Get(reflectClazz); + if (classBeingCreated != null) + { + return classBeingCreated; + } + ClassMetadata newClassMetadata = new ClassMetadata(Container(), reflectClazz); + _creating.Put(reflectClazz, newClassMetadata); + try + { + if (!CreateClassMetadata(newClassMetadata, reflectClazz)) + { + return null; + } + // ObjectContainerBase#createClassMetadata may add the ClassMetadata already, + // so we have to check again + if (!IsRegistered(reflectClazz)) + { + AddClassMetadata(newClassMetadata); + _classInits.Process(newClassMetadata); + } + else + { + RegisterClassMetadataById(newClassMetadata); + if (newClassMetadata.AspectsAreNull()) + { + _classInits.Process(newClassMetadata); + } + } + Container().SetDirtyInSystemTransaction(this); + } + finally + { + _creating.Remove(reflectClazz); + } + return newClassMetadata; + } + + private bool IsRegistered(IReflectClass reflectClazz) + { + return _classMetadataByClass.Get(reflectClazz) != null; + } + + internal ClassMetadata ClassMetadataForId(int id) + { + ClassMetadata classMetadata = (ClassMetadata)_classMetadataByID.Get(id); + if (null == classMetadata) + { + return null; + } + return ReadClassMetadata(classMetadata, null); + } + + public int ClassMetadataIdForName(string name) + { + ClassMetadata classMetadata = (ClassMetadata)_classMetadataByBytes.Get(GetNameBytes + (name)); + if (classMetadata == null) + { + classMetadata = FindInitializedClassByName(name); + } + if (classMetadata != null) + { + return classMetadata.GetID(); + } + return 0; + } + + public ClassMetadata GetClassMetadata(string name) + { + ClassMetadata classMetadata = (ClassMetadata)_classMetadataByBytes.Remove(GetNameBytes + (name)); + if (classMetadata == null) + { + classMetadata = FindInitializedClassByName(name); + } + if (classMetadata != null) + { + classMetadata = ReadClassMetadata(classMetadata, null); + } + return classMetadata; + } + + private ClassMetadata FindInitializedClassByName(string name) + { + ClassMetadata classMetadata = (ClassMetadata)_classMetadataByName.Get(name); + if (classMetadata != null) + { + return classMetadata; + } + ClassMetadataIterator i = Iterator(); + while (i.MoveNext()) + { + classMetadata = (ClassMetadata)i.Current; + if (name.Equals(classMetadata.GetName())) + { + _classMetadataByName.Put(name, classMetadata); + return classMetadata; + } + } + return null; + } + + public int GetClassMetadataID(string name) + { + ClassMetadata clazz = (ClassMetadata)_classMetadataByBytes.Get(GetNameBytes(name) + ); + if (clazz != null) + { + return clazz.GetID(); + } + return 0; + } + + internal byte[] GetNameBytes(string name) + { + return AsBytes(ResolveAliasRuntimeName(name)); + } + + private string ResolveAliasRuntimeName(string name) + { + return Container().ConfigImpl.ResolveAliasRuntimeName(name); + } + + public void InitOnUp(Transaction systemTrans) + { + _classMetadataCreationDepth++; + systemTrans.Container().ShowInternalClasses(true); + try + { + IEnumerator i = _classes.GetEnumerator(); + while (i.MoveNext()) + { + ((ClassMetadata)i.Current).InitOnUp(systemTrans); + } + } + finally + { + systemTrans.Container().ShowInternalClasses(false); + _classMetadataCreationDepth--; + } + InitClassMetadataOnUp(); + } + + internal void InitTables(int size) + { + _classes = new Collection4(); + _classMetadataByBytes = new Hashtable4(size); + if (size < 16) + { + size = 16; + } + _classMetadataByClass = new Hashtable4(size); + _classMetadataByName = new Hashtable4(size); + _classMetadataByID = new Hashtable4(size); + _creating = new Hashtable4(1); + } + + private void InitClassMetadataOnUp() + { + if (_classMetadataCreationDepth != 0) + { + return; + } + ClassMetadata clazz = (ClassMetadata)_initClassMetadataOnUp.Next(); + while (clazz != null) + { + clazz.InitOnUp(_systemTransaction); + clazz = (ClassMetadata)_initClassMetadataOnUp.Next(); + } + } + + public ClassMetadataIterator Iterator() + { + return new ClassMetadataIterator(this, new ArrayIterator4(_classes.ToArray())); + } + + private class ClassIDIterator : MappingIterator + { + public ClassIDIterator(Collection4 classes) : base(classes.GetEnumerator()) + { + } + + protected override object Map(object current) + { + return ((ClassMetadata)current).GetID(); + } + } + + public IEnumerator Ids() + { + return new ClassMetadataRepository.ClassIDIterator(_classes); + } + + public override int OwnLength() + { + return Const4.ObjectLength + Const4.IntLength + (_classes.Size() * Const4.IdLength + ); + } + + internal void Purge() + { + IEnumerator i = _classes.GetEnumerator(); + while (i.MoveNext()) + { + ((ClassMetadata)i.Current).Purge(); + } + } + + public sealed override void ReadThis(Transaction trans, ByteArrayBuffer buffer) + { + int classCount = buffer.ReadInt(); + InitTables(classCount); + ObjectContainerBase container = Container(); + int[] ids = ReadMetadataIds(buffer, classCount); + ByteArrayBuffer[] metadataSlots = container.ReadSlotBuffers(trans, ids); + for (int i = 0; i < classCount; ++i) + { + ClassMetadata classMetadata = new ClassMetadata(container, null); + classMetadata.SetID(ids[i]); + _classes.Add(classMetadata); + _classMetadataByID.Put(ids[i], classMetadata); + byte[] name = classMetadata.ReadName1(trans, metadataSlots[i]); + if (name != null) + { + _classMetadataByBytes.Put(name, classMetadata); + } + } + ApplyReadAs(); + } + + private int[] ReadMetadataIds(ByteArrayBuffer buffer, int classCount) + { + int[] ids = new int[classCount]; + for (int i = 0; i < classCount; ++i) + { + ids[i] = buffer.ReadInt(); + } + return ids; + } + + internal Hashtable4 ClassByBytes() + { + return _classMetadataByBytes; + } + + private void ApplyReadAs() + { + Hashtable4 readAs = Container().ConfigImpl.ReadAs(); + IEnumerator i = readAs.Iterator(); + while (i.MoveNext()) + { + IEntry4 entry = (IEntry4)i.Current; + string dbName = (string)entry.Key(); + string useName = (string)entry.Value(); + byte[] dbbytes = GetNameBytes(dbName); + byte[] useBytes = GetNameBytes(useName); + if (ClassByBytes().Get(useBytes) == null) + { + ClassMetadata clazz = (ClassMetadata)ClassByBytes().Get(dbbytes); + if (clazz != null) + { + clazz.i_nameBytes = useBytes; + clazz.SetConfig(ConfigClass(dbName)); + ClassByBytes().Remove(dbbytes); + ClassByBytes().Put(useBytes, clazz); + } + } + } + } + + private Config4Class ConfigClass(string name) + { + return Container().ConfigImpl.ConfigClass(name); + } + + public ClassMetadata ReadClassMetadata(ClassMetadata classMetadata, IReflectClass + clazz) + { + if (classMetadata == null) + { + throw new ArgumentNullException(); + } + if (!classMetadata.StateUnread()) + { + return classMetadata; + } + _classMetadataCreationDepth++; + try + { + classMetadata.CreateConfigAndConstructor(_classMetadataByBytes, clazz); + IReflectClass claxx = classMetadata.ClassReflector(); + if (claxx != null) + { + _classMetadataByClass.Put(claxx, classMetadata); + classMetadata.ReadThis(); + classMetadata.CheckChanges(); + _initClassMetadataOnUp.Add(classMetadata); + } + } + finally + { + _classMetadataCreationDepth--; + } + InitClassMetadataOnUp(); + return classMetadata; + } + + public void CheckAllClassChanges() + { + IEnumerator i = _classMetadataByID.Keys(); + while (i.MoveNext()) + { + int classMetadataID = ((int)i.Current); + ClassMetadataForId(classMetadataID); + } + } + + public void RefreshClasses() + { + ClassMetadataRepository rereader = new ClassMetadataRepository(_systemTransaction + ); + rereader._id = _id; + rereader.Read(Container().SystemTransaction()); + IEnumerator i = rereader._classes.GetEnumerator(); + while (i.MoveNext()) + { + ClassMetadata clazz = (ClassMetadata)i.Current; + RefreshClass(clazz); + } + i = _classes.GetEnumerator(); + while (i.MoveNext()) + { + ClassMetadata clazz = (ClassMetadata)i.Current; + clazz.Refresh(); + } + } + + private void RefreshClass(ClassMetadata clazz) + { + if (_classMetadataByID.Get(clazz.GetID()) == null) + { + _classes.Add(clazz); + _classMetadataByID.Put(clazz.GetID(), clazz); + RefreshClassCache(clazz, null); + } + } + + public void RefreshClassCache(ClassMetadata clazz, IReflectClass oldReflector) + { + if (clazz.StateUnread()) + { + _classMetadataByBytes.Put(clazz.ReadName(_systemTransaction), clazz); + } + else + { + if (oldReflector != null) + { + _classMetadataByClass.Remove(oldReflector); + } + _classMetadataByClass.Put(clazz.ClassReflector(), clazz); + } + } + + internal void ReReadClassMetadata(ClassMetadata clazz) + { + if (clazz != null) + { + ReReadClassMetadata(clazz._ancestor); + clazz.ReadName(_systemTransaction); + clazz.ForceRead(); + clazz.SetStateClean(); + clazz.BitFalse(Const4.CheckedChanges); + clazz.BitFalse(Const4.Reading); + clazz.BitFalse(Const4.Continue); + clazz.BitFalse(Const4.Dead); + clazz.CheckChanges(); + } + } + + public IStoredClass[] StoredClasses() + { + EnsureAllClassesRead(); + IStoredClass[] sclasses = new IStoredClass[_classes.Size()]; + _classes.ToArray(sclasses); + return sclasses; + } + + public void WriteAllClasses() + { + Collection4 deadClasses = new Collection4(); + IStoredClass[] storedClasses = StoredClasses(); + for (int i = 0; i < storedClasses.Length; i++) + { + ClassMetadata clazz = (ClassMetadata)storedClasses[i]; + clazz.SetStateDirty(); + if (clazz.StateDead()) + { + deadClasses.Add(clazz); + clazz.SetStateOK(); + } + } + for (int i = 0; i < storedClasses.Length; i++) + { + ClassMetadata clazz = (ClassMetadata)storedClasses[i]; + clazz.Write(_systemTransaction); + } + IEnumerator it = deadClasses.GetEnumerator(); + while (it.MoveNext()) + { + ((ClassMetadata)it.Current).SetStateDead(); + } + } + + public override void WriteThis(Transaction trans, ByteArrayBuffer buffer) + { + buffer.WriteInt(_classes.Size()); + IEnumerator i = _classes.GetEnumerator(); + while (i.MoveNext()) + { + buffer.WriteIDOf(trans, i.Current); + } + } + + public override string ToString() + { + string str = "Active:\n"; + IEnumerator i = _classes.GetEnumerator(); + while (i.MoveNext()) + { + ClassMetadata clazz = (ClassMetadata)i.Current; + str += clazz.GetID() + " " + clazz + "\n"; + } + return str; + } + + internal ObjectContainerBase Container() + { + return _systemTransaction.Container(); + } + + public override void SetID(int id) + { + if (Container().IsClient) + { + base.SetID(id); + return; + } + if (_id == 0) + { + SystemData().ClassCollectionID(id); + } + base.SetID(id); + } + + private SystemData SystemData() + { + return LocalSystemTransaction().LocalContainer().SystemData(); + } + + private LocalTransaction LocalSystemTransaction() + { + return ((LocalTransaction)_systemTransaction); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Collections/BigSetBTreeManager.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Collections/BigSetBTreeManager.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Collections/BigSetBTreeManager.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Collections/BigSetBTreeManager.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,100 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using System.Collections; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Btree; +using Db4objects.Db4o.Internal.Handlers; + +namespace Db4objects.Db4o.Internal.Collections +{ + /// + public class BigSetBTreeManager + { + private sealed class _TransactionLocal_14 : TransactionLocal + { + public _TransactionLocal_14() + { + } + + public override object InitialValueFor(Transaction transaction) + { + return new Hashtable(); + } + } + + private static readonly TransactionLocal _bTreesInTransaction = new _TransactionLocal_14 + (); + + private readonly Transaction _transaction; + + internal BigSetBTreeManager(Transaction transaction) + { + _transaction = transaction; + } + + internal virtual BTree ProduceBTree(int id) + { + AssertValidBTreeId(id); + BTree bTree = ExistingBTreeInTransactionWith(id); + if (null == bTree) + { + bTree = NewBTreeWithId(id); + RegisterBTreeInTransaction(bTree); + } + return bTree; + } + + internal virtual BTree NewBTree() + { + BTree bTree = NewBTreeWithId(0); + bTree.Write(SystemTransaction()); + RegisterBTreeInTransaction(bTree); + return bTree; + } + + internal virtual void EnsureIsManaged(BTree tree) + { + RegisterBTreeInTransaction(tree); + } + + private BTree NewBTreeWithId(int id) + { + return NewBTreeWithId(id, SystemTransaction()); + } + + private Transaction SystemTransaction() + { + return _transaction.SystemTransaction(); + } + + private static BTree NewBTreeWithId(int id, Transaction systemTransaction) + { + return new BTree(systemTransaction, id, new IntHandler()); + } + + private static void AssertValidBTreeId(int id) + { + if (id <= 0) + { + throw new ArgumentException(); + } + } + + private void RegisterBTreeInTransaction(BTree tree) + { + AssertValidBTreeId(tree.GetID()); + BTreesIn(_transaction)[tree.GetID()] = tree; + } + + private BTree ExistingBTreeInTransactionWith(int id) + { + return ((BTree)BTreesIn(_transaction)[id]); + } + + private static IDictionary BTreesIn(Transaction transaction) + { + return ((IDictionary)transaction.Get(_bTreesInTransaction).value); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Collections/BigSet.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Collections/BigSet.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Collections/BigSet.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Collections/BigSet.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,238 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using System.Collections; +using System.Collections.Generic; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Activation; +using Db4objects.Db4o.Internal.Btree; +using Db4objects.Db4o.Internal.Collections; +using Db4objects.Db4o.Marshall; + +namespace Db4objects.Db4o.Internal.Collections +{ + /// + public partial class BigSet : Db4objects.Db4o.Collections.ISet, IBigSetPersistence + { + private Db4objects.Db4o.Internal.Btree.BTree _bTree; + + private Db4objects.Db4o.Internal.Transaction _transaction; + + public BigSet(LocalObjectContainer db) + { + if (db == null) + { + return; + } + _transaction = db.Transaction; + _bTree = BTreeManager().NewBTree(); + } + + private ObjectContainerBase Container() + { + return Transaction().Container(); + } + + public virtual bool Add(E obj) + { + lock (Lock()) + { + int id = GetID(obj); + if (id == 0) + { + Add(Store(obj)); + return true; + } + if (Contains(id)) + { + return false; + } + Add(id); + return true; + } + } + + private int Store(E obj) + { + return Container().Store(_transaction, obj, Container().UpdateDepthProvider().Unspecified + (NullModifiedObjectQuery.Instance)); + } + + private void Add(int id) + { + BTreeForUpdate().Add(_transaction, id); + } + + private int GetID(object obj) + { + return (int)Container().GetID(obj); + } + + public virtual bool AddAll(IEnumerable iterable) + { + bool result = false; + foreach (E element in iterable) + { + if (Add(element)) + { + result = true; + } + } + return result; + } + + public virtual void Clear() + { + lock (Lock()) + { + BTreeForUpdate().Clear(Transaction()); + } + } + + public virtual bool Contains(object obj) + { + int id = GetID(obj); + if (id == 0) + { + return false; + } + return Contains(id); + } + + private bool Contains(int id) + { + lock (Lock()) + { + IBTreeRange range = BTree().SearchRange(Transaction(), id); + return !range.IsEmpty(); + } + } + + public virtual bool IsEmpty + { + get + { + return Count == 0; + } + } + + private IEnumerator BTreeIterator() + { + return new SynchronizedIterator4(BTree().Iterator(Transaction()), Lock()); + } + + public virtual bool Remove(object obj) + { + lock (Lock()) + { + if (!Contains(obj)) + { + return false; + } + int id = GetID(obj); + BTreeForUpdate().Remove(Transaction(), id); + return true; + } + } + + public virtual int Count + { + get + { + lock (Lock()) + { + return BTree().Size(Transaction()); + } + } + } + + public virtual object[] ToArray() + { + throw new NotSupportedException(); + } + + public virtual T[] ToArray(T[] a) + { + throw new NotSupportedException(); + } + + public virtual void Write(IWriteContext context) + { + int id = BTree().GetID(); + if (id == 0) + { + BTree().Write(SystemTransaction()); + } + context.WriteInt(BTree().GetID()); + } + + public virtual void Read(IReadContext context) + { + int id = context.ReadInt(); + if (_bTree != null) + { + AssertCurrentBTreeId(id); + return; + } + _transaction = context.Transaction(); + _bTree = BTreeManager().ProduceBTree(id); + } + + private BigSetBTreeManager BTreeManager() + { + return new BigSetBTreeManager(_transaction); + } + + private void AssertCurrentBTreeId(int id) + { + if (id != _bTree.GetID()) + { + throw new InvalidOperationException(); + } + } + + private Db4objects.Db4o.Internal.Transaction Transaction() + { + return _transaction; + } + + private Db4objects.Db4o.Internal.Transaction SystemTransaction() + { + return Container().SystemTransaction(); + } + + public virtual void Invalidate() + { + _bTree = null; + } + + private Db4objects.Db4o.Internal.Btree.BTree BTree() + { + if (_bTree == null) + { + throw new InvalidOperationException(); + } + return _bTree; + } + + private Db4objects.Db4o.Internal.Btree.BTree BTreeForUpdate() + { + Db4objects.Db4o.Internal.Btree.BTree bTree = BTree(); + BTreeManager().EnsureIsManaged(bTree); + return bTree; + } + + private object Element(int id) + { + object obj = Container().GetByID(Transaction(), id); + Container().Activate(obj); + return obj; + } + + private object Lock() + { + return Container().Lock(); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Collections/BigSetTypeHandler.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Collections/BigSetTypeHandler.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Collections/BigSetTypeHandler.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Collections/BigSetTypeHandler.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,102 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Defragment; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Btree; +using Db4objects.Db4o.Internal.Collections; +using Db4objects.Db4o.Internal.Delete; +using Db4objects.Db4o.Internal.Marshall; +using Db4objects.Db4o.Marshall; +using Db4objects.Db4o.Typehandlers; + +namespace Db4objects.Db4o.Internal.Collections +{ + /// + public class BigSetTypeHandler : IReferenceTypeHandler, ICascadingTypeHandler + { + public virtual void Defragment(IDefragmentContext context) + { + int pos = context.Offset(); + int id = context.ReadInt(); + BTree bTree = NewBTree(context, id); + DefragmentServicesImpl services = (DefragmentServicesImpl)context.Services(); + IDMappingCollector collector = new IDMappingCollector(); + services.RegisterBTreeIDs(bTree, collector); + collector.Flush(services); + context.Seek(pos); + context.CopyID(); + bTree.DefragBTree(services); + } + + /// + public virtual void Delete(IDeleteContext context) + { + InvalidBigSet(context); + int id = context.ReadInt(); + FreeBTree(context, id); + } + + private void InvalidBigSet(IDeleteContext context) + { + IBigSetPersistence bigSet = (IBigSetPersistence)context.Transaction().ObjectForIdFromCache + (context.ObjectId()); + if (bigSet != null) + { + bigSet.Invalidate(); + } + } + + private void FreeBTree(IDeleteContext context, int id) + { + BTree bTree = NewBTree(context, id); + bTree.Free(SystemTransaction(context)); + bTree = null; + } + + private static LocalTransaction SystemTransaction(IContext context) + { + return (LocalTransaction)context.Transaction().SystemTransaction(); + } + + private BTree NewBTree(IContext context, int id) + { + return new BTree(SystemTransaction(context), id, new IDHandler()); + } + + public virtual void Write(IWriteContext context, object obj) + { + IBigSetPersistence bigSet = (IBigSetPersistence)obj; + bigSet.Write(context); + } + + public virtual IPreparedComparison PrepareComparison(IContext context, object obj + ) + { + // TODO Auto-generated method stub + return null; + } + + public virtual void Activate(IReferenceActivationContext context) + { + IBigSetPersistence bigSet = (IBigSetPersistence)context.PersistentObject(); + bigSet.Read(context); + } + + public virtual void CascadeActivation(IActivationContext context) + { + } + + // TODO Auto-generated method stub + public virtual void CollectIDs(QueryingReadContext context) + { + } + + // TODO Auto-generated method stub + public virtual ITypeHandler4 ReadCandidateHandler(QueryingReadContext context) + { + // TODO Auto-generated method stub + return null; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Collections/IBigSetPersistence.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Collections/IBigSetPersistence.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Collections/IBigSetPersistence.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Collections/IBigSetPersistence.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,15 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Marshall; + +namespace Db4objects.Db4o.Internal.Collections +{ + public interface IBigSetPersistence + { + void Write(IWriteContext context); + + void Read(IReadContext context); + + void Invalidate(); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/CommitTimestampFieldMetadata.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/CommitTimestampFieldMetadata.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/CommitTimestampFieldMetadata.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/CommitTimestampFieldMetadata.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,94 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Ext; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Btree; +using Db4objects.Db4o.Internal.Delete; +using Db4objects.Db4o.Internal.Handlers; +using Db4objects.Db4o.Internal.Marshall; +using Db4objects.Db4o.Marshall; + +namespace Db4objects.Db4o.Internal +{ + /// + public class CommitTimestampFieldMetadata : VirtualFieldMetadata + { + internal CommitTimestampFieldMetadata() : base(Handlers4.LongId, new LongHandler( + )) + { + SetName(VirtualField.CommitTimestamp); + } + + /// + public override void AddFieldIndex(ObjectIdContextImpl context) + { + } + + public override void AddIndexEntry(Transaction trans, int parentID, object indexEntry + ) + { + } + + public override void RemoveIndexEntry(Transaction trans, int parentID, object indexEntry + ) + { + } + + public override void Delete(DeleteContextImpl context, bool isUpdate) + { + } + + internal override void Instantiate1(ObjectReferenceContext context) + { + } + + internal override void Marshall(Transaction trans, ObjectReference @ref, IWriteBuffer + buffer, bool isMigrating, bool isNew) + { + } + + public override int LinkLength() + { + return 0; + } + + public override void DefragAspect(IDefragmentContext context) + { + } + + internal override void MarshallIgnore(IWriteBuffer buffer) + { + } + + public override void Activate(UnmarshallingContext context) + { + } + + // do nothing. + public override BTree GetIndex(Transaction trans) + { + return ((LocalTransaction)trans.SystemTransaction()).CommitTimestampSupport().TimestampToId + (); + } + + public override bool HasIndex() + { + return true; + } + + protected override IFieldIndexKey CreateFieldIndexKey(int parentID, object indexEntry + ) + { + return new CommitTimestampSupport.TimestampEntry(parentID, ((long)indexEntry)); + } + + internal int counter = 0; + + public override object Read(IObjectIdContext context) + { + int objectId = context.ObjectId(); + long version = context.Transaction().SystemTransaction().VersionForId(objectId); + return version; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/CommitTimestampSupport.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/CommitTimestampSupport.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/CommitTimestampSupport.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/CommitTimestampSupport.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,270 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using System.Collections; +using Db4objects.Db4o.Events; +using Db4objects.Db4o.Ext; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Btree; +using Db4objects.Db4o.Internal.Handlers; +using Db4objects.Db4o.Marshall; + +namespace Db4objects.Db4o.Internal +{ + public class CommitTimestampSupport + { + private BTree _idToTimestamp; + + private BTree _timestampToId; + + private readonly LocalObjectContainer _container; + + public CommitTimestampSupport(LocalObjectContainer container) + { + _container = container; + } + + public virtual void EnsureInitialized() + { + IdToTimestamp(); + } + + public virtual BTree IdToTimestamp() + { + if (_idToTimestamp != null) + { + return _idToTimestamp; + } + if (!_container.Config().GenerateCommitTimestamps().DefiniteYes()) + { + return null; + } + Initialize(); + return _idToTimestamp; + } + + public virtual BTree TimestampToId() + { + if (_timestampToId != null) + { + return _timestampToId; + } + if (!_container.Config().GenerateCommitTimestamps().DefiniteYes()) + { + return null; + } + Initialize(); + return _timestampToId; + } + + private void Initialize() + { + int idToTimestampIndexId = _container.SystemData().IdToTimestampIndexId(); + int timestampToIdIndexId = _container.SystemData().TimestampToIdIndexId(); + _idToTimestamp = new BTree(_container.SystemTransaction(), idToTimestampIndexId, + new CommitTimestampSupport.TimestampEntryById()); + _timestampToId = new BTree(_container.SystemTransaction(), timestampToIdIndexId, + new CommitTimestampSupport.IdEntryByTimestamp()); + if (idToTimestampIndexId != _idToTimestamp.GetID()) + { + StoreBtreesIds(); + } + EventRegistryFactory.ForObjectContainer(_container).Committing += new System.EventHandler + (new _IEventListener4_69(this).OnEvent); + } + + private sealed class _IEventListener4_69 + { + public _IEventListener4_69(CommitTimestampSupport _enclosing) + { + this._enclosing = _enclosing; + } + + public void OnEvent(object sender, Db4objects.Db4o.Events.CommitEventArgs args) + { + LocalTransaction trans = (LocalTransaction)((CommitEventArgs)args).Transaction(); + long transactionTimestamp = trans.Timestamp(); + long commitTimestamp = (transactionTimestamp > 0) ? transactionTimestamp : this._enclosing + ._container.GenerateTimeStampId(); + Transaction sysTrans = trans.SystemTransaction(); + this.AddTimestamp(sysTrans, ((CommitEventArgs)args).Added.GetEnumerator(), commitTimestamp + ); + this.AddTimestamp(sysTrans, ((CommitEventArgs)args).Updated.GetEnumerator(), commitTimestamp + ); + this.AddTimestamp(sysTrans, ((CommitEventArgs)args).Deleted.GetEnumerator(), 0); + } + + private void AddTimestamp(Transaction trans, IEnumerator it, long commitTimestamp + ) + { + while (it.MoveNext()) + { + IObjectInfo objInfo = (IObjectInfo)it.Current; + CommitTimestampSupport.TimestampEntry te = new CommitTimestampSupport.TimestampEntry + ((int)objInfo.GetInternalID(), commitTimestamp); + CommitTimestampSupport.TimestampEntry oldEntry = (CommitTimestampSupport.TimestampEntry + )this._enclosing._idToTimestamp.Remove(trans, te); + if (oldEntry != null) + { + this._enclosing._timestampToId.Remove(trans, oldEntry); + } + if (commitTimestamp != 0) + { + this._enclosing._idToTimestamp.Add(trans, te); + this._enclosing._timestampToId.Add(trans, te); + } + } + } + + private readonly CommitTimestampSupport _enclosing; + } + + private void StoreBtreesIds() + { + _container.SystemData().IdToTimestampIndexId(_idToTimestamp.GetID()); + _container.SystemData().TimestampToIdIndexId(_timestampToId.GetID()); + _container.GetFileHeader().WriteVariablePart(_container); + } + + public class TimestampEntry : IFieldIndexKey + { + public readonly int objectId; + + public readonly long commitTimestamp; + + public override string ToString() + { + return "TimestampEntry [objectId=" + objectId + ", commitTimestamp=" + commitTimestamp + + "]"; + } + + public TimestampEntry(int objectId, long commitTimestamp) + { + this.objectId = objectId; + this.commitTimestamp = commitTimestamp; + } + + public virtual int ParentID() + { + return objectId; + } + + public virtual long GetCommitTimestamp() + { + return commitTimestamp; + } + + public virtual object Value() + { + return commitTimestamp; + } + } + + private class TimestampEntryById : IIndexable4 + { + public virtual IPreparedComparison PrepareComparison(IContext context, object first + ) + { + return new _IPreparedComparison_139(first); + } + + private sealed class _IPreparedComparison_139 : IPreparedComparison + { + public _IPreparedComparison_139(object first) + { + this.first = first; + } + + public int CompareTo(object second) + { + return IntHandler.Compare(((CommitTimestampSupport.TimestampEntry)first).objectId + , ((CommitTimestampSupport.TimestampEntry)second).objectId); + } + + private readonly object first; + } + + public virtual int LinkLength() + { + return Const4.IntLength + Const4.LongLength; + } + + public virtual object ReadIndexEntry(IContext context, ByteArrayBuffer reader) + { + return new CommitTimestampSupport.TimestampEntry(reader.ReadInt(), reader.ReadLong + ()); + } + + public virtual void WriteIndexEntry(IContext context, ByteArrayBuffer writer, object + obj) + { + writer.WriteInt(((CommitTimestampSupport.TimestampEntry)obj).ParentID()); + writer.WriteLong(((CommitTimestampSupport.TimestampEntry)obj).GetCommitTimestamp( + )); + } + + public virtual void DefragIndexEntry(DefragmentContextImpl context) + { + // we are storing ids in the btree, so the order will change when the ids change + // to properly defrag the btree we need to readd all the entries + throw new NotSupportedException(); + } + } + + private sealed class IdEntryByTimestamp : CommitTimestampSupport.TimestampEntryById + { + public override IPreparedComparison PrepareComparison(IContext context, object first + ) + { + return new _IPreparedComparison_168(first); + } + + private sealed class _IPreparedComparison_168 : IPreparedComparison + { + public _IPreparedComparison_168(object first) + { + this.first = first; + } + + public int CompareTo(object second) + { + int result = LongHandler.Compare(((CommitTimestampSupport.TimestampEntry)first).commitTimestamp + , ((CommitTimestampSupport.TimestampEntry)second).commitTimestamp); + if (result != 0) + { + return result; + } + return IntHandler.Compare(((CommitTimestampSupport.TimestampEntry)first).objectId + , ((CommitTimestampSupport.TimestampEntry)second).objectId); + } + + private readonly object first; + } + } + + public virtual long VersionForId(int id) + { + if (IdToTimestamp() == null || id == 0) + { + return 0; + } + CommitTimestampSupport.TimestampEntry te = (CommitTimestampSupport.TimestampEntry + )IdToTimestamp().Search(_container.SystemTransaction(), new CommitTimestampSupport.TimestampEntry + (id, 0)); + if (te == null) + { + return 0; + } + return te.GetCommitTimestamp(); + } + + public virtual void Put(Transaction trans, int objectId, long version) + { + CommitTimestampSupport.TimestampEntry te = new CommitTimestampSupport.TimestampEntry + (objectId, version); + IdToTimestamp().Add(trans, te); + TimestampToId().Add(trans, te); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Config/CacheConfigurationImpl.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Config/CacheConfigurationImpl.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Config/CacheConfigurationImpl.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Config/CacheConfigurationImpl.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,27 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Config; +using Db4objects.Db4o.Internal; + +namespace Db4objects.Db4o.Internal.Config +{ + /// + public class CacheConfigurationImpl : ICacheConfiguration + { + private readonly Config4Impl _config; + + public CacheConfigurationImpl(Config4Impl config) + { + _config = config; + } + + [System.ObsoleteAttribute(@"since 7.14 BTrees have their own LRU cache now.")] + public virtual int SlotCacheSize + { + set + { + int size = value; + } + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Config/CommonConfigurationImpl.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Config/CommonConfigurationImpl.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Config/CommonConfigurationImpl.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Config/CommonConfigurationImpl.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,281 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System.IO; +using Db4objects.Db4o.Config; +using Db4objects.Db4o.Config.Encoding; +using Db4objects.Db4o.Diagnostic; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Reflect; +using Db4objects.Db4o.Typehandlers; + +namespace Db4objects.Db4o.Internal.Config +{ + public class CommonConfigurationImpl : ICommonConfiguration + { + private readonly Config4Impl _config; + + public CommonConfigurationImpl(Config4Impl config) + { + _config = config; + } + + public virtual int ActivationDepth + { + get + { + return _config.ActivationDepth(); + } + set + { + int depth = value; + _config.ActivationDepth(depth); + } + } + + public virtual void Add(IConfigurationItem configurationItem) + { + _config.Add(configurationItem); + } + + public virtual void AddAlias(IAlias alias) + { + _config.AddAlias(alias); + } + + public virtual void RemoveAlias(IAlias alias) + { + _config.RemoveAlias(alias); + } + + public virtual bool AllowVersionUpdates + { + set + { + bool flag = value; + _config.AllowVersionUpdates(flag); + } + } + + public virtual bool AutomaticShutDown + { + set + { + bool flag = value; + _config.AutomaticShutDown(flag); + } + } + + public virtual int BTreeNodeSize + { + set + { + int size = value; + _config.BTreeNodeSize(size); + } + } + + public virtual bool Callbacks + { + set + { + bool flag = value; + _config.Callbacks(flag); + } + } + + public virtual void CallbackMode(CallBackMode mode) + { + _config.CallbackMode(mode); + } + + public virtual bool CallConstructors + { + set + { + bool flag = value; + _config.CallConstructors(flag); + } + } + + public virtual bool DetectSchemaChanges + { + set + { + bool flag = value; + _config.DetectSchemaChanges(flag); + } + } + + public virtual IDiagnosticConfiguration Diagnostic + { + get + { + return _config.Diagnostic(); + } + } + + public virtual bool ExceptionsOnNotStorable + { + set + { + bool flag = value; + _config.ExceptionsOnNotStorable(flag); + } + } + + public virtual bool InternStrings + { + set + { + bool flag = value; + _config.InternStrings(flag); + } + } + + public virtual void MarkTransient(string attributeName) + { + _config.MarkTransient(attributeName); + } + + public virtual int MessageLevel + { + set + { + int level = value; + _config.MessageLevel(level); + } + } + + public virtual IObjectClass ObjectClass(object clazz) + { + return _config.ObjectClass(clazz); + } + + public virtual bool OptimizeNativeQueries + { + get + { + return _config.OptimizeNativeQueries(); + } + set + { + bool optimizeNQ = value; + _config.OptimizeNativeQueries(optimizeNQ); + } + } + + public virtual IQueryConfiguration Queries + { + get + { + return _config.Queries(); + } + } + + public virtual void ReflectWith(IReflector reflector) + { + _config.ReflectWith(reflector); + } + + public virtual TextWriter OutStream + { + set + { + TextWriter outStream = value; + _config.SetOut(outStream); + } + } + + public virtual IStringEncoding StringEncoding + { + set + { + IStringEncoding encoding = value; + _config.StringEncoding(encoding); + } + } + + public virtual bool TestConstructors + { + set + { + bool flag = value; + _config.TestConstructors(flag); + } + } + + public virtual int UpdateDepth + { + set + { + int depth = value; + _config.UpdateDepth(depth); + } + } + + public virtual bool WeakReferences + { + set + { + bool flag = value; + _config.WeakReferences(flag); + } + } + + public virtual int WeakReferenceCollectionInterval + { + set + { + int milliseconds = value; + _config.WeakReferenceCollectionInterval(milliseconds); + } + } + + public virtual void RegisterTypeHandler(ITypeHandlerPredicate predicate, ITypeHandler4 + typeHandler) + { + _config.RegisterTypeHandler(predicate, typeHandler); + } + + public virtual IEnvironmentConfiguration Environment + { + get + { + return new _IEnvironmentConfiguration_139(this); + } + } + + private sealed class _IEnvironmentConfiguration_139 : IEnvironmentConfiguration + { + public _IEnvironmentConfiguration_139(CommonConfigurationImpl _enclosing) + { + this._enclosing = _enclosing; + } + + public void Add(object service) + { + this._enclosing._config.EnvironmentContributions().Add(service); + } + + private readonly CommonConfigurationImpl _enclosing; + } + + public virtual void NameProvider(INameProvider provider) + { + _config.NameProvider(provider); + } + + public virtual int MaxStackDepth + { + get + { + return _config.MaxStackDepth(); + } + set + { + int maxStackDepth = value; + _config.MaxStackDepth(maxStackDepth); + } + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Config/Db4oLegacyConfigurationBridge.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Config/Db4oLegacyConfigurationBridge.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Config/Db4oLegacyConfigurationBridge.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Config/Db4oLegacyConfigurationBridge.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,38 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Config; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Config; + +namespace Db4objects.Db4o.Internal.Config +{ + public class Db4oLegacyConfigurationBridge + { + public static IEmbeddedConfiguration AsEmbeddedConfiguration(IConfiguration legacy + ) + { + return new EmbeddedConfigurationImpl(legacy); + } + + public static ICommonConfiguration AsCommonConfiguration(IConfiguration config) + { + return new CommonConfigurationImpl((Config4Impl)config); + } + + public static Config4Impl AsLegacy(object config) + { + return ((ILegacyConfigurationProvider)config).Legacy(); + } + + public static IFileConfiguration AsFileConfiguration(IConfiguration config) + { + return new FileConfigurationImpl((Config4Impl)config); + } + + public static IIdSystemConfiguration AsIdSystemConfiguration(IConfiguration config + ) + { + return new IdSystemConfigurationImpl((Config4Impl)config); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Config/EmbeddedConfigurationImpl.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Config/EmbeddedConfigurationImpl.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Config/EmbeddedConfigurationImpl.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Config/EmbeddedConfigurationImpl.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,88 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System.Collections; +using Db4objects.Db4o; +using Db4objects.Db4o.Config; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Config; + +namespace Db4objects.Db4o.Internal.Config +{ + public class EmbeddedConfigurationImpl : IEmbeddedConfiguration, ILegacyConfigurationProvider + { + private readonly Config4Impl _legacy; + + private IList _configItems; + + public EmbeddedConfigurationImpl(IConfiguration legacy) + { + _legacy = (Config4Impl)legacy; + } + + public virtual ICacheConfiguration Cache + { + get + { + return new CacheConfigurationImpl(_legacy); + } + } + + public virtual IFileConfiguration File + { + get + { + return new FileConfigurationImpl(_legacy); + } + } + + public virtual ICommonConfiguration Common + { + get + { + return Db4oLegacyConfigurationBridge.AsCommonConfiguration(Legacy()); + } + } + + public virtual Config4Impl Legacy() + { + return _legacy; + } + + public virtual void AddConfigurationItem(IEmbeddedConfigurationItem configItem) + { + if (_configItems != null && _configItems.Contains(configItem)) + { + return; + } + configItem.Prepare(this); + if (_configItems == null) + { + _configItems = new ArrayList(); + } + _configItems.Add(configItem); + } + + public virtual void ApplyConfigurationItems(IEmbeddedObjectContainer container) + { + if (_configItems == null) + { + return; + } + for (IEnumerator configItemIter = _configItems.GetEnumerator(); configItemIter.MoveNext + (); ) + { + IEmbeddedConfigurationItem configItem = ((IEmbeddedConfigurationItem)configItemIter + .Current); + configItem.Apply(container); + } + } + + public virtual IIdSystemConfiguration IdSystem + { + get + { + return new IdSystemConfigurationImpl(_legacy); + } + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Config/FileConfigurationImpl.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Config/FileConfigurationImpl.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Config/FileConfigurationImpl.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Config/FileConfigurationImpl.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,147 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Config; +using Db4objects.Db4o.IO; +using Db4objects.Db4o.Internal; + +namespace Db4objects.Db4o.Internal.Config +{ + internal class FileConfigurationImpl : IFileConfiguration + { + private readonly Config4Impl _config; + + public FileConfigurationImpl(Config4Impl config) + { + _config = config; + } + + public virtual int BlockSize + { + set + { + int bytes = value; + _config.BlockSize(bytes); + } + } + + public virtual int DatabaseGrowthSize + { + set + { + int bytes = value; + _config.DatabaseGrowthSize(bytes); + } + } + + public virtual void DisableCommitRecovery() + { + _config.DisableCommitRecovery(); + } + + public virtual IFreespaceConfiguration Freespace + { + get + { + return _config.Freespace(); + } + } + + public virtual ConfigScope GenerateUUIDs + { + set + { + ConfigScope setting = value; + _config.GenerateUUIDs(setting); + } + } + + public virtual ConfigScope GenerateVersionNumbers + { + set + { + ConfigScope setting = value; + _config.GenerateVersionNumbers(setting); + } + } + + public virtual bool GenerateCommitTimestamps + { + set + { + bool setting = value; + _config.GenerateCommitTimestamps(setting); + } + } + + /// + public virtual IStorage Storage + { + get + { + return _config.Storage; + } + set + { + IStorage factory = value; + _config.Storage = factory; + } + } + + public virtual bool LockDatabaseFile + { + set + { + bool flag = value; + _config.LockDatabaseFile(flag); + } + } + + /// + /// + public virtual long ReserveStorageSpace + { + set + { + long byteCount = value; + _config.ReserveStorageSpace(byteCount); + } + } + + /// + public virtual string BlobPath + { + set + { + string path = value; + _config.SetBlobPath(path); + } + } + + public virtual bool ReadOnly + { + set + { + bool flag = value; + _config.ReadOnly(flag); + } + } + + public virtual bool RecoveryMode + { + set + { + bool flag = value; + _config.RecoveryMode(flag); + } + } + + public virtual bool AsynchronousSync + { + set + { + bool flag = value; + _config.AsynchronousSync(flag); + } + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Config/IdSystemConfigurationImpl.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Config/IdSystemConfigurationImpl.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Config/IdSystemConfigurationImpl.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Config/IdSystemConfigurationImpl.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,43 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Config; +using Db4objects.Db4o.Internal; + +namespace Db4objects.Db4o.Internal.Config +{ + /// + public class IdSystemConfigurationImpl : IIdSystemConfiguration + { + private readonly Config4Impl _config; + + public IdSystemConfigurationImpl(Config4Impl config) + { + _config = config; + } + + public virtual void UsePointerBasedSystem() + { + _config.UsePointerBasedIdSystem(); + } + + public virtual void UseStackedBTreeSystem() + { + _config.UseStackedBTreeIdSystem(); + } + + public virtual void UseInMemorySystem() + { + _config.UseInMemoryIdSystem(); + } + + public virtual void UseCustomSystem(IIdSystemFactory factory) + { + _config.UseCustomIdSystem(factory); + } + + public virtual void UseSingleBTreeSystem() + { + _config.UseSingleBTreeIdSystem(); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Config/ILegacyConfigurationProvider.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Config/ILegacyConfigurationProvider.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Config/ILegacyConfigurationProvider.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Config/ILegacyConfigurationProvider.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,11 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal; + +namespace Db4objects.Db4o.Internal.Config +{ + public interface ILegacyConfigurationProvider + { + Config4Impl Legacy(); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Config4Abstract.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Config4Abstract.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Config4Abstract.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Config4Abstract.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,117 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal; + +namespace Db4objects.Db4o.Internal +{ + /// + public abstract class Config4Abstract + { + protected KeySpecHashtable4 _config; + + private static readonly KeySpec CascadeOnActivateKey = new KeySpec(TernaryBool.Unspecified + ); + + private static readonly KeySpec CascadeOnDeleteKey = new KeySpec(TernaryBool.Unspecified + ); + + private static readonly KeySpec CascadeOnUpdateKey = new KeySpec(TernaryBool.Unspecified + ); + + private static readonly KeySpec NameKey = new KeySpec(null); + + public Config4Abstract() : this(new KeySpecHashtable4(10)) + { + } + + protected Config4Abstract(KeySpecHashtable4 config) + { + _config = (KeySpecHashtable4)config.DeepClone(this); + } + + public virtual void CascadeOnActivate(bool flag) + { + PutThreeValued(CascadeOnActivateKey, flag); + } + + public virtual void CascadeOnDelete(bool flag) + { + PutThreeValued(CascadeOnDeleteKey, flag); + } + + public virtual void CascadeOnUpdate(bool flag) + { + PutThreeValued(CascadeOnUpdateKey, flag); + } + + protected virtual void PutThreeValued(KeySpec spec, bool flag) + { + _config.Put(spec, TernaryBool.ForBoolean(flag)); + } + + protected virtual void PutThreeValuedInt(KeySpec spec, bool flag) + { + _config.Put(spec, flag ? 1 : -1); + } + + public virtual TernaryBool CascadeOnActivate() + { + return Cascade(CascadeOnActivateKey); + } + + public virtual TernaryBool CascadeOnDelete() + { + return Cascade(CascadeOnDeleteKey); + } + + public virtual TernaryBool CascadeOnUpdate() + { + return Cascade(CascadeOnUpdateKey); + } + + private TernaryBool Cascade(KeySpec spec) + { + return _config.GetAsTernaryBool(spec); + } + + internal abstract string ClassName(); + + /// Will raise an exception if argument class doesn't match this class - violates equals() contract in favor of failing fast. + /// + /// Will raise an exception if argument class doesn't match this class - violates equals() contract in favor of failing fast. + /// + public override bool Equals(object obj) + { + if (this == obj) + { + return true; + } + if (null == obj) + { + return false; + } + if (GetType() != obj.GetType()) + { + Exceptions4.ShouldNeverHappen(); + } + return GetName().Equals(((Db4objects.Db4o.Internal.Config4Abstract)obj).GetName() + ); + } + + public override int GetHashCode() + { + return GetName().GetHashCode(); + } + + public virtual string GetName() + { + return _config.GetAsString(NameKey); + } + + protected virtual void SetName(string name) + { + _config.Put(NameKey, name); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Config4Class.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Config4Class.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Config4Class.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Config4Class.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,344 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using Db4objects.Db4o.Config; +using Db4objects.Db4o.Ext; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Reflect; + +namespace Db4objects.Db4o.Internal +{ + /// + public class Config4Class : Config4Abstract, IObjectClass, IDeepClone + { + private readonly Config4Impl _configImpl; + + private static readonly KeySpec CallConstructorKey = new KeySpec(TernaryBool.Unspecified + ); + + private static readonly KeySpec ClassIndexedKey = new KeySpec(true); + + private static readonly KeySpec ExceptionalFieldsKey = new KeySpec(null); + + private static readonly KeySpec GenerateUuidsKey = new KeySpec(TernaryBool.Unspecified + ); + + /// + /// We are running into cyclic dependancies on reading the PBootRecord + /// object, if we maintain MetaClass information there + /// + private static readonly KeySpec MaintainMetaclassKey = new KeySpec(true); + + private static readonly KeySpec MaximumActivationDepthKey = new KeySpec(0); + + private static readonly KeySpec MinimumActivationDepthKey = new KeySpec(0); + + private static readonly KeySpec PersistStaticFieldValuesKey = new KeySpec(false); + + private static readonly KeySpec QueryAttributeProviderKey = new KeySpec(null); + + private static readonly KeySpec StoreTransientFieldsKey = new KeySpec(false); + + private static readonly KeySpec TranslatorKey = new KeySpec(null); + + private static readonly KeySpec TranslatorNameKey = new KeySpec((string)null); + + private static readonly KeySpec UpdateDepthKey = new KeySpec(Const4.Unspecified); + + private static readonly KeySpec WriteAsKey = new KeySpec((string)null); + + protected Config4Class(Config4Impl configuration, KeySpecHashtable4 config) : base + (config) + { + _configImpl = configuration; + } + + internal Config4Class(Config4Impl a_configuration, string a_name) + { + _configImpl = a_configuration; + SetName(a_name); + } + + public virtual int AdjustActivationDepth(int depth) + { + TernaryBool cascadeOnActivate = CascadeOnActivate(); + if (cascadeOnActivate.DefiniteYes() && depth < 2) + { + depth = 2; + } + if (cascadeOnActivate.DefiniteNo() && depth > 1) + { + depth = 1; + } + if (Config().ClassActivationDepthConfigurable()) + { + int minimumActivationDepth = MinimumActivationDepth(); + if (minimumActivationDepth != 0 && depth < minimumActivationDepth) + { + depth = minimumActivationDepth; + } + int maximumActivationDepth = MaximumActivationDepth(); + if (maximumActivationDepth != 0 && depth > maximumActivationDepth) + { + depth = maximumActivationDepth; + } + } + return depth; + } + + public virtual void CallConstructor(bool flag) + { + PutThreeValued(CallConstructorKey, flag); + } + + internal override string ClassName() + { + return GetName(); + } + + internal virtual IReflectClass ClassReflector() + { + return Config().Reflector().ForName(GetName()); + } + + [System.ObsoleteAttribute] + public virtual void Compare(IObjectAttribute comparator) + { + _config.Put(QueryAttributeProviderKey, comparator); + } + + internal virtual Config4Field ConfigField(string fieldName) + { + Hashtable4 exceptionalFields = ExceptionalFieldsOrNull(); + if (exceptionalFields == null) + { + return null; + } + Config4Field config4Field = (Config4Field)exceptionalFields.Get(fieldName); + if (config4Field == null) + { + return null; + } + config4Field.Used(true); + return config4Field; + } + + public virtual object DeepClone(object param) + { + Config4Impl parentConfig = ((Config4Impl.ConfigDeepCloneContext)param)._cloned; + return new Db4objects.Db4o.Internal.Config4Class(parentConfig, _config); + } + + public virtual void EnableReplication(bool setting) + { + throw new NotSupportedException("See documentation"); + } + + public virtual void GenerateUUIDs(bool setting) + { + _config.Put(GenerateUuidsKey, TernaryBool.ForBoolean(setting)); + } + + public virtual void GenerateVersionNumbers(bool setting) + { + throw new NotSupportedException("See documentation"); + } + + public virtual IObjectTranslator GetTranslator() + { + IObjectTranslator translator = (IObjectTranslator)_config.Get(TranslatorKey); + if (translator != null) + { + return translator; + } + string translatorName = _config.GetAsString(TranslatorNameKey); + if (translatorName == null) + { + return null; + } + try + { + translator = NewTranslatorFromReflector(translatorName); + } + catch (Exception) + { + try + { + translator = NewTranslatorFromPlatform(translatorName); + } + catch (Exception e) + { + throw new Db4oException(e); + } + } + Translate(translator); + return translator; + } + + /// + /// + private IObjectTranslator NewTranslatorFromPlatform(string translatorName) + { + return (IObjectTranslator)System.Activator.CreateInstance(ReflectPlatform.ForName + (translatorName)); + } + + private IObjectTranslator NewTranslatorFromReflector(string translatorName) + { + return (IObjectTranslator)Config().Reflector().ForName(translatorName).NewInstance + (); + } + + public virtual void Indexed(bool flag) + { + _config.Put(ClassIndexedKey, flag); + } + + public virtual bool Indexed() + { + return _config.GetAsBoolean(ClassIndexedKey); + } + + public virtual void MaximumActivationDepth(int depth) + { + _config.Put(MaximumActivationDepthKey, depth); + } + + internal virtual int MaximumActivationDepth() + { + return _config.GetAsInt(MaximumActivationDepthKey); + } + + public virtual void MinimumActivationDepth(int depth) + { + _config.Put(MinimumActivationDepthKey, depth); + } + + public virtual int MinimumActivationDepth() + { + return _config.GetAsInt(MinimumActivationDepthKey); + } + + public virtual TernaryBool CallConstructor() + { + if (_config.Get(TranslatorKey) != null) + { + return TernaryBool.Yes; + } + return _config.GetAsTernaryBool(CallConstructorKey); + } + + internal virtual Hashtable4 ExceptionalFieldsOrNull() + { + return (Hashtable4)_config.Get(ExceptionalFieldsKey); + } + + private Hashtable4 ExceptionalFields() + { + Hashtable4 exceptionalFieldsCollection = ExceptionalFieldsOrNull(); + if (exceptionalFieldsCollection == null) + { + exceptionalFieldsCollection = new Hashtable4(16); + _config.Put(ExceptionalFieldsKey, exceptionalFieldsCollection); + } + return exceptionalFieldsCollection; + } + + public virtual IObjectField ObjectField(string fieldName) + { + Hashtable4 exceptionalFieldsCollection = ExceptionalFields(); + Config4Field c4f = (Config4Field)exceptionalFieldsCollection.Get(fieldName); + if (c4f == null) + { + c4f = new Config4Field(this, fieldName); + exceptionalFieldsCollection.Put(fieldName, c4f); + } + return c4f; + } + + public virtual void PersistStaticFieldValues() + { + _config.Put(PersistStaticFieldValuesKey, true); + } + + public virtual void Rename(string newName) + { + Config().Rename(Renames.ForClass(GetName(), newName)); + SetName(newName); + } + + public virtual void StoreTransientFields(bool flag) + { + _config.Put(StoreTransientFieldsKey, flag); + } + + public virtual void Translate(IObjectTranslator translator) + { + if (translator == null) + { + _config.Put(TranslatorNameKey, null); + } + _config.Put(TranslatorKey, translator); + } + + internal virtual void TranslateOnDemand(string a_translatorName) + { + _config.Put(TranslatorNameKey, a_translatorName); + } + + public virtual void UpdateDepth(int depth) + { + if (depth < 0) + { + throw new ArgumentException("update depth must not be negative"); + } + _config.Put(UpdateDepthKey, depth); + } + + internal virtual Config4Impl Config() + { + return _configImpl; + } + + internal virtual TernaryBool GenerateUUIDs() + { + return (TernaryBool)_config.Get(GenerateUuidsKey); + } + + internal virtual TernaryBool GenerateVersionNumbers() + { + return TernaryBool.No; + } + + internal virtual void MaintainMetaClass(bool flag) + { + _config.Put(MaintainMetaclassKey, flag); + } + + internal virtual bool StaticFieldValuesArePersisted() + { + return _config.GetAsBoolean(PersistStaticFieldValuesKey); + } + + public virtual IObjectAttribute QueryAttributeProvider() + { + return (IObjectAttribute)_config.Get(QueryAttributeProviderKey); + } + + public virtual bool StoreTransientFields() + { + return _config.GetAsBoolean(StoreTransientFieldsKey); + } + + internal virtual int UpdateDepth() + { + return _config.GetAsInt(UpdateDepthKey); + } + + internal virtual string WriteAs() + { + return _config.GetAsString(WriteAsKey); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Config4Field.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Config4Field.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Config4Field.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Config4Field.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,100 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Config; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal; + +namespace Db4objects.Db4o.Internal +{ + public class Config4Field : Config4Abstract, IObjectField, IDeepClone + { + private readonly Config4Class _configClass; + + private bool _used; + + private static readonly KeySpec IndexedKey = new KeySpec(TernaryBool.Unspecified); + + protected Config4Field(Config4Class a_class, KeySpecHashtable4 config) : base(config + ) + { + _configClass = a_class; + } + + internal Config4Field(Config4Class a_class, string a_name) + { + _configClass = a_class; + SetName(a_name); + } + + private Config4Class ClassConfig() + { + return _configClass; + } + + internal override string ClassName() + { + return ClassConfig().GetName(); + } + + public virtual object DeepClone(object param) + { + return new Db4objects.Db4o.Internal.Config4Field((Config4Class)param, _config); + } + + public virtual void Rename(string newName) + { + ClassConfig().Config().Rename(Renames.ForField(ClassName(), GetName(), newName)); + SetName(newName); + } + + public virtual void Indexed(bool flag) + { + PutThreeValued(IndexedKey, flag); + } + + public virtual void InitOnUp(Transaction systemTrans, FieldMetadata fieldMetadata + ) + { + ObjectContainerBase anyStream = systemTrans.Container(); + if (!anyStream.MaintainsIndices()) + { + return; + } + if (!fieldMetadata.SupportsIndex()) + { + Indexed(false); + } + TernaryBool indexedFlag = _config.GetAsTernaryBool(IndexedKey); + if (indexedFlag.DefiniteNo()) + { + fieldMetadata.DropIndex((LocalTransaction)systemTrans); + return; + } + if (UseExistingIndex(systemTrans, fieldMetadata)) + { + return; + } + if (!indexedFlag.DefiniteYes()) + { + return; + } + fieldMetadata.CreateIndex(); + } + + private bool UseExistingIndex(Transaction systemTrans, FieldMetadata fieldMetadata + ) + { + return fieldMetadata.GetIndex(systemTrans) != null; + } + + public virtual void Used(bool flag) + { + _used = flag; + } + + public virtual bool Used() + { + return _used; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Config4Impl.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Config4Impl.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Config4Impl.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Config4Impl.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,1450 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using System.Collections; +using System.IO; +using Db4objects.Db4o; +using Db4objects.Db4o.Config; +using Db4objects.Db4o.Config.Encoding; +using Db4objects.Db4o.Diagnostic; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.IO; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Activation; +using Db4objects.Db4o.Internal.Config; +using Db4objects.Db4o.Internal.Encoding; +using Db4objects.Db4o.Internal.Freespace; +using Db4objects.Db4o.Internal.Handlers; +using Db4objects.Db4o.Internal.Ids; +using Db4objects.Db4o.Internal.References; +using Db4objects.Db4o.Messaging; +using Db4objects.Db4o.Reflect; +using Db4objects.Db4o.Reflect.Core; +using Db4objects.Db4o.Reflect.Generic; +using Db4objects.Db4o.Typehandlers; +using Sharpen; + +namespace Db4objects.Db4o.Internal +{ + /// Configuration template for creating new db4o files + /// + public sealed partial class Config4Impl : IConfiguration, IDeepClone, IMessageSender + , IFreespaceConfiguration, IQueryConfiguration, IClientServerConfiguration + { + private KeySpecHashtable4 _config = new KeySpecHashtable4(50); + + private static readonly KeySpec ActivationDepthKey = new KeySpec(5); + + private static readonly KeySpec ActivationDepthProviderKey = new KeySpec(LegacyActivationDepthProvider + .Instance); + + private static readonly KeySpec UpdateDepthProviderKey = new KeySpec(new LegacyUpdateDepthProvider + ()); + + private static readonly KeySpec AllowVersionUpdatesKey = new KeySpec(false); + + private static readonly KeySpec AsynchronousSyncKey = new KeySpec(false); + + private static readonly KeySpec AutomaticShutdownKey = new KeySpec(true); + + private static readonly KeySpec BlocksizeKey = new KeySpec((byte)1); + + private static readonly KeySpec BlobPathKey = new KeySpec(null); + + private static readonly KeySpec BtreeNodeSizeKey = new KeySpec(201); + + private static readonly KeySpec CallbacksKey = new KeySpec(CallBackMode.All); + + private static readonly KeySpec CallConstructorsKey = new KeySpec(TernaryBool.Unspecified + ); + + private static readonly KeySpec ConfigurationItemsKey = new KeySpec(null); + + private static readonly KeySpec ConfiguredReflectorKey = new KeySpec(null); + + private static readonly KeySpec ClassActivationDepthConfigurableKey = new KeySpec + (true); + + private static readonly KeySpec ClassloaderKey = new KeySpec(null); + + private sealed class _IDeferred_75 : KeySpec.IDeferred + { + public _IDeferred_75() + { + } + + // TODO: consider setting default to 8, it's more efficient with freespace. + public object Evaluate() + { + return Config4Impl.DefaultClientServerFactory(); + } + } + + private static readonly KeySpec ClientServerFactoryKey = new KeySpec(new _IDeferred_75 + ()); + + private static readonly KeySpec DatabaseGrowthSizeKey = new KeySpec(0); + + private static readonly KeySpec DetectSchemaChangesKey = new KeySpec(true); + + private sealed class _IDeferred_85 : KeySpec.IDeferred + { + public _IDeferred_85() + { + } + + public object Evaluate() + { + return new Db4objects.Db4o.Internal.Diagnostic.DiagnosticProcessor(); + } + } + + private static readonly KeySpec DiagnosticKey = new KeySpec(new _IDeferred_85()); + + private static readonly KeySpec DisableCommitRecoveryKey = new KeySpec(false); + + private static readonly KeySpec DiscardFreespaceKey = new KeySpec(0); + + private static readonly IStringEncoding DefaultStringEncoding = StringEncodings.Unicode + (); + + private static readonly KeySpec StringEncodingKey = new KeySpec(DefaultStringEncoding + ); + + private static readonly KeySpec EncodingKey = new KeySpec(BuiltInStringEncoding.EncodingByteForEncoding + (DefaultStringEncoding)); + + private static readonly KeySpec EncryptKey = new KeySpec(false); + + private sealed class _IDeferred_103 : KeySpec.IDeferred + { + public _IDeferred_103() + { + } + + public object Evaluate() + { + return new ArrayList(); + } + } + + private static readonly KeySpec EnvironmentContributionsKey = new KeySpec(new _IDeferred_103 + ()); + + private static readonly KeySpec ExceptionalClassesKey = new KeySpec(null); + + private static readonly KeySpec ExceptionsOnNotStorableKey = new KeySpec(true); + + private static readonly KeySpec FileBasedTransactionLogKey = new KeySpec(false); + + private static readonly KeySpec FreespaceFillerKey = new KeySpec(null); + + private static readonly KeySpec FreespaceSystemKey = new KeySpec(AbstractFreespaceManager + .FmDefault); + + private static readonly KeySpec GenerateUuidsKey = new KeySpec(ConfigScope.Individually + ); + + private static readonly KeySpec GenerateCommitTimestampsKey = new KeySpec(TernaryBool + .Unspecified); + + private static readonly KeySpec IdSystemKey = new KeySpec(StandardIdSystemFactory + .Default); + + private static readonly KeySpec IdSystemCustomFactoryKey = new KeySpec(null); + + private static readonly KeySpec QueryEvaluationModeKey = new KeySpec(QueryEvaluationMode + .Immediate); + + private static readonly KeySpec LockFileKey = new KeySpec(true); + + private static readonly KeySpec MessageRecipientKey = new KeySpec(null); + + private static readonly KeySpec OptimizeNqKey = new KeySpec(true); + + private static readonly KeySpec OutstreamKey = new KeySpec(null); + + private static readonly KeySpec PasswordKey = new KeySpec((string)null); + + private static readonly KeySpec ClientQueryResultIteratorFactoryKey = new KeySpec + (null); + + private static readonly KeySpec PrefetchIdCountKey = new KeySpec(10); + + private static readonly KeySpec PrefetchObjectCountKey = new KeySpec(10); + + private static readonly KeySpec PrefetchDepthKey = new KeySpec(0); + + public const int PrefetchSlotCacheSizeFactor = 10; + + private const int MaximumPrefetchSlotCacheSize = 10000; + + private static readonly KeySpec PrefetchSlotCacheSizeKey = new KeySpec(0); + + private sealed class _IDeferred_155 : KeySpec.IDeferred + { + public _IDeferred_155() + { + } + + // for playing with different strategies of prefetching + // object + public object Evaluate() + { + return new Hashtable4(16); + } + } + + private static readonly KeySpec ReadAsKey = new KeySpec(new _IDeferred_155()); + + private static readonly KeySpec RecoveryModeKey = new KeySpec(false); + + private static readonly KeySpec ReflectorKey = new KeySpec(null); + + private static readonly KeySpec RenameKey = new KeySpec(null); + + private static readonly KeySpec ReservedStorageSpaceKey = new KeySpec(0); + + private static readonly KeySpec SingleThreadedClientKey = new KeySpec(false); + + private static readonly KeySpec TestConstructorsKey = new KeySpec(true); + + private static readonly KeySpec TimeoutClientSocketKey = new KeySpec(Const4.ClientSocketTimeout + ); + + private static readonly KeySpec TimeoutServerSocketKey = new KeySpec(Const4.ServerSocketTimeout + ); + + private static readonly KeySpec UpdateDepthKey = new KeySpec(1); + + private static readonly KeySpec WeakReferenceCollectionIntervalKey = new KeySpec( + 1000); + + private static readonly KeySpec WeakReferencesKey = new KeySpec(true); + + private static readonly KeySpec StorageFactoryKey = new KeySpec(new CachingStorage + (new FileStorage())); + + private static readonly KeySpec AliasesKey = new KeySpec(null); + + private static readonly KeySpec BatchMessagesKey = new KeySpec(true); + + private static readonly KeySpec MaxBatchQueueSizeKey = new KeySpec(int.MaxValue); + + private static readonly KeySpec TaintedKey = new KeySpec(false); + + private sealed class _IReferenceSystemFactory_193 : IReferenceSystemFactory + { + public _IReferenceSystemFactory_193() + { + } + + public IReferenceSystem NewReferenceSystem(IInternalObjectContainer container) + { + return new TransactionalReferenceSystem(); + } + } + + private static readonly KeySpec ReferenceSystemFactoryKey = new KeySpec(new _IReferenceSystemFactory_193 + ()); + + private sealed class _INameProvider_199 : INameProvider + { + public _INameProvider_199() + { + } + + public string Name(IObjectContainer db) + { + return null; + } + } + + private static readonly KeySpec NameProviderKey = new KeySpec(new _INameProvider_199 + ()); + + private static readonly KeySpec MaxStackDepthKey = new KeySpec("Dalvik".Equals(Runtime + .GetProperty("java.vm.name")) ? 2 : Const4.DefaultMaxStackDepth); + + private ObjectContainerBase _container; + + private bool _internStrings; + + private int _messageLevel; + + private bool _readOnly; + + private Collection4 _registeredTypeHandlers; + + private System.EventHandler _prefetchSettingsChanged; + + private bool _prefetchSlotCacheSizeModifiedExternally; + + // TODO find a better place to do this, and use AndroidConfiguration instead. + // is null in the global configuration until deepClone is called + // The following are very frequently being asked for, so they show up in the profiler. + // Let's keep them out of the Hashtable. + public int ActivationDepth() + { + return _config.GetAsInt(ActivationDepthKey); + } + + // FIXME: circular cs dependancy. Improve. + public void ActivationDepth(int depth) + { + _config.Put(ActivationDepthKey, depth); + } + + public void Add(IConfigurationItem item) + { + item.Prepare(this); + SafeConfigurationItems().Put(item, item); + } + + /// + /// Returns an iterator for all + /// Db4objects.Db4o.Config.IConfigurationItem + /// + /// instances + /// added. + /// + /// Add(Db4objects.Db4o.Config.IConfigurationItem) + /// + /// the iterator + public IEnumerator ConfigurationItemsIterator() + { + Hashtable4 items = ConfigurationItems(); + if (items == null) + { + return Iterators.EmptyIterator; + } + return items.Keys(); + } + + private Hashtable4 SafeConfigurationItems() + { + Hashtable4 items = ConfigurationItems(); + if (items == null) + { + items = new Hashtable4(16); + _config.Put(ConfigurationItemsKey, items); + } + return items; + } + + public void AllowVersionUpdates(bool flag) + { + _config.Put(AllowVersionUpdatesKey, flag); + } + + private Hashtable4 ConfigurationItems() + { + return (Hashtable4)_config.Get(ConfigurationItemsKey); + } + + public void ApplyConfigurationItems(IInternalObjectContainer container) + { + Hashtable4 items = ConfigurationItems(); + if (items == null) + { + return; + } + IEnumerator i = items.Iterator(); + while (i.MoveNext()) + { + IEntry4 entry = (IEntry4)i.Current; + IConfigurationItem item = (IConfigurationItem)entry.Value(); + item.Apply(container); + } + } + + public void AutomaticShutDown(bool flag) + { + _config.Put(AutomaticShutdownKey, flag); + } + + public void BlockSize(int bytes) + { + if (bytes < 1 || bytes > 127) + { + throw new ArgumentException(); + } + GlobalSettingOnly(); + _config.Put(BlocksizeKey, (byte)bytes); + } + + public void BTreeNodeSize(int size) + { + _config.Put(BtreeNodeSizeKey, size); + } + + public void BTreeCacheHeight(int height) + { + } + + public void Callbacks(bool turnOn) + { + CallbackMode(turnOn ? CallBackMode.All : CallBackMode.None); + } + + public void CallbackMode(CallBackMode mode) + { + _config.Put(CallbacksKey, mode); + } + + public void CallConstructors(bool flag) + { + _config.Put(CallConstructorsKey, TernaryBool.ForBoolean(flag)); + } + + public void ClassActivationDepthConfigurable(bool turnOn) + { + _config.Put(ClassActivationDepthConfigurableKey, turnOn); + } + + public Config4Class ConfigClass(string className) + { + Config4Class config = (Config4Class)ExceptionalClasses().Get(className); + return config; + } + + private bool IsIgnoredClass(string className) + { + Type[] ignore = IgnoredClasses(); + for (int i = 0; i < ignore.Length; i++) + { + if (ignore[i].FullName.Equals(className)) + { + return true; + } + } + return false; + } + + private Type[] IgnoredClasses() + { + return new Type[] { typeof(StaticClass), typeof(StaticField) }; + } + + public object DeepClone(object param) + { + Config4Impl ret = new Config4Impl(); + Config4Impl.ConfigDeepCloneContext context = new Config4Impl.ConfigDeepCloneContext + (this, ret); + ret._config = (KeySpecHashtable4)_config.DeepClone(context); + ret._internStrings = _internStrings; + ret._messageLevel = _messageLevel; + ret._readOnly = _readOnly; + if (_registeredTypeHandlers != null) + { + ret._registeredTypeHandlers = (Collection4)_registeredTypeHandlers.DeepClone(context + ); + } + return ret; + } + + public void Container(ObjectContainerBase container) + { + _container = container; + } + + public void DatabaseGrowthSize(int bytes) + { + _config.Put(DatabaseGrowthSizeKey, bytes); + } + + public int DatabaseGrowthSize() + { + return _config.GetAsInt(DatabaseGrowthSizeKey); + } + + public void DetectSchemaChanges(bool flag) + { + _config.Put(DetectSchemaChangesKey, flag); + } + + public void DisableCommitRecovery() + { + _config.Put(DisableCommitRecoveryKey, true); + } + + public void DiscardSmallerThan(int byteCount) + { + if (byteCount < 0) + { + throw new ArgumentException(); + } + _config.Put(DiscardFreespaceKey, byteCount); + } + + [System.ObsoleteAttribute] + public void Encrypt(bool flag) + { + GlobalSettingOnly(); + _config.Put(EncryptKey, flag); + } + + internal void OldEncryptionOff() + { + _config.Put(EncryptKey, false); + } + + /// + internal void EnsureDirExists(string path) + { + Sharpen.IO.File file = new Sharpen.IO.File(path); + if (!file.Exists()) + { + file.Mkdirs(); + } + if (file.Exists() && file.IsDirectory()) + { + } + else + { + throw new IOException(Db4objects.Db4o.Internal.Messages.Get(37, path)); + } + } + + internal TextWriter ErrStream() + { + TextWriter outStream = OutStreamOrNull(); + return outStream == null ? Sharpen.Runtime.Err : outStream; + } + + public void ExceptionsOnNotStorable(bool flag) + { + _config.Put(ExceptionsOnNotStorableKey, flag); + } + + public IFreespaceConfiguration Freespace() + { + return this; + } + + public void FreespaceFiller(IFreespaceFiller freespaceFiller) + { + _config.Put(FreespaceFillerKey, freespaceFiller); + } + + public IFreespaceFiller FreespaceFiller() + { + return (IFreespaceFiller)_config.Get(FreespaceFillerKey); + } + + public void GenerateUUIDs(ConfigScope scope) + { + _config.Put(GenerateUuidsKey, scope); + } + + public void GenerateVersionNumbers(ConfigScope scope) + { + if (scope == ConfigScope.Individually) + { + throw new NotSupportedException(); + } + GenerateCommitTimestamps(scope == ConfigScope.Globally); + } + + public void GenerateCommitTimestamps(bool flag) + { + _config.Put(GenerateCommitTimestampsKey, TernaryBool.ForBoolean(flag)); + } + + public IMessageSender GetMessageSender() + { + return this; + } + + private void GlobalSettingOnly() + { + if (_container != null) + { + throw new GlobalOnlyConfigException(); + } + } + + public void InternStrings(bool doIntern) + { + _internStrings = doIntern; + } + + public void Io(IoAdapter adapter) + { + GlobalSettingOnly(); + Storage = new IoAdapterStorage(adapter); + } + + public void LockDatabaseFile(bool flag) + { + _config.Put(LockFileKey, flag); + } + + public void MarkTransient(string marker) + { + Platform4.MarkTransient(marker); + } + + public void MessageLevel(int level) + { + _messageLevel = level; + if (OutStream() == null) + { + SetOut(Sharpen.Runtime.Out); + } + } + + public void OptimizeNativeQueries(bool optimizeNQ) + { + _config.Put(OptimizeNqKey, optimizeNQ); + } + + public bool OptimizeNativeQueries() + { + return _config.GetAsBoolean(OptimizeNqKey); + } + + public IObjectClass ObjectClass(object clazz) + { + string className = null; + if (clazz is string) + { + className = (string)clazz; + } + else + { + IReflectClass claxx = ReflectorFor(clazz); + if (claxx == null) + { + return null; + } + className = claxx.GetName(); + } + if (ReflectPlatform.FullyQualifiedName(typeof(object)).Equals(className)) + { + throw new ArgumentException("Configuration of the Object class is not supported." + ); + } + Hashtable4 xClasses = ExceptionalClasses(); + Config4Class c4c = (Config4Class)xClasses.Get(className); + if (c4c == null) + { + c4c = new Config4Class(this, className); + xClasses.Put(className, c4c); + } + return c4c; + } + + private TextWriter OutStreamOrNull() + { + return (TextWriter)_config.Get(OutstreamKey); + } + + public TextWriter OutStream() + { + TextWriter outStream = OutStreamOrNull(); + return outStream == null ? Sharpen.Runtime.Out : outStream; + } + + [System.ObsoleteAttribute] + public void Password(string pw) + { + GlobalSettingOnly(); + _config.Put(PasswordKey, pw); + } + + public void ReadOnly(bool flag) + { + _readOnly = flag; + } + + public GenericReflector Reflector() + { + GenericReflector reflector = (GenericReflector)_config.Get(ReflectorKey); + if (reflector == null) + { + IReflector configuredReflector = (IReflector)_config.Get(ConfiguredReflectorKey); + if (configuredReflector == null) + { + configuredReflector = Platform4.CreateReflector(ClassLoader()); + _config.Put(ConfiguredReflectorKey, configuredReflector); + } + reflector = new GenericReflector(configuredReflector); + _config.Put(ReflectorKey, reflector); + } + // TODO: transaction assignment has been moved to YapStreamBase#initialize1(). + // implement better, more generic solution as described in COR-288 + // if(! reflector.hasTransaction() && i_stream != null){ + // reflector.setTransaction(i_stream.getSystemTransaction()); + // } + return reflector; + } + + public void ReflectWith(IReflector reflect) + { + if (_container != null) + { + Exceptions4.ThrowRuntimeException(46); + } + // see readable message for code in Messages.java + if (reflect == null) + { + throw new ArgumentNullException(); + } + _config.Put(ConfiguredReflectorKey, reflect); + _config.Put(ReflectorKey, null); + } + + public void RefreshClasses() + { + throw new NotImplementedException(); + } + + internal void Rename(Db4objects.Db4o.Rename a_rename) + { + Collection4 renameCollection = Rename(); + if (renameCollection == null) + { + renameCollection = new Collection4(); + _config.Put(RenameKey, renameCollection); + } + renameCollection.Add(a_rename); + } + + /// + public void ReserveStorageSpace(long byteCount) + { + int reservedStorageSpace = (int)byteCount; + if (reservedStorageSpace < 0) + { + reservedStorageSpace = 0; + } + _config.Put(ReservedStorageSpaceKey, reservedStorageSpace); + if (_container != null) + { + _container.Reserve(reservedStorageSpace); + } + } + + /// The ConfigImpl also is our messageSender + public void Send(object obj) + { + if (_container != null) + { + _container.Send(obj); + } + } + + /// + public void SetBlobPath(string path) + { + EnsureDirExists(path); + _config.Put(BlobPathKey, path); + } + + public void SetMessageRecipient(IMessageRecipient messageRecipient) + { + _config.Put(MessageRecipientKey, messageRecipient); + } + + [System.ObsoleteAttribute] + public void SetOut(TextWriter outStream) + { + _config.Put(OutstreamKey, outStream); + if (_container != null) + { + _container.LogMsg(19, Db4oFactory.Version()); + } + else + { + Db4objects.Db4o.Internal.Messages.LogMsg(this, 19, Db4oFactory.Version()); + } + } + + public void SingleThreadedClient(bool flag) + { + _config.Put(SingleThreadedClientKey, flag); + } + + public IStringEncoding StringEncoding() + { + return (IStringEncoding)_config.Get(StringEncodingKey); + } + + public void StringEncoding(IStringEncoding encoding) + { + _config.Put(StringEncodingKey, encoding); + _config.Put(EncodingKey, BuiltInStringEncoding.EncodingByteForEncoding(encoding)); + } + + public void TestConstructors(bool flag) + { + _config.Put(TestConstructorsKey, flag); + } + + public void TimeoutClientSocket(int milliseconds) + { + _config.Put(TimeoutClientSocketKey, milliseconds); + } + + public void TimeoutServerSocket(int milliseconds) + { + _config.Put(TimeoutServerSocketKey, milliseconds); + } + + public void UpdateDepth(int depth) + { + if (depth < 0) + { + throw new ArgumentException("update depth must not be negative"); + } + Db4objects.Db4o.Internal.Diagnostic.DiagnosticProcessor dp = DiagnosticProcessor( + ); + if (dp.Enabled()) + { + dp.CheckUpdateDepth(depth); + } + _config.Put(UpdateDepthKey, depth); + } + + public void UseBTreeSystem() + { + _config.Put(FreespaceSystemKey, AbstractFreespaceManager.FmBtree); + } + + public void UseRamSystem() + { + _config.Put(FreespaceSystemKey, AbstractFreespaceManager.FmRam); + } + + [System.ObsoleteAttribute] + public void UseIndexSystem() + { + throw new NotSupportedException(); + } + + public void WeakReferenceCollectionInterval(int milliseconds) + { + _config.Put(WeakReferenceCollectionIntervalKey, milliseconds); + } + + public void WeakReferences(bool flag) + { + _config.Put(WeakReferencesKey, flag); + } + + private Collection4 Aliases() + { + Collection4 aliasesCollection = (Collection4)_config.Get(AliasesKey); + if (null == aliasesCollection) + { + aliasesCollection = new Collection4(); + _config.Put(AliasesKey, aliasesCollection); + } + return aliasesCollection; + } + + public void AddAlias(IAlias alias) + { + if (null == alias) + { + throw new ArgumentNullException("alias"); + } + Aliases().Add(alias); + } + + public void RemoveAlias(IAlias alias) + { + if (null == alias) + { + throw new ArgumentNullException("alias"); + } + Aliases().Remove(alias); + } + + public string ResolveAliasRuntimeName(string runtimeType) + { + Collection4 configuredAliases = Aliases(); + if (null == configuredAliases) + { + return runtimeType; + } + IEnumerator i = configuredAliases.GetEnumerator(); + while (i.MoveNext()) + { + string resolved = ((IAlias)i.Current).ResolveRuntimeName(runtimeType); + if (null != resolved) + { + return resolved; + } + } + return runtimeType; + } + + public string ResolveAliasStoredName(string storedType) + { + Collection4 configuredAliases = Aliases(); + if (null == configuredAliases) + { + return storedType; + } + IEnumerator i = configuredAliases.GetEnumerator(); + while (i.MoveNext()) + { + string resolved = ((IAlias)i.Current).ResolveStoredName(storedType); + if (null != resolved) + { + return resolved; + } + } + return storedType; + } + + internal IReflectClass ReflectorFor(object clazz) + { + return ReflectorUtils.ReflectClassFor(Reflector(), clazz); + } + + public bool AllowVersionUpdates() + { + return _config.GetAsBoolean(AllowVersionUpdatesKey); + } + + public bool AutomaticShutDown() + { + return _config.GetAsBoolean(AutomaticShutdownKey); + } + + public byte BlockSize() + { + return _config.GetAsByte(BlocksizeKey); + } + + public int BTreeNodeSize() + { + return _config.GetAsInt(BtreeNodeSizeKey); + } + + public string BlobPath() + { + return _config.GetAsString(BlobPathKey); + } + + public CallBackMode CallbackMode() + { + return (CallBackMode)_config.Get(CallbacksKey); + } + + public TernaryBool CallConstructors() + { + return _config.GetAsTernaryBool(CallConstructorsKey); + } + + internal bool ClassActivationDepthConfigurable() + { + return _config.GetAsBoolean(ClassActivationDepthConfigurableKey); + } + + internal object ClassLoader() + { + return _config.Get(ClassloaderKey); + } + + public bool DetectSchemaChanges() + { + return _config.GetAsBoolean(DetectSchemaChangesKey); + } + + public bool CommitRecoveryDisabled() + { + return _config.GetAsBoolean(DisableCommitRecoveryKey); + } + + public IDiagnosticConfiguration Diagnostic() + { + return (IDiagnosticConfiguration)_config.Get(DiagnosticKey); + } + + public Db4objects.Db4o.Internal.Diagnostic.DiagnosticProcessor DiagnosticProcessor + () + { + return (Db4objects.Db4o.Internal.Diagnostic.DiagnosticProcessor)_config.Get(DiagnosticKey + ); + } + + public int DiscardFreeSpace() + { + return _config.GetAsInt(DiscardFreespaceKey); + } + + internal byte Encoding() + { + return _config.GetAsByte(EncodingKey); + } + + internal bool Encrypt() + { + return _config.GetAsBoolean(EncryptKey); + } + + public Hashtable4 ExceptionalClasses() + { + Hashtable4 exceptionalClasses = (Hashtable4)_config.Get(ExceptionalClassesKey); + if (exceptionalClasses == null) + { + exceptionalClasses = new Hashtable4(16); + _config.Put(ExceptionalClassesKey, exceptionalClasses); + } + return exceptionalClasses; + } + + public bool ExceptionsOnNotStorable() + { + return _config.GetAsBoolean(ExceptionsOnNotStorableKey); + } + + internal byte FreespaceSystem() + { + return _config.GetAsByte(FreespaceSystemKey); + } + + public ConfigScope GenerateUUIDs() + { + return (ConfigScope)_config.Get(GenerateUuidsKey); + } + + public TernaryBool GenerateCommitTimestamps() + { + return (TernaryBool)_config.Get(GenerateCommitTimestampsKey); + } + + public bool InternStrings() + { + return _internStrings; + } + + public bool LockFile() + { + return _config.GetAsBoolean(LockFileKey); + } + + public int MessageLevel() + { + return _messageLevel; + } + + public IMessageRecipient MessageRecipient() + { + return (IMessageRecipient)_config.Get(MessageRecipientKey); + } + + internal bool OptimizeNQ() + { + return _config.GetAsBoolean(OptimizeNqKey); + } + + internal string Password() + { + return _config.GetAsString(PasswordKey); + } + + public void PrefetchIDCount(int prefetchIDCount) + { + _config.Put(PrefetchIdCountKey, prefetchIDCount); + } + + public int PrefetchIDCount() + { + return _config.GetAsInt(PrefetchIdCountKey); + } + + public void PrefetchObjectCount(int prefetchObjectCount) + { + _config.Put(PrefetchObjectCountKey, prefetchObjectCount); + EnsurePrefetchSlotCacheSize(); + } + + public int PrefetchObjectCount() + { + return _config.GetAsInt(PrefetchObjectCountKey); + } + + public Hashtable4 ReadAs() + { + return (Hashtable4)_config.Get(ReadAsKey); + } + + public bool IsReadOnly() + { + return _readOnly; + } + + public void RecoveryMode(bool flag) + { + _config.Put(RecoveryModeKey, flag); + } + + public bool RecoveryMode() + { + return _config.GetAsBoolean(RecoveryModeKey); + } + + internal Collection4 Rename() + { + return (Collection4)_config.Get(RenameKey); + } + + public int ReservedStorageSpace() + { + return _config.GetAsInt(ReservedStorageSpaceKey); + } + + public bool SingleThreadedClient() + { + return _config.GetAsBoolean(SingleThreadedClientKey); + } + + public bool TestConstructors() + { + return _config.GetAsBoolean(TestConstructorsKey); + } + + public int TimeoutClientSocket() + { + return _config.GetAsInt(TimeoutClientSocketKey); + } + + public int TimeoutServerSocket() + { + return _config.GetAsInt(TimeoutServerSocketKey); + } + + public int UpdateDepth() + { + return _config.GetAsInt(UpdateDepthKey); + } + + public int WeakReferenceCollectionInterval() + { + return _config.GetAsInt(WeakReferenceCollectionIntervalKey); + } + + public bool WeakReferences() + { + return _config.GetAsBoolean(WeakReferencesKey); + } + + public IoAdapter Io() + { + throw new NotImplementedException(); + } + + public IStorage Storage + { + get + { + return (IStorage)_config.Get(StorageFactoryKey); + } + set + { + IStorage factory = value; + _config.Put(StorageFactoryKey, factory); + } + } + + public IQueryConfiguration Queries() + { + return this; + } + + public void EvaluationMode(QueryEvaluationMode mode) + { + _config.Put(QueryEvaluationModeKey, mode); + } + + public QueryEvaluationMode EvaluationMode() + { + return (QueryEvaluationMode)_config.Get(QueryEvaluationModeKey); + } + + public void QueryResultIteratorFactory(IQueryResultIteratorFactory factory) + { + _config.Put(ClientQueryResultIteratorFactoryKey, factory); + } + + public IQueryResultIteratorFactory QueryResultIteratorFactory() + { + return (IQueryResultIteratorFactory)_config.Get(ClientQueryResultIteratorFactoryKey + ); + } + + public IClientServerConfiguration ClientServer() + { + return this; + } + + public void BatchMessages(bool flag) + { + _config.Put(BatchMessagesKey, flag); + } + + public bool BatchMessages() + { + return _config.GetAsBoolean(BatchMessagesKey); + } + + public void MaxBatchQueueSize(int maxSize) + { + _config.Put(MaxBatchQueueSizeKey, maxSize); + } + + public int MaxBatchQueueSize() + { + return _config.GetAsInt(MaxBatchQueueSizeKey); + } + + public void ActivationDepthProvider(IActivationDepthProvider provider) + { + _config.Put(ActivationDepthProviderKey, provider); + } + + public void UpdateDepthProvider(IUpdateDepthProvider provider) + { + _config.Put(UpdateDepthProviderKey, provider); + } + + public IActivationDepthProvider ActivationDepthProvider() + { + return (IActivationDepthProvider)_config.Get(ActivationDepthProviderKey); + } + + public IUpdateDepthProvider UpdateDepthProvider() + { + return (IUpdateDepthProvider)_config.Get(UpdateDepthProviderKey); + } + + public void RegisterTypeHandler(ITypeHandlerPredicate predicate, ITypeHandler4 typeHandler + ) + { + if (_registeredTypeHandlers == null) + { + _registeredTypeHandlers = new Collection4(); + } + _registeredTypeHandlers.Add(new TypeHandlerPredicatePair(predicate, typeHandler)); + } + + public ITypeHandler4 TypeHandlerForClass(IReflectClass classReflector, byte handlerVersion + ) + { + if (_registeredTypeHandlers == null) + { + return null; + } + IEnumerator i = _registeredTypeHandlers.GetEnumerator(); + while (i.MoveNext()) + { + TypeHandlerPredicatePair pair = (TypeHandlerPredicatePair)i.Current; + if (pair._predicate.Match(classReflector)) + { + return pair._typeHandler; + } + } + return null; + } + + public class ConfigDeepCloneContext + { + public readonly Config4Impl _orig; + + public readonly Config4Impl _cloned; + + public ConfigDeepCloneContext(Config4Impl orig, Config4Impl cloned) + { + _orig = orig; + _cloned = cloned; + } + } + + public void Factory(ILegacyClientServerFactory factory) + { + _config.Put(ClientServerFactoryKey, factory); + } + + public ILegacyClientServerFactory ClientServerFactory() + { + return (ILegacyClientServerFactory)_config.Get(ClientServerFactoryKey); + } + + public ICacheConfiguration Cache() + { + return new CacheConfigurationImpl(this); + } + + public bool FileBasedTransactionLog() + { + return _config.GetAsBoolean(FileBasedTransactionLogKey); + } + + public void FileBasedTransactionLog(bool flag) + { + _config.Put(FileBasedTransactionLogKey, flag); + } + + private bool IsTainted() + { + return _config.GetAsBoolean(TaintedKey); + } + + public void Taint() + { + _config.Put(TaintedKey, true); + } + + public static void AssertIsNotTainted(IConfiguration config) + { + if (((Config4Impl)config).IsTainted()) + { + throw new ArgumentException("Configuration already used."); + } + } + + public void PrefetchDepth(int prefetchDepth) + { + _config.Put(PrefetchDepthKey, prefetchDepth); + EnsurePrefetchSlotCacheSize(); + } + + private void EnsurePrefetchSlotCacheSize() + { + if (!_prefetchSlotCacheSizeModifiedExternally) + { + PrefetchSlotCacheSize(CalculatedPrefetchSlotcacheSize()); + _prefetchSlotCacheSizeModifiedExternally = false; + } + } + + public int PrefetchDepth() + { + return _config.GetAsInt(PrefetchDepthKey); + } + + public IList EnvironmentContributions() + { + return (IList)_config.Get(EnvironmentContributionsKey); + } + + public void PrefetchSlotCacheSize(int slotCacheSize) + { + _prefetchSlotCacheSizeModifiedExternally = true; + _config.Put(PrefetchSlotCacheSizeKey, slotCacheSize); + if (null != _prefetchSettingsChanged) _prefetchSettingsChanged(null, EventArgs.Empty + ); + } + + public int PrefetchSlotCacheSize() + { + return _config.GetAsInt(PrefetchSlotCacheSizeKey); + } + + private int CalculatedPrefetchSlotcacheSize() + { + long calculated = (long)PrefetchDepth() * PrefetchObjectCount() * PrefetchSlotCacheSizeFactor; + if (calculated > MaximumPrefetchSlotCacheSize) + { + calculated = MaximumPrefetchSlotCacheSize; + } + return (int)calculated; + } + + public event System.EventHandler PrefetchSettingsChanged + { + add + { + _prefetchSettingsChanged = (System.EventHandler)System.Delegate.Combine + (_prefetchSettingsChanged, value); + } + remove + { + _prefetchSettingsChanged = (System.EventHandler)System.Delegate.Remove + (_prefetchSettingsChanged, value); + } + } + + public void ReferenceSystemFactory(IReferenceSystemFactory referenceSystemFactory + ) + { + _config.Put(ReferenceSystemFactoryKey, referenceSystemFactory); + } + + public IReferenceSystemFactory ReferenceSystemFactory() + { + return (IReferenceSystemFactory)_config.Get(ReferenceSystemFactoryKey); + } + + public void NameProvider(INameProvider provider) + { + _config.Put(NameProviderKey, provider); + } + + public INameProvider NameProvider() + { + return (INameProvider)_config.Get(NameProviderKey); + } + + public void UsePointerBasedIdSystem() + { + _config.Put(IdSystemKey, StandardIdSystemFactory.PointerBased); + } + + public void UseStackedBTreeIdSystem() + { + _config.Put(IdSystemKey, StandardIdSystemFactory.StackedBtree); + } + + public void UseSingleBTreeIdSystem() + { + _config.Put(IdSystemKey, StandardIdSystemFactory.SingleBtree); + } + + public byte IdSystemType() + { + return _config.GetAsByte(IdSystemKey); + } + + public void UseInMemoryIdSystem() + { + _config.Put(IdSystemKey, StandardIdSystemFactory.InMemory); + } + + public void UseCustomIdSystem(IIdSystemFactory factory) + { + _config.Put(IdSystemKey, StandardIdSystemFactory.Custom); + _config.Put(IdSystemCustomFactoryKey, factory); + } + + public IIdSystemFactory CustomIdSystemFactory() + { + return (IIdSystemFactory)_config.Get(IdSystemCustomFactoryKey); + } + + public void AsynchronousSync(bool flag) + { + _config.Put(AsynchronousSyncKey, flag); + } + + public bool AsynchronousSync() + { + return _config.GetAsBoolean(AsynchronousSyncKey); + } + + public int MaxStackDepth() + { + return _config.GetAsInt(MaxStackDepthKey); + } + + public void MaxStackDepth(int maxStackDepth) + { + _config.Put(MaxStackDepthKey, maxStackDepth); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Const4.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Const4.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Const4.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Const4.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,227 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using Db4objects.Db4o; +using Db4objects.Db4o.Config; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Encoding; +using Db4objects.Db4o.Types; + +namespace Db4objects.Db4o.Internal +{ + /// TODO: Split into separate enums with defined range and values. + public sealed partial class Const4 + { + public const byte Yapfileversion = 4; + + public const byte Yapbegin = (byte)'{'; + + public const byte Yapfile = (byte)'Y'; + + public const byte Yapid = (byte)'#'; + + public const byte Yappointer = (byte)'>'; + + public const byte Yapclasscollection = (byte)'A'; + + public const byte Yapclass = (byte)'C'; + + public const byte Yapfield = (byte)'F'; + + public const byte Yapobject = (byte)'O'; + + public const byte Yaparray = (byte)'N'; + + public const byte Yaparrayn = (byte)'Z'; + + public const byte Yapindex = (byte)'X'; + + public const byte Yapstring = (byte)'S'; + + public const byte Yaplong = (byte)'l'; + + public const byte Yapinteger = (byte)'i'; + + public const byte Yapboolean = (byte)'='; + + public const byte Yapdouble = (byte)'d'; + + public const byte Yapbyte = (byte)'b'; + + public const byte Yapshort = (byte)'s'; + + public const byte Yapchar = (byte)'c'; + + public const byte Yapfloat = (byte)'f'; + + public const byte Yapend = (byte)'}'; + + public const byte Yapnull = (byte)'0'; + + public const byte Btree = (byte)'T'; + + public const byte BtreeNode = (byte)'B'; + + public const byte Header = (byte)'H'; + + public const byte IntegerArray = (byte)'I'; + + public const byte BtreeList = (byte)'L'; + + public const int IdentifierLength = (Deploy.debug && Deploy.identifiers) ? 1 : 0; + + public const int BracketsBytes = (Deploy.debug && Deploy.brackets) ? 1 : 0; + + public const int BracketsLength = BracketsBytes * 2; + + public const int LeadingLength = IdentifierLength + BracketsBytes; + + public const int AddedLength = IdentifierLength + BracketsLength; + + public const int ShortBytes = 2; + + public const int IntegerBytes = (Deploy.debug && Deploy.debugLong) ? 11 : 4; + + public const int LongBytes = (Deploy.debug && Deploy.debugLong) ? 20 : 8; + + public const int CharBytes = 2; + + public const int Unspecified = int.MinValue + 100; + + public const int IntLength = IntegerBytes + AddedLength; + + public const int IdLength = IntLength; + + public const int LongLength = LongBytes + AddedLength; + + public const int IndirectionLength = IntLength + IdLength; + + public const int WriteLoop = (IntegerBytes - 1) * 8; + + public const int ObjectLength = AddedLength; + + public const int PointerLength = (IntLength * 2) + AddedLength; + + public const int MessageLength = IntLength * 2 + 1; + + public const byte SystemTrans = (byte)'s'; + + public const byte UserTrans = (byte)'u'; + + public const byte Xbyte = (byte)'X'; + + public const int IgnoreId = -99999; + + public const int Primitive = -2000000000; + + public const int TypeArray = 3; + + public const int TypeNarray = 4; + + public const int None = 0; + + public const int State = 1; + + public const int Activation = 2; + + public const int Transient = -1; + + public const int AddMembersToIdTreeOnly = 0; + + public const int AddToIdTree = 1; + + public const int LockTimeInterval = 1000; + + public const int ServerSocketTimeout = Debug4.longTimeOuts ? 1000000 : 600000; + + public const int ClientSocketTimeout = ServerSocketTimeout; + + public const int MaximumBlockSize = 70000000; + + public const int MaximumArrayEntries = 7000000; + + public const int MaximumArrayEntriesPrimitive = MaximumArrayEntries * 100; + + public static readonly Type ClassCompare = typeof(ICompare); + + public static readonly Type ClassDb4otype = typeof(IDb4oType); + + public static readonly Type ClassDb4otypeimpl = typeof(IDb4oTypeImpl); + + public static readonly Type ClassInternal = typeof(IInternal4); + + public static readonly Type ClassUnversioned = typeof(IUnversioned); + + public static readonly Type ClassObject = new object().GetType(); + + public static readonly Type ClassObjectcontainer = typeof(IObjectContainer); + + public static readonly Type ClassStaticfield = new StaticField().GetType(); + + public static readonly Type ClassStaticclass = new StaticClass().GetType(); + + public static readonly Type ClassTransientclass = typeof(ITransientClass); + + public static readonly string EmbeddedClientUser = "embedded client"; + + public const int Clean = 0; + + public const int Active = 1; + + public const int Processing = 2; + + public const int CachedDirty = 3; + + public const int Continue = 4; + + public const int StaticFieldsStored = 5; + + public const int CheckedChanges = 6; + + public const int Dead = 7; + + public const int Reading = 8; + + public const int Activating = 9; + + public const int Old = -1; + + public const int New = 1; + + public static readonly UnicodeStringIO stringIO = new UnicodeStringIO(); + + public static readonly Type[] EssentialClasses = new Type[] { ClassStaticfield, ClassStaticclass + }; + + public static readonly string VirtualFieldPrefix = "v4o"; + + public const int InvalidObjectId = 1; + + public const int DefaultMaxStackDepth = 20; + // make sure we don't fall over the -1 cliff + // TODO: Is this the right place for the knowledge, that an indirection + // within a slot is an address and a length? + // debug constants + // TODO: This one is a terrible low-frequency blunder in YapArray.writeClass!!! + // If YapClass-ID == 99999 (not very likely) then we will get IGNORE_ID. Change + // to -Integer.MAX_VALUE or protect 99999 in YapFile.getPointerSlot() + // This is a hard coded 2 Gig-Limit for YapClass-IDs. + // TODO: get rid of magic numbers like this one + // array type information + // message levels + // Use if > NONE: normal messages + // if > STATE: state messages + // if > ACTIVATION: activation messages + // Timings + // 10 minutes until clients are disconnected, (5 minutes until they get pinged) + // TODO: Consider to make configurable + // 70 MB + // 7 Million + // 70 MB for byte arrays + // bits in PersistentBase.i_state + // and reuse in other classes + // system classes that need to get loaded first + // StaticClass should load Staticfield + // TODO: remove unnecessary + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Convert/Conversion.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Convert/Conversion.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Convert/Conversion.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Convert/Conversion.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,20 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal.Convert; + +namespace Db4objects.Db4o.Internal.Convert +{ + /// + public abstract class Conversion + { + /// + public virtual void Convert(ConversionStage.ClassCollectionAvailableStage stage) + { + } + + /// + public virtual void Convert(ConversionStage.SystemUpStage stage) + { + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Convert/Conversions/ClassAspects_7_4.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Convert/Conversions/ClassAspects_7_4.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Convert/Conversions/ClassAspects_7_4.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Convert/Conversions/ClassAspects_7_4.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,17 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal.Convert; + +namespace Db4objects.Db4o.Internal.Convert.Conversions +{ + /// + public class ClassAspects_7_4 : Conversion + { + public const int Version = 7; + + public override void Convert(ConversionStage.SystemUpStage stage) + { + stage.File().ClassCollection().WriteAllClasses(); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Convert/Conversions/ClassIndexesToBTrees_5_5.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Convert/Conversions/ClassIndexesToBTrees_5_5.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Convert/Conversions/ClassIndexesToBTrees_5_5.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Convert/Conversions/ClassIndexesToBTrees_5_5.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,38 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Btree; +using Db4objects.Db4o.Internal.Convert; + +namespace Db4objects.Db4o.Internal.Convert.Conversions +{ + /// + public class ClassIndexesToBTrees_5_5 : Conversion + { + public const int Version = 5; + + public virtual void Convert(LocalObjectContainer container, int classIndexId, BTree + bTree) + { + Transaction trans = container.SystemTransaction(); + ByteArrayBuffer reader = container.ReadBufferById(trans, classIndexId); + if (reader == null) + { + return; + } + int entries = reader.ReadInt(); + for (int i = 0; i < entries; i++) + { + bTree.Add(trans, reader.ReadInt()); + } + } + + public override void Convert(ConversionStage.SystemUpStage stage) + { + // calling #storedClasses forces reading all classes + // That's good enough to load them all and to call the + // above convert method. + stage.File().StoredClasses(); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Convert/Conversions/CommonConversions.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Convert/Conversions/CommonConversions.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Convert/Conversions/CommonConversions.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Convert/Conversions/CommonConversions.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,29 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal.Convert; +using Db4objects.Db4o.Internal.Convert.Conversions; + +namespace Db4objects.Db4o.Internal.Convert.Conversions +{ + /// + public class CommonConversions + { + public static void Register(Converter converter) + { + converter.Register(ClassIndexesToBTrees_5_5.Version, new ClassIndexesToBTrees_5_5 + ()); + converter.Register(FieldIndexesToBTrees_5_7.Version, new FieldIndexesToBTrees_5_7 + ()); + converter.Register(ClassAspects_7_4.Version, new ClassAspects_7_4()); + converter.Register(ReindexNetDateTime_7_8.Version, new ReindexNetDateTime_7_8()); + converter.Register(DropEnumClassIndexes_7_10.Version, new DropEnumClassIndexes_7_10 + ()); + converter.Register(DropGuidClassIndexes_7_12.Version, new DropGuidClassIndexes_7_12 + ()); + converter.Register(DropDateTimeOffsetClassIndexes_7_12.Version, new DropDateTimeOffsetClassIndexes_7_12 + ()); + converter.Register(VersionNumberToCommitTimestamp_8_0.Version, new VersionNumberToCommitTimestamp_8_0 + ()); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Convert/Conversions/DropDateTimeOffsetClassIndexes_7_12.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Convert/Conversions/DropDateTimeOffsetClassIndexes_7_12.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Convert/Conversions/DropDateTimeOffsetClassIndexes_7_12.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Convert/Conversions/DropDateTimeOffsetClassIndexes_7_12.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,10 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +namespace Db4objects.Db4o.Internal.Convert.Conversions +{ + /// + public partial class DropDateTimeOffsetClassIndexes_7_12 + { + public const int Version = 11; + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Convert/Conversions/DropEnumClassIndexes_7_10.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Convert/Conversions/DropEnumClassIndexes_7_10.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Convert/Conversions/DropEnumClassIndexes_7_10.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Convert/Conversions/DropEnumClassIndexes_7_10.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,10 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +namespace Db4objects.Db4o.Internal.Convert.Conversions +{ + /// * + public partial class DropEnumClassIndexes_7_10 + { + public const int Version = 9; + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Convert/Conversions/DropGuidClassIndexes_7_12.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Convert/Conversions/DropGuidClassIndexes_7_12.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Convert/Conversions/DropGuidClassIndexes_7_12.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Convert/Conversions/DropGuidClassIndexes_7_12.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,10 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +namespace Db4objects.Db4o.Internal.Convert.Conversions +{ + /// + public partial class DropGuidClassIndexes_7_12 + { + public const int Version = 10; + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Convert/Conversions/FieldIndexesToBTrees_5_7.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Convert/Conversions/FieldIndexesToBTrees_5_7.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Convert/Conversions/FieldIndexesToBTrees_5_7.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Convert/Conversions/FieldIndexesToBTrees_5_7.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,40 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Convert; + +namespace Db4objects.Db4o.Internal.Convert.Conversions +{ + /// + public class FieldIndexesToBTrees_5_7 : Conversion + { + public const int Version = 6; + + public override void Convert(ConversionStage.SystemUpStage stage) + { + stage.File().ClassCollection().WriteAllClasses(); + RebuildUUIDIndex(stage.File()); + FreeOldUUIDMetaIndex(stage.File()); + } + + private void RebuildUUIDIndex(LocalObjectContainer file) + { + UUIDFieldMetadata uuid = file.UUIDIndex(); + ClassMetadataIterator i = file.ClassCollection().Iterator(); + while (i.MoveNext()) + { + ClassMetadata clazz = i.CurrentClass(); + if (clazz.GenerateUUIDs()) + { + uuid.RebuildIndexForClass(file, clazz); + } + } + } + + /// + private void FreeOldUUIDMetaIndex(LocalObjectContainer file) + { + } + // updating removed here to allow removing MetaIndex class + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Convert/Conversions/ReindexNetDateTime_7_8.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Convert/Conversions/ReindexNetDateTime_7_8.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Convert/Conversions/ReindexNetDateTime_7_8.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Convert/Conversions/ReindexNetDateTime_7_8.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,10 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +namespace Db4objects.Db4o.Internal.Convert.Conversions +{ + /// + public partial class ReindexNetDateTime_7_8 + { + public const int Version = 8; + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Convert/Conversions/VersionNumberToCommitTimestamp_8_0.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Convert/Conversions/VersionNumberToCommitTimestamp_8_0.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Convert/Conversions/VersionNumberToCommitTimestamp_8_0.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Convert/Conversions/VersionNumberToCommitTimestamp_8_0.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,90 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Convert; +using Db4objects.Db4o.Internal.Handlers; +using Db4objects.Db4o.Internal.Marshall; + +namespace Db4objects.Db4o.Internal.Convert.Conversions +{ + /// + public class VersionNumberToCommitTimestamp_8_0 : Conversion + { + public const int Version = 12; + + private VersionFieldMetadata versionFieldMetadata; + + public override void Convert(ConversionStage.SystemUpStage stage) + { + LocalObjectContainer container = stage.File(); + if (!container.Config().GenerateCommitTimestamps().DefiniteYes()) + { + return; + } + container.ClassCollection().WriteAllClasses(); + BuildCommitTimestampIndex(container); + container.SystemTransaction().Commit(); + } + + private void BuildCommitTimestampIndex(LocalObjectContainer container) + { + versionFieldMetadata = container.Handlers.Indexes()._version; + ClassMetadataIterator i = container.ClassCollection().Iterator(); + while (i.MoveNext()) + { + ClassMetadata clazz = i.CurrentClass(); + if (clazz.HasVersionField() && !clazz.IsStruct()) + { + RebuildIndexForClass(container, clazz); + } + } + } + + public virtual bool RebuildIndexForClass(LocalObjectContainer container, ClassMetadata + classMetadata) + { + long[] ids = classMetadata.GetIDs(); + for (int i = 0; i < ids.Length; i++) + { + RebuildIndexForObject(container, (int)ids[i]); + } + return ids.Length > 0; + } + + /// + protected virtual void RebuildIndexForObject(LocalObjectContainer container, int + objectId) + { + StatefulBuffer writer = container.ReadStatefulBufferById(container.SystemTransaction + (), objectId); + if (writer != null) + { + RebuildIndexForWriter(container, writer, objectId); + } + } + + protected virtual void RebuildIndexForWriter(LocalObjectContainer container, StatefulBuffer + buffer, int objectId) + { + ObjectHeader objectHeader = new ObjectHeader(container, buffer); + ObjectIdContextImpl context = new ObjectIdContextImpl(container.SystemTransaction + (), buffer, objectHeader, objectId); + ClassMetadata classMetadata = context.ClassMetadata(); + if (classMetadata.IsStruct()) + { + // We don't keep version information for structs. + return; + } + if (classMetadata.SeekToField(container.SystemTransaction(), buffer, versionFieldMetadata + ) != HandlerVersion.Invalid) + { + long version = ((long)versionFieldMetadata.Read(context)); + if (version != 0) + { + LocalTransaction t = (LocalTransaction)container.SystemTransaction(); + t.CommitTimestampSupport().Put(container.SystemTransaction(), objectId, version); + } + } + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Convert/ConversionStage.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Convert/ConversionStage.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Convert/ConversionStage.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Convert/ConversionStage.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,54 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Convert; + +namespace Db4objects.Db4o.Internal.Convert +{ + /// + public abstract class ConversionStage + { + public sealed class ClassCollectionAvailableStage : ConversionStage + { + public ClassCollectionAvailableStage(LocalObjectContainer file) : base(file) + { + } + + public override void Accept(Conversion conversion) + { + conversion.Convert(this); + } + } + + public sealed class SystemUpStage : ConversionStage + { + public SystemUpStage(LocalObjectContainer file) : base(file) + { + } + + public override void Accept(Conversion conversion) + { + conversion.Convert(this); + } + } + + private LocalObjectContainer _file; + + protected ConversionStage(LocalObjectContainer file) + { + _file = file; + } + + public virtual LocalObjectContainer File() + { + return _file; + } + + public virtual int ConverterVersion() + { + return _file.SystemData().ConverterVersion(); + } + + public abstract void Accept(Conversion conversion); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Convert/Converter.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Convert/Converter.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Convert/Converter.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Convert/Converter.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,87 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using System.Collections; +using Db4objects.Db4o.Internal.Convert; +using Db4objects.Db4o.Internal.Convert.Conversions; + +namespace Db4objects.Db4o.Internal.Convert +{ + /// + public class Converter + { + public const int Version = VersionNumberToCommitTimestamp_8_0.Version; + + public static bool Convert(ConversionStage stage) + { + if (!NeedsConversion(stage.ConverterVersion())) + { + return false; + } + return Instance().RunConversions(stage); + } + + private static Db4objects.Db4o.Internal.Convert.Converter _instance; + + private IDictionary _conversions; + + private int _minimumVersion = int.MaxValue; + + private Converter() + { + _conversions = new Hashtable(); + // TODO: There probably will be Java and .NET conversions + // Create Platform4.registerConversions() method ann + // call from here when needed. + CommonConversions.Register(this); + } + + public static Db4objects.Db4o.Internal.Convert.Converter Instance() + { + if (_instance == null) + { + _instance = new Db4objects.Db4o.Internal.Convert.Converter(); + } + return _instance; + } + + public virtual Conversion ConversionFor(int version) + { + return ((Conversion)_conversions[version]); + } + + private static bool NeedsConversion(int converterVersion) + { + return converterVersion < Version; + } + + public virtual void Register(int introducedVersion, Conversion conversion) + { + if (_conversions.Contains(introducedVersion)) + { + throw new InvalidOperationException(); + } + if (introducedVersion < _minimumVersion) + { + _minimumVersion = introducedVersion; + } + _conversions[introducedVersion] = conversion; + } + + public virtual bool RunConversions(ConversionStage stage) + { + int startingVersion = Math.Max(stage.ConverterVersion() + 1, _minimumVersion); + for (int version = startingVersion; version <= Version; version++) + { + Conversion conversion = ConversionFor(version); + if (conversion == null) + { + throw new InvalidOperationException("Could not find a conversion for version " + + version); + } + stage.Accept(conversion); + } + return true; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/DefragmentContextImpl.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/DefragmentContextImpl.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/DefragmentContextImpl.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/DefragmentContextImpl.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,480 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o; +using Db4objects.Db4o.Defragment; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Encoding; +using Db4objects.Db4o.Internal.Mapping; +using Db4objects.Db4o.Internal.Marshall; +using Db4objects.Db4o.Internal.Slots; +using Db4objects.Db4o.Marshall; +using Db4objects.Db4o.Typehandlers; + +namespace Db4objects.Db4o.Internal +{ + /// + public sealed class DefragmentContextImpl : IReadWriteBuffer, IDefragmentContext + { + private ByteArrayBuffer _source; + + private ByteArrayBuffer _target; + + private IDefragmentServices _services; + + private readonly ObjectHeader _objectHeader; + + private int _declaredAspectCount; + + private int _currentParentSourceID; + + public DefragmentContextImpl(ByteArrayBuffer source, Db4objects.Db4o.Internal.DefragmentContextImpl + context) : this(source, context._services, context._objectHeader) + { + } + + public DefragmentContextImpl(ByteArrayBuffer source, IDefragmentServices services + ) : this(source, services, null) + { + } + + public DefragmentContextImpl(ByteArrayBuffer source, IDefragmentServices services + , ObjectHeader header) + { + _source = source; + _services = services; + _target = new ByteArrayBuffer(Length()); + _source.CopyTo(_target, 0, 0, Length()); + _objectHeader = header; + } + + public DefragmentContextImpl(Db4objects.Db4o.Internal.DefragmentContextImpl parentContext + , ObjectHeader header) + { + _source = parentContext._source; + _target = parentContext._target; + _services = parentContext._services; + _objectHeader = header; + } + + public int Offset() + { + return _source.Offset(); + } + + public void Seek(int offset) + { + _source.Seek(offset); + _target.Seek(offset); + } + + public void IncrementOffset(int numBytes) + { + _source.IncrementOffset(numBytes); + _target.IncrementOffset(numBytes); + } + + public void IncrementIntSize() + { + IncrementOffset(Const4.IntLength); + } + + public int CopySlotlessID() + { + return CopyUnindexedId(false); + } + + public int CopyUnindexedID() + { + return CopyUnindexedId(true); + } + + private int CopyUnindexedId(bool doRegister) + { + int orig = _source.ReadInt(); + // TODO: There is no test case for the zero case + if (orig == 0) + { + _target.WriteInt(0); + return 0; + } + int mapped = -1; + try + { + mapped = _services.StrictMappedID(orig); + } + catch (MappingNotFoundException) + { + mapped = _services.TargetNewId(); + _services.MapIDs(orig, mapped, false); + if (doRegister) + { + _services.RegisterUnindexed(orig); + } + } + _target.WriteInt(mapped); + return mapped; + } + + public int CopyID() + { + // This code is slightly redundant. + // The profiler shows it's a hotspot. + // The following would be non-redudant. + // return copy(false, false); + int id = _source.ReadInt(); + return WriteMappedID(id); + } + + public int CopyID(bool flipNegative) + { + int id = _source.ReadInt(); + return InternalCopyID(flipNegative, id); + } + + public int CopyIDReturnOriginalID() + { + return CopyIDReturnOriginalID(false); + } + + public int CopyIDReturnOriginalID(bool flipNegative) + { + int id = _source.ReadInt(); + InternalCopyID(flipNegative, id); + bool flipped = flipNegative && (id < 0); + if (flipped) + { + return -id; + } + return id; + } + + private int InternalCopyID(bool flipNegative, int id) + { + bool flipped = flipNegative && (id < 0); + if (flipped) + { + id = -id; + } + int mapped = _services.MappedID(id); + if (flipped) + { + mapped = -mapped; + } + _target.WriteInt(mapped); + return mapped; + } + + public void ReadBegin(byte identifier) + { + _source.ReadBegin(identifier); + _target.ReadBegin(identifier); + } + + public byte ReadByte() + { + byte value = _source.ReadByte(); + _target.IncrementOffset(1); + return value; + } + + public void ReadBytes(byte[] bytes) + { + _source.ReadBytes(bytes); + _target.IncrementOffset(bytes.Length); + } + + public int ReadInt() + { + int value = _source.ReadInt(); + _target.IncrementOffset(Const4.IntLength); + return value; + } + + public void WriteInt(int value) + { + _source.IncrementOffset(Const4.IntLength); + _target.WriteInt(value); + } + + public void Write(LocalObjectContainer file, int address) + { + file.WriteBytes(_target, address, 0); + } + + public void IncrementStringOffset(LatinStringIO sio) + { + IncrementStringOffset(sio, _source); + IncrementStringOffset(sio, _target); + } + + private void IncrementStringOffset(LatinStringIO sio, ByteArrayBuffer buffer) + { + sio.ReadLengthAndString(buffer); + } + + public ByteArrayBuffer SourceBuffer() + { + return _source; + } + + public ByteArrayBuffer TargetBuffer() + { + return _target; + } + + public IIDMapping Mapping() + { + return _services; + } + + public Db4objects.Db4o.Internal.Transaction SystemTrans() + { + return Transaction(); + } + + public IDefragmentServices Services() + { + return _services; + } + + public static void ProcessCopy(IDefragmentServices context, int sourceID, ISlotCopyHandler + command) + { + ByteArrayBuffer sourceReader = context.SourceBufferByID(sourceID); + ProcessCopy(context, sourceID, command, sourceReader); + } + + public static void ProcessCopy(IDefragmentServices services, int sourceID, ISlotCopyHandler + command, ByteArrayBuffer sourceReader) + { + int targetID = services.StrictMappedID(sourceID); + Slot targetSlot = services.AllocateTargetSlot(sourceReader.Length()); + services.Mapping().MapId(targetID, targetSlot); + Db4objects.Db4o.Internal.DefragmentContextImpl context = new Db4objects.Db4o.Internal.DefragmentContextImpl + (sourceReader, services); + command.ProcessCopy(context); + services.TargetWriteBytes(context, targetSlot.Address()); + } + + public void WriteByte(byte value) + { + _source.IncrementOffset(1); + _target.WriteByte(value); + } + + public long ReadLong() + { + long value = _source.ReadLong(); + _target.IncrementOffset(Const4.LongLength); + return value; + } + + public void WriteLong(long value) + { + _source.IncrementOffset(Const4.LongLength); + _target.WriteLong(value); + } + + public BitMap4 ReadBitMap(int bitCount) + { + BitMap4 value = _source.ReadBitMap(bitCount); + _target.IncrementOffset(value.MarshalledLength()); + return value; + } + + public void ReadEnd() + { + _source.ReadEnd(); + _target.ReadEnd(); + } + + public int WriteMappedID(int originalID) + { + int mapped = _services.MappedID(originalID); + _target.WriteInt(mapped); + return mapped; + } + + public int Length() + { + return _source.Length(); + } + + public Db4objects.Db4o.Internal.Transaction Transaction() + { + return Services().SystemTrans(); + } + + public ObjectContainerBase Container() + { + return Transaction().Container(); + } + + public ITypeHandler4 TypeHandlerForId(int id) + { + return Container().TypeHandlerForClassMetadataID(id); + } + + public int HandlerVersion() + { + return _objectHeader.HandlerVersion(); + } + + public bool IsLegacyHandlerVersion() + { + return HandlerVersion() == 0; + } + + public int MappedID(int origID) + { + return Mapping().StrictMappedID(origID); + } + + public IObjectContainer ObjectContainer() + { + return Container(); + } + + /// only used by old handlers: OpenTypeHandler0, StringHandler0, ArrayHandler0. + /// + /// + /// only used by old handlers: OpenTypeHandler0, StringHandler0, ArrayHandler0. + /// Doesn't need to work with modern IdSystems. + /// + public Slot AllocateTargetSlot(int length) + { + return _services.AllocateTargetSlot(length); + } + + /// only used by old handlers: OpenTypeHandler0, StringHandler0, ArrayHandler0. + /// + /// + /// only used by old handlers: OpenTypeHandler0, StringHandler0, ArrayHandler0. + /// Doesn't need to work with modern IdSystems. + /// + public Slot AllocateMappedTargetSlot(int sourceAddress, int length) + { + Slot slot = AllocateTargetSlot(length); + _services.MapIDs(sourceAddress, slot.Address(), false); + return slot; + } + + /// + public int CopySlotToNewMapped(int sourceAddress, int length) + { + Slot slot = AllocateMappedTargetSlot(sourceAddress, length); + ByteArrayBuffer sourceBuffer = SourceBufferByAddress(sourceAddress, length); + TargetWriteBytes(slot.Address(), sourceBuffer); + return slot.Address(); + } + + public void TargetWriteBytes(int address, ByteArrayBuffer buffer) + { + _services.TargetWriteBytes(buffer, address); + } + + /// + public ByteArrayBuffer SourceBufferByAddress(int sourceAddress, int length) + { + ByteArrayBuffer sourceBuffer = _services.SourceBufferByAddress(sourceAddress, length + ); + return sourceBuffer; + } + + /// + public ByteArrayBuffer SourceBufferById(int sourceId) + { + ByteArrayBuffer sourceBuffer = _services.SourceBufferByID(sourceId); + return sourceBuffer; + } + + public void WriteToTarget(int address) + { + _services.TargetWriteBytes(this, address); + } + + public void WriteBytes(byte[] bytes) + { + _target.WriteBytes(bytes); + _source.IncrementOffset(bytes.Length); + } + + public IReadBuffer Buffer() + { + return _source; + } + + public void Defragment(ITypeHandler4 handler) + { + ITypeHandler4 typeHandler = HandlerRegistry.CorrectHandlerVersion(this, handler); + if (Handlers4.UseDedicatedSlot(this, typeHandler)) + { + if (Handlers4.HasClassIndex(typeHandler)) + { + CopyID(); + } + else + { + CopyUnindexedID(); + } + return; + } + typeHandler.Defragment(this); + } + + public void BeginSlot() + { + } + + // do nothing + public Db4objects.Db4o.Internal.ClassMetadata ClassMetadata() + { + return _objectHeader.ClassMetadata(); + } + + public bool IsNull(int fieldIndex) + { + return _objectHeader._headerAttributes.IsNull(fieldIndex); + } + + public int DeclaredAspectCount() + { + return _declaredAspectCount; + } + + public void DeclaredAspectCount(int count) + { + _declaredAspectCount = count; + } + + public Db4objects.Db4o.Internal.Marshall.SlotFormat SlotFormat() + { + return Db4objects.Db4o.Internal.Marshall.SlotFormat.ForHandlerVersion(HandlerVersion + ()); + } + + public void CurrentParentSourceID(int id) + { + _currentParentSourceID = id; + } + + public int ConsumeCurrentParentSourceID() + { + int id = _currentParentSourceID; + _currentParentSourceID = 0; + return id; + } + + public void CopyAddress() + { + int sourceEntryAddress = _source.ReadInt(); + int sourceId = ConsumeCurrentParentSourceID(); + int sourceObjectAddress = _services.SourceAddressByID(sourceId); + int entryOffset = sourceEntryAddress - sourceObjectAddress; + int targetObjectAddress = _services.TargetAddressByID(_services.StrictMappedID(sourceId + )); + _target.WriteInt(targetObjectAddress + entryOffset); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Delete/DeleteContextImpl.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Delete/DeleteContextImpl.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Delete/DeleteContextImpl.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Delete/DeleteContextImpl.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,122 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Diagnostic; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Delete; +using Db4objects.Db4o.Internal.Diagnostic; +using Db4objects.Db4o.Internal.Marshall; +using Db4objects.Db4o.Internal.Slots; +using Db4objects.Db4o.Reflect; +using Db4objects.Db4o.Typehandlers; + +namespace Db4objects.Db4o.Internal.Delete +{ + /// + public class DeleteContextImpl : ObjectHeaderContext, IDeleteContext, IObjectIdContext + { + private readonly IReflectClass _fieldClass; + + private readonly Config4Field _fieldConfig; + + public DeleteContextImpl(Db4objects.Db4o.Internal.StatefulBuffer buffer, ObjectHeader + objectHeader, IReflectClass fieldClass, Config4Field fieldConfig) : base(buffer + .Transaction(), buffer, objectHeader) + { + _fieldClass = fieldClass; + _fieldConfig = fieldConfig; + } + + public DeleteContextImpl(Db4objects.Db4o.Internal.Delete.DeleteContextImpl parentContext + , IReflectClass fieldClass, Config4Field fieldConfig) : this(parentContext.StatefulBuffer + (), parentContext._objectHeader, fieldClass, fieldConfig) + { + } + + public virtual void CascadeDeleteDepth(int depth) + { + StatefulBuffer().SetCascadeDeletes(depth); + } + + private Db4objects.Db4o.Internal.StatefulBuffer StatefulBuffer() + { + return ((Db4objects.Db4o.Internal.StatefulBuffer)Buffer()); + } + + public virtual int CascadeDeleteDepth() + { + return StatefulBuffer().CascadeDeletes(); + } + + public virtual bool CascadeDelete() + { + return CascadeDeleteDepth() > 0; + } + + public virtual void DefragmentRecommended() + { + DiagnosticProcessor dp = Container()._handlers.DiagnosticProcessor(); + if (dp.Enabled()) + { + dp.DefragmentRecommended(DefragmentRecommendation.DefragmentRecommendationReason. + DeleteEmbeded); + } + } + + public virtual Slot ReadSlot() + { + return new Slot(Buffer().ReadInt(), Buffer().ReadInt()); + } + + public virtual void Delete(ITypeHandler4 handler) + { + ITypeHandler4 correctHandlerVersion = HandlerRegistry.CorrectHandlerVersion(this, + handler); + int preservedCascadeDepth = CascadeDeleteDepth(); + CascadeDeleteDepth(AdjustedDepth()); + if (Handlers4.HandleAsObject(correctHandlerVersion)) + { + DeleteObject(); + } + else + { + correctHandlerVersion.Delete(this); + } + CascadeDeleteDepth(preservedCascadeDepth); + } + + public virtual void DeleteObject() + { + int id = Buffer().ReadInt(); + if (CascadeDelete()) + { + Container().DeleteByID(Transaction(), id, CascadeDeleteDepth()); + } + } + + private int AdjustedDepth() + { + if (Platform4.IsStruct(_fieldClass)) + { + return 1; + } + if (_fieldConfig == null) + { + return CascadeDeleteDepth(); + } + if (_fieldConfig.CascadeOnDelete().DefiniteYes()) + { + return 1; + } + if (_fieldConfig.CascadeOnDelete().DefiniteNo()) + { + return 0; + } + return CascadeDeleteDepth(); + } + + public virtual int ObjectId() + { + return StatefulBuffer().GetID(); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Delete/IDeleteContext.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Delete/IDeleteContext.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Delete/IDeleteContext.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Delete/IDeleteContext.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,29 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal.Marshall; +using Db4objects.Db4o.Internal.Slots; +using Db4objects.Db4o.Marshall; +using Db4objects.Db4o.Typehandlers; + +namespace Db4objects.Db4o.Internal.Delete +{ + /// + public interface IDeleteContext : IContext, IReadBuffer, IHandlerVersionContext + { + bool CascadeDelete(); + + int CascadeDeleteDepth(); + + void Delete(ITypeHandler4 handler); + + void DeleteObject(); + + bool IsLegacyHandlerVersion(); + + void DefragmentRecommended(); + + Slot ReadSlot(); + + int ObjectId(); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/DeleteInfo.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/DeleteInfo.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/DeleteInfo.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/DeleteInfo.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,27 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal; + +namespace Db4objects.Db4o.Internal +{ + /// + public class DeleteInfo : TreeInt + { + internal int _cascade; + + public ObjectReference _reference; + + public DeleteInfo(int id, ObjectReference reference, int cascade) : base(id) + { + _reference = reference; + _cascade = cascade; + } + + public override object ShallowClone() + { + Db4objects.Db4o.Internal.DeleteInfo deleteinfo = new Db4objects.Db4o.Internal.DeleteInfo + (0, _reference, _cascade); + return ShallowCloneInternal(deleteinfo); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Diagnostic/DiagnosticProcessor.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Diagnostic/DiagnosticProcessor.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Diagnostic/DiagnosticProcessor.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Diagnostic/DiagnosticProcessor.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,153 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using System.Collections; +using Db4objects.Db4o.Diagnostic; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Query; + +namespace Db4objects.Db4o.Internal.Diagnostic +{ + /// FIXME: remove me from the core and make me a facade over Events + public class DiagnosticProcessor : IDiagnosticConfiguration, IDeepClone + { + private Collection4 _listeners; + + public DiagnosticProcessor() + { + } + + private DiagnosticProcessor(Collection4 listeners) + { + _listeners = listeners; + } + + public virtual void AddListener(IDiagnosticListener listener) + { + if (_listeners == null) + { + _listeners = new Collection4(); + } + _listeners.Add(listener); + } + + public virtual void CheckClassHasFields(ClassMetadata classMetadata) + { + if (classMetadata.AspectsAreNull() || classMetadata.DeclaredAspectCount() == 0) + { + string name = classMetadata.GetName(); + string[] ignoredPackages = new string[] { "java.util." }; + for (int i = 0; i < ignoredPackages.Length; i++) + { + if (name.IndexOf(ignoredPackages[i]) == 0) + { + return; + } + } + if (IsDb4oClass(classMetadata)) + { + return; + } + OnDiagnostic(new ClassHasNoFields(name)); + } + } + + public virtual void CheckUpdateDepth(int depth) + { + if (depth > 1) + { + OnDiagnostic(new UpdateDepthGreaterOne(depth)); + } + } + + public virtual object DeepClone(object context) + { + return new Db4objects.Db4o.Internal.Diagnostic.DiagnosticProcessor(CloneListeners + ()); + } + + public virtual void DeletionFailed() + { + OnDiagnostic(new Db4objects.Db4o.Diagnostic.DeletionFailed()); + } + + public virtual void DefragmentRecommended(DefragmentRecommendation.DefragmentRecommendationReason + reason) + { + OnDiagnostic(new DefragmentRecommendation(reason)); + } + + private Collection4 CloneListeners() + { + return _listeners != null ? new Collection4(_listeners) : null; + } + + public virtual bool Enabled() + { + return _listeners != null; + } + + private bool IsDb4oClass(ClassMetadata classMetadata) + { + return classMetadata.IsInternal(); + } + + public virtual void LoadedFromClassIndex(ClassMetadata classMetadata) + { + if (IsDb4oClass(classMetadata)) + { + return; + } + OnDiagnostic(new Db4objects.Db4o.Diagnostic.LoadedFromClassIndex(classMetadata.GetName + ())); + } + + public virtual void DescendIntoTranslator(ClassMetadata parent, string fieldName) + { + OnDiagnostic(new Db4objects.Db4o.Diagnostic.DescendIntoTranslator(parent.GetName( + ), fieldName)); + } + + public virtual void NativeQueryUnoptimized(Predicate predicate, Exception exception + ) + { + OnDiagnostic(new NativeQueryNotOptimized(predicate, exception)); + } + + public virtual void NativeQueryOptimizerNotLoaded(int reason, Exception e) + { + OnDiagnostic(new Db4objects.Db4o.Diagnostic.NativeQueryOptimizerNotLoaded(reason, + e)); + } + + public virtual void ObjectFieldDoesNotExist(string className, string fieldName) + { + OnDiagnostic(new Db4objects.Db4o.Diagnostic.ObjectFieldDoesNotExist(className, fieldName + )); + } + + public virtual void ClassMissed(string className) + { + OnDiagnostic(new MissingClass(className)); + } + + public virtual void OnDiagnostic(IDiagnostic d) + { + if (_listeners == null) + { + return; + } + IEnumerator i = _listeners.GetEnumerator(); + while (i.MoveNext()) + { + ((IDiagnosticListener)i.Current).OnDiagnostic(d); + } + } + + public virtual void RemoveAllListeners() + { + _listeners = null; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/DisabledBlockConverter.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/DisabledBlockConverter.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/DisabledBlockConverter.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/DisabledBlockConverter.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,36 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Slots; + +namespace Db4objects.Db4o.Internal +{ + /// + public class DisabledBlockConverter : IBlockConverter + { + public virtual int BlockAlignedBytes(int bytes) + { + return bytes; + } + + public virtual int BlocksToBytes(int blocks) + { + return blocks; + } + + public virtual int BytesToBlocks(long bytes) + { + return (int)bytes; + } + + public virtual Slot ToBlockedLength(Slot slot) + { + return slot; + } + + public virtual Slot ToNonBlockedLength(Slot slot) + { + return slot; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Encoding/BuiltInStringEncoding.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Encoding/BuiltInStringEncoding.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Encoding/BuiltInStringEncoding.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Encoding/BuiltInStringEncoding.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,62 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using Db4objects.Db4o.Config.Encoding; +using Db4objects.Db4o.Internal.Encoding; + +namespace Db4objects.Db4o.Internal.Encoding +{ + /// + public abstract class BuiltInStringEncoding : IStringEncoding + { + /// keep the position in the array. + /// + /// keep the position in the array. + /// Information is used to look up encodings. + /// + private static readonly BuiltInStringEncoding[] AllEncodings = new BuiltInStringEncoding + [] { null, new LatinStringEncoding(), new UnicodeStringEncoding(), new UTF8StringEncoding + () }; + + public static byte EncodingByteForEncoding(IStringEncoding encoding) + { + for (int i = 1; i < AllEncodings.Length; i++) + { + if (encoding.GetType() == AllEncodings[i].GetType()) + { + return (byte)i; + } + } + return 0; + } + + public static LatinStringIO StringIoForEncoding(byte encodingByte, IStringEncoding + encoding) + { + if (encodingByte < 0 || encodingByte > AllEncodings.Length) + { + throw new ArgumentException(); + } + if (encodingByte == 0) + { + if (encoding is BuiltInStringEncoding) + { + Sharpen.Runtime.Out.WriteLine("Warning! Database was created with a custom string encoding but no custom string encoding is configured for this session." + ); + } + return new DelegatingStringIO(encoding); + } + BuiltInStringEncoding builtInEncoding = AllEncodings[encodingByte]; + return builtInEncoding.CreateStringIo(encoding); + } + + protected virtual LatinStringIO CreateStringIo(IStringEncoding encoding) + { + return new DelegatingStringIO(encoding); + } + + public abstract string Decode(byte[] arg1, int arg2, int arg3); + + public abstract byte[] Encode(string arg1); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Encoding/DelegatingStringIO.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Encoding/DelegatingStringIO.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Encoding/DelegatingStringIO.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Encoding/DelegatingStringIO.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,93 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Config.Encoding; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Encoding; +using Db4objects.Db4o.Marshall; + +namespace Db4objects.Db4o.Internal.Encoding +{ + /// + public class DelegatingStringIO : LatinStringIO + { + private readonly IStringEncoding _encoding; + + public DelegatingStringIO(IStringEncoding encoding) + { + _encoding = encoding; + } + + private string Decode(byte[] bytes, int start, int length) + { + return _encoding.Decode(bytes, start, length); + } + + private byte[] Encode(string str) + { + return _encoding.Encode(str); + } + + public override byte EncodingByte() + { + if (_encoding is BuiltInStringEncoding) + { + return BuiltInStringEncoding.EncodingByteForEncoding(_encoding); + } + return 0; + } + + public override int Length(string str) + { + return Encode(str).Length + Const4.ObjectLength + Const4.IntLength; + } + + public override string Read(IReadBuffer buffer, int length) + { + byte[] bytes = new byte[length]; + buffer.ReadBytes(bytes); + return Decode(bytes, 0, bytes.Length); + } + + public override string Read(byte[] bytes) + { + return Decode(bytes, 0, bytes.Length); + } + + public override int ShortLength(string str) + { + return Encode(str).Length + Const4.IntLength; + } + + public override void Write(IWriteBuffer buffer, string str) + { + buffer.WriteBytes(Encode(str)); + } + + public override byte[] Write(string str) + { + return Encode(str); + } + + /// + /// Note the different implementation when compared to LatinStringIO and UnicodeStringIO: + /// Instead of writing the length of the string, UTF8StringIO writes the length of the + /// byte array. + /// + /// + /// Note the different implementation when compared to LatinStringIO and UnicodeStringIO: + /// Instead of writing the length of the string, UTF8StringIO writes the length of the + /// byte array. + /// + public override void WriteLengthAndString(IWriteBuffer buffer, string str) + { + if (str == null) + { + buffer.WriteInt(0); + return; + } + byte[] bytes = Encode(str); + buffer.WriteInt(bytes.Length); + buffer.WriteBytes(bytes); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Encoding/LatinStringEncoding.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Encoding/LatinStringEncoding.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Encoding/LatinStringEncoding.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Encoding/LatinStringEncoding.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,29 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using Db4objects.Db4o.Config.Encoding; +using Db4objects.Db4o.Internal.Encoding; + +namespace Db4objects.Db4o.Internal.Encoding +{ + /// + public class LatinStringEncoding : BuiltInStringEncoding + { + public override string Decode(byte[] bytes, int start, int length) + { + throw new NotImplementedException(); + } + + // special StringIO, should never be called + public override byte[] Encode(string str) + { + throw new NotImplementedException(); + } + + // special StringIO, should never be called + protected override LatinStringIO CreateStringIo(IStringEncoding encoding) + { + return new LatinStringIO(); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Encoding/LatinStringIO.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Encoding/LatinStringIO.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Encoding/LatinStringIO.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Encoding/LatinStringIO.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,107 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Encoding; +using Db4objects.Db4o.Marshall; +using Sharpen; + +namespace Db4objects.Db4o.Internal.Encoding +{ + /// + public class LatinStringIO + { + public virtual byte[] Bytes(ByteArrayBuffer buffer) + { + int len = buffer.ReadInt(); + len = BytesPerChar() * len; + byte[] res = new byte[len]; + System.Array.Copy(buffer._buffer, buffer._offset, res, 0, len); + return res; + } + + protected virtual int BytesPerChar() + { + return 1; + } + + public virtual byte EncodingByte() + { + return BuiltInStringEncoding.EncodingByteForEncoding(new LatinStringEncoding()); + } + + public virtual int Length(string str) + { + return str.Length + Const4.ObjectLength + Const4.IntLength; + } + + public virtual string Read(IReadBuffer buffer, int length) + { + char[] chars = new char[length]; + for (int ii = 0; ii < length; ii++) + { + chars[ii] = (char)(buffer.ReadByte() & unchecked((int)(0xff))); + } + return new string(chars, 0, length); + } + + public virtual string Read(byte[] bytes) + { + char[] chars = new char[bytes.Length]; + for (int i = 0; i < bytes.Length; i++) + { + chars[i] = (char)(bytes[i] & unchecked((int)(0xff))); + } + return new string(chars, 0, bytes.Length); + } + + public virtual string ReadLengthAndString(IReadBuffer buffer) + { + int length = buffer.ReadInt(); + if (length == 0) + { + return string.Empty; + } + return Read(buffer, length); + } + + public virtual int ShortLength(string str) + { + return str.Length + Const4.IntLength; + } + + public virtual void Write(IWriteBuffer buffer, string str) + { + int length = str.Length; + char[] chars = new char[length]; + Sharpen.Runtime.GetCharsForString(str, 0, length, chars, 0); + for (int i = 0; i < length; i++) + { + buffer.WriteByte((byte)(chars[i] & unchecked((int)(0xff)))); + } + } + + public virtual byte[] Write(string str) + { + int length = str.Length; + char[] chars = new char[length]; + Sharpen.Runtime.GetCharsForString(str, 0, length, chars, 0); + byte[] bytes = new byte[length]; + for (int i = 0; i < length; i++) + { + bytes[i] = (byte)(chars[i] & unchecked((int)(0xff))); + } + return bytes; + } + + public virtual void WriteLengthAndString(IWriteBuffer buffer, string str) + { + if (str == null) + { + buffer.WriteInt(0); + return; + } + buffer.WriteInt(str.Length); + Write(buffer, str); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Encoding/UnicodeStringEncoding.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Encoding/UnicodeStringEncoding.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Encoding/UnicodeStringEncoding.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Encoding/UnicodeStringEncoding.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,16 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Config.Encoding; +using Db4objects.Db4o.Internal.Encoding; + +namespace Db4objects.Db4o.Internal.Encoding +{ + /// + public class UnicodeStringEncoding : LatinStringEncoding + { + protected override LatinStringIO CreateStringIo(IStringEncoding encoding) + { + return new UnicodeStringIO(); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Encoding/UnicodeStringIO.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Encoding/UnicodeStringIO.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Encoding/UnicodeStringIO.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Encoding/UnicodeStringIO.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,83 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Encoding; +using Db4objects.Db4o.Marshall; + +namespace Db4objects.Db4o.Internal.Encoding +{ + /// + public sealed class UnicodeStringIO : LatinStringIO + { + protected override int BytesPerChar() + { + return 2; + } + + public override byte EncodingByte() + { + return BuiltInStringEncoding.EncodingByteForEncoding(new UnicodeStringEncoding()); + } + + public override int Length(string str) + { + return (str.Length * 2) + Const4.ObjectLength + Const4.IntLength; + } + + public override string Read(IReadBuffer buffer, int length) + { + char[] chars = new char[length]; + for (int ii = 0; ii < length; ii++) + { + chars[ii] = (char)((buffer.ReadByte() & unchecked((int)(0xff))) | ((buffer.ReadByte + () & unchecked((int)(0xff))) << 8)); + } + return new string(chars, 0, length); + } + + public override string Read(byte[] bytes) + { + int length = bytes.Length / 2; + char[] chars = new char[length]; + int j = 0; + for (int ii = 0; ii < length; ii++) + { + chars[ii] = (char)((bytes[j++] & unchecked((int)(0xff))) | ((bytes[j++] & unchecked( + (int)(0xff))) << 8)); + } + return new string(chars, 0, length); + } + + public override int ShortLength(string str) + { + return (str.Length * 2) + Const4.IntLength; + } + + public override void Write(IWriteBuffer buffer, string str) + { + int length = str.Length; + char[] chars = new char[length]; + Sharpen.Runtime.GetCharsForString(str, 0, length, chars, 0); + for (int i = 0; i < length; i++) + { + buffer.WriteByte((byte)(chars[i] & unchecked((int)(0xff)))); + buffer.WriteByte((byte)(chars[i] >> 8)); + } + } + + public override byte[] Write(string str) + { + int length = str.Length; + char[] chars = new char[length]; + Sharpen.Runtime.GetCharsForString(str, 0, length, chars, 0); + byte[] bytes = new byte[length * 2]; + int j = 0; + for (int i = 0; i < length; i++) + { + bytes[j++] = (byte)(chars[i] & unchecked((int)(0xff))); + bytes[j++] = (byte)(chars[i] >> 8); + } + return bytes; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/EventDispatchers.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/EventDispatchers.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/EventDispatchers.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/EventDispatchers.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,182 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Reflect; + +namespace Db4objects.Db4o.Internal +{ + /// + public sealed class EventDispatchers + { + private sealed class _IEventDispatcher_11 : IEventDispatcher + { + public _IEventDispatcher_11() + { + } + + public bool Dispatch(Transaction trans, object obj, int eventID) + { + return true; + } + + public bool HasEventRegistered(int eventID) + { + return false; + } + } + + public static readonly IEventDispatcher NullDispatcher = new _IEventDispatcher_11 + (); + + private static readonly string[] events = new string[] { "objectCanDelete", "objectOnDelete" + , "objectOnActivate", "objectOnDeactivate", "objectOnNew", "objectOnUpdate", "objectCanActivate" + , "objectCanDeactivate", "objectCanNew", "objectCanUpdate" }; + + internal const int CanDelete = 0; + + internal const int Delete = 1; + + internal const int Activate = 2; + + internal const int Deactivate = 3; + + internal const int New = 4; + + public const int Update = 5; + + internal const int CanActivate = 6; + + internal const int CanDeactivate = 7; + + internal const int CanNew = 8; + + internal const int CanUpdate = 9; + + internal const int DeleteCount = 2; + + internal const int Count = 10; + + private class EventDispatcherImpl : IEventDispatcher + { + private readonly IReflectMethod[] methods; + + public EventDispatcherImpl(IReflectMethod[] methods_) + { + methods = methods_; + } + + public virtual bool HasEventRegistered(int eventID) + { + return methods[eventID] != null; + } + + public virtual bool Dispatch(Transaction trans, object obj, int eventID) + { + if (methods[eventID] == null) + { + return true; + } + object[] parameters = new object[] { trans.ObjectContainer() }; + ObjectContainerBase container = trans.Container(); + int stackDepth = container.StackDepth(); + int topLevelCallId = container.TopLevelCallId(); + container.StackDepth(0); + try + { + object res = methods[eventID].Invoke(obj, parameters); + if (res is bool) + { + return ((bool)res); + } + } + finally + { + container.StackDepth(stackDepth); + container.TopLevelCallId(topLevelCallId); + } + return true; + } + } + + public static IEventDispatcher ForClass(ObjectContainerBase container, IReflectClass + classReflector) + { + if (container == null || classReflector == null) + { + throw new ArgumentNullException(); + } + if (!container.DispatchsEvents()) + { + return NullDispatcher; + } + int count = EventCountFor(container); + if (count == 0) + { + return NullDispatcher; + } + IReflectMethod[] handlers = EventHandlerTableFor(container, classReflector); + return HasEventHandler(handlers) ? new EventDispatchers.EventDispatcherImpl(handlers + ) : NullDispatcher; + } + + private static IReflectMethod[] EventHandlerTableFor(ObjectContainerBase container + , IReflectClass classReflector) + { + IReflectClass[] parameterClasses = new IReflectClass[] { container._handlers.IclassObjectcontainer + }; + IReflectMethod[] methods = new IReflectMethod[Count]; + for (int i = Count - 1; i >= 0; i--) + { + IReflectMethod method = classReflector.GetMethod(events[i], parameterClasses); + if (null == method) + { + method = classReflector.GetMethod(ToPascalCase(events[i]), parameterClasses); + } + if (method != null) + { + methods[i] = method; + } + } + return methods; + } + + private static bool HasEventHandler(IReflectMethod[] methods) + { + return Iterators.Any(Iterators.Iterate(methods), new _IPredicate4_118()); + } + + private sealed class _IPredicate4_118 : IPredicate4 + { + public _IPredicate4_118() + { + } + + public bool Match(object candidate) + { + return candidate != null; + } + } + + private static int EventCountFor(ObjectContainerBase container) + { + CallBackMode callbackMode = container.ConfigImpl.CallbackMode(); + if (callbackMode == CallBackMode.All) + { + return Count; + } + if (callbackMode == CallBackMode.DeleteOnly) + { + return DeleteCount; + } + return 0; + } + + private static string ToPascalCase(string name) + { + return Sharpen.Runtime.Substring(name, 0, 1).ToUpper() + Sharpen.Runtime.Substring + (name, 1); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Events/EventRegistryImpl.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Events/EventRegistryImpl.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Events/EventRegistryImpl.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Events/EventRegistryImpl.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,732 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using Db4objects.Db4o; +using Db4objects.Db4o.Events; +using Db4objects.Db4o.Ext; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Callbacks; +using Db4objects.Db4o.Internal.Events; +using Db4objects.Db4o.Query; +using Sharpen.Lang; + +namespace Db4objects.Db4o.Internal.Events +{ + /// + public class EventRegistryImpl : ICallbacks, IEventRegistry + { + protected System.EventHandler _queryStarted; + + protected System.EventHandler _queryFinished; + + protected System.EventHandler + _creating; + + protected System.EventHandler + _activating; + + protected System.EventHandler + _updating; + + protected System.EventHandler + _deleting; + + protected System.EventHandler + _deactivating; + + protected System.EventHandler _created; + + protected System.EventHandler _activated; + + protected System.EventHandler _updated; + + protected System.EventHandler _deleted; + + protected System.EventHandler _deactivated; + + protected System.EventHandler _committing; + + protected System.EventHandler _committed; + + protected System.EventHandler _instantiated; + + protected System.EventHandler _classRegistered; + + protected System.EventHandler _closing; + + protected System.EventHandler _opened; + + // Callbacks implementation + public virtual void QueryOnFinished(Transaction transaction, IQuery query) + { + if (!(_queryFinished != null)) + { + return; + } + WithExceptionHandling(new _IRunnable_50(this, transaction, query)); + } + + private sealed class _IRunnable_50 : IRunnable + { + public _IRunnable_50(EventRegistryImpl _enclosing, Transaction transaction, IQuery + query) + { + this._enclosing = _enclosing; + this.transaction = transaction; + this.query = query; + } + + public void Run() + { + if (null != this._enclosing._queryFinished) this._enclosing._queryFinished(null, + new QueryEventArgs(transaction, query)); + } + + private readonly EventRegistryImpl _enclosing; + + private readonly Transaction transaction; + + private readonly IQuery query; + } + + public virtual void QueryOnStarted(Transaction transaction, IQuery query) + { + if (!(_queryStarted != null)) + { + return; + } + WithExceptionHandling(new _IRunnable_59(this, transaction, query)); + } + + private sealed class _IRunnable_59 : IRunnable + { + public _IRunnable_59(EventRegistryImpl _enclosing, Transaction transaction, IQuery + query) + { + this._enclosing = _enclosing; + this.transaction = transaction; + this.query = query; + } + + public void Run() + { + if (null != this._enclosing._queryStarted) this._enclosing._queryStarted(null, new + QueryEventArgs(transaction, query)); + } + + private readonly EventRegistryImpl _enclosing; + + private readonly Transaction transaction; + + private readonly IQuery query; + } + + public virtual bool ObjectCanNew(Transaction transaction, object obj) + { + return TriggerCancellableObjectEventArgsInCallback(transaction, _creating, null, + obj); + } + + public virtual bool ObjectCanActivate(Transaction transaction, object obj) + { + return TriggerCancellableObjectEventArgsInCallback(transaction, _activating, null + , obj); + } + + public virtual bool ObjectCanUpdate(Transaction transaction, IObjectInfo objectInfo + ) + { + return TriggerCancellableObjectEventArgsInCallback(transaction, _updating, objectInfo + , objectInfo.GetObject()); + } + + public virtual bool ObjectCanDelete(Transaction transaction, IObjectInfo objectInfo + ) + { + return TriggerCancellableObjectEventArgsInCallback(transaction, _deleting, objectInfo + , objectInfo.GetObject()); + } + + public virtual bool ObjectCanDeactivate(Transaction transaction, IObjectInfo objectInfo + ) + { + return TriggerCancellableObjectEventArgsInCallback(transaction, _deactivating, objectInfo + , objectInfo.GetObject()); + } + + public virtual void ObjectOnActivate(Transaction transaction, IObjectInfo obj) + { + TriggerObjectInfoEventInCallback(transaction, _activated, obj); + } + + public virtual void ObjectOnNew(Transaction transaction, IObjectInfo obj) + { + TriggerObjectInfoEventInCallback(transaction, _created, obj); + } + + public virtual void ObjectOnUpdate(Transaction transaction, IObjectInfo obj) + { + TriggerObjectInfoEventInCallback(transaction, _updated, obj); + } + + public virtual void ObjectOnDelete(Transaction transaction, IObjectInfo obj) + { + TriggerObjectInfoEventInCallback(transaction, _deleted, obj); + } + + public virtual void ClassOnRegistered(ClassMetadata clazz) + { + if (!(_classRegistered != null)) + { + return; + } + WithExceptionHandling(new _IRunnable_104(this, clazz)); + } + + private sealed class _IRunnable_104 : IRunnable + { + public _IRunnable_104(EventRegistryImpl _enclosing, ClassMetadata clazz) + { + this._enclosing = _enclosing; + this.clazz = clazz; + } + + public void Run() + { + if (null != this._enclosing._classRegistered) this._enclosing._classRegistered(null, + new ClassEventArgs(clazz)); + } + + private readonly EventRegistryImpl _enclosing; + + private readonly ClassMetadata clazz; + } + + public virtual void ObjectOnDeactivate(Transaction transaction, IObjectInfo obj) + { + TriggerObjectInfoEventInCallback(transaction, _deactivated, obj); + } + + public virtual void ObjectOnInstantiate(Transaction transaction, IObjectInfo obj) + { + TriggerObjectInfoEventInCallback(transaction, _instantiated, obj); + } + + public virtual void CommitOnStarted(Transaction transaction, CallbackObjectInfoCollections + objectInfoCollections) + { + if (!(_committing != null)) + { + return; + } + WithExceptionHandlingInCallback(new _IRunnable_121(this, transaction, objectInfoCollections + )); + } + + private sealed class _IRunnable_121 : IRunnable + { + public _IRunnable_121(EventRegistryImpl _enclosing, Transaction transaction, CallbackObjectInfoCollections + objectInfoCollections) + { + this._enclosing = _enclosing; + this.transaction = transaction; + this.objectInfoCollections = objectInfoCollections; + } + + public void Run() + { + if (null != this._enclosing._committing) this._enclosing._committing(null, new CommitEventArgs + (transaction, objectInfoCollections, false)); + } + + private readonly EventRegistryImpl _enclosing; + + private readonly Transaction transaction; + + private readonly CallbackObjectInfoCollections objectInfoCollections; + } + + public virtual void CommitOnCompleted(Transaction transaction, CallbackObjectInfoCollections + objectInfoCollections, bool isOwnCommit) + { + if (!(_committed != null)) + { + return; + } + WithExceptionHandlingInCallback(new _IRunnable_132(this, transaction, objectInfoCollections + , isOwnCommit)); + } + + private sealed class _IRunnable_132 : IRunnable + { + public _IRunnable_132(EventRegistryImpl _enclosing, Transaction transaction, CallbackObjectInfoCollections + objectInfoCollections, bool isOwnCommit) + { + this._enclosing = _enclosing; + this.transaction = transaction; + this.objectInfoCollections = objectInfoCollections; + this.isOwnCommit = isOwnCommit; + } + + public void Run() + { + if (null != this._enclosing._committed) this._enclosing._committed(null, new CommitEventArgs + (transaction, objectInfoCollections, isOwnCommit)); + } + + private readonly EventRegistryImpl _enclosing; + + private readonly Transaction transaction; + + private readonly CallbackObjectInfoCollections objectInfoCollections; + + private readonly bool isOwnCommit; + } + + public virtual void CloseOnStarted(IObjectContainer container) + { + if (!(_closing != null)) + { + return; + } + WithExceptionHandlingInCallback(new _IRunnable_143(this, container)); + } + + private sealed class _IRunnable_143 : IRunnable + { + public _IRunnable_143(EventRegistryImpl _enclosing, IObjectContainer container) + { + this._enclosing = _enclosing; + this.container = container; + } + + public void Run() + { + if (null != this._enclosing._closing) this._enclosing._closing(null, new ObjectContainerEventArgs + (container)); + } + + private readonly EventRegistryImpl _enclosing; + + private readonly IObjectContainer container; + } + + public virtual void OpenOnFinished(IObjectContainer container) + { + if (!(_opened != null)) + { + return; + } + WithExceptionHandlingInCallback(new _IRunnable_154(this, container)); + } + + private sealed class _IRunnable_154 : IRunnable + { + public _IRunnable_154(EventRegistryImpl _enclosing, IObjectContainer container) + { + this._enclosing = _enclosing; + this.container = container; + } + + public void Run() + { + if (null != this._enclosing._opened) this._enclosing._opened(null, new ObjectContainerEventArgs + (container)); + } + + private readonly EventRegistryImpl _enclosing; + + private readonly IObjectContainer container; + } + + public virtual event System.EventHandler QueryFinished + { + add + { + _queryFinished = (System.EventHandler)System.Delegate.Combine + (_queryFinished, value); + } + remove + { + _queryFinished = (System.EventHandler)System.Delegate.Remove + (_queryFinished, value); + } + } + + public virtual event System.EventHandler QueryStarted + { + add + { + _queryStarted = (System.EventHandler)System.Delegate.Combine + (_queryStarted, value); + } + remove + { + _queryStarted = (System.EventHandler)System.Delegate.Remove + (_queryStarted, value); + } + } + + public virtual event System.EventHandler + Creating + { + add + { + _creating = (System.EventHandler + )System.Delegate.Combine(_creating, value); + } + remove + { + _creating = (System.EventHandler + )System.Delegate.Remove(_creating, value); + } + } + + public virtual event System.EventHandler + Activating + { + add + { + _activating = (System.EventHandler + )System.Delegate.Combine(_activating, value); + } + remove + { + _activating = (System.EventHandler + )System.Delegate.Remove(_activating, value); + } + } + + public virtual event System.EventHandler + Updating + { + add + { + _updating = (System.EventHandler + )System.Delegate.Combine(_updating, value); + } + remove + { + _updating = (System.EventHandler + )System.Delegate.Remove(_updating, value); + } + } + + public virtual event System.EventHandler + Deleting + { + add + { + _deleting = (System.EventHandler + )System.Delegate.Combine(_deleting, value); + } + remove + { + _deleting = (System.EventHandler + )System.Delegate.Remove(_deleting, value); + } + } + + public virtual event System.EventHandler + Deactivating + { + add + { + _deactivating = (System.EventHandler + )System.Delegate.Combine(_deactivating, value); + } + remove + { + _deactivating = (System.EventHandler + )System.Delegate.Remove(_deactivating, value); + } + } + + public virtual event System.EventHandler + Created + { + add + { + _created = (System.EventHandler)System.Delegate.Combine + (_created, value); + } + remove + { + _created = (System.EventHandler)System.Delegate.Remove + (_created, value); + } + } + + public virtual event System.EventHandler + Activated + { + add + { + _activated = (System.EventHandler)System.Delegate.Combine + (_activated, value); + } + remove + { + _activated = (System.EventHandler)System.Delegate.Remove + (_activated, value); + } + } + + public virtual event System.EventHandler + Updated + { + add + { + _updated = (System.EventHandler)System.Delegate.Combine + (_updated, value); + } + remove + { + _updated = (System.EventHandler)System.Delegate.Remove + (_updated, value); + } + } + + public virtual event System.EventHandler + Deleted + { + add + { + _deleted = (System.EventHandler)System.Delegate.Combine + (_deleted, value); + } + remove + { + _deleted = (System.EventHandler)System.Delegate.Remove + (_deleted, value); + } + } + + public virtual event System.EventHandler + Deactivated + { + add + { + _deactivated = (System.EventHandler)System.Delegate.Combine + (_deactivated, value); + } + remove + { + _deactivated = (System.EventHandler)System.Delegate.Remove + (_deactivated, value); + } + } + + public virtual event System.EventHandler + Committing + { + add + { + _committing = (System.EventHandler)System.Delegate.Combine + (_committing, value); + } + remove + { + _committing = (System.EventHandler)System.Delegate.Remove + (_committing, value); + } + } + + public virtual event System.EventHandler + Committed + { + add + { + _committed = (System.EventHandler)System.Delegate.Combine + (_committed, value); + OnCommittedListenerAdded(); + } + remove + { + _committed = (System.EventHandler)System.Delegate.Remove + (_committed, value); + } + } + + public virtual event System.EventHandler ClassRegistered + { + add + { + _classRegistered = (System.EventHandler)System.Delegate.Combine + (_classRegistered, value); + } + remove + { + _classRegistered = (System.EventHandler)System.Delegate.Remove + (_classRegistered, value); + } + } + + public virtual event System.EventHandler + Instantiated + { + add + { + _instantiated = (System.EventHandler) + System.Delegate.Combine(_instantiated, value); + } + remove + { + _instantiated = (System.EventHandler) + System.Delegate.Remove(_instantiated, value); + } + } + + public virtual event System.EventHandler + Closing + { + add + { + _closing = (System.EventHandler) + System.Delegate.Combine(_closing, value); + } + remove + { + _closing = (System.EventHandler) + System.Delegate.Remove(_closing, value); + } + } + + protected virtual void OnCommittedListenerAdded() + { + } + + // do nothing + public virtual bool CaresAboutCommitting() + { + return (_committing != null); + } + + public virtual bool CaresAboutCommitted() + { + return (_committed != null); + } + + public virtual bool CaresAboutDeleting() + { + return (_deleting != null); + } + + public virtual bool CaresAboutDeleted() + { + return (_deleted != null); + } + + internal virtual bool TriggerCancellableObjectEventArgsInCallback(Transaction transaction + , System.EventHandler e, IObjectInfo objectInfo, object + o) + { + if (!(e != null)) + { + return true; + } + CancellableObjectEventArgs args = new CancellableObjectEventArgs(transaction, objectInfo + , o); + WithExceptionHandlingInCallback(new _IRunnable_258(e, args)); + return !args.IsCancelled; + } + + private sealed class _IRunnable_258 : IRunnable + { + public _IRunnable_258(System.EventHandler e, CancellableObjectEventArgs + args) + { + this.e = e; + this.args = args; + } + + public void Run() + { + if (null != e) e(null, args); + } + + private readonly System.EventHandler e; + + private readonly CancellableObjectEventArgs args; + } + + internal virtual void TriggerObjectInfoEventInCallback(Transaction transaction, System.EventHandler< + ObjectInfoEventArgs> e, IObjectInfo o) + { + if (!(e != null)) + { + return; + } + WithExceptionHandlingInCallback(new _IRunnable_270(e, transaction, o)); + } + + private sealed class _IRunnable_270 : IRunnable + { + public _IRunnable_270(System.EventHandler e, Transaction transaction + , IObjectInfo o) + { + this.e = e; + this.transaction = transaction; + this.o = o; + } + + public void Run() + { + if (null != e) e(null, new ObjectInfoEventArgs(transaction, o)); + } + + private readonly System.EventHandler e; + + private readonly Transaction transaction; + + private readonly IObjectInfo o; + } + + private void WithExceptionHandlingInCallback(IRunnable runnable) + { + try + { + InCallback.Run(runnable); + } + catch (Db4oException e) + { + throw; + } + catch (Exception x) + { + throw new EventException(x); + } + } + + private void WithExceptionHandling(IRunnable runnable) + { + try + { + runnable.Run(); + } + catch (Db4oException e) + { + throw; + } + catch (Exception x) + { + throw new EventException(x); + } + } + + public virtual event System.EventHandler + Opened + { + add + { + _opened = (System.EventHandler)System.Delegate.Combine + (_opened, value); + } + remove + { + _opened = (System.EventHandler)System.Delegate.Remove + (_opened, value); + } + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Exceptions4.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Exceptions4.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Exceptions4.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Exceptions4.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,68 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using Db4objects.Db4o; +using Db4objects.Db4o.Ext; + +namespace Db4objects.Db4o.Internal +{ + /// + public class Exceptions4 + { + public static void ThrowRuntimeException(int code) + { + ThrowRuntimeException(code, null, null); + } + + public static void ThrowRuntimeException(int code, Exception cause) + { + ThrowRuntimeException(code, null, cause); + } + + public static void ThrowRuntimeException(int code, string msg) + { + ThrowRuntimeException(code, msg, null); + } + + public static void ThrowRuntimeException(int code, string msg, Exception cause) + { + ThrowRuntimeException(code, msg, cause, true); + } + + [System.ObsoleteAttribute] + public static void ThrowRuntimeException(int code, string msg, Exception cause, bool + doLog) + { + if (doLog) + { + Db4objects.Db4o.Internal.Messages.LogErr(Db4oFactory.Configure(), code, msg, cause + ); + } + throw new Db4oException(Db4objects.Db4o.Internal.Messages.Get(code, msg)); + } + + /// + public static void CatchAllExceptDb4oException(Exception exc) + { + if (exc is Db4oException) + { + throw (Db4oException)exc; + } + } + + public static Exception ShouldNeverBeCalled() + { + throw new Exception(); + } + + public static void ShouldNeverHappen() + { + throw new Exception(); + } + + public static Exception VirtualException() + { + throw new Exception(); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/ExternalObjectContainer.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/ExternalObjectContainer.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/ExternalObjectContainer.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/ExternalObjectContainer.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,193 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using Db4objects.Db4o; +using Db4objects.Db4o.Config; +using Db4objects.Db4o.Ext; +using Db4objects.Db4o.IO; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Activation; +using Db4objects.Db4o.Query; + +namespace Db4objects.Db4o.Internal +{ + /// + public abstract class ExternalObjectContainer : ObjectContainerBase + { + public ExternalObjectContainer(IConfiguration config) : base(config) + { + } + + public sealed override void Activate(object obj) + { + Activate(null, obj); + } + + /// + public sealed override void Activate(object obj, int depth) + { + Activate(null, obj, ActivationDepthProvider().ActivationDepth(depth, ActivationMode + .Activate)); + } + + public sealed override void Deactivate(object obj) + { + Deactivate(null, obj); + } + + /// + /// + public sealed override void Bind(object obj, long id) + { + Bind(null, obj, id); + } + + /// + /// + public sealed override void Commit() + { + Commit(null); + } + + /// + public sealed override void Deactivate(object obj, int depth) + { + Deactivate(null, obj, depth); + } + + public sealed override void Delete(object a_object) + { + Delete(null, a_object); + } + + public override object Descend(object obj, string[] path) + { + return Descend(null, obj, path); + } + + public override IExtObjectContainer Ext() + { + return this; + } + + /// + public sealed override IObjectSet QueryByExample(object template) + { + return QueryByExample(null, template); + } + + /// + /// + public sealed override object GetByID(long id) + { + return GetByID(null, id); + } + + public sealed override object GetByUUID(Db4oUUID uuid) + { + return GetByUUID(null, uuid); + } + + public sealed override long GetID(object obj) + { + return GetID(null, obj); + } + + public sealed override IObjectInfo GetObjectInfo(object obj) + { + return GetObjectInfo(null, obj); + } + + public override bool IsActive(object obj) + { + return IsActive(null, obj); + } + + public override bool IsCached(long id) + { + return IsCached(null, id); + } + + public override bool IsStored(object obj) + { + return IsStored(null, obj); + } + + /// + public sealed override object PeekPersisted(object obj, int depth, bool committed + ) + { + return PeekPersisted(null, obj, ActivationDepthProvider().ActivationDepth(depth, + ActivationMode.Peek), committed); + } + + public sealed override void Purge(object obj) + { + Purge(null, obj); + } + + public override IQuery Query() + { + return Query((Transaction)null); + } + + public sealed override IObjectSet Query(Type clazz) + { + return QueryByExample(clazz); + } + + public sealed override IObjectSet Query(Predicate predicate) + { + return Query(predicate, (IQueryComparator)null); + } + + public sealed override IObjectSet Query(Predicate predicate, IQueryComparator comparator + ) + { + return Query(null, predicate, comparator); + } + + public sealed override void Refresh(object obj, int depth) + { + Refresh(null, obj, depth); + } + + public sealed override void Rollback() + { + Rollback(null); + } + + /// + /// + public sealed override void Store(object obj) + { + Store(obj, Const4.Unspecified); + } + + /// + /// + public sealed override void Store(object obj, int depth) + { + Store(null, obj, depth == Const4.Unspecified ? (IUpdateDepth)UpdateDepthProvider( + ).Unspecified(NullModifiedObjectQuery.Instance) : (IUpdateDepth)UpdateDepthProvider + ().ForDepth(depth)); + } + + public sealed override IStoredClass StoredClass(object clazz) + { + return StoredClass(null, clazz); + } + + public override IStoredClass[] StoredClasses() + { + return StoredClasses(null); + } + + /// + /// + /// + public abstract override void Backup(IStorage targetStorage, string path); + + public abstract override Db4oDatabase Identity(); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Fieldindex/AndIndexedLeaf.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Fieldindex/AndIndexedLeaf.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Fieldindex/AndIndexedLeaf.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Fieldindex/AndIndexedLeaf.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,15 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal.Fieldindex; +using Db4objects.Db4o.Internal.Query.Processor; + +namespace Db4objects.Db4o.Internal.Fieldindex +{ + public class AndIndexedLeaf : JoinedLeaf + { + public AndIndexedLeaf(QCon constraint, IIndexedNodeWithRange leaf1, IIndexedNodeWithRange + leaf2) : base(constraint, leaf1, leaf1.GetRange().Intersect(leaf2.GetRange())) + { + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Fieldindex/FieldIndexProcessor.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Fieldindex/FieldIndexProcessor.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Fieldindex/FieldIndexProcessor.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Fieldindex/FieldIndexProcessor.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,75 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System.Collections; +using Db4objects.Db4o.Internal.Fieldindex; +using Db4objects.Db4o.Internal.Query.Processor; + +namespace Db4objects.Db4o.Internal.Fieldindex +{ + public class FieldIndexProcessor + { + private readonly QCandidates _candidates; + + public FieldIndexProcessor(QCandidates candidates) + { + _candidates = candidates; + } + + public virtual FieldIndexProcessorResult Run() + { + IIndexedNode bestIndex = SelectBestIndex(); + if (null == bestIndex) + { + return FieldIndexProcessorResult.NoIndexFound; + } + if (bestIndex.ResultSize() > 0) + { + IIndexedNode resolved = ResolveFully(bestIndex); + if (null == resolved) + { + return FieldIndexProcessorResult.NoIndexFound; + } + resolved.MarkAsBestIndex(); + return new FieldIndexProcessorResult(resolved); + } + return FieldIndexProcessorResult.FoundIndexButNoMatch; + } + + private IIndexedNode ResolveFully(IIndexedNode bestIndex) + { + if (null == bestIndex) + { + return null; + } + if (bestIndex.IsResolved()) + { + return bestIndex; + } + return ResolveFully(bestIndex.Resolve()); + } + + public virtual IIndexedNode SelectBestIndex() + { + IEnumerator i = CollectIndexedNodes(); + if (!i.MoveNext()) + { + return null; + } + IIndexedNode best = (IIndexedNode)i.Current; + while (i.MoveNext()) + { + IIndexedNode leaf = (IIndexedNode)i.Current; + if (leaf.ResultSize() < best.ResultSize()) + { + best = leaf; + } + } + return best; + } + + public virtual IEnumerator CollectIndexedNodes() + { + return new IndexedNodeCollector(_candidates).GetNodes(); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Fieldindex/FieldIndexProcessorResult.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Fieldindex/FieldIndexProcessorResult.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Fieldindex/FieldIndexProcessorResult.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Fieldindex/FieldIndexProcessorResult.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,76 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System.Collections; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Btree; +using Db4objects.Db4o.Internal.Fieldindex; +using Db4objects.Db4o.Internal.Query.Processor; + +namespace Db4objects.Db4o.Internal.Fieldindex +{ + public class FieldIndexProcessorResult + { + public static readonly Db4objects.Db4o.Internal.Fieldindex.FieldIndexProcessorResult + NoIndexFound = new Db4objects.Db4o.Internal.Fieldindex.FieldIndexProcessorResult + (null); + + public static readonly Db4objects.Db4o.Internal.Fieldindex.FieldIndexProcessorResult + FoundIndexButNoMatch = new Db4objects.Db4o.Internal.Fieldindex.FieldIndexProcessorResult + (null); + + private readonly IIndexedNode _indexedNode; + + public FieldIndexProcessorResult(IIndexedNode indexedNode) + { + _indexedNode = indexedNode; + } + + public virtual Tree ToQCandidate(QCandidates candidates) + { + return TreeInt.ToQCandidate(ToTreeInt(), candidates); + } + + public virtual TreeInt ToTreeInt() + { + if (FoundMatch()) + { + return _indexedNode.ToTreeInt(); + } + return null; + } + + public virtual bool FoundMatch() + { + return FoundIndex() && !NoMatch(); + } + + public virtual bool FoundIndex() + { + return this != NoIndexFound; + } + + public virtual bool NoMatch() + { + return this == FoundIndexButNoMatch; + } + + public virtual IEnumerator IterateIDs() + { + return new _MappingIterator_46(_indexedNode.GetEnumerator()); + } + + private sealed class _MappingIterator_46 : MappingIterator + { + public _MappingIterator_46(IEnumerator baseArg1) : base(baseArg1) + { + } + + protected override object Map(object current) + { + IFieldIndexKey composite = (IFieldIndexKey)current; + return composite.ParentID(); + } + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Fieldindex/IIndexedNode.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Fieldindex/IIndexedNode.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Fieldindex/IIndexedNode.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Fieldindex/IIndexedNode.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,25 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System.Collections; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Btree; +using Db4objects.Db4o.Internal.Fieldindex; + +namespace Db4objects.Db4o.Internal.Fieldindex +{ + public interface IIndexedNode : IEnumerable + { + bool IsResolved(); + + IIndexedNode Resolve(); + + BTree GetIndex(); + + int ResultSize(); + + //FIXME: do we need this? + TreeInt ToTreeInt(); + + void MarkAsBestIndex(); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Fieldindex/IIndexedNodeWithRange.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Fieldindex/IIndexedNodeWithRange.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Fieldindex/IIndexedNodeWithRange.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Fieldindex/IIndexedNodeWithRange.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,12 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal.Btree; +using Db4objects.Db4o.Internal.Fieldindex; + +namespace Db4objects.Db4o.Internal.Fieldindex +{ + public interface IIndexedNodeWithRange : IIndexedNode + { + IBTreeRange GetRange(); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Fieldindex/IndexedLeaf.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Fieldindex/IndexedLeaf.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Fieldindex/IndexedLeaf.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Fieldindex/IndexedLeaf.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,68 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System.Collections; +using Db4objects.Db4o.Internal.Btree; +using Db4objects.Db4o.Internal.Fieldindex; +using Db4objects.Db4o.Internal.Query.Processor; + +namespace Db4objects.Db4o.Internal.Fieldindex +{ + /// + public class IndexedLeaf : IndexedNodeBase, IIndexedNodeWithRange + { + private readonly IBTreeRange _range; + + public IndexedLeaf(QConObject qcon) : base(qcon) + { + _range = Search(); + } + + private IBTreeRange Search() + { + IBTreeRange range = Search(Constraint().GetObject()); + QEBitmap bitmap = QEBitmap.ForQE(Constraint().Evaluator()); + if (bitmap.TakeGreater()) + { + if (bitmap.TakeEqual()) + { + return range.ExtendToLast(); + } + IBTreeRange greater = range.Greater(); + if (bitmap.TakeSmaller()) + { + return greater.Union(range.Smaller()); + } + return greater; + } + if (bitmap.TakeSmaller()) + { + if (bitmap.TakeEqual()) + { + return range.ExtendToFirst(); + } + return range.Smaller(); + } + return range; + } + + public override int ResultSize() + { + return _range.Size(); + } + + public override IEnumerator GetEnumerator() + { + return _range.Keys(); + } + + public virtual IBTreeRange GetRange() + { + return _range; + } + + public override void MarkAsBestIndex() + { + _constraint.SetProcessedByIndex(); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Fieldindex/IndexedNodeBase.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Fieldindex/IndexedNodeBase.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Fieldindex/IndexedNodeBase.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Fieldindex/IndexedNodeBase.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,92 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using System.Collections; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Btree; +using Db4objects.Db4o.Internal.Fieldindex; +using Db4objects.Db4o.Internal.Query.Processor; + +namespace Db4objects.Db4o.Internal.Fieldindex +{ + public abstract class IndexedNodeBase : IIndexedNode + { + protected readonly QConObject _constraint; + + public IndexedNodeBase(QConObject qcon) + { + if (null == qcon) + { + throw new ArgumentNullException(); + } + if (null == qcon.GetField()) + { + throw new ArgumentException(); + } + _constraint = qcon; + } + + public virtual TreeInt ToTreeInt() + { + return AddToTree(null, this); + } + + public BTree GetIndex() + { + return GetYapField().GetIndex(Transaction()); + } + + private FieldMetadata GetYapField() + { + return _constraint.GetField().GetFieldMetadata(); + } + + public virtual QCon Constraint() + { + return _constraint; + } + + public virtual bool IsResolved() + { + QCon parent = Constraint().Parent(); + return null == parent || !parent.HasParent(); + } + + public virtual IBTreeRange Search(object value) + { + return GetYapField().Search(Transaction(), value); + } + + public static TreeInt AddToTree(TreeInt tree, IIndexedNode node) + { + IEnumerator i = node.GetEnumerator(); + while (i.MoveNext()) + { + IFieldIndexKey composite = (IFieldIndexKey)i.Current; + tree = (TreeInt)((TreeInt)Tree.Add(tree, new TreeInt(composite.ParentID()))); + } + return tree; + } + + public virtual IIndexedNode Resolve() + { + if (IsResolved()) + { + return null; + } + return IndexedPath.NewParentPath(this, Constraint()); + } + + private Db4objects.Db4o.Internal.Transaction Transaction() + { + return Constraint().Transaction(); + } + + public abstract IEnumerator GetEnumerator(); + + public abstract void MarkAsBestIndex(); + + public abstract int ResultSize(); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Fieldindex/IndexedNodeCollector.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Fieldindex/IndexedNodeCollector.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Fieldindex/IndexedNodeCollector.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Fieldindex/IndexedNodeCollector.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,354 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System.Collections; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal.Fieldindex; +using Db4objects.Db4o.Internal.Query.Processor; + +namespace Db4objects.Db4o.Internal.Fieldindex +{ + public class IndexedNodeCollector + { + private readonly Collection4 _nodes; + + private readonly Hashtable4 _nodeCache; + + public IndexedNodeCollector(QCandidates candidates) + { + _nodes = new Collection4(); + _nodeCache = new Hashtable4(); + CollectIndexedNodes(candidates); + } + + public virtual IEnumerator GetNodes() + { + return _nodes.GetEnumerator(); + } + + private void CollectIndexedNodes(QCandidates candidates) + { + CollectIndexedNodes(candidates.IterateConstraints()); + ImplicitlyAndJoinsOnSameField(); + } + + private void ImplicitlyAndJoinsOnSameField() + { + object[] nodes = _nodes.ToArray(); + for (int i = 0; i < nodes.Length; i++) + { + object node = nodes[i]; + if (node is OrIndexedLeaf) + { + OrIndexedLeaf current = (OrIndexedLeaf)node; + OrIndexedLeaf other = FindJoinOnSameFieldAtSameLevel(current); + if (null != other) + { + nodes[Arrays4.IndexOfIdentity(nodes, other)] = null; + CollectImplicitAnd(current.GetConstraint(), current, other); + } + } + } + } + + private OrIndexedLeaf FindJoinOnSameFieldAtSameLevel(OrIndexedLeaf join) + { + IEnumerator i = _nodes.GetEnumerator(); + while (i.MoveNext()) + { + if (i.Current == join) + { + continue; + } + if (i.Current is OrIndexedLeaf) + { + OrIndexedLeaf current = (OrIndexedLeaf)i.Current; + if (current.GetIndex() == join.GetIndex() && ParentConstraint(current) == ParentConstraint + (join)) + { + return current; + } + } + } + return null; + } + + private object ParentConstraint(OrIndexedLeaf node) + { + return node.GetConstraint().Parent(); + } + + private void CollectIndexedNodes(IEnumerator qcons) + { + while (qcons.MoveNext()) + { + QCon qcon = (QCon)qcons.Current; + if (IsCached(qcon)) + { + continue; + } + if (IsLeaf(qcon)) + { + if (qcon.CanLoadByIndex() && qcon.CanBeIndexLeaf()) + { + QConObject conObject = (QConObject)qcon; + if (conObject.HasJoins()) + { + CollectJoinedNode(conObject); + } + else + { + CollectStandaloneNode(conObject); + } + } + } + else + { + if (!qcon.HasJoins()) + { + CollectIndexedNodes(qcon.IterateChildren()); + } + } + } + } + + private bool IsCached(QCon qcon) + { + return null != _nodeCache.Get(qcon); + } + + private void CollectStandaloneNode(QConObject conObject) + { + IndexedLeaf existing = FindLeafOnSameField(conObject); + if (existing != null) + { + CollectImplicitAnd(conObject, existing, new IndexedLeaf(conObject)); + } + else + { + _nodes.Add(new IndexedLeaf(conObject)); + } + } + + private void CollectJoinedNode(QConObject constraintWithJoins) + { + Collection4 joins = CollectTopLevelJoins(constraintWithJoins); + if (!CanJoinsBeSearchedByIndex(joins)) + { + return; + } + if (1 == joins.Size()) + { + _nodes.Add(NodeForConstraint((QCon)joins.SingleElement())); + return; + } + CollectImplicitlyAndingJoins(joins, constraintWithJoins); + } + + private bool AllHaveSamePath(Collection4 leaves) + { + IEnumerator i = leaves.GetEnumerator(); + i.MoveNext(); + QCon first = (QCon)i.Current; + while (i.MoveNext()) + { + if (!HaveSamePath(first, (QCon)i.Current)) + { + return false; + } + } + return true; + } + + private bool HaveSamePath(QCon x, QCon y) + { + if (x == y) + { + return true; + } + if (!x.OnSameFieldAs(y)) + { + return false; + } + if (!x.HasParent()) + { + return !y.HasParent(); + } + return HaveSamePath(x.Parent(), y.Parent()); + } + + private Collection4 CollectLeaves(Collection4 joins) + { + Collection4 leaves = new Collection4(); + CollectLeaves(leaves, joins); + return leaves; + } + + private void CollectLeaves(Collection4 leaves, Collection4 joins) + { + IEnumerator i = joins.GetEnumerator(); + while (i.MoveNext()) + { + QConJoin join = ((QConJoin)i.Current); + CollectLeavesFromJoin(leaves, join); + } + } + + private void CollectLeavesFromJoin(Collection4 leaves, QConJoin join) + { + CollectLeavesFromJoinConstraint(leaves, join.Constraint1()); + CollectLeavesFromJoinConstraint(leaves, join.Constraint2()); + } + + private void CollectLeavesFromJoinConstraint(Collection4 leaves, QCon constraint) + { + if (constraint is QConJoin) + { + CollectLeavesFromJoin(leaves, (QConJoin)constraint); + } + else + { + if (!leaves.ContainsByIdentity(constraint)) + { + leaves.Add(constraint); + } + } + } + + private bool CanJoinsBeSearchedByIndex(Collection4 joins) + { + Collection4 leaves = CollectLeaves(joins); + return AllHaveSamePath(leaves) && AllCanBeSearchedByIndex(leaves); + } + + private bool AllCanBeSearchedByIndex(Collection4 leaves) + { + IEnumerator i = leaves.GetEnumerator(); + while (i.MoveNext()) + { + QCon leaf = ((QCon)i.Current); + if (!leaf.CanLoadByIndex()) + { + return false; + } + } + return true; + } + + private void CollectImplicitlyAndingJoins(Collection4 joins, QConObject constraintWithJoins + ) + { + IEnumerator i = joins.GetEnumerator(); + i.MoveNext(); + IIndexedNodeWithRange last = NodeForConstraint((QCon)i.Current); + while (i.MoveNext()) + { + IIndexedNodeWithRange node = NodeForConstraint((QCon)i.Current); + last = new AndIndexedLeaf(constraintWithJoins, node, last); + _nodes.Add(last); + } + } + + private Collection4 CollectTopLevelJoins(QConObject constraintWithJoins) + { + Collection4 joins = new Collection4(); + CollectTopLevelJoins(joins, constraintWithJoins); + return joins; + } + + private void CollectTopLevelJoins(Collection4 joins, QCon constraintWithJoins) + { + IEnumerator i = constraintWithJoins.IterateJoins(); + while (i.MoveNext()) + { + QConJoin join = (QConJoin)i.Current; + if (!join.HasJoins()) + { + if (!joins.ContainsByIdentity(join)) + { + joins.Add(join); + } + } + else + { + CollectTopLevelJoins(joins, join); + } + } + } + + private IIndexedNodeWithRange NewNodeForConstraint(QConJoin join) + { + IIndexedNodeWithRange c1 = NodeForConstraint(join.Constraint1()); + IIndexedNodeWithRange c2 = NodeForConstraint(join.Constraint2()); + if (join.IsOr()) + { + return new OrIndexedLeaf(FindLeafForJoin(join), c1, c2); + } + return new AndIndexedLeaf(join.Constraint1(), c1, c2); + } + + private QCon FindLeafForJoin(QConJoin join) + { + if (join.Constraint1() is QConObject) + { + return join.Constraint1(); + } + QCon con = join.Constraint2(); + if (con is QConObject) + { + return con; + } + return FindLeafForJoin((QConJoin)con); + } + + private IIndexedNodeWithRange NodeForConstraint(QCon con) + { + IIndexedNodeWithRange node = (IIndexedNodeWithRange)_nodeCache.Get(con); + if (null != node || _nodeCache.ContainsKey(con)) + { + return node; + } + node = NewNodeForConstraint(con); + _nodeCache.Put(con, node); + return node; + } + + private IIndexedNodeWithRange NewNodeForConstraint(QCon con) + { + if (con is QConJoin) + { + return NewNodeForConstraint((QConJoin)con); + } + return new IndexedLeaf((QConObject)con); + } + + private void CollectImplicitAnd(QCon constraint, IIndexedNodeWithRange x, IIndexedNodeWithRange + y) + { + _nodes.Remove(x); + _nodes.Remove(y); + _nodes.Add(new AndIndexedLeaf(constraint, x, y)); + } + + private IndexedLeaf FindLeafOnSameField(QConObject conObject) + { + IEnumerator i = _nodes.GetEnumerator(); + while (i.MoveNext()) + { + if (i.Current is IndexedLeaf) + { + IndexedLeaf leaf = (IndexedLeaf)i.Current; + if (conObject.OnSameFieldAs(leaf.Constraint())) + { + return leaf; + } + } + } + return null; + } + + private bool IsLeaf(QCon qcon) + { + return !qcon.HasChildren(); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Fieldindex/IndexedPath.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Fieldindex/IndexedPath.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Fieldindex/IndexedPath.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Fieldindex/IndexedPath.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,73 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using System.Collections; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Fieldindex; +using Db4objects.Db4o.Internal.Query.Processor; + +namespace Db4objects.Db4o.Internal.Fieldindex +{ + public class IndexedPath : IndexedNodeBase + { + public static IIndexedNode NewParentPath(IIndexedNode next, QCon constraint) + { + if (!CanFollowParent(constraint)) + { + return null; + } + return new Db4objects.Db4o.Internal.Fieldindex.IndexedPath((QConObject)constraint + .Parent(), next); + } + + private static bool CanFollowParent(QCon con) + { + QCon parent = con.Parent(); + FieldMetadata parentField = GetYapField(parent); + if (null == parentField) + { + return false; + } + FieldMetadata conField = GetYapField(con); + if (null == conField) + { + return false; + } + return parentField.HasIndex() && parentField.FieldType().IsAssignableFrom(conField + .ContainingClass()); + } + + private static FieldMetadata GetYapField(QCon con) + { + QField field = con.GetField(); + if (null == field) + { + return null; + } + return field.GetFieldMetadata(); + } + + private IIndexedNode _next; + + public IndexedPath(QConObject parent, IIndexedNode next) : base(parent) + { + _next = next; + } + + public override IEnumerator GetEnumerator() + { + return new IndexedPathIterator(this, _next.GetEnumerator()); + } + + public override int ResultSize() + { + throw new NotSupportedException(); + } + + public override void MarkAsBestIndex() + { + _constraint.SetProcessedByIndex(); + _next.MarkAsBestIndex(); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Fieldindex/IndexedPathIterator.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Fieldindex/IndexedPathIterator.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Fieldindex/IndexedPathIterator.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Fieldindex/IndexedPathIterator.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,26 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System.Collections; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal.Btree; +using Db4objects.Db4o.Internal.Fieldindex; + +namespace Db4objects.Db4o.Internal.Fieldindex +{ + internal sealed class IndexedPathIterator : CompositeIterator4 + { + private IndexedPath _path; + + public IndexedPathIterator(IndexedPath path, IEnumerator iterator) : base(iterator + ) + { + _path = path; + } + + protected override IEnumerator NextIterator(object current) + { + IFieldIndexKey key = (IFieldIndexKey)current; + return _path.Search(key.ParentID()).Keys(); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Fieldindex/JoinedLeaf.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Fieldindex/JoinedLeaf.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Fieldindex/JoinedLeaf.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Fieldindex/JoinedLeaf.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,78 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using System.Collections; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Btree; +using Db4objects.Db4o.Internal.Fieldindex; +using Db4objects.Db4o.Internal.Query.Processor; + +namespace Db4objects.Db4o.Internal.Fieldindex +{ + public abstract class JoinedLeaf : IIndexedNodeWithRange + { + private readonly QCon _constraint; + + private readonly IIndexedNodeWithRange _leaf1; + + private readonly IBTreeRange _range; + + public JoinedLeaf(QCon constraint, IIndexedNodeWithRange leaf1, IBTreeRange range + ) + { + if (null == constraint || null == leaf1 || null == range) + { + throw new ArgumentNullException(); + } + _constraint = constraint; + _leaf1 = leaf1; + _range = range; + } + + public virtual QCon GetConstraint() + { + return _constraint; + } + + public virtual IBTreeRange GetRange() + { + return _range; + } + + public virtual IEnumerator GetEnumerator() + { + return _range.Keys(); + } + + public virtual TreeInt ToTreeInt() + { + return IndexedNodeBase.AddToTree(null, this); + } + + public virtual BTree GetIndex() + { + return _leaf1.GetIndex(); + } + + public virtual bool IsResolved() + { + return _leaf1.IsResolved(); + } + + public virtual IIndexedNode Resolve() + { + return IndexedPath.NewParentPath(this, _constraint); + } + + public virtual int ResultSize() + { + return _range.Size(); + } + + public virtual void MarkAsBestIndex() + { + _leaf1.MarkAsBestIndex(); + _constraint.SetProcessedByIndex(); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Fieldindex/OrIndexedLeaf.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Fieldindex/OrIndexedLeaf.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Fieldindex/OrIndexedLeaf.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Fieldindex/OrIndexedLeaf.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,15 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal.Fieldindex; +using Db4objects.Db4o.Internal.Query.Processor; + +namespace Db4objects.Db4o.Internal.Fieldindex +{ + public class OrIndexedLeaf : JoinedLeaf + { + public OrIndexedLeaf(QCon constraint, IIndexedNodeWithRange leaf1, IIndexedNodeWithRange + leaf2) : base(constraint, leaf1, leaf1.GetRange().Union(leaf2.GetRange())) + { + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Fieldindex/QEBitmap.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Fieldindex/QEBitmap.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Fieldindex/QEBitmap.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Fieldindex/QEBitmap.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,38 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal.Query.Processor; + +namespace Db4objects.Db4o.Internal.Fieldindex +{ + internal class QEBitmap + { + public static Db4objects.Db4o.Internal.Fieldindex.QEBitmap ForQE(QE qe) + { + bool[] bitmap = new bool[4]; + qe.IndexBitMap(bitmap); + return new Db4objects.Db4o.Internal.Fieldindex.QEBitmap(bitmap); + } + + private QEBitmap(bool[] bitmap) + { + _bitmap = bitmap; + } + + private bool[] _bitmap; + + public virtual bool TakeGreater() + { + return _bitmap[QE.Greater]; + } + + public virtual bool TakeEqual() + { + return _bitmap[QE.Equal]; + } + + public virtual bool TakeSmaller() + { + return _bitmap[QE.Smaller]; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/FieldIndexException.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/FieldIndexException.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/FieldIndexException.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/FieldIndexException.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,62 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using Db4objects.Db4o.Internal; + +namespace Db4objects.Db4o.Internal +{ + [System.Serializable] + public class FieldIndexException : Exception + { + private string _className; + + private string _fieldName; + + public FieldIndexException(FieldMetadata field) : this(null, null, field) + { + } + + public FieldIndexException(string msg, FieldMetadata field) : this(msg, null, field + ) + { + } + + public FieldIndexException(Exception cause, FieldMetadata field) : this(null, cause + , field) + { + } + + public FieldIndexException(string msg, Exception cause, FieldMetadata field) : this + (msg, cause, field.ContainingClass().GetName(), field.GetName()) + { + } + + public FieldIndexException(string msg, Exception cause, string className, string + fieldName) : base(EnhancedMessage(msg, className, fieldName), cause) + { + _className = className; + _fieldName = fieldName; + } + + public virtual string ClassName() + { + return _className; + } + + public virtual string FieldName() + { + return _fieldName; + } + + private static string EnhancedMessage(string msg, string className, string fieldName + ) + { + string enhancedMessage = "Field index for " + className + "#" + fieldName; + if (msg != null) + { + enhancedMessage += ": " + msg; + } + return enhancedMessage; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/FieldMetadata.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/FieldMetadata.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/FieldMetadata.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/FieldMetadata.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,1374 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using System.Collections; +using System.Text; +using Db4objects.Db4o; +using Db4objects.Db4o.Config; +using Db4objects.Db4o.Ext; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Activation; +using Db4objects.Db4o.Internal.Btree; +using Db4objects.Db4o.Internal.Delete; +using Db4objects.Db4o.Internal.Handlers; +using Db4objects.Db4o.Internal.Handlers.Array; +using Db4objects.Db4o.Internal.Marshall; +using Db4objects.Db4o.Internal.Query.Processor; +using Db4objects.Db4o.Internal.Reflect; +using Db4objects.Db4o.Marshall; +using Db4objects.Db4o.Reflect; +using Db4objects.Db4o.Reflect.Generic; +using Db4objects.Db4o.Typehandlers; + +namespace Db4objects.Db4o.Internal +{ + /// + public class FieldMetadata : ClassAspect, IStoredField + { + private ClassMetadata _containingClass; + + private string _name; + + protected bool _isArray; + + private bool _isNArray; + + private bool _isPrimitive; + + private IReflectField _reflectField; + + private FieldMetadataState _state = FieldMetadataState.NotLoaded; + + private Config4Field _config; + + private IDb4oTypeImpl _db4oType; + + private int _linkLength; + + private BTree _index; + + protected ClassMetadata _fieldType; + + protected int _fieldTypeID; + + internal static readonly Db4objects.Db4o.Internal.FieldMetadata[] EmptyArray = new + Db4objects.Db4o.Internal.FieldMetadata[0]; + + public FieldMetadata(ClassMetadata classMetadata) + { + _containingClass = classMetadata; + } + + protected Type TranslatorStoredClass(IObjectTranslator translator) + { + try + { + return translator.StoredClass(); + } + catch (Exception e) + { + throw new ReflectException(e); + } + } + + internal FieldMetadata(ClassMetadata containingClass, IReflectField field, ClassMetadata + fieldType) : this(containingClass) + { + Init(field.GetName()); + _reflectField = field; + _fieldType = fieldType; + _fieldTypeID = fieldType.GetID(); + // TODO: beautify !!! possibly pull up isPrimitive to ReflectField + bool isPrimitive = field is GenericField ? ((GenericField)field).IsPrimitive() : + false; + Configure(field.GetFieldType(), isPrimitive); + CheckDb4oType(); + SetAvailable(); + } + + protected virtual void SetAvailable() + { + _state = FieldMetadataState.Available; + } + + protected FieldMetadata(int fieldTypeID) + { + _fieldTypeID = fieldTypeID; + } + + public FieldMetadata(ClassMetadata containingClass, string name, int fieldTypeID, + bool primitive, bool isArray, bool isNArray) : this(containingClass) + { + Init(name, fieldTypeID, primitive, isArray, isNArray); + } + + protected FieldMetadata(ClassMetadata containingClass, string name) : this(containingClass + ) + { + Init(name); + } + + /// + public virtual void AddFieldIndex(ObjectIdContextImpl context) + { + if (!HasIndex()) + { + IncrementOffset(context); + return; + } + try + { + AddIndexEntry(context.Transaction(), context.ObjectId(), ReadIndexEntry(context)); + } + catch (CorruptionException exc) + { + throw new FieldIndexException(exc, this); + } + } + + protected void AddIndexEntry(StatefulBuffer a_bytes, object indexEntry) + { + AddIndexEntry(a_bytes.Transaction(), a_bytes.GetID(), indexEntry); + } + + public virtual void AddIndexEntry(Transaction trans, int parentID, object indexEntry + ) + { + if (!HasIndex()) + { + return; + } + BTree index = GetIndex(trans); + index.Add(trans, CreateFieldIndexKey(parentID, indexEntry)); + } + + protected virtual IFieldIndexKey CreateFieldIndexKey(int parentID, object indexEntry + ) + { + object convertedIndexEntry = IndexEntryFor(indexEntry); + return new FieldIndexKeyImpl(parentID, convertedIndexEntry); + } + + protected virtual object IndexEntryFor(object indexEntry) + { + return _reflectField.IndexEntry(indexEntry); + } + + public virtual bool CanUseNullBitmap() + { + return true; + } + + /// + /// + public object ReadIndexEntry(IObjectIdContext context) + { + IIndexableTypeHandler indexableTypeHandler = (IIndexableTypeHandler)HandlerRegistry + .CorrectHandlerVersion(context, GetHandler()); + return indexableTypeHandler.ReadIndexEntry(context); + } + + public virtual void RemoveIndexEntry(Transaction trans, int parentID, object indexEntry + ) + { + if (!HasIndex()) + { + return; + } + BTree index = GetIndex(trans); + if (index == null) + { + return; + } + index.Remove(trans, CreateFieldIndexKey(parentID, indexEntry)); + } + + //TODO: Split into command query separation. + public virtual bool Alive() + { + if (_state == FieldMetadataState.Available) + { + return true; + } + if (_state == FieldMetadataState.NotLoaded) + { + return Load(); + } + return _state == FieldMetadataState.Available; + } + + private bool Load() + { + if (_fieldType == null) + { + // this may happen if the local ClassMetadataRepository + // has not been updated from the server and presumably + // in some refactoring cases. + // We try to heal the problem by re-reading the class. + // This could be dangerous, if the class type of a field + // has been modified. + // TODO: add class refactoring features + _fieldType = DetectFieldType(); + CheckFieldTypeID(); + } + CheckCorrectTypeForField(); + if (_fieldType == null || _reflectField == null) + { + _state = FieldMetadataState.Unavailable; + _reflectField = null; + return false; + } + if (Updating()) + { + return false; + } + SetAvailable(); + CheckDb4oType(); + return true; + } + + private bool ShouldStoreField() + { + return !_reflectField.IsTransient() || (_containingClass != null && _containingClass + .ShouldStoreTransientFields()); + } + + public virtual bool Updating() + { + return _state == FieldMetadataState.Updating; + } + + private void CheckFieldTypeID() + { + int id = _fieldType != null ? _fieldType.GetID() : 0; + if (_fieldTypeID == 0) + { + _fieldTypeID = id; + return; + } + if (id > 0 && id != _fieldTypeID) + { + // wrong type, refactoring, field should be turned off + // TODO: it would be cool to log something here + _fieldType = null; + } + } + + internal virtual bool CanAddToQuery(string fieldName) + { + if (!Alive()) + { + return false; + } + return fieldName.Equals(GetName()) && ContainingClass() != null && !ContainingClass + ().IsInternal(); + } + + private bool CanHold(IReflectClass type) + { + if (type == null) + { + throw new ArgumentNullException(); + } + ITypeHandler4 typeHandler = GetHandler(); + if (typeHandler is IQueryableTypeHandler) + { + if (((IQueryableTypeHandler)typeHandler).DescendsIntoMembers()) + { + return true; + } + } + IReflectClass classReflector = FieldType().ClassReflector(); + if (classReflector.IsCollection()) + { + return true; + } + return classReflector.IsAssignableFrom(type); + } + + public virtual GenericReflector Reflector() + { + ObjectContainerBase container = Container(); + if (container == null) + { + return null; + } + return container.Reflector(); + } + + public virtual object Coerce(IReflectClass valueClass, object value) + { + if (value == null) + { + return _isPrimitive ? No4.Instance : value; + } + if (valueClass == null) + { + throw new ArgumentNullException(); + } + if (GetHandler() is PrimitiveHandler) + { + return ((PrimitiveHandler)GetHandler()).Coerce(valueClass, value); + } + if (!CanHold(valueClass)) + { + return No4.Instance; + } + return value; + } + + public bool CanLoadByIndex() + { + return Handlers4.CanLoadFieldByIndex(GetHandler()); + } + + public sealed override void CascadeActivation(IActivationContext context) + { + if (!Alive()) + { + return; + } + object cascadeTo = CascadingTarget(context); + if (cascadeTo == null) + { + return; + } + IActivationContext cascadeContext = context.ForObject(cascadeTo); + ClassMetadata classMetadata = cascadeContext.ClassMetadata(); + if (classMetadata == null) + { + return; + } + EnsureObjectIsActive(cascadeContext); + Handlers4.CascadeActivation(cascadeContext, classMetadata.TypeHandler()); + } + + private void EnsureObjectIsActive(IActivationContext context) + { + if (!context.Depth().Mode().IsActivate()) + { + return; + } + if (Handlers4.IsValueType(GetHandler())) + { + return; + } + ObjectContainerBase container = context.Container(); + ClassMetadata classMetadata = container.ClassMetadataForObject(context.TargetObject + ()); + if (classMetadata == null || !classMetadata.HasIdentity()) + { + return; + } + if (container.IsActive(context.TargetObject())) + { + return; + } + container.StillToActivate(context.Descend()); + } + + protected object CascadingTarget(IActivationContext context) + { + if (context.Depth().Mode().IsDeactivate()) + { + if (null == _reflectField) + { + return null; + } + return FieldAccessor().Get(_reflectField, context.TargetObject()); + } + return GetOrCreate(context.Transaction(), context.TargetObject()); + } + + private void CheckDb4oType() + { + if (_reflectField != null) + { + if (Container()._handlers.IclassDb4otype.IsAssignableFrom(_reflectField.GetFieldType + ())) + { + _db4oType = HandlerRegistry.GetDb4oType(_reflectField.GetFieldType()); + } + } + } + + internal virtual void CollectConstraints(Transaction trans, QConObject a_parent, + object a_template, IVisitor4 a_visitor) + { + object obj = GetOn(trans, a_template); + if (obj != null) + { + Collection4 objs = Platform4.FlattenCollection(trans.Container(), obj); + IEnumerator j = objs.GetEnumerator(); + while (j.MoveNext()) + { + obj = j.Current; + if (obj != null) + { + if (_isPrimitive && !_isArray) + { + object nullValue = _reflectField.GetFieldType().NullValue(); + if (obj.Equals(nullValue)) + { + return; + } + } + if (Platform4.IgnoreAsConstraint(obj)) + { + return; + } + if (!a_parent.HasObjectInParentPath(obj)) + { + QConObject constraint = new QConObject(trans, a_parent, QField(trans), obj); + constraint.ByExample(); + a_visitor.Visit(constraint); + } + } + } + } + } + + /// + public sealed override void CollectIDs(CollectIdContext context) + { + if (!Alive()) + { + IncrementOffset(context.Buffer()); + return; + } + ITypeHandler4 handler = HandlerRegistry.CorrectHandlerVersion(context, GetHandler + ()); + Handlers4.CollectIdsInternal(context, handler, LinkLength(), true); + } + + internal virtual void Configure(IReflectClass clazz, bool isPrimitive) + { + _isArray = clazz.IsArray(); + if (_isArray) + { + IReflectArray reflectArray = Reflector().Array(); + _isNArray = reflectArray.IsNDimensional(clazz); + _isPrimitive = reflectArray.GetComponentType(clazz).IsPrimitive(); + } + else + { + _isPrimitive = isPrimitive | clazz.IsPrimitive(); + } + } + + protected ITypeHandler4 WrapHandlerToArrays(ITypeHandler4 handler) + { + if (handler == null) + { + return null; + } + if (_isNArray) + { + return new MultidimensionalArrayHandler(handler, ArraysUsePrimitiveClassReflector + ()); + } + if (_isArray) + { + return new ArrayHandler(handler, ArraysUsePrimitiveClassReflector()); + } + return handler; + } + + private bool ArraysUsePrimitiveClassReflector() + { + return _isPrimitive; + } + + public override void Deactivate(IActivationContext context) + { + if (!Alive() || !ShouldStoreField()) + { + return; + } + bool isEnumClass = _containingClass.IsEnum(); + if (_isPrimitive && !_isArray) + { + if (!isEnumClass) + { + object nullValue = _reflectField.GetFieldType().NullValue(); + FieldAccessor().Set(_reflectField, context.TargetObject(), nullValue); + } + return; + } + if (context.Depth().RequiresActivation()) + { + CascadeActivation(context); + } + if (!isEnumClass) + { + FieldAccessor().Set(_reflectField, context.TargetObject(), null); + } + } + + private IFieldAccessor FieldAccessor() + { + return _containingClass.FieldAccessor(); + } + + /// + public override void Delete(DeleteContextImpl context, bool isUpdate) + { + if (!CheckAlive(context)) + { + return; + } + try + { + RemoveIndexEntry(context); + if (isUpdate) + { + IncrementOffset(context); + return; + } + StatefulBuffer buffer = (StatefulBuffer)context.Buffer(); + DeleteContextImpl childContext = new DeleteContextImpl(context, GetStoredType(), + _config); + context.SlotFormat().DoWithSlotIndirection(buffer, GetHandler(), new _IClosure4_445 + (this, childContext)); + } + catch (CorruptionException exc) + { + throw new FieldIndexException(exc, this); + } + } + + private sealed class _IClosure4_445 : IClosure4 + { + public _IClosure4_445(FieldMetadata _enclosing, DeleteContextImpl childContext) + { + this._enclosing = _enclosing; + this.childContext = childContext; + } + + public object Run() + { + childContext.Delete(this._enclosing.GetHandler()); + return null; + } + + private readonly FieldMetadata _enclosing; + + private readonly DeleteContextImpl childContext; + } + + /// + /// + private void RemoveIndexEntry(DeleteContextImpl context) + { + if (!HasIndex()) + { + return; + } + int offset = context.Offset(); + object obj = ReadIndexEntry(context); + RemoveIndexEntry(context.Transaction(), context.ObjectId(), obj); + context.Seek(offset); + } + + public override bool Equals(object obj) + { + if (!(obj is Db4objects.Db4o.Internal.FieldMetadata)) + { + return false; + } + Db4objects.Db4o.Internal.FieldMetadata other = (Db4objects.Db4o.Internal.FieldMetadata + )obj; + other.Alive(); + Alive(); + return other._isPrimitive == _isPrimitive && other._fieldType == _fieldType && other + ._name.Equals(_name); + } + + public override int GetHashCode() + { + return _name.GetHashCode(); + } + + public object Get(object onObject) + { + return Get(null, onObject); + } + + public object Get(Transaction trans, object onObject) + { + if (_containingClass == null) + { + return null; + } + ObjectContainerBase container = Container(); + if (container == null) + { + return null; + } + lock (container.Lock()) + { + // FIXME: The following is not really transactional. + // This will work OK for normal C/S and for + // single local mode but the transaction will + // be wrong for MTOC. + if (trans == null) + { + trans = container.Transaction; + } + container.CheckClosed(); + ObjectReference @ref = trans.ReferenceForObject(onObject); + if (@ref == null) + { + return null; + } + int id = @ref.GetID(); + if (id <= 0) + { + return null; + } + UnmarshallingContext context = new UnmarshallingContext(trans, @ref, Const4.AddToIdTree + , false); + context.ActivationDepth(new LegacyActivationDepth(1)); + return context.ReadFieldValue(this); + } + } + + public override string GetName() + { + return _name; + } + + public ClassMetadata FieldType() + { + // alive needs to be checked by all callers: Done + return _fieldType; + } + + public virtual ITypeHandler4 GetHandler() + { + if (_fieldType == null) + { + return null; + } + // alive needs to be checked by all callers: Done + return WrapHandlerToArrays(_fieldType.TypeHandler()); + } + + public virtual int FieldTypeID() + { + // alive needs to be checked by all callers: Done + return _fieldTypeID; + } + + public virtual object GetOn(Transaction trans, object onObject) + { + if (Alive()) + { + return FieldAccessor().Get(_reflectField, onObject); + } + return null; + } + + /// + /// dirty hack for com.db4o.types some of them (BlobImpl) need to be set automatically + /// TODO: Derive from FieldMetadata for Db4oTypes + /// + public virtual object GetOrCreate(Transaction trans, object onObject) + { + if (!Alive()) + { + return null; + } + object obj = FieldAccessor().Get(_reflectField, onObject); + if (_db4oType != null && obj == null) + { + obj = _db4oType.CreateDefault(trans); + FieldAccessor().Set(_reflectField, onObject, obj); + } + return obj; + } + + public ClassMetadata ContainingClass() + { + // alive needs to be checked by all callers: Done + return _containingClass; + } + + public virtual IReflectClass GetStoredType() + { + if (_reflectField == null) + { + return null; + } + return Handlers4.BaseType(_reflectField.GetFieldType()); + } + + public virtual ObjectContainerBase Container() + { + if (_containingClass == null) + { + return null; + } + return _containingClass.Container(); + } + + public virtual bool HasConfig() + { + return _config != null; + } + + public virtual bool HasIndex() + { + return _index != null; + } + + public void Init(string name) + { + _name = name; + InitConfiguration(name); + } + + internal void InitConfiguration(string name) + { + Config4Class containingClassConfig = _containingClass.Config(); + if (containingClassConfig == null) + { + return; + } + _config = containingClassConfig.ConfigField(name); + } + + public virtual void Init(string name, int fieldTypeID, bool isPrimitive, bool isArray + , bool isNArray) + { + _fieldTypeID = fieldTypeID; + _isPrimitive = isPrimitive; + _isArray = isArray; + _isNArray = isNArray; + Init(name); + LoadFieldTypeById(); + Alive(); + } + + private bool _initialized = false; + + internal void InitConfigOnUp(Transaction trans) + { + if (_initialized) + { + return; + } + _initialized = true; + if (_config != null) + { + _config.InitOnUp(trans, this); + } + } + + public override void Activate(UnmarshallingContext context) + { + if (!CheckAlive(context)) + { + return; + } + if (!ShouldStoreField()) + { + IncrementOffset(context); + return; + } + object toSet = Read(context); + InformAboutTransaction(toSet, context.Transaction()); + Set(context.PersistentObject(), toSet); + } + + public virtual void AttemptUpdate(UnmarshallingContext context) + { + if (!Updating()) + { + IncrementOffset(context); + return; + } + int savedOffset = context.Offset(); + try + { + object toSet = context.Read(GetHandler()); + if (toSet != null) + { + Set(context.PersistentObject(), toSet); + } + } + catch (Exception) + { + // FIXME: COR-547 Diagnostics here please. + context.Buffer().Seek(savedOffset); + IncrementOffset(context); + } + } + + private bool CheckAlive(IAspectVersionContext context) + { + if (!CheckEnabled(context)) + { + return false; + } + bool alive = Alive(); + if (!alive) + { + IncrementOffset((IReadBuffer)context); + } + return alive; + } + + private void InformAboutTransaction(object obj, Transaction trans) + { + if (_db4oType != null && obj != null) + { + ((IDb4oTypeImpl)obj).SetTrans(trans); + } + } + + public virtual bool IsArray() + { + return _isArray; + } + + public override int LinkLength() + { + Alive(); + if (_linkLength == 0) + { + _linkLength = CalculateLinkLength(); + } + return _linkLength; + } + + private int CalculateLinkLength() + { + return Handlers4.CalculateLinkLength(GetHandler()); + } + + public virtual void LoadFieldTypeById() + { + _fieldType = Container().ClassMetadataForID(_fieldTypeID); + } + + private ClassMetadata DetectFieldType() + { + IReflectClass claxx = _containingClass.ClassReflector(); + if (claxx == null) + { + return null; + } + _reflectField = claxx.GetDeclaredField(_name); + if (_reflectField == null) + { + return null; + } + IReflectClass fieldType = _reflectField.GetFieldType(); + if (fieldType == null) + { + return null; + } + return Handlers4.ErasedFieldType(Container(), fieldType); + } + + protected virtual ITypeHandler4 TypeHandlerForClass(ObjectContainerBase container + , IReflectClass fieldType) + { + container.ShowInternalClasses(true); + try + { + return container.TypeHandlerForClass(Handlers4.BaseType(fieldType)); + } + finally + { + container.ShowInternalClasses(false); + } + } + + private void CheckCorrectTypeForField() + { + ClassMetadata currentFieldType = DetectFieldType(); + if (currentFieldType == null) + { + _reflectField = null; + _state = FieldMetadataState.Unavailable; + return; + } + if (currentFieldType == _fieldType && Handlers4.BaseType(_reflectField.GetFieldType + ()).IsPrimitive() == _isPrimitive) + { + return; + } + // special case when migrating from type handler ids + // to class metadata ids which caused + // any interface metadata id to be mapped to UNTYPED_ID + if (Handlers4.IsUntyped(currentFieldType.TypeHandler()) && Handlers4.IsUntyped(_fieldType + .TypeHandler())) + { + return; + } + // FIXME: COR-547 Diagnostics here please. + _state = FieldMetadataState.Updating; + } + + private IUpdateDepth AdjustUpdateDepthForCascade(object obj, IUpdateDepth updateDepth + ) + { + return updateDepth.AdjustUpdateDepthForCascade(_containingClass.IsCollection(obj) + ); + } + + private bool CascadeOnUpdate(Config4Class parentClassConfiguration) + { + return ((parentClassConfiguration != null && (parentClassConfiguration.CascadeOnUpdate + ().DefiniteYes())) || (_config != null && (_config.CascadeOnUpdate().DefiniteYes + ()))); + } + + public override void Marshall(MarshallingContext context, object obj) + { + // alive needs to be checked by all callers: Done + IUpdateDepth updateDepth = context.UpdateDepth(); + if (obj != null && CascadeOnUpdate(context.ClassConfiguration())) + { + context.UpdateDepth(AdjustUpdateDepthForCascade(obj, updateDepth)); + } + context.WriteObjectWithCurrentState(GetHandler(), obj); + context.UpdateDepth(updateDepth); + if (HasIndex()) + { + context.AddIndexEntry(this, obj); + } + } + + public virtual bool NeedsArrayAndPrimitiveInfo() + { + return true; + } + + public virtual IPreparedComparison PrepareComparison(IContext context, object obj + ) + { + if (!Alive()) + { + return null; + } + return Handlers4.PrepareComparisonFor(GetHandler(), context, obj); + } + + public virtual Db4objects.Db4o.Internal.Query.Processor.QField QField(Transaction + a_trans) + { + int classMetadataID = 0; + if (_containingClass != null) + { + classMetadataID = _containingClass.GetID(); + } + return new Db4objects.Db4o.Internal.Query.Processor.QField(a_trans, _name, this, + classMetadataID, _handle); + } + + public virtual object Read(IObjectIdContext context) + { + if (!CanReadFromSlot((IAspectVersionContext)context)) + { + IncrementOffset(context); + return null; + } + return context.Read(GetHandler()); + } + + private bool CanReadFromSlot(IAspectVersionContext context) + { + if (!IsEnabledOn(context)) + { + return false; + } + if (Alive()) + { + return true; + } + return _state != FieldMetadataState.NotLoaded; + } + + internal virtual void Refresh() + { + ClassMetadata newFieldType = DetectFieldType(); + if (newFieldType != null && newFieldType.Equals(_fieldType)) + { + return; + } + _reflectField = null; + _state = FieldMetadataState.Unavailable; + } + + // FIXME: needs test case + public virtual void Rename(string newName) + { + ObjectContainerBase container = Container(); + if (!container.IsClient) + { + _name = newName; + _containingClass.SetStateDirty(); + _containingClass.Write(container.SystemTransaction()); + } + else + { + Exceptions4.ThrowRuntimeException(58); + } + } + + public virtual void Set(object onObject, object obj) + { + // TODO: remove the following if and check callers + if (null == _reflectField) + { + return; + } + FieldAccessor().Set(_reflectField, onObject, obj); + } + + internal virtual void SetName(string a_name) + { + _name = a_name; + } + + internal virtual bool SupportsIndex() + { + return Alive() && (GetHandler() is IIndexable4) && (!Handlers4.IsUntyped(GetHandler + ())); + } + + public void TraverseValues(IVisitor4 userVisitor) + { + if (!Alive()) + { + return; + } + TraverseValues(Container().Transaction, userVisitor); + } + + public void TraverseValues(Transaction transaction, IVisitor4 userVisitor) + { + if (!Alive()) + { + return; + } + AssertHasIndex(); + ObjectContainerBase stream = transaction.Container(); + if (stream.IsClient) + { + Exceptions4.ThrowRuntimeException(Db4objects.Db4o.Internal.Messages.ClientServerUnsupported + ); + } + lock (stream.Lock()) + { + IContext context = transaction.Context(); + _index.TraverseKeys(transaction, new _IVisitor4_866(this, userVisitor, context)); + } + } + + private sealed class _IVisitor4_866 : IVisitor4 + { + public _IVisitor4_866(FieldMetadata _enclosing, IVisitor4 userVisitor, IContext context + ) + { + this._enclosing = _enclosing; + this.userVisitor = userVisitor; + this.context = context; + } + + public void Visit(object obj) + { + IFieldIndexKey key = (IFieldIndexKey)obj; + userVisitor.Visit(((IIndexableTypeHandler)this._enclosing.GetHandler()).IndexEntryToObject + (context, key.Value())); + } + + private readonly FieldMetadata _enclosing; + + private readonly IVisitor4 userVisitor; + + private readonly IContext context; + } + + private void AssertHasIndex() + { + if (!HasIndex()) + { + Exceptions4.ThrowRuntimeException(Db4objects.Db4o.Internal.Messages.OnlyForIndexedFields + ); + } + } + + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + if (_containingClass != null) + { + sb.Append(_containingClass.GetName()); + sb.Append("."); + } + sb.Append(GetName()); + return sb.ToString(); + } + + private void InitIndex(Transaction systemTrans) + { + InitIndex(systemTrans, 0); + } + + public virtual void InitIndex(Transaction systemTrans, int id) + { + if (_index != null) + { + throw new InvalidOperationException(); + } + if (systemTrans.Container().IsClient) + { + return; + } + _index = NewBTree(systemTrans, id); + } + + protected BTree NewBTree(Transaction systemTrans, int id) + { + ObjectContainerBase stream = systemTrans.Container(); + IIndexable4 indexHandler = IndexHandler(stream); + if (indexHandler == null) + { + return null; + } + return new BTree(systemTrans, id, new FieldIndexKeyHandler(indexHandler)); + } + + protected virtual IIndexable4 IndexHandler(ObjectContainerBase stream) + { + if (_reflectField == null) + { + return null; + } + IReflectClass indexType = _reflectField.IndexType(); + ITypeHandler4 classHandler = TypeHandlerForClass(stream, indexType); + if (!(classHandler is IIndexable4)) + { + return null; + } + return (IIndexable4)classHandler; + } + + /// + public virtual BTree GetIndex(Transaction trans) + { + return _index; + } + + public virtual bool IsVirtual() + { + return false; + } + + public virtual bool IsPrimitive() + { + return _isPrimitive; + } + + public virtual IBTreeRange Search(Transaction transaction, object value) + { + AssertHasIndex(); + object transActionalValue = Handlers4.WrapWithTransactionContext(transaction, value + , GetHandler()); + BTreeNodeSearchResult lowerBound = SearchLowerBound(transaction, transActionalValue + ); + BTreeNodeSearchResult upperBound = SearchUpperBound(transaction, transActionalValue + ); + return lowerBound.CreateIncludingRange(upperBound); + } + + private BTreeNodeSearchResult SearchUpperBound(Transaction transaction, object value + ) + { + return SearchBound(transaction, int.MaxValue, value); + } + + private BTreeNodeSearchResult SearchLowerBound(Transaction transaction, object value + ) + { + return SearchBound(transaction, 0, value); + } + + private BTreeNodeSearchResult SearchBound(Transaction transaction, int parentID, + object keyPart) + { + return GetIndex(transaction).SearchLeaf(transaction, CreateFieldIndexKey(parentID + , keyPart), SearchTarget.Lowest); + } + + public virtual bool RebuildIndexForClass(LocalObjectContainer stream, ClassMetadata + classMetadata) + { + // FIXME: BTree traversal over index here. + long[] ids = classMetadata.GetIDs(); + for (int i = 0; i < ids.Length; i++) + { + RebuildIndexForObject(stream, classMetadata, (int)ids[i]); + } + return ids.Length > 0; + } + + /// + protected virtual void RebuildIndexForObject(LocalObjectContainer stream, ClassMetadata + classMetadata, int objectId) + { + StatefulBuffer writer = stream.ReadStatefulBufferById(stream.SystemTransaction(), + objectId); + if (writer != null) + { + RebuildIndexForWriter(stream, writer, objectId); + } + } + + protected virtual void RebuildIndexForWriter(LocalObjectContainer stream, StatefulBuffer + writer, int objectId) + { + ObjectHeader oh = new ObjectHeader(stream, writer); + object obj = ReadIndexEntryForRebuild(writer, oh); + AddIndexEntry(stream.SystemTransaction(), objectId, obj); + } + + private object ReadIndexEntryForRebuild(StatefulBuffer writer, ObjectHeader oh) + { + ClassMetadata classMetadata = oh.ClassMetadata(); + if (classMetadata == null) + { + return DefaultValueForFieldType(); + } + ObjectIdContextImpl context = new ObjectIdContextImpl(writer.Transaction(), writer + , oh, writer.GetID()); + if (!classMetadata.SeekToField(context, this)) + { + return DefaultValueForFieldType(); + } + try + { + return ReadIndexEntry(context); + } + catch (CorruptionException exc) + { + throw new FieldIndexException(exc, this); + } + } + + private object DefaultValueForFieldType() + { + ITypeHandler4 handler = _fieldType.TypeHandler(); + return (handler is PrimitiveHandler) ? ((PrimitiveHandler)handler).PrimitiveNull( + ) : null; + } + + public void DropIndex(LocalTransaction systemTrans) + { + if (_index == null) + { + return; + } + ObjectContainerBase stream = systemTrans.Container(); + if (stream.ConfigImpl.MessageLevel() > Const4.None) + { + stream.Message("dropping index " + ToString()); + } + _index.Free(systemTrans); + stream.SetDirtyInSystemTransaction(ContainingClass()); + _index = null; + } + + public override void DefragAspect(IDefragmentContext context) + { + if (!CanDefragment()) + { + throw new InvalidOperationException("Field '" + ToString() + "' cannot be defragmented at this time." + ); + } + ITypeHandler4 correctTypeHandlerVersion = HandlerRegistry.CorrectHandlerVersion(context + , GetHandler(), _fieldType); + context.SlotFormat().DoWithSlotIndirection(context, correctTypeHandlerVersion, new + _IClosure4_1029(context, correctTypeHandlerVersion)); + } + + private sealed class _IClosure4_1029 : IClosure4 + { + public _IClosure4_1029(IDefragmentContext context, ITypeHandler4 correctTypeHandlerVersion + ) + { + this.context = context; + this.correctTypeHandlerVersion = correctTypeHandlerVersion; + } + + public object Run() + { + context.Defragment(correctTypeHandlerVersion); + return null; + } + + private readonly IDefragmentContext context; + + private readonly ITypeHandler4 correctTypeHandlerVersion; + } + + private bool CanDefragment() + { + if (Alive() || Updating()) + { + return true; + } + if (_fieldType == null || GetHandler() == null) + { + return false; + } + return !_fieldType.StateDead(); + } + + public virtual void CreateIndex() + { + if (HasIndex()) + { + return; + } + LocalObjectContainer container = (LocalObjectContainer)Container(); + if (container.ConfigImpl.MessageLevel() > Const4.None) + { + container.Message("creating index " + ToString()); + } + InitIndex(container.SystemTransaction()); + container.SetDirtyInSystemTransaction(ContainingClass()); + Reindex(container); + } + + private void Reindex(LocalObjectContainer container) + { + ClassMetadata clazz = ContainingClass(); + if (RebuildIndexForClass(container, clazz)) + { + container.SystemTransaction().Commit(); + } + } + + public override Db4objects.Db4o.Internal.Marshall.AspectType AspectType() + { + return Db4objects.Db4o.Internal.Marshall.AspectType.Field; + } + + // overriden in VirtualFieldMetadata + public override bool CanBeDisabled() + { + return true; + } + + public virtual void DropIndex() + { + DropIndex((LocalTransaction)Container().SystemTransaction()); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/FieldMetadataState.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/FieldMetadataState.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/FieldMetadataState.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/FieldMetadataState.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,32 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +namespace Db4objects.Db4o.Internal +{ + /// + internal class FieldMetadataState + { + private readonly string _info; + + private FieldMetadataState(string info) + { + _info = info; + } + + internal static readonly Db4objects.Db4o.Internal.FieldMetadataState NotLoaded = + new Db4objects.Db4o.Internal.FieldMetadataState("not loaded"); + + internal static readonly Db4objects.Db4o.Internal.FieldMetadataState Unavailable = + new Db4objects.Db4o.Internal.FieldMetadataState("unavailable"); + + internal static readonly Db4objects.Db4o.Internal.FieldMetadataState Available = + new Db4objects.Db4o.Internal.FieldMetadataState("available"); + + internal static readonly Db4objects.Db4o.Internal.FieldMetadataState Updating = new + Db4objects.Db4o.Internal.FieldMetadataState("updating"); + + public override string ToString() + { + return _info; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Fileheader/FileHeader1.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Fileheader/FileHeader1.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Fileheader/FileHeader1.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Fileheader/FileHeader1.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,88 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Fileheader; + +namespace Db4objects.Db4o.Internal.Fileheader +{ + /// + public class FileHeader1 : NewFileHeaderBase + { + private static readonly int TransactionPointerOffset = AccessTimeOffset + Const4. + LongLength; + + private static readonly int BlocksizeOffset = TransactionPointerOffset + (Const4. + IntLength * 2); + + public static readonly int HeaderLength = TransactionPointerOffset + (Const4.IntLength + * 6); + + // The header format is: + // (byte) 'd' + // (byte) 'b' + // (byte) '4' + // (byte) 'o' + // (byte) headerVersion + // (int) headerLock + // (long) openTime + // (long) accessTime + // (int) Transaction pointer 1 + // (int) Transaction pointer 2 + // (int) blockSize + // (int) classCollectionID + // (int) freespaceID + // (int) variablePartID + public override int Length() + { + return HeaderLength; + } + + protected override void Read(LocalObjectContainer file, ByteArrayBuffer reader) + { + NewTimerFileLock(file); + OldEncryptionOff(file); + CheckThreadFileLock(file, reader); + reader.Seek(TransactionPointerOffset); + file.SystemData().TransactionPointer1(reader.ReadInt()); + file.SystemData().TransactionPointer2(reader.ReadInt()); + reader.Seek(BlocksizeOffset); + file.BlockSizeReadFromFile(reader.ReadInt()); + SystemData systemData = file.SystemData(); + systemData.ClassCollectionID(reader.ReadInt()); + reader.ReadInt(); + // was freespace ID, can no longer be read + _variablePart = CreateVariablePart(file); + int variablePartId = reader.ReadInt(); + _variablePart.Read(variablePartId, 0); + } + + public override void WriteFixedPart(LocalObjectContainer file, bool startFileLockingThread + , bool shuttingDown, StatefulBuffer writer, int blockSize) + { + throw new InvalidOperationException(); + } + + public override void WriteTransactionPointer(Transaction systemTransaction, int transactionPointer + ) + { + throw new InvalidOperationException(); + } + + protected override NewFileHeaderBase CreateNew() + { + return new FileHeader1(); + } + + protected override byte Version() + { + return (byte)1; + } + + public override FileHeaderVariablePart CreateVariablePart(LocalObjectContainer file + ) + { + return new FileHeaderVariablePart1(file); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Fileheader/FileHeader2.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Fileheader/FileHeader2.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Fileheader/FileHeader2.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Fileheader/FileHeader2.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,125 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Fileheader; +using Sharpen; + +namespace Db4objects.Db4o.Internal.Fileheader +{ + /// + public class FileHeader2 : NewFileHeaderBase + { + private static readonly int BlocksizeOffset = AccessTimeOffset + Const4.LongLength; + + public static readonly int HeaderLength = BlocksizeOffset + (Const4.IntLength * 5 + ) + 1; + + private int _transactionPointerAddress = 0; + + // The header format is: + // (byte) 'd' + // (byte) 'b' + // (byte) '4' + // (byte) 'o' + // (byte) headerVersion + // (int) headerLock + // (long) openTime + // (long) accessTime + // (int) blockSize + // (int) classCollectionID + // (byte) idSystemType + // (int) variable part address + // (int) variable part length + // (int) transaction pointer address + public override int Length() + { + return HeaderLength; + } + + protected override void Read(LocalObjectContainer container, ByteArrayBuffer reader + ) + { + NewTimerFileLock(container); + OldEncryptionOff(container); + CheckThreadFileLock(container, reader); + reader.Seek(BlocksizeOffset); + container.BlockSizeReadFromFile(reader.ReadInt()); + SystemData systemData = container.SystemData(); + systemData.ClassCollectionID(reader.ReadInt()); + container.SystemData().IdSystemType(reader.ReadByte()); + _variablePart = CreateVariablePart(container); + int variablePartAddress = reader.ReadInt(); + int variablePartLength = reader.ReadInt(); + _variablePart.Read(variablePartAddress, variablePartLength); + _transactionPointerAddress = reader.ReadInt(); + if (_transactionPointerAddress != 0) + { + ByteArrayBuffer buffer = new ByteArrayBuffer(TransactionPointerLength); + buffer.Read(container, _transactionPointerAddress, 0); + systemData.TransactionPointer1(buffer.ReadInt()); + systemData.TransactionPointer2(buffer.ReadInt()); + } + } + + public override void WriteFixedPart(LocalObjectContainer file, bool startFileLockingThread + , bool shuttingDown, StatefulBuffer writer, int blockSize) + { + SystemData systemData = file.SystemData(); + writer.Append(Signature); + writer.WriteByte(Version()); + writer.WriteInt((int)TimeToWrite(_timerFileLock.OpenTime(), shuttingDown)); + writer.WriteLong(TimeToWrite(_timerFileLock.OpenTime(), shuttingDown)); + writer.WriteLong(TimeToWrite(Runtime.CurrentTimeMillis(), shuttingDown)); + writer.WriteInt(blockSize); + writer.WriteInt(systemData.ClassCollectionID()); + writer.WriteByte(systemData.IdSystemType()); + writer.WriteInt(((FileHeaderVariablePart2)_variablePart).Address()); + writer.WriteInt(((FileHeaderVariablePart2)_variablePart).Length()); + writer.WriteInt(_transactionPointerAddress); + writer.Write(); + if (shuttingDown) + { + WriteVariablePart(file, true); + } + else + { + file.SyncFiles(); + } + if (startFileLockingThread) + { + file.ThreadPool().Start("db4o lock thread", _timerFileLock); + } + } + + public override void WriteTransactionPointer(Transaction systemTransaction, int transactionPointer + ) + { + if (_transactionPointerAddress == 0) + { + LocalObjectContainer file = ((LocalTransaction)systemTransaction).LocalContainer( + ); + _transactionPointerAddress = file.AllocateSafeSlot(TransactionPointerLength).Address + (); + file.WriteHeader(false, false); + } + WriteTransactionPointer(systemTransaction, transactionPointer, _transactionPointerAddress + , 0); + } + + protected override byte Version() + { + return (byte)2; + } + + protected override NewFileHeaderBase CreateNew() + { + return new FileHeader2(); + } + + public override FileHeaderVariablePart CreateVariablePart(LocalObjectContainer file + ) + { + return new FileHeaderVariablePart2(file); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Fileheader/FileHeader3.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Fileheader/FileHeader3.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Fileheader/FileHeader3.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Fileheader/FileHeader3.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,32 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Fileheader; + +namespace Db4objects.Db4o.Internal.Fileheader +{ + /// + public class FileHeader3 : FileHeader2 + { + public override FileHeaderVariablePart CreateVariablePart(LocalObjectContainer file + ) + { + return new FileHeaderVariablePart3(file); + } + + protected override byte Version() + { + return (byte)3; + } + + protected override NewFileHeaderBase CreateNew() + { + return new FileHeader3(); + } + + public override FileHeader Convert(LocalObjectContainer file) + { + return this; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Fileheader/FileHeader.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Fileheader/FileHeader.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Fileheader/FileHeader.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Fileheader/FileHeader.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,151 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Fileheader; +using Sharpen.Lang; + +namespace Db4objects.Db4o.Internal.Fileheader +{ + /// + public abstract class FileHeader + { + public const int TransactionPointerLength = Const4.IntLength * 2; + + private static readonly FileHeader[] AvailableFileHeaders = new FileHeader[] { new + FileHeader1(), new FileHeader2(), new FileHeader3() }; + + public static NewFileHeaderBase NewCurrentFileHeader() + { + return new FileHeader3(); + } + + private static int ReaderLength() + { + int length = AvailableFileHeaders[0].Length(); + for (int i = 1; i < AvailableFileHeaders.Length; i++) + { + length = Math.Max(length, AvailableFileHeaders[i].Length()); + } + return length; + } + + /// + public static FileHeader Read(LocalObjectContainer file) + { + ByteArrayBuffer reader = PrepareFileHeaderReader(file); + FileHeader header = DetectFileHeader(file, reader); + if (header == null) + { + Exceptions4.ThrowRuntimeException(Db4objects.Db4o.Internal.Messages.IncompatibleFormat + , file.ToString()); + } + else + { + header.Read(file, reader); + } + return header; + } + + public virtual FileHeader Convert(LocalObjectContainer file) + { + FileHeader3 fileHeader = new FileHeader3(); + fileHeader.InitNew(file); + return fileHeader; + } + + private static ByteArrayBuffer PrepareFileHeaderReader(LocalObjectContainer file) + { + ByteArrayBuffer reader = new ByteArrayBuffer(ReaderLength()); + reader.Read(file, 0, 0); + return reader; + } + + private static FileHeader DetectFileHeader(LocalObjectContainer file, ByteArrayBuffer + reader) + { + for (int i = 0; i < AvailableFileHeaders.Length; i++) + { + reader.Seek(0); + FileHeader result = AvailableFileHeaders[i].NewOnSignatureMatch(file, reader); + if (result != null) + { + return result; + } + } + return null; + } + + /// + public abstract void Close(); + + /// + public abstract void InitNew(LocalObjectContainer file); + + public abstract void CompleteInterruptedTransaction(LocalObjectContainer container + ); + + public abstract int Length(); + + protected abstract FileHeader NewOnSignatureMatch(LocalObjectContainer file, ByteArrayBuffer + reader); + + protected virtual long TimeToWrite(long time, bool shuttingDown) + { + return shuttingDown ? 0 : time; + } + + protected abstract void Read(LocalObjectContainer file, ByteArrayBuffer reader); + + protected virtual bool SignatureMatches(ByteArrayBuffer reader, byte[] signature, + byte version) + { + for (int i = 0; i < signature.Length; i++) + { + if (reader.ReadByte() != signature[i]) + { + return false; + } + } + return reader.ReadByte() == version; + } + + // TODO: freespaceID should not be passed here, it should be taken from SystemData + public abstract void WriteFixedPart(LocalObjectContainer file, bool startFileLockingThread + , bool shuttingDown, StatefulBuffer writer, int blockSize); + + public abstract void WriteTransactionPointer(Transaction systemTransaction, int transactionPointer + ); + + protected virtual void WriteTransactionPointer(Transaction systemTransaction, int + transactionPointer, int address, int offset) + { + StatefulBuffer bytes = new StatefulBuffer(systemTransaction, address, TransactionPointerLength + ); + bytes.MoveForward(offset); + bytes.WriteInt(transactionPointer); + bytes.WriteInt(transactionPointer); + // Dangerous write. + // On corruption transaction pointers will not be the same and nothing will happen. + bytes.Write(); + } + + public virtual void WriteVariablePart(LocalObjectContainer file) + { + WriteVariablePart(file, false); + } + + public abstract void WriteVariablePart(LocalObjectContainer file, bool shuttingDown + ); + + public static bool LockedByOtherSession(LocalObjectContainer container, long lastAccessTime + ) + { + return container.NeedsLockFileThread() && (lastAccessTime != 0); + } + + public abstract void ReadIdentity(LocalObjectContainer container); + + public abstract IRunnable Commit(bool shuttingDown); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Fileheader/FileHeaderVariablePart1.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Fileheader/FileHeaderVariablePart1.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Fileheader/FileHeaderVariablePart1.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Fileheader/FileHeaderVariablePart1.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,81 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Fileheader; +using Db4objects.Db4o.Internal.Slots; +using Sharpen.Lang; + +namespace Db4objects.Db4o.Internal.Fileheader +{ + /// + public class FileHeaderVariablePart1 : FileHeaderVariablePart + { + private const int Length = 1 + (Const4.IntLength * 4) + Const4.LongLength + Const4 + .AddedLength; + + private int _id; + + public FileHeaderVariablePart1(LocalObjectContainer container, int id) : base(container + ) + { + // The variable part format is: + // (int) converter version + // (byte) freespace system used + // (int) freespace address + // (int) identity ID + // (long) versionGenerator + // (int) uuid index ID + _id = id; + } + + public FileHeaderVariablePart1(LocalObjectContainer container) : this(container, + 0) + { + } + + public virtual int OwnLength() + { + return Length; + } + + public virtual void ReadThis(ByteArrayBuffer buffer) + { + SystemData().ConverterVersion(buffer.ReadInt()); + SystemData().FreespaceSystem(buffer.ReadByte()); + buffer.ReadInt(); + // was BTreeFreespaceId, converted to slot, can no longer be used + SystemData().IdentityId(buffer.ReadInt()); + SystemData().LastTimeStampID(buffer.ReadLong()); + SystemData().UuidIndexId(buffer.ReadInt()); + } + + public virtual void WriteThis(ByteArrayBuffer buffer) + { + throw new InvalidOperationException(); + } + + public override IRunnable Commit(bool shuttingDown) + { + throw new InvalidOperationException(); + } + + public virtual int Id() + { + return _id; + } + + public override void Read(int variablePartID, int unused) + { + _id = variablePartID; + Slot slot = _container.ReadPointerSlot(_id); + ByteArrayBuffer buffer = _container.ReadBufferBySlot(slot); + ReadThis(buffer); + } + + public override int MarshalledLength() + { + return OwnLength(); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Fileheader/FileHeaderVariablePart2.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Fileheader/FileHeaderVariablePart2.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Fileheader/FileHeaderVariablePart2.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Fileheader/FileHeaderVariablePart2.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,283 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Ext; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Fileheader; +using Db4objects.Db4o.Internal.Slots; +using Sharpen.Lang; + +namespace Db4objects.Db4o.Internal.Fileheader +{ + /// + public class FileHeaderVariablePart2 : FileHeaderVariablePart + { + private const int ChecksumLength = Const4.LongLength; + + private const int SingleLength = ChecksumLength + (Const4.IntLength * 8) + Const4 + .LongLength + 1 + Const4.AddedLength; + + private int _address; + + private int _length; + + public FileHeaderVariablePart2(LocalObjectContainer container, int address, int length + ) : base(container) + { + // The variable part format is: + // (long) checksum + // (int) address of InMemoryIdSystem slot + // (int) length of InMemoryIdSystem slot + // (int) address of InMemoryFreespace + // (int) length of InMemoryFreespace + // (int) BTreeFreespace id + // (int) converter version + // (int) uuid index ID + // (int) identity ID + // (long) versionGenerator + // (byte) freespace system used + _address = address; + _length = length; + } + + public FileHeaderVariablePart2(LocalObjectContainer container) : this(container, + 0, 0) + { + } + + public override IRunnable Commit(bool shuttingDown) + { + int length = OwnLength(); + if (_address == 0 || _length < length) + { + Slot slot = AllocateSlot(MarshalledLength(length)); + _address = slot.Address(); + _length = length; + } + ByteArrayBuffer buffer = new ByteArrayBuffer(length); + Marshall(buffer, shuttingDown); + WriteToFile(0, buffer); + return new _IRunnable_65(this, length, buffer); + } + + private sealed class _IRunnable_65 : IRunnable + { + public _IRunnable_65(FileHeaderVariablePart2 _enclosing, int length, ByteArrayBuffer + buffer) + { + this._enclosing = _enclosing; + this.length = length; + this.buffer = buffer; + } + + public void Run() + { + this._enclosing.WriteToFile(length * 2, buffer); + } + + private readonly FileHeaderVariablePart2 _enclosing; + + private readonly int length; + + private readonly ByteArrayBuffer buffer; + } + + private int MarshalledLength(int length) + { + return length * 4; + } + + private void WriteToFile(int startAdress, ByteArrayBuffer buffer) + { + _container.WriteEncrypt(buffer, _address, startAdress); + _container.WriteEncrypt(buffer, _address, startAdress + _length); + } + + public virtual int OwnLength() + { + return SingleLength; + } + + public virtual int Address() + { + return _address; + } + + public virtual int Length() + { + return _length; + } + + public override void Read(int address, int length) + { + _address = address; + _length = length; + ByteArrayBuffer buffer = _container.ReadBufferBySlot(new Slot(address, MarshalledLength + (length))); + bool versionsAreConsistent = VersionsAreConsistentAndSeek(buffer); + // TODO: Diagnostic message if versions aren't consistent. + ReadBuffer(buffer, versionsAreConsistent); + } + + protected virtual void ReadBuffer(ByteArrayBuffer buffer, bool versionsAreConsistent + ) + { + buffer.IncrementOffset(ChecksumLength); + SystemData systemData = SystemData(); + systemData.IdSystemSlot(ReadSlot(buffer, false)); + systemData.InMemoryFreespaceSlot(ReadSlot(buffer, !versionsAreConsistent)); + systemData.BTreeFreespaceId(buffer.ReadInt()); + systemData.ConverterVersion(buffer.ReadInt()); + systemData.UuidIndexId(buffer.ReadInt()); + systemData.IdentityId(buffer.ReadInt()); + systemData.LastTimeStampID(buffer.ReadLong()); + systemData.FreespaceSystem(buffer.ReadByte()); + } + + private Slot ReadSlot(ByteArrayBuffer buffer, bool readZero) + { + Slot slot = new Slot(buffer.ReadInt(), buffer.ReadInt()); + if (readZero) + { + return Slot.Zero; + } + return slot; + } + + private void Marshall(ByteArrayBuffer buffer, bool shuttingDown) + { + int checkSumOffset = buffer.Offset(); + buffer.IncrementOffset(ChecksumLength); + int checkSumBeginOffset = buffer.Offset(); + WriteBuffer(buffer, shuttingDown); + int checkSumEndOffSet = buffer.Offset(); + byte[] bytes = buffer._buffer; + int length = checkSumEndOffSet - checkSumBeginOffset; + long checkSum = CRC32.CheckSum(bytes, checkSumBeginOffset, length); + buffer.Seek(checkSumOffset); + buffer.WriteLong(checkSum); + buffer.Seek(checkSumEndOffSet); + } + + protected virtual void WriteBuffer(ByteArrayBuffer buffer, bool shuttingDown) + { + SystemData systemData = SystemData(); + WriteSlot(buffer, systemData.IdSystemSlot(), false); + WriteSlot(buffer, systemData.InMemoryFreespaceSlot(), !shuttingDown); + buffer.WriteInt(systemData.BTreeFreespaceId()); + buffer.WriteInt(systemData.ConverterVersion()); + buffer.WriteInt(systemData.UuidIndexId()); + Db4oDatabase identity = systemData.Identity(); + buffer.WriteInt(identity == null ? 0 : identity.GetID(_container.SystemTransaction + ())); + buffer.WriteLong(systemData.LastTimeStampID()); + buffer.WriteByte(systemData.FreespaceSystem()); + } + + private void WriteSlot(ByteArrayBuffer buffer, Slot slot, bool writeZero) + { + if (writeZero || slot == null) + { + buffer.WriteInt(0); + buffer.WriteInt(0); + return; + } + buffer.WriteInt(slot.Address()); + buffer.WriteInt(slot.Length()); + } + + private bool CheckSumOK(ByteArrayBuffer buffer, int offset) + { + int initialOffSet = buffer.Offset(); + int length = OwnLength(); + length -= ChecksumLength; + buffer.Seek(offset); + long readCheckSum = buffer.ReadLong(); + int checkSumBeginOffset = buffer.Offset(); + byte[] bytes = buffer._buffer; + long calculatedCheckSum = CRC32.CheckSum(bytes, checkSumBeginOffset, length); + buffer.Seek(initialOffSet); + return calculatedCheckSum == readCheckSum; + } + + private bool VersionsAreConsistentAndSeek(ByteArrayBuffer buffer) + { + byte[] bytes = buffer._buffer; + int length = OwnLength(); + int[] offsets = Offsets(); + bool different = false; + for (int i = 0; i < length; i++) + { + byte b = bytes[offsets[0] + i]; + for (int j = 1; j < 4; j++) + { + if (b != bytes[offsets[j] + i]) + { + different = true; + break; + } + } + } + if (!different) + { + // The following line cements our checksum algorithm in stone. + // Things should be safe enough if we remove the throw. + // If all four versions of the header are the same, + // it's bound to be OK. (unless all bytes are zero or + // greyed out by some kind of overwriting algorithm.) + int firstOffset = 0; + if (!CheckSumOK(buffer, firstOffset)) + { + throw new Db4oFileHeaderCorruptionException(); + } + return true; + } + bool firstPairDiffers = false; + bool secondPairDiffers = false; + for (int i = 0; i < length; i++) + { + if (bytes[offsets[0] + i] != bytes[offsets[1] + i]) + { + firstPairDiffers = true; + } + if (bytes[offsets[2] + i] != bytes[offsets[3] + i]) + { + secondPairDiffers = true; + } + } + if (!secondPairDiffers) + { + if (CheckSumOK(buffer, offsets[2])) + { + buffer.Seek(offsets[2]); + return false; + } + } + if (firstPairDiffers) + { + // Should never ever happen, we are toast. + // We could still try to use any random version of + // the header but which one? + // Maybe the first of the second pair could be an + // option for a recovery tool, or it could try all + // versions. + throw new Db4oFileHeaderCorruptionException(); + } + if (!CheckSumOK(buffer, 0)) + { + throw new Db4oFileHeaderCorruptionException(); + } + return false; + } + + private int[] Offsets() + { + return new int[] { 0, OwnLength(), OwnLength() * 2, OwnLength() * 3 }; + } + + public override int MarshalledLength() + { + return MarshalledLength(OwnLength()); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Fileheader/FileHeaderVariablePart3.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Fileheader/FileHeaderVariablePart3.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Fileheader/FileHeaderVariablePart3.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Fileheader/FileHeaderVariablePart3.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,37 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Fileheader; + +namespace Db4objects.Db4o.Internal.Fileheader +{ + /// + public class FileHeaderVariablePart3 : FileHeaderVariablePart2 + { + public FileHeaderVariablePart3(LocalObjectContainer container) : base(container) + { + } + + public override int OwnLength() + { + return base.OwnLength() + Const4.IntLength * 2; + } + + protected override void ReadBuffer(ByteArrayBuffer buffer, bool versionsAreConsistent + ) + { + base.ReadBuffer(buffer, versionsAreConsistent); + SystemData systemData = SystemData(); + systemData.IdToTimestampIndexId(buffer.ReadInt()); + systemData.TimestampToIdIndexId(buffer.ReadInt()); + } + + protected override void WriteBuffer(ByteArrayBuffer buffer, bool shuttingDown) + { + base.WriteBuffer(buffer, shuttingDown); + SystemData systemData = SystemData(); + buffer.WriteInt(systemData.IdToTimestampIndexId()); + buffer.WriteInt(systemData.TimestampToIdIndexId()); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Fileheader/FileHeaderVariablePart.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Fileheader/FileHeaderVariablePart.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Fileheader/FileHeaderVariablePart.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Fileheader/FileHeaderVariablePart.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,65 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o; +using Db4objects.Db4o.Ext; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Activation; +using Db4objects.Db4o.Internal.Slots; +using Sharpen.Lang; + +namespace Db4objects.Db4o.Internal.Fileheader +{ + /// + public abstract class FileHeaderVariablePart + { + protected readonly LocalObjectContainer _container; + + public abstract IRunnable Commit(bool shuttingDown); + + public abstract void Read(int variablePartAddress, int variablePartLength); + + protected FileHeaderVariablePart(LocalObjectContainer container) + { + _container = container; + } + + public byte GetIdentifier() + { + return Const4.Header; + } + + protected Db4objects.Db4o.Internal.SystemData SystemData() + { + return _container.SystemData(); + } + + protected Slot AllocateSlot(int length) + { + Slot reusedSlot = _container.FreespaceManager().AllocateSafeSlot(length); + if (reusedSlot != null) + { + return reusedSlot; + } + return _container.AppendBytes(length); + } + + public virtual void ReadIdentity(LocalTransaction trans) + { + LocalObjectContainer file = trans.LocalContainer(); + Db4oDatabase identity = Debug4.staticIdentity ? Db4oDatabase.StaticIdentity : (Db4oDatabase + )file.GetByID(trans, SystemData().IdentityId()); + if (null != identity) + { + file.Activate(trans, identity, new FixedActivationDepth(2)); + SystemData().Identity(identity); + } + } + + // TODO: What now? + // Apparently we get this state after defragment + // and defragment then sets the identity. + // If we blindly generate a new identity here, + // ObjectUpdateFileSizeTestCase reports trouble. + public abstract int MarshalledLength(); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Fileheader/NewFileHeaderBase.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Fileheader/NewFileHeaderBase.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Fileheader/NewFileHeaderBase.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Fileheader/NewFileHeaderBase.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,120 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Fileheader; +using Sharpen.Lang; + +namespace Db4objects.Db4o.Internal.Fileheader +{ + /// + public abstract class NewFileHeaderBase : FileHeader + { + protected static readonly byte[] Signature = new byte[] { (byte)'d', (byte)'b', ( + byte)'4', (byte)'o' }; + + protected static readonly int HeaderLockOffset = Signature.Length + 1; + + protected static readonly int OpenTimeOffset = HeaderLockOffset + Const4.IntLength; + + protected static readonly int AccessTimeOffset = OpenTimeOffset + Const4.LongLength; + + protected TimerFileLock _timerFileLock; + + protected FileHeaderVariablePart _variablePart; + + /// + public override void Close() + { + if (_timerFileLock == null) + { + return; + } + _timerFileLock.Close(); + } + + protected virtual void NewTimerFileLock(LocalObjectContainer file) + { + _timerFileLock = TimerFileLock.ForFile(file); + _timerFileLock.SetAddresses(0, OpenTimeOffset, AccessTimeOffset); + } + + protected abstract NewFileHeaderBase CreateNew(); + + protected abstract byte Version(); + + /// + public sealed override void InitNew(LocalObjectContainer file) + { + NewTimerFileLock(file); + OldEncryptionOff(file); + _variablePart = CreateVariablePart(file); + WriteVariablePart(file); + } + + public abstract FileHeaderVariablePart CreateVariablePart(LocalObjectContainer file + ); + + protected virtual void OldEncryptionOff(LocalObjectContainer file) + { + file._handlers.OldEncryptionOff(); + } + + public sealed override void WriteVariablePart(LocalObjectContainer file, bool shuttingDown + ) + { + if (!IsInitalized()) + { + return; + } + IRunnable commitHook = Commit(shuttingDown); + file.SyncFiles(); + commitHook.Run(); + file.SyncFiles(); + } + + private bool IsInitalized() + { + return _variablePart != null; + } + + protected override FileHeader NewOnSignatureMatch(LocalObjectContainer file, ByteArrayBuffer + reader) + { + if (SignatureMatches(reader, Signature, Version())) + { + return CreateNew(); + } + return null; + } + + public override void CompleteInterruptedTransaction(LocalObjectContainer container + ) + { + SystemData systemData = container.SystemData(); + container.IdSystem().CompleteInterruptedTransaction(systemData.TransactionPointer1 + (), systemData.TransactionPointer2()); + } + + protected virtual void CheckThreadFileLock(LocalObjectContainer container, ByteArrayBuffer + reader) + { + reader.Seek(AccessTimeOffset); + long lastAccessTime = reader.ReadLong(); + if (FileHeader.LockedByOtherSession(container, lastAccessTime)) + { + _timerFileLock.CheckIfOtherSessionAlive(container, 0, AccessTimeOffset, lastAccessTime + ); + } + } + + public override void ReadIdentity(LocalObjectContainer container) + { + _variablePart.ReadIdentity((LocalTransaction)container.SystemTransaction()); + } + + public override IRunnable Commit(bool shuttingDown) + { + return _variablePart.Commit(shuttingDown); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Fileheader/TimerFileLock.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Fileheader/TimerFileLock.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Fileheader/TimerFileLock.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Fileheader/TimerFileLock.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,44 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Fileheader; +using Sharpen.Lang; + +namespace Db4objects.Db4o.Internal.Fileheader +{ + /// + public abstract class TimerFileLock : IRunnable + { + public static TimerFileLock ForFile(LocalObjectContainer file) + { + return new TimerFileLockDisabled(); + } + + public abstract void CheckHeaderLock(); + + public abstract void CheckOpenTime(); + + public abstract bool LockFile(); + + public abstract long OpenTime(); + + public abstract void SetAddresses(int baseAddress, int openTimeOffset, int accessTimeOffset + ); + + /// + public abstract void Start(); + + public abstract void WriteHeaderLock(); + + public abstract void WriteOpenTime(); + + /// + public abstract void Close(); + + /// + public abstract void CheckIfOtherSessionAlive(LocalObjectContainer container, int + address, int offset, long lastAccessTime); + + public abstract void Run(); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Fileheader/TimerFileLockDisabled.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Fileheader/TimerFileLockDisabled.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Fileheader/TimerFileLockDisabled.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Fileheader/TimerFileLockDisabled.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,60 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Fileheader; + +namespace Db4objects.Db4o.Internal.Fileheader +{ + /// + public class TimerFileLockDisabled : TimerFileLock + { + public override void CheckHeaderLock() + { + } + + public override void CheckOpenTime() + { + } + + public override void Close() + { + } + + public override bool LockFile() + { + return false; + } + + public override long OpenTime() + { + return 0; + } + + public override void Run() + { + } + + public override void SetAddresses(int baseAddress, int openTimeOffset, int accessTimeOffset + ) + { + } + + public override void Start() + { + } + + public override void WriteHeaderLock() + { + } + + public override void WriteOpenTime() + { + } + + /// + public override void CheckIfOtherSessionAlive(LocalObjectContainer container, int + address, int offset, long lastAccessTime) + { + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Freespace/AbstractFreespaceManager.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Freespace/AbstractFreespaceManager.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Freespace/AbstractFreespaceManager.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Freespace/AbstractFreespaceManager.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,267 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Freespace; +using Db4objects.Db4o.Internal.Slots; + +namespace Db4objects.Db4o.Internal.Freespace +{ + public abstract class AbstractFreespaceManager : IFreespaceManager + { + public const byte FmDebug = 127; + + public const byte FmDefault = 0; + + public const byte FmLegacyRam = 1; + + public const byte FmRam = 2; + + public const byte FmIx = 3; + + public const byte FmBtree = 4; + + private const int IntsInSlot = 12; + + public const int RemainderSizeLimit = 20; + + public static byte CheckType(byte systemType) + { + if (systemType == FmDefault) + { + return FmRam; + } + return systemType; + } + + protected IProcedure4 _slotFreedCallback; + + private readonly int _discardLimit; + + public AbstractFreespaceManager(IProcedure4 slotFreedCallback, int discardLimit) + { + _slotFreedCallback = slotFreedCallback; + _discardLimit = discardLimit; + } + + public static Db4objects.Db4o.Internal.Freespace.AbstractFreespaceManager CreateNew + (LocalObjectContainer file) + { + return CreateNew(file, file.SystemData().FreespaceSystem()); + } + + public static Db4objects.Db4o.Internal.Freespace.AbstractFreespaceManager CreateNew + (LocalObjectContainer file, byte systemType) + { + systemType = CheckType(systemType); + int unblockedDiscardLimit = file.ConfigImpl.DiscardFreeSpace(); + int blockedDiscardLimit = unblockedDiscardLimit == int.MaxValue ? unblockedDiscardLimit + : file.BlockConverter().BytesToBlocks(unblockedDiscardLimit); + IProcedure4 slotFreedCallback = new _IProcedure4_50(file); + switch (systemType) + { + case FmIx: + { + return new FreespaceManagerIx(blockedDiscardLimit); + } + + case FmBtree: + { + return new BTreeFreespaceManager(file, slotFreedCallback, blockedDiscardLimit); + } + + default: + { + return new InMemoryFreespaceManager(slotFreedCallback, blockedDiscardLimit); + break; + } + } + } + + private sealed class _IProcedure4_50 : IProcedure4 + { + public _IProcedure4_50(LocalObjectContainer file) + { + this.file = file; + } + + public void Apply(object slot) + { + file.OverwriteDeletedBlockedSlot(((Slot)slot)); + } + + private readonly LocalObjectContainer file; + } + + public static int InitSlot(LocalObjectContainer file) + { + int address = file.AllocateSlot(SlotLength()).Address(); + SlotEntryToZeroes(file, address); + return address; + } + + public virtual void MigrateTo(IFreespaceManager fm) + { + Traverse(new _IVisitor4_72(fm)); + } + + private sealed class _IVisitor4_72 : IVisitor4 + { + public _IVisitor4_72(IFreespaceManager fm) + { + this.fm = fm; + } + + public void Visit(object obj) + { + fm.Free((Slot)obj); + } + + private readonly IFreespaceManager fm; + } + + internal static void SlotEntryToZeroes(LocalObjectContainer file, int address) + { + StatefulBuffer writer = new StatefulBuffer(file.SystemTransaction(), address, SlotLength + ()); + for (int i = 0; i < IntsInSlot; i++) + { + writer.WriteInt(0); + } + writer.WriteEncrypt(); + } + + internal static int SlotLength() + { + return Const4.IntLength * IntsInSlot; + } + + public virtual int TotalFreespace() + { + IntByRef mint = new IntByRef(); + Traverse(new _IVisitor4_97(mint)); + return mint.value; + } + + private sealed class _IVisitor4_97 : IVisitor4 + { + public _IVisitor4_97(IntByRef mint) + { + this.mint = mint; + } + + public void Visit(object obj) + { + Slot slot = (Slot)obj; + mint.value += slot.Length(); + } + + private readonly IntByRef mint; + } + + protected virtual int DiscardLimit() + { + return _discardLimit; + } + + protected bool SplitRemainder(int length) + { + if (CanDiscard(length)) + { + return false; + } + return length > RemainderSizeLimit; + } + + internal bool CanDiscard(int length) + { + return length == 0 || length < DiscardLimit(); + } + + public static void Migrate(IFreespaceManager oldFM, IFreespaceManager newFM) + { + oldFM.MigrateTo(newFM); + oldFM.FreeSelf(); + } + + public virtual void DebugCheckIntegrity() + { + IntByRef lastStart = new IntByRef(); + IntByRef lastEnd = new IntByRef(); + Traverse(new _IVisitor4_129(lastEnd, lastStart)); + } + + private sealed class _IVisitor4_129 : IVisitor4 + { + public _IVisitor4_129(IntByRef lastEnd, IntByRef lastStart) + { + this.lastEnd = lastEnd; + this.lastStart = lastStart; + } + + public void Visit(object obj) + { + Slot slot = (Slot)obj; + if (slot.Address() <= lastEnd.value) + { + throw new InvalidOperationException(); + } + lastStart.value = slot.Address(); + lastEnd.value = slot.Address() + slot.Length(); + } + + private readonly IntByRef lastEnd; + + private readonly IntByRef lastStart; + } + + public static bool MigrationRequired(byte systemType) + { + return systemType == FmLegacyRam || systemType == FmIx; + } + + public virtual void SlotFreed(Slot slot) + { + if (_slotFreedCallback == null) + { + return; + } + _slotFreedCallback.Apply(slot); + } + + public abstract Slot AllocateSafeSlot(int arg1); + + public abstract Slot AllocateSlot(int arg1); + + public abstract Slot AllocateTransactionLogSlot(int arg1); + + public abstract void BeginCommit(); + + public abstract void Commit(); + + public abstract void EndCommit(); + + public abstract void Free(Slot arg1); + + public abstract void FreeSafeSlot(Slot arg1); + + public abstract void FreeSelf(); + + public abstract bool IsStarted(); + + public abstract void Listener(IFreespaceListener arg1); + + public abstract void Read(LocalObjectContainer arg1, Slot arg2); + + public abstract int SlotCount(); + + public abstract void Start(int arg1); + + public abstract byte SystemType(); + + public abstract void Traverse(IVisitor4 arg1); + + public abstract void Write(LocalObjectContainer arg1); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Freespace/AddressKeySlotHandler.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Freespace/AddressKeySlotHandler.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Freespace/AddressKeySlotHandler.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Freespace/AddressKeySlotHandler.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,43 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal.Freespace; +using Db4objects.Db4o.Internal.Slots; +using Db4objects.Db4o.Marshall; + +namespace Db4objects.Db4o.Internal.Freespace +{ + /// + public class AddressKeySlotHandler : SlotHandler + { + public virtual int CompareTo(object obj) + { + return _current.CompareByAddress((Slot)obj); + } + + public override IPreparedComparison PrepareComparison(IContext context, object slot + ) + { + Slot sourceSlot = (Slot)slot; + return new _IPreparedComparison_21(sourceSlot); + } + + private sealed class _IPreparedComparison_21 : IPreparedComparison + { + public _IPreparedComparison_21(Slot sourceSlot) + { + this.sourceSlot = sourceSlot; + } + + public int CompareTo(object obj) + { + Slot targetSlot = (Slot)obj; + // FIXME: The comparison method in #compareByAddress is the wrong way around. + // Fix there and here after other references are fixed. + return -sourceSlot.CompareByAddress(targetSlot); + } + + private readonly Slot sourceSlot; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Freespace/BlockAwareFreespaceManager.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Freespace/BlockAwareFreespaceManager.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Freespace/BlockAwareFreespaceManager.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Freespace/BlockAwareFreespaceManager.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,159 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Freespace; +using Db4objects.Db4o.Internal.Slots; + +namespace Db4objects.Db4o.Internal.Freespace +{ + /// + public class BlockAwareFreespaceManager : IFreespaceManager + { + private readonly IFreespaceManager _delegate; + + private readonly IBlockConverter _blockConverter; + + public BlockAwareFreespaceManager(IFreespaceManager delegate_, IBlockConverter blockConverter + ) + { + _delegate = delegate_; + _blockConverter = blockConverter; + } + + public virtual Slot AllocateSlot(int length) + { + Slot slot = _delegate.AllocateSlot(_blockConverter.BytesToBlocks(length)); + if (slot == null) + { + return null; + } + return _blockConverter.ToNonBlockedLength(slot); + } + + public virtual Slot AllocateSafeSlot(int length) + { + Slot slot = _delegate.AllocateSafeSlot(_blockConverter.BytesToBlocks(length)); + if (slot == null) + { + return null; + } + return _blockConverter.ToNonBlockedLength(slot); + } + + public virtual void BeginCommit() + { + _delegate.BeginCommit(); + } + + public virtual void Commit() + { + _delegate.Commit(); + } + + public virtual void EndCommit() + { + _delegate.EndCommit(); + } + + public virtual void Free(Slot slot) + { + _delegate.Free(_blockConverter.ToBlockedLength(slot)); + } + + public virtual void FreeSelf() + { + _delegate.FreeSelf(); + } + + public virtual void FreeSafeSlot(Slot slot) + { + _delegate.FreeSafeSlot(_blockConverter.ToBlockedLength(slot)); + } + + public virtual void Listener(IFreespaceListener listener) + { + _delegate.Listener(listener); + } + + public virtual void MigrateTo(IFreespaceManager fm) + { + throw new InvalidOperationException(); + } + + public virtual int SlotCount() + { + return _delegate.SlotCount(); + } + + public virtual void Start(int id) + { + throw new InvalidOperationException(); + } + + public virtual byte SystemType() + { + return _delegate.SystemType(); + } + + public virtual int TotalFreespace() + { + return _blockConverter.BlocksToBytes(_delegate.TotalFreespace()); + } + + public virtual void Traverse(IVisitor4 visitor) + { + _delegate.Traverse(new _IVisitor4_89(this, visitor)); + } + + private sealed class _IVisitor4_89 : IVisitor4 + { + public _IVisitor4_89(BlockAwareFreespaceManager _enclosing, IVisitor4 visitor) + { + this._enclosing = _enclosing; + this.visitor = visitor; + } + + public void Visit(object slot) + { + visitor.Visit(this._enclosing._blockConverter.ToNonBlockedLength(((Slot)slot))); + } + + private readonly BlockAwareFreespaceManager _enclosing; + + private readonly IVisitor4 visitor; + } + + public virtual void Write(LocalObjectContainer container) + { + _delegate.Write(container); + } + + public virtual void SlotFreed(Slot slot) + { + _delegate.SlotFreed(slot); + } + + public virtual bool IsStarted() + { + return _delegate.IsStarted(); + } + + public virtual Slot AllocateTransactionLogSlot(int length) + { + Slot slot = _delegate.AllocateTransactionLogSlot(_blockConverter.BytesToBlocks(length + )); + if (slot == null) + { + return null; + } + return _blockConverter.ToNonBlockedLength(slot); + } + + public virtual void Read(LocalObjectContainer container, Slot slot) + { + throw new InvalidOperationException(); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Freespace/BTreeFreespaceManager.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Freespace/BTreeFreespaceManager.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Freespace/BTreeFreespaceManager.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Freespace/BTreeFreespaceManager.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,339 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Btree; +using Db4objects.Db4o.Internal.Freespace; +using Db4objects.Db4o.Internal.Ids; +using Db4objects.Db4o.Internal.Slots; + +namespace Db4objects.Db4o.Internal.Freespace +{ + /// + public class BTreeFreespaceManager : AbstractFreespaceManager + { + private readonly LocalObjectContainer _file; + + private InMemoryFreespaceManager _delegate; + + private BTree _slotsByAddress; + + private BTree _slotsByLength; + + private PersistentIntegerArray _idArray; + + private int _delegationRequests; + + private IFreespaceListener _listener = NullFreespaceListener.Instance; + + private ITransactionalIdSystem _idSystem; + + public BTreeFreespaceManager(LocalObjectContainer file, IProcedure4 slotFreedCallback + , int discardLimit) : base(slotFreedCallback, discardLimit) + { + _file = file; + _delegate = new InMemoryFreespaceManager(slotFreedCallback, discardLimit); + _idSystem = file.SystemData().FreespaceIdSystem(); + } + + private void AddSlot(Slot slot) + { + _slotsByLength.Add(Transaction(), slot); + _slotsByAddress.Add(Transaction(), slot); + _listener.SlotAdded(slot.Length()); + } + + public override Slot AllocateSafeSlot(int length) + { + return _delegate.AllocateSafeSlot(length); + } + + public override void BeginCommit() + { + BeginDelegation(); + } + + private void BeginDelegation() + { + _delegationRequests++; + } + + public override void Commit() + { + _slotsByAddress.Commit(Transaction()); + _slotsByLength.Commit(Transaction()); + } + + private void CreateBTrees(int addressID, int lengthID) + { + BTreeConfiguration config = new BTreeConfiguration(_idSystem, SlotChangeFactory.FreeSpace + , 64, false); + _slotsByAddress = new BTree(Transaction(), config, addressID, new AddressKeySlotHandler + ()); + _slotsByLength = new BTree(Transaction(), config, lengthID, new LengthKeySlotHandler + ()); + } + + public override void EndCommit() + { + EndDelegation(); + } + + private void EndDelegation() + { + _delegationRequests--; + } + + public override void Free(Slot slot) + { + if (!IsStarted()) + { + return; + } + if (IsDelegating()) + { + _delegate.Free(slot); + return; + } + try + { + BeginDelegation(); + if (DTrace.enabled) + { + DTrace.FreespacemanagerBtreeFree.LogLength(slot.Address(), slot.Length()); + } + Slot[] remove = new Slot[2]; + Slot newFreeSlot = slot; + BTreePointer pointer = SearchBTree(_slotsByAddress, slot, SearchTarget.Lowest); + BTreePointer previousPointer = pointer != null ? pointer.Previous() : _slotsByAddress + .LastPointer(Transaction()); + if (previousPointer != null) + { + Slot previousSlot = (Slot)previousPointer.Key(); + if (previousSlot.IsDirectlyPreceding(newFreeSlot)) + { + remove[0] = previousSlot; + newFreeSlot = previousSlot.Append(newFreeSlot); + } + } + if (pointer != null) + { + Slot nextSlot = (Slot)pointer.Key(); + if (newFreeSlot.IsDirectlyPreceding(nextSlot)) + { + remove[1] = nextSlot; + newFreeSlot = newFreeSlot.Append(nextSlot); + } + } + for (int i = 0; i < remove.Length; i++) + { + if (remove[i] != null) + { + RemoveSlot(remove[i]); + } + } + if (!CanDiscard(newFreeSlot.Length())) + { + AddSlot(newFreeSlot); + } + SlotFreed(slot); + } + finally + { + EndDelegation(); + } + } + + public override void FreeSelf() + { + _slotsByAddress.Free(Transaction()); + _slotsByLength.Free(Transaction()); + } + + public override void FreeSafeSlot(Slot slot) + { + _delegate.FreeSafeSlot(slot); + } + + public override Slot AllocateSlot(int length) + { + if (!IsStarted()) + { + return null; + } + if (IsDelegating()) + { + return _delegate.AllocateSlot(length); + } + try + { + BeginDelegation(); + BTreePointer pointer = SearchBTree(_slotsByLength, new Slot(0, length), SearchTarget + .Highest); + if (pointer == null) + { + return null; + } + Slot slot = (Slot)pointer.Key(); + RemoveSlot(slot); + int remainingLength = slot.Length() - length; + if (SplitRemainder(remainingLength)) + { + AddSlot(slot.SubSlot(length)); + slot = slot.Truncate(length); + } + if (DTrace.enabled) + { + DTrace.FreespacemanagerGetSlot.LogLength(slot.Address(), slot.Length()); + } + return slot; + } + finally + { + EndDelegation(); + } + } + + private void InitializeExisting(int id) + { + _idArray = new PersistentIntegerArray(SlotChangeFactory.FreeSpace, _idSystem, id); + _idArray.Read(Transaction()); + int[] ids = _idArray.Array(); + int addressId = ids[0]; + int lengthID = ids[1]; + CreateBTrees(addressId, lengthID); + _slotsByAddress.Read(Transaction()); + _slotsByLength.Read(Transaction()); + _delegate.Read(_file, _file.SystemData().InMemoryFreespaceSlot()); + } + + private void InitializeNew() + { + CreateBTrees(0, 0); + _slotsByAddress.Write(Transaction()); + _slotsByLength.Write(Transaction()); + int[] ids = new int[] { _slotsByAddress.GetID(), _slotsByLength.GetID() }; + _idArray = new PersistentIntegerArray(SlotChangeFactory.FreeSpace, _idSystem, ids + ); + _idArray.Write(Transaction()); + _file.SystemData().BTreeFreespaceId(_idArray.GetID()); + } + + private bool IsDelegating() + { + return _delegationRequests > 0; + } + + public virtual void Read(LocalObjectContainer container, int freeSpaceID) + { + } + + // do nothing + // reading happens in start( ) + private void RemoveSlot(Slot slot) + { + _slotsByLength.Remove(Transaction(), slot); + _slotsByAddress.Remove(Transaction(), slot); + _listener.SlotRemoved(slot.Length()); + } + + private BTreePointer SearchBTree(BTree bTree, Slot slot, SearchTarget target) + { + BTreeNodeSearchResult searchResult = bTree.SearchLeaf(Transaction(), slot, target + ); + return searchResult.FirstValidPointer(); + } + + public override int SlotCount() + { + return _slotsByAddress.Size(Transaction()) + _delegate.SlotCount(); + } + + public override void Start(int id) + { + try + { + BeginDelegation(); + if (id == 0) + { + InitializeNew(); + } + else + { + InitializeExisting(id); + } + } + finally + { + EndDelegation(); + } + } + + public override bool IsStarted() + { + return _idArray != null; + } + + public override byte SystemType() + { + return FmBtree; + } + + public override string ToString() + { + return _slotsByLength.ToString(); + } + + public override int TotalFreespace() + { + return base.TotalFreespace() + _delegate.TotalFreespace(); + } + + public override void Traverse(IVisitor4 visitor) + { + _slotsByAddress.TraverseKeys(Transaction(), visitor); + } + + public override void MigrateTo(IFreespaceManager fm) + { + base.MigrateTo(fm); + _delegate.MigrateTo(fm); + } + + public override void Write(LocalObjectContainer container) + { + try + { + BeginDelegation(); + _delegate.Write(container); + container.SystemData().BTreeFreespaceId(_idArray.GetID()); + } + finally + { + EndDelegation(); + } + } + + public override void Listener(IFreespaceListener listener) + { + _listener = listener; + } + + private LocalTransaction Transaction() + { + return (LocalTransaction)_file.SystemTransaction(); + } + + public override Slot AllocateTransactionLogSlot(int length) + { + return _delegate.AllocateTransactionLogSlot(length); + } + + public override void Read(LocalObjectContainer container, Slot slot) + { + } + // do nothing + // everything happens in start + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Freespace/FreeSlotNode.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Freespace/FreeSlotNode.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Freespace/FreeSlotNode.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Freespace/FreeSlotNode.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,149 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal; + +namespace Db4objects.Db4o.Internal.Freespace +{ + /// + public sealed class FreeSlotNode : TreeInt + { + internal static int sizeLimit; + + internal Db4objects.Db4o.Internal.Freespace.FreeSlotNode _peer; + + internal FreeSlotNode(int a_key) : base(a_key) + { + } + + public override object ShallowClone() + { + Db4objects.Db4o.Internal.Freespace.FreeSlotNode frslot = new Db4objects.Db4o.Internal.Freespace.FreeSlotNode + (_key); + frslot._peer = _peer; + return base.ShallowCloneInternal(frslot); + } + + internal void CreatePeer(int a_key) + { + _peer = new Db4objects.Db4o.Internal.Freespace.FreeSlotNode(a_key); + _peer._peer = this; + } + + public override bool Duplicates() + { + return true; + } + + public sealed override int OwnLength() + { + return Const4.IntLength * 2; + } + + internal static Tree RemoveGreaterOrEqual(Db4objects.Db4o.Internal.Freespace.FreeSlotNode + a_in, TreeIntObject a_finder) + { + if (a_in == null) + { + return null; + } + int cmp = a_in._key - a_finder._key; + if (cmp == 0) + { + a_finder._object = a_in; + // the highest node in the hierarchy !!! + return a_in.Remove(); + } + if (cmp > 0) + { + a_in._preceding = RemoveGreaterOrEqual((Db4objects.Db4o.Internal.Freespace.FreeSlotNode + )((Tree)a_in._preceding), a_finder); + if (a_finder._object != null) + { + a_in._size--; + return a_in; + } + a_finder._object = a_in; + return a_in.Remove(); + } + a_in._subsequent = RemoveGreaterOrEqual((Db4objects.Db4o.Internal.Freespace.FreeSlotNode + )((Tree)a_in._subsequent), a_finder); + if (a_finder._object != null) + { + a_in._size--; + } + return a_in; + } + + public override object Read(ByteArrayBuffer buffer) + { + int size = buffer.ReadInt(); + int address = buffer.ReadInt(); + if (size > sizeLimit) + { + Db4objects.Db4o.Internal.Freespace.FreeSlotNode node = new Db4objects.Db4o.Internal.Freespace.FreeSlotNode + (size); + node.CreatePeer(address); + if (Deploy.debug && Debug4.xbytes) + { + DebugCheckBuffer(buffer, node); + } + return node; + } + return null; + } + + private void DebugCheckBuffer(ByteArrayBuffer buffer, Db4objects.Db4o.Internal.Freespace.FreeSlotNode + node) + { + if (!(buffer is StatefulBuffer)) + { + return; + } + Transaction trans = ((StatefulBuffer)buffer).Transaction(); + if (!(trans.Container() is IoAdaptedObjectContainer)) + { + return; + } + StatefulBuffer checker = trans.Container().CreateStatefulBuffer(trans, node._peer + ._key, node._key); + checker.Read(); + for (int i = 0; i < node._key; i++) + { + if (checker.ReadByte() != (byte)'X') + { + Sharpen.Runtime.Out.WriteLine("!!! Free space corruption at:" + node._peer._key); + break; + } + } + } + + public sealed override void Write(ByteArrayBuffer a_writer) + { + // byte order: size, address + a_writer.WriteInt(_key); + a_writer.WriteInt(_peer._key); + } + + // public static final void debug(FreeSlotNode a_node){ + // if(a_node == null){ + // return; + // } + // System.out.println("Address:" + a_node.i_key); + // System.out.println("Length:" + a_node.i_peer.i_key); + // debug((FreeSlotNode)a_node.i_preceding); + // debug((FreeSlotNode)a_node.i_subsequent); + // } + public override string ToString() + { + return base.ToString(); + string str = "FreeSlotNode " + _key; + if (_peer != null) + { + str += " peer: " + _peer._key; + } + return str; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Freespace/FreespaceManagerIx.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Freespace/FreespaceManagerIx.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Freespace/FreespaceManagerIx.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Freespace/FreespaceManagerIx.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,108 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Freespace; +using Db4objects.Db4o.Internal.Slots; + +namespace Db4objects.Db4o.Internal.Freespace +{ + /// Old freespacemanager, before version 7.0. + /// + /// Old freespacemanager, before version 7.0. + /// If it is still in use freespace is dropped. + /// BTreeFreespaceManager + /// should be used instead. + /// + public class FreespaceManagerIx : AbstractFreespaceManager + { + public FreespaceManagerIx(int discardLimit) : base(null, discardLimit) + { + } + + public override Slot AllocateSafeSlot(int length) + { + return null; + } + + public override void FreeSafeSlot(Slot slot) + { + } + + // do nothing + public override void BeginCommit() + { + } + + public override void EndCommit() + { + } + + public override int SlotCount() + { + throw new InvalidOperationException(); + } + + public override void Free(Slot slot) + { + } + + // Should no longer be used: Should not happen. + public override void FreeSelf() + { + } + + // do nothing, freespace is dropped. + public override Slot AllocateSlot(int length) + { + // implementation is no longer present, no freespace returned. + return null; + } + + public override void MigrateTo(IFreespaceManager fm) + { + } + + // do nothing, freespace is dropped. + public override void Traverse(IVisitor4 visitor) + { + throw new InvalidOperationException(); + } + + public override void Start(int id) + { + } + + public override byte SystemType() + { + return FmIx; + } + + public override void Write(LocalObjectContainer container) + { + } + + public override void Commit() + { + } + + public override void Listener(IFreespaceListener listener) + { + } + + public override bool IsStarted() + { + return false; + } + + public override Slot AllocateTransactionLogSlot(int length) + { + return null; + } + + public override void Read(LocalObjectContainer container, Slot slot) + { + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Freespace/IFreespaceListener.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Freespace/IFreespaceListener.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Freespace/IFreespaceListener.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Freespace/IFreespaceListener.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,12 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +namespace Db4objects.Db4o.Internal.Freespace +{ + /// + public interface IFreespaceListener + { + void SlotAdded(int size); + + void SlotRemoved(int size); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Freespace/IFreespaceManager.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Freespace/IFreespaceManager.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Freespace/IFreespaceManager.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Freespace/IFreespaceManager.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,53 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Freespace; +using Db4objects.Db4o.Internal.Slots; + +namespace Db4objects.Db4o.Internal.Freespace +{ + /// + public interface IFreespaceManager + { + void BeginCommit(); + + void EndCommit(); + + int SlotCount(); + + void Free(Slot slot); + + void FreeSelf(); + + int TotalFreespace(); + + Slot AllocateTransactionLogSlot(int length); + + Slot AllocateSlot(int length); + + void MigrateTo(IFreespaceManager fm); + + void Read(LocalObjectContainer container, Slot slot); + + void Start(int id); + + byte SystemType(); + + void Traverse(IVisitor4 visitor); + + void Write(LocalObjectContainer container); + + void Commit(); + + Slot AllocateSafeSlot(int length); + + void FreeSafeSlot(Slot slot); + + void Listener(IFreespaceListener listener); + + void SlotFreed(Slot slot); + + bool IsStarted(); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Freespace/InMemoryFreespaceManager.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Freespace/InMemoryFreespaceManager.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Freespace/InMemoryFreespaceManager.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Freespace/InMemoryFreespaceManager.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,336 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using System.Text; +using Db4objects.Db4o; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Freespace; +using Db4objects.Db4o.Internal.Slots; + +namespace Db4objects.Db4o.Internal.Freespace +{ + public class InMemoryFreespaceManager : AbstractFreespaceManager + { + private readonly TreeIntObject _finder = new TreeIntObject(0); + + private Tree _freeByAddress; + + private Tree _freeBySize; + + private IFreespaceListener _listener = NullFreespaceListener.Instance; + + public InMemoryFreespaceManager(IProcedure4 slotFreedCallback, int discardLimit) : + base(slotFreedCallback, discardLimit) + { + } + + private void AddFreeSlotNodes(int address, int length) + { + FreeSlotNode addressNode = new FreeSlotNode(address); + addressNode.CreatePeer(length); + _freeByAddress = Tree.Add(_freeByAddress, addressNode); + AddToFreeBySize(addressNode._peer); + } + + private void AddToFreeBySize(FreeSlotNode node) + { + _freeBySize = Tree.Add(_freeBySize, node); + _listener.SlotAdded(node._key); + } + + public override Slot AllocateTransactionLogSlot(int length) + { + FreeSlotNode sizeNode = (FreeSlotNode)Tree.Last(_freeBySize); + if (sizeNode == null || sizeNode._key < length) + { + return null; + } + // We can just be appending to the end of the file, using one + // really big contigous slot that keeps growing. Let's limit. + int limit = length + 100; + if (sizeNode._key > limit) + { + return AllocateSlot(limit); + } + RemoveFromBothTrees(sizeNode); + return new Slot(sizeNode._peer._key, sizeNode._key); + } + + public override Slot AllocateSafeSlot(int length) + { + return AllocateSlot(length); + } + + public override void FreeSafeSlot(Slot slot) + { + Free(slot); + } + + public override void BeginCommit() + { + } + + // do nothing + public override void Commit() + { + } + + // do nothing + public override void EndCommit() + { + } + + // do nothing + public override void Free(Slot slot) + { + int address = slot.Address(); + if (address <= 0) + { + throw new ArgumentException(); + } + int length = slot.Length(); + if (DTrace.enabled) + { + DTrace.FreespacemanagerRamFree.LogLength(address, length); + } + _finder._key = address; + FreeSlotNode sizeNode; + FreeSlotNode addressnode = (FreeSlotNode)Tree.FindSmaller(_freeByAddress, _finder + ); + if ((addressnode != null) && ((addressnode._key + addressnode._peer._key) == address + )) + { + sizeNode = addressnode._peer; + RemoveFromFreeBySize(sizeNode); + sizeNode._key += length; + FreeSlotNode secondAddressNode = (FreeSlotNode)Tree.FindGreaterOrEqual(_freeByAddress + , _finder); + if ((secondAddressNode != null) && (address + length == secondAddressNode._key)) + { + sizeNode._key += secondAddressNode._peer._key; + RemoveFromBothTrees(secondAddressNode._peer); + } + sizeNode.RemoveChildren(); + AddToFreeBySize(sizeNode); + } + else + { + addressnode = (FreeSlotNode)Tree.FindGreaterOrEqual(_freeByAddress, _finder); + if ((addressnode != null) && (address + length == addressnode._key)) + { + sizeNode = addressnode._peer; + RemoveFromBothTrees(sizeNode); + sizeNode._key += length; + addressnode._key = address; + addressnode.RemoveChildren(); + sizeNode.RemoveChildren(); + _freeByAddress = Tree.Add(_freeByAddress, addressnode); + AddToFreeBySize(sizeNode); + } + else + { + if (CanDiscard(length)) + { + return; + } + AddFreeSlotNodes(address, length); + } + } + SlotFreed(slot); + } + + public override void FreeSelf() + { + } + + // Do nothing. + // The RAM manager frees itself on reading. + public override Slot AllocateSlot(int length) + { + _finder._key = length; + _finder._object = null; + _freeBySize = FreeSlotNode.RemoveGreaterOrEqual((FreeSlotNode)_freeBySize, _finder + ); + if (_finder._object == null) + { + return null; + } + FreeSlotNode node = (FreeSlotNode)_finder._object; + _listener.SlotRemoved(node._key); + int blocksFound = node._key; + int address = node._peer._key; + _freeByAddress = _freeByAddress.RemoveNode(node._peer); + int remainingBlocks = blocksFound - length; + if (SplitRemainder(remainingBlocks)) + { + AddFreeSlotNodes(address + length, remainingBlocks); + } + else + { + length = blocksFound; + } + if (DTrace.enabled) + { + DTrace.FreespacemanagerGetSlot.LogLength(address, length); + } + return new Slot(address, length); + } + + internal virtual int MarshalledLength() + { + return TreeInt.MarshalledLength((TreeInt)_freeBySize); + } + + private void Read(ByteArrayBuffer reader) + { + FreeSlotNode.sizeLimit = DiscardLimit(); + _freeBySize = new TreeReader(reader, new FreeSlotNode(0), true).Read(); + ByRef addressTree = ByRef.NewInstance(); + if (_freeBySize != null) + { + _freeBySize.Traverse(new _IVisitor4_176(addressTree)); + } + _freeByAddress = ((Tree)addressTree.value); + } + + private sealed class _IVisitor4_176 : IVisitor4 + { + public _IVisitor4_176(ByRef addressTree) + { + this.addressTree = addressTree; + } + + public void Visit(object a_object) + { + FreeSlotNode node = ((FreeSlotNode)a_object)._peer; + addressTree.value = Tree.Add(((Tree)addressTree.value), node); + } + + private readonly ByRef addressTree; + } + + public override void Read(LocalObjectContainer container, Slot slot) + { + if (Slot.IsNull(slot)) + { + return; + } + ByteArrayBuffer buffer = container.ReadBufferBySlot(slot); + if (buffer == null) + { + return; + } + Read(buffer); + container.Free(slot); + } + + private void RemoveFromBothTrees(FreeSlotNode sizeNode) + { + RemoveFromFreeBySize(sizeNode); + _freeByAddress = _freeByAddress.RemoveNode(sizeNode._peer); + } + + private void RemoveFromFreeBySize(FreeSlotNode node) + { + _freeBySize = _freeBySize.RemoveNode(node); + _listener.SlotRemoved(node._key); + } + + public override int SlotCount() + { + return Tree.Size(_freeByAddress); + } + + public override void Start(int id) + { + } + + // this is done in read(), nothing to do here + public override byte SystemType() + { + return FmRam; + } + + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("RAM FreespaceManager\n"); + sb.Append("Address Index\n"); + _freeByAddress.Traverse(new InMemoryFreespaceManager.ToStringVisitor(sb)); + sb.Append("Length Index\n"); + _freeBySize.Traverse(new InMemoryFreespaceManager.ToStringVisitor(sb)); + return sb.ToString(); + } + + public override void Traverse(IVisitor4 visitor) + { + if (_freeByAddress == null) + { + return; + } + _freeByAddress.Traverse(new _IVisitor4_236(visitor)); + } + + private sealed class _IVisitor4_236 : IVisitor4 + { + public _IVisitor4_236(IVisitor4 visitor) + { + this.visitor = visitor; + } + + public void Visit(object a_object) + { + FreeSlotNode fsn = (FreeSlotNode)a_object; + int address = fsn._key; + int length = fsn._peer._key; + visitor.Visit(new Slot(address, length)); + } + + private readonly IVisitor4 visitor; + } + + public override void Write(LocalObjectContainer container) + { + Slot slot = container.AllocateSlot(MarshalledLength()); + while (slot.Length() < MarshalledLength()) + { + // This can happen if DatabaseGrowthSize is configured. + // Allocating a slot may produce an additional entry + // in this FreespaceManager. + container.Free(slot); + slot = container.AllocateSlot(MarshalledLength()); + } + ByteArrayBuffer buffer = new ByteArrayBuffer(slot.Length()); + TreeInt.Write(buffer, (TreeInt)_freeBySize); + container.WriteEncrypt(buffer, slot.Address(), 0); + container.SystemData().InMemoryFreespaceSlot(slot); + } + + internal sealed class ToStringVisitor : IVisitor4 + { + private readonly StringBuilder _sb; + + internal ToStringVisitor(StringBuilder sb) + { + _sb = sb; + } + + public void Visit(object obj) + { + _sb.Append(obj); + _sb.Append("\n"); + } + } + + public override void Listener(IFreespaceListener listener) + { + _listener = listener; + } + + public override bool IsStarted() + { + return true; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Freespace/LengthKeySlotHandler.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Freespace/LengthKeySlotHandler.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Freespace/LengthKeySlotHandler.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Freespace/LengthKeySlotHandler.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,43 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal.Freespace; +using Db4objects.Db4o.Internal.Slots; +using Db4objects.Db4o.Marshall; + +namespace Db4objects.Db4o.Internal.Freespace +{ + /// + public class LengthKeySlotHandler : SlotHandler + { + public virtual int CompareTo(object obj) + { + return _current.CompareByLength((Slot)obj); + } + + public override IPreparedComparison PrepareComparison(IContext context, object slot + ) + { + Slot sourceSlot = (Slot)slot; + return new _IPreparedComparison_21(sourceSlot); + } + + private sealed class _IPreparedComparison_21 : IPreparedComparison + { + public _IPreparedComparison_21(Slot sourceSlot) + { + this.sourceSlot = sourceSlot; + } + + public int CompareTo(object obj) + { + Slot targetSlot = (Slot)obj; + // FIXME: The comparison method in #compareByLength is the wrong way around. + // Fix there and here after other references are fixed. + return -sourceSlot.CompareByLength(targetSlot); + } + + private readonly Slot sourceSlot; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Freespace/NullFreespaceListener.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Freespace/NullFreespaceListener.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Freespace/NullFreespaceListener.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Freespace/NullFreespaceListener.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,27 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal.Freespace; + +namespace Db4objects.Db4o.Internal.Freespace +{ + /// + public class NullFreespaceListener : IFreespaceListener + { + public static readonly IFreespaceListener Instance = new Db4objects.Db4o.Internal.Freespace.NullFreespaceListener + (); + + private NullFreespaceListener() + { + } + + public virtual void SlotAdded(int size) + { + } + + // do nothing; + public virtual void SlotRemoved(int size) + { + } + // do nothing + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Freespace/NullFreespaceManager.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Freespace/NullFreespaceManager.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Freespace/NullFreespaceManager.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Freespace/NullFreespaceManager.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,107 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Freespace; +using Db4objects.Db4o.Internal.Slots; + +namespace Db4objects.Db4o.Internal.Freespace +{ + /// + public class NullFreespaceManager : IFreespaceManager + { + public static readonly IFreespaceManager Instance = new Db4objects.Db4o.Internal.Freespace.NullFreespaceManager + (); + + private NullFreespaceManager() + { + } + + public virtual Slot AllocateSlot(int length) + { + return null; + } + + public virtual Slot AllocateSafeSlot(int length) + { + return null; + } + + public virtual void BeginCommit() + { + } + + public virtual void Commit() + { + } + + public virtual void EndCommit() + { + } + + public virtual void Free(Slot slot) + { + } + + public virtual void FreeSelf() + { + } + + public virtual void FreeSafeSlot(Slot slot) + { + } + + public virtual void Listener(IFreespaceListener listener) + { + } + + public virtual void MigrateTo(IFreespaceManager fm) + { + } + + public virtual int SlotCount() + { + return 0; + } + + public virtual void SlotFreed(Slot slot) + { + } + + public virtual void Start(int id) + { + } + + public virtual byte SystemType() + { + return 0; + } + + public virtual int TotalFreespace() + { + return 0; + } + + public virtual void Traverse(IVisitor4 visitor) + { + } + + public virtual void Write(LocalObjectContainer container) + { + } + + public virtual bool IsStarted() + { + return false; + } + + public virtual Slot AllocateTransactionLogSlot(int length) + { + return null; + } + + public virtual void Read(LocalObjectContainer container, Slot slot) + { + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Freespace/SlotHandler.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Freespace/SlotHandler.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Freespace/SlotHandler.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Freespace/SlotHandler.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,41 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Slots; +using Db4objects.Db4o.Marshall; + +namespace Db4objects.Db4o.Internal.Freespace +{ + /// + public abstract class SlotHandler : IIndexable4 + { + protected Slot _current; + + public virtual void DefragIndexEntry(DefragmentContextImpl context) + { + throw new NotImplementedException(); + } + + public virtual int LinkLength() + { + return Slot.MarshalledLength; + } + + public virtual object ReadIndexEntry(IContext context, ByteArrayBuffer reader) + { + return new Slot(reader.ReadInt(), reader.ReadInt()); + } + + public virtual void WriteIndexEntry(IContext context, ByteArrayBuffer writer, object + obj) + { + Slot slot = (Slot)obj; + writer.WriteInt(slot.Address()); + writer.WriteInt(slot.Length()); + } + + public abstract IPreparedComparison PrepareComparison(IContext arg1, object arg2); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/FrozenObjectInfo.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/FrozenObjectInfo.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/FrozenObjectInfo.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/FrozenObjectInfo.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,92 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Ext; +using Db4objects.Db4o.Internal; + +namespace Db4objects.Db4o.Internal +{ + public class FrozenObjectInfo : IObjectInfo + { + private readonly Db4oDatabase _sourceDatabase; + + private readonly long _uuidLongPart; + + private readonly long _id; + + private readonly long _commitTimestamp; + + private readonly object _object; + + public FrozenObjectInfo(object @object, long id, Db4oDatabase sourceDatabase, long + uuidLongPart, long commitTimestamp) + { + _sourceDatabase = sourceDatabase; + _uuidLongPart = uuidLongPart; + _id = id; + _commitTimestamp = commitTimestamp; + _object = @object; + } + + private FrozenObjectInfo(ObjectReference @ref, VirtualAttributes virtualAttributes + ) : this(@ref == null ? null : @ref.GetObject(), @ref == null ? -1 : @ref.GetID( + ), virtualAttributes == null ? null : virtualAttributes.i_database, virtualAttributes + == null ? -1 : virtualAttributes.i_uuid, virtualAttributes == null ? 0 : virtualAttributes + .i_version) + { + } + + public FrozenObjectInfo(Transaction trans, ObjectReference @ref, bool committed) : + this(@ref, IsInstantiatedReference(@ref) ? @ref.VirtualAttributes(trans, committed + ) : null) + { + } + + private static bool IsInstantiatedReference(ObjectReference @ref) + { + return @ref != null && @ref.GetObject() != null; + } + + public virtual long GetInternalID() + { + return _id; + } + + public virtual object GetObject() + { + return _object; + } + + public virtual Db4oUUID GetUUID() + { + if (_sourceDatabase == null) + { + return null; + } + return new Db4oUUID(_uuidLongPart, _sourceDatabase.GetSignature()); + } + + public virtual long GetVersion() + { + return GetCommitTimestamp(); + } + + public virtual long GetCommitTimestamp() + { + return _commitTimestamp; + } + + public virtual long SourceDatabaseId(Transaction trans) + { + if (_sourceDatabase == null) + { + return -1; + } + return _sourceDatabase.GetID(trans); + } + + public virtual long UuidLongPart() + { + return _uuidLongPart; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/HandlerRegistry.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/HandlerRegistry.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/HandlerRegistry.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/HandlerRegistry.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,640 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Encoding; +using Db4objects.Db4o.Internal.Handlers; +using Db4objects.Db4o.Internal.Handlers.Array; +using Db4objects.Db4o.Internal.Handlers.Versions; +using Db4objects.Db4o.Internal.Marshall; +using Db4objects.Db4o.Internal.Replication; +using Db4objects.Db4o.Reflect; +using Db4objects.Db4o.Reflect.Generic; +using Db4objects.Db4o.Typehandlers; + +namespace Db4objects.Db4o.Internal +{ + /// + /// TODO: This class was written to make ObjectContainerBase + /// leaner, so TransportObjectContainer has less members. + /// All functionality of this class should become part of + /// ObjectContainerBase and the functionality in + /// ObjectContainerBase should delegate to independent + /// modules without circular references. + /// + public sealed class HandlerRegistry + { + public const byte HandlerVersion = (byte)10; + + private readonly ObjectContainerBase _container; + + private static readonly IDb4oTypeImpl[] _db4oTypes = new IDb4oTypeImpl[] { new BlobImpl + () }; + + private ITypeHandler4 _openArrayHandler; + + private ITypeHandler4 _openMultiDimensionalArrayHandler; + + private ITypeHandler4 _openTypeHandler; + + public StringHandler _stringHandler; + + private Hashtable4 _mapIdToTypeInfo = NewHashtable(); + + private Hashtable4 _mapReflectorToClassMetadata = NewHashtable(); + + private int _highestBuiltinTypeID = Handlers4.AnyArrayNId + 1; + + private readonly VirtualFieldMetadata[] _virtualFields = new VirtualFieldMetadata + [3]; + + private readonly Hashtable4 _mapReflectorToTypeHandler = NewHashtable(); + + private SharedIndexedFields _indexes; + + internal IDb4oReplicationReferenceProvider _replicationReferenceProvider; + + private readonly Db4objects.Db4o.Internal.Diagnostic.DiagnosticProcessor _diagnosticProcessor; + + public bool i_encrypt; + + internal byte[] i_encryptor; + + internal int i_lastEncryptorByte; + + internal readonly GenericReflector _reflector; + + private readonly HandlerVersionRegistry _handlerVersions; + + private LatinStringIO _stringIO; + + public IReflectClass IclassCompare; + + internal IReflectClass IclassDb4otype; + + internal IReflectClass IclassDb4otypeimpl; + + public IReflectClass IclassInternal; + + internal IReflectClass IclassUnversioned; + + public IReflectClass IclassObject; + + internal IReflectClass IclassObjectcontainer; + + public IReflectClass IclassStaticclass; + + public IReflectClass IclassString; + + internal IReflectClass IclassTransientclass; + + private PrimitiveTypeMetadata _untypedArrayMetadata; + + private PrimitiveTypeMetadata _untypedMultiDimensionalMetadata; + + internal HandlerRegistry(ObjectContainerBase container, byte stringEncoding, GenericReflector + reflector) + { + // this is the master container and not valid + // for TransportObjectContainer + _handlerVersions = new HandlerVersionRegistry(this); + _stringIO = BuiltInStringEncoding.StringIoForEncoding(stringEncoding, container.ConfigImpl + .StringEncoding()); + _container = container; + container._handlers = this; + _reflector = reflector; + _diagnosticProcessor = container.ConfigImpl.DiagnosticProcessor(); + InitClassReflectors(reflector); + _indexes = new SharedIndexedFields(); + _virtualFields[0] = _indexes._version; + _virtualFields[1] = _indexes._uUID; + _virtualFields[2] = _indexes._commitTimestamp; + RegisterBuiltinHandlers(); + RegisterPlatformTypes(); + InitArrayHandlers(); + Platform4.RegisterPlatformHandlers(container); + } + + private void InitArrayHandlers() + { + ITypeHandler4 elementHandler = OpenTypeHandler(); + _untypedArrayMetadata = new PrimitiveTypeMetadata(Container(), new ArrayHandler(elementHandler + , false), Handlers4.AnyArrayId, IclassObject); + _openArrayHandler = _untypedArrayMetadata.TypeHandler(); + MapTypeInfo(Handlers4.AnyArrayId, _untypedArrayMetadata, null); + _untypedMultiDimensionalMetadata = new PrimitiveTypeMetadata(Container(), new MultidimensionalArrayHandler + (elementHandler, false), Handlers4.AnyArrayNId, IclassObject); + _openMultiDimensionalArrayHandler = _untypedMultiDimensionalMetadata.TypeHandler( + ); + MapTypeInfo(Handlers4.AnyArrayNId, _untypedMultiDimensionalMetadata, null); + } + + private void RegisterPlatformTypes() + { + NetTypeHandler[] handlers = Platform4.Types(_container.Reflector()); + for (int i = 0; i < handlers.Length; i++) + { + RegisterNetTypeHandler(handlers[i]); + } + } + + public void RegisterNetTypeHandler(NetTypeHandler handler) + { + handler.RegisterReflector(_reflector); + IGenericConverter converter = (handler is IGenericConverter) ? (IGenericConverter + )handler : null; + RegisterBuiltinHandler(handler.GetID(), handler, true, handler.GetName(), converter + ); + } + + private void RegisterBuiltinHandlers() + { + IntHandler intHandler = new IntHandler(); + RegisterBuiltinHandler(Handlers4.IntId, intHandler); + RegisterHandlerVersion(intHandler, 0, new IntHandler0()); + LongHandler longHandler = new LongHandler(); + RegisterBuiltinHandler(Handlers4.LongId, longHandler); + RegisterHandlerVersion(longHandler, 0, new LongHandler0()); + FloatHandler floatHandler = new FloatHandler(); + RegisterBuiltinHandler(Handlers4.FloatId, floatHandler); + RegisterHandlerVersion(floatHandler, 0, new FloatHandler0()); + BooleanHandler booleanHandler = new BooleanHandler(); + RegisterBuiltinHandler(Handlers4.BooleanId, booleanHandler); + // TODO: Are we missing a boolean handler version? + DoubleHandler doubleHandler = new DoubleHandler(); + RegisterBuiltinHandler(Handlers4.DoubleId, doubleHandler); + RegisterHandlerVersion(doubleHandler, 0, new DoubleHandler0()); + ByteHandler byteHandler = new ByteHandler(); + RegisterBuiltinHandler(Handlers4.ByteId, byteHandler); + // TODO: Are we missing a byte handler version? + CharHandler charHandler = new CharHandler(); + RegisterBuiltinHandler(Handlers4.CharId, charHandler); + // TODO: Are we missing a char handler version? + ShortHandler shortHandler = new ShortHandler(); + RegisterBuiltinHandler(Handlers4.ShortId, shortHandler); + RegisterHandlerVersion(shortHandler, 0, new ShortHandler0()); + _stringHandler = new StringHandler(); + RegisterBuiltinHandler(Handlers4.StringId, _stringHandler); + RegisterHandlerVersion(_stringHandler, 0, new StringHandler0()); + DateHandler dateHandler = new DateHandler(); + RegisterBuiltinHandler(Handlers4.DateId, dateHandler); + RegisterHandlerVersion(dateHandler, 0, new DateHandler0()); + RegisterUntypedHandlers(); + RegisterCompositeHandlerVersions(); + } + + private void RegisterUntypedHandlers() + { + _openTypeHandler = new Db4objects.Db4o.Internal.OpenTypeHandler(Container()); + PrimitiveTypeMetadata classMetadata = new ObjectTypeMetadata(Container(), _openTypeHandler + , Handlers4.UntypedId, IclassObject); + Map(Handlers4.UntypedId, classMetadata, IclassObject); + RegisterHandlerVersion(_openTypeHandler, 0, new OpenTypeHandler0(Container())); + RegisterHandlerVersion(_openTypeHandler, 2, new OpenTypeHandler2(Container())); + RegisterHandlerVersion(_openTypeHandler, 7, new OpenTypeHandler7(Container())); + } + + private void RegisterCompositeHandlerVersions() + { + RegisterHandlerVersion(new StandardReferenceTypeHandler(), 0, new StandardReferenceTypeHandler0 + ()); + ArrayHandler arrayHandler = new ArrayHandler(); + RegisterHandlerVersion(arrayHandler, 0, new ArrayHandler0()); + RegisterHandlerVersion(arrayHandler, 1, new ArrayHandler1()); + RegisterHandlerVersion(arrayHandler, 3, new ArrayHandler3()); + RegisterHandlerVersion(arrayHandler, 5, new ArrayHandler5()); + MultidimensionalArrayHandler multidimensionalArrayHandler = new MultidimensionalArrayHandler + (); + RegisterHandlerVersion(multidimensionalArrayHandler, 0, new MultidimensionalArrayHandler0 + ()); + RegisterHandlerVersion(multidimensionalArrayHandler, 3, new MultidimensionalArrayHandler3 + ()); + } + + private void RegisterBuiltinHandler(int id, IBuiltinTypeHandler handler) + { + RegisterBuiltinHandler(id, handler, true, null, null); + } + + private void RegisterBuiltinHandler(int id, IBuiltinTypeHandler typeHandler, bool + registerPrimitiveClass, string primitiveName, IGenericConverter converter) + { + typeHandler.RegisterReflector(_reflector); + if (primitiveName == null) + { + primitiveName = typeHandler.ClassReflector().GetName(); + } + if (registerPrimitiveClass) + { + _reflector.RegisterPrimitiveClass(id, primitiveName, converter); + } + IReflectClass classReflector = typeHandler.ClassReflector(); + PrimitiveTypeMetadata classMetadata = new PrimitiveTypeMetadata(Container(), typeHandler + , id, classReflector); + Map(id, classMetadata, classReflector); + if (typeHandler is PrimitiveHandler) + { + IReflectClass primitiveClassReflector = ((PrimitiveHandler)typeHandler).PrimitiveClassReflector + (); + if (primitiveClassReflector != null) + { + MapPrimitive(0, classMetadata, primitiveClassReflector); + } + } + } + + private void Map(int id, PrimitiveTypeMetadata classMetadata, IReflectClass classReflector + ) + { + // TODO: remove when _mapIdToClassMetadata is gone + MapTypeInfo(id, classMetadata, classReflector); + MapPrimitive(id, classMetadata, classReflector); + if (id > _highestBuiltinTypeID) + { + _highestBuiltinTypeID = id; + } + } + + private void MapTypeInfo(int id, ClassMetadata classMetadata, IReflectClass classReflector + ) + { + _mapIdToTypeInfo.Put(id, new HandlerRegistry.TypeInfo(classMetadata, classReflector + )); + } + + private void MapPrimitive(int id, ClassMetadata classMetadata, IReflectClass classReflector + ) + { + MapClassToTypeHandler(classReflector, classMetadata.TypeHandler()); + if (classReflector != null) + { + _mapReflectorToClassMetadata.Put(classReflector, classMetadata); + } + } + + private void MapClassToTypeHandler(IReflectClass classReflector, ITypeHandler4 typeHandler + ) + { + _mapReflectorToTypeHandler.Put(classReflector, typeHandler); + } + + public void RegisterHandlerVersion(ITypeHandler4 handler, int version, ITypeHandler4 + replacement) + { + if (replacement is IBuiltinTypeHandler) + { + ((IBuiltinTypeHandler)replacement).RegisterReflector(_reflector); + } + _handlerVersions.Put(handler, version, replacement); + } + + public ITypeHandler4 CorrectHandlerVersion(ITypeHandler4 handler, int version) + { + return _handlerVersions.CorrectHandlerVersion(handler, version); + } + + public static ITypeHandler4 CorrectHandlerVersion(IHandlerVersionContext context, + ITypeHandler4 typeHandler, ClassMetadata classMetadata) + { + ITypeHandler4 correctHandlerVersion = CorrectHandlerVersion(context, typeHandler); + if (typeHandler != correctHandlerVersion) + { + CorrectClassMetadataOn(correctHandlerVersion, classMetadata); + if (correctHandlerVersion is ArrayHandler) + { + ArrayHandler arrayHandler = (ArrayHandler)correctHandlerVersion; + CorrectClassMetadataOn(arrayHandler.DelegateTypeHandler(), classMetadata); + } + } + return correctHandlerVersion; + } + + private static void CorrectClassMetadataOn(ITypeHandler4 typeHandler, ClassMetadata + classMetadata) + { + if (typeHandler is StandardReferenceTypeHandler) + { + StandardReferenceTypeHandler handler = (StandardReferenceTypeHandler)typeHandler; + handler.ClassMetadata(classMetadata); + } + } + + internal Db4objects.Db4o.Internal.ArrayType ArrayType(object obj) + { + IReflectClass claxx = Reflector().ForObject(obj); + if (!claxx.IsArray()) + { + return Db4objects.Db4o.Internal.ArrayType.None; + } + if (IsNDimensional(claxx)) + { + return Db4objects.Db4o.Internal.ArrayType.MultidimensionalArray; + } + return Db4objects.Db4o.Internal.ArrayType.PlainArray; + } + + public void Decrypt(ByteArrayBuffer reader) + { + if (i_encrypt) + { + int encryptorOffSet = i_lastEncryptorByte; + byte[] bytes = reader._buffer; + for (int i = reader.Length() - 1; i >= 0; i--) + { + bytes[i] += i_encryptor[encryptorOffSet]; + if (encryptorOffSet == 0) + { + encryptorOffSet = i_lastEncryptorByte; + } + else + { + encryptorOffSet--; + } + } + } + } + + public void Encrypt(ByteArrayBuffer reader) + { + if (i_encrypt) + { + byte[] bytes = reader._buffer; + int encryptorOffSet = i_lastEncryptorByte; + for (int i = reader.Length() - 1; i >= 0; i--) + { + bytes[i] -= i_encryptor[encryptorOffSet]; + if (encryptorOffSet == 0) + { + encryptorOffSet = i_lastEncryptorByte; + } + else + { + encryptorOffSet--; + } + } + } + } + + public void OldEncryptionOff() + { + i_encrypt = false; + i_encryptor = null; + i_lastEncryptorByte = 0; + Container().ConfigImpl.OldEncryptionOff(); + } + + public IReflectClass ClassForID(int id) + { + HandlerRegistry.TypeInfo typeInfo = TypeInfoForID(id); + if (typeInfo == null) + { + return null; + } + return typeInfo.classReflector; + } + + private HandlerRegistry.TypeInfo TypeInfoForID(int id) + { + return (HandlerRegistry.TypeInfo)_mapIdToTypeInfo.Get(id); + } + + private void InitClassReflectors(GenericReflector reflector) + { + IclassCompare = reflector.ForClass(Const4.ClassCompare); + IclassDb4otype = reflector.ForClass(Const4.ClassDb4otype); + IclassDb4otypeimpl = reflector.ForClass(Const4.ClassDb4otypeimpl); + IclassInternal = reflector.ForClass(Const4.ClassInternal); + IclassUnversioned = reflector.ForClass(Const4.ClassUnversioned); + IclassObject = reflector.ForClass(Const4.ClassObject); + IclassObjectcontainer = reflector.ForClass(Const4.ClassObjectcontainer); + IclassStaticclass = reflector.ForClass(Const4.ClassStaticclass); + IclassString = reflector.ForClass(typeof(string)); + IclassTransientclass = reflector.ForClass(Const4.ClassTransientclass); + Platform4.RegisterCollections(reflector); + } + + internal void InitEncryption(Config4Impl a_config) + { + if (a_config.Encrypt() && a_config.Password() != null && a_config.Password().Length + > 0) + { + i_encrypt = true; + i_encryptor = new byte[a_config.Password().Length]; + for (int i = 0; i < i_encryptor.Length; i++) + { + i_encryptor[i] = (byte)(a_config.Password()[i] & unchecked((int)(0xff))); + } + i_lastEncryptorByte = a_config.Password().Length - 1; + return; + } + OldEncryptionOff(); + } + + internal static IDb4oTypeImpl GetDb4oType(IReflectClass clazz) + { + for (int i = 0; i < _db4oTypes.Length; i++) + { + if (clazz.IsInstance(_db4oTypes[i])) + { + return _db4oTypes[i]; + } + } + return null; + } + + public ClassMetadata ClassMetadataForId(int id) + { + HandlerRegistry.TypeInfo typeInfo = TypeInfoForID(id); + if (typeInfo == null) + { + return null; + } + return typeInfo.classMetadata; + } + + internal ClassMetadata ClassMetadataForClass(IReflectClass clazz) + { + if (clazz == null) + { + return null; + } + if (clazz.IsArray()) + { + return IsNDimensional(clazz) ? _untypedMultiDimensionalMetadata : _untypedArrayMetadata; + } + return (ClassMetadata)_mapReflectorToClassMetadata.Get(clazz); + } + + public ITypeHandler4 OpenTypeHandler() + { + return _openTypeHandler; + } + + public ITypeHandler4 OpenArrayHandler(IReflectClass clazz) + { + if (clazz.IsArray()) + { + if (IsNDimensional(clazz)) + { + return _openMultiDimensionalArrayHandler; + } + return _openArrayHandler; + } + return null; + } + + private bool IsNDimensional(IReflectClass clazz) + { + return Reflector().Array().IsNDimensional(clazz); + } + + public ITypeHandler4 TypeHandlerForClass(IReflectClass clazz) + { + if (clazz == null) + { + return null; + } + if (clazz.IsArray()) + { + if (IsNDimensional(clazz)) + { + return _openMultiDimensionalArrayHandler; + } + return _openArrayHandler; + } + ITypeHandler4 cachedTypeHandler = (ITypeHandler4)_mapReflectorToTypeHandler.Get(clazz + ); + if (cachedTypeHandler != null) + { + return cachedTypeHandler; + } + ITypeHandler4 configuredTypeHandler = ConfiguredTypeHandler(clazz); + if (Handlers4.IsValueType(configuredTypeHandler)) + { + return configuredTypeHandler; + } + return null; + } + + public bool IsSystemHandler(int id) + { + return id > 0 && id <= _highestBuiltinTypeID; + } + + public int LowestValidId() + { + return _highestBuiltinTypeID + 1; + } + + public VirtualFieldMetadata VirtualFieldByName(string name) + { + for (int i = 0; i < _virtualFields.Length; i++) + { + if (name.Equals(_virtualFields[i].GetName())) + { + return _virtualFields[i]; + } + } + return null; + } + + public SharedIndexedFields Indexes() + { + return _indexes; + } + + public LatinStringIO StringIO() + { + return _stringIO; + } + + public void StringIO(LatinStringIO io) + { + _stringIO = io; + } + + private GenericReflector Reflector() + { + return Container().Reflector(); + } + + private ObjectContainerBase Container() + { + return _container; + } + + private static Hashtable4 NewHashtable() + { + return new Hashtable4(32); + } + + public ITypeHandler4 ConfiguredTypeHandler(IReflectClass claxx) + { + object cachedHandler = _mapReflectorToTypeHandler.Get(claxx); + if (null != cachedHandler) + { + return (ITypeHandler4)cachedHandler; + } + ITypeHandler4 typeHandler = Container().ConfigImpl.TypeHandlerForClass(claxx, HandlerVersion + ); + if (typeHandler is IBuiltinTypeHandler) + { + ((IBuiltinTypeHandler)typeHandler).RegisterReflector(Reflector()); + } + if (Handlers4.IsValueType(typeHandler)) + { + MapClassToTypeHandler(claxx, typeHandler); + } + return typeHandler; + } + + public static ITypeHandler4 CorrectHandlerVersion(IHandlerVersionContext context, + ITypeHandler4 handler) + { + int version = context.HandlerVersion(); + if (version >= HandlerVersion) + { + return handler; + } + return context.Transaction().Container().Handlers.CorrectHandlerVersion(handler, + version); + } + + public bool IsTransient(IReflectClass claxx) + { + return IclassTransientclass.IsAssignableFrom(claxx) || Platform4.IsTransient(claxx + ); + } + + public void TreatAsOpenType(Type clazz) + { + MapClassToTypeHandler(ReflectClassFor(clazz), OpenTypeHandler()); + } + + private IReflectClass ReflectClassFor(Type clazz) + { + return Container().Reflector().ForClass(clazz); + } + + public Db4objects.Db4o.Internal.Diagnostic.DiagnosticProcessor DiagnosticProcessor + () + { + return _diagnosticProcessor; + } + + private class TypeInfo + { + public ClassMetadata classMetadata; + + public IReflectClass classReflector; + + public TypeInfo(ClassMetadata classMetadata_, IReflectClass classReflector_) + { + // TODO: remove when no longer needed in HandlerRegistry + classMetadata = classMetadata_; + classReflector = classReflector_; + } + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/Array/ArrayHandler0.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/Array/ArrayHandler0.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/Array/ArrayHandler0.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/Array/ArrayHandler0.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,100 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System.IO; +using Db4objects.Db4o.Ext; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Delete; +using Db4objects.Db4o.Internal.Handlers.Array; +using Db4objects.Db4o.Internal.Marshall; +using Db4objects.Db4o.Internal.Slots; +using Db4objects.Db4o.Marshall; +using Sharpen.Lang; + +namespace Db4objects.Db4o.Internal.Handlers.Array +{ + /// + public class ArrayHandler0 : ArrayHandler1 + { + protected override ArrayVersionHelper CreateVersionHelper() + { + return new ArrayVersionHelper0(); + } + + protected override void WithContent(AbstractBufferContext context, IRunnable runnable + ) + { + int address = context.ReadInt(); + int length = context.ReadInt(); + if (address == 0) + { + return; + } + IReadBuffer temp = context.Buffer(); + ByteArrayBuffer indirectedBuffer = Container(context).DecryptedBufferByAddress(address + , length); + context.Buffer(indirectedBuffer); + runnable.Run(); + context.Buffer(temp); + } + + /// + public override void Delete(IDeleteContext context) + { + context.ReadSlot(); + context.DefragmentRecommended(); + } + + public override object Read(IReadContext readContext) + { + IInternalReadContext context = (IInternalReadContext)readContext; + ByteArrayBuffer buffer = (ByteArrayBuffer)context.ReadIndirectedBuffer(); + if (buffer == null) + { + return null; + } + // With the following line we ask the context to work with + // a different buffer. Should this logic ever be needed by + // a user handler, it should be implemented by using a Queue + // in the UnmarshallingContext. + // The buffer has to be set back from the outside! See below + IReadBuffer contextBuffer = context.Buffer(buffer); + object array = base.Read(context); + // The context buffer has to be set back. + context.Buffer(contextBuffer); + return array; + } + + public static void Defragment(IDefragmentContext context, ArrayHandler handler) + { + int sourceAddress = context.SourceBuffer().ReadInt(); + int length = context.SourceBuffer().ReadInt(); + if (sourceAddress == 0 && length == 0) + { + context.TargetBuffer().WriteInt(0); + context.TargetBuffer().WriteInt(0); + return; + } + Slot slot = context.AllocateMappedTargetSlot(sourceAddress, length); + ByteArrayBuffer sourceBuffer = null; + try + { + sourceBuffer = context.SourceBufferByAddress(sourceAddress, length); + } + catch (IOException exc) + { + throw new Db4oIOException(exc); + } + DefragmentContextImpl payloadContext = new DefragmentContextImpl(sourceBuffer, (DefragmentContextImpl + )context); + handler.DefragmentSlot(payloadContext); + payloadContext.WriteToTarget(slot.Address()); + context.TargetBuffer().WriteInt(slot.Address()); + context.TargetBuffer().WriteInt(length); + } + + public override void Defragment(IDefragmentContext context) + { + Defragment(context, this); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/Array/ArrayHandler1.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/Array/ArrayHandler1.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/Array/ArrayHandler1.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/Array/ArrayHandler1.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,21 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal.Handlers.Array; +using Db4objects.Db4o.Marshall; + +namespace Db4objects.Db4o.Internal.Handlers.Array +{ + /// + public class ArrayHandler1 : ArrayHandler3 + { + protected override bool HandleAsByteArray(IBufferContext context) + { + return false; + } + + protected override bool HandleAsByteArray(object obj) + { + return false; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/Array/ArrayHandler3.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/Array/ArrayHandler3.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/Array/ArrayHandler3.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/Array/ArrayHandler3.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,15 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal.Handlers.Array; + +namespace Db4objects.Db4o.Internal.Handlers.Array +{ + /// + public class ArrayHandler3 : ArrayHandler5 + { + protected override ArrayVersionHelper CreateVersionHelper() + { + return new ArrayVersionHelper3(); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/Array/ArrayHandler5.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/Array/ArrayHandler5.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/Array/ArrayHandler5.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/Array/ArrayHandler5.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,15 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal.Handlers.Array; + +namespace Db4objects.Db4o.Internal.Handlers.Array +{ + /// + public class ArrayHandler5 : ArrayHandler + { + protected override ArrayVersionHelper CreateVersionHelper() + { + return new ArrayVersionHelper5(); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/Array/ArrayHandler.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/Array/ArrayHandler.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/Array/ArrayHandler.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/Array/ArrayHandler.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,689 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System.Collections; +using Db4objects.Db4o; +using Db4objects.Db4o.Ext; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Delete; +using Db4objects.Db4o.Internal.Handlers; +using Db4objects.Db4o.Internal.Handlers.Array; +using Db4objects.Db4o.Internal.Marshall; +using Db4objects.Db4o.Marshall; +using Db4objects.Db4o.Reflect; +using Db4objects.Db4o.Typehandlers; +using Sharpen.Lang; + +namespace Db4objects.Db4o.Internal.Handlers.Array +{ + /// This is the latest version, the one that should be used. + /// This is the latest version, the one that should be used. + /// + public class ArrayHandler : ICascadingTypeHandler, IComparable4, IValueTypeHandler + , IVariableLengthTypeHandler, IVersionedTypeHandler, IQueryableTypeHandler + { + private ITypeHandler4 _handler; + + private bool _usePrimitiveClassReflector; + + protected readonly ArrayVersionHelper _versionHelper; + + public ArrayHandler() + { + _versionHelper = CreateVersionHelper(); + } + + public ArrayHandler(ITypeHandler4 handler, bool usePrimitiveClassReflector) : this + () + { + _handler = handler; + _usePrimitiveClassReflector = usePrimitiveClassReflector; + } + + protected virtual ArrayVersionHelper CreateVersionHelper() + { + return new ArrayVersionHelper(); + } + + protected virtual IReflectArray ArrayReflector(ObjectContainerBase container) + { + return container.Reflector().Array(); + } + + public virtual IEnumerator AllElements(ObjectContainerBase container, object a_object + ) + { + return AllElements(ArrayReflector(container), a_object); + } + + public static IEnumerator AllElements(IReflectArray reflectArray, object array) + { + return new ReflectArrayIterator(reflectArray, array); + } + + public void CascadeActivation(IActivationContext context) + { + if (!Handlers4.IsCascading(_handler)) + { + return; + } + ObjectContainerBase container = context.Container(); + IEnumerator all = AllElements(container, context.TargetObject()); + while (all.MoveNext()) + { + context.CascadeActivationToChild(all.Current); + } + } + + internal virtual ObjectContainerBase Container(Transaction trans) + { + return trans.Container(); + } + + public virtual void CollectIDs(QueryingReadContext context) + { + ITypeHandler4 handler = HandlerRegistry.CorrectHandlerVersion(context, _handler); + ForEachElement(context, new _IRunnable_71(context, handler)); + } + + private sealed class _IRunnable_71 : IRunnable + { + public _IRunnable_71(QueryingReadContext context, ITypeHandler4 handler) + { + this.context = context; + this.handler = handler; + } + + public void Run() + { + context.ReadId(handler); + } + + private readonly QueryingReadContext context; + + private readonly ITypeHandler4 handler; + } + + protected virtual ArrayInfo ForEachElement(AbstractBufferContext context, IRunnable + elementRunnable) + { + ArrayInfo info = NewArrayInfo(); + WithContent(context, new _IRunnable_80(this, context, info, elementRunnable)); + return info; + } + + private sealed class _IRunnable_80 : IRunnable + { + public _IRunnable_80(ArrayHandler _enclosing, AbstractBufferContext context, ArrayInfo + info, IRunnable elementRunnable) + { + this._enclosing = _enclosing; + this.context = context; + this.info = info; + this.elementRunnable = elementRunnable; + } + + public void Run() + { + if (context.Buffer() == null) + { + return; + } + if (this._enclosing.IsUntypedByteArray(context)) + { + return; + } + this._enclosing.ReadInfo(context.Transaction(), context, info); + int elementCount = info.ElementCount(); + elementCount -= this._enclosing.ReducedCountForNullBitMap(info, context); + for (int i = 0; i < elementCount; i++) + { + elementRunnable.Run(); + } + } + + private readonly ArrayHandler _enclosing; + + private readonly AbstractBufferContext context; + + private readonly ArrayInfo info; + + private readonly IRunnable elementRunnable; + } + + protected virtual void WithContent(AbstractBufferContext context, IRunnable runnable + ) + { + runnable.Run(); + } + + private int ReducedCountForNullBitMap(ArrayInfo info, IReadBuffer context) + { + if (!HasNullBitmap(info)) + { + return 0; + } + return ReducedCountForNullBitMap(info.ElementCount(), ReadNullBitmap(context, info + .ElementCount())); + } + + private int ReducedCountForNullBitMap(int count, BitMap4 bitMap) + { + int nullCount = 0; + for (int i = 0; i < count; i++) + { + if (bitMap.IsTrue(i)) + { + nullCount++; + } + } + return nullCount; + } + + /// + public virtual void Delete(IDeleteContext context) + { + if (!CascadeDelete(context)) + { + return; + } + ForEachElement((AbstractBufferContext)context, new _IRunnable_127(this, context)); + } + + private sealed class _IRunnable_127 : IRunnable + { + public _IRunnable_127(ArrayHandler _enclosing, IDeleteContext context) + { + this._enclosing = _enclosing; + this.context = context; + } + + public void Run() + { + this._enclosing._handler.Delete(context); + } + + private readonly ArrayHandler _enclosing; + + private readonly IDeleteContext context; + } + + private bool CascadeDelete(IDeleteContext context) + { + // FIXME: ValueType could reference objects, shouldn't they be deleted too? + return context.CascadeDelete() && Handlers4.IsCascading(_handler); + } + + // FIXME: This code has not been called in any test case when the + // new ArrayMarshaller was written. + // Apparently it only frees slots. + // For now the code simply returns without freeing. + /// + public void DeletePrimitiveEmbedded(StatefulBuffer buffer, PrimitiveTypeMetadata + classPrimitive) + { + buffer.ReadInt(); + //int address = a_bytes.readInt(); + buffer.ReadInt(); + } + + //int length = a_bytes.readInt(); + public override bool Equals(object obj) + { + if (!(obj is Db4objects.Db4o.Internal.Handlers.Array.ArrayHandler)) + { + return false; + } + Db4objects.Db4o.Internal.Handlers.Array.ArrayHandler other = (Db4objects.Db4o.Internal.Handlers.Array.ArrayHandler + )obj; + if (other.Identifier() != Identifier()) + { + return false; + } + if (_handler == null) + { + return other._handler == null; + } + return _handler.Equals(other._handler) && _usePrimitiveClassReflector == other._usePrimitiveClassReflector; + } + + public override int GetHashCode() + { + if (_handler == null) + { + return HashcodeForNull; + } + int hc = _handler.GetHashCode() >> 7; + return _usePrimitiveClassReflector ? hc : -hc; + } + + protected virtual bool HandleAsByteArray(object obj) + { + return obj.GetType() == typeof(byte[]); + return obj is byte[]; + } + + public virtual byte Identifier() + { + return Const4.Yaparray; + } + + public virtual IReflectClass PrimitiveClassReflector(IReflector reflector) + { + return Handlers4.PrimitiveClassReflector(_handler, reflector); + } + + protected virtual object ReadCreate(Transaction trans, IReadBuffer buffer, ArrayInfo + info) + { + ReadInfo(trans, buffer, info); + IReflectClass clazz = NewInstanceReflectClass(trans.Reflector(), info); + if (clazz == null) + { + return null; + } + return NewInstance(ArrayReflector(Container(trans)), info, clazz); + } + + protected object NewInstance(IReflectArray arrayReflector, ArrayInfo info, IReflectClass + clazz) + { + return arrayReflector.NewInstance(clazz, info); + } + + protected IReflectClass NewInstanceReflectClass(IReflector reflector, ArrayInfo info + ) + { + if (_usePrimitiveClassReflector) + { + return PrimitiveClassReflector(reflector); + } + return info.ReflectClass(); + } + + public virtual ITypeHandler4 ReadCandidateHandler(QueryingReadContext context) + { + return this; + } + + protected virtual void ReadInfo(Transaction trans, IReadBuffer buffer, ArrayInfo + info) + { + int classID = buffer.ReadInt(); + if (IsPreVersion0Format(classID)) + { + throw new UnsupportedOldFormatException(); + } + else + { + _versionHelper.ReadTypeInfo(trans, buffer, info, classID); + ReflectClassFromElementsEntry(Container(trans), info, classID); + ReadDimensions(info, buffer); + } + if (Debug4.ExceedsMaximumArrayEntries(info.ElementCount(), _usePrimitiveClassReflector + )) + { + info.ElementCount(0); + } + } + + protected virtual void ReadDimensions(ArrayInfo info, IReadBuffer buffer) + { + info.ElementCount(buffer.ReadInt()); + } + + protected virtual bool IsPreVersion0Format(int elementCount) + { + return _versionHelper.IsPreVersion0Format(elementCount); + } + + private void ReflectClassFromElementsEntry(ObjectContainerBase container, ArrayInfo + info, int classID) + { + info.ReflectClass(_versionHelper.ReflectClassFromElementsEntry(container, info, classID + )); + } + + protected IReflectClass ClassReflector(IReflector reflector, Db4objects.Db4o.Internal.ClassMetadata + classMetadata, bool isPrimitive) + { + return _versionHelper.ClassReflector(reflector, classMetadata, isPrimitive); + } + + public static IEnumerator Iterator(IReflectClass claxx, object obj) + { + IReflectArray reflectArray = claxx.Reflector().Array(); + if (reflectArray.IsNDimensional(claxx)) + { + return MultidimensionalArrayHandler.AllElementsMultidimensional(reflectArray, obj + ); + } + return Db4objects.Db4o.Internal.Handlers.Array.ArrayHandler.AllElements(reflectArray + , obj); + } + + protected virtual bool UseJavaHandling() + { + return _versionHelper.UseJavaHandling(); + } + + protected virtual int ClassIDFromInfo(ObjectContainerBase container, ArrayInfo info + ) + { + return _versionHelper.ClassIDFromInfo(container, info); + } + + private int MarshalledClassID(ObjectContainerBase container, ArrayInfo info) + { + return ClassIdToMarshalledClassId(ClassIDFromInfo(container, info), info.Primitive + ()); + } + + public int ClassIdToMarshalledClassId(int classID, bool primitive) + { + return _versionHelper.ClassIdToMarshalledClassId(classID, primitive); + } + + protected bool IsPrimitive(IReflector reflector, IReflectClass claxx, Db4objects.Db4o.Internal.ClassMetadata + classMetadata) + { + return _versionHelper.IsPrimitive(reflector, claxx, classMetadata); + } + + private IReflectClass ComponentType(ObjectContainerBase container, object obj) + { + return ArrayReflector(container).GetComponentType(container.Reflector().ForObject + (obj)); + } + + public virtual void Defragment(IDefragmentContext context) + { + if (context.ClassMetadata().HasIdentity()) + { + DefragmentSlot(context); + } + else + { + context.IncrementOffset(LinkLength()); + } + } + + public void DefragmentSlot(IDefragmentContext context) + { + if (IsUntypedByteArray(context)) + { + return; + } + int classIdOffset = context.TargetBuffer().Offset(); + ArrayInfo info = NewArrayInfo(); + ReadInfo(context.Transaction(), context, info); + DefragmentWriteMappedClassId(context, info, classIdOffset); + int elementCount = info.ElementCount(); + if (HasNullBitmap(info)) + { + BitMap4 bitMap = ReadNullBitmap(context, elementCount); + elementCount -= ReducedCountForNullBitMap(elementCount, bitMap); + } + ITypeHandler4 correctTypeHandlerVersion = CorrectHandlerVersion(context, _handler + , info); + for (int i = 0; i < elementCount; i++) + { + context.Defragment(correctTypeHandlerVersion); + } + } + + private ITypeHandler4 CorrectHandlerVersion(IDefragmentContext context, ITypeHandler4 + handler, ArrayInfo info) + { + Db4objects.Db4o.Internal.ClassMetadata classMetadata = ClassMetadata(context, info + ); + return HandlerRegistry.CorrectHandlerVersion(context, handler, classMetadata); + } + + private Db4objects.Db4o.Internal.ClassMetadata ClassMetadata(IDefragmentContext context + , ArrayInfo info) + { + int classMetadataId = ClassIDFromInfo(Container(context), info); + return Container(context).ClassMetadataForID(classMetadataId); + } + + private void DefragmentWriteMappedClassId(IDefragmentContext context, ArrayInfo info + , int classIdOffset) + { + ByteArrayBuffer targetBuffer = context.TargetBuffer(); + int currentOffset = targetBuffer.Offset(); + targetBuffer.Seek(classIdOffset); + int classID = ClassIDFromInfo(Container(context), info); + int mappedID = context.MappedID(classID); + int marshalledMappedId = ClassIdToMarshalledClassId(mappedID, info.Primitive()); + targetBuffer.WriteInt(marshalledMappedId); + targetBuffer.Seek(currentOffset); + } + + private bool IsUntypedByteArray(IBufferContext context) + { + return Handlers4.IsUntyped(_handler) && HandleAsByteArray(context); + } + + protected virtual bool HandleAsByteArray(IBufferContext context) + { + int offset = context.Offset(); + ArrayInfo info = NewArrayInfo(); + ReadInfo(context.Transaction(), context, info); + bool isByteArray = context.Transaction().Reflector().ForClass(typeof(byte)).Equals + (info.ReflectClass()); + context.Seek(offset); + return isByteArray; + } + + public virtual object Read(IReadContext context) + { + ArrayInfo info = NewArrayInfo(); + object array = ReadCreate(context.Transaction(), context, info); + ReadElements(context, info, array); + return array; + } + + protected virtual void ReadElements(IReadContext context, ArrayInfo info, object + array) + { + ReadInto(context, info, array); + } + + protected virtual ArrayInfo NewArrayInfo() + { + return new ArrayInfo(); + } + + protected void ReadInto(IReadContext context, ArrayInfo info, object array) + { + if (array == null) + { + return; + } + if (HandleAsByteArray(array)) + { + context.ReadBytes((byte[])array); + // byte[] performance optimisation + return; + } + if (HasNullBitmap(info)) + { + BitMap4 nullBitMap = ReadNullBitmap(context, info.ElementCount()); + for (int i = 0; i < info.ElementCount(); i++) + { + object obj = nullBitMap.IsTrue(i) ? null : context.ReadObject(_handler); + ArrayReflector(Container(context)).Set(array, i, obj); + } + } + else + { + for (int i = 0; i < info.ElementCount(); i++) + { + ArrayReflector(Container(context)).Set(array, i, context.ReadObject(_handler)); + } + } + } + + protected virtual BitMap4 ReadNullBitmap(IReadBuffer context, int length) + { + return context.ReadBitMap(length); + } + + protected bool HasNullBitmap(ArrayInfo info) + { + return _versionHelper.HasNullBitmap(info); + } + + public virtual void Write(IWriteContext context, object obj) + { + ArrayInfo info = NewArrayInfo(); + Analyze(Container(context), obj, info); + WriteInfo(context, info); + WriteElements(context, obj, info); + } + + protected virtual void WriteElements(IWriteContext context, object obj, ArrayInfo + info) + { + if (HandleAsByteArray(obj)) + { + context.WriteBytes((byte[])obj); + } + else + { + // byte[] performance optimisation + if (HasNullBitmap(info)) + { + BitMap4 nullItems = NullItemsMap(ArrayReflector(Container(context)), obj); + WriteNullBitmap(context, nullItems); + for (int i = 0; i < info.ElementCount(); i++) + { + if (!nullItems.IsTrue(i)) + { + context.WriteObject(_handler, ArrayReflector(Container(context)).Get(obj, i)); + } + } + } + else + { + for (int i = 0; i < info.ElementCount(); i++) + { + context.WriteObject(_handler, ArrayReflector(Container(context)).Get(obj, i)); + } + } + } + } + + protected virtual void WriteInfo(IWriteContext context, ArrayInfo info) + { + WriteHeader(context, info); + WriteDimensions(context, info); + } + + private void WriteHeader(IWriteContext context, ArrayInfo info) + { + context.WriteInt(MarshalledClassID(Container(context), info)); + _versionHelper.WriteTypeInfo(context, info); + } + + protected virtual void WriteDimensions(IWriteContext context, ArrayInfo info) + { + context.WriteInt(info.ElementCount()); + } + + protected void Analyze(ObjectContainerBase container, object obj, ArrayInfo info) + { + // TODO: Move as much analysis as possible to ReflectArray#analyze() + ArrayReflector(container).Analyze(obj, info); + IReflectClass claxx = ComponentType(container, obj); + Db4objects.Db4o.Internal.ClassMetadata classMetadata = container.ProduceClassMetadata + (claxx); + bool primitive = IsPrimitive(container.Reflector(), claxx, classMetadata); + if (primitive) + { + claxx = classMetadata.ClassReflector(); + } + info.Primitive(primitive); + info.ReflectClass(claxx); + AnalyzeDimensions(container, obj, info); + } + + protected virtual void AnalyzeDimensions(ObjectContainerBase container, object obj + , ArrayInfo info) + { + info.ElementCount(ArrayReflector(container).GetLength(obj)); + } + + private void WriteNullBitmap(IWriteBuffer context, BitMap4 bitMap) + { + context.WriteBytes(bitMap.Bytes()); + } + + protected virtual BitMap4 NullItemsMap(IReflectArray reflector, object array) + { + int arrayLength = reflector.GetLength(array); + BitMap4 nullBitMap = new BitMap4(arrayLength); + for (int i = 0; i < arrayLength; i++) + { + if (reflector.Get(array, i) == null) + { + nullBitMap.Set(i, true); + } + } + return nullBitMap; + } + + internal virtual ObjectContainerBase Container(IContext context) + { + return context.Transaction().Container(); + } + + public virtual IPreparedComparison PrepareComparison(IContext context, object obj + ) + { + return new PreparedArrayContainsComparison(context, this, _handler, obj); + } + + public virtual int LinkLength() + { + return Const4.IndirectionLength; + } + + public virtual ITypeHandler4 UnversionedTemplate() + { + return new Db4objects.Db4o.Internal.Handlers.Array.ArrayHandler(); + } + + public virtual object DeepClone(object context) + { + TypeHandlerCloneContext typeHandlerCloneContext = (TypeHandlerCloneContext)context; + Db4objects.Db4o.Internal.Handlers.Array.ArrayHandler original = (Db4objects.Db4o.Internal.Handlers.Array.ArrayHandler + )typeHandlerCloneContext.original; + Db4objects.Db4o.Internal.Handlers.Array.ArrayHandler cloned = (Db4objects.Db4o.Internal.Handlers.Array.ArrayHandler + )Reflection4.NewInstance(this); + cloned._usePrimitiveClassReflector = original._usePrimitiveClassReflector; + cloned._handler = typeHandlerCloneContext.CorrectHandlerVersion(original.DelegateTypeHandler + ()); + return cloned; + } + + public virtual ITypeHandler4 DelegateTypeHandler() + { + return _handler; + } + + private const int HashcodeForNull = 9141078; + + public override string ToString() + { + return "ArrayHandler(isPrimitive=" + _usePrimitiveClassReflector + ", handler=" + + _handler + ")"; + } + + public virtual bool DescendsIntoMembers() + { + return true; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/Array/ArrayVersionHelper0.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/Array/ArrayVersionHelper0.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/Array/ArrayVersionHelper0.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/Array/ArrayVersionHelper0.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,15 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal.Handlers.Array; + +namespace Db4objects.Db4o.Internal.Handlers.Array +{ + /// + public class ArrayVersionHelper0 : ArrayVersionHelper3 + { + public override bool IsPreVersion0Format(int elementCount) + { + return elementCount >= 0; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/Array/ArrayVersionHelper3.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/Array/ArrayVersionHelper3.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/Array/ArrayVersionHelper3.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/Array/ArrayVersionHelper3.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,104 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Handlers.Array; +using Db4objects.Db4o.Marshall; +using Db4objects.Db4o.Reflect; + +namespace Db4objects.Db4o.Internal.Handlers.Array +{ + /// + public class ArrayVersionHelper3 : ArrayVersionHelper5 + { + public override int ClassIDFromInfo(ObjectContainerBase container, ArrayInfo info + ) + { + ClassMetadata classMetadata = container.ProduceClassMetadata(info.ReflectClass()); + if (classMetadata == null) + { + // TODO: This one is a terrible low-frequency blunder !!! + // If YapClass-ID == 99999 then we will get IGNORE back. + // Discovered on adding the primitives + return Const4.IgnoreId; + } + return classMetadata.GetID(); + } + + public override int ClassIdToMarshalledClassId(int classID, bool primitive) + { + if (primitive) + { + classID -= Const4.Primitive; + } + return -classID; + } + + public override IReflectClass ClassReflector(IReflector reflector, ClassMetadata + classMetadata, bool isPrimitive) + { + IReflectClass primitiveClaxx = Handlers4.PrimitiveClassReflector(classMetadata, reflector + ); + if (primitiveClaxx != null) + { + return primitiveClaxx; + } + return base.ClassReflector(reflector, classMetadata, isPrimitive); + } + + public override bool HasNullBitmap(ArrayInfo info) + { + return false; + } + + public override bool IsPrimitive(IReflector reflector, IReflectClass claxx, ClassMetadata + classMetadata) + { + return Handlers4.PrimitiveClassReflector(classMetadata, reflector) != null; + return claxx.IsPrimitive(); + } + + public override IReflectClass ReflectClassFromElementsEntry(ObjectContainerBase container + , ArrayInfo info, int classID) + { + if (classID == Const4.IgnoreId) + { + // TODO: Here is a low-frequency mistake, extremely unlikely. + // If classID == 99999 by accident then we will get ignore. + return null; + } + info.Primitive(false); + if (UseJavaHandling()) + { + if (classID < Const4.Primitive) + { + info.Primitive(true); + classID -= Const4.Primitive; + } + } + classID = -classID; + ClassMetadata classMetadata = container.ClassMetadataForID(classID); + if (classMetadata != null) + { + return ClassReflector(container.Reflector(), classMetadata, info.Primitive()); + } + return null; + } + + public sealed override bool UseJavaHandling() + { + return !Deploy.csharp; + } + + public override void WriteTypeInfo(IWriteContext context, ArrayInfo info) + { + } + + // do nothing, the byte for additional type information was added after format 3 + public override void ReadTypeInfo(Transaction trans, IReadBuffer buffer, ArrayInfo + info, int classID) + { + } + // do nothing, the byte for additional type information was added after format 3 + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/Array/ArrayVersionHelper5.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/Array/ArrayVersionHelper5.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/Array/ArrayVersionHelper5.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/Array/ArrayVersionHelper5.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,16 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal.Handlers.Array; +using Db4objects.Db4o.Reflect; + +namespace Db4objects.Db4o.Internal.Handlers.Array +{ + /// + public class ArrayVersionHelper5 : ArrayVersionHelper + { + public override bool HasNullBitmap(ArrayInfo info) + { + return !info.Primitive(); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/Array/ArrayVersionHelper.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/Array/ArrayVersionHelper.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/Array/ArrayVersionHelper.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/Array/ArrayVersionHelper.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,91 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Marshall; +using Db4objects.Db4o.Reflect; + +namespace Db4objects.Db4o.Internal.Handlers.Array +{ + /// + public class ArrayVersionHelper + { + public virtual int ClassIDFromInfo(ObjectContainerBase container, ArrayInfo info) + { + ClassMetadata classMetadata = container.ProduceClassMetadata(info.ReflectClass()); + if (classMetadata == null) + { + return 0; + } + return classMetadata.GetID(); + } + + public virtual int ClassIdToMarshalledClassId(int classID, bool primitive) + { + return classID; + } + + public virtual IReflectClass ClassReflector(IReflector reflector, ClassMetadata classMetadata + , bool isPrimitive) + { + return isPrimitive ? Handlers4.PrimitiveClassReflector(classMetadata, reflector) : + classMetadata.ClassReflector(); + } + + public virtual bool UseJavaHandling() + { + return true; + } + + public virtual bool HasNullBitmap(ArrayInfo info) + { + if (info.Nullable()) + { + return true; + } + return !info.Primitive(); + } + + public virtual bool IsPreVersion0Format(int elementCount) + { + return false; + } + + public virtual bool IsPrimitive(IReflector reflector, IReflectClass claxx, ClassMetadata + classMetadata) + { + return claxx.IsPrimitive(); + } + + public virtual IReflectClass ReflectClassFromElementsEntry(ObjectContainerBase container + , ArrayInfo info, int classID) + { + if (classID == 0) + { + return null; + } + ClassMetadata classMetadata = container.ClassMetadataForID(classID); + if (classMetadata == null) + { + return null; + } + return ClassReflector(container.Reflector(), classMetadata, info.Primitive()); + } + + public virtual void WriteTypeInfo(IWriteContext context, ArrayInfo info) + { + BitMap4 typeInfoBitmap = new BitMap4(2); + typeInfoBitmap.Set(0, info.Primitive()); + typeInfoBitmap.Set(1, info.Nullable()); + context.WriteByte(typeInfoBitmap.GetByte(0)); + } + + public virtual void ReadTypeInfo(Transaction trans, IReadBuffer buffer, ArrayInfo + info, int classID) + { + BitMap4 typeInfoBitmap = new BitMap4(buffer.ReadByte()); + info.Primitive(typeInfoBitmap.IsTrue(0)); + info.Nullable(typeInfoBitmap.IsTrue(1)); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/Array/MultidimensionalArrayHandler0.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/Array/MultidimensionalArrayHandler0.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/Array/MultidimensionalArrayHandler0.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/Array/MultidimensionalArrayHandler0.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,43 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Handlers.Array; +using Db4objects.Db4o.Internal.Marshall; +using Db4objects.Db4o.Marshall; + +namespace Db4objects.Db4o.Internal.Handlers.Array +{ + /// + public class MultidimensionalArrayHandler0 : MultidimensionalArrayHandler3 + { + protected override ArrayVersionHelper CreateVersionHelper() + { + return new ArrayVersionHelper0(); + } + + public override object Read(IReadContext readContext) + { + IInternalReadContext context = (IInternalReadContext)readContext; + ByteArrayBuffer buffer = (ByteArrayBuffer)context.ReadIndirectedBuffer(); + if (buffer == null) + { + return null; + } + // With the following line we ask the context to work with + // a different buffer. Should this logic ever be needed by + // a user handler, it should be implemented by using a Queue + // in the UnmarshallingContext. + // The buffer has to be set back from the outside! See below + IReadBuffer contextBuffer = context.Buffer(buffer); + object array = base.Read(context); + // The context buffer has to be set back. + context.Buffer(contextBuffer); + return array; + } + + public override void Defragment(IDefragmentContext context) + { + ArrayHandler0.Defragment(context, this); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/Array/MultidimensionalArrayHandler3.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/Array/MultidimensionalArrayHandler3.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/Array/MultidimensionalArrayHandler3.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/Array/MultidimensionalArrayHandler3.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,15 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal.Handlers.Array; + +namespace Db4objects.Db4o.Internal.Handlers.Array +{ + /// + public class MultidimensionalArrayHandler3 : MultidimensionalArrayHandler + { + protected override ArrayVersionHelper CreateVersionHelper() + { + return new ArrayVersionHelper3(); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/Array/MultidimensionalArrayHandler.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/Array/MultidimensionalArrayHandler.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/Array/MultidimensionalArrayHandler.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/Array/MultidimensionalArrayHandler.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,145 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System.Collections; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Handlers.Array; +using Db4objects.Db4o.Marshall; +using Db4objects.Db4o.Reflect; +using Db4objects.Db4o.Typehandlers; + +namespace Db4objects.Db4o.Internal.Handlers.Array +{ + /// n-dimensional array + /// + public class MultidimensionalArrayHandler : ArrayHandler + { + public MultidimensionalArrayHandler(ITypeHandler4 a_handler, bool a_isPrimitive) : + base(a_handler, a_isPrimitive) + { + } + + public MultidimensionalArrayHandler() + { + } + + // required for reflection cloning + public sealed override IEnumerator AllElements(ObjectContainerBase container, object + array) + { + return AllElementsMultidimensional(ArrayReflector(container), array); + } + + public static IEnumerator AllElementsMultidimensional(IReflectArray reflectArray, + object array) + { + return new MultidimensionalArrayIterator(reflectArray, (object[])array); + } + + protected static int ElementCount(int[] a_dim) + { + int elements = a_dim[0]; + for (int i = 1; i < a_dim.Length; i++) + { + elements = elements * a_dim[i]; + } + return elements; + } + + public sealed override byte Identifier() + { + return Const4.Yaparrayn; + } + + protected override ArrayInfo NewArrayInfo() + { + return new MultidimensionalArrayInfo(); + } + + protected override void ReadDimensions(ArrayInfo info, IReadBuffer buffer) + { + ReadDimensions(info, buffer, buffer.ReadInt()); + } + + private void ReadDimensions(ArrayInfo info, IReadBuffer buffer, int dimensionCount + ) + { + int[] dim = new int[dimensionCount]; + for (int i = 0; i < dim.Length; i++) + { + dim[i] = buffer.ReadInt(); + } + ((MultidimensionalArrayInfo)info).Dimensions(dim); + info.ElementCount(ElementCount(dim)); + } + + protected override void ReadElements(IReadContext context, ArrayInfo info, object + array) + { + if (array == null) + { + return; + } + object[] objects = new object[info.ElementCount()]; + ReadInto(context, info, objects); + ArrayReflector(Container(context)).Shape(objects, 0, array, ((MultidimensionalArrayInfo + )info).Dimensions(), 0); + } + + protected override void WriteDimensions(IWriteContext context, ArrayInfo info) + { + int[] dim = ((MultidimensionalArrayInfo)info).Dimensions(); + context.WriteInt(dim.Length); + for (int i = 0; i < dim.Length; i++) + { + context.WriteInt(dim[i]); + } + } + + protected override void WriteElements(IWriteContext context, object obj, ArrayInfo + info) + { + IEnumerator objects = AllElements(Container(context), obj); + if (HasNullBitmap(info)) + { + BitMap4 nullBitMap = new BitMap4(info.ElementCount()); + IReservedBuffer nullBitMapBuffer = context.Reserve(nullBitMap.MarshalledLength()); + int currentElement = 0; + while (objects.MoveNext()) + { + object current = objects.Current; + if (current == null) + { + nullBitMap.SetTrue(currentElement); + } + else + { + context.WriteObject(DelegateTypeHandler(), current); + } + currentElement++; + } + nullBitMapBuffer.WriteBytes(nullBitMap.Bytes()); + } + else + { + while (objects.MoveNext()) + { + context.WriteObject(DelegateTypeHandler(), objects.Current); + } + } + } + + protected override void AnalyzeDimensions(ObjectContainerBase container, object obj + , ArrayInfo info) + { + int[] dim = ArrayReflector(container).Dimensions(obj); + ((MultidimensionalArrayInfo)info).Dimensions(dim); + info.ElementCount(ElementCount(dim)); + } + + public override ITypeHandler4 UnversionedTemplate() + { + return new Db4objects.Db4o.Internal.Handlers.Array.MultidimensionalArrayHandler(); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/Array/MultidimensionalArrayIterator.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/Array/MultidimensionalArrayIterator.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/Array/MultidimensionalArrayIterator.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/Array/MultidimensionalArrayIterator.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,79 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using System.Collections; +using Db4objects.Db4o.Internal.Handlers.Array; +using Db4objects.Db4o.Reflect; + +namespace Db4objects.Db4o.Internal.Handlers.Array +{ + /// + public class MultidimensionalArrayIterator : IEnumerator + { + private readonly IReflectArray _reflectArray; + + private readonly object[] _array; + + private int _currentElement; + + private IEnumerator _delegate; + + public MultidimensionalArrayIterator(IReflectArray reflectArray, object[] array) + { + _reflectArray = reflectArray; + _array = array; + Reset(); + } + + public virtual object Current + { + get + { + if (_delegate == null) + { + return _array[_currentElement]; + } + return _delegate.Current; + } + } + + public virtual bool MoveNext() + { + if (_delegate != null) + { + if (_delegate.MoveNext()) + { + return true; + } + _delegate = null; + } + _currentElement++; + if (_currentElement >= _array.Length) + { + return false; + } + object obj = _array[_currentElement]; + Type clazz = obj.GetType(); + if (clazz.IsArray) + { + if (clazz.GetElementType().IsArray) + { + _delegate = new Db4objects.Db4o.Internal.Handlers.Array.MultidimensionalArrayIterator + (_reflectArray, (object[])obj); + } + else + { + _delegate = new ReflectArrayIterator(_reflectArray, obj); + } + return MoveNext(); + } + return true; + } + + public virtual void Reset() + { + _currentElement = -1; + _delegate = null; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/Array/ReflectArrayIterator.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/Array/ReflectArrayIterator.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/Array/ReflectArrayIterator.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/Array/ReflectArrayIterator.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,27 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Reflect; + +namespace Db4objects.Db4o.Internal.Handlers.Array +{ + /// + internal sealed class ReflectArrayIterator : IndexedIterator + { + private readonly object _array; + + private readonly IReflectArray _reflectArray; + + public ReflectArrayIterator(IReflectArray reflectArray, object array) : base(reflectArray + .GetLength(array)) + { + _reflectArray = reflectArray; + _array = array; + } + + protected override object Get(int index) + { + return _reflectArray.Get(_array, index); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/BooleanHandler.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/BooleanHandler.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/BooleanHandler.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/BooleanHandler.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,121 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Handlers; +using Db4objects.Db4o.Marshall; + +namespace Db4objects.Db4o.Internal.Handlers +{ + /// + public sealed class BooleanHandler : PrimitiveHandler + { + internal const int Length = 1 + Const4.AddedLength; + + private const byte True = (byte)'T'; + + private const byte False = (byte)'F'; + + private const byte Null = (byte)'N'; + + private static readonly bool Defaultvalue = false; + + public override object DefaultValue() + { + return Defaultvalue; + } + + public override int LinkLength() + { + return Length; + } + + public override Type PrimitiveJavaClass() + { + return typeof(bool); + } + + internal override object Read1(ByteArrayBuffer a_bytes) + { + byte ret = a_bytes.ReadByte(); + if (ret == True) + { + return true; + } + if (ret == False) + { + return false; + } + return null; + } + + public override void Write(object obj, ByteArrayBuffer buffer) + { + buffer.WriteByte(GetEncodedByteValue(obj)); + } + + private byte GetEncodedByteValue(object obj) + { + if (obj == null) + { + return Null; + } + if (((bool)obj)) + { + return True; + } + return False; + } + + public override object Read(IReadContext context) + { + byte ret = context.ReadByte(); + if (ret == True) + { + return true; + } + if (ret == False) + { + return false; + } + return null; + } + + public override void Write(IWriteContext context, object obj) + { + context.WriteByte(GetEncodedByteValue(obj)); + } + + public override object NullRepresentationInUntypedArrays() + { + return null; + } + + public override IPreparedComparison InternalPrepareComparison(object source) + { + bool sourceBoolean = ((bool)source); + return new _IPreparedComparison_111(sourceBoolean); + } + + private sealed class _IPreparedComparison_111 : IPreparedComparison + { + public _IPreparedComparison_111(bool sourceBoolean) + { + this.sourceBoolean = sourceBoolean; + } + + public int CompareTo(object target) + { + if (target == null) + { + return 1; + } + bool targetBoolean = ((bool)target); + return sourceBoolean == targetBoolean ? 0 : (sourceBoolean ? 1 : -1); + } + + private readonly bool sourceBoolean; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/ByteHandler.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/ByteHandler.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/ByteHandler.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/ByteHandler.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,86 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Handlers; +using Db4objects.Db4o.Marshall; +using Db4objects.Db4o.Reflect; + +namespace Db4objects.Db4o.Internal.Handlers +{ + public sealed class ByteHandler : PrimitiveHandler + { + internal const int Length = 1 + Const4.AddedLength; + + private static readonly byte Defaultvalue = (byte)0; + + public override object Coerce(IReflectClass claxx, object obj) + { + return Coercion4.ToByte(obj); + } + + public override object DefaultValue() + { + return Defaultvalue; + } + + public override int LinkLength() + { + return Length; + } + + public override Type PrimitiveJavaClass() + { + return typeof(byte); + } + + internal override object Read1(ByteArrayBuffer a_bytes) + { + byte ret = a_bytes.ReadByte(); + return ret; + } + + public override void Write(object a_object, ByteArrayBuffer a_bytes) + { + a_bytes.WriteByte(((byte)a_object)); + } + + public override object Read(IReadContext context) + { + byte byteValue = context.ReadByte(); + return byteValue; + } + + public override void Write(IWriteContext context, object obj) + { + context.WriteByte(((byte)obj)); + } + + public override IPreparedComparison InternalPrepareComparison(object source) + { + byte sourceByte = ((byte)source); + return new _IPreparedComparison_82(sourceByte); + } + + private sealed class _IPreparedComparison_82 : IPreparedComparison + { + public _IPreparedComparison_82(byte sourceByte) + { + this.sourceByte = sourceByte; + } + + public int CompareTo(object target) + { + if (target == null) + { + return 1; + } + byte targetByte = ((byte)target); + return sourceByte == targetByte ? 0 : (sourceByte < targetByte ? -1 : 1); + } + + private readonly byte sourceByte; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/CharHandler.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/CharHandler.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/CharHandler.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/CharHandler.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,90 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Handlers; +using Db4objects.Db4o.Marshall; + +namespace Db4objects.Db4o.Internal.Handlers +{ + public sealed class CharHandler : PrimitiveHandler + { + internal const int Length = Const4.CharBytes + Const4.AddedLength; + + private static readonly char Defaultvalue = (char)0; + + public override object DefaultValue() + { + return Defaultvalue; + } + + public override int LinkLength() + { + return Length; + } + + public override Type PrimitiveJavaClass() + { + return typeof(char); + } + + internal override object Read1(ByteArrayBuffer a_bytes) + { + byte b1 = a_bytes.ReadByte(); + byte b2 = a_bytes.ReadByte(); + char ret = (char)((b1 & unchecked((int)(0xff))) | ((b2 & unchecked((int)(0xff))) + << 8)); + return ret; + } + + public override void Write(object a_object, ByteArrayBuffer a_bytes) + { + char char_ = ((char)a_object); + a_bytes.WriteByte((byte)(char_ & unchecked((int)(0xff)))); + a_bytes.WriteByte((byte)(char_ >> 8)); + } + + public override object Read(IReadContext context) + { + byte b1 = context.ReadByte(); + byte b2 = context.ReadByte(); + char charValue = (char)((b1 & unchecked((int)(0xff))) | ((b2 & unchecked((int)(0xff + ))) << 8)); + return charValue; + } + + public override void Write(IWriteContext context, object obj) + { + char charValue = ((char)obj); + context.WriteBytes(new byte[] { (byte)(charValue & unchecked((int)(0xff))), (byte + )(charValue >> 8) }); + } + + public override IPreparedComparison InternalPrepareComparison(object source) + { + char sourceChar = ((char)source); + return new _IPreparedComparison_90(sourceChar); + } + + private sealed class _IPreparedComparison_90 : IPreparedComparison + { + public _IPreparedComparison_90(char sourceChar) + { + this.sourceChar = sourceChar; + } + + public int CompareTo(object target) + { + if (target == null) + { + return 1; + } + char targetChar = ((char)target); + return sourceChar == targetChar ? 0 : (sourceChar < targetChar ? -1 : 1); + } + + private readonly char sourceChar; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/DateHandler0.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/DateHandler0.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/DateHandler0.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/DateHandler0.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,22 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using Db4objects.Db4o.Internal.Handlers; +using Db4objects.Db4o.Marshall; + +namespace Db4objects.Db4o.Internal.Handlers +{ + /// + public class DateHandler0 : DateHandler + { + public override object Read(IReadContext context) + { + long value = context.ReadLong(); + if (value == long.MaxValue) + { + return PrimitiveNull(); + } + return new DateTime(value); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/DateHandlerBase.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/DateHandlerBase.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/DateHandlerBase.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/DateHandlerBase.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,104 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Handlers; +using Db4objects.Db4o.Internal.Marshall; +using Db4objects.Db4o.Marshall; +using Db4objects.Db4o.Reflect; + +namespace Db4objects.Db4o.Internal.Handlers +{ + /// Shared (java/.net) logic for Date handling. + /// Shared (java/.net) logic for Date handling. + public abstract class DateHandlerBase : LongHandler + { + public override object Coerce(IReflectClass claxx, object obj) + { + return ClassReflector().IsAssignableFrom(claxx) ? obj : No4.Instance; + } + + public abstract object CopyValue(object from, object to); + + public abstract override object DefaultValue(); + + public abstract override object NullRepresentationInUntypedArrays(); + + public override Type PrimitiveJavaClass() + { + return null; + } + + protected override Type JavaClass() + { + return DefaultValue().GetType(); + } + + /// + public override object Read(MarshallerFamily mf, StatefulBuffer writer, bool redirect + ) + { + return mf._primitive.ReadDate(writer); + } + + internal override object Read1(ByteArrayBuffer a_bytes) + { + return PrimitiveMarshaller().ReadDate(a_bytes); + } + + public override void Write(object a_object, ByteArrayBuffer a_bytes) + { + // TODO: This is a temporary fix to prevent exceptions with + // Marshaller.LEGACY. + if (a_object == null) + { + a_object = new DateTime(0); + } + a_bytes.WriteLong(((DateTime)a_object).Ticks); + } + + public static string Now() + { + return Platform4.Format(Platform4.Now(), true); + } + + public override object Read(IReadContext context) + { + long milliseconds = ((long)base.Read(context)); + return new DateTime(milliseconds); + } + + public override void Write(IWriteContext context, object obj) + { + long milliseconds = ((DateTime)obj).Ticks; + base.Write(context, milliseconds); + } + + public override IPreparedComparison InternalPrepareComparison(object source) + { + long sourceDate = ((DateTime)source).Ticks; + return new _IPreparedComparison_69(sourceDate); + } + + private sealed class _IPreparedComparison_69 : IPreparedComparison + { + public _IPreparedComparison_69(long sourceDate) + { + this.sourceDate = sourceDate; + } + + public int CompareTo(object target) + { + if (target == null) + { + return 1; + } + long targetDate = ((DateTime)target).Ticks; + return sourceDate == targetDate ? 0 : (sourceDate < targetDate ? -1 : 1); + } + + private readonly long sourceDate; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/DoubleHandler0.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/DoubleHandler0.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/DoubleHandler0.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/DoubleHandler0.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,20 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal.Handlers; +using Db4objects.Db4o.Marshall; + +namespace Db4objects.Db4o.Internal.Handlers +{ + public class DoubleHandler0 : DoubleHandler + { + public override object Read(IReadContext context) + { + double value = (double)base.Read(context); + if (double.IsNaN(value)) + { + return null; + } + return value; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/DoubleHandler.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/DoubleHandler.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/DoubleHandler.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/DoubleHandler.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,87 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Handlers; +using Db4objects.Db4o.Internal.Marshall; +using Db4objects.Db4o.Marshall; +using Db4objects.Db4o.Reflect; + +namespace Db4objects.Db4o.Internal.Handlers +{ + /// + public class DoubleHandler : LongHandler + { + private static readonly double Defaultvalue = System.Convert.ToDouble(0); + + public override object Coerce(IReflectClass claxx, object obj) + { + return Coercion4.ToDouble(obj); + } + + public override object DefaultValue() + { + return Defaultvalue; + } + + public override Type PrimitiveJavaClass() + { + return typeof(double); + } + + /// + public override object Read(MarshallerFamily mf, StatefulBuffer buffer, bool redirect + ) + { + return mf._primitive.ReadDouble(buffer); + } + + internal override object Read1(ByteArrayBuffer buffer) + { + return PrimitiveMarshaller().ReadDouble(buffer); + } + + public override void Write(object a_object, ByteArrayBuffer a_bytes) + { + a_bytes.WriteLong(Platform4.DoubleToLong(((double)a_object))); + } + + public override object Read(IReadContext context) + { + long l = (long)base.Read(context); + return Platform4.LongToDouble(l); + } + + public override void Write(IWriteContext context, object obj) + { + context.WriteLong(Platform4.DoubleToLong(((double)obj))); + } + + public override IPreparedComparison InternalPrepareComparison(object source) + { + double sourceDouble = ((double)source); + return new _IPreparedComparison_55(sourceDouble); + } + + private sealed class _IPreparedComparison_55 : IPreparedComparison + { + public _IPreparedComparison_55(double sourceDouble) + { + this.sourceDouble = sourceDouble; + } + + public int CompareTo(object target) + { + if (target == null) + { + return 1; + } + double targetDouble = ((double)target); + return sourceDouble == targetDouble ? 0 : (sourceDouble < targetDouble ? -1 : 1); + } + + private readonly double sourceDouble; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/FloatHandler0.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/FloatHandler0.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/FloatHandler0.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/FloatHandler0.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,20 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal.Handlers; +using Db4objects.Db4o.Marshall; + +namespace Db4objects.Db4o.Internal.Handlers +{ + public class FloatHandler0 : FloatHandler + { + public override object Read(IReadContext context) + { + float value = (float)base.Read(context); + if (float.IsNaN(value)) + { + return null; + } + return value; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/FloatHandler.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/FloatHandler.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/FloatHandler.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/FloatHandler.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,85 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Handlers; +using Db4objects.Db4o.Internal.Marshall; +using Db4objects.Db4o.Marshall; +using Db4objects.Db4o.Reflect; + +namespace Db4objects.Db4o.Internal.Handlers +{ + public class FloatHandler : IntHandler + { + private static readonly float Defaultvalue = System.Convert.ToSingle(0); + + public override object Coerce(IReflectClass claxx, object obj) + { + return Coercion4.ToFloat(obj); + } + + public override object DefaultValue() + { + return Defaultvalue; + } + + public override Type PrimitiveJavaClass() + { + return typeof(float); + } + + /// + public override object Read(MarshallerFamily mf, StatefulBuffer writer, bool redirect + ) + { + return mf._primitive.ReadFloat(writer); + } + + internal override object Read1(ByteArrayBuffer a_bytes) + { + return PrimitiveMarshaller().ReadFloat(a_bytes); + } + + public override void Write(object a_object, ByteArrayBuffer a_bytes) + { + WriteInt(Sharpen.Runtime.FloatToIntBits(((float)a_object)), a_bytes); + } + + public override object Read(IReadContext context) + { + return Sharpen.Runtime.IntBitsToFloat(context.ReadInt()); + } + + public override void Write(IWriteContext context, object obj) + { + context.WriteInt(Sharpen.Runtime.FloatToIntBits(((float)obj))); + } + + public override IPreparedComparison InternalPrepareComparison(object source) + { + float sourceFloat = ((float)source); + return new _IPreparedComparison_54(sourceFloat); + } + + private sealed class _IPreparedComparison_54 : IPreparedComparison + { + public _IPreparedComparison_54(float sourceFloat) + { + this.sourceFloat = sourceFloat; + } + + public int CompareTo(object target) + { + if (target == null) + { + return 1; + } + float targetFloat = ((float)target); + return sourceFloat == targetFloat ? 0 : (sourceFloat < targetFloat ? -1 : 1); + } + + private readonly float sourceFloat; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/HandlerVersion.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/HandlerVersion.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/HandlerVersion.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/HandlerVersion.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,27 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +namespace Db4objects.Db4o.Internal.Handlers +{ + /// + public class HandlerVersion + { + public readonly int _number; + + public static readonly Db4objects.Db4o.Internal.Handlers.HandlerVersion Invalid = + new Db4objects.Db4o.Internal.Handlers.HandlerVersion(-1); + + public HandlerVersion(int number) + { + _number = number; + } + + public override bool Equals(object obj) + { + if (this == obj) + { + return true; + } + return ((Db4objects.Db4o.Internal.Handlers.HandlerVersion)obj)._number == _number; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/IFieldAwareTypeHandler.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/IFieldAwareTypeHandler.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/IFieldAwareTypeHandler.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/IFieldAwareTypeHandler.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,28 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Delete; +using Db4objects.Db4o.Internal.Handlers; +using Db4objects.Db4o.Internal.Marshall; +using Db4objects.Db4o.Typehandlers; + +namespace Db4objects.Db4o.Internal.Handlers +{ + /// + public interface IFieldAwareTypeHandler : IReferenceTypeHandler, IVersionedTypeHandler + , ICascadingTypeHandler, IVirtualAttributeHandler + { + void AddFieldIndices(ObjectIdContextImpl context); + + void CollectIDs(CollectIdContext context, IPredicate4 predicate); + + void DeleteMembers(DeleteContextImpl deleteContext, bool isUpdate); + + void ReadVirtualAttributes(ObjectReferenceContext context); + + void ClassMetadata(Db4objects.Db4o.Internal.ClassMetadata classMetadata); + + bool SeekToField(ObjectHeaderContext context, ClassAspect aspect); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/IntHandler0.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/IntHandler0.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/IntHandler0.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/IntHandler0.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,21 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal.Handlers; +using Db4objects.Db4o.Marshall; + +namespace Db4objects.Db4o.Internal.Handlers +{ + /// + public class IntHandler0 : IntHandler + { + public override object Read(IReadContext context) + { + int i = context.ReadInt(); + if (i == int.MaxValue) + { + return null; + } + return i; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/IntHandler.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/IntHandler.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/IntHandler.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/IntHandler.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,122 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Handlers; +using Db4objects.Db4o.Internal.Marshall; +using Db4objects.Db4o.Marshall; +using Db4objects.Db4o.Reflect; + +namespace Db4objects.Db4o.Internal.Handlers +{ + /// + public class IntHandler : PrimitiveHandler + { + private static readonly int Defaultvalue = 0; + + public override object Coerce(IReflectClass claxx, object obj) + { + return Coercion4.ToInt(obj); + } + + public override object DefaultValue() + { + return Defaultvalue; + } + + public override Type PrimitiveJavaClass() + { + return typeof(int); + } + + public override int LinkLength() + { + return Const4.IntLength; + } + + /// + public override object Read(MarshallerFamily mf, StatefulBuffer writer, bool redirect + ) + { + return mf._primitive.ReadInteger(writer); + } + + internal override object Read1(ByteArrayBuffer a_bytes) + { + return a_bytes.ReadInt(); + } + + public override void Write(object obj, ByteArrayBuffer writer) + { + Write(((int)obj), writer); + } + + public virtual void Write(int intValue, ByteArrayBuffer writer) + { + WriteInt(intValue, writer); + } + + public static void WriteInt(int a_int, ByteArrayBuffer a_bytes) + { + a_bytes.WriteInt(a_int); + } + + public override void DefragIndexEntry(DefragmentContextImpl context) + { + context.IncrementIntSize(); + } + + public override object Read(IReadContext context) + { + return context.ReadInt(); + } + + public override void Write(IWriteContext context, object obj) + { + context.WriteInt(((int)obj)); + } + + public override IPreparedComparison InternalPrepareComparison(object source) + { + return NewPrepareCompare(((int)source)); + } + + public virtual IPreparedComparison NewPrepareCompare(int i) + { + return new IntHandler.PreparedIntComparison(this, i); + } + + public static int Compare(int first, int second) + { + if (first == second) + { + return 0; + } + return first > second ? 1 : -1; + } + + public sealed class PreparedIntComparison : IPreparedComparison + { + private readonly int _sourceInt; + + public PreparedIntComparison(IntHandler _enclosing, int sourceInt) + { + this._enclosing = _enclosing; + this._sourceInt = sourceInt; + } + + public int CompareTo(object target) + { + if (target == null) + { + return 1; + } + int targetInt = ((int)target); + return IntHandler.Compare(this._sourceInt, targetInt); + } + + private readonly IntHandler _enclosing; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/IVariableLengthTypeHandler.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/IVariableLengthTypeHandler.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/IVariableLengthTypeHandler.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/IVariableLengthTypeHandler.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,15 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Typehandlers; + +namespace Db4objects.Db4o.Internal.Handlers +{ + /// + /// marker interface for TypeHandlers where the slot + /// length can change, depending on the object stored + /// + /// + public interface IVariableLengthTypeHandler : ITypeHandler4 + { + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/IVirtualAttributeHandler.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/IVirtualAttributeHandler.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/IVirtualAttributeHandler.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/IVirtualAttributeHandler.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,12 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal.Marshall; + +namespace Db4objects.Db4o.Internal.Handlers +{ + /// + public interface IVirtualAttributeHandler + { + void ReadVirtualAttributes(ObjectReferenceContext context); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/LongHandler0.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/LongHandler0.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/LongHandler0.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/LongHandler0.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,20 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal.Handlers; +using Db4objects.Db4o.Marshall; + +namespace Db4objects.Db4o.Internal.Handlers +{ + public class LongHandler0 : LongHandler + { + public override object Read(IReadContext context) + { + long value = (long)base.Read(context); + if (value == long.MaxValue) + { + return null; + } + return value; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/LongHandler.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/LongHandler.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/LongHandler.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/LongHandler.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,136 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using Db4objects.Db4o; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Encoding; +using Db4objects.Db4o.Internal.Handlers; +using Db4objects.Db4o.Internal.Marshall; +using Db4objects.Db4o.Marshall; +using Db4objects.Db4o.Reflect; + +namespace Db4objects.Db4o.Internal.Handlers +{ + /// + public class LongHandler : PrimitiveHandler + { + private static readonly long Defaultvalue = System.Convert.ToInt64(0); + + public override object Coerce(IReflectClass claxx, object obj) + { + return Coercion4.ToLong(obj); + } + + public override object DefaultValue() + { + return Defaultvalue; + } + + public override Type PrimitiveJavaClass() + { + return typeof(long); + } + + public override int LinkLength() + { + return Const4.LongLength; + } + + /// + public override object Read(MarshallerFamily mf, StatefulBuffer buffer, bool redirect + ) + { + return mf._primitive.ReadLong(buffer); + } + + internal override object Read1(ByteArrayBuffer a_bytes) + { + return a_bytes.ReadLong(); + } + + public override void Write(object obj, ByteArrayBuffer buffer) + { + WriteLong(buffer, ((long)obj)); + } + + public static void WriteLong(IWriteBuffer buffer, long val) + { + if (Deploy.debug && Deploy.debugLong) + { + string l_s = " " + val; + new LatinStringIO().Write(buffer, Sharpen.Runtime.Substring(l_s, l_s.Length - Const4 + .LongBytes)); + } + else + { + for (int i = 0; i < Const4.LongBytes; i++) + { + buffer.WriteByte((byte)(val >> ((Const4.LongBytes - 1 - i) * 8))); + } + } + } + + public static long ReadLong(IReadBuffer buffer) + { + long ret = 0; + if (Deploy.debug && Deploy.debugLong) + { + ret = long.Parse(new LatinStringIO().Read(buffer, Const4.LongBytes).Trim()); + } + else + { + for (int i = 0; i < Const4.LongBytes; i++) + { + ret = (ret << 8) + (buffer.ReadByte() & unchecked((int)(0xff))); + } + } + return ret; + } + + public override object Read(IReadContext context) + { + return context.ReadLong(); + } + + public override void Write(IWriteContext context, object obj) + { + context.WriteLong(((long)obj)); + } + + public static int Compare(long first, long second) + { + if (first == second) + { + return 0; + } + return first > second ? 1 : -1; + } + + public override IPreparedComparison InternalPrepareComparison(object source) + { + long sourceLong = ((long)source); + return new _IPreparedComparison_102(sourceLong); + } + + private sealed class _IPreparedComparison_102 : IPreparedComparison + { + public _IPreparedComparison_102(long sourceLong) + { + this.sourceLong = sourceLong; + } + + public int CompareTo(object target) + { + if (target == null) + { + return 1; + } + long targetLong = ((long)target); + return LongHandler.Compare(sourceLong, targetLong); + } + + private readonly long sourceLong; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/NetType.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/NetType.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/NetType.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/NetType.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,15 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +namespace Db4objects.Db4o.Internal.Handlers +{ + internal interface INetType + { + object DefaultValue(); + + int TypeID(); + + void Write(object obj, byte[] bytes, int offset); + + object Read(byte[] bytes, int offset); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/NetTypeHandler.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/NetTypeHandler.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/NetTypeHandler.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/NetTypeHandler.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,105 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Handlers; +using Db4objects.Db4o.Reflect; + +namespace Db4objects.Db4o.Internal.Handlers +{ + /// + public abstract class NetTypeHandler : PrimitiveHandler, INetType + { + private int i_linkLength; + + public virtual string DotNetClassName() + { + string className = this.GetType().FullName; + int pos = className.IndexOf(".Net"); + if (pos >= 0) + { + return "System." + Sharpen.Runtime.Substring(className, pos + 4) + ", mscorlib"; + } + return DefaultValue().GetType().FullName; + } + + public override void RegisterReflector(IReflector reflector) + { + base.RegisterReflector(reflector); + byte[] bytes = new byte[65]; + for (int i = 0; i < bytes.Length; i++) + { + bytes[i] = 55; + } + // TODO: Why 55? This is a '7'. Remove. + Write(PrimitiveNull(), bytes, 0); + for (int i = 0; i < bytes.Length; i++) + { + if (bytes[i] == 55) + { + i_linkLength = i; + break; + } + } + } + + public virtual int GetID() + { + return TypeID(); + } + + // This method is needed for NetSimpleTypeHandler only during + // initalisation and overloaded there. No abstract declaration + // here, so we don't have to implement the methods on .NET. + public virtual string GetName() + { + return DotNetClassName(); + } + + public override int LinkLength() + { + return i_linkLength; + } + + public override Type PrimitiveJavaClass() + { + return DefaultValue().GetType(); + } + + protected override Type JavaClass() + { + return base.JavaClass(); + } + + public abstract object Read(byte[] bytes, int offset); + + /// + internal override object Read1(ByteArrayBuffer a_bytes) + { + int offset = a_bytes._offset; + object ret = Read(a_bytes._buffer, a_bytes._offset); + a_bytes._offset = offset + LinkLength(); + return ret; + } + + public abstract int TypeID(); + + public abstract void Write(object obj, byte[] bytes, int offset); + + public override void Write(object a_object, ByteArrayBuffer a_bytes) + { + int offset = a_bytes._offset; + if (a_object != null) + { + Write(a_object, a_bytes._buffer, a_bytes._offset); + } + a_bytes._offset = offset + LinkLength(); + } + + public override IPreparedComparison InternalPrepareComparison(object obj) + { + throw new NotImplementedException(); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/NullFieldAwareTypeHandler.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/NullFieldAwareTypeHandler.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/NullFieldAwareTypeHandler.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/NullFieldAwareTypeHandler.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,91 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Delete; +using Db4objects.Db4o.Internal.Handlers; +using Db4objects.Db4o.Internal.Marshall; +using Db4objects.Db4o.Marshall; +using Db4objects.Db4o.Typehandlers; + +namespace Db4objects.Db4o.Internal.Handlers +{ + /// + public class NullFieldAwareTypeHandler : IFieldAwareTypeHandler + { + public static readonly IFieldAwareTypeHandler Instance = new NullFieldAwareTypeHandler + (); + + public virtual void AddFieldIndices(ObjectIdContextImpl context) + { + } + + public virtual void ClassMetadata(Db4objects.Db4o.Internal.ClassMetadata classMetadata + ) + { + } + + public virtual void CollectIDs(CollectIdContext context, IPredicate4 predicate) + { + } + + public virtual void DeleteMembers(DeleteContextImpl deleteContext, bool isUpdate) + { + } + + public virtual void ReadVirtualAttributes(ObjectReferenceContext context) + { + } + + public virtual bool SeekToField(ObjectHeaderContext context, ClassAspect aspect) + { + return false; + } + + public virtual void Defragment(IDefragmentContext context) + { + } + + /// + public virtual void Delete(IDeleteContext context) + { + } + + public virtual void Activate(IReferenceActivationContext context) + { + } + + public virtual void Write(IWriteContext context, object obj) + { + } + + public virtual IPreparedComparison PrepareComparison(IContext context, object obj + ) + { + return null; + } + + public virtual ITypeHandler4 UnversionedTemplate() + { + return null; + } + + public virtual object DeepClone(object context) + { + return null; + } + + public virtual void CascadeActivation(IActivationContext context) + { + } + + public virtual void CollectIDs(QueryingReadContext context) + { + } + + public virtual ITypeHandler4 ReadCandidateHandler(QueryingReadContext context) + { + return null; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/PlainObjectHandler.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/PlainObjectHandler.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/PlainObjectHandler.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/PlainObjectHandler.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,31 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Delete; +using Db4objects.Db4o.Marshall; +using Db4objects.Db4o.Typehandlers; + +namespace Db4objects.Db4o.Internal.Handlers +{ + /// Tyehandler for naked plain objects (java.lang.Object). + /// Tyehandler for naked plain objects (java.lang.Object). + public class PlainObjectHandler : IReferenceTypeHandler + { + public virtual void Defragment(IDefragmentContext context) + { + } + + /// + public virtual void Delete(IDeleteContext context) + { + } + + public virtual void Activate(IReferenceActivationContext context) + { + } + + public virtual void Write(IWriteContext context, object obj) + { + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/PrimitiveHandler.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/PrimitiveHandler.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/PrimitiveHandler.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/PrimitiveHandler.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,196 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using Db4objects.Db4o; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Delete; +using Db4objects.Db4o.Internal.Marshall; +using Db4objects.Db4o.Marshall; +using Db4objects.Db4o.Reflect; +using Db4objects.Db4o.Typehandlers; + +namespace Db4objects.Db4o.Internal.Handlers +{ + /// + public abstract class PrimitiveHandler : IValueTypeHandler, IIndexableTypeHandler + , IBuiltinTypeHandler, IQueryableTypeHandler + { + protected IReflectClass _classReflector; + + private IReflectClass _primitiveClassReflector; + + private object _primitiveNull; + + public virtual object Coerce(IReflectClass claxx, object obj) + { + return IsAssignableFrom(claxx) ? obj : No4.Instance; + } + + private bool IsAssignableFrom(IReflectClass claxx) + { + return ClassReflector().IsAssignableFrom(claxx) || PrimitiveClassReflector().IsAssignableFrom + (claxx); + } + + public abstract object DefaultValue(); + + public virtual void Delete(IDeleteContext context) + { + context.Seek(context.Offset() + LinkLength()); + } + + public object IndexEntryToObject(IContext context, object indexEntry) + { + return indexEntry; + } + + public abstract Type PrimitiveJavaClass(); + + protected virtual Type JavaClass() + { + return Platform4.NullableTypeFor(PrimitiveJavaClass()); + } + + public virtual bool DescendsIntoMembers() + { + return false; + } + + public virtual object PrimitiveNull() + { + if (_primitiveNull == null) + { + IReflectClass claxx = (_primitiveClassReflector == null ? _classReflector : _primitiveClassReflector + ); + _primitiveNull = claxx.NullValue(); + } + return _primitiveNull; + } + + /// + /// + /// + /// + public virtual object Read(MarshallerFamily mf, StatefulBuffer buffer, bool redirect + ) + { + return Read1(buffer); + } + + /// + internal abstract object Read1(ByteArrayBuffer reader); + + public virtual object ReadIndexEntry(IContext context, ByteArrayBuffer buffer) + { + try + { + return Read1(buffer); + } + catch (CorruptionException) + { + } + return null; + } + + /// + public object ReadIndexEntryFromObjectSlot(MarshallerFamily mf, StatefulBuffer statefulBuffer + ) + { + return Read(mf, statefulBuffer, true); + } + + /// + /// + public virtual object ReadIndexEntry(IObjectIdContext context) + { + return Read(context); + } + + public virtual IReflectClass ClassReflector() + { + return _classReflector; + } + + public virtual IReflectClass PrimitiveClassReflector() + { + return _primitiveClassReflector; + } + + public virtual void RegisterReflector(IReflector reflector) + { + _classReflector = reflector.ForClass(JavaClass()); + Type clazz = PrimitiveJavaClass(); + if (clazz != null) + { + _primitiveClassReflector = reflector.ForClass(clazz); + } + } + + public abstract void Write(object a_object, ByteArrayBuffer a_bytes); + + public virtual void WriteIndexEntry(IContext context, ByteArrayBuffer a_writer, object + a_object) + { + if (a_object == null) + { + a_object = PrimitiveNull(); + } + Write(a_object, a_writer); + } + + // redundant, only added to make Sun JDK 1.2's java happy :( + public abstract int LinkLength(); + + public void Defragment(IDefragmentContext context) + { + context.IncrementOffset(LinkLength()); + } + + public virtual void DefragIndexEntry(DefragmentContextImpl context) + { + try + { + Read1(context.SourceBuffer()); + Read1(context.TargetBuffer()); + } + catch (CorruptionException) + { + Exceptions4.VirtualException(); + } + } + + protected virtual Db4objects.Db4o.Internal.Marshall.PrimitiveMarshaller PrimitiveMarshaller + () + { + return MarshallerFamily.Current()._primitive; + } + + public virtual void Write(IWriteContext context, object obj) + { + throw new NotImplementedException(); + } + + public virtual object Read(IReadContext context) + { + throw new NotImplementedException(); + } + + public virtual object NullRepresentationInUntypedArrays() + { + return PrimitiveNull(); + } + + public virtual IPreparedComparison PrepareComparison(IContext context, object obj + ) + { + if (obj == null) + { + return Null.Instance; + } + return InternalPrepareComparison(obj); + } + + public abstract IPreparedComparison InternalPrepareComparison(object obj); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/ShortHandler0.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/ShortHandler0.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/ShortHandler0.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/ShortHandler0.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,20 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal.Handlers; +using Db4objects.Db4o.Marshall; + +namespace Db4objects.Db4o.Internal.Handlers +{ + public class ShortHandler0 : ShortHandler + { + public override object Read(IReadContext context) + { + short value = (short)base.Read(context); + if (value == short.MaxValue) + { + return null; + } + return value; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/ShortHandler.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/ShortHandler.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/ShortHandler.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/ShortHandler.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,104 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Handlers; +using Db4objects.Db4o.Internal.Marshall; +using Db4objects.Db4o.Marshall; +using Db4objects.Db4o.Reflect; + +namespace Db4objects.Db4o.Internal.Handlers +{ + public class ShortHandler : PrimitiveHandler + { + internal const int Length = Const4.ShortBytes + Const4.AddedLength; + + private static readonly short Defaultvalue = (short)0; + + public override object Coerce(IReflectClass claxx, object obj) + { + return Coercion4.ToShort(obj); + } + + public override object DefaultValue() + { + return Defaultvalue; + } + + public override int LinkLength() + { + return Length; + } + + public override Type PrimitiveJavaClass() + { + return typeof(short); + } + + /// + public override object Read(MarshallerFamily mf, StatefulBuffer buffer, bool redirect + ) + { + return mf._primitive.ReadShort(buffer); + } + + internal override object Read1(ByteArrayBuffer buffer) + { + return PrimitiveMarshaller().ReadShort(buffer); + } + + public override void Write(object a_object, ByteArrayBuffer a_bytes) + { + WriteShort(((short)a_object), a_bytes); + } + + internal static void WriteShort(int a_short, ByteArrayBuffer a_bytes) + { + for (int i = 0; i < Const4.ShortBytes; i++) + { + a_bytes._buffer[a_bytes._offset++] = (byte)(a_short >> ((Const4.ShortBytes - 1 - + i) * 8)); + } + } + + public override object Read(IReadContext context) + { + int value = ((context.ReadByte() & unchecked((int)(0xff))) << 8) + (context.ReadByte + () & unchecked((int)(0xff))); + return (short)value; + } + + public override void Write(IWriteContext context, object obj) + { + int shortValue = ((short)obj); + context.WriteBytes(new byte[] { (byte)(shortValue >> 8), (byte)shortValue }); + } + + public override IPreparedComparison InternalPrepareComparison(object source) + { + short sourceShort = ((short)source); + return new _IPreparedComparison_86(sourceShort); + } + + private sealed class _IPreparedComparison_86 : IPreparedComparison + { + public _IPreparedComparison_86(short sourceShort) + { + this.sourceShort = sourceShort; + } + + public int CompareTo(object target) + { + if (target == null) + { + return 1; + } + short targetShort = ((short)target); + return sourceShort == targetShort ? 0 : (sourceShort < targetShort ? -1 : 1); + } + + private readonly short sourceShort; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/StandardReferenceTypeHandler0.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/StandardReferenceTypeHandler0.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/StandardReferenceTypeHandler0.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/StandardReferenceTypeHandler0.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,58 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Handlers; +using Db4objects.Db4o.Internal.Marshall; +using Db4objects.Db4o.Marshall; + +namespace Db4objects.Db4o.Internal.Handlers +{ + /// + public class StandardReferenceTypeHandler0 : StandardReferenceTypeHandler + { + protected override IMarshallingInfo EnsureFieldList(IMarshallingInfo context) + { + return new _IMarshallingInfo_16(context); + } + + private sealed class _IMarshallingInfo_16 : IMarshallingInfo + { + public _IMarshallingInfo_16(IMarshallingInfo context) + { + this.context = context; + } + + public void DeclaredAspectCount(int count) + { + context.DeclaredAspectCount(count); + } + + public int DeclaredAspectCount() + { + return context.DeclaredAspectCount(); + } + + public bool IsNull(int fieldIndex) + { + return false; + } + + public ClassMetadata ClassMetadata() + { + return context.ClassMetadata(); + } + + public IReadBuffer Buffer() + { + return context.Buffer(); + } + + public void BeginSlot() + { + context.BeginSlot(); + } + + private readonly IMarshallingInfo context; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/StandardReferenceTypeHandler.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/StandardReferenceTypeHandler.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/StandardReferenceTypeHandler.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/StandardReferenceTypeHandler.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,816 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Activation; +using Db4objects.Db4o.Internal.Delete; +using Db4objects.Db4o.Internal.Handlers; +using Db4objects.Db4o.Internal.Marshall; +using Db4objects.Db4o.Internal.Metadata; +using Db4objects.Db4o.Marshall; +using Db4objects.Db4o.Reflect; +using Db4objects.Db4o.Typehandlers; + +namespace Db4objects.Db4o.Internal.Handlers +{ + /// + public class StandardReferenceTypeHandler : IFieldAwareTypeHandler, IIndexableTypeHandler + , IReadsObjectIds + { + private const int HashcodeForNull = 72483944; + + private Db4objects.Db4o.Internal.ClassMetadata _classMetadata; + + public StandardReferenceTypeHandler(Db4objects.Db4o.Internal.ClassMetadata classMetadata + ) + { + ClassMetadata(classMetadata); + } + + public StandardReferenceTypeHandler() + { + } + + public virtual void Defragment(IDefragmentContext context) + { + TraverseAllAspects(context, new _MarshallingInfoTraverseAspectCommand_35(context, + EnsureFieldList(context))); + } + + private sealed class _MarshallingInfoTraverseAspectCommand_35 : MarshallingInfoTraverseAspectCommand + { + public _MarshallingInfoTraverseAspectCommand_35(IDefragmentContext context, IMarshallingInfo + baseArg1) : base(baseArg1) + { + this.context = context; + } + + protected override int InternalDeclaredAspectCount(Db4objects.Db4o.Internal.ClassMetadata + classMetadata) + { + return context.ReadInt(); + } + + protected override void ProcessAspect(ClassAspect aspect, int currentSlot, bool isNull + ) + { + if (!isNull) + { + aspect.DefragAspect(context); + } + } + + public override bool Accept(ClassAspect aspect) + { + return aspect.IsEnabledOn(context); + } + + private readonly IDefragmentContext context; + } + + /// + public virtual void Delete(IDeleteContext context) + { + context.DeleteObject(); + } + + public void ActivateAspects(UnmarshallingContext context) + { + BooleanByRef schemaUpdateDetected = new BooleanByRef(); + ContextState savedState = context.SaveState(); + ITraverseAspectCommand command = new _MarshallingInfoTraverseAspectCommand_63(context + , schemaUpdateDetected, EnsureFieldList(context)); + // TODO: cant the aspect handle it itself? + // Probably no because old aspect versions might not be able + // to handle null... + TraverseAllAspects(context, command); + if (schemaUpdateDetected.value) + { + context.RestoreState(savedState); + command = new _MarshallingInfoTraverseAspectCommand_94(context, EnsureFieldList(context + )); + TraverseAllAspects(context, command); + } + } + + private sealed class _MarshallingInfoTraverseAspectCommand_63 : MarshallingInfoTraverseAspectCommand + { + public _MarshallingInfoTraverseAspectCommand_63(UnmarshallingContext context, BooleanByRef + schemaUpdateDetected, IMarshallingInfo baseArg1) : base(baseArg1) + { + this.context = context; + this.schemaUpdateDetected = schemaUpdateDetected; + } + + public override bool Accept(ClassAspect aspect) + { + return aspect.IsEnabledOn(context); + } + + protected override void ProcessAspect(ClassAspect aspect, int currentSlot, bool isNull + ) + { + if (aspect is FieldMetadata) + { + FieldMetadata field = (FieldMetadata)aspect; + if (field.Updating()) + { + schemaUpdateDetected.value = true; + } + if (isNull) + { + if (field.GetStoredType() == null || !field.GetStoredType().IsPrimitive()) + { + field.Set(context.PersistentObject(), null); + } + return; + } + } + aspect.Activate(context); + } + + private readonly UnmarshallingContext context; + + private readonly BooleanByRef schemaUpdateDetected; + } + + private sealed class _MarshallingInfoTraverseAspectCommand_94 : MarshallingInfoTraverseAspectCommand + { + public _MarshallingInfoTraverseAspectCommand_94(UnmarshallingContext context, IMarshallingInfo + baseArg1) : base(baseArg1) + { + this.context = context; + } + + protected override void ProcessAspect(ClassAspect aspect, int currentSlot, bool isNull + ) + { + FieldMetadata field = (FieldMetadata)aspect; + if (!isNull) + { + field.AttemptUpdate(context); + } + } + + public override bool Accept(ClassAspect aspect) + { + return aspect is FieldMetadata; + } + + private readonly UnmarshallingContext context; + } + + public virtual void Activate(IReferenceActivationContext context) + { + ActivateAspects((UnmarshallingContext)context); + } + + public virtual void Write(IWriteContext context, object obj) + { + MarshallAspects(obj, (MarshallingContext)context); + } + + public virtual void MarshallAspects(object obj, MarshallingContext context) + { + Transaction trans = context.Transaction(); + ITraverseAspectCommand command = new _MarshallingInfoTraverseAspectCommand_122(context + , obj, trans, EnsureFieldList(context)); + TraverseAllAspects(context, command); + } + + private sealed class _MarshallingInfoTraverseAspectCommand_122 : MarshallingInfoTraverseAspectCommand + { + public _MarshallingInfoTraverseAspectCommand_122(MarshallingContext context, object + obj, Transaction trans, IMarshallingInfo baseArg1) : base(baseArg1) + { + this.context = context; + this.obj = obj; + this.trans = trans; + } + + protected override int InternalDeclaredAspectCount(Db4objects.Db4o.Internal.ClassMetadata + classMetadata) + { + int aspectCount = classMetadata._aspects.Length; + context.WriteDeclaredAspectCount(aspectCount); + return aspectCount; + } + + public override bool Accept(ClassAspect aspect) + { + return aspect.IsEnabledOn(context); + } + + protected override void ProcessAspect(ClassAspect aspect, int currentSlot, bool isNull + ) + { + object marshalledObject = obj; + if (aspect is FieldMetadata) + { + FieldMetadata field = (FieldMetadata)aspect; + marshalledObject = field.GetOrCreate(trans, obj); + if (marshalledObject == null) + { + context.IsNull(currentSlot, true); + field.AddIndexEntry(trans, context.ObjectID(), null); + return; + } + } + aspect.Marshall(context, marshalledObject); + } + + public override void ProcessAspectOnMissingClass(ClassAspect aspect, int currentSlot + ) + { + ((MarshallingContext)context).IsNull(currentSlot, true); + } + + private readonly MarshallingContext context; + + private readonly object obj; + + private readonly Transaction trans; + } + + public virtual IPreparedComparison PrepareComparison(IContext context, object source + ) + { + if (source == null) + { + return Null.Instance; + } + if (source is int) + { + int id = ((int)source); + return new StandardReferenceTypeHandler.PreparedComparisonImpl(id, null); + } + if (source is TransactionContext) + { + TransactionContext tc = (TransactionContext)source; + object obj = tc._object; + int id = IdFor(obj, tc._transaction); + return new StandardReferenceTypeHandler.PreparedComparisonImpl(id, ReflectClassFor + (obj)); + } + return PlatformComparisonFor(source); + } + + private IPreparedComparison PlatformComparisonFor(object source) + { + if (source == null) + { + return new _IPreparedComparison_179(); + } + //TODO: Move the comparable wrapping to a .Net specific StandardStructHandler + if (source is IComparable) + { + return new _IPreparedComparison_187(source); + } + throw new IllegalComparisonException(); + } + + private sealed class _IPreparedComparison_179 : IPreparedComparison + { + public _IPreparedComparison_179() + { + } + + public int CompareTo(object obj) + { + return obj == null ? 0 : -1; + } + } + + private sealed class _IPreparedComparison_187 : IPreparedComparison + { + public _IPreparedComparison_187(object source) + { + this.source = source; + } + + public int CompareTo(object obj) + { + if (obj == null) + { + return 1; + } + IComparable self = (IComparable)source; + return self.CompareTo(obj); + } + + private readonly object source; + } + + private IReflectClass ReflectClassFor(object obj) + { + return ClassMetadata().Reflector().ForObject(obj); + } + + private int IdFor(object @object, Transaction inTransaction) + { + return Stream().GetID(inTransaction, @object); + } + + private ObjectContainerBase Stream() + { + return ClassMetadata().Container(); + } + + public sealed class PreparedComparisonImpl : IPreparedComparison + { + private readonly int _id; + + private readonly IReflectClass _claxx; + + public PreparedComparisonImpl(int id, IReflectClass claxx) + { + _id = id; + _claxx = claxx; + } + + public int CompareTo(object obj) + { + if (obj is TransactionContext) + { + obj = ((TransactionContext)obj)._object; + } + if (obj == null) + { + return _id == 0 ? 0 : 1; + } + if (obj is int) + { + int targetInt = ((int)obj); + return _id == targetInt ? 0 : (_id < targetInt ? -1 : 1); + } + if (_claxx != null) + { + if (_claxx.IsAssignableFrom(_claxx.Reflector().ForObject(obj))) + { + return 0; + } + } + throw new IllegalComparisonException(); + } + } + + public void TraverseAllAspects(IMarshallingInfo context, ITraverseAspectCommand command + ) + { + ClassMetadata classMetadata = ClassMetadata(); + AssertClassMetadata(context.ClassMetadata()); + classMetadata.TraverseAllAspects(command); + } + + protected virtual IMarshallingInfo EnsureFieldList(IMarshallingInfo context) + { + return context; + } + + private void AssertClassMetadata(ClassMetadata contextMetadata) + { + } + + // if (contextMetadata != classMetadata()) { + // throw new IllegalStateException("expecting '" + classMetadata() + "', got '" + contextMetadata + "'"); + // } + public virtual ClassMetadata ClassMetadata() + { + return _classMetadata; + } + + public virtual void ClassMetadata(ClassMetadata classMetadata) + { + _classMetadata = classMetadata; + } + + public override bool Equals(object obj) + { + if (!(obj is StandardReferenceTypeHandler)) + { + return false; + } + StandardReferenceTypeHandler other = (StandardReferenceTypeHandler)obj; + if (ClassMetadata() == null) + { + return other.ClassMetadata() == null; + } + return ClassMetadata().Equals(other.ClassMetadata()); + } + + public override int GetHashCode() + { + if (ClassMetadata() != null) + { + return ClassMetadata().GetHashCode(); + } + return HashcodeForNull; + } + + public virtual ITypeHandler4 UnversionedTemplate() + { + return new StandardReferenceTypeHandler(null); + } + + public virtual object DeepClone(object context) + { + TypeHandlerCloneContext typeHandlerCloneContext = (TypeHandlerCloneContext)context; + StandardReferenceTypeHandler cloned = (StandardReferenceTypeHandler)Reflection4.NewInstance + (this); + if (typeHandlerCloneContext.original is StandardReferenceTypeHandler) + { + StandardReferenceTypeHandler original = (StandardReferenceTypeHandler)typeHandlerCloneContext + .original; + cloned.ClassMetadata(original.ClassMetadata()); + } + else + { + // New logic: ClassMetadata takes the responsibility in + // #correctHandlerVersion() to set the + // ClassMetadata directly on cloned handler. + // if(_classMetadata == null){ + // throw new IllegalStateException(); + // } + cloned.ClassMetadata(_classMetadata); + } + return cloned; + } + + public virtual void CollectIDs(CollectIdContext context, IPredicate4 predicate) + { + ITraverseAspectCommand command = new _MarshallingInfoTraverseAspectCommand_311(predicate + , context, EnsureFieldList(context)); + TraverseAllAspects(context, command); + } + + private sealed class _MarshallingInfoTraverseAspectCommand_311 : MarshallingInfoTraverseAspectCommand + { + public _MarshallingInfoTraverseAspectCommand_311(IPredicate4 predicate, CollectIdContext + context, IMarshallingInfo baseArg1) : base(baseArg1) + { + this.predicate = predicate; + this.context = context; + } + + protected override void ProcessAspect(ClassAspect aspect, int currentSlot, bool isNull + ) + { + if (isNull) + { + return; + } + if (predicate.Match(aspect)) + { + aspect.CollectIDs(context); + } + else + { + aspect.IncrementOffset(context); + } + } + + private readonly IPredicate4 predicate; + + private readonly CollectIdContext context; + } + + public virtual void CascadeActivation(IActivationContext context) + { + AssertClassMetadata(context.ClassMetadata()); + context.CascadeActivationToTarget(); + } + + public virtual ITypeHandler4 ReadCandidateHandler(QueryingReadContext context) + { + if (ClassMetadata().IsArray()) + { + return this; + } + return null; + } + + /// + public virtual void CollectIDs(QueryingReadContext context) + { + if (CollectIDsByTypehandlerAspect(context)) + { + return; + } + CollectIDsByInstantiatingCollection(context); + } + + /// + private bool CollectIDsByTypehandlerAspect(QueryingReadContext context) + { + BooleanByRef aspectFound = new BooleanByRef(false); + CollectIdContext subContext = CollectIdContext.ForID(context.Transaction(), context + .Collector(), context.CollectionID()); + ITraverseAspectCommand command = new _MarshallingInfoTraverseAspectCommand_349(this + , aspectFound, subContext, EnsureFieldList(subContext)); + TraverseAllAspects(subContext, command); + return aspectFound.value; + } + + private sealed class _MarshallingInfoTraverseAspectCommand_349 : MarshallingInfoTraverseAspectCommand + { + public _MarshallingInfoTraverseAspectCommand_349(StandardReferenceTypeHandler _enclosing + , BooleanByRef aspectFound, CollectIdContext subContext, IMarshallingInfo baseArg1 + ) : base(baseArg1) + { + this._enclosing = _enclosing; + this.aspectFound = aspectFound; + this.subContext = subContext; + } + + protected override void ProcessAspect(ClassAspect aspect, int currentSlot, bool isNull + ) + { + if (isNull) + { + return; + } + if (this._enclosing.IsCollectIdTypehandlerAspect(aspect)) + { + aspectFound.value = true; + aspect.CollectIDs(subContext); + } + else + { + aspect.IncrementOffset(subContext); + } + } + + private readonly StandardReferenceTypeHandler _enclosing; + + private readonly BooleanByRef aspectFound; + + private readonly CollectIdContext subContext; + } + + private bool IsCollectIdTypehandlerAspect(ClassAspect aspect) + { + if (!(aspect is TypeHandlerAspect)) + { + return false; + } + ITypeHandler4 typehandler = ((TypeHandlerAspect)aspect)._typeHandler; + return Handlers4.IsCascading(typehandler); + } + + /// + private void CollectIDsByInstantiatingCollection(QueryingReadContext context) + { + int id = context.CollectionID(); + if (id == 0) + { + return; + } + Transaction transaction = context.Transaction(); + ObjectContainerBase container = context.Container(); + object obj = container.GetByID(transaction, id); + if (obj == null) + { + return; + } + // FIXME: [TA] review activation depth + int depth = DepthUtil.AdjustDepthToBorders(2); + container.Activate(transaction, obj, container.ActivationDepthProvider().ActivationDepth + (depth, ActivationMode.Activate)); + Platform4.ForEachCollectionElement(obj, new _IVisitor4_390(context)); + } + + private sealed class _IVisitor4_390 : IVisitor4 + { + public _IVisitor4_390(QueryingReadContext context) + { + this.context = context; + } + + public void Visit(object elem) + { + context.Add(elem); + } + + private readonly QueryingReadContext context; + } + + public virtual void ReadVirtualAttributes(ObjectReferenceContext context) + { + ITraverseAspectCommand command = new _MarshallingInfoTraverseAspectCommand_398(context + , EnsureFieldList(context)); + TraverseAllAspects(context, command); + } + + private sealed class _MarshallingInfoTraverseAspectCommand_398 : MarshallingInfoTraverseAspectCommand + { + public _MarshallingInfoTraverseAspectCommand_398(ObjectReferenceContext context, + IMarshallingInfo baseArg1) : base(baseArg1) + { + this.context = context; + } + + protected override void ProcessAspect(ClassAspect aspect, int currentSlot, bool isNull + ) + { + if (!isNull) + { + if (aspect is VirtualFieldMetadata) + { + ((VirtualFieldMetadata)aspect).ReadVirtualAttribute(context); + } + else + { + aspect.IncrementOffset(context); + } + } + } + + private readonly ObjectReferenceContext context; + } + + public virtual void AddFieldIndices(ObjectIdContextImpl context) + { + ITraverseAspectCommand command = new _MarshallingInfoTraverseAspectCommand_414(context + , EnsureFieldList(context)); + TraverseAllAspects(context, command); + } + + private sealed class _MarshallingInfoTraverseAspectCommand_414 : MarshallingInfoTraverseAspectCommand + { + public _MarshallingInfoTraverseAspectCommand_414(ObjectIdContextImpl context, IMarshallingInfo + baseArg1) : base(baseArg1) + { + this.context = context; + } + + protected override void ProcessAspect(ClassAspect aspect, int currentSlot, bool isNull + ) + { + if (aspect is FieldMetadata) + { + FieldMetadata field = (FieldMetadata)aspect; + if (isNull) + { + field.AddIndexEntry(context.Transaction(), context.ObjectId(), null); + } + else + { + field.AddFieldIndex(context); + } + } + else + { + aspect.IncrementOffset(context.Buffer()); + } + } + + public override bool Accept(ClassAspect aspect) + { + return aspect.IsEnabledOn(context); + } + + private readonly ObjectIdContextImpl context; + } + + public virtual void DeleteMembers(DeleteContextImpl context, bool isUpdate) + { + ITraverseAspectCommand command = new _MarshallingInfoTraverseAspectCommand_438(context + , isUpdate, EnsureFieldList(context)); + TraverseAllAspects(context, command); + } + + private sealed class _MarshallingInfoTraverseAspectCommand_438 : MarshallingInfoTraverseAspectCommand + { + public _MarshallingInfoTraverseAspectCommand_438(DeleteContextImpl context, bool + isUpdate, IMarshallingInfo baseArg1) : base(baseArg1) + { + this.context = context; + this.isUpdate = isUpdate; + } + + protected override void ProcessAspect(ClassAspect aspect, int currentSlot, bool isNull + ) + { + if (isNull) + { + if (aspect is FieldMetadata) + { + FieldMetadata field = (FieldMetadata)aspect; + field.RemoveIndexEntry(context.Transaction(), context.ObjectId(), null); + } + return; + } + aspect.Delete(context, isUpdate); + } + + private readonly DeleteContextImpl context; + + private readonly bool isUpdate; + } + + public virtual bool SeekToField(ObjectHeaderContext context, ClassAspect aspect) + { + BooleanByRef found = new BooleanByRef(false); + ITraverseAspectCommand command = new _MarshallingInfoTraverseAspectCommand_456(aspect + , found, EnsureFieldList(context)); + TraverseAllAspects(context, command); + return found.value; + } + + private sealed class _MarshallingInfoTraverseAspectCommand_456 : MarshallingInfoTraverseAspectCommand + { + public _MarshallingInfoTraverseAspectCommand_456(ClassAspect aspect, BooleanByRef + found, IMarshallingInfo baseArg1) : base(baseArg1) + { + this.aspect = aspect; + this.found = found; + } + + public override bool Accept(ClassAspect aspect) + { + return aspect.IsEnabledOn(this._marshallingInfo); + } + + protected override void ProcessAspect(ClassAspect curField, int currentSlot, bool + isNull) + { + if (curField == aspect) + { + found.value = !isNull; + this.Cancel(); + return; + } + if (!isNull) + { + curField.IncrementOffset(this._marshallingInfo.Buffer()); + } + } + + private readonly ClassAspect aspect; + + private readonly BooleanByRef found; + } + + public object IndexEntryToObject(IContext context, object indexEntry) + { + if (indexEntry == null) + { + return null; + } + int id = ((int)indexEntry); + return ((ObjectContainerBase)context.ObjectContainer()).GetByID2(context.Transaction + (), id); + } + + public void DefragIndexEntry(DefragmentContextImpl context) + { + context.CopyID(); + } + + public object ReadIndexEntry(IContext context, ByteArrayBuffer a_reader) + { + return a_reader.ReadInt(); + } + + /// + public object ReadIndexEntryFromObjectSlot(MarshallerFamily mf, StatefulBuffer statefulBuffer + ) + { + return ReadIndexEntry(statefulBuffer.Transaction().Context(), statefulBuffer); + } + + /// + /// + public virtual object ReadIndexEntry(IObjectIdContext context) + { + return context.ReadInt(); + } + + public virtual int LinkLength() + { + return Const4.IdLength; + } + + public virtual void WriteIndexEntry(IContext context, ByteArrayBuffer a_writer, object + a_object) + { + if (a_object == null) + { + a_writer.WriteInt(0); + return; + } + a_writer.WriteInt(((int)a_object)); + } + + public virtual ITypeHandler4 DelegateTypeHandler(IContext context) + { + return ClassMetadata().DelegateTypeHandler(context); + } + + public virtual ObjectID ReadObjectID(IInternalReadContext context) + { + return ObjectID.Read(context); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/StringBasedValueTypeHandlerBase.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/StringBasedValueTypeHandlerBase.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/StringBasedValueTypeHandlerBase.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/StringBasedValueTypeHandlerBase.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,88 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Delete; +using Db4objects.Db4o.Internal.Handlers; +using Db4objects.Db4o.Marshall; +using Db4objects.Db4o.Reflect; +using Db4objects.Db4o.Typehandlers; + +namespace Db4objects.Db4o.Internal.Handlers +{ + public abstract class StringBasedValueTypeHandlerBase : IValueTypeHandler, IBuiltinTypeHandler + , IVariableLengthTypeHandler, IQueryableTypeHandler, IComparable4 + { + public readonly Type _clazz; + + private IReflectClass _classReflector; + + public StringBasedValueTypeHandlerBase(Type clazz) + { + _clazz = clazz; + } + + public virtual void Defragment(IDefragmentContext context) + { + StringHandler(context).Defragment(context); + } + + /// + public virtual void Delete(IDeleteContext context) + { + StringHandler(context).Delete(context); + } + + public virtual object Read(IReadContext context) + { + object read = StringHandler(context).Read(context); + if (null == read) + { + return null; + } + return ConvertString((string)read); + } + + public virtual void Write(IWriteContext context, object obj) + { + StringHandler(context).Write(context, ConvertObject((object)obj)); + } + + private Db4objects.Db4o.Internal.Handlers.StringHandler StringHandler(IContext context + ) + { + return Handlers(context)._stringHandler; + } + + private HandlerRegistry Handlers(IContext context) + { + return ((IInternalObjectContainer)context.ObjectContainer()).Handlers; + } + + public virtual IPreparedComparison PrepareComparison(IContext context, object obj + ) + { + return StringHandler(context).PrepareComparison(context, obj); + } + + public virtual IReflectClass ClassReflector() + { + return _classReflector; + } + + public virtual void RegisterReflector(IReflector reflector) + { + _classReflector = reflector.ForClass(_clazz); + } + + public virtual bool DescendsIntoMembers() + { + return false; + } + + protected abstract string ConvertObject(object obj); + + protected abstract object ConvertString(string str); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/StringBufferHandler.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/StringBufferHandler.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/StringBufferHandler.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/StringBufferHandler.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,24 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System.Text; +using Db4objects.Db4o.Internal.Handlers; + +namespace Db4objects.Db4o.Internal.Handlers +{ + public sealed class StringBufferHandler : StringBasedValueTypeHandlerBase + { + public StringBufferHandler() : base(typeof(StringBuilder)) + { + } + + protected override string ConvertObject(object obj) + { + return ((StringBuilder)obj).ToString(); + } + + protected override object ConvertString(string str) + { + return new StringBuilder(str); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/StringHandler0.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/StringHandler0.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/StringHandler0.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/StringHandler0.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,72 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System.IO; +using Db4objects.Db4o.Ext; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Delete; +using Db4objects.Db4o.Internal.Handlers; +using Db4objects.Db4o.Internal.Marshall; +using Db4objects.Db4o.Marshall; + +namespace Db4objects.Db4o.Internal.Handlers +{ + /// + public class StringHandler0 : StringHandler + { + public override object Read(IReadContext context) + { + ByteArrayBuffer buffer = (ByteArrayBuffer)((IInternalReadContext)context).ReadIndirectedBuffer + (); + if (buffer == null) + { + return null; + } + return ReadString(context, buffer); + } + + public override void Delete(IDeleteContext context) + { + context.DefragmentRecommended(); + } + + public override void Defragment(IDefragmentContext context) + { + int sourceAddress = context.SourceBuffer().ReadInt(); + int length = context.SourceBuffer().ReadInt(); + if (sourceAddress == 0 && length == 0) + { + context.TargetBuffer().WriteInt(0); + context.TargetBuffer().WriteInt(0); + return; + } + int targetAddress = 0; + try + { + targetAddress = context.CopySlotToNewMapped(sourceAddress, length); + } + catch (IOException exc) + { + throw new Db4oIOException(exc); + } + context.TargetBuffer().WriteInt(targetAddress); + context.TargetBuffer().WriteInt(length); + } + + /// + /// + public override object ReadIndexEntryFromObjectSlot(MarshallerFamily mf, StatefulBuffer + buffer) + { + return buffer.Container().ReadWriterByAddress(buffer.Transaction(), buffer.ReadInt + (), buffer.ReadInt()); + } + + /// + /// + public override object ReadIndexEntry(IObjectIdContext context) + { + return context.Transaction().Container().ReadWriterByAddress(context.Transaction( + ), context.ReadInt(), context.ReadInt()); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/StringHandler.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/StringHandler.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/StringHandler.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/StringHandler.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,299 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Delete; +using Db4objects.Db4o.Internal.Encoding; +using Db4objects.Db4o.Internal.Handlers; +using Db4objects.Db4o.Internal.Marshall; +using Db4objects.Db4o.Internal.Slots; +using Db4objects.Db4o.Marshall; +using Db4objects.Db4o.Reflect; +using Db4objects.Db4o.Typehandlers; + +namespace Db4objects.Db4o.Internal.Handlers +{ + /// + public class StringHandler : IValueTypeHandler, IIndexableTypeHandler, IBuiltinTypeHandler + , IVariableLengthTypeHandler, IQueryableTypeHandler + { + private IReflectClass _classReflector; + + public virtual IReflectClass ClassReflector() + { + return _classReflector; + } + + public virtual void Delete(IDeleteContext context) + { + } + + // do nothing, we are in a slot indirection anyway, the + // buffer position does not need to be changed. + internal virtual byte GetIdentifier() + { + return Const4.Yapstring; + } + + public virtual bool DescendsIntoMembers() + { + return false; + } + + public object IndexEntryToObject(IContext context, object indexEntry) + { + if (indexEntry is Slot) + { + Slot slot = (Slot)indexEntry; + indexEntry = context.Transaction().Container().DecryptedBufferByAddress(slot.Address + (), slot.Length()); + } + return ReadStringNoDebug(context, (IReadBuffer)indexEntry); + } + + /// This readIndexEntry method reads from the parent slot. + /// This readIndexEntry method reads from the parent slot. + /// + /// + public virtual object ReadIndexEntryFromObjectSlot(MarshallerFamily mf, StatefulBuffer + buffer) + { + int payLoadOffSet = buffer.ReadInt(); + int length = buffer.ReadInt(); + if (payLoadOffSet == 0) + { + return null; + } + return buffer.ReadPayloadWriter(payLoadOffSet, length); + } + + /// + /// + public virtual object ReadIndexEntry(IObjectIdContext context) + { + int payLoadOffSet = context.ReadInt(); + int length = context.ReadInt(); + if (payLoadOffSet == 0) + { + return null; + } + return ((StatefulBuffer)context.Buffer()).ReadPayloadWriter(payLoadOffSet, length + ); + } + + /// This readIndexEntry method reads from the actual index in the file. + /// This readIndexEntry method reads from the actual index in the file. + public virtual object ReadIndexEntry(IContext context, ByteArrayBuffer reader) + { + Slot s = new Slot(reader.ReadInt(), reader.ReadInt()); + if (IsInvalidSlot(s)) + { + return null; + } + return s; + } + + private bool IsInvalidSlot(Slot slot) + { + return slot.IsNull(); + } + + public virtual void WriteIndexEntry(IContext context, ByteArrayBuffer writer, object + entry) + { + if (entry == null) + { + writer.WriteInt(0); + writer.WriteInt(0); + return; + } + if (entry is StatefulBuffer) + { + StatefulBuffer entryAsWriter = (StatefulBuffer)entry; + writer.WriteInt(entryAsWriter.GetAddress()); + writer.WriteInt(entryAsWriter.Length()); + return; + } + if (entry is Slot) + { + Slot s = (Slot)entry; + writer.WriteInt(s.Address()); + writer.WriteInt(s.Length()); + return; + } + throw new ArgumentException(); + } + + public void WriteShort(Transaction trans, string str, ByteArrayBuffer buffer) + { + StringIo(trans.Container()).WriteLengthAndString(buffer, str); + } + + internal virtual ByteArrayBuffer Val(object obj, IContext context) + { + if (obj is ByteArrayBuffer) + { + return (ByteArrayBuffer)obj; + } + ObjectContainerBase oc = context.Transaction().Container(); + if (obj is string) + { + return WriteToBuffer((IInternalObjectContainer)oc, (string)obj); + } + if (obj is Slot) + { + Slot s = (Slot)obj; + return oc.DecryptedBufferByAddress(s.Address(), s.Length()); + } + return null; + } + + /// + /// returns: -x for left is greater and +x for right is greater + /// FIXME: The returned value is the wrong way around. + /// + /// + /// returns: -x for left is greater and +x for right is greater + /// FIXME: The returned value is the wrong way around. + /// TODO: You will need collators here for different languages. + /// + internal int Compare(ByteArrayBuffer a_compare, ByteArrayBuffer a_with) + { + if (a_compare == null) + { + if (a_with == null) + { + return 0; + } + return -1; + } + if (a_with == null) + { + return 1; + } + return Compare(a_compare._buffer, a_with._buffer); + } + + public static int Compare(byte[] compare, byte[] with) + { + int min = compare.Length < with.Length ? compare.Length : with.Length; + int start = Const4.IntLength; + for (int i = start; i < min; i++) + { + if (compare[i] != with[i]) + { + return compare[i] - with[i]; + } + } + return compare.Length - with.Length; + } + + public virtual void DefragIndexEntry(DefragmentContextImpl context) + { + context.CopyAddress(); + // length + context.IncrementIntSize(); + } + + public virtual void Write(IWriteContext context, object obj) + { + InternalWrite((IInternalObjectContainer)context.ObjectContainer(), context, (string + )obj); + } + + protected static void InternalWrite(IInternalObjectContainer objectContainer, IWriteBuffer + buffer, string str) + { + StringIo(objectContainer).WriteLengthAndString(buffer, str); + } + + public static ByteArrayBuffer WriteToBuffer(IInternalObjectContainer container, string + str) + { + ByteArrayBuffer buffer = new ByteArrayBuffer(StringIo(container).Length(str)); + InternalWrite(container, buffer, str); + return buffer; + } + + protected static LatinStringIO StringIo(IContext context) + { + return StringIo((IInternalObjectContainer)context.ObjectContainer()); + } + + protected static LatinStringIO StringIo(IInternalObjectContainer objectContainer) + { + return objectContainer.Container.StringIO(); + } + + public static string ReadString(IContext context, IReadBuffer buffer) + { + string str = ReadStringNoDebug(context, buffer); + return str; + } + + public static string ReadStringNoDebug(IContext context, IReadBuffer buffer) + { + return Intern(context, StringIo(context).ReadLengthAndString(buffer)); + } + + protected static string Intern(IContext context, string str) + { + if (context.ObjectContainer().Ext().Configure().InternStrings()) + { + return string.Intern(str); + } + return str; + } + + public virtual object Read(IReadContext context) + { + return ReadString(context, context); + } + + public virtual void Defragment(IDefragmentContext context) + { + context.IncrementOffset(LinkLength()); + } + + public virtual IPreparedComparison PrepareComparison(IContext context, object obj + ) + { + ByteArrayBuffer sourceBuffer = Val(obj, context); + return new _IPreparedComparison_229(this, context, sourceBuffer); + } + + private sealed class _IPreparedComparison_229 : IPreparedComparison + { + public _IPreparedComparison_229(StringHandler _enclosing, IContext context, ByteArrayBuffer + sourceBuffer) + { + this._enclosing = _enclosing; + this.context = context; + this.sourceBuffer = sourceBuffer; + } + + public int CompareTo(object target) + { + ByteArrayBuffer targetBuffer = this._enclosing.Val(target, context); + return this._enclosing.Compare(sourceBuffer, targetBuffer); + } + + private readonly StringHandler _enclosing; + + private readonly IContext context; + + private readonly ByteArrayBuffer sourceBuffer; + } + + public virtual int LinkLength() + { + return Const4.IndirectionLength; + } + + public virtual void RegisterReflector(IReflector reflector) + { + _classReflector = reflector.ForClass(typeof(string)); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/TypeHandlerPredicatePair.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/TypeHandlerPredicatePair.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/TypeHandlerPredicatePair.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/TypeHandlerPredicatePair.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,21 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Typehandlers; + +namespace Db4objects.Db4o.Internal.Handlers +{ + /// + public class TypeHandlerPredicatePair + { + public readonly ITypeHandlerPredicate _predicate; + + public readonly ITypeHandler4 _typeHandler; + + public TypeHandlerPredicatePair(ITypeHandlerPredicate predicate, ITypeHandler4 typeHandler + ) + { + _predicate = predicate; + _typeHandler = typeHandler; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/Versions/OpenTypeHandler0.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/Versions/OpenTypeHandler0.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/Versions/OpenTypeHandler0.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/Versions/OpenTypeHandler0.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,116 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using System.IO; +using Db4objects.Db4o.Ext; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Handlers.Versions; +using Db4objects.Db4o.Internal.Mapping; +using Db4objects.Db4o.Internal.Marshall; +using Db4objects.Db4o.Internal.Slots; +using Db4objects.Db4o.Marshall; +using Db4objects.Db4o.Typehandlers; + +namespace Db4objects.Db4o.Internal.Handlers.Versions +{ + /// + public class OpenTypeHandler0 : OpenTypeHandler2 + { + public OpenTypeHandler0(ObjectContainerBase container) : base(container) + { + } + + public override object Read(IReadContext context) + { + return context.ReadObject(); + } + + public override ITypeHandler4 ReadCandidateHandler(QueryingReadContext context) + { + int id = 0; + int offset = context.Offset(); + try + { + id = context.ReadInt(); + } + catch (Exception) + { + } + context.Seek(offset); + if (id != 0) + { + StatefulBuffer reader = context.Container().ReadStatefulBufferById(context.Transaction + (), id); + if (reader != null) + { + ObjectHeader oh = new ObjectHeader(context.Container(), reader); + try + { + if (oh.ClassMetadata() != null) + { + context.Buffer(reader); + return oh.ClassMetadata().SeekCandidateHandler(context); + } + } + catch (Exception e) + { + } + } + } + // TODO: Check Exception Types + // Errors typically occur, if classes don't match + return null; + } + + public override ObjectID ReadObjectID(IInternalReadContext context) + { + int id = context.ReadInt(); + return id == 0 ? ObjectID.IsNull : new ObjectID(id); + } + + public override void Defragment(IDefragmentContext context) + { + int sourceId = context.SourceBuffer().ReadInt(); + if (sourceId == 0) + { + context.TargetBuffer().WriteInt(0); + return; + } + int targetId = 0; + try + { + targetId = context.MappedID(sourceId); + } + catch (MappingNotFoundException) + { + targetId = CopyDependentSlot(context, sourceId); + } + context.TargetBuffer().WriteInt(targetId); + } + + private int CopyDependentSlot(IDefragmentContext context, int sourceId) + { + try + { + ByteArrayBuffer sourceBuffer = context.SourceBufferById(sourceId); + Slot targetPayloadSlot = context.AllocateTargetSlot(sourceBuffer.Length()); + int targetId = context.Services().TargetNewId(); + context.Services().MapIDs(sourceId, targetId, false); + context.Services().Mapping().MapId(targetId, targetPayloadSlot); + DefragmentContextImpl payloadContext = new DefragmentContextImpl(sourceBuffer, (DefragmentContextImpl + )context); + int clazzId = payloadContext.CopyIDReturnOriginalID(); + ITypeHandler4 payloadHandler = payloadContext.TypeHandlerForId(clazzId); + ITypeHandler4 versionedPayloadHandler = HandlerRegistry.CorrectHandlerVersion(payloadContext + , payloadHandler); + versionedPayloadHandler.Defragment(payloadContext); + payloadContext.WriteToTarget(targetPayloadSlot.Address()); + return targetId; + } + catch (IOException ioexc) + { + throw new Db4oIOException(ioexc); + } + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/Versions/OpenTypeHandler2.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/Versions/OpenTypeHandler2.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/Versions/OpenTypeHandler2.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/Versions/OpenTypeHandler2.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,26 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Handlers.Versions; +using Db4objects.Db4o.Marshall; +using Db4objects.Db4o.Typehandlers; + +namespace Db4objects.Db4o.Internal.Handlers.Versions +{ + /// + public class OpenTypeHandler2 : OpenTypeHandler7 + { + public OpenTypeHandler2(ObjectContainerBase container) : base(container) + { + } + + protected override void SeekSecondaryOffset(IReadBuffer buffer, ITypeHandler4 typeHandler + ) + { + if (Handlers4.HandlesPrimitiveArray(typeHandler)) + { + buffer.Seek(buffer.ReadInt()); + } + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/Versions/OpenTypeHandler7.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/Versions/OpenTypeHandler7.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/Versions/OpenTypeHandler7.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers/Versions/OpenTypeHandler7.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,136 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Activation; +using Db4objects.Db4o.Internal.Marshall; +using Db4objects.Db4o.Internal.Slots; +using Db4objects.Db4o.Marshall; +using Db4objects.Db4o.Typehandlers; + +namespace Db4objects.Db4o.Internal.Handlers.Versions +{ + public class OpenTypeHandler7 : OpenTypeHandler + { + public OpenTypeHandler7(ObjectContainerBase container) : base(container) + { + } + + public override object Read(IReadContext readContext) + { + IInternalReadContext context = (IInternalReadContext)readContext; + int payloadOffset = context.ReadInt(); + if (payloadOffset == 0) + { + context.NotifyNullReferenceSkipped(); + return null; + } + int savedOffSet = context.Offset(); + try + { + ITypeHandler4 typeHandler = ReadTypeHandler(context, payloadOffset); + if (typeHandler == null) + { + return null; + } + if (IsPlainObject(typeHandler)) + { + return ReadPlainObject(readContext); + } + SeekSecondaryOffset(context, typeHandler); + return context.ReadAtCurrentSeekPosition(typeHandler); + } + finally + { + context.Seek(savedOffSet); + } + } + + public override void Defragment(IDefragmentContext context) + { + int payLoadOffSet = context.ReadInt(); + if (payLoadOffSet == 0) + { + return; + } + int savedOffSet = context.Offset(); + context.Seek(payLoadOffSet); + int classMetadataId = context.CopyIDReturnOriginalID(); + ITypeHandler4 typeHandler = CorrectTypeHandlerVersionFor(context, classMetadataId + ); + if (typeHandler != null) + { + if (IsPlainObject(typeHandler)) + { + context.CopySlotlessID(); + } + else + { + SeekSecondaryOffset(context, typeHandler); + context.Defragment(typeHandler); + } + } + context.Seek(savedOffSet); + } + + private object ReadPlainObject(IReadContext context) + { + int id = context.ReadInt(); + Transaction transaction = context.Transaction(); + object obj = transaction.ObjectForIdFromCache(id); + if (obj != null) + { + return obj; + } + obj = new object(); + AddReference(context, obj, id); + return obj; + } + + private void AddReference(IContext context, object obj, int id) + { + Transaction transaction = context.Transaction(); + ObjectReference @ref = new _ObjectReference_74(id); + @ref.ClassMetadata(transaction.Container().ClassMetadataForID(Handlers4.UntypedId + )); + @ref.SetObjectWeak(transaction.Container(), obj); + transaction.AddNewReference(@ref); + } + + private sealed class _ObjectReference_74 : ObjectReference + { + public _ObjectReference_74(int baseArg1) : base(baseArg1) + { + this._firstUpdate = true; + } + + internal bool _firstUpdate; + + public override void WriteUpdate(Transaction transaction, IUpdateDepth updatedepth + ) + { + if (!this._firstUpdate) + { + base.WriteUpdate(transaction, updatedepth); + return; + } + this._firstUpdate = false; + ObjectContainerBase container = transaction.Container(); + this.SetStateClean(); + MarshallingContext context = new MarshallingContext(transaction, this, updatedepth + , false); + Handlers4.Write(this.ClassMetadata().TypeHandler(), context, this.GetObject()); + int length = this.Container().BlockConverter().BlockAlignedBytes(context.MarshalledLength + ()); + Slot slot = context.AllocateNewSlot(length); + Pointer4 pointer = new Pointer4(this.GetID(), slot); + ByteArrayBuffer buffer = context.ToWriteBuffer(pointer); + container.WriteUpdate(transaction, pointer, this.ClassMetadata(), ArrayType.None, + buffer); + if (this.IsActive()) + { + this.SetStateClean(); + } + } + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers4.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers4.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers4.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Handlers4.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,402 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Handlers; +using Db4objects.Db4o.Internal.Handlers.Array; +using Db4objects.Db4o.Internal.Marshall; +using Db4objects.Db4o.Marshall; +using Db4objects.Db4o.Reflect; +using Db4objects.Db4o.Typehandlers; + +namespace Db4objects.Db4o.Internal +{ + /// + public class Handlers4 + { + public const int IntId = 1; + + public const int LongId = 2; + + public const int FloatId = 3; + + public const int BooleanId = 4; + + public const int DoubleId = 5; + + public const int ByteId = 6; + + public const int CharId = 7; + + public const int ShortId = 8; + + public const int StringId = 9; + + public const int DateId = 10; + + public const int UntypedId = 11; + + public const int AnyArrayId = 12; + + public const int AnyArrayNId = 13; + + public static bool IsQueryLeaf(ITypeHandler4 handler) + { + ITypeHandler4 baseTypeHandler = BaseTypeHandler(handler); + if (!(baseTypeHandler is IQueryableTypeHandler)) + { + return false; + } + if (baseTypeHandler is ArrayHandler) + { + return false; + } + return baseTypeHandler is IValueTypeHandler; + } + + public static bool HandlesArray(ITypeHandler4 handler) + { + return handler is ArrayHandler; + } + + public static bool HandlesMultidimensionalArray(ITypeHandler4 handler) + { + return handler is MultidimensionalArrayHandler; + } + + public static bool HandlesClass(ITypeHandler4 handler) + { + return BaseTypeHandler(handler) is ICascadingTypeHandler; + } + + public static IReflectClass PrimitiveClassReflector(ITypeHandler4 handler, IReflector + reflector) + { + ITypeHandler4 baseTypeHandler = BaseTypeHandler(handler); + if (baseTypeHandler is PrimitiveHandler) + { + return ((PrimitiveHandler)baseTypeHandler).PrimitiveClassReflector(); + } + return null; + } + + public static ITypeHandler4 BaseTypeHandler(ITypeHandler4 handler) + { + if (handler is ArrayHandler) + { + return ((ArrayHandler)handler).DelegateTypeHandler(); + } + if (handler is PrimitiveTypeMetadata) + { + return ((PrimitiveTypeMetadata)handler).TypeHandler(); + } + return handler; + } + + public static IReflectClass BaseType(IReflectClass clazz) + { + if (clazz == null) + { + return null; + } + if (clazz.IsArray()) + { + return BaseType(clazz.GetComponentType()); + } + return clazz; + } + + public static bool IsClassAware(ITypeHandler4 typeHandler) + { + return typeHandler is IBuiltinTypeHandler || typeHandler is StandardReferenceTypeHandler; + } + + public static int CalculateLinkLength(ITypeHandler4 handler) + { + if (handler == null) + { + throw new ArgumentNullException(); + } + if (handler is ILinkLengthAware) + { + return ((ILinkLengthAware)handler).LinkLength(); + } + if (handler is IReferenceTypeHandler) + { + return Const4.IdLength; + } + if (handler is IVariableLengthTypeHandler) + { + return Const4.IndirectionLength; + } + // TODO: For custom handlers there will have to be a way + // to calculate the length in the slot. + // Options: + // (1) Remember when the first object is marshalled. + // (2) Add a #defaultValue() method to TypeHandler4, + // marshall the default value and check. + // (3) Add a way to test the custom handler when it + // is installed and remember the length there. + throw new NotImplementedException("Unexpected typehandler: " + handler); + } + + public static bool HoldsValueType(ITypeHandler4 handler) + { + return IsValueType(BaseTypeHandler(handler)); + } + + public static bool IsValueType(ITypeHandler4 handler) + { + return !(handler is IReferenceTypeHandler); + } + + public static bool IsCascading(ITypeHandler4 handler) + { + return handler is ICascadingTypeHandler; + } + + public static bool IsUntyped(ITypeHandler4 handler) + { + return handler is OpenTypeHandler; + } + + public static bool IsVariableLength(ITypeHandler4 handler) + { + return handler is IVariableLengthTypeHandler; + } + + public static IFieldAwareTypeHandler FieldAwareTypeHandler(ITypeHandler4 typeHandler + ) + { + if (typeHandler is IFieldAwareTypeHandler) + { + return (IFieldAwareTypeHandler)typeHandler; + } + return NullFieldAwareTypeHandler.Instance; + } + + public static void CollectIDs(QueryingReadContext context, ITypeHandler4 typeHandler + ) + { + if (typeHandler is ICascadingTypeHandler) + { + ((ICascadingTypeHandler)typeHandler).CollectIDs(context); + } + } + + public static bool UseDedicatedSlot(IContext context, ITypeHandler4 handler) + { + if (IsValueType(handler)) + { + return false; + } + if (IsUntyped(handler)) + { + return false; + } + return true; + } + + public static ITypeHandler4 ArrayElementHandler(ITypeHandler4 handler, QueryingReadContext + queryingReadContext) + { + if (!(handler is ICascadingTypeHandler)) + { + return null; + } + ICascadingTypeHandler cascadingHandler = (ICascadingTypeHandler)HandlerRegistry.CorrectHandlerVersion + (queryingReadContext, handler); + return HandlerRegistry.CorrectHandlerVersion(queryingReadContext, cascadingHandler + .ReadCandidateHandler(queryingReadContext)); + } + + public static object NullRepresentationInUntypedArrays(ITypeHandler4 handler) + { + if (handler is PrimitiveHandler) + { + return ((PrimitiveHandler)handler).NullRepresentationInUntypedArrays(); + } + return null; + } + + public static bool HandleAsObject(ITypeHandler4 typeHandler) + { + if (IsValueType(typeHandler)) + { + return false; + } + if (IsUntyped(typeHandler)) + { + return false; + } + return true; + } + + public static void CascadeActivation(IActivationContext context, ITypeHandler4 handler + ) + { + if (!(handler is ICascadingTypeHandler)) + { + return; + } + ((ICascadingTypeHandler)handler).CascadeActivation(context); + } + + public static bool HandlesPrimitiveArray(ITypeHandler4 typeHandler) + { + return typeHandler is ArrayHandler; + } + + // && isPrimitive(((ArrayHandler)typeHandler).delegateTypeHandler()); + public static bool HasClassIndex(ITypeHandler4 typeHandler) + { + if (typeHandler is StandardReferenceTypeHandler) + { + return ((StandardReferenceTypeHandler)typeHandler).ClassMetadata().HasClassIndex( + ); + } + return false; + } + + public static bool CanLoadFieldByIndex(ITypeHandler4 handler) + { + if (handler is IQueryableTypeHandler) + { + return !((IQueryableTypeHandler)handler).DescendsIntoMembers(); + } + return true; + } + + public static object WrapWithTransactionContext(Transaction transaction, object value + , ITypeHandler4 handler) + { + if (IsValueType(handler)) + { + return value; + } + return transaction.Wrap(value); + } + + public static void CollectIdsInternal(CollectIdContext context, ITypeHandler4 handler + , int linkLength, bool doWithSlotIndirection) + { + if (!(IsCascading(handler))) + { + IReadBuffer buffer = context.Buffer(); + buffer.Seek(buffer.Offset() + linkLength); + return; + } + if (handler is StandardReferenceTypeHandler) + { + context.AddId(); + return; + } + LocalObjectContainer container = (LocalObjectContainer)context.Container(); + SlotFormat slotFormat = context.SlotFormat(); + if (HandleAsObject(handler)) + { + // TODO: Code is similar to QCandidate.readArrayCandidates. Try to refactor to one place. + int collectionID = context.ReadInt(); + ByteArrayBuffer collectionBuffer = container.ReadBufferById(context.Transaction() + , collectionID); + ObjectHeader objectHeader = new ObjectHeader(container, collectionBuffer); + QueryingReadContext subContext = new QueryingReadContext(context.Transaction(), context + .HandlerVersion(), collectionBuffer, collectionID, context.Collector()); + objectHeader.ClassMetadata().CollectIDs(subContext); + return; + } + QueryingReadContext queryingReadContext = new QueryingReadContext(context.Transaction + (), context.HandlerVersion(), context.Buffer(), 0, context.Collector()); + IClosure4 collectIDsFromQueryingContext = new _IClosure4_263(handler, queryingReadContext + ); + if (doWithSlotIndirection) + { + slotFormat.DoWithSlotIndirection(queryingReadContext, handler, collectIDsFromQueryingContext + ); + } + else + { + collectIDsFromQueryingContext.Run(); + } + } + + private sealed class _IClosure4_263 : IClosure4 + { + public _IClosure4_263(ITypeHandler4 handler, QueryingReadContext queryingReadContext + ) + { + this.handler = handler; + this.queryingReadContext = queryingReadContext; + } + + public object Run() + { + ((ICascadingTypeHandler)handler).CollectIDs(queryingReadContext); + return null; + } + + private readonly ITypeHandler4 handler; + + private readonly QueryingReadContext queryingReadContext; + } + + public static bool IsIndirectedIndexed(ITypeHandler4 handler) + { + return IsValueType(handler) && (handler is IVariableLengthTypeHandler) && (handler + is IIndexableTypeHandler); + } + + public static IPreparedComparison PrepareComparisonFor(ITypeHandler4 handler, IContext + context, object obj) + { + if (!(handler is IComparable4)) + { + return null; + } + return ((IComparable4)handler).PrepareComparison(context, obj); + } + + public static IReflectClass PrimitiveClassReflector(ClassMetadata classMetadata, + IReflector reflector) + { + if (classMetadata is PrimitiveTypeMetadata) + { + return PrimitiveClassReflector(((PrimitiveTypeMetadata)classMetadata).TypeHandler + (), reflector); + } + return null; + } + + public static void Activate(UnmarshallingContext context, ITypeHandler4 handler) + { + if (handler is IReferenceTypeHandler) + { + ((IReferenceTypeHandler)handler).Activate(context); + } + } + + public static void Write(ITypeHandler4 handler, IWriteContext context, object obj + ) + { + handler.Write(context, obj); + } + + public static object ReadValueType(IReadContext context, ITypeHandler4 handler) + { + return ((IValueTypeHandler)handler).Read(context); + } + + public static bool IsStandaloneTypeHandler(ITypeHandler4 customTypeHandler) + { + return IsValueType(customTypeHandler) || customTypeHandler is OpenTypeHandler; + } + + public static ClassMetadata ErasedFieldType(ObjectContainerBase container, IReflectClass + fieldType) + { + return fieldType.IsInterface() ? container.ClassMetadataForID(UntypedId) : container + .ProduceClassMetadata(BaseType(fieldType)); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/HandlerVersionRegistry.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/HandlerVersionRegistry.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/HandlerVersionRegistry.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/HandlerVersionRegistry.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,92 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Typehandlers; + +namespace Db4objects.Db4o.Internal +{ + /// + public class HandlerVersionRegistry + { + private readonly HandlerRegistry _registry; + + private readonly Hashtable4 _versions = new Hashtable4(); + + public HandlerVersionRegistry(HandlerRegistry registry) + { + _registry = registry; + } + + public virtual void Put(ITypeHandler4 handler, int version, ITypeHandler4 replacement + ) + { + _versions.Put(new HandlerVersionRegistry.HandlerVersionKey(this, handler, version + ), replacement); + } + + public virtual ITypeHandler4 CorrectHandlerVersion(ITypeHandler4 originalHandler, + int version) + { + if (version >= HandlerRegistry.HandlerVersion) + { + return originalHandler; + } + if (originalHandler == null) + { + return null; + } + // HandlerVersionKey with null key will throw NPE. + ITypeHandler4 replacement = (ITypeHandler4)_versions.Get(new HandlerVersionRegistry.HandlerVersionKey + (this, GenericTemplate(originalHandler), version)); + if (replacement == null) + { + return CorrectHandlerVersion(originalHandler, version + 1); + } + if (replacement is IVersionedTypeHandler) + { + return (ITypeHandler4)((IVersionedTypeHandler)replacement).DeepClone(new TypeHandlerCloneContext + (_registry, originalHandler, version)); + } + return replacement; + } + + private ITypeHandler4 GenericTemplate(ITypeHandler4 handler) + { + if (handler is IVersionedTypeHandler) + { + return ((IVersionedTypeHandler)handler).UnversionedTemplate(); + } + return handler; + } + + private class HandlerVersionKey + { + private readonly ITypeHandler4 _handler; + + private readonly int _version; + + public HandlerVersionKey(HandlerVersionRegistry _enclosing, ITypeHandler4 handler + , int version) + { + this._enclosing = _enclosing; + this._handler = handler; + this._version = version; + } + + public override int GetHashCode() + { + return this._handler.GetHashCode() + this._version * 4271; + } + + public override bool Equals(object obj) + { + HandlerVersionRegistry.HandlerVersionKey other = (HandlerVersionRegistry.HandlerVersionKey + )obj; + return this._handler.Equals(other._handler) && this._version == other._version; + } + + private readonly HandlerVersionRegistry _enclosing; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/HardObjectReference.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/HardObjectReference.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/HardObjectReference.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/HardObjectReference.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,43 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Activation; + +namespace Db4objects.Db4o.Internal +{ + /// + public class HardObjectReference + { + public static readonly Db4objects.Db4o.Internal.HardObjectReference Invalid = new + Db4objects.Db4o.Internal.HardObjectReference(null, null); + + public readonly ObjectReference _reference; + + public readonly object _object; + + public HardObjectReference(ObjectReference @ref, object obj) + { + _reference = @ref; + _object = obj; + } + + public static Db4objects.Db4o.Internal.HardObjectReference PeekPersisted(Transaction + trans, int id, int depth) + { + object obj = trans.Container().PeekPersisted(trans, id, ActivationDepthProvider(trans + ).ActivationDepth(depth, ActivationMode.Peek), true); + if (obj == null) + { + return null; + } + ObjectReference @ref = trans.ReferenceForId(id); + return new Db4objects.Db4o.Internal.HardObjectReference(@ref, obj); + } + + private static IActivationDepthProvider ActivationDepthProvider(Transaction trans + ) + { + return trans.Container().ActivationDepthProvider(); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/IBlockConverter.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/IBlockConverter.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/IBlockConverter.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/IBlockConverter.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,20 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal.Slots; + +namespace Db4objects.Db4o.Internal +{ + /// + public interface IBlockConverter + { + int BytesToBlocks(long bytes); + + int BlockAlignedBytes(int bytes); + + int BlocksToBytes(int blocks); + + Slot ToBlockedLength(Slot slot); + + Slot ToNonBlockedLength(Slot slot); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/IBuiltinTypeHandler.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/IBuiltinTypeHandler.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/IBuiltinTypeHandler.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/IBuiltinTypeHandler.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,15 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Reflect; +using Db4objects.Db4o.Typehandlers; + +namespace Db4objects.Db4o.Internal +{ + /// + public interface IBuiltinTypeHandler : ITypeHandler4 + { + void RegisterReflector(IReflector reflector); + + IReflectClass ClassReflector(); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/ICallbackInfoCollector.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/ICallbackInfoCollector.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/ICallbackInfoCollector.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/ICallbackInfoCollector.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,13 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +namespace Db4objects.Db4o.Internal +{ + public interface ICallbackInfoCollector + { + void Added(int id); + + void Updated(int id); + + void Deleted(int id); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/ICommittedCallbackDispatcher.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/ICommittedCallbackDispatcher.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/ICommittedCallbackDispatcher.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/ICommittedCallbackDispatcher.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,14 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal; + +namespace Db4objects.Db4o.Internal +{ + /// + public interface ICommittedCallbackDispatcher + { + bool WillDispatchCommitted(); + + void DispatchCommitted(CallbackObjectInfoCollections committedInfo); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/IComparable4.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/IComparable4.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/IComparable4.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/IComparable4.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,28 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Marshall; + +namespace Db4objects.Db4o.Internal +{ + /// Interface for comparison support in queries. + /// Interface for comparison support in queries. + public interface IComparable4 + { + /// + /// creates a prepared comparison to compare multiple objects + /// against one single object. + /// + /// + /// creates a prepared comparison to compare multiple objects + /// against one single object. + /// + /// the context of the comparison + /// + /// the object that is to be compared + /// against multiple other objects + /// + /// the prepared comparison + IPreparedComparison PrepareComparison(IContext context, object obj); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/IDb4oTypeImpl.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/IDb4oTypeImpl.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/IDb4oTypeImpl.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/IDb4oTypeImpl.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,18 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o; +using Db4objects.Db4o.Internal; + +namespace Db4objects.Db4o.Internal +{ + /// marker interface for special db4o datatypes + /// + public interface IDb4oTypeImpl : ITransactionAware + { + object CreateDefault(Transaction trans); + + bool HasClassIndex(); + + void SetObjectReference(ObjectReference @ref); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/IDefragmentContext.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/IDefragmentContext.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/IDefragmentContext.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/IDefragmentContext.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,57 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Defragment; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Marshall; +using Db4objects.Db4o.Internal.Slots; +using Db4objects.Db4o.Marshall; +using Db4objects.Db4o.Typehandlers; + +namespace Db4objects.Db4o.Internal +{ + public interface IDefragmentContext : IBufferContext, IMarshallingInfo, IHandlerVersionContext + { + ITypeHandler4 TypeHandlerForId(int id); + + int CopyID(); + + int CopyIDReturnOriginalID(); + + int CopySlotlessID(); + + int CopyUnindexedID(); + + void Defragment(ITypeHandler4 handler); + + int HandlerVersion(); + + void IncrementOffset(int length); + + bool IsLegacyHandlerVersion(); + + int MappedID(int origID); + + ByteArrayBuffer SourceBuffer(); + + ByteArrayBuffer TargetBuffer(); + + Slot AllocateTargetSlot(int length); + + Slot AllocateMappedTargetSlot(int sourceAddress, int length); + + /// + int CopySlotToNewMapped(int sourceAddress, int length); + + /// + ByteArrayBuffer SourceBufferByAddress(int sourceAddress, int length); + + /// + ByteArrayBuffer SourceBufferById(int sourceId); + + void TargetWriteBytes(int address, ByteArrayBuffer buffer); + + IDefragmentServices Services(); + + ObjectContainerBase Container(); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Identifiable.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Identifiable.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Identifiable.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Identifiable.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,107 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using Db4objects.Db4o; +using Db4objects.Db4o.Internal; + +namespace Db4objects.Db4o.Internal +{ + /// + public abstract class Identifiable + { + protected int _id; + + protected int _state = 2; + + // DIRTY and ACTIVE + public bool BeginProcessing() + { + if (BitIsTrue(Const4.Processing)) + { + return false; + } + BitTrue(Const4.Processing); + return true; + } + + internal void BitFalse(int bitPos) + { + _state &= ~(1 << bitPos); + } + + internal bool BitIsFalse(int bitPos) + { + return (_state | (1 << bitPos)) != _state; + } + + internal bool BitIsTrue(int bitPos) + { + return (_state | (1 << bitPos)) == _state; + } + + internal void BitTrue(int bitPos) + { + _state |= (1 << bitPos); + } + + public virtual void EndProcessing() + { + BitFalse(Const4.Processing); + } + + public virtual int GetID() + { + return _id; + } + + public bool IsActive() + { + return BitIsTrue(Const4.Active); + } + + public virtual bool IsDirty() + { + return BitIsTrue(Const4.Active) && (!BitIsTrue(Const4.Clean)); + } + + public bool IsNew() + { + return GetID() == 0; + } + + public virtual void SetID(int id) + { + if (DTrace.enabled) + { + DTrace.PersistentbaseSetId.Log(id); + } + _id = id; + } + + public void SetStateClean() + { + BitTrue(Const4.Active); + BitTrue(Const4.Clean); + } + + public void SetStateDeactivated() + { + BitFalse(Const4.Active); + } + + public virtual void SetStateDirty() + { + BitTrue(Const4.Active); + BitFalse(Const4.Clean); + } + + public override int GetHashCode() + { + if (IsNew()) + { + throw new InvalidOperationException(); + } + return GetID(); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/IDGenerator.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/IDGenerator.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/IDGenerator.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/IDGenerator.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,20 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +namespace Db4objects.Db4o.Internal +{ + public class IDGenerator + { + private int id = 0; + + public virtual int Next() + { + id++; + if (id > 0) + { + return id; + } + id = 1; + return 1; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/IDHandler.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/IDHandler.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/IDHandler.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/IDHandler.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,17 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Handlers; + +namespace Db4objects.Db4o.Internal +{ + /// + public class IDHandler : IntHandler + { + public override void DefragIndexEntry(DefragmentContextImpl context) + { + int sourceId = context.CopyIDReturnOriginalID(true); + context.CurrentParentSourceID(sourceId); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Ids/BTreeIdSystem.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Ids/BTreeIdSystem.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Ids/BTreeIdSystem.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Ids/BTreeIdSystem.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,313 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using Db4objects.Db4o; +using Db4objects.Db4o.Ext; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Btree; +using Db4objects.Db4o.Internal.Ids; +using Db4objects.Db4o.Internal.Slots; +using Db4objects.Db4o.Marshall; + +namespace Db4objects.Db4o.Internal.Ids +{ + /// + public class BTreeIdSystem : IStackableIdSystem + { + private const int BtreeIdIndex = 0; + + private const int IdGeneratorIndex = 1; + + private const int ChildIdIndex = 2; + + private readonly LocalObjectContainer _container; + + private readonly IStackableIdSystem _parentIdSystem; + + private readonly ITransactionalIdSystem _transactionalIdSystem; + + private readonly SequentialIdGenerator _idGenerator; + + private BTree _bTree; + + private PersistentIntegerArray _persistentState; + + public BTreeIdSystem(LocalObjectContainer container, IStackableIdSystem parentIdSystem + , int maxValidId) + { + _container = container; + _parentIdSystem = parentIdSystem; + _transactionalIdSystem = container.NewTransactionalIdSystem(null, new _IClosure4_40 + (parentIdSystem)); + int persistentArrayId = parentIdSystem.ChildId(); + if (persistentArrayId == 0) + { + InitializeNew(); + } + else + { + InitializeExisting(persistentArrayId); + } + _idGenerator = new SequentialIdGenerator(new _IFunction4_52(this), IdGeneratorValue + (), _container.Handlers.LowestValidId(), maxValidId); + } + + private sealed class _IClosure4_40 : IClosure4 + { + public _IClosure4_40(IStackableIdSystem parentIdSystem) + { + this.parentIdSystem = parentIdSystem; + } + + public object Run() + { + return parentIdSystem; + } + + private readonly IStackableIdSystem parentIdSystem; + } + + private sealed class _IFunction4_52 : IFunction4 + { + public _IFunction4_52(BTreeIdSystem _enclosing) + { + this._enclosing = _enclosing; + } + + public object Apply(object start) + { + return this._enclosing.FindFreeId((((int)start))); + } + + private readonly BTreeIdSystem _enclosing; + } + + public BTreeIdSystem(LocalObjectContainer container, IStackableIdSystem idSystem) + : this(container, idSystem, int.MaxValue) + { + } + + private void InitializeExisting(int persistentArrayId) + { + _persistentState = new PersistentIntegerArray(SlotChangeFactory.IdSystem, _transactionalIdSystem + , persistentArrayId); + _persistentState.Read(Transaction()); + _bTree = new BTree(Transaction(), BTreeConfiguration(), BTreeId(), new BTreeIdSystem.IdSlotMappingHandler + ()); + } + + private Db4objects.Db4o.Internal.Btree.BTreeConfiguration BTreeConfiguration() + { + return new Db4objects.Db4o.Internal.Btree.BTreeConfiguration(_transactionalIdSystem + , SlotChangeFactory.IdSystem, 64, false); + } + + private int IdGeneratorValue() + { + return _persistentState.Array()[IdGeneratorIndex]; + } + + private void IdGeneratorValue(int value) + { + _persistentState.Array()[IdGeneratorIndex] = value; + } + + private int BTreeId() + { + return _persistentState.Array()[BtreeIdIndex]; + } + + private void InitializeNew() + { + _bTree = new BTree(Transaction(), BTreeConfiguration(), new BTreeIdSystem.IdSlotMappingHandler + ()); + int idGeneratorValue = _container.Handlers.LowestValidId() - 1; + _persistentState = new PersistentIntegerArray(SlotChangeFactory.IdSystem, _transactionalIdSystem + , new int[] { _bTree.GetID(), idGeneratorValue, 0 }); + _persistentState.Write(Transaction()); + _parentIdSystem.ChildId(_persistentState.GetID()); + } + + private int FindFreeId(int start) + { + throw new NotImplementedException(); + } + + public virtual void Close() + { + } + + public virtual Slot CommittedSlot(int id) + { + IdSlotMapping mapping = (IdSlotMapping)_bTree.Search(Transaction(), new IdSlotMapping + (id, 0, 0)); + if (mapping == null) + { + throw new InvalidIDException(id); + } + return mapping.Slot(); + } + + public virtual void CompleteInterruptedTransaction(int transactionId1, int transactionId2 + ) + { + } + + // do nothing + public virtual int NewId() + { + int id = _idGenerator.NewId(); + _bTree.Add(Transaction(), new IdSlotMapping(id, 0, 0)); + return id; + } + + private Db4objects.Db4o.Internal.Transaction Transaction() + { + return _container.SystemTransaction(); + } + + public virtual void Commit(IVisitable slotChanges, FreespaceCommitter freespaceCommitter + ) + { + _container.FreespaceManager().BeginCommit(); + slotChanges.Accept(new _IVisitor4_129(this)); + // TODO: Maybe we want a BTree that doesn't allow duplicates. + // Then we could do the following in one step without removing first. + _bTree.Commit(Transaction()); + IdGeneratorValue(_idGenerator.PersistentGeneratorValue()); + if (_idGenerator.IsDirty()) + { + _idGenerator.SetClean(); + _persistentState.SetStateDirty(); + } + if (_persistentState.IsDirty()) + { + _persistentState.Write(Transaction()); + } + _container.FreespaceManager().EndCommit(); + _transactionalIdSystem.Commit(freespaceCommitter); + _transactionalIdSystem.Clear(); + } + + private sealed class _IVisitor4_129 : IVisitor4 + { + public _IVisitor4_129(BTreeIdSystem _enclosing) + { + this._enclosing = _enclosing; + } + + public void Visit(object slotChange) + { + if (!((SlotChange)slotChange).SlotModified()) + { + return; + } + this._enclosing._bTree.Remove(this._enclosing.Transaction(), new IdSlotMapping((( + TreeInt)slotChange)._key, 0, 0)); + if (((SlotChange)slotChange).RemoveId()) + { + return; + } + this._enclosing._bTree.Add(this._enclosing.Transaction(), new IdSlotMapping(((TreeInt + )slotChange)._key, ((SlotChange)slotChange).NewSlot())); + if (DTrace.enabled) + { + DTrace.SlotMapped.LogLength(((TreeInt)slotChange)._key, ((SlotChange)slotChange). + NewSlot()); + } + } + + private readonly BTreeIdSystem _enclosing; + } + + public virtual void ReturnUnusedIds(IVisitable visitable) + { + visitable.Accept(new _IVisitor4_167(this)); + } + + private sealed class _IVisitor4_167 : IVisitor4 + { + public _IVisitor4_167(BTreeIdSystem _enclosing) + { + this._enclosing = _enclosing; + } + + public void Visit(object id) + { + this._enclosing._bTree.Remove(this._enclosing.Transaction(), new IdSlotMapping((( + (int)id)), 0, 0)); + } + + private readonly BTreeIdSystem _enclosing; + } + + public class IdSlotMappingHandler : IIndexable4 + { + public virtual void DefragIndexEntry(DefragmentContextImpl context) + { + throw new NotImplementedException(); + } + + public virtual object ReadIndexEntry(IContext context, ByteArrayBuffer buffer) + { + return IdSlotMapping.Read(buffer); + } + + public virtual void WriteIndexEntry(IContext context, ByteArrayBuffer buffer, object + mapping) + { + ((IdSlotMapping)mapping).Write(buffer); + } + + public virtual IPreparedComparison PrepareComparison(IContext context, object sourceMapping + ) + { + return new _IPreparedComparison_190(sourceMapping); + } + + private sealed class _IPreparedComparison_190 : IPreparedComparison + { + public _IPreparedComparison_190(object sourceMapping) + { + this.sourceMapping = sourceMapping; + } + + public int CompareTo(object targetMapping) + { + return ((IdSlotMapping)sourceMapping)._id == ((IdSlotMapping)targetMapping)._id ? + 0 : (((IdSlotMapping)sourceMapping)._id < ((IdSlotMapping)targetMapping)._id ? - + 1 : 1); + } + + private readonly object sourceMapping; + } + + public int LinkLength() + { + return Const4.IntLength * 3; + } + } + + public virtual ITransactionalIdSystem FreespaceIdSystem() + { + return _transactionalIdSystem; + } + + public virtual int ChildId() + { + return _persistentState.Array()[ChildIdIndex]; + } + + public virtual void ChildId(int id) + { + _persistentState.Array()[ChildIdIndex] = id; + _persistentState.SetStateDirty(); + } + + public virtual void TraverseIds(IVisitor4 visitor) + { + _bTree.TraverseKeys(_container.SystemTransaction(), visitor); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Ids/FreespaceCommitter.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Ids/FreespaceCommitter.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Ids/FreespaceCommitter.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Ids/FreespaceCommitter.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,79 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System.Collections; +using Db4objects.Db4o.Internal.Freespace; +using Db4objects.Db4o.Internal.Ids; +using Db4objects.Db4o.Internal.Slots; + +namespace Db4objects.Db4o.Internal.Ids +{ + /// + public class FreespaceCommitter + { + public static readonly Db4objects.Db4o.Internal.Ids.FreespaceCommitter DoNothing = + new FreespaceCommitter.NullFreespaceCommitter(); + + private readonly IList _freeToUserFreespaceSystem = new ArrayList(); + + private readonly IList _freeToSystemFreespaceSystem = new ArrayList(); + + private readonly IFreespaceManager _freespaceManager; + + private ITransactionalIdSystem _transactionalIdSystem; + + public FreespaceCommitter(IFreespaceManager freespaceManager) + { + _freespaceManager = freespaceManager == null ? NullFreespaceManager.Instance : freespaceManager; + } + + public virtual void Commit() + { + Apply(_freeToUserFreespaceSystem); + _freespaceManager.BeginCommit(); + _freespaceManager.Commit(); + _transactionalIdSystem.AccumulateFreeSlots(this, true); + Apply(_freeToSystemFreespaceSystem); + _freespaceManager.EndCommit(); + } + + private void Apply(IList toFree) + { + for (IEnumerator slotIter = toFree.GetEnumerator(); slotIter.MoveNext(); ) + { + Slot slot = ((Slot)slotIter.Current); + _freespaceManager.Free(slot); + } + toFree.Clear(); + } + + public virtual void TransactionalIdSystem(ITransactionalIdSystem transactionalIdSystem + ) + { + _transactionalIdSystem = transactionalIdSystem; + } + + private class NullFreespaceCommitter : FreespaceCommitter + { + public NullFreespaceCommitter() : base(NullFreespaceManager.Instance) + { + } + + public override void Commit() + { + } + // do nothing + } + + public virtual void DelayedFree(Slot slot, bool freeToSystemFreeSpaceSystem) + { + if (freeToSystemFreeSpaceSystem) + { + _freeToSystemFreespaceSystem.Add(slot); + } + else + { + _freeToUserFreespaceSystem.Add(slot); + } + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Ids/IdSlotChanges.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Ids/IdSlotChanges.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Ids/IdSlotChanges.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Ids/IdSlotChanges.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,177 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Freespace; +using Db4objects.Db4o.Internal.Ids; +using Db4objects.Db4o.Internal.Slots; + +namespace Db4objects.Db4o.Internal.Ids +{ + public class IdSlotChanges + { + private readonly LockedTree _slotChanges = new LockedTree(); + + private readonly TransactionalIdSystemImpl _idSystem; + + private readonly IClosure4 _freespaceManager; + + private TreeInt _prefetchedIDs; + + public IdSlotChanges(TransactionalIdSystemImpl idSystem, IClosure4 freespaceManager + ) + { + _idSystem = idSystem; + _freespaceManager = freespaceManager; + } + + public void AccumulateFreeSlots(FreespaceCommitter freespaceCommitter, bool forFreespace + , bool traverseMutable) + { + IVisitor4 visitor = new _IVisitor4_27(this, freespaceCommitter, forFreespace); + if (traverseMutable) + { + _slotChanges.TraverseMutable(visitor); + } + else + { + _slotChanges.TraverseLocked(visitor); + } + } + + private sealed class _IVisitor4_27 : IVisitor4 + { + public _IVisitor4_27(IdSlotChanges _enclosing, FreespaceCommitter freespaceCommitter + , bool forFreespace) + { + this._enclosing = _enclosing; + this.freespaceCommitter = freespaceCommitter; + this.forFreespace = forFreespace; + } + + public void Visit(object obj) + { + ((SlotChange)obj).AccumulateFreeSlot(this._enclosing._idSystem, freespaceCommitter + , forFreespace); + } + + private readonly IdSlotChanges _enclosing; + + private readonly FreespaceCommitter freespaceCommitter; + + private readonly bool forFreespace; + } + + public virtual void Clear() + { + _slotChanges.Clear(); + } + + public virtual void Rollback() + { + _slotChanges.TraverseLocked(new _IVisitor4_44(this)); + } + + private sealed class _IVisitor4_44 : IVisitor4 + { + public _IVisitor4_44(IdSlotChanges _enclosing) + { + this._enclosing = _enclosing; + } + + public void Visit(object slotChange) + { + ((SlotChange)slotChange).Rollback(this._enclosing.FreespaceManager()); + } + + private readonly IdSlotChanges _enclosing; + } + + public virtual bool IsDeleted(int id) + { + SlotChange slot = FindSlotChange(id); + if (slot == null) + { + return false; + } + return slot.IsDeleted(); + } + + public virtual SlotChange ProduceSlotChange(int id, SlotChangeFactory slotChangeFactory + ) + { + if (DTrace.enabled) + { + DTrace.ProduceSlotChange.Log(id); + } + SlotChange slot = slotChangeFactory.NewInstance(id); + _slotChanges.Add(slot); + return (SlotChange)slot.AddedOrExisting(); + } + + public SlotChange FindSlotChange(int id) + { + return (SlotChange)_slotChanges.Find(id); + } + + public virtual void TraverseSlotChanges(IVisitor4 visitor) + { + _slotChanges.TraverseLocked(visitor); + } + + public virtual bool IsDirty() + { + return !_slotChanges.IsEmpty(); + } + + public virtual void ReadSlotChanges(ByteArrayBuffer buffer) + { + _slotChanges.Read(buffer, new SlotChange(0)); + } + + public virtual void AddPrefetchedID(int id) + { + _prefetchedIDs = ((TreeInt)Tree.Add(_prefetchedIDs, new TreeInt(id))); + } + + public virtual void PrefetchedIDConsumed(int id) + { + _prefetchedIDs = ((TreeInt)_prefetchedIDs.RemoveLike(new TreeInt(id))); + } + + internal void FreePrefetchedIDs(IIdSystem idSystem) + { + if (_prefetchedIDs == null) + { + return; + } + idSystem.ReturnUnusedIds(_prefetchedIDs); + _prefetchedIDs = null; + } + + public virtual void NotifySlotCreated(int id, Slot slot, SlotChangeFactory slotChangeFactory + ) + { + ProduceSlotChange(id, slotChangeFactory).NotifySlotCreated(slot); + } + + internal virtual void NotifySlotUpdated(int id, Slot slot, SlotChangeFactory slotChangeFactory + ) + { + ProduceSlotChange(id, slotChangeFactory).NotifySlotUpdated(FreespaceManager(), slot + ); + } + + public virtual void NotifySlotDeleted(int id, SlotChangeFactory slotChangeFactory + ) + { + ProduceSlotChange(id, slotChangeFactory).NotifyDeleted(FreespaceManager()); + } + + private IFreespaceManager FreespaceManager() + { + return ((IFreespaceManager)_freespaceManager.Run()); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Ids/IdSlotMapping.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Ids/IdSlotMapping.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Ids/IdSlotMapping.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Ids/IdSlotMapping.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,53 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal; + +namespace Db4objects.Db4o.Internal.Ids +{ + /// + public class IdSlotMapping + { + public int _id; + + public int _address; + + public int _length; + + public IdSlotMapping(int id, int address, int length) + { + // persistent and indexed in DatabaseIdMapping, don't change the name + _id = id; + _address = address; + _length = length; + } + + public IdSlotMapping(int id, Db4objects.Db4o.Internal.Slots.Slot slot) : this(id, + slot.Address(), slot.Length()) + { + } + + public virtual Db4objects.Db4o.Internal.Slots.Slot Slot() + { + return new Db4objects.Db4o.Internal.Slots.Slot(_address, _length); + } + + public virtual void Write(ByteArrayBuffer buffer) + { + buffer.WriteInt(_id); + buffer.WriteInt(_address); + buffer.WriteInt(_length); + } + + public static Db4objects.Db4o.Internal.Ids.IdSlotMapping Read(ByteArrayBuffer buffer + ) + { + return new Db4objects.Db4o.Internal.Ids.IdSlotMapping(buffer.ReadInt(), buffer.ReadInt + (), buffer.ReadInt()); + } + + public override string ToString() + { + return string.Empty + _id + ":" + _address + "," + _length; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Ids/IdSlotTree.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Ids/IdSlotTree.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Ids/IdSlotTree.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Ids/IdSlotTree.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,52 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal; + +namespace Db4objects.Db4o.Internal.Ids +{ + /// + public class IdSlotTree : TreeInt + { + private readonly Db4objects.Db4o.Internal.Slots.Slot _slot; + + public IdSlotTree(int id, Db4objects.Db4o.Internal.Slots.Slot slot) : base(id) + { + _slot = slot; + } + + public virtual Db4objects.Db4o.Internal.Slots.Slot Slot() + { + return _slot; + } + + public override Tree OnAttemptToAddDuplicate(Tree oldNode) + { + _preceding = ((Tree)oldNode._preceding); + _subsequent = ((Tree)oldNode._subsequent); + _size = oldNode._size; + return this; + } + + public override int OwnLength() + { + return Const4.IntLength * 3; + } + + // _key, _slot._address, _slot._length + public override object Read(ByteArrayBuffer buffer) + { + int id = buffer.ReadInt(); + Db4objects.Db4o.Internal.Slots.Slot slot = new Db4objects.Db4o.Internal.Slots.Slot + (buffer.ReadInt(), buffer.ReadInt()); + return new Db4objects.Db4o.Internal.Ids.IdSlotTree(id, slot); + } + + public override void Write(ByteArrayBuffer buffer) + { + buffer.WriteInt(_key); + buffer.WriteInt(_slot.Address()); + buffer.WriteInt(_slot.Length()); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Ids/IIdSystem.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Ids/IIdSystem.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Ids/IIdSystem.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Ids/IIdSystem.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,24 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal.Ids; +using Db4objects.Db4o.Internal.Slots; + +namespace Db4objects.Db4o.Internal.Ids +{ + /// + public interface IIdSystem + { + int NewId(); + + Slot CommittedSlot(int id); + + void ReturnUnusedIds(IVisitable visitable); + + void Close(); + + void CompleteInterruptedTransaction(int transactionId1, int transactionId2); + + void Commit(IVisitable slotChanges, FreespaceCommitter freespaceCommitter); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Ids/InMemoryIdSystem.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Ids/InMemoryIdSystem.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Ids/InMemoryIdSystem.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Ids/InMemoryIdSystem.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,336 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using Db4objects.Db4o; +using Db4objects.Db4o.Ext; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Freespace; +using Db4objects.Db4o.Internal.Ids; +using Db4objects.Db4o.Internal.Slots; +using Sharpen.Lang; + +namespace Db4objects.Db4o.Internal.Ids +{ + /// + public class InMemoryIdSystem : IStackableIdSystem + { + private readonly LocalObjectContainer _container; + + private IdSlotTree _ids; + + private Slot _slot; + + private readonly SequentialIdGenerator _idGenerator; + + private int _childId; + + /// for testing purposes only. + /// for testing purposes only. + public InMemoryIdSystem(LocalObjectContainer container, int maxValidId) + { + _container = container; + _idGenerator = new SequentialIdGenerator(new _IFunction4_32(this, maxValidId), _container + .Handlers.LowestValidId(), maxValidId); + } + + private sealed class _IFunction4_32 : IFunction4 + { + public _IFunction4_32(InMemoryIdSystem _enclosing, int maxValidId) + { + this._enclosing = _enclosing; + this.maxValidId = maxValidId; + } + + public object Apply(object start) + { + return this._enclosing.FindFreeId((((int)start)), maxValidId); + } + + private readonly InMemoryIdSystem _enclosing; + + private readonly int maxValidId; + } + + public InMemoryIdSystem(LocalObjectContainer container) : this(container, int.MaxValue + ) + { + ReadThis(); + } + + private void ReadThis() + { + SystemData systemData = _container.SystemData(); + _slot = systemData.IdSystemSlot(); + if (!Slot.IsNull(_slot)) + { + ByteArrayBuffer buffer = _container.ReadBufferBySlot(_slot); + _childId = buffer.ReadInt(); + _idGenerator.Read(buffer); + _ids = (IdSlotTree)new TreeReader(buffer, new IdSlotTree(0, null)).Read(); + } + } + + public virtual void Close() + { + } + + // do nothing + public virtual void Commit(IVisitable slotChanges, FreespaceCommitter freespaceCommitter + ) + { + Slot oldSlot = _slot; + Slot reservedSlot = AllocateSlot(false, EstimatedSlotLength(EstimateMappingCount( + slotChanges))); + // No more operations against the FreespaceManager. + // Time to free old slots. + freespaceCommitter.Commit(); + slotChanges.Accept(new _IVisitor4_69(this)); + WriteThis(reservedSlot); + FreeSlot(oldSlot); + } + + private sealed class _IVisitor4_69 : IVisitor4 + { + public _IVisitor4_69(InMemoryIdSystem _enclosing) + { + this._enclosing = _enclosing; + } + + public void Visit(object slotChange) + { + if (!((SlotChange)slotChange).SlotModified()) + { + return; + } + if (((SlotChange)slotChange).RemoveId()) + { + this._enclosing._ids = (IdSlotTree)Tree.RemoveLike(this._enclosing._ids, new TreeInt + (((TreeInt)slotChange)._key)); + return; + } + if (DTrace.enabled) + { + DTrace.SlotCommitted.LogLength(((TreeInt)slotChange)._key, ((SlotChange)slotChange + ).NewSlot()); + } + this._enclosing._ids = ((IdSlotTree)Tree.Add(this._enclosing._ids, new IdSlotTree + (((TreeInt)slotChange)._key, ((SlotChange)slotChange).NewSlot()))); + } + + private readonly InMemoryIdSystem _enclosing; + } + + private Slot AllocateSlot(bool appendToFile, int slotLength) + { + if (!appendToFile) + { + Slot slot = _container.FreespaceManager().AllocateSafeSlot(slotLength); + if (slot != null) + { + return slot; + } + } + return _container.AppendBytes(slotLength); + } + + private int EstimateMappingCount(IVisitable slotChanges) + { + IntByRef count = new IntByRef(); + count.value = _ids == null ? 0 : _ids.Size(); + slotChanges.Accept(new _IVisitor4_103(count)); + return count.value; + } + + private sealed class _IVisitor4_103 : IVisitor4 + { + public _IVisitor4_103(IntByRef count) + { + this.count = count; + } + + public void Visit(object slotChange) + { + if (!((SlotChange)slotChange).SlotModified() || ((SlotChange)slotChange).RemoveId + ()) + { + return; + } + count.value++; + } + + private readonly IntByRef count; + } + + private void WriteThis(Slot reservedSlot) + { + // We need a little dance here to keep filling free slots + // with X bytes. The FreespaceManager would do it immediately + // upon the free call, but then our CrashSimulatingTestCase + // fails because we have the Xses in the file before flushing. + Slot xByteSlot = null; + int slotLength = SlotLength(); + if (reservedSlot.Length() >= slotLength) + { + _slot = reservedSlot; + reservedSlot = null; + } + else + { + _slot = AllocateSlot(true, slotLength); + } + ByteArrayBuffer buffer = new ByteArrayBuffer(_slot.Length()); + buffer.WriteInt(_childId); + _idGenerator.Write(buffer); + TreeInt.Write(buffer, _ids); + _container.WriteBytes(buffer, _slot.Address(), 0); + _container.SystemData().IdSystemSlot(_slot); + IRunnable commitHook = _container.CommitHook(); + _container.SyncFiles(commitHook); + FreeSlot(reservedSlot); + } + + private void FreeSlot(Slot slot) + { + if (Slot.IsNull(slot)) + { + return; + } + IFreespaceManager freespaceManager = _container.FreespaceManager(); + if (freespaceManager == null) + { + return; + } + freespaceManager.FreeSafeSlot(slot); + } + + private int SlotLength() + { + return TreeInt.MarshalledLength(_ids) + _idGenerator.MarshalledLength() + Const4. + IdLength; + } + + private int EstimatedSlotLength(int estimatedCount) + { + IdSlotTree template = _ids; + if (template == null) + { + template = new IdSlotTree(0, new Slot(0, 0)); + } + return template.MarshalledLength(estimatedCount) + _idGenerator.MarshalledLength( + ) + Const4.IdLength; + } + + public virtual Slot CommittedSlot(int id) + { + IdSlotTree idSlotMapping = (IdSlotTree)Tree.Find(_ids, new TreeInt(id)); + if (idSlotMapping == null) + { + throw new InvalidIDException(id); + } + return idSlotMapping.Slot(); + } + + public virtual void CompleteInterruptedTransaction(int address, int length) + { + } + + // do nothing + public virtual int NewId() + { + int id = _idGenerator.NewId(); + _ids = ((IdSlotTree)Tree.Add(_ids, new IdSlotTree(id, Slot.Zero))); + return id; + } + + private int FindFreeId(int start, int end) + { + if (_ids == null) + { + return start; + } + IntByRef lastId = new IntByRef(); + IntByRef freeId = new IntByRef(); + Tree.Traverse(_ids, new TreeInt(start), new _ICancellableVisitor4_204(lastId, start + , freeId)); + if (freeId.value > 0) + { + return freeId.value; + } + if (lastId.value < end) + { + return Math.Max(start, lastId.value + 1); + } + return 0; + } + + private sealed class _ICancellableVisitor4_204 : ICancellableVisitor4 + { + public _ICancellableVisitor4_204(IntByRef lastId, int start, IntByRef freeId) + { + this.lastId = lastId; + this.start = start; + this.freeId = freeId; + } + + public bool Visit(object node) + { + int id = ((TreeInt)node)._key; + if (lastId.value == 0) + { + if (id > start) + { + freeId.value = start; + return false; + } + lastId.value = id; + return true; + } + if (id > lastId.value + 1) + { + freeId.value = lastId.value + 1; + return false; + } + lastId.value = id; + return true; + } + + private readonly IntByRef lastId; + + private readonly int start; + + private readonly IntByRef freeId; + } + + public virtual void ReturnUnusedIds(IVisitable visitable) + { + visitable.Accept(new _IVisitor4_233(this)); + } + + private sealed class _IVisitor4_233 : IVisitor4 + { + public _IVisitor4_233(InMemoryIdSystem _enclosing) + { + this._enclosing = _enclosing; + } + + public void Visit(object obj) + { + this._enclosing._ids = (IdSlotTree)Tree.RemoveLike(this._enclosing._ids, new TreeInt + ((((int)obj)))); + } + + private readonly InMemoryIdSystem _enclosing; + } + + public virtual int ChildId() + { + return _childId; + } + + public virtual void ChildId(int id) + { + _childId = id; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Ids/IStackableIdSystem.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Ids/IStackableIdSystem.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Ids/IStackableIdSystem.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Ids/IStackableIdSystem.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,14 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal.Ids; + +namespace Db4objects.Db4o.Internal.Ids +{ + /// + public interface IStackableIdSystem : IIdSystem + { + int ChildId(); + + void ChildId(int id); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Ids/ITransactionalIdSystem.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Ids/ITransactionalIdSystem.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Ids/ITransactionalIdSystem.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Ids/ITransactionalIdSystem.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,45 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Ids; +using Db4objects.Db4o.Internal.Slots; + +namespace Db4objects.Db4o.Internal.Ids +{ + /// + public interface ITransactionalIdSystem + { + void CollectCallBackInfo(ICallbackInfoCollector collector); + + bool IsDirty(); + + void Commit(FreespaceCommitter freespaceCommitter); + + Slot CommittedSlot(int id); + + Slot CurrentSlot(int id); + + void AccumulateFreeSlots(FreespaceCommitter freespaceCommitter, bool forFreespace + ); + + void Rollback(); + + void Clear(); + + bool IsDeleted(int id); + + void NotifySlotUpdated(int id, Slot slot, SlotChangeFactory slotChangeFactory); + + void NotifySlotCreated(int id, Slot slot, SlotChangeFactory slotChangeFactory); + + void NotifySlotDeleted(int id, SlotChangeFactory slotChangeFactory); + + int NewId(SlotChangeFactory slotChangeFactory); + + int PrefetchID(); + + void PrefetchedIDConsumed(int id); + + void Close(); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Ids/PointerBasedIdSystem.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Ids/PointerBasedIdSystem.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Ids/PointerBasedIdSystem.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Ids/PointerBasedIdSystem.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,112 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Ids; +using Db4objects.Db4o.Internal.Slots; +using Db4objects.Db4o.Internal.Transactionlog; + +namespace Db4objects.Db4o.Internal.Ids +{ + /// + public sealed class PointerBasedIdSystem : IIdSystem + { + internal readonly TransactionLogHandler _transactionLogHandler; + + private readonly LocalObjectContainer _container; + + public PointerBasedIdSystem(LocalObjectContainer container) + { + _container = container; + _transactionLogHandler = NewTransactionLogHandler(container); + } + + public int NewId() + { + return _container.AllocatePointerSlot(); + } + + public Slot CommittedSlot(int id) + { + return _container.ReadPointerSlot(id); + } + + public void Commit(IVisitable slotChanges, FreespaceCommitter freespaceCommitter) + { + Slot reservedSlot = _transactionLogHandler.AllocateSlot(false, CountSlotChanges(slotChanges + )); + freespaceCommitter.Commit(); + _transactionLogHandler.ApplySlotChanges(slotChanges, CountSlotChanges(slotChanges + ), reservedSlot); + } + + private int CountSlotChanges(IVisitable slotChanges) + { + IntByRef slotChangeCount = new IntByRef(); + slotChanges.Accept(new _IVisitor4_40(slotChangeCount)); + return slotChangeCount.value; + } + + private sealed class _IVisitor4_40 : IVisitor4 + { + public _IVisitor4_40(IntByRef slotChangeCount) + { + this.slotChangeCount = slotChangeCount; + } + + public void Visit(object slotChange) + { + if (((SlotChange)slotChange).SlotModified()) + { + slotChangeCount.value++; + } + } + + private readonly IntByRef slotChangeCount; + } + + public void ReturnUnusedIds(IVisitable visitable) + { + visitable.Accept(new _IVisitor4_51(this)); + } + + private sealed class _IVisitor4_51 : IVisitor4 + { + public _IVisitor4_51(PointerBasedIdSystem _enclosing) + { + this._enclosing = _enclosing; + } + + public void Visit(object id) + { + this._enclosing._container.Free((((int)id)), Const4.PointerLength); + } + + private readonly PointerBasedIdSystem _enclosing; + } + + private TransactionLogHandler NewTransactionLogHandler(LocalObjectContainer container + ) + { + bool fileBased = container.Config().FileBasedTransactionLog() && container is IoAdaptedObjectContainer; + if (!fileBased) + { + return new EmbeddedTransactionLogHandler(container); + } + string fileName = ((IoAdaptedObjectContainer)container).FileName(); + return new FileBasedTransactionLogHandler(container, fileName); + } + + public void Close() + { + _transactionLogHandler.Close(); + } + + public void CompleteInterruptedTransaction(int transactionId1, int transactionId2 + ) + { + _transactionLogHandler.CompleteInterruptedTransaction(transactionId1, transactionId2 + ); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Ids/SequentialIdGenerator.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Ids/SequentialIdGenerator.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Ids/SequentialIdGenerator.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Ids/SequentialIdGenerator.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,115 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Ext; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal; + +namespace Db4objects.Db4o.Internal.Ids +{ + /// + public class SequentialIdGenerator + { + private readonly int _minValidId; + + private readonly int _maxValidId; + + private int _idGenerator; + + private bool _overflow; + + private int _lastIdGenerator; + + private readonly IFunction4 _findFreeId; + + public SequentialIdGenerator(IFunction4 findFreeId, int initialValue, int minValidId + , int maxValidId) + { + _findFreeId = findFreeId; + _minValidId = minValidId; + _maxValidId = maxValidId; + InitializeGenerator(initialValue); + } + + public SequentialIdGenerator(IFunction4 findFreeId, int minValidId, int maxValidId + ) : this(findFreeId, minValidId - 1, minValidId, maxValidId) + { + } + + public virtual void Read(ByteArrayBuffer buffer) + { + InitializeGenerator(buffer.ReadInt()); + } + + private void InitializeGenerator(int val) + { + if (val < 0) + { + _overflow = true; + _idGenerator = -val; + } + else + { + _idGenerator = val; + } + _lastIdGenerator = _idGenerator; + } + + public virtual void Write(ByteArrayBuffer buffer) + { + buffer.WriteInt(PersistentGeneratorValue()); + } + + public virtual int PersistentGeneratorValue() + { + return _overflow ? -_idGenerator : _idGenerator; + } + + public virtual int NewId() + { + AdjustIdGenerator(_idGenerator); + if (!_overflow) + { + return _idGenerator; + } + int id = (((int)_findFreeId.Apply(_idGenerator))); + if (id > 0) + { + AdjustIdGenerator(id - 1); + return id; + } + id = (((int)_findFreeId.Apply(_minValidId))); + if (id > 0) + { + AdjustIdGenerator(id - 1); + return id; + } + throw new Db4oFatalException("Out of IDs"); + } + + private void AdjustIdGenerator(int id) + { + if (id == _maxValidId) + { + _idGenerator = _minValidId; + _overflow = true; + return; + } + _idGenerator = id + 1; + } + + public virtual int MarshalledLength() + { + return Const4.IntLength; + } + + public virtual bool IsDirty() + { + return _idGenerator != _lastIdGenerator; + } + + public virtual void SetClean() + { + _lastIdGenerator = _idGenerator; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Ids/StandardIdSystemFactory.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Ids/StandardIdSystemFactory.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Ids/StandardIdSystemFactory.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Ids/StandardIdSystemFactory.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,85 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Config; +using Db4objects.Db4o.Ext; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Ids; + +namespace Db4objects.Db4o.Internal.Ids +{ + /// + public class StandardIdSystemFactory + { + public const byte Legacy = 0; + + public const byte PointerBased = 1; + + public const byte StackedBtree = 2; + + public const byte Default = StackedBtree; + + public const byte InMemory = 3; + + public const byte Custom = 4; + + public const byte SingleBtree = 5; + + public static IIdSystem NewInstance(LocalObjectContainer localContainer) + { + SystemData systemData = localContainer.SystemData(); + byte idSystemType = systemData.IdSystemType(); + switch (idSystemType) + { + case Legacy: + { + return new PointerBasedIdSystem(localContainer); + } + + case PointerBased: + { + return new PointerBasedIdSystem(localContainer); + } + + case StackedBtree: + { + InMemoryIdSystem inMemoryIdSystem = new InMemoryIdSystem(localContainer); + BTreeIdSystem bTreeIdSystem = new BTreeIdSystem(localContainer, inMemoryIdSystem); + systemData.FreespaceIdSystem(bTreeIdSystem.FreespaceIdSystem()); + return new BTreeIdSystem(localContainer, bTreeIdSystem); + } + + case SingleBtree: + { + InMemoryIdSystem smallInMemoryIdSystem = new InMemoryIdSystem(localContainer); + BTreeIdSystem smallBTreeIdSystem = new BTreeIdSystem(localContainer, smallInMemoryIdSystem + ); + systemData.FreespaceIdSystem(smallBTreeIdSystem.FreespaceIdSystem()); + return smallBTreeIdSystem; + } + + case InMemory: + { + return new InMemoryIdSystem(localContainer); + } + + case Custom: + { + IIdSystemFactory customIdSystemFactory = localContainer.ConfigImpl.CustomIdSystemFactory + (); + if (customIdSystemFactory == null) + { + throw new Db4oFatalException("Custom IdSystem configured but no factory was found. See IdSystemConfiguration#useCustomSystem()" + ); + } + return customIdSystemFactory.NewInstance(localContainer); + } + + default: + { + return new PointerBasedIdSystem(localContainer); + break; + } + } + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Ids/TransactionalIdSystemImpl.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Ids/TransactionalIdSystemImpl.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Ids/TransactionalIdSystemImpl.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Ids/TransactionalIdSystemImpl.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,239 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Ids; +using Db4objects.Db4o.Internal.Slots; + +namespace Db4objects.Db4o.Internal.Ids +{ + /// + public class TransactionalIdSystemImpl : ITransactionalIdSystem + { + private IdSlotChanges _slotChanges; + + private Db4objects.Db4o.Internal.Ids.TransactionalIdSystemImpl _parentIdSystem; + + private readonly IClosure4 _globalIdSystem; + + public TransactionalIdSystemImpl(IClosure4 freespaceManager, IClosure4 globalIdSystem + , Db4objects.Db4o.Internal.Ids.TransactionalIdSystemImpl parentIdSystem) + { + _globalIdSystem = globalIdSystem; + _slotChanges = new IdSlotChanges(this, freespaceManager); + _parentIdSystem = parentIdSystem; + } + + public virtual void CollectCallBackInfo(ICallbackInfoCollector collector) + { + if (!_slotChanges.IsDirty()) + { + return; + } + _slotChanges.TraverseSlotChanges(new _IVisitor4_31(collector)); + } + + private sealed class _IVisitor4_31 : IVisitor4 + { + public _IVisitor4_31(ICallbackInfoCollector collector) + { + this.collector = collector; + } + + public void Visit(object slotChange) + { + int id = ((TreeInt)slotChange)._key; + if (((SlotChange)slotChange).IsDeleted()) + { + if (!((SlotChange)slotChange).IsNew()) + { + collector.Deleted(id); + } + } + else + { + if (((SlotChange)slotChange).IsNew()) + { + collector.Added(id); + } + else + { + collector.Updated(id); + } + } + } + + private readonly ICallbackInfoCollector collector; + } + + public virtual bool IsDirty() + { + return _slotChanges.IsDirty(); + } + + public virtual void Commit(FreespaceCommitter freespaceCommitter) + { + IVisitable slotChangeVisitable = new _IVisitable_52(this); + freespaceCommitter.TransactionalIdSystem(this); + AccumulateFreeSlots(freespaceCommitter, false); + GlobalIdSystem().Commit(slotChangeVisitable, freespaceCommitter); + } + + private sealed class _IVisitable_52 : IVisitable + { + public _IVisitable_52(TransactionalIdSystemImpl _enclosing) + { + this._enclosing = _enclosing; + } + + public void Accept(IVisitor4 visitor) + { + this._enclosing.TraverseSlotChanges(visitor); + } + + private readonly TransactionalIdSystemImpl _enclosing; + } + + public virtual void AccumulateFreeSlots(FreespaceCommitter accumulator, bool forFreespace + ) + { + _slotChanges.AccumulateFreeSlots(accumulator, forFreespace, IsSystemIdSystem()); + if (_parentIdSystem != null) + { + _parentIdSystem.AccumulateFreeSlots(accumulator, forFreespace); + } + } + + private bool IsSystemIdSystem() + { + return _parentIdSystem == null; + } + + public virtual void CompleteInterruptedTransaction(int transactionId1, int transactionId2 + ) + { + GlobalIdSystem().CompleteInterruptedTransaction(transactionId1, transactionId2); + } + + public virtual Slot CommittedSlot(int id) + { + if (id == 0) + { + return null; + } + return GlobalIdSystem().CommittedSlot(id); + } + + public virtual Slot CurrentSlot(int id) + { + Slot slot = ModifiedSlot(id); + if (slot != null) + { + return slot; + } + return CommittedSlot(id); + } + + public virtual Slot ModifiedSlot(int id) + { + if (id == 0) + { + return null; + } + SlotChange change = _slotChanges.FindSlotChange(id); + if (change != null) + { + if (change.SlotModified()) + { + return change.NewSlot(); + } + } + return ModifiedSlotInParentIdSystem(id); + } + + public Slot ModifiedSlotInParentIdSystem(int id) + { + if (_parentIdSystem == null) + { + return null; + } + return _parentIdSystem.ModifiedSlot(id); + } + + public virtual void Rollback() + { + _slotChanges.Rollback(); + } + + public virtual void Clear() + { + _slotChanges.Clear(); + } + + public virtual bool IsDeleted(int id) + { + return _slotChanges.IsDeleted(id); + } + + public virtual void NotifySlotUpdated(int id, Slot slot, SlotChangeFactory slotChangeFactory + ) + { + _slotChanges.NotifySlotUpdated(id, slot, slotChangeFactory); + } + + private void TraverseSlotChanges(IVisitor4 visitor) + { + if (_parentIdSystem != null) + { + _parentIdSystem.TraverseSlotChanges(visitor); + } + _slotChanges.TraverseSlotChanges(visitor); + } + + public virtual int NewId(SlotChangeFactory slotChangeFactory) + { + int id = AcquireId(); + _slotChanges.ProduceSlotChange(id, slotChangeFactory).NotifySlotCreated(null); + return id; + } + + private int AcquireId() + { + return GlobalIdSystem().NewId(); + } + + public virtual int PrefetchID() + { + int id = AcquireId(); + _slotChanges.AddPrefetchedID(id); + return id; + } + + public virtual void PrefetchedIDConsumed(int id) + { + _slotChanges.PrefetchedIDConsumed(id); + } + + public virtual void NotifySlotCreated(int id, Slot slot, SlotChangeFactory slotChangeFactory + ) + { + _slotChanges.NotifySlotCreated(id, slot, slotChangeFactory); + } + + public virtual void NotifySlotDeleted(int id, SlotChangeFactory slotChangeFactory + ) + { + _slotChanges.NotifySlotDeleted(id, slotChangeFactory); + } + + private IIdSystem GlobalIdSystem() + { + return ((IIdSystem)_globalIdSystem.Run()); + } + + public virtual void Close() + { + _slotChanges.FreePrefetchedIDs(GlobalIdSystem()); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Ids/TransportIdSystem.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Ids/TransportIdSystem.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Ids/TransportIdSystem.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Ids/TransportIdSystem.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,103 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Ids; +using Db4objects.Db4o.Internal.Slots; + +namespace Db4objects.Db4o.Internal.Ids +{ + /// + public sealed class TransportIdSystem : ITransactionalIdSystem + { + private readonly LocalObjectContainer _container; + + public TransportIdSystem(LocalObjectContainer localObjectContainer) + { + _container = localObjectContainer; + } + + public int NewId(SlotChangeFactory slotChangeFactory) + { + return _container.AllocatePointerSlot(); + } + + public void NotifySlotCreated(int id, Slot slot, SlotChangeFactory slotChangeFactory + ) + { + WritePointer(id, slot); + } + + private void WritePointer(int id, Slot slot) + { + _container.WritePointer(id, slot); + } + + public void NotifySlotUpdated(int id, Slot slot, SlotChangeFactory slotChangeFactory + ) + { + WritePointer(id, slot); + } + + public void NotifySlotDeleted(int id, SlotChangeFactory slotChangeFactory) + { + WritePointer(id, Slot.Zero); + } + + public void Commit(FreespaceCommitter accumulator) + { + } + + // don't do anything + public Slot CurrentSlot(int id) + { + return CommittedSlot(id); + } + + public void CollectCallBackInfo(ICallbackInfoCollector collector) + { + } + + // do nothing + public void Clear() + { + } + + // TODO Auto-generated method stub + public Slot CommittedSlot(int id) + { + return _container.ReadPointerSlot(id); + } + + public bool IsDeleted(int id) + { + return false; + } + + public bool IsDirty() + { + return false; + } + + public int PrefetchID() + { + return 0; + } + + public void PrefetchedIDConsumed(int id) + { + } + + public void Rollback() + { + } + + public void Close() + { + } + + public void AccumulateFreeSlots(FreespaceCommitter freespaceCommitter, bool forFreespace + ) + { + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/IEventDispatcher.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/IEventDispatcher.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/IEventDispatcher.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/IEventDispatcher.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,13 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal; + +namespace Db4objects.Db4o.Internal +{ + public interface IEventDispatcher + { + bool Dispatch(Transaction trans, object obj, int eventID); + + bool HasEventRegistered(int eventID); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/IIndexable4.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/IIndexable4.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/IIndexable4.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/IIndexable4.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,17 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Marshall; + +namespace Db4objects.Db4o.Internal +{ + /// + public interface IIndexable4 : IComparable4, ILinkLengthAware + { + object ReadIndexEntry(IContext context, ByteArrayBuffer reader); + + void WriteIndexEntry(IContext context, ByteArrayBuffer writer, object obj); + + void DefragIndexEntry(DefragmentContextImpl context); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/IIndexableTypeHandler.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/IIndexableTypeHandler.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/IIndexableTypeHandler.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/IIndexableTypeHandler.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,23 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Marshall; +using Db4objects.Db4o.Marshall; +using Db4objects.Db4o.Typehandlers; + +namespace Db4objects.Db4o.Internal +{ + /// + public interface IIndexableTypeHandler : IIndexable4, ITypeHandler4 + { + object IndexEntryToObject(IContext context, object indexEntry); + + /// + /// + object ReadIndexEntryFromObjectSlot(MarshallerFamily mf, StatefulBuffer writer); + + /// + /// + object ReadIndexEntry(IObjectIdContext context); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/IInternalObjectContainer.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/IInternalObjectContainer.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/IInternalObjectContainer.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/IInternalObjectContainer.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,66 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System.Collections; +using Db4objects.Db4o.Ext; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Activation; +using Db4objects.Db4o.Internal.Callbacks; +using Db4objects.Db4o.Internal.Events; +using Db4objects.Db4o.Internal.Query; +using Db4objects.Db4o.Reflect; + +namespace Db4objects.Db4o.Internal +{ + /// + public partial interface IInternalObjectContainer : IExtObjectContainer + { + void Callbacks(ICallbacks cb); + + ICallbacks Callbacks(); + + ObjectContainerBase Container + { + get; + } + + Db4objects.Db4o.Internal.Transaction Transaction + { + get; + } + + NativeQueryHandler GetNativeQueryHandler(); + + ClassMetadata ClassMetadataForReflectClass(IReflectClass reflectClass); + + ClassMetadata ClassMetadataForName(string name); + + ClassMetadata ClassMetadataForID(int id); + + HandlerRegistry Handlers + { + get; + } + + Config4Impl ConfigImpl + { + get; + } + + object SyncExec(IClosure4 block); + + int InstanceCount(ClassMetadata clazz, Db4objects.Db4o.Internal.Transaction trans + ); + + bool IsClient + { + get; + } + + void StoreAll(Db4objects.Db4o.Internal.Transaction trans, IEnumerator objects); + + IUpdateDepthProvider UpdateDepthProvider(); + + EventRegistryImpl NewEventRegistry(); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/ILinkLengthAware.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/ILinkLengthAware.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/ILinkLengthAware.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/ILinkLengthAware.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,9 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +namespace Db4objects.Db4o.Internal +{ + public interface ILinkLengthAware + { + int LinkLength(); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/IllegalComparisonException.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/IllegalComparisonException.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/IllegalComparisonException.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/IllegalComparisonException.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,12 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Ext; + +namespace Db4objects.Db4o.Internal +{ + /// + [System.Serializable] + public class IllegalComparisonException : Db4oRecoverableException + { + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/IModificationAware.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/IModificationAware.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/IModificationAware.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/IModificationAware.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,10 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +namespace Db4objects.Db4o.Internal +{ + /// + public interface IModificationAware + { + bool IsModified(object obj); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/InCallback.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/InCallback.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/InCallback.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/InCallback.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,35 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Foundation; +using Sharpen.Lang; + +namespace Db4objects.Db4o.Internal +{ + /// + public class InCallback + { + private sealed class _DynamicVariable_12 : DynamicVariable + { + public _DynamicVariable_12() + { + } + + protected override object DefaultValue() + { + return false; + } + } + + private static readonly DynamicVariable _inCallback = new _DynamicVariable_12(); + + public static bool Value() + { + return (((bool)_inCallback.Value)); + } + + public static void Run(IRunnable runnable) + { + _inCallback.With(true, runnable); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/InterfaceTypeHandler.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/InterfaceTypeHandler.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/InterfaceTypeHandler.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/InterfaceTypeHandler.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,18 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal; + +namespace Db4objects.Db4o.Internal +{ + public sealed class InterfaceTypeHandler : OpenTypeHandler + { + public InterfaceTypeHandler(ObjectContainerBase container) : base(container) + { + } + + public override bool Equals(object obj) + { + return obj is Db4objects.Db4o.Internal.InterfaceTypeHandler; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/IntMatcher.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/IntMatcher.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/IntMatcher.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/IntMatcher.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,54 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal; + +namespace Db4objects.Db4o.Internal +{ + /// + public abstract class IntMatcher + { + public abstract bool Match(int i); + + private sealed class _IntMatcher_13 : IntMatcher + { + public _IntMatcher_13() + { + } + + public override bool Match(int i) + { + return i == 0; + } + } + + public static readonly IntMatcher Zero = new _IntMatcher_13(); + + private sealed class _IntMatcher_19 : IntMatcher + { + public _IntMatcher_19() + { + } + + public override bool Match(int i) + { + return i > 0; + } + } + + public static readonly IntMatcher Positive = new _IntMatcher_19(); + + private sealed class _IntMatcher_25 : IntMatcher + { + public _IntMatcher_25() + { + } + + public override bool Match(int i) + { + return i < 0; + } + } + + public static readonly IntMatcher Negative = new _IntMatcher_25(); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/IO/BlockSizeImpl.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/IO/BlockSizeImpl.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/IO/BlockSizeImpl.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/IO/BlockSizeImpl.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,31 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.IO; + +namespace Db4objects.Db4o.Internal.IO +{ + public class BlockSizeImpl : IBlockSize + { + private readonly ListenerRegistry _listenerRegistry = ListenerRegistry.NewInstance + (); + + private int _value; + + public virtual void Register(IListener4 listener) + { + _listenerRegistry.Register(listener); + } + + public virtual void Set(int newValue) + { + _value = newValue; + _listenerRegistry.NotifyListeners(_value); + } + + public virtual int Value() + { + return _value; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/IoAdaptedObjectContainer.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/IoAdaptedObjectContainer.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/IoAdaptedObjectContainer.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/IoAdaptedObjectContainer.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,441 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using System.IO; +using Db4objects.Db4o; +using Db4objects.Db4o.Config; +using Db4objects.Db4o.Ext; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.IO; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Slots; +using Sharpen.Lang; + +namespace Db4objects.Db4o.Internal +{ + /// + public class IoAdaptedObjectContainer : LocalObjectContainer, IEmbeddedObjectContainer + { + private readonly string _fileName; + + private BlockAwareBin _file; + + private volatile BlockAwareBin _backupFile; + + private object _fileLock; + + private readonly IFreespaceFiller _freespaceFiller; + + /// + internal IoAdaptedObjectContainer(IConfiguration config, string fileName) : base( + config) + { + _fileLock = new object(); + _fileName = fileName; + _freespaceFiller = CreateFreespaceFiller(); + Open(); + } + + /// + /// + protected sealed override void OpenImpl() + { + Config4Impl configImpl = ConfigImpl; + IStorage storage = configImpl.Storage; + bool isNew = !storage.Exists(FileName()); + if (isNew) + { + LogMsg(14, FileName()); + CheckReadOnly(); + _handlers.OldEncryptionOff(); + } + bool readOnly = configImpl.IsReadOnly(); + bool lockFile = Debug4.lockFile && configImpl.LockFile() && (!readOnly); + if (NeedsLockFileThread()) + { + IBin fileBin = storage.Open(new BinConfiguration(FileName(), false, 0, false, configImpl + .BlockSize())); + IBin synchronizedBin = new SynchronizedBin(fileBin); + _file = new BlockAwareBin(synchronizedBin); + } + else + { + IBin bin = storage.Open(new BinConfiguration(FileName(), lockFile, 0, readOnly, configImpl + .BlockSize())); + if (configImpl.AsynchronousSync()) + { + bin = new ThreadedSyncBin(bin); + } + _file = new BlockAwareBin(bin); + } + if (isNew) + { + ConfigureNewFile(); + if (configImpl.ReservedStorageSpace() > 0) + { + Reserve(configImpl.ReservedStorageSpace()); + } + CommitTransaction(); + WriteHeader(true, false); + } + else + { + ReadThis(); + } + } + + /// + /// + public override void Backup(IStorage targetStorage, string path) + { + WithEnvironment(new _IRunnable_76(this, targetStorage, path)); + } + + private sealed class _IRunnable_76 : IRunnable + { + public _IRunnable_76(IoAdaptedObjectContainer _enclosing, IStorage targetStorage, + string path) + { + this._enclosing = _enclosing; + this.targetStorage = targetStorage; + this.path = path; + } + + public void Run() + { + lock (this._enclosing._lock) + { + this._enclosing.CheckClosed(); + if (this._enclosing._backupFile != null) + { + throw new BackupInProgressException(); + } + this._enclosing._backupFile = new BlockAwareBin(targetStorage.Open(new BinConfiguration + (path, true, this._enclosing._file.Length(), false, this._enclosing._blockConverter + .BlocksToBytes(1)))); + } + long pos = 0; + byte[] buffer = new byte[8192]; + while (true) + { + lock (this._enclosing._lock) + { + int read = this._enclosing._file.Read(pos, buffer); + if (read <= 0) + { + break; + } + this._enclosing._backupFile.Write(pos, buffer, read); + pos += read; + } + // Let the database engine continue to do + // some work if it likes to. + Runtime4.Sleep(1); + } + lock (this._enclosing._lock) + { + try + { + Db4objects.Db4o.Internal.IoAdaptedObjectContainer.SyncAndClose(this._enclosing._backupFile + ); + } + finally + { + this._enclosing._backupFile = null; + } + } + } + + private readonly IoAdaptedObjectContainer _enclosing; + + private readonly IStorage targetStorage; + + private readonly string path; + } + + public override void BlockSize(int size) + { + CreateBlockConverter(size); + _file.BlockSize(size); + } + + public override byte BlockSize() + { + return (byte)_file.BlockSize(); + } + + protected override void ShutdownDataStorage() + { + lock (_fileLock) + { + try + { + CloseFileHeader(); + } + finally + { + CloseDatabaseFile(); + } + } + } + + private void CloseDatabaseFile() + { + try + { + SyncAndClose(_file); + } + finally + { + _file = null; + } + } + + private static void SyncAndClose(IBin bin) + { + if (bin != null) + { + try + { + bin.Sync(); + } + finally + { + bin.Close(); + } + } + } + + private void CloseFileHeader() + { + try + { + if (_fileHeader != null) + { + _fileHeader.Close(); + } + } + finally + { + _fileHeader = null; + } + } + + public override void CloseTransaction(Transaction transaction, bool isSystemTransaction + , bool rollbackOnClose) + { + transaction.Close(rollbackOnClose); + } + + public override void Commit1(Transaction trans) + { + EnsureLastSlotWritten(); + base.Commit1(trans); + } + + private void CheckXBytes(int newAddress, int newAddressOffset, int length) + { + if (Debug4.xbytes && Deploy.overwrite) + { + try + { + byte[] checkXBytes = new byte[length]; + _file.BlockRead(newAddress, newAddressOffset, checkXBytes); + for (int i = 0; i < checkXBytes.Length; i++) + { + if (checkXBytes[i] != Const4.Xbyte) + { + string msg = "XByte corruption adress:" + newAddress + " length:" + length + " starting:" + + i; + throw new Db4oException(msg); + } + } + } + catch (Exception e) + { + Sharpen.Runtime.PrintStackTrace(e); + } + } + } + + public override long FileLength() + { + return _file.Length(); + } + + public override string FileName() + { + return _fileName; + } + + /// + public override void ReadBytes(byte[] bytes, int address, int length) + { + ReadBytes(bytes, address, 0, length); + } + + /// + public override void ReadBytes(byte[] bytes, int address, int addressOffset, int + length) + { + if (DTrace.enabled) + { + DTrace.ReadBytes.LogLength(address + addressOffset, length); + } + int bytesRead = _file.BlockRead(address, addressOffset, bytes, length); + CheckReadCount(bytesRead, length); + } + + private void CheckReadCount(int bytesRead, int expected) + { + if (bytesRead != expected) + { + throw new IncompatibleFileFormatException(); + } + } + + /// + public override void Reserve(int byteCount) + { + CheckReadOnly(); + lock (_lock) + { + Slot slot = AllocateSlot(byteCount); + ZeroReservedSlot(slot); + Free(slot); + } + } + + private void ZeroReservedSlot(Slot slot) + { + ZeroFile(_file, slot); + ZeroFile(_backupFile, slot); + } + + private void ZeroFile(BlockAwareBin io, Slot slot) + { + if (io == null) + { + return; + } + byte[] zeroBytes = new byte[1024]; + int left = slot.Length(); + int offset = 0; + while (left > zeroBytes.Length) + { + io.BlockWrite(slot.Address(), offset, zeroBytes, zeroBytes.Length); + offset += zeroBytes.Length; + left -= zeroBytes.Length; + } + if (left > 0) + { + io.BlockWrite(slot.Address(), offset, zeroBytes, left); + } + } + + public override void SyncFiles() + { + _file.Sync(); + } + + public override void SyncFiles(IRunnable runnable) + { + _file.Sync(runnable); + } + + public override void WriteBytes(ByteArrayBuffer buffer, int blockedAddress, int addressOffset + ) + { + if (Deploy.debug && !Deploy.flush) + { + return; + } + if (Debug4.xbytes && Deploy.overwrite) + { + if (buffer.CheckXBytes()) + { + CheckXBytes(blockedAddress, addressOffset, buffer.Length()); + } + else + { + buffer.CheckXBytes(true); + } + } + if (DTrace.enabled) + { + DTrace.WriteBytes.LogLength(blockedAddress + addressOffset, buffer.Length()); + } + _file.BlockWrite(blockedAddress, addressOffset, buffer._buffer, buffer.Length()); + if (_backupFile != null) + { + _backupFile.BlockWrite(blockedAddress, addressOffset, buffer._buffer, buffer.Length + ()); + } + } + + public override void OverwriteDeletedBytes(int address, int length) + { + if (_freespaceFiller == null) + { + return; + } + if (address > 0 && length > 0) + { + if (DTrace.enabled) + { + DTrace.WriteXbytes.LogLength(address, length); + } + BlockAwareBinWindow window = new BlockAwareBinWindow(_file, address, length); + try + { + CreateFreespaceFiller().Fill(window); + } + catch (IOException e) + { + Sharpen.Runtime.PrintStackTrace(e); + } + finally + { + window.Disable(); + } + } + } + + public virtual BlockAwareBin TimerFile() + { + return _file; + } + + private IFreespaceFiller CreateFreespaceFiller() + { + return Config().FreespaceFiller(); + } + + private class XByteFreespaceFiller : IFreespaceFiller + { + /// + public virtual void Fill(BlockAwareBinWindow io) + { + io.Write(0, XBytes(io.Length())); + } + + private byte[] XBytes(int len) + { + byte[] bytes = new byte[len]; + for (int i = 0; i < len; i++) + { + bytes[i] = Const4.Xbyte; + } + return bytes; + } + } + + protected override void FatalStorageShutdown() + { + if (_file != null) + { + _file.Close(); + } + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/IObjectContainerSpec.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/IObjectContainerSpec.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/IObjectContainerSpec.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/IObjectContainerSpec.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,16 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +namespace Db4objects.Db4o.Internal +{ + /// Workaround to provide the Java 5 version with a hook to add ExtObjectContainer. + /// + /// + /// Workaround to provide the Java 5 version with a hook to add ExtObjectContainer. + /// (Generic method declarations won't match ungenerified YapStreamBase implementations + /// otherwise and implementing it directly kills .NET conversion.) + /// + /// + public interface IObjectContainerSpec + { + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/IPersistent.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/IPersistent.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/IPersistent.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/IPersistent.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,18 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal; + +namespace Db4objects.Db4o.Internal +{ + /// + public interface IPersistent + { + byte GetIdentifier(); + + int OwnLength(); + + void ReadThis(Transaction trans, ByteArrayBuffer reader); + + void WriteThis(Transaction trans, ByteArrayBuffer writer); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/IQueryResultIteratorFactory.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/IQueryResultIteratorFactory.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/IQueryResultIteratorFactory.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/IQueryResultIteratorFactory.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,12 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System.Collections; +using Db4objects.Db4o.Internal.Query.Result; + +namespace Db4objects.Db4o.Internal +{ + public interface IQueryResultIteratorFactory + { + IEnumerator NewInstance(AbstractQueryResult result); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/IReadable.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/IReadable.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/IReadable.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/IReadable.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,14 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal; + +namespace Db4objects.Db4o.Internal +{ + /// + public interface IReadable + { + object Read(ByteArrayBuffer buffer); + + int MarshalledLength(); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/IReadsObjectIds.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/IReadsObjectIds.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/IReadsObjectIds.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/IReadsObjectIds.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,13 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Marshall; + +namespace Db4objects.Db4o.Internal +{ + /// + public interface IReadsObjectIds + { + ObjectID ReadObjectID(IInternalReadContext context); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/IReadWriteable.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/IReadWriteable.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/IReadWriteable.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/IReadWriteable.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,12 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal; + +namespace Db4objects.Db4o.Internal +{ + /// + public interface IReadWriteable : IReadable + { + void Write(ByteArrayBuffer buffer); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/IReadWriteBuffer.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/IReadWriteBuffer.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/IReadWriteBuffer.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/IReadWriteBuffer.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,20 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Marshall; + +namespace Db4objects.Db4o.Internal +{ + /// + public interface IReadWriteBuffer : IReadBuffer, IWriteBuffer + { + void IncrementOffset(int numBytes); + + void IncrementIntSize(); + + int Length(); + + void ReadBegin(byte identifier); + + void ReadEnd(); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/ISlotCopyHandler.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/ISlotCopyHandler.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/ISlotCopyHandler.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/ISlotCopyHandler.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,12 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal; + +namespace Db4objects.Db4o.Internal +{ + /// + public interface ISlotCopyHandler + { + void ProcessCopy(DefragmentContextImpl context); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/ITransactionParticipant.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/ITransactionParticipant.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/ITransactionParticipant.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/ITransactionParticipant.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,16 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal; + +namespace Db4objects.Db4o.Internal +{ + /// + public interface ITransactionParticipant + { + void Commit(Transaction transaction); + + void Rollback(Transaction transaction); + + void Dispose(Transaction transaction); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/IVersionedTypeHandler.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/IVersionedTypeHandler.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/IVersionedTypeHandler.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/IVersionedTypeHandler.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,13 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Typehandlers; + +namespace Db4objects.Db4o.Internal +{ + /// + public interface IVersionedTypeHandler : ITypeHandler4, IDeepClone + { + ITypeHandler4 UnversionedTemplate(); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/LazyObjectReference.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/LazyObjectReference.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/LazyObjectReference.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/LazyObjectReference.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,68 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Ext; +using Db4objects.Db4o.Internal; + +namespace Db4objects.Db4o.Internal +{ + /// + public class LazyObjectReference : IObjectInfo + { + private readonly Transaction _transaction; + + private readonly int _id; + + public LazyObjectReference(Transaction transaction, int id) + { + _transaction = transaction; + _id = id; + } + + public virtual long GetInternalID() + { + return _id; + } + + public virtual object GetObject() + { + lock (ContainerLock()) + { + return Reference().GetObject(); + } + } + + public virtual Db4oUUID GetUUID() + { + lock (ContainerLock()) + { + return Reference().GetUUID(); + } + } + + public virtual long GetVersion() + { + return GetCommitTimestamp(); + } + + public virtual long GetCommitTimestamp() + { + lock (ContainerLock()) + { + return Reference().GetCommitTimestamp(); + } + } + + public virtual ObjectReference Reference() + { + HardObjectReference hardRef = _transaction.Container().GetHardObjectReferenceById + (_transaction, _id); + return hardRef._reference; + } + + private object ContainerLock() + { + _transaction.Container().CheckClosed(); + return _transaction.Container().Lock(); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/LocalObjectContainer.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/LocalObjectContainer.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/LocalObjectContainer.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/LocalObjectContainer.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,1146 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using System.Collections; +using Db4objects.Db4o; +using Db4objects.Db4o.Config; +using Db4objects.Db4o.Ext; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Btree; +using Db4objects.Db4o.Internal.Convert; +using Db4objects.Db4o.Internal.Events; +using Db4objects.Db4o.Internal.Fileheader; +using Db4objects.Db4o.Internal.Freespace; +using Db4objects.Db4o.Internal.Ids; +using Db4objects.Db4o.Internal.Qlin; +using Db4objects.Db4o.Internal.Query.Processor; +using Db4objects.Db4o.Internal.Query.Result; +using Db4objects.Db4o.Internal.References; +using Db4objects.Db4o.Internal.Slots; +using Db4objects.Db4o.Qlin; +using Sharpen; +using Sharpen.Lang; + +namespace Db4objects.Db4o.Internal +{ + /// + public abstract class LocalObjectContainer : ExternalObjectContainer, IInternalObjectContainer + , IEmbeddedObjectContainer + { + protected FileHeader _fileHeader; + + private readonly Collection4 _dirtyClassMetadata = new Collection4(); + + private IFreespaceManager _freespaceManager; + + private bool i_isServer = false; + + private Lock4 _semaphoresLock = new Lock4(); + + private Hashtable4 _semaphores; + + private int _blockEndAddress; + + private Db4objects.Db4o.Internal.SystemData _systemData; + + private IIdSystem _idSystem; + + private readonly byte[] _pointerBuffer = new byte[Const4.PointerLength]; + + protected readonly ByteArrayBuffer _pointerIo = new ByteArrayBuffer(Const4.PointerLength + ); + + internal LocalObjectContainer(IConfiguration config) : base(config) + { + } + + public override Transaction NewTransaction(Transaction parentTransaction, IReferenceSystem + referenceSystem, bool isSystemTransaction) + { + ITransactionalIdSystem systemIdSystem = null; + if (!isSystemTransaction) + { + systemIdSystem = SystemTransaction().IdSystem(); + } + IClosure4 idSystem = new _IClosure4_58(this); + ITransactionalIdSystem transactionalIdSystem = NewTransactionalIdSystem(systemIdSystem + , idSystem); + return new LocalTransaction(this, parentTransaction, transactionalIdSystem, referenceSystem + ); + } + + private sealed class _IClosure4_58 : IClosure4 + { + public _IClosure4_58(LocalObjectContainer _enclosing) + { + this._enclosing = _enclosing; + } + + public object Run() + { + return this._enclosing.IdSystem(); + } + + private readonly LocalObjectContainer _enclosing; + } + + public virtual ITransactionalIdSystem NewTransactionalIdSystem(ITransactionalIdSystem + systemIdSystem, IClosure4 idSystem) + { + return new TransactionalIdSystemImpl(new _IClosure4_69(this), idSystem, (TransactionalIdSystemImpl + )systemIdSystem); + } + + private sealed class _IClosure4_69 : IClosure4 + { + public _IClosure4_69(LocalObjectContainer _enclosing) + { + this._enclosing = _enclosing; + } + + public object Run() + { + return this._enclosing.FreespaceManager(); + } + + private readonly LocalObjectContainer _enclosing; + } + + public virtual IFreespaceManager FreespaceManager() + { + return _freespaceManager; + } + + public virtual void BlockSizeReadFromFile(int size) + { + BlockSize(size); + SetRegularEndAddress(FileLength()); + } + + public virtual void SetRegularEndAddress(long address) + { + _blockEndAddress = _blockConverter.BytesToBlocks(address); + } + + protected sealed override void Close2() + { + try + { + if (!_config.IsReadOnly()) + { + CommitTransaction(); + Shutdown(); + } + } + finally + { + ShutdownObjectContainer(); + } + } + + public override void Commit1(Transaction trans) + { + trans.Commit(); + } + + internal virtual void ConfigureNewFile() + { + BlockSize(ConfigImpl.BlockSize()); + _fileHeader = FileHeader.NewCurrentFileHeader(); + SetRegularEndAddress(_fileHeader.Length()); + NewSystemData(ConfigImpl.FreespaceSystem(), ConfigImpl.IdSystemType()); + SystemData().ConverterVersion(Converter.Version); + CreateStringIO(_systemData.StringEncoding()); + CreateIdSystem(); + InitializeClassMetadataRepository(); + InitalizeWeakReferenceSupport(); + GenerateNewIdentity(); + AbstractFreespaceManager blockedFreespaceManager = AbstractFreespaceManager.CreateNew + (this); + InstallFreespaceManager(blockedFreespaceManager); + InitNewClassCollection(); + InitializeEssentialClasses(); + _fileHeader.InitNew(this); + blockedFreespaceManager.Start(0); + } + + private void NewSystemData(byte freespaceSystemType, byte idSystemType) + { + _systemData = new Db4objects.Db4o.Internal.SystemData(); + _systemData.StringEncoding(ConfigImpl.Encoding()); + _systemData.FreespaceSystem(freespaceSystemType); + _systemData.IdSystemType(idSystemType); + } + + public override int ConverterVersion() + { + return _systemData.ConverterVersion(); + } + + public override long CurrentVersion() + { + return _timeStampIdGenerator.Last(); + } + + internal virtual void InitNewClassCollection() + { + // overridden in YapObjectCarrier to do nothing + ClassCollection().InitTables(1); + } + + public BTree CreateBTreeClassIndex(int id) + { + return new BTree(_transaction, id, new IDHandler()); + } + + public AbstractQueryResult NewQueryResult(Transaction trans) + { + return NewQueryResult(trans, Config().EvaluationMode()); + } + + public sealed override AbstractQueryResult NewQueryResult(Transaction trans, QueryEvaluationMode + mode) + { + if (trans == null) + { + throw new ArgumentNullException(); + } + if (mode == QueryEvaluationMode.Immediate) + { + return new IdListQueryResult(trans); + } + return new HybridQueryResult(trans, mode); + } + + public sealed override bool Delete4(Transaction transaction, ObjectReference @ref + , object obj, int cascade, bool userCall) + { + int id = @ref.GetID(); + StatefulBuffer reader = ReadStatefulBufferById(transaction, id); + if (reader != null) + { + if (obj != null) + { + if ((!ShowInternalClasses()) && Const4.ClassInternal.IsAssignableFrom(obj.GetType + ())) + { + return false; + } + } + reader.SetCascadeDeletes(cascade); + transaction.IdSystem().NotifySlotDeleted(id, SlotChangeFactory.UserObjects); + ClassMetadata classMetadata = @ref.ClassMetadata(); + classMetadata.Delete(reader, obj); + return true; + } + return false; + } + + public abstract long FileLength(); + + public abstract string FileName(); + + public virtual void Free(Slot slot) + { + if (slot.IsNull()) + { + return; + } + // TODO: This should really be an IllegalArgumentException but old database files + // with index-based FreespaceManagers appear to deliver zeroed slots. + // throw new IllegalArgumentException(); + if (_freespaceManager == null) + { + // Can happen on early free before freespacemanager + // is up, during conversion. + return; + } + if (DTrace.enabled) + { + DTrace.FileFree.LogLength(slot.Address(), slot.Length()); + } + _freespaceManager.Free(slot); + } + + public virtual void Free(int address, int a_length) + { + Free(new Slot(address, a_length)); + } + + public virtual void GenerateNewIdentity() + { + lock (_lock) + { + SetIdentity(Db4oDatabase.Generate()); + } + } + + public override AbstractQueryResult QueryAllObjects(Transaction trans) + { + return GetAll(trans, Config().EvaluationMode()); + } + + public virtual AbstractQueryResult GetAll(Transaction trans, QueryEvaluationMode + mode) + { + AbstractQueryResult queryResult = NewQueryResult(trans, mode); + queryResult.LoadFromClassIndexes(ClassCollection().Iterator()); + return queryResult; + } + + public virtual int AllocatePointerSlot() + { + int id = AllocateSlot(Const4.PointerLength).Address(); + if (!IsValidPointer(id)) + { + return AllocatePointerSlot(); + } + // write a zero pointer first + // to prevent delete interaction trouble + WritePointer(id, Slot.Zero); + if (DTrace.enabled) + { + DTrace.GetPointerSlot.Log(id); + } + return id; + } + + protected virtual bool IsValidPointer(int id) + { + // We have to make sure that object IDs do not collide + // with built-in type IDs. + return !_handlers.IsSystemHandler(id); + } + + public virtual Slot AllocateSlot(int length) + { + if (length <= 0) + { + throw new ArgumentException(); + } + if (_freespaceManager != null && _freespaceManager.IsStarted()) + { + Slot slot = _freespaceManager.AllocateSlot(length); + if (slot != null) + { + if (DTrace.enabled) + { + DTrace.GetSlot.LogLength(slot.Address(), slot.Length()); + } + return slot; + } + while (GrowDatabaseByConfiguredSize()) + { + slot = _freespaceManager.AllocateSlot(length); + if (slot != null) + { + if (DTrace.enabled) + { + DTrace.GetSlot.LogLength(slot.Address(), slot.Length()); + } + return slot; + } + } + } + Slot appendedSlot = AppendBytes(length); + if (DTrace.enabled) + { + DTrace.GetSlot.LogLength(appendedSlot.Address(), appendedSlot.Length()); + } + return appendedSlot; + } + + private bool GrowDatabaseByConfiguredSize() + { + int reservedStorageSpace = ConfigImpl.DatabaseGrowthSize(); + if (reservedStorageSpace <= 0) + { + return false; + } + int reservedBlocks = _blockConverter.BytesToBlocks(reservedStorageSpace); + int reservedBytes = _blockConverter.BlocksToBytes(reservedBlocks); + Slot slot = new Slot(_blockEndAddress, reservedBlocks); + if (Debug4.xbytes && Deploy.overwrite) + { + OverwriteDeletedBlockedSlot(slot); + } + else + { + WriteBytes(new ByteArrayBuffer(reservedBytes), _blockEndAddress, 0); + } + _freespaceManager.Free(_blockConverter.ToNonBlockedLength(slot)); + _blockEndAddress += reservedBlocks; + return true; + } + + public Slot AppendBytes(long bytes) + { + int blockCount = _blockConverter.BytesToBlocks(bytes); + int blockedStartAddress = _blockEndAddress; + int blockedEndAddress = _blockEndAddress + blockCount; + CheckBlockedAddress(blockedEndAddress); + _blockEndAddress = blockedEndAddress; + Slot slot = new Slot(blockedStartAddress, blockCount); + if (Debug4.xbytes && Deploy.overwrite) + { + OverwriteDeletedBlockedSlot(slot); + } + return _blockConverter.ToNonBlockedLength(slot); + } + + private void CheckBlockedAddress(int blockedAddress) + { + if (blockedAddress < 0) + { + SwitchToReadOnlyMode(); + throw new DatabaseMaximumSizeReachedException(); + } + } + + private void SwitchToReadOnlyMode() + { + _config.ReadOnly(true); + } + + // When a file gets opened, it uses the file size to determine where + // new slots can be appended. If this method would not be called, the + // freespace system could already contain a slot that points beyond + // the end of the file and this space could be allocated and used twice, + // for instance if a slot was allocated and freed without ever being + // written to file. + internal virtual void EnsureLastSlotWritten() + { + if (_blockEndAddress > _blockConverter.BytesToBlocks(FileLength())) + { + StatefulBuffer writer = CreateStatefulBuffer(SystemTransaction(), _blockEndAddress + - 1, BlockSize()); + writer.Write(); + } + } + + public override Db4oDatabase Identity() + { + return _systemData.Identity(); + } + + public virtual void SetIdentity(Db4oDatabase identity) + { + lock (Lock()) + { + _systemData.Identity(identity); + // The dirty TimeStampIdGenerator triggers writing of + // the variable part of the systemdata. We need to + // make it dirty here, so the new identity is persisted: + _timeStampIdGenerator.Generate(); + _fileHeader.WriteVariablePart(this); + } + } + + internal override bool IsServer() + { + return i_isServer; + } + + public sealed override int IdForNewUserObject(Transaction trans) + { + return trans.IdSystem().NewId(SlotChangeFactory.UserObjects); + } + + public override void RaiseCommitTimestamp(long minimumVersion) + { + lock (Lock()) + { + _timeStampIdGenerator.SetMinimumNext(minimumVersion); + } + } + + public override StatefulBuffer ReadStatefulBufferById(Transaction a_ta, int a_id) + { + return ReadStatefulBufferById(a_ta, a_id, false); + } + + public override ByteArrayBuffer[] ReadSlotBuffers(Transaction transaction, int[] + ids) + { + ByteArrayBuffer[] buffers = new ByteArrayBuffer[ids.Length]; + for (int i = 0; i < ids.Length; ++i) + { + if (ids[i] == 0) + { + buffers[i] = null; + } + else + { + buffers[i] = ReadBufferById(transaction, ids[i]); + } + } + return buffers; + } + + public override ByteArrayBuffer ReadBufferById(Transaction trans, int id) + { + return ReadBufferById(trans, id, false); + } + + public sealed override ByteArrayBuffer ReadBufferById(Transaction trans, int id, + bool lastCommitted) + { + if (id <= 0) + { + throw new ArgumentException(); + } + Slot slot = lastCommitted ? trans.IdSystem().CommittedSlot(id) : trans.IdSystem() + .CurrentSlot(id); + if (DTrace.enabled) + { + DTrace.SlotRead.LogLength(id, slot); + } + return ReadBufferBySlot(slot); + } + + public override StatefulBuffer ReadStatefulBufferById(Transaction trans, int id, + bool lastCommitted) + { + if (id <= 0) + { + throw new ArgumentException(); + } + Slot slot = lastCommitted ? trans.IdSystem().CommittedSlot(id) : trans.IdSystem() + .CurrentSlot(id); + if (DTrace.enabled) + { + DTrace.SlotRead.LogLength(id, slot); + } + return ReadStatefulBufferBySlot(trans, id, slot); + } + + public virtual ByteArrayBuffer ReadBufferBySlot(Slot slot) + { + if (Slot.IsNull(slot)) + { + return null; + } + if (DTrace.enabled) + { + DTrace.ReadSlot.LogLength(slot.Address(), slot.Length()); + } + ByteArrayBuffer buffer = new ByteArrayBuffer(slot.Length()); + buffer.ReadEncrypt(this, slot.Address()); + return buffer; + } + + public virtual StatefulBuffer ReadStatefulBufferBySlot(Transaction trans, int id, + Slot slot) + { + if (Slot.IsNull(slot)) + { + return null; + } + if (DTrace.enabled) + { + DTrace.ReadSlot.LogLength(slot.Address(), slot.Length()); + } + StatefulBuffer buffer = CreateStatefulBuffer(trans, slot.Address(), slot.Length() + ); + buffer.SetID(id); + buffer.ReadEncrypt(this, slot.Address()); + return buffer; + } + + protected override bool DoFinalize() + { + return _fileHeader != null; + } + + /// + internal virtual void ReadThis() + { + NewSystemData(AbstractFreespaceManager.FmLegacyRam, StandardIdSystemFactory.Legacy + ); + BlockSizeReadFromFile(1); + _fileHeader = FileHeader.Read(this); + if (Config().GenerateCommitTimestamps().IsUnspecified()) + { + Config().GenerateCommitTimestamps(_systemData.IdToTimestampIndexId() != 0); + } + CreateStringIO(_systemData.StringEncoding()); + CreateIdSystem(); + InitializeClassMetadataRepository(); + InitalizeWeakReferenceSupport(); + SetNextTimeStampId(SystemData().LastTimeStampID()); + ClassCollection().SetID(_systemData.ClassCollectionID()); + ClassCollection().Read(SystemTransaction()); + Converter.Convert(new ConversionStage.ClassCollectionAvailableStage(this)); + _fileHeader.ReadIdentity(this); + if (_config.IsReadOnly()) + { + return; + } + if (!ConfigImpl.CommitRecoveryDisabled()) + { + _fileHeader.CompleteInterruptedTransaction(this); + } + IFreespaceManager blockedFreespaceManager = AbstractFreespaceManager.CreateNew(this + , _systemData.FreespaceSystem()); + InstallFreespaceManager(blockedFreespaceManager); + blockedFreespaceManager.Read(this, _systemData.InMemoryFreespaceSlot()); + blockedFreespaceManager.Start(_systemData.BTreeFreespaceId()); + _fileHeader = _fileHeader.Convert(this); + if (FreespaceMigrationRequired(blockedFreespaceManager)) + { + MigrateFreespace(blockedFreespaceManager); + } + WriteHeader(true, false); + if (Converter.Convert(new ConversionStage.SystemUpStage(this))) + { + _systemData.ConverterVersion(Converter.Version); + _fileHeader.WriteVariablePart(this); + Transaction.Commit(); + } + } + + private void InstallFreespaceManager(IFreespaceManager blockedFreespaceManager) + { + _freespaceManager = BlockSize() == 1 ? blockedFreespaceManager : new BlockAwareFreespaceManager + (blockedFreespaceManager, _blockConverter); + } + + protected virtual void CreateIdSystem() + { + _idSystem = StandardIdSystemFactory.NewInstance(this); + } + + private bool FreespaceMigrationRequired(IFreespaceManager freespaceManager) + { + if (freespaceManager == null) + { + return false; + } + byte readSystem = _systemData.FreespaceSystem(); + byte configuredSystem = ConfigImpl.FreespaceSystem(); + if (freespaceManager.SystemType() == configuredSystem) + { + return false; + } + if (configuredSystem != 0) + { + return true; + } + return AbstractFreespaceManager.MigrationRequired(readSystem); + } + + private void MigrateFreespace(IFreespaceManager oldFreespaceManager) + { + IFreespaceManager newFreespaceManager = AbstractFreespaceManager.CreateNew(this, + ConfigImpl.FreespaceSystem()); + newFreespaceManager.Start(0); + SystemData().FreespaceSystem(ConfigImpl.FreespaceSystem()); + InstallFreespaceManager(newFreespaceManager); + AbstractFreespaceManager.Migrate(oldFreespaceManager, newFreespaceManager); + _fileHeader.WriteVariablePart(this); + } + + public sealed override void ReleaseSemaphore(string name) + { + ReleaseSemaphore(null, name); + } + + public sealed override void ReleaseSemaphore(Transaction trans, string name) + { + lock (_lock) + { + if (_semaphores == null) + { + return; + } + } + _semaphoresLock.Run(new _IClosure4_574(this, trans, name)); + } + + private sealed class _IClosure4_574 : IClosure4 + { + public _IClosure4_574(LocalObjectContainer _enclosing, Transaction trans, string + name) + { + this._enclosing = _enclosing; + this.trans = trans; + this.name = name; + } + + public object Run() + { + Transaction transaction = this._enclosing.CheckTransaction(trans); + if (this._enclosing._semaphores != null && transaction == this._enclosing._semaphores + .Get(name)) + { + this._enclosing._semaphores.Remove(name); + } + this._enclosing._semaphoresLock.Awake(); + return null; + } + + private readonly LocalObjectContainer _enclosing; + + private readonly Transaction trans; + + private readonly string name; + } + + public override void ReleaseSemaphores(Transaction trans) + { + if (_semaphores != null) + { + Hashtable4 semaphores = _semaphores; + _semaphoresLock.Run(new _IClosure4_588(this, semaphores, trans)); + } + } + + private sealed class _IClosure4_588 : IClosure4 + { + public _IClosure4_588(LocalObjectContainer _enclosing, Hashtable4 semaphores, Transaction + trans) + { + this._enclosing = _enclosing; + this.semaphores = semaphores; + this.trans = trans; + } + + public object Run() + { + semaphores.ForEachKeyForIdentity(new _IVisitor4_589(semaphores), trans); + this._enclosing._semaphoresLock.Awake(); + return null; + } + + private sealed class _IVisitor4_589 : IVisitor4 + { + public _IVisitor4_589(Hashtable4 semaphores) + { + this.semaphores = semaphores; + } + + public void Visit(object a_object) + { + semaphores.Remove(a_object); + } + + private readonly Hashtable4 semaphores; + } + + private readonly LocalObjectContainer _enclosing; + + private readonly Hashtable4 semaphores; + + private readonly Transaction trans; + } + + public sealed override void Rollback1(Transaction trans) + { + trans.Rollback(); + } + + public sealed override void SetDirtyInSystemTransaction(PersistentBase a_object) + { + a_object.SetStateDirty(); + a_object.CacheDirty(_dirtyClassMetadata); + } + + public sealed override bool SetSemaphore(string name, int timeout) + { + return SetSemaphore(null, name, timeout); + } + + public sealed override bool SetSemaphore(Transaction trans, string name, int timeout + ) + { + if (name == null) + { + throw new ArgumentNullException(); + } + lock (_lock) + { + if (_semaphores == null) + { + _semaphores = new Hashtable4(10); + } + } + BooleanByRef acquired = new BooleanByRef(); + _semaphoresLock.Run(new _IClosure4_625(this, trans, name, acquired, timeout)); + return acquired.value; + } + + private sealed class _IClosure4_625 : IClosure4 + { + public _IClosure4_625(LocalObjectContainer _enclosing, Transaction trans, string + name, BooleanByRef acquired, int timeout) + { + this._enclosing = _enclosing; + this.trans = trans; + this.name = name; + this.acquired = acquired; + this.timeout = timeout; + } + + public object Run() + { + try + { + Transaction transaction = this._enclosing.CheckTransaction(trans); + object candidateTransaction = this._enclosing._semaphores.Get(name); + if (trans == candidateTransaction) + { + acquired.value = true; + return null; + } + if (candidateTransaction == null) + { + this._enclosing._semaphores.Put(name, transaction); + acquired.value = true; + return null; + } + long endtime = Runtime.CurrentTimeMillis() + timeout; + long waitTime = timeout; + while (waitTime > 0) + { + this._enclosing._semaphoresLock.Awake(); + this._enclosing._semaphoresLock.Snooze(waitTime); + if (this._enclosing.ClassCollection() == null) + { + acquired.value = false; + return null; + } + candidateTransaction = this._enclosing._semaphores.Get(name); + if (candidateTransaction == null) + { + this._enclosing._semaphores.Put(name, transaction); + acquired.value = true; + return null; + } + waitTime = endtime - Runtime.CurrentTimeMillis(); + } + acquired.value = false; + return null; + } + finally + { + this._enclosing._semaphoresLock.Awake(); + } + } + + private readonly LocalObjectContainer _enclosing; + + private readonly Transaction trans; + + private readonly string name; + + private readonly BooleanByRef acquired; + + private readonly int timeout; + } + + public virtual void SetServer(bool flag) + { + i_isServer = flag; + } + + public abstract void SyncFiles(); + + public abstract void SyncFiles(IRunnable runnable); + + protected override string DefaultToString() + { + return FileName(); + } + + public override void Shutdown() + { + WriteHeader(false, true); + } + + public void CommitTransaction() + { + _transaction.Commit(); + } + + public abstract void WriteBytes(ByteArrayBuffer buffer, int blockedAddress, int addressOffset + ); + + public sealed override void WriteDirtyClassMetadata() + { + WriteCachedDirty(); + } + + private void WriteCachedDirty() + { + IEnumerator i = _dirtyClassMetadata.GetEnumerator(); + while (i.MoveNext()) + { + PersistentBase dirty = (PersistentBase)i.Current; + dirty.Write(SystemTransaction()); + dirty.NotCachedDirty(); + } + _dirtyClassMetadata.Clear(); + } + + public void WriteEncrypt(ByteArrayBuffer buffer, int address, int addressOffset) + { + _handlers.Encrypt(buffer); + WriteBytes(buffer, address, addressOffset); + _handlers.Decrypt(buffer); + } + + public virtual void WriteHeader(bool startFileLockingThread, bool shuttingDown) + { + if (shuttingDown) + { + _freespaceManager.Write(this); + _freespaceManager = null; + } + StatefulBuffer writer = CreateStatefulBuffer(SystemTransaction(), 0, _fileHeader. + Length()); + _fileHeader.WriteFixedPart(this, startFileLockingThread, shuttingDown, writer, BlockSize + ()); + if (shuttingDown) + { + EnsureLastSlotWritten(); + } + SyncFiles(); + } + + public sealed override void WriteNew(Transaction trans, Pointer4 pointer, ClassMetadata + classMetadata, ByteArrayBuffer buffer) + { + WriteEncrypt(buffer, pointer.Address(), 0); + if (classMetadata == null) + { + return; + } + classMetadata.AddToIndex(trans, pointer.Id()); + } + + // This is a reroute of writeBytes to write the free blocks + // unchecked. + public abstract void OverwriteDeletedBytes(int address, int length); + + public virtual void OverwriteDeletedBlockedSlot(Slot slot) + { + OverwriteDeletedBytes(slot.Address(), _blockConverter.BlocksToBytes(slot.Length() + )); + } + + public void WriteTransactionPointer(int pointer) + { + _fileHeader.WriteTransactionPointer(SystemTransaction(), pointer); + } + + public Slot AllocateSlotForUserObjectUpdate(Transaction trans, int id, int length + ) + { + Slot slot = AllocateSlot(length); + trans.IdSystem().NotifySlotUpdated(id, slot, SlotChangeFactory.UserObjects); + return slot; + } + + public Slot AllocateSlotForNewUserObject(Transaction trans, int id, int length) + { + Slot slot = AllocateSlot(length); + trans.IdSystem().NotifySlotCreated(id, slot, SlotChangeFactory.UserObjects); + return slot; + } + + public sealed override void WriteUpdate(Transaction trans, Pointer4 pointer, ClassMetadata + classMetadata, ArrayType arrayType, ByteArrayBuffer buffer) + { + int address = pointer.Address(); + if (address == 0) + { + address = AllocateSlotForUserObjectUpdate(trans, pointer.Id(), pointer.Length()). + Address(); + } + WriteEncrypt(buffer, address, 0); + } + + public virtual void SetNextTimeStampId(long val) + { + _timeStampIdGenerator.SetMinimumNext(val); + } + + public override ISystemInfo SystemInfo() + { + return new SystemInfoFileImpl(this); + } + + public virtual FileHeader GetFileHeader() + { + return _fileHeader; + } + + public virtual void InstallDebugFreespaceManager(IFreespaceManager manager) + { + _freespaceManager = manager; + } + + public virtual Db4objects.Db4o.Internal.SystemData SystemData() + { + return _systemData; + } + + public override long[] GetIDsForClass(Transaction trans, ClassMetadata clazz) + { + IntArrayList ids = new IntArrayList(); + clazz.Index().TraverseAll(trans, new _IVisitor4_792(ids)); + return ids.AsLong(); + } + + private sealed class _IVisitor4_792 : IVisitor4 + { + public _IVisitor4_792(IntArrayList ids) + { + this.ids = ids; + } + + public void Visit(object obj) + { + ids.Add(((int)obj)); + } + + private readonly IntArrayList ids; + } + + public override IQueryResult ClassOnlyQuery(QQueryBase query, ClassMetadata clazz + ) + { + if (!clazz.HasClassIndex()) + { + return new IdListQueryResult(query.Transaction()); + } + AbstractQueryResult queryResult = NewQueryResult(query.Transaction()); + queryResult.LoadFromClassIndex(clazz); + return queryResult; + } + + public override IQueryResult ExecuteQuery(QQuery query) + { + AbstractQueryResult queryResult = NewQueryResult(query.Transaction()); + queryResult.LoadFromQuery(query); + return queryResult; + } + + public virtual LocalTransaction LocalSystemTransaction() + { + return (LocalTransaction)SystemTransaction(); + } + + public override int InstanceCount(ClassMetadata clazz, Transaction trans) + { + lock (Lock()) + { + return clazz.IndexEntryCount(trans); + } + } + + public override IObjectContainer OpenSession() + { + lock (Lock()) + { + return new ObjectContainerSession(this); + } + } + + public override bool IsDeleted(Transaction trans, int id) + { + return trans.IdSystem().IsDeleted(id); + } + + public virtual void WritePointer(int id, Slot slot) + { + if (DTrace.enabled) + { + DTrace.WritePointer.Log(id); + DTrace.WritePointer.LogLength(slot); + } + _pointerIo.Seek(0); + _pointerIo.WriteInt(slot.Address()); + _pointerIo.WriteInt(slot.Length()); + WriteBytes(_pointerIo, id, 0); + } + + public virtual Slot DebugReadPointerSlot(int id) + { + return null; + } + + public Slot ReadPointerSlot(int id) + { + if (!IsValidId(id)) + { + throw new InvalidIDException(id); + } + ReadBytes(_pointerBuffer, id, Const4.PointerLength); + int address = (_pointerBuffer[3] & 255) | (_pointerBuffer[2] & 255) << 8 | (_pointerBuffer + [1] & 255) << 16 | _pointerBuffer[0] << 24; + int length = (_pointerBuffer[7] & 255) | (_pointerBuffer[6] & 255) << 8 | (_pointerBuffer + [5] & 255) << 16 | _pointerBuffer[4] << 24; + if (!IsValidSlot(address, length)) + { + throw new InvalidSlotException(address, length, id); + } + return new Slot(address, length); + } + + private bool IsValidId(int id) + { + return FileLength() >= id; + } + + private bool IsValidSlot(int address, int length) + { + // just in case overflow + long fileLength = FileLength(); + bool validAddress = fileLength >= address; + bool validLength = fileLength >= length; + bool validSlot = fileLength >= (address + length); + return validAddress && validLength && validSlot; + } + + protected override void CloseIdSystem() + { + if (_idSystem != null) + { + _idSystem.Close(); + } + } + + public virtual IIdSystem IdSystem() + { + return _idSystem; + } + + public virtual IRunnable CommitHook() + { + _systemData.LastTimeStampID(_timeStampIdGenerator.Last()); + return _fileHeader.Commit(false); + } + + public Slot AllocateSafeSlot(int length) + { + Slot reusedSlot = FreespaceManager().AllocateSafeSlot(length); + if (reusedSlot != null) + { + return reusedSlot; + } + return AppendBytes(length); + } + + public override EventRegistryImpl NewEventRegistry() + { + return new EventRegistryImpl(); + } + + public virtual IQLin From(Type clazz) + { + return new QLinRoot(Query(), clazz); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/LocalPersistentBase.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/LocalPersistentBase.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/LocalPersistentBase.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/LocalPersistentBase.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,43 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Ids; +using Db4objects.Db4o.Internal.Slots; + +namespace Db4objects.Db4o.Internal +{ + /// + public abstract class LocalPersistentBase : PersistentBase + { + private readonly ITransactionalIdSystem _idSystem; + + public LocalPersistentBase(ITransactionalIdSystem idSystem) + { + _idSystem = idSystem; + } + + public LocalPersistentBase() : this(null) + { + } + + public override ITransactionalIdSystem IdSystem(Transaction trans) + { + if (_idSystem != null) + { + return _idSystem; + } + return base.IdSystem(trans); + } + + protected override ByteArrayBuffer ReadBufferById(Transaction trans) + { + Slot slot = IdSystem(trans).CurrentSlot(GetID()); + if (DTrace.enabled) + { + DTrace.SlotRead.LogLength(GetID(), slot); + } + return ((LocalObjectContainer)trans.Container()).ReadBufferBySlot(slot); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/LocalTransaction.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/LocalTransaction.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/LocalTransaction.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/LocalTransaction.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,541 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using System.Collections; +using Db4objects.Db4o; +using Db4objects.Db4o.Ext; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Activation; +using Db4objects.Db4o.Internal.Callbacks; +using Db4objects.Db4o.Internal.Ids; +using Db4objects.Db4o.Internal.References; + +namespace Db4objects.Db4o.Internal +{ + /// + public class LocalTransaction : Transaction + { + private readonly IdentitySet4 _participants = new IdentitySet4(); + + internal Tree _writtenUpdateAdjustedIndexes; + + protected readonly LocalObjectContainer _file; + + private readonly ICommittedCallbackDispatcher _committedCallbackDispatcher; + + private readonly ITransactionalIdSystem _idSystem; + + private Db4objects.Db4o.Internal.CommitTimestampSupport _commitTimestampSupport = + null; + + private long _timestamp; + + public LocalTransaction(ObjectContainerBase container, Transaction parentTransaction + , ITransactionalIdSystem idSystem, IReferenceSystem referenceSystem) : base(container + , parentTransaction, referenceSystem) + { + _file = (LocalObjectContainer)container; + _committedCallbackDispatcher = new _ICommittedCallbackDispatcher_35(this); + _idSystem = idSystem; + } + + private sealed class _ICommittedCallbackDispatcher_35 : ICommittedCallbackDispatcher + { + public _ICommittedCallbackDispatcher_35(LocalTransaction _enclosing) + { + this._enclosing = _enclosing; + } + + public bool WillDispatchCommitted() + { + return this._enclosing.Callbacks().CaresAboutCommitted(); + } + + public void DispatchCommitted(CallbackObjectInfoCollections committedInfo) + { + this._enclosing.Callbacks().CommitOnCompleted(this._enclosing, committedInfo, false + ); + } + + private readonly LocalTransaction _enclosing; + } + + public virtual Config4Impl Config() + { + return Container().Config(); + } + + public virtual LocalObjectContainer LocalContainer() + { + return _file; + } + + public override void Commit() + { + if (IsSystemTransaction()) + { + CommitTimestampSupport().EnsureInitialized(); + } + Commit(_committedCallbackDispatcher); + } + + public virtual void Commit(ICommittedCallbackDispatcher dispatcher) + { + lock (Container().Lock()) + { + DispatchCommittingCallback(); + if (!DoCommittedCallbacks(dispatcher)) + { + CommitListeners(); + CommitImpl(); + CommitClearAll(); + } + else + { + CommitListeners(); + Collection4 deleted = CollectCommittedCallbackDeletedInfo(); + CommitImpl(); + CallbackObjectInfoCollections committedInfo = CollectCommittedCallbackInfo(deleted + ); + CommitClearAll(); + dispatcher.DispatchCommitted(CallbackObjectInfoCollections.Emtpy == committedInfo + ? committedInfo : new CallbackObjectInfoCollections(committedInfo.added, committedInfo + .updated, new ObjectInfoCollectionImpl(deleted))); + } + } + } + + private void DispatchCommittingCallback() + { + if (DoCommittingCallbacks()) + { + Callbacks().CommitOnStarted(this, CollectCommittingCallbackInfo()); + } + } + + private bool DoCommittedCallbacks(ICommittedCallbackDispatcher dispatcher) + { + if (IsSystemTransaction()) + { + return false; + } + return dispatcher.WillDispatchCommitted(); + } + + private bool DoCommittingCallbacks() + { + if (IsSystemTransaction()) + { + return false; + } + return Callbacks().CaresAboutCommitting(); + } + + public virtual void Enlist(ITransactionParticipant participant) + { + if (null == participant) + { + throw new ArgumentNullException(); + } + CheckSynchronization(); + if (!_participants.Contains(participant)) + { + _participants.Add(participant); + } + } + + private void CommitImpl() + { + if (DTrace.enabled) + { + DTrace.TransCommit.LogInfo("server == " + Container().IsServer() + ", systemtrans == " + + IsSystemTransaction()); + } + CommitClassMetadata(); + CommitParticipants(); + Container().WriteDirtyClassMetadata(); + IdSystem().Commit(new FreespaceCommitter(LocalContainer().FreespaceManager())); + } + + private void CommitListeners() + { + CommitParentListeners(); + CommitTransactionListeners(); + } + + private void CommitParentListeners() + { + if (_systemTransaction != null) + { + ParentLocalTransaction().CommitListeners(); + } + } + + private void CommitParticipants() + { + if (ParentLocalTransaction() != null) + { + ParentLocalTransaction().CommitParticipants(); + } + IEnumerator iterator = _participants.GetEnumerator(); + while (iterator.MoveNext()) + { + ((ITransactionParticipant)iterator.Current).Commit(this); + } + } + + private void CommitClassMetadata() + { + Container().ProcessPendingClassUpdates(); + Container().WriteDirtyClassMetadata(); + Container().ClassCollection().Write(Container().SystemTransaction()); + } + + private Db4objects.Db4o.Internal.LocalTransaction ParentLocalTransaction() + { + return (Db4objects.Db4o.Internal.LocalTransaction)_systemTransaction; + } + + private void CommitClearAll() + { + if (_systemTransaction != null) + { + ParentLocalTransaction().CommitClearAll(); + } + ClearAll(); + } + + protected override void Clear() + { + IdSystem().Clear(); + DisposeParticipants(); + _participants.Clear(); + } + + private void DisposeParticipants() + { + IEnumerator iterator = _participants.ValuesIterator(); + while (iterator.MoveNext()) + { + ((ITransactionParticipant)iterator.Current).Dispose(this); + } + } + + public override void Rollback() + { + lock (Container().Lock()) + { + RollbackParticipants(); + IdSystem().Rollback(); + RollBackTransactionListeners(); + ClearAll(); + } + } + + private void RollbackParticipants() + { + IEnumerator iterator = _participants.ValuesIterator(); + while (iterator.MoveNext()) + { + ((ITransactionParticipant)iterator.Current).Rollback(this); + } + } + + public virtual void FlushFile() + { + if (DTrace.enabled) + { + DTrace.TransFlush.Log(); + } + _file.SyncFiles(); + } + + public override void ProcessDeletes() + { + if (_delete == null) + { + _writtenUpdateAdjustedIndexes = null; + return; + } + while (_delete != null) + { + Tree delete = _delete; + _delete = null; + delete.Traverse(new _IVisitor4_225(this)); + } + // if the object has been deleted + // We need to hold a hard reference here, otherwise we can get + // intermediate garbage collection kicking in. + // This means the object was gc'd. + // Let's try to read it again, but this may fail in + // CS mode if another transaction has deleted it. + _writtenUpdateAdjustedIndexes = null; + } + + private sealed class _IVisitor4_225 : IVisitor4 + { + public _IVisitor4_225(LocalTransaction _enclosing) + { + this._enclosing = _enclosing; + } + + public void Visit(object a_object) + { + DeleteInfo info = (DeleteInfo)a_object; + if (this._enclosing.LocalContainer().IsDeleted(this._enclosing, info._key)) + { + return; + } + object obj = null; + if (info._reference != null) + { + obj = info._reference.GetObject(); + } + if (obj == null || info._reference.GetID() < 0) + { + HardObjectReference hardRef = this._enclosing.Container().GetHardObjectReferenceById + (this._enclosing, info._key); + if (hardRef == HardObjectReference.Invalid) + { + return; + } + info._reference = hardRef._reference; + info._reference.FlagForDelete(this._enclosing.Container().TopLevelCallId()); + obj = info._reference.GetObject(); + } + this._enclosing.Container().Delete3(this._enclosing, info._reference, obj, info._cascade + , false); + } + + private readonly LocalTransaction _enclosing; + } + + public override void WriteUpdateAdjustIndexes(int id, ClassMetadata clazz, ArrayType + typeInfo) + { + new WriteUpdateProcessor(this, id, clazz, typeInfo).Run(); + } + + private ICallbacks Callbacks() + { + return Container().Callbacks(); + } + + private Collection4 CollectCommittedCallbackDeletedInfo() + { + Collection4 deleted = new Collection4(); + CollectCallBackInfo(new _ICallbackInfoCollector_275(this, deleted)); + return deleted; + } + + private sealed class _ICallbackInfoCollector_275 : ICallbackInfoCollector + { + public _ICallbackInfoCollector_275(LocalTransaction _enclosing, Collection4 deleted + ) + { + this._enclosing = _enclosing; + this.deleted = deleted; + } + + public void Deleted(int id) + { + IObjectInfo @ref = this._enclosing.FrozenReferenceFor(id); + if (@ref != null) + { + deleted.Add(@ref); + } + } + + public void Updated(int id) + { + } + + public void Added(int id) + { + } + + private readonly LocalTransaction _enclosing; + + private readonly Collection4 deleted; + } + + private CallbackObjectInfoCollections CollectCommittedCallbackInfo(Collection4 deleted + ) + { + if (!IdSystem().IsDirty()) + { + return CallbackObjectInfoCollections.Emtpy; + } + Collection4 added = new Collection4(); + Collection4 updated = new Collection4(); + CollectCallBackInfo(new _ICallbackInfoCollector_298(this, added, updated)); + return NewCallbackObjectInfoCollections(added, updated, deleted); + } + + private sealed class _ICallbackInfoCollector_298 : ICallbackInfoCollector + { + public _ICallbackInfoCollector_298(LocalTransaction _enclosing, Collection4 added + , Collection4 updated) + { + this._enclosing = _enclosing; + this.added = added; + this.updated = updated; + } + + public void Added(int id) + { + added.Add(this._enclosing.LazyReferenceFor(id)); + } + + public void Updated(int id) + { + updated.Add(this._enclosing.LazyReferenceFor(id)); + } + + public void Deleted(int id) + { + } + + private readonly LocalTransaction _enclosing; + + private readonly Collection4 added; + + private readonly Collection4 updated; + } + + private CallbackObjectInfoCollections CollectCommittingCallbackInfo() + { + if (!IdSystem().IsDirty()) + { + return CallbackObjectInfoCollections.Emtpy; + } + Collection4 added = new Collection4(); + Collection4 deleted = new Collection4(); + Collection4 updated = new Collection4(); + CollectCallBackInfo(new _ICallbackInfoCollector_321(this, added, updated, deleted + )); + return NewCallbackObjectInfoCollections(added, updated, deleted); + } + + private sealed class _ICallbackInfoCollector_321 : ICallbackInfoCollector + { + public _ICallbackInfoCollector_321(LocalTransaction _enclosing, Collection4 added + , Collection4 updated, Collection4 deleted) + { + this._enclosing = _enclosing; + this.added = added; + this.updated = updated; + this.deleted = deleted; + } + + public void Added(int id) + { + added.Add(this._enclosing.LazyReferenceFor(id)); + } + + public void Updated(int id) + { + updated.Add(this._enclosing.LazyReferenceFor(id)); + } + + public void Deleted(int id) + { + IObjectInfo @ref = this._enclosing.FrozenReferenceFor(id); + if (@ref != null) + { + deleted.Add(@ref); + } + } + + private readonly LocalTransaction _enclosing; + + private readonly Collection4 added; + + private readonly Collection4 updated; + + private readonly Collection4 deleted; + } + + private CallbackObjectInfoCollections NewCallbackObjectInfoCollections(Collection4 + added, Collection4 updated, Collection4 deleted) + { + return new CallbackObjectInfoCollections(new ObjectInfoCollectionImpl(added), new + ObjectInfoCollectionImpl(updated), new ObjectInfoCollectionImpl(deleted)); + } + + private void CollectCallBackInfo(ICallbackInfoCollector collector) + { + IdSystem().CollectCallBackInfo(collector); + } + + public override ITransactionalIdSystem IdSystem() + { + return _idSystem; + } + + public virtual IObjectInfo FrozenReferenceFor(int id) + { + ObjectReference @ref = ReferenceForId(id); + if (@ref != null) + { + return new FrozenObjectInfo(this, @ref, true); + } + @ref = Container().PeekReference(SystemTransaction(), id, new FixedActivationDepth + (0), true); + if (@ref == null || @ref.GetObject() == null) + { + return null; + } + return new FrozenObjectInfo(SystemTransaction(), @ref, true); + } + + public virtual LazyObjectReference LazyReferenceFor(int id) + { + return new LazyObjectReference(this, id); + } + + public override long VersionForId(int id) + { + return CommitTimestampSupport().VersionForId(id); + } + + public virtual Db4objects.Db4o.Internal.CommitTimestampSupport CommitTimestampSupport + () + { + if (!IsSystemTransaction()) + { + throw new InvalidOperationException(); + } + if (_commitTimestampSupport == null) + { + _commitTimestampSupport = new Db4objects.Db4o.Internal.CommitTimestampSupport(LocalContainer + ()); + } + return _commitTimestampSupport; + } + + public override long GenerateTransactionTimestamp(long forcedTimeStamp) + { + if (forcedTimeStamp > 0) + { + _timestamp = forcedTimeStamp; + } + else + { + _timestamp = LocalContainer().GenerateTimeStampId(); + } + return _timestamp; + } + + public override void UseDefaultTransactionTimestamp() + { + _timestamp = 0; + } + + public virtual long Timestamp() + { + return _timestamp; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/LockedTree.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/LockedTree.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/LockedTree.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/LockedTree.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,87 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using System.Collections; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal; + +namespace Db4objects.Db4o.Internal +{ + /// + public class LockedTree + { + private Tree _tree; + + private int _version; + + public virtual void Add(Tree tree) + { + Changed(); + _tree = _tree == null ? tree : _tree.Add(tree); + } + + private void Changed() + { + _version++; + } + + public virtual void Clear() + { + Changed(); + _tree = null; + } + + public virtual Tree Find(int key) + { + return TreeInt.Find(_tree, key); + } + + public virtual void Read(ByteArrayBuffer buffer, IReadable template) + { + Clear(); + _tree = new TreeReader(buffer, template).Read(); + Changed(); + } + + public virtual void TraverseLocked(IVisitor4 visitor) + { + int currentVersion = _version; + Tree.Traverse(_tree, visitor); + if (_version != currentVersion) + { + throw new InvalidOperationException(); + } + } + + public virtual void TraverseMutable(IVisitor4 visitor) + { + Collection4 currentContent = new Collection4(); + TraverseLocked(new _IVisitor4_51(currentContent)); + IEnumerator i = currentContent.GetEnumerator(); + while (i.MoveNext()) + { + visitor.Visit(i.Current); + } + } + + private sealed class _IVisitor4_51 : IVisitor4 + { + public _IVisitor4_51(Collection4 currentContent) + { + this.currentContent = currentContent; + } + + public void Visit(object obj) + { + currentContent.Add(obj); + } + + private readonly Collection4 currentContent; + } + + public virtual bool IsEmpty() + { + return _tree == null; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Mapping/IdSource.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Mapping/IdSource.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Mapping/IdSource.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Mapping/IdSource.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,26 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Foundation; + +namespace Db4objects.Db4o.Internal.Mapping +{ + public class IdSource + { + private readonly IQueue4 _queue; + + public IdSource(IQueue4 queue) + { + _queue = queue; + } + + public virtual bool HasMoreIds() + { + return _queue.HasNext(); + } + + public virtual int NextId() + { + return ((int)_queue.Next()); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Mapping/IIDMapping.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Mapping/IIDMapping.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Mapping/IIDMapping.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Mapping/IIDMapping.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,21 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +namespace Db4objects.Db4o.Internal.Mapping +{ + /// A mapping from db4o file source IDs/addresses to target IDs/addresses, used for defragmenting. + /// + /// A mapping from db4o file source IDs/addresses to target IDs/addresses, used for defragmenting. + /// + /// + public interface IIDMapping + { + /// a mapping for the given id. if it does refer to a system handler or the empty reference (0), returns the given id. + /// + /// if the given id does not refer to a system handler or the empty reference (0) and if no mapping is found + /// + /// + int StrictMappedID(int oldID); + + void MapIDs(int oldID, int newID, bool isClassID); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Mapping/MappedIDPair.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Mapping/MappedIDPair.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Mapping/MappedIDPair.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Mapping/MappedIDPair.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,33 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +namespace Db4objects.Db4o.Internal.Mapping +{ + /// + public class MappedIDPair + { + private int _orig; + + private int _mapped; + + public MappedIDPair(int orig, int mapped) + { + _orig = orig; + _mapped = mapped; + } + + public virtual int Orig() + { + return _orig; + } + + public virtual int Mapped() + { + return _mapped; + } + + public override string ToString() + { + return _orig + "->" + _mapped; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Mapping/MappedIDPairHandler.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Mapping/MappedIDPairHandler.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Mapping/MappedIDPairHandler.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Mapping/MappedIDPairHandler.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,80 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Handlers; +using Db4objects.Db4o.Internal.Mapping; +using Db4objects.Db4o.Marshall; + +namespace Db4objects.Db4o.Internal.Mapping +{ + /// + public class MappedIDPairHandler : IIndexable4 + { + private readonly IntHandler _origHandler; + + private readonly IntHandler _mappedHandler; + + public MappedIDPairHandler() + { + _origHandler = new IntHandler(); + _mappedHandler = new IntHandler(); + } + + public virtual void DefragIndexEntry(DefragmentContextImpl context) + { + throw new NotImplementedException(); + } + + public virtual int LinkLength() + { + return _origHandler.LinkLength() + _mappedHandler.LinkLength(); + } + + public virtual object ReadIndexEntry(IContext context, ByteArrayBuffer reader) + { + int origID = ReadID(context, reader); + int mappedID = ReadID(context, reader); + return new MappedIDPair(origID, mappedID); + } + + public virtual void WriteIndexEntry(IContext context, ByteArrayBuffer reader, object + obj) + { + MappedIDPair mappedIDs = (MappedIDPair)obj; + _origHandler.WriteIndexEntry(context, reader, mappedIDs.Orig()); + _mappedHandler.WriteIndexEntry(context, reader, mappedIDs.Mapped()); + } + + private int ReadID(IContext context, ByteArrayBuffer a_reader) + { + return ((int)_origHandler.ReadIndexEntry(context, a_reader)); + } + + public virtual IPreparedComparison PrepareComparison(IContext context, object source + ) + { + MappedIDPair sourceIDPair = (MappedIDPair)source; + int sourceID = sourceIDPair.Orig(); + return new _IPreparedComparison_50(sourceID); + } + + private sealed class _IPreparedComparison_50 : IPreparedComparison + { + public _IPreparedComparison_50(int sourceID) + { + this.sourceID = sourceID; + } + + public int CompareTo(object target) + { + MappedIDPair targetIDPair = (MappedIDPair)target; + int targetID = targetIDPair.Orig(); + return sourceID == targetID ? 0 : (sourceID < targetID ? -1 : 1); + } + + private readonly int sourceID; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Mapping/MappingNotFoundException.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Mapping/MappingNotFoundException.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Mapping/MappingNotFoundException.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Mapping/MappingNotFoundException.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,30 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; + +namespace Db4objects.Db4o.Internal.Mapping +{ + /// + [System.Serializable] + public class MappingNotFoundException : Exception + { + private const long serialVersionUID = -1771324770287654802L; + + private int _id; + + public MappingNotFoundException(int id) + { + this._id = id; + } + + public virtual int Id() + { + return _id; + } + + public override string ToString() + { + return base.ToString() + " : " + _id; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/AbstractFieldMarshaller.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/AbstractFieldMarshaller.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/AbstractFieldMarshaller.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/AbstractFieldMarshaller.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,32 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Encoding; +using Db4objects.Db4o.Internal.Marshall; + +namespace Db4objects.Db4o.Internal.Marshall +{ + /// + public abstract class AbstractFieldMarshaller : IFieldMarshaller + { + protected abstract RawFieldSpec ReadSpec(AspectType aspectType, ObjectContainerBase + stream, ByteArrayBuffer reader); + + public virtual RawFieldSpec ReadSpec(ObjectContainerBase stream, ByteArrayBuffer + reader) + { + return ReadSpec(AspectType.Field, stream, reader); + } + + public abstract void Defrag(ClassMetadata arg1, ClassAspect arg2, LatinStringIO arg3 + , DefragmentContextImpl arg4); + + public abstract int MarshalledLength(ObjectContainerBase arg1, ClassAspect arg2); + + public abstract FieldMetadata Read(ObjectContainerBase arg1, ClassMetadata arg2, + ByteArrayBuffer arg3); + + public abstract void Write(Transaction arg1, ClassMetadata arg2, ClassAspect arg3 + , ByteArrayBuffer arg4); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/AbstractReadContext.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/AbstractReadContext.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/AbstractReadContext.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/AbstractReadContext.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,158 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Activation; +using Db4objects.Db4o.Internal.Marshall; +using Db4objects.Db4o.Marshall; +using Db4objects.Db4o.Typehandlers; + +namespace Db4objects.Db4o.Internal.Marshall +{ + /// + public abstract class AbstractReadContext : AbstractBufferContext, IInternalReadContext + { + protected IActivationDepth _activationDepth = UnknownActivationDepth.Instance; + + private bool _lastReferenceReadWasReallyNull = false; + + protected AbstractReadContext(Transaction transaction, IReadBuffer buffer) : base + (transaction, buffer) + { + } + + protected AbstractReadContext(Transaction transaction) : this(transaction, null) + { + } + + public object Read(ITypeHandler4 handlerType) + { + return ReadObject(handlerType); + } + + public object ReadObject(ITypeHandler4 handlerType) + { + if (null == handlerType) + { + throw new ArgumentNullException(); + } + ITypeHandler4 handler = HandlerRegistry.CorrectHandlerVersion(this, handlerType); + return SlotFormat().DoWithSlotIndirection(this, handler, new _IClosure4_38(this, + handler)); + } + + private sealed class _IClosure4_38 : IClosure4 + { + public _IClosure4_38(AbstractReadContext _enclosing, ITypeHandler4 handler) + { + this._enclosing = _enclosing; + this.handler = handler; + } + + public object Run() + { + return this._enclosing.ReadAtCurrentSeekPosition(handler); + } + + private readonly AbstractReadContext _enclosing; + + private readonly ITypeHandler4 handler; + } + + public virtual object ReadAtCurrentSeekPosition(ITypeHandler4 handler) + { + if (Handlers4.UseDedicatedSlot(this, handler)) + { + return ReadObject(); + } + return Handlers4.ReadValueType(this, handler); + } + + public object ReadObject() + { + int objectId = ReadInt(); + if (objectId == 0) + { + _lastReferenceReadWasReallyNull = true; + return null; + } + _lastReferenceReadWasReallyNull = false; + if (objectId == Const4.InvalidObjectId) + { + return null; + } + ClassMetadata classMetadata = ClassMetadataForObjectId(objectId); + if (null == classMetadata) + { + // TODO: throw here + return null; + } + IActivationDepth depth = ActivationDepth().Descend(classMetadata); + if (PeekPersisted()) + { + return Container().PeekPersisted(Transaction(), objectId, depth, false); + } + object obj = Container().GetByID2(Transaction(), objectId); + if (null == obj) + { + return null; + } + // this is OK for boxed value types. They will not be added + // to the list, since they will not be found in the ID tree. + Container().StillToActivate(Container().ActivationContextFor(Transaction(), obj, + depth)); + return obj; + } + + private ClassMetadata ClassMetadataForObjectId(int objectId) + { + // TODO: This method is *very* costly as is, since it reads + // the whole slot once and doesn't reuse it. Optimize. + HardObjectReference hardRef = Container().GetHardObjectReferenceById(Transaction( + ), objectId); + if (null == hardRef || hardRef._reference == null) + { + // com.db4o.db4ounit.common.querying.CascadeDeleteDeleted + return null; + } + return hardRef._reference.ClassMetadata(); + } + + protected virtual bool PeekPersisted() + { + return false; + } + + public virtual IActivationDepth ActivationDepth() + { + return _activationDepth; + } + + public virtual void ActivationDepth(IActivationDepth depth) + { + _activationDepth = depth; + } + + public virtual IReadWriteBuffer ReadIndirectedBuffer() + { + int address = ReadInt(); + int length = ReadInt(); + if (address == 0) + { + return null; + } + return Container().DecryptedBufferByAddress(address, length); + } + + public virtual bool LastReferenceReadWasReallyNull() + { + return _lastReferenceReadWasReallyNull; + } + + public virtual void NotifyNullReferenceSkipped() + { + _lastReferenceReadWasReallyNull = true; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/AspectType.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/AspectType.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/AspectType.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/AspectType.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,67 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; + +namespace Db4objects.Db4o.Internal.Marshall +{ + /// + public class AspectType + { + public readonly byte _id; + + public static readonly Db4objects.Db4o.Internal.Marshall.AspectType Field = new Db4objects.Db4o.Internal.Marshall.AspectType + ((byte)1); + + public static readonly Db4objects.Db4o.Internal.Marshall.AspectType Translator = + new Db4objects.Db4o.Internal.Marshall.AspectType((byte)2); + + public static readonly Db4objects.Db4o.Internal.Marshall.AspectType Typehandler = + new Db4objects.Db4o.Internal.Marshall.AspectType((byte)3); + + private AspectType(byte id) + { + _id = id; + } + + public static Db4objects.Db4o.Internal.Marshall.AspectType ForByte(byte b) + { + switch (b) + { + case 1: + { + return Field; + } + + case 2: + { + return Translator; + } + + case 3: + { + return Typehandler; + } + + default: + { + throw new ArgumentException(); + } + } + } + + public virtual bool IsFieldMetadata() + { + return IsField() || IsTranslator(); + } + + public virtual bool IsTranslator() + { + return this == Db4objects.Db4o.Internal.Marshall.AspectType.Translator; + } + + public virtual bool IsField() + { + return this == Db4objects.Db4o.Internal.Marshall.AspectType.Field; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/AspectVersionContextImpl.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/AspectVersionContextImpl.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/AspectVersionContextImpl.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/AspectVersionContextImpl.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,36 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using Db4objects.Db4o.Internal.Marshall; + +namespace Db4objects.Db4o.Internal.Marshall +{ + /// + public class AspectVersionContextImpl : IAspectVersionContext + { + private readonly int _declaredAspectCount; + + private AspectVersionContextImpl(int count) + { + _declaredAspectCount = count; + } + + public virtual int DeclaredAspectCount() + { + return _declaredAspectCount; + } + + public virtual void DeclaredAspectCount(int count) + { + throw new InvalidOperationException(); + } + + public static readonly Db4objects.Db4o.Internal.Marshall.AspectVersionContextImpl + AlwaysEnabled = new Db4objects.Db4o.Internal.Marshall.AspectVersionContextImpl( + int.MaxValue); + + public static readonly Db4objects.Db4o.Internal.Marshall.AspectVersionContextImpl + CheckAlwaysEnabled = new Db4objects.Db4o.Internal.Marshall.AspectVersionContextImpl + (int.MaxValue - 1); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/ClassMarshaller0.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/ClassMarshaller0.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/ClassMarshaller0.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/ClassMarshaller0.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,55 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Btree; +using Db4objects.Db4o.Internal.Classindex; +using Db4objects.Db4o.Internal.Convert.Conversions; +using Db4objects.Db4o.Internal.Marshall; + +namespace Db4objects.Db4o.Internal.Marshall +{ + /// + public class ClassMarshaller0 : ClassMarshaller + { + protected override void ReadIndex(ObjectContainerBase stream, ClassMetadata clazz + , ByteArrayBuffer reader) + { + int indexID = reader.ReadInt(); + if (!stream.MaintainsIndices() || !(stream is LocalObjectContainer)) + { + return; + } + if (Btree(clazz) != null) + { + return; + } + clazz.Index().Read(stream, ValidIndexId(indexID)); + if (IsOldClassIndex(indexID)) + { + new ClassIndexesToBTrees_5_5().Convert((LocalObjectContainer)stream, indexID, Btree + (clazz)); + stream.SetDirtyInSystemTransaction(clazz); + } + } + + private BTree Btree(ClassMetadata clazz) + { + return BTreeClassIndexStrategy.Btree(clazz); + } + + private int ValidIndexId(int indexID) + { + return IsOldClassIndex(indexID) ? 0 : -indexID; + } + + private bool IsOldClassIndex(int indexID) + { + return indexID > 0; + } + + protected override int IndexIDForWriting(int indexID) + { + return indexID; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/ClassMarshaller1.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/ClassMarshaller1.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/ClassMarshaller1.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/ClassMarshaller1.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,23 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Marshall; + +namespace Db4objects.Db4o.Internal.Marshall +{ + /// + public class ClassMarshaller1 : ClassMarshaller + { + protected override void ReadIndex(ObjectContainerBase stream, ClassMetadata clazz + , ByteArrayBuffer reader) + { + int indexID = reader.ReadInt(); + clazz.Index().Read(stream, -indexID); + } + + protected override int IndexIDForWriting(int indexID) + { + return -indexID; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/ClassMarshaller2.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/ClassMarshaller2.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/ClassMarshaller2.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/ClassMarshaller2.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,27 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Marshall; + +namespace Db4objects.Db4o.Internal.Marshall +{ + /// + public class ClassMarshaller2 : ClassMarshaller + { + protected override void ReadIndex(ObjectContainerBase stream, ClassMetadata clazz + , ByteArrayBuffer reader) + { + int indexID = reader.ReadInt(); + if (indexID == 0) + { + return; + } + clazz.Index().Read(stream, indexID); + } + + protected override int IndexIDForWriting(int indexID) + { + return indexID; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/ClassMarshaller.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/ClassMarshaller.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/ClassMarshaller.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/ClassMarshaller.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,215 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Encoding; +using Db4objects.Db4o.Internal.Marshall; + +namespace Db4objects.Db4o.Internal.Marshall +{ + /// + public abstract class ClassMarshaller + { + public MarshallerFamily _family; + + public virtual RawClassSpec ReadSpec(Transaction trans, ByteArrayBuffer reader) + { + byte[] nameBytes = ReadName(trans, reader); + string className = trans.Container().StringIO().Read(nameBytes); + ReadMetaClassID(reader); + // skip + int ancestorID = reader.ReadInt(); + reader.IncrementOffset(Const4.IntLength); + // index ID + int numFields = reader.ReadInt(); + return new RawClassSpec(className, ancestorID, numFields); + } + + public virtual void Write(Transaction trans, ClassMetadata clazz, ByteArrayBuffer + writer) + { + writer.WriteShortString(trans, clazz.NameToWrite()); + int intFormerlyKnownAsMetaClassID = 0; + writer.WriteInt(intFormerlyKnownAsMetaClassID); + writer.WriteIDOf(trans, clazz._ancestor); + WriteIndex(trans, clazz, writer); + writer.WriteInt(clazz.DeclaredAspectCount()); + clazz.TraverseDeclaredAspects(new _IProcedure4_39(this, trans, clazz, writer)); + } + + private sealed class _IProcedure4_39 : IProcedure4 + { + public _IProcedure4_39(ClassMarshaller _enclosing, Transaction trans, ClassMetadata + clazz, ByteArrayBuffer writer) + { + this._enclosing = _enclosing; + this.trans = trans; + this.clazz = clazz; + this.writer = writer; + } + + public void Apply(object arg) + { + this._enclosing._family._field.Write(trans, clazz, (ClassAspect)arg, writer); + } + + private readonly ClassMarshaller _enclosing; + + private readonly Transaction trans; + + private readonly ClassMetadata clazz; + + private readonly ByteArrayBuffer writer; + } + + protected virtual void WriteIndex(Transaction trans, ClassMetadata clazz, ByteArrayBuffer + writer) + { + int indexID = clazz.Index().Write(trans); + writer.WriteInt(IndexIDForWriting(indexID)); + } + + protected abstract int IndexIDForWriting(int indexID); + + public byte[] ReadName(Transaction trans, ByteArrayBuffer reader) + { + return ReadName(trans.Container().StringIO(), reader); + } + + public int ReadMetaClassID(ByteArrayBuffer reader) + { + return reader.ReadInt(); + } + + private byte[] ReadName(LatinStringIO sio, ByteArrayBuffer reader) + { + byte[] nameBytes = sio.Bytes(reader); + reader.IncrementOffset(nameBytes.Length); + nameBytes = Platform4.UpdateClassName(nameBytes); + return nameBytes; + } + + public void Read(ObjectContainerBase stream, ClassMetadata clazz, ByteArrayBuffer + reader) + { + clazz.SetAncestor(stream.ClassMetadataForID(reader.ReadInt())); + // if(clazz.callConstructor()){ + // // The logic further down checks the ancestor YapClass, whether + // // or not it is allowed, not to call constructors. The ancestor + // // YapClass may possibly have not been loaded yet. + // clazz.createConstructor(true); + // } + clazz.CheckType(); + ReadIndex(stream, clazz, reader); + clazz._aspects = ReadAspects(stream, reader, clazz); + } + + protected abstract void ReadIndex(ObjectContainerBase stream, ClassMetadata clazz + , ByteArrayBuffer reader); + + private ClassAspect[] ReadAspects(ObjectContainerBase stream, ByteArrayBuffer reader + , ClassMetadata clazz) + { + ClassAspect[] aspects = new ClassAspect[reader.ReadInt()]; + for (int i = 0; i < aspects.Length; i++) + { + aspects[i] = _family._field.Read(stream, clazz, reader); + aspects[i].SetHandle(i); + } + return aspects; + } + + public virtual int MarshalledLength(ObjectContainerBase stream, ClassMetadata clazz + ) + { + IntByRef len = new IntByRef(stream.StringIO().ShortLength(clazz.NameToWrite()) + + Const4.ObjectLength + (Const4.IntLength * 2) + (Const4.IdLength)); + len.value += clazz.Index().OwnLength(); + clazz.TraverseDeclaredAspects(new _IProcedure4_108(this, len, stream)); + return len.value; + } + + private sealed class _IProcedure4_108 : IProcedure4 + { + public _IProcedure4_108(ClassMarshaller _enclosing, IntByRef len, ObjectContainerBase + stream) + { + this._enclosing = _enclosing; + this.len = len; + this.stream = stream; + } + + public void Apply(object arg) + { + len.value += this._enclosing._family._field.MarshalledLength(stream, (ClassAspect + )arg); + } + + private readonly ClassMarshaller _enclosing; + + private readonly IntByRef len; + + private readonly ObjectContainerBase stream; + } + + public virtual void Defrag(ClassMetadata classMetadata, LatinStringIO sio, DefragmentContextImpl + context, int classIndexID) + { + ReadName(sio, context.SourceBuffer()); + ReadName(sio, context.TargetBuffer()); + int metaClassID = 0; + context.WriteInt(metaClassID); + // ancestor ID + context.CopyID(); + context.WriteInt((classMetadata.HasClassIndex() ? IndexIDForWriting(classIndexID) + : 0)); + int aspectCount = context.ReadInt(); + if (aspectCount > classMetadata.DeclaredAspectCount()) + { + throw new InvalidOperationException(); + } + IntByRef processedAspectCount = new IntByRef(0); + classMetadata.TraverseDeclaredAspects(new _IProcedure4_136(this, processedAspectCount + , aspectCount, classMetadata, sio, context)); + } + + private sealed class _IProcedure4_136 : IProcedure4 + { + public _IProcedure4_136(ClassMarshaller _enclosing, IntByRef processedAspectCount + , int aspectCount, ClassMetadata classMetadata, LatinStringIO sio, DefragmentContextImpl + context) + { + this._enclosing = _enclosing; + this.processedAspectCount = processedAspectCount; + this.aspectCount = aspectCount; + this.classMetadata = classMetadata; + this.sio = sio; + this.context = context; + } + + public void Apply(object arg) + { + if (processedAspectCount.value >= aspectCount) + { + return; + } + ClassAspect aspect = (ClassAspect)arg; + this._enclosing._family._field.Defrag(classMetadata, aspect, sio, context); + processedAspectCount.value++; + } + + private readonly ClassMarshaller _enclosing; + + private readonly IntByRef processedAspectCount; + + private readonly int aspectCount; + + private readonly ClassMetadata classMetadata; + + private readonly LatinStringIO sio; + + private readonly DefragmentContextImpl context; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/CollectIdContext.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/CollectIdContext.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/CollectIdContext.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/CollectIdContext.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,84 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Marshall; +using Db4objects.Db4o.Marshall; + +namespace Db4objects.Db4o.Internal.Marshall +{ + /// + public class CollectIdContext : ObjectHeaderContext + { + private readonly IdObjectCollector _collector; + + public CollectIdContext(Transaction transaction, IdObjectCollector collector, ObjectHeader + oh, IReadBuffer buffer) : base(transaction, buffer, oh) + { + _collector = collector; + } + + public CollectIdContext(Transaction transaction, ObjectHeader oh, IReadBuffer buffer + ) : this(transaction, new IdObjectCollector(), oh, buffer) + { + } + + public static Db4objects.Db4o.Internal.Marshall.CollectIdContext ForID(Transaction + transaction, int id) + { + return ForID(transaction, new IdObjectCollector(), id); + } + + public static Db4objects.Db4o.Internal.Marshall.CollectIdContext ForID(Transaction + transaction, IdObjectCollector collector, int id) + { + StatefulBuffer reader = transaction.Container().ReadStatefulBufferById(transaction + , id); + if (reader == null) + { + return null; + } + ObjectHeader oh = new ObjectHeader(transaction.Container(), reader); + return new Db4objects.Db4o.Internal.Marshall.CollectIdContext(transaction, collector + , oh, reader); + } + + public virtual void AddId() + { + int id = ReadInt(); + if (id <= 0) + { + return; + } + AddId(id); + } + + private void AddId(int id) + { + _collector.AddId(id); + } + + public override Db4objects.Db4o.Internal.ClassMetadata ClassMetadata() + { + return _objectHeader.ClassMetadata(); + } + + public virtual TreeInt Ids() + { + return _collector.Ids(); + } + + public virtual void ReadID(IReadsObjectIds objectIDHandler) + { + ObjectID objectID = objectIDHandler.ReadObjectID(this); + if (objectID.IsValid()) + { + AddId(objectID._id); + } + } + + public virtual IdObjectCollector Collector() + { + return _collector; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/ContextState.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/ContextState.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/ContextState.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/ContextState.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,15 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +namespace Db4objects.Db4o.Internal.Marshall +{ + /// + public class ContextState + { + public readonly int _offset; + + public ContextState(int offset) + { + _offset = offset; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/FieldMarshaller0.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/FieldMarshaller0.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/FieldMarshaller0.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/FieldMarshaller0.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,136 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Encoding; +using Db4objects.Db4o.Internal.Handlers; +using Db4objects.Db4o.Internal.Marshall; +using Db4objects.Db4o.Typehandlers; + +namespace Db4objects.Db4o.Internal.Marshall +{ + /// + public class FieldMarshaller0 : AbstractFieldMarshaller + { + public override int MarshalledLength(ObjectContainerBase stream, ClassAspect aspect + ) + { + int len = stream.StringIO().ShortLength(aspect.GetName()); + if (aspect is FieldMetadata) + { + FieldMetadata field = (FieldMetadata)aspect; + if (field.NeedsArrayAndPrimitiveInfo()) + { + len += 1; + } + if (!(field is VirtualFieldMetadata)) + { + len += Const4.IdLength; + } + } + return len; + } + + protected override RawFieldSpec ReadSpec(AspectType aspectType, ObjectContainerBase + stream, ByteArrayBuffer reader) + { + string name = StringHandler.ReadStringNoDebug(stream.Transaction.Context(), reader + ); + if (!aspectType.IsFieldMetadata()) + { + return new RawFieldSpec(aspectType, name); + } + if (name.IndexOf(Const4.VirtualFieldPrefix) == 0) + { + if (stream._handlers.VirtualFieldByName(name) != null) + { + return new RawFieldSpec(aspectType, name); + } + } + int fieldTypeID = reader.ReadInt(); + byte attribs = reader.ReadByte(); + return new RawFieldSpec(aspectType, name, fieldTypeID, attribs); + } + + public sealed override FieldMetadata Read(ObjectContainerBase stream, ClassMetadata + containingClass, ByteArrayBuffer reader) + { + RawFieldSpec spec = ReadSpec(stream, reader); + return FromSpec(spec, stream, containingClass); + } + + protected virtual FieldMetadata FromSpec(RawFieldSpec spec, ObjectContainerBase stream + , ClassMetadata containingClass) + { + if (spec == null) + { + return null; + } + string name = spec.Name(); + if (spec.IsVirtualField()) + { + return stream._handlers.VirtualFieldByName(name); + } + if (spec.IsTranslator()) + { + return new TranslatedAspect(containingClass, name); + } + if (spec.IsField()) + { + return new FieldMetadata(containingClass, name, spec.FieldTypeID(), spec.IsPrimitive + (), spec.IsArray(), spec.IsNArray()); + } + return new UnknownTypeHandlerAspect(containingClass, name); + } + + public override void Write(Transaction trans, ClassMetadata clazz, ClassAspect aspect + , ByteArrayBuffer writer) + { + writer.WriteShortString(trans, aspect.GetName()); + if (!(aspect is FieldMetadata)) + { + return; + } + FieldMetadata field = (FieldMetadata)aspect; + field.Alive(); + if (field.IsVirtual()) + { + return; + } + ITypeHandler4 handler = field.GetHandler(); + if (handler is StandardReferenceTypeHandler) + { + // TODO: ensure there is a test case, to make this happen + if (((StandardReferenceTypeHandler)handler).ClassMetadata().GetID() == 0) + { + trans.Container().NeedsUpdate(clazz); + } + } + writer.WriteInt(field.FieldTypeID()); + BitMap4 bitmap = new BitMap4(3); + bitmap.Set(0, field.IsPrimitive()); + bitmap.Set(1, Handlers4.HandlesArray(handler)); + bitmap.Set(2, Handlers4.HandlesMultidimensionalArray(handler)); + // keep the order + writer.WriteByte(bitmap.GetByte(0)); + } + + public override void Defrag(ClassMetadata classMetadata, ClassAspect aspect, LatinStringIO + sio, DefragmentContextImpl context) + { + context.IncrementStringOffset(sio); + if (!(aspect is FieldMetadata)) + { + return; + } + if (((FieldMetadata)aspect).IsVirtual()) + { + return; + } + // handler ID + context.CopyID(); + // skip primitive/array/narray attributes + context.IncrementOffset(1); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/FieldMarshaller1.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/FieldMarshaller1.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/FieldMarshaller1.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/FieldMarshaller1.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,110 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Btree; +using Db4objects.Db4o.Internal.Encoding; +using Db4objects.Db4o.Internal.Marshall; + +namespace Db4objects.Db4o.Internal.Marshall +{ + /// + public class FieldMarshaller1 : FieldMarshaller0 + { + private bool HasBTreeIndex(FieldMetadata field) + { + return !field.IsVirtual(); + } + + public override void Write(Transaction trans, ClassMetadata clazz, ClassAspect aspect + , ByteArrayBuffer writer) + { + base.Write(trans, clazz, aspect, writer); + if (!(aspect is FieldMetadata)) + { + return; + } + FieldMetadata field = (FieldMetadata)aspect; + if (!HasBTreeIndex(field)) + { + return; + } + writer.WriteIDOf(trans, field.GetIndex(trans)); + } + + protected override RawFieldSpec ReadSpec(AspectType aspectType, ObjectContainerBase + stream, ByteArrayBuffer reader) + { + RawFieldSpec spec = base.ReadSpec(aspectType, stream, reader); + if (spec == null) + { + return null; + } + if (spec.IsVirtual()) + { + return spec; + } + int indexID = reader.ReadInt(); + spec.IndexID(indexID); + return spec; + } + + protected override FieldMetadata FromSpec(RawFieldSpec spec, ObjectContainerBase + stream, ClassMetadata containingClass) + { + FieldMetadata actualField = base.FromSpec(spec, stream, containingClass); + if (spec == null) + { + return null; + } + if (spec.IndexID() != 0) + { + actualField.InitIndex(stream.SystemTransaction(), spec.IndexID()); + } + return actualField; + } + + public override int MarshalledLength(ObjectContainerBase stream, ClassAspect aspect + ) + { + int len = base.MarshalledLength(stream, aspect); + if (!(aspect is FieldMetadata)) + { + return len; + } + FieldMetadata field = (FieldMetadata)aspect; + if (!HasBTreeIndex(field)) + { + return len; + } + return len + Const4.IdLength; + } + + public override void Defrag(ClassMetadata classMetadata, ClassAspect aspect, LatinStringIO + sio, DefragmentContextImpl context) + { + base.Defrag(classMetadata, aspect, sio, context); + if (!(aspect is FieldMetadata)) + { + return; + } + FieldMetadata field = (FieldMetadata)aspect; + if (field.IsVirtual()) + { + return; + } + if (field.HasIndex()) + { + BTree index = field.GetIndex(context.SystemTrans()); + int targetIndexID = context.CopyID(); + if (targetIndexID != 0) + { + index.DefragBTree(context.Services()); + } + } + else + { + context.WriteInt(0); + } + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/FieldMarshaller2.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/FieldMarshaller2.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/FieldMarshaller2.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/FieldMarshaller2.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,40 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Encoding; +using Db4objects.Db4o.Internal.Marshall; + +namespace Db4objects.Db4o.Internal.Marshall +{ + /// + public class FieldMarshaller2 : FieldMarshaller1 + { + private const int AspectTypeTagLength = 1; + + public override int MarshalledLength(ObjectContainerBase stream, ClassAspect aspect + ) + { + return base.MarshalledLength(stream, aspect) + AspectTypeTagLength; + } + + protected override RawFieldSpec ReadSpec(AspectType aspectType, ObjectContainerBase + stream, ByteArrayBuffer reader) + { + return base.ReadSpec(AspectType.ForByte(reader.ReadByte()), stream, reader); + } + + public override void Write(Transaction trans, ClassMetadata clazz, ClassAspect aspect + , ByteArrayBuffer writer) + { + writer.WriteByte(aspect.AspectType()._id); + base.Write(trans, clazz, aspect, writer); + } + + public override void Defrag(ClassMetadata classMetadata, ClassAspect aspect, LatinStringIO + sio, DefragmentContextImpl context) + { + context.ReadByte(); + base.Defrag(classMetadata, aspect, sio, context); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/IAspectVersionContext.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/IAspectVersionContext.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/IAspectVersionContext.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/IAspectVersionContext.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,12 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +namespace Db4objects.Db4o.Internal.Marshall +{ + /// + public interface IAspectVersionContext + { + int DeclaredAspectCount(); + + void DeclaredAspectCount(int count); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/IdObjectCollector.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/IdObjectCollector.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/IdObjectCollector.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/IdObjectCollector.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,36 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System.Collections; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal; + +namespace Db4objects.Db4o.Internal.Marshall +{ + /// + public class IdObjectCollector + { + private TreeInt _ids; + + private List4 _objects; + + public virtual void AddId(int id) + { + _ids = (TreeInt)((TreeInt)Tree.Add(_ids, new TreeInt(id))); + } + + public virtual TreeInt Ids() + { + return _ids; + } + + public virtual void Add(object obj) + { + _objects = new List4(_objects, obj); + } + + public virtual IEnumerator Objects() + { + return new Iterator4Impl(_objects); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/IFieldMarshaller.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/IFieldMarshaller.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/IFieldMarshaller.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/IFieldMarshaller.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,25 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Encoding; +using Db4objects.Db4o.Internal.Marshall; + +namespace Db4objects.Db4o.Internal.Marshall +{ + /// + public interface IFieldMarshaller + { + void Write(Transaction trans, ClassMetadata clazz, ClassAspect aspect, ByteArrayBuffer + writer); + + RawFieldSpec ReadSpec(ObjectContainerBase stream, ByteArrayBuffer reader); + + FieldMetadata Read(ObjectContainerBase stream, ClassMetadata clazz, ByteArrayBuffer + reader); + + int MarshalledLength(ObjectContainerBase stream, ClassAspect aspect); + + void Defrag(ClassMetadata classMetadata, ClassAspect aspect, LatinStringIO sio, DefragmentContextImpl + context); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/IHandlerVersionContext.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/IHandlerVersionContext.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/IHandlerVersionContext.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/IHandlerVersionContext.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,14 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Marshall; + +namespace Db4objects.Db4o.Internal.Marshall +{ + /// + public interface IHandlerVersionContext : IContext + { + int HandlerVersion(); + + Db4objects.Db4o.Internal.Marshall.SlotFormat SlotFormat(); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/IInternalReadContext.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/IInternalReadContext.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/IInternalReadContext.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/IInternalReadContext.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,33 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Marshall; +using Db4objects.Db4o.Marshall; +using Db4objects.Db4o.Typehandlers; + +namespace Db4objects.Db4o.Internal.Marshall +{ + /// + public interface IInternalReadContext : IReadContext, IHandlerVersionContext + { + IReadBuffer Buffer(IReadBuffer buffer); + + IReadBuffer Buffer(); + + ObjectContainerBase Container(); + + int Offset(); + + object Read(ITypeHandler4 handler); + + object ReadAtCurrentSeekPosition(ITypeHandler4 handler); + + IReadWriteBuffer ReadIndirectedBuffer(); + + void Seek(int offset); + + int HandlerVersion(); + + void NotifyNullReferenceSkipped(); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/IMarshallingInfo.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/IMarshallingInfo.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/IMarshallingInfo.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/IMarshallingInfo.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,19 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal.Marshall; +using Db4objects.Db4o.Marshall; + +namespace Db4objects.Db4o.Internal.Marshall +{ + /// + public interface IMarshallingInfo : IAspectVersionContext + { + Db4objects.Db4o.Internal.ClassMetadata ClassMetadata(); + + IReadBuffer Buffer(); + + void BeginSlot(); + + bool IsNull(int fieldIndex); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/IObjectIdContext.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/IObjectIdContext.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/IObjectIdContext.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/IObjectIdContext.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,12 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal.Marshall; + +namespace Db4objects.Db4o.Internal.Marshall +{ + /// + public interface IObjectIdContext : IHandlerVersionContext, IInternalReadContext + { + int ObjectId(); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/MarshallerFamily.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/MarshallerFamily.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/MarshallerFamily.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/MarshallerFamily.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,129 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using Db4objects.Db4o.Ext; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Convert.Conversions; +using Db4objects.Db4o.Internal.Marshall; + +namespace Db4objects.Db4o.Internal.Marshall +{ + /// + /// Represents a db4o file format version, assembles all the marshallers + /// needed to read/write this specific version. + /// + /// + /// Represents a db4o file format version, assembles all the marshallers + /// needed to read/write this specific version. + /// A marshaller knows how to read/write certain types of values from/to its + /// representation on disk for a given db4o file format version. + /// Responsibilities are somewhat overlapping with TypeHandler's. + /// + /// + public class MarshallerFamily + { + public class FamilyVersion + { + public const int PreMarshaller = 0; + + public const int Marshaller = 1; + + public const int BtreeFieldIndexes = 2; + + public const int ClassAspects = 3; + } + + private static int CurrentVersion = MarshallerFamily.FamilyVersion.ClassAspects; + + public readonly ClassMarshaller _class; + + public readonly IFieldMarshaller _field; + + public readonly PrimitiveMarshaller _primitive; + + private readonly int _converterVersion; + + private readonly int _handlerVersion; + + private static readonly MarshallerFamily[] allVersions; + + static MarshallerFamily() + { + allVersions = new MarshallerFamily[HandlerRegistry.HandlerVersion + 1]; + allVersions[0] = new MarshallerFamily(0, 0, new ClassMarshaller0(), new FieldMarshaller0 + (), new PrimitiveMarshaller0()); + // LEGACY => before 5.4 + allVersions[1] = new MarshallerFamily(ClassIndexesToBTrees_5_5.Version, 1, new ClassMarshaller1 + (), new FieldMarshaller0(), new PrimitiveMarshaller1()); + allVersions[2] = new MarshallerFamily(FieldIndexesToBTrees_5_7.Version, 2, new ClassMarshaller2 + (), new FieldMarshaller1(), new PrimitiveMarshaller1()); + for (int i = 3; i < allVersions.Length; i++) + { + allVersions[i] = LatestFamily(i); + } + } + + public MarshallerFamily(int converterVersion, int handlerVersion, ClassMarshaller + classMarshaller, IFieldMarshaller fieldMarshaller, PrimitiveMarshaller primitiveMarshaller + ) + { + _converterVersion = converterVersion; + _handlerVersion = handlerVersion; + _class = classMarshaller; + _class._family = this; + _field = fieldMarshaller; + _primitive = primitiveMarshaller; + _primitive._family = this; + } + + public static MarshallerFamily LatestFamily(int version) + { + return new MarshallerFamily(ClassAspects_7_4.Version, version, new ClassMarshaller2 + (), new FieldMarshaller2(), new PrimitiveMarshaller1()); + } + + public static MarshallerFamily Version(int n) + { + CheckIfVersionIsTooNew(n); + return allVersions[n]; + } + + private static void CheckIfVersionIsTooNew(int n) + { + if (n > allVersions.Length) + { + throw new IncompatibleFileFormatException("Databasefile was created with a newer db4o version. Marshaller version: " + + n); + } + } + + public static MarshallerFamily Current() + { + if (CurrentVersion < MarshallerFamily.FamilyVersion.BtreeFieldIndexes) + { + throw new InvalidOperationException("Using old marshaller versions to write database files is not supported, source code has been removed." + ); + } + return Version(CurrentVersion); + } + + public static MarshallerFamily ForConverterVersion(int n) + { + MarshallerFamily result = allVersions[0]; + for (int i = 1; i < allVersions.Length; i++) + { + if (allVersions[i]._converterVersion > n) + { + return result; + } + result = allVersions[i]; + } + return result; + } + + public virtual int HandlerVersion() + { + return _handlerVersion; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/MarshallingContext.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/MarshallingContext.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/MarshallingContext.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/MarshallingContext.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,396 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Activation; +using Db4objects.Db4o.Internal.Marshall; +using Db4objects.Db4o.Internal.Slots; +using Db4objects.Db4o.Marshall; +using Db4objects.Db4o.Typehandlers; + +namespace Db4objects.Db4o.Internal.Marshall +{ + /// + public class MarshallingContext : IMarshallingInfo, IWriteContext + { + private const int HeaderLength = Const4.LeadingLength + Const4.IdLength + 1 + Const4 + .IntLength; + + private readonly Db4objects.Db4o.Internal.Transaction _transaction; + + private readonly ObjectReference _reference; + + private IUpdateDepth _updateDepth; + + private readonly bool _isNew; + + private readonly BitMap4 _nullBitMap; + + private readonly MarshallingBuffer _writeBuffer; + + private MarshallingBuffer _currentBuffer; + + private ByteArrayBuffer _debugPrepend; + + private object _currentMarshalledObject; + + private object _currentIndexEntry; + + private int _declaredAspectCount; + + public MarshallingContext(Db4objects.Db4o.Internal.Transaction trans, ObjectReference + @ref, IUpdateDepth updateDepth, bool isNew) + { + // YapClass ID + // Marshaller Version + // number of fields + _transaction = trans; + _reference = @ref; + _nullBitMap = new BitMap4(AspectCount()); + _updateDepth = ClassMetadata().AdjustUpdateDepth(trans, updateDepth); + _isNew = isNew; + _writeBuffer = new MarshallingBuffer(); + _currentBuffer = _writeBuffer; + } + + private int AspectCount() + { + return ClassMetadata().AspectCount(); + } + + public virtual Db4objects.Db4o.Internal.ClassMetadata ClassMetadata() + { + return _reference.ClassMetadata(); + } + + public virtual bool IsNew() + { + return _isNew; + } + + public virtual bool IsNull(int fieldIndex) + { + // TODO Auto-generated method stub + return false; + } + + public virtual void IsNull(int fieldIndex, bool flag) + { + _nullBitMap.Set(fieldIndex, flag); + } + + public virtual Db4objects.Db4o.Internal.Transaction Transaction() + { + return _transaction; + } + + public virtual Slot AllocateNewSlot(int length) + { + if (_transaction is LocalTransaction) + { + return LocalContainer().AllocateSlotForNewUserObject(_transaction, ObjectID(), length + ); + } + return new Slot(Slot.New, length); + } + + private Slot AllocateUpdateSlot(int length) + { + if (_transaction is LocalTransaction) + { + return LocalContainer().AllocateSlotForUserObjectUpdate(Transaction(), ObjectID() + , length); + } + return new Slot(Slot.Update, length); + } + + private LocalObjectContainer LocalContainer() + { + return ((LocalTransaction)Transaction()).LocalContainer(); + } + + public virtual Pointer4 AllocateSlot() + { + int length = Container().BlockConverter().BlockAlignedBytes(MarshalledLength()); + Slot slot = IsNew() ? AllocateNewSlot(length) : AllocateUpdateSlot(length); + return new Pointer4(ObjectID(), slot); + } + + public virtual ByteArrayBuffer ToWriteBuffer(Pointer4 pointer) + { + ByteArrayBuffer buffer = new ByteArrayBuffer(pointer.Length()); + _writeBuffer.MergeChildren(this, pointer.Address(), WriteBufferOffset()); + WriteObjectClassID(buffer, ClassMetadata().GetID()); + buffer.WriteByte(HandlerRegistry.HandlerVersion); + buffer.WriteInt(AspectCount()); + buffer.WriteBitMap(_nullBitMap); + _writeBuffer.TransferContentTo(buffer); + return buffer; + } + + private int WriteBufferOffset() + { + return HeaderLength + _nullBitMap.MarshalledLength(); + } + + public virtual int MarshalledLength() + { + int length = WriteBufferOffset(); + _writeBuffer.CheckBlockAlignment(this, null, new IntByRef(length)); + return length + _writeBuffer.MarshalledLength() + Const4.BracketsBytes; + } + + public virtual int RequiredLength(MarshallingBuffer buffer, bool align) + { + if (!align) + { + return buffer.Length(); + } + return Container().BlockConverter().BlockAlignedBytes(buffer.Length()); + } + + private void WriteObjectClassID(ByteArrayBuffer reader, int id) + { + reader.WriteInt(-id); + } + + public virtual object GetObject() + { + return _reference.GetObject(); + } + + public virtual Config4Class ClassConfiguration() + { + return ClassMetadata().Config(); + } + + public virtual IUpdateDepth UpdateDepth() + { + return _updateDepth; + } + + public virtual void UpdateDepth(IUpdateDepth depth) + { + _updateDepth = depth; + } + + public virtual int ObjectID() + { + return _reference.GetID(); + } + + public virtual object CurrentIndexEntry() + { + // TODO Auto-generated method stub + return null; + } + + public virtual ObjectContainerBase Container() + { + return Transaction().Container(); + } + + public virtual IObjectContainer ObjectContainer() + { + return Transaction().ObjectContainer(); + } + + public virtual void WriteByte(byte b) + { + PreWrite(); + _currentBuffer.WriteByte(b); + PostWrite(); + } + + public virtual void WriteBytes(byte[] bytes) + { + PreWrite(); + _currentBuffer.WriteBytes(bytes); + PostWrite(); + } + + public virtual void WriteInt(int i) + { + PreWrite(); + _currentBuffer.WriteInt(i); + PostWrite(); + } + + public virtual void WriteLong(long l) + { + PreWrite(); + _currentBuffer.WriteLong(l); + PostWrite(); + } + + private void PreWrite() + { + } + + private void PostWrite() + { + } + + public virtual void CreateChildBuffer(bool storeLengthInLink) + { + MarshallingBuffer childBuffer = _currentBuffer.AddChild(false, storeLengthInLink); + _currentBuffer.ReserveChildLinkSpace(storeLengthInLink); + _currentBuffer = childBuffer; + } + + public virtual void BeginSlot() + { + _currentBuffer = _writeBuffer; + } + + public virtual void WriteDeclaredAspectCount(int count) + { + _writeBuffer.WriteInt(count); + } + + public virtual void DebugPrependNextWrite(ByteArrayBuffer prepend) + { + } + + public virtual void DebugWriteEnd(byte b) + { + _currentBuffer.WriteByte(b); + } + + public virtual void WriteObject(object obj) + { + int id = Container().StoreInternal(Transaction(), obj, _updateDepth, true); + WriteInt(id); + _currentMarshalledObject = obj; + _currentIndexEntry = id; + } + + public virtual void WriteObject(ITypeHandler4 handler, object obj) + { + MarshallingContextState state = CurrentState(); + WriteObjectWithCurrentState(handler, obj); + RestoreState(state); + } + + public virtual void WriteObjectWithCurrentState(ITypeHandler4 handler, object obj + ) + { + if (Handlers4.UseDedicatedSlot(this, handler)) + { + WriteObject(obj); + } + else + { + if (obj == null) + { + WriteNullReference(handler); + } + else + { + CreateIndirectionWithinSlot(handler); + handler.Write(this, obj); + } + } + } + + private void WriteNullReference(ITypeHandler4 handler) + { + if (IsIndirectedWithinSlot(handler)) + { + WriteNullLink(); + return; + } + Handlers4.Write(handler, this, Handlers4.NullRepresentationInUntypedArrays(handler + )); + } + + private void WriteNullLink() + { + WriteInt(0); + WriteInt(0); + } + + public virtual void AddIndexEntry(FieldMetadata fieldMetadata, object obj) + { + if (!_currentBuffer.HasParent()) + { + object indexEntry = (obj == _currentMarshalledObject) ? _currentIndexEntry : obj; + if (_isNew || !UpdateDepth().CanSkip(_reference)) + { + fieldMetadata.AddIndexEntry(Transaction(), ObjectID(), indexEntry); + } + return; + } + _currentBuffer.RequestIndexEntry(fieldMetadata); + } + + public virtual void PurgeFieldIndexEntriesOnUpdate(Db4objects.Db4o.Internal.Transaction + transaction, ArrayType arrayType) + { + if (!UpdateDepth().CanSkip(_reference)) + { + transaction.WriteUpdateAdjustIndexes(_reference.GetID(), _reference.ClassMetadata + (), arrayType); + } + } + + public virtual ObjectReference Reference() + { + return _reference; + } + + public virtual void CreateIndirectionWithinSlot(ITypeHandler4 handler) + { + if (IsIndirectedWithinSlot(handler)) + { + CreateIndirectionWithinSlot(); + } + } + + public virtual void CreateIndirectionWithinSlot() + { + CreateChildBuffer(true); + } + + private bool IsIndirectedWithinSlot(ITypeHandler4 handler) + { + return SlotFormat.Current().IsIndirectedWithinSlot(handler); + } + + // FIXME: This method was just temporarily added to fulfill contract of MarshallingInfo + // It will go, the buffer is never needed in new marshalling. + public virtual IReadBuffer Buffer() + { + return null; + } + + public virtual MarshallingContextState CurrentState() + { + return new MarshallingContextState(_currentBuffer); + } + + public virtual void RestoreState(MarshallingContextState state) + { + _currentBuffer = state._buffer; + } + + public virtual IReservedBuffer Reserve(int length) + { + PreWrite(); + IReservedBuffer reservedBuffer = _currentBuffer.Reserve(length); + PostWrite(); + return reservedBuffer; + } + + public virtual int DeclaredAspectCount() + { + return _declaredAspectCount; + } + + public virtual void DeclaredAspectCount(int count) + { + _declaredAspectCount = count; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/MarshallingContextState.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/MarshallingContextState.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/MarshallingContextState.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/MarshallingContextState.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,17 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal; + +namespace Db4objects.Db4o.Internal.Marshall +{ + /// + public class MarshallingContextState + { + internal readonly MarshallingBuffer _buffer; + + public MarshallingContextState(MarshallingBuffer buffer) + { + _buffer = buffer; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/ObjectHeaderAttributes.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/ObjectHeaderAttributes.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/ObjectHeaderAttributes.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/ObjectHeaderAttributes.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,26 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal; + +namespace Db4objects.Db4o.Internal.Marshall +{ + /// + public class ObjectHeaderAttributes + { + private readonly int _fieldCount; + + private readonly BitMap4 _nullBitMap; + + public ObjectHeaderAttributes(ByteArrayBuffer reader) + { + _fieldCount = reader.ReadInt(); + _nullBitMap = reader.ReadBitMap(_fieldCount); + } + + public virtual bool IsNull(int fieldIndex) + { + return _nullBitMap.IsTrue(fieldIndex); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/ObjectHeaderContext.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/ObjectHeaderContext.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/ObjectHeaderContext.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/ObjectHeaderContext.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,67 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Marshall; +using Db4objects.Db4o.Marshall; + +namespace Db4objects.Db4o.Internal.Marshall +{ + /// + public class ObjectHeaderContext : AbstractReadContext, IMarshallingInfo, IHandlerVersionContext + { + protected ObjectHeader _objectHeader; + + private int _declaredAspectCount; + + public ObjectHeaderContext(Transaction transaction, IReadBuffer buffer, ObjectHeader + objectHeader) : base(transaction, buffer) + { + _objectHeader = objectHeader; + } + + public ObjectHeaderAttributes HeaderAttributes() + { + return _objectHeader._headerAttributes; + } + + public bool IsNull(int fieldIndex) + { + return HeaderAttributes().IsNull(fieldIndex); + } + + public override int HandlerVersion() + { + return _objectHeader.HandlerVersion(); + } + + public virtual void BeginSlot() + { + } + + // do nothing + public virtual ContextState SaveState() + { + return new ContextState(Offset()); + } + + public virtual void RestoreState(ContextState state) + { + Seek(state._offset); + } + + public virtual Db4objects.Db4o.Internal.ClassMetadata ClassMetadata() + { + return _objectHeader.ClassMetadata(); + } + + public virtual int DeclaredAspectCount() + { + return _declaredAspectCount; + } + + public virtual void DeclaredAspectCount(int count) + { + _declaredAspectCount = count; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/ObjectHeader.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/ObjectHeader.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/ObjectHeader.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/ObjectHeader.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,104 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Marshall; + +namespace Db4objects.Db4o.Internal.Marshall +{ + /// + public sealed class ObjectHeader + { + private readonly Db4objects.Db4o.Internal.ClassMetadata _classMetadata; + + public readonly MarshallerFamily _marshallerFamily; + + public readonly ObjectHeaderAttributes _headerAttributes; + + private int _handlerVersion; + + public ObjectHeader(ObjectContainerBase container, IReadWriteBuffer reader) : this + (container, null, reader) + { + } + + public ObjectHeader(Db4objects.Db4o.Internal.ClassMetadata classMetadata, IReadWriteBuffer + reader) : this(null, classMetadata, reader) + { + } + + private ObjectHeader(ObjectContainerBase container, Db4objects.Db4o.Internal.ClassMetadata + classMetadata, IReadWriteBuffer reader) + { + int classID = reader.ReadInt(); + _marshallerFamily = ReadMarshallerFamily(reader, classID); + classID = NormalizeID(classID); + _classMetadata = (classMetadata != null ? classMetadata : container.ClassMetadataForID + (classID)); + // This check has been added to cope with defragment in debug mode: SlotDefragment#setIdentity() + // will trigger calling this constructor with a source db class metadata and a target db stream, + // thus _classMetadata==null. There may be a better solution, since this call is just meant to + // skip the object header. + _headerAttributes = SlotFormat().ReadHeaderAttributes((ByteArrayBuffer)reader); + } + + public static Db4objects.Db4o.Internal.Marshall.ObjectHeader Defrag(DefragmentContextImpl + context) + { + ByteArrayBuffer source = context.SourceBuffer(); + ByteArrayBuffer target = context.TargetBuffer(); + Db4objects.Db4o.Internal.Marshall.ObjectHeader header = new Db4objects.Db4o.Internal.Marshall.ObjectHeader + (context.Services().SystemTrans().Container(), null, source); + int newID = context.Mapping().StrictMappedID(header.ClassMetadata().GetID()); + Db4objects.Db4o.Internal.Marshall.SlotFormat slotFormat = header.SlotFormat(); + slotFormat.WriteObjectClassID(target, newID); + slotFormat.SkipMarshallerInfo(target); + slotFormat.ReadHeaderAttributes(target); + return header; + } + + private Db4objects.Db4o.Internal.Marshall.SlotFormat SlotFormat() + { + return Db4objects.Db4o.Internal.Marshall.SlotFormat.ForHandlerVersion(HandlerVersion + ()); + } + + private MarshallerFamily ReadMarshallerFamily(IReadWriteBuffer reader, int classID + ) + { + bool marshallerAware = MarshallerAware(classID); + _handlerVersion = 0; + if (marshallerAware) + { + _handlerVersion = reader.ReadByte(); + } + MarshallerFamily marshallerFamily = MarshallerFamily.Version(_handlerVersion); + return marshallerFamily; + } + + private bool MarshallerAware(int id) + { + return id < 0; + } + + private int NormalizeID(int id) + { + return (id < 0 ? -id : id); + } + + public Db4objects.Db4o.Internal.ClassMetadata ClassMetadata() + { + return _classMetadata; + } + + public int HandlerVersion() + { + return _handlerVersion; + } + + public static Db4objects.Db4o.Internal.Marshall.ObjectHeader ScrollBufferToContent + (LocalObjectContainer container, ByteArrayBuffer buffer) + { + return new Db4objects.Db4o.Internal.Marshall.ObjectHeader(container, buffer); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/ObjectIdContextImpl.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/ObjectIdContextImpl.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/ObjectIdContextImpl.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/ObjectIdContextImpl.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,25 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Marshall; +using Db4objects.Db4o.Marshall; + +namespace Db4objects.Db4o.Internal.Marshall +{ + /// + public class ObjectIdContextImpl : ObjectHeaderContext, IObjectIdContext + { + private readonly int _id; + + public ObjectIdContextImpl(Transaction transaction, IReadBuffer buffer, ObjectHeader + objectHeader, int id) : base(transaction, buffer, objectHeader) + { + _id = id; + } + + public virtual int ObjectId() + { + return _id; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/ObjectReferenceContext.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/ObjectReferenceContext.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/ObjectReferenceContext.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/ObjectReferenceContext.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,46 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Marshall; +using Db4objects.Db4o.Marshall; + +namespace Db4objects.Db4o.Internal.Marshall +{ + public class ObjectReferenceContext : ObjectHeaderContext, IObjectIdContext + { + protected readonly Db4objects.Db4o.Internal.ObjectReference _reference; + + public ObjectReferenceContext(Transaction transaction, IReadBuffer buffer, ObjectHeader + objectHeader, Db4objects.Db4o.Internal.ObjectReference reference) : base(transaction + , buffer, objectHeader) + { + _reference = reference; + } + + public virtual int ObjectId() + { + return _reference.GetID(); + } + + public override Db4objects.Db4o.Internal.ClassMetadata ClassMetadata() + { + Db4objects.Db4o.Internal.ClassMetadata classMetadata = _reference.ClassMetadata(); + if (classMetadata == null) + { + throw new InvalidOperationException(); + } + return classMetadata; + } + + public virtual Db4objects.Db4o.Internal.ObjectReference ObjectReference() + { + return _reference; + } + + protected virtual Db4objects.Db4o.Internal.ByteArrayBuffer ByteArrayBuffer() + { + return (Db4objects.Db4o.Internal.ByteArrayBuffer)Buffer(); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/PrimitiveMarshaller0.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/PrimitiveMarshaller0.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/PrimitiveMarshaller0.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/PrimitiveMarshaller0.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,96 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Marshall; + +namespace Db4objects.Db4o.Internal.Marshall +{ + public class PrimitiveMarshaller0 : PrimitiveMarshaller + { + public override bool UseNormalClassRead() + { + return true; + } + + public override DateTime ReadDate(ByteArrayBuffer bytes) + { + long value = bytes.ReadLong(); + if (value == long.MaxValue) + { + return MarshallingConstants0.NullDate; + } + return new DateTime(value); + } + + public override object ReadInteger(ByteArrayBuffer bytes) + { + int value = bytes.ReadInt(); + if (value == int.MaxValue) + { + return null; + } + return value; + } + + public override object ReadFloat(ByteArrayBuffer bytes) + { + float value = UnmarshallFloat(bytes); + if (float.IsNaN(value)) + { + return null; + } + return value; + } + + public override object ReadDouble(ByteArrayBuffer buffer) + { + double value = UnmarshalDouble(buffer); + if (double.IsNaN(value)) + { + return null; + } + return value; + } + + public override object ReadLong(ByteArrayBuffer buffer) + { + long value = buffer.ReadLong(); + if (value == long.MaxValue) + { + return null; + } + return value; + } + + public override object ReadShort(ByteArrayBuffer buffer) + { + short value = UnmarshallShort(buffer); + if (value == short.MaxValue) + { + return null; + } + return value; + } + + public static double UnmarshalDouble(ByteArrayBuffer buffer) + { + return Platform4.LongToDouble(buffer.ReadLong()); + } + + public static float UnmarshallFloat(ByteArrayBuffer buffer) + { + return Sharpen.Runtime.IntBitsToFloat(buffer.ReadInt()); + } + + public static short UnmarshallShort(ByteArrayBuffer buffer) + { + int ret = 0; + for (int i = 0; i < Const4.ShortBytes; i++) + { + ret = (ret << 8) + (buffer._buffer[buffer._offset++] & unchecked((int)(0xff))); + } + return (short)ret; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/PrimitiveMarshaller1.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/PrimitiveMarshaller1.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/PrimitiveMarshaller1.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/PrimitiveMarshaller1.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,46 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Marshall; + +namespace Db4objects.Db4o.Internal.Marshall +{ + public class PrimitiveMarshaller1 : PrimitiveMarshaller + { + public override bool UseNormalClassRead() + { + return false; + } + + public override DateTime ReadDate(ByteArrayBuffer bytes) + { + return new DateTime(bytes.ReadLong()); + } + + public override object ReadInteger(ByteArrayBuffer bytes) + { + return bytes.ReadInt(); + } + + public override object ReadFloat(ByteArrayBuffer bytes) + { + return PrimitiveMarshaller0.UnmarshallFloat(bytes); + } + + public override object ReadDouble(ByteArrayBuffer buffer) + { + return PrimitiveMarshaller0.UnmarshalDouble(buffer); + } + + public override object ReadLong(ByteArrayBuffer buffer) + { + return buffer.ReadLong(); + } + + public override object ReadShort(ByteArrayBuffer buffer) + { + return PrimitiveMarshaller0.UnmarshallShort(buffer); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/PrimitiveMarshaller.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/PrimitiveMarshaller.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/PrimitiveMarshaller.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/PrimitiveMarshaller.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,27 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Marshall; + +namespace Db4objects.Db4o.Internal.Marshall +{ + public abstract class PrimitiveMarshaller + { + public MarshallerFamily _family; + + public abstract bool UseNormalClassRead(); + + public abstract DateTime ReadDate(ByteArrayBuffer bytes); + + public abstract object ReadShort(ByteArrayBuffer buffer); + + public abstract object ReadInteger(ByteArrayBuffer buffer); + + public abstract object ReadFloat(ByteArrayBuffer buffer); + + public abstract object ReadDouble(ByteArrayBuffer buffer); + + public abstract object ReadLong(ByteArrayBuffer buffer); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/QueryingReadContext.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/QueryingReadContext.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/QueryingReadContext.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/QueryingReadContext.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,183 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using System.Collections; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Activation; +using Db4objects.Db4o.Internal.Marshall; +using Db4objects.Db4o.Internal.Query.Processor; +using Db4objects.Db4o.Marshall; +using Db4objects.Db4o.Typehandlers; + +namespace Db4objects.Db4o.Internal.Marshall +{ + /// + public class QueryingReadContext : AbstractReadContext, IHandlerVersionContext, IAspectVersionContext + , IObjectIdContext + { + private readonly QCandidates _candidates; + + private readonly int _collectionID; + + private readonly int _handlerVersion; + + private IdObjectCollector _collector; + + private int _declaredAspectCount; + + private int _id; + + private QueryingReadContext(Transaction transaction, QCandidates candidates, int + handlerVersion, IReadBuffer buffer, int collectionID, IdObjectCollector collector + ) : base(transaction, buffer) + { + _candidates = candidates; + _activationDepth = new LegacyActivationDepth(0); + _collectionID = collectionID; + _handlerVersion = handlerVersion; + _collector = collector; + } + + public QueryingReadContext(Transaction transaction, QCandidates candidates, int handlerVersion + , IReadBuffer buffer, int collectionID) : this(transaction, candidates, handlerVersion + , buffer, collectionID, new IdObjectCollector()) + { + } + + public QueryingReadContext(Transaction transaction, int handlerVersion, IReadBuffer + buffer, int id) : this(transaction, null, handlerVersion, buffer, 0) + { + _id = id; + } + + public QueryingReadContext(Transaction transaction, int handlerVersion, IReadBuffer + buffer, int collectionID, IdObjectCollector collector) : this(transaction, null + , handlerVersion, buffer, collectionID, collector) + { + } + + public virtual int CollectionID() + { + return _collectionID; + } + + public virtual QCandidates Candidates() + { + return _candidates; + } + + public override int HandlerVersion() + { + return _handlerVersion; + } + + private void AddId(int id) + { + _collector.AddId(id); + } + + public virtual TreeInt Ids() + { + return _collector.Ids(); + } + + public virtual void Add(object obj) + { + int id = GetID(obj); + if (id > 0) + { + AddId(id); + return; + } + AddObjectWithoutId(obj); + } + + private int GetID(object obj) + { + return Container().GetID(Transaction(), obj); + } + + public virtual void ReadId(ITypeHandler4 handler) + { + ObjectID objectID = ObjectID.NotPossible; + try + { + int offset = Offset(); + if (handler is IReadsObjectIds) + { + objectID = ((IReadsObjectIds)handler).ReadObjectID(this); + } + if (objectID.IsValid()) + { + AddId(objectID._id); + return; + } + if (objectID == ObjectID.NotPossible) + { + Seek(offset); + // FIXME: there's no point in activating the object + // just find its id + // type handlers know how to do it + object obj = Read(handler); + if (obj != null) + { + int id = (int)GetID(obj); + if (id > 0) + { + AddId(id); + } + else + { + AddObjectWithoutId(obj); + } + } + } + } + catch (Exception) + { + } + } + + // FIXME: Catchall + private void AddObjectWithoutId(object obj) + { + _collector.Add(obj); + } + + public virtual void SkipId(ITypeHandler4 handler) + { + if (handler is IReadsObjectIds) + { + ((IReadsObjectIds)handler).ReadObjectID(this); + return; + } + // TODO: Optimize for just doing a seek here. + Read(handler); + } + + public virtual IEnumerator ObjectsWithoutId() + { + return _collector.Objects(); + } + + public virtual int DeclaredAspectCount() + { + return _declaredAspectCount; + } + + public virtual void DeclaredAspectCount(int count) + { + _declaredAspectCount = count; + } + + public virtual IdObjectCollector Collector() + { + return _collector; + } + + public virtual int ObjectId() + { + return _id; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/RawClassSpec.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/RawClassSpec.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/RawClassSpec.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/RawClassSpec.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,36 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +namespace Db4objects.Db4o.Internal.Marshall +{ + /// + public class RawClassSpec + { + private readonly string _name; + + private readonly int _superClassID; + + private readonly int _numFields; + + public RawClassSpec(string name, int superClassID, int numFields) + { + _name = name; + _superClassID = superClassID; + _numFields = numFields; + } + + public virtual string Name() + { + return _name; + } + + public virtual int SuperClassID() + { + return _superClassID; + } + + public virtual int NumFields() + { + return _numFields; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/RawFieldSpec.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/RawFieldSpec.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/RawFieldSpec.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/RawFieldSpec.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,117 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal.Marshall; + +namespace Db4objects.Db4o.Internal.Marshall +{ + public class RawFieldSpec + { + private readonly AspectType _type; + + private readonly string _name; + + private readonly int _fieldTypeID; + + private readonly bool _isPrimitive; + + private readonly bool _isArray; + + private readonly bool _isNArray; + + private readonly bool _isVirtual; + + private int _indexID; + + public RawFieldSpec(AspectType aspectType, string name, int fieldTypeID, byte attribs + ) + { + _type = aspectType; + _name = name; + _fieldTypeID = fieldTypeID; + BitMap4 bitmap = new BitMap4(attribs); + _isPrimitive = bitmap.IsTrue(0); + _isArray = bitmap.IsTrue(1); + _isNArray = bitmap.IsTrue(2); + _isVirtual = false; + _indexID = 0; + } + + public RawFieldSpec(AspectType aspectType, string name) + { + _type = aspectType; + _name = name; + _fieldTypeID = 0; + _isPrimitive = false; + _isArray = false; + _isNArray = false; + _isVirtual = true; + _indexID = 0; + } + + public virtual string Name() + { + return _name; + } + + public virtual int FieldTypeID() + { + return _fieldTypeID; + } + + public virtual bool IsPrimitive() + { + return _isPrimitive; + } + + public virtual bool IsArray() + { + return _isArray; + } + + public virtual bool IsNArray() + { + return _isNArray; + } + + public virtual bool IsVirtual() + { + return _isVirtual; + } + + public virtual bool IsVirtualField() + { + return IsVirtual() && IsField(); + } + + public virtual bool IsField() + { + return _type.IsField(); + } + + public virtual int IndexID() + { + return _indexID; + } + + internal virtual void IndexID(int indexID) + { + _indexID = indexID; + } + + public override string ToString() + { + return "RawFieldSpec(" + Name() + ")"; + } + + public virtual bool IsFieldMetadata() + { + return _type.IsFieldMetadata(); + } + + public virtual bool IsTranslator() + { + return _type.IsTranslator(); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/SlotFormat0.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/SlotFormat0.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/SlotFormat0.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/SlotFormat0.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,37 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Marshall; +using Db4objects.Db4o.Typehandlers; + +namespace Db4objects.Db4o.Internal.Marshall +{ + /// + public class SlotFormat0 : SlotFormat + { + protected override int HandlerVersion() + { + return 0; + } + + public override bool IsIndirectedWithinSlot(ITypeHandler4 handler) + { + return false; + } + + public override void WriteObjectClassID(ByteArrayBuffer buffer, int id) + { + buffer.WriteInt(id); + } + + public override void SkipMarshallerInfo(ByteArrayBuffer reader) + { + } + + public override ObjectHeaderAttributes ReadHeaderAttributes(ByteArrayBuffer reader + ) + { + return null; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/SlotFormat2.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/SlotFormat2.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/SlotFormat2.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/SlotFormat2.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,22 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Marshall; +using Db4objects.Db4o.Typehandlers; + +namespace Db4objects.Db4o.Internal.Marshall +{ + /// + public class SlotFormat2 : SlotFormat + { + protected override int HandlerVersion() + { + return 2; + } + + public override bool IsIndirectedWithinSlot(ITypeHandler4 handler) + { + return Handlers4.IsVariableLength(handler); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/SlotFormat.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/SlotFormat.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/SlotFormat.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/SlotFormat.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,118 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Marshall; +using Db4objects.Db4o.Marshall; +using Db4objects.Db4o.Typehandlers; + +namespace Db4objects.Db4o.Internal.Marshall +{ + /// + public abstract class SlotFormat + { + private static readonly Hashtable4 _versions = new Hashtable4(); + + private static readonly Db4objects.Db4o.Internal.Marshall.SlotFormat CurrentSlotFormat + = new SlotFormatCurrent(); + + static SlotFormat() + { + new SlotFormat0(); + new SlotFormat2(); + } + + protected SlotFormat() + { + _versions.Put(HandlerVersion(), this); + } + + public static Db4objects.Db4o.Internal.Marshall.SlotFormat ForHandlerVersion(int + handlerVersion) + { + if (handlerVersion == HandlerRegistry.HandlerVersion) + { + return CurrentSlotFormat; + } + if (handlerVersion < 0 || handlerVersion > CurrentSlotFormat.HandlerVersion()) + { + throw new ArgumentException(); + } + Db4objects.Db4o.Internal.Marshall.SlotFormat slotFormat = (Db4objects.Db4o.Internal.Marshall.SlotFormat + )_versions.Get(handlerVersion); + if (slotFormat != null) + { + return slotFormat; + } + return ForHandlerVersion(handlerVersion + 1); + } + + public override bool Equals(object obj) + { + if (!(obj is Db4objects.Db4o.Internal.Marshall.SlotFormat)) + { + return false; + } + return HandlerVersion() == ((Db4objects.Db4o.Internal.Marshall.SlotFormat)obj).HandlerVersion + (); + } + + public override int GetHashCode() + { + return HandlerVersion(); + } + + protected abstract int HandlerVersion(); + + public abstract bool IsIndirectedWithinSlot(ITypeHandler4 handler); + + public static Db4objects.Db4o.Internal.Marshall.SlotFormat Current() + { + return CurrentSlotFormat; + } + + public virtual object DoWithSlotIndirection(IReadBuffer buffer, ITypeHandler4 typeHandler + , IClosure4 closure) + { + if (!IsIndirectedWithinSlot(typeHandler)) + { + return closure.Run(); + } + return DoWithSlotIndirection(buffer, closure); + } + + public virtual object DoWithSlotIndirection(IReadBuffer buffer, IClosure4 closure + ) + { + int payLoadOffset = buffer.ReadInt(); + buffer.ReadInt(); + // length, not used + int savedOffset = buffer.Offset(); + object res = null; + if (payLoadOffset != 0) + { + buffer.Seek(payLoadOffset); + res = closure.Run(); + } + buffer.Seek(savedOffset); + return res; + } + + public virtual void WriteObjectClassID(ByteArrayBuffer buffer, int id) + { + buffer.WriteInt(-id); + } + + public virtual void SkipMarshallerInfo(ByteArrayBuffer reader) + { + reader.IncrementOffset(1); + } + + public virtual ObjectHeaderAttributes ReadHeaderAttributes(ByteArrayBuffer reader + ) + { + return new ObjectHeaderAttributes(reader); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/SlotFormatCurrent.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/SlotFormatCurrent.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/SlotFormatCurrent.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/SlotFormatCurrent.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,26 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Marshall; +using Db4objects.Db4o.Typehandlers; + +namespace Db4objects.Db4o.Internal.Marshall +{ + /// + public class SlotFormatCurrent : SlotFormat + { + protected override int HandlerVersion() + { + return HandlerRegistry.HandlerVersion; + } + + public override bool IsIndirectedWithinSlot(ITypeHandler4 handler) + { + if (Handlers4.IsUntyped(handler)) + { + return false; + } + return Handlers4.IsVariableLength(handler) && Handlers4.IsValueType(handler); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/UnknownTypeHandlerAspect.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/UnknownTypeHandlerAspect.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/UnknownTypeHandlerAspect.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/UnknownTypeHandlerAspect.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,26 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using Db4objects.Db4o.Internal; + +namespace Db4objects.Db4o.Internal.Marshall +{ + public class UnknownTypeHandlerAspect : FieldMetadata + { + public UnknownTypeHandlerAspect(ClassMetadata containingClass, string name) : base + (containingClass, name) + { + } + + public override void DefragAspect(IDefragmentContext context) + { + throw new InvalidOperationException("Type handler for '" + ContainingClass() + "' could not be found. Defragment cannot proceed. " + + " Please ensure all required types are available and try again."); + } + + public override bool Alive() + { + return false; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/UnmarshallingContext.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/UnmarshallingContext.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/UnmarshallingContext.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Marshall/UnmarshallingContext.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,201 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Ext; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Activation; +using Db4objects.Db4o.Internal.Marshall; +using Db4objects.Db4o.Marshall; +using Db4objects.Db4o.Typehandlers; + +namespace Db4objects.Db4o.Internal.Marshall +{ + /// Wraps the low-level details of reading a Buffer, which in turn is a glorified byte array. + /// + /// Wraps the low-level details of reading a Buffer, which in turn is a glorified byte array. + /// + /// + public class UnmarshallingContext : ObjectReferenceContext, IHandlerVersionContext + , IReferenceActivationContext + { + private object _object; + + private int _addToIDTree; + + private bool _checkIDTree; + + public UnmarshallingContext(Transaction transaction, ByteArrayBuffer buffer, ObjectReference + @ref, int addToIDTree, bool checkIDTree) : base(transaction, buffer, null, @ref + ) + { + _addToIDTree = addToIDTree; + _checkIDTree = checkIDTree; + } + + public UnmarshallingContext(Transaction transaction, ObjectReference @ref, int addToIDTree + , bool checkIDTree) : this(transaction, null, @ref, addToIDTree, checkIDTree) + { + } + + public virtual object Read() + { + if (!BeginProcessing()) + { + return _object; + } + ReadBuffer(ObjectId()); + if (Buffer() == null) + { + EndProcessing(); + return _object; + } + ClassMetadata classMetadata = ReadObjectHeader(); + if (classMetadata == null) + { + InvalidSlot(); + EndProcessing(); + return _object; + } + _reference.ClassMetadata(classMetadata); + AdjustActivationDepth(); + if (_checkIDTree) + { + object objectInCacheFromClassCreation = Transaction().ObjectForIdFromCache(ObjectId + ()); + if (objectInCacheFromClassCreation != null) + { + _object = objectInCacheFromClassCreation; + EndProcessing(); + return _object; + } + } + if (PeekPersisted()) + { + _object = ClassMetadata().InstantiateTransient(this); + } + else + { + _object = ClassMetadata().Instantiate(this); + } + EndProcessing(); + return _object; + } + + private void InvalidSlot() + { + if (Container().Config().RecoveryMode()) + { + return; + } + throw new InvalidSlotException("id: " + ObjectId()); + } + + private void AdjustActivationDepth() + { + if (UnknownActivationDepth.Instance == _activationDepth) + { + _activationDepth = Container().DefaultActivationDepth(ClassMetadata()); + } + } + + private IActivationDepthProvider ActivationDepthProvider() + { + return Container().ActivationDepthProvider(); + } + + public virtual object ReadFullyActivatedObjectForKeys(ITypeHandler4 handler) + { + object obj = ReadObject(handler); + if (obj == null) + { + return obj; + } + IActivationDepth activationDepth = ActivationDepthProvider().ActivationDepth(int.MaxValue + , ActivationMode.Activate); + Container().Activate(Transaction(), obj, activationDepth); + return obj; + } + + public virtual object ReadFieldValue(FieldMetadata field) + { + ReadBuffer(ObjectId()); + if (Buffer() == null) + { + return null; + } + ClassMetadata classMetadata = ReadObjectHeader(); + if (classMetadata == null) + { + return null; + } + return ReadFieldValue(classMetadata, field); + } + + private object ReadFieldValue(ClassMetadata classMetadata, FieldMetadata field) + { + if (!classMetadata.SeekToField(this, field)) + { + return null; + } + return field.Read(this); + } + + private ClassMetadata ReadObjectHeader() + { + _objectHeader = new ObjectHeader(Container(), ByteArrayBuffer()); + ClassMetadata classMetadata = _objectHeader.ClassMetadata(); + if (classMetadata == null) + { + return null; + } + return classMetadata; + } + + private void ReadBuffer(int id) + { + if (Buffer() == null && id > 0) + { + Buffer(Container().ReadBufferById(Transaction(), id)); + } + } + + private bool BeginProcessing() + { + return _reference.BeginProcessing(); + } + + private void EndProcessing() + { + _reference.EndProcessing(); + } + + public virtual void SetStateClean() + { + _reference.SetStateClean(); + } + + public virtual object PersistentObject() + { + return _object; + } + + public virtual void SetObjectWeak(object obj) + { + _reference.SetObjectWeak(Container(), obj); + } + + protected override bool PeekPersisted() + { + return _addToIDTree == Const4.Transient; + } + + public virtual Config4Class ClassConfig() + { + return ClassMetadata().Config(); + } + + public virtual void PersistentObject(object obj) + { + _object = obj; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/MarshallingBuffer.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/MarshallingBuffer.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/MarshallingBuffer.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/MarshallingBuffer.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,380 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using System.Collections; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Marshall; +using Db4objects.Db4o.Marshall; +using Sharpen; + +namespace Db4objects.Db4o.Internal +{ + /// + public class MarshallingBuffer : IWriteBuffer + { + private const int SizeNeeded = Const4.LongLength; + + private const int NoParent = -int.MaxValue; + + private ByteArrayBuffer _delegate; + + private int _lastOffSet; + + private int _addressInParent = NoParent; + + private List4 _children; + + private FieldMetadata _indexedField; + + public virtual int Length() + { + return Offset(); + } + + public virtual int Offset() + { + if (_delegate == null) + { + return 0; + } + return _delegate.Offset(); + } + + public virtual void WriteByte(byte b) + { + PrepareWrite(); + _delegate.WriteByte(b); + } + + public virtual void WriteBytes(byte[] bytes) + { + PrepareWrite(bytes.Length); + _delegate.WriteBytes(bytes); + } + + public virtual void WriteInt(int i) + { + PrepareWrite(); + _delegate.WriteInt(i); + } + + public virtual void WriteLong(long l) + { + PrepareWrite(); + _delegate.WriteLong(l); + } + + private void PrepareWrite() + { + PrepareWrite(SizeNeeded); + } + + public virtual void PrepareWrite(int sizeNeeded) + { + if (_delegate == null) + { + _delegate = new ByteArrayBuffer(sizeNeeded); + } + _lastOffSet = _delegate.Offset(); + if (RemainingSize() < sizeNeeded) + { + Resize(sizeNeeded); + } + } + + private int RemainingSize() + { + return _delegate.Length() - _delegate.Offset(); + } + + private void Resize(int sizeNeeded) + { + int newSize = _delegate.Length() * 2; + if (newSize - _lastOffSet < sizeNeeded) + { + newSize += sizeNeeded; + } + ByteArrayBuffer temp = new ByteArrayBuffer(newSize); + temp.Seek(_lastOffSet); + _delegate.CopyTo(temp, 0, 0, _delegate.Length()); + _delegate = temp; + } + + public virtual void TransferLastWriteTo(MarshallingBuffer other, bool storeLengthInLink + ) + { + other.AddressInParent(_lastOffSet, storeLengthInLink); + int length = _delegate.Offset() - _lastOffSet; + other.PrepareWrite(length); + int otherOffset = other._delegate.Offset(); + System.Array.Copy(_delegate._buffer, _lastOffSet, other._delegate._buffer, otherOffset + , length); + _delegate.Seek(_lastOffSet); + other._delegate.Seek(otherOffset + length); + other._lastOffSet = otherOffset; + } + + private void AddressInParent(int offset, bool storeLengthInLink) + { + _addressInParent = storeLengthInLink ? offset : -offset; + } + + public virtual void TransferContentTo(ByteArrayBuffer buffer) + { + TransferContentTo(buffer, Length()); + } + + public virtual void TransferContentTo(ByteArrayBuffer buffer, int length) + { + if (_delegate == null) + { + return; + } + System.Array.Copy(_delegate._buffer, 0, buffer._buffer, buffer._offset, length); + buffer._offset += length; + } + + public virtual ByteArrayBuffer TestDelegate() + { + return _delegate; + } + + public virtual MarshallingBuffer AddChild() + { + return AddChild(true, false); + } + + public virtual MarshallingBuffer AddChild(bool reserveLinkSpace, bool storeLengthInLink + ) + { + MarshallingBuffer child = new MarshallingBuffer(); + child.AddressInParent(Offset(), storeLengthInLink); + _children = new List4(_children, child); + if (reserveLinkSpace) + { + ReserveChildLinkSpace(storeLengthInLink); + } + return child; + } + + public virtual void ReserveChildLinkSpace(bool storeLengthInLink) + { + int length = storeLengthInLink ? Const4.IntLength * 2 : Const4.IntLength; + PrepareWrite(length); + _delegate.IncrementOffset(length); + } + + public virtual void MergeChildren(MarshallingContext context, int masterAddress, + int linkOffset) + { + MergeChildren(context, masterAddress, this, this, linkOffset); + } + + private static void MergeChildren(MarshallingContext context, int masterAddress, + MarshallingBuffer writeBuffer, MarshallingBuffer parentBuffer, int linkOffset) + { + if (parentBuffer._children == null) + { + return; + } + IEnumerator i = new Iterator4Impl(parentBuffer._children); + while (i.MoveNext()) + { + Merge(context, masterAddress, writeBuffer, parentBuffer, (MarshallingBuffer)i.Current + , linkOffset); + } + } + + private static void Merge(MarshallingContext context, int masterAddress, MarshallingBuffer + writeBuffer, MarshallingBuffer parentBuffer, MarshallingBuffer childBuffer, int + linkOffset) + { + int childPosition = writeBuffer.Offset(); + writeBuffer.Reserve(childBuffer.BlockedLength()); + MergeChildren(context, masterAddress, writeBuffer, childBuffer, linkOffset); + int savedWriteBufferOffset = writeBuffer.Offset(); + writeBuffer.Seek(childPosition); + childBuffer.TransferContentTo(writeBuffer._delegate); + writeBuffer.Seek(savedWriteBufferOffset); + parentBuffer.WriteLink(childBuffer, childPosition + linkOffset, childBuffer.UnblockedLength + ()); + childBuffer.WriteIndex(context, masterAddress, childPosition + linkOffset); + } + + public virtual void Seek(int offset) + { + _delegate.Seek(offset); + } + + public virtual IReservedBuffer Reserve(int length) + { + PrepareWrite(length); + IReservedBuffer reservedBuffer = new _IReservedBuffer_178(this); + _delegate.Seek(_delegate.Offset() + length); + return reservedBuffer; + } + + private sealed class _IReservedBuffer_178 : IReservedBuffer + { + public _IReservedBuffer_178(MarshallingBuffer _enclosing) + { + this._enclosing = _enclosing; + this.reservedOffset = this._enclosing._delegate.Offset(); + } + + private readonly int reservedOffset; + + public void WriteBytes(byte[] bytes) + { + int currentOffset = this._enclosing._delegate.Offset(); + this._enclosing._delegate.Seek(this.reservedOffset); + this._enclosing._delegate.WriteBytes(bytes); + this._enclosing._delegate.Seek(currentOffset); + } + + private readonly MarshallingBuffer _enclosing; + } + + private void WriteLink(MarshallingBuffer child, int position, int length) + { + int offset = Offset(); + _delegate.Seek(child.AddressInParent()); + _delegate.WriteInt(position); + if (child.StoreLengthInLink()) + { + _delegate.WriteInt(length); + } + _delegate.Seek(offset); + } + + private void WriteIndex(MarshallingContext context, int masterAddress, int position + ) + { + if (_indexedField != null) + { + // for now this is a String index only, it takes the entire slot. + StatefulBuffer buffer = new StatefulBuffer(context.Transaction(), UnblockedLength + ()); + int blockedPosition = context.Container().BlockConverter().BytesToBlocks(position + ); + int indexID = masterAddress + blockedPosition; + buffer.SetID(indexID); + buffer.Address(indexID); + TransferContentTo(buffer, UnblockedLength()); + _indexedField.AddIndexEntry(context.Transaction(), context.ObjectID(), buffer); + } + } + + private int AddressInParent() + { + if (!HasParent()) + { + throw new InvalidOperationException(); + } + if (_addressInParent < 0) + { + return -_addressInParent; + } + return _addressInParent; + } + + public virtual void DebugDecrementLastOffset(int count) + { + _lastOffSet -= count; + } + + public virtual bool HasParent() + { + return _addressInParent != NoParent; + } + + private bool StoreLengthInLink() + { + return _addressInParent > 0; + } + + public virtual void RequestIndexEntry(FieldMetadata fieldMetadata) + { + _indexedField = fieldMetadata; + } + + public virtual MarshallingBuffer CheckBlockAlignment(MarshallingContext context, + MarshallingBuffer precedingBuffer, IntByRef precedingLength) + { + _lastOffSet = Offset(); + if (DoBlockAlign()) + { + precedingBuffer.BlockAlign(context, precedingLength.value); + } + if (precedingBuffer != null) + { + precedingLength.value += precedingBuffer.Length(); + } + precedingBuffer = this; + if (_children != null) + { + IEnumerator i = new Iterator4Impl(_children); + while (i.MoveNext()) + { + precedingBuffer = ((MarshallingBuffer)i.Current).CheckBlockAlignment(context, precedingBuffer + , precedingLength); + } + } + return precedingBuffer; + } + + private void BlockAlign(MarshallingContext context, int precedingLength) + { + int totalLength = context.Container().BlockConverter().BlockAlignedBytes(precedingLength + + Length()); + int newLength = totalLength - precedingLength; + BlockAlign(newLength); + } + + public virtual int MarshalledLength() + { + int length = Length(); + if (_children != null) + { + IEnumerator i = new Iterator4Impl(_children); + while (i.MoveNext()) + { + length += ((MarshallingBuffer)i.Current).MarshalledLength(); + } + } + return length; + } + + private void BlockAlign(int length) + { + if (_delegate == null) + { + return; + } + if (length > _delegate.Length()) + { + int sizeNeeded = length - _delegate.Offset(); + PrepareWrite(sizeNeeded); + } + _delegate.Seek(length); + } + + private bool DoBlockAlign() + { + return HasParent(); + } + + // For now we block align every linked entry. Indexes could be created late. + private int BlockedLength() + { + return Length(); + } + + private int UnblockedLength() + { + // This is only valid after checkBlockAlignMent has been called. + return _lastOffSet; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/MessageOutput.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/MessageOutput.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/MessageOutput.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/MessageOutput.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,45 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System.IO; +using Db4objects.Db4o; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Handlers; + +namespace Db4objects.Db4o.Internal +{ + internal sealed class MessageOutput + { + internal readonly TextWriter stream; + + internal MessageOutput(ObjectContainerBase a_stream, string msg) + { + stream = a_stream.ConfigImpl.OutStream(); + Print(msg, true); + } + + internal MessageOutput(string a_StringParam, int a_intParam, TextWriter a_stream, + bool header) + { + stream = a_stream; + Print(Db4objects.Db4o.Internal.Messages.Get(a_intParam, a_StringParam), header); + } + + internal MessageOutput(string a_StringParam, int a_intParam, TextWriter a_stream) + : this(a_StringParam, a_intParam, a_stream, true) + { + } + + private void Print(string msg, bool header) + { + if (stream != null) + { + if (header) + { + stream.WriteLine("[" + Db4oFactory.Version() + " " + DateHandlerBase.Now() + "] " + ); + } + stream.WriteLine(" " + msg); + } + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Messages.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Messages.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Messages.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Messages.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,152 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using System.IO; +using Db4objects.Db4o; +using Db4objects.Db4o.Config; +using Db4objects.Db4o.Internal; + +namespace Db4objects.Db4o.Internal +{ + /// + public sealed class Messages + { + public const int IncompatibleFormat = 17; + + public const int ClosedOrOpenFailed = 20; + + public const int FailedToShutdown = 28; + + public const int FatalMsgId = 44; + + public const int NotImplemented = 49; + + public const int OldDatabaseFormat = 65; + + public const int OnlyForIndexedFields = 66; + + public const int ClientServerUnsupported = 67; + + public const int CouldNotOpenPort = 30; + + public const int ServerListeningOnPort = 31; + + private static string[] i_messages; + + public static string Get(int a_code) + { + return Get(a_code, null); + } + + public static string Get(int a_code, string param) + { + if (a_code < 0) + { + return param; + } + Load(); + if (i_messages == null || a_code > i_messages.Length - 1) + { + return "msg[" + a_code + "]"; + } + string msg = i_messages[a_code]; + if (param != null) + { + int pos = msg.IndexOf("%", 0); + if (pos > -1) + { + msg = Sharpen.Runtime.Substring(msg, 0, pos) + "'" + param + "'" + Sharpen.Runtime.Substring + (msg, pos + 1); + } + } + return msg; + } + + private static void Load() + { + if (i_messages == null) + { + i_messages = new string[] { string.Empty, "blocksize should be between 1 and 127" + , "% close request", "% closed", "Exception opening %", "% opened O.K.", "Class %: Instantiation failed. \n Check custom ObjectConstructor code." + , "Class %: Instantiation failed.\n Add a constructor for use with db4o, ideally with zero arguments." + , "renaming %", "rename not possible. % already exists", "rename failed", "File close failed." + , "File % not available for readwrite access.", "File read access failed.", "File not found: % Creating new file" + , "Creation of file failed: %", "File write failed.", "File format incompatible: %" + , "Uncaught Exception. Engine closed.", "writing log for %", "% is closed. close() was called or open() failed." + , "Filename not specified.", "The database file is locked by another process.", + "Class not available: %. Check CLASSPATH settings.", "finalized while performing a task.\n DO NOT USE CTRL + C OR System.exit() TO STOP THE ENGINE." + , "Please mail the following to exception@db4o.com:\n ", "", "Creation of lock file failed: %" + , "Previous session was not shut down correctly", "This method call is only possible on stored objects" + , "Could not open port: %", "Server listening on port: %", "Client % connected." + , "Client % timed out and closed.", "Connection closed by client %.", "Connection closed by server. %." + , "% connected to server.", "The directory % can neither be found nor created.", + "This blob was never stored.", "Blob file % not available.", "Failure finding blob filename." + , "File does not exist %.", "Failed to connect to server.", "No blob data stored." + , "Uncaught Exception. db4o engine closed.", "Add constructor that won't throw exceptions, configure constructor calls, configure exceptionsOnNotStorable(false) or provide a translator to class % and make sure the class is deployed to the server with the same package/namespace + assembly name." + , "This method can only be called before opening the database file.", "AccessibleObject#setAccessible() is not available. Private fields can not be stored." + , "ObjectTranslator could not be installed: %.", "Not implemented", "% closed by ShutdownHook." + , string.Empty, "Add at least one ObjectContainer to the Cluster", "Unsupported Operation" + , "Database password does not match user-provided password.", "Thread interrupted." + , "Password can not be null.", "Classes does not match.", "rename() needs to be executed on the server." + , "Primitive types like % can not be stored directly. Store and retrieve them in wrapper objects." + , "Backups can not be run from clients and memory files.", "Backup in progress." + , "Only use persisted first class objects as keys for IdentityHashMap.", "This functionality is only available from version 5.0 onwards." + , "By convention a Predicate needs the following method: public boolean match(ExtentClass extent){}" + , "Old database file format detected. To allow automatic updates call Db4o.configure().allowVersionUpdates(true)." + , "This functionality is only available for indexed fields.", "This functionality is not supported for db4o clients in Client/Server mode." + , "Invalid address: %", "Maximum file size reached" }; + } + } + + // unused + // 5 + // 10 + // 15 + // 20 + // 25 + // 30 + // 35 + // 40 + // 45 + // 50 + // removed, can be reused + // 55 + // 60 + // 65 + // 66 + // 67 + // 69 + public static void LogErr(IConfiguration config, int code, string msg, Exception + t) + { + TextWriter ps = ((Config4Impl)SafeConfig(config)).ErrStream(); + new MessageOutput(msg, code, ps); + if (t != null) + { + new MessageOutput(null, 25, ps); + Sharpen.Runtime.PrintStackTrace(t, ps); + new MessageOutput(null, 26, ps, false); + } + } + + [System.ObsoleteAttribute(@"uses deprecated api")] + private static IConfiguration SafeConfig(IConfiguration config) + { + if (config != null) + { + return config; + } + return Db4oFactory.Configure(); + } + + public static void LogMsg(IConfiguration config, int code, string msg) + { + Config4Impl c4i = (Config4Impl)config; + if (c4i.MessageLevel() > Const4.None) + { + new MessageOutput(msg, code, c4i.OutStream()); + } + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Metadata/HierarchyAnalyzer.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Metadata/HierarchyAnalyzer.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Metadata/HierarchyAnalyzer.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Metadata/HierarchyAnalyzer.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,144 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using System.Collections; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Metadata; +using Db4objects.Db4o.Reflect; + +namespace Db4objects.Db4o.Internal.Metadata +{ + /// + public class HierarchyAnalyzer + { + public class Diff + { + private readonly Db4objects.Db4o.Internal.ClassMetadata _classMetadata; + + public Diff(Db4objects.Db4o.Internal.ClassMetadata classMetadata) + { + if (classMetadata == null) + { + throw new ArgumentNullException(); + } + _classMetadata = classMetadata; + } + + public override bool Equals(object obj) + { + if (GetType() != obj.GetType()) + { + return false; + } + HierarchyAnalyzer.Diff other = (HierarchyAnalyzer.Diff)obj; + return _classMetadata == other._classMetadata; + } + + public override string ToString() + { + return ReflectPlatform.SimpleName(GetType()) + "(" + _classMetadata.GetName() + ")"; + } + + public virtual Db4objects.Db4o.Internal.ClassMetadata ClassMetadata() + { + return _classMetadata; + } + + public virtual bool IsRemoved() + { + return false; + } + } + + public class Same : HierarchyAnalyzer.Diff + { + public Same(ClassMetadata classMetadata) : base(classMetadata) + { + } + } + + public class Removed : HierarchyAnalyzer.Diff + { + public Removed(ClassMetadata classMetadata) : base(classMetadata) + { + } + + public override bool IsRemoved() + { + return true; + } + } + + private ClassMetadata _storedClass; + + private IReflectClass _runtimeClass; + + private readonly IReflectClass _objectClass; + + public HierarchyAnalyzer(ClassMetadata storedClass, IReflectClass runtimeClass) + { + if (storedClass == null || runtimeClass == null) + { + throw new ArgumentNullException(); + } + _storedClass = storedClass; + _runtimeClass = runtimeClass; + _objectClass = runtimeClass.Reflector().ForClass(typeof(object)); + } + + public virtual IList Analyze() + { + IList ancestors = new ArrayList(); + ClassMetadata storedAncestor = _storedClass.GetAncestor(); + IReflectClass runtimeAncestor = _runtimeClass.GetSuperclass(); + while (storedAncestor != null) + { + if (runtimeAncestor == storedAncestor.ClassReflector()) + { + ancestors.Add(new HierarchyAnalyzer.Same(storedAncestor)); + } + else + { + do + { + ancestors.Add(new HierarchyAnalyzer.Removed(storedAncestor)); + storedAncestor = storedAncestor.GetAncestor(); + if (null == storedAncestor) + { + if (IsObject(runtimeAncestor)) + { + return ancestors; + } + ThrowUnsupportedAdd(runtimeAncestor); + } + if (runtimeAncestor == storedAncestor.ClassReflector()) + { + ancestors.Add(new HierarchyAnalyzer.Same(storedAncestor)); + break; + } + } + while (storedAncestor != null); + } + storedAncestor = storedAncestor.GetAncestor(); + runtimeAncestor = runtimeAncestor.GetSuperclass(); + } + if (runtimeAncestor != null && (!IsObject(runtimeAncestor))) + { + ThrowUnsupportedAdd(runtimeAncestor); + } + return ancestors; + } + + private void ThrowUnsupportedAdd(IReflectClass runtimeAncestor) + { + throw new InvalidOperationException("Unsupported class hierarchy change. Class " + + runtimeAncestor.GetName() + " was added to hierarchy of " + _runtimeClass.GetName + ()); + } + + private bool IsObject(IReflectClass clazz) + { + return _objectClass == clazz; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Metadata/IAspectTraversalStrategy.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Metadata/IAspectTraversalStrategy.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Metadata/IAspectTraversalStrategy.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Metadata/IAspectTraversalStrategy.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,12 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal.Metadata; + +namespace Db4objects.Db4o.Internal.Metadata +{ + /// + public interface IAspectTraversalStrategy + { + void TraverseAllAspects(ITraverseAspectCommand command); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Metadata/ITraverseAspectCommand.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Metadata/ITraverseAspectCommand.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Metadata/ITraverseAspectCommand.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Metadata/ITraverseAspectCommand.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,18 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal; + +namespace Db4objects.Db4o.Internal.Metadata +{ + /// + public interface ITraverseAspectCommand + { + int DeclaredAspectCount(ClassMetadata classMetadata); + + bool Cancelled(); + + void ProcessAspectOnMissingClass(ClassAspect aspect, int currentSlot); + + void ProcessAspect(ClassAspect aspect, int currentSlot); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Metadata/MarshallingInfoTraverseAspectCommand.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Metadata/MarshallingInfoTraverseAspectCommand.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Metadata/MarshallingInfoTraverseAspectCommand.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Metadata/MarshallingInfoTraverseAspectCommand.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,70 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Marshall; +using Db4objects.Db4o.Internal.Metadata; + +namespace Db4objects.Db4o.Internal.Metadata +{ + /// + public abstract class MarshallingInfoTraverseAspectCommand : ITraverseAspectCommand + { + private bool _cancelled = false; + + protected readonly IMarshallingInfo _marshallingInfo; + + public MarshallingInfoTraverseAspectCommand(IMarshallingInfo marshallingInfo) + { + _marshallingInfo = marshallingInfo; + } + + public int DeclaredAspectCount(ClassMetadata classMetadata) + { + int aspectCount = InternalDeclaredAspectCount(classMetadata); + _marshallingInfo.DeclaredAspectCount(aspectCount); + return aspectCount; + } + + protected virtual int InternalDeclaredAspectCount(ClassMetadata classMetadata) + { + return classMetadata.ReadAspectCount(_marshallingInfo.Buffer()); + } + + public virtual bool Cancelled() + { + return _cancelled; + } + + protected virtual void Cancel() + { + _cancelled = true; + } + + public virtual bool Accept(ClassAspect aspect) + { + return true; + } + + public virtual void ProcessAspectOnMissingClass(ClassAspect aspect, int currentSlot + ) + { + if (_marshallingInfo.IsNull(currentSlot)) + { + return; + } + aspect.IncrementOffset(_marshallingInfo.Buffer()); + } + + public virtual void ProcessAspect(ClassAspect aspect, int currentSlot) + { + if (Accept(aspect)) + { + ProcessAspect(aspect, currentSlot, _marshallingInfo.IsNull(currentSlot)); + } + _marshallingInfo.BeginSlot(); + } + + protected abstract void ProcessAspect(ClassAspect aspect, int currentSlot, bool isNull + ); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Metadata/ModifiedAspectTraversalStrategy.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Metadata/ModifiedAspectTraversalStrategy.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Metadata/ModifiedAspectTraversalStrategy.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Metadata/ModifiedAspectTraversalStrategy.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,101 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System.Collections; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Metadata; + +namespace Db4objects.Db4o.Internal.Metadata +{ + /// + public class ModifiedAspectTraversalStrategy : IAspectTraversalStrategy + { + private readonly IList _classDiffs; + + public ModifiedAspectTraversalStrategy(ClassMetadata classMetadata, IList ancestors + ) + { + _classDiffs = new ArrayList(); + _classDiffs.Add(new HierarchyAnalyzer.Same(classMetadata)); + Sharpen.Collections.AddAll(_classDiffs, ancestors); + } + + public virtual void TraverseAllAspects(ITraverseAspectCommand command) + { + int currentSlot = 0; + for (IEnumerator diffIter = _classDiffs.GetEnumerator(); diffIter.MoveNext(); ) + { + HierarchyAnalyzer.Diff diff = ((HierarchyAnalyzer.Diff)diffIter.Current); + ClassMetadata classMetadata = diff.ClassMetadata(); + if (diff.IsRemoved()) + { + currentSlot = SkipAspectsOf(classMetadata, command, currentSlot); + continue; + } + currentSlot = TraverseAspectsOf(classMetadata, command, currentSlot); + if (command.Cancelled()) + { + return; + } + } + } + + internal interface ITraverseAspectCommandProcessor + { + void Process(ITraverseAspectCommand command, ClassAspect currentAspect, int currentSlot + ); + } + + private int TraverseAspectsOf(ClassMetadata classMetadata, ITraverseAspectCommand + command, int currentSlot) + { + return ProcessAspectsOf(classMetadata, command, currentSlot, new _ITraverseAspectCommandProcessor_49 + ()); + } + + private sealed class _ITraverseAspectCommandProcessor_49 : ModifiedAspectTraversalStrategy.ITraverseAspectCommandProcessor + { + public _ITraverseAspectCommandProcessor_49() + { + } + + public void Process(ITraverseAspectCommand command, ClassAspect currentAspect, int + currentSlot) + { + command.ProcessAspect(currentAspect, currentSlot); + } + } + + private int ProcessAspectsOf(ClassMetadata classMetadata, ITraverseAspectCommand + command, int currentSlot, ModifiedAspectTraversalStrategy.ITraverseAspectCommandProcessor + processor) + { + int aspectCount = command.DeclaredAspectCount(classMetadata); + for (int i = 0; i < aspectCount && !command.Cancelled(); i++) + { + processor.Process(command, classMetadata._aspects[i], currentSlot); + currentSlot++; + } + return currentSlot; + } + + private int SkipAspectsOf(ClassMetadata classMetadata, ITraverseAspectCommand command + , int currentSlot) + { + return ProcessAspectsOf(classMetadata, command, currentSlot, new _ITraverseAspectCommandProcessor_70 + ()); + } + + private sealed class _ITraverseAspectCommandProcessor_70 : ModifiedAspectTraversalStrategy.ITraverseAspectCommandProcessor + { + public _ITraverseAspectCommandProcessor_70() + { + } + + public void Process(ITraverseAspectCommand command, ClassAspect currentAspect, int + currentSlot) + { + command.ProcessAspectOnMissingClass(currentAspect, currentSlot); + } + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Metadata/StandardAspectTraversalStrategy.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Metadata/StandardAspectTraversalStrategy.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Metadata/StandardAspectTraversalStrategy.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Metadata/StandardAspectTraversalStrategy.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,38 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Metadata; + +namespace Db4objects.Db4o.Internal.Metadata +{ + /// + public class StandardAspectTraversalStrategy : IAspectTraversalStrategy + { + private readonly ClassMetadata _classMetadata; + + public StandardAspectTraversalStrategy(ClassMetadata classMetadata) + { + _classMetadata = classMetadata; + } + + public virtual void TraverseAllAspects(ITraverseAspectCommand command) + { + ClassMetadata classMetadata = _classMetadata; + int currentSlot = 0; + while (classMetadata != null) + { + int aspectCount = command.DeclaredAspectCount(classMetadata); + for (int i = 0; i < aspectCount && !command.Cancelled(); i++) + { + command.ProcessAspect(classMetadata._aspects[i], currentSlot); + currentSlot++; + } + if (command.Cancelled()) + { + return; + } + classMetadata = classMetadata._ancestor; + } + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Metadata/TraverseFieldCommand.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Metadata/TraverseFieldCommand.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Metadata/TraverseFieldCommand.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Metadata/TraverseFieldCommand.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,37 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Metadata; + +namespace Db4objects.Db4o.Internal.Metadata +{ + /// + public abstract class TraverseFieldCommand : ITraverseAspectCommand + { + public virtual bool Cancelled() + { + return false; + } + + public virtual int DeclaredAspectCount(ClassMetadata classMetadata) + { + return classMetadata.DeclaredAspectCount(); + } + + public virtual void ProcessAspect(ClassAspect aspect, int currentSlot) + { + if (aspect is FieldMetadata) + { + Process((FieldMetadata)aspect); + } + } + + public virtual void ProcessAspectOnMissingClass(ClassAspect aspect, int currentSlot + ) + { + } + + // do nothing + protected abstract void Process(FieldMetadata field); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Null.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Null.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Null.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Null.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,75 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Marshall; + +namespace Db4objects.Db4o.Internal +{ + /// + public class Null : IIndexable4, IPreparedComparison + { + public static readonly Db4objects.Db4o.Internal.Null Instance = new Db4objects.Db4o.Internal.Null + (); + + private Null() + { + } + + public virtual int CompareTo(object a_obj) + { + if (a_obj == null) + { + return 0; + } + return -1; + } + + public virtual int LinkLength() + { + return 0; + } + + public virtual object ReadIndexEntry(IContext context, ByteArrayBuffer a_reader) + { + return null; + } + + public virtual void WriteIndexEntry(IContext context, ByteArrayBuffer a_writer, object + a_object) + { + } + + // do nothing + public virtual void DefragIndexEntry(DefragmentContextImpl context) + { + } + + // do nothing + public virtual IPreparedComparison PrepareComparison(IContext context, object obj_ + ) + { + return new _IPreparedComparison_43(); + } + + private sealed class _IPreparedComparison_43 : IPreparedComparison + { + public _IPreparedComparison_43() + { + } + + public int CompareTo(object obj) + { + if (obj == null) + { + return 0; + } + if (obj is Db4objects.Db4o.Internal.Null) + { + return 0; + } + return -1; + } + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/NullFieldMetadata.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/NullFieldMetadata.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/NullFieldMetadata.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/NullFieldMetadata.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,27 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Marshall; + +namespace Db4objects.Db4o.Internal +{ + /// + public class NullFieldMetadata : FieldMetadata + { + public NullFieldMetadata() : base(null) + { + } + + /// + public virtual IPreparedComparison PrepareComparison(object obj) + { + return Null.Instance; + } + + public sealed override object Read(IObjectIdContext context) + { + return null; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/NullTransactionListener.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/NullTransactionListener.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/NullTransactionListener.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/NullTransactionListener.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,24 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o; + +namespace Db4objects.Db4o.Internal +{ + public class NullTransactionListener : ITransactionListener + { + public static readonly ITransactionListener Instance = new Db4objects.Db4o.Internal.NullTransactionListener + (); + + private NullTransactionListener() + { + } + + public virtual void PostRollback() + { + } + + public virtual void PreCommit() + { + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/ObjectAnalyzer.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/ObjectAnalyzer.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/ObjectAnalyzer.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/ObjectAnalyzer.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,102 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Reflect; + +namespace Db4objects.Db4o.Internal +{ + /// + internal class ObjectAnalyzer + { + private readonly ObjectContainerBase _container; + + private readonly object _obj; + + private Db4objects.Db4o.Internal.ClassMetadata _classMetadata; + + private Db4objects.Db4o.Internal.ObjectReference _ref; + + private bool _notStorable; + + internal ObjectAnalyzer(ObjectContainerBase container, object obj) + { + _container = container; + _obj = obj; + } + + internal virtual void Analyze(Transaction trans) + { + _ref = trans.ReferenceForObject(_obj); + if (_ref != null) + { + _classMetadata = _ref.ClassMetadata(); + return; + } + IReflectClass claxx = _container.Reflector().ForObject(_obj); + if (claxx == null) + { + NotStorable(_obj, claxx); + return; + } + if (!DetectClassMetadata(trans, claxx)) + { + return; + } + if (IsValueType(_classMetadata)) + { + NotStorable(_obj, _classMetadata.ClassReflector()); + } + } + + private bool DetectClassMetadata(Transaction trans, IReflectClass claxx) + { + _classMetadata = _container.GetActiveClassMetadata(claxx); + if (_classMetadata != null) + { + if (!_classMetadata.IsStorable()) + { + NotStorable(_obj, claxx); + return false; + } + return true; + } + _classMetadata = _container.ProduceClassMetadata(claxx); + if (_classMetadata == null || !_classMetadata.IsStorable()) + { + NotStorable(_obj, claxx); + return false; + } + // The following may return a reference if the object is held + // in a static variable somewhere ( often: Enums) that gets + // stored or associated on initialization of the ClassMetadata. + _ref = trans.ReferenceForObject(_obj); + return true; + } + + private void NotStorable(object obj, IReflectClass claxx) + { + _container.NotStorable(claxx, obj); + _notStorable = true; + } + + internal virtual bool NotStorable() + { + return _notStorable; + } + + private bool IsValueType(Db4objects.Db4o.Internal.ClassMetadata classMetadata) + { + return classMetadata.IsValueType(); + } + + internal virtual Db4objects.Db4o.Internal.ObjectReference ObjectReference() + { + return _ref; + } + + public virtual Db4objects.Db4o.Internal.ClassMetadata ClassMetadata() + { + return _classMetadata; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/ObjectContainerBase.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/ObjectContainerBase.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/ObjectContainerBase.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/ObjectContainerBase.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,2885 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using System.Collections; +using Db4objects.Db4o; +using Db4objects.Db4o.Config; +using Db4objects.Db4o.Ext; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.IO; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Activation; +using Db4objects.Db4o.Internal.Callbacks; +using Db4objects.Db4o.Internal.Encoding; +using Db4objects.Db4o.Internal.Events; +using Db4objects.Db4o.Internal.Handlers.Array; +using Db4objects.Db4o.Internal.Marshall; +using Db4objects.Db4o.Internal.Metadata; +using Db4objects.Db4o.Internal.Query; +using Db4objects.Db4o.Internal.Query.Processor; +using Db4objects.Db4o.Internal.Query.Result; +using Db4objects.Db4o.Internal.References; +using Db4objects.Db4o.Internal.Replication; +using Db4objects.Db4o.Internal.Slots; +using Db4objects.Db4o.Internal.Threading; +using Db4objects.Db4o.Internal.Weakref; +using Db4objects.Db4o.Query; +using Db4objects.Db4o.Reflect; +using Db4objects.Db4o.Reflect.Core; +using Db4objects.Db4o.Reflect.Generic; +using Db4objects.Db4o.Typehandlers; +using Db4objects.Db4o.Types; +using Sharpen; +using Sharpen.Lang; + +namespace Db4objects.Db4o.Internal +{ + /// + public abstract partial class ObjectContainerBase : System.IDisposable, ITransientClass + , IInternal4, IObjectContainerSpec, IInternalObjectContainer + { + protected ClassMetadataRepository _classCollection; + + protected Config4Impl _config; + + private int _stackDepth; + + private readonly int _maxStackDepth; + + private readonly Db4objects.Db4o.Internal.References.ReferenceSystemRegistry _referenceSystemRegistry + = new Db4objects.Db4o.Internal.References.ReferenceSystemRegistry(); + + private Tree _justPeeked; + + protected object _lock; + + private List4 _pendingClassUpdates; + + internal int _showInternalClasses = 0; + + private List4 _stillToActivate; + + private List4 _stillToDeactivate; + + private List4 _stillToSet; + + private bool _handlingStackLimitPendings = false; + + private Db4objects.Db4o.Internal.Transaction _systemTransaction; + + protected Db4objects.Db4o.Internal.Transaction _transaction; + + public HandlerRegistry _handlers; + + internal int _replicationCallState; + + internal IWeakReferenceSupport _references; + + private NativeQueryHandler _nativeQueryHandler; + + private ICallbacks _callbacks = new NullCallbacks(); + + protected readonly TimeStampIdGenerator _timeStampIdGenerator = new TimeStampIdGenerator + (); + + private int _topLevelCallId = 1; + + private IntIdGenerator _topLevelCallIdGenerator = new IntIdGenerator(); + + private readonly IEnvironment _environment; + + private IReferenceSystemFactory _referenceSystemFactory; + + private string _name; + + protected IBlockConverter _blockConverter = new DisabledBlockConverter(); + + protected ObjectContainerBase(IConfiguration config) + { + // Collection of all classes + // if (_classCollection == null) the engine is down. + // the Configuration context for this ObjectContainer + // Counts the number of toplevel calls into YapStream + // currently used to resolve self-linking concurrency problems + // in cylic links, stores only ClassMetadata objects + // a value greater than 0 indicates class implementing the + // "Internal" interface are visible in queries and can + // be used. + // used for ClassMetadata and ClassMetadataRepository + // may be parent or equal to i_trans + // used for Objects + // all the per-YapStream references that we don't + // want created in YapobjectCarrier + // One of three constants in ReplicationHandler: NONE, OLD, NEW + // Detailed replication variables are stored in i_handlers. + // Call state has to be maintained here, so YapObjectCarrier (who shares i_handlers) does + // not accidentally think it operates in a replication call. + // weak reference management + _lock = new object(); + _config = (Config4Impl)config; + _environment = CreateEnvironment(_config); + _maxStackDepth = _config.MaxStackDepth(); + } + + private IEnvironment CreateEnvironment(Config4Impl config) + { + ArrayList bindings = new ArrayList(); + Sharpen.Collections.AddAll(bindings, config.EnvironmentContributions()); + bindings.Add(this); + // my(ObjectContainer.class) + bindings.Add(config); + // my(Configuration.class) + return Environments.NewConventionBasedEnvironment(Sharpen.Collections.ToArray(bindings + )); + } + + protected virtual IEnvironment Environment() + { + return _environment; + } + + /// + protected void Open() + { + WithEnvironment(new _IRunnable_129(this)); + } + + private sealed class _IRunnable_129 : IRunnable + { + public _IRunnable_129(ObjectContainerBase _enclosing) + { + this._enclosing = _enclosing; + } + + public void Run() + { + bool ok = false; + lock (this._enclosing._lock) + { + try + { + this._enclosing._name = this._enclosing.ConfigImpl.NameProvider().Name(this._enclosing + ); + this._enclosing.InitializeReferenceSystemFactory(this._enclosing._config); + this._enclosing.InitializeTransactions(); + this._enclosing.Initialize1(this._enclosing._config); + this._enclosing.OpenImpl(); + this._enclosing.InitializePostOpen(); + this._enclosing.Callbacks().OpenOnFinished(this._enclosing); + ok = true; + } + finally + { + if (!ok) + { + // TODO: This will swallow the causing exception if + // an exception occurs during shutdown. + this._enclosing.ShutdownObjectContainer(); + } + } + } + } + + private readonly ObjectContainerBase _enclosing; + } + + private void InitializeReferenceSystemFactory(Config4Impl config) + { + _referenceSystemFactory = config.ReferenceSystemFactory(); + } + + public virtual void WithEnvironment(IRunnable runnable) + { + Environments.RunWith(_environment, runnable); + } + + /// + protected abstract void OpenImpl(); + + public virtual IActivationDepth DefaultActivationDepth(ClassMetadata classMetadata + ) + { + return ActivationDepthProvider().ActivationDepthFor(classMetadata, ActivationMode + .Activate); + } + + public virtual IActivationDepthProvider ActivationDepthProvider() + { + return ConfigImpl.ActivationDepthProvider(); + } + + public void Activate(Db4objects.Db4o.Internal.Transaction trans, object obj) + { + lock (_lock) + { + Activate(trans, obj, DefaultActivationDepthForObject(obj)); + } + } + + public void Deactivate(Db4objects.Db4o.Internal.Transaction trans, object obj) + { + Deactivate(trans, obj, 1); + } + + private IActivationDepth DefaultActivationDepthForObject(object obj) + { + ClassMetadata classMetadata = ClassMetadataForObject(obj); + return DefaultActivationDepth(classMetadata); + } + + public void Activate(Db4objects.Db4o.Internal.Transaction trans, object obj, IActivationDepth + depth) + { + lock (_lock) + { + AsTopLevelCall(new _IFunction4_189(this, obj, depth), trans); + } + } + + private sealed class _IFunction4_189 : IFunction4 + { + public _IFunction4_189(ObjectContainerBase _enclosing, object obj, IActivationDepth + depth) + { + this._enclosing = _enclosing; + this.obj = obj; + this.depth = depth; + } + + public object Apply(object trans) + { + this._enclosing.StillToActivate(this._enclosing.ActivationContextFor(((Db4objects.Db4o.Internal.Transaction + )trans), obj, depth)); + this._enclosing.ActivatePending(((Db4objects.Db4o.Internal.Transaction)trans)); + return null; + } + + private readonly ObjectContainerBase _enclosing; + + private readonly object obj; + + private readonly IActivationDepth depth; + } + + internal sealed class PendingActivation + { + public readonly ObjectReference @ref; + + public readonly IActivationDepth depth; + + public PendingActivation(ObjectReference ref_, IActivationDepth depth_) + { + this.@ref = ref_; + this.depth = depth_; + } + } + + internal void ActivatePending(Transaction ta) + { + while (_stillToActivate != null) + { + // TODO: Optimize! A lightweight int array would be faster. + IEnumerator i = new Iterator4Impl(_stillToActivate); + _stillToActivate = null; + while (i.MoveNext()) + { + ObjectContainerBase.PendingActivation item = (ObjectContainerBase.PendingActivation + )i.Current; + ObjectReference @ref = item.@ref; + object obj = @ref.GetObject(); + if (obj == null) + { + ta.RemoveReference(@ref); + } + else + { + @ref.ActivateInternal(ActivationContextFor(ta, obj, item.depth)); + } + } + } + } + + /// + /// + public virtual void Backup(string path) + { + Backup(ConfigImpl.Storage, path); + } + + public virtual ActivationContext4 ActivationContextFor(Transaction ta, object obj + , IActivationDepth depth) + { + return new ActivationContext4(ta, obj, depth); + } + + /// + /// + public void Bind(Transaction trans, object obj, long id) + { + lock (_lock) + { + if (obj == null) + { + throw new ArgumentNullException(); + } + if (DTrace.enabled) + { + DTrace.Bind.Log(id, " ihc " + Runtime.IdentityHashCode(obj)); + } + trans = CheckTransaction(trans); + int intID = (int)id; + object oldObject = GetByID(trans, id); + if (oldObject == null) + { + throw new ArgumentException("id"); + } + ObjectReference @ref = trans.ReferenceForId(intID); + if (@ref == null) + { + throw new ArgumentException("obj"); + } + if (ReflectorForObject(obj) == @ref.ClassMetadata().ClassReflector()) + { + ObjectReference newRef = Bind2(trans, @ref, obj); + newRef.VirtualAttributes(trans, false); + } + else + { + throw new Db4oException(Db4objects.Db4o.Internal.Messages.Get(57)); + } + } + } + + public ObjectReference Bind2(Transaction trans, ObjectReference oldRef, object obj + ) + { + int id = oldRef.GetID(); + trans.RemoveReference(oldRef); + ObjectReference newRef = new ObjectReference(ClassMetadataForObject(obj), id); + newRef.SetObjectWeak(this, obj); + newRef.SetStateDirty(); + trans.ReferenceSystem().AddExistingReference(newRef); + return newRef; + } + + public virtual ClassMetadata ClassMetadataForObject(object obj) + { + return ProduceClassMetadata(ReflectorForObject(obj)); + } + + public abstract byte BlockSize(); + + private bool BreakDeleteForEnum(ObjectReference reference, bool userCall) + { + return false; + if (userCall) + { + return false; + } + if (reference == null) + { + return false; + } + return Platform4.IsEnum(Reflector(), reference.ClassMetadata().ClassReflector()); + } + + internal virtual bool CanUpdate() + { + return true; + } + + /// + public void CheckClosed() + { + if (_classCollection == null) + { + throw new DatabaseClosedException(); + } + } + + /// + protected void CheckReadOnly() + { + if (_config.IsReadOnly()) + { + throw new DatabaseReadOnlyException(); + } + } + + internal void ProcessPendingClassUpdates() + { + if (_pendingClassUpdates == null) + { + return; + } + IEnumerator i = new Iterator4Impl(_pendingClassUpdates); + while (i.MoveNext()) + { + ClassMetadata classMetadata = (ClassMetadata)i.Current; + classMetadata.SetStateDirty(); + classMetadata.Write(_systemTransaction); + } + _pendingClassUpdates = null; + } + + public Transaction CheckTransaction() + { + return CheckTransaction(null); + } + + public Transaction CheckTransaction(Transaction ta) + { + CheckClosed(); + if (ta != null) + { + return ta; + } + return Transaction; + } + + public bool Close() + { + lock (_lock) + { + Callbacks().CloseOnStarted(this); + if (DTrace.enabled) + { + DTrace.CloseCalled.Log(this.ToString()); + } + Close1(); + return true; + } + } + + protected virtual void HandleExceptionOnClose(Exception exc) + { + FatalException(exc); + } + + private void Close1() + { + if (IsClosed()) + { + return; + } + ProcessPendingClassUpdates(); + if (StateMessages()) + { + LogMsg(2, ToString()); + } + Close2(); + } + + protected abstract void Close2(); + + public void ShutdownObjectContainer() + { + if (DTrace.enabled) + { + DTrace.Close.Log(); + } + LogMsg(3, ToString()); + lock (_lock) + { + CloseUserTransaction(); + CloseSystemTransaction(); + CloseIdSystem(); + StopSession(); + ShutdownDataStorage(); + } + } + + protected abstract void CloseIdSystem(); + + protected void CloseUserTransaction() + { + CloseTransaction(_transaction, false, false); + } + + protected void CloseSystemTransaction() + { + CloseTransaction(_systemTransaction, true, false); + } + + public abstract void CloseTransaction(Transaction transaction, bool isSystemTransaction + , bool rollbackOnClose); + + protected abstract void ShutdownDataStorage(); + + /// + /// + public void Commit(Transaction trans) + { + lock (_lock) + { + if (DTrace.enabled) + { + DTrace.Commit.Log(); + } + CheckReadOnly(); + AsTopLevelCall(new _IFunction4_399(this), trans); + } + } + + private sealed class _IFunction4_399 : IFunction4 + { + public _IFunction4_399(ObjectContainerBase _enclosing) + { + this._enclosing = _enclosing; + } + + public object Apply(object trans) + { + this._enclosing.Commit1(((Transaction)trans)); + ((Transaction)trans).CommitReferenceSystem(); + return null; + } + + private readonly ObjectContainerBase _enclosing; + } + + private object AsTopLevelStore(IFunction4 block, Transaction trans) + { + trans = CheckTransaction(trans); + object result = AsTopLevelCall(block, trans); + if (_stackDepth == 0) + { + trans.ProcessDeletes(); + } + return result; + } + + // should never happen - just to make compiler happy + public virtual void FatalShutdown(Exception origExc) + { + try + { + StopSession(); + FatalStorageShutdown(); + } + catch (Exception exc) + { + throw new CompositeDb4oException(new Exception[] { origExc, exc }); + } + Platform4.ThrowUncheckedException(origExc); + } + + protected abstract void FatalStorageShutdown(); + + public abstract void Commit1(Transaction trans); + + public virtual IConfiguration Configure() + { + return ConfigImpl; + } + + public virtual Config4Impl Config() + { + return ConfigImpl; + } + + public abstract int ConverterVersion(); + + public abstract AbstractQueryResult NewQueryResult(Transaction trans, QueryEvaluationMode + mode); + + protected void CreateStringIO(byte encoding) + { + StringIO(BuiltInStringEncoding.StringIoForEncoding(encoding, ConfigImpl.StringEncoding + ())); + } + + protected void InitializeTransactions() + { + _systemTransaction = NewSystemTransaction(); + _transaction = NewUserTransaction(); + } + + public abstract Transaction NewTransaction(Transaction parentTransaction, IReferenceSystem + referenceSystem, bool isSystemTransaction); + + public virtual Transaction NewUserTransaction() + { + return NewTransaction(SystemTransaction(), CreateReferenceSystem(), false); + } + + public virtual Transaction NewSystemTransaction() + { + return NewTransaction(null, CreateReferenceSystem(), true); + } + + public abstract long CurrentVersion(); + + public virtual bool CreateClassMetadata(ClassMetadata classMeta, IReflectClass clazz + , ClassMetadata superClassMeta) + { + return classMeta.Init(superClassMeta); + } + + /// allows special handling for all Db4oType objects. + /// + /// allows special handling for all Db4oType objects. + /// Redirected here from #set() so only instanceof check is necessary + /// in the #set() method. + /// + /// object if handled here and #set() should not continue processing + public virtual IDb4oType Db4oTypeStored(Transaction trans, object obj) + { + if (!(obj is Db4oDatabase)) + { + return null; + } + Db4oDatabase database = (Db4oDatabase)obj; + if (trans.ReferenceForObject(obj) != null) + { + return database; + } + ShowInternalClasses(true); + try + { + return database.Query(trans); + } + finally + { + ShowInternalClasses(false); + } + } + + /// + public void Deactivate(Transaction trans, object obj, int depth) + { + lock (_lock) + { + AsTopLevelCall(new _IFunction4_516(this, obj, depth), trans); + } + } + + private sealed class _IFunction4_516 : IFunction4 + { + public _IFunction4_516(ObjectContainerBase _enclosing, object obj, int depth) + { + this._enclosing = _enclosing; + this.obj = obj; + this.depth = depth; + } + + public object Apply(object trans) + { + this._enclosing.DeactivateInternal(((Transaction)trans), obj, this._enclosing.ActivationDepthProvider + ().ActivationDepth(depth, ActivationMode.Deactivate)); + return null; + } + + private readonly ObjectContainerBase _enclosing; + + private readonly object obj; + + private readonly int depth; + } + + private void DeactivateInternal(Transaction trans, object obj, IActivationDepth depth + ) + { + StillToDeactivate(trans, obj, depth, true); + DeactivatePending(trans); + } + + private void DeactivatePending(Transaction trans) + { + while (_stillToDeactivate != null) + { + IEnumerator i = new Iterator4Impl(_stillToDeactivate); + _stillToDeactivate = null; + while (i.MoveNext()) + { + ObjectContainerBase.PendingActivation item = (ObjectContainerBase.PendingActivation + )i.Current; + item.@ref.Deactivate(trans, item.depth); + } + } + } + + /// + /// + public void Delete(Transaction trans, object obj) + { + if (null == obj) + { + throw new ArgumentNullException(); + } + lock (Lock()) + { + trans = CheckTransaction(trans); + CheckReadOnly(); + Delete1(trans, obj, true); + UnregisterFromTransparentPersistence(trans, obj); + trans.ProcessDeletes(); + } + } + + public void Delete1(Transaction trans, object obj, bool userCall) + { + if (obj == null) + { + return; + } + ObjectReference @ref = trans.ReferenceForObject(obj); + if (@ref == null) + { + return; + } + if (userCall) + { + GenerateCallIDOnTopLevel(); + } + AsTopLevelCall(new _IFunction4_565(this, @ref, obj, userCall), trans); + } + + private sealed class _IFunction4_565 : IFunction4 + { + public _IFunction4_565(ObjectContainerBase _enclosing, ObjectReference @ref, object + obj, bool userCall) + { + this._enclosing = _enclosing; + this.@ref = @ref; + this.obj = obj; + this.userCall = userCall; + } + + public object Apply(object trans) + { + this._enclosing.Delete2(((Transaction)trans), @ref, obj, 0, userCall); + return null; + } + + private readonly ObjectContainerBase _enclosing; + + private readonly ObjectReference @ref; + + private readonly object obj; + + private readonly bool userCall; + } + + public void Delete2(Transaction trans, ObjectReference @ref, object obj, int cascade + , bool userCall) + { + // This check is performed twice, here and in delete3, intentionally. + if (BreakDeleteForEnum(@ref, userCall)) + { + return; + } + if (obj is Entry) + { + if (!FlagForDelete(@ref)) + { + return; + } + Delete3(trans, @ref, obj, cascade, userCall); + return; + } + trans.Delete(@ref, @ref.GetID(), cascade); + } + + internal void Delete3(Transaction trans, ObjectReference @ref, object obj, int cascade + , bool userCall) + { + // The passed reference can be null, when calling from Transaction. + if (@ref == null || !@ref.BeginProcessing()) + { + return; + } + // This check is performed twice, here and in delete2, intentionally. + if (BreakDeleteForEnum(@ref, userCall)) + { + @ref.EndProcessing(); + return; + } + if (!@ref.IsFlaggedForDelete()) + { + @ref.EndProcessing(); + return; + } + ClassMetadata yc = @ref.ClassMetadata(); + // We have to end processing temporarily here, otherwise the can delete callback + // can't do anything at all with this object. + @ref.EndProcessing(); + ActivateForDeletionCallback(trans, yc, @ref, obj); + if (!ObjectCanDelete(trans, yc, @ref)) + { + return; + } + @ref.BeginProcessing(); + if (DTrace.enabled) + { + DTrace.Delete.Log(@ref.GetID()); + } + if (Delete4(trans, @ref, obj, cascade, userCall)) + { + ObjectOnDelete(trans, yc, @ref); + if (ConfigImpl.MessageLevel() > Const4.State) + { + Message(string.Empty + @ref.GetID() + " delete " + @ref.ClassMetadata().GetName() + ); + } + } + @ref.EndProcessing(); + } + + private void UnregisterFromTransparentPersistence(Transaction trans, object obj) + { + if (!(ActivationDepthProvider() is ITransparentActivationDepthProvider)) + { + return; + } + ITransparentActivationDepthProvider provider = (ITransparentActivationDepthProvider + )ActivationDepthProvider(); + provider.RemoveModified(obj, trans); + } + + private void ActivateForDeletionCallback(Transaction trans, ClassMetadata classMetadata + , ObjectReference @ref, object obj) + { + if (!@ref.IsActive() && (CaresAboutDeleting(classMetadata) || CaresAboutDeleted(classMetadata + ))) + { + // Activate Objects for Callbacks, because in C/S mode Objects are not activated on the Server + // FIXME: [TA] review activation depth + IActivationDepth depth = classMetadata.AdjustCollectionDepthToBorders(new FixedActivationDepth + (1)); + Activate(trans, obj, depth); + } + } + + private bool CaresAboutDeleting(ClassMetadata yc) + { + return this._callbacks.CaresAboutDeleting() || yc.HasEventRegistered(SystemTransaction + (), EventDispatchers.CanDelete); + } + + private bool CaresAboutDeleted(ClassMetadata yc) + { + return this._callbacks.CaresAboutDeleted() || yc.HasEventRegistered(SystemTransaction + (), EventDispatchers.Delete); + } + + private bool ObjectCanDelete(Transaction transaction, ClassMetadata yc, IObjectInfo + objectInfo) + { + return Callbacks().ObjectCanDelete(transaction, objectInfo) && yc.DispatchEvent(transaction + , objectInfo.GetObject(), EventDispatchers.CanDelete); + } + + private void ObjectOnDelete(Transaction transaction, ClassMetadata yc, IObjectInfo + reference) + { + Callbacks().ObjectOnDelete(transaction, reference); + yc.DispatchEvent(transaction, reference.GetObject(), EventDispatchers.Delete); + } + + public abstract bool Delete4(Transaction ta, ObjectReference @ref, object obj, int + a_cascade, bool userCall); + + internal virtual object Descend(Transaction trans, object obj, string[] path) + { + lock (_lock) + { + trans = CheckTransaction(trans); + ObjectReference @ref = trans.ReferenceForObject(obj); + if (@ref == null) + { + return null; + } + string fieldName = path[0]; + if (fieldName == null) + { + return null; + } + ClassMetadata classMetadata = @ref.ClassMetadata(); + ByRef foundField = new ByRef(); + classMetadata.TraverseAllAspects(new _TraverseFieldCommand_693(fieldName, foundField + )); + FieldMetadata field = (FieldMetadata)foundField.value; + if (field == null) + { + return null; + } + object child = @ref.IsActive() ? field.Get(trans, obj) : DescendMarshallingContext + (trans, @ref).ReadFieldValue(field); + if (path.Length == 1) + { + return child; + } + if (child == null) + { + return null; + } + string[] subPath = new string[path.Length - 1]; + System.Array.Copy(path, 1, subPath, 0, path.Length - 1); + return Descend(trans, child, subPath); + } + } + + private sealed class _TraverseFieldCommand_693 : TraverseFieldCommand + { + public _TraverseFieldCommand_693(string fieldName, ByRef foundField) + { + this.fieldName = fieldName; + this.foundField = foundField; + } + + protected override void Process(FieldMetadata field) + { + if (field.CanAddToQuery(fieldName)) + { + foundField.value = field; + } + } + + private readonly string fieldName; + + private readonly ByRef foundField; + } + + private UnmarshallingContext DescendMarshallingContext(Transaction trans, ObjectReference + @ref) + { + UnmarshallingContext context = new UnmarshallingContext(trans, @ref, Const4.AddToIdTree + , false); + context.ActivationDepth(ActivationDepthProvider().ActivationDepth(1, ActivationMode + .Activate)); + return context; + } + + public virtual bool DetectSchemaChanges() + { + // overriden in YapClient + return ConfigImpl.DetectSchemaChanges(); + } + + public virtual bool DispatchsEvents() + { + return true; + } + + protected virtual bool DoFinalize() + { + return true; + } + + internal void ShutdownHook() + { + if (IsClosed()) + { + return; + } + if (AllOperationsCompleted()) + { + Db4objects.Db4o.Internal.Messages.LogErr(ConfigImpl, 50, ToString(), null); + Close(); + } + else + { + ShutdownObjectContainer(); + if (OperationIsProcessing()) + { + Db4objects.Db4o.Internal.Messages.LogErr(ConfigImpl, 24, null, null); + } + } + } + + private bool OperationIsProcessing() + { + return _stackDepth > 0; + } + + private bool AllOperationsCompleted() + { + return _stackDepth == 0; + } + + internal virtual void FatalException(int msgID) + { + FatalException(null, msgID); + } + + internal void FatalException(Exception t) + { + FatalException(t, Db4objects.Db4o.Internal.Messages.FatalMsgId); + } + + internal void FatalException(Exception t, int msgID) + { + if (DTrace.enabled) + { + DTrace.FatalException.Log(t.ToString()); + } + Db4objects.Db4o.Internal.Messages.LogErr(ConfigImpl, (msgID == Db4objects.Db4o.Internal.Messages + .FatalMsgId ? 18 : msgID), null, t); + if (!IsClosed()) + { + ShutdownObjectContainer(); + } + throw new Db4oException(Db4objects.Db4o.Internal.Messages.Get(msgID)); + } + + private bool ConfiguredForAutomaticShutDown() + { + return (ConfigImpl == null || ConfigImpl.AutomaticShutDown()); + } + + internal virtual void Gc() + { + _references.Purge(); + } + + public IObjectSet QueryByExample(Transaction trans, object template) + { + lock (_lock) + { + trans = CheckTransaction(trans); + IQueryResult res = ((IQueryResult)AsTopLevelCall(new _IFunction4_810(this, template + ), trans)); + return new ObjectSetFacade(res); + } + } + + private sealed class _IFunction4_810 : IFunction4 + { + public _IFunction4_810(ObjectContainerBase _enclosing, object template) + { + this._enclosing = _enclosing; + this.template = template; + } + + public object Apply(object trans) + { + return this._enclosing.QueryByExampleInternal(((Transaction)trans), template); + } + + private readonly ObjectContainerBase _enclosing; + + private readonly object template; + } + + private IQueryResult QueryByExampleInternal(Transaction trans, object template) + { + if (template == null || template.GetType() == Const4.ClassObject || template == Const4 + .ClassObject) + { + return QueryAllObjects(trans); + } + IQuery q = Query(trans); + q.Constrain(template).ByExample(); + return ExecuteQuery((QQuery)q); + } + + public abstract AbstractQueryResult QueryAllObjects(Transaction ta); + + /// + public object TryGetByID(Transaction ta, long id) + { + try + { + return GetByID(ta, id); + } + catch (InvalidSlotException) + { + } + catch (InvalidIDException) + { + } + // can happen return null + // can happen return null + return null; + } + + /// + /// + public object GetByID(Transaction ta, long id) + { + lock (_lock) + { + if (id <= 0 || id >= int.MaxValue) + { + throw new ArgumentException(); + } + CheckClosed(); + ta = CheckTransaction(ta); + BeginTopLevelCall(); + try + { + return GetByID2(ta, (int)id); + } + catch (Db4oRecoverableException exc) + { + throw; + } + catch (OutOfMemoryException e) + { + throw new Db4oRecoverableException(e); + } + catch (Exception e) + { + throw new Db4oRecoverableException(e); + } + finally + { + // Never shut down for getById() + // There may be OutOfMemoryErrors or similar + // The user may want to catch and continue working. + EndTopLevelCall(); + } + } + } + + public virtual object GetByID2(Transaction ta, int id) + { + object obj = ta.ObjectForIdFromCache(id); + if (obj != null) + { + // Take care about handling the returned candidate reference. + // If you loose the reference, weak reference management might + // also. + return obj; + } + return new ObjectReference(id).Read(ta, new LegacyActivationDepth(0), Const4.AddToIdTree + , true); + } + + public object GetActivatedObjectFromCache(Transaction ta, int id) + { + object obj = ta.ObjectForIdFromCache(id); + if (obj == null) + { + return null; + } + Activate(ta, obj); + return obj; + } + + public object ReadActivatedObjectNotInCache(Transaction trans, int id) + { + object obj = AsTopLevelCall(new _IFunction4_892(id), trans); + ActivatePending(trans); + return obj; + } + + private sealed class _IFunction4_892 : IFunction4 + { + public _IFunction4_892(int id) + { + this.id = id; + } + + public object Apply(object trans) + { + return new ObjectReference(id).Read(((Transaction)trans), UnknownActivationDepth. + Instance, Const4.AddToIdTree, true); + } + + private readonly int id; + } + + public object GetByUUID(Transaction trans, Db4oUUID uuid) + { + lock (_lock) + { + if (uuid == null) + { + return null; + } + HardObjectReference hardRef = GetHardReferenceBySignature(CheckTransaction(trans) + , uuid.GetLongPart(), uuid.GetSignaturePart()); + return hardRef._object; + } + } + + public virtual HardObjectReference GetHardReferenceBySignature(Transaction trans, + long uuid, byte[] signature) + { + return UUIDIndex().GetHardObjectReferenceBySignature(trans, uuid, signature); + } + + public int GetID(Transaction trans, object obj) + { + lock (_lock) + { + trans = CheckTransaction(trans); + CheckClosed(); + if (obj == null) + { + return 0; + } + ObjectReference yo = trans.ReferenceForObject(obj); + if (yo != null) + { + return yo.GetID(); + } + return 0; + } + } + + public IObjectInfo GetObjectInfo(Transaction trans, object obj) + { + lock (_lock) + { + trans = CheckTransaction(trans); + return trans.ReferenceForObject(obj); + } + } + + public HardObjectReference GetHardObjectReferenceById(Transaction trans, int id) + { + if (id <= 0) + { + return HardObjectReference.Invalid; + } + ObjectReference @ref = trans.ReferenceForId(id); + if (@ref != null) + { + // Take care about handling the returned candidate reference. + // If you loose the reference, weak reference management might also. + object candidate = @ref.GetObject(); + if (candidate != null) + { + return new HardObjectReference(@ref, candidate); + } + trans.RemoveReference(@ref); + } + @ref = new ObjectReference(id); + object readObject = @ref.Read(trans, new LegacyActivationDepth(0), Const4.AddToIdTree + , true); + if (readObject == null) + { + return HardObjectReference.Invalid; + } + // check class creation side effect and simply retry recursively + // if it hits: + if (readObject != @ref.GetObject()) + { + return GetHardObjectReferenceById(trans, id); + } + return new HardObjectReference(@ref, readObject); + } + + public StatefulBuffer CreateStatefulBuffer(Transaction trans, int address, int length + ) + { + if (Debug4.ExceedsMaximumBlockSize(length)) + { + return null; + } + return new StatefulBuffer(trans, address, length); + } + + public Transaction SystemTransaction() + { + return _systemTransaction; + } + + public Transaction Transaction + { + get + { + return _transaction; + } + } + + public ClassMetadata ClassMetadataForReflectClass(IReflectClass claxx) + { + if (null == claxx) + { + throw new ArgumentNullException(); + } + if (HideClassForExternalUse(claxx)) + { + return null; + } + ClassMetadata classMetadata = _handlers.ClassMetadataForClass(claxx); + if (classMetadata != null) + { + return classMetadata; + } + return _classCollection.ClassMetadataForReflectClass(claxx); + } + + // TODO: Some ReflectClass implementations could hold a + // reference to ClassMetadata to improve lookup performance here. + public virtual ClassMetadata ProduceClassMetadata(IReflectClass claxx) + { + if (null == claxx) + { + throw new ArgumentNullException(); + } + if (HideClassForExternalUse(claxx)) + { + return null; + } + ClassMetadata classMetadata = _handlers.ClassMetadataForClass(claxx); + if (classMetadata != null) + { + return classMetadata; + } + return _classCollection.ProduceClassMetadata(claxx); + } + + /// + /// Differentiating getActiveClassMetadata from getYapClass is a tuning + /// optimization: If we initialize a YapClass, #set3() has to check for + /// the possibility that class initialization associates the currently + /// stored object with a previously stored static object, causing the + /// object to be known afterwards. + /// + /// + /// Differentiating getActiveClassMetadata from getYapClass is a tuning + /// optimization: If we initialize a YapClass, #set3() has to check for + /// the possibility that class initialization associates the currently + /// stored object with a previously stored static object, causing the + /// object to be known afterwards. + /// In this call we only return active YapClasses, initialization + /// is not done on purpose + /// + internal ClassMetadata GetActiveClassMetadata(IReflectClass claxx) + { + if (HideClassForExternalUse(claxx)) + { + return null; + } + return _classCollection.GetActiveClassMetadata(claxx); + } + + private bool HideClassForExternalUse(IReflectClass claxx) + { + if ((!ShowInternalClasses()) && _handlers.IclassInternal.IsAssignableFrom(claxx)) + { + return true; + } + return false; + } + + public virtual int ClassMetadataIdForName(string name) + { + return _classCollection.ClassMetadataIdForName(name); + } + + public virtual ClassMetadata ClassMetadataForName(string name) + { + return ClassMetadataForID(ClassMetadataIdForName(name)); + } + + public virtual ClassMetadata ClassMetadataForID(int id) + { + if (DTrace.enabled) + { + DTrace.ClassmetadataById.Log(id); + } + if (id == 0) + { + return null; + } + ClassMetadata classMetadata = _handlers.ClassMetadataForId(id); + if (classMetadata != null) + { + return classMetadata; + } + return _classCollection.ClassMetadataForId(id); + } + + public virtual HandlerRegistry Handlers + { + get + { + return _handlers; + } + } + + public virtual bool NeedsLockFileThread() + { + if (!Platform4.NeedsLockFileThread()) + { + return false; + } + if (ConfigImpl.IsReadOnly()) + { + return false; + } + return ConfigImpl.LockFile(); + } + + protected virtual bool HasShutDownHook() + { + return ConfigImpl.AutomaticShutDown(); + } + + protected virtual void Initialize1(IConfiguration config) + { + _config = InitializeConfig(config); + _handlers = new HandlerRegistry(this, ConfigImpl.Encoding(), ConfigImpl.Reflector + ()); + if (_references != null) + { + Gc(); + _references.Stop(); + } + _references = WeakReferenceSupportFactory.ForObjectContainer(this); + if (HasShutDownHook()) + { + Platform4.AddShutDownHook(this); + } + _handlers.InitEncryption(ConfigImpl); + _stillToSet = null; + } + + private Config4Impl InitializeConfig(IConfiguration config) + { + Config4Impl impl = ((Config4Impl)config); + impl.Container(this); + impl.Reflector().SetTransaction(SystemTransaction()); + impl.Reflector().Configuration(new ReflectorConfigurationImpl(impl)); + impl.Taint(); + return impl; + } + + public virtual IReferenceSystem CreateReferenceSystem() + { + IReferenceSystem referenceSystem = _referenceSystemFactory.NewReferenceSystem(this + ); + _referenceSystemRegistry.AddReferenceSystem(referenceSystem); + return referenceSystem; + } + + protected virtual void InitalizeWeakReferenceSupport() + { + _references.Start(); + } + + protected virtual void InitializeClassMetadataRepository() + { + _classCollection = new ClassMetadataRepository(_systemTransaction); + } + + private void InitializePostOpen() + { + _showInternalClasses = 100000; + InitializePostOpenExcludingTransportObjectContainer(); + _showInternalClasses = 0; + } + + protected virtual void InitializePostOpenExcludingTransportObjectContainer() + { + InitializeEssentialClasses(); + Rename(ConfigImpl); + _classCollection.InitOnUp(_systemTransaction); + if (ConfigImpl.DetectSchemaChanges()) + { + if (!ConfigImpl.IsReadOnly()) + { + _systemTransaction.Commit(); + } + } + ConfigImpl.ApplyConfigurationItems(this); + } + + internal virtual void InitializeEssentialClasses() + { + for (int i = 0; i < Const4.EssentialClasses.Length; i++) + { + ProduceClassMetadata(Reflector().ForClass(Const4.EssentialClasses[i])); + } + } + + internal bool IsActive(Transaction trans, object obj) + { + lock (_lock) + { + trans = CheckTransaction(trans); + if (obj != null) + { + ObjectReference @ref = trans.ReferenceForObject(obj); + if (@ref != null) + { + return @ref.IsActive(); + } + } + return false; + } + } + + public virtual bool IsCached(Transaction trans, long id) + { + lock (_lock) + { + trans = CheckTransaction(trans); + return trans.ObjectForIdFromCache((int)id) != null; + } + } + + /// + /// overridden in ClientObjectContainer + /// The method allows checking whether will make it easier to refactor than + /// an "instanceof YapClient" check. + /// + /// + /// overridden in ClientObjectContainer + /// The method allows checking whether will make it easier to refactor than + /// an "instanceof YapClient" check. + /// + public virtual bool IsClient + { + get + { + return false; + } + } + + public bool IsClosed() + { + lock (_lock) + { + // this is set to null in close2 and is therefore our check for down. + return _classCollection == null; + } + } + + internal virtual bool IsServer() + { + return false; + } + + public bool IsStored(Transaction trans, object obj) + { + lock (_lock) + { + trans = CheckTransaction(trans); + if (obj == null) + { + return false; + } + ObjectReference @ref = trans.ReferenceForObject(obj); + if (@ref == null) + { + return false; + } + return !IsDeleted(trans, @ref.GetID()); + } + } + + public virtual IReflectClass[] KnownClasses() + { + lock (_lock) + { + CheckClosed(); + return Reflector().KnownClasses(); + } + } + + public virtual ITypeHandler4 TypeHandlerForClass(IReflectClass claxx) + { + if (HideClassForExternalUse(claxx)) + { + return null; + } + ITypeHandler4 typeHandler = _handlers.TypeHandlerForClass(claxx); + if (typeHandler != null) + { + return typeHandler; + } + return _classCollection.ProduceClassMetadata(claxx).TypeHandler(); + } + + public virtual ITypeHandler4 TypeHandlerForClassMetadataID(int id) + { + if (id < 1) + { + return null; + } + ClassMetadata classMetadata = ClassMetadataForID(id); + if (classMetadata == null) + { + return null; + } + return classMetadata.TypeHandler(); + } + + public virtual object Lock() + { + return _lock; + } + + public void LogMsg(int code, string msg) + { + Db4objects.Db4o.Internal.Messages.LogMsg(ConfigImpl, code, msg); + } + + public virtual bool MaintainsIndices() + { + return true; + } + + internal virtual void Message(string msg) + { + new MessageOutput(this, msg); + } + + public void NeedsUpdate(ClassMetadata classMetadata) + { + _pendingClassUpdates = new List4(_pendingClassUpdates, classMetadata); + } + + public virtual long GenerateTimeStampId() + { + return _timeStampIdGenerator.Generate(); + } + + public abstract int IdForNewUserObject(Transaction trans); + + /// + public virtual object PeekPersisted(Transaction trans, object obj, IActivationDepth + depth, bool committed) + { + // TODO: peekPersisted is not stack overflow safe, if depth is too high. + lock (_lock) + { + CheckClosed(); + return AsTopLevelCall(new _IFunction4_1271(this, obj, committed, depth), trans); + } + } + + private sealed class _IFunction4_1271 : IFunction4 + { + public _IFunction4_1271(ObjectContainerBase _enclosing, object obj, bool committed + , IActivationDepth depth) + { + this._enclosing = _enclosing; + this.obj = obj; + this.committed = committed; + this.depth = depth; + } + + public object Apply(object trans) + { + trans = this._enclosing.CheckTransaction(((Transaction)trans)); + ObjectReference @ref = ((Transaction)trans).ReferenceForObject(obj); + trans = committed ? this._enclosing._systemTransaction : ((Transaction)trans); + object cloned = null; + if (@ref != null) + { + cloned = this._enclosing.PeekPersisted(((Transaction)trans), @ref.GetID(), depth, + true); + } + return cloned; + } + + private readonly ObjectContainerBase _enclosing; + + private readonly object obj; + + private readonly bool committed; + + private readonly IActivationDepth depth; + } + + public object PeekPersisted(Transaction trans, int id, IActivationDepth depth, bool + resetJustPeeked) + { + if (resetJustPeeked) + { + _justPeeked = null; + } + else + { + TreeInt ti = new TreeInt(id); + TreeIntObject tio = (TreeIntObject)Tree.Find(_justPeeked, ti); + if (tio != null) + { + return tio._object; + } + } + ObjectReference @ref = PeekReference(trans, id, depth, resetJustPeeked); + return @ref.GetObject(); + } + + public virtual ObjectReference PeekReference(Transaction trans, int id, IActivationDepth + depth, bool resetJustPeeked) + { + ObjectReference @ref = new ObjectReference(id); + @ref.PeekPersisted(trans, depth); + if (resetJustPeeked) + { + _justPeeked = null; + } + return @ref; + } + + internal virtual void Peeked(int id, object obj) + { + _justPeeked = Tree.Add(_justPeeked, new TreeIntObject(id, obj)); + } + + public virtual void Purge() + { + lock (_lock) + { + CheckClosed(); + Runtime.Gc(); + Runtime.RunFinalization(); + Runtime.Gc(); + Gc(); + _classCollection.Purge(); + } + } + + public void Purge(Transaction trans, object obj) + { + lock (_lock) + { + trans = CheckTransaction(trans); + trans.RemoveObjectFromReferenceSystem(obj); + } + } + + internal void RemoveFromAllReferenceSystems(object obj) + { + if (obj == null) + { + return; + } + if (obj is ObjectReference) + { + _referenceSystemRegistry.RemoveReference((ObjectReference)obj); + return; + } + _referenceSystemRegistry.RemoveObject(obj); + } + + public NativeQueryHandler GetNativeQueryHandler() + { + lock (_lock) + { + if (null == _nativeQueryHandler) + { + _nativeQueryHandler = new NativeQueryHandler(this); + } + return _nativeQueryHandler; + } + } + + public IObjectSet Query(Transaction trans, Predicate predicate) + { + return Query(trans, predicate, (IQueryComparator)null); + } + + public IObjectSet Query(Transaction trans, Predicate predicate, IQueryComparator + comparator) + { + lock (_lock) + { + return GetNativeQueryHandler().Execute(Query(trans), predicate, comparator); + } + } + + public IObjectSet Query(Transaction trans, Type clazz) + { + return QueryByExample(trans, clazz); + } + + public IQuery Query(Transaction ta) + { + return new QQuery(CheckTransaction(ta), null, null); + } + + public abstract void RaiseCommitTimestamp(long minimumTimestamp); + + /// + public abstract void ReadBytes(byte[] a_bytes, int a_address, int a_length); + + /// + public abstract void ReadBytes(byte[] bytes, int address, int addressOffset, int + length); + + /// + public ByteArrayBuffer DecryptedBufferByAddress(int address, int length) + { + ByteArrayBuffer reader = RawBufferByAddress(address, length); + _handlers.Decrypt(reader); + return reader; + } + + public virtual ByteArrayBuffer RawBufferByAddress(int address, int length) + { + CheckAddress(address); + ByteArrayBuffer reader = new ByteArrayBuffer(length); + ReadBytes(reader._buffer, address, length); + return reader; + } + + /// + private void CheckAddress(int address) + { + if (address <= 0) + { + throw new ArgumentException("Invalid address offset: " + address); + } + } + + /// + public StatefulBuffer ReadWriterByAddress(Transaction a_trans, int address, int length + ) + { + CheckAddress(address); + StatefulBuffer reader = CreateStatefulBuffer(a_trans, address, length); + reader.ReadEncrypt(this, address); + return reader; + } + + public abstract StatefulBuffer ReadStatefulBufferById(Transaction trans, int id); + + public abstract StatefulBuffer ReadStatefulBufferById(Transaction trans, int id, + bool lastCommitted); + + public abstract ByteArrayBuffer ReadBufferById(Transaction trans, int id); + + public abstract ByteArrayBuffer ReadBufferById(Transaction trans, int id, bool lastCommitted + ); + + public abstract ByteArrayBuffer[] ReadSlotBuffers(Transaction trans, int[] ids); + + private void Reboot() + { + Commit(null); + Close(); + Open(); + } + + public virtual GenericReflector Reflector() + { + return _handlers._reflector; + } + + public void Refresh(Transaction trans, object obj, int depth) + { + lock (_lock) + { + RefreshInternal(trans, obj, depth); + } + } + + protected virtual void RefreshInternal(Transaction trans, object obj, int depth) + { + Activate(trans, obj, RefreshActivationDepth(depth)); + } + + private IActivationDepth RefreshActivationDepth(int depth) + { + return ActivationDepthProvider().ActivationDepth(depth, ActivationMode.Refresh); + } + + public abstract void ReleaseSemaphore(string name); + + public virtual void FlagAsHandled(ObjectReference @ref) + { + @ref.FlagAsHandled(_topLevelCallId); + } + + internal virtual bool FlagForDelete(ObjectReference @ref) + { + if (@ref == null) + { + return false; + } + if (HandledInCurrentTopLevelCall(@ref)) + { + return false; + } + @ref.FlagForDelete(_topLevelCallId); + return true; + } + + public abstract void ReleaseSemaphores(Transaction ta); + + internal virtual void Rename(Config4Impl config) + { + bool renamedOne = false; + if (config.Rename() != null) + { + renamedOne = ApplyRenames(config); + } + _classCollection.CheckChanges(); + if (renamedOne) + { + Reboot(); + } + } + + protected virtual bool ApplyRenames(Config4Impl config) + { + bool renamed = false; + IEnumerator i = config.Rename().GetEnumerator(); + while (i.MoveNext()) + { + Rename ren = (Rename)i.Current; + if (AlreadyApplied(ren)) + { + continue; + } + if (ApplyRename(ren)) + { + renamed = true; + } + } + return renamed; + } + + private bool ApplyRename(Rename ren) + { + if (ren.IsField()) + { + return ApplyFieldRename(ren); + } + return ApplyClassRename(ren); + } + + private bool ApplyClassRename(Rename ren) + { + ClassMetadata classToRename = _classCollection.GetClassMetadata(ren.rFrom); + if (classToRename == null) + { + return false; + } + ClassMetadata existing = _classCollection.GetClassMetadata(ren.rTo); + if (existing != null) + { + LogMsg(9, "class " + ren.rTo); + return false; + } + classToRename.SetName(ren.rTo); + CommitRenameFor(ren, classToRename); + return true; + } + + private bool ApplyFieldRename(Rename ren) + { + ClassMetadata parentClass = _classCollection.GetClassMetadata(ren.rClass); + if (parentClass == null) + { + return false; + } + if (!parentClass.RenameField(ren.rFrom, ren.rTo)) + { + return false; + } + CommitRenameFor(ren, parentClass); + return true; + } + + private void CommitRenameFor(Rename rename, ClassMetadata classMetadata) + { + SetDirtyInSystemTransaction(classMetadata); + LogMsg(8, rename.rFrom + " to " + rename.rTo); + DeleteInverseRenames(rename); + // store the rename, so we only do it once + Store(SystemTransaction(), rename); + } + + private void DeleteInverseRenames(Rename rename) + { + // delete all that rename from the new name + // to allow future backswitching + IObjectSet inverseRenames = QueryInverseRenames(rename); + while (inverseRenames.HasNext()) + { + Delete(SystemTransaction(), inverseRenames.Next()); + } + } + + private IObjectSet QueryInverseRenames(Rename ren) + { + return QueryByExample(SystemTransaction(), Renames.ForInverseQBE(ren)); + } + + private bool AlreadyApplied(Rename ren) + { + return QueryByExample(SystemTransaction(), ren).Count != 0; + } + + public bool HandledInCurrentTopLevelCall(ObjectReference @ref) + { + return @ref.IsFlaggedAsHandled(_topLevelCallId); + } + + public abstract void Reserve(int byteCount); + + public void Rollback(Transaction trans) + { + lock (_lock) + { + trans = CheckTransaction(trans); + CheckReadOnly(); + Rollback1(trans); + trans.RollbackReferenceSystem(); + } + } + + public abstract void Rollback1(Transaction trans); + + /// + public virtual void Send(object obj) + { + // TODO: implement + throw new NotSupportedException(); + } + + /// + /// + public void Store(Transaction trans, object obj) + { + Store(trans, obj, UpdateDepthProvider().Unspecified(NullModifiedObjectQuery.Instance + )); + } + + /// + /// + public int Store(Transaction trans, object obj, IUpdateDepth depth) + { + lock (_lock) + { + try + { + ShowInternalClasses(true); + return StoreInternal(trans, obj, depth, true); + } + finally + { + ShowInternalClasses(false); + } + } + } + + /// + /// + public int StoreInternal(Transaction trans, object obj, bool checkJustSet) + { + return StoreInternal(trans, obj, UpdateDepthProvider().Unspecified(NullModifiedObjectQuery + .Instance), checkJustSet); + } + + /// + /// + public virtual int StoreInternal(Transaction trans, object obj, IUpdateDepth depth + , bool checkJustSet) + { + CheckReadOnly(); + return (((int)AsTopLevelStore(new _IFunction4_1599(this, obj, depth, checkJustSet + ), trans))); + } + + private sealed class _IFunction4_1599 : IFunction4 + { + public _IFunction4_1599(ObjectContainerBase _enclosing, object obj, IUpdateDepth + depth, bool checkJustSet) + { + this._enclosing = _enclosing; + this.obj = obj; + this.depth = depth; + this.checkJustSet = checkJustSet; + } + + public object Apply(object trans) + { + return this._enclosing.StoreAfterReplication(((Transaction)trans), obj, depth, checkJustSet + ); + } + + private readonly ObjectContainerBase _enclosing; + + private readonly object obj; + + private readonly IUpdateDepth depth; + + private readonly bool checkJustSet; + } + + public int StoreAfterReplication(Transaction trans, object obj, IUpdateDepth depth + , bool checkJust) + { + if (obj is IDb4oType) + { + IDb4oType db4oType = Db4oTypeStored(trans, obj); + if (db4oType != null) + { + return GetID(trans, db4oType); + } + } + return Store2(trans, obj, depth, checkJust); + } + + public void StoreByNewReplication(IDb4oReplicationReferenceProvider referenceProvider + , object obj) + { + lock (_lock) + { + _replicationCallState = Const4.New; + _handlers._replicationReferenceProvider = referenceProvider; + try + { + Store2(CheckTransaction(), obj, UpdateDepthProvider().ForDepth(1), false); + } + finally + { + _replicationCallState = Const4.None; + _handlers._replicationReferenceProvider = null; + } + } + } + + public virtual void CheckStillToSet() + { + List4 postponedStillToSet = null; + while (_stillToSet != null) + { + IEnumerator i = new Iterator4Impl(_stillToSet); + _stillToSet = null; + while (i.MoveNext()) + { + ObjectContainerBase.PendingSet item = (ObjectContainerBase.PendingSet)i.Current; + ObjectReference @ref = item.@ref; + Transaction trans = item.transaction; + if (!@ref.ContinueSet(trans, item.depth)) + { + postponedStillToSet = new List4(postponedStillToSet, item); + } + } + } + _stillToSet = postponedStillToSet; + } + + internal virtual void NotStorable(IReflectClass claxx, object obj) + { + if (!ConfigImpl.ExceptionsOnNotStorable()) + { + return; + } + if (claxx == null) + { + throw new ObjectNotStorableException(obj.ToString()); + } + if (_handlers.IsTransient(claxx)) + { + return; + } + throw new ObjectNotStorableException(claxx); + } + + public int Store2(Transaction trans, object obj, IUpdateDepth updateDepth, bool checkJustSet + ) + { + if (obj == null || (obj is ITransientClass)) + { + return 0; + } + ObjectAnalyzer analyzer = new ObjectAnalyzer(this, obj); + analyzer.Analyze(trans); + if (analyzer.NotStorable()) + { + return 0; + } + ObjectReference @ref = analyzer.ObjectReference(); + if (@ref == null) + { + ClassMetadata classMetadata = analyzer.ClassMetadata(); + if (!ObjectCanNew(trans, classMetadata, obj)) + { + return 0; + } + @ref = new ObjectReference(); + @ref.Store(trans, classMetadata, obj); + trans.AddNewReference(@ref); + if (obj is IDb4oTypeImpl) + { + ((IDb4oTypeImpl)obj).SetTrans(trans); + } + if (ConfigImpl.MessageLevel() > Const4.State) + { + Message(string.Empty + @ref.GetID() + " new " + @ref.ClassMetadata().GetName()); + } + FlagAsHandled(@ref); + StillToSet(trans, @ref, updateDepth); + } + else + { + if (@ref.IsFlaggedAsHandled(_topLevelCallId)) + { + AssertNotInCallback(); + } + if (CanUpdate()) + { + if (checkJustSet) + { + if ((!@ref.IsNew()) && HandledInCurrentTopLevelCall(@ref)) + { + return @ref.GetID(); + } + } + if (updateDepth.SufficientDepth()) + { + FlagAsHandled(@ref); + @ref.WriteUpdate(trans, updateDepth); + } + } + } + ProcessPendingClassUpdates(); + return @ref.GetID(); + } + + private void AssertNotInCallback() + { + if (InCallback.Value()) + { + throw new Db4oIllegalStateException("Objects must not be updated in callback"); + } + } + + private bool ObjectCanNew(Transaction transaction, ClassMetadata yc, object obj) + { + return Callbacks().ObjectCanNew(transaction, obj) && yc.DispatchEvent(transaction + , obj, EventDispatchers.CanNew); + } + + public abstract void SetDirtyInSystemTransaction(PersistentBase a_object); + + public abstract bool SetSemaphore(string name, int timeout); + + public abstract bool SetSemaphore(Transaction trans, string name, int timeout); + + public abstract void ReleaseSemaphore(Transaction trans, string name); + + internal virtual void StringIO(LatinStringIO io) + { + _handlers.StringIO(io); + } + + internal bool ShowInternalClasses() + { + return IsServer() || _showInternalClasses > 0; + } + + /// + /// Objects implementing the "Internal4" marker interface are + /// not visible to queries, unless this flag is set to true. + /// + /// + /// Objects implementing the "Internal4" marker interface are + /// not visible to queries, unless this flag is set to true. + /// The caller should reset the flag after the call. + /// + public virtual void ShowInternalClasses(bool show) + { + lock (this) + { + if (show) + { + _showInternalClasses++; + } + else + { + _showInternalClasses--; + } + if (_showInternalClasses < 0) + { + _showInternalClasses = 0; + } + } + } + + private bool StackIsSmall() + { + return _stackDepth < _maxStackDepth; + } + + internal virtual bool StateMessages() + { + return true; + } + + // overridden to do nothing in YapObjectCarrier + internal List4 StillTo1(Transaction trans, List4 still, object obj, IActivationDepth + depth) + { + if (obj == null || !depth.RequiresActivation()) + { + return still; + } + ObjectReference @ref = trans.ReferenceForObject(obj); + if (@ref != null) + { + if (HandledInCurrentTopLevelCall(@ref)) + { + return still; + } + FlagAsHandled(@ref); + return new List4(still, new ObjectContainerBase.PendingActivation(@ref, depth)); + } + IReflectClass clazz = ReflectorForObject(obj); + if (clazz.IsArray()) + { + if (!clazz.GetComponentType().IsPrimitive()) + { + IEnumerator arr = ArrayHandler.Iterator(clazz, obj); + while (arr.MoveNext()) + { + object current = arr.Current; + if (current == null) + { + continue; + } + ClassMetadata classMetadata = ClassMetadataForObject(current); + still = StillTo1(trans, still, current, depth.Descend(classMetadata)); + } + } + return still; + } + else + { + if (obj is Entry) + { + still = StillTo1(trans, still, ((Entry)obj).key, depth); + still = StillTo1(trans, still, ((Entry)obj).value, depth); + } + else + { + if (depth.Mode().IsDeactivate()) + { + // Special handling to deactivate .net structs + ClassMetadata metadata = ClassMetadataForObject(obj); + if (metadata != null && metadata.IsStruct()) + { + metadata.ForceDeactivation(trans, depth, obj); + } + } + } + } + return still; + } + + public void StillToActivate(IActivationContext context) + { + // TODO: We don't want the simple classes to search the hc_tree + // Kick them out here. + // if (a_object != null) { + // Class clazz = a_object.getClass(); + // if(! clazz.isPrimitive()){ + if (ProcessedByImmediateActivation(context)) + { + return; + } + _stillToActivate = StillTo1(context.Transaction(), _stillToActivate, context.TargetObject + (), context.Depth()); + } + + private bool ProcessedByImmediateActivation(IActivationContext context) + { + if (!StackIsSmall()) + { + return false; + } + if (!context.Depth().RequiresActivation()) + { + return true; + } + ObjectReference @ref = context.Transaction().ReferenceForObject(context.TargetObject + ()); + if (@ref == null) + { + return false; + } + if (HandledInCurrentTopLevelCall(@ref)) + { + return true; + } + FlagAsHandled(@ref); + IncStackDepth(); + try + { + @ref.ActivateInternal(context); + } + finally + { + DecStackDepth(); + } + return true; + } + + private int DecStackDepth() + { + int i = _stackDepth--; + if (StackIsSmall() && !_handlingStackLimitPendings) + { + _handlingStackLimitPendings = true; + try + { + HandleStackLimitPendings(); + } + finally + { + _handlingStackLimitPendings = false; + } + } + return i; + } + + private void HandleStackLimitPendings() + { + CheckStillToSet(); + } + + // activatePending(); + // deactivatePending(); + private int IncStackDepth() + { + return _stackDepth++; + } + + public void StillToDeactivate(Transaction trans, object a_object, IActivationDepth + a_depth, bool a_forceUnknownDeactivate) + { + _stillToDeactivate = StillTo1(trans, _stillToDeactivate, a_object, a_depth); + } + + internal class PendingSet + { + public readonly Transaction transaction; + + public readonly ObjectReference @ref; + + public readonly IUpdateDepth depth; + + public PendingSet(Transaction transaction_, ObjectReference ref_, IUpdateDepth depth_ + ) + { + this.transaction = transaction_; + this.@ref = ref_; + this.depth = depth_; + } + } + + internal virtual void StillToSet(Transaction transaction, ObjectReference @ref, IUpdateDepth + updateDepth) + { + if (StackIsSmall()) + { + if (@ref.ContinueSet(transaction, updateDepth)) + { + return; + } + } + _stillToSet = new List4(_stillToSet, new ObjectContainerBase.PendingSet(transaction + , @ref, updateDepth)); + } + + protected void StopSession() + { + if (HasShutDownHook()) + { + Platform4.RemoveShutDownHook(this); + } + _classCollection = null; + if (_references != null) + { + _references.Stop(); + } + _systemTransaction = null; + _transaction = null; + } + + public IStoredClass StoredClass(Transaction trans, object clazz) + { + lock (_lock) + { + trans = CheckTransaction(trans); + IReflectClass claxx = ReflectorUtils.ReflectClassFor(Reflector(), clazz); + if (claxx == null) + { + return null; + } + ClassMetadata classMetadata = ClassMetadataForReflectClass(claxx); + if (classMetadata == null) + { + return null; + } + return new StoredClassImpl(trans, classMetadata); + } + } + + public virtual IStoredClass[] StoredClasses(Transaction trans) + { + lock (_lock) + { + trans = CheckTransaction(trans); + IStoredClass[] classMetadata = _classCollection.StoredClasses(); + IStoredClass[] storedClasses = new IStoredClass[classMetadata.Length]; + for (int i = 0; i < classMetadata.Length; i++) + { + storedClasses[i] = new StoredClassImpl(trans, (ClassMetadata)classMetadata[i]); + } + return storedClasses; + } + } + + public virtual LatinStringIO StringIO() + { + return _handlers.StringIO(); + } + + public abstract ISystemInfo SystemInfo(); + + private void BeginTopLevelCall() + { + if (DTrace.enabled) + { + DTrace.BeginTopLevelCall.Log(); + } + GenerateCallIDOnTopLevel(); + IncStackDepth(); + } + + private void EndTopLevelCall() + { + if (DTrace.enabled) + { + DTrace.EndTopLevelCall.Log(); + } + DecStackDepth(); + GenerateCallIDOnTopLevel(); + } + + private void GenerateCallIDOnTopLevel() + { + if (_stackDepth == 0) + { + _topLevelCallId = _topLevelCallIdGenerator.Next(); + } + } + + public virtual int StackDepth() + { + return _stackDepth; + } + + public virtual void StackDepth(int depth) + { + _stackDepth = depth; + } + + public virtual int TopLevelCallId() + { + return _topLevelCallId; + } + + public virtual void TopLevelCallId(int id) + { + _topLevelCallId = id; + } + + public virtual long Version() + { + lock (_lock) + { + return CurrentVersion(); + } + } + + public abstract void Shutdown(); + + public abstract void WriteDirtyClassMetadata(); + + public abstract void WriteNew(Transaction trans, Pointer4 pointer, ClassMetadata + classMetadata, ByteArrayBuffer buffer); + + public abstract void WriteUpdate(Transaction trans, Pointer4 pointer, ClassMetadata + classMetadata, ArrayType arrayType, ByteArrayBuffer buffer); + + public virtual ICallbacks Callbacks() + { + return _callbacks; + } + + public virtual void Callbacks(ICallbacks cb) + { + if (cb == null) + { + throw new ArgumentException(); + } + _callbacks = cb; + } + + public virtual Config4Impl ConfigImpl + { + get + { + return _config; + } + } + + public virtual UUIDFieldMetadata UUIDIndex() + { + return _handlers.Indexes()._uUID; + } + + public virtual VersionFieldMetadata VersionIndex() + { + return _handlers.Indexes()._version; + } + + public virtual CommitTimestampFieldMetadata CommitTimestampIndex() + { + return _handlers.Indexes()._commitTimestamp; + } + + public virtual ClassMetadataRepository ClassCollection() + { + return _classCollection; + } + + public abstract long[] GetIDsForClass(Transaction trans, ClassMetadata clazz); + + public abstract IQueryResult ClassOnlyQuery(QQueryBase queryBase, ClassMetadata clazz + ); + + public abstract IQueryResult ExecuteQuery(QQuery query); + + public virtual void ReplicationCallState(int state) + { + _replicationCallState = state; + } + + public virtual ReferenceSystemRegistry ReferenceSystemRegistry() + { + return _referenceSystemRegistry; + } + + public virtual ObjectContainerBase Container + { + get + { + return this; + } + } + + public virtual void DeleteByID(Transaction transaction, int id, int cascadeDeleteDepth + ) + { + if (id <= 0) + { + throw new ArgumentException("ID: " + id); + } + // return; + if (cascadeDeleteDepth <= 0) + { + return; + } + object obj = GetByID2(transaction, id); + if (obj == null) + { + return; + } + cascadeDeleteDepth--; + IReflectClass claxx = ReflectorForObject(obj); + if (claxx.IsCollection()) + { + cascadeDeleteDepth += 1; + } + ObjectReference @ref = transaction.ReferenceForId(id); + if (@ref == null) + { + return; + } + Delete2(transaction, @ref, obj, cascadeDeleteDepth, false); + } + + internal virtual IReflectClass ReflectorForObject(object obj) + { + return Reflector().ForObject(obj); + } + + public virtual object SyncExec(IClosure4 block) + { + lock (_lock) + { + CheckClosed(); + return block.Run(); + } + } + + public virtual void StoreAll(Transaction transaction, IEnumerator objects) + { + while (objects.MoveNext()) + { + Store(transaction, objects.Current); + } + } + + public virtual void StoreAll(Transaction transaction, IEnumerator objects, IUpdateDepth + depth) + { + while (objects.MoveNext()) + { + Store(transaction, objects.Current, depth); + } + } + + public virtual void WithTransaction(Transaction transaction, IRunnable runnable) + { + lock (_lock) + { + Transaction old = _transaction; + _transaction = transaction; + try + { + runnable.Run(); + } + finally + { + _transaction = old; + } + } + } + + public virtual IThreadPool4 ThreadPool() + { + return ((IThreadPool4)Environment().Provide(typeof(IThreadPool4))); + } + + public virtual object NewWeakReference(ObjectReference referent, object obj) + { + return _references.NewWeakReference(referent, obj); + } + + public sealed override string ToString() + { + if (_name != null) + { + return _name; + } + return DefaultToString(); + } + + protected abstract string DefaultToString(); + + public abstract bool IsDeleted(Transaction trans, int id); + + public abstract void BlockSize(int size); + + public virtual IBlockConverter BlockConverter() + { + return _blockConverter; + } + + protected virtual void CreateBlockConverter(int blockSize) + { + if (blockSize == 1) + { + _blockConverter = new DisabledBlockConverter(); + } + else + { + _blockConverter = new BlockSizeBlockConverter(blockSize); + } + } + + public virtual IUpdateDepthProvider UpdateDepthProvider() + { + return ConfigImpl.UpdateDepthProvider(); + } + + public virtual void ReplaceClassMetadataRepository(ClassMetadataRepository repository + ) + { + _classCollection = repository; + } + + public long GenerateTransactionTimestamp(long forcedTimestamp) + { + lock (Lock()) + { + return CheckTransaction().GenerateTransactionTimestamp(forcedTimestamp); + } + } + + public void UseDefaultTransactionTimestamp() + { + lock (Lock()) + { + CheckTransaction().UseDefaultTransactionTimestamp(); + } + } + + public abstract void Activate(object arg1, int arg2); + + public abstract void Commit(); + + public abstract void Deactivate(object arg1, int arg2); + + public abstract void Delete(object arg1); + + public abstract IExtObjectContainer Ext(); + + public abstract IQuery Query(); + + public abstract IObjectSet Query(Type arg1); + + public abstract IObjectSet Query(Predicate arg1); + + public abstract IObjectSet Query(Predicate arg1, IQueryComparator arg2); + + public abstract IObjectSet QueryByExample(object arg1); + + public abstract void Rollback(); + + public abstract void Store(object arg1); + + public abstract void Activate(object arg1); + + public abstract void Backup(IStorage arg1, string arg2); + + public abstract void Bind(object arg1, long arg2); + + public abstract void Deactivate(object arg1); + + public abstract object Descend(object arg1, string[] arg2); + + public abstract object GetByID(long arg1); + + public abstract object GetByUUID(Db4oUUID arg1); + + public abstract long GetID(object arg1); + + public abstract IObjectInfo GetObjectInfo(object arg1); + + public abstract Db4oDatabase Identity(); + + public abstract bool IsActive(object arg1); + + public abstract bool IsCached(long arg1); + + public abstract bool IsStored(object arg1); + + public abstract IObjectContainer OpenSession(); + + public abstract object PeekPersisted(object arg1, int arg2, bool arg3); + + public abstract void Purge(object arg1); + + public abstract void Refresh(object arg1, int arg2); + + public abstract void Store(object arg1, int arg2); + + public abstract IStoredClass StoredClass(object arg1); + + public abstract IStoredClass[] StoredClasses(); + + public abstract int InstanceCount(ClassMetadata arg1, Transaction arg2); + + public abstract EventRegistryImpl NewEventRegistry(); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/ObjectContainerFactory.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/ObjectContainerFactory.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/ObjectContainerFactory.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/ObjectContainerFactory.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,30 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o; +using Db4objects.Db4o.Config; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Config; + +namespace Db4objects.Db4o.Internal +{ + public class ObjectContainerFactory + { + /// + public static IEmbeddedObjectContainer OpenObjectContainer(IEmbeddedConfiguration + config, string databaseFileName) + { + IConfiguration legacyConfig = Db4oLegacyConfigurationBridge.AsLegacy(config); + Config4Impl.AssertIsNotTainted(legacyConfig); + EmitDebugInfo(); + IEmbeddedObjectContainer oc = new IoAdaptedObjectContainer(legacyConfig, databaseFileName + ); + ((EmbeddedConfigurationImpl)config).ApplyConfigurationItems(oc); + Db4objects.Db4o.Internal.Messages.LogMsg(legacyConfig, 5, databaseFileName); + return oc; + } + + private static void EmitDebugInfo() + { + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/ObjectContainerSession.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/ObjectContainerSession.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/ObjectContainerSession.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/ObjectContainerSession.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,605 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using System.Collections; +using Db4objects.Db4o; +using Db4objects.Db4o.Config; +using Db4objects.Db4o.Ext; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.IO; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Activation; +using Db4objects.Db4o.Internal.Callbacks; +using Db4objects.Db4o.Internal.Events; +using Db4objects.Db4o.Internal.Qlin; +using Db4objects.Db4o.Internal.Query; +using Db4objects.Db4o.Qlin; +using Db4objects.Db4o.Query; +using Db4objects.Db4o.Reflect; +using Db4objects.Db4o.Reflect.Generic; +using Db4objects.Db4o.Types; + +namespace Db4objects.Db4o.Internal +{ + /// + public partial class ObjectContainerSession : IInternalObjectContainer, ITransientClass + , IObjectContainerSpec + { + protected readonly ObjectContainerBase _server; + + protected readonly Db4objects.Db4o.Internal.Transaction _transaction; + + private bool _closed = false; + + public ObjectContainerSession(ObjectContainerBase server, Db4objects.Db4o.Internal.Transaction + trans) + { + _server = server; + _transaction = trans; + } + + public ObjectContainerSession(ObjectContainerBase server) : this(server, server.NewUserTransaction + ()) + { + _transaction.SetOutSideRepresentation(this); + } + + /// + /// + /// + /// + public virtual void Backup(string path) + { + throw new NotSupportedException(); + } + + /// + /// + /// + public virtual void Backup(IStorage storage, string path) + { + throw new NotSupportedException(); + } + + /// + /// + public virtual void Bind(object obj, long id) + { + _server.Bind(_transaction, obj, id); + } + + public virtual Config4Impl ConfigImpl + { + get + { + // internal interface method doesn't need to lock + return _server.ConfigImpl; + } + } + + public virtual IConfiguration Configure() + { + // FIXME: Consider throwing NotSupportedException here. + // throw new NotSupportedException(); + lock (Lock()) + { + CheckClosed(); + return _server.Configure(); + } + } + + public virtual object Descend(object obj, string[] path) + { + lock (Lock()) + { + CheckClosed(); + return _server.Descend(_transaction, obj, path); + } + } + + private void CheckClosed() + { + if (IsClosed()) + { + throw new DatabaseClosedException(); + } + } + + /// + /// + public virtual object GetByID(long id) + { + lock (Lock()) + { + CheckClosed(); + return _server.GetByID(_transaction, id); + } + } + + /// + /// + public virtual object GetByUUID(Db4oUUID uuid) + { + lock (Lock()) + { + CheckClosed(); + return _server.GetByUUID(_transaction, uuid); + } + } + + public virtual long GetID(object obj) + { + lock (Lock()) + { + CheckClosed(); + return _server.GetID(_transaction, obj); + } + } + + public virtual IObjectInfo GetObjectInfo(object obj) + { + lock (Lock()) + { + CheckClosed(); + return _server.GetObjectInfo(_transaction, obj); + } + } + + // TODO: Db4oDatabase is shared between embedded clients. + // This should work, since there is an automatic bind + // replacement. Replication test cases will tell. + public virtual Db4oDatabase Identity() + { + lock (Lock()) + { + CheckClosed(); + return _server.Identity(); + } + } + + public virtual bool IsActive(object obj) + { + lock (Lock()) + { + CheckClosed(); + return _server.IsActive(_transaction, obj); + } + } + + public virtual bool IsCached(long id) + { + lock (Lock()) + { + CheckClosed(); + return _server.IsCached(_transaction, id); + } + } + + public virtual bool IsClosed() + { + lock (Lock()) + { + return _closed == true; + } + } + + /// + public virtual bool IsStored(object obj) + { + lock (Lock()) + { + CheckClosed(); + return _server.IsStored(_transaction, obj); + } + } + + public virtual IReflectClass[] KnownClasses() + { + lock (Lock()) + { + CheckClosed(); + return _server.KnownClasses(); + } + } + + public virtual object Lock() + { + return _server.Lock(); + } + + public virtual object PeekPersisted(object @object, int depth, bool committed) + { + lock (Lock()) + { + CheckClosed(); + return _server.PeekPersisted(_transaction, @object, ActivationDepthProvider().ActivationDepth + (depth, ActivationMode.Peek), committed); + } + } + + public virtual void Purge() + { + lock (Lock()) + { + CheckClosed(); + _server.Purge(); + } + } + + public virtual void Purge(object obj) + { + lock (Lock()) + { + CheckClosed(); + _server.Purge(_transaction, obj); + } + } + + public virtual GenericReflector Reflector() + { + lock (Lock()) + { + CheckClosed(); + return _server.Reflector(); + } + } + + public virtual void Refresh(object obj, int depth) + { + lock (Lock()) + { + CheckClosed(); + _server.Refresh(_transaction, obj, depth); + } + } + + public virtual void ReleaseSemaphore(string name) + { + CheckClosed(); + _server.ReleaseSemaphore(_transaction, name); + } + + public virtual void Store(object obj, int depth) + { + lock (Lock()) + { + CheckClosed(); + _server.Store(_transaction, obj, (depth == Const4.Unspecified ? (IUpdateDepth)UpdateDepthProvider + ().Unspecified(NullModifiedObjectQuery.Instance) : (IUpdateDepth)UpdateDepthProvider + ().ForDepth(depth))); + } + } + + public virtual bool SetSemaphore(string name, int waitForAvailability) + { + CheckClosed(); + return _server.SetSemaphore(_transaction, name, waitForAvailability); + } + + public virtual IStoredClass StoredClass(object clazz) + { + lock (Lock()) + { + CheckClosed(); + return _server.StoredClass(_transaction, clazz); + } + } + + public virtual IStoredClass[] StoredClasses() + { + lock (Lock()) + { + CheckClosed(); + return _server.StoredClasses(_transaction); + } + } + + public virtual ISystemInfo SystemInfo() + { + lock (Lock()) + { + CheckClosed(); + return _server.SystemInfo(); + } + } + + public virtual long Version() + { + lock (Lock()) + { + CheckClosed(); + return _server.Version(); + } + } + + /// + /// + public virtual void Activate(object obj) + { + lock (Lock()) + { + CheckClosed(); + _server.Activate(_transaction, obj); + } + } + + /// + /// + public virtual void Activate(object obj, int depth) + { + lock (Lock()) + { + CheckClosed(); + _server.Activate(_transaction, obj, ActivationDepthProvider().ActivationDepth(depth + , ActivationMode.Activate)); + } + } + + private IActivationDepthProvider ActivationDepthProvider() + { + return _server.ActivationDepthProvider(); + } + + /// + public virtual bool Close() + { + lock (Lock()) + { + if (IsClosed()) + { + return false; + } + if (!_server.IsClosed()) + { + if (!_server.ConfigImpl.IsReadOnly()) + { + Commit(); + } + } + _server.Callbacks().CloseOnStarted(this); + _server.CloseTransaction(_transaction, false, false); + _closed = true; + return true; + } + } + + /// + /// + /// + /// + public virtual void Commit() + { + lock (Lock()) + { + CheckClosed(); + _server.Commit(_transaction); + } + } + + /// + public virtual void Deactivate(object obj, int depth) + { + lock (Lock()) + { + CheckClosed(); + _server.Deactivate(_transaction, obj, depth); + } + } + + /// + public virtual void Deactivate(object obj) + { + Deactivate(obj, 1); + } + + /// + /// + /// + public virtual void Delete(object obj) + { + lock (Lock()) + { + CheckClosed(); + _server.Delete(_transaction, obj); + } + } + + public virtual IExtObjectContainer Ext() + { + return (IExtObjectContainer)this; + } + + /// + /// + public virtual IObjectSet QueryByExample(object template) + { + lock (Lock()) + { + CheckClosed(); + return _server.QueryByExample(_transaction, template); + } + } + + /// + public virtual IQuery Query() + { + lock (Lock()) + { + CheckClosed(); + return _server.Query(_transaction); + } + } + + /// + /// + public virtual IObjectSet Query(Type clazz) + { + lock (Lock()) + { + CheckClosed(); + return _server.Query(_transaction, clazz); + } + } + + /// + /// + public virtual IObjectSet Query(Predicate predicate) + { + lock (Lock()) + { + CheckClosed(); + return _server.Query(_transaction, predicate); + } + } + + /// + /// + public virtual IObjectSet Query(Predicate predicate, IQueryComparator comparator) + { + lock (Lock()) + { + CheckClosed(); + return _server.Query(_transaction, predicate, comparator); + } + } + + /// + /// + /// + public virtual void Rollback() + { + lock (Lock()) + { + CheckClosed(); + _server.Rollback(_transaction); + } + } + + /// + /// + public virtual void Store(object obj) + { + lock (Lock()) + { + CheckClosed(); + _server.Store(_transaction, obj); + } + } + + public virtual ObjectContainerBase Container + { + get + { + return _server; + } + } + + public virtual Db4objects.Db4o.Internal.Transaction Transaction + { + get + { + return _transaction; + } + } + + public virtual void Callbacks(ICallbacks cb) + { + lock (Lock()) + { + CheckClosed(); + _server.Callbacks(cb); + } + } + + public virtual ICallbacks Callbacks() + { + lock (Lock()) + { + CheckClosed(); + return _server.Callbacks(); + } + } + + public NativeQueryHandler GetNativeQueryHandler() + { + lock (Lock()) + { + CheckClosed(); + return _server.GetNativeQueryHandler(); + } + } + + public virtual ClassMetadata ClassMetadataForReflectClass(IReflectClass reflectClass + ) + { + return _server.ClassMetadataForReflectClass(reflectClass); + } + + public virtual ClassMetadata ClassMetadataForName(string name) + { + return _server.ClassMetadataForName(name); + } + + public virtual ClassMetadata ClassMetadataForID(int id) + { + return _server.ClassMetadataForID(id); + } + + public virtual HandlerRegistry Handlers + { + get + { + return _server.Handlers; + } + } + + public virtual object SyncExec(IClosure4 block) + { + return _server.SyncExec(block); + } + + public virtual int InstanceCount(ClassMetadata clazz, Db4objects.Db4o.Internal.Transaction + trans) + { + return _server.InstanceCount(clazz, trans); + } + + public virtual bool IsClient + { + get + { + return true; + } + } + + public virtual void StoreAll(Db4objects.Db4o.Internal.Transaction transaction, IEnumerator + objects) + { + _server.StoreAll(transaction, objects); + } + + public virtual IUpdateDepthProvider UpdateDepthProvider() + { + return ConfigImpl.UpdateDepthProvider(); + } + + public virtual IObjectContainer OpenSession() + { + lock (Lock()) + { + return new Db4objects.Db4o.Internal.ObjectContainerSession(_server); + } + } + + public virtual EventRegistryImpl NewEventRegistry() + { + return new EventRegistryImpl(); + } + + public virtual IQLin From(Type clazz) + { + return new QLinRoot(Query(), clazz); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/ObjectID.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/ObjectID.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/ObjectID.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/ObjectID.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,80 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal.Marshall; + +namespace Db4objects.Db4o.Internal +{ + /// + public class ObjectID + { + public readonly int _id; + + private sealed class _ObjectID_15 : Db4objects.Db4o.Internal.ObjectID + { + public _ObjectID_15(int baseArg1) : base(baseArg1) + { + } + + public override string ToString() + { + return "ObjectID.IS_NULL"; + } + } + + public static readonly Db4objects.Db4o.Internal.ObjectID IsNull = new _ObjectID_15 + (-1); + + private sealed class _ObjectID_21 : Db4objects.Db4o.Internal.ObjectID + { + public _ObjectID_21(int baseArg1) : base(baseArg1) + { + } + + public override string ToString() + { + return "ObjectID.NOT_POSSIBLE"; + } + } + + public static readonly Db4objects.Db4o.Internal.ObjectID NotPossible = new _ObjectID_21 + (-2); + + private sealed class _ObjectID_27 : Db4objects.Db4o.Internal.ObjectID + { + public _ObjectID_27(int baseArg1) : base(baseArg1) + { + } + + public override string ToString() + { + return "ObjectID.IGNORE"; + } + } + + public static readonly Db4objects.Db4o.Internal.ObjectID Ignore = new _ObjectID_27 + (-3); + + public ObjectID(int id) + { + _id = id; + } + + public virtual bool IsValid() + { + return _id > 0; + } + + public static Db4objects.Db4o.Internal.ObjectID Read(IInternalReadContext context + ) + { + int id = context.ReadInt(); + return id == 0 ? Db4objects.Db4o.Internal.ObjectID.IsNull : new Db4objects.Db4o.Internal.ObjectID + (id); + } + + public override string ToString() + { + return "ObjectID(" + _id + ")"; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/ObjectInfoCollectionImpl.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/ObjectInfoCollectionImpl.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/ObjectInfoCollectionImpl.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/ObjectInfoCollectionImpl.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,27 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System.Collections; +using Db4objects.Db4o.Ext; +using Db4objects.Db4o.Foundation; + +namespace Db4objects.Db4o.Internal +{ + /// + public sealed class ObjectInfoCollectionImpl : IObjectInfoCollection + { + public static readonly IObjectInfoCollection Empty = new Db4objects.Db4o.Internal.ObjectInfoCollectionImpl + (Iterators.EmptyIterable); + + public IEnumerable _collection; + + public ObjectInfoCollectionImpl(IEnumerable collection) + { + _collection = collection; + } + + public IEnumerator GetEnumerator() + { + return _collection.GetEnumerator(); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/ObjectReference.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/ObjectReference.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/ObjectReference.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/ObjectReference.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,1103 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using Db4objects.Db4o; +using Db4objects.Db4o.Activation; +using Db4objects.Db4o.Ext; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Activation; +using Db4objects.Db4o.Internal.Marshall; +using Db4objects.Db4o.Internal.Slots; +using Db4objects.Db4o.Reflect; +using Db4objects.Db4o.Typehandlers; +using Sharpen; + +namespace Db4objects.Db4o.Internal +{ + /// A weak reference to an known object. + /// + /// A weak reference to an known object. + /// "Known" ~ has been stored and/or retrieved within a transaction. + /// References the corresponding ClassMetaData along with further metadata: + /// internal id, UUID/version information, ... + /// + /// + public class ObjectReference : Identifiable, IObjectInfo, IActivator + { + private Db4objects.Db4o.Internal.ClassMetadata _class; + + private object _object; + + private Db4objects.Db4o.Internal.VirtualAttributes _virtualAttributes; + + private Db4objects.Db4o.Internal.ObjectReference _idPreceding; + + private Db4objects.Db4o.Internal.ObjectReference _idSubsequent; + + private int _idSize; + + private Db4objects.Db4o.Internal.ObjectReference _hcPreceding; + + private Db4objects.Db4o.Internal.ObjectReference _hcSubsequent; + + private int _hcSize; + + public int _hcHashcode; + + private int _lastTopLevelCallId; + + public ObjectReference() + { + } + + public ObjectReference(int id) + { + // redundant hashCode + _id = id; + if (DTrace.enabled) + { + DTrace.ObjectReferenceCreated.Log(id); + } + } + + public ObjectReference(Db4objects.Db4o.Internal.ClassMetadata classMetadata, int + id) : this(id) + { + _class = classMetadata; + } + + public virtual void Activate(ActivationPurpose purpose) + { + ActivateOn(Container().Transaction, purpose); + } + + public virtual void ActivateOn(Db4objects.Db4o.Internal.Transaction transaction, + ActivationPurpose purpose) + { + if (Activating()) + { + return; + } + try + { + Activating(true); + ObjectContainerBase container = transaction.Container(); + if (!(container.ActivationDepthProvider() is ITransparentActivationDepthProvider)) + { + return; + } + ITransparentActivationDepthProvider provider = (ITransparentActivationDepthProvider + )container.ActivationDepthProvider(); + if (ActivationPurpose.Write == purpose) + { + lock (container.Lock()) + { + provider.AddModified(GetObject(), transaction); + } + } + if (IsActive()) + { + return; + } + lock (container.Lock()) + { + Activate(transaction, GetObject(), new DescendingActivationDepth(provider, ActivationMode + .Activate)); + } + } + finally + { + Activating(false); + } + } + + private bool Activating() + { + return BitIsTrue(Const4.Activating); + } + + private void Activating(bool isActivating) + { + if (isActivating) + { + BitTrue(Const4.Activating); + } + else + { + BitFalse(Const4.Activating); + } + } + + public virtual void Activate(Db4objects.Db4o.Internal.Transaction ta, object obj, + IActivationDepth depth) + { + ObjectContainerBase container = ta.Container(); + ActivateInternal(container.ActivationContextFor(ta, obj, depth)); + container.ActivatePending(ta); + } + + internal virtual void ActivateInternal(IActivationContext context) + { + if (null == context) + { + throw new ArgumentNullException(); + } + if (!context.Depth().RequiresActivation()) + { + return; + } + ObjectContainerBase container = context.Container(); + if (context.Depth().Mode().IsRefresh()) + { + LogActivation(container, "refresh"); + } + else + { + if (IsActive()) + { + _class.CascadeActivation(context); + return; + } + LogActivation(container, "activate"); + } + ReadForActivation(context); + } + + private void ReadForActivation(IActivationContext context) + { + Read(context.Transaction(), null, context.TargetObject(), context.Depth(), Const4 + .AddMembersToIdTreeOnly, false); + } + + private void LogActivation(ObjectContainerBase container, string @event) + { + LogEvent(container, @event, Const4.Activation); + } + + private void LogEvent(ObjectContainerBase container, string @event, int level) + { + if (container.ConfigImpl.MessageLevel() > level) + { + container.Message(string.Empty + GetID() + " " + @event + " " + _class.GetName()); + } + } + + /// return false if class not completely initialized, otherwise true + internal virtual bool ContinueSet(Db4objects.Db4o.Internal.Transaction trans, IUpdateDepth + updateDepth) + { + if (!BitIsTrue(Const4.Continue)) + { + return true; + } + if (!_class.StateOK()) + { + return false; + } + if (!_class.AspectsAreInitialized()) + { + return false; + } + if (DTrace.enabled) + { + DTrace.Continueset.Log(GetID()); + } + BitFalse(Const4.Continue); + MarshallingContext context = new MarshallingContext(trans, this, updateDepth, true + ); + Handlers4.Write(ClassMetadata().TypeHandler(), context, GetObject()); + Pointer4 pointer = context.AllocateSlot(); + ByteArrayBuffer buffer = context.ToWriteBuffer(pointer); + ObjectContainerBase container = trans.Container(); + container.WriteNew(trans, pointer, _class, buffer); + object obj = _object; + ObjectOnNew(trans, obj); + if (_class.HasIdentity()) + { + _object = container.NewWeakReference(this, obj); + } + SetStateClean(); + EndProcessing(); + return true; + } + + private void ObjectOnNew(Db4objects.Db4o.Internal.Transaction transaction, object + obj) + { + ObjectContainerBase container = transaction.Container(); + container.Callbacks().ObjectOnNew(transaction, this); + _class.DispatchEvent(transaction, obj, EventDispatchers.New); + } + + public virtual void Deactivate(Db4objects.Db4o.Internal.Transaction trans, IActivationDepth + depth) + { + if (!depth.RequiresActivation()) + { + return; + } + object obj = GetObject(); + if (obj == null) + { + return; + } + ObjectContainerBase container = trans.Container(); + LogActivation(container, "deactivate"); + SetStateDeactivated(); + _class.Deactivate(trans, this, depth); + } + + public virtual byte GetIdentifier() + { + return Const4.Yapobject; + } + + public virtual long GetInternalID() + { + return GetID(); + } + + public virtual object GetObject() + { + if (Platform4.HasWeakReferences()) + { + return Platform4.GetYapRefObject(_object); + } + return _object; + } + + public virtual object GetObjectReference() + { + return _object; + } + + public virtual ObjectContainerBase Container() + { + if (_class == null) + { + throw new InvalidOperationException(); + } + return _class.Container(); + } + + public virtual Db4objects.Db4o.Internal.Transaction Transaction() + { + return Container().Transaction; + } + + public virtual Db4oUUID GetUUID() + { + Db4objects.Db4o.Internal.VirtualAttributes va = VirtualAttributes(Transaction()); + if (va != null && va.i_database != null) + { + return new Db4oUUID(va.i_uuid, va.i_database.i_signature); + } + return null; + } + + public virtual long GetVersion() + { + return GetCommitTimestamp(); + } + + public virtual long GetCommitTimestamp() + { + lock (Container().Lock()) + { + return Container().SystemTransaction().VersionForId(GetID()); + } + } + + public Db4objects.Db4o.Internal.ClassMetadata ClassMetadata() + { + return _class; + } + + public virtual void ClassMetadata(Db4objects.Db4o.Internal.ClassMetadata classMetadata + ) + { + if (_class == classMetadata) + { + return; + } + if (_class != null) + { + throw new InvalidOperationException("Object types aren't supposed to change!"); + } + _class = classMetadata; + } + + public virtual int OwnLength() + { + throw Exceptions4.ShouldNeverBeCalled(); + } + + public virtual Db4objects.Db4o.Internal.VirtualAttributes ProduceVirtualAttributes + () + { + if (_virtualAttributes == null) + { + _virtualAttributes = new Db4objects.Db4o.Internal.VirtualAttributes(); + } + return _virtualAttributes; + } + + internal void PeekPersisted(Db4objects.Db4o.Internal.Transaction trans, IActivationDepth + depth) + { + SetObject(Read(trans, depth, Const4.Transient, false)); + } + + internal object Read(Db4objects.Db4o.Internal.Transaction trans, IActivationDepth + instantiationDepth, int addToIDTree, bool checkIDTree) + { + return Read(trans, null, null, instantiationDepth, addToIDTree, checkIDTree); + } + + public object Read(Db4objects.Db4o.Internal.Transaction trans, ByteArrayBuffer buffer + , object obj, IActivationDepth instantiationDepth, int addToIDTree, bool checkIDTree + ) + { + UnmarshallingContext context = new UnmarshallingContext(trans, buffer, this, addToIDTree + , checkIDTree); + context.PersistentObject(obj); + context.ActivationDepth(instantiationDepth); + return context.Read(); + } + + public virtual object ReadPrefetch(Db4objects.Db4o.Internal.Transaction trans, ByteArrayBuffer + buffer, int addToIDTree) + { + UnmarshallingContext context = new UnmarshallingContext(trans, buffer, this, addToIDTree + , false); + context.ActivationDepth(new FixedActivationDepth(1, ActivationMode.Prefetch)); + return context.Read(); + } + + public void ReadThis(Db4objects.Db4o.Internal.Transaction trans, ByteArrayBuffer + buffer) + { + } + + public virtual void SetObjectWeak(ObjectContainerBase container, object obj) + { + if (_object != null) + { + Platform4.KillYapRef(_object); + } + _object = container.NewWeakReference(this, obj); + } + + public virtual void SetObject(object obj) + { + _object = obj; + } + + internal void Store(Db4objects.Db4o.Internal.Transaction trans, Db4objects.Db4o.Internal.ClassMetadata + classMetadata, object obj) + { + _object = obj; + _class = classMetadata; + int id = trans.Container().IdForNewUserObject(trans); + SetID(id); + // will be ended in continueset() + BeginProcessing(); + BitTrue(Const4.Continue); + } + + public virtual void FlagForDelete(int callId) + { + _lastTopLevelCallId = -callId; + } + + public virtual bool IsFlaggedForDelete() + { + return _lastTopLevelCallId < 0; + } + + public virtual void FlagAsHandled(int callId) + { + _lastTopLevelCallId = callId; + } + + public bool IsFlaggedAsHandled(int callID) + { + return _lastTopLevelCallId == callID; + } + + public bool IsValid() + { + return IsValidId(GetID()) && GetObject() != null; + } + + public static bool IsValidId(int id) + { + return id > 0; + } + + public virtual Db4objects.Db4o.Internal.VirtualAttributes VirtualAttributes() + { + return _virtualAttributes; + } + + public virtual Db4objects.Db4o.Internal.VirtualAttributes VirtualAttributes(Db4objects.Db4o.Internal.Transaction + trans, bool lastCommitted) + { + if (trans == null) + { + return _virtualAttributes; + } + lock (trans.Container().Lock()) + { + if (_virtualAttributes == null) + { + if (_class.HasVirtualAttributes()) + { + _virtualAttributes = new Db4objects.Db4o.Internal.VirtualAttributes(); + _class.ReadVirtualAttributes(trans, this, lastCommitted); + } + } + else + { + if (!_virtualAttributes.SuppliesUUID()) + { + if (_class.HasVirtualAttributes()) + { + _class.ReadVirtualAttributes(trans, this, lastCommitted); + } + } + } + return _virtualAttributes; + } + } + + public virtual Db4objects.Db4o.Internal.VirtualAttributes VirtualAttributes(Db4objects.Db4o.Internal.Transaction + trans) + { + return VirtualAttributes(trans, false); + } + + public virtual void SetVirtualAttributes(Db4objects.Db4o.Internal.VirtualAttributes + at) + { + _virtualAttributes = at; + } + + public virtual void WriteThis(Db4objects.Db4o.Internal.Transaction trans, ByteArrayBuffer + buffer) + { + } + + public virtual void WriteUpdate(Db4objects.Db4o.Internal.Transaction transaction, + IUpdateDepth updatedepth) + { + ContinueSet(transaction, updatedepth); + // make sure, a concurrent new, possibly triggered by objectOnNew + // is written to the file + // preventing recursive + if (!BeginProcessing()) + { + return; + } + object obj = GetObject(); + if (!ObjectCanUpdate(transaction, obj) || !IsActive() || obj == null || !ClassMetadata + ().IsModified(obj)) + { + EndProcessing(); + return; + } + MarshallingContext context = new MarshallingContext(transaction, this, updatedepth + , false); + if (context.UpdateDepth().Negative()) + { + EndProcessing(); + return; + } + ObjectContainerBase container = transaction.Container(); + LogEvent(container, "update", Const4.State); + SetStateClean(); + context.PurgeFieldIndexEntriesOnUpdate(transaction, container._handlers.ArrayType + (obj)); + Handlers4.Write(_class.TypeHandler(), context, obj); + if (context.UpdateDepth().CanSkip(this)) + { + EndProcessing(); + return; + } + Pointer4 pointer = context.AllocateSlot(); + ByteArrayBuffer buffer = context.ToWriteBuffer(pointer); + container.WriteUpdate(transaction, pointer, _class, container._handlers.ArrayType + (obj), buffer); + if (IsActive()) + { + SetStateClean(); + } + EndProcessing(); + container.Callbacks().ObjectOnUpdate(transaction, this); + ClassMetadata().DispatchEvent(transaction, obj, EventDispatchers.Update); + } + + protected virtual bool ObjectCanUpdate(Db4objects.Db4o.Internal.Transaction transaction + , object obj) + { + ObjectContainerBase container = transaction.Container(); + return container.Callbacks().ObjectCanUpdate(transaction, this) && _class.DispatchEvent + (transaction, obj, EventDispatchers.CanUpdate); + } + + public virtual void Ref_init() + { + Hc_init(); + Id_init(); + } + + /// HCTREE + public virtual Db4objects.Db4o.Internal.ObjectReference Hc_add(Db4objects.Db4o.Internal.ObjectReference + newRef) + { + if (newRef.GetObject() == null) + { + return this; + } + newRef.Hc_init(); + return Hc_add1(newRef); + } + + private void Hc_init() + { + _hcPreceding = null; + _hcSubsequent = null; + _hcSize = 1; + _hcHashcode = Hc_getCode(GetObject()); + } + + private Db4objects.Db4o.Internal.ObjectReference Hc_add1(Db4objects.Db4o.Internal.ObjectReference + newRef) + { + int cmp = Hc_compare(newRef); + if (cmp < 0) + { + if (_hcPreceding == null) + { + _hcPreceding = newRef; + _hcSize++; + } + else + { + _hcPreceding = _hcPreceding.Hc_add1(newRef); + if (_hcSubsequent == null) + { + return Hc_rotateRight(); + } + return Hc_balance(); + } + } + else + { + if (_hcSubsequent == null) + { + _hcSubsequent = newRef; + _hcSize++; + } + else + { + _hcSubsequent = _hcSubsequent.Hc_add1(newRef); + if (_hcPreceding == null) + { + return Hc_rotateLeft(); + } + return Hc_balance(); + } + } + return this; + } + + private Db4objects.Db4o.Internal.ObjectReference Hc_balance() + { + int cmp = _hcSubsequent._hcSize - _hcPreceding._hcSize; + if (cmp < -2) + { + return Hc_rotateRight(); + } + else + { + if (cmp > 2) + { + return Hc_rotateLeft(); + } + else + { + _hcSize = _hcPreceding._hcSize + _hcSubsequent._hcSize + 1; + return this; + } + } + } + + private void Hc_calculateSize() + { + if (_hcPreceding == null) + { + if (_hcSubsequent == null) + { + _hcSize = 1; + } + else + { + _hcSize = _hcSubsequent._hcSize + 1; + } + } + else + { + if (_hcSubsequent == null) + { + _hcSize = _hcPreceding._hcSize + 1; + } + else + { + _hcSize = _hcPreceding._hcSize + _hcSubsequent._hcSize + 1; + } + } + } + + private int Hc_compare(Db4objects.Db4o.Internal.ObjectReference toRef) + { + int cmp = toRef._hcHashcode - _hcHashcode; + if (cmp == 0) + { + cmp = toRef._id - _id; + } + return cmp; + } + + public virtual Db4objects.Db4o.Internal.ObjectReference Hc_find(object obj) + { + return Hc_find(Hc_getCode(obj), obj); + } + + private Db4objects.Db4o.Internal.ObjectReference Hc_find(int id, object obj) + { + int cmp = id - _hcHashcode; + if (cmp < 0) + { + if (_hcPreceding != null) + { + return _hcPreceding.Hc_find(id, obj); + } + } + else + { + if (cmp > 0) + { + if (_hcSubsequent != null) + { + return _hcSubsequent.Hc_find(id, obj); + } + } + else + { + if (obj == GetObject()) + { + return this; + } + if (_hcPreceding != null) + { + Db4objects.Db4o.Internal.ObjectReference inPreceding = _hcPreceding.Hc_find(id, obj + ); + if (inPreceding != null) + { + return inPreceding; + } + } + if (_hcSubsequent != null) + { + return _hcSubsequent.Hc_find(id, obj); + } + } + } + return null; + } + + public static int Hc_getCode(object obj) + { + int hcode = Runtime.IdentityHashCode(obj); + if (hcode < 0) + { + hcode = ~hcode; + } + return hcode; + } + + private Db4objects.Db4o.Internal.ObjectReference Hc_rotateLeft() + { + Db4objects.Db4o.Internal.ObjectReference tree = _hcSubsequent; + _hcSubsequent = tree._hcPreceding; + Hc_calculateSize(); + tree._hcPreceding = this; + if (tree._hcSubsequent == null) + { + tree._hcSize = 1 + _hcSize; + } + else + { + tree._hcSize = 1 + _hcSize + tree._hcSubsequent._hcSize; + } + return tree; + } + + private Db4objects.Db4o.Internal.ObjectReference Hc_rotateRight() + { + Db4objects.Db4o.Internal.ObjectReference tree = _hcPreceding; + _hcPreceding = tree._hcSubsequent; + Hc_calculateSize(); + tree._hcSubsequent = this; + if (tree._hcPreceding == null) + { + tree._hcSize = 1 + _hcSize; + } + else + { + tree._hcSize = 1 + _hcSize + tree._hcPreceding._hcSize; + } + return tree; + } + + private Db4objects.Db4o.Internal.ObjectReference Hc_rotateSmallestUp() + { + if (_hcPreceding != null) + { + _hcPreceding = _hcPreceding.Hc_rotateSmallestUp(); + return Hc_rotateRight(); + } + return this; + } + + public virtual Db4objects.Db4o.Internal.ObjectReference Hc_remove(Db4objects.Db4o.Internal.ObjectReference + findRef) + { + if (this == findRef) + { + return Hc_remove(); + } + int cmp = Hc_compare(findRef); + if (cmp <= 0) + { + if (_hcPreceding != null) + { + _hcPreceding = _hcPreceding.Hc_remove(findRef); + } + } + if (cmp >= 0) + { + if (_hcSubsequent != null) + { + _hcSubsequent = _hcSubsequent.Hc_remove(findRef); + } + } + Hc_calculateSize(); + return this; + } + + public virtual void Hc_traverse(IVisitor4 visitor) + { + if (_hcPreceding != null) + { + _hcPreceding.Hc_traverse(visitor); + } + if (_hcSubsequent != null) + { + _hcSubsequent.Hc_traverse(visitor); + } + // Traversing the leaves first allows to add ObjectReference + // nodes to different ReferenceSystem trees during commit + visitor.Visit(this); + } + + private Db4objects.Db4o.Internal.ObjectReference Hc_remove() + { + if (_hcSubsequent != null && _hcPreceding != null) + { + _hcSubsequent = _hcSubsequent.Hc_rotateSmallestUp(); + _hcSubsequent._hcPreceding = _hcPreceding; + _hcSubsequent.Hc_calculateSize(); + return _hcSubsequent; + } + if (_hcSubsequent != null) + { + return _hcSubsequent; + } + return _hcPreceding; + } + + /// IDTREE + public virtual Db4objects.Db4o.Internal.ObjectReference Id_add(Db4objects.Db4o.Internal.ObjectReference + newRef) + { + newRef.Id_init(); + return Id_add1(newRef); + } + + private void Id_init() + { + _idPreceding = null; + _idSubsequent = null; + _idSize = 1; + } + + private Db4objects.Db4o.Internal.ObjectReference Id_add1(Db4objects.Db4o.Internal.ObjectReference + newRef) + { + int cmp = newRef._id - _id; + if (cmp < 0) + { + if (_idPreceding == null) + { + _idPreceding = newRef; + _idSize++; + } + else + { + _idPreceding = _idPreceding.Id_add1(newRef); + if (_idSubsequent == null) + { + return Id_rotateRight(); + } + return Id_balance(); + } + } + else + { + if (cmp > 0) + { + if (_idSubsequent == null) + { + _idSubsequent = newRef; + _idSize++; + } + else + { + _idSubsequent = _idSubsequent.Id_add1(newRef); + if (_idPreceding == null) + { + return Id_rotateLeft(); + } + return Id_balance(); + } + } + } + return this; + } + + private Db4objects.Db4o.Internal.ObjectReference Id_balance() + { + int cmp = _idSubsequent._idSize - _idPreceding._idSize; + if (cmp < -2) + { + return Id_rotateRight(); + } + else + { + if (cmp > 2) + { + return Id_rotateLeft(); + } + else + { + _idSize = _idPreceding._idSize + _idSubsequent._idSize + 1; + return this; + } + } + } + + private void Id_calculateSize() + { + if (_idPreceding == null) + { + if (_idSubsequent == null) + { + _idSize = 1; + } + else + { + _idSize = _idSubsequent._idSize + 1; + } + } + else + { + if (_idSubsequent == null) + { + _idSize = _idPreceding._idSize + 1; + } + else + { + _idSize = _idPreceding._idSize + _idSubsequent._idSize + 1; + } + } + } + + public virtual Db4objects.Db4o.Internal.ObjectReference Id_find(int id) + { + int cmp = id - _id; + if (cmp > 0) + { + if (_idSubsequent != null) + { + return _idSubsequent.Id_find(id); + } + } + else + { + if (cmp < 0) + { + if (_idPreceding != null) + { + return _idPreceding.Id_find(id); + } + } + else + { + return this; + } + } + return null; + } + + private Db4objects.Db4o.Internal.ObjectReference Id_rotateLeft() + { + Db4objects.Db4o.Internal.ObjectReference tree = _idSubsequent; + _idSubsequent = tree._idPreceding; + Id_calculateSize(); + tree._idPreceding = this; + if (tree._idSubsequent == null) + { + tree._idSize = _idSize + 1; + } + else + { + tree._idSize = _idSize + 1 + tree._idSubsequent._idSize; + } + return tree; + } + + private Db4objects.Db4o.Internal.ObjectReference Id_rotateRight() + { + Db4objects.Db4o.Internal.ObjectReference tree = _idPreceding; + _idPreceding = tree._idSubsequent; + Id_calculateSize(); + tree._idSubsequent = this; + if (tree._idPreceding == null) + { + tree._idSize = _idSize + 1; + } + else + { + tree._idSize = _idSize + 1 + tree._idPreceding._idSize; + } + return tree; + } + + private Db4objects.Db4o.Internal.ObjectReference Id_rotateSmallestUp() + { + if (_idPreceding != null) + { + _idPreceding = _idPreceding.Id_rotateSmallestUp(); + return Id_rotateRight(); + } + return this; + } + + public virtual Db4objects.Db4o.Internal.ObjectReference Id_remove(Db4objects.Db4o.Internal.ObjectReference + @ref) + { + int cmp = @ref._id - _id; + if (cmp < 0) + { + if (_idPreceding != null) + { + _idPreceding = _idPreceding.Id_remove(@ref); + } + } + else + { + if (cmp > 0) + { + if (_idSubsequent != null) + { + _idSubsequent = _idSubsequent.Id_remove(@ref); + } + } + else + { + if (this == @ref) + { + return Id_remove(); + } + return this; + } + } + Id_calculateSize(); + return this; + } + + private Db4objects.Db4o.Internal.ObjectReference Id_remove() + { + if (_idSubsequent != null && _idPreceding != null) + { + _idSubsequent = _idSubsequent.Id_rotateSmallestUp(); + _idSubsequent._idPreceding = _idPreceding; + _idSubsequent.Id_calculateSize(); + return _idSubsequent; + } + if (_idSubsequent != null) + { + return _idSubsequent; + } + return _idPreceding; + } + + public override string ToString() + { + try + { + int id = GetID(); + string str = "ObjectReference\nID=" + id; + object obj = GetObject(); + if (obj == null && _class != null) + { + ObjectContainerBase container = _class.Container(); + if (container != null && id > 0) + { + obj = container.PeekPersisted(container.Transaction, id, container.DefaultActivationDepth + (ClassMetadata()), true).ToString(); + } + } + if (obj == null) + { + str += "\nfor [null]"; + } + else + { + string objToString = string.Empty; + try + { + objToString = obj.ToString(); + } + catch (Exception) + { + } + if (ClassMetadata() != null) + { + IReflectClass claxx = ClassMetadata().Reflector().ForObject(obj); + str += "\n" + claxx.GetName(); + } + str += "\n" + objToString; + } + return str; + } + catch (Exception) + { + } + return "ObjectReference " + GetID(); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/ObjectTypeMetadata.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/ObjectTypeMetadata.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/ObjectTypeMetadata.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/ObjectTypeMetadata.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,25 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Marshall; +using Db4objects.Db4o.Reflect; +using Db4objects.Db4o.Typehandlers; + +namespace Db4objects.Db4o.Internal +{ + public class ObjectTypeMetadata : PrimitiveTypeMetadata + { + public ObjectTypeMetadata(ObjectContainerBase container, ITypeHandler4 handler, int + id, IReflectClass classReflector) : base(container, handler, id, classReflector + ) + { + } + + public override object Instantiate(UnmarshallingContext context) + { + object @object = new object(); + OnInstantiate(context, @object); + return @object; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/OpenTypeHandler.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/OpenTypeHandler.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/OpenTypeHandler.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/OpenTypeHandler.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,393 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Delete; +using Db4objects.Db4o.Internal.Handlers; +using Db4objects.Db4o.Internal.Handlers.Versions; +using Db4objects.Db4o.Internal.Marshall; +using Db4objects.Db4o.Marshall; +using Db4objects.Db4o.Reflect; +using Db4objects.Db4o.Typehandlers; + +namespace Db4objects.Db4o.Internal +{ + public class OpenTypeHandler : IReferenceTypeHandler, IValueTypeHandler, IBuiltinTypeHandler + , ICascadingTypeHandler, ILinkLengthAware + { + private const int Hashcode = 1003303143; + + private ObjectContainerBase _container; + + public OpenTypeHandler(ObjectContainerBase container) + { + _container = container; + } + + internal virtual ObjectContainerBase Container() + { + return _container; + } + + public virtual IReflectClass ClassReflector() + { + return Container().Handlers.IclassObject; + } + + public virtual void CascadeActivation(IActivationContext context) + { + object targetObject = context.TargetObject(); + if (IsPlainObject(targetObject)) + { + return; + } + ITypeHandler4 typeHandler = TypeHandlerForObject(targetObject); + Handlers4.CascadeActivation(context, typeHandler); + } + + /// + public virtual void Delete(IDeleteContext context) + { + int payLoadOffset = context.ReadInt(); + if (context.IsLegacyHandlerVersion()) + { + context.DefragmentRecommended(); + return; + } + if (payLoadOffset <= 0) + { + return; + } + int linkOffset = context.Offset(); + context.Seek(payLoadOffset); + int classMetadataID = context.ReadInt(); + ITypeHandler4 typeHandler = Container().ClassMetadataForID(classMetadataID).TypeHandler + (); + if (typeHandler != null) + { + context.Delete(typeHandler); + } + context.Seek(linkOffset); + } + + public virtual int GetID() + { + return Handlers4.UntypedId; + } + + public virtual bool HasField(ObjectContainerBase a_stream, string a_path) + { + return a_stream.ClassCollection().FieldExists(a_path); + } + + public virtual ITypeHandler4 ReadCandidateHandler(QueryingReadContext context) + { + int payLoadOffSet = context.ReadInt(); + if (payLoadOffSet == 0) + { + return null; + } + context.Seek(payLoadOffSet); + int classMetadataID = context.ReadInt(); + ClassMetadata classMetadata = context.Container().ClassMetadataForID(classMetadataID + ); + if (classMetadata == null) + { + return null; + } + return classMetadata.ReadCandidateHandler(context); + } + + public virtual ObjectID ReadObjectID(IInternalReadContext context) + { + int payloadOffset = context.ReadInt(); + if (payloadOffset == 0) + { + return ObjectID.IsNull; + } + int savedOffset = context.Offset(); + ITypeHandler4 typeHandler = ReadTypeHandler(context, payloadOffset); + if (typeHandler == null) + { + context.Seek(savedOffset); + return ObjectID.IsNull; + } + SeekSecondaryOffset(context, typeHandler); + if (typeHandler is IReadsObjectIds) + { + ObjectID readObjectID = ((IReadsObjectIds)typeHandler).ReadObjectID(context); + context.Seek(savedOffset); + return readObjectID; + } + context.Seek(savedOffset); + return ObjectID.NotPossible; + } + + public virtual void Defragment(IDefragmentContext context) + { + int payLoadOffSet = context.ReadInt(); + if (payLoadOffSet == 0) + { + return; + } + int savedOffSet = context.Offset(); + context.Seek(payLoadOffSet); + try + { + int classMetadataId = context.CopyIDReturnOriginalID(); + ITypeHandler4 typeHandler = CorrectTypeHandlerVersionFor(context, classMetadataId + ); + if (typeHandler == null) + { + return; + } + SeekSecondaryOffset(context, typeHandler); + if (IsPlainObject(typeHandler)) + { + context.Defragment(new PlainObjectHandler()); + } + else + { + context.Defragment(typeHandler); + } + } + finally + { + context.Seek(savedOffSet); + } + } + + protected virtual ITypeHandler4 CorrectTypeHandlerVersionFor(IDefragmentContext context + , int classMetadataId) + { + ITypeHandler4 typeHandler = context.TypeHandlerForId(classMetadataId); + if (null == typeHandler) + { + return null; + } + ClassMetadata classMetadata = Container(context).ClassMetadataForID(classMetadataId + ); + return HandlerRegistry.CorrectHandlerVersion(context, typeHandler, classMetadata); + } + + protected virtual ObjectContainerBase Container(IDefragmentContext context) + { + return context.Transaction().Container(); + } + + protected virtual ITypeHandler4 ReadTypeHandler(IInternalReadContext context, int + payloadOffset) + { + context.Seek(payloadOffset); + ITypeHandler4 typeHandler = Container().TypeHandlerForClassMetadataID(context.ReadInt + ()); + return HandlerRegistry.CorrectHandlerVersion(context, typeHandler); + } + + /// + /// + protected virtual void SeekSecondaryOffset(IReadBuffer buffer, ITypeHandler4 typeHandler + ) + { + } + + // do nothing, no longer needed in current implementation. + public virtual object Read(IReadContext readContext) + { + IInternalReadContext context = (IInternalReadContext)readContext; + int payloadOffset = context.ReadInt(); + if (payloadOffset == 0) + { + context.NotifyNullReferenceSkipped(); + return null; + } + int savedOffSet = context.Offset(); + try + { + ITypeHandler4 typeHandler = ReadTypeHandler(context, payloadOffset); + if (typeHandler == null) + { + return null; + } + SeekSecondaryOffset(context, typeHandler); + if (IsPlainObject(typeHandler)) + { + return context.ReadAtCurrentSeekPosition(new PlainObjectHandler()); + } + return context.ReadAtCurrentSeekPosition(typeHandler); + } + finally + { + context.Seek(savedOffSet); + } + } + + public virtual void Activate(IReferenceActivationContext context) + { + } + + // throw new IllegalStateException(); + public virtual void CollectIDs(QueryingReadContext readContext) + { + IInternalReadContext context = (IInternalReadContext)readContext; + int payloadOffset = context.ReadInt(); + if (payloadOffset == 0) + { + return; + } + int savedOffSet = context.Offset(); + try + { + ITypeHandler4 typeHandler = ReadTypeHandler(context, payloadOffset); + if (typeHandler == null) + { + return; + } + SeekSecondaryOffset(context, typeHandler); + if (IsPlainObject(typeHandler)) + { + readContext.Collector().AddId(readContext.ReadInt()); + return; + } + CollectIdContext collectIdContext = new _CollectIdContext_201(readContext, readContext + .Transaction(), readContext.Collector(), null, readContext.Buffer()); + Handlers4.CollectIdsInternal(collectIdContext, context.Container().Handlers.CorrectHandlerVersion + (typeHandler, context.HandlerVersion()), 0, false); + } + finally + { + context.Seek(savedOffSet); + } + } + + private sealed class _CollectIdContext_201 : CollectIdContext + { + public _CollectIdContext_201(QueryingReadContext readContext, Transaction baseArg1 + , IdObjectCollector baseArg2, ObjectHeader baseArg3, IReadBuffer baseArg4) : base + (baseArg1, baseArg2, baseArg3, baseArg4) + { + this.readContext = readContext; + } + + public override int HandlerVersion() + { + return readContext.HandlerVersion(); + } + + public override SlotFormat SlotFormat() + { + return new _SlotFormatCurrent_207(); + } + + private sealed class _SlotFormatCurrent_207 : SlotFormatCurrent + { + public _SlotFormatCurrent_207() + { + } + + public override bool IsIndirectedWithinSlot(ITypeHandler4 handler) + { + return false; + } + } + + private readonly QueryingReadContext readContext; + } + + public virtual ITypeHandler4 ReadTypeHandlerRestoreOffset(IInternalReadContext context + ) + { + int savedOffset = context.Offset(); + int payloadOffset = context.ReadInt(); + ITypeHandler4 typeHandler = payloadOffset == 0 ? null : ReadTypeHandler(context, + payloadOffset); + context.Seek(savedOffset); + return typeHandler; + } + + public virtual void Write(IWriteContext context, object obj) + { + if (obj == null) + { + context.WriteInt(0); + return; + } + MarshallingContext marshallingContext = (MarshallingContext)context; + ClassMetadata classMetadata = ClassMetadataFor(obj); + if (classMetadata == null) + { + context.WriteInt(0); + return; + } + MarshallingContextState state = marshallingContext.CurrentState(); + marshallingContext.CreateChildBuffer(false); + context.WriteInt(classMetadata.GetID()); + WriteObject(context, classMetadata.TypeHandler(), obj); + marshallingContext.RestoreState(state); + } + + private ClassMetadata ClassMetadataFor(object obj) + { + return Container().ClassMetadataForObject(obj); + } + + private void WriteObject(IWriteContext context, ITypeHandler4 typeHandler, object + obj) + { + if (IsPlainObject(obj)) + { + context.WriteObject(new PlainObjectHandler(), obj); + return; + } + if (Handlers4.UseDedicatedSlot(context, typeHandler)) + { + context.WriteObject(obj); + } + else + { + typeHandler.Write(context, obj); + } + } + + private bool IsPlainObject(object obj) + { + if (obj == null) + { + return false; + } + return obj.GetType() == Const4.ClassObject; + } + + public static bool IsPlainObject(ITypeHandler4 typeHandler) + { + return typeHandler.GetType() == typeof(Db4objects.Db4o.Internal.OpenTypeHandler) + || typeHandler.GetType() == typeof(OpenTypeHandler0) || typeHandler.GetType() == + typeof(OpenTypeHandler2) || typeHandler.GetType() == typeof(OpenTypeHandler7); + } + + public virtual ITypeHandler4 TypeHandlerForObject(object obj) + { + return ClassMetadataFor(obj).TypeHandler(); + } + + public override bool Equals(object obj) + { + return obj is Db4objects.Db4o.Internal.OpenTypeHandler && !(obj is InterfaceTypeHandler + ); + } + + public override int GetHashCode() + { + return Hashcode; + } + + public virtual void RegisterReflector(IReflector reflector) + { + } + + // nothing to do + public virtual int LinkLength() + { + return Const4.IdLength; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/PendingClassInits.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/PendingClassInits.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/PendingClassInits.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/PendingClassInits.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,104 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal; + +namespace Db4objects.Db4o.Internal +{ + internal class PendingClassInits + { + private readonly Transaction _systemTransaction; + + private Collection4 _pending = new Collection4(); + + private IQueue4 _members = new NonblockingQueue(); + + private IQueue4 _statics = new NonblockingQueue(); + + private IQueue4 _writes = new NonblockingQueue(); + + private IQueue4 _inits = new NonblockingQueue(); + + private bool _running = false; + + internal PendingClassInits(Transaction systemTransaction) + { + _systemTransaction = systemTransaction; + } + + internal virtual void Process(ClassMetadata newClassMetadata) + { + if (_pending.Contains(newClassMetadata)) + { + return; + } + ClassMetadata ancestor = newClassMetadata.GetAncestor(); + if (ancestor != null) + { + Process(ancestor); + } + _pending.Add(newClassMetadata); + _members.Add(newClassMetadata); + if (_running) + { + return; + } + _running = true; + try + { + CheckInits(); + _pending = new Collection4(); + } + finally + { + _running = false; + } + } + + private void InitializeAspects() + { + while (_members.HasNext()) + { + ClassMetadata classMetadata = ((ClassMetadata)_members.Next()); + classMetadata.InitializeAspects(); + _statics.Add(classMetadata); + } + } + + private void CheckStatics() + { + InitializeAspects(); + while (_statics.HasNext()) + { + ClassMetadata classMetadata = ((ClassMetadata)_statics.Next()); + classMetadata.StoreStaticFieldValues(_systemTransaction, true); + _writes.Add(classMetadata); + InitializeAspects(); + } + } + + private void CheckWrites() + { + CheckStatics(); + while (_writes.HasNext()) + { + ClassMetadata classMetadata = ((ClassMetadata)_writes.Next()); + classMetadata.SetStateDirty(); + classMetadata.Write(_systemTransaction); + _inits.Add(classMetadata); + CheckStatics(); + } + } + + private void CheckInits() + { + CheckWrites(); + while (_inits.HasNext()) + { + ClassMetadata classMetadata = ((ClassMetadata)_inits.Next()); + classMetadata.InitConfigOnUp(_systemTransaction); + CheckWrites(); + } + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/PersistentBase.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/PersistentBase.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/PersistentBase.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/PersistentBase.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,181 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Ids; +using Db4objects.Db4o.Internal.Slots; + +namespace Db4objects.Db4o.Internal +{ + /// + public abstract class PersistentBase : Identifiable, IPersistent, ILinkLengthAware + { + internal virtual void CacheDirty(Collection4 col) + { + if (!BitIsTrue(Const4.CachedDirty)) + { + BitTrue(Const4.CachedDirty); + col.Add(this); + } + } + + public virtual void Free(LocalTransaction trans) + { + IdSystem(trans.SystemTransaction()).NotifySlotDeleted(GetID(), SlotChangeFactory( + )); + } + + public int LinkLength() + { + return Const4.IdLength; + } + + internal void NotCachedDirty() + { + BitFalse(Const4.CachedDirty); + } + + public virtual void Read(Transaction trans) + { + if (!BeginProcessing()) + { + return; + } + try + { + Read(trans, ProduceReadBuffer(trans)); + } + finally + { + EndProcessing(); + } + } + + protected virtual void Read(Transaction trans, ByteArrayBuffer reader) + { + ReadThis(trans, reader); + SetStateOnRead(reader); + } + + protected ByteArrayBuffer ProduceReadBuffer(Transaction trans) + { + return ReadBufferById(trans); + } + + protected virtual ByteArrayBuffer ReadBufferById(Transaction trans) + { + return trans.Container().ReadBufferById(trans, GetID()); + } + + internal virtual void SetStateOnRead(ByteArrayBuffer reader) + { + if (BitIsTrue(Const4.CachedDirty)) + { + SetStateDirty(); + } + else + { + SetStateClean(); + } + } + + public virtual void Write(Transaction trans) + { + if (!WriteObjectBegin()) + { + return; + } + try + { + LocalObjectContainer container = (LocalObjectContainer)trans.Container(); + if (DTrace.enabled) + { + DTrace.PersistentOwnLength.Log(GetID()); + } + int length = OwnLength(); + length = container.BlockConverter().BlockAlignedBytes(length); + Slot slot = container.AllocateSlot(length); + if (IsNew()) + { + SetID(IdSystem(trans).NewId(SlotChangeFactory())); + IdSystem(trans).NotifySlotCreated(_id, slot, SlotChangeFactory()); + } + else + { + IdSystem(trans).NotifySlotUpdated(_id, slot, SlotChangeFactory()); + } + if (DTrace.enabled) + { + DTrace.PersistentBaseNewSlot.LogLength(GetID(), slot); + } + ByteArrayBuffer writer = ProduceWriteBuffer(trans, length); + WriteToFile(trans, writer, slot); + } + finally + { + EndProcessing(); + } + } + + public virtual ITransactionalIdSystem IdSystem(Transaction trans) + { + return trans.IdSystem(); + } + + protected virtual ByteArrayBuffer ProduceWriteBuffer(Transaction trans, int length + ) + { + return NewWriteBuffer(length); + } + + protected virtual ByteArrayBuffer NewWriteBuffer(int length) + { + return new ByteArrayBuffer(length); + } + + private void WriteToFile(Transaction trans, ByteArrayBuffer writer, Slot slot) + { + if (DTrace.enabled) + { + DTrace.PersistentbaseWrite.Log(GetID()); + } + LocalObjectContainer container = (LocalObjectContainer)trans.Container(); + WriteThis(trans, writer); + container.WriteEncrypt(writer, slot.Address(), 0); + if (IsActive()) + { + SetStateClean(); + } + } + + public virtual bool WriteObjectBegin() + { + if (IsDirty()) + { + return BeginProcessing(); + } + return false; + } + + public virtual void WriteOwnID(Transaction trans, ByteArrayBuffer writer) + { + Write(trans); + writer.WriteInt(GetID()); + } + + public virtual Db4objects.Db4o.Internal.Slots.SlotChangeFactory SlotChangeFactory + () + { + return Db4objects.Db4o.Internal.Slots.SlotChangeFactory.SystemObjects; + } + + public abstract byte GetIdentifier(); + + public abstract int OwnLength(); + + public abstract void ReadThis(Transaction arg1, ByteArrayBuffer arg2); + + public abstract void WriteThis(Transaction arg1, ByteArrayBuffer arg2); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/PersistentIntegerArray.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/PersistentIntegerArray.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/PersistentIntegerArray.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/PersistentIntegerArray.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,76 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Ids; +using Sharpen; + +namespace Db4objects.Db4o.Internal +{ + /// + public class PersistentIntegerArray : LocalPersistentBase + { + private readonly Db4objects.Db4o.Internal.Slots.SlotChangeFactory _slotChangeFactory; + + private int[] _ints; + + public PersistentIntegerArray(Db4objects.Db4o.Internal.Slots.SlotChangeFactory slotChangeFactory + , ITransactionalIdSystem idSystem, int[] arr) : base(idSystem) + { + _slotChangeFactory = slotChangeFactory; + _ints = new int[arr.Length]; + System.Array.Copy(arr, 0, _ints, 0, arr.Length); + } + + public PersistentIntegerArray(Db4objects.Db4o.Internal.Slots.SlotChangeFactory slotChangeFactory + , ITransactionalIdSystem idSystem, int id) : base(idSystem) + { + _slotChangeFactory = slotChangeFactory; + SetID(id); + } + + public override byte GetIdentifier() + { + return Const4.IntegerArray; + } + + public override int OwnLength() + { + return (Const4.IntLength * (Size() + 1)) + Const4.AddedLength; + } + + public override void ReadThis(Transaction trans, ByteArrayBuffer reader) + { + int length = reader.ReadInt(); + _ints = new int[length]; + for (int i = 0; i < length; i++) + { + _ints[i] = reader.ReadInt(); + } + } + + public override void WriteThis(Transaction trans, ByteArrayBuffer writer) + { + writer.WriteInt(Size()); + for (int i = 0; i < _ints.Length; i++) + { + writer.WriteInt(_ints[i]); + } + } + + private int Size() + { + return _ints.Length; + } + + public virtual int[] Array() + { + return _ints; + } + + public override Db4objects.Db4o.Internal.Slots.SlotChangeFactory SlotChangeFactory + () + { + return _slotChangeFactory; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/PreparedArrayContainsComparison.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/PreparedArrayContainsComparison.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/PreparedArrayContainsComparison.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/PreparedArrayContainsComparison.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,70 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using System.Collections; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Handlers.Array; +using Db4objects.Db4o.Marshall; +using Db4objects.Db4o.Typehandlers; + +namespace Db4objects.Db4o.Internal +{ + /// + public class PreparedArrayContainsComparison : IPreparedComparison + { + private readonly ArrayHandler _arrayHandler; + + private readonly IPreparedComparison _preparedComparison; + + private ObjectContainerBase _container; + + public PreparedArrayContainsComparison(IContext context, ArrayHandler arrayHandler + , ITypeHandler4 typeHandler, object obj) + { + _arrayHandler = arrayHandler; + _preparedComparison = Handlers4.PrepareComparisonFor(typeHandler, context, obj); + _container = context.Transaction().Container(); + } + + public virtual int CompareTo(object obj) + { + // We never expect this call + // TODO: The callers of this class should be refactored to pass a matcher and + // to expect a PreparedArrayComparison. + throw new InvalidOperationException(); + } + + public virtual bool IsEqual(object array) + { + return IsMatch(array, IntMatcher.Zero); + } + + public virtual bool IsGreaterThan(object array) + { + return IsMatch(array, IntMatcher.Positive); + } + + public virtual bool IsSmallerThan(object array) + { + return IsMatch(array, IntMatcher.Negative); + } + + private bool IsMatch(object array, IntMatcher matcher) + { + if (array == null) + { + return false; + } + IEnumerator i = _arrayHandler.AllElements(_container, array); + while (i.MoveNext()) + { + if (matcher.Match(_preparedComparison.CompareTo(i.Current))) + { + return true; + } + } + return false; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/PrimitiveTypeMetadata.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/PrimitiveTypeMetadata.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/PrimitiveTypeMetadata.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/PrimitiveTypeMetadata.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,236 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Delete; +using Db4objects.Db4o.Internal.Handlers.Array; +using Db4objects.Db4o.Internal.Marshall; +using Db4objects.Db4o.Internal.Metadata; +using Db4objects.Db4o.Marshall; +using Db4objects.Db4o.Reflect; +using Db4objects.Db4o.Typehandlers; + +namespace Db4objects.Db4o.Internal +{ + /// + public class PrimitiveTypeMetadata : ClassMetadata + { + private const int HashcodeForNull = 283636383; + + public PrimitiveTypeMetadata(ObjectContainerBase container, ITypeHandler4 handler + , int id, IReflectClass classReflector) : base(container, classReflector) + { + _aspects = FieldMetadata.EmptyArray; + _typeHandler = handler; + _id = id; + } + + public PrimitiveTypeMetadata(ObjectContainerBase container) : base(container) + { + _typeHandler = null; + } + + public override void CascadeActivation(IActivationContext context) + { + } + + // Override + // do nothing + internal sealed override void AddToIndex(Transaction trans, int id) + { + } + + // Override + // Primitive Indices will be created later. + internal override bool AllowsQueries() + { + return false; + } + + internal override void CacheDirty(Collection4 col) + { + } + + // do nothing + public override bool DescendOnCascadingActivation() + { + return false; + } + + /// + public override void Delete(IDeleteContext context) + { + if (context.IsLegacyHandlerVersion()) + { + context.ReadInt(); + context.DefragmentRecommended(); + } + } + + internal override void DeleteMembers(DeleteContextImpl context, ArrayType arrayType + , bool isUpdate) + { + if (arrayType == ArrayType.PlainArray) + { + new ArrayHandler(TypeHandler(), true).DeletePrimitiveEmbedded((StatefulBuffer)context + .Buffer(), this); + } + else + { + if (arrayType == ArrayType.MultidimensionalArray) + { + new MultidimensionalArrayHandler(TypeHandler(), true).DeletePrimitiveEmbedded((StatefulBuffer + )context.Buffer(), this); + } + } + } + + public override bool HasClassIndex() + { + return false; + } + + public override object Instantiate(UnmarshallingContext context) + { + object obj = context.PersistentObject(); + if (obj == null) + { + obj = context.Read(TypeHandler()); + context.SetObjectWeak(obj); + } + context.SetStateClean(); + return obj; + } + + public override object InstantiateTransient(UnmarshallingContext context) + { + return Handlers4.ReadValueType(context, CorrectHandlerVersion(context)); + } + + internal override void InstantiateFields(UnmarshallingContext context) + { + throw new NotImplementedException(); + } + + public override bool IsArray() + { + return _id == Handlers4.AnyArrayId || _id == Handlers4.AnyArrayNId; + } + + public override bool HasIdentity() + { + return false; + } + + public override bool IsStronglyTyped() + { + return false; + } + + public override IPreparedComparison PrepareComparison(IContext context, object source + ) + { + return Handlers4.PrepareComparisonFor(TypeHandler(), context, source); + } + + public override ITypeHandler4 ReadCandidateHandler(QueryingReadContext context) + { + if (IsArray()) + { + return TypeHandler(); + } + return null; + } + + // @Override + // public ObjectID readObjectID(InternalReadContext context){ + // if(_handler instanceof ClassMetadata){ + // return ((ClassMetadata)_handler).readObjectID(context); + // } + // if(Handlers4.handlesArray(_handler)){ + // // TODO: Here we should theoretically read through the array and collect candidates. + // // The respective construct is wild: "Contains query through an array in an array." + // // Ignore for now. + // return ObjectID.IGNORE; + // } + // return ObjectID.NOT_POSSIBLE; + // } + internal override void RemoveFromIndex(Transaction ta, int id) + { + } + + // do nothing + public sealed override bool WriteObjectBegin() + { + return false; + } + + public override string ToString() + { + return GetType().FullName + "(" + TypeHandler() + ")"; + } + + public override void Defragment(IDefragmentContext context) + { + CorrectHandlerVersion(context).Defragment(context); + } + + public override object WrapWithTransactionContext(Transaction transaction, object + value) + { + return value; + } + + public override ITypeHandler4 DelegateTypeHandler(IContext context) + { + return TypeHandler(); + } + + public override bool Equals(object obj) + { + if (!(obj is Db4objects.Db4o.Internal.PrimitiveTypeMetadata)) + { + return false; + } + Db4objects.Db4o.Internal.PrimitiveTypeMetadata other = (Db4objects.Db4o.Internal.PrimitiveTypeMetadata + )obj; + if (TypeHandler() == null) + { + return other.TypeHandler() == null; + } + return TypeHandler().Equals(other.TypeHandler()); + } + + public override int GetHashCode() + { + if (TypeHandler() == null) + { + return HashcodeForNull; + } + return TypeHandler().GetHashCode(); + } + + public virtual object DeepClone(object context) + { + throw new InvalidOperationException(); + } + + protected override IAspectTraversalStrategy DetectAspectTraversalStrategy() + { + return new _IAspectTraversalStrategy_178(); + } + + private sealed class _IAspectTraversalStrategy_178 : IAspectTraversalStrategy + { + public _IAspectTraversalStrategy_178() + { + } + + public void TraverseAllAspects(ITraverseAspectCommand command) + { + } + } + // do nothing + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Qlin/QLinConstraint.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Qlin/QLinConstraint.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Qlin/QLinConstraint.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Qlin/QLinConstraint.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,18 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal.Qlin; +using Db4objects.Db4o.Query; + +namespace Db4objects.Db4o.Internal.Qlin +{ + /// + public class QLinConstraint : QLinSubNode + { + private readonly IConstraint _constraint; + + public QLinConstraint(QLinRoot root, IConstraint constraint) : base(root) + { + _constraint = constraint; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Qlin/QLinField.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Qlin/QLinField.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Qlin/QLinField.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Qlin/QLinField.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,47 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal.Qlin; +using Db4objects.Db4o.Qlin; +using Db4objects.Db4o.Query; + +namespace Db4objects.Db4o.Internal.Qlin +{ + /// + public class QLinField : QLinSubNode + { + private readonly IQuery _node; + + public QLinField(QLinRoot root, object expression) : base(root) + { + _node = root.Descend(expression); + } + + public override IQLin Equal(object obj) + { + IConstraint constraint = _node.Constrain(obj); + constraint.Equal(); + return new QLinConstraint(((QLinRoot)_root), constraint); + } + + public override IQLin StartsWith(string @string) + { + IConstraint constraint = _node.Constrain(@string); + constraint.StartsWith(true); + return new QLinConstraint(((QLinRoot)_root), constraint); + } + + public override IQLin Smaller(object obj) + { + IConstraint constraint = _node.Constrain(obj); + constraint.Smaller(); + return new QLinConstraint(((QLinRoot)_root), constraint); + } + + public override IQLin Greater(object obj) + { + IConstraint constraint = _node.Constrain(obj); + constraint.Greater(); + return new QLinConstraint(((QLinRoot)_root), constraint); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Qlin/QLinNode.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Qlin/QLinNode.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Qlin/QLinNode.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Qlin/QLinNode.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,73 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o; +using Db4objects.Db4o.Qlin; + +namespace Db4objects.Db4o.Internal.Qlin +{ + /// + public abstract class QLinNode : IQLin + { + public virtual IQLin Equal(object obj) + { + throw new QLinException("#equal() is not supported on this node"); + } + + public virtual IQLin StartsWith(string @string) + { + throw new QLinException("#startsWith() is not supported on this node"); + } + + public virtual IQLin Smaller(object obj) + { + throw new QLinException("#smaller() is not supported on this node"); + } + + public virtual IQLin Greater(object obj) + { + throw new QLinException("#greater() is not supported on this node"); + } + + public virtual object SingleOrDefault(object defaultValue) + { + IObjectSet collection = Select(); + // TODO: Change to #isEmpty here after decafs, so the size doesn#t need to be calculated + if (collection.Count == 0) + { + return defaultValue; + } + if (collection.Count > 1) + { + // Consider: Use a more specific exception if a query does not return + // the expected result + throw new QLinException("Expected one or none. Found: " + collection.Count); + } + // The following would be the right way to work against + // a collection but for now it won't decaf. + // return collection.iterator().next(); + // This is the ugly old db4o interface, where a Collection is + // an iterator directly. For now it's convenient but we don't + // really want to use this in the future. + // Update #single() in the same way. + return collection.Next(); + } + + public virtual object Single() + { + IObjectSet collection = Select(); + if (collection.Count != 1) + { + throw new QLinException("Expected exactly one. Found: " + collection.Count); + } + return collection.Next(); + } + + public abstract IQLin Limit(int arg1); + + public abstract IQLin OrderBy(object arg1, QLinOrderByDirection arg2); + + public abstract IObjectSet Select(); + + public abstract IQLin Where(object arg1); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Qlin/QLinOrderBy.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Qlin/QLinOrderBy.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Qlin/QLinOrderBy.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Qlin/QLinOrderBy.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,28 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal.Qlin; +using Db4objects.Db4o.Qlin; +using Db4objects.Db4o.Query; + +namespace Db4objects.Db4o.Internal.Qlin +{ + /// + public class QLinOrderBy : QLinSubNode + { + private readonly IQuery _node; + + public QLinOrderBy(QLinRoot root, object expression, QLinOrderByDirection direction + ) : base(root) + { + _node = root.Descend(expression); + if (direction == QLinSupport.Ascending()) + { + _node.OrderAscending(); + } + else + { + _node.OrderDescending(); + } + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Qlin/QLinRoot.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Qlin/QLinRoot.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Qlin/QLinRoot.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Qlin/QLinRoot.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,77 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using Db4objects.Db4o; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal.Qlin; +using Db4objects.Db4o.Internal.Query; +using Db4objects.Db4o.Internal.Query.Processor; +using Db4objects.Db4o.Internal.Query.Result; +using Db4objects.Db4o.Qlin; +using Db4objects.Db4o.Query; + +namespace Db4objects.Db4o.Internal.Qlin +{ + /// + public class QLinRoot : QLinSodaNode + { + private readonly QQuery _query; + + private int _limit = -1; + + public QLinRoot(IQuery query, Type clazz) + { + _query = (QQuery)query; + query.Constrain(clazz); + QLinSupport.Context(clazz); + } + + public virtual IQuery Query() + { + return _query; + } + + public override IObjectSet Select() + { + if (_limit == -1) + { + return _query.Execute(); + } + IQueryResult queryResult = _query.GetQueryResult(); + IdListQueryResult limitedResult = new IdListQueryResult(_query.Transaction(), _limit + ); + int counter = 0; + IIntIterator4 i = queryResult.IterateIDs(); + while (i.MoveNext()) + { + if (counter++ >= _limit) + { + break; + } + limitedResult.Add(i.CurrentInt()); + } + return new ObjectSetFacade(limitedResult); + } + + public override IQLin Limit(int size) + { + if (size < 1) + { + throw new QLinException("Limit must be greater that 0"); + } + _limit = size; + return this; + } + + protected override Db4objects.Db4o.Internal.Qlin.QLinRoot Root() + { + return this; + } + + internal virtual IQuery Descend(object expression) + { + // TODO: Implement deep descend + return Query().Descend(QLinSupport.Field(expression).GetName()); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Qlin/QLinSodaNode.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Qlin/QLinSodaNode.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Qlin/QLinSodaNode.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Qlin/QLinSodaNode.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,23 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal.Qlin; +using Db4objects.Db4o.Qlin; + +namespace Db4objects.Db4o.Internal.Qlin +{ + /// + public abstract class QLinSodaNode : QLinNode + { + protected abstract QLinRoot Root(); + + public override IQLin Where(object expression) + { + return new QLinField(Root(), expression); + } + + public override IQLin OrderBy(object expression, QLinOrderByDirection direction) + { + return new QLinOrderBy(Root(), expression, direction); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Qlin/QLinSubNode.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Qlin/QLinSubNode.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Qlin/QLinSubNode.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Qlin/QLinSubNode.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,41 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o; +using Db4objects.Db4o.Internal.Qlin; +using Db4objects.Db4o.Qlin; +using Db4objects.Db4o.Query; + +namespace Db4objects.Db4o.Internal.Qlin +{ + /// + public abstract class QLinSubNode : QLinSodaNode + { + protected readonly QLinRoot _root; + + public QLinSubNode(QLinRoot root) + { + _root = root; + } + + protected override QLinRoot Root() + { + return _root; + } + + protected virtual IQuery Query() + { + return Root().Query(); + } + + public override IQLin Limit(int size) + { + Root().Limit(size); + return this; + } + + public override IObjectSet Select() + { + return Root().Select(); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/IDb4oEnhancedFilter.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/IDb4oEnhancedFilter.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/IDb4oEnhancedFilter.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/IDb4oEnhancedFilter.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,12 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Query; + +namespace Db4objects.Db4o.Internal.Query +{ + /// FIXME: Rename to Db4oEnhancedPredicate + public interface IDb4oEnhancedFilter + { + void OptimizeQuery(IQuery query); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/IDb4oNQOptimizer.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/IDb4oNQOptimizer.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/IDb4oNQOptimizer.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/IDb4oNQOptimizer.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,11 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Query; + +namespace Db4objects.Db4o.Internal.Query +{ + public interface IDb4oNQOptimizer + { + object Optimize(IQuery query, Predicate filter); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/IDb4oQueryExecutionListener.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/IDb4oQueryExecutionListener.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/IDb4oQueryExecutionListener.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/IDb4oQueryExecutionListener.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,11 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal.Query; + +namespace Db4objects.Db4o.Internal.Query +{ + public interface IDb4oQueryExecutionListener + { + void NotifyQueryExecuted(NQOptimizationInfo info); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/NQOptimizationInfo.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/NQOptimizationInfo.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/NQOptimizationInfo.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/NQOptimizationInfo.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,41 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +namespace Db4objects.Db4o.Internal.Query +{ + public class NQOptimizationInfo + { + private Db4objects.Db4o.Query.Predicate _predicate; + + private string _message; + + private object _optimized; + + public NQOptimizationInfo(Db4objects.Db4o.Query.Predicate predicate, string message + , object optimized) + { + this._predicate = predicate; + this._message = message; + this._optimized = optimized; + } + + public virtual string Message() + { + return _message; + } + + public virtual object Optimized() + { + return _optimized; + } + + public virtual Db4objects.Db4o.Query.Predicate Predicate() + { + return _predicate; + } + + public override string ToString() + { + return Message() + "/" + Optimized(); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/PredicateEvaluation.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/PredicateEvaluation.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/PredicateEvaluation.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/PredicateEvaluation.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,28 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Query; + +namespace Db4objects.Db4o.Internal.Query +{ + /// + [System.Serializable] + public class PredicateEvaluation : IEvaluation + { + public Predicate _predicate; + + public PredicateEvaluation() + { + } + + public PredicateEvaluation(Predicate predicate) + { + // CS + _predicate = predicate; + } + + public virtual void Evaluate(ICandidate candidate) + { + candidate.Include(_predicate.AppliesTo(candidate.GetObject())); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/Processor/IInternalQuery.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/Processor/IInternalQuery.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/Processor/IInternalQuery.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/Processor/IInternalQuery.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,15 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal; + +namespace Db4objects.Db4o.Internal.Query.Processor +{ + /// + public interface IInternalQuery + { + IInternalObjectContainer Container + { + get; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/Processor/QCandidate.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/Processor/QCandidate.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/Processor/QCandidate.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/Processor/QCandidate.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,830 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System.Collections; +using Db4objects.Db4o; +using Db4objects.Db4o.Config; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Handlers; +using Db4objects.Db4o.Internal.Handlers.Array; +using Db4objects.Db4o.Internal.Marshall; +using Db4objects.Db4o.Internal.Query.Processor; +using Db4objects.Db4o.Marshall; +using Db4objects.Db4o.Query; +using Db4objects.Db4o.Reflect; +using Db4objects.Db4o.Typehandlers; + +namespace Db4objects.Db4o.Internal.Query.Processor +{ + /// Represents an actual object in the database. + /// + /// Represents an actual object in the database. Forms a tree structure, indexed + /// by id. Can have dependents that are doNotInclude'd in the query result when + /// this is doNotInclude'd. + /// + /// + public class QCandidate : TreeInt, ICandidate + { + internal ByteArrayBuffer _bytes; + + internal readonly QCandidates _candidates; + + private List4 _dependants; + + internal bool _include = true; + + private object _member; + + private Tree _pendingJoins; + + private Db4objects.Db4o.Internal.Query.Processor.QCandidate _root; + + private Db4objects.Db4o.Internal.ClassMetadata _classMetadata; + + private FieldMetadata _fieldMetadata; + + private int _handlerVersion; + + private QCandidate(QCandidates qcandidates) : base(0) + { + // db4o ID is stored in _key; + // db4o byte stream storing the object + // Dependent candidates + // whether to include in the result set + // may use id for optimisation ??? + // Possible pending joins on children + // The evaluation root to compare all ORs + // the ClassMetadata of this object + // temporary field and member for one field during evaluation + // null denotes null object + _candidates = qcandidates; + } + + public QCandidate(QCandidates candidates, object member, int id) : base(id) + { + if (DTrace.enabled) + { + DTrace.CreateCandidate.Log(id); + } + _candidates = candidates; + _member = member; + _include = true; + if (id == 0) + { + _key = candidates.GenerateCandidateId(); + } + } + + public override object ShallowClone() + { + Db4objects.Db4o.Internal.Query.Processor.QCandidate qcan = new Db4objects.Db4o.Internal.Query.Processor.QCandidate + (_candidates); + qcan.SetBytes(_bytes); + qcan._dependants = _dependants; + qcan._include = _include; + qcan._member = _member; + qcan._pendingJoins = _pendingJoins; + qcan._root = _root; + qcan._classMetadata = _classMetadata; + qcan._fieldMetadata = _fieldMetadata; + return base.ShallowCloneInternal(qcan); + } + + internal virtual void AddDependant(Db4objects.Db4o.Internal.Query.Processor.QCandidate + a_candidate) + { + _dependants = new List4(_dependants, a_candidate); + } + + private void CheckInstanceOfCompare() + { + if (_member is ICompare) + { + _member = ((ICompare)_member).Compare(); + LocalObjectContainer stream = Container(); + _classMetadata = stream.ClassMetadataForReflectClass(stream.Reflector().ForObject + (_member)); + _key = stream.GetID(Transaction(), _member); + if (_key == 0) + { + SetBytes(null); + } + else + { + SetBytes(stream.ReadBufferById(Transaction(), _key)); + } + } + } + + internal virtual bool CreateChild(QCandidates a_candidates) + { + if (!_include) + { + return false; + } + if (_fieldMetadata != null) + { + ITypeHandler4 handler = _fieldMetadata.GetHandler(); + if (handler != null) + { + QueryingReadContext queryingReadContext = new QueryingReadContext(Transaction(), + MarshallerFamily().HandlerVersion(), _bytes, _key); + ITypeHandler4 arrayElementHandler = Handlers4.ArrayElementHandler(handler, queryingReadContext + ); + if (arrayElementHandler != null) + { + int offset = queryingReadContext.Offset(); + bool outerRes = true; + // The following construct is worse than not ideal. + // For each constraint it completely reads the + // underlying structure again. The structure could b + // kept fairly easy. TODO: Optimize! + IEnumerator i = a_candidates.IterateConstraints(); + while (i.MoveNext()) + { + QCon qcon = (QCon)i.Current; + QField qf = qcon.GetField(); + if (qf == null || qf.Name().Equals(_fieldMetadata.GetName())) + { + QCon tempParent = qcon.Parent(); + qcon.SetParent(null); + QCandidates candidates = new QCandidates(a_candidates.i_trans, null, qf); + candidates.AddConstraint(qcon); + qcon.SetCandidates(candidates); + ReadArrayCandidates(handler, queryingReadContext.Buffer(), arrayElementHandler, candidates + ); + queryingReadContext.Seek(offset); + bool isNot = qcon.IsNot(); + if (isNot) + { + qcon.RemoveNot(); + } + candidates.Evaluate(); + ByRef pending = ByRef.NewInstance(); + bool[] innerRes = new bool[] { isNot }; + candidates.Traverse(new _IVisitor4_160(innerRes, isNot, pending)); + // Collect all pending subresults. + // We need to change + // the + // constraint here, so + // our + // pending collector + // uses + // the right + // comparator. + // We only keep one + // pending result + // for + // all array + // elements. + // and memorize, + // whether we had a + // true or a false + // result. + // or both. + if (isNot) + { + qcon.Not(); + } + // In case we had pending subresults, we + // need to communicate + // them up to our root. + if (((Tree)pending.value) != null) + { + ((Tree)pending.value).Traverse(new _IVisitor4_229(this)); + } + if (!innerRes[0]) + { + // Again this could be double triggering. + // + // We want to clean up the "No route" + // at some stage. + qcon.Visit(GetRoot(), qcon.Evaluator().Not(false)); + outerRes = false; + } + qcon.SetParent(tempParent); + } + } + return outerRes; + } + // We may get simple types here too, if the YapField was null + // in the higher level simple evaluation. Evaluate these + // immediately. + if (Handlers4.IsQueryLeaf(handler)) + { + a_candidates.i_currentConstraint.Visit(this); + return true; + } + } + } + if (_fieldMetadata == null) + { + return false; + } + if (_fieldMetadata is NullFieldMetadata) + { + return false; + } + _classMetadata.SeekToField(Transaction(), _bytes, _fieldMetadata); + Db4objects.Db4o.Internal.Query.Processor.QCandidate candidate = ReadSubCandidate( + a_candidates); + if (candidate == null) + { + return false; + } + // fast early check for ClassMetadata + if (a_candidates.i_classMetadata != null && a_candidates.i_classMetadata.IsStronglyTyped + ()) + { + ITypeHandler4 handler = _fieldMetadata.GetHandler(); + if (Handlers4.IsUntyped(handler)) + { + handler = TypeHandlerFor(candidate); + } + if (handler == null) + { + return false; + } + } + AddDependant(a_candidates.Add(candidate)); + return true; + } + + private sealed class _IVisitor4_160 : IVisitor4 + { + public _IVisitor4_160(bool[] innerRes, bool isNot, ByRef pending) + { + this.innerRes = innerRes; + this.isNot = isNot; + this.pending = pending; + } + + public void Visit(object obj) + { + Db4objects.Db4o.Internal.Query.Processor.QCandidate cand = (Db4objects.Db4o.Internal.Query.Processor.QCandidate + )obj; + if (cand.Include()) + { + innerRes[0] = !isNot; + } + if (cand._pendingJoins != null) + { + cand._pendingJoins.Traverse(new _IVisitor4_173(pending)); + } + } + + private sealed class _IVisitor4_173 : IVisitor4 + { + public _IVisitor4_173(ByRef pending) + { + this.pending = pending; + } + + public void Visit(object a_object) + { + QPending newPending = ((QPending)a_object).InternalClonePayload(); + newPending.ChangeConstraint(); + QPending oldPending = (QPending)Tree.Find(((Tree)pending.value), newPending); + if (oldPending != null) + { + if (oldPending._result != newPending._result) + { + oldPending._result = QPending.Both; + } + } + else + { + pending.value = Tree.Add(((Tree)pending.value), newPending); + } + } + + private readonly ByRef pending; + } + + private readonly bool[] innerRes; + + private readonly bool isNot; + + private readonly ByRef pending; + } + + private sealed class _IVisitor4_229 : IVisitor4 + { + public _IVisitor4_229(QCandidate _enclosing) + { + this._enclosing = _enclosing; + } + + public void Visit(object a_object) + { + this._enclosing.GetRoot().Evaluate((QPending)a_object); + } + + private readonly QCandidate _enclosing; + } + + private ITypeHandler4 TypeHandlerFor(Db4objects.Db4o.Internal.Query.Processor.QCandidate + candidate) + { + Db4objects.Db4o.Internal.ClassMetadata classMetadata = candidate.ReadClassMetadata + (); + if (classMetadata != null) + { + return classMetadata.TypeHandler(); + } + return null; + } + + private void ReadArrayCandidates(ITypeHandler4 typeHandler, IReadBuffer buffer, ITypeHandler4 + arrayElementHandler, QCandidates candidates) + { + if (!Handlers4.IsCascading(arrayElementHandler)) + { + return; + } + SlotFormat slotFormat = SlotFormat.ForHandlerVersion(_handlerVersion); + slotFormat.DoWithSlotIndirection(buffer, typeHandler, new _IClosure4_318(this, arrayElementHandler + , buffer, candidates)); + } + + private sealed class _IClosure4_318 : IClosure4 + { + public _IClosure4_318(QCandidate _enclosing, ITypeHandler4 arrayElementHandler, IReadBuffer + buffer, QCandidates candidates) + { + this._enclosing = _enclosing; + this.arrayElementHandler = arrayElementHandler; + this.buffer = buffer; + this.candidates = candidates; + } + + public object Run() + { + QueryingReadContext context = null; + if (Handlers4.HandleAsObject(arrayElementHandler)) + { + // TODO: Code is similar to FieldMetadata.collectIDs. Try to refactor to one place. + int collectionID = buffer.ReadInt(); + ByteArrayBuffer arrayElementBuffer = this._enclosing.Container().ReadBufferById(this + ._enclosing.Transaction(), collectionID); + ObjectHeader objectHeader = ObjectHeader.ScrollBufferToContent(this._enclosing.Container + (), arrayElementBuffer); + context = new QueryingReadContext(this._enclosing.Transaction(), candidates, this + ._enclosing._handlerVersion, arrayElementBuffer, collectionID); + objectHeader.ClassMetadata().CollectIDs(context); + } + else + { + context = new QueryingReadContext(this._enclosing.Transaction(), candidates, this + ._enclosing._handlerVersion, buffer, 0); + ((ICascadingTypeHandler)arrayElementHandler).CollectIDs(context); + } + Tree.Traverse(context.Ids(), new _IVisitor4_336(candidates)); + IEnumerator i = context.ObjectsWithoutId(); + while (i.MoveNext()) + { + object obj = i.Current; + candidates.Add(new Db4objects.Db4o.Internal.Query.Processor.QCandidate(candidates + , obj, 0)); + } + return null; + } + + private sealed class _IVisitor4_336 : IVisitor4 + { + public _IVisitor4_336(QCandidates candidates) + { + this.candidates = candidates; + } + + public void Visit(object obj) + { + TreeInt idNode = (TreeInt)obj; + candidates.Add(new Db4objects.Db4o.Internal.Query.Processor.QCandidate(candidates + , null, idNode._key)); + } + + private readonly QCandidates candidates; + } + + private readonly QCandidate _enclosing; + + private readonly ITypeHandler4 arrayElementHandler; + + private readonly IReadBuffer buffer; + + private readonly QCandidates candidates; + } + + internal virtual void DoNotInclude() + { + Include(false); + if (_dependants != null) + { + IEnumerator i = new Iterator4Impl(_dependants); + _dependants = null; + while (i.MoveNext()) + { + ((Db4objects.Db4o.Internal.Query.Processor.QCandidate)i.Current).DoNotInclude(); + } + } + } + + internal virtual bool Evaluate(QConObject a_constraint, QE a_evaluator) + { + if (a_evaluator.Identity()) + { + return a_evaluator.Evaluate(a_constraint, this, null); + } + if (_member == null) + { + _member = Value(); + } + return a_evaluator.Evaluate(a_constraint, this, a_constraint.Translate(_member)); + } + + internal virtual bool Evaluate(QPending a_pending) + { + QPending oldPending = (QPending)Tree.Find(_pendingJoins, a_pending); + if (oldPending == null) + { + a_pending.ChangeConstraint(); + _pendingJoins = Tree.Add(_pendingJoins, a_pending.InternalClonePayload()); + return true; + } + _pendingJoins = _pendingJoins.RemoveNode(oldPending); + oldPending._join.EvaluatePending(this, oldPending, a_pending._result); + return false; + } + + internal virtual IReflectClass ClassReflector() + { + ReadClassMetadata(); + if (_classMetadata == null) + { + return null; + } + return _classMetadata.ClassReflector(); + } + + internal virtual bool FieldIsAvailable() + { + return ClassReflector() != null; + } + + // / ****** + public virtual IObjectContainer ObjectContainer() + { + return Container(); + } + + public virtual object GetObject() + { + object obj = Value(true); + if (obj is ByteArrayBuffer) + { + ByteArrayBuffer reader = (ByteArrayBuffer)obj; + int offset = reader._offset; + obj = ReadString(reader); + reader._offset = offset; + } + return obj; + } + + public virtual string ReadString(ByteArrayBuffer buffer) + { + return StringHandler.ReadString(Transaction().Context(), buffer); + } + + internal virtual Db4objects.Db4o.Internal.Query.Processor.QCandidate GetRoot() + { + return _root == null ? this : _root; + } + + internal LocalObjectContainer Container() + { + return Transaction().LocalContainer(); + } + + internal LocalTransaction Transaction() + { + return _candidates.i_trans; + } + + public virtual bool Include() + { + return _include; + } + + /// For external interface use only. + /// + /// For external interface use only. Call doNotInclude() internally so + /// dependancies can be checked. + /// + public virtual void Include(bool flag) + { + // TODO: + // Internal and external flag may need to be handled seperately. + _include = flag; + } + + public override Tree OnAttemptToAddDuplicate(Tree oldNode) + { + _size = 0; + _root = (Db4objects.Db4o.Internal.Query.Processor.QCandidate)oldNode; + return oldNode; + } + + private IReflectClass MemberClass() + { + return Transaction().Reflector().ForObject(_member); + } + + internal virtual IPreparedComparison PrepareComparison(ObjectContainerBase container + , object constraint) + { + IContext context = container.Transaction.Context(); + if (_fieldMetadata != null) + { + return _fieldMetadata.PrepareComparison(context, constraint); + } + if (_classMetadata != null) + { + return _classMetadata.PrepareComparison(context, constraint); + } + IReflector reflector = container.Reflector(); + Db4objects.Db4o.Internal.ClassMetadata classMetadata = null; + if (_bytes != null) + { + classMetadata = container.ProduceClassMetadata(reflector.ForObject(constraint)); + } + else + { + if (_member != null) + { + classMetadata = container.ClassMetadataForReflectClass(reflector.ForObject(_member + )); + } + } + if (classMetadata != null) + { + if (_member != null && _member.GetType().IsArray) + { + ITypeHandler4 arrayElementTypehandler = classMetadata.TypeHandler(); + if (reflector.Array().IsNDimensional(MemberClass())) + { + MultidimensionalArrayHandler mah = new MultidimensionalArrayHandler(arrayElementTypehandler + , false); + return mah.PrepareComparison(context, _member); + } + ArrayHandler ya = new ArrayHandler(arrayElementTypehandler, false); + return ya.PrepareComparison(context, _member); + } + return classMetadata.PrepareComparison(context, constraint); + } + return null; + } + + private void Read() + { + if (_include) + { + if (_bytes == null) + { + if (_key > 0) + { + if (DTrace.enabled) + { + DTrace.CandidateRead.Log(_key); + } + SetBytes(Container().ReadBufferById(Transaction(), _key)); + if (_bytes == null) + { + Include(false); + } + } + else + { + Include(false); + } + } + } + } + + private int CurrentOffSet() + { + return _bytes._offset; + } + + private Db4objects.Db4o.Internal.Query.Processor.QCandidate ReadSubCandidate(QCandidates + candidateCollection) + { + Read(); + if (_bytes == null || _fieldMetadata == null) + { + return null; + } + int offset = CurrentOffSet(); + QueryingReadContext context = NewQueryingReadContext(); + ITypeHandler4 handler = HandlerRegistry.CorrectHandlerVersion(context, _fieldMetadata + .GetHandler()); + Db4objects.Db4o.Internal.Query.Processor.QCandidate subCandidate = candidateCollection + .ReadSubCandidate(context, handler); + Seek(offset); + if (subCandidate != null) + { + subCandidate._root = GetRoot(); + return subCandidate; + } + return null; + } + + private void Seek(int offset) + { + _bytes._offset = offset; + } + + private QueryingReadContext NewQueryingReadContext() + { + return new QueryingReadContext(Transaction(), _handlerVersion, _bytes, _key); + } + + private void ReadThis(bool a_activate) + { + Read(); + ObjectContainerBase container = Transaction().Container(); + _member = container.TryGetByID(Transaction(), _key); + if (_member != null && (a_activate || _member is ICompare)) + { + container.Activate(Transaction(), _member); + CheckInstanceOfCompare(); + } + } + + internal virtual Db4objects.Db4o.Internal.ClassMetadata ReadClassMetadata() + { + if (_classMetadata == null) + { + Read(); + if (_bytes != null) + { + Seek(0); + ObjectContainerBase stream = Container(); + ObjectHeader objectHeader = new ObjectHeader(stream, _bytes); + _classMetadata = objectHeader.ClassMetadata(); + if (_classMetadata != null) + { + if (stream._handlers.IclassCompare.IsAssignableFrom(_classMetadata.ClassReflector + ())) + { + ReadThis(false); + } + } + } + } + return _classMetadata; + } + + public override string ToString() + { + string str = "QCandidate "; + if (_classMetadata != null) + { + str += "\n YapClass " + _classMetadata.GetName(); + } + if (_fieldMetadata != null) + { + str += "\n YapField " + _fieldMetadata.GetName(); + } + if (_member != null) + { + str += "\n Member " + _member.ToString(); + } + if (_root != null) + { + str += "\n rooted by:\n"; + str += _root.ToString(); + } + else + { + str += "\n ROOT"; + } + return str; + } + + internal virtual void UseField(QField a_field) + { + Read(); + if (_bytes == null) + { + _fieldMetadata = null; + return; + } + ReadClassMetadata(); + _member = null; + if (a_field == null) + { + _fieldMetadata = null; + return; + } + if (_classMetadata == null) + { + _fieldMetadata = null; + return; + } + _fieldMetadata = FieldMetadataFrom(a_field, _classMetadata); + if (_fieldMetadata == null) + { + FieldNotFound(); + return; + } + HandlerVersion handlerVersion = _classMetadata.SeekToField(Transaction(), _bytes, + _fieldMetadata); + if (handlerVersion == HandlerVersion.Invalid) + { + FieldNotFound(); + return; + } + _handlerVersion = handlerVersion._number; + } + + private FieldMetadata FieldMetadataFrom(QField qField, Db4objects.Db4o.Internal.ClassMetadata + type) + { + FieldMetadata existingField = qField.GetFieldMetadata(); + if (existingField != null) + { + return existingField; + } + FieldMetadata field = type.FieldMetadataForName(qField.Name()); + if (field != null) + { + field.Alive(); + } + return field; + } + + private void FieldNotFound() + { + if (_classMetadata.HoldsAnyClass()) + { + // retry finding the field on reading the value + _fieldMetadata = null; + } + else + { + // we can't get a value for the field, comparisons should definitely run against null + _fieldMetadata = new NullFieldMetadata(); + } + _handlerVersion = HandlerRegistry.HandlerVersion; + } + + internal virtual object Value() + { + return Value(false); + } + + // TODO: This is only used for Evaluations. Handling may need + // to be different for collections also. + internal virtual object Value(bool a_activate) + { + if (_member == null) + { + if (_fieldMetadata == null) + { + ReadThis(a_activate); + } + else + { + int offset = CurrentOffSet(); + _member = _fieldMetadata.Read(NewQueryingReadContext()); + Seek(offset); + CheckInstanceOfCompare(); + } + } + return _member; + } + + internal virtual void SetBytes(ByteArrayBuffer bytes) + { + _bytes = bytes; + } + + private Db4objects.Db4o.Internal.Marshall.MarshallerFamily MarshallerFamily() + { + return Db4objects.Db4o.Internal.Marshall.MarshallerFamily.Version(_handlerVersion + ); + } + + public override bool Duplicates() + { + return _root != null; + } + + public virtual void ClassMetadata(Db4objects.Db4o.Internal.ClassMetadata classMetadata + ) + { + _classMetadata = classMetadata; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/Processor/QCandidates.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/Processor/QCandidates.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/Processor/QCandidates.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/Processor/QCandidates.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,659 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using System.Collections; +using System.Text; +using Db4objects.Db4o; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Classindex; +using Db4objects.Db4o.Internal.Diagnostic; +using Db4objects.Db4o.Internal.Fieldindex; +using Db4objects.Db4o.Internal.Handlers; +using Db4objects.Db4o.Internal.Marshall; +using Db4objects.Db4o.Internal.Query.Processor; +using Db4objects.Db4o.Typehandlers; + +namespace Db4objects.Db4o.Internal.Query.Processor +{ + /// + /// Holds the tree of + /// QCandidate + /// objects and the list of + /// QCon + /// during query evaluation. + /// The query work (adding and removing nodes) happens here. + /// Candidates during query evaluation. + /// QCandidate + /// objects are stored in i_root + /// + /// + public sealed class QCandidates : IVisitor4 + { + public readonly LocalTransaction i_trans; + + public Tree i_root; + + private List4 _constraints; + + internal ClassMetadata i_classMetadata; + + private QField _field; + + internal QCon i_currentConstraint; + + private IDGenerator _idGenerator; + + private bool _loadedFromClassIndex; + + internal QCandidates(LocalTransaction a_trans, ClassMetadata a_classMetadata, QField + a_field) + { + // Transaction necessary as reference to stream + // root of the QCandidate tree + // collection of all constraints + // possible class information + // possible field information + // current executing constraint, only set where needed + i_trans = a_trans; + i_classMetadata = a_classMetadata; + _field = a_field; + if (a_field == null || a_field._fieldMetadata == null || !(a_field._fieldMetadata + .GetHandler() is StandardReferenceTypeHandler)) + { + return; + } + ClassMetadata yc = ((StandardReferenceTypeHandler)a_field._fieldMetadata.GetHandler + ()).ClassMetadata(); + if (i_classMetadata == null) + { + i_classMetadata = yc; + } + else + { + yc = i_classMetadata.GetHigherOrCommonHierarchy(yc); + if (yc != null) + { + i_classMetadata = yc; + } + } + } + + public QCandidate Add(QCandidate candidate) + { + i_root = Tree.Add(i_root, candidate); + if (candidate._size == 0) + { + // This means that the candidate was already present + // and QCandidate does not allow duplicates. + // In this case QCandidate#isDuplicateOf will have + // placed the existing QCandidate in the i_root + // variable of the new candidate. We return it here: + return candidate.GetRoot(); + } + return candidate; + } + + internal void AddConstraint(QCon a_constraint) + { + _constraints = new List4(_constraints, a_constraint); + } + + public QCandidate ReadSubCandidate(QueryingReadContext context, ITypeHandler4 handler + ) + { + ObjectID objectID = ObjectID.NotPossible; + try + { + int offset = context.Offset(); + if (handler is IReadsObjectIds) + { + objectID = ((IReadsObjectIds)handler).ReadObjectID(context); + } + if (objectID.IsValid()) + { + return new QCandidate(this, null, objectID._id); + } + if (objectID == ObjectID.NotPossible) + { + context.Seek(offset); + object obj = context.Read(handler); + if (obj != null) + { + QCandidate candidate = new QCandidate(this, obj, context.Container().GetID(context + .Transaction(), obj)); + candidate.ClassMetadata(context.Container().ClassMetadataForObject(obj)); + return candidate; + } + } + } + catch (Exception) + { + } + // FIXME: Catchall + return null; + } + + internal void Collect(Db4objects.Db4o.Internal.Query.Processor.QCandidates a_candidates + ) + { + IEnumerator i = IterateConstraints(); + while (i.MoveNext()) + { + QCon qCon = (QCon)i.Current; + SetCurrentConstraint(qCon); + qCon.Collect(a_candidates); + } + SetCurrentConstraint(null); + } + + internal void Execute() + { + if (DTrace.enabled) + { + DTrace.QueryProcess.Log(); + } + FieldIndexProcessorResult result = ProcessFieldIndexes(); + if (result.FoundIndex()) + { + i_root = result.ToQCandidate(this); + } + else + { + LoadFromClassIndex(); + } + Evaluate(); + } + + public IEnumerator ExecuteSnapshot(Collection4 executionPath) + { + IIntIterator4 indexIterator = new IntIterator4Adaptor(IterateIndex(ProcessFieldIndexes + ())); + Tree idRoot = TreeInt.AddAll(null, indexIterator); + IEnumerator snapshotIterator = new TreeKeyIterator(idRoot); + IEnumerator singleObjectQueryIterator = SingleObjectSodaProcessor(snapshotIterator + ); + return MapIdsToExecutionPath(singleObjectQueryIterator, executionPath); + } + + private IEnumerator SingleObjectSodaProcessor(IEnumerator indexIterator) + { + return Iterators.Map(indexIterator, new _IFunction4_159(this)); + } + + private sealed class _IFunction4_159 : IFunction4 + { + public _IFunction4_159(QCandidates _enclosing) + { + this._enclosing = _enclosing; + } + + public object Apply(object current) + { + int id = ((int)current); + QCandidate candidate = new QCandidate(this._enclosing, null, id); + this._enclosing.i_root = candidate; + this._enclosing.Evaluate(); + if (!candidate.Include()) + { + return Iterators.Skip; + } + return current; + } + + private readonly QCandidates _enclosing; + } + + public IEnumerator ExecuteLazy(Collection4 executionPath) + { + IEnumerator indexIterator = IterateIndex(ProcessFieldIndexes()); + IEnumerator singleObjectQueryIterator = SingleObjectSodaProcessor(indexIterator); + return MapIdsToExecutionPath(singleObjectQueryIterator, executionPath); + } + + private IEnumerator IterateIndex(FieldIndexProcessorResult result) + { + if (result.NoMatch()) + { + return Iterators.EmptyIterator; + } + if (result.FoundIndex()) + { + return result.IterateIDs(); + } + if (!i_classMetadata.HasClassIndex()) + { + return Iterators.EmptyIterator; + } + return BTreeClassIndexStrategy.Iterate(i_classMetadata, i_trans); + } + + private IEnumerator MapIdsToExecutionPath(IEnumerator singleObjectQueryIterator, + Collection4 executionPath) + { + if (executionPath == null) + { + return singleObjectQueryIterator; + } + IEnumerator res = singleObjectQueryIterator; + IEnumerator executionPathIterator = executionPath.GetEnumerator(); + while (executionPathIterator.MoveNext()) + { + string fieldName = (string)executionPathIterator.Current; + res = Iterators.Concat(Iterators.Map(res, new _IFunction4_205(this, fieldName))); + } + return res; + } + + private sealed class _IFunction4_205 : IFunction4 + { + public _IFunction4_205(QCandidates _enclosing, string fieldName) + { + this._enclosing = _enclosing; + this.fieldName = fieldName; + } + + public object Apply(object current) + { + int id = ((int)current); + CollectIdContext context = CollectIdContext.ForID(this._enclosing.i_trans, id); + if (context == null) + { + return Iterators.Skip; + } + context.ClassMetadata().CollectIDs(context, fieldName); + return new TreeKeyIterator(context.Ids()); + } + + private readonly QCandidates _enclosing; + + private readonly string fieldName; + } + + public ObjectContainerBase Stream() + { + return i_trans.Container(); + } + + public int ClassIndexEntryCount() + { + return i_classMetadata.IndexEntryCount(i_trans); + } + + private FieldIndexProcessorResult ProcessFieldIndexes() + { + if (_constraints == null) + { + return FieldIndexProcessorResult.NoIndexFound; + } + return new FieldIndexProcessor(this).Run(); + } + + internal void Evaluate() + { + if (_constraints == null) + { + return; + } + ForEachConstraint(new _IProcedure4_243(this)); + ForEachConstraint(new _IProcedure4_251()); + ForEachConstraint(new _IProcedure4_257()); + ForEachConstraint(new _IProcedure4_263()); + ForEachConstraint(new _IProcedure4_269()); + ForEachConstraint(new _IProcedure4_275()); + } + + private sealed class _IProcedure4_243 : IProcedure4 + { + public _IProcedure4_243(QCandidates _enclosing) + { + this._enclosing = _enclosing; + } + + public void Apply(object arg) + { + QCon qCon = (QCon)arg; + qCon.SetCandidates(this._enclosing); + qCon.EvaluateSelf(); + } + + private readonly QCandidates _enclosing; + } + + private sealed class _IProcedure4_251 : IProcedure4 + { + public _IProcedure4_251() + { + } + + public void Apply(object arg) + { + ((QCon)arg).EvaluateSimpleChildren(); + } + } + + private sealed class _IProcedure4_257 : IProcedure4 + { + public _IProcedure4_257() + { + } + + public void Apply(object arg) + { + ((QCon)arg).EvaluateEvaluations(); + } + } + + private sealed class _IProcedure4_263 : IProcedure4 + { + public _IProcedure4_263() + { + } + + public void Apply(object arg) + { + ((QCon)arg).EvaluateCreateChildrenCandidates(); + } + } + + private sealed class _IProcedure4_269 : IProcedure4 + { + public _IProcedure4_269() + { + } + + public void Apply(object arg) + { + ((QCon)arg).EvaluateCollectChildren(); + } + } + + private sealed class _IProcedure4_275 : IProcedure4 + { + public _IProcedure4_275() + { + } + + public void Apply(object arg) + { + ((QCon)arg).EvaluateChildren(); + } + } + + private void ForEachConstraint(IProcedure4 proc) + { + IEnumerator i = IterateConstraints(); + while (i.MoveNext()) + { + QCon constraint = (QCon)i.Current; + if (!constraint.ProcessedByIndex()) + { + proc.Apply(constraint); + } + } + } + + internal bool IsEmpty() + { + bool[] ret = new bool[] { true }; + Traverse(new _IVisitor4_295(ret)); + return ret[0]; + } + + private sealed class _IVisitor4_295 : IVisitor4 + { + public _IVisitor4_295(bool[] ret) + { + this.ret = ret; + } + + public void Visit(object obj) + { + if (((QCandidate)obj)._include) + { + ret[0] = false; + } + } + + private readonly bool[] ret; + } + + internal bool Filter(IVisitor4 a_host) + { + if (i_root != null) + { + i_root.Traverse(a_host); + i_root = i_root.Filter(new _IPredicate4_308()); + } + return i_root != null; + } + + private sealed class _IPredicate4_308 : IPredicate4 + { + public _IPredicate4_308() + { + } + + public bool Match(object a_candidate) + { + return ((QCandidate)a_candidate)._include; + } + } + + internal int GenerateCandidateId() + { + if (_idGenerator == null) + { + _idGenerator = new IDGenerator(); + } + return -_idGenerator.Next(); + } + + public IEnumerator IterateConstraints() + { + if (_constraints == null) + { + return Iterators.EmptyIterator; + } + return new Iterator4Impl(_constraints); + } + + internal sealed class TreeIntBuilder + { + public TreeInt tree; + + public void Add(TreeInt node) + { + tree = (TreeInt)((TreeInt)Tree.Add(tree, node)); + } + } + + internal void LoadFromClassIndex() + { + if (!IsEmpty()) + { + return; + } + QCandidates.TreeIntBuilder result = new QCandidates.TreeIntBuilder(); + IClassIndexStrategy index = i_classMetadata.Index(); + index.TraverseAll(i_trans, new _IVisitor4_346(this, result)); + i_root = result.tree; + DiagnosticProcessor dp = i_trans.Container()._handlers.DiagnosticProcessor(); + if (dp.Enabled() && !IsClassOnlyQuery()) + { + dp.LoadedFromClassIndex(i_classMetadata); + } + _loadedFromClassIndex = true; + } + + private sealed class _IVisitor4_346 : IVisitor4 + { + public _IVisitor4_346(QCandidates _enclosing, QCandidates.TreeIntBuilder result) + { + this._enclosing = _enclosing; + this.result = result; + } + + public void Visit(object obj) + { + result.Add(new QCandidate(this._enclosing, null, ((int)obj))); + } + + private readonly QCandidates _enclosing; + + private readonly QCandidates.TreeIntBuilder result; + } + + internal void SetCurrentConstraint(QCon a_constraint) + { + i_currentConstraint = a_constraint; + } + + internal void Traverse(IVisitor4 a_visitor) + { + if (i_root != null) + { + i_root.Traverse(a_visitor); + } + } + + // FIXME: This method should go completely. + // We changed the code to create the QCandidates graph in two steps: + // (1) call fitsIntoExistingConstraintHierarchy to determine whether + // or not we need more QCandidates objects + // (2) add all constraints + // This method tries to do both in one, which results in missing + // constraints. Not all are added to all QCandiates. + // Right methodology is in + // QQueryBase#createCandidateCollection + // and + // QQueryBase#createQCandidatesList + internal bool TryAddConstraint(QCon a_constraint) + { + if (_field != null) + { + QField qf = a_constraint.GetField(); + if (qf != null) + { + if (_field.Name() != null && !_field.Name().Equals(qf.Name())) + { + return false; + } + } + } + if (i_classMetadata == null || a_constraint.IsNullConstraint()) + { + AddConstraint(a_constraint); + return true; + } + ClassMetadata yc = a_constraint.GetYapClass(); + if (yc != null) + { + yc = i_classMetadata.GetHigherOrCommonHierarchy(yc); + if (yc != null) + { + i_classMetadata = yc; + AddConstraint(a_constraint); + return true; + } + } + AddConstraint(a_constraint); + return false; + } + + public void Visit(object a_tree) + { + QCandidate parent = (QCandidate)a_tree; + if (parent.CreateChild(this)) + { + return; + } + // No object found. + // All children constraints are necessarily false. + // Check immediately. + IEnumerator i = IterateConstraints(); + while (i.MoveNext()) + { + ((QCon)i.Current).VisitOnNull(parent.GetRoot()); + } + } + + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + i_root.Traverse(new _IVisitor4_430(sb)); + return sb.ToString(); + } + + private sealed class _IVisitor4_430 : IVisitor4 + { + public _IVisitor4_430(StringBuilder sb) + { + this.sb = sb; + } + + public void Visit(object obj) + { + QCandidate candidate = (QCandidate)obj; + sb.Append(" "); + sb.Append(candidate._key); + } + + private readonly StringBuilder sb; + } + + public Transaction Transaction() + { + return i_trans; + } + + public bool WasLoadedFromClassIndex() + { + return _loadedFromClassIndex; + } + + public bool FitsIntoExistingConstraintHierarchy(QCon constraint) + { + if (_field != null) + { + QField qf = constraint.GetField(); + if (qf != null) + { + if (_field.Name() != null && !_field.Name().Equals(qf.Name())) + { + return false; + } + } + } + if (i_classMetadata == null || constraint.IsNullConstraint()) + { + return true; + } + ClassMetadata classMetadata = constraint.GetYapClass(); + if (classMetadata == null) + { + return false; + } + classMetadata = i_classMetadata.GetHigherOrCommonHierarchy(classMetadata); + if (classMetadata == null) + { + return false; + } + i_classMetadata = classMetadata; + return true; + } + + private bool IsClassOnlyQuery() + { + if (((List4)_constraints._next) != null) + { + return false; + } + if (!(_constraints._element is QConClass)) + { + return false; + } + return !((QCon)_constraints._element).HasChildren(); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/Processor/QConClass.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/Processor/QConClass.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/Processor/QConClass.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/Processor/QConClass.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,166 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System.Collections; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Query.Processor; +using Db4objects.Db4o.Query; +using Db4objects.Db4o.Reflect; + +namespace Db4objects.Db4o.Internal.Query.Processor +{ + /// Class constraint on queries + /// + public class QConClass : QConObject + { + [System.NonSerialized] + private IReflectClass _claxx; + + private string _className; + + private bool i_equal; + + public QConClass() + { + } + + internal QConClass(Transaction a_trans, QCon a_parent, QField a_field, IReflectClass + claxx) : base(a_trans, a_parent, a_field, null) + { + // C/S + if (claxx != null) + { + _classMetadata = a_trans.Container().ProduceClassMetadata(claxx); + if (claxx.Equals(a_trans.Container()._handlers.IclassObject)) + { + _classMetadata = (ClassMetadata)_classMetadata.TypeHandler(); + } + } + _claxx = claxx; + } + + internal QConClass(Transaction trans, IReflectClass claxx) : this(trans, null, null + , claxx) + { + } + + public virtual string GetClassName() + { + return _claxx == null ? null : _claxx.GetName(); + } + + public override bool CanBeIndexLeaf() + { + return false; + } + + internal override bool Evaluate(QCandidate a_candidate) + { + bool res = true; + IReflectClass claxx = a_candidate.ClassReflector(); + if (claxx == null) + { + res = false; + } + else + { + res = i_equal ? _claxx.Equals(claxx) : _claxx.IsAssignableFrom(claxx); + } + return i_evaluator.Not(res); + } + + internal override void EvaluateSelf() + { + // optimization for simple class queries: + // No instantiation of objects, if not necessary. + // Does not handle the special comparison of the + // Compare interface. + // + if (i_candidates.WasLoadedFromClassIndex()) + { + if (i_evaluator.IsDefault()) + { + if (!HasJoins()) + { + if (_classMetadata != null && i_candidates.i_classMetadata != null) + { + if (_classMetadata.GetHigherHierarchy(i_candidates.i_classMetadata) == _classMetadata) + { + return; + } + } + } + } + } + i_candidates.Filter(this); + } + + public override IConstraint Equal() + { + lock (StreamLock()) + { + i_equal = true; + return this; + } + } + + internal override bool IsNullConstraint() + { + return false; + } + + internal override string LogObject() + { + return string.Empty; + } + + internal override void Marshall() + { + base.Marshall(); + if (_claxx != null) + { + _className = Container().Config().ResolveAliasRuntimeName(_claxx.GetName()); + } + } + + public override string ToString() + { + string str = "QConClass "; + if (_claxx != null) + { + str += _claxx.GetName() + " "; + } + return str + base.ToString(); + } + + internal override void Unmarshall(Transaction a_trans) + { + if (i_trans == null) + { + base.Unmarshall(a_trans); + if (_className != null) + { + _className = Container().Config().ResolveAliasStoredName(_className); + _claxx = a_trans.Reflector().ForName(_className); + } + } + } + + internal override void SetEvaluationMode() + { + IEnumerator children = IterateChildren(); + while (children.MoveNext()) + { + object child = children.Current; + if (child is QConObject) + { + ((QConObject)child).SetEvaluationMode(); + } + } + } + + public override void SetProcessedByIndex() + { + } + // do nothing, QConClass needs to stay in the evaluation graph. + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/Processor/QCon.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/Processor/QCon.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/Processor/QCon.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/Processor/QCon.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,894 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using System.Collections; +using Db4objects.Db4o; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Query.Processor; +using Db4objects.Db4o.Query; +using Db4objects.Db4o.Reflect; +using Db4objects.Db4o.Types; + +namespace Db4objects.Db4o.Internal.Query.Processor +{ + /// Base class for all constraints on queries. + /// Base class for all constraints on queries. + /// + public abstract class QCon : IConstraint, IVisitor4, IUnversioned + { + internal static readonly IDGenerator idGenerator = new IDGenerator(); + + [System.NonSerialized] + internal QCandidates i_candidates; + + private Collection4 i_childrenCandidates; + + protected List4 _children; + + protected QE i_evaluator = QE.Default; + + private int i_id; + + internal Collection4 i_joins; + + protected Db4objects.Db4o.Internal.Query.Processor.QCon i_parent; + + private bool i_removed = false; + + [System.NonSerialized] + internal Db4objects.Db4o.Internal.Transaction i_trans; + + [System.NonSerialized] + private bool _processedByIndex; + + public QCon() + { + } + + internal QCon(Db4objects.Db4o.Internal.Transaction a_trans) + { + //Used for query debug only. + // our candidate object tree + // collection of QCandidates to collect children elements and to + // execute children. For convenience we hold them in the constraint, + // so we can do collection and execution in two steps + // all subconstraints + // for evaluation + // ID handling for fast find of QConstraint objects in + // pending OR evaluations + // ANDs and ORs on this constraint + // the parent of this constraint or null, if this is a root + // prevents circular calls on removal + // our transaction to get a stream object anywhere + // whether or not this constraint was used to get the initial set + // in the FieldIndexProcessor + // C/S only + i_id = idGenerator.Next(); + i_trans = a_trans; + } + + internal virtual Db4objects.Db4o.Internal.Query.Processor.QCon AddConstraint(Db4objects.Db4o.Internal.Query.Processor.QCon + a_child) + { + _children = new List4(_children, a_child); + return a_child; + } + + public virtual ObjectContainerBase Container() + { + return Transaction().Container(); + } + + public virtual Db4objects.Db4o.Internal.Transaction Transaction() + { + return i_trans; + } + + internal virtual void AddJoin(QConJoin a_join) + { + if (i_joins == null) + { + i_joins = new Collection4(); + } + i_joins.Add(a_join); + } + + internal virtual Db4objects.Db4o.Internal.Query.Processor.QCon AddSharedConstraint + (QField a_field, object a_object) + { + QConObject newConstraint = new QConObject(i_trans, this, a_field, a_object); + AddConstraint(newConstraint); + return newConstraint; + } + + public virtual IConstraint And(IConstraint andWith) + { + lock (StreamLock()) + { + return Join(andWith, true); + } + } + + internal virtual bool Attach(QQuery query, string a_field) + { + Db4objects.Db4o.Internal.Query.Processor.QCon qcon = this; + ClassMetadata yc = GetYapClass(); + bool[] foundField = new bool[] { false }; + ForEachChildField(a_field, new _IVisitor4_104(foundField, query)); + if (foundField[0]) + { + return true; + } + QField qf = null; + if (yc == null || yc.HoldsAnyClass()) + { + int[] count = new int[] { 0 }; + FieldMetadata[] yfs = new FieldMetadata[] { null }; + i_trans.Container().ClassCollection().AttachQueryNode(a_field, new _IVisitor4_122 + (yfs, count)); + if (count[0] == 0) + { + return false; + } + if (count[0] == 1) + { + qf = yfs[0].QField(i_trans); + } + else + { + qf = new QField(i_trans, a_field, null, 0, 0); + } + } + else + { + if (yc.IsTranslated()) + { + i_trans.Container()._handlers.DiagnosticProcessor().DescendIntoTranslator(yc, a_field + ); + } + FieldMetadata yf = yc.FieldMetadataForName(a_field); + if (yf != null) + { + qf = yf.QField(i_trans); + } + if (qf == null) + { + qf = new QField(i_trans, a_field, null, 0, 0); + } + } + QConPath qcp = new QConPath(i_trans, qcon, qf); + query.AddConstraint(qcp); + qcon.AddConstraint(qcp); + return true; + } + + private sealed class _IVisitor4_104 : IVisitor4 + { + public _IVisitor4_104(bool[] foundField, QQuery query) + { + this.foundField = foundField; + this.query = query; + } + + public void Visit(object obj) + { + foundField[0] = true; + query.AddConstraint((Db4objects.Db4o.Internal.Query.Processor.QCon)obj); + } + + private readonly bool[] foundField; + + private readonly QQuery query; + } + + private sealed class _IVisitor4_122 : IVisitor4 + { + public _IVisitor4_122(FieldMetadata[] yfs, int[] count) + { + this.yfs = yfs; + this.count = count; + } + + public void Visit(object obj) + { + yfs[0] = (FieldMetadata)((object[])obj)[1]; + count[0]++; + } + + private readonly FieldMetadata[] yfs; + + private readonly int[] count; + } + + public virtual bool CanBeIndexLeaf() + { + return false; + } + + public virtual bool CanLoadByIndex() + { + // virtual + return false; + } + + internal virtual void CheckLastJoinRemoved() + { + if (i_joins.Size() == 0) + { + i_joins = null; + } + } + + /// + internal virtual void Collect(QCandidates candidates) + { + } + + // virtual + public virtual IConstraint Contains() + { + throw NotSupported(); + } + + internal virtual void CreateCandidates(Collection4 a_candidateCollection) + { + IEnumerator j = a_candidateCollection.GetEnumerator(); + while (j.MoveNext()) + { + QCandidates candidates = (QCandidates)j.Current; + if (candidates.TryAddConstraint(this)) + { + i_candidates = candidates; + return; + } + } + i_candidates = new QCandidates((LocalTransaction)i_trans, GetYapClass(), GetField + ()); + i_candidates.AddConstraint(this); + a_candidateCollection.Add(i_candidates); + } + + internal virtual void DoNotInclude(QCandidate a_root) + { + if (DTrace.enabled) + { + DTrace.Donotinclude.Log(Id()); + } + if (i_parent != null) + { + i_parent.Visit1(a_root, this, false); + } + else + { + a_root.DoNotInclude(); + } + } + + public virtual IConstraint Equal() + { + throw NotSupported(); + } + + /// + internal virtual bool Evaluate(QCandidate candidate) + { + throw Exceptions4.VirtualException(); + } + + internal virtual void EvaluateChildren() + { + IEnumerator i = i_childrenCandidates.GetEnumerator(); + while (i.MoveNext()) + { + ((QCandidates)i.Current).Evaluate(); + } + } + + internal virtual void EvaluateCollectChildren() + { + if (DTrace.enabled) + { + DTrace.CollectChildren.Log(Id()); + } + IEnumerator i = i_childrenCandidates.GetEnumerator(); + while (i.MoveNext()) + { + ((QCandidates)i.Current).Collect(i_candidates); + } + } + + internal virtual void EvaluateCreateChildrenCandidates() + { + i_childrenCandidates = new Collection4(); + IEnumerator i = IterateChildren(); + while (i.MoveNext()) + { + ((Db4objects.Db4o.Internal.Query.Processor.QCon)i.Current).CreateCandidates(i_childrenCandidates + ); + } + } + + internal virtual void EvaluateEvaluations() + { + IEnumerator i = IterateChildren(); + while (i.MoveNext()) + { + ((Db4objects.Db4o.Internal.Query.Processor.QCon)i.Current).EvaluateEvaluationsExec + (i_candidates, true); + } + } + + /// + /// + internal virtual void EvaluateEvaluationsExec(QCandidates candidates, bool rereadObject + ) + { + } + + // virtual + internal virtual void EvaluateSelf() + { + i_candidates.Filter(this); + } + + internal virtual void EvaluateSimpleChildren() + { + // TODO: sort the constraints for YapFields first, + // so we stay with the same YapField + if (_children == null) + { + return; + } + IEnumerator i = IterateChildren(); + while (i.MoveNext()) + { + Db4objects.Db4o.Internal.Query.Processor.QCon qcon = (Db4objects.Db4o.Internal.Query.Processor.QCon + )i.Current; + i_candidates.SetCurrentConstraint(qcon); + qcon.SetCandidates(i_candidates); + qcon.EvaluateSimpleExec(i_candidates); + } + i_candidates.SetCurrentConstraint(null); + } + + /// + internal virtual void EvaluateSimpleExec(QCandidates candidates) + { + } + + // virtual + internal virtual void ExchangeConstraint(Db4objects.Db4o.Internal.Query.Processor.QCon + a_exchange, Db4objects.Db4o.Internal.Query.Processor.QCon a_with) + { + List4 previous = null; + List4 current = _children; + while (current != null) + { + if (current._element == a_exchange) + { + if (previous == null) + { + _children = ((List4)current._next); + } + else + { + previous._next = ((List4)current._next); + } + } + previous = current; + current = ((List4)current._next); + } + _children = new List4(_children, a_with); + } + + internal virtual void ForEachChildField(string name, IVisitor4 visitor) + { + IEnumerator i = IterateChildren(); + while (i.MoveNext()) + { + object obj = i.Current; + if (obj is QConObject) + { + if (((QConObject)obj).GetField().Name().Equals(name)) + { + visitor.Visit(obj); + } + } + } + } + + public virtual QField GetField() + { + return null; + } + + public virtual object GetObject() + { + throw NotSupported(); + } + + internal virtual Db4objects.Db4o.Internal.Query.Processor.QCon GetRoot() + { + if (i_parent != null) + { + return i_parent.GetRoot(); + } + return this; + } + + internal virtual Db4objects.Db4o.Internal.Query.Processor.QCon ProduceTopLevelJoin + () + { + if (!HasJoins()) + { + return this; + } + IEnumerator i = IterateJoins(); + if (i_joins.Size() == 1) + { + i.MoveNext(); + return ((Db4objects.Db4o.Internal.Query.Processor.QCon)i.Current).ProduceTopLevelJoin + (); + } + Collection4 col = new Collection4(); + while (i.MoveNext()) + { + col.Ensure(((Db4objects.Db4o.Internal.Query.Processor.QCon)i.Current).ProduceTopLevelJoin + ()); + } + i = col.GetEnumerator(); + i.MoveNext(); + Db4objects.Db4o.Internal.Query.Processor.QCon qcon = (Db4objects.Db4o.Internal.Query.Processor.QCon + )i.Current; + if (col.Size() == 1) + { + return qcon; + } + while (i.MoveNext()) + { + qcon = (Db4objects.Db4o.Internal.Query.Processor.QCon)qcon.And((IConstraint)i.Current + ); + } + return qcon; + } + + internal virtual ClassMetadata GetYapClass() + { + return null; + } + + public virtual IConstraint Greater() + { + throw NotSupported(); + } + + public virtual bool HasChildren() + { + return _children != null; + } + + public virtual bool HasParent() + { + return i_parent != null; + } + + public virtual Db4objects.Db4o.Internal.Query.Processor.QCon Parent() + { + return i_parent; + } + + public virtual bool HasJoins() + { + if (i_joins == null) + { + return false; + } + return i_joins.Size() > 0; + } + + public virtual bool HasObjectInParentPath(object obj) + { + if (i_parent != null) + { + return i_parent.HasObjectInParentPath(obj); + } + return false; + } + + public virtual IConstraint Identity() + { + throw NotSupported(); + } + + public virtual IConstraint ByExample() + { + throw NotSupported(); + } + + public virtual int IdentityID() + { + return 0; + } + + internal virtual bool IsNot() + { + return i_evaluator is QENot; + } + + internal virtual bool IsNullConstraint() + { + return false; + } + + public virtual IEnumerator IterateJoins() + { + if (i_joins == null) + { + return Iterators.EmptyIterator; + } + return i_joins.GetEnumerator(); + } + + public virtual IEnumerator IterateChildren() + { + if (_children == null) + { + return Iterators.EmptyIterator; + } + return new Iterator4Impl(_children); + } + + internal virtual IConstraint Join(IConstraint a_with, bool a_and) + { + if (!(a_with is Db4objects.Db4o.Internal.Query.Processor.QCon)) + { + // TODO: one of our STOr test cases somehow carries + // the same constraint twice. This may be a result + // of a funny AND. Check! + return null; + } + if (a_with == this) + { + return this; + } + return Join1((Db4objects.Db4o.Internal.Query.Processor.QCon)a_with, a_and); + } + + internal virtual IConstraint Join1(Db4objects.Db4o.Internal.Query.Processor.QCon + a_with, bool a_and) + { + if (a_with is QConstraints) + { + int j = 0; + Collection4 joinHooks = new Collection4(); + IConstraint[] constraints = ((QConstraints)a_with).ToArray(); + for (j = 0; j < constraints.Length; j++) + { + joinHooks.Ensure(((Db4objects.Db4o.Internal.Query.Processor.QCon)constraints[j]). + JoinHook()); + } + IConstraint[] joins = new IConstraint[joinHooks.Size()]; + j = 0; + IEnumerator i = joinHooks.GetEnumerator(); + while (i.MoveNext()) + { + joins[j++] = Join((IConstraint)i.Current, a_and); + } + return new QConstraints(i_trans, joins); + } + Db4objects.Db4o.Internal.Query.Processor.QCon myHook = JoinHook(); + Db4objects.Db4o.Internal.Query.Processor.QCon otherHook = a_with.JoinHook(); + if (myHook == otherHook) + { + // You might like to check out, what happens, if you + // remove this line. It seems to open a bug in an + // StOr testcase. + return myHook; + } + QConJoin cj = new QConJoin(i_trans, myHook, otherHook, a_and); + myHook.AddJoin(cj); + otherHook.AddJoin(cj); + return cj; + } + + internal virtual Db4objects.Db4o.Internal.Query.Processor.QCon JoinHook() + { + return ProduceTopLevelJoin(); + } + + public virtual IConstraint Like() + { + throw NotSupported(); + } + + public virtual IConstraint StartsWith(bool caseSensitive) + { + throw NotSupported(); + } + + public virtual IConstraint EndsWith(bool caseSensitive) + { + throw NotSupported(); + } + + internal virtual void Log(string indent) + { + } + + // System.out.println(indent + "JOINS"); + // joins += join.i_id + " "; + // System.out.println(joins); + // System.out.println(indent + getClass().getName() + " " + i_id + " " + i_debugField + " " + joins ); + // System.out.println(indent + "CONSTRAINTS"); + internal virtual string LogObject() + { + return string.Empty; + } + + internal virtual void Marshall() + { + IEnumerator i = IterateChildren(); + while (i.MoveNext()) + { + ((Db4objects.Db4o.Internal.Query.Processor.QCon)i.Current).Marshall(); + } + } + + public virtual IConstraint Not() + { + lock (StreamLock()) + { + if (!(i_evaluator is QENot)) + { + i_evaluator = new QENot(i_evaluator); + } + return this; + } + } + + private Exception NotSupported() + { + return new Exception("Not supported."); + } + + /// + public virtual bool OnSameFieldAs(Db4objects.Db4o.Internal.Query.Processor.QCon other + ) + { + return false; + } + + public virtual IConstraint Or(IConstraint orWith) + { + lock (StreamLock()) + { + return Join(orWith, false); + } + } + + internal virtual bool Remove() + { + if (!i_removed) + { + i_removed = true; + RemoveChildrenJoins(); + return true; + } + return false; + } + + internal virtual void RemoveChildrenJoins() + { + if (!HasJoins()) + { + return; + } + Collection4 toBeRemoved = CollectJoinsToBeRemoved(); + i_joins.RemoveAll(toBeRemoved); + CheckLastJoinRemoved(); + } + + private Collection4 CollectJoinsToBeRemoved() + { + Collection4 toBeRemoved = new Collection4(); + IEnumerator joinIter = IterateJoins(); + while (joinIter.MoveNext()) + { + QConJoin join = (QConJoin)joinIter.Current; + if (join.RemoveForParent(this)) + { + toBeRemoved.Add(join); + } + } + return toBeRemoved; + } + + internal virtual void RemoveJoin(QConJoin a_join) + { + i_joins.Remove(a_join); + CheckLastJoinRemoved(); + } + + internal virtual void RemoveNot() + { + if (IsNot()) + { + i_evaluator = ((QENot)i_evaluator).Evaluator(); + } + } + + public virtual void SetCandidates(QCandidates a_candidates) + { + i_candidates = a_candidates; + } + + internal virtual void SetParent(Db4objects.Db4o.Internal.Query.Processor.QCon a_newParent + ) + { + i_parent = a_newParent; + } + + /// + /// + internal virtual Db4objects.Db4o.Internal.Query.Processor.QCon ShareParent(object + obj, BooleanByRef removeExisting) + { + // virtual + return null; + } + + /// + /// + internal virtual QConClass ShareParentForClass(IReflectClass claxx, BooleanByRef + removeExisting) + { + // virtual + return null; + } + + public virtual IConstraint Smaller() + { + throw NotSupported(); + } + + protected virtual object StreamLock() + { + return i_trans.Container().Lock(); + } + + internal virtual void Unmarshall(Db4objects.Db4o.Internal.Transaction a_trans) + { + if (i_trans != null) + { + return; + } + i_trans = a_trans; + UnmarshallParent(a_trans); + UnmarshallJoins(a_trans); + UnmarshallChildren(a_trans); + } + + private void UnmarshallParent(Db4objects.Db4o.Internal.Transaction a_trans) + { + if (i_parent != null) + { + i_parent.Unmarshall(a_trans); + } + } + + private void UnmarshallChildren(Db4objects.Db4o.Internal.Transaction a_trans) + { + IEnumerator i = IterateChildren(); + while (i.MoveNext()) + { + ((Db4objects.Db4o.Internal.Query.Processor.QCon)i.Current).Unmarshall(a_trans); + } + } + + private void UnmarshallJoins(Db4objects.Db4o.Internal.Transaction a_trans) + { + if (HasJoins()) + { + IEnumerator i = IterateJoins(); + while (i.MoveNext()) + { + ((Db4objects.Db4o.Internal.Query.Processor.QCon)i.Current).Unmarshall(a_trans); + } + } + } + + public virtual void Visit(object obj) + { + QCandidate qc = (QCandidate)obj; + Visit1(qc.GetRoot(), this, Evaluate(qc)); + } + + internal virtual void Visit(QCandidate a_root, bool res) + { + Visit1(a_root, this, i_evaluator.Not(res)); + } + + internal virtual void Visit1(QCandidate root, Db4objects.Db4o.Internal.Query.Processor.QCon + reason, bool res) + { + // The a_reason parameter makes it eays to distinguish + // between calls from above (a_reason == this) and below. + if (HasJoins()) + { + // this should probably be on the Join + IEnumerator i = IterateJoins(); + while (i.MoveNext()) + { + root.Evaluate(new QPending((QConJoin)i.Current, this, res)); + } + } + else + { + if (!res) + { + DoNotInclude(root); + } + } + } + + internal void VisitOnNull(QCandidate a_root) + { + // TODO: It may be more efficient to rule out + // all possible keepOnNull issues when starting + // evaluation. + IEnumerator i = IterateChildren(); + while (i.MoveNext()) + { + ((Db4objects.Db4o.Internal.Query.Processor.QCon)i.Current).VisitOnNull(a_root); + } + if (VisitSelfOnNull()) + { + Visit(a_root, IsNullConstraint()); + } + } + + internal virtual bool VisitSelfOnNull() + { + return true; + } + + public virtual QE Evaluator() + { + return i_evaluator; + } + + public virtual void SetProcessedByIndex() + { + InternalSetProcessedByIndex(); + } + + protected virtual void InternalSetProcessedByIndex() + { + _processedByIndex = true; + if (i_joins != null) + { + IEnumerator i = i_joins.GetEnumerator(); + while (i.MoveNext()) + { + ((QConJoin)i.Current).SetProcessedByIndex(); + } + } + } + + public virtual bool ProcessedByIndex() + { + return _processedByIndex; + } + + public virtual int ChildrenCount() + { + return List4.Size(_children); + } + + public virtual int Id() + { + return i_id; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/Processor/QConEvaluation.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/Processor/QConEvaluation.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/Processor/QConEvaluation.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/Processor/QConEvaluation.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,128 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Query.Processor; + +namespace Db4objects.Db4o.Internal.Query.Processor +{ + /// + public class QConEvaluation : QCon + { + [System.NonSerialized] + private object i_evaluation; + + private byte[] i_marshalledEvaluation; + + private int i_marshalledID; + + public QConEvaluation() + { + } + + public QConEvaluation(Transaction a_trans, object a_evaluation) : base(a_trans) + { + // C/S only + i_evaluation = a_evaluation; + } + + internal override void EvaluateEvaluationsExec(QCandidates a_candidates, bool rereadObject + ) + { + if (rereadObject) + { + a_candidates.Traverse(new _IVisitor4_31()); + } + a_candidates.Filter(this); + } + + private sealed class _IVisitor4_31 : IVisitor4 + { + public _IVisitor4_31() + { + } + + public void Visit(object a_object) + { + ((QCandidate)a_object).UseField(null); + } + } + + internal override void Marshall() + { + base.Marshall(); + if (!Platform4.UseNativeSerialization()) + { + MarshallUsingDb4oFormat(); + } + else + { + try + { + i_marshalledEvaluation = Platform4.Serialize(i_evaluation); + } + catch (Exception) + { + MarshallUsingDb4oFormat(); + } + } + } + + private void MarshallUsingDb4oFormat() + { + SerializedGraph serialized = Serializer.Marshall(Container(), i_evaluation); + i_marshalledEvaluation = serialized._bytes; + i_marshalledID = serialized._id; + } + + internal override void Unmarshall(Transaction a_trans) + { + if (i_trans == null) + { + base.Unmarshall(a_trans); + if (i_marshalledID > 0 || !Platform4.UseNativeSerialization()) + { + i_evaluation = Serializer.Unmarshall(Container(), i_marshalledEvaluation, i_marshalledID + ); + } + else + { + i_evaluation = Platform4.Deserialize(i_marshalledEvaluation); + } + } + } + + public override void Visit(object obj) + { + QCandidate candidate = (QCandidate)obj; + // force activation outside the try block + // so any activation errors bubble up + ForceActivation(candidate); + try + { + Platform4.EvaluationEvaluate(i_evaluation, candidate); + } + catch (Exception) + { + candidate.Include(false); + } + // TODO: implement Exception callback for the user coder + // at least for test cases + if (!candidate._include) + { + DoNotInclude(candidate.GetRoot()); + } + } + + private void ForceActivation(QCandidate candidate) + { + candidate.GetObject(); + } + + internal virtual bool SupportsIndex() + { + return false; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/Processor/QConJoin.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/Processor/QConJoin.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/Processor/QConJoin.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/Processor/QConJoin.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,152 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using System.Collections; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Query.Processor; + +namespace Db4objects.Db4o.Internal.Query.Processor +{ + /// Join constraint on queries + /// + public class QConJoin : QCon + { + private bool i_and; + + private QCon i_constraint1; + + private QCon i_constraint2; + + public QConJoin() + { + } + + internal QConJoin(Transaction a_trans, QCon a_c1, QCon a_c2, bool a_and) : base(a_trans + ) + { + // FIELDS MUST BE PUBLIC TO BE REFLECTED ON UNDER JDK <= 1.1 + // C/S + i_constraint1 = a_c1; + i_constraint2 = a_c2; + i_and = a_and; + } + + public virtual QCon Constraint2() + { + return i_constraint2; + } + + public virtual QCon Constraint1() + { + return i_constraint1; + } + + internal override void DoNotInclude(QCandidate a_root) + { + Constraint1().DoNotInclude(a_root); + Constraint2().DoNotInclude(a_root); + } + + internal override void ExchangeConstraint(QCon a_exchange, QCon a_with) + { + base.ExchangeConstraint(a_exchange, a_with); + if (a_exchange == Constraint1()) + { + i_constraint1 = a_with; + } + if (a_exchange == Constraint2()) + { + i_constraint2 = a_with; + } + } + + internal virtual void EvaluatePending(QCandidate a_root, QPending a_pending, int + a_secondResult) + { + bool res = i_evaluator.Not(i_and ? ((a_pending._result + a_secondResult) > 0) : ( + a_pending._result + a_secondResult) > QPending.False); + if (HasJoins()) + { + IEnumerator i = IterateJoins(); + while (i.MoveNext()) + { + Db4objects.Db4o.Internal.Query.Processor.QConJoin qcj = (Db4objects.Db4o.Internal.Query.Processor.QConJoin + )i.Current; + a_root.Evaluate(new QPending(qcj, this, res)); + } + } + else + { + if (!res) + { + Constraint1().DoNotInclude(a_root); + Constraint2().DoNotInclude(a_root); + } + } + } + + public virtual QCon GetOtherConstraint(QCon a_constraint) + { + if (a_constraint == Constraint1()) + { + return Constraint2(); + } + else + { + if (a_constraint == Constraint2()) + { + return Constraint1(); + } + } + throw new ArgumentException(); + } + + internal override string LogObject() + { + return string.Empty; + } + + internal virtual bool RemoveForParent(QCon a_constraint) + { + if (i_and) + { + QCon other = GetOtherConstraint(a_constraint); + other.RemoveJoin(this); + // prevents circular call + other.Remove(); + return true; + } + return false; + } + + public override string ToString() + { + string str = "QConJoin " + (i_and ? "AND " : "OR"); + if (Constraint1() != null) + { + str += "\n " + Constraint1(); + } + if (Constraint2() != null) + { + str += "\n " + Constraint2(); + } + return str; + } + + public virtual bool IsOr() + { + return !i_and; + } + + public override void SetProcessedByIndex() + { + if (ProcessedByIndex()) + { + return; + } + base.SetProcessedByIndex(); + Constraint1().SetProcessedByIndex(); + Constraint2().SetProcessedByIndex(); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/Processor/QConObject.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/Processor/QConObject.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/Processor/QConObject.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/Processor/QConObject.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,561 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using System.Collections; +using Db4objects.Db4o; +using Db4objects.Db4o.Config; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Handlers; +using Db4objects.Db4o.Internal.Query.Processor; +using Db4objects.Db4o.Marshall; +using Db4objects.Db4o.Query; +using Db4objects.Db4o.Reflect; + +namespace Db4objects.Db4o.Internal.Query.Processor +{ + /// Object constraint on queries + /// + public class QConObject : QCon + { + private object i_object; + + private int i_objectID; + + [System.NonSerialized] + internal ClassMetadata _classMetadata; + + private int i_classMetadataID; + + private QField i_field; + + [System.NonSerialized] + internal IPreparedComparison _preparedComparison; + + private IObjectAttribute i_attributeProvider; + + [System.NonSerialized] + private bool _checkClassMetadataOnly = false; + + public QConObject() + { + } + + public QConObject(Transaction a_trans, QCon a_parent, QField a_field, object a_object + ) : base(a_trans) + { + // the constraining object + // cache for the db4o object ID + // the YapClass + // needed for marshalling the request + // C/S only + i_parent = a_parent; + if (a_object is ICompare) + { + a_object = ((ICompare)a_object).Compare(); + } + i_object = a_object; + i_field = a_field; + } + + private void AssociateYapClass(Transaction a_trans, object a_object) + { + if (a_object == null) + { + } + else + { + //It seems that we need not result the following field + //i_object = null; + //i_comparator = Null.INSTANCE; + //i_classMetadata = null; + // FIXME: Setting the YapClass to null will prevent index use + // If the field is typed we can guess the right one with the + // following line. However this does break some SODA test cases. + // Revisit! + // if(i_field != null){ + // i_classMetadata = i_field.getYapClass(); + // } + _classMetadata = a_trans.Container().ProduceClassMetadata(a_trans.Reflector().ForObject + (a_object)); + if (_classMetadata != null) + { + i_object = _classMetadata.GetComparableObject(a_object); + if (a_object != i_object) + { + i_attributeProvider = _classMetadata.Config().QueryAttributeProvider(); + _classMetadata = a_trans.Container().ProduceClassMetadata(a_trans.Reflector().ForObject + (i_object)); + } + if (_classMetadata != null) + { + _classMetadata.CollectConstraints(a_trans, this, i_object, new _IVisitor4_84(this + )); + } + else + { + AssociateYapClass(a_trans, null); + } + } + else + { + AssociateYapClass(a_trans, null); + } + } + } + + private sealed class _IVisitor4_84 : IVisitor4 + { + public _IVisitor4_84(QConObject _enclosing) + { + this._enclosing = _enclosing; + } + + public void Visit(object obj) + { + this._enclosing.AddConstraint((QCon)obj); + } + + private readonly QConObject _enclosing; + } + + public override bool CanBeIndexLeaf() + { + return i_object == null || ((_classMetadata != null && _classMetadata.IsValueType + ()) || Evaluator().Identity()); + } + + public override bool CanLoadByIndex() + { + if (i_field == null) + { + return false; + } + if (i_field._fieldMetadata == null) + { + return false; + } + if (!i_field._fieldMetadata.HasIndex()) + { + return false; + } + if (!i_evaluator.SupportsIndex()) + { + return false; + } + return i_field._fieldMetadata.CanLoadByIndex(); + } + + internal override bool Evaluate(QCandidate a_candidate) + { + try + { + return a_candidate.Evaluate(this, i_evaluator); + } + catch (Exception e) + { + return false; + } + } + + internal override void EvaluateEvaluationsExec(QCandidates a_candidates, bool rereadObject + ) + { + if (i_field.IsQueryLeaf()) + { + bool hasEvaluation = false; + IEnumerator i = IterateChildren(); + while (i.MoveNext()) + { + if (i.Current is QConEvaluation) + { + hasEvaluation = true; + break; + } + } + if (hasEvaluation) + { + a_candidates.Traverse(i_field); + IEnumerator j = IterateChildren(); + while (j.MoveNext()) + { + ((QCon)j.Current).EvaluateEvaluationsExec(a_candidates, false); + } + } + } + } + + internal override void EvaluateSelf() + { + if (DTrace.enabled) + { + DTrace.EvaluateSelf.Log(Id()); + } + if (_classMetadata != null) + { + if (!(_classMetadata is PrimitiveTypeMetadata)) + { + if (!i_evaluator.Identity() && (_classMetadata.TypeHandler() is StandardReferenceTypeHandler + )) + { + _checkClassMetadataOnly = true; + } + object transactionalObject = _classMetadata.WrapWithTransactionContext(Transaction + (), i_object); + _preparedComparison = _classMetadata.PrepareComparison(Context(), transactionalObject + ); + } + } + base.EvaluateSelf(); + _checkClassMetadataOnly = false; + } + + private IContext Context() + { + return Transaction().Context(); + } + + internal override void Collect(QCandidates a_candidates) + { + if (i_field.IsClass()) + { + a_candidates.Traverse(i_field); + a_candidates.Filter(i_candidates); + } + } + + internal override void EvaluateSimpleExec(QCandidates a_candidates) + { + // TODO: The following can be skipped if we used the index on + // this field to load the objects, if hasOrdering() is false + if (i_field.IsQueryLeaf() || IsNullConstraint()) + { + a_candidates.Traverse(i_field); + PrepareComparison(i_field); + a_candidates.Filter(this); + } + } + + internal virtual IPreparedComparison PrepareComparison(QCandidate candidate) + { + if (_preparedComparison != null) + { + return _preparedComparison; + } + return candidate.PrepareComparison(Container(), i_object); + } + + internal override ClassMetadata GetYapClass() + { + return _classMetadata; + } + + public override QField GetField() + { + return i_field; + } + + internal virtual int GetObjectID() + { + if (i_objectID == 0) + { + i_objectID = i_trans.Container().GetID(i_trans, i_object); + if (i_objectID == 0) + { + i_objectID = -1; + } + } + return i_objectID; + } + + public override bool HasObjectInParentPath(object obj) + { + if (obj == i_object) + { + return true; + } + return base.HasObjectInParentPath(obj); + } + + public override int IdentityID() + { + if (i_evaluator.Identity()) + { + int id = GetObjectID(); + if (id != 0) + { + if (!(i_evaluator is QENot)) + { + return id; + } + } + } + return 0; + } + + internal override bool IsNullConstraint() + { + return i_object == null; + } + + internal override void Log(string indent) + { + } + + internal override string LogObject() + { + return string.Empty; + } + + internal override void Marshall() + { + base.Marshall(); + GetObjectID(); + if (_classMetadata != null) + { + i_classMetadataID = _classMetadata.GetID(); + } + } + + public override bool OnSameFieldAs(QCon other) + { + if (!(other is Db4objects.Db4o.Internal.Query.Processor.QConObject)) + { + return false; + } + return i_field == ((Db4objects.Db4o.Internal.Query.Processor.QConObject)other).i_field; + } + + internal virtual void PrepareComparison(QField a_field) + { + if (IsNullConstraint() & !a_field.IsArray()) + { + _preparedComparison = Null.Instance; + } + else + { + _preparedComparison = a_field.PrepareComparison(Context(), i_object); + } + } + + internal override void RemoveChildrenJoins() + { + base.RemoveChildrenJoins(); + _children = null; + } + + internal override QCon ShareParent(object a_object, BooleanByRef removeExisting) + { + if (i_parent == null) + { + return null; + } + object obj = i_field.Coerce(a_object); + if (obj == No4.Instance) + { + return null; + } + return i_parent.AddSharedConstraint(i_field, obj); + } + + internal override QConClass ShareParentForClass(IReflectClass a_class, BooleanByRef + removeExisting) + { + if (i_parent == null) + { + return null; + } + QConClass newConstraint = new QConClass(i_trans, i_parent, i_field, a_class); + i_parent.AddConstraint(newConstraint); + return newConstraint; + } + + internal object Translate(object candidate) + { + if (i_attributeProvider != null) + { + i_candidates.i_trans.Container().Activate(i_candidates.i_trans, candidate); + return i_attributeProvider.Attribute(candidate); + } + return candidate; + } + + internal override void Unmarshall(Transaction trans) + { + if (i_trans != null) + { + return; + } + base.Unmarshall(trans); + if (i_object == null) + { + _preparedComparison = Null.Instance; + } + if (i_classMetadataID != 0) + { + _classMetadata = trans.Container().ClassMetadataForID(i_classMetadataID); + } + if (i_field != null) + { + i_field.Unmarshall(trans); + } + if (i_objectID > 0) + { + object obj = trans.Container().TryGetByID(trans, i_objectID); + if (obj != null) + { + i_object = obj; + } + } + } + + public override void Visit(object obj) + { + QCandidate qc = (QCandidate)obj; + bool res = true; + bool processed = false; + if (_checkClassMetadataOnly) + { + ClassMetadata yc = qc.ReadClassMetadata(); + if (yc != null) + { + res = i_evaluator.Not(_classMetadata.GetHigherHierarchy(yc) == _classMetadata); + processed = true; + } + } + if (!processed) + { + res = Evaluate(qc); + } + Visit1(qc.GetRoot(), this, res); + } + + public override IConstraint Contains() + { + lock (StreamLock()) + { + i_evaluator = i_evaluator.Add(new QEContains(true)); + return this; + } + } + + public override IConstraint Equal() + { + lock (StreamLock()) + { + i_evaluator = i_evaluator.Add(new QEEqual()); + return this; + } + } + + public override object GetObject() + { + return i_object; + } + + public override IConstraint Greater() + { + lock (StreamLock()) + { + i_evaluator = i_evaluator.Add(new QEGreater()); + return this; + } + } + + public override IConstraint Identity() + { + lock (StreamLock()) + { + if (i_object == null) + { + return this; + } + GetObjectID(); + // TODO: this may not be correct for NOT + // It may be necessary to add an if(i_evaluator.identity()) + RemoveChildrenJoins(); + i_evaluator = i_evaluator.Add(new QEIdentity()); + return this; + } + } + + public override IConstraint ByExample() + { + lock (StreamLock()) + { + AssociateYapClass(i_trans, i_object); + return this; + } + } + + internal virtual void SetEvaluationMode() + { + if ((i_object == null) || EvaluationModeAlreadySet()) + { + return; + } + int id = GetObjectID(); + if (id < 0) + { + ByExample(); + } + else + { + _classMetadata = i_trans.Container().ProduceClassMetadata(i_trans.Reflector().ForObject + (i_object)); + Identity(); + } + } + + internal virtual bool EvaluationModeAlreadySet() + { + return _classMetadata != null; + } + + public override IConstraint Like() + { + lock (StreamLock()) + { + i_evaluator = i_evaluator.Add(new QEContains(false)); + return this; + } + } + + public override IConstraint Smaller() + { + lock (StreamLock()) + { + i_evaluator = i_evaluator.Add(new QESmaller()); + return this; + } + } + + public override IConstraint StartsWith(bool caseSensitive) + { + lock (StreamLock()) + { + i_evaluator = i_evaluator.Add(new QEStartsWith(caseSensitive)); + return this; + } + } + + public override IConstraint EndsWith(bool caseSensitive) + { + lock (StreamLock()) + { + i_evaluator = i_evaluator.Add(new QEEndsWith(caseSensitive)); + return this; + } + } + + public override string ToString() + { + string str = "QConObject "; + if (i_object != null) + { + str += i_object.ToString(); + } + return str; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/Processor/QConPath.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/Processor/QConPath.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/Processor/QConPath.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/Processor/QConPath.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,166 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System.Collections; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Query.Processor; +using Db4objects.Db4o.Reflect; + +namespace Db4objects.Db4o.Internal.Query.Processor +{ + /// + /// Placeholder for a constraint, only necessary to attach children + /// to the query graph. + /// + /// + /// Placeholder for a constraint, only necessary to attach children + /// to the query graph. + /// Added upon a call to Query#descend(), if there is no + /// other place to hook up a new constraint. + /// + /// + public class QConPath : QConClass + { + public QConPath() + { + } + + internal QConPath(Transaction a_trans, QCon a_parent, QField a_field) : base(a_trans + , a_parent, a_field, null) + { + if (a_field != null) + { + _classMetadata = a_field.GetFieldType(); + } + } + + public override bool CanLoadByIndex() + { + return false; + } + + internal override bool Evaluate(QCandidate a_candidate) + { + if (!a_candidate.FieldIsAvailable()) + { + VisitOnNull(a_candidate.GetRoot()); + } + return true; + } + + internal override void EvaluateSelf() + { + } + + // do nothing + internal override bool IsNullConstraint() + { + return !HasChildren(); + } + + internal override QConClass ShareParentForClass(IReflectClass a_class, BooleanByRef + removeExisting) + { + if (i_parent == null) + { + return null; + } + QConClass newConstraint = new QConClass(i_trans, i_parent, GetField(), a_class); + Morph(removeExisting, newConstraint, a_class); + return newConstraint; + } + + internal override QCon ShareParent(object a_object, BooleanByRef removeExisting) + { + if (i_parent == null) + { + return null; + } + object obj = GetField().Coerce(a_object); + if (obj == No4.Instance) + { + QCon falseConstraint = new QConUnconditional(i_trans, false); + Morph(removeExisting, falseConstraint, ReflectClassForObject(obj)); + return falseConstraint; + } + QConObject newConstraint = new QConObject(i_trans, i_parent, GetField(), obj); + Morph(removeExisting, newConstraint, ReflectClassForObject(obj)); + return newConstraint; + } + + private IReflectClass ReflectClassForObject(object obj) + { + return i_trans.Reflector().ForObject(obj); + } + + // Our QConPath objects are just placeholders to fields, + // so the parents are reachable. + // If we find a "real" constraint, we throw the QPath + // out and replace it with the other constraint. + private void Morph(BooleanByRef removeExisting, QCon newConstraint, IReflectClass + claxx) + { + bool mayMorph = true; + if (claxx != null) + { + ClassMetadata yc = i_trans.Container().ProduceClassMetadata(claxx); + if (yc != null) + { + IEnumerator i = IterateChildren(); + while (i.MoveNext()) + { + QField qf = ((QCon)i.Current).GetField(); + if (!yc.HasField(i_trans.Container(), qf.Name())) + { + mayMorph = false; + break; + } + } + } + } + // } + if (mayMorph) + { + IEnumerator j = IterateChildren(); + while (j.MoveNext()) + { + newConstraint.AddConstraint((QCon)j.Current); + } + if (HasJoins()) + { + IEnumerator k = IterateJoins(); + while (k.MoveNext()) + { + QConJoin qcj = (QConJoin)k.Current; + qcj.ExchangeConstraint(this, newConstraint); + newConstraint.AddJoin(qcj); + } + } + i_parent.ExchangeConstraint(this, newConstraint); + removeExisting.value = true; + } + else + { + i_parent.AddConstraint(newConstraint); + } + } + + internal sealed override bool VisitSelfOnNull() + { + return false; + } + + public override string ToString() + { + return "QConPath " + base.ToString(); + } + + public override void SetProcessedByIndex() + { + if (ChildrenCount() <= 1) + { + InternalSetProcessedByIndex(); + } + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/Processor/QConstraints.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/Processor/QConstraints.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/Processor/QConstraints.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/Processor/QConstraints.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,168 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Query.Processor; +using Db4objects.Db4o.Query; + +namespace Db4objects.Db4o.Internal.Query.Processor +{ + /// Array of constraints for queries. + /// + /// Array of constraints for queries. + /// Necessary to be returned to Query#constraints() + /// + /// + public class QConstraints : QCon, IConstraints + { + private IConstraint[] i_constraints; + + internal QConstraints(Transaction a_trans, IConstraint[] constraints) : base(a_trans + ) + { + i_constraints = constraints; + } + + internal override IConstraint Join(IConstraint a_with, bool a_and) + { + lock (StreamLock()) + { + if (!(a_with is QCon)) + { + return null; + } + // resolving multiple constraints happens in QCon for + // a_with, so we simply turn things around + return ((QCon)a_with).Join1(this, a_and); + } + } + + public virtual IConstraint[] ToArray() + { + lock (StreamLock()) + { + return i_constraints; + } + } + + public override IConstraint Contains() + { + lock (StreamLock()) + { + for (int i = 0; i < i_constraints.Length; i++) + { + i_constraints[i].Contains(); + } + return this; + } + } + + public override IConstraint Equal() + { + lock (StreamLock()) + { + for (int i = 0; i < i_constraints.Length; i++) + { + i_constraints[i].Equal(); + } + return this; + } + } + + public override IConstraint Greater() + { + lock (StreamLock()) + { + for (int i = 0; i < i_constraints.Length; i++) + { + i_constraints[i].Greater(); + } + return this; + } + } + + public override IConstraint Identity() + { + lock (StreamLock()) + { + for (int i = 0; i < i_constraints.Length; i++) + { + i_constraints[i].Identity(); + } + return this; + } + } + + public override IConstraint Not() + { + lock (StreamLock()) + { + for (int i = 0; i < i_constraints.Length; i++) + { + i_constraints[i].Not(); + } + return this; + } + } + + public override IConstraint Like() + { + lock (StreamLock()) + { + for (int i = 0; i < i_constraints.Length; i++) + { + i_constraints[i].Like(); + } + return this; + } + } + + public override IConstraint StartsWith(bool caseSensitive) + { + lock (StreamLock()) + { + for (int i = 0; i < i_constraints.Length; i++) + { + i_constraints[i].StartsWith(caseSensitive); + } + return this; + } + } + + public override IConstraint EndsWith(bool caseSensitive) + { + lock (StreamLock()) + { + for (int i = 0; i < i_constraints.Length; i++) + { + i_constraints[i].EndsWith(caseSensitive); + } + return this; + } + } + + public override IConstraint Smaller() + { + lock (StreamLock()) + { + for (int i = 0; i < i_constraints.Length; i++) + { + i_constraints[i].Smaller(); + } + return this; + } + } + + public override object GetObject() + { + lock (StreamLock()) + { + object[] objects = new object[i_constraints.Length]; + for (int i = 0; i < i_constraints.Length; i++) + { + objects[i] = i_constraints[i].GetObject(); + } + return objects; + } + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/Processor/QConUnconditional.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/Processor/QConUnconditional.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/Processor/QConUnconditional.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/Processor/QConUnconditional.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,34 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Query.Processor; + +namespace Db4objects.Db4o.Internal.Query.Processor +{ + /// + public class QConUnconditional : QCon + { + private bool _value; + + public QConUnconditional() + { + } + + public QConUnconditional(Transaction trans, bool value) : base(trans) + { + // cannot be final for C/S unmarshalling + // C/S only + _value = value; + } + + internal override void EvaluateSimpleExec(QCandidates a_candidates) + { + a_candidates.Filter(this); + } + + internal override bool Evaluate(QCandidate a_candidate) + { + return _value; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/Processor/QEAbstract.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/Processor/QEAbstract.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/Processor/QEAbstract.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/Processor/QEAbstract.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,23 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal.Query.Processor; + +namespace Db4objects.Db4o.Internal.Query.Processor +{ + /// + public abstract class QEAbstract : QE + { + internal override QE Add(QE evaluator) + { + QE qe = new QEMulti(); + qe.Add(this); + qe.Add(evaluator); + return qe; + } + + internal override bool IsDefault() + { + return false; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/Processor/QEContains.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/Processor/QEContains.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/Processor/QEContains.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/Processor/QEContains.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,24 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal.Query.Processor; + +namespace Db4objects.Db4o.Internal.Query.Processor +{ + /// + public class QEContains : QEStringCmp + { + /// for C/S messaging only + public QEContains() + { + } + + public QEContains(bool caseSensitive_) : base(caseSensitive_) + { + } + + protected override bool CompareStrings(string candidate, string constraint) + { + return candidate.IndexOf(constraint) > -1; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/Processor/QE.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/Processor/QE.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/Processor/QE.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/Processor/QE.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,93 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Query.Processor; +using Db4objects.Db4o.Types; + +namespace Db4objects.Db4o.Internal.Query.Processor +{ + /// Query Evaluator - Represents such things as >, >=, <, <=, EQUAL, LIKE, etc. + /// + /// Query Evaluator - Represents such things as >, >=, <, <=, EQUAL, LIKE, etc. + /// + /// + public class QE : IUnversioned + { + internal static readonly QE Default = new QE(); + + public const int Nulls = 0; + + public const int Smaller = 1; + + public const int Equal = 2; + + public const int Greater = 3; + + internal virtual QE Add(QE evaluator) + { + return evaluator; + } + + public virtual bool Identity() + { + return false; + } + + internal virtual bool IsDefault() + { + return true; + } + + internal virtual bool Evaluate(QConObject constraint, QCandidate candidate, object + obj) + { + IPreparedComparison prepareComparison = constraint.PrepareComparison(candidate); + if (obj == null) + { + return prepareComparison is Null; + } + if (prepareComparison is PreparedArrayContainsComparison) + { + return ((PreparedArrayContainsComparison)prepareComparison).IsEqual(obj); + } + return prepareComparison.CompareTo(obj) == 0; + } + + public override bool Equals(object obj) + { + return obj != null && obj.GetType() == this.GetType(); + } + + public override int GetHashCode() + { + return GetType().GetHashCode(); + } + + // overridden in QENot + internal virtual bool Not(bool res) + { + return res; + } + + /// Specifies which part of the index to take. + /// + /// Specifies which part of the index to take. + /// Array elements: + /// [0] - smaller + /// [1] - equal + /// [2] - greater + /// [3] - nulls + /// + /// + public virtual void IndexBitMap(bool[] bits) + { + bits[QE.Equal] = true; + } + + public virtual bool SupportsIndex() + { + return true; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/Processor/QEEndsWith.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/Processor/QEEndsWith.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/Processor/QEEndsWith.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/Processor/QEEndsWith.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,29 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal.Query.Processor; + +namespace Db4objects.Db4o.Internal.Query.Processor +{ + /// + public class QEEndsWith : QEStringCmp + { + /// for C/S messaging only + public QEEndsWith() + { + } + + public QEEndsWith(bool caseSensitive_) : base(caseSensitive_) + { + } + + protected override bool CompareStrings(string candidate, string constraint) + { + int lastIndex = candidate.LastIndexOf(constraint); + if (lastIndex == -1) + { + return false; + } + return lastIndex == candidate.Length - constraint.Length; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/Processor/QEEqual.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/Processor/QEEqual.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/Processor/QEEqual.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/Processor/QEEqual.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,15 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal.Query.Processor; + +namespace Db4objects.Db4o.Internal.Query.Processor +{ + /// + public class QEEqual : QEAbstract + { + public override void IndexBitMap(bool[] bits) + { + bits[QE.Equal] = true; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/Processor/QEGreater.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/Processor/QEGreater.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/Processor/QEGreater.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/Processor/QEGreater.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,32 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Query.Processor; + +namespace Db4objects.Db4o.Internal.Query.Processor +{ + /// + public class QEGreater : QEAbstract + { + internal override bool Evaluate(QConObject constraint, QCandidate candidate, object + obj) + { + if (obj == null) + { + return false; + } + IPreparedComparison preparedComparison = constraint.PrepareComparison(candidate); + if (preparedComparison is PreparedArrayContainsComparison) + { + return ((PreparedArrayContainsComparison)preparedComparison).IsSmallerThan(obj); + } + return preparedComparison.CompareTo(obj) < 0; + } + + public override void IndexBitMap(bool[] bits) + { + bits[QE.Greater] = true; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/Processor/QEIdentity.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/Processor/QEIdentity.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/Processor/QEIdentity.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/Processor/QEIdentity.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,27 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal.Query.Processor; + +namespace Db4objects.Db4o.Internal.Query.Processor +{ + /// + public class QEIdentity : QEEqual + { + private int i_objectID; + + public override bool Identity() + { + return true; + } + + internal override bool Evaluate(QConObject a_constraint, QCandidate a_candidate, + object a_value) + { + if (i_objectID == 0) + { + i_objectID = a_constraint.GetObjectID(); + } + return a_candidate._key == i_objectID; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/Processor/QEMulti.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/Processor/QEMulti.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/Processor/QEMulti.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/Processor/QEMulti.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,85 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System.Collections; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal.Query.Processor; + +namespace Db4objects.Db4o.Internal.Query.Processor +{ + /// + public class QEMulti : QE + { + private Collection4 i_evaluators = new Collection4(); + + // used by .net LINQ tests + public virtual IEnumerable Evaluators() + { + return i_evaluators; + } + + internal override QE Add(QE evaluator) + { + i_evaluators.Ensure(evaluator); + return this; + } + + public override bool Identity() + { + bool ret = false; + IEnumerator i = i_evaluators.GetEnumerator(); + while (i.MoveNext()) + { + if (((QE)i.Current).Identity()) + { + ret = true; + } + else + { + return false; + } + } + return ret; + } + + internal override bool IsDefault() + { + return false; + } + + internal override bool Evaluate(QConObject a_constraint, QCandidate a_candidate, + object a_value) + { + IEnumerator i = i_evaluators.GetEnumerator(); + while (i.MoveNext()) + { + if (((QE)i.Current).Evaluate(a_constraint, a_candidate, a_value)) + { + return true; + } + } + return false; + } + + public override void IndexBitMap(bool[] bits) + { + IEnumerator i = i_evaluators.GetEnumerator(); + while (i.MoveNext()) + { + ((QE)i.Current).IndexBitMap(bits); + } + } + + public override bool SupportsIndex() + { + IEnumerator i = i_evaluators.GetEnumerator(); + while (i.MoveNext()) + { + if (!((QE)i.Current).SupportsIndex()) + { + return false; + } + } + return true; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/Processor/QENot.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/Processor/QENot.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/Processor/QENot.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/Processor/QENot.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,71 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal.Query.Processor; + +namespace Db4objects.Db4o.Internal.Query.Processor +{ + /// + public class QENot : QE + { + private QE i_evaluator; + + public QENot() + { + } + + internal QENot(QE a_evaluator) + { + // CS + i_evaluator = a_evaluator; + } + + internal override QE Add(QE evaluator) + { + if (!(evaluator is Db4objects.Db4o.Internal.Query.Processor.QENot)) + { + i_evaluator = i_evaluator.Add(evaluator); + } + return this; + } + + public virtual QE Evaluator() + { + return i_evaluator; + } + + public override bool Identity() + { + return i_evaluator.Identity(); + } + + internal override bool IsDefault() + { + return false; + } + + internal override bool Evaluate(QConObject a_constraint, QCandidate a_candidate, + object a_value) + { + return !i_evaluator.Evaluate(a_constraint, a_candidate, a_value); + } + + internal override bool Not(bool res) + { + return !res; + } + + public override void IndexBitMap(bool[] bits) + { + i_evaluator.IndexBitMap(bits); + for (int i = 0; i < 4; i++) + { + bits[i] = !bits[i]; + } + } + + public override bool SupportsIndex() + { + return i_evaluator.SupportsIndex(); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/Processor/QESmaller.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/Processor/QESmaller.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/Processor/QESmaller.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/Processor/QESmaller.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,32 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Query.Processor; + +namespace Db4objects.Db4o.Internal.Query.Processor +{ + /// + public class QESmaller : QEAbstract + { + internal override bool Evaluate(QConObject constraint, QCandidate candidate, object + obj) + { + if (obj == null) + { + return false; + } + IPreparedComparison preparedComparison = constraint.PrepareComparison(candidate); + if (preparedComparison is PreparedArrayContainsComparison) + { + return ((PreparedArrayContainsComparison)preparedComparison).IsGreaterThan(obj); + } + return preparedComparison.CompareTo(obj) > 0; + } + + public override void IndexBitMap(bool[] bits) + { + bits[QE.Smaller] = true; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/Processor/QEStartsWith.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/Processor/QEStartsWith.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/Processor/QEStartsWith.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/Processor/QEStartsWith.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,24 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal.Query.Processor; + +namespace Db4objects.Db4o.Internal.Query.Processor +{ + /// + public class QEStartsWith : QEStringCmp + { + /// for C/S messaging only + public QEStartsWith() + { + } + + public QEStartsWith(bool caseSensitive_) : base(caseSensitive_) + { + } + + protected override bool CompareStrings(string candidate, string constraint) + { + return candidate.IndexOf(constraint) == 0; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/Processor/QEStringCmp.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/Processor/QEStringCmp.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/Processor/QEStringCmp.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/Processor/QEStringCmp.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,51 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Query.Processor; + +namespace Db4objects.Db4o.Internal.Query.Processor +{ + /// + public abstract class QEStringCmp : QEAbstract + { + private bool caseSensitive; + + /// for C/S messaging only + public QEStringCmp() + { + } + + public QEStringCmp(bool caseSensitive_) + { + caseSensitive = caseSensitive_; + } + + internal override bool Evaluate(QConObject constraint, QCandidate candidate, object + obj) + { + if (obj != null) + { + if (obj is ByteArrayBuffer) + { + obj = candidate.ReadString((ByteArrayBuffer)obj); + } + string candidateStringValue = obj.ToString(); + string stringConstraint = constraint.GetObject().ToString(); + if (!caseSensitive) + { + candidateStringValue = candidateStringValue.ToLower(); + stringConstraint = stringConstraint.ToLower(); + } + return CompareStrings(candidateStringValue, stringConstraint); + } + return constraint.GetObject() == null; + } + + public override bool SupportsIndex() + { + return false; + } + + protected abstract bool CompareStrings(string candidate, string constraint); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/Processor/QField.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/Processor/QField.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/Processor/QField.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/Processor/QField.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,156 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Query.Processor; +using Db4objects.Db4o.Marshall; +using Db4objects.Db4o.Reflect; +using Db4objects.Db4o.Types; + +namespace Db4objects.Db4o.Internal.Query.Processor +{ + /// + public class QField : IVisitor4, IUnversioned + { + [System.NonSerialized] + internal Transaction i_trans; + + private string i_name; + + [System.NonSerialized] + internal FieldMetadata _fieldMetadata; + + private int i_classMetadataID; + + private int _fieldHandle; + + public QField() + { + } + + public QField(Transaction a_trans, string name, FieldMetadata fieldMetadata, int + classMetadataID, int a_index) + { + // C/S only + i_trans = a_trans; + i_name = name; + _fieldMetadata = fieldMetadata; + i_classMetadataID = classMetadataID; + _fieldHandle = a_index; + if (_fieldMetadata != null) + { + if (!_fieldMetadata.Alive()) + { + _fieldMetadata = null; + } + } + } + + public virtual string Name() + { + return i_name; + } + + internal virtual object Coerce(object a_object) + { + IReflectClass claxx = null; + if (a_object != null) + { + if (a_object is IReflectClass) + { + claxx = (IReflectClass)a_object; + } + else + { + claxx = i_trans.Reflector().ForObject(a_object); + } + } + else + { + // TODO: Review this line for NullableArrayHandling + return a_object; + } + if (_fieldMetadata == null) + { + return a_object; + } + return _fieldMetadata.Coerce(claxx, a_object); + } + + internal virtual ClassMetadata GetFieldType() + { + if (_fieldMetadata != null) + { + return _fieldMetadata.FieldType(); + } + return null; + } + + public virtual FieldMetadata GetFieldMetadata() + { + return _fieldMetadata; + } + + internal virtual bool IsArray() + { + return _fieldMetadata != null && Handlers4.HandlesArray(_fieldMetadata.GetHandler + ()); + } + + internal virtual bool IsClass() + { + return _fieldMetadata == null || Handlers4.HandlesClass(_fieldMetadata.GetHandler + ()); + } + + internal virtual bool IsQueryLeaf() + { + return _fieldMetadata != null && Handlers4.IsQueryLeaf(_fieldMetadata.GetHandler( + )); + } + + internal virtual IPreparedComparison PrepareComparison(IContext context, object obj + ) + { + if (_fieldMetadata != null) + { + return _fieldMetadata.PrepareComparison(context, obj); + } + if (obj == null) + { + return Null.Instance; + } + ClassMetadata yc = i_trans.Container().ProduceClassMetadata(i_trans.Reflector().ForObject + (obj)); + FieldMetadata yf = yc.FieldMetadataForName(Name()); + if (yf != null) + { + return yf.PrepareComparison(context, obj); + } + return null; + } + + internal virtual void Unmarshall(Transaction a_trans) + { + if (i_classMetadataID != 0) + { + ClassMetadata yc = a_trans.Container().ClassMetadataForID(i_classMetadataID); + _fieldMetadata = (FieldMetadata)yc._aspects[_fieldHandle]; + } + } + + public virtual void Visit(object obj) + { + ((QCandidate)obj).UseField(this); + } + + public override string ToString() + { + if (_fieldMetadata != null) + { + return "QField " + _fieldMetadata.ToString(); + } + return base.ToString(); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/Processor/QPending.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/Processor/QPending.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/Processor/QPending.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/Processor/QPending.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,65 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal.Query.Processor; + +namespace Db4objects.Db4o.Internal.Query.Processor +{ + /// + internal class QPending : Tree + { + internal readonly QConJoin _join; + + internal QCon _constraint; + + internal int _result; + + internal const int False = -4; + + internal const int Both = 1; + + internal const int True = 2; + + internal QPending(QConJoin a_join, QCon a_constraint, bool a_firstResult) + { + // Constants, so QConJoin.evaluatePending is made easy: + _join = a_join; + _constraint = a_constraint; + _result = a_firstResult ? True : False; + } + + public override int Compare(Tree a_to) + { + return _constraint.Id() - ((Db4objects.Db4o.Internal.Query.Processor.QPending)a_to + )._constraint.Id(); + } + + internal virtual void ChangeConstraint() + { + _constraint = _join.GetOtherConstraint(_constraint); + } + + public override object ShallowClone() + { + Db4objects.Db4o.Internal.Query.Processor.QPending pending = InternalClonePayload( + ); + base.ShallowCloneInternal(pending); + return pending; + } + + internal virtual Db4objects.Db4o.Internal.Query.Processor.QPending InternalClonePayload + () + { + Db4objects.Db4o.Internal.Query.Processor.QPending pending = new Db4objects.Db4o.Internal.Query.Processor.QPending + (_join, _constraint, false); + pending._result = _result; + return pending; + } + + public override object Key() + { + throw new NotImplementedException(); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/Processor/QQueryBase.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/Processor/QQueryBase.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/Processor/QQueryBase.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/Processor/QQueryBase.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,1206 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using System.Collections; +using System.Text; +using Db4objects.Db4o; +using Db4objects.Db4o.Config; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Marshall; +using Db4objects.Db4o.Internal.Query; +using Db4objects.Db4o.Internal.Query.Processor; +using Db4objects.Db4o.Internal.Query.Result; +using Db4objects.Db4o.Query; +using Db4objects.Db4o.Reflect; +using Db4objects.Db4o.Types; +using Sharpen.Util; + +namespace Db4objects.Db4o.Internal.Query.Processor +{ + /// QQuery is the users hook on our graph. + /// + /// QQuery is the users hook on our graph. + /// A QQuery is defined by it's constraints. + /// NOTE: This is just a 'partial' base class to allow for variant implementations + /// in db4oj and db4ojdk1.2. It assumes that itself is an instance of QQuery + /// and should never be used explicitly. + /// + /// + public abstract class QQueryBase : IInternalQuery, IUnversioned + { + [System.NonSerialized] + internal Db4objects.Db4o.Internal.Transaction _trans; + + private Collection4 i_constraints = new Collection4(); + + private QQuery i_parent; + + private string i_field; + + [System.NonSerialized] + private QueryEvaluationMode _evaluationMode; + + private int _prefetchDepth; + + private int _prefetchCount; + + private int _evaluationModeAsInt; + + private IQueryComparator _comparator; + + [System.NonSerialized] + private readonly QQuery _this; + + private IList _orderings; + + protected QQueryBase() + { + // C/S only + _this = Cast(this); + } + + protected QQueryBase(Db4objects.Db4o.Internal.Transaction a_trans, QQuery a_parent + , string a_field) + { + _this = Cast(this); + _trans = a_trans; + i_parent = a_parent; + i_field = a_field; + } + + public virtual void CaptureQueryResultConfig() + { + Config4Impl config = _trans.Container().Config(); + _evaluationMode = config.EvaluationMode(); + _prefetchDepth = config.PrefetchDepth(); + _prefetchCount = config.PrefetchObjectCount(); + } + + internal virtual void AddConstraint(QCon a_constraint) + { + i_constraints.Add(a_constraint); + } + + private void AddConstraint(Collection4 col, object obj) + { + if (AttachToExistingConstraints(col, obj, true)) + { + return; + } + if (AttachToExistingConstraints(col, obj, false)) + { + return; + } + QConObject newConstraint = new QConObject(_trans, null, null, obj); + AddConstraint(newConstraint); + col.Add(newConstraint); + } + + private bool AttachToExistingConstraints(Collection4 newConstraintsCollector, object + obj, bool onlyForPaths) + { + bool found = false; + IEnumerator j = IterateConstraints(); + while (j.MoveNext()) + { + QCon existingConstraint = (QCon)j.Current; + BooleanByRef removeExisting = new BooleanByRef(false); + if (!onlyForPaths || (existingConstraint is QConPath)) + { + QCon newConstraint = existingConstraint.ShareParent(obj, removeExisting); + if (newConstraint != null) + { + newConstraintsCollector.Add(newConstraint); + AddConstraint(newConstraint); + if (removeExisting.value) + { + RemoveConstraint(existingConstraint); + } + found = true; + if (!onlyForPaths) + { + break; + } + } + } + } + return found; + } + + /// Search for slot that corresponds to class. + /// + /// Search for slot that corresponds to class.
If not found add it. + ///
Constrain it.
+ ///
+ public virtual IConstraint Constrain(object example) + { + lock (StreamLock()) + { + IReflectClass claxx = ReflectClassForClass(example); + if (claxx != null) + { + return AddClassConstraint(claxx); + } + QConEvaluation eval = Platform4.EvaluationCreate(_trans, example); + if (eval != null) + { + return AddEvaluationToAllConstraints(eval); + } + Collection4 constraints = new Collection4(); + AddConstraint(constraints, example); + return ToConstraint(constraints); + } + } + + private IConstraint AddEvaluationToAllConstraints(QConEvaluation eval) + { + if (i_constraints.Size() == 0) + { + _trans.Container().ClassCollection().IterateTopLevelClasses(new _IVisitor4_139(this + )); + } + IEnumerator i = IterateConstraints(); + while (i.MoveNext()) + { + ((QCon)i.Current).AddConstraint(eval); + } + // FIXME: should return valid Constraint object + return null; + } + + private sealed class _IVisitor4_139 : IVisitor4 + { + public _IVisitor4_139(QQueryBase _enclosing) + { + this._enclosing = _enclosing; + } + + public void Visit(object obj) + { + ClassMetadata classMetadata = (ClassMetadata)obj; + QConClass qcc = new QConClass(this._enclosing._trans, classMetadata.ClassReflector + ()); + this._enclosing.AddConstraint(qcc); + this._enclosing.ToConstraint(this._enclosing.i_constraints).Or(qcc); + } + + private readonly QQueryBase _enclosing; + } + + private IConstraint AddClassConstraint(IReflectClass claxx) + { + if (IsTheObjectClass(claxx)) + { + return null; + } + if (claxx.IsInterface()) + { + return AddInterfaceConstraint(claxx); + } + Collection4 newConstraints = IntroduceClassConstrain(claxx); + if (newConstraints.IsEmpty()) + { + QConClass qcc = new QConClass(_trans, claxx); + AddConstraint(qcc); + return qcc; + } + return ToConstraint(newConstraints); + } + + private Collection4 IntroduceClassConstrain(IReflectClass claxx) + { + Collection4 newConstraints = new Collection4(); + IEnumerator existingConstraints = IterateConstraints(); + while (existingConstraints.MoveNext()) + { + QCon existingConstraint = (QConObject)existingConstraints.Current; + BooleanByRef removeExisting = new BooleanByRef(false); + QCon newConstraint = existingConstraint.ShareParentForClass(claxx, removeExisting + ); + if (newConstraint != null) + { + newConstraints.Add(newConstraint); + AddConstraint(newConstraint); + if (removeExisting.value) + { + RemoveConstraint(existingConstraint); + } + } + } + return newConstraints; + } + + private bool IsTheObjectClass(IReflectClass claxx) + { + return claxx.Equals(Stream()._handlers.IclassObject); + } + + private IConstraint AddInterfaceConstraint(IReflectClass claxx) + { + Collection4 classes = Stream().ClassCollection().ForInterface(claxx); + if (classes.Size() == 0) + { + QConClass qcc = new QConClass(_trans, null, null, claxx); + AddConstraint(qcc); + return qcc; + } + IEnumerator i = classes.GetEnumerator(); + IConstraint constr = null; + while (i.MoveNext()) + { + ClassMetadata classMetadata = (ClassMetadata)i.Current; + IReflectClass classMetadataClaxx = classMetadata.ClassReflector(); + if (classMetadataClaxx != null) + { + if (!classMetadataClaxx.IsInterface()) + { + if (constr == null) + { + constr = Constrain(classMetadataClaxx); + } + else + { + constr = constr.Or(Constrain(classMetadata.ClassReflector())); + } + } + } + } + return constr; + } + + private IReflectClass ReflectClassForClass(object example) + { + if (example is IReflectClass) + { + return (IReflectClass)example; + } + if (example is Type) + { + return _trans.Reflector().ForClass((Type)example); + } + return null; + } + + public virtual IConstraints Constraints() + { + lock (StreamLock()) + { + IConstraint[] constraints = new IConstraint[i_constraints.Size()]; + i_constraints.ToArray(constraints); + return new QConstraints(_trans, constraints); + } + } + + public virtual IQuery Descend(string a_field) + { + lock (StreamLock()) + { + QQuery query = new QQuery(_trans, _this, a_field); + IntByRef run = new IntByRef(1); + if (!Descend1(query, a_field, run)) + { + // try to add unparented nodes on the second run, + // if not added in the first run and a descendant + // was not found + if (run.value == 1) + { + run.value = 2; + if (!Descend1(query, a_field, run)) + { + new QConUnconditional(_trans, false).Attach(query, a_field); + } + } + } + return query; + } + } + + private bool Descend1(QQuery query, string fieldName, IntByRef run) + { + if (run.value == 2 || i_constraints.Size() == 0) + { + // On the second run we are really creating a second independant + // query network that is not joined to other higher level + // constraints. + // Let's see how this works out. We may need to join networks. + run.value = 0; + // prevent a double run of this code + Stream().ClassCollection().AttachQueryNode(fieldName, new _IVisitor4_275(this)); + } + CheckConstraintsEvaluationMode(); + BooleanByRef foundClass = new BooleanByRef(false); + IEnumerator i = IterateConstraints(); + while (i.MoveNext()) + { + if (((QCon)i.Current).Attach(query, fieldName)) + { + foundClass.value = true; + } + } + return foundClass.value; + } + + private sealed class _IVisitor4_275 : IVisitor4 + { + public _IVisitor4_275(QQueryBase _enclosing) + { + this._enclosing = _enclosing; + this.untypedFieldConstraintCollected = false; + } + + internal bool untypedFieldConstraintCollected; + + public void Visit(object obj) + { + object[] pair = ((object[])obj); + ClassMetadata containingClass = (ClassMetadata)pair[0]; + FieldMetadata field = (FieldMetadata)pair[1]; + if (this.IsTyped(field)) + { + this.AddFieldConstraint(containingClass, field); + return; + } + if (this.untypedFieldConstraintCollected) + { + return; + } + this.AddFieldConstraint(containingClass, field); + this.untypedFieldConstraintCollected = true; + } + + private bool IsTyped(FieldMetadata field) + { + return !Handlers4.IsUntyped(field.GetHandler()); + } + + private void AddFieldConstraint(ClassMetadata containingClass, FieldMetadata field + ) + { + QConClass qcc = new QConClass(this._enclosing._trans, null, field.QField(this._enclosing + ._trans), containingClass.ClassReflector()); + this._enclosing.AddConstraint(qcc); + this._enclosing.ToConstraint(this._enclosing.i_constraints).Or(qcc); + } + + private readonly QQueryBase _enclosing; + } + + public virtual IObjectSet Execute() + { + lock (StreamLock()) + { + return ((IObjectSet)TriggeringQueryEvents(new _IClosure4_331(this))); + } + } + + private sealed class _IClosure4_331 : IClosure4 + { + public _IClosure4_331(QQueryBase _enclosing) + { + this._enclosing = _enclosing; + } + + public object Run() + { + return new ObjectSetFacade(this._enclosing.GetQueryResult()); + } + + private readonly QQueryBase _enclosing; + } + + public virtual void ExecuteLocal(IdListQueryResult result) + { + CheckConstraintsEvaluationMode(); + QQueryBase.CreateCandidateCollectionResult r = CreateCandidateCollection(); + bool checkDuplicates = r.checkDuplicates; + bool topLevel = r.topLevel; + List4 candidateCollection = r.candidateCollection; + if (candidateCollection != null) + { + Collection4 executionPath = topLevel ? null : FieldPathFromTop(); + IEnumerator i = new Iterator4Impl(candidateCollection); + while (i.MoveNext()) + { + ((QCandidates)i.Current).Execute(); + } + if (((List4)candidateCollection._next) != null) + { + checkDuplicates = true; + } + if (checkDuplicates) + { + result.CheckDuplicates(); + } + ObjectContainerBase stream = Stream(); + i = new Iterator4Impl(candidateCollection); + while (i.MoveNext()) + { + QCandidates candidates = (QCandidates)i.Current; + if (topLevel) + { + candidates.Traverse(result); + } + else + { + candidates.Traverse(new _IVisitor4_374(this, executionPath, stream, result)); + } + } + } + Sort(result); + } + + private sealed class _IVisitor4_374 : IVisitor4 + { + public _IVisitor4_374(QQueryBase _enclosing, Collection4 executionPath, ObjectContainerBase + stream, IdListQueryResult result) + { + this._enclosing = _enclosing; + this.executionPath = executionPath; + this.stream = stream; + this.result = result; + } + + public void Visit(object a_object) + { + QCandidate candidate = (QCandidate)a_object; + if (candidate.Include()) + { + TreeInt ids = new TreeInt(candidate._key); + ByRef idsNew = new ByRef(); + IEnumerator itPath = executionPath.GetEnumerator(); + while (itPath.MoveNext()) + { + idsNew.value = null; + string fieldName = (string)(itPath.Current); + if (ids != null) + { + ids.Traverse(new _IVisitor4_385(this, stream, fieldName, idsNew)); + } + ids = (TreeInt)((TreeInt)idsNew.value); + } + if (ids != null) + { + ids.Traverse(new _IVisitor4_406(result)); + } + } + } + + private sealed class _IVisitor4_385 : IVisitor4 + { + public _IVisitor4_385(_IVisitor4_374 _enclosing, ObjectContainerBase stream, string + fieldName, ByRef idsNew) + { + this._enclosing = _enclosing; + this.stream = stream; + this.fieldName = fieldName; + this.idsNew = idsNew; + } + + public void Visit(object treeInt) + { + int id = ((TreeInt)treeInt)._key; + StatefulBuffer reader = stream.ReadStatefulBufferById(this._enclosing._enclosing. + _trans, id); + if (reader != null) + { + ObjectHeader oh = new ObjectHeader(stream, reader); + CollectIdContext context = new CollectIdContext(this._enclosing._enclosing._trans + , oh, reader); + oh.ClassMetadata().CollectIDs(context, fieldName); + Tree.Traverse(context.Ids(), new _IVisitor4_394(idsNew)); + } + } + + private sealed class _IVisitor4_394 : IVisitor4 + { + public _IVisitor4_394(ByRef idsNew) + { + this.idsNew = idsNew; + } + + public void Visit(object node) + { + idsNew.value = TreeInt.Add(((TreeInt)idsNew.value), ((TreeInt)node)._key); + } + + private readonly ByRef idsNew; + } + + private readonly _IVisitor4_374 _enclosing; + + private readonly ObjectContainerBase stream; + + private readonly string fieldName; + + private readonly ByRef idsNew; + } + + private sealed class _IVisitor4_406 : IVisitor4 + { + public _IVisitor4_406(IdListQueryResult result) + { + this.result = result; + } + + public void Visit(object treeInt) + { + result.AddKeyCheckDuplicates(((TreeInt)treeInt)._key); + } + + private readonly IdListQueryResult result; + } + + private readonly QQueryBase _enclosing; + + private readonly Collection4 executionPath; + + private readonly ObjectContainerBase stream; + + private readonly IdListQueryResult result; + } + + private void TriggerQueryOnFinished() + { + Stream().Callbacks().QueryOnFinished(_trans, Cast(this)); + } + + private void TriggerQueryOnStarted() + { + Stream().Callbacks().QueryOnStarted(_trans, Cast(this)); + } + + public virtual IEnumerator ExecuteLazy() + { + CheckConstraintsEvaluationMode(); + QQueryBase.CreateCandidateCollectionResult r = CreateCandidateCollection(); + Collection4 executionPath = ExecutionPath(r); + IEnumerator candidateCollection = new Iterator4Impl(r.candidateCollection); + MappingIterator executeCandidates = new _MappingIterator_438(executionPath, candidateCollection + ); + CompositeIterator4 resultingIDs = new CompositeIterator4(executeCandidates); + if (!r.checkDuplicates) + { + return resultingIDs; + } + return CheckDuplicates(resultingIDs); + } + + private sealed class _MappingIterator_438 : MappingIterator + { + public _MappingIterator_438(Collection4 executionPath, IEnumerator baseArg1) : base + (baseArg1) + { + this.executionPath = executionPath; + } + + protected override object Map(object current) + { + return ((QCandidates)current).ExecuteLazy(executionPath); + } + + private readonly Collection4 executionPath; + } + + public virtual IQueryResult GetQueryResult() + { + lock (StreamLock()) + { + if (i_constraints.Size() == 0) + { + return ExecuteAllObjectsQuery(); + } + IQueryResult result = ExecuteClassOnlyQuery(); + if (result != null) + { + return result; + } + OptimizeJoins(); + return ExecuteQuery(); + } + } + + protected IQueryResult ExecuteQuery() + { + return Stream().ExecuteQuery(_this); + } + + private IQueryResult ExecuteAllObjectsQuery() + { + return Stream().QueryAllObjects(_trans); + } + + protected virtual ObjectContainerBase Stream() + { + return _trans.Container(); + } + + public virtual IInternalObjectContainer Container + { + get + { + return Stream(); + } + } + + private IQueryResult ExecuteClassOnlyQuery() + { + ClassMetadata clazz = SingleClassConstraint(); + if (null == clazz) + { + return null; + } + IQueryResult queryResult = Stream().ClassOnlyQuery(this, clazz); + Sort(queryResult); + return queryResult; + } + + private ClassMetadata SingleClassConstraint() + { + if (RequiresSort()) + { + return null; + } + QConClass clazzconstr = ClassConstraint(); + if (clazzconstr == null) + { + return null; + } + ClassMetadata clazz = clazzconstr._classMetadata; + if (clazz == null) + { + return null; + } + if (clazzconstr.HasChildren() || clazz.IsArray()) + { + return null; + } + return clazz; + } + + private QConClass ClassConstraint() + { + if (i_constraints.Size() != 1) + { + return null; + } + IConstraint constr = SingleConstraint(); + if (constr.GetType() != typeof(QConClass)) + { + return null; + } + return (QConClass)constr; + } + + private IConstraint SingleConstraint() + { + return (IConstraint)i_constraints.SingleElement(); + } + + public class CreateCandidateCollectionResult + { + public readonly bool checkDuplicates; + + public readonly bool topLevel; + + public readonly List4 candidateCollection; + + public CreateCandidateCollectionResult(List4 candidateCollection_, bool checkDuplicates_ + , bool topLevel_) + { + candidateCollection = candidateCollection_; + topLevel = topLevel_; + checkDuplicates = checkDuplicates_; + } + } + + public virtual IEnumerator ExecuteSnapshot() + { + QQueryBase.CreateCandidateCollectionResult r = CreateCandidateCollection(); + Collection4 executionPath = ExecutionPath(r); + IEnumerator candidatesIterator = new Iterator4Impl(r.candidateCollection); + Collection4 snapshots = new Collection4(); + while (candidatesIterator.MoveNext()) + { + QCandidates candidates = (QCandidates)candidatesIterator.Current; + snapshots.Add(candidates.ExecuteSnapshot(executionPath)); + } + IEnumerator snapshotsIterator = snapshots.GetEnumerator(); + CompositeIterator4 resultingIDs = new CompositeIterator4(snapshotsIterator); + if (!r.checkDuplicates) + { + return resultingIDs; + } + return CheckDuplicates(resultingIDs); + } + + public virtual object TriggeringQueryEvents(IClosure4 closure) + { + TriggerQueryOnStarted(); + try + { + return closure.Run(); + } + finally + { + TriggerQueryOnFinished(); + } + } + + private IEnumerator CheckDuplicates(CompositeIterator4 executeAllCandidates) + { + return Iterators.Filter(executeAllCandidates, new _IPredicate4_573()); + } + + private sealed class _IPredicate4_573 : IPredicate4 + { + public _IPredicate4_573() + { + this.ids = new TreeInt(0); + } + + private TreeInt ids; + + public bool Match(object current) + { + int id = ((int)current); + if (this.ids.Find(id) != null) + { + return false; + } + this.ids = (TreeInt)((TreeInt)this.ids.Add(new TreeInt(id))); + return true; + } + } + + private Collection4 ExecutionPath(QQueryBase.CreateCandidateCollectionResult r) + { + return r.topLevel ? null : FieldPathFromTop(); + } + + public virtual void CheckConstraintsEvaluationMode() + { + IEnumerator constraints = IterateConstraints(); + while (constraints.MoveNext()) + { + ((QConObject)constraints.Current).SetEvaluationMode(); + } + } + + private Collection4 FieldPathFromTop() + { + QQueryBase q = this; + Collection4 fieldPath = new Collection4(); + while (q.i_parent != null) + { + fieldPath.Prepend(q.i_field); + q = q.i_parent; + } + return fieldPath; + } + + private void LogConstraints() + { + } + + public virtual QQueryBase.CreateCandidateCollectionResult CreateCandidateCollection + () + { + List4 candidatesList = CreateQCandidatesList(); + bool checkDuplicates = false; + bool topLevel = true; + IEnumerator i = IterateConstraints(); + while (i.MoveNext()) + { + QCon constraint = (QCon)i.Current; + QCon old = constraint; + constraint = constraint.GetRoot(); + if (constraint != old) + { + checkDuplicates = true; + topLevel = false; + } + ClassMetadata classMetadata = constraint.GetYapClass(); + if (classMetadata == null) + { + break; + } + AddConstraintToCandidatesList(candidatesList, constraint); + } + return new QQueryBase.CreateCandidateCollectionResult(candidatesList, checkDuplicates + , topLevel); + } + + private void AddConstraintToCandidatesList(List4 candidatesList, QCon qcon) + { + if (candidatesList == null) + { + return; + } + IEnumerator j = new Iterator4Impl(candidatesList); + while (j.MoveNext()) + { + QCandidates candidates = (QCandidates)j.Current; + candidates.AddConstraint(qcon); + } + } + + private List4 CreateQCandidatesList() + { + List4 candidatesList = null; + IEnumerator i = IterateConstraints(); + while (i.MoveNext()) + { + QCon constraint = (QCon)i.Current; + constraint = constraint.GetRoot(); + ClassMetadata classMetadata = constraint.GetYapClass(); + if (classMetadata == null) + { + continue; + } + if (ConstraintCanBeAddedToExisting(candidatesList, constraint)) + { + continue; + } + QCandidates candidates = new QCandidates((LocalTransaction)_trans, classMetadata, + null); + candidatesList = new List4(candidatesList, candidates); + } + return candidatesList; + } + + private bool ConstraintCanBeAddedToExisting(List4 candidatesList, QCon constraint + ) + { + IEnumerator j = new Iterator4Impl(candidatesList); + while (j.MoveNext()) + { + QCandidates candidates = (QCandidates)j.Current; + if (candidates.FitsIntoExistingConstraintHierarchy(constraint)) + { + return true; + } + } + return false; + } + + public Transaction Transaction() + { + return _trans; + } + + public virtual IEnumerator IterateConstraints() + { + // clone the collection first to avoid + // InvalidIteratorException as i_constraints might be + // modified during the execution of callee + return new Collection4(i_constraints).GetEnumerator(); + } + + public virtual IQuery OrderAscending() + { + if (i_parent == null) + { + throw new InvalidOperationException("Cannot apply ordering at top level."); + } + lock (StreamLock()) + { + AddOrdering(SodaQueryComparator.Direction.Ascending); + return _this; + } + } + + public virtual IQuery OrderDescending() + { + if (i_parent == null) + { + throw new InvalidOperationException("Cannot apply ordering at top level."); + } + lock (StreamLock()) + { + AddOrdering(SodaQueryComparator.Direction.Descending); + return _this; + } + } + + private void AddOrdering(SodaQueryComparator.Direction direction) + { + AddOrdering(direction, new ArrayList()); + } + + protected void AddOrdering(SodaQueryComparator.Direction direction, IList path) + { + if (i_field != null) + { + path.Add(i_field); + } + if (i_parent != null) + { + i_parent.AddOrdering(direction, path); + return; + } + string[] fieldPath = ReverseFieldPath(path); + RemoveExistingOrderingFor(fieldPath); + Orderings().Add(new SodaQueryComparator.Ordering(direction, fieldPath)); + } + + private void RemoveExistingOrderingFor(string[] fieldPath) + { + for (IEnumerator orderingIter = Orderings().GetEnumerator(); orderingIter.MoveNext + (); ) + { + SodaQueryComparator.Ordering ordering = ((SodaQueryComparator.Ordering)orderingIter + .Current); + if (Arrays.Equals(ordering.FieldPath(), fieldPath)) + { + Orderings().Remove(ordering); + break; + } + } + } + + /// Public so it can be used by the LINQ test cases. + /// Public so it can be used by the LINQ test cases. + public IList Orderings() + { + if (null == _orderings) + { + _orderings = new ArrayList(); + } + return _orderings; + } + + private string[] ReverseFieldPath(IList path) + { + string[] reversedPath = new string[path.Count]; + for (int i = 0; i < reversedPath.Length; i++) + { + reversedPath[i] = ((string)path[path.Count - i - 1]); + } + return reversedPath; + } + + public virtual void Marshall() + { + CheckConstraintsEvaluationMode(); + _evaluationModeAsInt = _evaluationMode.AsInt(); + IEnumerator i = IterateConstraints(); + while (i.MoveNext()) + { + ((QCon)i.Current).GetRoot().Marshall(); + } + } + + public virtual void Unmarshall(Transaction a_trans) + { + _evaluationMode = QueryEvaluationMode.FromInt(_evaluationModeAsInt); + _trans = a_trans; + IEnumerator i = IterateConstraints(); + while (i.MoveNext()) + { + ((QCon)i.Current).Unmarshall(a_trans); + } + } + + internal virtual void RemoveConstraint(QCon a_constraint) + { + i_constraints.Remove(a_constraint); + } + + internal virtual IConstraint ToConstraint(Collection4 constraints) + { + if (constraints.Size() == 1) + { + return (IConstraint)constraints.SingleElement(); + } + else + { + if (constraints.Size() > 0) + { + IConstraint[] constraintArray = new IConstraint[constraints.Size()]; + constraints.ToArray(constraintArray); + return new QConstraints(_trans, constraintArray); + } + } + return null; + } + + protected virtual object StreamLock() + { + return Stream().Lock(); + } + + public virtual IQuery SortBy(IQueryComparator comparator) + { + _comparator = comparator; + return _this; + } + + private void Sort(IQueryResult result) + { + if (_orderings != null) + { + result.SortIds(NewSodaQueryComparator()); + } + if (_comparator != null) + { + result.Sort(_comparator); + } + } + + private IIntComparator NewSodaQueryComparator() + { + return new SodaQueryComparator((LocalObjectContainer)this.Transaction().Container + (), ExtentType(), ((SodaQueryComparator.Ordering[])Sharpen.Collections.ToArray(_orderings + , new SodaQueryComparator.Ordering[_orderings.Count]))); + } + + private ClassMetadata ExtentType() + { + return ClassConstraint().GetYapClass(); + } + + // cheat emulating '(QQuery)this' + private static QQuery Cast(QQueryBase obj) + { + return (QQuery)obj; + } + + public virtual bool RequiresSort() + { + if (_comparator != null || _orderings != null) + { + return true; + } + return false; + } + + public virtual IQueryComparator Comparator() + { + return _comparator; + } + + public virtual QueryEvaluationMode EvaluationMode() + { + return _evaluationMode; + } + + public virtual void EvaluationMode(QueryEvaluationMode mode) + { + _evaluationMode = mode; + } + + private void OptimizeJoins() + { + if (!HasOrJoins()) + { + RemoveJoins(); + } + } + + private bool HasOrJoins() + { + return ForEachConstraintRecursively(new _IFunction4_855()); + } + + private sealed class _IFunction4_855 : IFunction4 + { + public _IFunction4_855() + { + } + + public object Apply(object obj) + { + QCon constr = (QCon)obj; + IEnumerator joinIter = constr.IterateJoins(); + while (joinIter.MoveNext()) + { + QConJoin join = (QConJoin)joinIter.Current; + if (join.IsOr()) + { + return true; + } + } + return false; + } + } + + private void RemoveJoins() + { + ForEachConstraintRecursively(new _IFunction4_871()); + } + + private sealed class _IFunction4_871 : IFunction4 + { + public _IFunction4_871() + { + } + + public object Apply(object obj) + { + QCon constr = (QCon)obj; + constr.i_joins = null; + return false; + } + } + + private bool ForEachConstraintRecursively(IFunction4 block) + { + IQueue4 queue = new NoDuplicatesQueue(new NonblockingQueue()); + IEnumerator constrIter = IterateConstraints(); + while (constrIter.MoveNext()) + { + queue.Add(constrIter.Current); + } + while (queue.HasNext()) + { + QCon constr = (QCon)queue.Next(); + bool cancel = (bool)block.Apply(constr); + if (cancel) + { + return true; + } + IEnumerator childIter = constr.IterateChildren(); + while (childIter.MoveNext()) + { + queue.Add(childIter.Current); + } + IEnumerator joinIter = constr.IterateJoins(); + while (joinIter.MoveNext()) + { + queue.Add(joinIter.Current); + } + } + return false; + } + + public virtual int PrefetchDepth() + { + return _prefetchDepth; + } + + public virtual int PrefetchCount() + { + return _prefetchCount; + } + + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("QQueryBase\n"); + IEnumerator i = IterateConstraints(); + while (i.MoveNext()) + { + QCon constraint = (QCon)i.Current; + sb.Append(constraint); + sb.Append("\n"); + } + return sb.ToString(); + } + + public virtual QQuery Parent() + { + return i_parent; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/Processor/QQuery.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/Processor/QQuery.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/Processor/QQuery.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/Processor/QQuery.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,27 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Query.Processor; +using Db4objects.Db4o.Query; + +namespace Db4objects.Db4o.Internal.Query.Processor +{ + /// QQuery is the users hook on our graph. + /// + /// QQuery is the users hook on our graph. + /// A QQuery is defined by it's constraints. + /// + /// + public class QQuery : QQueryBase, IQuery + { + public QQuery() + { + } + + public QQuery(Transaction a_trans, Db4objects.Db4o.Internal.Query.Processor.QQuery + a_parent, string a_field) : base(a_trans, a_parent, a_field) + { + } + // C/S only + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/Result/AbstractLateQueryResult.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/Result/AbstractLateQueryResult.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/Result/AbstractLateQueryResult.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/Result/AbstractLateQueryResult.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,125 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using System.Collections; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Classindex; +using Db4objects.Db4o.Internal.Query.Result; +using Db4objects.Db4o.Reflect; + +namespace Db4objects.Db4o.Internal.Query.Result +{ + /// + public abstract class AbstractLateQueryResult : AbstractQueryResult + { + protected IEnumerable _iterable; + + public AbstractLateQueryResult(Transaction transaction) : base(transaction) + { + } + + public override AbstractQueryResult SupportSize() + { + return ToIdTree(); + } + + public override AbstractQueryResult SupportSort() + { + return ToIdList(); + } + + public override AbstractQueryResult SupportElementAccess() + { + return ToIdList(); + } + + protected override int KnownSize() + { + return 0; + } + + public override IIntIterator4 IterateIDs() + { + if (_iterable == null) + { + throw new InvalidOperationException(); + } + return new IntIterator4Adaptor(_iterable); + } + + public override AbstractQueryResult ToIdList() + { + return ToIdTree().ToIdList(); + } + + public virtual bool SkipClass(ClassMetadata classMetadata) + { + if (classMetadata.GetName() == null) + { + return true; + } + IReflectClass claxx = classMetadata.ClassReflector(); + if (Stream()._handlers.IclassInternal.IsAssignableFrom(claxx)) + { + return true; + } + return false; + } + + protected virtual IEnumerable ClassIndexesIterable(ClassMetadataIterator classCollectionIterator + ) + { + return Iterators.ConcatMap(Iterators.Iterable(classCollectionIterator), new _IFunction4_61 + (this)); + } + + private sealed class _IFunction4_61 : IFunction4 + { + public _IFunction4_61(AbstractLateQueryResult _enclosing) + { + this._enclosing = _enclosing; + } + + public object Apply(object current) + { + ClassMetadata classMetadata = (ClassMetadata)current; + if (this._enclosing.SkipClass(classMetadata)) + { + return Iterators.Skip; + } + return this._enclosing.ClassIndexIterable(classMetadata); + } + + private readonly AbstractLateQueryResult _enclosing; + } + + protected virtual IEnumerable ClassIndexIterable(ClassMetadata clazz) + { + return new _IEnumerable_73(this, clazz); + } + + private sealed class _IEnumerable_73 : IEnumerable + { + public _IEnumerable_73(AbstractLateQueryResult _enclosing, ClassMetadata clazz) + { + this._enclosing = _enclosing; + this.clazz = clazz; + } + + public IEnumerator GetEnumerator() + { + return this._enclosing.ClassIndexIterator(clazz); + } + + private readonly AbstractLateQueryResult _enclosing; + + private readonly ClassMetadata clazz; + } + + public virtual IEnumerator ClassIndexIterator(ClassMetadata clazz) + { + return BTreeClassIndexStrategy.Iterate(clazz, Transaction()); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/Result/AbstractQueryResult.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/Result/AbstractQueryResult.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/Result/AbstractQueryResult.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/Result/AbstractQueryResult.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,199 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using System.Collections; +using Db4objects.Db4o.Ext; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Query.Processor; +using Db4objects.Db4o.Internal.Query.Result; +using Db4objects.Db4o.Query; + +namespace Db4objects.Db4o.Internal.Query.Result +{ + /// + public abstract class AbstractQueryResult : IQueryResult + { + protected readonly Db4objects.Db4o.Internal.Transaction _transaction; + + public AbstractQueryResult(Db4objects.Db4o.Internal.Transaction transaction) + { + _transaction = transaction; + } + + public object Activate(object obj) + { + Stream().Activate(_transaction, obj); + return obj; + } + + public object ActivatedObject(int id) + { + ObjectContainerBase stream = Stream(); + object ret = stream.GetActivatedObjectFromCache(_transaction, id); + if (ret != null) + { + return ret; + } + return stream.ReadActivatedObjectNotInCache(_transaction, id); + } + + public virtual object Lock() + { + ObjectContainerBase stream = Stream(); + stream.CheckClosed(); + return stream.Lock(); + } + + public virtual ObjectContainerBase Stream() + { + return _transaction.Container(); + } + + public virtual Db4objects.Db4o.Internal.Transaction Transaction() + { + return _transaction; + } + + public virtual IExtObjectContainer ObjectContainer() + { + return Transaction().ObjectContainer().Ext(); + } + + public virtual IEnumerator GetEnumerator() + { + return new _MappingIterator_56(this, IterateIDs()); + } + + private sealed class _MappingIterator_56 : MappingIterator + { + public _MappingIterator_56(AbstractQueryResult _enclosing, IEnumerator baseArg1) : + base(baseArg1) + { + this._enclosing = _enclosing; + } + + protected override object Map(object current) + { + if (current == null) + { + return Iterators.Skip; + } + lock (this._enclosing.Lock()) + { + object obj = this._enclosing.ActivatedObject(((int)current)); + if (obj == null) + { + return Iterators.Skip; + } + return obj; + } + } + + private readonly AbstractQueryResult _enclosing; + } + + public virtual Db4objects.Db4o.Internal.Query.Result.AbstractQueryResult SupportSize + () + { + return this; + } + + public virtual Db4objects.Db4o.Internal.Query.Result.AbstractQueryResult SupportSort + () + { + return this; + } + + public virtual Db4objects.Db4o.Internal.Query.Result.AbstractQueryResult SupportElementAccess + () + { + return this; + } + + protected virtual int KnownSize() + { + return Size(); + } + + public virtual Db4objects.Db4o.Internal.Query.Result.AbstractQueryResult ToIdList + () + { + IdListQueryResult res = new IdListQueryResult(Transaction(), KnownSize()); + IIntIterator4 i = IterateIDs(); + while (i.MoveNext()) + { + res.Add(i.CurrentInt()); + } + return res; + } + + protected virtual Db4objects.Db4o.Internal.Query.Result.AbstractQueryResult ToIdTree + () + { + return new IdTreeQueryResult(Transaction(), IterateIDs()); + } + + public virtual Config4Impl Config() + { + return Stream().Config(); + } + + public virtual int Size() + { + throw new NotImplementedException(); + } + + public virtual void Sort(IQueryComparator cmp) + { + throw new NotImplementedException(); + } + + public virtual void SortIds(IIntComparator cmp) + { + throw new NotImplementedException(); + } + + public virtual object Get(int index) + { + throw new NotImplementedException(); + } + + /// + public virtual int GetId(int i) + { + throw new NotImplementedException(); + } + + public virtual int IndexOf(int id) + { + throw new NotImplementedException(); + } + + /// + public virtual void LoadFromClassIndex(ClassMetadata c) + { + throw new NotImplementedException(); + } + + /// + public virtual void LoadFromClassIndexes(ClassMetadataIterator i) + { + throw new NotImplementedException(); + } + + /// + public virtual void LoadFromIdReader(IEnumerator ids) + { + throw new NotImplementedException(); + } + + /// + public virtual void LoadFromQuery(QQuery q) + { + throw new NotImplementedException(); + } + + public abstract IIntIterator4 IterateIDs(); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/Result/HybridQueryResult.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/Result/HybridQueryResult.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/Result/HybridQueryResult.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/Result/HybridQueryResult.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,108 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System.Collections; +using Db4objects.Db4o.Config; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Query.Processor; +using Db4objects.Db4o.Internal.Query.Result; +using Db4objects.Db4o.Query; + +namespace Db4objects.Db4o.Internal.Query.Result +{ + /// + public class HybridQueryResult : AbstractQueryResult + { + private AbstractQueryResult _delegate; + + public HybridQueryResult(Transaction transaction, QueryEvaluationMode mode) : base + (transaction) + { + _delegate = ForMode(transaction, mode); + } + + private static AbstractQueryResult ForMode(Transaction transaction, QueryEvaluationMode + mode) + { + if (mode == QueryEvaluationMode.Lazy) + { + return new LazyQueryResult(transaction); + } + if (mode == QueryEvaluationMode.Snapshot) + { + return new SnapShotQueryResult(transaction); + } + return new IdListQueryResult(transaction); + } + + public override object Get(int index) + { + _delegate = _delegate.SupportElementAccess(); + return _delegate.Get(index); + } + + public override int GetId(int index) + { + _delegate = _delegate.SupportElementAccess(); + return _delegate.GetId(index); + } + + public override int IndexOf(int id) + { + _delegate = _delegate.SupportElementAccess(); + return _delegate.IndexOf(id); + } + + public override IIntIterator4 IterateIDs() + { + return _delegate.IterateIDs(); + } + + public override IEnumerator GetEnumerator() + { + return _delegate.GetEnumerator(); + } + + public override void LoadFromClassIndex(ClassMetadata clazz) + { + _delegate.LoadFromClassIndex(clazz); + } + + public override void LoadFromClassIndexes(ClassMetadataIterator iterator) + { + _delegate.LoadFromClassIndexes(iterator); + } + + public override void LoadFromIdReader(IEnumerator reader) + { + _delegate.LoadFromIdReader(reader); + } + + public override void LoadFromQuery(QQuery query) + { + if (query.RequiresSort()) + { + _delegate = new IdListQueryResult(Transaction()); + } + _delegate.LoadFromQuery(query); + } + + public override int Size() + { + _delegate = _delegate.SupportSize(); + return _delegate.Size(); + } + + public override void Sort(IQueryComparator cmp) + { + _delegate = _delegate.SupportSort(); + _delegate.Sort(cmp); + } + + public override void SortIds(IIntComparator cmp) + { + _delegate = _delegate.SupportSort(); + _delegate.SortIds(cmp); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/Result/IdListQueryResult.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/Result/IdListQueryResult.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/Result/IdListQueryResult.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/Result/IdListQueryResult.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,250 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using System.Collections; +using Db4objects.Db4o.Ext; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Btree; +using Db4objects.Db4o.Internal.Classindex; +using Db4objects.Db4o.Internal.Query.Processor; +using Db4objects.Db4o.Internal.Query.Result; +using Db4objects.Db4o.Query; +using Db4objects.Db4o.Reflect; + +namespace Db4objects.Db4o.Internal.Query.Result +{ + /// + public class IdListQueryResult : AbstractQueryResult, IVisitor4 + { + private Tree _candidates; + + private bool _checkDuplicates; + + public IntArrayList _ids; + + public IdListQueryResult(Transaction trans, int initialSize) : base(trans) + { + _ids = new IntArrayList(initialSize); + } + + public IdListQueryResult(Transaction trans) : this(trans, 0) + { + } + + public override IIntIterator4 IterateIDs() + { + return _ids.IntIterator(); + } + + public override object Get(int index) + { + lock (Lock()) + { + return ActivatedObject(GetId(index)); + } + } + + public override int GetId(int index) + { + if (index < 0 || index >= Size()) + { + throw new Db4oRecoverableException(new IndexOutOfRangeException()); + } + return _ids.Get(index); + } + + public void CheckDuplicates() + { + _checkDuplicates = true; + } + + public virtual void Visit(object a_tree) + { + QCandidate candidate = (QCandidate)a_tree; + if (candidate.Include()) + { + AddKeyCheckDuplicates(candidate._key); + } + } + + public virtual void AddKeyCheckDuplicates(int a_key) + { + if (_checkDuplicates) + { + TreeInt newNode = new TreeInt(a_key); + _candidates = Tree.Add(_candidates, newNode); + if (newNode._size == 0) + { + return; + } + } + Add(a_key); + } + + public override void Sort(IQueryComparator cmp) + { + Algorithms4.Sort(new _ISortable4_74(this, cmp)); + } + + private sealed class _ISortable4_74 : ISortable4 + { + public _ISortable4_74(IdListQueryResult _enclosing, IQueryComparator cmp) + { + this._enclosing = _enclosing; + this.cmp = cmp; + } + + public void Swap(int leftIndex, int rightIndex) + { + this._enclosing._ids.Swap(leftIndex, rightIndex); + } + + public int Size() + { + return this._enclosing.Size(); + } + + public int Compare(int leftIndex, int rightIndex) + { + return cmp.Compare(this._enclosing.Get(leftIndex), this._enclosing.Get(rightIndex + )); + } + + private readonly IdListQueryResult _enclosing; + + private readonly IQueryComparator cmp; + } + + public override void SortIds(IIntComparator cmp) + { + Algorithms4.Sort(new _ISortable4_88(this, cmp)); + } + + private sealed class _ISortable4_88 : ISortable4 + { + public _ISortable4_88(IdListQueryResult _enclosing, IIntComparator cmp) + { + this._enclosing = _enclosing; + this.cmp = cmp; + } + + public void Swap(int leftIndex, int rightIndex) + { + this._enclosing._ids.Swap(leftIndex, rightIndex); + } + + public int Size() + { + return this._enclosing.Size(); + } + + public int Compare(int leftIndex, int rightIndex) + { + return cmp.Compare(this._enclosing._ids.Get(leftIndex), this._enclosing._ids.Get( + rightIndex)); + } + + private readonly IdListQueryResult _enclosing; + + private readonly IIntComparator cmp; + } + + public override void LoadFromClassIndex(ClassMetadata clazz) + { + IClassIndexStrategy index = clazz.Index(); + if (index is BTreeClassIndexStrategy) + { + BTree btree = ((BTreeClassIndexStrategy)index).Btree(); + _ids = new IntArrayList(btree.Size(Transaction())); + } + index.TraverseAll(_transaction, new _IVisitor4_107(this)); + } + + private sealed class _IVisitor4_107 : IVisitor4 + { + public _IVisitor4_107(IdListQueryResult _enclosing) + { + this._enclosing = _enclosing; + } + + public void Visit(object a_object) + { + this._enclosing.Add(((int)a_object)); + } + + private readonly IdListQueryResult _enclosing; + } + + public override void LoadFromQuery(QQuery query) + { + query.ExecuteLocal(this); + } + + public override void LoadFromClassIndexes(ClassMetadataIterator iter) + { + // duplicates because of inheritance hierarchies + ByRef duplicates = new ByRef(); + while (iter.MoveNext()) + { + ClassMetadata classMetadata = iter.CurrentClass(); + if (classMetadata.GetName() != null) + { + IReflectClass claxx = classMetadata.ClassReflector(); + if (claxx == null || !(Stream()._handlers.IclassInternal.IsAssignableFrom(claxx))) + { + IClassIndexStrategy index = classMetadata.Index(); + index.TraverseAll(_transaction, new _IVisitor4_130(this, duplicates)); + } + } + } + } + + private sealed class _IVisitor4_130 : IVisitor4 + { + public _IVisitor4_130(IdListQueryResult _enclosing, ByRef duplicates) + { + this._enclosing = _enclosing; + this.duplicates = duplicates; + } + + public void Visit(object obj) + { + int id = ((int)obj); + TreeInt newNode = new TreeInt(id); + duplicates.value = Tree.Add(((Tree)duplicates.value), newNode); + if (newNode.Size() != 0) + { + this._enclosing.Add(id); + } + } + + private readonly IdListQueryResult _enclosing; + + private readonly ByRef duplicates; + } + + public override void LoadFromIdReader(IEnumerator ids) + { + while (ids.MoveNext()) + { + Add(((int)ids.Current)); + } + } + + public virtual void Add(int id) + { + _ids.Add(id); + } + + public override int IndexOf(int id) + { + return _ids.IndexOf(id); + } + + public override int Size() + { + return _ids.Size(); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/Result/IdTreeQueryResult.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/Result/IdTreeQueryResult.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/Result/IdTreeQueryResult.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/Result/IdTreeQueryResult.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,44 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Query.Result; + +namespace Db4objects.Db4o.Internal.Query.Result +{ + /// + public class IdTreeQueryResult : AbstractQueryResult + { + private Tree _ids; + + public IdTreeQueryResult(Transaction transaction, IIntIterator4 ids) : base(transaction + ) + { + _ids = TreeInt.AddAll(null, ids); + } + + public override IIntIterator4 IterateIDs() + { + return new IntIterator4Adaptor(new TreeKeyIterator(_ids)); + } + + public override int Size() + { + if (_ids == null) + { + return 0; + } + return _ids.Size(); + } + + public override AbstractQueryResult SupportSort() + { + return ToIdList(); + } + + public override AbstractQueryResult SupportElementAccess() + { + return ToIdList(); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/Result/IQueryResult.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/Result/IQueryResult.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/Result/IQueryResult.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/Result/IQueryResult.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,29 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System.Collections; +using Db4objects.Db4o.Ext; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Query; + +namespace Db4objects.Db4o.Internal.Query.Result +{ + /// + public interface IQueryResult : IEnumerable + { + object Get(int index); + + IIntIterator4 IterateIDs(); + + object Lock(); + + IExtObjectContainer ObjectContainer(); + + int IndexOf(int id); + + int Size(); + + void Sort(IQueryComparator cmp); + + void SortIds(IIntComparator cmp); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/Result/LazyQueryResult.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/Result/LazyQueryResult.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/Result/LazyQueryResult.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/Result/LazyQueryResult.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,48 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System.Collections; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Query.Processor; +using Db4objects.Db4o.Internal.Query.Result; + +namespace Db4objects.Db4o.Internal.Query.Result +{ + /// + public class LazyQueryResult : AbstractLateQueryResult + { + public LazyQueryResult(Transaction trans) : base(trans) + { + } + + public override void LoadFromClassIndex(ClassMetadata clazz) + { + _iterable = ClassIndexIterable(clazz); + } + + public override void LoadFromClassIndexes(ClassMetadataIterator classCollectionIterator + ) + { + _iterable = ClassIndexesIterable(classCollectionIterator); + } + + public override void LoadFromQuery(QQuery query) + { + _iterable = new _IEnumerable_28(query); + } + + private sealed class _IEnumerable_28 : IEnumerable + { + public _IEnumerable_28(QQuery query) + { + this.query = query; + } + + public IEnumerator GetEnumerator() + { + return query.ExecuteLazy(); + } + + private readonly QQuery query; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/Result/SnapShotQueryResult.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/Result/SnapShotQueryResult.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/Result/SnapShotQueryResult.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/Result/SnapShotQueryResult.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,72 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System.Collections; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Query.Processor; +using Db4objects.Db4o.Internal.Query.Result; + +namespace Db4objects.Db4o.Internal.Query.Result +{ + /// + public class SnapShotQueryResult : AbstractLateQueryResult + { + public SnapShotQueryResult(Transaction transaction) : base(transaction) + { + } + + public override void LoadFromClassIndex(ClassMetadata clazz) + { + CreateSnapshot(ClassIndexIterable(clazz)); + } + + public override void LoadFromClassIndexes(ClassMetadataIterator classCollectionIterator + ) + { + CreateSnapshot(ClassIndexesIterable(classCollectionIterator)); + } + + public override void LoadFromQuery(QQuery query) + { + IEnumerator _iterator = query.ExecuteSnapshot(); + _iterable = new _IEnumerable_29(_iterator); + } + + private sealed class _IEnumerable_29 : IEnumerable + { + public _IEnumerable_29(IEnumerator _iterator) + { + this._iterator = _iterator; + } + + public IEnumerator GetEnumerator() + { + _iterator.Reset(); + return _iterator; + } + + private readonly IEnumerator _iterator; + } + + private void CreateSnapshot(IEnumerable iterable) + { + Tree ids = TreeInt.AddAll(null, new IntIterator4Adaptor(iterable)); + _iterable = new _IEnumerable_39(ids); + } + + private sealed class _IEnumerable_39 : IEnumerable + { + public _IEnumerable_39(Tree ids) + { + this.ids = ids; + } + + public IEnumerator GetEnumerator() + { + return new TreeKeyIterator(ids); + } + + private readonly Tree ids; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/Result/StatefulQueryResult.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/Result/StatefulQueryResult.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/Result/StatefulQueryResult.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/Result/StatefulQueryResult.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,126 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System.Collections; +using Db4objects.Db4o.Ext; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal.Query.Result; +using Db4objects.Db4o.Query; + +namespace Db4objects.Db4o.Internal.Query.Result +{ + /// + public class StatefulQueryResult : IEnumerable + { + private readonly IQueryResult _delegate; + + private readonly Iterable4Adaptor _iterable; + + public StatefulQueryResult(IQueryResult queryResult) + { + _delegate = queryResult; + _iterable = new Iterable4Adaptor(queryResult); + } + + public virtual object Get(int index) + { + lock (Lock()) + { + return _delegate.Get(index); + } + } + + public virtual long[] GetIDs() + { + lock (Lock()) + { + long[] ids = new long[Size()]; + int i = 0; + IIntIterator4 iterator = _delegate.IterateIDs(); + while (iterator.MoveNext()) + { + ids[i++] = iterator.CurrentInt(); + } + return ids; + } + } + + public virtual bool HasNext() + { + lock (Lock()) + { + return _iterable.HasNext(); + } + } + + public virtual object Next() + { + lock (Lock()) + { + return _iterable.Next(); + } + } + + public virtual void Reset() + { + lock (Lock()) + { + _iterable.Reset(); + } + } + + public virtual int Size() + { + lock (Lock()) + { + return _delegate.Size(); + } + } + + public virtual void Sort(IQueryComparator cmp) + { + lock (Lock()) + { + _delegate.Sort(cmp); + } + } + + public virtual object Lock() + { + return _delegate.Lock(); + } + + internal virtual IExtObjectContainer ObjectContainer() + { + return _delegate.ObjectContainer(); + } + + public virtual int IndexOf(object a_object) + { + lock (Lock()) + { + int id = (int)ObjectContainer().GetID(a_object); + if (id <= 0) + { + return -1; + } + return _delegate.IndexOf(id); + } + } + + public virtual IEnumerator IterateIDs() + { + lock (Lock()) + { + return _delegate.IterateIDs(); + } + } + + public virtual IEnumerator GetEnumerator() + { + lock (Lock()) + { + return _delegate.GetEnumerator(); + } + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/SodaQueryComparator.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/SodaQueryComparator.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/SodaQueryComparator.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Query/SodaQueryComparator.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,247 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using System.Collections; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Handlers; +using Db4objects.Db4o.Internal.Marshall; +using Db4objects.Db4o.Internal.Query; + +namespace Db4objects.Db4o.Internal.Query +{ + public class SodaQueryComparator : IComparer, IIntComparator + { + public class Ordering + { + private SodaQueryComparator.Direction _direction; + + private string[] _fieldPath; + + [System.NonSerialized] + internal IList _resolvedPath; + + public Ordering(SodaQueryComparator.Direction direction, string[] fieldPath) + { + _direction = direction; + _fieldPath = fieldPath; + } + + public virtual SodaQueryComparator.Direction Direction() + { + return _direction; + } + + public virtual string[] FieldPath() + { + return _fieldPath; + } + } + + public class Direction + { + public static readonly SodaQueryComparator.Direction Ascending = new SodaQueryComparator.Direction + (0); + + public static readonly SodaQueryComparator.Direction Descending = new SodaQueryComparator.Direction + (1); + + private int value; + + private Direction() + { + } + + private Direction(int value) + { + this.value = value; + } + + public override bool Equals(object obj) + { + return ((SodaQueryComparator.Direction)obj).value == value; + } + + public override string ToString() + { + return this.Equals(Ascending) ? "ASCENDING" : "DESCENDING"; + } + } + + private readonly LocalObjectContainer _container; + + private readonly LocalTransaction _transaction; + + private readonly ClassMetadata _extentType; + + private readonly SodaQueryComparator.Ordering[] _orderings; + + private readonly IDictionary _bufferCache = new Hashtable(); + + private readonly IDictionary _fieldValueCache = new Hashtable(); + + public SodaQueryComparator(LocalObjectContainer container, Type extentType, SodaQueryComparator.Ordering + [] orderings) : this(container, container.ProduceClassMetadata(container.Reflector + ().ForClass(extentType)), orderings) + { + } + + public SodaQueryComparator(LocalObjectContainer container, ClassMetadata extent, + SodaQueryComparator.Ordering[] orderings) + { + _container = container; + _transaction = ((LocalTransaction)_container.Transaction); + _extentType = extent; + _orderings = orderings; + ResolveFieldPaths(orderings); + } + + private void ResolveFieldPaths(SodaQueryComparator.Ordering[] orderings) + { + for (int fieldPathIndex = 0; fieldPathIndex < orderings.Length; ++fieldPathIndex) + { + SodaQueryComparator.Ordering fieldPath = orderings[fieldPathIndex]; + fieldPath._resolvedPath = ResolveFieldPath(fieldPath.FieldPath()); + } + } + + public virtual IList Sort(long[] ids) + { + ArrayList idList = ListFrom(ids); + idList.Sort(this); + return idList; + } + + private ArrayList ListFrom(long[] ids) + { + ArrayList idList = new ArrayList(ids.Length); + for (int idIndex = 0; idIndex < ids.Length; ++idIndex) + { + long id = ids[idIndex]; + idList.Add((int)id); + } + return idList; + } + + private IList ResolveFieldPath(string[] fieldPath) + { + IList fields = new ArrayList(fieldPath.Length); + ClassMetadata currentType = _extentType; + for (int fieldNameIndex = 0; fieldNameIndex < fieldPath.Length; ++fieldNameIndex) + { + string fieldName = fieldPath[fieldNameIndex]; + FieldMetadata field = currentType.FieldMetadataForName(fieldName); + currentType = field.FieldType(); + fields.Add(field); + } + return fields; + } + + public virtual int Compare(object x, object y) + { + return Compare(((int)x), ((int)y)); + } + + public virtual int Compare(int x, int y) + { + for (int orderingIndex = 0; orderingIndex < _orderings.Length; ++orderingIndex) + { + SodaQueryComparator.Ordering ordering = _orderings[orderingIndex]; + int result = CompareByField(x, y, ordering._resolvedPath); + if (result != 0) + { + return ordering.Direction().Equals(SodaQueryComparator.Direction.Ascending) ? result + : -result; + } + } + return 0; + } + + private int CompareByField(int x, int y, IList path) + { + object xFieldValue = GetFieldValue(x, path); + object yFieldValue = GetFieldValue(y, path); + FieldMetadata field = ((FieldMetadata)path[path.Count - 1]); + return field.PrepareComparison(_transaction.Context(), xFieldValue).CompareTo(yFieldValue + ); + } + + private object GetFieldValue(int id, IList path) + { + for (int i = 0; i < path.Count - 1; ++i) + { + object obj = GetFieldValue(id, ((FieldMetadata)path[i])); + if (null == obj) + { + return null; + } + id = _container.GetID(_transaction, obj); + } + return GetFieldValue(id, ((FieldMetadata)path[path.Count - 1])); + } + + internal class FieldValueKey + { + private int _id; + + private FieldMetadata _field; + + public FieldValueKey(int id, FieldMetadata field) + { + _id = id; + _field = field; + } + + public override int GetHashCode() + { + return _field.GetHashCode() ^ _id; + } + + public override bool Equals(object obj) + { + SodaQueryComparator.FieldValueKey other = (SodaQueryComparator.FieldValueKey)obj; + return _field == other._field && _id == other._id; + } + } + + private object GetFieldValue(int id, FieldMetadata field) + { + SodaQueryComparator.FieldValueKey key = new SodaQueryComparator.FieldValueKey(id, + field); + object cachedValue = _fieldValueCache[key]; + if (null != cachedValue) + { + return cachedValue; + } + object fieldValue = ReadFieldValue(id, field); + _fieldValueCache[key] = fieldValue; + return fieldValue; + } + + private object ReadFieldValue(int id, FieldMetadata field) + { + ByteArrayBuffer buffer = BufferFor(id); + HandlerVersion handlerVersion = field.ContainingClass().SeekToField(_transaction, + buffer, field); + if (handlerVersion == HandlerVersion.Invalid) + { + return null; + } + QueryingReadContext context = new QueryingReadContext(_transaction, handlerVersion + ._number, buffer, id); + return field.Read(context); + } + + private ByteArrayBuffer BufferFor(int id) + { + ByteArrayBuffer cachedBuffer = ((ByteArrayBuffer)_bufferCache[id]); + if (null != cachedBuffer) + { + return cachedBuffer; + } + ByteArrayBuffer buffer = _container.ReadBufferById(_transaction, id); + _bufferCache[id] = buffer; + return buffer; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/References/HashcodeReferenceSystem.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/References/HashcodeReferenceSystem.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/References/HashcodeReferenceSystem.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/References/HashcodeReferenceSystem.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,158 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System.Text; +using Db4objects.Db4o; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.References; + +namespace Db4objects.Db4o.Internal.References +{ + /// + public class HashcodeReferenceSystem : IReferenceSystem + { + private ObjectReference _hashCodeTree; + + private ObjectReference _idTree; + + public virtual void AddNewReference(ObjectReference @ref) + { + AddReference(@ref); + } + + public virtual void AddExistingReference(ObjectReference @ref) + { + AddReference(@ref); + } + + private void AddReference(ObjectReference @ref) + { + @ref.Ref_init(); + IdAdd(@ref); + HashCodeAdd(@ref); + } + + public virtual void Commit() + { + } + + // do nothing + private void HashCodeAdd(ObjectReference @ref) + { + if (_hashCodeTree == null) + { + _hashCodeTree = @ref; + return; + } + _hashCodeTree = _hashCodeTree.Hc_add(@ref); + } + + private void IdAdd(ObjectReference @ref) + { + if (DTrace.enabled) + { + DTrace.IdTreeAdd.Log(@ref.GetID()); + } + if (_idTree == null) + { + _idTree = @ref; + return; + } + _idTree = _idTree.Id_add(@ref); + } + + public virtual ObjectReference ReferenceForId(int id) + { + if (DTrace.enabled) + { + DTrace.GetYapobject.Log(id); + } + if (_idTree == null) + { + return null; + } + if (!ObjectReference.IsValidId(id)) + { + return null; + } + return _idTree.Id_find(id); + } + + public virtual ObjectReference ReferenceForObject(object obj) + { + if (_hashCodeTree == null) + { + return null; + } + return _hashCodeTree.Hc_find(obj); + } + + public virtual void RemoveReference(ObjectReference @ref) + { + if (DTrace.enabled) + { + DTrace.ReferenceRemoved.Log(@ref.GetID()); + } + if (_hashCodeTree != null) + { + _hashCodeTree = _hashCodeTree.Hc_remove(@ref); + } + if (_idTree != null) + { + _idTree = _idTree.Id_remove(@ref); + } + } + + public virtual void Rollback() + { + } + + // do nothing + public virtual void TraverseReferences(IVisitor4 visitor) + { + if (_hashCodeTree == null) + { + return; + } + _hashCodeTree.Hc_traverse(visitor); + } + + public override string ToString() + { + BooleanByRef found = new BooleanByRef(); + StringBuilder str = new StringBuilder("HashcodeReferenceSystem {"); + TraverseReferences(new _IVisitor4_117(found, str)); + str.Append("}"); + return str.ToString(); + } + + private sealed class _IVisitor4_117 : IVisitor4 + { + public _IVisitor4_117(BooleanByRef found, StringBuilder str) + { + this.found = found; + this.str = str; + } + + public void Visit(object obj) + { + if (found.value) + { + str.Append(", "); + } + ObjectReference @ref = (ObjectReference)obj; + str.Append(@ref.GetID()); + found.value = true; + } + + private readonly BooleanByRef found; + + private readonly StringBuilder str; + } + + public virtual void Discarded() + { + } + // do nothing + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/References/IReferenceSystem.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/References/IReferenceSystem.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/References/IReferenceSystem.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/References/IReferenceSystem.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,29 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal; + +namespace Db4objects.Db4o.Internal.References +{ + /// + public interface IReferenceSystem + { + void AddNewReference(ObjectReference @ref); + + void AddExistingReference(ObjectReference @ref); + + void Commit(); + + ObjectReference ReferenceForId(int id); + + ObjectReference ReferenceForObject(object obj); + + void RemoveReference(ObjectReference @ref); + + void Rollback(); + + void TraverseReferences(IVisitor4 visitor); + + void Discarded(); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/References/IReferenceSystemFactory.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/References/IReferenceSystemFactory.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/References/IReferenceSystemFactory.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/References/IReferenceSystemFactory.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,13 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.References; + +namespace Db4objects.Db4o.Internal.References +{ + /// + public interface IReferenceSystemFactory + { + IReferenceSystem NewReferenceSystem(IInternalObjectContainer container); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/References/ReferenceSystemRegistry.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/References/ReferenceSystemRegistry.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/References/ReferenceSystemRegistry.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/References/ReferenceSystemRegistry.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,107 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System.Collections; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.References; + +namespace Db4objects.Db4o.Internal.References +{ + /// + public class ReferenceSystemRegistry + { + private readonly Collection4 _referenceSystems = new Collection4(); + + public virtual void RemoveId(int id) + { + RemoveReference(new _IReferenceSource_17(id)); + } + + private sealed class _IReferenceSource_17 : ReferenceSystemRegistry.IReferenceSource + { + public _IReferenceSource_17(int id) + { + this.id = id; + } + + public ObjectReference ReferenceFrom(IReferenceSystem referenceSystem) + { + return referenceSystem.ReferenceForId(id); + } + + private readonly int id; + } + + public virtual void RemoveObject(object obj) + { + RemoveReference(new _IReferenceSource_25(obj)); + } + + private sealed class _IReferenceSource_25 : ReferenceSystemRegistry.IReferenceSource + { + public _IReferenceSource_25(object obj) + { + this.obj = obj; + } + + public ObjectReference ReferenceFrom(IReferenceSystem referenceSystem) + { + return referenceSystem.ReferenceForObject(obj); + } + + private readonly object obj; + } + + public virtual void RemoveReference(ObjectReference reference) + { + RemoveReference(new _IReferenceSource_33(reference)); + } + + private sealed class _IReferenceSource_33 : ReferenceSystemRegistry.IReferenceSource + { + public _IReferenceSource_33(ObjectReference reference) + { + this.reference = reference; + } + + public ObjectReference ReferenceFrom(IReferenceSystem referenceSystem) + { + return reference; + } + + private readonly ObjectReference reference; + } + + private void RemoveReference(ReferenceSystemRegistry.IReferenceSource referenceSource + ) + { + IEnumerator i = _referenceSystems.GetEnumerator(); + while (i.MoveNext()) + { + IReferenceSystem referenceSystem = (IReferenceSystem)i.Current; + ObjectReference reference = referenceSource.ReferenceFrom(referenceSystem); + if (reference != null) + { + referenceSystem.RemoveReference(reference); + } + } + } + + public virtual void AddReferenceSystem(IReferenceSystem referenceSystem) + { + _referenceSystems.Add(referenceSystem); + } + + public virtual bool RemoveReferenceSystem(IReferenceSystem referenceSystem) + { + bool res = _referenceSystems.Remove(referenceSystem); + referenceSystem.Discarded(); + return res; + } + + private interface IReferenceSource + { + ObjectReference ReferenceFrom(IReferenceSystem referenceSystem); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/References/TransactionalReferenceSystemBase.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/References/TransactionalReferenceSystemBase.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/References/TransactionalReferenceSystemBase.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/References/TransactionalReferenceSystemBase.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,73 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.References; + +namespace Db4objects.Db4o.Internal.References +{ + /// + public abstract class TransactionalReferenceSystemBase + { + protected readonly IReferenceSystem _committedReferences; + + protected IReferenceSystem _newReferences; + + public TransactionalReferenceSystemBase() + { + CreateNewReferences(); + _committedReferences = NewReferenceSystem(); + } + + private IReferenceSystem NewReferenceSystem() + { + return new HashcodeReferenceSystem(); + } + + public abstract void AddExistingReference(ObjectReference @ref); + + public abstract void AddNewReference(ObjectReference @ref); + + public abstract void Commit(); + + protected virtual void TraverseNewReferences(IVisitor4 visitor) + { + _newReferences.TraverseReferences(visitor); + } + + protected virtual void CreateNewReferences() + { + _newReferences = NewReferenceSystem(); + } + + public virtual ObjectReference ReferenceForId(int id) + { + ObjectReference @ref = _newReferences.ReferenceForId(id); + if (@ref != null) + { + return @ref; + } + return _committedReferences.ReferenceForId(id); + } + + public virtual ObjectReference ReferenceForObject(object obj) + { + ObjectReference @ref = _newReferences.ReferenceForObject(obj); + if (@ref != null) + { + return @ref; + } + return _committedReferences.ReferenceForObject(obj); + } + + public abstract void RemoveReference(ObjectReference @ref); + + public abstract void Rollback(); + + public virtual void TraverseReferences(IVisitor4 visitor) + { + TraverseNewReferences(visitor); + _committedReferences.TraverseReferences(visitor); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/References/TransactionalReferenceSystem.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/References/TransactionalReferenceSystem.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/References/TransactionalReferenceSystem.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/References/TransactionalReferenceSystem.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,63 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.References; + +namespace Db4objects.Db4o.Internal.References +{ + /// + public class TransactionalReferenceSystem : TransactionalReferenceSystemBase, IReferenceSystem + { + public override void Commit() + { + TraverseNewReferences(new _IVisitor4_16(this)); + CreateNewReferences(); + } + + private sealed class _IVisitor4_16 : IVisitor4 + { + public _IVisitor4_16(TransactionalReferenceSystem _enclosing) + { + this._enclosing = _enclosing; + } + + public void Visit(object obj) + { + ObjectReference oref = (ObjectReference)obj; + if (oref.GetObject() != null) + { + this._enclosing._committedReferences.AddExistingReference(oref); + } + } + + private readonly TransactionalReferenceSystem _enclosing; + } + + public override void AddExistingReference(ObjectReference @ref) + { + _committedReferences.AddExistingReference(@ref); + } + + public override void AddNewReference(ObjectReference @ref) + { + _newReferences.AddNewReference(@ref); + } + + public override void RemoveReference(ObjectReference @ref) + { + _newReferences.RemoveReference(@ref); + _committedReferences.RemoveReference(@ref); + } + + public override void Rollback() + { + CreateNewReferences(); + } + + public virtual void Discarded() + { + } + // do nothing; + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Reflect/Generic/KnownClassesCollector.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Reflect/Generic/KnownClassesCollector.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Reflect/Generic/KnownClassesCollector.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Reflect/Generic/KnownClassesCollector.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,105 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System.Collections; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Reflect; +using Db4objects.Db4o.Reflect.Generic; + +namespace Db4objects.Db4o.Internal.Reflect.Generic +{ + public class KnownClassesCollector + { + private readonly ObjectContainerBase _container; + + private readonly KnownClassesRepository _repository; + + public KnownClassesCollector(ObjectContainerBase container, KnownClassesRepository + repository) + { + _container = container; + _repository = repository; + } + + public virtual IReflectClass[] Collect() + { + Collection4 classes = new Collection4(); + CollectKnownClasses(classes); + return (IReflectClass[])classes.ToArray(new IReflectClass[classes.Size()]); + } + + private void CollectKnownClasses(Collection4 classes) + { + IListener4 collectingListener = NewCollectingClassListener(classes); + _repository.AddListener(collectingListener); + try + { + CollectKnownClasses(classes, Iterators.Copy(_repository.Classes())); + } + finally + { + _repository.RemoveListener(collectingListener); + } + } + + private IListener4 NewCollectingClassListener(Collection4 classes) + { + return new _IListener4_37(this, classes); + } + + private sealed class _IListener4_37 : IListener4 + { + public _IListener4_37(KnownClassesCollector _enclosing, Collection4 classes) + { + this._enclosing = _enclosing; + this.classes = classes; + } + + public void OnEvent(object addedClass) + { + this._enclosing.CollectKnownClass(classes, ((IReflectClass)addedClass)); + } + + private readonly KnownClassesCollector _enclosing; + + private readonly Collection4 classes; + } + + private void CollectKnownClasses(Collection4 collector, IEnumerator knownClasses) + { + while (knownClasses.MoveNext()) + { + IReflectClass clazz = (IReflectClass)knownClasses.Current; + CollectKnownClass(collector, clazz); + } + } + + private void CollectKnownClass(Collection4 classes, IReflectClass clazz) + { + if (IsInternalClass(clazz)) + { + return; + } + if (!HasIdentity(clazz)) + { + return; + } + if (clazz.IsArray()) + { + return; + } + classes.Add(clazz); + } + + private bool IsInternalClass(IReflectClass clazz) + { + return _container._handlers.IclassInternal.IsAssignableFrom(clazz); + } + + private bool HasIdentity(IReflectClass clazz) + { + ClassMetadata clazzMeta = _container.ClassMetadataForReflectClass(clazz); + return clazzMeta == null || clazzMeta.HasIdentity(); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Reflect/IFieldAccessor.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Reflect/IFieldAccessor.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Reflect/IFieldAccessor.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Reflect/IFieldAccessor.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,14 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Reflect; + +namespace Db4objects.Db4o.Internal.Reflect +{ + /// 7.7 + public interface IFieldAccessor + { + void Set(IReflectField field, object onObject, object value); + + object Get(IReflectField field, object onObject); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Reflect/LenientFieldAccessor.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Reflect/LenientFieldAccessor.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Reflect/LenientFieldAccessor.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Reflect/LenientFieldAccessor.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,35 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Ext; +using Db4objects.Db4o.Internal.Reflect; +using Db4objects.Db4o.Reflect; + +namespace Db4objects.Db4o.Internal.Reflect +{ + /// 7.7 + public class LenientFieldAccessor : IFieldAccessor + { + public virtual object Get(IReflectField field, object onObject) + { + try + { + return field.Get(onObject); + } + catch (Db4oException) + { + return null; + } + } + + public virtual void Set(IReflectField field, object onObject, object value) + { + try + { + field.Set(onObject, value); + } + catch (Db4oException) + { + } + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Reflect/ReflectClasses.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Reflect/ReflectClasses.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Reflect/ReflectClasses.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Reflect/ReflectClasses.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,15 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using Db4objects.Db4o.Reflect; + +namespace Db4objects.Db4o.Internal.Reflect +{ + public class ReflectClasses + { + public static bool AreEqual(Type expected, IReflectClass actual) + { + return actual.Reflector().ForClass(expected) == actual; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Reflect/StrictFieldAccessor.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Reflect/StrictFieldAccessor.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Reflect/StrictFieldAccessor.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Reflect/StrictFieldAccessor.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,21 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal.Reflect; +using Db4objects.Db4o.Reflect; + +namespace Db4objects.Db4o.Internal.Reflect +{ + /// 7.7 + public class StrictFieldAccessor : IFieldAccessor + { + public virtual object Get(IReflectField field, object onObject) + { + return field.Get(onObject); + } + + public virtual void Set(IReflectField field, object onObject, object value) + { + field.Set(onObject, value); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/ReflectException.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/ReflectException.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/ReflectException.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/ReflectException.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,38 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using Db4objects.Db4o.Ext; + +namespace Db4objects.Db4o.Internal +{ + /// + /// db4o-specific exception.
+ ///
+ /// This exception is thrown when one of the db4o reflection methods fails. + ///
+ /// + /// db4o-specific exception.
+ ///
+ /// This exception is thrown when one of the db4o reflection methods fails. + ///
+ /// Db4objects.Db4o.Reflect + [System.Serializable] + public class ReflectException : Db4oRecoverableException + { + public ReflectException(string msg, Exception cause) : base(msg, cause) + { + } + + /// Constructor with the cause exception + /// cause exception + public ReflectException(Exception cause) : base(cause) + { + } + + /// Constructor with message + /// detailed explanation + public ReflectException(string message) : base(message) + { + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Reflection4.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Reflection4.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Reflection4.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Reflection4.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,241 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using System.Reflection; +using System.Text; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal; +using Sharpen; + +namespace Db4objects.Db4o.Internal +{ + /// + /// Use the methods in this class for system classes only, since they + /// are not ClassLoader or Reflector-aware. + /// TODO: this class should go to foundation.reflect, along with ReflectException and ReflectPlatform + /// + public class Reflection4 + { + public static object InvokeStatic(Type clazz, string methodName) + { + return Invoke(clazz, methodName, null, null, null); + } + + /// + public static object Invoke(object obj, string methodName) + { + return Invoke(obj.GetType(), methodName, null, null, obj); + } + + /// + public static object Invoke(object obj, string methodName, object[] @params) + { + Type[] paramClasses = new Type[@params.Length]; + for (int i = 0; i < @params.Length; i++) + { + paramClasses[i] = @params[i].GetType(); + } + return Invoke(obj.GetType(), methodName, paramClasses, @params, obj); + } + + /// + public static object Invoke(object obj, string methodName, Type[] paramClasses, object + [] @params) + { + return Invoke(obj.GetType(), methodName, paramClasses, @params, obj); + } + + /// + public static object Invoke(Type clazz, string methodName, Type[] paramClasses, object + [] @params) + { + return Invoke(clazz, methodName, paramClasses, @params, null); + } + + private static object Invoke(Type clazz, string methodName, Type[] paramClasses, + object[] @params, object onObject) + { + return Invoke(@params, onObject, GetMethod(clazz, methodName, paramClasses)); + } + + /// + public static object Invoke(string className, string methodName, Type[] paramClasses + , object[] @params, object onObject) + { + MethodInfo method = GetMethod(className, methodName, paramClasses); + return Invoke(@params, onObject, method); + } + + /// + public static object Invoke(object[] @params, object onObject, MethodInfo method) + { + if (method == null) + { + return null; + } + Platform4.SetAccessible(method); + try + { + return method.Invoke(onObject, @params); + } + catch (TargetInvocationException e) + { + throw new ReflectException(e.InnerException); + } + catch (ArgumentException e) + { + throw new ReflectException(e); + } + catch (MemberAccessException e) + { + throw new ReflectException(e); + } + } + + /// calling this method "method" will break C# conversion with the old converter + /// + public static MethodInfo GetMethod(string className, string methodName, Type[] paramClasses + ) + { + Type clazz = ReflectPlatform.ForName(className); + if (clazz == null) + { + return null; + } + return GetMethod(clazz, methodName, paramClasses); + } + + public static MethodInfo GetMethod(Type clazz, string methodName, Type[] paramClasses + ) + { + Type curclazz = clazz; + while (curclazz != null) + { + try + { + return Sharpen.Runtime.GetDeclaredMethod(curclazz, methodName, paramClasses); + } + catch (Exception) + { + } + curclazz = curclazz.BaseType; + } + return null; + } + + /// + public static object Invoke(object obj, string methodName, Type signature, object + value) + { + return Invoke(obj, methodName, new Type[] { signature }, new object[] { value }); + } + + public static FieldInfo GetField(Type clazz, string name) + { + Type curclazz = clazz; + while (curclazz != null) + { + try + { + FieldInfo field = Sharpen.Runtime.GetDeclaredField(curclazz, name); + Platform4.SetAccessible(field); + if (field != null) + { + return field; + } + } + catch (Exception) + { + } + curclazz = curclazz.BaseType; + } + return null; + } + + /// + public static object GetFieldValue(object obj, string fieldName) + { + try + { + return GetField(obj.GetType(), fieldName).GetValue(obj); + } + catch (Exception e) + { + throw new ReflectException(e); + } + } + + public static object NewInstance(object template) + { + try + { + return System.Activator.CreateInstance(template.GetType()); + } + catch (Exception e) + { + throw new ReflectException(e); + } + } + + public static string Dump(object obj) + { + return DumpPreventRecursion(obj, new IdentitySet4(), 2); + } + + private static string DumpPreventRecursion(object obj, IdentitySet4 dumped, int stackLimit + ) + { + stackLimit--; + if (obj == null) + { + return "null"; + } + Type clazz = obj.GetType(); + if (Platform4.IsSimple(clazz)) + { + return obj.ToString(); + } + StringBuilder sb = new StringBuilder(); + sb.Append(clazz.FullName); + sb.Append(" ("); + sb.Append(Runtime.IdentityHashCode(obj)); + sb.Append(")"); + if (dumped.Contains(obj) || stackLimit <= 0) + { + return sb.ToString(); + } + dumped.Add(obj); + FieldInfo[] fields = Sharpen.Runtime.GetDeclaredFields(clazz); + for (int fieldIndex = 0; fieldIndex < fields.Length; ++fieldIndex) + { + FieldInfo field = fields[fieldIndex]; + Platform4.SetAccessible(field); + try + { + if (field.GetValue(null) == field.GetValue(obj)) + { + continue; + } + } + catch (Exception) + { + } + // static field.getModifiers() wouldn't sharpen + sb.Append("\n"); + sb.Append("\t"); + sb.Append(field.Name); + sb.Append(": "); + try + { + sb.Append(DumpPreventRecursion(field.GetValue(obj), dumped, stackLimit)); + } + catch (Exception e) + { + sb.Append("Exception caught: "); + sb.Append(e); + } + } + return sb.ToString(); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/ReflectorConfigurationImpl.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/ReflectorConfigurationImpl.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/ReflectorConfigurationImpl.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/ReflectorConfigurationImpl.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,56 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Reflect; + +namespace Db4objects.Db4o.Internal +{ + public class ReflectorConfigurationImpl : IReflectorConfiguration + { + private Config4Impl _config; + + public ReflectorConfigurationImpl(Config4Impl config) + { + _config = config; + } + + public virtual bool TestConstructors() + { + return _config.TestConstructors(); + } + + public virtual bool CallConstructor(IReflectClass clazz) + { + TernaryBool specialized = CallConstructorSpecialized(clazz); + if (!specialized.IsUnspecified()) + { + return specialized.DefiniteYes(); + } + return _config.CallConstructors().DefiniteYes(); + } + + private TernaryBool CallConstructorSpecialized(IReflectClass clazz) + { + Config4Class clazzConfig = _config.ConfigClass(clazz.GetName()); + if (clazzConfig != null) + { + TernaryBool res = clazzConfig.CallConstructor(); + if (!res.IsUnspecified()) + { + return res; + } + } + if (Platform4.IsEnum(_config.Reflector(), clazz)) + { + return TernaryBool.No; + } + IReflectClass ancestor = clazz.GetSuperclass(); + if (ancestor != null) + { + return CallConstructorSpecialized(ancestor); + } + return TernaryBool.Unspecified; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Renames.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Renames.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Renames.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Renames.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,24 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o; + +namespace Db4objects.Db4o.Internal +{ + public class Renames + { + public static Rename ForField(string className, string name, string newName) + { + return new Rename(className, name, newName); + } + + public static Rename ForClass(string name, string newName) + { + return new Rename(string.Empty, name, newName); + } + + public static Rename ForInverseQBE(Rename ren) + { + return new Rename(ren.rClass, null, ren.rFrom); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Replication/IDb4oReplicationReference.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Replication/IDb4oReplicationReference.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Replication/IDb4oReplicationReference.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Replication/IDb4oReplicationReference.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,16 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Ext; + +namespace Db4objects.Db4o.Internal.Replication +{ + /// + public interface IDb4oReplicationReference + { + Db4oDatabase SignaturePart(); + + long LongPart(); + + long Version(); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Replication/IDb4oReplicationReferenceProvider.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Replication/IDb4oReplicationReferenceProvider.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Replication/IDb4oReplicationReferenceProvider.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Replication/IDb4oReplicationReferenceProvider.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,12 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal.Replication; + +namespace Db4objects.Db4o.Internal.Replication +{ + /// + public interface IDb4oReplicationReferenceProvider + { + IDb4oReplicationReference ReferenceFor(object obj); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/SerializedGraph.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/SerializedGraph.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/SerializedGraph.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/SerializedGraph.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,45 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal; + +namespace Db4objects.Db4o.Internal +{ + /// + public class SerializedGraph + { + public readonly int _id; + + public readonly byte[] _bytes; + + public SerializedGraph(int id, byte[] bytes) + { + _id = id; + _bytes = bytes; + } + + public virtual int Length() + { + return _bytes.Length; + } + + public virtual int MarshalledLength() + { + return (Const4.IntLength * 2) + Length(); + } + + public virtual void Write(ByteArrayBuffer buffer) + { + buffer.WriteInt(_id); + buffer.WriteInt(Length()); + buffer.Append(_bytes); + } + + public static Db4objects.Db4o.Internal.SerializedGraph Read(ByteArrayBuffer buffer + ) + { + int id = buffer.ReadInt(); + int length = buffer.ReadInt(); + return new Db4objects.Db4o.Internal.SerializedGraph(id, buffer.ReadBytes(length)); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Serializer.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Serializer.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Serializer.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Serializer.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,76 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.IO; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Activation; + +namespace Db4objects.Db4o.Internal +{ + /// + public class Serializer + { + public static StatefulBuffer Marshall(Transaction ta, object obj) + { + SerializedGraph serialized = Marshall(ta.Container(), obj); + StatefulBuffer buffer = new StatefulBuffer(ta, serialized.Length()); + buffer.Append(serialized._bytes); + buffer.UseSlot(serialized._id, 0, serialized.Length()); + return buffer; + } + + public static SerializedGraph Marshall(ObjectContainerBase serviceProvider, object + obj) + { + MemoryBin memoryBin = new MemoryBin(223, GrowthStrategy()); + TransportObjectContainer carrier = NewTransportObjectContainer(serviceProvider, memoryBin + ); + carrier.ProduceClassMetadata(carrier.Reflector().ForObject(obj)); + carrier.Store(obj); + int id = (int)carrier.GetID(obj); + carrier.Close(); + return new SerializedGraph(id, memoryBin.Data()); + } + + private static ConstantGrowthStrategy GrowthStrategy() + { + return new ConstantGrowthStrategy(300); + } + + private static TransportObjectContainer NewTransportObjectContainer(ObjectContainerBase + serviceProvider, MemoryBin memoryBin) + { + TransportObjectContainer container = new TransportObjectContainer(serviceProvider + , memoryBin); + container.DeferredOpen(); + return container; + } + + public static object Unmarshall(ObjectContainerBase serviceProvider, StatefulBuffer + buffer) + { + return Unmarshall(serviceProvider, buffer._buffer, buffer.GetID()); + } + + public static object Unmarshall(ObjectContainerBase serviceProvider, SerializedGraph + serialized) + { + return Unmarshall(serviceProvider, serialized._bytes, serialized._id); + } + + public static object Unmarshall(ObjectContainerBase serviceProvider, byte[] bytes + , int id) + { + if (id <= 0) + { + return null; + } + MemoryBin memoryBin = new MemoryBin(bytes, GrowthStrategy()); + TransportObjectContainer carrier = NewTransportObjectContainer(serviceProvider, memoryBin + ); + object obj = carrier.GetByID(id); + carrier.Activate(carrier.Transaction, obj, new FullActivationDepth()); + carrier.Close(); + return obj; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/SharedIndexedFields.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/SharedIndexedFields.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/SharedIndexedFields.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/SharedIndexedFields.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,17 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal; + +namespace Db4objects.Db4o.Internal +{ + /// + public class SharedIndexedFields + { + public readonly VersionFieldMetadata _version = new VersionFieldMetadata(); + + public readonly UUIDFieldMetadata _uUID = new UUIDFieldMetadata(); + + public readonly CommitTimestampFieldMetadata _commitTimestamp = new CommitTimestampFieldMetadata + (); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/ShutDownRunnable.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/ShutDownRunnable.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/ShutDownRunnable.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/ShutDownRunnable.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,42 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System.Collections; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal; +using Sharpen.Lang; + +namespace Db4objects.Db4o.Internal +{ + internal class ShutDownRunnable : IRunnable + { + private Collection4 _containers = new Collection4(); + + public volatile bool dontRemove = false; + + public virtual void Ensure(ObjectContainerBase container) + { + _containers.Ensure(container); + } + + public virtual void Remove(ObjectContainerBase container) + { + _containers.Remove(container); + } + + public virtual void Run() + { + dontRemove = true; + Collection4 copy = new Collection4(_containers); + IEnumerator i = copy.GetEnumerator(); + while (i.MoveNext()) + { + ((ObjectContainerBase)i.Current).ShutdownHook(); + } + } + + public virtual int Size() + { + return _containers.Size(); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Slots/FreespaceSlotChange.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Slots/FreespaceSlotChange.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Slots/FreespaceSlotChange.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Slots/FreespaceSlotChange.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,19 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal.Slots; + +namespace Db4objects.Db4o.Internal.Slots +{ + /// + public class FreespaceSlotChange : IdSystemSlotChange + { + public FreespaceSlotChange(int id) : base(id) + { + } + + protected override bool ForFreespace() + { + return true; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Slots/IdSystemSlotChange.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Slots/IdSystemSlotChange.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Slots/IdSystemSlotChange.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Slots/IdSystemSlotChange.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,58 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System.Collections; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal.Freespace; +using Db4objects.Db4o.Internal.Ids; +using Db4objects.Db4o.Internal.Slots; + +namespace Db4objects.Db4o.Internal.Slots +{ + /// + public class IdSystemSlotChange : SystemSlotChange + { + private Collection4 _freed; + + public IdSystemSlotChange(int id) : base(id) + { + } + + protected override void Free(IFreespaceManager freespaceManager, Slot slot) + { + if (slot.IsNull()) + { + return; + } + if (_freed == null) + { + _freed = new Collection4(); + } + _freed.Add(slot); + } + + public override void AccumulateFreeSlot(TransactionalIdSystemImpl idSystem, FreespaceCommitter + freespaceCommitter, bool forFreespace) + { + if (ForFreespace() != forFreespace) + { + return; + } + base.AccumulateFreeSlot(idSystem, freespaceCommitter, forFreespace); + if (_freed == null) + { + return; + } + IEnumerator iterator = _freed.GetEnumerator(); + while (iterator.MoveNext()) + { + freespaceCommitter.DelayedFree((Slot)iterator.Current, FreeToSystemFreespaceSystem + ()); + } + } + + protected override bool FreeToSystemFreespaceSystem() + { + return true; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Slots/Pointer4.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Slots/Pointer4.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Slots/Pointer4.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Slots/Pointer4.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,35 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal.Slots; + +namespace Db4objects.Db4o.Internal.Slots +{ + /// + public class Pointer4 + { + public readonly int _id; + + public readonly Slot _slot; + + public Pointer4(int id, Slot slot) + { + _id = id; + _slot = slot; + } + + public virtual int Address() + { + return _slot.Address(); + } + + public virtual int Id() + { + return _id; + } + + public virtual int Length() + { + return _slot.Length(); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Slots/ReferencedSlot.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Slots/ReferencedSlot.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Slots/ReferencedSlot.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Slots/ReferencedSlot.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,65 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal; + +namespace Db4objects.Db4o.Internal.Slots +{ + /// + public class ReferencedSlot : TreeInt + { + private Db4objects.Db4o.Internal.Slots.Slot _slot; + + private int _references; + + public ReferencedSlot(int a_key) : base(a_key) + { + } + + public override object ShallowClone() + { + Db4objects.Db4o.Internal.Slots.ReferencedSlot rs = new Db4objects.Db4o.Internal.Slots.ReferencedSlot + (_key); + rs._slot = _slot; + rs._references = _references; + return base.ShallowCloneInternal(rs); + } + + public virtual void PointTo(Db4objects.Db4o.Internal.Slots.Slot slot) + { + _slot = slot; + } + + public virtual Tree Free(LocalObjectContainer file, Tree treeRoot, Db4objects.Db4o.Internal.Slots.Slot + slot) + { + file.Free(_slot.Address(), _slot.Length()); + if (RemoveReferenceIsLast()) + { + if (treeRoot != null) + { + return treeRoot.RemoveNode(this); + } + } + PointTo(slot); + return treeRoot; + } + + public virtual bool AddReferenceIsFirst() + { + _references++; + return (_references == 1); + } + + public virtual bool RemoveReferenceIsLast() + { + _references--; + return _references < 1; + } + + public virtual Db4objects.Db4o.Internal.Slots.Slot Slot() + { + return _slot; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Slots/SlotChange.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Slots/SlotChange.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Slots/SlotChange.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Slots/SlotChange.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,253 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Freespace; +using Db4objects.Db4o.Internal.Ids; +using Db4objects.Db4o.Internal.Slots; + +namespace Db4objects.Db4o.Internal.Slots +{ + /// + public class SlotChange : TreeInt + { + private class SlotChangeOperation + { + private readonly string _type; + + public SlotChangeOperation(string type) + { + _type = type; + } + + internal static readonly SlotChange.SlotChangeOperation create = new SlotChange.SlotChangeOperation + ("create"); + + internal static readonly SlotChange.SlotChangeOperation update = new SlotChange.SlotChangeOperation + ("update"); + + internal static readonly SlotChange.SlotChangeOperation delete = new SlotChange.SlotChangeOperation + ("delete"); + + public override string ToString() + { + return _type; + } + } + + private SlotChange.SlotChangeOperation _firstOperation; + + private SlotChange.SlotChangeOperation _currentOperation; + + protected Slot _newSlot; + + public SlotChange(int id) : base(id) + { + } + + public override object ShallowClone() + { + SlotChange sc = new SlotChange(0); + sc.NewSlot(_newSlot); + return base.ShallowCloneInternal(sc); + } + + public virtual void AccumulateFreeSlot(TransactionalIdSystemImpl idSystem, FreespaceCommitter + freespaceCommitter, bool forFreespace) + { + if (ForFreespace() != forFreespace) + { + return; + } + if (_firstOperation == SlotChange.SlotChangeOperation.create) + { + return; + } + if (_currentOperation == SlotChange.SlotChangeOperation.update || _currentOperation + == SlotChange.SlotChangeOperation.delete) + { + Slot slot = ModifiedSlotInParentIdSystem(idSystem); + if (Slot.IsNull(slot)) + { + slot = idSystem.CommittedSlot(_key); + } + // No old slot at all can be the case if the object + // has been deleted by another transaction and we add it again. + if (!Slot.IsNull(slot)) + { + freespaceCommitter.DelayedFree(slot, FreeToSystemFreespaceSystem()); + } + } + } + + protected virtual bool ForFreespace() + { + return false; + } + + protected virtual Slot ModifiedSlotInParentIdSystem(TransactionalIdSystemImpl idSystem + ) + { + return idSystem.ModifiedSlotInParentIdSystem(_key); + } + + public virtual bool IsDeleted() + { + return SlotModified() && _newSlot.IsNull(); + } + + public virtual bool IsNew() + { + return _firstOperation == SlotChange.SlotChangeOperation.create; + } + + private bool IsFreeOnRollback() + { + return !Slot.IsNull(_newSlot); + } + + public bool SlotModified() + { + return _newSlot != null; + } + + /// FIXME: Check where pointers should be freed on commit. + /// + /// FIXME: Check where pointers should be freed on commit. + /// This should be triggered in this class. + /// + public virtual Slot NewSlot() + { + // private final boolean isFreePointerOnCommit() { + // return isBitSet(FREE_POINTER_ON_COMMIT_BIT); + // } + return _newSlot; + } + + public override object Read(ByteArrayBuffer reader) + { + SlotChange change = new SlotChange(reader.ReadInt()); + Slot newSlot = new Slot(reader.ReadInt(), reader.ReadInt()); + change.NewSlot(newSlot); + return change; + } + + public virtual void Rollback(IFreespaceManager freespaceManager) + { + if (IsFreeOnRollback()) + { + freespaceManager.Free(_newSlot); + } + } + + public override void Write(ByteArrayBuffer writer) + { + if (SlotModified()) + { + writer.WriteInt(_key); + writer.WriteInt(_newSlot.Address()); + writer.WriteInt(_newSlot.Length()); + } + } + + public void WritePointer(LocalObjectContainer container) + { + if (SlotModified()) + { + container.WritePointer(_key, _newSlot); + } + } + + private void NewSlot(Slot slot) + { + _newSlot = slot; + } + + public virtual void NotifySlotUpdated(IFreespaceManager freespaceManager, Slot slot + ) + { + if (DTrace.enabled) + { + DTrace.NotifySlotUpdated.LogLength(_key, slot); + } + FreePreviouslyModifiedSlot(freespaceManager); + _newSlot = slot; + Operation(SlotChange.SlotChangeOperation.update); + } + + protected virtual void FreePreviouslyModifiedSlot(IFreespaceManager freespaceManager + ) + { + if (Slot.IsNull(_newSlot)) + { + return; + } + Free(freespaceManager, _newSlot); + _newSlot = null; + } + + protected virtual void Free(IFreespaceManager freespaceManager, Slot slot) + { + if (slot.IsNull()) + { + return; + } + if (freespaceManager == null) + { + return; + } + freespaceManager.Free(slot); + } + + private void Operation(SlotChange.SlotChangeOperation operation) + { + if (_firstOperation == null) + { + _firstOperation = operation; + } + _currentOperation = operation; + } + + public virtual void NotifySlotCreated(Slot slot) + { + if (DTrace.enabled) + { + DTrace.NotifySlotCreated.Log(_key); + DTrace.NotifySlotCreated.LogLength(slot); + } + Operation(SlotChange.SlotChangeOperation.create); + _newSlot = slot; + } + + public virtual void NotifyDeleted(IFreespaceManager freespaceManager) + { + if (DTrace.enabled) + { + DTrace.NotifySlotDeleted.Log(_key); + } + Operation(SlotChange.SlotChangeOperation.delete); + FreePreviouslyModifiedSlot(freespaceManager); + _newSlot = Slot.Zero; + } + + public virtual bool RemoveId() + { + return false; + } + + public override string ToString() + { + string str = "id: " + _key; + if (_newSlot != null) + { + str += " newSlot: " + _newSlot; + } + return str; + } + + protected virtual bool FreeToSystemFreespaceSystem() + { + return false; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Slots/SlotChangeFactory.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Slots/SlotChangeFactory.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Slots/SlotChangeFactory.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Slots/SlotChangeFactory.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,67 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal.Slots; + +namespace Db4objects.Db4o.Internal.Slots +{ + /// + public class SlotChangeFactory + { + private SlotChangeFactory() + { + } + + public virtual SlotChange NewInstance(int id) + { + return new SlotChange(id); + } + + public static readonly Db4objects.Db4o.Internal.Slots.SlotChangeFactory UserObjects + = new Db4objects.Db4o.Internal.Slots.SlotChangeFactory(); + + private sealed class _SlotChangeFactory_20 : Db4objects.Db4o.Internal.Slots.SlotChangeFactory + { + public _SlotChangeFactory_20() + { + } + + public override SlotChange NewInstance(int id) + { + return new SystemSlotChange(id); + } + } + + public static readonly Db4objects.Db4o.Internal.Slots.SlotChangeFactory SystemObjects + = new _SlotChangeFactory_20(); + + private sealed class _SlotChangeFactory_26 : Db4objects.Db4o.Internal.Slots.SlotChangeFactory + { + public _SlotChangeFactory_26() + { + } + + public override SlotChange NewInstance(int id) + { + return new IdSystemSlotChange(id); + } + } + + public static readonly Db4objects.Db4o.Internal.Slots.SlotChangeFactory IdSystem = + new _SlotChangeFactory_26(); + + private sealed class _SlotChangeFactory_32 : Db4objects.Db4o.Internal.Slots.SlotChangeFactory + { + public _SlotChangeFactory_32() + { + } + + public override SlotChange NewInstance(int id) + { + return new FreespaceSlotChange(id); + } + } + + public static readonly Db4objects.Db4o.Internal.Slots.SlotChangeFactory FreeSpace + = new _SlotChangeFactory_32(); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Slots/Slot.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Slots/Slot.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Slots/Slot.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Slots/Slot.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,132 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal; + +namespace Db4objects.Db4o.Internal.Slots +{ + /// + public class Slot + { + private readonly int _address; + + private readonly int _length; + + public static readonly Db4objects.Db4o.Internal.Slots.Slot Zero = new Db4objects.Db4o.Internal.Slots.Slot + (0, 0); + + public const int New = -1; + + public const int Update = -2; + + public Slot(int address, int length) + { + _address = address; + _length = length; + } + + public virtual int Address() + { + return _address; + } + + public virtual int Length() + { + return _length; + } + + public override bool Equals(object obj) + { + if (obj == this) + { + return true; + } + if (!(obj is Db4objects.Db4o.Internal.Slots.Slot)) + { + return false; + } + Db4objects.Db4o.Internal.Slots.Slot other = (Db4objects.Db4o.Internal.Slots.Slot) + obj; + return (_address == other._address) && (Length() == other.Length()); + } + + public override int GetHashCode() + { + return _address ^ Length(); + } + + public virtual Db4objects.Db4o.Internal.Slots.Slot SubSlot(int offset) + { + return new Db4objects.Db4o.Internal.Slots.Slot(_address + offset, Length() - offset + ); + } + + public override string ToString() + { + return "[A:" + _address + ",L:" + Length() + "]"; + } + + public virtual Db4objects.Db4o.Internal.Slots.Slot Truncate(int requiredLength) + { + return new Db4objects.Db4o.Internal.Slots.Slot(_address, requiredLength); + } + + public static int MarshalledLength = Const4.IntLength * 2; + + public virtual int CompareByAddress(Db4objects.Db4o.Internal.Slots.Slot slot) + { + // FIXME: This is the wrong way around !!! + // Fix here and in all referers. + int res = slot._address - _address; + if (res != 0) + { + return res; + } + return slot.Length() - Length(); + } + + public virtual int CompareByLength(Db4objects.Db4o.Internal.Slots.Slot slot) + { + // FIXME: This is the wrong way around !!! + // Fix here and in all referers. + int res = slot.Length() - Length(); + if (res != 0) + { + return res; + } + return slot._address - _address; + } + + public virtual bool IsDirectlyPreceding(Db4objects.Db4o.Internal.Slots.Slot other + ) + { + return _address + Length() == other._address; + } + + public virtual Db4objects.Db4o.Internal.Slots.Slot Append(Db4objects.Db4o.Internal.Slots.Slot + slot) + { + return new Db4objects.Db4o.Internal.Slots.Slot(Address(), _length + slot.Length() + ); + } + + public virtual bool IsNull() + { + return Address() == 0 || Length() == 0; + } + + public virtual bool IsNew() + { + return _address == New; + } + + public virtual bool IsUpdate() + { + return _address == Update; + } + + public static bool IsNull(Db4objects.Db4o.Internal.Slots.Slot slot) + { + return slot == null || slot.IsNull(); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Slots/SystemSlotChange.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Slots/SystemSlotChange.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Slots/SystemSlotChange.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Slots/SystemSlotChange.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,33 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal.Ids; +using Db4objects.Db4o.Internal.Slots; + +namespace Db4objects.Db4o.Internal.Slots +{ + /// + public class SystemSlotChange : SlotChange + { + public SystemSlotChange(int id) : base(id) + { + } + + public override void AccumulateFreeSlot(TransactionalIdSystemImpl idSystem, FreespaceCommitter + freespaceCommitter, bool forFreespace) + { + base.AccumulateFreeSlot(idSystem, freespaceCommitter, forFreespace); + } + + // FIXME: If we are doing a delete, we should also free our pointer here. + protected override Slot ModifiedSlotInParentIdSystem(TransactionalIdSystemImpl idSystem + ) + { + return null; + } + + public override bool RemoveId() + { + return _newSlot == Slot.Zero; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/StatefulBuffer.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/StatefulBuffer.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/StatefulBuffer.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/StatefulBuffer.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,238 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Slots; +using Sharpen; + +namespace Db4objects.Db4o.Internal +{ + /// + /// public for .NET conversion reasons + /// TODO: Split this class for individual usecases. + /// + /// + /// public for .NET conversion reasons + /// TODO: Split this class for individual usecases. Only use the member + /// variables needed for the respective usecase. + /// + /// + public sealed class StatefulBuffer : ByteArrayBuffer + { + internal Db4objects.Db4o.Internal.Transaction _trans; + + private int _address; + + private int _addressOffset; + + private int _cascadeDelete; + + private int _id; + + private int _length; + + public StatefulBuffer(Db4objects.Db4o.Internal.Transaction trans, int initialBufferSize + ) + { + _trans = trans; + _length = initialBufferSize; + _buffer = new byte[_length]; + } + + public StatefulBuffer(Db4objects.Db4o.Internal.Transaction trans, int address, int + length) : this(trans, length) + { + _address = address; + } + + public StatefulBuffer(Db4objects.Db4o.Internal.Transaction trans, Db4objects.Db4o.Internal.Slots.Slot + slot) : this(trans, slot.Address(), slot.Length()) + { + } + + public StatefulBuffer(Db4objects.Db4o.Internal.Transaction trans, Pointer4 pointer + ) : this(trans, pointer._slot) + { + _id = pointer._id; + } + + public void DebugCheckBytes() + { + } + + // Db4o.log("!!! YapBytes.debugCheckBytes not all bytes used"); + // This is normal for writing The FreeSlotArray, becauce one + // slot is possibly reserved by it's own pointer. + public int GetAddress() + { + return _address; + } + + public int GetID() + { + return _id; + } + + public override int Length() + { + return _length; + } + + public ObjectContainerBase Container() + { + return _trans.Container(); + } + + public LocalObjectContainer File() + { + return ((LocalTransaction)_trans).LocalContainer(); + } + + public Db4objects.Db4o.Internal.Transaction Transaction() + { + return _trans; + } + + public byte[] GetWrittenBytes() + { + byte[] bytes = new byte[_offset]; + System.Array.Copy(_buffer, 0, bytes, 0, _offset); + return bytes; + } + + /// + public void Read() + { + Container().ReadBytes(_buffer, _address, _addressOffset, _length); + } + + public Db4objects.Db4o.Internal.StatefulBuffer ReadStatefulBuffer() + { + int length = ReadInt(); + if (length == 0) + { + return null; + } + Db4objects.Db4o.Internal.StatefulBuffer yb = new Db4objects.Db4o.Internal.StatefulBuffer + (_trans, length); + System.Array.Copy(_buffer, _offset, yb._buffer, 0, length); + _offset += length; + return yb; + } + + public void RemoveFirstBytes(int aLength) + { + _length -= aLength; + byte[] temp = new byte[_length]; + System.Array.Copy(_buffer, aLength, temp, 0, _length); + _buffer = temp; + _offset -= aLength; + if (_offset < 0) + { + _offset = 0; + } + } + + public void Address(int address) + { + _address = address; + } + + public void SetID(int id) + { + _id = id; + } + + public void SetTransaction(Db4objects.Db4o.Internal.Transaction aTrans) + { + _trans = aTrans; + } + + public void UseSlot(int adress) + { + _address = adress; + _offset = 0; + } + + // FIXME: FB remove + public void UseSlot(int address, int length) + { + UseSlot(new Db4objects.Db4o.Internal.Slots.Slot(address, length)); + } + + public void UseSlot(Db4objects.Db4o.Internal.Slots.Slot slot) + { + _address = slot.Address(); + _offset = 0; + if (slot.Length() > _buffer.Length) + { + _buffer = new byte[slot.Length()]; + } + _length = slot.Length(); + } + + // FIXME: FB remove + public void UseSlot(int id, int adress, int length) + { + _id = id; + UseSlot(adress, length); + } + + public void Write() + { + File().WriteBytes(this, _address, _addressOffset); + } + + public void WriteEncrypt() + { + File().WriteEncrypt(this, _address, _addressOffset); + } + + public ByteArrayBuffer ReadPayloadWriter(int offset, int length) + { + Db4objects.Db4o.Internal.StatefulBuffer payLoad = new Db4objects.Db4o.Internal.StatefulBuffer + (_trans, 0, length); + System.Array.Copy(_buffer, offset, payLoad._buffer, 0, length); + TransferPayLoadAddress(payLoad, offset); + return payLoad; + } + + private void TransferPayLoadAddress(Db4objects.Db4o.Internal.StatefulBuffer toWriter + , int offset) + { + int blockedOffset = offset / Container().BlockSize(); + toWriter._address = _address + blockedOffset; + toWriter._id = toWriter._address; + toWriter._addressOffset = _addressOffset; + } + + public void MoveForward(int length) + { + _addressOffset += length; + } + + public override string ToString() + { + return "id " + _id + " adr " + _address + " len " + _length; + } + + public Db4objects.Db4o.Internal.Slots.Slot Slot() + { + return new Db4objects.Db4o.Internal.Slots.Slot(_address, _length); + } + + public Pointer4 Pointer() + { + return new Pointer4(_id, Slot()); + } + + public int CascadeDeletes() + { + return _cascadeDelete; + } + + public void SetCascadeDeletes(int depth) + { + _cascadeDelete = depth; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/StoredClassImpl.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/StoredClassImpl.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/StoredClassImpl.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/StoredClassImpl.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,131 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using Db4objects.Db4o.Ext; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal; + +namespace Db4objects.Db4o.Internal +{ + /// + public class StoredClassImpl : IStoredClass + { + private readonly Transaction _transaction; + + private readonly ClassMetadata _classMetadata; + + public StoredClassImpl(Transaction transaction, ClassMetadata classMetadata) + { + if (classMetadata == null) + { + throw new ArgumentException(); + } + _transaction = transaction; + _classMetadata = classMetadata; + } + + public virtual long[] GetIDs() + { + return _classMetadata.GetIDs(_transaction); + } + + public virtual string GetName() + { + return _classMetadata.GetName(); + } + + public virtual IStoredClass GetParentStoredClass() + { + ClassMetadata parentClassMetadata = _classMetadata.GetAncestor(); + if (parentClassMetadata == null) + { + return null; + } + return new Db4objects.Db4o.Internal.StoredClassImpl(_transaction, parentClassMetadata + ); + } + + public virtual IStoredField[] GetStoredFields() + { + IStoredField[] fieldMetadata = _classMetadata.GetStoredFields(); + IStoredField[] storedFields = new IStoredField[fieldMetadata.Length]; + for (int i = 0; i < fieldMetadata.Length; i++) + { + storedFields[i] = new StoredFieldImpl(_transaction, (FieldMetadata)fieldMetadata[ + i]); + } + return storedFields; + } + + public virtual bool HasClassIndex() + { + return _classMetadata.HasClassIndex(); + } + + public virtual void Rename(string newName) + { + IInternalObjectContainer container = (IInternalObjectContainer)_transaction.ObjectContainer + (); + container.SyncExec(new _IClosure4_56(this, newName)); + } + + private sealed class _IClosure4_56 : IClosure4 + { + public _IClosure4_56(StoredClassImpl _enclosing, string newName) + { + this._enclosing = _enclosing; + this.newName = newName; + } + + public object Run() + { + this._enclosing._classMetadata.Rename(newName); + return null; + } + + private readonly StoredClassImpl _enclosing; + + private readonly string newName; + } + + public virtual IStoredField StoredField(string name, object type) + { + FieldMetadata fieldMetadata = (FieldMetadata)_classMetadata.StoredField(name, type + ); + if (fieldMetadata == null) + { + return null; + } + return new StoredFieldImpl(_transaction, fieldMetadata); + } + + public override int GetHashCode() + { + return _classMetadata.GetHashCode(); + } + + public override bool Equals(object obj) + { + if (obj == null) + { + return false; + } + if (GetType() != obj.GetType()) + { + return false; + } + return _classMetadata.Equals(((Db4objects.Db4o.Internal.StoredClassImpl)obj)._classMetadata + ); + } + + public override string ToString() + { + return "StoredClass(" + _classMetadata + ")"; + } + + public virtual int InstanceCount() + { + return _classMetadata.InstanceCount(_transaction); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/StoredFieldImpl.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/StoredFieldImpl.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/StoredFieldImpl.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/StoredFieldImpl.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,107 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Ext; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Reflect; + +namespace Db4objects.Db4o.Internal +{ + /// + public class StoredFieldImpl : IStoredField + { + private readonly Transaction _transaction; + + private readonly Db4objects.Db4o.Internal.FieldMetadata _fieldMetadata; + + public StoredFieldImpl(Transaction transaction, Db4objects.Db4o.Internal.FieldMetadata + fieldMetadata) + { + _transaction = transaction; + _fieldMetadata = fieldMetadata; + } + + public virtual void CreateIndex() + { + lock (Lock()) + { + _fieldMetadata.CreateIndex(); + } + } + + public virtual void DropIndex() + { + lock (Lock()) + { + _fieldMetadata.DropIndex(); + } + } + + private object Lock() + { + return _transaction.Container().Lock(); + } + + public virtual Db4objects.Db4o.Internal.FieldMetadata FieldMetadata() + { + return _fieldMetadata; + } + + public virtual object Get(object onObject) + { + return _fieldMetadata.Get(_transaction, onObject); + } + + public virtual string GetName() + { + return _fieldMetadata.GetName(); + } + + public virtual IReflectClass GetStoredType() + { + return _fieldMetadata.GetStoredType(); + } + + public virtual bool HasIndex() + { + return _fieldMetadata.HasIndex(); + } + + public virtual bool IsArray() + { + return _fieldMetadata.IsArray(); + } + + public virtual void Rename(string name) + { + lock (Lock()) + { + _fieldMetadata.Rename(name); + } + } + + public virtual void TraverseValues(IVisitor4 visitor) + { + _fieldMetadata.TraverseValues(_transaction, visitor); + } + + public override int GetHashCode() + { + return _fieldMetadata.GetHashCode(); + } + + public override bool Equals(object obj) + { + if (obj == null) + { + return false; + } + if (GetType() != obj.GetType()) + { + return false; + } + return _fieldMetadata.Equals(((Db4objects.Db4o.Internal.StoredFieldImpl)obj)._fieldMetadata + ); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/SystemData.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/SystemData.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/SystemData.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/SystemData.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,217 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Ext; +using Db4objects.Db4o.Internal.Ids; +using Db4objects.Db4o.Internal.Slots; + +namespace Db4objects.Db4o.Internal +{ + /// + public class SystemData + { + private int _classCollectionID; + + private int _converterVersion; + + private Slot _inMemoryFreespaceSlot; + + private int _bTreeFreespaceId; + + private byte _freespaceSystem; + + private Db4oDatabase _identity; + + private int _identityId; + + private long _lastTimeStampID; + + private byte _stringEncoding; + + private int _uuidIndexId; + + private byte _idSystemType; + + private int _transactionPointer1; + + private int _transactionPointer2; + + private Slot _idSystemSlot; + + private int _idToTimestampIndexId; + + private int _timestampToIdIndexId; + + public virtual Slot IdSystemSlot() + { + return _idSystemSlot; + } + + public virtual void IdSystemSlot(Slot slot) + { + _idSystemSlot = slot; + } + + private ITransactionalIdSystem _freespaceIdSystem; + + public virtual void IdSystemType(byte idSystem) + { + _idSystemType = idSystem; + } + + public virtual byte IdSystemType() + { + return _idSystemType; + } + + public virtual int ClassCollectionID() + { + return _classCollectionID; + } + + public virtual void ClassCollectionID(int id) + { + _classCollectionID = id; + } + + public virtual int ConverterVersion() + { + return _converterVersion; + } + + public virtual void ConverterVersion(int version) + { + _converterVersion = version; + } + + public virtual int BTreeFreespaceId() + { + return _bTreeFreespaceId; + } + + public virtual void BTreeFreespaceId(int id) + { + _bTreeFreespaceId = id; + } + + public virtual Slot InMemoryFreespaceSlot() + { + return _inMemoryFreespaceSlot; + } + + public virtual void InMemoryFreespaceSlot(Slot slot) + { + _inMemoryFreespaceSlot = slot; + } + + public virtual byte FreespaceSystem() + { + return _freespaceSystem; + } + + public virtual void FreespaceSystem(byte freespaceSystemtype) + { + _freespaceSystem = freespaceSystemtype; + } + + public virtual Db4oDatabase Identity() + { + return _identity; + } + + public virtual void Identity(Db4oDatabase identityObject) + { + _identity = identityObject; + } + + public virtual long LastTimeStampID() + { + return _lastTimeStampID; + } + + public virtual void LastTimeStampID(long id) + { + _lastTimeStampID = id; + } + + public virtual byte StringEncoding() + { + return _stringEncoding; + } + + public virtual void StringEncoding(byte encodingByte) + { + _stringEncoding = encodingByte; + } + + public virtual int UuidIndexId() + { + return _uuidIndexId; + } + + public virtual void UuidIndexId(int id) + { + _uuidIndexId = id; + } + + public virtual void IdentityId(int id) + { + _identityId = id; + } + + public virtual int IdentityId() + { + return _identityId; + } + + public virtual void TransactionPointer1(int pointer) + { + _transactionPointer1 = pointer; + } + + public virtual void TransactionPointer2(int pointer) + { + _transactionPointer2 = pointer; + } + + public virtual int TransactionPointer1() + { + return _transactionPointer1; + } + + public virtual int TransactionPointer2() + { + return _transactionPointer2; + } + + public virtual void FreespaceIdSystem(ITransactionalIdSystem transactionalIdSystem + ) + { + _freespaceIdSystem = transactionalIdSystem; + } + + public virtual ITransactionalIdSystem FreespaceIdSystem() + { + return _freespaceIdSystem; + } + + public virtual void IdToTimestampIndexId(int idToTimestampIndexId) + { + _idToTimestampIndexId = idToTimestampIndexId; + } + + public virtual int IdToTimestampIndexId() + { + return _idToTimestampIndexId; + } + + public virtual void TimestampToIdIndexId(int timestampToIdIndexId) + { + _timestampToIdIndexId = timestampToIdIndexId; + } + + public virtual int TimestampToIdIndexId() + { + return _timestampToIdIndexId; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/SystemInfoFileImpl.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/SystemInfoFileImpl.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/SystemInfoFileImpl.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/SystemInfoFileImpl.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,54 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Ext; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Freespace; + +namespace Db4objects.Db4o.Internal +{ + /// + public class SystemInfoFileImpl : ISystemInfo + { + private LocalObjectContainer _file; + + public SystemInfoFileImpl(LocalObjectContainer file) + { + _file = file; + } + + public virtual int FreespaceEntryCount() + { + if (!HasFreespaceManager()) + { + return 0; + } + return FreespaceManager().SlotCount(); + } + + private bool HasFreespaceManager() + { + return FreespaceManager() != null; + } + + private IFreespaceManager FreespaceManager() + { + return _file.FreespaceManager(); + } + + public virtual long FreespaceSize() + { + if (!HasFreespaceManager()) + { + return 0; + } + long blockSize = _file.BlockSize(); + long blockedSize = FreespaceManager().TotalFreespace(); + return blockSize * blockedSize; + } + + public virtual long TotalSize() + { + return _file.FileLength(); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Threading/IThreadPool4.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Threading/IThreadPool4.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Threading/IThreadPool4.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Threading/IThreadPool4.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,18 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Sharpen.Lang; + +namespace Db4objects.Db4o.Internal.Threading +{ + public interface IThreadPool4 + { + void Start(string taskName, IRunnable task); + + void StartLowPriority(string taskName, IRunnable task); + + event System.EventHandler UncaughtException; + + /// + void Join(int timeoutMilliseconds); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Threading/ThreadPool4Impl.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Threading/ThreadPool4Impl.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Threading/ThreadPool4Impl.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Threading/ThreadPool4Impl.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,124 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using System.Collections.Generic; +using Db4objects.Db4o.Internal.Threading; +using Sharpen.Lang; + +namespace Db4objects.Db4o.Internal.Threading +{ + public class ThreadPool4Impl : IThreadPool4 + { + private System.EventHandler _uncaughtException; + + private readonly IList _activeThreads = new List(); + + /// + public virtual void Join(int timeoutMilliseconds) + { + foreach (Thread thread in ActiveThreads()) + { + thread.Join(timeoutMilliseconds); + } + } + + public virtual void StartLowPriority(string taskName, IRunnable task) + { + Thread thread = ThreadFor(taskName, task); + ActivateThread(thread); + } + + public virtual void Start(string taskName, IRunnable task) + { + Thread thread = ThreadFor(taskName, task); + ActivateThread(thread); + } + + private Thread ThreadFor(string threadName, IRunnable task) + { + Thread thread = new Thread(new _IRunnable_41(this, task), threadName); + thread.SetDaemon(true); + return thread; + } + + private sealed class _IRunnable_41 : IRunnable + { + public _IRunnable_41(ThreadPool4Impl _enclosing, IRunnable task) + { + this._enclosing = _enclosing; + this.task = task; + } + + public void Run() + { + try + { + task.Run(); + } + catch (Exception e) + { + this._enclosing.TriggerUncaughtExceptionEvent(e); + } + finally + { + this._enclosing.Dispose(Thread.CurrentThread()); + } + } + + private readonly ThreadPool4Impl _enclosing; + + private readonly IRunnable task; + } + + private void ActivateThread(Thread thread) + { + AddActiveThread(thread); + thread.Start(); + } + + private Thread[] ActiveThreads() + { + lock (_activeThreads) + { + return Sharpen.Collections.ToArray(_activeThreads, new Thread[_activeThreads.Count + ]); + } + } + + private void AddActiveThread(Thread thread) + { + lock (_activeThreads) + { + _activeThreads.Add(thread); + } + } + + protected virtual void Dispose(Thread thread) + { + lock (_activeThreads) + { + _activeThreads.Remove(thread); + } + } + + protected virtual void TriggerUncaughtExceptionEvent(Exception e) + { + if (null != _uncaughtException) _uncaughtException(null, new UncaughtExceptionEventArgs + (e)); + } + + public virtual event System.EventHandler UncaughtException + { + add + { + _uncaughtException = (System.EventHandler)System.Delegate.Combine + (_uncaughtException, value); + } + remove + { + _uncaughtException = (System.EventHandler)System.Delegate.Remove + (_uncaughtException, value); + } + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Threading/UncaughtExceptionEventArgs.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Threading/UncaughtExceptionEventArgs.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Threading/UncaughtExceptionEventArgs.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Threading/UncaughtExceptionEventArgs.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,24 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; + +namespace Db4objects.Db4o.Internal.Threading +{ + public class UncaughtExceptionEventArgs : EventArgs + { + private System.Exception _exception; + + public UncaughtExceptionEventArgs(System.Exception e) + { + _exception = e; + } + + public virtual System.Exception Exception + { + get + { + return _exception; + } + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/TransactionContext.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/TransactionContext.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/TransactionContext.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/TransactionContext.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,20 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal; + +namespace Db4objects.Db4o.Internal +{ + /// + public class TransactionContext + { + public readonly Transaction _transaction; + + public readonly object _object; + + public TransactionContext(Transaction transaction, object obj) + { + _transaction = transaction; + _object = obj; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Transaction.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Transaction.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Transaction.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Transaction.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,402 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System.Collections; +using Db4objects.Db4o; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Ids; +using Db4objects.Db4o.Internal.References; +using Db4objects.Db4o.Marshall; +using Db4objects.Db4o.Reflect; + +namespace Db4objects.Db4o.Internal +{ + /// + public abstract class Transaction + { + private IContext _context; + + internal Tree _delete; + + protected readonly Db4objects.Db4o.Internal.Transaction _systemTransaction; + + /// + /// This is the inside representation to operate against, the actual + /// file-based ObjectContainerBase or the client. + /// + /// + /// This is the inside representation to operate against, the actual + /// file-based ObjectContainerBase or the client. For all calls + /// against this ObjectContainerBase the method signatures that take + /// a transaction have to be used. + /// + private readonly ObjectContainerBase _container; + + /// This is the outside representation to the user. + /// + /// This is the outside representation to the user. This ObjectContainer + /// should use this transaction as it's main user transation, so it also + /// allows using the method signatures on ObjectContainer without a + /// transaction. + /// + private IObjectContainer _objectContainer; + + private List4 _transactionListeners; + + private readonly IReferenceSystem _referenceSystem; + + private readonly IDictionary _locals = new Hashtable(); + + public Transaction(ObjectContainerBase container, Db4objects.Db4o.Internal.Transaction + systemTransaction, IReferenceSystem referenceSystem) + { + // contains DeleteInfo nodes + _container = container; + _systemTransaction = systemTransaction; + _referenceSystem = referenceSystem; + } + + /// Retrieves the value of a transaction local variables. + /// + /// Retrieves the value of a transaction local variables. + /// If this is the first time the variable is accessed + /// TransactionLocal.InitialValueFor(Transaction) + /// + /// will provide the initial value. + /// + public virtual ByRef Get(TransactionLocal local) + { + ByRef existing = (ByRef)_locals[local]; + if (null != existing) + { + return existing; + } + ByRef initialValue = ByRef.NewInstance(local.InitialValueFor(this)); + _locals[local] = initialValue; + return initialValue; + } + + public void CheckSynchronization() + { + } + + public virtual void AddTransactionListener(ITransactionListener listener) + { + _transactionListeners = new List4(_transactionListeners, listener); + } + + protected void ClearAll() + { + Clear(); + _transactionListeners = null; + _locals.Clear(); + } + + protected abstract void Clear(); + + public virtual void Close(bool rollbackOnClose) + { + if (Container() != null) + { + CheckSynchronization(); + Container().ReleaseSemaphores(this); + DiscardReferenceSystem(); + } + if (rollbackOnClose) + { + Rollback(); + } + ITransactionalIdSystem idSystem = IdSystem(); + if (idSystem != null) + { + idSystem.Close(); + } + } + + protected virtual void DiscardReferenceSystem() + { + if (_referenceSystem != null) + { + Container().ReferenceSystemRegistry().RemoveReferenceSystem(_referenceSystem); + } + } + + public abstract void Commit(); + + protected virtual void CommitTransactionListeners() + { + CheckSynchronization(); + if (_transactionListeners != null) + { + IEnumerator i = new Iterator4Impl(_transactionListeners); + while (i.MoveNext()) + { + ((ITransactionListener)i.Current).PreCommit(); + } + _transactionListeners = null; + } + } + + protected virtual bool IsSystemTransaction() + { + return _systemTransaction == null; + } + + public virtual bool Delete(ObjectReference @ref, int id, int cascade) + { + CheckSynchronization(); + if (@ref != null) + { + if (!_container.FlagForDelete(@ref)) + { + return false; + } + } + if (DTrace.enabled) + { + DTrace.TransDelete.Log(id); + } + DeleteInfo info = (DeleteInfo)TreeInt.Find(_delete, id); + if (info == null) + { + info = new DeleteInfo(id, @ref, cascade); + _delete = Tree.Add(_delete, info); + return true; + } + info._reference = @ref; + if (cascade > info._cascade) + { + info._cascade = cascade; + } + return true; + } + + public virtual void DontDelete(int a_id) + { + if (DTrace.enabled) + { + DTrace.TransDontDelete.Log(a_id); + } + if (_delete == null) + { + return; + } + _delete = TreeInt.RemoveLike((TreeInt)_delete, a_id); + } + + public abstract void ProcessDeletes(); + + public virtual IReferenceSystem ReferenceSystem() + { + if (_referenceSystem != null) + { + return _referenceSystem; + } + return ParentTransaction().ReferenceSystem(); + } + + public IReflector Reflector() + { + return Container().Reflector(); + } + + public abstract void Rollback(); + + protected virtual void RollBackTransactionListeners() + { + CheckSynchronization(); + if (_transactionListeners != null) + { + IEnumerator i = new Iterator4Impl(_transactionListeners); + while (i.MoveNext()) + { + ((ITransactionListener)i.Current).PostRollback(); + } + _transactionListeners = null; + } + } + + internal virtual bool SupportsVirtualFields() + { + return true; + } + + public virtual Db4objects.Db4o.Internal.Transaction SystemTransaction() + { + if (_systemTransaction != null) + { + return _systemTransaction; + } + return this; + } + + public override string ToString() + { + return Container().ToString(); + } + + public abstract void WriteUpdateAdjustIndexes(int id, ClassMetadata clazz, ArrayType + typeInfo); + + public ObjectContainerBase Container() + { + return _container; + } + + public virtual Db4objects.Db4o.Internal.Transaction ParentTransaction() + { + return _systemTransaction; + } + + public virtual void RollbackReferenceSystem() + { + ReferenceSystem().Rollback(); + } + + public virtual void CommitReferenceSystem() + { + ReferenceSystem().Commit(); + } + + public virtual void AddNewReference(ObjectReference @ref) + { + ReferenceSystem().AddNewReference(@ref); + } + + public object ObjectForIdFromCache(int id) + { + ObjectReference @ref = ReferenceForId(id); + if (@ref == null) + { + return null; + } + object candidate = @ref.GetObject(); + if (candidate == null) + { + RemoveReference(@ref); + } + return candidate; + } + + public ObjectReference ReferenceForId(int id) + { + ObjectReference @ref = ReferenceSystem().ReferenceForId(id); + if (@ref != null) + { + if (@ref.GetObject() == null) + { + RemoveReference(@ref); + return null; + } + return @ref; + } + if (ParentTransaction() != null) + { + return ParentTransaction().ReferenceForId(id); + } + return null; + } + + public ObjectReference ReferenceForObject(object obj) + { + ObjectReference @ref = ReferenceSystem().ReferenceForObject(obj); + if (@ref != null) + { + return @ref; + } + if (ParentTransaction() != null) + { + return ParentTransaction().ReferenceForObject(obj); + } + return null; + } + + public void RemoveReference(ObjectReference @ref) + { + ReferenceSystem().RemoveReference(@ref); + // setting the ID to minus 1 ensures that the + // gc mechanism does not kill the new YapObject + @ref.SetID(-1); + Platform4.KillYapRef(@ref.GetObjectReference()); + } + + public void RemoveObjectFromReferenceSystem(object obj) + { + ObjectReference @ref = ReferenceForObject(obj); + if (@ref != null) + { + RemoveReference(@ref); + } + } + + public virtual void SetOutSideRepresentation(IObjectContainer objectContainer) + { + _objectContainer = objectContainer; + } + + public virtual IObjectContainer ObjectContainer() + { + if (_objectContainer != null) + { + return _objectContainer; + } + return _container; + } + + public virtual IContext Context() + { + if (_context == null) + { + _context = new _IContext_295(this); + } + return _context; + } + + private sealed class _IContext_295 : IContext + { + public _IContext_295(Transaction _enclosing) + { + this._enclosing = _enclosing; + } + + public IObjectContainer ObjectContainer() + { + return this._enclosing.ObjectContainer(); + } + + public Db4objects.Db4o.Internal.Transaction Transaction() + { + return this._enclosing; + } + + private readonly Transaction _enclosing; + } + + protected virtual void TraverseDelete(IVisitor4 deleteVisitor) + { + if (_delete == null) + { + return; + } + _delete.Traverse(deleteVisitor); + _delete = null; + } + + public virtual object Wrap(object value) + { + if (value is int) + { + return value; + } + return new TransactionContext(this, value); + } + + public abstract ITransactionalIdSystem IdSystem(); + + public abstract long VersionForId(int id); + + public abstract long GenerateTransactionTimestamp(long forcedTimeStamp); + + public abstract void UseDefaultTransactionTimestamp(); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/TransactionLocal.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/TransactionLocal.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/TransactionLocal.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/TransactionLocal.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,18 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal; + +namespace Db4objects.Db4o.Internal +{ + /// A transaction local variable. + /// A transaction local variable. + /// Transaction.Get(TransactionLocal) + /// + public class TransactionLocal + { + public virtual object InitialValueFor(Transaction transaction) + { + return null; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Transactionlog/EmbeddedTransactionLogHandler.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Transactionlog/EmbeddedTransactionLogHandler.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Transactionlog/EmbeddedTransactionLogHandler.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Transactionlog/EmbeddedTransactionLogHandler.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,113 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Freespace; +using Db4objects.Db4o.Internal.Slots; +using Db4objects.Db4o.Internal.Transactionlog; +using Sharpen.Lang; + +namespace Db4objects.Db4o.Internal.Transactionlog +{ + /// + public class EmbeddedTransactionLogHandler : TransactionLogHandler + { + public EmbeddedTransactionLogHandler(LocalObjectContainer container) : base(container + ) + { + } + + public override void CompleteInterruptedTransaction(int transactionId1, int transactionId2 + ) + { + if (transactionId1 <= 0 || transactionId1 != transactionId2) + { + return; + } + StatefulBuffer bytes = new StatefulBuffer(_container.SystemTransaction(), transactionId1 + , Const4.IntLength); + bytes.Read(); + int length = bytes.ReadInt(); + if (length > 0) + { + bytes = new StatefulBuffer(_container.SystemTransaction(), transactionId1, length + ); + bytes.Read(); + bytes.IncrementOffset(Const4.IntLength); + ReadWriteSlotChanges(bytes); + } + _container.WriteTransactionPointer(0); + FlushDatabaseFile(); + } + + public override Slot AllocateSlot(bool appendToFile, int slotChangeCount) + { + int transactionLogByteCount = TransactionLogSlotLength(slotChangeCount); + IFreespaceManager freespaceManager = _container.FreespaceManager(); + if (!appendToFile && freespaceManager != null) + { + Slot slot = freespaceManager.AllocateTransactionLogSlot(transactionLogByteCount); + if (slot != null) + { + return slot; + } + } + return _container.AppendBytes(transactionLogByteCount); + } + + private void FreeSlot(Slot slot) + { + if (slot == null) + { + return; + } + if (_container.FreespaceManager() == null) + { + return; + } + _container.FreespaceManager().FreeSafeSlot(slot); + } + + public override void ApplySlotChanges(IVisitable slotChangeTree, int slotChangeCount + , Slot reservedSlot) + { + if (slotChangeCount > 0) + { + Slot transactionLogSlot = SlotLongEnoughForLog(slotChangeCount, reservedSlot) ? reservedSlot + : AllocateSlot(true, slotChangeCount); + StatefulBuffer buffer = new StatefulBuffer(_container.SystemTransaction(), transactionLogSlot + ); + buffer.WriteInt(transactionLogSlot.Length()); + buffer.WriteInt(slotChangeCount); + AppendSlotChanges(buffer, slotChangeTree); + buffer.Write(); + IRunnable commitHook = _container.CommitHook(); + FlushDatabaseFile(); + _container.WriteTransactionPointer(transactionLogSlot.Address()); + FlushDatabaseFile(); + if (WriteSlots(slotChangeTree)) + { + FlushDatabaseFile(); + } + _container.WriteTransactionPointer(0); + commitHook.Run(); + FlushDatabaseFile(); + if (transactionLogSlot != reservedSlot) + { + FreeSlot(transactionLogSlot); + } + } + FreeSlot(reservedSlot); + } + + private bool SlotLongEnoughForLog(int slotChangeCount, Slot slot) + { + return slot != null && slot.Length() >= TransactionLogSlotLength(slotChangeCount); + } + + public override void Close() + { + } + // do nothing + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Transactionlog/FileBasedTransactionLogHandler.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Transactionlog/FileBasedTransactionLogHandler.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Transactionlog/FileBasedTransactionLogHandler.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Transactionlog/FileBasedTransactionLogHandler.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,225 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Foundation.IO; +using Db4objects.Db4o.IO; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Slots; +using Db4objects.Db4o.Internal.Transactionlog; +using Sharpen.Lang; + +namespace Db4objects.Db4o.Internal.Transactionlog +{ + /// + public class FileBasedTransactionLogHandler : TransactionLogHandler + { + internal const int LockInt = int.MaxValue - 1; + + private IBin _lockFile; + + private IBin _logFile; + + private readonly string _fileName; + + public FileBasedTransactionLogHandler(LocalObjectContainer container, string fileName + ) : base(container) + { + _fileName = fileName; + } + + public static string LogFileName(string fileName) + { + return fileName + ".log"; + } + + public static string LockFileName(string fileName) + { + return fileName + ".lock"; + } + + private IBin OpenBin(string fileName) + { + return new FileStorage().Open(new BinConfiguration(fileName, _container.Config(). + LockFile(), 0, false)); + } + + public override void CompleteInterruptedTransaction(int transactionId1, int transactionId2 + ) + { + if (!System.IO.File.Exists(LockFileName(_fileName))) + { + return; + } + if (!LockFileSignalsInterruptedTransaction()) + { + return; + } + ByteArrayBuffer buffer = new ByteArrayBuffer(Const4.IntLength); + OpenLogFile(); + Read(_logFile, buffer); + int length = buffer.ReadInt(); + if (length > 0) + { + buffer = new ByteArrayBuffer(length); + Read(_logFile, buffer); + buffer.IncrementOffset(Const4.IntLength); + ReadWriteSlotChanges(buffer); + } + DeleteLockFile(); + CloseLogFile(); + DeleteLogFile(); + } + + private bool LockFileSignalsInterruptedTransaction() + { + OpenLockFile(); + ByteArrayBuffer buffer = NewLockFileBuffer(); + Read(_lockFile, buffer); + for (int i = 0; i < 2; i++) + { + int checkInt = buffer.ReadInt(); + if (checkInt != LockInt) + { + CloseLockFile(); + return false; + } + } + CloseLockFile(); + return true; + } + + public override void Close() + { + if (!LogsOpened()) + { + return; + } + CloseLockFile(); + CloseLogFile(); + DeleteLockFile(); + DeleteLogFile(); + } + + private void CloseLockFile() + { + SyncAndClose(_lockFile); + _lockFile = null; + } + + private void SyncAndClose(IBin bin) + { + try + { + bin.Sync(); + } + finally + { + bin.Close(); + } + } + + private void CloseLogFile() + { + SyncAndClose(_logFile); + _logFile = null; + } + + private void DeleteLockFile() + { + File4.Delete(LockFileName(_fileName)); + } + + private void DeleteLogFile() + { + File4.Delete(LogFileName(_fileName)); + } + + public override Slot AllocateSlot(bool append, int slotChangeCount) + { + // do nothing + return null; + } + + public override void ApplySlotChanges(IVisitable slotChangeTree, int slotChangeCount + , Slot reservedSlot) + { + if (slotChangeCount < 1) + { + return; + } + IRunnable commitHook = _container.CommitHook(); + FlushDatabaseFile(); + EnsureLogAndLock(); + int length = TransactionLogSlotLength(slotChangeCount); + ByteArrayBuffer logBuffer = new ByteArrayBuffer(length); + logBuffer.WriteInt(length); + logBuffer.WriteInt(slotChangeCount); + AppendSlotChanges(logBuffer, slotChangeTree); + Write(_logFile, logBuffer); + _logFile.Sync(); + WriteToLockFile(LockInt); + WriteSlots(slotChangeTree); + commitHook.Run(); + FlushDatabaseFile(); + WriteToLockFile(0); + } + + private void WriteToLockFile(int lockSignal) + { + ByteArrayBuffer lockBuffer = NewLockFileBuffer(); + lockBuffer.WriteInt(lockSignal); + lockBuffer.WriteInt(lockSignal); + Write(_lockFile, lockBuffer); + _lockFile.Sync(); + } + + private ByteArrayBuffer NewLockFileBuffer() + { + return new ByteArrayBuffer(LockFileBufferLength()); + } + + private int LockFileBufferLength() + { + return Const4.LongLength * 2; + } + + private void EnsureLogAndLock() + { + if (_container.Config().IsReadOnly()) + { + return; + } + if (LogsOpened()) + { + return; + } + OpenLockFile(); + OpenLogFile(); + } + + private void OpenLogFile() + { + _logFile = OpenBin(LogFileName(_fileName)); + } + + private void OpenLockFile() + { + _lockFile = OpenBin(LockFileName(_fileName)); + } + + private bool LogsOpened() + { + return _lockFile != null; + } + + private void Read(IBin storage, ByteArrayBuffer buffer) + { + storage.Read(0, buffer._buffer, buffer.Length()); + } + + private void Write(IBin storage, ByteArrayBuffer buffer) + { + storage.Write(0, buffer._buffer, buffer.Length()); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Transactionlog/TransactionLogHandler.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Transactionlog/TransactionLogHandler.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Transactionlog/TransactionLogHandler.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Transactionlog/TransactionLogHandler.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,118 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Slots; + +namespace Db4objects.Db4o.Internal.Transactionlog +{ + /// + public abstract class TransactionLogHandler + { + protected readonly LocalObjectContainer _container; + + protected TransactionLogHandler(LocalObjectContainer container) + { + _container = container; + } + + protected virtual LocalObjectContainer LocalContainer() + { + return _container; + } + + protected void FlushDatabaseFile() + { + _container.SyncFiles(); + } + + protected void AppendSlotChanges(ByteArrayBuffer writer, IVisitable slotChangeVisitable + ) + { + slotChangeVisitable.Accept(new _IVisitor4_30(writer)); + } + + private sealed class _IVisitor4_30 : IVisitor4 + { + public _IVisitor4_30(ByteArrayBuffer writer) + { + this.writer = writer; + } + + public void Visit(object obj) + { + ((SlotChange)obj).Write(writer); + } + + private readonly ByteArrayBuffer writer; + } + + protected virtual bool WriteSlots(IVisitable slotChangeTree) + { + BooleanByRef ret = new BooleanByRef(); + slotChangeTree.Accept(new _IVisitor4_39(this, ret)); + return ret.value; + } + + private sealed class _IVisitor4_39 : IVisitor4 + { + public _IVisitor4_39(TransactionLogHandler _enclosing, BooleanByRef ret) + { + this._enclosing = _enclosing; + this.ret = ret; + } + + public void Visit(object obj) + { + ((SlotChange)obj).WritePointer(this._enclosing._container); + ret.value = true; + } + + private readonly TransactionLogHandler _enclosing; + + private readonly BooleanByRef ret; + } + + protected int TransactionLogSlotLength(int slotChangeCount) + { + // slotchanges * 3 for ID, address, length + // 2 ints for slotlength and count + return ((slotChangeCount * 3) + 2) * Const4.IntLength; + } + + public abstract Slot AllocateSlot(bool append, int slotChangeCount); + + public abstract void ApplySlotChanges(IVisitable slotChangeTree, int slotChangeCount + , Slot reservedSlot); + + public abstract void CompleteInterruptedTransaction(int transactionId1, int transactionId2 + ); + + public abstract void Close(); + + protected virtual void ReadWriteSlotChanges(ByteArrayBuffer buffer) + { + LockedTree slotChanges = new LockedTree(); + slotChanges.Read(buffer, new SlotChange(0)); + if (WriteSlots(new _IVisitable_65(slotChanges))) + { + FlushDatabaseFile(); + } + } + + private sealed class _IVisitable_65 : IVisitable + { + public _IVisitable_65(LockedTree slotChanges) + { + this.slotChanges = slotChanges; + } + + public void Accept(IVisitor4 visitor) + { + slotChanges.TraverseMutable(visitor); + } + + private readonly LockedTree slotChanges; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/TransactionObjectCarrier.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/TransactionObjectCarrier.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/TransactionObjectCarrier.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/TransactionObjectCarrier.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,42 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Ids; +using Db4objects.Db4o.Internal.References; + +namespace Db4objects.Db4o.Internal +{ + /// TODO: Check if all time-consuming stuff is overridden! + internal class TransactionObjectCarrier : LocalTransaction + { + private readonly ITransactionalIdSystem _idSystem; + + internal TransactionObjectCarrier(ObjectContainerBase container, Transaction parentTransaction + , ITransactionalIdSystem idSystem, IReferenceSystem referenceSystem) : base(container + , parentTransaction, idSystem, referenceSystem) + { + _idSystem = idSystem; + } + + public override void Commit() + { + } + + // do nothing + internal override bool SupportsVirtualFields() + { + return false; + } + + public override long VersionForId(int id) + { + return 0; + } + + public override Db4objects.Db4o.Internal.CommitTimestampSupport CommitTimestampSupport + () + { + return null; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/TranslatedAspect.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/TranslatedAspect.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/TranslatedAspect.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/TranslatedAspect.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,199 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using Db4objects.Db4o.Config; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Marshall; +using Db4objects.Db4o.Reflect; +using Db4objects.Db4o.Typehandlers; + +namespace Db4objects.Db4o.Internal +{ + public sealed class TranslatedAspect : FieldMetadata + { + private IObjectTranslator _translator; + + public TranslatedAspect(ClassMetadata containingClass, string name) : this(containingClass + ) + { + Init(name); + } + + public TranslatedAspect(ClassMetadata containingClass, IObjectTranslator translator + ) : this(containingClass) + { + InitializeTranslator(translator); + } + + private TranslatedAspect(ClassMetadata containingClass) : base(containingClass) + { + SetAvailable(); + } + + public void InitializeTranslator(IObjectTranslator translator) + { + _translator = translator; + InitializeFieldName(); + InitializeFieldType(); + } + + public override bool Alive() + { + return true; + } + + private void InitializeFieldName() + { + Init(FieldNameFor(_translator)); + } + + private void InitializeFieldType() + { + ObjectContainerBase stream = ContainingClass().Container(); + IReflectClass storedClass = stream.Reflector().ForClass(TranslatorStoredClass(_translator + )); + Configure(storedClass, false); + IReflectClass baseType = Handlers4.BaseType(storedClass); + stream.ShowInternalClasses(true); + try + { + _fieldType = stream.ProduceClassMetadata(baseType); + } + finally + { + stream.ShowInternalClasses(false); + } + if (null == _fieldType) + { + throw new InvalidOperationException("Cannot produce class metadata for " + baseType + + "!"); + } + } + + public static string FieldNameFor(IObjectTranslator translator) + { + return translator.GetType().FullName; + } + + public override bool CanUseNullBitmap() + { + return false; + } + + public override void Deactivate(IActivationContext context) + { + if (context.Depth().RequiresActivation()) + { + CascadeActivation(context); + } + SetOn(context.Transaction(), context.TargetObject(), null); + } + + public override object GetOn(Transaction a_trans, object a_OnObject) + { + try + { + return _translator.OnStore(a_trans.ObjectContainer(), a_OnObject); + } + catch (ReflectException e) + { + throw; + } + catch (Exception e) + { + throw new ReflectException(e); + } + } + + public override object GetOrCreate(Transaction a_trans, object a_OnObject) + { + return GetOn(a_trans, a_OnObject); + } + + public override void Activate(UnmarshallingContext context) + { + object obj = Read(context); + // Activation of members is necessary on purpose here. + // Classes like Hashtable need fully activated members + // to be able to calculate hashCode() + if (obj != null) + { + context.Container().Activate(context.Transaction(), obj, context.ActivationDepth( + )); + } + SetOn(context.Transaction(), context.PersistentObject(), obj); + } + + internal override void Refresh() + { + } + + // do nothing + private void SetOn(Transaction trans, object a_onObject, object toSet) + { + try + { + _translator.OnActivate(trans.ObjectContainer(), a_onObject, toSet); + } + catch (Exception e) + { + throw new ReflectException(e); + } + } + + protected override object IndexEntryFor(object indexEntry) + { + return indexEntry; + } + + protected override IIndexable4 IndexHandler(ObjectContainerBase stream) + { + return (IIndexable4)GetHandler(); + } + + public override bool Equals(object obj) + { + if (obj == this) + { + return true; + } + if (obj == null || obj.GetType() != GetType()) + { + return false; + } + Db4objects.Db4o.Internal.TranslatedAspect other = (Db4objects.Db4o.Internal.TranslatedAspect + )obj; + return _translator.Equals(other._translator); + } + + public override int GetHashCode() + { + return _translator.GetHashCode(); + } + + public override Db4objects.Db4o.Internal.Marshall.AspectType AspectType() + { + return Db4objects.Db4o.Internal.Marshall.AspectType.Translator; + } + + public bool IsObjectConstructor() + { + return _translator is IObjectConstructor; + } + + public object Construct(ObjectReferenceContext context) + { + ContextState contextState = context.SaveState(); + bool fieldHasValue = ContainingClass().SeekToField(context, this); + try + { + return ((IObjectConstructor)_translator).OnInstantiate(context.Container(), fieldHasValue + ? Read(context) : null); + } + finally + { + context.RestoreState(contextState); + } + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/TransportObjectContainer.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/TransportObjectContainer.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/TransportObjectContainer.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/TransportObjectContainer.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,380 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using Db4objects.Db4o.Config; +using Db4objects.Db4o.Ext; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.IO; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Activation; +using Db4objects.Db4o.Internal.Convert; +using Db4objects.Db4o.Internal.Ids; +using Db4objects.Db4o.Internal.References; +using Db4objects.Db4o.Internal.Slots; +using Db4objects.Db4o.Internal.Weakref; +using Db4objects.Db4o.Reflect; +using Db4objects.Db4o.Types; +using Sharpen.Lang; + +namespace Db4objects.Db4o.Internal +{ + /// + /// no reading + /// no writing + /// no updates + /// no weak references + /// navigation by ID only both sides need synchronised ClassCollections and + /// MetaInformationCaches + /// + /// + public class TransportObjectContainer : LocalObjectContainer + { + private readonly ObjectContainerBase _parent; + + private readonly MemoryBin _memoryBin; + + public TransportObjectContainer(ObjectContainerBase parent, MemoryBin memoryFile) + : base(parent.Config()) + { + _memoryBin = memoryFile; + _parent = parent; + _lock = parent.Lock(); + _showInternalClasses = parent._showInternalClasses; + Open(); + } + + protected override void Initialize1(IConfiguration config) + { + _handlers = _parent._handlers; + _classCollection = _parent.ClassCollection(); + _config = _parent.ConfigImpl; + _references = WeakReferenceSupportFactory.DisabledWeakReferenceSupport(); + } + + protected override void InitializeClassMetadataRepository() + { + } + + // do nothing, it's passed from the parent ObjectContainer + protected override void InitalizeWeakReferenceSupport() + { + } + + // do nothing, no Weak references + internal override void InitializeEssentialClasses() + { + } + + // do nothing + protected override void InitializePostOpenExcludingTransportObjectContainer() + { + } + + // do nothing + internal override void InitNewClassCollection() + { + } + + // do nothing + internal override bool CanUpdate() + { + return false; + } + + public override ClassMetadata ClassMetadataForID(int id) + { + return _parent.ClassMetadataForID(id); + } + + internal override void ConfigureNewFile() + { + } + + // do nothing + public override int ConverterVersion() + { + return Converter.Version; + } + + protected virtual void DropReferences() + { + _config = null; + } + + protected override void HandleExceptionOnClose(Exception exc) + { + } + + // do nothing here + public sealed override Transaction NewTransaction(Transaction parentTransaction, + IReferenceSystem referenceSystem, bool isSystemTransaction) + { + if (null != parentTransaction) + { + return parentTransaction; + } + return new TransactionObjectCarrier(this, null, new TransportIdSystem(this), referenceSystem + ); + } + + public override long CurrentVersion() + { + return 0; + } + + public override IDb4oType Db4oTypeStored(Transaction a_trans, object a_object) + { + return null; + } + + public override bool DispatchsEvents() + { + return false; + } + + ~TransportObjectContainer() + { + } + + // do nothing + public sealed override void Free(int a_address, int a_length) + { + } + + // do nothing + public sealed override void Free(Slot slot) + { + } + + // do nothing + public override Slot AllocateSlot(int length) + { + return AppendBytes(length); + } + + protected override bool IsValidPointer(int id) + { + return id != 0 && base.IsValidPointer(id); + } + + public override Db4oDatabase Identity() + { + return ((ExternalObjectContainer)_parent).Identity(); + } + + public override bool MaintainsIndices() + { + return false; + } + + public override long GenerateTimeStampId() + { + return _parent.GenerateTimeStampId(); + } + + internal override void Message(string msg) + { + } + + // do nothing + public override ClassMetadata ProduceClassMetadata(IReflectClass claxx) + { + return _parent.ProduceClassMetadata(claxx); + } + + public override void RaiseCommitTimestamp(long a_minimumVersion) + { + } + + // do nothing + internal override void ReadThis() + { + } + + // do nothing + internal override bool StateMessages() + { + return false; + } + + // overridden to do nothing in YapObjectCarrier + public override void Shutdown() + { + ProcessPendingClassUpdates(); + WriteDirtyClassMetadata(); + Transaction.Commit(); + } + + public sealed override void WriteHeader(bool startFileLockingThread, bool shuttingDown + ) + { + } + + public class KnownObjectIdentity + { + public int _id; + + public KnownObjectIdentity(int id) + { + // do nothing + _id = id; + } + } + + /// + /// + public override int StoreInternal(Transaction trans, object obj, IUpdateDepth depth + , bool checkJustSet) + { + int id = _parent.GetID(null, obj); + if (id > 0) + { + return base.StoreInternal(trans, new TransportObjectContainer.KnownObjectIdentity + (id), depth, checkJustSet); + } + return base.StoreInternal(trans, obj, depth, checkJustSet); + } + + public override object GetByID2(Transaction ta, int id) + { + object obj = base.GetByID2(ta, id); + if (obj is TransportObjectContainer.KnownObjectIdentity) + { + TransportObjectContainer.KnownObjectIdentity oi = (TransportObjectContainer.KnownObjectIdentity + )obj; + Activate(oi); + obj = _parent.GetByID(null, oi._id); + } + return obj; + } + + public virtual void DeferredOpen() + { + Open(); + } + + /// + protected sealed override void OpenImpl() + { + CreateIdSystem(); + if (_memoryBin.Length() == 0) + { + ConfigureNewFile(); + CommitTransaction(); + } + else + { + ReadThis(); + } + } + + /// + public override void Backup(IStorage targetStorage, string path) + { + throw new NotSupportedException(); + } + + public override void BlockSize(int size) + { + } + + // do nothing, blocksize is always 1 + public override void CloseTransaction(Transaction transaction, bool isSystemTransaction + , bool rollbackOnClose) + { + } + + // do nothing + protected override void ShutdownDataStorage() + { + DropReferences(); + } + + public override long FileLength() + { + return _memoryBin.Length(); + } + + public override string FileName() + { + return "Memory File"; + } + + protected override bool HasShutDownHook() + { + return false; + } + + public sealed override bool NeedsLockFileThread() + { + return false; + } + + public override void ReadBytes(byte[] bytes, int address, int length) + { + try + { + _memoryBin.Read(address, bytes, length); + } + catch (Exception e) + { + Exceptions4.ThrowRuntimeException(13, e); + } + } + + public override void ReadBytes(byte[] bytes, int address, int addressOffset, int + length) + { + ReadBytes(bytes, address + addressOffset, length); + } + + public override void SyncFiles() + { + } + + public override void WriteBytes(ByteArrayBuffer buffer, int address, int addressOffset + ) + { + _memoryBin.Write(address + addressOffset, buffer._buffer, buffer.Length()); + } + + public override void OverwriteDeletedBytes(int a_address, int a_length) + { + } + + public override void Reserve(int byteCount) + { + throw new NotSupportedException(); + } + + public override byte BlockSize() + { + return 1; + } + + protected override void FatalStorageShutdown() + { + ShutdownDataStorage(); + } + + public override IReferenceSystem CreateReferenceSystem() + { + return new HashcodeReferenceSystem(); + } + + protected override void CreateIdSystem() + { + } + + // do nothing + public override IRunnable CommitHook() + { + return Runnable4.DoNothing; + } + + public override void SyncFiles(IRunnable runnable) + { + runnable.Run(); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/TreeInt.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/TreeInt.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/TreeInt.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/TreeInt.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,247 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Query.Processor; + +namespace Db4objects.Db4o.Internal +{ + /// Base class for balanced trees. + /// Base class for balanced trees. + /// + public class TreeInt : Tree, IReadWriteable + { + public static Db4objects.Db4o.Internal.TreeInt Add(Db4objects.Db4o.Internal.TreeInt + tree, int value) + { + return (Db4objects.Db4o.Internal.TreeInt)((Db4objects.Db4o.Internal.TreeInt)Tree. + Add(tree, new Db4objects.Db4o.Internal.TreeInt(value))); + } + + public static Db4objects.Db4o.Internal.TreeInt RemoveLike(Db4objects.Db4o.Internal.TreeInt + tree, int value) + { + return (Db4objects.Db4o.Internal.TreeInt)Tree.RemoveLike(tree, new Db4objects.Db4o.Internal.TreeInt + (value)); + } + + public static Tree AddAll(Tree tree, IIntIterator4 iter) + { + if (!iter.MoveNext()) + { + return tree; + } + Db4objects.Db4o.Internal.TreeInt firstAdded = new Db4objects.Db4o.Internal.TreeInt + (iter.CurrentInt()); + tree = Tree.Add(tree, firstAdded); + while (iter.MoveNext()) + { + tree = tree.Add(new Db4objects.Db4o.Internal.TreeInt(iter.CurrentInt())); + } + return tree; + } + + public int _key; + + public TreeInt(int a_key) + { + this._key = a_key; + } + + public override int Compare(Tree a_to) + { + return _key - ((Db4objects.Db4o.Internal.TreeInt)a_to)._key; + } + + internal virtual Tree DeepClone() + { + return new Db4objects.Db4o.Internal.TreeInt(_key); + } + + public override bool Duplicates() + { + return false; + } + + public static Db4objects.Db4o.Internal.TreeInt Find(Tree a_in, int a_key) + { + if (a_in == null) + { + return null; + } + return ((Db4objects.Db4o.Internal.TreeInt)a_in).Find(a_key); + } + + public Db4objects.Db4o.Internal.TreeInt Find(int a_key) + { + int cmp = _key - a_key; + if (cmp < 0) + { + if (((Tree)_subsequent) != null) + { + return ((Db4objects.Db4o.Internal.TreeInt)((Tree)_subsequent)).Find(a_key); + } + } + else + { + if (cmp > 0) + { + if (((Tree)_preceding) != null) + { + return ((Db4objects.Db4o.Internal.TreeInt)((Tree)_preceding)).Find(a_key); + } + } + else + { + return this; + } + } + return null; + } + + public virtual object Read(ByteArrayBuffer buffer) + { + return new Db4objects.Db4o.Internal.TreeInt(buffer.ReadInt()); + } + + public virtual void Write(ByteArrayBuffer buffer) + { + buffer.WriteInt(_key); + } + + public static void Write(ByteArrayBuffer buffer, Db4objects.Db4o.Internal.TreeInt + tree) + { + Write(buffer, tree, tree == null ? 0 : tree.Size()); + } + + public static void Write(ByteArrayBuffer buffer, Db4objects.Db4o.Internal.TreeInt + tree, int size) + { + if (tree == null) + { + buffer.WriteInt(0); + return; + } + buffer.WriteInt(size); + tree.Traverse(new _IVisitor4_97(buffer)); + } + + private sealed class _IVisitor4_97 : IVisitor4 + { + public _IVisitor4_97(ByteArrayBuffer buffer) + { + this.buffer = buffer; + } + + public void Visit(object a_object) + { + ((Db4objects.Db4o.Internal.TreeInt)a_object).Write(buffer); + } + + private readonly ByteArrayBuffer buffer; + } + + public virtual int OwnLength() + { + return Const4.IntLength; + } + + internal virtual bool VariableLength() + { + return false; + } + + internal virtual QCandidate ToQCandidate(QCandidates candidates) + { + QCandidate qc = new QCandidate(candidates, null, _key); + qc._preceding = ToQCandidate((Db4objects.Db4o.Internal.TreeInt)((Tree)_preceding) + , candidates); + qc._subsequent = ToQCandidate((Db4objects.Db4o.Internal.TreeInt)((Tree)_subsequent + ), candidates); + qc._size = _size; + return qc; + } + + public static QCandidate ToQCandidate(Db4objects.Db4o.Internal.TreeInt tree, QCandidates + candidates) + { + if (tree == null) + { + return null; + } + return tree.ToQCandidate(candidates); + } + + public override string ToString() + { + return string.Empty + _key; + } + + protected override Tree ShallowCloneInternal(Tree tree) + { + Db4objects.Db4o.Internal.TreeInt treeint = (Db4objects.Db4o.Internal.TreeInt)base + .ShallowCloneInternal(tree); + treeint._key = _key; + return treeint; + } + + public override object ShallowClone() + { + Db4objects.Db4o.Internal.TreeInt treeint = new Db4objects.Db4o.Internal.TreeInt(_key + ); + return ShallowCloneInternal(treeint); + } + + public static int MarshalledLength(Db4objects.Db4o.Internal.TreeInt a_tree) + { + if (a_tree == null) + { + return Const4.IntLength; + } + return a_tree.MarshalledLength(); + } + + public int MarshalledLength() + { + if (VariableLength()) + { + IntByRef length = new IntByRef(Const4.IntLength); + Traverse(new _IVisitor4_152(length)); + return length.value; + } + return MarshalledLength(Size()); + } + + private sealed class _IVisitor4_152 : IVisitor4 + { + public _IVisitor4_152(IntByRef length) + { + this.length = length; + } + + public void Visit(object obj) + { + length.value += ((Db4objects.Db4o.Internal.TreeInt)obj).OwnLength(); + } + + private readonly IntByRef length; + } + + public int MarshalledLength(int size) + { + return Const4.IntLength + (size * OwnLength()); + } + + public override object Key() + { + return _key; + } + + public override bool Equals(object obj) + { + Db4objects.Db4o.Internal.TreeInt other = (Db4objects.Db4o.Internal.TreeInt)obj; + return other._key == _key; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/TreeIntObject.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/TreeIntObject.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/TreeIntObject.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/TreeIntObject.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,101 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal; + +namespace Db4objects.Db4o.Internal +{ + /// + public class TreeIntObject : TreeInt + { + public object _object; + + public TreeIntObject(int a_key) : base(a_key) + { + } + + public TreeIntObject(int a_key, object a_object) : base(a_key) + { + _object = a_object; + } + + public override object ShallowClone() + { + return ShallowCloneInternal(new Db4objects.Db4o.Internal.TreeIntObject(_key)); + } + + protected override Tree ShallowCloneInternal(Tree tree) + { + Db4objects.Db4o.Internal.TreeIntObject tio = (Db4objects.Db4o.Internal.TreeIntObject + )base.ShallowCloneInternal(tree); + tio._object = _object; + return tio; + } + + public virtual object GetObject() + { + return _object; + } + + public virtual void SetObject(object obj) + { + _object = obj; + } + + public override object Read(ByteArrayBuffer a_bytes) + { + int key = a_bytes.ReadInt(); + object obj = null; + if (_object is TreeInt) + { + obj = new TreeReader(a_bytes, (IReadable)_object).Read(); + } + else + { + obj = ((IReadable)_object).Read(a_bytes); + } + return new Db4objects.Db4o.Internal.TreeIntObject(key, obj); + } + + public override void Write(ByteArrayBuffer a_writer) + { + a_writer.WriteInt(_key); + if (_object == null) + { + a_writer.WriteInt(0); + } + else + { + if (_object is TreeInt) + { + TreeInt.Write(a_writer, (TreeInt)_object); + } + else + { + ((IReadWriteable)_object).Write(a_writer); + } + } + } + + public override int OwnLength() + { + if (_object == null) + { + return Const4.IntLength * 2; + } + return Const4.IntLength + ((IReadable)_object).MarshalledLength(); + } + + internal override bool VariableLength() + { + return true; + } + + public static Db4objects.Db4o.Internal.TreeIntObject Add(Db4objects.Db4o.Internal.TreeIntObject + tree, int key, object value) + { + return ((Db4objects.Db4o.Internal.TreeIntObject)Tree.Add(tree, new Db4objects.Db4o.Internal.TreeIntObject + (key, value))); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/TreeReader.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/TreeReader.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/TreeReader.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/TreeReader.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,97 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal; + +namespace Db4objects.Db4o.Internal +{ + /// + public sealed class TreeReader + { + private readonly IReadable i_template; + + private readonly ByteArrayBuffer i_bytes; + + private int i_current = 0; + + private int i_levels = 0; + + private int i_size; + + private bool i_orderOnRead; + + public TreeReader(ByteArrayBuffer a_bytes, IReadable a_template) : this(a_bytes, + a_template, false) + { + } + + public TreeReader(ByteArrayBuffer a_bytes, IReadable a_template, bool a_orderOnRead + ) + { + i_template = a_template; + i_bytes = a_bytes; + i_orderOnRead = a_orderOnRead; + } + + public Tree Read() + { + return Read(i_bytes.ReadInt()); + } + + public Tree Read(int a_size) + { + i_size = a_size; + if (i_size > 0) + { + if (i_orderOnRead) + { + Tree tree = null; + for (int i = 0; i < i_size; i++) + { + tree = Tree.Add(tree, (Tree)i_template.Read(i_bytes)); + } + return tree; + } + while ((1 << i_levels) < (i_size + 1)) + { + i_levels++; + } + return LinkUp(null, i_levels); + } + return null; + } + + private Tree LinkUp(Tree a_preceding, int a_level) + { + Tree node = (Tree)i_template.Read(i_bytes); + i_current++; + node._preceding = a_preceding; + node._subsequent = LinkDown(a_level + 1); + node.CalculateSize(); + if (i_current < i_size) + { + return LinkUp(node, a_level - 1); + } + return node; + } + + private Tree LinkDown(int a_level) + { + if (i_current < i_size) + { + i_current++; + if (a_level < i_levels) + { + Tree preceding = LinkDown(a_level + 1); + Tree node = (Tree)i_template.Read(i_bytes); + node._preceding = preceding; + node._subsequent = LinkDown(a_level + 1); + node.CalculateSize(); + return node; + } + return (Tree)i_template.Read(i_bytes); + } + return null; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/TypeHandlerAspect.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/TypeHandlerAspect.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/TypeHandlerAspect.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/TypeHandlerAspect.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,220 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Delete; +using Db4objects.Db4o.Internal.Marshall; +using Db4objects.Db4o.Typehandlers; + +namespace Db4objects.Db4o.Internal +{ + /// + public class TypeHandlerAspect : ClassAspect + { + public readonly ITypeHandler4 _typeHandler; + + private readonly ClassMetadata _ownerMetadata; + + public TypeHandlerAspect(ClassMetadata classMetadata, ITypeHandler4 typeHandler) + { + if (Handlers4.IsValueType(typeHandler)) + { + throw new InvalidOperationException(); + } + _ownerMetadata = classMetadata; + _typeHandler = typeHandler; + } + + public override bool Equals(object obj) + { + if (obj == this) + { + return true; + } + if (obj == null || obj.GetType() != GetType()) + { + return false; + } + Db4objects.Db4o.Internal.TypeHandlerAspect other = (Db4objects.Db4o.Internal.TypeHandlerAspect + )obj; + return _typeHandler.Equals(other._typeHandler); + } + + public override int GetHashCode() + { + return _typeHandler.GetHashCode(); + } + + public override string GetName() + { + return _typeHandler.GetType().FullName; + } + + public override void CascadeActivation(IActivationContext context) + { + if (!Handlers4.IsCascading(_typeHandler)) + { + return; + } + Handlers4.CascadeActivation(context, _typeHandler); + } + + public override void CollectIDs(CollectIdContext context) + { + if (!Handlers4.IsCascading(_typeHandler)) + { + IncrementOffset(context); + return; + } + context.SlotFormat().DoWithSlotIndirection(context, new _IClosure4_58(this, context + )); + } + + private sealed class _IClosure4_58 : IClosure4 + { + public _IClosure4_58(TypeHandlerAspect _enclosing, CollectIdContext context) + { + this._enclosing = _enclosing; + this.context = context; + } + + public object Run() + { + QueryingReadContext queryingReadContext = new QueryingReadContext(context.Transaction + (), context.HandlerVersion(), context.Buffer(), 0, context.Collector()); + ((ICascadingTypeHandler)this._enclosing._typeHandler).CollectIDs(queryingReadContext + ); + return null; + } + + private readonly TypeHandlerAspect _enclosing; + + private readonly CollectIdContext context; + } + + public override void DefragAspect(IDefragmentContext context) + { + context.SlotFormat().DoWithSlotIndirection(context, new _IClosure4_68(this, context + )); + } + + private sealed class _IClosure4_68 : IClosure4 + { + public _IClosure4_68(TypeHandlerAspect _enclosing, IDefragmentContext context) + { + this._enclosing = _enclosing; + this.context = context; + } + + public object Run() + { + this._enclosing._typeHandler.Defragment(context); + return null; + } + + private readonly TypeHandlerAspect _enclosing; + + private readonly IDefragmentContext context; + } + + public override int LinkLength() + { + return Const4.IndirectionLength; + } + + public override void Marshall(MarshallingContext context, object obj) + { + context.CreateIndirectionWithinSlot(); + if (IsNotHandlingConcreteType(context)) + { + _typeHandler.Write(context, obj); + return; + } + if (_typeHandler is IInstantiatingTypeHandler) + { + IInstantiatingTypeHandler instantiating = (IInstantiatingTypeHandler)_typeHandler; + instantiating.WriteInstantiation(context, obj); + instantiating.Write(context, obj); + } + else + { + _typeHandler.Write(context, obj); + } + } + + private bool IsNotHandlingConcreteType(MarshallingContext context) + { + return context.ClassMetadata() != _ownerMetadata; + } + + public override Db4objects.Db4o.Internal.Marshall.AspectType AspectType() + { + return Db4objects.Db4o.Internal.Marshall.AspectType.Typehandler; + } + + public override void Activate(UnmarshallingContext context) + { + if (!CheckEnabled(context)) + { + return; + } + context.SlotFormat().DoWithSlotIndirection(context, new _IClosure4_110(this, context + )); + } + + private sealed class _IClosure4_110 : IClosure4 + { + public _IClosure4_110(TypeHandlerAspect _enclosing, UnmarshallingContext context) + { + this._enclosing = _enclosing; + this.context = context; + } + + public object Run() + { + Handlers4.Activate(context, this._enclosing._typeHandler); + return null; + } + + private readonly TypeHandlerAspect _enclosing; + + private readonly UnmarshallingContext context; + } + + public override void Delete(DeleteContextImpl context, bool isUpdate) + { + context.SlotFormat().DoWithSlotIndirection(context, new _IClosure4_119(this, context + )); + } + + private sealed class _IClosure4_119 : IClosure4 + { + public _IClosure4_119(TypeHandlerAspect _enclosing, DeleteContextImpl context) + { + this._enclosing = _enclosing; + this.context = context; + } + + public object Run() + { + this._enclosing._typeHandler.Delete(context); + return null; + } + + private readonly TypeHandlerAspect _enclosing; + + private readonly DeleteContextImpl context; + } + + public override void Deactivate(IActivationContext context) + { + CascadeActivation(context); + } + + public override bool CanBeDisabled() + { + return true; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/TypeHandlerCloneContext.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/TypeHandlerCloneContext.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/TypeHandlerCloneContext.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/TypeHandlerCloneContext.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,30 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Typehandlers; + +namespace Db4objects.Db4o.Internal +{ + /// + public class TypeHandlerCloneContext + { + private readonly HandlerRegistry handlerRegistry; + + public readonly ITypeHandler4 original; + + private readonly int version; + + public TypeHandlerCloneContext(HandlerRegistry handlerRegistry_, ITypeHandler4 original_ + , int version_) + { + handlerRegistry = handlerRegistry_; + original = original_; + version = version_; + } + + public virtual ITypeHandler4 CorrectHandlerVersion(ITypeHandler4 typeHandler) + { + return handlerRegistry.CorrectHandlerVersion(typeHandler, version); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/TypeHandlerConfiguration.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/TypeHandlerConfiguration.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/TypeHandlerConfiguration.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/TypeHandlerConfiguration.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,68 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Typehandlers; + +namespace Db4objects.Db4o.Internal +{ + /// + public abstract class TypeHandlerConfiguration + { + protected readonly Config4Impl _config; + + private ITypeHandler4 _listTypeHandler; + + private ITypeHandler4 _mapTypeHandler; + + public abstract void Apply(); + + public TypeHandlerConfiguration(Config4Impl config) + { + _config = config; + } + + protected virtual void ListTypeHandler(ITypeHandler4 listTypeHandler) + { + _listTypeHandler = listTypeHandler; + } + + protected virtual void MapTypeHandler(ITypeHandler4 mapTypehandler) + { + _mapTypeHandler = mapTypehandler; + } + + protected virtual void RegisterCollection(Type clazz) + { + RegisterListTypeHandlerFor(clazz); + } + + protected virtual void RegisterMap(Type clazz) + { + RegisterMapTypeHandlerFor(clazz); + } + + protected virtual void IgnoreFieldsOn(Type clazz) + { + _config.RegisterTypeHandler(new SingleClassTypeHandlerPredicate(clazz), IgnoreFieldsTypeHandler + .Instance); + } + + private void RegisterListTypeHandlerFor(Type clazz) + { + RegisterTypeHandlerFor(clazz, _listTypeHandler); + } + + private void RegisterMapTypeHandlerFor(Type clazz) + { + RegisterTypeHandlerFor(clazz, _mapTypeHandler); + } + + protected virtual void RegisterTypeHandlerFor(Type clazz, ITypeHandler4 typeHandler + ) + { + _config.RegisterTypeHandler(new SingleClassTypeHandlerPredicate(clazz), typeHandler + ); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/UUIDFieldMetadata.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/UUIDFieldMetadata.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/UUIDFieldMetadata.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/UUIDFieldMetadata.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,304 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using System.Collections; +using Db4objects.Db4o; +using Db4objects.Db4o.Ext; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Activation; +using Db4objects.Db4o.Internal.Btree; +using Db4objects.Db4o.Internal.Delete; +using Db4objects.Db4o.Internal.Handlers; +using Db4objects.Db4o.Internal.Marshall; +using Db4objects.Db4o.Internal.Slots; +using Db4objects.Db4o.Marshall; + +namespace Db4objects.Db4o.Internal +{ + /// + public class UUIDFieldMetadata : VirtualFieldMetadata + { + internal UUIDFieldMetadata() : base(Handlers4.LongId, new LongHandler()) + { + SetName(Const4.VirtualFieldPrefix + "uuid"); + } + + /// + public override void AddFieldIndex(ObjectIdContextImpl context) + { + LocalTransaction transaction = (LocalTransaction)context.Transaction(); + LocalObjectContainer localContainer = (LocalObjectContainer)transaction.Container + (); + Slot oldSlot = transaction.IdSystem().CommittedSlot(context.ObjectId()); + int savedOffset = context.Offset(); + int db4oDatabaseIdentityID = context.ReadInt(); + long uuid = context.ReadLong(); + context.Seek(savedOffset); + bool isnew = (oldSlot.IsNull()); + if ((uuid == 0 || db4oDatabaseIdentityID == 0) && context.ObjectId() > 0 && !isnew) + { + UUIDFieldMetadata.DatabaseIdentityIDAndUUID identityAndUUID = ReadDatabaseIdentityIDAndUUID + (localContainer, context.ClassMetadata(), oldSlot, false); + db4oDatabaseIdentityID = identityAndUUID.databaseIdentityID; + uuid = identityAndUUID.uuid; + } + if (db4oDatabaseIdentityID == 0) + { + db4oDatabaseIdentityID = localContainer.Identity().GetID(transaction); + } + if (uuid == 0) + { + uuid = localContainer.GenerateTimeStampId(); + } + StatefulBuffer writer = (StatefulBuffer)context.Buffer(); + writer.WriteInt(db4oDatabaseIdentityID); + writer.WriteLong(uuid); + if (isnew) + { + AddIndexEntry(writer, uuid); + } + } + + internal class DatabaseIdentityIDAndUUID + { + public int databaseIdentityID; + + public long uuid; + + public DatabaseIdentityIDAndUUID(int databaseIdentityID_, long uuid_) + { + databaseIdentityID = databaseIdentityID_; + uuid = uuid_; + } + } + + /// + private UUIDFieldMetadata.DatabaseIdentityIDAndUUID ReadDatabaseIdentityIDAndUUID + (ObjectContainerBase container, ClassMetadata classMetadata, Slot oldSlot, bool + checkClass) + { + if (DTrace.enabled) + { + DTrace.RereadOldUuid.LogLength(oldSlot.Address(), oldSlot.Length()); + } + ByteArrayBuffer reader = container.DecryptedBufferByAddress(oldSlot.Address(), oldSlot + .Length()); + if (checkClass) + { + ClassMetadata realClass = ClassMetadata.ReadClass(container, reader); + if (realClass != classMetadata) + { + return null; + } + } + if (classMetadata.SeekToField(container.Transaction, reader, this) == HandlerVersion + .Invalid) + { + return null; + } + return new UUIDFieldMetadata.DatabaseIdentityIDAndUUID(reader.ReadInt(), reader.ReadLong + ()); + } + + public override void Delete(DeleteContextImpl context, bool isUpdate) + { + if (isUpdate) + { + context.Seek(context.Offset() + LinkLength()); + return; + } + context.Seek(context.Offset() + Const4.IntLength); + long longPart = context.ReadLong(); + if (longPart > 0) + { + if (context.Container().MaintainsIndices()) + { + RemoveIndexEntry(context.Transaction(), context.ObjectId(), longPart); + } + } + } + + public override bool HasIndex() + { + return true; + } + + public override BTree GetIndex(Transaction transaction) + { + EnsureIndex(transaction); + return base.GetIndex(transaction); + } + + /// + protected override void RebuildIndexForObject(LocalObjectContainer container, ClassMetadata + classMetadata, int objectId) + { + Slot slot = container.SystemTransaction().IdSystem().CurrentSlot(objectId); + UUIDFieldMetadata.DatabaseIdentityIDAndUUID data = ReadDatabaseIdentityIDAndUUID( + container, classMetadata, slot, true); + if (null == data) + { + return; + } + AddIndexEntry(container.LocalSystemTransaction(), objectId, data.uuid); + } + + private void EnsureIndex(Transaction transaction) + { + if (null == transaction) + { + throw new ArgumentNullException(); + } + if (null != base.GetIndex(transaction)) + { + return; + } + LocalObjectContainer file = ((LocalObjectContainer)transaction.Container()); + SystemData sd = file.SystemData(); + if (sd == null) + { + // too early, in new file, try again later. + return; + } + InitIndex(transaction, sd.UuidIndexId()); + if (sd.UuidIndexId() == 0) + { + sd.UuidIndexId(base.GetIndex(transaction).GetID()); + file.GetFileHeader().WriteVariablePart(file); + } + } + + internal override void Instantiate1(ObjectReferenceContext context) + { + int dbID = context.ReadInt(); + Transaction trans = context.Transaction(); + ObjectContainerBase container = trans.Container(); + container.ShowInternalClasses(true); + try + { + Db4oDatabase db = (Db4oDatabase)container.GetByID2(trans, dbID); + if (db != null && db.i_signature == null) + { + container.Activate(trans, db, new FixedActivationDepth(2)); + } + VirtualAttributes va = context.ObjectReference().VirtualAttributes(); + va.i_database = db; + va.i_uuid = context.ReadLong(); + } + finally + { + container.ShowInternalClasses(false); + } + } + + public override int LinkLength() + { + return Const4.LongLength + Const4.IdLength; + } + + internal override void Marshall(Transaction trans, ObjectReference @ref, IWriteBuffer + buffer, bool isMigrating, bool isNew) + { + VirtualAttributes attr = @ref.VirtualAttributes(); + ObjectContainerBase container = trans.Container(); + bool doAddIndexEntry = isNew && container.MaintainsIndices(); + int dbID = 0; + bool linkToDatabase = (attr != null && attr.i_database == null) ? true : !isMigrating; + if (linkToDatabase) + { + Db4oDatabase db = ((IInternalObjectContainer)container).Identity(); + if (db == null) + { + // can happen on early classes like Metaxxx, no problem + attr = null; + } + else + { + if (attr.i_database == null) + { + attr.i_database = db; + // TODO: Should be check for ! client instead of instanceof + if (container is LocalObjectContainer) + { + attr.i_uuid = container.GenerateTimeStampId(); + doAddIndexEntry = true; + } + } + db = attr.i_database; + if (db != null) + { + dbID = db.GetID(trans); + } + } + } + else + { + if (attr != null) + { + dbID = attr.i_database.GetID(trans); + } + } + buffer.WriteInt(dbID); + if (attr == null) + { + buffer.WriteLong(0); + return; + } + buffer.WriteLong(attr.i_uuid); + if (doAddIndexEntry) + { + AddIndexEntry(trans, @ref.GetID(), attr.i_uuid); + } + } + + internal override void MarshallIgnore(IWriteBuffer buffer) + { + buffer.WriteInt(0); + buffer.WriteLong(0); + } + + public HardObjectReference GetHardObjectReferenceBySignature(Transaction transaction + , long longPart, byte[] signature) + { + IBTreeRange range = Search(transaction, longPart); + IEnumerator keys = range.Keys(); + while (keys.MoveNext()) + { + IFieldIndexKey current = (IFieldIndexKey)keys.Current; + HardObjectReference hardRef = GetHardObjectReferenceById(transaction, current.ParentID + (), signature); + if (null != hardRef) + { + return hardRef; + } + } + return HardObjectReference.Invalid; + } + + protected HardObjectReference GetHardObjectReferenceById(Transaction transaction, + int parentId, byte[] signature) + { + HardObjectReference hardRef = transaction.Container().GetHardObjectReferenceById( + transaction, parentId); + if (hardRef._reference == null) + { + return null; + } + VirtualAttributes vad = hardRef._reference.VirtualAttributes(transaction, false); + if (!Arrays4.Equals(signature, vad.i_database.i_signature)) + { + return null; + } + return hardRef; + } + + public override void DefragAspect(IDefragmentContext context) + { + // database id + context.CopyID(); + // uuid + context.IncrementOffset(Const4.LongLength); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/VersionFieldMetadata.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/VersionFieldMetadata.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/VersionFieldMetadata.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/VersionFieldMetadata.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,65 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Ext; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Delete; +using Db4objects.Db4o.Internal.Handlers; +using Db4objects.Db4o.Internal.Marshall; +using Db4objects.Db4o.Marshall; + +namespace Db4objects.Db4o.Internal +{ + /// + public class VersionFieldMetadata : VirtualFieldMetadata + { + internal VersionFieldMetadata() : base(Handlers4.LongId, new LongHandler()) + { + SetName(VirtualField.Version); + } + + /// + public override void AddFieldIndex(ObjectIdContextImpl context) + { + StatefulBuffer buffer = (StatefulBuffer)context.Buffer(); + buffer.WriteLong(context.Transaction().Container().GenerateTimeStampId()); + } + + public override void Delete(DeleteContextImpl context, bool isUpdate) + { + context.Seek(context.Offset() + LinkLength()); + } + + internal override void Instantiate1(ObjectReferenceContext context) + { + context.ObjectReference().VirtualAttributes().i_version = context.ReadLong(); + } + + internal override void Marshall(Transaction trans, ObjectReference @ref, IWriteBuffer + buffer, bool isMigrating, bool isNew) + { + VirtualAttributes attr = @ref.VirtualAttributes(); + if (!isMigrating) + { + attr.i_version = trans.Container().GenerateTimeStampId(); + } + if (attr == null) + { + buffer.WriteLong(0); + } + else + { + buffer.WriteLong(attr.i_version); + } + } + + public override int LinkLength() + { + return Const4.LongLength; + } + + internal override void MarshallIgnore(IWriteBuffer buffer) + { + buffer.WriteLong(0); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/VirtualAttributes.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/VirtualAttributes.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/VirtualAttributes.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/VirtualAttributes.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,33 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Ext; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal; + +namespace Db4objects.Db4o.Internal +{ + /// + public class VirtualAttributes : IShallowClone + { + public Db4oDatabase i_database; + + public long i_version; + + public long i_uuid; + + // FIXME: should be named "uuidLongPart" or even better "creationTime" + public virtual object ShallowClone() + { + VirtualAttributes va = new VirtualAttributes(); + va.i_database = i_database; + va.i_version = i_version; + va.i_uuid = i_uuid; + return va; + } + + internal virtual bool SuppliesUUID() + { + return i_database != null && i_uuid != 0; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/VirtualFieldMetadata.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/VirtualFieldMetadata.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/VirtualFieldMetadata.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/VirtualFieldMetadata.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,181 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Delete; +using Db4objects.Db4o.Internal.Marshall; +using Db4objects.Db4o.Internal.Query.Processor; +using Db4objects.Db4o.Internal.Replication; +using Db4objects.Db4o.Marshall; +using Db4objects.Db4o.Reflect; +using Db4objects.Db4o.Typehandlers; + +namespace Db4objects.Db4o.Internal +{ + /// + /// TODO: refactor for symmetric inheritance - don't inherit from YapField and override, + /// instead extract an abstract superclass from YapField and let both YapField and this class implement + /// + /// + public abstract class VirtualFieldMetadata : FieldMetadata + { + private static readonly object AnyObject = new object(); + + private IReflectClass _classReflector; + + private IBuiltinTypeHandler _handler; + + internal VirtualFieldMetadata(int fieldTypeID, IBuiltinTypeHandler handler) : base + (fieldTypeID) + { + _handler = handler; + } + + public override ITypeHandler4 GetHandler() + { + return _handler; + } + + /// + public abstract override void AddFieldIndex(ObjectIdContextImpl context); + + public override bool Alive() + { + return true; + } + + internal override bool CanAddToQuery(string fieldName) + { + return fieldName.Equals(GetName()); + } + + public override bool CanBeDisabled() + { + return false; + } + + public override bool CanUseNullBitmap() + { + return false; + } + + public virtual IReflectClass ClassReflector(IReflector reflector) + { + if (_classReflector == null) + { + _classReflector = ((IBuiltinTypeHandler)GetHandler()).ClassReflector(); + } + return _classReflector; + } + + internal override void CollectConstraints(Transaction a_trans, QConObject a_parent + , object a_template, IVisitor4 a_visitor) + { + } + + // QBE constraint collection call + // There isn't anything useful to do here, since virtual fields + // are not on the actual object. + public override void Deactivate(IActivationContext context) + { + } + + // do nothing + public abstract override void Delete(DeleteContextImpl context, bool isUpdate); + + public override object GetOrCreate(Transaction a_trans, object a_OnObject) + { + // This is the first part of marshalling + // Virtual fields do it all in #marshall(), the object is never used. + // Returning any object here prevents triggering null handling. + return AnyObject; + } + + public override bool NeedsArrayAndPrimitiveInfo() + { + return false; + } + + public override void Activate(UnmarshallingContext context) + { + context.ObjectReference().ProduceVirtualAttributes(); + Instantiate1(context); + } + + internal abstract void Instantiate1(ObjectReferenceContext context); + + public override void LoadFieldTypeById() + { + } + + // do nothing + public override void Marshall(MarshallingContext context, object obj) + { + Marshall(context.Transaction(), context.Reference(), context, context.IsNew()); + } + + private void Marshall(Transaction trans, ObjectReference @ref, IWriteBuffer buffer + , bool isNew) + { + if (!trans.SupportsVirtualFields()) + { + MarshallIgnore(buffer); + return; + } + ObjectContainerBase stream = trans.Container(); + HandlerRegistry handlers = stream._handlers; + bool migrating = false; + if (stream._replicationCallState == Const4.New) + { + IDb4oReplicationReferenceProvider provider = handlers._replicationReferenceProvider; + object parentObject = @ref.GetObject(); + IDb4oReplicationReference replicationReference = provider.ReferenceFor(parentObject + ); + if (replicationReference != null) + { + migrating = true; + VirtualAttributes va = @ref.ProduceVirtualAttributes(); + va.i_version = replicationReference.Version(); + va.i_uuid = replicationReference.LongPart(); + va.i_database = replicationReference.SignaturePart(); + } + } + if (@ref.VirtualAttributes() == null) + { + @ref.ProduceVirtualAttributes(); + migrating = false; + } + Marshall(trans, @ref, buffer, migrating, isNew); + } + + internal abstract void Marshall(Transaction trans, ObjectReference @ref, IWriteBuffer + buffer, bool migrating, bool isNew); + + internal abstract void MarshallIgnore(IWriteBuffer writer); + + public virtual void ReadVirtualAttribute(ObjectReferenceContext context) + { + if (!context.Transaction().SupportsVirtualFields()) + { + IncrementOffset(context); + return; + } + Instantiate1(context); + } + + public override bool IsVirtual() + { + return true; + } + + protected override object IndexEntryFor(object indexEntry) + { + return indexEntry; + } + + protected override IIndexable4 IndexHandler(ObjectContainerBase stream) + { + return (IIndexable4)GetHandler(); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Weakref/EnabledWeakReferenceSupport.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Weakref/EnabledWeakReferenceSupport.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Weakref/EnabledWeakReferenceSupport.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Weakref/EnabledWeakReferenceSupport.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,92 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using Db4objects.Db4o.Ext; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Weakref; +using Sharpen.Lang; + +namespace Db4objects.Db4o.Internal.Weakref +{ + internal class EnabledWeakReferenceSupport : IWeakReferenceSupport + { + private readonly object _queue; + + private readonly ObjectContainerBase _container; + + private SimpleTimer _timer; + + internal EnabledWeakReferenceSupport(ObjectContainerBase container) + { + _container = container; + _queue = Platform4.CreateReferenceQueue(); + } + + public virtual object NewWeakReference(ObjectReference referent, object obj) + { + return Platform4.CreateActiveObjectReference(_queue, referent, obj); + } + + public virtual void Purge() + { + Platform4.PollReferenceQueue(_container, _queue); + } + + public virtual void Start() + { + if (_timer != null) + { + return; + } + if (!_container.ConfigImpl.WeakReferences()) + { + return; + } + if (_container.ConfigImpl.WeakReferenceCollectionInterval() <= 0) + { + return; + } + _timer = new SimpleTimer(new EnabledWeakReferenceSupport.Collector(this), _container + .ConfigImpl.WeakReferenceCollectionInterval()); + _container.ThreadPool().Start("db4o WeakReference collector", _timer); + } + + public virtual void Stop() + { + if (_timer == null) + { + return; + } + _timer.Stop(); + _timer = null; + } + + private sealed class Collector : IRunnable + { + public void Run() + { + try + { + this._enclosing.Purge(); + } + catch (DatabaseClosedException) + { + } + catch (Exception e) + { + // can happen, no stack trace + // don't bring down the thread + Sharpen.Runtime.PrintStackTrace(e); + } + } + + internal Collector(EnabledWeakReferenceSupport _enclosing) + { + this._enclosing = _enclosing; + } + + private readonly EnabledWeakReferenceSupport _enclosing; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Weakref/IWeakReferenceSupport.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Weakref/IWeakReferenceSupport.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Weakref/IWeakReferenceSupport.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Weakref/IWeakReferenceSupport.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,17 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal; + +namespace Db4objects.Db4o.Internal.Weakref +{ + public interface IWeakReferenceSupport + { + object NewWeakReference(ObjectReference referent, object obj); + + void Purge(); + + void Start(); + + void Stop(); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Weakref/WeakReferenceSupportFactory.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Weakref/WeakReferenceSupportFactory.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Weakref/WeakReferenceSupportFactory.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/Weakref/WeakReferenceSupportFactory.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,53 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Weakref; + +namespace Db4objects.Db4o.Internal.Weakref +{ + public class WeakReferenceSupportFactory + { + public static IWeakReferenceSupport ForObjectContainer(ObjectContainerBase container + ) + { + if (!Platform4.HasWeakReferences()) + { + return DisabledWeakReferenceSupport(); + } + if (!container.ConfigImpl.WeakReferences()) + { + return DisabledWeakReferenceSupport(); + } + return new EnabledWeakReferenceSupport(container); + } + + public static IWeakReferenceSupport DisabledWeakReferenceSupport() + { + return new _IWeakReferenceSupport_22(); + } + + private sealed class _IWeakReferenceSupport_22 : IWeakReferenceSupport + { + public _IWeakReferenceSupport_22() + { + } + + public void Stop() + { + } + + public void Start() + { + } + + public void Purge() + { + } + + public object NewWeakReference(ObjectReference referent, object obj) + { + return obj; + } + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/WriteUpdateProcessor.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/WriteUpdateProcessor.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/WriteUpdateProcessor.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Internal/WriteUpdateProcessor.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,103 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Delete; +using Db4objects.Db4o.Internal.Marshall; +using Db4objects.Db4o.Internal.Slots; + +namespace Db4objects.Db4o.Internal +{ + /// + internal class WriteUpdateProcessor + { + private readonly LocalTransaction _transaction; + + private readonly int _id; + + private readonly ClassMetadata _clazz; + + private readonly ArrayType _typeInfo; + + private int _cascade = 0; + + public WriteUpdateProcessor(LocalTransaction transaction, int id, ClassMetadata clazz + , ArrayType typeInfo) + { + _transaction = transaction; + _id = id; + _clazz = clazz; + _typeInfo = typeInfo; + } + + public virtual void Run() + { + _transaction.CheckSynchronization(); + if (DTrace.enabled) + { + DTrace.WriteUpdateAdjustIndexes.Log(_id); + } + if (AlreadyHandled()) + { + return; + } + // TODO: Try to get rid of getting the slot here because it + // will invoke reading a pointer from the file system. + // It may be possible to figure out the readd case + // by asking the IdSystem in a smarter way. + Slot slot = _transaction.IdSystem().CurrentSlot(_id); + if (HandledAsReAdd(slot)) + { + return; + } + if (_clazz.CanUpdateFast()) + { + return; + } + StatefulBuffer objectBytes = Container().ReadStatefulBufferBySlot(_transaction, _id + , slot); + DeleteMembers(objectBytes); + } + + private LocalObjectContainer Container() + { + return _transaction.LocalContainer(); + } + + private void DeleteMembers(StatefulBuffer objectBytes) + { + ObjectHeader oh = new ObjectHeader(_clazz, objectBytes); + DeleteInfo info = (DeleteInfo)TreeInt.Find(_transaction._delete, _id); + if (info != null) + { + if (info._cascade > _cascade) + { + _cascade = info._cascade; + } + } + objectBytes.SetCascadeDeletes(_cascade); + DeleteContextImpl context = new DeleteContextImpl(objectBytes, oh, _clazz.ClassReflector + (), null); + _clazz.DeleteMembers(context, _typeInfo, true); + } + + private bool HandledAsReAdd(Slot slot) + { + if (!Slot.IsNull(slot)) + { + return false; + } + _clazz.AddToIndex(_transaction, _id); + return true; + } + + private bool AlreadyHandled() + { + TreeInt newNode = new TreeInt(_id); + _transaction._writtenUpdateAdjustedIndexes = Tree.Add(_transaction._writtenUpdateAdjustedIndexes + , newNode); + return !newNode.WasAddedToTree(); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IO/BinConfiguration.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IO/BinConfiguration.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IO/BinConfiguration.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IO/BinConfiguration.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,64 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +namespace Db4objects.Db4o.IO +{ + /// + public class BinConfiguration + { + private readonly string _uri; + + private readonly bool _lockFile; + + private readonly long _initialLength; + + private readonly bool _readOnly; + + private readonly int _blockSize; + + public BinConfiguration(string uri, bool lockFile, long initialLength, bool readOnly + ) : this(uri, lockFile, initialLength, readOnly, 1) + { + } + + public BinConfiguration(string uri, bool lockFile, long initialLength, bool readOnly + , int blockSize) + { + _uri = uri; + _lockFile = lockFile; + _initialLength = initialLength; + _readOnly = readOnly; + _blockSize = blockSize; + } + + public virtual string Uri() + { + return _uri; + } + + public virtual bool LockFile() + { + return _lockFile; + } + + public virtual long InitialLength() + { + return _initialLength; + } + + public virtual bool ReadOnly() + { + return _readOnly; + } + + public virtual int BlockSize() + { + return _blockSize; + } + + public override string ToString() + { + return "BinConfiguration(Uri: " + _uri + ", Locked: " + _lockFile + ", ReadOnly: " + + _readOnly + ", BlockSize: " + _blockSize + ")"; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IO/BinDecorator.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IO/BinDecorator.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IO/BinDecorator.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IO/BinDecorator.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,80 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.IO; +using Sharpen.Lang; + +namespace Db4objects.Db4o.IO +{ + /// Wrapper baseclass for all classes that wrap Bin. + /// + /// Wrapper baseclass for all classes that wrap Bin. + /// Each class that adds functionality to a Bin must + /// extend this class to allow db4o to access the + /// delegate instance with + /// StorageDecorator.Decorate(BinConfiguration, IBin) + /// + /// . + /// + public class BinDecorator : IBin + { + protected readonly IBin _bin; + + /// Default constructor. + /// Default constructor. + /// + /// the + /// IBin + /// that is to be wrapped. + /// + public BinDecorator(IBin bin) + { + _bin = bin; + } + + /// + /// closes the BinDecorator and the underlying + /// IBin + /// . + /// + public virtual void Close() + { + _bin.Close(); + } + + /// + public virtual long Length() + { + return _bin.Length(); + } + + /// IBin.Read(long, byte[], int) + public virtual int Read(long position, byte[] bytes, int bytesToRead) + { + return _bin.Read(position, bytes, bytesToRead); + } + + /// IBin.Sync() + public virtual void Sync() + { + _bin.Sync(); + } + + /// IBin.SyncRead(long, byte[], int) + /// + public virtual int SyncRead(long position, byte[] bytes, int bytesToRead) + { + return _bin.SyncRead(position, bytes, bytesToRead); + } + + /// IBin.Write(long, byte[], int) + public virtual void Write(long position, byte[] bytes, int bytesToWrite) + { + _bin.Write(position, bytes, bytesToWrite); + } + + public virtual void Sync(IRunnable runnable) + { + _bin.Sync(runnable); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IO/BlockAwareBin.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IO/BlockAwareBin.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IO/BlockAwareBin.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IO/BlockAwareBin.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,212 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using Db4objects.Db4o; +using Db4objects.Db4o.Ext; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.IO; +using Sharpen.Lang; + +namespace Db4objects.Db4o.IO +{ + /// + public class BlockAwareBin : BinDecorator + { + private const int CopySize = 4096; + + private bool _readOnly; + + private readonly IBlockSize _blockSize = ((IBlockSize)Environments.My(typeof(IBlockSize + ))); + + public BlockAwareBin(IBin bin) : base(bin) + { + } + + /// converts address and address offset to an absolute address + protected long RegularAddress(int blockAddress, int blockAddressOffset) + { + if (0 == BlockSize()) + { + throw new InvalidOperationException(); + } + return (long)blockAddress * BlockSize() + blockAddressOffset; + } + + /// copies a block within a file in block mode + /// + public virtual void BlockCopy(int oldAddress, int oldAddressOffset, int newAddress + , int newAddressOffset, int length) + { + Copy(RegularAddress(oldAddress, oldAddressOffset), RegularAddress(newAddress, newAddressOffset + ), length); + } + + /// copies a block within a file in absolute mode + /// + public virtual void Copy(long oldAddress, long newAddress, int length) + { + if (DTrace.enabled) + { + DTrace.IoCopy.LogLength(newAddress, length); + } + if (length > CopySize) + { + byte[] buffer = new byte[CopySize]; + int pos = 0; + while (pos + CopySize < length) + { + Copy(buffer, oldAddress + pos, newAddress + pos); + pos += CopySize; + } + oldAddress += pos; + newAddress += pos; + length -= pos; + } + Copy(new byte[length], oldAddress, newAddress); + } + + /// + private void Copy(byte[] buffer, long oldAddress, long newAddress) + { + Read(oldAddress, buffer); + Write(oldAddress, buffer); + } + + /// reads a buffer at the seeked address + /// the number of bytes read and returned + /// + public virtual int BlockRead(int address, int offset, byte[] buffer) + { + return BlockRead(address, offset, buffer, buffer.Length); + } + + /// implement to read a buffer at the seeked address + /// + public virtual int BlockRead(int address, int offset, byte[] bytes, int length) + { + return Read(RegularAddress(address, offset), bytes, length); + } + + /// reads a buffer at the seeked address + /// the number of bytes read and returned + /// + public virtual int BlockRead(int address, byte[] buffer) + { + return BlockRead(address, 0, buffer, buffer.Length); + } + + /// implement to read a buffer at the seeked address + /// + public virtual int BlockRead(int address, byte[] bytes, int length) + { + return BlockRead(address, 0, bytes, length); + } + + /// reads a buffer at the seeked address + /// the number of bytes read and returned + /// + public virtual int Read(long pos, byte[] buffer) + { + return Read(pos, buffer, buffer.Length); + } + + /// reads a buffer at the seeked address + /// the number of bytes read and returned + /// + public virtual void BlockWrite(int address, int offset, byte[] buffer) + { + BlockWrite(address, offset, buffer, buffer.Length); + } + + /// implement to read a buffer at the seeked address + /// + public virtual void BlockWrite(int address, int offset, byte[] bytes, int length) + { + Write(RegularAddress(address, offset), bytes, length); + } + + /// reads a buffer at the seeked address + /// the number of bytes read and returned + /// + public virtual void BlockWrite(int address, byte[] buffer) + { + BlockWrite(address, 0, buffer, buffer.Length); + } + + /// implement to read a buffer at the seeked address + /// + public virtual void BlockWrite(int address, byte[] bytes, int length) + { + BlockWrite(address, 0, bytes, length); + } + + public override void Sync() + { + ValidateReadOnly(); + try + { + base.Sync(); + } + catch (Db4oIOException e) + { + _readOnly = true; + throw; + } + } + + public override void Sync(IRunnable runnable) + { + ValidateReadOnly(); + try + { + base.Sync(runnable); + } + catch (Db4oIOException e) + { + _readOnly = true; + throw; + } + } + + /// writes a buffer to the seeked address + /// + public virtual void Write(long pos, byte[] bytes) + { + ValidateReadOnly(); + try + { + Write(pos, bytes, bytes.Length); + } + catch (Db4oIOException e) + { + _readOnly = true; + throw; + } + } + + private void ValidateReadOnly() + { + if (_readOnly) + { + throw new EmergencyShutdownReadOnlyException(); + } + } + + /// returns the block size currently used + public virtual int BlockSize() + { + return _blockSize.Value(); + } + + /// outside call to set the block size of this adapter + public virtual void BlockSize(int blockSize) + { + if (blockSize < 1) + { + throw new ArgumentException(); + } + _blockSize.Set(blockSize); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IO/BlockAwareBinWindow.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IO/BlockAwareBinWindow.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IO/BlockAwareBinWindow.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IO/BlockAwareBinWindow.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,87 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using Db4objects.Db4o.IO; + +namespace Db4objects.Db4o.IO +{ + /// Bounded handle into an IoAdapter: Can only access a restricted area. + /// Bounded handle into an IoAdapter: Can only access a restricted area. + /// + public class BlockAwareBinWindow + { + private BlockAwareBin _bin; + + private int _blockOff; + + private int _len; + + private bool _disabled; + + /// The delegate I/O adapter + /// The block offset address into the I/O adapter that maps to the start index (0) of this window + /// + /// The size of this window in bytes + public BlockAwareBinWindow(BlockAwareBin io, int blockOff, int len) + { + _bin = io; + _blockOff = blockOff; + _len = len; + _disabled = false; + } + + /// Size of this I/O adapter window in bytes. + public virtual int Length() + { + return _len; + } + + /// Offset in bytes relative to the window start + /// Data to write into the window starting from the given offset + /// + /// + public virtual void Write(int off, byte[] data) + { + CheckBounds(off, data); + _bin.BlockWrite(_blockOff + off, data); + } + + /// Offset in bytes relative to the window start + /// Data buffer to read from the window starting from the given offset + /// + /// + /// + public virtual int Read(int off, byte[] data) + { + CheckBounds(off, data); + return _bin.BlockRead(_blockOff + off, data); + } + + /// Disable IO Adapter Window + public virtual void Disable() + { + _disabled = true; + } + + /// Flush IO Adapter Window + public virtual void Flush() + { + if (!_disabled) + { + _bin.Sync(); + } + } + + private void CheckBounds(int off, byte[] data) + { + if (_disabled) + { + throw new InvalidOperationException(); + } + if (data == null || off < 0 || off + data.Length > _len) + { + throw new ArgumentException(); + } + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IO/CachedIoAdapter.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IO/CachedIoAdapter.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IO/CachedIoAdapter.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IO/CachedIoAdapter.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,547 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using Db4objects.Db4o.Ext; +using Db4objects.Db4o.IO; +using Db4objects.Db4o.Internal.Fileheader; +using Sharpen; + +namespace Db4objects.Db4o.IO +{ + /// + /// CachedIoAdapter is an IOAdapter for random access files, which caches data + /// for IO access. + /// + /// + /// CachedIoAdapter is an IOAdapter for random access files, which caches data + /// for IO access. Its functionality is similar to OS cache.
+ /// Example:
+ /// delegateAdapter = new RandomAccessFileAdapter();
+ /// config.Io(new CachedIoAdapter(delegateAdapter));
+ ///
+ public class CachedIoAdapter : IoAdapter + { + private CachedIoAdapter.Page _head; + + private CachedIoAdapter.Page _tail; + + private long _position; + + private int _pageSize; + + private int _pageCount; + + private long _fileLength; + + private long _filePointer; + + private IoAdapter _io; + + private bool _readOnly; + + private static int DefaultPageSize = 1024; + + private static int DefaultPageCount = 64; + + /// + /// Creates an instance of CachedIoAdapter with the default page size and + /// page count. + /// + /// + /// Creates an instance of CachedIoAdapter with the default page size and + /// page count. + /// + /// delegate IO adapter (RandomAccessFileAdapter by default) + public CachedIoAdapter(IoAdapter ioAdapter) : this(ioAdapter, DefaultPageSize, DefaultPageCount + ) + { + } + + /// + /// Creates an instance of CachedIoAdapter with a custom page size and page + /// count.
+ ///
+ /// delegate IO adapter (RandomAccessFileAdapter by default) + /// cache page size + /// allocated amount of pages + public CachedIoAdapter(IoAdapter ioAdapter, int pageSize, int pageCount) + { + // private Hashtable4 _posPageMap = new Hashtable4(PAGE_COUNT); + _io = ioAdapter; + _pageSize = pageSize; + _pageCount = pageCount; + } + + /// Creates an instance of CachedIoAdapter with extended parameters.
+ /// database file path + /// determines if the file should be locked + /// initial file length, new writes will start from this point + /// + /// + /// + /// if the file should be used in read-onlyt mode. + /// + /// delegate IO adapter (RandomAccessFileAdapter by default) + /// cache page size + /// allocated amount of pages + /// + public CachedIoAdapter(string path, bool lockFile, long initialLength, bool readOnly + , IoAdapter io, int pageSize, int pageCount) + { + _readOnly = readOnly; + _pageSize = pageSize; + _pageCount = pageCount; + InitCache(); + InitIOAdaptor(path, lockFile, initialLength, readOnly, io); + _position = initialLength; + _filePointer = initialLength; + _fileLength = _io.GetLength(); + } + + /// Creates and returns a new CachedIoAdapter
+ /// database file path + /// determines if the file should be locked + /// initial file length, new writes will start from this point + /// + /// + public override IoAdapter Open(string path, bool lockFile, long initialLength, bool + readOnly) + { + return new Db4objects.Db4o.IO.CachedIoAdapter(path, lockFile, initialLength, readOnly + , _io, _pageSize, _pageCount); + } + + /// Deletes the database file + /// file path + public override void Delete(string path) + { + _io.Delete(path); + } + + /// Checks if the file exists + /// file path + public override bool Exists(string path) + { + return _io.Exists(path); + } + + /// + private void InitIOAdaptor(string path, bool lockFile, long initialLength, bool readOnly + , IoAdapter io) + { + _io = io.Open(path, lockFile, initialLength, readOnly); + } + + private void InitCache() + { + _head = new CachedIoAdapter.Page(_pageSize); + _head._prev = null; + CachedIoAdapter.Page page = _head; + CachedIoAdapter.Page next = _head; + for (int i = 0; i < _pageCount - 1; ++i) + { + next = new CachedIoAdapter.Page(_pageSize); + page._next = next; + next._prev = page; + page = next; + } + _tail = next; + } + + /// Reads the file into the buffer using pages from cache. + /// + /// Reads the file into the buffer using pages from cache. If the next page + /// is not cached it will be read from the file. + /// + /// destination buffer + /// how many bytes to read + /// + public override int Read(byte[] buffer, int length) + { + long startAddress = _position; + int bytesToRead = length; + int totalRead = 0; + while (bytesToRead > 0) + { + CachedIoAdapter.Page page = GetPage(startAddress, true); + int readBytes = page.Read(buffer, totalRead, startAddress, bytesToRead); + MovePageToHead(page); + if (readBytes <= 0) + { + break; + } + bytesToRead -= readBytes; + startAddress += readBytes; + totalRead += readBytes; + } + _position = startAddress; + return totalRead == 0 ? -1 : totalRead; + } + + /// Writes the buffer to cache using pages + /// source buffer + /// how many bytes to write + /// + public override void Write(byte[] buffer, int length) + { + ValidateReadOnly(); + long startAddress = _position; + int bytesToWrite = length; + int bufferOffset = 0; + while (bytesToWrite > 0) + { + // page doesn't need to loadFromDisk if the whole page is dirty + bool loadFromDisk = (bytesToWrite < _pageSize) || (startAddress % _pageSize != 0); + CachedIoAdapter.Page page = GetPage(startAddress, loadFromDisk); + page.EnsureEndAddress(GetLength()); + int writtenBytes = page.Write(buffer, bufferOffset, startAddress, bytesToWrite); + FlushIfHeaderBlockPage(page); + MovePageToHead(page); + bytesToWrite -= writtenBytes; + startAddress += writtenBytes; + bufferOffset += writtenBytes; + } + long endAddress = startAddress; + _position = endAddress; + _fileLength = Math.Max(endAddress, _fileLength); + } + + private void FlushIfHeaderBlockPage(CachedIoAdapter.Page page) + { + if (ContainsHeaderBlock(page)) + { + FlushPage(page); + } + } + + private void ValidateReadOnly() + { + if (_readOnly) + { + throw new Db4oIOException(); + } + } + + /// Flushes cache to a physical storage + /// + public override void Sync() + { + ValidateReadOnly(); + FlushAllPages(); + _io.Sync(); + } + + /// Returns the file length + /// + public override long GetLength() + { + return _fileLength; + } + + /// Flushes and closes the file + /// + public override void Close() + { + try + { + FlushAllPages(); + } + finally + { + _io.Close(); + } + } + + public override IoAdapter DelegatedIoAdapter() + { + return _io.DelegatedIoAdapter(); + } + + /// + private CachedIoAdapter.Page GetPage(long startAddress, bool loadFromDisk) + { + CachedIoAdapter.Page page = GetPageFromCache(startAddress); + if (page != null) + { + if (ContainsHeaderBlock(page)) + { + GetPageFromDisk(page, startAddress); + } + page.EnsureEndAddress(_fileLength); + return page; + } + // in case that page is not found in the cache + page = GetFreePageFromCache(); + if (loadFromDisk) + { + GetPageFromDisk(page, startAddress); + } + else + { + ResetPageAddress(page, startAddress); + } + return page; + } + + private bool ContainsHeaderBlock(CachedIoAdapter.Page page) + { + return page.StartAddress() <= FileHeader1.HeaderLength; + } + + private void ResetPageAddress(CachedIoAdapter.Page page, long startAddress) + { + page.StartAddress(startAddress); + page.EndAddress(startAddress + _pageSize); + } + + /// + private CachedIoAdapter.Page GetFreePageFromCache() + { + if (!_tail.IsFree()) + { + FlushPage(_tail); + } + // _posPageMap.remove(new Long(tail.startPosition / PAGE_SIZE)); + return _tail; + } + + /// + private CachedIoAdapter.Page GetPageFromCache(long pos) + { + CachedIoAdapter.Page page = _head; + while (page != null) + { + if (page.Contains(pos)) + { + return page; + } + page = page._next; + } + return null; + } + + // Page page = (Page) _posPageMap.get(new Long(pos/PAGE_SIZE)); + // return page; + /// + private void FlushAllPages() + { + CachedIoAdapter.Page node = _head; + while (node != null) + { + FlushPage(node); + node = node._next; + } + } + + /// + private void FlushPage(CachedIoAdapter.Page page) + { + if (!page._dirty) + { + return; + } + IoSeek(page.StartAddress()); + WritePageToDisk(page); + return; + } + + /// + private void GetPageFromDisk(CachedIoAdapter.Page page, long pos) + { + long startAddress = pos - pos % _pageSize; + page.StartAddress(startAddress); + IoSeek(page._startAddress); + int count = IoRead(page); + if (count > 0) + { + page.EndAddress(startAddress + count); + } + else + { + page.EndAddress(startAddress); + } + } + + // _posPageMap.put(new Long(page.startPosition / PAGE_SIZE), page); + /// + private int IoRead(CachedIoAdapter.Page page) + { + int count = _io.Read(page._buffer); + if (count > 0) + { + _filePointer = page._startAddress + count; + } + return count; + } + + private void MovePageToHead(CachedIoAdapter.Page page) + { + if (page == _head) + { + return; + } + if (page == _tail) + { + CachedIoAdapter.Page tempTail = _tail._prev; + tempTail._next = null; + _tail._next = _head; + _tail._prev = null; + _head._prev = page; + _head = _tail; + _tail = tempTail; + } + else + { + page._prev._next = page._next; + page._next._prev = page._prev; + page._next = _head; + _head._prev = page; + page._prev = null; + _head = page; + } + } + + /// + private void WritePageToDisk(CachedIoAdapter.Page page) + { + ValidateReadOnly(); + try + { + _io.Write(page._buffer, page.Size()); + _filePointer = page.EndAddress(); + page._dirty = false; + } + catch (Db4oIOException e) + { + _readOnly = true; + throw; + } + } + + /// Moves the pointer to the specified file position + /// position within the file + /// + public override void Seek(long pos) + { + _position = pos; + } + + /// + private void IoSeek(long pos) + { + if (_filePointer != pos) + { + _io.Seek(pos); + _filePointer = pos; + } + } + + private class Page + { + internal byte[] _buffer; + + internal long _startAddress = -1; + + internal long _endAddress; + + internal readonly int _bufferSize; + + internal bool _dirty; + + internal CachedIoAdapter.Page _prev; + + internal CachedIoAdapter.Page _next; + + private byte[] zeroBytes; + + public Page(int size) + { + _bufferSize = size; + _buffer = new byte[_bufferSize]; + } + + internal virtual void EnsureEndAddress(long fileLength) + { + long bufferEndAddress = _startAddress + _bufferSize; + if (_endAddress < bufferEndAddress && fileLength > _endAddress) + { + long newEndAddress = Math.Min(fileLength, bufferEndAddress); + if (zeroBytes == null) + { + zeroBytes = new byte[_bufferSize]; + } + System.Array.Copy(zeroBytes, 0, _buffer, (int)(_endAddress - _startAddress), (int + )(newEndAddress - _endAddress)); + _endAddress = newEndAddress; + } + } + + internal virtual long EndAddress() + { + return _endAddress; + } + + internal virtual void StartAddress(long address) + { + _startAddress = address; + } + + internal virtual long StartAddress() + { + return _startAddress; + } + + internal virtual void EndAddress(long address) + { + _endAddress = address; + } + + internal virtual int Size() + { + return (int)(_endAddress - _startAddress); + } + + internal virtual int Read(byte[] @out, int outOffset, long startAddress, int length + ) + { + int bufferOffset = (int)(startAddress - _startAddress); + int pageAvailbeDataSize = (int)(_endAddress - startAddress); + int readBytes = Math.Min(pageAvailbeDataSize, length); + if (readBytes <= 0) + { + // meaning reach EOF + return -1; + } + System.Array.Copy(_buffer, bufferOffset, @out, outOffset, readBytes); + return readBytes; + } + + internal virtual int Write(byte[] data, int dataOffset, long startAddress, int length + ) + { + int bufferOffset = (int)(startAddress - _startAddress); + int pageAvailabeBufferSize = _bufferSize - bufferOffset; + int writtenBytes = Math.Min(pageAvailabeBufferSize, length); + System.Array.Copy(data, dataOffset, _buffer, bufferOffset, writtenBytes); + long endAddress = startAddress + writtenBytes; + if (endAddress > _endAddress) + { + _endAddress = endAddress; + } + _dirty = true; + return writtenBytes; + } + + internal virtual bool Contains(long address) + { + return (_startAddress != -1 && address >= _startAddress && address < _startAddress + + _bufferSize); + } + + internal virtual bool IsFree() + { + return _startAddress == -1; + } + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IO/CachingBin.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IO/CachingBin.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IO/CachingBin.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IO/CachingBin.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,364 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using System.Collections; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.IO; +using Db4objects.Db4o.Internal.Caching; +using Sharpen; +using Sharpen.Lang; + +namespace Db4objects.Db4o.IO +{ + /// + internal class CachingBin : BinDecorator + { + private readonly int _pageSize; + + private readonly ICache4 _cache; + + private readonly IObjectPool _pagePool; + + private long _fileLength; + + private sealed class _IProcedure4_22 : IProcedure4 + { + public _IProcedure4_22(CachingBin _enclosing) + { + this._enclosing = _enclosing; + } + + public void Apply(object discardedPage) + { + this._enclosing.FlushPage(((CachingBin.Page)discardedPage)); + this._enclosing._pagePool.ReturnObject(((CachingBin.Page)discardedPage)); + } + + private readonly CachingBin _enclosing; + } + + private IProcedure4 _onDiscardPage; + + /// + public CachingBin(IBin bin, ICache4 cache, int pageCount, int pageSize) : base(bin + ) + { + _onDiscardPage = new _IProcedure4_22(this); + _producerFromDisk = new _IFunction4_138(this); + _producerFromPool = new _IFunction4_147(this); + _pageSize = pageSize; + _pagePool = new SimpleObjectPool(NewPagePool(pageCount)); + _cache = cache; + _fileLength = _bin.Length(); + } + + private CachingBin.Page[] NewPagePool(int pageCount) + { + CachingBin.Page[] pages = new CachingBin.Page[pageCount]; + for (int i = 0; i < pages.Length; ++i) + { + pages[i] = new CachingBin.Page(_pageSize); + } + return pages; + } + + /// Reads the file into the buffer using pages from cache. + /// + /// Reads the file into the buffer using pages from cache. If the next page + /// is not cached it will be read from the file. + /// + /// + /// + /// start position to read + /// + /// destination buffer + /// how many bytes to read + /// + public override int Read(long pos, byte[] buffer, int length) + { + return ReadInternal(pos, buffer, length, false); + } + + private int ReadInternal(long pos, byte[] buffer, int length, bool syncRead) + { + long startAddress = pos; + int bytesToRead = length; + int totalRead = 0; + while (bytesToRead > 0) + { + CachingBin.Page page = syncRead ? SyncReadPage(startAddress) : GetPage(startAddress + , _producerFromDisk); + int readBytes = page.Read(buffer, totalRead, startAddress, bytesToRead); + if (readBytes <= 0) + { + break; + } + bytesToRead -= readBytes; + startAddress += readBytes; + totalRead += readBytes; + } + return totalRead == 0 ? -1 : totalRead; + } + + /// Writes the buffer to cache using pages + /// start position to write + /// source buffer + /// how many bytes to write + /// + public override void Write(long pos, byte[] buffer, int length) + { + long startAddress = pos; + int bytesToWrite = length; + int bufferOffset = 0; + while (bytesToWrite > 0) + { + // page doesn't need to loadFromDisk if the whole page is dirty + bool loadFromDisk = (bytesToWrite < _pageSize) || (startAddress % _pageSize != 0); + CachingBin.Page page = GetPage(startAddress, loadFromDisk); + int writtenBytes = page.Write(buffer, bufferOffset, startAddress, bytesToWrite); + bytesToWrite -= writtenBytes; + startAddress += writtenBytes; + bufferOffset += writtenBytes; + } + long endAddress = startAddress; + _fileLength = Math.Max(endAddress, _fileLength); + } + + /// Flushes cache to a physical storage + /// + public override void Sync() + { + FlushAllPages(); + base.Sync(); + } + + public override void Sync(IRunnable runnable) + { + FlushAllPages(); + base.Sync(new _IRunnable_119(this, runnable)); + } + + private sealed class _IRunnable_119 : IRunnable + { + public _IRunnable_119(CachingBin _enclosing, IRunnable runnable) + { + this._enclosing = _enclosing; + this.runnable = runnable; + } + + public void Run() + { + runnable.Run(); + this._enclosing.FlushAllPages(); + } + + private readonly CachingBin _enclosing; + + private readonly IRunnable runnable; + } + + public override int SyncRead(long position, byte[] bytes, int bytesToRead) + { + return ReadInternal(position, bytes, bytesToRead, true); + } + + /// Returns the file length + /// + public override long Length() + { + return _fileLength; + } + + private sealed class _IFunction4_138 : IFunction4 + { + public _IFunction4_138(CachingBin _enclosing) + { + this._enclosing = _enclosing; + } + + public object Apply(object pageAddress) + { + // in case that page is not found in the cache + CachingBin.Page newPage = ((CachingBin.Page)this._enclosing._pagePool.BorrowObject + ()); + this._enclosing.LoadPage(newPage, ((long)pageAddress)); + return newPage; + } + + private readonly CachingBin _enclosing; + } + + internal readonly IFunction4 _producerFromDisk; + + private sealed class _IFunction4_147 : IFunction4 + { + public _IFunction4_147(CachingBin _enclosing) + { + this._enclosing = _enclosing; + } + + public object Apply(object pageAddress) + { + // in case that page is not found in the cache + CachingBin.Page newPage = ((CachingBin.Page)this._enclosing._pagePool.BorrowObject + ()); + this._enclosing.ResetPageAddress(newPage, ((long)pageAddress)); + return newPage; + } + + private readonly CachingBin _enclosing; + } + + internal readonly IFunction4 _producerFromPool; + + /// + private CachingBin.Page GetPage(long startAddress, bool loadFromDisk) + { + IFunction4 producer = loadFromDisk ? _producerFromDisk : _producerFromPool; + return GetPage(startAddress, producer); + } + + private CachingBin.Page GetPage(long startAddress, IFunction4 producer) + { + CachingBin.Page page = ((CachingBin.Page)_cache.Produce(PageAddressFor(startAddress + ), producer, _onDiscardPage)); + page.EnsureEndAddress(_fileLength); + return page; + } + + private CachingBin.Page SyncReadPage(long startAddress) + { + CachingBin.Page page = new CachingBin.Page(_pageSize); + LoadPage(page, startAddress); + page.EnsureEndAddress(_fileLength); + return page; + } + + private long PageAddressFor(long startAddress) + { + return (startAddress / _pageSize) * _pageSize; + } + + private void ResetPageAddress(CachingBin.Page page, long startAddress) + { + page._startAddress = startAddress; + page._endAddress = startAddress + _pageSize; + } + + /// + protected virtual void FlushAllPages() + { + for (IEnumerator pIter = _cache.GetEnumerator(); pIter.MoveNext(); ) + { + CachingBin.Page p = ((CachingBin.Page)pIter.Current); + FlushPage(p); + } + } + + /// + private void FlushPage(CachingBin.Page page) + { + if (!page._dirty) + { + return; + } + WritePageToDisk(page); + } + + /// + private void LoadPage(CachingBin.Page page, long pos) + { + long startAddress = pos - pos % _pageSize; + page._startAddress = startAddress; + int count = _bin.Read(page._startAddress, page._buffer, page._bufferSize); + if (count > 0) + { + page._endAddress = startAddress + count; + } + else + { + page._endAddress = startAddress; + } + } + + /// + private void WritePageToDisk(CachingBin.Page page) + { + base.Write(page._startAddress, page._buffer, page.Size()); + page._dirty = false; + } + + private class Page + { + public readonly byte[] _buffer; + + public long _startAddress = -1; + + public long _endAddress; + + public readonly int _bufferSize; + + public bool _dirty; + + private byte[] zeroBytes; + + public Page(int size) + { + _bufferSize = size; + _buffer = new byte[_bufferSize]; + } + + internal virtual void EnsureEndAddress(long fileLength) + { + long bufferEndAddress = _startAddress + _bufferSize; + if (_endAddress < bufferEndAddress && fileLength > _endAddress) + { + long newEndAddress = Math.Min(fileLength, bufferEndAddress); + if (zeroBytes == null) + { + zeroBytes = new byte[_bufferSize]; + } + System.Array.Copy(zeroBytes, 0, _buffer, (int)(_endAddress - _startAddress), (int + )(newEndAddress - _endAddress)); + _endAddress = newEndAddress; + } + } + + internal virtual int Size() + { + return (int)(_endAddress - _startAddress); + } + + internal virtual int Read(byte[] @out, int outOffset, long startAddress, int length + ) + { + int bufferOffset = (int)(startAddress - _startAddress); + int pageAvailbeDataSize = (int)(_endAddress - startAddress); + int readBytes = Math.Min(pageAvailbeDataSize, length); + if (readBytes <= 0) + { + // meaning reach EOF + return -1; + } + System.Array.Copy(_buffer, bufferOffset, @out, outOffset, readBytes); + return readBytes; + } + + internal virtual int Write(byte[] data, int dataOffset, long startAddress, int length + ) + { + int bufferOffset = (int)(startAddress - _startAddress); + int pageAvailabeBufferSize = _bufferSize - bufferOffset; + int writtenBytes = Math.Min(pageAvailabeBufferSize, length); + System.Array.Copy(data, dataOffset, _buffer, bufferOffset, writtenBytes); + long endAddress = startAddress + writtenBytes; + if (endAddress > _endAddress) + { + _endAddress = endAddress; + } + _dirty = true; + return writtenBytes; + } + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IO/CachingStorage.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IO/CachingStorage.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IO/CachingStorage.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IO/CachingStorage.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,107 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.IO; +using Db4objects.Db4o.Internal.Caching; + +namespace Db4objects.Db4o.IO +{ + /// + /// Caching storage adapter to cache db4o database data in memory + /// until the underlying + /// IBin + /// is instructed to flush its + /// data when + /// IBin.Sync() + /// is called.

+ /// You can override the + /// NewCache() + /// method if you want to + /// work with a different caching strategy. + ///
+ public class CachingStorage : StorageDecorator + { + private static int DefaultPageCount = 64; + + private static int DefaultPageSize = 1024; + + private int _pageCount; + + private int _pageSize; + + /// + /// default constructor to create a Caching storage with the default + /// page count of 64 and the default page size of 1024. + /// + /// + /// default constructor to create a Caching storage with the default + /// page count of 64 and the default page size of 1024. + /// + /// + /// the + /// IStorage + /// to be cached. + /// + public CachingStorage(IStorage storage) : this(storage, DefaultPageCount, DefaultPageSize + ) + { + } + + /// + /// constructor to set up a CachingStorage with a configured page count + /// and page size + /// + /// + /// the + /// IStorage + /// to be cached. + /// + /// the number of pages the cache should use. + /// the size of the pages the cache should use. + public CachingStorage(IStorage storage, int pageCount, int pageSize) : base(storage + ) + { + _pageCount = pageCount; + _pageSize = pageSize; + } + + /// opens a Bin for the given URI. + /// opens a Bin for the given URI. + /// + public override IBin Open(BinConfiguration config) + { + IBin storage = base.Open(config); + if (config.ReadOnly()) + { + return new ReadOnlyBin(new CachingStorage.NonFlushingCachingBin(storage, NewCache + (), _pageCount, _pageSize)); + } + return new CachingBin(storage, NewCache(), _pageCount, _pageSize); + } + + /// + /// override this method if you want to work with a different caching + /// strategy than the default LRU2Q cache. + /// + /// + /// override this method if you want to work with a different caching + /// strategy than the default LRU2Q cache. + /// + protected virtual ICache4 NewCache() + { + return CacheFactory.NewLRULongCache(_pageCount); + } + + private sealed class NonFlushingCachingBin : CachingBin + { + /// + public NonFlushingCachingBin(IBin bin, ICache4 cache, int pageCount, int pageSize + ) : base(bin, cache, pageCount, pageSize) + { + } + + protected override void FlushAllPages() + { + } + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IO/ConstantGrowthStrategy.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IO/ConstantGrowthStrategy.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IO/ConstantGrowthStrategy.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IO/ConstantGrowthStrategy.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,34 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.IO; + +namespace Db4objects.Db4o.IO +{ + /// Strategy for file/byte array growth by a constant factor + public class ConstantGrowthStrategy : IGrowthStrategy + { + private readonly int _growth; + + /// The constant growth size + public ConstantGrowthStrategy(int growth) + { + _growth = growth; + } + + /// + /// returns the incremented size after the growth + /// strategy has been applied + /// + /// the original size + /// the new size + public virtual long NewSize(long curSize, long requiredSize) + { + long newSize = curSize; + while (newSize < requiredSize) + { + newSize += _growth; + } + return newSize; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IO/DoublingGrowthStrategy.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IO/DoublingGrowthStrategy.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IO/DoublingGrowthStrategy.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IO/DoublingGrowthStrategy.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,25 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.IO; + +namespace Db4objects.Db4o.IO +{ + /// Strategy for file/byte array growth that will always double the current size + /// + public class DoublingGrowthStrategy : IGrowthStrategy + { + public virtual long NewSize(long curSize, long requiredSize) + { + if (curSize == 0) + { + return requiredSize; + } + long newSize = curSize; + while (newSize < requiredSize) + { + newSize *= 2; + } + return newSize; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IO/FileStorage.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IO/FileStorage.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IO/FileStorage.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IO/FileStorage.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,209 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System.IO; +using Db4objects.Db4o; +using Db4objects.Db4o.Ext; +using Db4objects.Db4o.Foundation.IO; +using Db4objects.Db4o.IO; +using Db4objects.Db4o.Internal; +using Sharpen.IO; +using Sharpen.Lang; + +namespace Db4objects.Db4o.IO +{ + /// + /// Storage adapter to store db4o database data to physical + /// files on hard disc. + /// + /// + /// Storage adapter to store db4o database data to physical + /// files on hard disc. + /// + public class FileStorage : IStorage + { + /// + /// opens a + /// IBin + /// on the specified URI (file system path). + /// + /// + public virtual IBin Open(BinConfiguration config) + { + return new FileStorage.FileBin(config); + } + + /// returns true if the specified file system path already exists. + /// returns true if the specified file system path already exists. + public virtual bool Exists(string uri) + { + Sharpen.IO.File file = new Sharpen.IO.File(uri); + return file.Exists() && file.Length() > 0; + } + + public class FileBin : IBin + { + private readonly string _path; + + private RandomAccessFile _file; + + /// + public FileBin(BinConfiguration config) + { + bool ok = false; + try + { + _path = new Sharpen.IO.File(config.Uri()).GetCanonicalPath(); + _file = RandomAccessFileFactory.NewRandomAccessFile(_path, config.ReadOnly(), config + .LockFile()); + if (config.InitialLength() > 0) + { + Write(config.InitialLength() - 1, new byte[] { 0 }, 1); + } + ok = true; + } + catch (IOException e) + { + throw new Db4oIOException(e); + } + finally + { + if (!ok) + { + Close(); + } + } + } + + /// + public virtual void Close() + { + Platform4.UnlockFile(_path, _file); + try + { + if (!IsClosed()) + { + _file.Close(); + } + } + catch (IOException e) + { + throw new Db4oIOException(e); + } + finally + { + _file = null; + } + } + + internal virtual bool IsClosed() + { + return _file == null; + } + + /// + public virtual long Length() + { + try + { + return _file.Length(); + } + catch (IOException e) + { + throw new Db4oIOException(e); + } + } + + /// + public virtual int Read(long pos, byte[] bytes, int length) + { + try + { + Seek(pos); + if (DTrace.enabled) + { + DTrace.FileRead.LogLength(pos, length); + } + return _file.Read(bytes, 0, length); + } + catch (IOException e) + { + throw new Db4oIOException(e); + } + } + + /// + internal virtual void Seek(long pos) + { + if (DTrace.enabled) + { + DTrace.RegularSeek.Log(pos); + } + _file.Seek(pos); + } + + /// + public virtual void Sync() + { + try + { + _file.GetFD().Sync(); + } + catch (IOException e) + { + throw new Db4oIOException(e); + } + } + + public virtual int SyncRead(long position, byte[] bytes, int bytesToRead) + { + return Read(position, bytes, bytesToRead); + } + + /// + public virtual void Write(long pos, byte[] buffer, int length) + { + CheckClosed(); + try + { + Seek(pos); + if (DTrace.enabled) + { + DTrace.FileWrite.LogLength(pos, length); + } + _file.Write(buffer, 0, length); + } + catch (IOException e) + { + throw new Db4oIOException(e); + } + } + + private void CheckClosed() + { + if (IsClosed()) + { + throw new Db4oIOException(); + } + } + + public virtual void Sync(IRunnable runnable) + { + Sync(); + runnable.Run(); + Sync(); + } + } + + /// + public virtual void Delete(string uri) + { + File4.Delete(uri); + } + + /// + public virtual void Rename(string oldUri, string newUri) + { + System.IO.File.Move(oldUri, newUri); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IO/IBin.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IO/IBin.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IO/IBin.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IO/IBin.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,78 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Sharpen.Lang; + +namespace Db4objects.Db4o.IO +{ + /// + /// Representation of a container for storage of db4o + /// database data (to file, to memory). + /// + /// + /// Representation of a container for storage of db4o + /// database data (to file, to memory). + /// + public interface IBin + { + /// returns the length of the Bin (on disc, in memory). + /// returns the length of the Bin (on disc, in memory). + long Length(); + + /// + /// reads a given number of bytes into an array of bytes at an + /// offset position. + /// + /// + /// reads a given number of bytes into an array of bytes at an + /// offset position. + /// + /// the offset position to read at + /// the byte array to read bytes into + /// the number of bytes to be read + /// + int Read(long position, byte[] bytes, int bytesToRead); + + /// + /// writes a given number of bytes from an array of bytes at + /// an offset position + /// + /// the offset position to write at + /// the array of bytes to write + /// the number of bytes to write + void Write(long position, byte[] bytes, int bytesToWrite); + + /// + /// flushes the buffer content to the physical storage + /// media. + /// + /// + /// flushes the buffer content to the physical storage + /// media. + /// + void Sync(); + + /// runs the Runnable between two calls to sync(); + void Sync(IRunnable runnable); + + /// + /// reads a given number of bytes into an array of bytes at an + /// offset position. + /// + /// + /// reads a given number of bytes into an array of bytes at an + /// offset position. In contrast to the normal + /// Read(long, byte[], int) + /// method, the Bin should ensure direct access to the raw storage medium. + /// No caching should take place. + /// + /// the offset position to read at + /// the byte array to read bytes into + /// the number of bytes to be read + /// + int SyncRead(long position, byte[] bytes, int bytesToRead); + + /// closes the Bin. + /// closes the Bin. + void Close(); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IO/IBlockSize.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IO/IBlockSize.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IO/IBlockSize.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IO/IBlockSize.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,23 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Foundation; + +namespace Db4objects.Db4o.IO +{ + /// Block size registry. + /// + /// Block size registry. + /// Accessible through the environment. + /// + /// Db4objects.Db4o.Foundation.Environments.My(System.Type<T>) + /// + /// 7.7 + public interface IBlockSize + { + void Register(IListener4 listener); + + void Set(int newValue); + + int Value(); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IO/IGrowthStrategy.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IO/IGrowthStrategy.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IO/IGrowthStrategy.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IO/IGrowthStrategy.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,20 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +namespace Db4objects.Db4o.IO +{ + /// Strategy for file/byte array growth. + /// Strategy for file/byte array growth. + public interface IGrowthStrategy + { + /// + /// returns the incremented size after the growth + /// strategy has been applied + /// + /// the original size + /// + /// the new size, after the growth strategy has been + /// applied, must be bigger than curSize + /// + long NewSize(long curSize, long requiredSize); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IO/IoAdapter.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IO/IoAdapter.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IO/IoAdapter.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IO/IoAdapter.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,160 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using Db4objects.Db4o; +using Db4objects.Db4o.IO; + +namespace Db4objects.Db4o.IO +{ + /// Base class for database file adapters, both for file and memory databases. + /// + /// Base class for database file adapters, both for file and memory databases. + /// + [System.ObsoleteAttribute(@"Use classes that implement instead. The new functionality has been split: is the factory class to open adapters. is the actual implementation of IO access." + )] + public abstract class IoAdapter + { + private const int CopySize = 4096; + + private int _blockSize; + + /// converts address and address offset to an absolute address + protected long RegularAddress(int blockAddress, int blockAddressOffset) + { + if (0 == _blockSize) + { + throw new InvalidOperationException(); + } + return (long)blockAddress * _blockSize + blockAddressOffset; + } + + /// copies a block within a file in block mode + /// + public virtual void BlockCopy(int oldAddress, int oldAddressOffset, int newAddress + , int newAddressOffset, int length) + { + Copy(RegularAddress(oldAddress, oldAddressOffset), RegularAddress(newAddress, newAddressOffset + ), length); + } + + /// sets the read/write pointer in the file using block mode + /// + public virtual void BlockSeek(int address) + { + BlockSeek(address, 0); + } + + /// sets the read/write pointer in the file using block mode + /// + public virtual void BlockSeek(int address, int offset) + { + Seek(RegularAddress(address, offset)); + } + + /// outside call to set the block size of this adapter + public virtual void BlockSize(int blockSize) + { + if (blockSize < 1) + { + throw new ArgumentException(); + } + _blockSize = blockSize; + } + + /// implement to close the adapter + /// + public abstract void Close(); + + /// copies a block within a file in absolute mode + /// + public virtual void Copy(long oldAddress, long newAddress, int length) + { + if (DTrace.enabled) + { + DTrace.IoCopy.LogLength(newAddress, length); + } + if (length > CopySize) + { + byte[] buffer = new byte[CopySize]; + int pos = 0; + while (pos + CopySize < length) + { + Copy(buffer, oldAddress + pos, newAddress + pos); + pos += CopySize; + } + oldAddress += pos; + newAddress += pos; + length -= pos; + } + Copy(new byte[length], oldAddress, newAddress); + } + + /// + private void Copy(byte[] buffer, long oldAddress, long newAddress) + { + Seek(oldAddress); + Read(buffer); + Seek(newAddress); + Write(buffer); + } + + /// deletes the given path from whatever 'file system' is addressed + public abstract void Delete(string path); + + /// checks whether a file exists + public abstract bool Exists(string path); + + /// implement to return the absolute length of the file + /// + public abstract long GetLength(); + + /// implement to open the file + /// + public abstract IoAdapter Open(string path, bool lockFile, long initialLength, bool + readOnly); + + /// reads a buffer at the seeked address + /// the number of bytes read and returned + /// + public virtual int Read(byte[] buffer) + { + return Read(buffer, buffer.Length); + } + + /// implement to read a buffer at the seeked address + /// + public abstract int Read(byte[] bytes, int length); + + /// implement to set the read/write pointer in the file, absolute mode + /// + public abstract void Seek(long pos); + + /// implement to flush the file contents to storage + /// + public abstract void Sync(); + + /// writes a buffer to the seeked address + /// + public virtual void Write(byte[] bytes) + { + Write(bytes, bytes.Length); + } + + /// implement to write a buffer at the seeked address + /// + public abstract void Write(byte[] buffer, int length); + + /// returns the block size currently used + public virtual int BlockSize() + { + return _blockSize; + } + + /// Delegated IO Adapter + /// reference to itself + public virtual IoAdapter DelegatedIoAdapter() + { + return this; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IO/IoAdapterStorage.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IO/IoAdapterStorage.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IO/IoAdapterStorage.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IO/IoAdapterStorage.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,105 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.IO; +using Sharpen.Lang; + +namespace Db4objects.Db4o.IO +{ + /// + public class IoAdapterStorage : IStorage + { + private readonly IoAdapter _io; + + public IoAdapterStorage(IoAdapter io) + { + _io = io; + } + + public virtual bool Exists(string uri) + { + return _io.Exists(uri); + } + + /// + public virtual IBin Open(BinConfiguration config) + { + IoAdapterStorage.IoAdapterBin bin = new IoAdapterStorage.IoAdapterBin(_io.Open(config + .Uri(), config.LockFile(), config.InitialLength(), config.ReadOnly())); + ((IBlockSize)Environments.My(typeof(IBlockSize))).Register(bin); + return bin; + } + + internal class IoAdapterBin : IBin, IListener4 + { + private readonly IoAdapter _io; + + public IoAdapterBin(IoAdapter io) + { + _io = io; + } + + public virtual void Close() + { + _io.Close(); + } + + public virtual long Length() + { + return _io.GetLength(); + } + + public virtual int Read(long position, byte[] buffer, int bytesToRead) + { + _io.Seek(position); + return _io.Read(buffer, bytesToRead); + } + + public virtual void Sync() + { + _io.Sync(); + } + + public virtual int SyncRead(long position, byte[] bytes, int bytesToRead) + { + return Read(position, bytes, bytesToRead); + } + + public virtual void Write(long position, byte[] bytes, int bytesToWrite) + { + _io.Seek(position); + _io.Write(bytes, bytesToWrite); + } + + public virtual void BlockSize(int blockSize) + { + _io.BlockSize(blockSize); + } + + public virtual void OnEvent(object @event) + { + BlockSize((((int)@event))); + } + + public virtual void Sync(IRunnable runnable) + { + Sync(); + runnable.Run(); + Sync(); + } + } + + /// + public virtual void Delete(string uri) + { + _io.Delete(uri); + } + + /// + public virtual void Rename(string oldUri, string newUri) + { + throw new NotImplementedException(); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IO/IStorage.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IO/IStorage.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IO/IStorage.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IO/IStorage.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,45 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.IO; + +namespace Db4objects.Db4o.IO +{ + /// + /// Base interface for Storage adapters that open a + /// IBin + /// to store db4o database data to. + /// + /// + public interface IStorage + { + /// + /// opens a + /// IBin + /// to store db4o database data. + /// + /// + IBin Open(BinConfiguration config); + + /// returns true if a Bin (file or memory) exists with the passed name. + /// returns true if a Bin (file or memory) exists with the passed name. + bool Exists(string uri); + + /// Deletes the bin for the given URI from the storage. + /// Deletes the bin for the given URI from the storage. + /// 7.9 + /// bin URI + /// if the bin could not be deleted + void Delete(string uri); + + /// Renames the bin for the given old URI to the new URI. + /// + /// Renames the bin for the given old URI to the new URI. If a bin for the new URI + /// exists, it will be overwritten. + /// + /// 7.9 + /// URI of the existing bin + /// future URI of the bin + /// if the bin could not be deleted + void Rename(string oldUri, string newUri); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IO/MemoryBin.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IO/MemoryBin.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IO/MemoryBin.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IO/MemoryBin.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,110 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using Db4objects.Db4o.IO; +using Sharpen; +using Sharpen.Lang; + +namespace Db4objects.Db4o.IO +{ + public class MemoryBin : IBin + { + private byte[] _bytes; + + private int _length; + + private IGrowthStrategy _growthStrategy; + + public MemoryBin(int initialSize, IGrowthStrategy growthStrategy) : this(new byte + [initialSize], growthStrategy) + { + } + + public MemoryBin(byte[] bytes, IGrowthStrategy growthStrategy) + { + _bytes = bytes; + _length = bytes.Length; + _growthStrategy = growthStrategy; + } + + public virtual long Length() + { + return _length; + } + + public virtual long BufferSize() + { + return _bytes.Length; + } + + /// + public virtual int Read(long pos, byte[] bytes, int length) + { + long avail = _length - pos; + if (avail <= 0) + { + return -1; + } + int read = Math.Min((int)avail, length); + System.Array.Copy(_bytes, (int)pos, bytes, 0, read); + return read; + } + + /// + public virtual void Sync() + { + } + + public virtual int SyncRead(long position, byte[] bytes, int bytesToRead) + { + return Read(position, bytes, bytesToRead); + } + + public virtual void Close() + { + } + + /// Returns a copy of the raw data contained in this bin for external processing. + /// + /// + /// Returns a copy of the raw data contained in this bin for external processing. + /// Access to the data is not guarded by synchronisation. If this method is called + /// while the MemoryBin is in use, it is possible that the returned byte array is + /// not consistent. + /// + public virtual byte[] Data() + { + byte[] data = new byte[_length]; + System.Array.Copy(_bytes, 0, data, 0, _length); + return data; + } + + /// for internal processing only. + /// for internal processing only. + /// + public virtual void Write(long pos, byte[] buffer, int length) + { + if (pos + length > _bytes.Length) + { + long newSize = _growthStrategy.NewSize(_bytes.Length, pos + length); + // if (pos + length > newSize) { + // newSize = pos + length; + // } + byte[] temp = new byte[(int)newSize]; + System.Array.Copy(_bytes, 0, temp, 0, _length); + _bytes = temp; + } + System.Array.Copy(buffer, 0, _bytes, (int)pos, length); + pos += length; + if (pos > _length) + { + _length = (int)pos; + } + } + + public virtual void Sync(IRunnable runnable) + { + runnable.Run(); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IO/MemoryStorage.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IO/MemoryStorage.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IO/MemoryStorage.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IO/MemoryStorage.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,100 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System.Collections; +using System.IO; +using Db4objects.Db4o.IO; + +namespace Db4objects.Db4o.IO +{ + /// + /// IStorage + /// implementation that produces + /// IBin + /// instances + /// that operate in memory. + /// Use this + /// IStorage + /// to work with db4o as an in-memory database. + /// + public class MemoryStorage : IStorage + { + private readonly IDictionary _bins = new Hashtable(); + + private readonly IGrowthStrategy _growthStrategy; + + public MemoryStorage() : this(new DoublingGrowthStrategy()) + { + } + + public MemoryStorage(IGrowthStrategy growthStrategy) + { + _growthStrategy = growthStrategy; + } + + /// + /// returns true if a MemoryBin with the given URI name already exists + /// in this Storage. + /// + /// + /// returns true if a MemoryBin with the given URI name already exists + /// in this Storage. + /// + public virtual bool Exists(string uri) + { + return _bins.Contains(uri); + } + + /// opens a MemoryBin for the given URI (name can be freely chosen). + /// opens a MemoryBin for the given URI (name can be freely chosen). + /// + public virtual IBin Open(BinConfiguration config) + { + IBin storage = ProduceStorage(config); + return config.ReadOnly() ? new ReadOnlyBin(storage) : storage; + } + + /// Returns the memory bin for the given URI for external use. + /// Returns the memory bin for the given URI for external use. + public virtual MemoryBin Bin(string uri) + { + return ((MemoryBin)_bins[uri]); + } + + /// Registers the given bin for this storage with the given URI. + /// Registers the given bin for this storage with the given URI. + public virtual void Bin(string uri, MemoryBin bin) + { + _bins[uri] = bin; + } + + private IBin ProduceStorage(BinConfiguration config) + { + IBin storage = Bin(config.Uri()); + if (null != storage) + { + return storage; + } + MemoryBin newStorage = new MemoryBin(new byte[(int)config.InitialLength()], _growthStrategy + ); + _bins[config.Uri()] = newStorage; + return newStorage; + } + + /// + public virtual void Delete(string uri) + { + Sharpen.Collections.Remove(_bins, uri); + } + + /// + public virtual void Rename(string oldUri, string newUri) + { + MemoryBin bin = ((MemoryBin)Sharpen.Collections.Remove(_bins, oldUri)); + if (bin == null) + { + throw new IOException("Bin not found: " + oldUri); + } + _bins[newUri] = bin; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IO/NonFlushingStorage.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IO/NonFlushingStorage.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IO/NonFlushingStorage.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IO/NonFlushingStorage.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,48 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.IO; +using Sharpen.Lang; + +namespace Db4objects.Db4o.IO +{ + /// + /// Storage adapter that does not pass flush calls + /// on to its delegate. + /// + /// + /// Storage adapter that does not pass flush calls + /// on to its delegate. + /// You can use this + /// IStorage + /// for improved db4o + /// speed at the risk of corrupted database files in + /// case of system failure. + /// + public class NonFlushingStorage : StorageDecorator + { + public NonFlushingStorage(IStorage storage) : base(storage) + { + } + + protected override IBin Decorate(BinConfiguration config, IBin storage) + { + return new NonFlushingStorage.NonFlushingBin(storage); + } + + private class NonFlushingBin : BinDecorator + { + public NonFlushingBin(IBin storage) : base(storage) + { + } + + public override void Sync() + { + } + + public override void Sync(IRunnable runnable) + { + runnable.Run(); + } + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IO/PagingMemoryBin.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IO/PagingMemoryBin.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IO/PagingMemoryBin.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IO/PagingMemoryBin.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,135 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using System.Collections; +using Db4objects.Db4o.IO; +using Sharpen; +using Sharpen.Lang; + +namespace Db4objects.Db4o.IO +{ + /// + internal class PagingMemoryBin : IBin + { + private readonly int _pageSize; + + private IList _pages = new ArrayList(); + + private int _lastPageLength; + + public PagingMemoryBin(int pageSize) : this(pageSize, 0) + { + } + + public PagingMemoryBin(int pageSize, long initialLength) + { + _pageSize = pageSize; + EnsureLength(initialLength); + } + + public virtual long Length() + { + if (_pages.Count == 0) + { + return 0; + } + return (_pages.Count - 1) * _pageSize + _lastPageLength; + } + + /// + public virtual int Read(long pos, byte[] buffer, int length) + { + long avail = Length() - pos; + if (avail <= 0) + { + return -1; + } + int bytesToRead = Math.Min((int)avail, length); + int offset = PageOffset(pos); + int pageIdx = PageIdx(pos); + int bytesRead = 0; + while (bytesRead < bytesToRead) + { + byte[] curPage = ((byte[])_pages[pageIdx]); + int chunkLength = Math.Min(length - bytesRead, _pageSize - offset); + System.Array.Copy(curPage, offset, buffer, bytesRead, chunkLength); + bytesRead += chunkLength; + pageIdx++; + offset = 0; + } + return bytesToRead; + } + + /// + public virtual void Sync() + { + } + + public virtual int SyncRead(long position, byte[] bytes, int bytesToRead) + { + return Read(position, bytes, bytesToRead); + } + + public virtual void Close() + { + } + + /// + public virtual void Write(long pos, byte[] buffer, int length) + { + EnsureLength(pos + length); + int offset = PageOffset(pos); + int pageIdx = PageIdx(pos); + int bytesWritten = 0; + while (bytesWritten < length) + { + byte[] curPage = ((byte[])_pages[pageIdx]); + int chunkLength = Math.Min(length - bytesWritten, _pageSize - offset); + System.Array.Copy(buffer, bytesWritten, curPage, offset, chunkLength); + bytesWritten += chunkLength; + pageIdx++; + offset = 0; + } + } + + private void EnsureLength(long length) + { + if (length <= 0) + { + return; + } + long lastPos = length - 1; + int lastPosPageIdx = PageIdx(lastPos); + int lastPosPageLength = PageOffset(lastPos) + 1; + if (lastPosPageIdx == _pages.Count - 1) + { + _lastPageLength = Math.Max(lastPosPageLength, _lastPageLength); + return; + } + if (lastPosPageIdx < _pages.Count) + { + return; + } + for (int newPageIdx = _pages.Count; newPageIdx <= lastPosPageIdx; newPageIdx++) + { + _pages.Add(new byte[_pageSize]); + } + _lastPageLength = lastPosPageLength; + } + + private int PageIdx(long pos) + { + return (int)(pos / _pageSize); + } + + private int PageOffset(long pos) + { + return (int)(pos % _pageSize); + } + + public virtual void Sync(IRunnable runnable) + { + runnable.Run(); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IO/PagingMemoryStorage.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IO/PagingMemoryStorage.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IO/PagingMemoryStorage.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IO/PagingMemoryStorage.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,101 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System.Collections; +using System.IO; +using Db4objects.Db4o.IO; + +namespace Db4objects.Db4o.IO +{ + /// + /// IStorage + /// implementation that produces + /// IBin + /// instances + /// that operate in memory. + /// Use this + /// IStorage + /// to work with db4o as an in-memory database. + /// + public class PagingMemoryStorage : IStorage + { + private const int DefaultPagesize = 4096; + + private readonly IDictionary _binsByUri = new Hashtable(); + + private readonly int _pageSize; + + public PagingMemoryStorage() : this(DefaultPagesize) + { + } + + public PagingMemoryStorage(int pageSize) + { + _pageSize = pageSize; + } + + /// + /// returns true if a MemoryBin with the given URI name already exists + /// in this Storage. + /// + /// + /// returns true if a MemoryBin with the given URI name already exists + /// in this Storage. + /// + public virtual bool Exists(string uri) + { + return _binsByUri.Contains(uri); + } + + /// opens a MemoryBin for the given URI (name can be freely chosen). + /// opens a MemoryBin for the given URI (name can be freely chosen). + /// + public virtual IBin Open(BinConfiguration config) + { + IBin bin = ProduceBin(config); + return config.ReadOnly() ? new ReadOnlyBin(bin) : bin; + } + + /// Returns the memory bin for the given URI for external use. + /// Returns the memory bin for the given URI for external use. + public virtual IBin Bin(string uri) + { + return ((IBin)_binsByUri[uri]); + } + + /// Registers the given bin for this storage with the given URI. + /// Registers the given bin for this storage with the given URI. + public virtual void Bin(string uri, IBin bin) + { + _binsByUri[uri] = bin; + } + + private IBin ProduceBin(BinConfiguration config) + { + IBin storage = Bin(config.Uri()); + if (null != storage) + { + return storage; + } + IBin newStorage = new PagingMemoryBin(_pageSize, config.InitialLength()); + _binsByUri[config.Uri()] = newStorage; + return newStorage; + } + + /// + public virtual void Delete(string uri) + { + Sharpen.Collections.Remove(_binsByUri, uri); + } + + /// + public virtual void Rename(string oldUri, string newUri) + { + IBin bin = ((IBin)Sharpen.Collections.Remove(_binsByUri, oldUri)); + if (bin == null) + { + throw new IOException("Bin not found: " + oldUri); + } + _binsByUri[newUri] = bin; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IO/RandomAccessFileAdapter.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IO/RandomAccessFileAdapter.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IO/RandomAccessFileAdapter.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IO/RandomAccessFileAdapter.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,173 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System.IO; +using Db4objects.Db4o; +using Db4objects.Db4o.Ext; +using Db4objects.Db4o.IO; +using Db4objects.Db4o.Internal; +using Sharpen.IO; + +namespace Db4objects.Db4o.IO +{ + /// IO adapter for random access files. + /// IO adapter for random access files. + [System.ObsoleteAttribute(@"Use instead.")] + public class RandomAccessFileAdapter : IoAdapter + { + private string _path; + + private RandomAccessFile _delegate; + + public RandomAccessFileAdapter() + { + } + + /// + protected RandomAccessFileAdapter(string path, bool lockFile, long initialLength, + bool readOnly) + { + bool ok = false; + try + { + _path = new Sharpen.IO.File(path).GetCanonicalPath(); + _delegate = RandomAccessFileFactory.NewRandomAccessFile(_path, readOnly, lockFile + ); + if (initialLength > 0) + { + _delegate.Seek(initialLength - 1); + _delegate.Write(new byte[] { 0 }); + } + ok = true; + } + catch (IOException e) + { + throw new Db4oIOException(e); + } + finally + { + if (!ok) + { + Close(); + } + } + } + + /// + public override void Close() + { + // FIXME: This is a temporary quickfix for a bug in Android. + // Remove after Android has been fixed. + try + { + if (_delegate != null) + { + _delegate.Seek(0); + } + } + catch (IOException) + { + } + // ignore + Platform4.UnlockFile(_path, _delegate); + try + { + if (_delegate != null) + { + _delegate.Close(); + } + } + catch (IOException e) + { + throw new Db4oIOException(e); + } + } + + public override void Delete(string path) + { + new Sharpen.IO.File(path).Delete(); + } + + public override bool Exists(string path) + { + Sharpen.IO.File existingFile = new Sharpen.IO.File(path); + return existingFile.Exists() && existingFile.Length() > 0; + } + + /// + public override long GetLength() + { + try + { + return _delegate.Length(); + } + catch (IOException e) + { + throw new Db4oIOException(e); + } + } + + /// + public override IoAdapter Open(string path, bool lockFile, long initialLength, bool + readOnly) + { + return new Db4objects.Db4o.IO.RandomAccessFileAdapter(path, lockFile, initialLength + , readOnly); + } + + /// + public override int Read(byte[] bytes, int length) + { + try + { + return _delegate.Read(bytes, 0, length); + } + catch (IOException e) + { + throw new Db4oIOException(e); + } + } + + /// + public override void Seek(long pos) + { + if (DTrace.enabled) + { + DTrace.RegularSeek.Log(pos); + } + try + { + _delegate.Seek(pos); + } + catch (IOException e) + { + throw new Db4oIOException(e); + } + } + + /// + public override void Sync() + { + try + { + _delegate.GetFD().Sync(); + } + catch (IOException e) + { + throw new Db4oIOException(e); + } + } + + /// + public override void Write(byte[] buffer, int length) + { + try + { + _delegate.Write(buffer, 0, length); + } + catch (IOException e) + { + throw new Db4oIOException(e); + } + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IO/ReadOnlyBin.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IO/ReadOnlyBin.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IO/ReadOnlyBin.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IO/ReadOnlyBin.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,20 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Ext; +using Db4objects.Db4o.IO; + +namespace Db4objects.Db4o.IO +{ + /// + public class ReadOnlyBin : BinDecorator + { + public ReadOnlyBin(IBin storage) : base(storage) + { + } + + public override void Write(long position, byte[] bytes, int bytesToWrite) + { + throw new Db4oIOException(); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IO/StorageDecorator.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IO/StorageDecorator.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IO/StorageDecorator.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IO/StorageDecorator.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,51 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.IO; + +namespace Db4objects.Db4o.IO +{ + /// Wrapper base class for all classes that wrap Storage. + /// + /// Wrapper base class for all classes that wrap Storage. + /// Each class that adds functionality to a Storage must + /// extend this class. + /// + /// + public class StorageDecorator : IStorage + { + protected readonly IStorage _storage; + + public StorageDecorator(IStorage storage) + { + _storage = storage; + } + + public virtual bool Exists(string uri) + { + return _storage.Exists(uri); + } + + /// + public virtual IBin Open(BinConfiguration config) + { + return Decorate(config, _storage.Open(config)); + } + + protected virtual IBin Decorate(BinConfiguration config, IBin bin) + { + return bin; + } + + /// + public virtual void Delete(string uri) + { + _storage.Delete(uri); + } + + /// + public virtual void Rename(string oldUri, string newUri) + { + _storage.Rename(oldUri, newUri); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IO/SynchronizedBin.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IO/SynchronizedBin.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IO/SynchronizedBin.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IO/SynchronizedBin.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,63 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.IO; +using Sharpen.Lang; + +namespace Db4objects.Db4o.IO +{ + /// + public class SynchronizedBin : BinDecorator + { + public SynchronizedBin(IBin bin) : base(bin) + { + } + + public override void Close() + { + lock (_bin) + { + base.Close(); + } + } + + public override long Length() + { + lock (_bin) + { + return base.Length(); + } + } + + public override int Read(long position, byte[] buffer, int bytesToRead) + { + lock (_bin) + { + return base.Read(position, buffer, bytesToRead); + } + } + + public override void Write(long position, byte[] bytes, int bytesToWrite) + { + lock (_bin) + { + base.Write(position, bytes, bytesToWrite); + } + } + + public override void Sync() + { + lock (_bin) + { + base.Sync(); + } + } + + public override void Sync(IRunnable runnable) + { + lock (_bin) + { + base.Sync(runnable); + } + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IO/ThreadedSyncBin.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IO/ThreadedSyncBin.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IO/ThreadedSyncBin.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IO/ThreadedSyncBin.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,165 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.IO; +using Sharpen.Lang; + +namespace Db4objects.Db4o.IO +{ + public class ThreadedSyncBin : BinDecorator + { + private const int OneSecond = 1000; + + private volatile IRunnable _syncRunnable; + + private volatile bool _closed; + + private readonly Thread _thread; + + private readonly Lock4 _lock = new Lock4(); + + public ThreadedSyncBin(IBin bin) : base(bin) + { + _thread = new Thread(new _IRunnable_23(this), "ThreadedSyncBin"); + _thread.Start(); + } + + private sealed class _IRunnable_23 : IRunnable + { + public _IRunnable_23(ThreadedSyncBin _enclosing) + { + this._enclosing = _enclosing; + } + + public void Run() + { + IClosure4 closure = new _IClosure4_25(this); + while (true) + { + this._enclosing._lock.Run(closure); + if (this._enclosing._closed) + { + return; + } + } + } + + private sealed class _IClosure4_25 : IClosure4 + { + public _IClosure4_25(_IRunnable_23 _enclosing) + { + this._enclosing = _enclosing; + } + + public object Run() + { + this._enclosing._enclosing.RunSyncRunnable(); + this._enclosing._enclosing._lock.Snooze(Db4objects.Db4o.IO.ThreadedSyncBin.OneSecond + ); + return null; + } + + private readonly _IRunnable_23 _enclosing; + } + + private readonly ThreadedSyncBin _enclosing; + } + + public override void Close() + { + WaitForPendingSync(); + _closed = true; + _lock.Run(new _IClosure4_46(this)); + base.Close(); + } + + private sealed class _IClosure4_46 : IClosure4 + { + public _IClosure4_46(ThreadedSyncBin _enclosing) + { + this._enclosing = _enclosing; + } + + public object Run() + { + this._enclosing._lock.Awake(); + return null; + } + + private readonly ThreadedSyncBin _enclosing; + } + + private void WaitForPendingSync() + { + while (_syncRunnable != null) + { + if (Thread.CurrentThread() == _thread) + { + return; + } + } + } + + public override long Length() + { + WaitForPendingSync(); + return base.Length(); + } + + public override int Read(long position, byte[] buffer, int bytesToRead) + { + WaitForPendingSync(); + return base.Read(position, buffer, bytesToRead); + } + + public override void Write(long position, byte[] bytes, int bytesToWrite) + { + WaitForPendingSync(); + base.Write(position, bytes, bytesToWrite); + } + + public override void Sync() + { + WaitForPendingSync(); + base.Sync(); + } + + public override void Sync(IRunnable runnable) + { + WaitForPendingSync(); + _lock.Run(new _IClosure4_85(this, runnable)); + } + + private sealed class _IClosure4_85 : IClosure4 + { + public _IClosure4_85(ThreadedSyncBin _enclosing, IRunnable runnable) + { + this._enclosing = _enclosing; + this.runnable = runnable; + } + + public object Run() + { + this._enclosing._syncRunnable = runnable; + this._enclosing._lock.Awake(); + return null; + } + + private readonly ThreadedSyncBin _enclosing; + + private readonly IRunnable runnable; + } + + internal void RunSyncRunnable() + { + IRunnable runnable = _syncRunnable; + if (runnable != null) + { + base.Sync(); + runnable.Run(); + base.Sync(); + _syncRunnable = null; + } + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IO/VanillaIoAdapter.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IO/VanillaIoAdapter.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IO/VanillaIoAdapter.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IO/VanillaIoAdapter.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,72 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.IO; + +namespace Db4objects.Db4o.IO +{ + /// base class for IoAdapters that delegate to other IoAdapters (decorator pattern) + /// + [System.ObsoleteAttribute(@"use / instead.")] + public abstract class VanillaIoAdapter : IoAdapter + { + protected IoAdapter _delegate; + + public VanillaIoAdapter(IoAdapter delegateAdapter) + { + _delegate = delegateAdapter; + } + + /// + protected VanillaIoAdapter(IoAdapter delegateAdapter, string path, bool lockFile, + long initialLength, bool readOnly) : this(delegateAdapter.Open(path, lockFile, initialLength + , readOnly)) + { + } + + /// + public override void Close() + { + _delegate.Close(); + } + + public override void Delete(string path) + { + _delegate.Delete(path); + } + + public override bool Exists(string path) + { + return _delegate.Exists(path); + } + + /// + public override long GetLength() + { + return _delegate.GetLength(); + } + + /// + public override int Read(byte[] bytes, int length) + { + return _delegate.Read(bytes, length); + } + + /// + public override void Seek(long pos) + { + _delegate.Seek(pos); + } + + /// + public override void Sync() + { + _delegate.Sync(); + } + + /// + public override void Write(byte[] buffer, int length) + { + _delegate.Write(buffer, length); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IObjectServer.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IObjectServer.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IObjectServer.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IObjectServer.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,84 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o; +using Db4objects.Db4o.Ext; + +namespace Db4objects.Db4o +{ + /// the db4o server interface. + /// + /// the db4o server interface. + ///

- db4o servers can be opened with + /// Db4oFactory.OpenServer(string, int) + /// + /// .
+ /// - Direct in-memory connections to servers can be made with + /// OpenClient() + ///
+ /// - TCP connections are available through + /// Db4oFactory.OpenClient(string, int, string, string) + /// + /// . + ///

Before connecting clients over TCP, you have to + /// GrantAccess(string, string) + /// to the username and password combination + /// that you want to use. + ///
+ /// Db4o.openServer + /// ExtObjectServer for extended functionality + /// + public interface IObjectServer : System.IDisposable + { + /// + /// closes the + /// + /// and writes all cached data. + ///

+ ///
+ /// + /// true - denotes that the last instance connected to the + /// used database file was closed. + /// + bool Close(); + + /// + /// returns an + /// + /// with extended functionality. + ///

Use this method as a convenient accessor to extended methods. + /// Every + /// + /// can be casted to an + /// Db4objects.Db4o.Ext.IExtObjectServer + /// + /// . + ///

The functionality is split to two interfaces to allow newcomers to + /// focus on the essential methods. + ///
+ IExtObjectServer Ext(); + + /// grants client access to the specified user with the specified password. + /// + /// grants client access to the specified user with the specified password. + ///

If the user already exists, the password is changed to + /// the specified password.

+ ///
+ /// the name of the user + /// the password to be used + void GrantAccess(string userName, string password); + + /// opens a client against this server. + /// + /// opens a client against this server. + ///

A client opened with this method operates within the same VM + /// as the server. Since an embedded client can use direct communication, without + /// an in-between socket connection, performance will be better than a client + /// opened with + /// Db4oFactory.OpenClient(string, int, string, string) + /// + ///

Every client has it's own transaction and uses it's own cache + /// for it's own version of all peristent objects. + ///
+ IObjectContainer OpenClient(); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IObjectSet.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IObjectSet.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IObjectSet.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/IObjectSet.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,72 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System.Collections; +using Db4objects.Db4o.Ext; + +namespace Db4objects.Db4o +{ + /// + /// An ObjectSet is a representation for a set of objects returned + /// by a query. + /// + /// + /// An ObjectSet is a representation for a set of objects returned + /// by a query. + ///

ObjectSet extends the system collection interfaces + /// java.util.List/System.Collections.IList where they are available. It is + /// recommended, never to reference ObjectSet directly in code but to use + /// List / IList instead. + ///

Note that the underlying + /// IObjectContainer + /// of an ObjectSet + /// needs to remain open as long as an ObjectSet is used. This is necessary + /// for lazy instantiation. The objects in an ObjectSet are only instantiated + /// when they are actually being used by the application. + ///
+ /// for extended functionality. + public interface IObjectSet : IList, IEnumerable + { + /// returns an ObjectSet with extended functionality. + /// + /// returns an ObjectSet with extended functionality. + ///

Every ObjectSet that db4o provides can be casted to + /// an ExtObjectSet. This method is supplied for your convenience + /// to work without a cast. + ///

The ObjectSet functionality is split to two interfaces + /// to allow newcomers to focus on the essential methods. + ///
+ IExtObjectSet Ext(); + + /// returns true if the ObjectSet has more elements. + /// + /// returns true if the ObjectSet has more elements. + /// + /// + /// boolean - true if the ObjectSet has more + /// elements. + /// + bool HasNext(); + + /// returns the next object in the ObjectSet. + /// + /// returns the next object in the ObjectSet. + ///

+ /// Before returning the Object, next() triggers automatic activation of the + /// Object with the respective + /// global + /// or + /// class specific + /// + /// setting.

+ ///
+ /// the next object in the ObjectSet. + object Next(); + + /// resets the ObjectSet cursor before the first element. + /// + /// resets the ObjectSet cursor before the first element. + ///

A subsequent call to next() will return the first element. + ///
+ void Reset(); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/ITransactionAware.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/ITransactionAware.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/ITransactionAware.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/ITransactionAware.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,12 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal; + +namespace Db4objects.Db4o +{ + /// + public interface ITransactionAware + { + void SetTrans(Transaction a_trans); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/ITransactionListener.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/ITransactionListener.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/ITransactionListener.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/ITransactionListener.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,16 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +namespace Db4objects.Db4o +{ + /// + /// allows registration with a transaction to be notified of + /// commit and rollback + /// + /// + public interface ITransactionListener + { + void PreCommit(); + + void PostRollback(); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Marshall/IBufferContext.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Marshall/IBufferContext.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Marshall/IBufferContext.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Marshall/IBufferContext.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,12 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Marshall; + +namespace Db4objects.Db4o.Marshall +{ + /// + public interface IBufferContext : IReadBuffer, IContext + { + IReadBuffer Buffer(); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Marshall/IContext.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Marshall/IContext.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Marshall/IContext.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Marshall/IContext.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,23 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o; + +namespace Db4objects.Db4o.Marshall +{ + /// + /// common functionality for + /// IReadContext + /// and + /// IWriteContext + /// and + /// Db4objects.Db4o.Internal.Delete.IDeleteContext + /// + /// + /// + public interface IContext + { + IObjectContainer ObjectContainer(); + + Db4objects.Db4o.Internal.Transaction Transaction(); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Marshall/IReadBuffer.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Marshall/IReadBuffer.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Marshall/IReadBuffer.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Marshall/IReadBuffer.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,52 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Foundation; + +namespace Db4objects.Db4o.Marshall +{ + /// + /// a buffer interface with methods to read and to position + /// the read pointer in the buffer. + /// + /// + /// a buffer interface with methods to read and to position + /// the read pointer in the buffer. + /// + public interface IReadBuffer + { + /// returns the current offset in the buffer + /// the offset + int Offset(); + + BitMap4 ReadBitMap(int bitCount); + + /// reads a byte from the buffer. + /// reads a byte from the buffer. + /// the byte + byte ReadByte(); + + /// reads an array of bytes from the buffer. + /// + /// reads an array of bytes from the buffer. + /// The length of the array that is passed as a parameter specifies the + /// number of bytes that are to be read. The passed bytes buffer parameter + /// is directly filled. + /// + /// the byte array to read the bytes into. + void ReadBytes(byte[] bytes); + + /// reads an int from the buffer. + /// reads an int from the buffer. + /// the int + int ReadInt(); + + /// reads a long from the buffer. + /// reads a long from the buffer. + /// the long + long ReadLong(); + + /// positions the read pointer at the specified position + /// the desired position in the buffer + void Seek(int offset); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Marshall/IReadContext.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Marshall/IReadContext.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Marshall/IReadContext.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Marshall/IReadContext.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,35 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Marshall; +using Db4objects.Db4o.Typehandlers; + +namespace Db4objects.Db4o.Marshall +{ + /// + /// this interface is passed to internal class + /// Db4objects.Db4o.Typehandlers.ITypeHandler4 + /// + /// when instantiating objects. + /// + public interface IReadContext : IContext, IReadBuffer + { + /// + /// Interprets the current position in the context as + /// an ID and returns the object with this ID. + /// + /// + /// Interprets the current position in the context as + /// an ID and returns the object with this ID. + /// + /// the object + object ReadObject(); + + /// + /// reads sub-objects, in cases where the + /// Db4objects.Db4o.Typehandlers.ITypeHandler4 + /// + /// is known. + /// + object ReadObject(ITypeHandler4 handler); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Marshall/IReferenceActivationContext.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Marshall/IReferenceActivationContext.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Marshall/IReferenceActivationContext.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Marshall/IReferenceActivationContext.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,13 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Marshall; + +namespace Db4objects.Db4o.Marshall +{ + /// this interface is passed to reference type handlers. + /// this interface is passed to reference type handlers. + public interface IReferenceActivationContext : IReadContext + { + object PersistentObject(); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Marshall/IReservedBuffer.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Marshall/IReservedBuffer.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Marshall/IReservedBuffer.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Marshall/IReservedBuffer.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,21 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +namespace Db4objects.Db4o.Marshall +{ + /// a reserved buffer within a write buffer. + /// + /// a reserved buffer within a write buffer. + /// The usecase this class was written for: A null bitmap should be at the + /// beginning of a slot to allow lazy processing. During writing the content + /// of the null bitmap is not yet fully known until all members are processed. + /// With the Reservedbuffer the space in the slot can be occupied and writing + /// can happen after all members are processed. + /// + public interface IReservedBuffer + { + /// writes a byte array to the reserved buffer. + /// writes a byte array to the reserved buffer. + /// the byte array. + void WriteBytes(byte[] bytes); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Marshall/IWriteBuffer.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Marshall/IWriteBuffer.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Marshall/IWriteBuffer.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Marshall/IWriteBuffer.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,27 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +namespace Db4objects.Db4o.Marshall +{ + /// a buffer interface with write methods. + /// a buffer interface with write methods. + public interface IWriteBuffer + { + /// writes a single byte to the buffer. + /// writes a single byte to the buffer. + /// the byte + void WriteByte(byte b); + + /// writes an array of bytes to the buffer + /// the byte array + void WriteBytes(byte[] bytes); + + /// writes an int to the buffer. + /// writes an int to the buffer. + /// the int + void WriteInt(int i); + + /// writes a long to the buffer + /// the long + void WriteLong(long l); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Marshall/IWriteContext.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Marshall/IWriteContext.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Marshall/IWriteContext.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Marshall/IWriteContext.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,56 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Marshall; +using Db4objects.Db4o.Typehandlers; + +namespace Db4objects.Db4o.Marshall +{ + /// + /// this interface is passed to internal class + /// Db4objects.Db4o.Typehandlers.ITypeHandler4 + /// + /// during marshaling + /// and provides methods to marshal objects. + /// + public interface IWriteContext : IContext, IWriteBuffer + { + /// + /// makes sure the object is stored and writes the ID of + /// the object to the context. + /// + /// + /// makes sure the object is stored and writes the ID of + /// the object to the context. + /// Use this method for first class objects only (objects that + /// have an identity in the database). If the object can potentially + /// be a primitive type, do not use this method but use + /// a matching + /// IWriteBuffer + /// method instead. + /// + /// the object to write. + void WriteObject(object obj); + + /// + /// writes sub-objects, in cases where the + /// Db4objects.Db4o.Typehandlers.ITypeHandler4 + /// + /// is known. + /// + /// typehandler to be used to write the object. + /// the object to write + void WriteObject(ITypeHandler4 handler, object obj); + + /// + /// reserves a buffer with a specific length at the current + /// position, to be written in a later step. + /// + /// + /// reserves a buffer with a specific length at the current + /// position, to be written in a later step. + /// + /// the length to be reserved. + /// the ReservedBuffer + IReservedBuffer Reserve(int length); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Messaging/IMessageContext.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Messaging/IMessageContext.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Messaging/IMessageContext.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Messaging/IMessageContext.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,36 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o; +using Db4objects.Db4o.Messaging; + +namespace Db4objects.Db4o.Messaging +{ + /// Additional message-related information. + /// Additional message-related information. + public interface IMessageContext + { + /// The container the message was dispatched to. + /// The container the message was dispatched to. + IObjectContainer Container + { + get; + } + + /// The sender of the current message. + /// + /// The sender of the current message. + /// The reference can be used to send a reply to it. + /// + IMessageSender Sender + { + get; + } + + /// The transaction the current message has been sent with. + /// The transaction the current message has been sent with. + Db4objects.Db4o.Internal.Transaction Transaction + { + get; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Messaging/IMessageRecipient.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Messaging/IMessageRecipient.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Messaging/IMessageRecipient.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Messaging/IMessageRecipient.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,36 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Messaging; + +namespace Db4objects.Db4o.Messaging +{ + /// message recipient for client/server messaging. + /// + /// message recipient for client/server messaging. + ///

db4o allows using the client/server TCP connection to send + /// messages from the client to the server. Any object that can be + /// stored to a db4o database file may be used as a message.

+ /// For an example see Reference documentation:
+ /// http://developer.db4o.com/Resources/view.aspx/Reference/Client-Server/Messaging
+ /// http://developer.db4o.com/Resources/view.aspx/Reference/Client-Server/Remote_Code_Execution

+ /// See Also:
+ /// ClientServerConfiguration.setMessageRecipient(MessageRecipient) + /// ,
+ /// IMessageSender + /// ,
+ /// Db4objects.Db4o.Config.IClientServerConfiguration.GetMessageSender() + /// + /// ,
+ /// MessageRecipientWithContext + ///
+ ///
+ public interface IMessageRecipient + { + /// the method called upon the arrival of messages. + /// the method called upon the arrival of messages. + /// contextual information for the message. + /// the message received. + void ProcessMessage(IMessageContext context, object message); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Messaging/IMessageSender.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Messaging/IMessageSender.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Messaging/IMessageSender.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Messaging/IMessageSender.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,31 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +namespace Db4objects.Db4o.Messaging +{ + /// message sender for client/server messaging. + /// + /// message sender for client/server messaging. + ///

db4o allows using the client/server TCP connection to send + /// messages from the client to the server. Any object that can be + /// stored to a db4o database file may be used as a message.

+ /// For an example see Reference documentation:
+ /// http://developer.db4o.com/Resources/view.aspx/Reference/Client-Server/Messaging
+ /// http://developer.db4o.com/Resources/view.aspx/Reference/Client-Server/Remote_Code_Execution

+ /// See Also:
+ /// Db4objects.Db4o.Config.IClientServerConfiguration.GetMessageSender() + /// + /// ,
+ /// IMessageRecipient + /// ,
+ /// Db4objects.Db4o.Config.IClientServerConfiguration.SetMessageRecipient(IMessageRecipient) + /// + ///
+ public interface IMessageSender + { + /// sends a message to the server. + /// sends a message to the server. + /// the message parameter, any object may be used. + void Send(object obj); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Qlin/IQLinable.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Qlin/IQLinable.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Qlin/IQLinable.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Qlin/IQLinable.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,23 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using Db4objects.Db4o.Qlin; + +namespace Db4objects.Db4o.Qlin +{ + /// support for the new experimental QLin ("Coolin") query interface. + /// + /// support for the new experimental QLin ("Coolin") query interface. + /// We would really like to have LINQ for Java instead. + /// + /// 8.0 + public interface IQLinable + { + /// + /// starts a + /// IQLin + /// query against a class. + /// + IQLin From(Type clazz); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Qlin/IQLin.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Qlin/IQLin.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Qlin/IQLin.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Qlin/IQLin.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,62 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o; +using Db4objects.Db4o.Qlin; + +namespace Db4objects.Db4o.Qlin +{ + /// a node in a QLin ("Coolin") query. + /// + /// a node in a QLin ("Coolin") query. + /// QLin is a new experimental query interface. + /// We would really like to have LINQ for Java instead. + /// + /// 8.0 + public interface IQLin + { + /// adds a where node to this QLin query. + /// adds a where node to this QLin query. + /// can be any of the following: + IQLin Where(object expression); + + /// + /// executes the QLin query and returns the result + /// as an + /// Db4objects.Db4o.IObjectSet + /// . + /// Note that ObjectSet extends List and Iterable + /// on the platforms that support these interfaces. + /// You may want to use these interfaces instead of + /// working directly against an ObjectSet. + /// + IObjectSet Select(); + + // FIXME: The return value should not be as closely bound to db4o. + // Collection is mutable, it's not nice. + // Discuss !!! + IQLin Equal(object obj); + + IQLin StartsWith(string @string); + + IQLin Limit(int size); + + IQLin Smaller(object obj); + + IQLin Greater(object obj); + + /// orders the query by the expression. + /// + /// orders the query by the expression. + /// Use the + /// QLinSupport.Ascending() + /// and + /// QLinSupport.Descending() + /// helper methods to set the direction. + /// + IQLin OrderBy(object expression, QLinOrderByDirection direction); + + object SingleOrDefault(object defaultValue); + + object Single(); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Qlin/Prototypes.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Qlin/Prototypes.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Qlin/Prototypes.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Qlin/Prototypes.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,518 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using System.Collections; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Qlin; +using Db4objects.Db4o.Reflect; +using Db4objects.Db4o.Reflect.Core; +using Db4objects.Db4o.Reflect.Generic; + +namespace Db4objects.Db4o.Qlin +{ + /// creates prototype objects for classes. + /// + /// creates prototype objects for classes. Each field on prototype objects is set + /// to a newly created object or primitive that can be identified either by it's + /// identity or by an int ID that is generated by the system. Creation of fields + /// is recursed to the depth specified in the constructor.
+ ///
+ /// Allows analyzing expressions called on prototype objects to find the + /// underlying field that delivers the return value of the expression. Passed + /// expressions should not have side effects on objects, otherwise the + /// "prototype world" will no longer work.
+ ///
+ /// We plan to supply an ImmutableFieldClassLoader to instrument the code to + /// throw on every modification. This ClassLoader could also supply information + /// about all the method calls involved.
+ ///
+ /// For now our approach only works if expressions are directly backed by a + /// single field.
+ ///
+ /// We were inspired for this approach when we saw that Thomas Mueller managed to + /// map expressions to fields for his JaQu query interface, Kudos! + /// http://www.h2database.com/html/jaqu.html
+ ///
+ /// We took the idea a bit further and made it work for all primitives except for + /// boolean and we plan to also get deeper expressions, collections and + /// interfaces working nicely. + ///
+ public class Prototypes + { + private readonly IReflector _reflector; + + private readonly Hashtable4 _prototypes = new Hashtable4(); + + private readonly bool _ignoreTransient; + + private readonly int _recursionDepth; + + public Prototypes(IReflector reflector, int recursionDepth, bool ignoreTransient) + { + _reflector = reflector; + _recursionDepth = recursionDepth; + _ignoreTransient = ignoreTransient; + } + + public Prototypes() : this(DefaultReflector(), 5, false) + { + } + + /// returns a prototype object for a specific class. + /// returns a prototype object for a specific class. + public virtual object PrototypeForClass(Type clazz) + { + if (clazz == null) + { + throw new PrototypesException("Class can not be null"); + } + IReflectClass claxx = _reflector.ForClass(clazz); + if (claxx == null) + { + throw new PrototypesException("Not found in the reflector: " + clazz); + } + string className = claxx.GetName(); + Prototypes.Prototype prototype = (Prototypes.Prototype)_prototypes.Get(className); + if (prototype != null) + { + return prototype.Object(); + } + prototype = new Prototypes.Prototype(this, claxx); + _prototypes.Put(className, prototype); + return prototype.Object(); + } + + /// + /// analyzes the passed expression and tries to find the path to the + /// backing field that is accessed. + /// + /// + /// analyzes the passed expression and tries to find the path to the + /// backing field that is accessed. + /// + public virtual IEnumerator BackingFieldPath(Type clazz, object expression) + { + return BackingFieldPath(_reflector.ForClass(clazz), expression); + } + + /// + /// analyzes the passed expression and tries to find the path to the + /// backing field that is accessed. + /// + /// + /// analyzes the passed expression and tries to find the path to the + /// backing field that is accessed. + /// + public virtual IEnumerator BackingFieldPath(IReflectClass claxx, object expression + ) + { + return BackingFieldPath(claxx.GetName(), expression); + } + + /// + /// analyzes the passed expression and tries to find the path to the + /// backing field that is accessed. + /// + /// + /// analyzes the passed expression and tries to find the path to the + /// backing field that is accessed. + /// + public virtual IEnumerator BackingFieldPath(string className, object expression) + { + Prototypes.Prototype prototype = (Prototypes.Prototype)_prototypes.Get(className); + if (prototype == null) + { + return null; + } + return prototype.BackingFieldPath(_reflector, expression); + } + + private class Prototype + { + private readonly IdentityHashtable4 _fieldsByIdentity = new IdentityHashtable4(); + + private readonly Hashtable4 _fieldsByIntId = new Hashtable4(); + + private readonly object _object; + + private int intIdGenerator; + + public Prototype(Prototypes _enclosing, IReflectClass claxx) + { + this._enclosing = _enclosing; + this._object = (object)claxx.NewInstance(); + if (this._object == null) + { + throw new PrototypesException("Prototype could not be created for class " + claxx + .GetName()); + } + this.Analyze(this._object, claxx, this._enclosing._recursionDepth, null); + } + + private void Analyze(object @object, IReflectClass claxx, int depth, List4 parentPath + ) + { + if (depth < 0) + { + return; + } + ReflectorUtils.ForEachField(claxx, new _IProcedure4_130(this, parentPath, claxx, + @object, depth)); + } + + private sealed class _IProcedure4_130 : IProcedure4 + { + public _IProcedure4_130(Prototype _enclosing, List4 parentPath, IReflectClass claxx + , object @object, int depth) + { + this._enclosing = _enclosing; + this.parentPath = parentPath; + this.claxx = claxx; + this.@object = @object; + this.depth = depth; + } + + public void Apply(object field) + { + if (((IReflectField)field).IsStatic()) + { + return; + } + if (this._enclosing._enclosing._ignoreTransient && ((IReflectField)field).IsTransient + ()) + { + return; + } + IReflectClass fieldType = ((IReflectField)field).GetFieldType(); + List4 path = new List4(parentPath, ((IReflectField)field)); + Prototypes.IntegerConverter converter = Prototypes.IntegerConverterforClassName(claxx + .Reflector(), fieldType.GetName()); + if (converter != null) + { + int id = ++this._enclosing.intIdGenerator; + object integerRepresentation = converter.FromInteger(id); + if (!Prototypes.TrySetField(((IReflectField)field), @object, integerRepresentation + )) + { + return; + } + this._enclosing._fieldsByIntId.Put(id, new Pair(integerRepresentation, path)); + return; + } + if (!fieldType.IsPrimitive()) + { + object identityInstance = fieldType.NewInstance(); + if (identityInstance == null) + { + return; + } + if (!Prototypes.TrySetField(((IReflectField)field), @object, identityInstance)) + { + return; + } + this._enclosing._fieldsByIdentity.Put(identityInstance, path); + this._enclosing.Analyze(identityInstance, claxx, depth - 1, path); + } + } + + private readonly Prototype _enclosing; + + private readonly List4 parentPath; + + private readonly IReflectClass claxx; + + private readonly object @object; + + private readonly int depth; + } + + public virtual object Object() + { + return this._object; + } + + public virtual IEnumerator BackingFieldPath(IReflector reflector, object expression + ) + { + if (expression == null) + { + return null; + } + IReflectClass claxx = reflector.ForObject(expression); + if (claxx == null) + { + return null; + } + Prototypes.IntegerConverter converter = Prototypes.IntegerConverterforClassName(reflector + , claxx.GetName()); + if (converter != null) + { + Pair entry = (Pair)this._fieldsByIntId.Get(converter.ToInteger(expression)); + if (entry == null) + { + return null; + } + if (entry.first.Equals(expression)) + { + return this.AsIterator((List4)entry.second); + } + return null; + } + if (claxx.IsPrimitive()) + { + return null; + } + return this.AsIterator((List4)this._fieldsByIdentity.Get(expression)); + } + + private IEnumerator AsIterator(List4 lastElement) + { + return Iterators.Revert(Iterators.Map(Iterators.Iterate(lastElement), new _IFunction4_198 + ())); + } + + private sealed class _IFunction4_198 : IFunction4 + { + public _IFunction4_198() + { + } + + public object Apply(object field) + { + return ((IReflectField)field).GetName(); + } + } + + private readonly Prototypes _enclosing; + } + + private static Prototypes.IntegerConverter IntegerConverterforClassName(IReflector + reflector, string className) + { + if (_integerConverters == null) + { + _integerConverters = new Hashtable4(); + Prototypes.IntegerConverter[] converters = new Prototypes.IntegerConverter[] { new + _IntegerConverter_211(), new _IntegerConverter_215(), new _IntegerConverter_219( + ), new _IntegerConverter_223(), new _IntegerConverter_227(), new _IntegerConverter_231 + (), new _IntegerConverter_235(), new _IntegerConverter_239() }; + for (int converterIndex = 0; converterIndex < converters.Length; ++converterIndex) + { + Prototypes.IntegerConverter converter = converters[converterIndex]; + _integerConverters.Put(converter.PrimitiveName(), converter); + if (!converter.PrimitiveName().Equals(converter.WrapperName(reflector))) + { + _integerConverters.Put(converter.WrapperName(reflector), converter); + } + } + } + return (Prototypes.IntegerConverter)_integerConverters.Get(className); + } + + private sealed class _IntegerConverter_211 : Prototypes.IntegerConverter + { + public _IntegerConverter_211() + { + } + + public override string PrimitiveName() + { + return typeof(int).FullName; + } + + public override object FromInteger(int i) + { + return i; + } + } + + private sealed class _IntegerConverter_215 : Prototypes.IntegerConverter + { + public _IntegerConverter_215() + { + } + + public override string PrimitiveName() + { + return typeof(long).FullName; + } + + public override object FromInteger(int i) + { + return System.Convert.ToInt64(i); + } + } + + private sealed class _IntegerConverter_219 : Prototypes.IntegerConverter + { + public _IntegerConverter_219() + { + } + + public override string PrimitiveName() + { + return typeof(double).FullName; + } + + public override object FromInteger(int i) + { + return System.Convert.ToDouble(i); + } + } + + private sealed class _IntegerConverter_223 : Prototypes.IntegerConverter + { + public _IntegerConverter_223() + { + } + + public override string PrimitiveName() + { + return typeof(float).FullName; + } + + public override object FromInteger(int i) + { + return System.Convert.ToSingle(i); + } + } + + private sealed class _IntegerConverter_227 : Prototypes.IntegerConverter + { + public _IntegerConverter_227() + { + } + + public override string PrimitiveName() + { + return typeof(byte).FullName; + } + + public override object FromInteger(int i) + { + return (byte)i; + } + } + + private sealed class _IntegerConverter_231 : Prototypes.IntegerConverter + { + public _IntegerConverter_231() + { + } + + public override string PrimitiveName() + { + return typeof(char).FullName; + } + + public override object FromInteger(int i) + { + return (char)i; + } + } + + private sealed class _IntegerConverter_235 : Prototypes.IntegerConverter + { + public _IntegerConverter_235() + { + } + + public override string PrimitiveName() + { + return typeof(short).FullName; + } + + public override object FromInteger(int i) + { + return (short)i; + } + } + + private sealed class _IntegerConverter_239 : Prototypes.IntegerConverter + { + public _IntegerConverter_239() + { + } + + public override string PrimitiveName() + { + return typeof(string).FullName; + } + + public override object FromInteger(int i) + { + return Prototypes.StringIdentifier + i; + } + + public override int ToInteger(object obj) + { + if (!(obj is string)) + { + return -1; + } + string str = (string)obj; + if (str.Length < Prototypes.StringIdentifier.Length) + { + return -1; + } + if (str.IndexOf(Prototypes.StringIdentifier) != 0) + { + return -1; + } + return int.Parse(Sharpen.Runtime.Substring(str, Prototypes.StringIdentifier.Length + )); + } + } + + private static Hashtable4 _integerConverters; + + private abstract class IntegerConverter + { + public virtual string WrapperName(IReflector reflector) + { + return reflector.ForObject(FromInteger(1)).GetName(); + } + + public abstract string PrimitiveName(); + + public abstract object FromInteger(int i); + + public virtual int ToInteger(object obj) + { + return int.Parse(((object)obj).ToString()); + } + } + + private static readonly string StringIdentifier = "QLinIdentity"; + + // Strings get prepended the following, so we can also use strings + // without restrictions in queries. + public virtual IReflector Reflector() + { + return _reflector; + } + + // We could always use this, but we want to make users of this class + // aware that they have control over the reflector and that it is + // important. + public static IReflector DefaultReflector() + { + return new GenericReflector(Platform4.ReflectorForType(typeof(Prototypes))); + } + + private static bool TrySetField(IReflectField field, object onObject, object value + ) + { + try + { + field.Set(onObject, value); + } + catch + { + return false; + } + return true; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Qlin/PrototypesException.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Qlin/PrototypesException.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Qlin/PrototypesException.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Qlin/PrototypesException.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,16 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; + +namespace Db4objects.Db4o.Qlin +{ + /// exception for the the Prototypes world. + /// exception for the the Prototypes world. + [System.Serializable] + public class PrototypesException : Exception + { + public PrototypesException(string message) : base(message) + { + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Qlin/QLinException.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Qlin/QLinException.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Qlin/QLinException.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Qlin/QLinException.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,24 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using Db4objects.Db4o.Ext; + +namespace Db4objects.Db4o.Qlin +{ + /// + /// exceptions to signal improper use of the + /// IQLin + /// query interface. + /// + [System.Serializable] + public class QLinException : Db4oException + { + public QLinException(string message) : base(message) + { + } + + public QLinException(Exception cause) : base(cause) + { + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Qlin/QLinOrderByDirection.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Qlin/QLinOrderByDirection.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Qlin/QLinOrderByDirection.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Qlin/QLinOrderByDirection.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,53 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +namespace Db4objects.Db4o.Qlin +{ + /// + /// Internal implementation class, access should not be necessary, + /// except for implementors. + /// + /// + /// Internal implementation class, access should not be necessary, + /// except for implementors. + /// Use the static methods in + /// QLinSupport + /// + /// QLinSupport.Ascending() + /// and + /// QLinSupport.Descending() + /// + /// + public class QLinOrderByDirection + { + private readonly string _direction; + + private readonly bool _ascending; + + private QLinOrderByDirection(string direction, bool ascending) + { + _direction = direction; + _ascending = ascending; + } + + internal static readonly Db4objects.Db4o.Qlin.QLinOrderByDirection Ascending = new + Db4objects.Db4o.Qlin.QLinOrderByDirection("ascending", true); + + internal static readonly Db4objects.Db4o.Qlin.QLinOrderByDirection Descending = new + Db4objects.Db4o.Qlin.QLinOrderByDirection("descending", false); + + public virtual bool IsAscending() + { + return _ascending; + } + + public virtual bool IsDescending() + { + return !_ascending; + } + + public override string ToString() + { + return _direction; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Qlin/QLinSupport.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Qlin/QLinSupport.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Qlin/QLinSupport.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Qlin/QLinSupport.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,170 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using System.Collections; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Qlin; +using Db4objects.Db4o.Reflect; +using Db4objects.Db4o.Reflect.Core; + +namespace Db4objects.Db4o.Qlin +{ + /// + /// static import support class for + /// IQLin + /// queries. + /// + /// 8.0 + public class QLinSupport + { + /// + /// returns a prototype object for a specific class + /// to be passed to the where expression of a QLin + /// query. + /// + /// + /// returns a prototype object for a specific class + /// to be passed to the where expression of a QLin + /// query. + /// + /// IQLin.Where(object) + public static object Prototype(Type clazz) + { + try + { + return _prototypes.PrototypeForClass(clazz); + } + catch (PrototypesException ex) + { + throw new QLinException(ex); + } + } + + /// sets the context for the next query on this thread. + /// + /// sets the context for the next query on this thread. + /// This method should never have to be called manually. + /// The framework should set the context up. + /// + public static void Context(IReflectClass claxx) + { + _context.Value = claxx; + } + + /// sets the context for the next query on this thread. + /// + /// sets the context for the next query on this thread. + /// This method should never have to be called manually. + /// The framework should set the context up. + /// + public static void Context(Type clazz) + { + _context.Value = ReflectorUtils.ReflectClassFor(_prototypes.Reflector(), clazz); + } + + /// + /// shortcut for the + /// Prototype(System.Type<T>) + /// method. + /// + public static object P(Type clazz) + { + return Prototype(clazz); + } + + /// + /// parameter for + /// IQLin.OrderBy(object, QLinOrderByDirection) + /// + /// + public static QLinOrderByDirection Ascending() + { + return QLinOrderByDirection.Ascending; + } + + /// + /// parameter for + /// IQLin.OrderBy(object, QLinOrderByDirection) + /// + /// + public static QLinOrderByDirection Descending() + { + return QLinOrderByDirection.Descending; + } + + /// public for implementors, do not use directly + public static IEnumerator BackingFieldPath(object expression) + { + CheckForNull(expression); + if (expression is IReflectField) + { + return Iterators.Iterate(new string[] { ((IReflectField)expression).GetName() }); + } + IEnumerator path = _prototypes.BackingFieldPath(((IReflectClass)_context.Value), + expression); + if (path != null) + { + return path; + } + return Iterators.Iterate(new string[] { FieldByFieldName(expression).GetName() }); + } + + /// converts an expression to a single field. + /// converts an expression to a single field. + public static IReflectField Field(object expression) + { + CheckForNull(expression); + if (expression is IReflectField) + { + return (IReflectField)expression; + } + IEnumerator path = _prototypes.BackingFieldPath(((IReflectClass)_context.Value), + expression); + if (path != null) + { + if (path.MoveNext()) + { + expression = path.Current; + } + if (path.MoveNext()) + { + path.Reset(); + throw new QLinException("expression can not be converted to a single field. It evaluates to: " + + Iterators.Join(path, "[", "]", ", ")); + } + } + return FieldByFieldName(expression); + } + + private static IReflectField FieldByFieldName(object expression) + { + if (expression is string) + { + IReflectField field = ReflectorUtils.Field(((IReflectClass)_context.Value), (string + )expression); + if (field != null) + { + return field; + } + } + throw new QLinException("expression can not be mapped to a field"); + } + + private static void CheckForNull(object expression) + { + if (expression == null) + { + throw new QLinException("expression can not be null"); + } + } + + private const bool IgnoreTransientFields = true; + + private const int RecursionDepth = 4; + + private static readonly Prototypes _prototypes = new Prototypes(Prototypes.DefaultReflector + (), RecursionDepth, IgnoreTransientFields); + + private static readonly DynamicVariable _context = DynamicVariable.NewInstance(); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Query/ICandidate.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Query/ICandidate.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Query/ICandidate.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Query/ICandidate.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,62 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o; + +namespace Db4objects.Db4o.Query +{ + /// + /// candidate for + /// IEvaluation + /// callbacks. + ///

+ /// During + /// query execution + /// all registered + /// IEvaluation + /// callback + /// handlers are called with + /// ICandidate + /// proxies that represent the persistent objects that + /// meet all other + /// IQuery + /// criteria. + ///

+ /// A + /// ICandidate + /// provides access to the persistent object it + /// represents and allows to specify, whether it is to be included in the + /// Db4objects.Db4o.IObjectSet + /// resultset. + ///
+ public interface ICandidate + { + /// + /// returns the persistent object that is represented by this query + /// ICandidate + /// . + /// + /// Object the persistent object. + object GetObject(); + + /// + /// specify whether the Candidate is to be included in the + /// Db4objects.Db4o.IObjectSet + /// resultset. + ///

+ /// This method may be called multiple times. The last call prevails. + ///
+ /// inclusion. + void Include(bool flag); + + /// + /// returns the + /// Db4objects.Db4o.IObjectContainer + /// the Candidate object is stored in. + /// + /// + /// the + /// Db4objects.Db4o.IObjectContainer + /// + IObjectContainer ObjectContainer(); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Query/IConstraint.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Query/IConstraint.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Query/IConstraint.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Query/IConstraint.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,271 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Query; + +namespace Db4objects.Db4o.Query +{ + /// + /// constraint to limit the objects returned upon + /// query execution + /// . + ///

+ /// Constraints are constructed by calling + /// Db4objects.Db4o.Query.IQuery.Constrain + /// + /// . + ///

+ /// Constraints can be joined with the methods + /// Db4objects.Db4o.Query.IConstraint.And + /// + /// and + /// Db4objects.Db4o.Query.IConstraint.Or + /// + /// . + ///

+ /// The methods to modify the constraint evaluation algorithm may + /// be merged, to construct combined evaluation rules. + /// Examples: + ///
    + ///
  • Constraint.Smaller().Equal() for "smaller or equal"
  • + ///
  • Constraint.Not().Like() for "not like"
  • + ///
  • Constraint.Not().Greater().Equal() for "not greater or equal"
  • + ///
+ ///
+ public interface IConstraint + { + /// links two Constraints for AND evaluation. + /// + /// links two Constraints for AND evaluation. + /// For example:
+ /// query.Constrain(typeof(Pilot));
+ /// query.Descend("points").Constrain(101).Smaller().And(query.Descend("name").Constrain("Test Pilot0"));
+ /// will retrieve all pilots with points less than 101 and name as "Test Pilot0"
+ ///
+ /// + /// the other + /// Db4objects.Db4o.Query.IConstraint + /// + /// + /// a new + /// Db4objects.Db4o.Query.IConstraint + /// , that can be used for further calls + /// to + /// And + /// and + /// Or + /// + IConstraint And(IConstraint with); + + /// links two Constraints for OR evaluation. + /// + /// links two Constraints for OR evaluation. + /// For example:

+ /// query.Constrain(typeof(Pilot));
+ /// query.Descend("points").Constrain(101).Greater().Or(query.Descend("name").Constrain("Test Pilot0"));
+ /// will retrieve all pilots with points more than 101 or pilots with the name "Test Pilot0"
+ ///
+ /// + /// the other + /// Db4objects.Db4o.Query.IConstraint + /// + /// + /// a new + /// Db4objects.Db4o.Query.IConstraint + /// , that can be used for further calls + /// to + /// And + /// and + /// Or + /// + IConstraint Or(IConstraint with); + + /// + /// Used in conjunction with + /// Db4objects.Db4o.Query.IConstraint.Smaller + /// + /// or + /// Db4objects.Db4o.Query.IConstraint.Greater + /// + /// to create constraints + /// like "smaller or equal", "greater or equal". + /// For example:
+ /// query.Constrain(typeof(Pilot));
+ /// query.Descend("points").Constrain(101).Smaller().Equal();
+ /// will return all pilots with points <= 101.
+ ///
+ /// + /// this + /// Db4objects.Db4o.Query.IConstraint + /// to allow the chaining of method calls. + /// + IConstraint Equal(); + + /// sets the evaluation mode to >. + /// + /// sets the evaluation mode to >. + /// For example:
+ /// query.Constrain(typeof(Pilot));
+ /// query.Descend("points").Constrain(101).Greater()
+ /// will return all pilots with points > 101.
+ ///
+ /// + /// this + /// Db4objects.Db4o.Query.IConstraint + /// to allow the chaining of method calls. + /// + IConstraint Greater(); + + /// sets the evaluation mode to <. + /// + /// sets the evaluation mode to <. + /// For example:
+ /// query.Constrain(typeof(Pilot));
+ /// query.Descend("points").Constrain(101).Smaller()
+ /// will return all pilots with points < 101.
+ ///
+ /// + /// this + /// Db4objects.Db4o.Query.IConstraint + /// to allow the chaining of method calls. + /// + IConstraint Smaller(); + + /// sets the evaluation mode to identity comparison. + /// + /// sets the evaluation mode to identity comparison. In this case only + /// objects having the same database identity will be included in the result set. + /// For example:
+ /// Pilot pilot = new Pilot("Test Pilot1", 100);
+ /// Car car = new Car("BMW", pilot);
+ /// container.Store(car);
+ /// // Change the name, the pilot instance stays the same
+ /// pilot.SetName("Test Pilot2");
+ /// // create a new car
+ /// car = new Car("Ferrari", pilot);
+ /// container.Store(car);
+ /// IQuery query = container.Query();
+ /// query.Constrain(typeof(Car));
+ /// // All cars having pilot with the same database identity
+ /// // will be retrieved. As we only created Pilot object once
+ /// // it should mean all car objects
+ /// query.Descend("_pilot").Constrain(pilot).Identity();

+ ///
+ /// + /// this + /// Db4objects.Db4o.Query.IConstraint + /// to allow the chaining of method calls. + /// + IConstraint Identity(); + + /// set the evaluation mode to object comparison (query by example). + /// set the evaluation mode to object comparison (query by example). + /// + /// this + /// IConstraint + /// to allow the chaining of method calls. + /// + IConstraint ByExample(); + + /// sets the evaluation mode to "like" comparison. + /// + /// sets the evaluation mode to "like" comparison. This mode will include + /// all objects having the constrain expression somewhere inside the string field. + /// For example:
+ /// Pilot pilot = new Pilot("Test Pilot1", 100);
+ /// container.Store(pilot);
+ /// ...
+ /// query.Constrain(typeof(Pilot));
+ /// // All pilots with the name containing "est" will be retrieved
+ /// query.Descend("name").Constrain("est").Like();
+ ///
+ /// + /// this + /// Db4objects.Db4o.Query.IConstraint + /// to allow the chaining of method calls. + /// + IConstraint Like(); + + /// Sets the evaluation mode to string contains comparison. + /// + /// Sets the evaluation mode to string contains comparison. The contains comparison is case sensitive.
+ /// For example:
+ /// Pilot pilot = new Pilot("Test Pilot1", 100);
+ /// container.Store(pilot);
+ /// ...
+ /// query.Constrain(typeof(Pilot));
+ /// // All pilots with the name containing "est" will be retrieved
+ /// query.Descend("name").Constrain("est").Contains();
+ /// Like() for case insensitive string comparison + ///
+ /// + /// this + /// Db4objects.Db4o.Query.IConstraint + /// to allow the chaining of method calls. + /// + IConstraint Contains(); + + /// sets the evaluation mode to string StartsWith comparison. + /// + /// sets the evaluation mode to string StartsWith comparison. + /// For example:
+ /// Pilot pilot = new Pilot("Test Pilot0", 100);
+ /// container.Store(pilot);
+ /// ...
+ /// query.Constrain(typeof(Pilot));
+ /// query.Descend("name").Constrain("Test").StartsWith(true);
+ ///
+ /// comparison will be case sensitive if true, case insensitive otherwise + /// + /// + /// this + /// Db4objects.Db4o.Query.IConstraint + /// to allow the chaining of method calls. + /// + IConstraint StartsWith(bool caseSensitive); + + /// sets the evaluation mode to string EndsWith comparison. + /// + /// sets the evaluation mode to string EndsWith comparison. + /// For example:
+ /// Pilot pilot = new Pilot("Test Pilot0", 100);
+ /// container.Store(pilot);
+ /// ...
+ /// query.Constrain(typeof(Pilot));
+ /// query.Descend("name").Constrain("T0").EndsWith(false);
+ ///
+ /// comparison will be case sensitive if true, case insensitive otherwise + /// + /// + /// this + /// Db4objects.Db4o.Query.IConstraint + /// to allow the chaining of method calls. + /// + IConstraint EndsWith(bool caseSensitive); + + /// turns on Not() comparison. + /// + /// turns on Not() comparison. All objects not fullfilling the constrain condition will be returned. + /// For example:
+ /// Pilot pilot = new Pilot("Test Pilot1", 100);
+ /// container.Store(pilot);
+ /// ...
+ /// query.Constrain(typeof(Pilot));
+ /// query.Descend("name").Constrain("t0").EndsWith(true).Not();
+ ///
+ /// + /// this + /// Db4objects.Db4o.Query.IConstraint + /// to allow the chaining of method calls. + /// + IConstraint Not(); + + /// + /// returns the Object the query graph was constrained with to + /// create this + /// IConstraint + /// . + /// + /// Object the constraining object. + object GetObject(); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Query/IConstraints.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Query/IConstraints.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Query/IConstraints.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Query/IConstraints.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,36 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Query; + +namespace Db4objects.Db4o.Query +{ + /// + /// set of + /// IConstraint + /// objects. + ///

This extension of the + /// IConstraint + /// interface allows + /// setting the evaluation mode of all contained + /// IConstraint + /// objects with single calls. + ///

+ /// See also + /// IQuery.Constraints() + /// . + ///
+ public interface IConstraints : IConstraint + { + /// + /// returns an array of the contained + /// IConstraint + /// objects. + /// + /// + /// an array of the contained + /// IConstraint + /// objects. + /// + IConstraint[] ToArray(); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Query/IEvaluation.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Query/IEvaluation.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Query/IEvaluation.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Query/IEvaluation.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,48 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Query; + +namespace Db4objects.Db4o.Query +{ + /// for implementation of callback evaluations. + /// + /// for implementation of callback evaluations. + ///

+ /// To constrain a + /// IQuery + /// node with your own callback + /// Evaluation, construct an object that implements the + /// Evaluation interface and register it by passing it + /// to + /// IQuery.Constrain(object) + /// . + ///

+ /// Evaluations are called as the last step during query execution, + /// after all other constraints have been applied. Evaluations in higher + /// level + /// IQuery + /// nodes in the query graph are called first. + ///

Java client/server only:
+ /// db4o first attempts to use Java Serialization to allow to pass final + /// variables to the server. Please make sure that all variables that are + /// used within the + /// Evaluate(ICandidate) + /// method are Serializable. This may include + /// the class an anonymous Evaluation object is created in. If db4o is + /// not successful at using Serialization, the Evaluation is transported + /// to the server in a db4o + /// Db4objects.Db4o.IO.MemoryBin + /// . In this case final variables can + /// not be restored. + ///
+ public interface IEvaluation + { + /// + /// callback method during + /// query execution + /// . + /// + /// reference to the candidate persistent object. + void Evaluate(ICandidate candidate); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Query/IQueryComparator.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Query/IQueryComparator.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Query/IQueryComparator.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Query/IQueryComparator.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,19 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +namespace Db4objects.Db4o.Query +{ + /// + /// This interface is not used in .NET. + /// + public interface IQueryComparator + { + /// Implement to compare two arguments for sorting. + /// + /// Implement to compare two arguments for sorting. + /// Return a negative value, zero, or a positive value if + /// the first argument is smaller, equal or greater than + /// the second. + /// + int Compare(object first, object second); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Query/IQuery.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Query/IQuery.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Query/IQuery.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Query/IQuery.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,177 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o; +using Db4objects.Db4o.Query; + +namespace Db4objects.Db4o.Query +{ + /// handle to a node in a S.O.D.A. + /// + /// handle to a node in a S.O.D.A. query graph. + ///

+ /// A node in the query graph can represent multiple + /// classes, one class or an attribute of a class.

The graph + /// is automatically extended with attributes of added constraints + /// (see + /// Constrain(object) + /// ) and upon calls to + /// Descend(string) + /// that request nodes that do not yet exist. + ///

+ /// References to joined nodes in the query graph can be obtained + /// by "walking" along the nodes of the graph with the method + /// Descend(string) + /// . + ///

+ /// Execute() + /// evaluates the entire graph against all persistent objects. + ///

+ /// Execute() + /// can be called from any + /// IQuery + /// node + /// of the graph. It will return an + /// Db4objects.Db4o.IObjectSet + /// filled with + /// objects of the class/classes that the node, it was called from, + /// represents.

+ /// Note:
+ /// Native queries + /// are the recommended main query + /// interface of db4o.
+ ///
+ public interface IQuery + { + /// adds a constraint to this node. + /// + /// adds a constraint to this node. + ///

+ /// If the constraint contains attributes that are not yet + /// present in the query graph, the query graph is extended + /// accordingly. + ///

+ /// Special behaviour for: + ///
    + ///
  • class + /// System.Type<T> + /// : confine the result to objects of one + /// class or to objects implementing an interface.
  • + ///
  • interface + /// IEvaluation + /// : run + /// evaluation callbacks against all candidates.
  • + ///
+ ///
+ /// the constraint to be added to this Query. + /// + /// + /// IConstraint + /// a new + /// IConstraint + /// for this + /// query node or null for objects implementing the + /// IEvaluation + /// interface. + /// + IConstraint Constrain(object constraint); + + /// + /// returns a + /// IConstraints + /// object that holds an array of all constraints on this node. + /// + /// + /// + /// IConstraints + /// on this query node. + /// + IConstraints Constraints(); + + /// returns a reference to a descendant node in the query graph. + /// + /// returns a reference to a descendant node in the query graph. + ///

If the node does not exist, it will be created. + ///

+ /// All classes represented in the query node are tested, whether + /// they contain a field with the specified field name. The + /// descendant Query node will be created from all possible candidate + /// classes. + ///
+ /// path to the descendant. + /// + /// descendant + /// IQuery + /// node + /// + IQuery Descend(string fieldName); + + /// + /// executes the + /// IQuery + /// . + /// + /// + /// + /// Db4objects.Db4o.IObjectSet + /// - the result of the + /// IQuery + /// . + /// + IObjectSet Execute(); + + /// + /// adds an ascending ordering criteria to this node of + /// the query graph. + /// + /// + /// adds an ascending ordering criteria to this node of + /// the query graph. + ///

+ /// If multiple ordering criteria are applied, the chronological + /// order of method calls is relevant: criteria created by 'earlier' calls are + /// considered more significant, i.e. 'later' criteria only have an effect + /// for elements that are considered equal by all 'earlier' criteria. + ///

+ ///

+ /// As an example, consider a type with two int fields, and an instance set + /// {(a:1,b:3),(a:2,b:2),(a:1,b:2),(a:2,b:3)}. The call sequence [orderAscending(a), + /// orderDescending(b)] will result in [(a:1,b:3),(a:1,b:2),(a:2,b:3),(a:2,b:2)]. + ///

+ ///
+ /// + /// this + /// IQuery + /// object to allow the chaining of method calls. + /// + IQuery OrderAscending(); + + /// + /// adds a descending order criteria to this node of + /// the query graph. + /// + /// + /// adds a descending order criteria to this node of + /// the query graph. + ///

+ /// For semantics of multiple calls setting ordering criteria, see + /// OrderAscending() + /// . + ///
+ /// + /// this + /// IQuery + /// object to allow the chaining of method calls. + /// + IQuery OrderDescending(); + + /// Sort the resulting ObjectSet by the given comparator. + /// Sort the resulting ObjectSet by the given comparator. + /// The comparator to apply. + /// + /// this + /// IQuery + /// object to allow the chaining of method calls. + /// + IQuery SortBy(IQueryComparator comparator); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Query/Predicate.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Query/Predicate.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Query/Predicate.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Query/Predicate.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,168 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using System.Reflection; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Query; + +namespace Db4objects.Db4o.Query +{ + /// Base class for native queries. + /// + /// Base class for native queries. + ///

Native Queries provide the ability to run one or more lines + /// of code against all instances of a class. Native query expressions should + /// return true to mark specific instances as part of the result set. + /// db4o will attempt to optimize native query expressions and run them + /// against indexes and without instantiating actual objects, where this is + /// possible.

+ /// The syntax of the enclosing object for the native query expression varies + /// slightly, depending on the language version used. Here are some examples, + /// how a simple native query will look like in some of the programming languages and + /// dialects that db4o supports:

+ /// + /// // C# .NET 2.0
+ /// IList <Cat> cats = db.Query <Cat> (delegate(Cat cat) {
+ ///    return cat.Name == "Occam";
+ /// });
+ ///
+ ///
+ /// // Java JDK 5
+ /// List <Cat> cats = db.query(new Predicate<Cat>() {
+ ///    public boolean match(Cat cat) {
+ ///       return cat.getName().equals("Occam");
+ ///    }
+ /// });
+ ///
+ ///
+ /// // Java JDK 1.2 to 1.4
+ /// List cats = db.query(new Predicate() {
+ ///    public boolean match(Cat cat) {
+ ///       return cat.getName().equals("Occam");
+ ///    }
+ /// });
+ ///
+ ///
+ /// // Java JDK 1.1
+ /// ObjectSet cats = db.query(new CatOccam());
+ ///
+ /// public static class CatOccam extends Predicate {
+ ///    public boolean match(Cat cat) {
+ ///       return cat.getName().equals("Occam");
+ ///    }
+ /// });
+ ///
+ ///
+ /// // C# .NET 1.1
+ /// IList cats = db.Query(new CatOccam());
+ ///
+ /// public class CatOccam : Predicate {
+ ///    public boolean Match(Cat cat) {
+ ///       return cat.Name == "Occam";
+ ///    }
+ /// });
+ ///
+ ///
+ /// Summing up the above:
+ /// In order to run a Native Query, you can
+ /// - use the delegate notation for .NET 2.0.
+ /// - extend the Predicate class for all other language dialects

+ /// A class that extends Predicate is required to + /// implement the #match() / #Match() method, following the native query + /// conventions:
+ /// - The name of the method is "#match()" (Java) / "#Match()" (.NET).
+ /// - The method must be public public.
+ /// - The method returns a boolean.
+ /// - The method takes one parameter.
+ /// - The Type (.NET) / Class (Java) of the parameter specifies the extent.
+ /// - For all instances of the extent that are to be included into the + /// resultset of the query, the match method should return true. For all + /// instances that are not to be included, the match method should return + /// false.

+ ///
+ [System.Serializable] + public abstract class Predicate + { + /// public for implementation reasons, please ignore. + /// public for implementation reasons, please ignore. + public static readonly string PredicatemethodName = "match"; + + private Type _extentType; + + [System.NonSerialized] + private MethodInfo cachedFilterMethod = null; + + public Predicate() : this(null) + { + } + + public Predicate(Type extentType) + { + _extentType = extentType; + } + + public virtual MethodInfo GetFilterMethod() + { + if (cachedFilterMethod != null) + { + return cachedFilterMethod; + } + MethodInfo[] methods = GetType().GetMethods(); + for (int methodIdx = 0; methodIdx < methods.Length; methodIdx++) + { + MethodInfo method = methods[methodIdx]; + if ((!method.Name.Equals(PredicatePlatform.PredicatemethodName)) || Sharpen.Runtime.GetParameterTypes + (method).Length != 1) + { + continue; + } + cachedFilterMethod = method; + string targetName = Sharpen.Runtime.GetParameterTypes(method)[0].FullName; + if (!"java.lang.Object".Equals(targetName)) + { + break; + } + } + if (cachedFilterMethod == null) + { + throw new ArgumentException("Invalid predicate."); + } + return cachedFilterMethod; + } + + /// public for implementation reasons, please ignore. + /// public for implementation reasons, please ignore. + public virtual Type ExtentType() + { + if (_extentType == null) + { + _extentType = FilterParameterType(); + } + return _extentType; + } + + private Type FilterParameterType() + { + return (Type)Sharpen.Runtime.GetParameterTypes(GetFilterMethod())[0]; + } + + /// public for implementation reasons, please ignore. + /// public for implementation reasons, please ignore. + public virtual bool AppliesTo(object candidate) + { + try + { + MethodInfo filterMethod = GetFilterMethod(); + Platform4.SetAccessible(filterMethod); + object ret = filterMethod.Invoke(this, new object[] { candidate }); + return ((bool)ret); + } + catch (Exception) + { + // TODO: log this exception somewhere? + // e.printStackTrace(); + return false; + } + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Reflect/ArrayInfo.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Reflect/ArrayInfo.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Reflect/ArrayInfo.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Reflect/ArrayInfo.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,58 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Reflect; + +namespace Db4objects.Db4o.Reflect +{ + /// + public class ArrayInfo + { + private int _elementCount; + + private bool _primitive; + + private bool _nullable; + + private IReflectClass _reflectClass; + + public virtual int ElementCount() + { + return _elementCount; + } + + public virtual void ElementCount(int count) + { + _elementCount = count; + } + + public virtual bool Primitive() + { + return _primitive; + } + + public virtual void Primitive(bool flag) + { + _primitive = flag; + } + + public virtual bool Nullable() + { + return _nullable; + } + + public virtual void Nullable(bool flag) + { + _nullable = flag; + } + + public virtual IReflectClass ReflectClass() + { + return _reflectClass; + } + + public virtual void ReflectClass(IReflectClass claxx) + { + _reflectClass = claxx; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Reflect/Core/AbstractReflectArray.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Reflect/Core/AbstractReflectArray.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Reflect/Core/AbstractReflectArray.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Reflect/Core/AbstractReflectArray.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,151 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using Db4objects.Db4o.Reflect; +using Sharpen.Lang.Reflect; + +namespace Db4objects.Db4o.Reflect.Core +{ + /// + public abstract class AbstractReflectArray : IReflectArray + { + protected readonly IReflector _reflector; + + public AbstractReflectArray(IReflector reflector) + { + _reflector = reflector; + } + + public abstract object NewInstance(IReflectClass componentType, int[] dimensions); + + public abstract object NewInstance(IReflectClass componentType, int length); + + public virtual int[] Dimensions(object arr) + { + int count = 0; + IReflectClass claxx = _reflector.ForObject(arr); + while (claxx.IsArray()) + { + count++; + claxx = claxx.GetComponentType(); + } + int[] dim = new int[count]; + for (int i = 0; i < count; i++) + { + try + { + dim[i] = GetLength(arr); + arr = Get(arr, 0); + } + catch (Exception) + { + return dim; + } + } + return dim; + } + + public virtual int Flatten(object a_shaped, int[] a_dimensions, int a_currentDimension + , object[] a_flat, int a_flatElement) + { + if (a_currentDimension == (a_dimensions.Length - 1)) + { + for (int i = 0; i < a_dimensions[a_currentDimension]; i++) + { + a_flat[a_flatElement++] = GetNoExceptions(a_shaped, i); + } + } + else + { + for (int i = 0; i < a_dimensions[a_currentDimension]; i++) + { + a_flatElement = Flatten(GetNoExceptions(a_shaped, i), a_dimensions, a_currentDimension + + 1, a_flat, a_flatElement); + } + } + return a_flatElement; + } + + public virtual object Get(object onArray, int index) + { + return Sharpen.Runtime.GetArrayValue(onArray, index); + } + + public virtual IReflectClass GetComponentType(IReflectClass a_class) + { + while (a_class.IsArray()) + { + a_class = a_class.GetComponentType(); + } + return a_class; + } + + public virtual int GetLength(object array) + { + return Sharpen.Runtime.GetArrayLength(array); + } + + private object GetNoExceptions(object onArray, int index) + { + try + { + return Get(onArray, index); + } + catch (Exception) + { + return null; + } + } + + public virtual bool IsNDimensional(IReflectClass a_class) + { + return a_class.GetComponentType().IsArray(); + } + + public virtual void Set(object onArray, int index, object element) + { + if (element == null) + { + try + { + Sharpen.Runtime.SetArrayValue(onArray, index, element); + } + catch (Exception) + { + } + } + else + { + // This can happen on primitive arrays + // and we are fine with ignoring it. + // TODO: check if it's a primitive array first and don't ignore exceptions + Sharpen.Runtime.SetArrayValue(onArray, index, element); + } + } + + public virtual int Shape(object[] a_flat, int a_flatElement, object a_shaped, int + [] a_dimensions, int a_currentDimension) + { + if (a_currentDimension == (a_dimensions.Length - 1)) + { + for (int i = 0; i < a_dimensions[a_currentDimension]; i++) + { + Set(a_shaped, i, a_flat[a_flatElement++]); + } + } + else + { + for (int i = 0; i < a_dimensions[a_currentDimension]; i++) + { + a_flatElement = Shape(a_flat, a_flatElement, Get(a_shaped, i), a_dimensions, a_currentDimension + + 1); + } + } + return a_flatElement; + } + + public abstract void Analyze(object arg1, ArrayInfo arg2); + + public abstract object NewInstance(IReflectClass arg1, ArrayInfo arg2); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Reflect/Core/ConstructorSupport.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Reflect/Core/ConstructorSupport.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Reflect/Core/ConstructorSupport.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Reflect/Core/ConstructorSupport.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,123 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using System.Collections; +using Db4objects.Db4o; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Reflect; +using Db4objects.Db4o.Reflect.Core; + +namespace Db4objects.Db4o.Reflect.Core +{ + public class ConstructorSupport + { + public static ReflectConstructorSpec CreateConstructor(IConstructorAwareReflectClass + claxx, Type clazz, IReflectorConfiguration config, IReflectConstructor[] constructors + ) + { + if (claxx == null) + { + return ReflectConstructorSpec.InvalidConstructor; + } + if (claxx.IsAbstract() || claxx.IsInterface()) + { + return ReflectConstructorSpec.InvalidConstructor; + } + if (!Platform4.CallConstructor()) + { + bool skipConstructor = !config.CallConstructor(claxx); + if (!claxx.IsCollection()) + { + IReflectConstructor serializableConstructor = SkipConstructor(claxx, skipConstructor + , config.TestConstructors()); + if (serializableConstructor != null) + { + return new ReflectConstructorSpec(serializableConstructor, null); + } + } + } + if (!config.TestConstructors()) + { + return new ReflectConstructorSpec(new PlatformReflectConstructor(clazz), null); + } + if (ReflectPlatform.CreateInstance(clazz) != null) + { + return new ReflectConstructorSpec(new PlatformReflectConstructor(clazz), null); + } + Tree sortedConstructors = SortConstructorsByParamsCount(constructors); + return FindConstructor(claxx, sortedConstructors); + } + + private static ReflectConstructorSpec FindConstructor(IReflectClass claxx, Tree sortedConstructors + ) + { + if (sortedConstructors == null) + { + return ReflectConstructorSpec.InvalidConstructor; + } + IEnumerator iter = new TreeNodeIterator(sortedConstructors); + while (iter.MoveNext()) + { + object current = iter.Current; + IReflectConstructor constructor = (IReflectConstructor)((TreeIntObject)current)._object; + object[] args = NullArgumentsFor(constructor); + object res = constructor.NewInstance(args); + if (res != null) + { + return new ReflectConstructorSpec(constructor, args); + } + } + return ReflectConstructorSpec.InvalidConstructor; + } + + private static object[] NullArgumentsFor(IReflectConstructor constructor) + { + IReflectClass[] paramTypes = constructor.GetParameterTypes(); + object[] @params = new object[paramTypes.Length]; + for (int j = 0; j < @params.Length; j++) + { + @params[j] = paramTypes[j].NullValue(); + } + return @params; + } + + private static Tree SortConstructorsByParamsCount(IReflectConstructor[] constructors + ) + { + Tree sortedConstructors = null; + // sort constructors by parameter count + for (int i = 0; i < constructors.Length; i++) + { + int parameterCount = constructors[i].GetParameterTypes().Length; + sortedConstructors = Tree.Add(sortedConstructors, new TreeIntObject(i + constructors + .Length * parameterCount, constructors[i])); + } + return sortedConstructors; + } + + public static IReflectConstructor SkipConstructor(IConstructorAwareReflectClass claxx + , bool skipConstructor, bool testConstructor) + { + if (!skipConstructor) + { + return null; + } + IReflectConstructor serializableConstructor = claxx.GetSerializableConstructor(); + if (serializableConstructor == null) + { + return null; + } + if (!testConstructor || Deploy.csharp) + { + return serializableConstructor; + } + object obj = serializableConstructor.NewInstance((object[])null); + if (obj != null) + { + return serializableConstructor; + } + return null; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Reflect/Core/IConstructorAwareReflectClass.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Reflect/Core/IConstructorAwareReflectClass.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Reflect/Core/IConstructorAwareReflectClass.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Reflect/Core/IConstructorAwareReflectClass.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,12 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Reflect; +using Db4objects.Db4o.Reflect.Core; + +namespace Db4objects.Db4o.Reflect.Core +{ + public interface IConstructorAwareReflectClass : IReflectClass + { + IReflectConstructor GetSerializableConstructor(); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Reflect/Core/IReflectConstructor.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Reflect/Core/IReflectConstructor.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Reflect/Core/IReflectConstructor.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Reflect/Core/IReflectConstructor.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,19 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Reflect; + +namespace Db4objects.Db4o.Reflect.Core +{ + /// Reflection Constructor representation. + /// + /// Reflection Constructor representation + ///

See documentation for System.Reflection API. + ///
+ /// IReflector + public interface IReflectConstructor + { + IReflectClass[] GetParameterTypes(); + + object NewInstance(object[] parameters); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Reflect/Core/PlatformReflectConstructor.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Reflect/Core/PlatformReflectConstructor.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Reflect/Core/PlatformReflectConstructor.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Reflect/Core/PlatformReflectConstructor.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,31 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Reflect; +using Db4objects.Db4o.Reflect.Core; + +namespace Db4objects.Db4o.Reflect.Core +{ + public class PlatformReflectConstructor : IReflectConstructor + { + private static readonly IReflectClass[] ParameterTypes = new IReflectClass[] { }; + + private Type _clazz; + + public PlatformReflectConstructor(Type clazz) + { + _clazz = clazz; + } + + public virtual IReflectClass[] GetParameterTypes() + { + return ParameterTypes; + } + + public virtual object NewInstance(object[] parameters) + { + return ReflectPlatform.CreateInstance(_clazz); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Reflect/Core/ReflectConstructorSpec.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Reflect/Core/ReflectConstructorSpec.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Reflect/Core/ReflectConstructorSpec.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Reflect/Core/ReflectConstructorSpec.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,71 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Reflect.Core; + +namespace Db4objects.Db4o.Reflect.Core +{ + /// + /// a spec holding a constructor, it's arguments + /// and information, if the constructor can instantiate + /// objects. + /// + /// + /// a spec holding a constructor, it's arguments + /// and information, if the constructor can instantiate + /// objects. + /// + public class ReflectConstructorSpec + { + private IReflectConstructor _constructor; + + private object[] _args; + + private TernaryBool _canBeInstantiated; + + public static readonly Db4objects.Db4o.Reflect.Core.ReflectConstructorSpec UnspecifiedConstructor + = new Db4objects.Db4o.Reflect.Core.ReflectConstructorSpec(TernaryBool.Unspecified + ); + + public static readonly Db4objects.Db4o.Reflect.Core.ReflectConstructorSpec InvalidConstructor + = new Db4objects.Db4o.Reflect.Core.ReflectConstructorSpec(TernaryBool.No); + + public ReflectConstructorSpec(IReflectConstructor constructor, object[] args) + { + _constructor = constructor; + _args = args; + _canBeInstantiated = TernaryBool.Yes; + } + + private ReflectConstructorSpec(TernaryBool canBeInstantiated) + { + _canBeInstantiated = canBeInstantiated; + _constructor = null; + } + + /// creates a new instance. + /// creates a new instance. + /// the newly created instance. + public virtual object NewInstance() + { + if (_constructor == null) + { + return null; + } + return _constructor.NewInstance(_args); + } + + /// + /// returns true if an instance can be instantiated + /// with the constructor, otherwise false. + /// + /// + /// returns true if an instance can be instantiated + /// with the constructor, otherwise false. + /// + public virtual TernaryBool CanBeInstantiated() + { + return _canBeInstantiated; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Reflect/Core/ReflectorUtils.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Reflect/Core/ReflectorUtils.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Reflect/Core/ReflectorUtils.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Reflect/Core/ReflectorUtils.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,59 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Reflect; + +namespace Db4objects.Db4o.Reflect.Core +{ + /// + public class ReflectorUtils + { + public static IReflectClass ReflectClassFor(IReflector reflector, object clazz) + { + if (clazz is IReflectClass) + { + return (IReflectClass)clazz; + } + if (clazz is Type) + { + return reflector.ForClass((Type)clazz); + } + if (clazz is string) + { + return reflector.ForName((string)clazz); + } + return reflector.ForObject(clazz); + } + + public static IReflectField Field(IReflectClass claxx, string name) + { + while (claxx != null) + { + try + { + return claxx.GetDeclaredField(name); + } + catch (Exception) + { + } + claxx = claxx.GetSuperclass(); + } + return null; + } + + public static void ForEachField(IReflectClass claxx, IProcedure4 procedure) + { + while (claxx != null) + { + IReflectField[] declaredFields = claxx.GetDeclaredFields(); + for (int reflectFieldIndex = 0; reflectFieldIndex < declaredFields.Length; ++reflectFieldIndex) + { + IReflectField reflectField = declaredFields[reflectFieldIndex]; + procedure.Apply(reflectField); + } + claxx = claxx.GetSuperclass(); + } + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Reflect/Generic/CollectionUpdateDepthEntry.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Reflect/Generic/CollectionUpdateDepthEntry.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Reflect/Generic/CollectionUpdateDepthEntry.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Reflect/Generic/CollectionUpdateDepthEntry.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,19 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Reflect; + +namespace Db4objects.Db4o.Reflect.Generic +{ + internal class CollectionUpdateDepthEntry + { + internal readonly IReflectClassPredicate _predicate; + + internal readonly int _depth; + + internal CollectionUpdateDepthEntry(IReflectClassPredicate predicate, int depth) + { + _predicate = predicate; + _depth = depth; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Reflect/Generic/GenericArrayClass.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Reflect/Generic/GenericArrayClass.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Reflect/Generic/GenericArrayClass.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Reflect/Generic/GenericArrayClass.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,45 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Reflect; +using Db4objects.Db4o.Reflect.Generic; + +namespace Db4objects.Db4o.Reflect.Generic +{ + /// + public class GenericArrayClass : GenericClass + { + public GenericArrayClass(GenericReflector reflector, IReflectClass delegateClass, + string name, GenericClass superclass) : base(reflector, delegateClass, name, superclass + ) + { + } + + public override IReflectClass GetComponentType() + { + return GetDelegate(); + } + + public override bool IsArray() + { + return true; + } + + public override bool IsInstance(object candidate) + { + if (!(candidate is GenericArray)) + { + return false; + } + return IsAssignableFrom(((GenericArray)candidate)._clazz); + } + + public override string ToString(object obj) + { + if (_converter == null) + { + return "(GA) " + GetName(); + } + return _converter.ToString((GenericArray)obj); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Reflect/Generic/GenericArray.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Reflect/Generic/GenericArray.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Reflect/Generic/GenericArray.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Reflect/Generic/GenericArray.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,41 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System.Collections; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Reflect.Generic; + +namespace Db4objects.Db4o.Reflect.Generic +{ + /// + public class GenericArray + { + internal GenericClass _clazz; + + internal object[] _data; + + public GenericArray(GenericClass clazz, int size) + { + _clazz = clazz; + _data = new object[size]; + } + + public virtual IEnumerator Iterator() + { + return Iterators.Iterate(_data); + } + + internal virtual int GetLength() + { + return _data.Length; + } + + public override string ToString() + { + if (_clazz == null) + { + return base.ToString(); + } + return _clazz.ToString(this); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Reflect/Generic/GenericArrayReflector.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Reflect/Generic/GenericArrayReflector.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Reflect/Generic/GenericArrayReflector.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Reflect/Generic/GenericArrayReflector.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,115 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Reflect; +using Db4objects.Db4o.Reflect.Generic; + +namespace Db4objects.Db4o.Reflect.Generic +{ + /// + public class GenericArrayReflector : IReflectArray + { + private readonly IReflectArray _delegate; + + public GenericArrayReflector(GenericReflector reflector) + { + _delegate = reflector.GetDelegate().Array(); + } + + public virtual void Analyze(object obj, ArrayInfo info) + { + _delegate.Analyze(obj, info); + } + + public virtual int[] Dimensions(object arr) + { + return _delegate.Dimensions(arr); + } + + public virtual int Flatten(object a_shaped, int[] a_dimensions, int a_currentDimension + , object[] a_flat, int a_flatElement) + { + return _delegate.Flatten(a_shaped, a_dimensions, a_currentDimension, a_flat, a_flatElement + ); + } + + public virtual object Get(object onArray, int index) + { + if (onArray is GenericArray) + { + return ((GenericArray)onArray)._data[index]; + } + return _delegate.Get(onArray, index); + } + + public virtual IReflectClass GetComponentType(IReflectClass claxx) + { + claxx = claxx.GetDelegate(); + if (claxx is GenericClass) + { + return claxx; + } + return _delegate.GetComponentType(claxx); + } + + public virtual int GetLength(object array) + { + if (array is GenericArray) + { + return ((GenericArray)array).GetLength(); + } + return _delegate.GetLength(array); + } + + public virtual bool IsNDimensional(IReflectClass a_class) + { + if (a_class is GenericArrayClass) + { + return false; + } + return _delegate.IsNDimensional(a_class.GetDelegate()); + } + + public virtual object NewInstance(IReflectClass componentType, ArrayInfo info) + { + componentType = componentType.GetDelegate(); + if (componentType is GenericClass) + { + int length = info.ElementCount(); + return new GenericArray(((GenericClass)componentType).ArrayClass(), length); + } + return _delegate.NewInstance(componentType, info); + } + + public virtual object NewInstance(IReflectClass componentType, int length) + { + componentType = componentType.GetDelegate(); + if (componentType is GenericClass) + { + return new GenericArray(((GenericClass)componentType).ArrayClass(), length); + } + return _delegate.NewInstance(componentType, length); + } + + public virtual object NewInstance(IReflectClass componentType, int[] dimensions) + { + return _delegate.NewInstance(componentType.GetDelegate(), dimensions); + } + + public virtual void Set(object onArray, int index, object element) + { + if (onArray is GenericArray) + { + ((GenericArray)onArray)._data[index] = element; + return; + } + _delegate.Set(onArray, index, element); + } + + public virtual int Shape(object[] a_flat, int a_flatElement, object a_shaped, int + [] a_dimensions, int a_currentDimension) + { + return _delegate.Shape(a_flat, a_flatElement, a_shaped, a_dimensions, a_currentDimension + ); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Reflect/Generic/GenericClassBuilder.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Reflect/Generic/GenericClassBuilder.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Reflect/Generic/GenericClassBuilder.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Reflect/Generic/GenericClassBuilder.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,53 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Reflect; +using Db4objects.Db4o.Reflect.Generic; + +namespace Db4objects.Db4o.Reflect.Generic +{ + /// + public class GenericClassBuilder : IReflectClassBuilder + { + private GenericReflector _reflector; + + private IReflector _delegate; + + public GenericClassBuilder(GenericReflector reflector, IReflector delegate_) : base + () + { + _reflector = reflector; + _delegate = delegate_; + } + + public virtual IReflectClass CreateClass(string name, IReflectClass superClass, int + fieldCount) + { + IReflectClass nativeClass = _delegate.ForName(name); + GenericClass clazz = new GenericClass(_reflector, nativeClass, name, (GenericClass + )superClass); + clazz.SetDeclaredFieldCount(fieldCount); + return clazz; + } + + public virtual IReflectField CreateField(IReflectClass parentType, string fieldName + , IReflectClass fieldType, bool isVirtual, bool isPrimitive, bool isArray, bool + isNArray) + { + if (isVirtual) + { + return new GenericVirtualField(fieldName); + } + return new GenericField(fieldName, fieldType, isPrimitive); + } + + public virtual void InitFields(IReflectClass clazz, IReflectField[] fields) + { + ((GenericClass)clazz).InitFields((GenericField[])fields); + } + + public virtual IReflectField[] FieldArray(int length) + { + return new GenericField[length]; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Reflect/Generic/GenericClass.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Reflect/Generic/GenericClass.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Reflect/Generic/GenericClass.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Reflect/Generic/GenericClass.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,378 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Reflect; +using Db4objects.Db4o.Reflect.Generic; + +namespace Db4objects.Db4o.Reflect.Generic +{ + /// + public class GenericClass : IReflectClass, IDeepClone + { + private static readonly GenericField[] NoFields = new GenericField[0]; + + private readonly GenericReflector _reflector; + + private readonly IReflectClass _delegate; + + private readonly string _name; + + private Db4objects.Db4o.Reflect.Generic.GenericClass _superclass; + + private Db4objects.Db4o.Reflect.Generic.GenericClass _array; + + private bool _isPrimitive; + + private int _isCollection; + + protected IGenericConverter _converter; + + private GenericField[] _fields = NoFields; + + private int _declaredFieldCount = -1; + + private int _fieldCount = -1; + + private readonly int _hashCode; + + public GenericClass(GenericReflector reflector, IReflectClass delegateClass, string + name, Db4objects.Db4o.Reflect.Generic.GenericClass superclass) + { + _reflector = reflector; + _delegate = delegateClass; + _name = name; + _superclass = superclass; + _hashCode = _name.GetHashCode(); + } + + public virtual Db4objects.Db4o.Reflect.Generic.GenericClass ArrayClass() + { + if (_array != null) + { + return _array; + } + _array = new GenericArrayClass(_reflector, this, _name, _superclass); + return _array; + } + + public virtual object DeepClone(object obj) + { + GenericReflector reflector = (GenericReflector)obj; + Db4objects.Db4o.Reflect.Generic.GenericClass superClass = null; + if (_superclass != null) + { + _superclass = (Db4objects.Db4o.Reflect.Generic.GenericClass)reflector.ForName(_superclass + .GetName()); + } + Db4objects.Db4o.Reflect.Generic.GenericClass ret = new Db4objects.Db4o.Reflect.Generic.GenericClass + (reflector, _delegate, _name, superClass); + GenericField[] fields = new GenericField[_fields.Length]; + for (int i = 0; i < fields.Length; i++) + { + fields[i] = (GenericField)_fields[i].DeepClone(reflector); + } + ret.InitFields(fields); + return ret; + } + + public override bool Equals(object obj) + { + if (this == obj) + { + return true; + } + if (obj == null || GetType() != obj.GetType()) + { + return false; + } + Db4objects.Db4o.Reflect.Generic.GenericClass otherGC = (Db4objects.Db4o.Reflect.Generic.GenericClass + )obj; + if (_hashCode != otherGC.GetHashCode()) + { + return false; + } + return _name.Equals(otherGC._name); + } + + public virtual IReflectClass GetComponentType() + { + if (_delegate != null) + { + return _delegate.GetComponentType(); + } + return null; + } + + // TODO: consider that classes may have two fields of + // the same name after refactoring. + public virtual IReflectField GetDeclaredField(string name) + { + if (_delegate != null) + { + return _delegate.GetDeclaredField(name); + } + for (int i = 0; i < _fields.Length; i++) + { + if (_fields[i].GetName().Equals(name)) + { + return _fields[i]; + } + } + return null; + } + + public virtual IReflectField[] GetDeclaredFields() + { + if (_delegate != null) + { + return _delegate.GetDeclaredFields(); + } + return _fields; + } + + public virtual IReflectClass GetDelegate() + { + if (_delegate != null) + { + return _delegate; + } + return this; + } + + internal virtual int GetFieldCount() + { + if (_fieldCount != -1) + { + return _fieldCount; + } + _fieldCount = 0; + if (_superclass != null) + { + _fieldCount = _superclass.GetFieldCount(); + } + if (_declaredFieldCount == -1) + { + _declaredFieldCount = GetDeclaredFields().Length; + } + _fieldCount += _declaredFieldCount; + return _fieldCount; + } + + public virtual IReflectMethod GetMethod(string methodName, IReflectClass[] paramClasses + ) + { + if (_delegate != null) + { + return _delegate.GetMethod(methodName, paramClasses); + } + return null; + } + + public virtual string GetName() + { + return _name; + } + + public virtual IReflectClass GetSuperclass() + { + if (_superclass != null) + { + return _superclass; + } + if (_delegate == null) + { + return _reflector.ForClass(typeof(object)); + } + IReflectClass delegateSuperclass = _delegate.GetSuperclass(); + if (delegateSuperclass != null) + { + _superclass = _reflector.EnsureDelegate(delegateSuperclass); + } + return _superclass; + } + + public override int GetHashCode() + { + return _hashCode; + } + + public virtual void InitFields(GenericField[] fields) + { + int startIndex = 0; + if (_superclass != null) + { + startIndex = _superclass.GetFieldCount(); + } + _fields = fields; + for (int i = 0; i < _fields.Length; i++) + { + _fields[i].SetIndex(startIndex + i); + } + } + + // TODO: Consider: Will this method still be necessary + // once constructor logic is pushed into the reflectors? + public virtual bool IsAbstract() + { + if (_delegate != null) + { + return _delegate.IsAbstract(); + } + return false; + } + + public virtual bool IsArray() + { + if (_delegate != null) + { + return _delegate.IsArray(); + } + return false; + } + + public virtual bool IsAssignableFrom(IReflectClass subclassCandidate) + { + if (subclassCandidate == null) + { + return false; + } + if (Equals(subclassCandidate)) + { + return true; + } + if (_delegate != null) + { + if (subclassCandidate is Db4objects.Db4o.Reflect.Generic.GenericClass) + { + subclassCandidate = ((Db4objects.Db4o.Reflect.Generic.GenericClass)subclassCandidate + ).GetDelegate(); + } + return _delegate.IsAssignableFrom(subclassCandidate); + } + if (!(subclassCandidate is Db4objects.Db4o.Reflect.Generic.GenericClass)) + { + return false; + } + return IsAssignableFrom(subclassCandidate.GetSuperclass()); + } + + public virtual bool IsCollection() + { + if (_isCollection == 1) + { + return true; + } + if (_isCollection == -1) + { + return false; + } + _isCollection = _reflector.IsCollection(this) ? 1 : -1; + return IsCollection(); + } + + public virtual bool IsInstance(object candidate) + { + if (_delegate != null) + { + return _delegate.IsInstance(candidate); + } + if (!(candidate is GenericObject)) + { + return false; + } + return IsAssignableFrom(((GenericObject)candidate)._class); + } + + public virtual bool IsInterface() + { + if (_delegate != null) + { + return _delegate.IsInterface(); + } + return false; + } + + public virtual bool IsPrimitive() + { + if (_delegate != null) + { + return _delegate.IsPrimitive(); + } + return _isPrimitive; + } + + public virtual object NewInstance() + { + if (_delegate != null) + { + return _delegate.NewInstance(); + } + return new GenericObject(this); + } + + public virtual IReflector Reflector() + { + if (_delegate != null) + { + return _delegate.Reflector(); + } + return _reflector; + } + + internal virtual void SetConverter(IGenericConverter converter) + { + _converter = converter; + } + + internal virtual void SetDeclaredFieldCount(int count) + { + _declaredFieldCount = count; + } + + internal virtual void SetPrimitive() + { + _isPrimitive = true; + } + + public override string ToString() + { + return "GenericClass " + _name; + } + + public virtual string ToString(object obj) + { + if (_converter == null) + { + return "(G) " + GetName(); + } + return _converter.ToString((GenericObject)obj); + } + + public virtual bool EnsureCanBeInstantiated() + { + if (_delegate != null) + { + return _delegate.EnsureCanBeInstantiated(); + } + return true; + } + + public virtual object NullValue() + { + if (_delegate == null) + { + return null; + } + return _delegate.NullValue(); + } + + public virtual bool IsImmutable() + { + if (_delegate != null) + { + return _delegate.IsImmutable(); + } + return IsPrimitive(); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Reflect/Generic/GenericField.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Reflect/Generic/GenericField.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Reflect/Generic/GenericField.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Reflect/Generic/GenericField.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,99 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Reflect; +using Db4objects.Db4o.Reflect.Generic; + +namespace Db4objects.Db4o.Reflect.Generic +{ + /// + public class GenericField : IReflectField, IDeepClone + { + private readonly string _name; + + private readonly GenericClass _type; + + private readonly bool _primitive; + + private int _index = -1; + + public GenericField(string name, IReflectClass clazz, bool primitive) + { + _name = name; + _type = (GenericClass)clazz; + _primitive = primitive; + } + + public virtual object DeepClone(object obj) + { + IReflector reflector = (IReflector)obj; + IReflectClass newReflectClass = null; + if (_type != null) + { + newReflectClass = reflector.ForName(_type.GetName()); + } + return new Db4objects.Db4o.Reflect.Generic.GenericField(_name, newReflectClass, _primitive + ); + } + + public virtual object Get(object onObject) + { + //TODO Consider: Do we need to check that onObject is an instance of the DataClass this field is a member of? + return ((GenericObject)onObject).Get(_index); + } + + public virtual string GetName() + { + return _name; + } + + public virtual IReflectClass GetFieldType() + { + return _type; + } + + public virtual bool IsPublic() + { + return true; + } + + public virtual bool IsPrimitive() + { + return _primitive; + } + + public virtual bool IsStatic() + { + //FIXME Consider static fields. + return false; + } + + public virtual bool IsTransient() + { + return false; + } + + public virtual void Set(object onObject, object value) + { + // FIXME: Consider enabling type checking. + // The following will fail with arrays. + // if (!_type.isInstance(value)) throw new RuntimeException(); //TODO Consider: is this checking really necessary? + ((GenericObject)onObject).Set(_index, value); + } + + internal virtual void SetIndex(int index) + { + _index = index; + } + + public virtual object IndexEntry(object orig) + { + return orig; + } + + public virtual IReflectClass IndexType() + { + return GetFieldType(); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Reflect/Generic/GenericObject.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Reflect/Generic/GenericObject.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Reflect/Generic/GenericObject.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Reflect/Generic/GenericObject.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,62 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using Db4objects.Db4o.Reflect.Generic; + +namespace Db4objects.Db4o.Reflect.Generic +{ + /// + public class GenericObject : IComparable + { + internal readonly GenericClass _class; + + private object[] _values; + + public GenericObject(GenericClass clazz) + { + _class = clazz; + } + + private void EnsureValuesInitialized() + { + if (_values == null) + { + _values = new object[_class.GetFieldCount()]; + } + } + + public virtual void Set(int index, object value) + { + EnsureValuesInitialized(); + _values[index] = value; + } + + /// + /// the value of the field at index, based on the fields obtained GenericClass.getDeclaredFields + /// + public virtual object Get(int index) + { + EnsureValuesInitialized(); + return _values[index]; + } + + public override string ToString() + { + if (_class == null) + { + return base.ToString(); + } + return _class.ToString(this); + } + + public virtual GenericClass GetGenericClass() + { + return _class; + } + + public virtual int CompareTo(object o) + { + return 0; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Reflect/Generic/GenericReflector.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Reflect/Generic/GenericReflector.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Reflect/Generic/GenericReflector.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Reflect/Generic/GenericReflector.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,501 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using System.Collections; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Reflect.Generic; +using Db4objects.Db4o.Reflect; +using Db4objects.Db4o.Reflect.Generic; + +namespace Db4objects.Db4o.Reflect.Generic +{ + /// + /// db4o provides GenericReflector as a wrapper around specific + /// reflector (delegate). + /// + /// + /// db4o provides GenericReflector as a wrapper around specific + /// reflector (delegate). GenericReflector is set when an + /// ObjectContainer is opened. All subsequent reflector + /// calls are routed through this interface.

+ /// An instance of GenericReflector can be obtained through + /// Db4objects.Db4o.Ext.IExtObjectContainer.Reflector() + /// + /// .

+ /// GenericReflector keeps list of known classes in memory. + /// When the GenericReflector is called, it first checks its list of + /// known classes. If the class cannot be found, the task is + /// transferred to the delegate reflector. If the delegate fails as + /// well, generic objects are created, which hold simulated + /// "field values" in an array of objects.

+ /// Generic reflector makes possible the following usecases:
    + ///
  • running a db4o server without deploying application classes;
  • + ///
  • running db4o on Java dialects without reflection (J2ME CLDC, MIDP);
  • + ///
  • easier access to stored objects where classes or fields are not available;
  • + ///
  • running refactorings in the reflector;
  • + ///
  • building interfaces to db4o from any programming language.
+ ///

+ /// One of the live usecases is ObjectManager, which uses GenericReflector + /// to read C# objects from Java. + ///
+ public class GenericReflector : IReflector, IDeepClone + { + private KnownClassesRepository _repository; + + private IReflector _delegate; + + private GenericArrayReflector _array; + + private Collection4 _collectionPredicates = new Collection4(); + + private readonly Hashtable4 _classByClass = new Hashtable4(); + + private Transaction _trans; + + private ObjectContainerBase _stream; + + /// Creates an instance of GenericReflector + /// transaction + /// + /// delegate reflector, + /// providing specific reflector functionality. For example + /// + public GenericReflector(Transaction trans, IReflector delegateReflector) + { + // todo: Why have this when there is already the _repository by name? Redundant + _repository = new KnownClassesRepository(new GenericClassBuilder(this, delegateReflector + )); + SetTransaction(trans); + _delegate = delegateReflector; + if (_delegate != null) + { + _delegate.SetParent(this); + } + } + + public GenericReflector(IReflector delegateReflector) : this(null, delegateReflector + ) + { + } + + /// Creates a clone of provided object + /// object to copy + /// copy of the submitted object + public virtual object DeepClone(object obj) + { + Db4objects.Db4o.Reflect.Generic.GenericReflector myClone = new Db4objects.Db4o.Reflect.Generic.GenericReflector + (null, (IReflector)_delegate.DeepClone(this)); + myClone._collectionPredicates = (Collection4)_collectionPredicates.DeepClone(myClone + ); + // Interesting, adding the following messes things up. + // Keep the code, since it may make sense to carry the + // global reflectors into a running db4o session. + // Iterator4 i = _classes.iterator(); + // while(i.hasNext()){ + // GenericClass clazz = (GenericClass)i.next(); + // clazz = (GenericClass)clazz.deepClone(myClone); + // myClone._classByName.put(clazz.getName(), clazz); + // myClone._classes.add(clazz); + // } + return myClone; + } + + internal virtual ObjectContainerBase GetStream() + { + return _stream; + } + + /// If there is a transaction assosiated with the current refector. + /// If there is a transaction assosiated with the current refector. + /// true if there is a transaction assosiated with the current refector. + public virtual bool HasTransaction() + { + return _trans != null; + } + + /// Associated a transaction with the current reflector. + /// Associated a transaction with the current reflector. + /// + public virtual void SetTransaction(Transaction trans) + { + if (trans != null) + { + _trans = trans; + _stream = trans.Container(); + } + _repository.SetTransaction(trans); + } + + /// generic reflect array instance. + public virtual IReflectArray Array() + { + if (_array == null) + { + _array = new GenericArrayReflector(this); + } + return _array; + } + + internal virtual Db4objects.Db4o.Reflect.Generic.GenericClass EnsureDelegate(IReflectClass + clazz) + { + if (clazz == null) + { + return null; + } + Db4objects.Db4o.Reflect.Generic.GenericClass claxx = (Db4objects.Db4o.Reflect.Generic.GenericClass + )_repository.LookupByName(clazz.GetName()); + if (claxx == null) + { + // We don't have to worry about the superclass, it can be null + // because handling is delegated anyway + claxx = GenericClass(clazz); + _repository.Register(claxx); + } + return claxx; + } + + private Db4objects.Db4o.Reflect.Generic.GenericClass GenericClass(IReflectClass clazz + ) + { + Db4objects.Db4o.Reflect.Generic.GenericClass ret; + string name = clazz.GetName(); + if (name.Equals(ReflectPlatform.FullyQualifiedName(typeof(GenericArray)))) + { + // special case, comparing name because can't compare class == class directly with ReflectClass + ret = new GenericArrayClass(this, clazz, name, null); + } + else + { + ret = new Db4objects.Db4o.Reflect.Generic.GenericClass(this, clazz, name, null); + } + return ret; + } + + /// Returns a ReflectClass instance for the specified class + /// class + /// a ReflectClass instance for the specified class + /// Db4objects.Db4o.Reflect.IReflectClass + /// + public virtual IReflectClass ForClass(Type clazz) + { + if (clazz == null) + { + return null; + } + IReflectClass claxx = (IReflectClass)_classByClass.Get(clazz); + if (claxx != null) + { + return claxx; + } + if (!clazz.IsArray && ReflectPlatform.IsNamedClass(clazz)) + { + claxx = ForName(ReflectPlatform.FullyQualifiedName(clazz)); + if (claxx != null) + { + _classByClass.Put(clazz, claxx); + return claxx; + } + } + claxx = _delegate.ForClass(clazz); + if (claxx == null) + { + return null; + } + claxx = EnsureDelegate(claxx); + _classByClass.Put(clazz, claxx); + return claxx; + } + + /// Returns a ReflectClass instance for the specified class name + /// class name + /// a ReflectClass instance for the specified class name + /// Db4objects.Db4o.Reflect.IReflectClass + /// + public virtual IReflectClass ForName(string className) + { + return ((IReflectClass)WithLock(new _IClosure4_190(this, className))); + } + + private sealed class _IClosure4_190 : IClosure4 + { + public _IClosure4_190(GenericReflector _enclosing, string className) + { + this._enclosing = _enclosing; + this.className = className; + } + + public object Run() + { + IReflectClass clazz = this._enclosing._repository.LookupByName(className); + if (clazz != null) + { + return clazz; + } + clazz = this._enclosing._delegate.ForName(className); + if (clazz != null) + { + return this._enclosing.EnsureDelegate(clazz); + } + return this._enclosing._repository.ForName(className); + } + + private readonly GenericReflector _enclosing; + + private readonly string className; + } + + /// Returns a ReflectClass instance for the specified class object + /// class object + /// a ReflectClass instance for the specified class object + /// Db4objects.Db4o.Reflect.IReflectClass + /// + public virtual IReflectClass ForObject(object obj) + { + if (obj is GenericObject) + { + return ForGenericObject((GenericObject)obj); + } + if (obj is GenericArray) + { + return ((GenericArray)obj)._clazz; + } + return _delegate.ForObject(obj); + } + + private IReflectClass ForGenericObject(GenericObject genericObject) + { + Db4objects.Db4o.Reflect.Generic.GenericClass claxx = genericObject._class; + if (claxx == null) + { + throw new InvalidOperationException(); + } + string name = claxx.GetName(); + if (name == null) + { + throw new InvalidOperationException(); + } + Db4objects.Db4o.Reflect.Generic.GenericClass existingClass = (Db4objects.Db4o.Reflect.Generic.GenericClass + )ForName(name); + if (existingClass == null) + { + _repository.Register(claxx); + return claxx; + } + // TODO: Using .equals() here would be more consistent with + // the equals() method in GenericClass. + if (existingClass != claxx) + { + throw new InvalidOperationException(); + } + return claxx; + } + + /// Returns delegate reflector + /// delegate reflector + public virtual IReflector GetDelegate() + { + return _delegate; + } + + /// Determines if a candidate ReflectClass is a collection + /// candidate ReflectClass + /// true if a candidate ReflectClass is a collection. + public virtual bool IsCollection(IReflectClass candidate) + { + //candidate = candidate.getDelegate(); + IEnumerator i = _collectionPredicates.GetEnumerator(); + while (i.MoveNext()) + { + if (((IReflectClassPredicate)i.Current).Match(candidate)) + { + return true; + } + } + return _delegate.IsCollection(candidate.GetDelegate()); + } + + //TODO: will need knowledge for .NET collections here + // possibility: call registercollection with strings + /// Register a class as a collection + /// class to be registered + public virtual void RegisterCollection(Type clazz) + { + RegisterCollection(ClassPredicate(clazz)); + } + + /// Register a predicate as a collection + /// predicate to be registered + public virtual void RegisterCollection(IReflectClassPredicate predicate) + { + _collectionPredicates.Add(predicate); + } + + private IReflectClassPredicate ClassPredicate(Type clazz) + { + IReflectClass collectionClass = ForClass(clazz); + IReflectClassPredicate predicate = new _IReflectClassPredicate_290(collectionClass + ); + return predicate; + } + + private sealed class _IReflectClassPredicate_290 : IReflectClassPredicate + { + public _IReflectClassPredicate_290(IReflectClass collectionClass) + { + this.collectionClass = collectionClass; + } + + public bool Match(IReflectClass candidate) + { + return collectionClass.IsAssignableFrom(candidate); + } + + private readonly IReflectClass collectionClass; + } + + /// Register a class + /// class + public virtual void Register(Db4objects.Db4o.Reflect.Generic.GenericClass clazz) + { + WithLock(new _IClosure4_303(this, clazz)); + } + + private sealed class _IClosure4_303 : IClosure4 + { + public _IClosure4_303(GenericReflector _enclosing, Db4objects.Db4o.Reflect.Generic.GenericClass + clazz) + { + this._enclosing = _enclosing; + this.clazz = clazz; + } + + public object Run() + { + string name = clazz.GetName(); + if (this._enclosing._repository.LookupByName(name) == null) + { + this._enclosing._repository.Register(clazz); + } + return null; + } + + private readonly GenericReflector _enclosing; + + private readonly Db4objects.Db4o.Reflect.Generic.GenericClass clazz; + } + + /// Returns an array of classes known to the reflector + /// an array of classes known to the reflector + public virtual IReflectClass[] KnownClasses() + { + return ((IReflectClass[])WithLock(new _IClosure4_319(this))); + } + + private sealed class _IClosure4_319 : IClosure4 + { + public _IClosure4_319(GenericReflector _enclosing) + { + this._enclosing = _enclosing; + } + + public object Run() + { + return new KnownClassesCollector(this._enclosing._stream, this._enclosing._repository + ).Collect(); + } + + private readonly GenericReflector _enclosing; + } + + /// Registers primitive class + /// class id + /// class name + /// class converter + public virtual void RegisterPrimitiveClass(int id, string name, IGenericConverter + converter) + { + WithLock(new _IClosure4_333(this, id, converter, name)); + } + + private sealed class _IClosure4_333 : IClosure4 + { + public _IClosure4_333(GenericReflector _enclosing, int id, IGenericConverter converter + , string name) + { + this._enclosing = _enclosing; + this.id = id; + this.converter = converter; + this.name = name; + } + + public object Run() + { + Db4objects.Db4o.Reflect.Generic.GenericClass existing = (Db4objects.Db4o.Reflect.Generic.GenericClass + )this._enclosing._repository.LookupByID(id); + if (existing != null) + { + if (null != converter) + { + } + else + { + // existing.setSecondClass(); + existing.SetConverter(null); + } + return null; + } + IReflectClass clazz = this._enclosing._delegate.ForName(name); + Db4objects.Db4o.Reflect.Generic.GenericClass claxx = null; + if (clazz != null) + { + claxx = this._enclosing.EnsureDelegate(clazz); + } + else + { + claxx = new Db4objects.Db4o.Reflect.Generic.GenericClass(this._enclosing, null, name + , null); + this._enclosing.Register(claxx); + claxx.InitFields(new GenericField[] { new GenericField(null, null, true) }); + claxx.SetConverter(converter); + } + // claxx.setSecondClass(); + claxx.SetPrimitive(); + this._enclosing._repository.Register(id, claxx); + return null; + } + + private readonly GenericReflector _enclosing; + + private readonly int id; + + private readonly IGenericConverter converter; + + private readonly string name; + } + + /// method stub: generic reflector does not have a parent + public virtual void SetParent(IReflector reflector) + { + } + + // do nothing, the generic reflector does not have a parant + public virtual void Configuration(IReflectorConfiguration config) + { + if (_delegate != null) + { + _delegate.Configuration(config); + } + } + + private object WithLock(IClosure4 block) + { + if (_stream == null || _stream.IsClosed()) + { + return block.Run(); + } + return _stream.SyncExec(block); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Reflect/Generic/GenericVirtualField.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Reflect/Generic/GenericVirtualField.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Reflect/Generic/GenericVirtualField.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Reflect/Generic/GenericVirtualField.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,50 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Reflect; +using Db4objects.Db4o.Reflect.Generic; + +namespace Db4objects.Db4o.Reflect.Generic +{ + /// + public class GenericVirtualField : GenericField + { + public GenericVirtualField(string name) : base(name, null, false) + { + } + + public override object DeepClone(object obj) + { + return new Db4objects.Db4o.Reflect.Generic.GenericVirtualField(GetName()); + } + + public override object Get(object onObject) + { + return null; + } + + public override IReflectClass GetFieldType() + { + return null; + } + + public override bool IsPublic() + { + return false; + } + + public override bool IsStatic() + { + return true; + } + + public override bool IsTransient() + { + return true; + } + + public override void Set(object onObject, object value) + { + } + // do nothing + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Reflect/Generic/IGenericConverter.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Reflect/Generic/IGenericConverter.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Reflect/Generic/IGenericConverter.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Reflect/Generic/IGenericConverter.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,14 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Reflect.Generic; + +namespace Db4objects.Db4o.Reflect.Generic +{ + /// + public interface IGenericConverter + { + string ToString(GenericObject obj); + + string ToString(GenericArray array); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Reflect/Generic/IReflectClassBuilder.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Reflect/Generic/IReflectClassBuilder.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Reflect/Generic/IReflectClassBuilder.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Reflect/Generic/IReflectClassBuilder.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,19 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Reflect; + +namespace Db4objects.Db4o.Reflect.Generic +{ + /// + public interface IReflectClassBuilder + { + IReflectClass CreateClass(string name, IReflectClass superClass, int fieldCount); + + IReflectField CreateField(IReflectClass parentType, string fieldName, IReflectClass + fieldType, bool isVirtual, bool isPrimitive, bool isArray, bool isNArray); + + void InitFields(IReflectClass clazz, IReflectField[] fields); + + IReflectField[] FieldArray(int length); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Reflect/Generic/KnownClassesRepository.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Reflect/Generic/KnownClassesRepository.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Reflect/Generic/KnownClassesRepository.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Reflect/Generic/KnownClassesRepository.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,373 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using System.Collections; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Marshall; +using Db4objects.Db4o.Reflect; +using Db4objects.Db4o.Reflect.Generic; + +namespace Db4objects.Db4o.Reflect.Generic +{ + /// + public class KnownClassesRepository + { + private static readonly Hashtable4 Primitives; + + static KnownClassesRepository() + { + Primitives = new Hashtable4(); + Type[] primitiveArray = Platform4.PrimitiveTypes(); + for (int primitiveIndex = 0; primitiveIndex < primitiveArray.Length; ++primitiveIndex) + { + Type primitive = primitiveArray[primitiveIndex]; + RegisterPrimitive(primitive); + } + } + + private static void RegisterPrimitive(Type primitive) + { + Primitives.Put(ReflectPlatform.FullyQualifiedName(Platform4.NullableTypeFor(primitive + )), primitive); + } + + private ObjectContainerBase _stream; + + private Transaction _trans; + + private IReflectClassBuilder _builder; + + private readonly ListenerRegistry _listeners = ListenerRegistry.NewInstance(); + + private readonly Hashtable4 _classByName = new Hashtable4(); + + private readonly Hashtable4 _classByID = new Hashtable4(); + + private Collection4 _pendingClasses = new Collection4(); + + private readonly Collection4 _classes = new Collection4(); + + public KnownClassesRepository(IReflectClassBuilder builder) + { + _builder = builder; + } + + public virtual void SetTransaction(Transaction trans) + { + if (trans != null) + { + _trans = trans; + _stream = trans.Container(); + } + } + + public virtual void Register(IReflectClass clazz) + { + Register(clazz.GetName(), clazz); + } + + public virtual IReflectClass ForID(int id) + { + lock (_stream.Lock()) + { + if (_stream.Handlers.IsSystemHandler(id)) + { + return _stream.Handlers.ClassForID(id); + } + return EnsureClassAvailability(id); + } + } + + public virtual IReflectClass ForName(string className) + { + IReflectClass clazz = LookupByName(className); + if (clazz != null) + { + return clazz; + } + if (_stream == null) + { + return null; + } + lock (_stream.Lock()) + { + if (_stream.ClassCollection() == null) + { + return null; + } + int classID = _stream.ClassMetadataIdForName(className); + if (classID <= 0) + { + return null; + } + return InitializeClass(classID, className); + } + } + + private IReflectClass InitializeClass(int classID, string className) + { + IReflectClass newClazz = EnsureClassInitialised(classID); + _classByName.Put(className, newClazz); + return newClazz; + } + + private void ReadAll() + { + ForEachClassId(new _IProcedure4_102(this)); + ForEachClassId(new _IProcedure4_105(this)); + } + + private sealed class _IProcedure4_102 : IProcedure4 + { + public _IProcedure4_102(KnownClassesRepository _enclosing) + { + this._enclosing = _enclosing; + } + + public void Apply(object id) + { + this._enclosing.EnsureClassAvailability((((int)id))); + } + + private readonly KnownClassesRepository _enclosing; + } + + private sealed class _IProcedure4_105 : IProcedure4 + { + public _IProcedure4_105(KnownClassesRepository _enclosing) + { + this._enclosing = _enclosing; + } + + public void Apply(object id) + { + this._enclosing.EnsureClassRead((((int)id))); + } + + private readonly KnownClassesRepository _enclosing; + } + + private void ForEachClassId(IProcedure4 procedure) + { + for (IEnumerator ids = _stream.ClassCollection().Ids(); ids.MoveNext(); ) + { + procedure.Apply((int)ids.Current); + } + } + + private IReflectClass EnsureClassAvailability(int id) + { + if (id == 0) + { + return null; + } + IReflectClass ret = (IReflectClass)_classByID.Get(id); + if (ret != null) + { + return ret; + } + ByteArrayBuffer classreader = _stream.ReadStatefulBufferById(_trans, id); + ClassMarshaller marshaller = MarshallerFamily()._class; + RawClassSpec spec = marshaller.ReadSpec(_trans, classreader); + string className = spec.Name(); + ret = LookupByName(className); + if (ret != null) + { + _classByID.Put(id, ret); + _pendingClasses.Add(id); + return ret; + } + ReportMissingClass(className); + ret = _builder.CreateClass(className, EnsureClassAvailability(spec.SuperClassID() + ), spec.NumFields()); + // step 1 only add to _classByID, keep the class out of _classByName and _classes + _classByID.Put(id, ret); + _pendingClasses.Add(id); + return ret; + } + + private void ReportMissingClass(string className) + { + _stream.Handlers.DiagnosticProcessor().ClassMissed(className); + } + + private void EnsureClassRead(int id) + { + IReflectClass clazz = LookupByID(id); + ByteArrayBuffer classreader = _stream.ReadStatefulBufferById(_trans, id); + ClassMarshaller classMarshaller = MarshallerFamily()._class; + RawClassSpec classInfo = classMarshaller.ReadSpec(_trans, classreader); + string className = classInfo.Name(); + // Having the class in the _classByName Map for now indicates + // that the class is fully read. This is breakable if we start + // returning GenericClass'es in other methods like forName + // even if a native class has not been found + if (LookupByName(className) != null) + { + return; + } + // step 2 add the class to _classByName and _classes to denote reading is completed + Register(className, clazz); + int numFields = classInfo.NumFields(); + IReflectField[] fields = _builder.FieldArray(numFields); + IFieldMarshaller fieldMarshaller = MarshallerFamily()._field; + for (int i = 0; i < numFields; i++) + { + RawFieldSpec fieldInfo = fieldMarshaller.ReadSpec(_stream, classreader); + string fieldName = fieldInfo.Name(); + IReflectClass fieldClass = ReflectClassForFieldSpec(fieldInfo, _stream.Reflector( + )); + if (null == fieldClass && (fieldInfo.IsField() && !fieldInfo.IsVirtual())) + { + throw new InvalidOperationException("Could not read field type for '" + className + + "." + fieldName + "'"); + } + fields[i] = _builder.CreateField(clazz, fieldName, fieldClass, fieldInfo.IsVirtual + (), fieldInfo.IsPrimitive(), fieldInfo.IsArray(), fieldInfo.IsNArray()); + } + _builder.InitFields(clazz, fields); + } + + private void Register(string className, IReflectClass clazz) + { + if (LookupByName(className) != null) + { + throw new ArgumentException(); + } + _classByName.Put(className, clazz); + _classes.Add(clazz); + _listeners.NotifyListeners(clazz); + } + + private IReflectClass ReflectClassForFieldSpec(RawFieldSpec fieldInfo, IReflector + reflector) + { + if (fieldInfo.IsVirtualField()) + { + return VirtualFieldByName(fieldInfo.Name()).ClassReflector(reflector); + } + int fieldTypeID = fieldInfo.FieldTypeID(); + switch (fieldTypeID) + { + case Handlers4.UntypedId: + { + // need to take care of special handlers here + return ObjectClass(); + } + + case Handlers4.AnyArrayId: + { + return ArrayClass(ObjectClass()); + } + + default: + { + IReflectClass fieldClass = ForID(fieldTypeID); + if (null != fieldClass) + { + return NormalizeFieldClass(fieldInfo, fieldClass); + } + break; + break; + } + } + return null; + } + + private IReflectClass NormalizeFieldClass(RawFieldSpec fieldInfo, IReflectClass fieldClass + ) + { + // TODO: why the following line is necessary? + IReflectClass theClass = _stream.Reflector().ForName(fieldClass.GetName()); + if (fieldInfo.IsPrimitive()) + { + theClass = PrimitiveClass(theClass); + } + if (fieldInfo.IsArray()) + { + theClass = ArrayClass(theClass); + } + return theClass; + } + + private IReflectClass ObjectClass() + { + return _stream.Reflector().ForClass(typeof(object)); + } + + private VirtualFieldMetadata VirtualFieldByName(string fieldName) + { + return _stream.Handlers.VirtualFieldByName(fieldName); + } + + private Db4objects.Db4o.Internal.Marshall.MarshallerFamily MarshallerFamily() + { + return Db4objects.Db4o.Internal.Marshall.MarshallerFamily.ForConverterVersion(_stream + .ConverterVersion()); + } + + private IReflectClass EnsureClassInitialised(int id) + { + IReflectClass ret = EnsureClassAvailability(id); + while (_pendingClasses.Size() > 0) + { + Collection4 pending = _pendingClasses; + _pendingClasses = new Collection4(); + IEnumerator i = pending.GetEnumerator(); + while (i.MoveNext()) + { + EnsureClassRead(((int)i.Current)); + } + } + return ret; + } + + public virtual IEnumerator Classes() + { + ReadAll(); + return _classes.GetEnumerator(); + } + + public virtual void Register(int id, IReflectClass clazz) + { + _classByID.Put(id, clazz); + } + + public virtual IReflectClass LookupByID(int id) + { + return (IReflectClass)_classByID.Get(id); + } + + public virtual IReflectClass LookupByName(string name) + { + return (IReflectClass)_classByName.Get(name); + } + + private IReflectClass ArrayClass(IReflectClass clazz) + { + object proto = clazz.Reflector().Array().NewInstance(clazz, 0); + return clazz.Reflector().ForObject(proto); + } + + private IReflectClass PrimitiveClass(IReflectClass baseClass) + { + Type primitive = (Type)Primitives.Get(baseClass.GetName()); + if (primitive != null) + { + return baseClass.Reflector().ForClass(primitive); + } + return baseClass; + } + + public virtual void AddListener(IListener4 listener) + { + _listeners.Register(listener); + } + + public virtual void RemoveListener(IListener4 listener) + { + _listeners.Remove(listener); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Reflect/IReflectArray.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Reflect/IReflectArray.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Reflect/IReflectArray.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Reflect/IReflectArray.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,41 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Reflect; + +namespace Db4objects.Db4o.Reflect +{ + /// Reflection Array representation. + /// + /// Reflection Array representation + ///

See documentation for System.Reflection API. + ///
+ /// IReflector + public interface IReflectArray + { + void Analyze(object obj, ArrayInfo info); + + int[] Dimensions(object arr); + + int Flatten(object a_shaped, int[] a_dimensions, int a_currentDimension, object[] + a_flat, int a_flatElement); + + object Get(object onArray, int index); + + IReflectClass GetComponentType(IReflectClass a_class); + + int GetLength(object array); + + bool IsNDimensional(IReflectClass a_class); + + object NewInstance(IReflectClass componentType, ArrayInfo info); + + object NewInstance(IReflectClass componentType, int length); + + object NewInstance(IReflectClass componentType, int[] dimensions); + + void Set(object onArray, int index, object element); + + int Shape(object[] a_flat, int a_flatElement, object a_shaped, int[] a_dimensions + , int a_currentDimension); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Reflect/IReflectClass.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Reflect/IReflectClass.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Reflect/IReflectClass.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Reflect/IReflectClass.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,82 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Reflect; + +namespace Db4objects.Db4o.Reflect +{ + /// Reflection Class representation. + /// + /// Reflection Class representation + ///

See documentation for System.Reflection API. + ///
+ /// IReflector + public interface IReflectClass + { + IReflectClass GetComponentType(); + + IReflectField[] GetDeclaredFields(); + + IReflectField GetDeclaredField(string name); + + /// Returns the ReflectClass instance being delegated to. + /// + /// Returns the ReflectClass instance being delegated to. + /// If there's no delegation it should return this. + /// + /// delegate or this + IReflectClass GetDelegate(); + + IReflectMethod GetMethod(string methodName, IReflectClass[] paramClasses); + + string GetName(); + + IReflectClass GetSuperclass(); + + bool IsAbstract(); + + bool IsArray(); + + bool IsAssignableFrom(IReflectClass type); + + bool IsCollection(); + + bool IsInstance(object obj); + + bool IsInterface(); + + bool IsPrimitive(); + + object NewInstance(); + + IReflector Reflector(); + + object NullValue(); + + /// + /// Calling this method may change the internal state of the class, even if a usable + /// constructor has been found on earlier invocations. + /// + /// + /// Calling this method may change the internal state of the class, even if a usable + /// constructor has been found on earlier invocations. + /// + /// true, if instances of this class can be created, false otherwise + bool EnsureCanBeInstantiated(); + + /// + /// We need this for replication, to find out if a class needs to be traversed + /// or if it simply can be copied across. + /// + /// + /// We need this for replication, to find out if a class needs to be traversed + /// or if it simply can be copied across. For now we will simply return + /// the classes that are + /// IsPrimitive() + /// and + /// Db4objects.Db4o.Internal.Platform4.IsSimple(System.Type<T>) + /// + /// We can think about letting users add an Immutable annotation. + /// + bool IsImmutable(); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Reflect/IReflectClassPredicate.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Reflect/IReflectClassPredicate.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Reflect/IReflectClassPredicate.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Reflect/IReflectClassPredicate.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,22 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Reflect; + +namespace Db4objects.Db4o.Reflect +{ + /// Predicate representation. + /// Predicate representation. + /// Db4objects.Db4o.Query.Predicate + /// IReflector + public interface IReflectClassPredicate + { + /// Match method definition. + /// + /// Match method definition. Used to select correct + /// results from an object set. + /// + /// item to be matched to the criteria + /// true, if the requirements are met + bool Match(IReflectClass item); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Reflect/IReflectField.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Reflect/IReflectField.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Reflect/IReflectField.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Reflect/IReflectField.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,53 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Reflect; + +namespace Db4objects.Db4o.Reflect +{ + /// Reflection Field representation. + /// + /// Reflection Field representation + ///

See documentation for System.Reflection API. + ///
+ /// IReflector + public interface IReflectField + { + object Get(object onObject); + + string GetName(); + + /// + /// The ReflectClass returned by this method should have been + /// provided by the parent reflector. + /// + /// + /// The ReflectClass returned by this method should have been + /// provided by the parent reflector. + /// + /// the ReflectClass representing the field type as provided by the parent reflector + /// + IReflectClass GetFieldType(); + + bool IsPublic(); + + bool IsStatic(); + + bool IsTransient(); + + void Set(object onObject, object value); + + /// + /// The ReflectClass returned by this method should have been + /// provided by the parent reflector. + /// + /// + /// The ReflectClass returned by this method should have been + /// provided by the parent reflector. + /// + /// the ReflectClass representing the index type as provided by the parent reflector + /// + IReflectClass IndexType(); + + object IndexEntry(object orig); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Reflect/IReflectMethod.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Reflect/IReflectMethod.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Reflect/IReflectMethod.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Reflect/IReflectMethod.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,20 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Reflect; + +namespace Db4objects.Db4o.Reflect +{ + /// Reflection Method representation. + /// + /// Reflection Method representation + ///

See documentation for System.Reflection API. + ///
+ /// IReflector + public interface IReflectMethod + { + /// + object Invoke(object onObject, object[] parameters); + + IReflectClass GetReturnType(); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Reflect/IReflectorConfiguration.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Reflect/IReflectorConfiguration.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Reflect/IReflectorConfiguration.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Reflect/IReflectorConfiguration.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,13 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Reflect; + +namespace Db4objects.Db4o.Reflect +{ + public interface IReflectorConfiguration + { + bool TestConstructors(); + + bool CallConstructor(IReflectClass clazz); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Reflect/IReflector.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Reflect/IReflector.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Reflect/IReflector.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Reflect/IReflector.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,52 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Reflect; + +namespace Db4objects.Db4o.Reflect +{ + /// root of the reflection implementation API. + /// + /// root of the reflection implementation API. + ///

The open reflection interface is supplied to allow to implement + /// custom reflection functionality.

+ /// Use + /// + /// Db4o.Configure().ReflectWith(IReflect reflector) + /// + /// to register the use of your implementation before opening database + /// files. + ///
+ public interface IReflector : IDeepClone + { + void Configuration(IReflectorConfiguration config); + + /// + /// returns an ReflectArray object. + /// + /// + /// returns an ReflectArray object. + /// + IReflectArray Array(); + + /// returns an ReflectClass for a Class + IReflectClass ForClass(Type clazz); + + /// + /// returns an ReflectClass class reflector for a class name or null + /// if no such class is found + /// + IReflectClass ForName(string className); + + /// returns an ReflectClass for an object or null if the passed object is null. + /// + /// returns an ReflectClass for an object or null if the passed object is null. + /// + IReflectClass ForObject(object obj); + + bool IsCollection(IReflectClass clazz); + + void SetParent(IReflector reflector); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Reflect/MultidimensionalArrayInfo.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Reflect/MultidimensionalArrayInfo.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Reflect/MultidimensionalArrayInfo.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Reflect/MultidimensionalArrayInfo.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,22 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Reflect; + +namespace Db4objects.Db4o.Reflect +{ + /// + public class MultidimensionalArrayInfo : ArrayInfo + { + private int[] _dimensions; + + public virtual void Dimensions(int[] dim) + { + _dimensions = dim; + } + + public virtual int[] Dimensions() + { + return _dimensions; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Rename.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Rename.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Rename.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Rename.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,41 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o; + +namespace Db4objects.Db4o +{ + /// + /// Renaming actions are stored to the database file to make + /// sure that they are only performed once. + /// + /// + /// Renaming actions are stored to the database file to make + /// sure that they are only performed once. + /// + /// + /// + public sealed class Rename : IInternal4 + { + public string rClass; + + public string rFrom; + + public string rTo; + + public Rename() + { + } + + public Rename(string aClass, string aFrom, string aTo) + { + rClass = aClass; + rFrom = aFrom; + rTo = aTo; + } + + public bool IsField() + { + return rClass.Length != 0; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/StaticClass.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/StaticClass.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/StaticClass.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/StaticClass.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,25 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o; + +namespace Db4objects.Db4o +{ + /// + /// + public class StaticClass : IInternal4 + { + public string name; + + public StaticField[] fields; + + public StaticClass() + { + } + + public StaticClass(string name_, StaticField[] fields_) + { + name = name_; + fields = fields_; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/StaticField.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/StaticField.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/StaticField.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/StaticField.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,25 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o; + +namespace Db4objects.Db4o +{ + /// + /// + public class StaticField : IInternal4 + { + public string name; + + public object value; + + public StaticField() + { + } + + public StaticField(string name_, object value_) + { + name = name_; + value = value_; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/TA/DeactivatingRollbackStrategy.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/TA/DeactivatingRollbackStrategy.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/TA/DeactivatingRollbackStrategy.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/TA/DeactivatingRollbackStrategy.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,20 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o; +using Db4objects.Db4o.TA; + +namespace Db4objects.Db4o.TA +{ + /// RollbackStrategy to deactivate all activated objects on rollback. + /// RollbackStrategy to deactivate all activated objects on rollback. + /// TransparentPersistenceSupport + public class DeactivatingRollbackStrategy : IRollbackStrategy + { + /// deactivates each object. + /// deactivates each object. + public virtual void Rollback(IObjectContainer container, object obj) + { + container.Ext().Deactivate(obj); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/TA/IActivatable.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/TA/IActivatable.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/TA/IActivatable.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/TA/IActivatable.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,135 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Activation; + +namespace Db4objects.Db4o.TA +{ + /// + /// IActivatable must be implemented by classes in order to support + /// Transparent Activation. + ///
+ ///
+ /// The IActivatable interface may be added to persistent classes by hand + /// or by using the db4o instrumentation (Db4oTools). + ///
+ /// + /// IActivatable must be implemented by classes in order to support + /// Transparent Activation. + ///
+ ///
+ /// The IActivatable interface may be added to persistent classes by hand + /// or by using the db4o instrumentation (Db4oTools). For further + /// information on the enhancer see: + ///
+ ///
+ /// http://developer.db4o.com/Resources/view.aspx/Reference/Implementation_Strategies/Enhancement_Tools/Enhancement_For_.NET. + ///
+ ///
+ /// The basic idea for Transparent Activation is as follows: + ///
+ /// Objects have an activation depth of 0, i.e. by default they are not + /// activated at all. Whenever a method is called on such an object, the + /// first thing to do before actually executing the method body is to + /// activate the object to level 1, i.e. populating its direct members. + ///
+ ///
+ /// To illustrate this approach, we will use the following simple class. + ///
+ ///
+ /// + /// public class Item { + ///
   private Item _next;

+ ///    public Item(Item next) {
+ ///       _next = next;
+ ///    }

+ ///    public Item Next {
+ ///      get {
+ ///       return _next;
+ ///      }
+ ///    }
+ /// }

+ /// The basic sequence of actions to get the above scheme to work is the + /// following:
+ ///
+ /// - Whenever an object is instantiated from db4o, the database registers an + /// activator for this object. To enable this, the object has to implement the + /// IActivatable interface and provide the according Bind(IActivator) method. The + /// default implementation of the bind method will simply store the given + /// activator reference for later use.
+ ///
+ /// + /// public class Item implements IActivatable {
+ ///    transient IActivator _activator;

+ ///    public void Bind(IActivator activator) {
+ ///       if (null != _activator) {
+ ///          throw new IllegalStateException();
+ ///       }
+ ///       _activator = activator;
+ ///    }

+ ///    // ...
+ /// }

+ /// - The first action in every method body of an activatable object should be a + /// call to the corresponding IActivator's Activate() method. (Note that this is + /// not enforced by any interface, it is rather a convention, and other + /// implementations are possible.)
+ ///
+ /// + /// public class Item implements IActivatable {
+ ///    public void Activate() {
+ ///       if (_activator == null) return;
+ ///       _activator.Activate();
+ ///    }

+ ///    public Item Next() {
+ ///      get {
+ ///       Activate();
+ ///       return _next;
+ ///      }
+ ///    }
+ /// }

+ /// - The Activate() method will check whether the object is already activated. + /// If this is not the case, it will request the container to activate the object + /// to level 1 and set the activated flag accordingly.
+ ///
+ /// To instruct db4o to actually use these hooks (i.e. to register the database + /// when instantiating an object), TransparentActivationSupport has to be + /// registered with the db4o configuration.
+ ///
+ /// + /// ICommonConfiguration config = ...
+ /// config.Add(new TransparentActivationSupport());

+ ///
+ ///
+ public interface IActivatable + { + /// called by db4o upon instantiation. + /// + /// called by db4o upon instantiation.
+ ///
+ /// The recommended implementation of this method is to store the passed + /// Db4objects.Db4o.Activation.IActivator + /// + /// in a transient field of the object. + ///
+ /// the Activator + void Bind(IActivator activator); + + /// should be called by every reading field access of an object. + /// + /// should be called by every reading field access of an object.
+ ///
+ /// The recommended implementation of this method is to call + /// Db4objects.Db4o.Activation.IActivator.Activate(Db4objects.Db4o.Activation.ActivationPurpose) + /// + /// on the + /// Db4objects.Db4o.Activation.IActivator + /// + /// that was previously passed to + /// Bind(Db4objects.Db4o.Activation.IActivator) + /// + /// . + ///
+ /// TODO + void Activate(ActivationPurpose purpose); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/TA/IActivatableInstrumented.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/TA/IActivatableInstrumented.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/TA/IActivatableInstrumented.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/TA/IActivatableInstrumented.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,16 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +namespace Db4objects.Db4o.TA +{ + /// + /// Marker interface to declare a class already implements the required TA/TP hooks + /// and does not want to be instrumented further. + /// + /// + /// Marker interface to declare a class already implements the required TA/TP hooks + /// and does not want to be instrumented further. + /// + public interface IActivatableInstrumented + { + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/TA/IRollbackStrategy.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/TA/IRollbackStrategy.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/TA/IRollbackStrategy.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/TA/IRollbackStrategy.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,22 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o; + +namespace Db4objects.Db4o.TA +{ + /// Interface defining rollback behavior when Transparent Persistence mode is on. + /// + /// Interface defining rollback behavior when Transparent Persistence mode is on. + /// + /// TransparentPersistenceSupport + public interface IRollbackStrategy + { + /// Method to be called per TP-enabled object when the transaction is rolled back. + /// + /// Method to be called per TP-enabled object when the transaction is rolled back. + /// + /// current ObjectContainer + /// TP-enabled object + void Rollback(IObjectContainer container, object obj); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/TA/NotTransparentActivationEnabled.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/TA/NotTransparentActivationEnabled.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/TA/NotTransparentActivationEnabled.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/TA/NotTransparentActivationEnabled.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,34 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Diagnostic; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.TA; + +namespace Db4objects.Db4o.TA +{ + public class NotTransparentActivationEnabled : DiagnosticBase + { + private ClassMetadata _class; + + public NotTransparentActivationEnabled(ClassMetadata clazz) + { + _class = clazz; + } + + public override string Problem() + { + return "An object of class " + _class + " was stored. Instances of this class very likely are not subject to transparent activation."; + } + + public override object Reason() + { + return _class; + } + + public override string Solution() + { + return "Use a TA aware class with equivalent functionality or ensure that this class provides a sensible implementation of the " + + typeof(IActivatable).FullName + " interface and the implicit TA hooks, either manually or by applying instrumentation."; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/TA/TransactionalActivator.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/TA/TransactionalActivator.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/TA/TransactionalActivator.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/TA/TransactionalActivator.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,34 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Activation; +using Db4objects.Db4o.Internal; + +namespace Db4objects.Db4o.TA +{ + /// + /// An + /// Db4objects.Db4o.Activation.IActivator + /// + /// implementation that activates an object on a specific + /// transaction. + /// + /// + internal sealed class TransactionalActivator : IActivator + { + private readonly Transaction _transaction; + + private readonly ObjectReference _objectReference; + + public TransactionalActivator(Transaction transaction, ObjectReference objectReference + ) + { + _objectReference = objectReference; + _transaction = transaction; + } + + public void Activate(ActivationPurpose purpose) + { + _objectReference.ActivateOn(_transaction, purpose); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/TA/TransparentActivationSupport.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/TA/TransparentActivationSupport.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/TA/TransparentActivationSupport.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/TA/TransparentActivationSupport.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,317 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using Db4objects.Db4o; +using Db4objects.Db4o.Activation; +using Db4objects.Db4o.Config; +using Db4objects.Db4o.Events; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Activation; +using Db4objects.Db4o.Internal.Diagnostic; +using Db4objects.Db4o.Internal.References; +using Db4objects.Db4o.Reflect; +using Db4objects.Db4o.TA; + +namespace Db4objects.Db4o.TA +{ + /// + /// Configuration item that enables Transparent Activation Mode for this + /// session. + /// + /// + /// Configuration item that enables Transparent Activation Mode for this + /// session. TA mode should be switched on explicitly for manual TA implementation: + ///

+ /// commonConfiguration.Add(new TransparentActivationSupport()); + ///
+ /// + public class TransparentActivationSupport : IConfigurationItem + { + // TODO: unbindOnClose should be configurable + public virtual void Prepare(IConfiguration configuration) + { + } + + // Nothing to do... + /// + /// Configures the just opened ObjectContainer by setting event listeners, + /// which will be triggered when activation or de-activation is required. + /// + /// + /// Configures the just opened ObjectContainer by setting event listeners, + /// which will be triggered when activation or de-activation is required. + /// + /// the ObjectContainer to configure + /// TransparentPersistenceSupport.Apply(Db4objects.Db4o.Internal.IInternalObjectContainer) + /// + public virtual void Apply(IInternalObjectContainer container) + { + if (IsTransparentActivationEnabledOn(container)) + { + return; + } + TransparentActivationDepthProviderImpl provider = new TransparentActivationDepthProviderImpl + (); + SetActivationDepthProvider(container, provider); + IEventRegistry registry = EventRegistryFor(container); + registry.Instantiated += new System.EventHandler + (new _IEventListener4_45(this).OnEvent); + registry.Created += new System.EventHandler + (new _IEventListener4_50(this).OnEvent); + registry.Closing += new System.EventHandler + (new _IEventListener4_56(this).OnEvent); + TransparentActivationSupport.TADiagnosticProcessor processor = new TransparentActivationSupport.TADiagnosticProcessor + (this, container); + registry.ClassRegistered += new System.EventHandler + (new _IEventListener4_67(processor).OnEvent); + } + + private sealed class _IEventListener4_45 + { + public _IEventListener4_45(TransparentActivationSupport _enclosing) + { + this._enclosing = _enclosing; + } + + public void OnEvent(object sender, Db4objects.Db4o.Events.ObjectInfoEventArgs args + ) + { + this._enclosing.BindActivatableToActivator((ObjectEventArgs)args); + } + + private readonly TransparentActivationSupport _enclosing; + } + + private sealed class _IEventListener4_50 + { + public _IEventListener4_50(TransparentActivationSupport _enclosing) + { + this._enclosing = _enclosing; + } + + public void OnEvent(object sender, Db4objects.Db4o.Events.ObjectInfoEventArgs args + ) + { + this._enclosing.BindActivatableToActivator((ObjectEventArgs)args); + } + + private readonly TransparentActivationSupport _enclosing; + } + + private sealed class _IEventListener4_56 + { + public _IEventListener4_56(TransparentActivationSupport _enclosing) + { + this._enclosing = _enclosing; + } + + public void OnEvent(object sender, Db4objects.Db4o.Events.ObjectContainerEventArgs + args) + { + IInternalObjectContainer objectContainer = (IInternalObjectContainer)((ObjectContainerEventArgs + )args).ObjectContainer; + this._enclosing.UnbindAll(objectContainer); + if (!this._enclosing.IsEmbeddedClient(objectContainer)) + { + this._enclosing.SetActivationDepthProvider(objectContainer, null); + } + } + + private readonly TransparentActivationSupport _enclosing; + } + + private sealed class _IEventListener4_67 + { + public _IEventListener4_67(TransparentActivationSupport.TADiagnosticProcessor processor + ) + { + this.processor = processor; + } + + public void OnEvent(object sender, Db4objects.Db4o.Events.ClassEventArgs args) + { + ClassEventArgs cea = (ClassEventArgs)args; + processor.OnClassRegistered(cea.ClassMetadata()); + } + + private readonly TransparentActivationSupport.TADiagnosticProcessor processor; + } + + public static bool IsTransparentActivationEnabledOn(IInternalObjectContainer container + ) + { + return ActivationProvider(container) is ITransparentActivationDepthProvider; + } + + private void SetActivationDepthProvider(IInternalObjectContainer container, IActivationDepthProvider + provider) + { + container.ConfigImpl.ActivationDepthProvider(provider); + } + + private IEventRegistry EventRegistryFor(IObjectContainer container) + { + return EventRegistryFactory.ForObjectContainer(container); + } + + private void UnbindAll(IInternalObjectContainer container) + { + Db4objects.Db4o.Internal.Transaction transaction = container.Transaction; + // FIXME should that ever happen? + if (transaction == null) + { + return; + } + IReferenceSystem referenceSystem = transaction.ReferenceSystem(); + referenceSystem.TraverseReferences(new _IVisitor4_95(this)); + } + + private sealed class _IVisitor4_95 : IVisitor4 + { + public _IVisitor4_95(TransparentActivationSupport _enclosing) + { + this._enclosing = _enclosing; + } + + public void Visit(object obj) + { + this._enclosing.Unbind((ObjectReference)obj); + } + + private readonly TransparentActivationSupport _enclosing; + } + + private void Unbind(ObjectReference objectReference) + { + object obj = objectReference.GetObject(); + if (obj == null || !(obj is IActivatable)) + { + return; + } + Bind(obj, null); + } + + private void BindActivatableToActivator(ObjectEventArgs oea) + { + object obj = oea.Object; + if (obj is IActivatable) + { + Db4objects.Db4o.Internal.Transaction transaction = (Db4objects.Db4o.Internal.Transaction + )oea.Transaction(); + ObjectReference objectReference = transaction.ReferenceForObject(obj); + Bind(obj, ActivatorForObject(transaction, objectReference)); + } + } + + private void Bind(object activatable, IActivator activator) + { + ((IActivatable)activatable).Bind(activator); + } + + private IActivator ActivatorForObject(Db4objects.Db4o.Internal.Transaction transaction + , ObjectReference objectReference) + { + if (IsEmbeddedClient(transaction)) + { + return new TransactionalActivator(transaction, objectReference); + } + return objectReference; + } + + private bool IsEmbeddedClient(Db4objects.Db4o.Internal.Transaction transaction) + { + return IsEmbeddedClient(transaction.ObjectContainer()); + } + + internal virtual Db4objects.Db4o.Internal.Transaction Transaction(EventArgs args) + { + return (Db4objects.Db4o.Internal.Transaction)((TransactionalEventArgs)args).Transaction + (); + } + + protected static IActivationDepthProvider ActivationProvider(IInternalObjectContainer + container) + { + return container.ConfigImpl.ActivationDepthProvider(); + } + + private bool IsEmbeddedClient(IObjectContainer objectContainer) + { + return objectContainer is ObjectContainerSession; + } + + private sealed class TADiagnosticProcessor + { + private readonly IInternalObjectContainer _container; + + public TADiagnosticProcessor(TransparentActivationSupport _enclosing, IInternalObjectContainer + container) + { + this._enclosing = _enclosing; + this._container = container; + } + + public void OnClassRegistered(ClassMetadata clazz) + { + // if(Platform4.isDb4oClass(clazz.getName())) { + // return; + // } + IReflectClass reflectClass = clazz.ClassReflector(); + if (this.ActivatableClass().IsAssignableFrom(reflectClass)) + { + return; + } + if (this.HasNoActivatingFields(reflectClass)) + { + return; + } + NotTransparentActivationEnabled diagnostic = new NotTransparentActivationEnabled( + clazz); + DiagnosticProcessor processor = this._container.Handlers.DiagnosticProcessor(); + processor.OnDiagnostic(diagnostic); + } + + private IReflectClass ActivatableClass() + { + return this._container.Reflector().ForClass(typeof(IActivatable)); + } + + private bool HasNoActivatingFields(IReflectClass clazz) + { + IReflectClass curClass = clazz; + while (curClass != null) + { + IReflectField[] fields = curClass.GetDeclaredFields(); + if (!this.HasNoActivatingFields(fields)) + { + return false; + } + curClass = curClass.GetSuperclass(); + } + return true; + } + + private bool HasNoActivatingFields(IReflectField[] fields) + { + for (int i = 0; i < fields.Length; i++) + { + if (this.IsActivating(fields[i])) + { + return false; + } + } + return true; + } + + private bool IsActivating(IReflectField field) + { + IReflectClass fieldType = field.GetFieldType(); + return fieldType != null && !fieldType.IsPrimitive(); + } + + private readonly TransparentActivationSupport _enclosing; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/TA/TransparentPersistenceSupport.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/TA/TransparentPersistenceSupport.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/TA/TransparentPersistenceSupport.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/TA/TransparentPersistenceSupport.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,71 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Config; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Activation; +using Db4objects.Db4o.TA; + +namespace Db4objects.Db4o.TA +{ + /// + /// Enables Transparent Persistence and Transparent Activation behaviours for + /// the current session. + /// + /// + /// Enables Transparent Persistence and Transparent Activation behaviours for + /// the current session. + ///

+ /// commonConfiguration.Add(new TransparentPersistenceSupport()); + ///
+ /// Db4objects.Db4o.TA.TransparentActivationSupport + /// + public class TransparentPersistenceSupport : TransparentActivationSupport + { + private readonly IRollbackStrategy _rollbackStrategy; + + /// Creates a new instance of TransparentPersistenceSupport class + /// + /// RollbackStrategy interface implementation, which + /// defines the actions to be taken on the object when the transaction is rolled back. + /// + public TransparentPersistenceSupport(IRollbackStrategy rollbackStrategy) + { + _rollbackStrategy = rollbackStrategy; + } + + /// + /// Creates a new instance of TransparentPersistenceSupport class + /// with no rollback strategies defined. + /// + /// + /// Creates a new instance of TransparentPersistenceSupport class + /// with no rollback strategies defined. + /// + public TransparentPersistenceSupport() : this(null) + { + } + + /// Configures current ObjectContainer to support Transparent Activation and Transparent Persistence + /// + /// + public override void Apply(IInternalObjectContainer container) + { + base.Apply(container); + EnableTransparentPersistenceFor(container); + } + + private void EnableTransparentPersistenceFor(IInternalObjectContainer container) + { + ITransparentActivationDepthProvider provider = (ITransparentActivationDepthProvider + )ActivationProvider(container); + provider.EnableTransparentPersistenceSupportFor(container, _rollbackStrategy); + } + + public override void Prepare(IConfiguration configuration) + { + base.Prepare(configuration); + ((Config4Impl)configuration).UpdateDepthProvider(new TPUpdateDepthProvider()); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Typehandlers/CollectionTypeHandler.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Typehandlers/CollectionTypeHandler.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Typehandlers/CollectionTypeHandler.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Typehandlers/CollectionTypeHandler.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,146 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System.Collections; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Delete; +using Db4objects.Db4o.Internal.Handlers; +using Db4objects.Db4o.Internal.Marshall; +using Db4objects.Db4o.Marshall; +using Db4objects.Db4o.Typehandlers; + +namespace Db4objects.Db4o.Typehandlers +{ + /// TypeHandler for Collections. + /// + /// TypeHandler for Collections. + /// On the .NET side, usage is restricted to instances of IList. + /// + public partial class CollectionTypeHandler : IReferenceTypeHandler, ICascadingTypeHandler + , IVariableLengthTypeHandler, IQueryableTypeHandler + { + public virtual IPreparedComparison PrepareComparison(IContext context, object obj + ) + { + // TODO Auto-generated method stub + return null; + } + + public virtual void Write(IWriteContext context, object obj) + { + ICollection collection = (ICollection)obj; + ITypeHandler4 elementHandler = DetectElementTypeHandler(Container(context), collection + ); + WriteElementClassMetadataId(context, elementHandler); + WriteElementCount(context, collection); + WriteElements(context, collection, elementHandler); + } + + public virtual void Activate(IReferenceActivationContext context) + { + ICollection collection = (ICollection)((UnmarshallingContext)context).PersistentObject + (); + ClearCollection(collection); + ITypeHandler4 elementHandler = ReadElementTypeHandler(context, context); + int elementCount = context.ReadInt(); + for (int i = 0; i < elementCount; i++) + { + object element = context.ReadObject(elementHandler); + AddToCollection(collection, element); + } + } + + private void WriteElementCount(IWriteContext context, ICollection collection) + { + context.WriteInt(collection.Count); + } + + private void WriteElements(IWriteContext context, ICollection collection, ITypeHandler4 + elementHandler) + { + IEnumerator elements = collection.GetEnumerator(); + while (elements.MoveNext()) + { + context.WriteObject(elementHandler, elements.Current); + } + } + + private ObjectContainerBase Container(IContext context) + { + return ((IInternalObjectContainer)context.ObjectContainer()).Container; + } + + /// + public virtual void Delete(IDeleteContext context) + { + if (!context.CascadeDelete()) + { + return; + } + ITypeHandler4 handler = ReadElementTypeHandler(context, context); + int elementCount = context.ReadInt(); + for (int i = elementCount; i > 0; i--) + { + handler.Delete(context); + } + } + + public virtual void Defragment(IDefragmentContext context) + { + ITypeHandler4 handler = ReadElementTypeHandler(context, context); + int elementCount = context.ReadInt(); + for (int i = 0; i < elementCount; i++) + { + handler.Defragment(context); + } + } + + public void CascadeActivation(IActivationContext context) + { + IEnumerator all = ((ICollection)context.TargetObject()).GetEnumerator(); + while (all.MoveNext()) + { + context.CascadeActivationToChild(all.Current); + } + } + + public virtual ITypeHandler4 ReadCandidateHandler(QueryingReadContext context) + { + return this; + } + + public virtual void CollectIDs(QueryingReadContext context) + { + ITypeHandler4 elementHandler = ReadElementTypeHandler(context, context); + int elementCount = context.ReadInt(); + for (int i = 0; i < elementCount; i++) + { + context.ReadId(elementHandler); + } + } + + private void WriteElementClassMetadataId(IWriteContext context, ITypeHandler4 elementHandler + ) + { + context.WriteInt(0); + } + + private ITypeHandler4 ReadElementTypeHandler(IReadBuffer buffer, IContext context + ) + { + buffer.ReadInt(); + return (ITypeHandler4)Container(context).Handlers.OpenTypeHandler(); + } + + private ITypeHandler4 DetectElementTypeHandler(IInternalObjectContainer container + , ICollection collection) + { + return (ITypeHandler4)container.Handlers.OpenTypeHandler(); + } + + public virtual bool DescendsIntoMembers() + { + return true; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Typehandlers/IActivationContext.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Typehandlers/IActivationContext.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Typehandlers/IActivationContext.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Typehandlers/IActivationContext.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,28 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Activation; +using Db4objects.Db4o.Marshall; +using Db4objects.Db4o.Typehandlers; + +namespace Db4objects.Db4o.Typehandlers +{ + public interface IActivationContext : IContext + { + void CascadeActivationToTarget(); + + void CascadeActivationToChild(object obj); + + ObjectContainerBase Container(); + + object TargetObject(); + + Db4objects.Db4o.Internal.ClassMetadata ClassMetadata(); + + IActivationDepth Depth(); + + IActivationContext ForObject(object newTargetObject); + + IActivationContext Descend(); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Typehandlers/ICascadingTypeHandler.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Typehandlers/ICascadingTypeHandler.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Typehandlers/ICascadingTypeHandler.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Typehandlers/ICascadingTypeHandler.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,38 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal.Marshall; +using Db4objects.Db4o.Typehandlers; + +namespace Db4objects.Db4o.Typehandlers +{ + /// TypeHandler for objects with members. + /// TypeHandler for objects with members. + public interface ICascadingTypeHandler : ITypeHandler4 + { + /// + /// will be called during activation if the handled + /// object is already active + /// + /// + void CascadeActivation(IActivationContext context); + + /// + /// will be called during querying to ask for the handler + /// to be used to collect children of the handled object + /// + /// + /// + ITypeHandler4 ReadCandidateHandler(QueryingReadContext context); + + /// + /// will be called during querying to ask for IDs of member + /// objects of the handled object. + /// + /// + /// will be called during querying to ask for IDs of member + /// objects of the handled object. + /// + /// + void CollectIDs(QueryingReadContext context); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Typehandlers/IgnoreFieldsTypeHandler.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Typehandlers/IgnoreFieldsTypeHandler.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Typehandlers/IgnoreFieldsTypeHandler.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Typehandlers/IgnoreFieldsTypeHandler.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,62 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Delete; +using Db4objects.Db4o.Internal.Marshall; +using Db4objects.Db4o.Marshall; +using Db4objects.Db4o.Typehandlers; + +namespace Db4objects.Db4o.Typehandlers +{ + /// Typehandler that ignores all fields on a class + public class IgnoreFieldsTypeHandler : IReferenceTypeHandler, ICascadingTypeHandler + { + public static readonly ITypeHandler4 Instance = new Db4objects.Db4o.Typehandlers.IgnoreFieldsTypeHandler + (); + + private IgnoreFieldsTypeHandler() + { + } + + public virtual void Defragment(IDefragmentContext context) + { + } + + // do nothing + /// + public virtual void Delete(IDeleteContext context) + { + } + + // do nothing + public virtual void Activate(IReferenceActivationContext context) + { + } + + public virtual void Write(IWriteContext context, object obj) + { + } + + public virtual IPreparedComparison PrepareComparison(IContext context, object obj + ) + { + return null; + } + + public virtual void CascadeActivation(IActivationContext context) + { + } + + // do nothing + public virtual void CollectIDs(QueryingReadContext context) + { + } + + // do nothing + public virtual ITypeHandler4 ReadCandidateHandler(QueryingReadContext context) + { + return null; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Typehandlers/IInstantiatingTypeHandler.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Typehandlers/IInstantiatingTypeHandler.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Typehandlers/IInstantiatingTypeHandler.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Typehandlers/IInstantiatingTypeHandler.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,28 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Marshall; +using Db4objects.Db4o.Typehandlers; + +namespace Db4objects.Db4o.Typehandlers +{ + public interface IInstantiatingTypeHandler : IReferenceTypeHandler + { + object Instantiate(IReadContext context); + + /// gets called when an object is to be written to the database. + /// + /// gets called when an object is to be written to the database. + /// The method must only write data necessary to re instantiate the object, usually + /// the immutable bits of information held by the object. For value + /// types that means their complete state. + /// Mutable state (only allowed in reference types) must be handled + /// during + /// IReferenceTypeHandler.Activate(Db4objects.Db4o.Marshall.IReferenceActivationContext) + /// + /// + /// + /// the object + void WriteInstantiation(IWriteContext context, object obj); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Typehandlers/Internal/KeyValueHandlerPair.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Typehandlers/Internal/KeyValueHandlerPair.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Typehandlers/Internal/KeyValueHandlerPair.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Typehandlers/Internal/KeyValueHandlerPair.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,20 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Typehandlers; + +namespace Db4objects.Db4o.Typehandlers.Internal +{ + /// + public class KeyValueHandlerPair + { + public readonly ITypeHandler4 _keyHandler; + + public readonly ITypeHandler4 _valueHandler; + + public KeyValueHandlerPair(ITypeHandler4 keyHandler, ITypeHandler4 valueHandler) + { + _keyHandler = keyHandler; + _valueHandler = valueHandler; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Typehandlers/IQueryableTypeHandler.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Typehandlers/IQueryableTypeHandler.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Typehandlers/IQueryableTypeHandler.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Typehandlers/IQueryableTypeHandler.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,11 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Typehandlers; + +namespace Db4objects.Db4o.Typehandlers +{ + public interface IQueryableTypeHandler : ITypeHandler4 + { + bool DescendsIntoMembers(); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Typehandlers/IReferenceTypeHandler.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Typehandlers/IReferenceTypeHandler.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Typehandlers/IReferenceTypeHandler.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Typehandlers/IReferenceTypeHandler.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,15 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Marshall; +using Db4objects.Db4o.Typehandlers; + +namespace Db4objects.Db4o.Typehandlers +{ + public interface IReferenceTypeHandler : ITypeHandler4 + { + /// gets called when an object is to be activated. + /// gets called when an object is to be activated. + /// + void Activate(IReferenceActivationContext context); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Typehandlers/ITypeFamilyTypeHandler.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Typehandlers/ITypeFamilyTypeHandler.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Typehandlers/ITypeFamilyTypeHandler.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Typehandlers/ITypeFamilyTypeHandler.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,12 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Typehandlers; + +namespace Db4objects.Db4o.Typehandlers +{ + /// + public interface ITypeFamilyTypeHandler : IQueryableTypeHandler, ILinkLengthAware + { + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Typehandlers/ITypeHandler4.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Typehandlers/ITypeHandler4.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Typehandlers/ITypeHandler4.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Typehandlers/ITypeHandler4.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,42 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Delete; +using Db4objects.Db4o.Marshall; + +namespace Db4objects.Db4o.Typehandlers +{ + /// + /// handles reading, writing, deleting, defragmenting and + /// comparisons for types of objects.

+ /// Custom Typehandlers can be implemented to alter the default + /// behaviour of storing all non-transient fields of an object.

+ ///
+ /// + /// + /// Db4objects.Db4o.Config.IConfiguration.RegisterTypeHandler(ITypeHandlerPredicate, ITypeHandler4) + /// + /// + /// + public interface ITypeHandler4 + { + /// gets called when an object gets deleted. + /// gets called when an object gets deleted. + /// + /// Db4objects.Db4o.Ext.Db4oIOException + /// + void Delete(IDeleteContext context); + + /// gets called when an object gets defragmented. + /// gets called when an object gets defragmented. + /// + void Defragment(IDefragmentContext context); + + /// gets called when an object is to be written to the database. + /// gets called when an object is to be written to the database. + /// + /// the object + void Write(IWriteContext context, object obj); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Typehandlers/ITypeHandlerPredicate.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Typehandlers/ITypeHandlerPredicate.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Typehandlers/ITypeHandlerPredicate.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Typehandlers/ITypeHandlerPredicate.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,31 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Reflect; + +namespace Db4objects.Db4o.Typehandlers +{ + /// + /// Predicate to be able to select if a specific TypeHandler is + /// applicable for a specific Type. + /// + /// + /// Predicate to be able to select if a specific TypeHandler is + /// applicable for a specific Type. + /// + public interface ITypeHandlerPredicate + { + /// + /// return true if a TypeHandler is to be used for a specific + /// Type + /// + /// + /// the Type passed by db4o that is to + /// be tested by this predicate. + /// + /// + /// true if the TypeHandler is to be used for a specific + /// Type. + /// + bool Match(IReflectClass classReflector); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Typehandlers/IValueTypeHandler.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Typehandlers/IValueTypeHandler.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Typehandlers/IValueTypeHandler.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Typehandlers/IValueTypeHandler.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,16 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Marshall; +using Db4objects.Db4o.Typehandlers; + +namespace Db4objects.Db4o.Typehandlers +{ + public interface IValueTypeHandler : ITypeHandler4 + { + /// gets called when an value type is to be read from the database. + /// gets called when an value type is to be read from the database. + /// + /// the read value type + object Read(IReadContext context); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Typehandlers/MapTypeHandler.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Typehandlers/MapTypeHandler.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Typehandlers/MapTypeHandler.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Typehandlers/MapTypeHandler.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,158 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System.Collections; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Delete; +using Db4objects.Db4o.Internal.Handlers; +using Db4objects.Db4o.Internal.Marshall; +using Db4objects.Db4o.Marshall; +using Db4objects.Db4o.Typehandlers; +using Db4objects.Db4o.Typehandlers.Internal; + +namespace Db4objects.Db4o.Typehandlers +{ + /// Typehandler for classes that implement IDictionary. + /// Typehandler for classes that implement IDictionary. + public class MapTypeHandler : IReferenceTypeHandler, ICascadingTypeHandler, IVariableLengthTypeHandler + { + public virtual IPreparedComparison PrepareComparison(IContext context, object obj + ) + { + // TODO Auto-generated method stub + return null; + } + + public virtual void Write(IWriteContext context, object obj) + { + IDictionary map = (IDictionary)obj; + KeyValueHandlerPair handlers = DetectKeyValueTypeHandlers(Container(context), map + ); + WriteClassMetadataIds(context, handlers); + WriteElementCount(context, map); + WriteElements(context, map, handlers); + } + + public virtual void Activate(IReferenceActivationContext context) + { + UnmarshallingContext unmarshallingContext = (UnmarshallingContext)context; + IDictionary map = (IDictionary)unmarshallingContext.PersistentObject(); + map.Clear(); + KeyValueHandlerPair handlers = ReadKeyValueTypeHandlers(context, context); + int elementCount = context.ReadInt(); + for (int i = 0; i < elementCount; i++) + { + object key = unmarshallingContext.ReadFullyActivatedObjectForKeys(handlers._keyHandler + ); + if (key == null && !unmarshallingContext.LastReferenceReadWasReallyNull()) + { + continue; + } + object value = context.ReadObject(handlers._valueHandler); + map[key] = value; + } + } + + private void WriteElementCount(IWriteContext context, IDictionary map) + { + context.WriteInt(map.Count); + } + + private void WriteElements(IWriteContext context, IDictionary map, KeyValueHandlerPair + handlers) + { + IEnumerator elements = map.Keys.GetEnumerator(); + while (elements.MoveNext()) + { + object key = elements.Current; + context.WriteObject(handlers._keyHandler, key); + context.WriteObject(handlers._valueHandler, map[key]); + } + } + + private ObjectContainerBase Container(IContext context) + { + return ((IInternalObjectContainer)context.ObjectContainer()).Container; + } + + /// + public virtual void Delete(IDeleteContext context) + { + if (!context.CascadeDelete()) + { + return; + } + KeyValueHandlerPair handlers = ReadKeyValueTypeHandlers(context, context); + int elementCount = context.ReadInt(); + for (int i = elementCount; i > 0; i--) + { + handlers._keyHandler.Delete(context); + handlers._valueHandler.Delete(context); + } + } + + public virtual void Defragment(IDefragmentContext context) + { + KeyValueHandlerPair handlers = ReadKeyValueTypeHandlers(context, context); + int elementCount = context.ReadInt(); + for (int i = elementCount; i > 0; i--) + { + context.Defragment(handlers._keyHandler); + context.Defragment(handlers._valueHandler); + } + } + + public void CascadeActivation(IActivationContext context) + { + IDictionary map = (IDictionary)context.TargetObject(); + IEnumerator keys = (map).Keys.GetEnumerator(); + while (keys.MoveNext()) + { + object key = keys.Current; + context.CascadeActivationToChild(key); + context.CascadeActivationToChild(map[key]); + } + } + + public virtual ITypeHandler4 ReadCandidateHandler(QueryingReadContext context) + { + return this; + } + + public virtual void CollectIDs(QueryingReadContext context) + { + KeyValueHandlerPair handlers = ReadKeyValueTypeHandlers(context, context); + int elementCount = context.ReadInt(); + for (int i = 0; i < elementCount; i++) + { + context.ReadId(handlers._keyHandler); + context.SkipId(handlers._valueHandler); + } + } + + private void WriteClassMetadataIds(IWriteContext context, KeyValueHandlerPair handlers + ) + { + context.WriteInt(0); + context.WriteInt(0); + } + + private KeyValueHandlerPair ReadKeyValueTypeHandlers(IReadBuffer buffer, IContext + context) + { + buffer.ReadInt(); + buffer.ReadInt(); + ITypeHandler4 untypedHandler = (ITypeHandler4)Container(context).Handlers.OpenTypeHandler + (); + return new KeyValueHandlerPair(untypedHandler, untypedHandler); + } + + private KeyValueHandlerPair DetectKeyValueTypeHandlers(IInternalObjectContainer container + , IDictionary map) + { + ITypeHandler4 untypedHandler = (ITypeHandler4)container.Handlers.OpenTypeHandler( + ); + return new KeyValueHandlerPair(untypedHandler, untypedHandler); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Typehandlers/SingleClassTypeHandlerPredicate.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Typehandlers/SingleClassTypeHandlerPredicate.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Typehandlers/SingleClassTypeHandlerPredicate.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Typehandlers/SingleClassTypeHandlerPredicate.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,26 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using Db4objects.Db4o.Reflect; +using Db4objects.Db4o.Typehandlers; + +namespace Db4objects.Db4o.Typehandlers +{ + /// allows installing a Typehandler for a single class. + /// allows installing a Typehandler for a single class. + public sealed class SingleClassTypeHandlerPredicate : ITypeHandlerPredicate + { + private readonly Type _class; + + public SingleClassTypeHandlerPredicate(Type clazz) + { + _class = clazz; + } + + public bool Match(IReflectClass candidate) + { + IReflectClass reflectClass = candidate.Reflector().ForClass(_class); + return candidate == reflectClass; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Types/IBlob.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Types/IBlob.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Types/IBlob.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Types/IBlob.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,131 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Types; + +namespace Db4objects.Db4o.Types +{ + /// + /// the db4o Blob type to store blobs independent of the main database + /// file and allows to perform asynchronous upload and download operations. + /// + /// + /// the db4o Blob type to store blobs independent of the main database + /// file and allows to perform asynchronous upload and download operations. + ///

+ /// Usage:
+ /// - Define Blob fields on your user classes.
+ /// - As soon as an object of your class is stored, db4o automatically + /// takes care that the Blob field is set.
+ /// - Call readFrom to read a blob file into the db4o system.
+ /// - Call writeTo to write a blob file from within the db4o system.
+ /// - getStatus may help you to determine, whether data has been + /// previously stored. It may also help you to track the completion + /// of the current process. + ///

+ /// db4o client/server carries out all blob operations in a separate + /// thread on a specially dedicated socket. One socket is used for + /// all blob operations and operations are queued. Your application + /// may continue to access db4o while a blob is transferred in the + /// background. + ///
+ public interface IBlob : IDb4oType + { + /// returns the name of the file the blob was stored to. + /// + /// returns the name of the file the blob was stored to. + ///

The method may return null, if the file was never + /// stored. + ///
+ /// String the name of the file. + string GetFileName(); + + /// returns the status after the last read- or write-operation. + /// + /// returns the status after the last read- or write-operation. + ///

The status value returned may be any of the following:
+ /// Db4objects.Db4o.Ext.Status.Unused + /// no data was ever stored to the Blob field.
+ /// Db4objects.Db4o.Ext.Status.Available + /// + /// available data was previously stored to the Blob field.
+ /// Db4objects.Db4o.Ext.Status.Queued + /// an operation was triggered and is waiting for it's turn in the Blob queue.
+ /// Db4objects.Db4o.Ext.Status.Completed + /// + /// the last operation on this field was completed successfully.
+ /// Db4objects.Db4o.Ext.Status.Processing + /// + /// for internal use only.
+ /// Db4objects.Db4o.Ext.Status.Error + /// the last operation failed.
+ /// or a double between 0 and 1 that signifies the current completion percentage of the currently + /// running operation.

the five + /// Db4objects.Db4o.Ext.Status + /// constants defined in this interface or a double + /// between 0 and 1 that signifies the completion of the currently running operation.

+ ///
+ /// status - the current status + /// constants + double GetStatus(); + + /// reads a file into the db4o system and stores it as a blob. + /// + /// reads a file into the db4o system and stores it as a blob. + ///

+ /// In Client/Server mode db4o will open an additional socket and + /// process writing data in an additional thread. + ///

+ ///
+ /// the file the blob is to be read from. + /// in case of errors + void ReadFrom(Sharpen.IO.File file); + + /// reads a file into the db4o system and stores it as a blob. + /// + /// reads a file into the db4o system and stores it as a blob. + ///

+ /// db4o will use the local file system in Client/Server mode also. + ///

+ ///
+ /// the file the blob is to be read from. + /// in case of errors + void ReadLocal(Sharpen.IO.File file); + + /// writes stored blob data to a file. + /// + /// writes stored blob data to a file. + ///

+ /// db4o will use the local file system in Client/Server mode also. + ///

+ ///
+ /// + /// in case of errors and in case no blob + /// data was stored + /// + /// the file the blob is to be written to. + void WriteLocal(Sharpen.IO.File file); + + /// writes stored blob data to a file. + /// + /// writes stored blob data to a file. + ///

+ /// In Client/Server mode db4o will open an additional socket and + /// process writing data in an additional thread. + ///

+ ///
+ /// + /// in case of errors and in case no blob + /// data was stored + /// + /// the file the blob is to be written to. + void WriteTo(Sharpen.IO.File file); + + /// Deletes the current file stored in this BLOB. + /// Deletes the current file stored in this BLOB. + /// + /// in case of errors and in case no + /// data was stored + /// + void DeleteFile(); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Types/IDb4oType.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Types/IDb4oType.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Types/IDb4oType.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Types/IDb4oType.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,10 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +namespace Db4objects.Db4o.Types +{ + /// marker interface for all special db4o types. + /// marker interface for all special db4o types. + public interface IDb4oType + { + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Types/ITransientClass.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Types/ITransientClass.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Types/ITransientClass.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Types/ITransientClass.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,10 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +namespace Db4objects.Db4o.Types +{ + /// Marker interface to denote that a class should not be stored by db4o. + /// Marker interface to denote that a class should not be stored by db4o. + public interface ITransientClass + { + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Types/IUnversioned.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Types/IUnversioned.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Types/IUnversioned.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/Types/IUnversioned.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,13 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +namespace Db4objects.Db4o.Types +{ + /// + /// marker interface to denote that version numbers and UUIDs should + /// not be generated for a class that implements this interface + /// + /// + public interface IUnversioned + { + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/User.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/User.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/User.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o/User.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,25 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o; + +namespace Db4objects.Db4o +{ + /// + /// + public class User : IInternal4 + { + public string name; + + public string password; + + public User() + { + } + + public User(string name_, string password_) + { + name = name_; + password = password_; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o-2008.csproj smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o-2008.csproj --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o-2008.csproj 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Db4objects.Db4o-2008.csproj 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,1046 @@ + + + + Debug + AnyCPU + 9.0.30729 + 2.0 + {600CD3BF-2ED2-4183-87F7-ADD78A968AE0} + Library + Properties + Db4objects.Db4o + Db4objects.Db4o + v3.5 + 512 + + + + + + + + + + + + + + + + + + + + + + +true +../db4objects.snk + + + true + full + false + bin\Debug\ + TRACE;DEBUG;NET_3_5 + prompt + 4 + bin\Debug\Db4objects.Db4o.xml + 1591;1572;1573;1574;0419; + + + full + true + bin\Release\ + TRACE;NET_3_5 + prompt + 4 + 1591;1572;1573;1574;0419; + bin\Release\Db4objects.Db4o.xml + true + + + + + 3.5 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/compact/Lock4.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/compact/Lock4.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/compact/Lock4.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/compact/Lock4.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,121 @@ +/* Copyright (C) 2009 Versant Inc. http://www.db4o.com */ + +using System; +using System.Threading; + +namespace Db4objects.Db4o.Foundation +{ +#if CF + public class Lock4 + { + private volatile Thread lockedByThread; + + private volatile Thread waitReleased; + private volatile Thread closureReleased; + + readonly AutoResetEvent waitEvent = new AutoResetEvent(false); + readonly AutoResetEvent closureEvent = new AutoResetEvent(false); + + public void Awake() + { + AwakeWait(); + } + + public Object Run(IClosure4 closure4) + { + EnterClosure(); + try + { + return closure4.Run(); + } + finally + { + AwakeClosure(); + } + } + + public void Snooze(long timeout) + { + AwakeClosure(); + WaitWait(timeout); + EnterClosure(); + } + + private void EnterClosure() + { + while (lockedByThread != Thread.CurrentThread) + { + while (!SetLock()) + { + WaitClosure(); + } + } + } + + private void AwakeClosure() + { + lock (this) + { + RemoveLock(); + closureReleased = Thread.CurrentThread; + closureEvent.Set(); + Thread.Sleep(0); + if (closureReleased == Thread.CurrentThread) + { + closureEvent.Reset(); + } + } + } + + private void AwakeWait() + { + lock (this) + { + waitReleased = Thread.CurrentThread; + waitEvent.Set(); + Thread.Sleep(0); + if (waitReleased == Thread.CurrentThread) + { + waitEvent.Reset(); + } + } + } + + private void WaitWait(long timeout) + { + waitEvent.WaitOne((int) timeout, false); + waitReleased = Thread.CurrentThread; + } + + private void WaitClosure() + { + closureEvent.WaitOne(); + closureReleased = Thread.CurrentThread; + } + + private bool SetLock() + { + lock (this) + { + if (lockedByThread == null) + { + lockedByThread = Thread.CurrentThread; + return true; + } + return false; + } + } + + private void RemoveLock() + { + lock (this) + { + if (lockedByThread == Thread.CurrentThread) + { + lockedByThread = null; + } + } + } + } +#endif +} \ No newline at end of file diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Collections/ActivatableDictionary.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Collections/ActivatableDictionary.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Collections/ActivatableDictionary.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Collections/ActivatableDictionary.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,320 @@ +/* Copyright (C) 2010 Versant Inc. http://www.db4o.com */ +using System; +using System.Collections; +using System.Collections.Generic; + +#if !CF && !SILVERLIGHT +using System.Reflection; +using System.Runtime.Serialization; +#endif + +using Db4objects.Db4o.Internal.Activation; + +namespace Db4objects.Db4o.Collections +{ + [Serializable] + public class ActivatableDictionary : + ActivatableBase, + IDictionary, + IDictionary +#if !CF && !SILVERLIGHT + ,ISerializable + ,IDeserializationCallback +#endif + { + public ActivatableDictionary() + { + } + + public ActivatableDictionary(IEqualityComparer comparer) + { + _dictionary = new Dictionary(comparer); + } + + public ActivatableDictionary(IDictionary dictionary, IEqualityComparer comparer) + { + _dictionary = new Dictionary(dictionary, comparer); + } + + public ActivatableDictionary(IDictionary dictionary) + { + _dictionary = new Dictionary(dictionary); + } + + public ActivatableDictionary(int capacity) + { + _dictionary = new Dictionary(capacity); + } + + public ActivatableDictionary(int capacity, IEqualityComparer comparer) + { + _dictionary = new Dictionary(capacity, comparer); + } + +#if !CF && !SILVERLIGHT + protected ActivatableDictionary(SerializationInfo info, StreamingContext context) + { + Type type = typeof(Dictionary); + ConstructorInfo ctor = type.GetConstructor(BindingFlags.NonPublic | BindingFlags.Instance, null, new Type[] { typeof(SerializationInfo), typeof(StreamingContext) }, null); + + _dictionary = (IDictionary)ctor.Invoke(new object[] { info, context }); + } +#endif + + #region Implementation of IEnumerable + + public IEnumerator> GetEnumerator() + { + ActivateForRead(); + return _dictionary.GetEnumerator(); + } + + public void Remove(object key) + { + Remove((TKey) key); + } + + object IDictionary.this[object key] + { + get { return this[(TKey) key]; } + set { this[(TKey) key] = (TValue) value; } + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } + + #endregion + + #region Implementation of ICollection> + + public void Add(KeyValuePair item) + { + ActivateForWrite(); + _dictionary.Add(item); + } + + public bool Contains(object key) + { + return ContainsKey( (TKey) key); + } + + public void Add(object key, object value) + { + Add( (TKey) key, (TValue) value); + } + + public void Clear() + { + ActivateForWrite(); + _dictionary.Clear(); + } + + IDictionaryEnumerator IDictionary.GetEnumerator() + { + ActivateForRead(); + return Cast().GetEnumerator(); + } + + public bool Contains(KeyValuePair item) + { + ActivateForRead(); + return _dictionary.Contains(item); + } + + public void CopyTo(KeyValuePair[] array, int arrayIndex) + { + ActivateForRead(); + _dictionary.CopyTo(array, arrayIndex); + } + + public bool Remove(KeyValuePair item) + { + ActivateForWrite(); + return _dictionary.Remove(item); + } + + public void CopyTo(Array array, int index) + { + ActivateForRead(); + Cast().CopyTo(array, index); + } + + public int Count + { + get + { + ActivateForRead(); + return _dictionary.Count; + } + } + + public object SyncRoot + { + get + { + return Cast().SyncRoot; + } + } + + public bool IsSynchronized + { + get + { + return Cast().IsSynchronized; + } + } + + ICollection IDictionary.Values + { + get { return Values; } + } + + public bool IsReadOnly + { + get + { + return _dictionary.IsReadOnly; + } + } + + public bool IsFixedSize + { + get + { + return Cast().IsFixedSize; + } + } + + #endregion + + #region Implementation of IDictionary + + public bool ContainsKey(TKey key) + { + ActivateForRead(); + return _dictionary.ContainsKey(key); + } + + public void Add(TKey key, TValue value) + { + ActivateForWrite(); + _dictionary.Add(key, value); + } + + public bool Remove(TKey key) + { + ActivateForWrite(); + return _dictionary.Remove(key); + } + + public bool TryGetValue(TKey key, out TValue value) + { + ActivateForRead(); + return _dictionary.TryGetValue(key, out value); + } + + public TValue this[TKey key] + { + get + { + ActivateForRead(); + return _dictionary[key]; + } + + set + { + ActivateForWrite(); + _dictionary[key] = value; + } + } + + public ICollection Keys + { + get + { + ActivateForRead(); + return _dictionary.Keys; + } + } + + ICollection IDictionary.Keys + { + get + { + ActivateForRead(); + return Cast().Keys; + } + } + + ICollection IDictionary.Values + { + get + { + ActivateForRead(); + return _dictionary.Values; + } + } + + #endregion + + #region Dictionary methods + + public Dictionary.ValueCollection Values + { + get + { + ActivateForRead(); + return ((Dictionary) _dictionary).Values; + } + } + + public bool ContainsValue(TValue value) + { + ActivateForRead(); + return Cast>().ContainsValue(value); + } + + public IEqualityComparer Comparer + { + get + { + return Cast>().Comparer; + } + } + + #endregion + +#if !CF && !SILVERLIGHT + #region Implementation of ISerializable + +#if NET_4_0 + [System.Security.SecurityCritical] +#endif + public void GetObjectData(SerializationInfo info, StreamingContext context) + { + ActivateForRead(); + Cast().GetObjectData(info, context); + } + + #endregion + + #region Implementation of IDeserializationCallback + + public void OnDeserialization(object sender) + { + Cast().OnDeserialization(sender); + } + + #endregion +#endif + + private T Cast() + { + return (T)_dictionary; + } + + private readonly IDictionary _dictionary = new Dictionary(); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Collections/ActivatableList.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Collections/ActivatableList.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Collections/ActivatableList.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Collections/ActivatableList.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,385 @@ +/* Copyright (C) 2010 Versant Inc. http://www.db4o.com */ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using Db4objects.Db4o.Activation; +using Db4objects.Db4o.Internal.Activation; + +namespace Db4objects.Db4o.Collections +{ + public class ActivatableList : ActivatableBase, IList, IActivatableCollection + { + public ActivatableList() + { + } + + public ActivatableList(IEnumerable source) + { + _list = new List(source); + } + + public ActivatableList(int capacity) + { + _list = new List(capacity); + } + + public ReadOnlyCollection AsReadOnly() + { + ActivateForRead(); + return AsList().AsReadOnly(); + } + + public IEnumerator GetEnumerator() + { + Activate(ActivationPurpose.Read); + return _list.GetEnumerator(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } + + public void Add(T item) + { + ActivateForWrite(); + AsList().Add(item); + } + + public void AddRange(IEnumerable collection) + { + ActivateForWrite(); + AsList().AddRange(collection); + } + + public int BinarySearch(T item) + { + ActivateForRead(); + return AsList().BinarySearch(item); + } + + public int BinarySearch(int index, int count, T item, IComparer comparer) + { + ActivateForRead(); + return AsList().BinarySearch(index, count, item, comparer); + } + + public int BinarySearch(T item, IComparer comparer) + { + ActivateForRead(); + return AsList().BinarySearch(item, comparer); + } + + public void Clear() + { + ActivateForWrite(); + AsList().Clear(); + } + + public bool Contains(T item) + { + ActivateForRead(); + return AsList().Contains(item); + } + + public void CopyTo(T[] array, int arrayIndex) + { + ActivateForRead(); + AsList().CopyTo(array, arrayIndex); + } + + public void CopyTo(T[] array) + { + ActivateForRead(); + AsList().CopyTo(array); + } + + public void CopyTo(int index, T[] array, int arrayIndex, int count) + { + ActivateForRead(); + AsList().CopyTo(index, array, arrayIndex, count); + } + + public override bool Equals(object obj) + { + ActivateForRead(); + return AsList().Equals(obj); + } + +#if !SILVERLIGHT + public bool Exists(Predicate match) + { + ActivateForRead(); + return AsList().Exists(match); + } + + public T Find(Predicate match) + { + ActivateForRead(); + return AsList().Find(match); + } + + public List FindAll(Predicate match) + { + ActivateForRead(); + return AsList().FindAll(match); + } + + public int FindIndex(Predicate match) + { + ActivateForRead(); + return AsList().FindIndex(match); + } + + public int FindIndex(int startIndex, Predicate match) + { + ActivateForRead(); + return AsList().FindIndex(startIndex, match); + } + + public int FindIndex(int startIndex, int count, Predicate match) + { + ActivateForRead(); + return AsList().FindIndex(startIndex, count, match); + } + + public T FindLast(Predicate match) + { + ActivateForRead(); + return AsList().FindLast(match); + } + + public int FindLastIndex(Predicate match) + { + ActivateForRead(); + return AsList().FindLastIndex(match); + } + + public int FindLastIndex(int startIndex, Predicate match) + { + ActivateForRead(); + return AsList().FindLastIndex(startIndex, match); + } + + public int FindLastIndex(int startIndex, int count, Predicate match) + { + ActivateForRead(); + return AsList().FindLastIndex(startIndex, count, match); + } +#endif + + public void ForEach(Action action) + { + ActivateForRead(); + AsList().ForEach(action); + } + + public List GetRange(int index, int count) + { + ActivateForRead(); + return AsList().GetRange(index, count); + } + + public int IndexOf(T item) + { + ActivateForRead(); + return AsList().IndexOf(item); + } + + public int IndexOf(T item, int index) + { + ActivateForRead(); + return AsList().IndexOf(item, index); + } + + public int IndexOf(T item, int index, int count) + { + ActivateForRead(); + return AsList().IndexOf(item, index, count); + } + + public void InsertRange(int index, IEnumerable collection) + { + ActivateForWrite(); + AsList().InsertRange(index, collection); + } + + public int LastIndexOf(T item) + { + ActivateForRead(); + return AsList().LastIndexOf(item); + } + + public int LastIndexOf(T item, int index) + { + ActivateForRead(); + return AsList().LastIndexOf(item, index); + } + + public int LastIndexOf(T item, int index, int count) + { + ActivateForRead(); + return AsList().LastIndexOf(item, index, count); + } + +#if !SILVERLIGHT + public int RemoveAll(Predicate match) + { + ActivateForWrite(); + return AsList().RemoveAll(match); + } +#endif + + public void RemoveRange(int index, int count) + { + ActivateForWrite(); + AsList().RemoveRange(index, count); + } + + public void Reverse() + { + ActivateForWrite(); + AsList().Reverse(); + } + + public void Reverse(int index, int count) + { + ActivateForWrite(); + AsList().Reverse(index, count); + } + + public void Sort() + { + ActivateForWrite(); + AsList().Sort(); + } + + public void Sort(IComparer comparer) + { + ActivateForWrite(); + AsList().Sort(comparer); + } + + public void Sort(int index, int count, IComparer comparer) + { + ActivateForWrite(); + AsList().Sort(index, count, comparer); + } + + public void Sort(Comparison comparison) + { + ActivateForWrite(); + AsList().Sort(comparison); + } + + public T[] ToArray() + { + ActivateForRead(); + return AsList().ToArray(); + } + + public void TrimExcess() + { + ActivateForWrite(); + AsList().TrimExcess(); + } + +#if !SILVERLIGHT + public bool TrueForAll(Predicate match) + { + ActivateForRead(); + return AsList().TrueForAll(match); + } + + public List ConvertAll(Converter converter) + { + ActivateForRead(); + return AsList().ConvertAll(converter); + } +#endif + + public bool Remove(T item) + { + ActivateForWrite(); + return AsList().Remove(item); + } + + public int Count + { + get + { + ActivateForRead(); + return AsList().Count; + } + } + + public int Capacity + { + get + { + ActivateForRead(); + return AsList().Capacity; + } + + set + { + ActivateForWrite(); + AsList().Capacity = value; + } + } + + public bool IsReadOnly + { + get + { + ActivateForRead(); + return AsIList().IsReadOnly; + } + } + + public void Insert(int index, T item) + { + ActivateForWrite(); + AsList().Insert(index, item); + } + + public void RemoveAt(int index) + { + ActivateForWrite(); + AsList().RemoveAt(index); + } + + public T this[int index] + { + get + { + ActivateForRead(); + return AsList()[index]; + } + + set + { + ActivateForWrite(); + AsList()[index] = value; + } + } + + private List AsList() + { + if (_list == null) + { + _list = new List(); + } + + return _list; + } + + private IList AsIList() + { + return AsList(); + } + + private List _list; + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Collections/ArrayDictionary4.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Collections/ArrayDictionary4.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Collections/ArrayDictionary4.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Collections/ArrayDictionary4.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,170 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using Db4objects.Db4o.Activation; +using Db4objects.Db4o.TA; + +namespace Db4objects.Db4o.Collections +{ + public partial class ArrayDictionary4 : IDictionary, IActivatable + { + public bool IsReadOnly + { + get { return false; } + } + + void ICollection>.Add(KeyValuePair item) + { + Add(item.Key, item.Value); + } + + public void Add(K key, V value) + { + Activate(ActivationPurpose.Read); + int index = IndexOfKey(key); + if (index != -1) + { + throw new ArgumentException(string.Format("Key {0} already exists", key)); + } + Activate(ActivationPurpose.Write); + Insert(key, value); + } + + public bool Remove(K key) + { + Activate(ActivationPurpose.Read); + int index = IndexOfKey(key); + if (index == -1) return false; + + Delete(index); + return true; + } + + bool ICollection>.Contains(KeyValuePair pair) + { + Activate(ActivationPurpose.Read); + int index = IndexOfKey(pair.Key); + if (index == -1) return false; + + KeyValuePair thisKeyValuePair = new KeyValuePair(pair.Key, ValueAt(index)); + return EqualityComparer>.Default.Equals(thisKeyValuePair, pair); + } + + void ICollection>.CopyTo(KeyValuePair[] array, int arrayIndex) + { + if (array == null) throw new ArgumentNullException(); + if (arrayIndex < 0) throw new ArgumentOutOfRangeException(); + if (arrayIndex >= array.Length || Count > (array.Length - arrayIndex)) throw new ArgumentException(); + + for (int i = 0; i < Count; i++) + { + KeyValuePair keyValuePair = new KeyValuePair(KeyAt(i), ValueAt(i)); + array[arrayIndex + i] = keyValuePair; + } + } + + bool ICollection>.Remove(KeyValuePair pair) + { + if (!((ICollection>)this).Contains(pair)) return false; + + return Remove(pair.Key); + } + + public bool TryGetValue(K key, out V value) + { + Activate(ActivationPurpose.Read); + int index = IndexOfKey(key); + if (index == -1) + { + value = default(V); + return false; + } + value = ValueAt(index); + return true; + } + + public V this[K key] + { + get + { + Activate(ActivationPurpose.Read); + int index = IndexOfKey(key); + if (index == -1) throw new KeyNotFoundException(); + return ValueAt(index); + } + set + { + Activate(ActivationPurpose.Read); + int index = IndexOfKey(key); + if (index == -1) + { + Add(key, value); + } + else + { + Activate(ActivationPurpose.Write); + Replace(index, value); + } + } + } + + public ICollection Keys + { + get + { + Activate(ActivationPurpose.Read); + K[] keys = new K[_size]; + Array.Copy(_keys, keys, _size); + return keys; + } + } + + public bool ContainsKey(K key) + { + return ContainsKeyImpl(key); + } + + public IEnumerator> GetEnumerator() + { + Activate(ActivationPurpose.Read); + for (int i = 0; i < _size; ++i) + { + yield return new KeyValuePair(KeyAt(i), ValueAt(i)); + } + } + + IEnumerator IEnumerable.GetEnumerator() + { + return ((IEnumerable>)this).GetEnumerator(); + } + + private int IndexOfKey(K key) + { + if (key == null) throw new ArgumentNullException(); + return Array.IndexOf(_keys, key); + } + + #region Sharpen Helpers + private static K DefaultKeyValue() + { + return default(K); + } + + private static V DefaultValue() + { + return default(V); + } + + private static K[] AllocateKeyStorage(int length) + { + return new K[length]; + } + + private static V[] AllocateValueStorage(int length) + { + return new V[length]; + } + + #endregion + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Collections/ArrayList4.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Collections/ArrayList4.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Collections/ArrayList4.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Collections/ArrayList4.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,299 @@ +/* Copyright (C) 2009 Versant Inc. http://www.db4o.com */ + +#if !SILVERLIGHT + +using System; +using System.Collections; +using System.Collections.Generic; +using Db4objects.Db4o.Activation; +using Db4objects.Db4o.TA; + +namespace Db4objects.Db4o.Collections +{ + public partial class ArrayList4 : IList, IList, IActivatable + { + #region Instance Variables + + [NonSerialized] + private int modCount; + + #endregion + + public int IndexOf(E item) + { + return Array.IndexOf(GetElements(), item, 0, listSize); + } + + public void Insert(int index, E item) + { + Add(index, item); + } + + public int Add(object value) + { + CheckObjectType(value); + Add((E) value); + return Count - 1; + } + + public bool Contains(object value) + { + CheckObjectType(value); + return IndexOf(value) != -1; + } + + public int IndexOf(object value) + { + CheckObjectType(value); + IList self = this; + return self.IndexOf((E) value); + } + + public void Insert(int index, object value) + { + CheckObjectType(value); + Insert(index, (E) value); + } + + public void Remove(object value) + { + CheckObjectType(value); + Remove((E)value); + } + + public void RemoveAt(int index) + { + RemoveImpl(index); + } + + object IList.this[int index] + { + get { return Get(index); } + set { Set(index, (E) value); } + } + + public E this[int index] + { + get { return Get(index); } + set { Set(index, value); } + } + + public void Add(E item) + { + Add(Count, item); + } + + public bool Contains(E item) + { + return Contains((object) item); + } + + public void CopyTo(E[] array, int arrayIndex) + { + CopyTo((Array) array, arrayIndex); + } + + public bool Remove(E item) + { + int index = IndexOf(item); + if (index == -1) return false; + + RemoveAt(index); + return true; + } + + public void CopyTo(Array array, int index) + { + if (null == array) throw new ArgumentNullException(); + if (array.Rank != 1) throw new ArgumentException(); + + Array.Copy(GetElements(), 0, array, index, listSize); + } + + public object SyncRoot + { + get { throw new NotSupportedException(); } + } + + public bool IsSynchronized + { + get { return false; } + } + + public bool IsReadOnly + { + get { return false; } + } + + public bool IsFixedSize + { + get { return false; } + } + + public IEnumerator GetEnumerator() + { + Activate(ActivationPurpose.Read); + int version = modCount; + int size = listSize; + for (int i = 0; i < size; ++i) + { + if (version != modCount) + { + throw new InvalidOperationException(); + } + + yield return elements[i]; + }; + } + + IEnumerator IEnumerable.GetEnumerator() + { + return ((IEnumerable) this).GetEnumerator(); + } + + public override string ToString() + { + return String.Format("ArrayList4<{0}> (Count={1})", typeof(E).Name, Count); + } + + #region Facility methods + + public void AddRange(IEnumerable collection) + { + } + + public int BinarySearch(E item) + { + return Array.BinarySearch(GetElements(), item); + } + + public int BinarySearch(E item, IComparer comparer) + { + return Array.BinarySearch(GetElements(), item, comparer); + } + + public int BinarySearch(int index, int count, E item, IComparer comparer) + { + return Array.BinarySearch(GetElements(), index, count, item, comparer); + } + + #if !CF + + public ArrayList4 ConvertAll(Converter converter) + { + return new ArrayList4(Array.ConvertAll(GetElements(), converter)); + } + + public bool Exists(Predicate match) + { + return Array.Exists(GetElements(), match); + } + + public E Find(Predicate match) + { + return Array.Find(GetElements(), match); + } + + public ArrayList4 FindAll(Predicate match) + { + return new ArrayList4(Array.FindAll(GetElements(), match)); + } + + public int FindIndex(int startIndex, int count, Predicate match) + { + return Array.FindIndex(GetElements(), startIndex, count, match); + } + + public E FindLast(Predicate match) + { + return Array.FindLast(GetElements(), match); + } + + public int FindLastIndex(int startIndex, int count, Predicate match) + { + return Array.FindLastIndex(GetElements(), startIndex, count, match); + } + + public void ForEach(Action action) + { + Array.ForEach(GetElements(), action); + } + + #endif + + public void InsertRange(int index, IEnumerable collection) + { + AddAllImpl(index, new List(collection).ToArray()); + } + + public void RemoveRange(int index, int count) + { + RemoveRangeImpl(index, count); + } + + public void Sort(int index, int count, IComparer comparer) + { + Array.Sort(GetElements(), index, count, comparer); + } + + public E[] ToArray() + { + E[] items = GetElements(); + return items == null ? items : (E[]) items.Clone(); + } + + public bool TrueForAll(Predicate match) + { + return Array.TrueForAll(GetElements(), match); + } + + #endregion + + #region Sharpen Helper Methods + + private static E[] CollectionToArray(ICollection coll) + { + return new List(coll).ToArray(); + } + + internal static void CheckIndex(int index, int from, int to) + { + if (index < from || index > to) + { + throw new ArgumentOutOfRangeException(String.Format("Index {0} must be in the range[{1} - {2}]", index, from, to)); + } + } + + private static E[] AllocateStorage(int size) + { + return new E[size]; + } + + private static E DefaultValue() + { + return default(E); + } + + #endregion + + #region Helper Methods + + private static void CheckObjectType(object value) + { + if (!(value is E)) + { + throw new ArgumentException(); + } + } + + private E[] GetElements() + { + Activate(ActivationPurpose.Read); + return elements; + } + + #endregion + } +} + +#endif diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Collections/IActivatableCollection.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Collections/IActivatableCollection.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Collections/IActivatableCollection.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Collections/IActivatableCollection.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,10 @@ +/* Copyright (C) 2010 Versant Inc. http://www.db4o.com */ +using System.Collections.Generic; +using Db4objects.Db4o.TA; + +namespace Db4objects.Db4o.Collections +{ + public interface IActivatableCollection : ICollection, IActivatable + { + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Collections/ISet.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Collections/ISet.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Collections/ISet.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Collections/ISet.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,13 @@ +/* Copyright (C) 2010 Versant Inc. http://www.db4o.com */ +using System.Collections.Generic; + +namespace Db4objects.Db4o.Collections +{ + public interface ISet : ICollection + { + bool IsEmpty { get; } + bool AddAll(IEnumerable ts); + bool RemoveAll(IEnumerable ts); + bool ContainsAll(IEnumerable ts); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Config/Attributes/ConfigurationIntrospector.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Config/Attributes/ConfigurationIntrospector.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Config/Attributes/ConfigurationIntrospector.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Config/Attributes/ConfigurationIntrospector.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,66 @@ +/* Copyright (C) 2006 Versant Inc. http://www.db4o.com */ + +using System; +using System.Reflection; + +using Db4objects.Db4o.Internal; + +namespace Db4objects.Db4o.Config.Attributes +{ + class ConfigurationIntrospector + { + private readonly Type _type; + private Config4Class _classConfig; + private readonly IConfiguration _config; + + public ConfigurationIntrospector(Type type, Config4Class classConfig, IConfiguration config) + { + if (null == type) throw new ArgumentNullException("type"); + if (null == config) throw new ArgumentNullException("config"); + _type = type; + _classConfig = classConfig; + _config = config; + } + + public Type Type + { + get { return _type; } + } + + public Config4Class ClassConfiguration + { + get + { + if (null == _classConfig) + { + _classConfig = (Config4Class)_config.ObjectClass(_type); + } + return _classConfig; + } + } + + public IConfiguration IConfiguration + { + get { return _config; } + } + + public void Apply() + { + Apply(_type); + foreach (FieldInfo field in _type.GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance)) + Apply(field); + } + + private void Apply(ICustomAttributeProvider provider) + { + foreach (object o in provider.GetCustomAttributes(false)) + { + IDb4oAttribute attr = o as IDb4oAttribute; + if (null == attr) + continue; + + attr.Apply(provider, this); + } + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Config/Attributes/IDb4oAttribute.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Config/Attributes/IDb4oAttribute.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Config/Attributes/IDb4oAttribute.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Config/Attributes/IDb4oAttribute.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,11 @@ +/* Copyright (C) 2006 Versant Inc. http://www.db4o.com */ + +using System; + +namespace Db4objects.Db4o.Config.Attributes +{ + interface IDb4oAttribute + { + void Apply (object subject, ConfigurationIntrospector introspector); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Config/Attributes/IndexedAttribute.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Config/Attributes/IndexedAttribute.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Config/Attributes/IndexedAttribute.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Config/Attributes/IndexedAttribute.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,17 @@ +/* Copyright (C) 2006 Versant Inc. http://www.db4o.com */ + +using System; +using System.Reflection; + +namespace Db4objects.Db4o.Config.Attributes +{ + [AttributeUsage(AttributeTargets.Field)] + public class IndexedAttribute : Attribute, IDb4oAttribute + { + void IDb4oAttribute.Apply(object subject, ConfigurationIntrospector introspector) + { + FieldInfo field = (FieldInfo)subject; + introspector.ClassConfiguration.ObjectField(field.Name).Indexed(true); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Config/TClass.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Config/TClass.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Config/TClass.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Config/TClass.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,10 @@ +/* Copyright (C) 2004 Versant Inc. http://www.db4o.com */ + +using System; +using Sharpen.Lang; +using Db4objects.Db4o; + +namespace Db4objects.Db4o.Config +{ + +} \ No newline at end of file diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Config/TCultureInfo.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Config/TCultureInfo.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Config/TCultureInfo.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Config/TCultureInfo.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,33 @@ +/* Copyright (C) 2004 Versant Inc. http://www.db4o.com */ + +using System; +using System.Globalization; +using Sharpen.Lang; +using Db4objects.Db4o; + +namespace Db4objects.Db4o.Config +{ + /// + public class TCultureInfo : IObjectConstructor + { + public Object OnInstantiate(IObjectContainer store, object stored) + { + return new CultureInfo((string)stored); + } + + public Object OnStore(IObjectContainer store, object obj) + { + CultureInfo culture = (CultureInfo)obj; + return culture.Name; + } + + public void OnActivate(IObjectContainer container, object applicationObject, object storedObject) + { + } + + public Type StoredClass() + { + return typeof(string); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Config/TDictionary.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Config/TDictionary.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Config/TDictionary.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Config/TDictionary.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,44 @@ +/* Copyright (C) 2004 Versant Inc. http://www.db4o.com */ + +using System; +using System.Collections; +using Sharpen.Lang; +using Db4objects.Db4o; + +namespace Db4objects.Db4o.Config { + + /// + public class TDictionary : IObjectTranslator { + + public void OnActivate(IObjectContainer objectContainer, object obj, object members){ + IDictionary dict = (IDictionary)obj; + dict.Clear(); + if(members != null){ + Entry[] entries = (Entry[]) members; + for(int i = 0; i < entries.Length; i++){ + if(entries[i].key != null && entries[i].value != null){ + dict[entries[i].key] = entries[i].value; + } + } + } + } + + public Object OnStore(IObjectContainer objectContainer, object obj){ + IDictionary dict = (IDictionary)obj; + Entry[] entries = new Entry[dict.Count]; + IDictionaryEnumerator e = dict.GetEnumerator(); + e.Reset(); + for(int i = 0; i < dict.Count; i++){ + e.MoveNext(); + entries[i] = new Entry(); + entries[i].key = e.Key; + entries[i].value = e.Value; + } + return entries; + } + + public System.Type StoredClass(){ + return typeof(Entry[]); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Config/TList.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Config/TList.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Config/TList.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Config/TList.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,37 @@ +/* Copyright (C) 2004 Versant Inc. http://www.db4o.com */ + +using System; +using System.Collections; +using Sharpen.Lang; +using Db4objects.Db4o; + +namespace Db4objects.Db4o.Config { + + /// + public class TList : IObjectTranslator { + + public void OnActivate(IObjectContainer objectContainer, object obj, object members){ + IList list = (IList)obj; + list.Clear(); + if(members != null){ + object[] elements = (object[]) members; + for(int i = 0; i < elements.Length; i++){ + list.Add(elements[i]); + } + } + } + + public Object OnStore(IObjectContainer objectContainer, object obj){ + IList list = (IList)obj; + object[] elements = new object[list.Count]; + for(int i = 0; i < list.Count; i++){ + elements[i] = list[i]; + } + return elements; + } + + public System.Type StoredClass(){ + return typeof(object[]); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Config/TQueue.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Config/TQueue.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Config/TQueue.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Config/TQueue.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,49 @@ +/* Copyright (C) 2009 Versant Inc. http://www.db4o.com */ + +#if !SILVERLIGHT + +using System; +using System.Collections; + +namespace Db4objects.Db4o.Config +{ + /// + public class TQueue : IObjectTranslator + { + public void OnActivate(IObjectContainer objectContainer, object obj, object members) + { + Queue queue = (Queue) obj; + queue.Clear(); + if (members != null) + { + object[] elements = (object[])members; + for (int i = 0; i < elements.Length; i++) + { + queue.Enqueue(elements[i]); + } + } + } + + public Object OnStore(IObjectContainer objectContainer, object obj) + { + Queue queue = (Queue)obj; + int count = queue.Count; + object[] elements = new object[count]; + IEnumerator e = queue.GetEnumerator(); + e.Reset(); + for (int i = 0; i < count; i++) + { + e.MoveNext(); + elements[i] = e.Current; + } + return elements; + } + + public System.Type StoredClass() + { + return typeof(object[]); + } + } +} + +#endif \ No newline at end of file diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Config/TStack.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Config/TStack.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Config/TStack.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Config/TStack.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,42 @@ +/* Copyright (C) 2009 Versant Inc. http://www.db4o.com */ + +#if !SILVERLIGHT + +using System; +using System.Collections; + +namespace Db4objects.Db4o.Config { + + /// + public class TStack : IObjectTranslator { + + public void OnActivate(IObjectContainer objectContainer, object obj, object members){ + Stack stack = (Stack)obj; + if(members != null){ + object[] elements = (object[]) members; + for(int i = elements.Length - 1; i >= 0 ; i--){ + stack.Push(elements[i]); + } + } + } + + public Object OnStore(IObjectContainer objectContainer, object obj){ + Stack stack = (Stack)obj; + int count = stack.Count; + object[] elements = new object[count]; + IEnumerator e = stack.GetEnumerator(); + e.Reset(); + for(int i = 0; i < count; i++){ + e.MoveNext(); + elements[i] = e.Current; + } + return elements; + } + + public System.Type StoredClass(){ + return typeof(object[]); + } + } +} + +#endif \ No newline at end of file diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Config/TTransient.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Config/TTransient.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Config/TTransient.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Config/TTransient.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,33 @@ +/* Copyright (C) 2004 Versant Inc. http://www.db4o.com */ + +using System; +using Sharpen.Lang; +using Db4objects.Db4o.Config; + +namespace Db4objects.Db4o.Config +{ + + /// + public class TTransient : IObjectConstructor + { + public void OnActivate(IObjectContainer objectContainer, object obj, object members) + { + } + + public object OnStore(IObjectContainer objectContainer, object obj) + { + return null; + } + + public System.Type StoredClass() + { + return typeof(object); + } + + public object OnInstantiate(IObjectContainer objectContainer, object storedObject) + { + return null; + } + + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Config/TType.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Config/TType.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Config/TType.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Config/TType.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,42 @@ +/* Copyright (C) 2004 Versant Inc. http://www.db4o.com */ + +using System; +using Sharpen.Lang; +using Db4objects.Db4o; + +namespace Db4objects.Db4o.Config +{ + /// + public class TType : IObjectConstructor + { + public void OnActivate(IObjectContainer objectContainer, object obj, object members) + { + } + + public Object OnInstantiate(IObjectContainer objectContainer, object obj) + { + if (obj != null) + { + try + { + return TypeReference.FromString((string) obj).Resolve(); + } + catch + { + } + } + return null; + } + + public Object OnStore(IObjectContainer objectContainer, object obj) + { + if (obj == null) return null; + return TypeReference.FromType((Type)obj).GetUnversionedName(); + } + + public Type StoredClass() + { + return typeof(string); + } + } +} \ No newline at end of file diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Defragment/AvailableTypeFilter.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Defragment/AvailableTypeFilter.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Defragment/AvailableTypeFilter.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Defragment/AvailableTypeFilter.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,21 @@ +/* Copyright (C) 2007 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Ext; + +using System; + +namespace Db4objects.Db4o.Defragment +{ + public class AvailableTypeFilter : IStoredClassFilter + { + + /// StoredClass instance to be checked + /// true, if the given StoredClass instance should be accepted, false otherwise. + /// + public bool Accept(IStoredClass storedClass) + { + return System.Type.GetType(storedClass.GetName(),false)!=null; + } + + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Diagnostic/DiagnosticToTrace.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Diagnostic/DiagnosticToTrace.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Diagnostic/DiagnosticToTrace.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Diagnostic/DiagnosticToTrace.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,28 @@ +/* Copyright (C) 2007 Versant Inc. http://www.db4o.com */ +namespace Db4objects.Db4o.Diagnostic +{ +#if !CF + /// prints Diagnostic messsages to the Console. + /// + /// prints Diagnostic messsages to System.Diagnostics.Trace. + /// Install this + /// Db4objects.Db4o.Diagnostic.IDiagnosticListener + /// + /// with:
+ /// commonConfig.Diagnostic.AddListener(new DiagnosticToTrace());
+ ///
+ /// Db4objects.Db4o.Diagnostic.DiagnosticConfiguration + /// + public class DiagnosticToTrace : Db4objects.Db4o.Diagnostic.IDiagnosticListener + { + /// redirects Diagnostic messages to System.Diagnostics.Trace + /// redirects Diagnostic messages to the Console. + public virtual void OnDiagnostic(Db4objects.Db4o.Diagnostic.IDiagnostic d) + { +#if !SILVERLIGHT + System.Diagnostics.Trace.WriteLine(d.ToString()); +#endif + } + } +#endif +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Dynamic.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Dynamic.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Dynamic.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Dynamic.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,44 @@ +/* Copyright (C) 2004 Versant Inc. http://www.db4o.com */ + +using System; +using System.Reflection; + +namespace Db4objects.Db4o { + + /// + public class Dynamic { + + private const BindingFlags AllMembers = BindingFlags.Static | BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public; + + public static object GetProperty(object obj, string prop){ + if(obj != null){ + Type type = TypeForObject(obj); + try { + PropertyInfo pi = type.GetProperty(prop, AllMembers); + return pi.GetValue(obj,null); + } catch { + } + } + return null; + } + + public static void SetProperty(object obj, string prop, object val){ + if(obj != null){ + Type type = TypeForObject(obj); + try { + PropertyInfo pi = type.GetProperty(prop, AllMembers); + pi.SetValue(obj, val, null); + } catch { + } + } + } + + private static Type TypeForObject(object obj){ + Type type = obj as Type; + if(type != null){ + return type; + } + return obj.GetType(); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Foundation/Closures4.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Foundation/Closures4.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Foundation/Closures4.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Foundation/Closures4.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,28 @@ +/* Copyright (C) 2004 - 2008 Versant Inc. http://www.db4o.com */ +namespace Db4objects.Db4o.Foundation +{ + class Closures4 + { + public delegate object Closure(); + + public static IClosure4 ForDelegate(Closure @delegate) + { + return new Closure4OverDelegate(@delegate); + } + + internal class Closure4OverDelegate : IClosure4 + { + private Closure _delegate; + + public Closure4OverDelegate(Closure @delegate) + { + _delegate = @delegate; + } + + public object Run() + { + return _delegate(); + } + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Foundation/Coercion4.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Foundation/Coercion4.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Foundation/Coercion4.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Foundation/Coercion4.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,72 @@ +/* Copyright (C) 2007 Versant Inc. http://www.db4o.com */ +using System; + +namespace Db4objects.Db4o.Foundation +{ + public class Coercion4 + { + public static object ToByte(object obj) + { + if (obj is byte) return obj; + + IConvertible convertible = obj as IConvertible; + if (null != convertible) return convertible.ToByte(null); + return Db4objects.Db4o.Foundation.No4.Instance; + } + + public static object ToSByte(object obj) + { + if (obj is sbyte) return obj; + + IConvertible convertible = obj as IConvertible; + if (null != convertible) return convertible.ToSByte(null); + return Db4objects.Db4o.Foundation.No4.Instance; + } + + public static object ToShort(object obj) + { + if (obj is short) return obj; + + IConvertible convertible = obj as IConvertible; + if (null != convertible) return convertible.ToInt16(null); + return Db4objects.Db4o.Foundation.No4.Instance; + } + + public static object ToInt(object obj) + { + if (obj is int) return obj; + + IConvertible convertible = obj as IConvertible; + if (null != convertible) return convertible.ToInt32(null); + return Db4objects.Db4o.Foundation.No4.Instance; + } + + public static object ToLong(object obj) + { + if (obj is long) return obj; + + IConvertible convertible = obj as IConvertible; + if (null != convertible) return convertible.ToInt64(null); + return Db4objects.Db4o.Foundation.No4.Instance; + } + + public static object ToFloat(object obj) + { + if (obj is float) return obj; + + IConvertible convertible = obj as IConvertible; + if (null != convertible) return convertible.ToSingle(null); + return Db4objects.Db4o.Foundation.No4.Instance; + } + + public static object ToDouble(object obj) + { + if (obj is double) return obj; + + IConvertible convertible = obj as IConvertible; + if (null != convertible) return convertible.ToDouble(null); + return Db4objects.Db4o.Foundation.No4.Instance; + } + } +} + diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Foundation/Collections/CollectionInitializer.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Foundation/Collections/CollectionInitializer.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Foundation/Collections/CollectionInitializer.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Foundation/Collections/CollectionInitializer.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,277 @@ +/* Copyright (C) 2008 Versant Inc. http://www.db4o.com */ + +using System; +using System.Collections; +using System.Collections.Generic; + +#if CF +using System.Reflection; +#endif + +namespace Db4objects.Db4o.Foundation.Collections +{ + public interface ICollectionInitializer + { + void Clear(); + void Add(object o); + void FinishAdding(); + int Count(); + } + + public sealed class CollectionInitializer + { + private static readonly Dictionary _initializerByType = new Dictionary(); + + static CollectionInitializer() + { + _initializerByType[typeof (ICollection<>)] = typeof (CollectionInitializerImpl<>); + _initializerByType[typeof(Stack<>)] = typeof(StackInitializer<>); + _initializerByType[typeof(Queue<>)] = typeof(QueueInitializer<>); +#if NET_3_5 && ! CF + _initializerByType[typeof (HashSet<>)] = typeof (HashSetInitializer<>); +#endif + } + + public static ICollectionInitializer For(object destination) + { + if (IsNonGenericList(destination)) + { + return new ListInitializer((IList)destination); + } + + return InitializerFor(destination); + } + + private static ICollectionInitializer InitializerFor(object destination) + { + Type destinationType = destination.GetType(); + if (!destinationType.IsGenericType) + { + throw new ArgumentException("Unknown collection: " + destination); + } + + Type containerType = GenericContainerTypeFor(destination); + if (containerType != null) + { + return GetInitializer(destination, _initializerByType[containerType]); + } + + throw new ArgumentException("Unknown collection: " + destination); + } + + private static Type GenericContainerTypeFor(object destination) + { + Type containerType = destination.GetType().GetGenericTypeDefinition(); + while (containerType != null && !_initializerByType.ContainsKey(containerType)) + { + foreach (Type interfaceType in containerType.GetInterfaces()) + { + if (!interfaceType.IsGenericType) + { + continue; + } + + Type genericInterfaceType = interfaceType.GetGenericTypeDefinition(); + if (_initializerByType.ContainsKey(genericInterfaceType)) + { + return genericInterfaceType; + } + } + + containerType = containerType.BaseType; + } + + return containerType; + } + + private static ICollectionInitializer GetInitializer(object destination, Type initializerType) + { + ICollectionInitializer initializer = null; + Type containedElementType = ContainerElementTypeFor(destination); + if (containedElementType != null) + { + Type genericProtocolType = initializerType.MakeGenericType(containedElementType); + initializer = InstantiateInitializer(destination, genericProtocolType); + } + return initializer; + } + + private static bool IsNonGenericList(object destination) + { + return !destination.GetType().IsGenericType && destination is IList; + } + + private static ICollectionInitializer InstantiateInitializer(object destination, Type genericProtocolType) + { +#if !CF + return (ICollectionInitializer) Activator.CreateInstance(genericProtocolType, destination); +#else + ConstructorInfo constructor = genericProtocolType.GetConstructors()[0]; + return (ICollectionInitializer) constructor.Invoke(new object[] {destination}); +#endif + } + + private static Type ContainerElementTypeFor(object destination) + { + Type containerType = destination.GetType(); + return containerType.GetGenericArguments()[0]; + } + + private sealed class ListInitializer : ICollectionInitializer + { + private readonly IList _list; + + public ListInitializer(IList list) + { + _list = list; + } + + public void Clear() + { + _list.Clear(); + } + + public void Add(object o) + { + _list.Add(o); + } + + public int Count() + { + return _list.Count; + } + + public void FinishAdding() + { + } + } + + private sealed class CollectionInitializerImpl : ICollectionInitializer + { + private readonly ICollection _collection; + + public CollectionInitializerImpl(ICollection collection) + { + _collection = collection; + } + + public void Clear() + { + _collection.Clear(); + } + + public int Count() + { + return _collection.Count; + } + + public void Add(object o) + { + _collection.Add((T)o); + } + + public void FinishAdding() + { + } + } + + private sealed class StackInitializer : ICollectionInitializer + { + private readonly Stack _stack; + private readonly Stack _tempStack; + + public StackInitializer(Stack stack) + { + _stack= stack; + _tempStack = new Stack(); + } + + public void Clear() + { + _tempStack.Clear(); + _stack.Clear(); + } + + public int Count() + { + return _stack.Count; + } + + public void Add(object o) + { + _tempStack.Push((T) o); + } + + public void FinishAdding() + { + foreach(T item in _tempStack) + { + _stack.Push(item); + } + + _tempStack.Clear(); + } + } + + private sealed class QueueInitializer : ICollectionInitializer + { + private readonly Queue _queue; + + public QueueInitializer(Queue queue) + { + _queue = queue; + } + + public void Clear() + { + _queue.Clear(); + } + + public int Count() + { + return _queue.Count; + } + + public void Add(object o) + { + _queue.Enqueue((T) o); + } + + public void FinishAdding() + { + } + } + +#if NET_3_5 && ! CF + private sealed class HashSetInitializer : ICollectionInitializer + { + private readonly HashSet _hashSet; + + public HashSetInitializer(HashSet stack) + { + _hashSet = stack; + } + + public void Clear() + { + _hashSet.Clear(); + } + + public void Add(object o) + { + _hashSet.Add((T)o); + } + + public int Count() + { + return _hashSet.Count; + } + + public void FinishAdding() + { + } + } +#endif + + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Foundation/CRC32.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Foundation/CRC32.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Foundation/CRC32.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Foundation/CRC32.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,52 @@ +namespace Db4objects.Db4o.Foundation +{ + public class CRC32 + { + private static uint[] crcTable; + + static CRC32() + { + BuildCRCTable(); + } + + private static void BuildCRCTable() + { + uint Crc32Polynomial = 0xEDB88320; + uint i; + uint j; + uint crc; + crcTable = new uint[256]; + for (i = 0; i <= 255; i++) + { + crc = i; + for (j = 8; j > 0; j--) + { + if ((crc & 1) == 1) + { + crc = ((crc) >> (1 & 0x1f)) ^ Crc32Polynomial; + } + else + { + crc = crc >> (1 & 0x1f); + } + } + crcTable[i] = crc; + } + } + + public static long CheckSum(byte[] buffer, int start, int count) + { + uint temp1; + uint temp2; + int i = start; + uint crc = 0xFFFFFFFF; + while (count-- != 0) + { + temp1 = (crc) >> (8 & 0x1f); + temp2 = crcTable[(crc ^ buffer[i++]) & 0xFF]; + crc = temp1 ^ temp2; + } + return (long)~crc & 0xFFFFFFFFL; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Foundation/Environments.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Foundation/Environments.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Foundation/Environments.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Foundation/Environments.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,30 @@ +/* Copyright (C) 2009 Versant Inc. http://www.db4o.com */ +using System; + +namespace Db4objects.Db4o.Foundation +{ + public partial class Environments + { + public static string DefaultImplementationFor(Type type) + { + string implName = ("." + type.Name.Substring(1) + "Impl"); + if (type.Namespace.IndexOf(".Internal.") > 0) + return type.Namespace + implName + ", " + AssemblyNameFor(type); + + int lastDot = type.Namespace.LastIndexOf('.'); + string typeName = type.Namespace.Substring(0, lastDot) + ".Internal." + type.Namespace.Substring(lastDot + 1) + implName; + return typeName + ", " + AssemblyNameFor(type); + } + + private static string AssemblyNameFor(Type type) + { +#if SILVERLIGHT + string fullyQualifiedTypeName = type.AssemblyQualifiedName; + int assemblyNameSeparator = fullyQualifiedTypeName.IndexOf(','); + return fullyQualifiedTypeName.Substring(assemblyNameSeparator + 1); +#else + return type.Assembly.GetName().Name; +#endif + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Foundation/IO/File4.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Foundation/IO/File4.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Foundation/IO/File4.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Foundation/IO/File4.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,30 @@ +/* Copyright (C) 2004 Versant Inc. http://www.db4o.com */ +#if !SILVERLIGHT +using System; + +using System.IO; + +namespace Db4objects.Db4o.Foundation.IO +{ + public class File4 + { + public static void Delete(string file) + { + if (File.Exists(file)) + { + File.Delete(file); + } + } + + public static void Copy(string from, string to) + { + File.Copy(from, to, true); + } + + public static long Size(string filePath) + { + return new System.IO.FileInfo(filePath).Length; + } + } +} +#endif diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Foundation/Iterators.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Foundation/Iterators.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Foundation/Iterators.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Foundation/Iterators.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,62 @@ +using System.Collections; +using System.Collections.Generic; + +namespace Db4objects.Db4o.Foundation +{ + public delegate B Function(A a); + + public struct Tuple + { + public A a; + public B b; + + public Tuple(A a, B b) + { + this.a = a; + this.b = b; + } + } + + public partial class Iterators + { + public static IEnumerator Map(System.Array array, IFunction4 function) + { + return Map(array.GetEnumerator(), function); + } + + public static IEnumerable Cast(IEnumerable source) + { + foreach (object o in source) yield return (T) o; + } + + public static IEnumerable> Zip(IEnumerable @as, IEnumerable bs) + { + return Zip(Cast(@as), Cast(bs)); + } + + public static IEnumerable> Zip(IEnumerable @as, IEnumerable bs) + { + IEnumerator bsEnumerator = bs.GetEnumerator(); + foreach (A a in @as) + { + if (!bsEnumerator.MoveNext()) + { + yield break; + } + + yield return new Tuple(a, bsEnumerator.Current); + } + } + + public static IEnumerable Unique(IEnumerable enumerable) + { + Hashtable seen = new Hashtable(); + foreach (object item in enumerable) + { + if (seen.ContainsKey(item)) continue; + seen.Add(item, item); + yield return item; + } + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Foundation/My.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Foundation/My.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Foundation/My.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Foundation/My.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,12 @@ +/* Copyright (C) 2009 Versant Inc. http://www.db4o.com */ + +namespace Db4objects.Db4o.Foundation +{ + public class My + { + public static TService Instance + { + get { return (TService)Environments.My(typeof(TService)); } + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Foundation/RunnableAction.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Foundation/RunnableAction.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Foundation/RunnableAction.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Foundation/RunnableAction.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,22 @@ +/* Copyright (C) 2009 Versant Inc. http://www.db4o.com */ +using Sharpen.Lang; + +namespace Db4objects.Db4o.Foundation +{ + public delegate void Action4(); + + public class RunnableAction : IRunnable + { + private readonly Action4 _action; + + public RunnableAction(Action4 action) + { + _action = action; + } + + public void Run() + { + _action(); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Foundation/SignatureGenerator.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Foundation/SignatureGenerator.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Foundation/SignatureGenerator.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Foundation/SignatureGenerator.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,37 @@ +/* Copyright (C) 2007 Versant Inc. http://www.db4o.com */ + +using System; + +namespace Db4objects.Db4o.Foundation +{ + public sealed class SignatureGenerator + { + private static Random _random = new Random(); + + private static int _counter; + + public static string GenerateSignature() { + string signature = ToHexString(Environment.TickCount); + signature += Pad(ToHexString(_random.Next())); + signature += Guid.NewGuid(); + signature += ToHexString(_counter++); + return signature; + } + + private static string ToHexString(int i) + { + return i.ToString("X"); + } + + private static string ToHexString(long l) + { + return l.ToString("X"); + } + + private static string Pad(String str) + { + return (str + "XXXXXXXX").Substring(0, 8); + } + + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Collections/BigSet.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Collections/BigSet.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Collections/BigSet.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Collections/BigSet.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,81 @@ +/* Copyright (C) 2010 Versant Inc. http://www.db4o.com */ +using System.Collections; +using System.Collections.Generic; + +namespace Db4objects.Db4o.Internal.Collections +{ + public partial class BigSet + { + #region Implementation of ICollection + + void ICollection.Add(E item) + { + Add(item); + } + + bool ICollection.Contains(E item) + { + return Contains(item); + } + + void ICollection.CopyTo(E[] array, int arrayIndex) + { + throw new System.NotImplementedException(); + } + + bool ICollection.Remove(E item) + { + return Remove(item); + } + + public bool IsReadOnly + { + get { return false; } + } + + IEnumerator IEnumerable.GetEnumerator() + { + IEnumerator iterator = BTreeIterator(); + while (iterator.MoveNext()) + { + yield return (E)Element((int) iterator.Current); + } + } + + IEnumerator IEnumerable.GetEnumerator() + { + return ((IEnumerable)this).GetEnumerator(); + } + + #endregion + + #region Implementation of ISet + + bool Db4o.Collections.ISet.RemoveAll(IEnumerable es) + { + bool result = false; + foreach (E e in es) + { + if (Remove(e)) + { + result = true; + } + } + return result; + } + + bool Db4o.Collections.ISet.ContainsAll(IEnumerable es) + { + foreach (E e in es) + { + if (!Contains(e)) + { + return false; + } + } + return true; + } + + #endregion + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/ComparerAdaptor.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/ComparerAdaptor.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/ComparerAdaptor.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/ComparerAdaptor.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,21 @@ +/* Copyright (C) 2007 Versant Inc. http://www.db4o.com */ +using System; +using System.Text; + +namespace Db4objects.Db4o.Internal +{ + class ComparerAdaptor : Db4objects.Db4o.Query.IQueryComparator + { + private System.Collections.IComparer _comparer; + + public ComparerAdaptor(System.Collections.IComparer comparer) + { + _comparer = comparer; + } + + public int Compare(object first, object second) + { + return _comparer.Compare(first, second); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Config4Impl.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Config4Impl.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Config4Impl.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Config4Impl.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,24 @@ +/* Copyright (C) 2009 Versant Inc. http://www.db4o.com */ + +using System; +using System.Reflection; +using Db4objects.Db4o.Config; + +namespace Db4objects.Db4o.Internal +{ + public partial class Config4Impl + { + private static ILegacyClientServerFactory DefaultClientServerFactory() + { + Assembly csAssembly = Assembly.Load(ClientServerAssemblyName()); + return (ILegacyClientServerFactory) Activator.CreateInstance(csAssembly.GetType("Db4objects.Db4o.CS.Internal.Config.LegacyClientServerFactoryImpl")); + } + + private static string ClientServerAssemblyName() + { + Assembly db4oAssembly = typeof(IObjectContainer).Assembly; + string db4oAssemblySimpleName = db4oAssembly.GetName().Name; + return db4oAssembly.FullName.Replace(db4oAssemblySimpleName, "Db4objects.Db4o.CS"); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Const4.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Const4.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Const4.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Const4.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,8 @@ +/* Copyright (C) 2004 - 2008 Versant Inc. http://www.db4o.com */ +namespace Db4objects.Db4o.Internal +{ + public sealed partial class Const4 + { + public const int MaxStackDepth = 20; + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Convert/Conversions/DropClassIndexesConversion.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Convert/Conversions/DropClassIndexesConversion.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Convert/Conversions/DropClassIndexesConversion.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Convert/Conversions/DropClassIndexesConversion.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,22 @@ +/* Copyright (C) 2009 Versant Inc. http://www.db4o.com */ +namespace Db4objects.Db4o.Internal.Convert.Conversions +{ + public abstract class DropClassIndexesConversion : Conversion + { + public override void Convert(ConversionStage.SystemUpStage stage) + { + LocalObjectContainer file = stage.File(); + ClassMetadataIterator i = file.ClassCollection().Iterator(); + while (i.MoveNext()) + { + ClassMetadata classmetadata = i.CurrentClass(); + if (Accept(classmetadata)) + { + classmetadata.DropClassIndex(); + } + } + } + + protected abstract bool Accept(ClassMetadata classmetadata); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Convert/Conversions/DropDateTimeOffsetClassIndexes_7_12.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Convert/Conversions/DropDateTimeOffsetClassIndexes_7_12.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Convert/Conversions/DropDateTimeOffsetClassIndexes_7_12.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Convert/Conversions/DropDateTimeOffsetClassIndexes_7_12.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,18 @@ +/* Copyright (C) 2009 Versant Inc. http://www.db4o.com */ +using System; +using Db4objects.Db4o.Reflect.Net; + +namespace Db4objects.Db4o.Internal.Convert.Conversions +{ + public partial class DropDateTimeOffsetClassIndexes_7_12 : DropClassIndexesConversion + { + protected override bool Accept(ClassMetadata classmetadata) + { +#if CF || SILVERLIGHT + return false; +#else + return NetReflector.ToNative(classmetadata.ClassReflector()) == typeof(DateTimeOffset); +#endif + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Convert/Conversions/DropEnumClassIndexes_7_10.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Convert/Conversions/DropEnumClassIndexes_7_10.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Convert/Conversions/DropEnumClassIndexes_7_10.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Convert/Conversions/DropEnumClassIndexes_7_10.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,15 @@ +/* Copyright (C) 2009 Versant Inc. http://www.db4o.com */ +using System; +using Db4objects.Db4o.Reflect.Net; + +namespace Db4objects.Db4o.Internal.Convert.Conversions +{ + public partial class DropEnumClassIndexes_7_10 : DropClassIndexesConversion + { + protected override bool Accept(ClassMetadata classmetadata) + { + Type type = NetReflector.ToNative(classmetadata.ClassReflector()); + return type != null ? type.IsEnum : false; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Convert/Conversions/DropGuidClassIndexes_7_12.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Convert/Conversions/DropGuidClassIndexes_7_12.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Convert/Conversions/DropGuidClassIndexes_7_12.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Convert/Conversions/DropGuidClassIndexes_7_12.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,14 @@ +/* Copyright (C) 2009 Versant Inc. http://www.db4o.com */ +using System; +using Db4objects.Db4o.Reflect.Net; + +namespace Db4objects.Db4o.Internal.Convert.Conversions +{ + public partial class DropGuidClassIndexes_7_12 : DropClassIndexesConversion + { + protected override bool Accept(ClassMetadata classmetadata) + { + return NetReflector.ToNative(classmetadata.ClassReflector()) == typeof(Guid); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Convert/Conversions/ReindexNetDateTime_7_8.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Convert/Conversions/ReindexNetDateTime_7_8.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Convert/Conversions/ReindexNetDateTime_7_8.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Convert/Conversions/ReindexNetDateTime_7_8.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,57 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ +using System; +using Db4objects.Db4o.Ext; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Reflect; +using Db4objects.Db4o.Reflect.Net; + +namespace Db4objects.Db4o.Internal.Convert.Conversions +{ + partial class ReindexNetDateTime_7_8 : Conversion + { + public override void Convert(ConversionStage.SystemUpStage stage) + { + ReindexDateTimeFields(stage); + } + + private static void ReindexDateTimeFields(ConversionStage stage) + { + DateTimeFieldReindexer reindexer = new DateTimeFieldReindexer(); + + ClassMetadataIterator i = stage.File().ClassCollection().Iterator(); + while (i.MoveNext()) + { + ClassMetadata classmetadata = i.CurrentClass(); + classmetadata.TraverseDeclaredFields(reindexer); + } + } + + private class DateTimeFieldReindexer : IProcedure4 + { + public void Apply(object field) + { + if (!((FieldMetadata)field).HasIndex()) + { + return; + } + ReindexDateTimeField(((FieldMetadata)field)); + } + + private static void ReindexDateTimeField(IStoredField field) + { + IReflectClass claxx = field.GetStoredType(); + if (claxx == null) + { + return; + } + + Type t = NetReflector.ToNative(claxx); + if (t == typeof(DateTime) || t == typeof(DateTime?)) + { + field.DropIndex(); + field.CreateIndex(); + } + } + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Encoding/UTF8StringEncoding.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Encoding/UTF8StringEncoding.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Encoding/UTF8StringEncoding.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Encoding/UTF8StringEncoding.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,20 @@ +/* Copyright (C) 2008 Versant Inc. http://www.db4o.com */ +using System; + +namespace Db4objects.Db4o.Internal.Encoding +{ + public class UTF8StringEncoding : BuiltInStringEncoding + { + public override byte[] Encode(String str) + { + return System.Text.Encoding.UTF8.GetBytes(str); + } + + public override String Decode(byte[] bytes, int start, int length) + { + return System.Text.Encoding.UTF8.GetString(bytes, start, length); + } + + } + +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/GenericTypeHandlerPredicate.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/GenericTypeHandlerPredicate.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/GenericTypeHandlerPredicate.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/GenericTypeHandlerPredicate.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,32 @@ +/* Copyright (C) 2008 Versant Inc. http://www.db4o.com */ +using System; +using Db4objects.Db4o.Reflect; +using Db4objects.Db4o.Reflect.Net; +using Db4objects.Db4o.Typehandlers; + +namespace Db4objects.Db4o.native.Db4objects.Db4o.Internal +{ + public class GenericTypeHandlerPredicate : ITypeHandlerPredicate + { + private readonly Type _genericType; + + public GenericTypeHandlerPredicate(Type genericType) + { + _genericType = genericType; + } + + public bool Match(IReflectClass classReflector) + { + Type type = NetReflector.ToNative(classReflector); + if (type == null) + { + return false; + } + if (!type.IsGenericType) + { + return false; + } + return type.GetGenericTypeDefinition() == _genericType; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Handlers/DateHandler.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Handlers/DateHandler.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Handlers/DateHandler.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Handlers/DateHandler.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,30 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ +using System; + +namespace Db4objects.Db4o.Internal.Handlers +{ + public class DateHandler : DateHandlerBase + { + public override object DefaultValue() + { + return DateTime.MinValue; + } + + public override object PrimitiveNull() + { + return DateTime.MinValue; + } + + public override object NullRepresentationInUntypedArrays() + { + return null; + } + + public override object CopyValue(object from, object to) + { + // nothing to do since we already have a immutable + // copy + return from; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Handlers/DateTimeHandler6.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Handlers/DateTimeHandler6.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Handlers/DateTimeHandler6.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Handlers/DateTimeHandler6.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,33 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ +using System; +using Db4objects.Db4o.Marshall; + +namespace Db4objects.Db4o.Internal.Handlers +{ + class DateTimeHandler6 : DateTimeHandler + { + protected override object ReadKind(IReadContext context, DateTime dateTime) + { + return dateTime; + } + + protected override void WriteKind(IWriteContext context, DateTime dateTime) + { + // do nothing + } + + protected override DateTime ReadKind (DateTime dateTime, byte[] bytes, int offset) + { + return dateTime; + } + + protected override void WriteKind(DateTime dateTime, byte[] bytes, int offset) + { + // do nothing + } + //public override int LinkLength() + //{ + // return base.LinkLength() - Const4.LongLength; + //} + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Handlers/DateTimeHandler.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Handlers/DateTimeHandler.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Handlers/DateTimeHandler.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Handlers/DateTimeHandler.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,94 @@ +/* Copyright (C) 2004 - 2007 Versant Inc. http://www.db4o.com */ + +using System; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Marshall; +using Sharpen; + +namespace Db4objects.Db4o.Internal.Handlers +{ + public class DateTimeHandler : StructHandler + { + public override Object DefaultValue() + { + return DateTime.MinValue; + } + + public override Object Read(byte[] bytes, int offset) + { + long ticks = 0; + for (int i = 0; i < 8; i++) + { + ticks = (ticks << 8) + (bytes[offset++] & 255); + } + return ReadKind(new DateTime(ticks), bytes, offset); + } + + protected virtual DateTime ReadKind (DateTime dateTime, byte[] bytes, int offset) + { + int kind = 0; + for (int i = 0; i < 4; i++) + { + kind = (kind << 8) + (bytes[offset++] & 255); + } + return DateTime.SpecifyKind(dateTime, (DateTimeKind)kind); + } + + public override int TypeID() + { + return 25; + } + + public override void Write(object obj, byte[] bytes, int offset) + { + long ticks = ((DateTime)obj).Ticks; + for (int i = 0; i < 8; i++) + { + bytes[offset++] = (byte)(int)(ticks >> (7 - i) * 8); + } + WriteKind((DateTime)obj, bytes, offset); + } + + protected virtual void WriteKind(DateTime dateTime, byte[] bytes, int offset) + { + int kind = (int) dateTime.Kind; + for (int i = 0; i < 4; i++) + { + bytes[offset++] = (byte)(int)(kind >> (3 - i) * 8); + } + } + + public override object Read(IReadContext context) + { + long ticks = context.ReadLong(); + DateTime dateTime = new DateTime(ticks); + return ReadKind(context, dateTime); + } + + protected virtual object ReadKind(IReadContext context, DateTime dateTime) + { + DateTimeKind kind = (DateTimeKind) context.ReadInt(); + return DateTime.SpecifyKind(dateTime, kind); + } + + public override void Write(IWriteContext context, object obj) + { + DateTime dateTime = (DateTime)obj; + long ticks = dateTime.Ticks; + context.WriteLong(ticks); + WriteKind(context, dateTime); + } + + protected virtual void WriteKind(IWriteContext context, DateTime dateTime) + { + context.WriteInt((int) dateTime.Kind); + } + + public override IPreparedComparison InternalPrepareComparison(object obj) + { + return new PreparedComparisonFor(((DateTime)obj)); + } + + + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Handlers/DecimalHandler.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Handlers/DecimalHandler.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Handlers/DecimalHandler.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Handlers/DecimalHandler.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,82 @@ +/* Copyright (C) 2004 - 2007 Versant Inc. http://www.db4o.com */ + +using System; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Marshall; + +namespace Db4objects.Db4o.Internal.Handlers +{ + public class DecimalHandler : IntegralTypeHandler + { + public override Object DefaultValue(){ + return (decimal)0; + } + + public override Object Read(byte[] bytes, int offset){ + int[] ints = new int[4]; + offset += 3; + for(int i = 0; i < 4; i ++){ + ints[i] = (bytes[offset] & 255 | (bytes[--offset] & 255) << 8 | (bytes[--offset] & 255) << 16 | bytes[--offset] << 24); + offset +=7; + } + return new Decimal(ints); + } + + public override int TypeID(){ + return 21; + } + + public override void Write(Object obj, byte[] bytes, int offset){ + decimal dec = (decimal)obj; + int[] ints = Decimal.GetBits(dec); + offset += 4; + for(int i = 0; i < 4; i ++){ + bytes[--offset] = (byte)ints[i]; + bytes[--offset] = (byte)(ints[i] >>= 8); + bytes[--offset] = (byte)(ints[i] >>= 8); + bytes[--offset] = (byte)(ints[i] >>= 8); + offset += 8; + } + } + public override object Read(IReadContext context) + { + byte[] bytes = new byte[16]; + int[] ints = new int[4]; + int offset = 4; + context.ReadBytes(bytes); + for (int i = 0; i < 4; i++) + { + ints[i] = ( + bytes[--offset] & 255 | + (bytes[--offset] & 255) << 8 | + (bytes[--offset] & 255) << 16 | + (bytes[--offset] & 255) << 24 + ); + offset += 8; + } + return new Decimal(ints); + } + + public override void Write(IWriteContext context, object obj) + { + decimal dec = (decimal)obj; + byte[] bytes = new byte[16]; + int offset = 4; + int[] ints = Decimal.GetBits(dec); + for (int i = 0; i < 4; i++) + { + bytes[--offset] = (byte)ints[i]; + bytes[--offset] = (byte)(ints[i] >>= 8); + bytes[--offset] = (byte)(ints[i] >>= 8); + bytes[--offset] = (byte)(ints[i] >>= 8); + offset += 8; + } + context.WriteBytes(bytes); + } + + public override IPreparedComparison InternalPrepareComparison(object obj) + { + return new PreparedComparisonFor(((decimal) obj)); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Handlers/IntegralTypeHandler.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Handlers/IntegralTypeHandler.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Handlers/IntegralTypeHandler.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Handlers/IntegralTypeHandler.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,11 @@ +/* Copyright (C) 2004 - 2007 Versant Inc. http://www.db4o.com */ + +using System; + +namespace Db4objects.Db4o.Internal.Handlers +{ + abstract public class IntegralTypeHandler : NetTypeHandler + { + + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Handlers/PreparedComparisonFor.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Handlers/PreparedComparisonFor.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Handlers/PreparedComparisonFor.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Handlers/PreparedComparisonFor.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,23 @@ +/* Copyright (C) 2009 Versant Inc. http://www.db4o.com */ + +using System; +using Db4objects.Db4o.Foundation; + +namespace Db4objects.Db4o.Internal.Handlers +{ + internal class PreparedComparisonFor : IPreparedComparison where T : IComparable + { + private readonly T _source; + + public PreparedComparisonFor(T source) + { + _source = source; + } + + public int CompareTo(object obj) + { + T target = ((T)obj); + return _source.CompareTo(target); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Handlers/SByteHandler.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Handlers/SByteHandler.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Handlers/SByteHandler.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Handlers/SByteHandler.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,48 @@ +/* Copyright (C) 2004 - 2007 Versant Inc. http://www.db4o.com */ + +using System; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Marshall; +using Db4objects.Db4o.Reflect; + +namespace Db4objects.Db4o.Internal.Handlers +{ + public class SByteHandler : IntegralTypeHandler + { + public override object Coerce(IReflectClass claxx, object obj) + { + return Coercion4.ToSByte(obj); + } + + public override Object DefaultValue(){ + return (sbyte)0; + } + + public override Object Read(byte[] bytes, int offset){ + return (sbyte) ((bytes[offset]) - 128) ; + } + + public override int TypeID(){ + return 20; + } + + public override void Write(Object obj, byte[] bytes, int offset){ + bytes[offset] = (byte)(((sbyte)obj) + 128); + } + + public override object Read(IReadContext context) + { + return (sbyte)(context.ReadByte() - 128); + } + + public override void Write(IWriteContext context, object obj) + { + context.WriteByte((byte)(((sbyte)obj) + 128)); + } + + public override IPreparedComparison InternalPrepareComparison(object obj) + { + return new PreparedComparisonFor(((sbyte)obj)); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Handlers/StructHandler.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Handlers/StructHandler.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Handlers/StructHandler.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Handlers/StructHandler.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,10 @@ +/* Copyright (C) 2004 - 2007 Versant Inc. http://www.db4o.com */ + +using System; + +namespace Db4objects.Db4o.Internal.Handlers +{ + abstract public class StructHandler : NetTypeHandler { + + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Handlers/UIntHandler.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Handlers/UIntHandler.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Handlers/UIntHandler.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Handlers/UIntHandler.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,61 @@ +/* Copyright (C) 2004 - 2007 Versant Inc. http://www.db4o.com */ + +using System; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Marshall; + +namespace Db4objects.Db4o.Internal.Handlers +{ + public class UIntHandler : IntegralTypeHandler + { + public override Object DefaultValue(){ + return (uint)0; + } + + public override Object Read(byte[] bytes, int offset){ + offset += 3; + return (uint) (bytes[offset] & 255 | (bytes[--offset] & 255) << 8 | (bytes[--offset] & 255) << 16 | bytes[--offset] << 24); + } + + public override int TypeID(){ + return 22; + } + + public override void Write(Object obj, byte[] bytes, int offset){ + uint ui = (uint)obj; + offset += 4; + bytes[--offset] = (byte)ui; + bytes[--offset] = (byte)(ui >>= 8); + bytes[--offset] = (byte)(ui >>= 8); + bytes[--offset] = (byte)(ui >>= 8); + } + public override object Read(IReadContext context) + { + byte[] bytes = new byte[4]; + context.ReadBytes(bytes); + return (uint)( + bytes[3] & 255 | + (bytes[2] & 255) << 8 | + (bytes[1] & 255) << 16 | + (bytes[0] & 255) << 24 + ); + } + + public override void Write(IWriteContext context, object obj) + { + uint ui = (uint)obj; + context.WriteBytes( + new byte[] { + (byte)(ui>>24), + (byte)(ui>>16), + (byte)(ui>>8), + (byte)ui, + }); + } + + public override IPreparedComparison InternalPrepareComparison(object obj) + { + return new PreparedComparisonFor(((uint)obj)); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Handlers/ULongHandler.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Handlers/ULongHandler.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Handlers/ULongHandler.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Handlers/ULongHandler.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,71 @@ +/* Copyright (C) 2004 - 2007 Versant Inc. http://www.db4o.com */ + +using System; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Marshall; + +namespace Db4objects.Db4o.Internal.Handlers +{ + public class ULongHandler : IntegralTypeHandler { + + public override Object DefaultValue(){ + return (ulong)0; + } + + public override void Write(object obj, byte[] bytes, int offset){ + ulong ul = (ulong)obj; + for (int i = 0; i < 8; i++){ + bytes[offset++] = (byte)(int)(ul >> (7 - i) * 8); + } + } + + public override int TypeID(){ + return 23; + } + + public override Object Read(byte[] bytes, int offset){ + ulong ul = 0; + for (int i = 0; i < 8; i++) { + ul = (ul << 8) + (ulong)(bytes[offset++] & 255); + } + return ul; + } + + public override object Read(IReadContext context) + { + byte[] bytes = new byte[8]; + context.ReadBytes(bytes); + return (ulong)( + (ulong)bytes[7] & 255 | + (ulong)(bytes[6] & 255) << 8 | + (ulong)(bytes[5] & 255) << 16 | + (ulong)(bytes[4] & 255) << 24 | + (ulong)(bytes[3] & 255) << 32 | + (ulong)(bytes[2] & 255) << 40 | + (ulong)(bytes[1] & 255) << 48 | + (ulong)(bytes[0] & 255) << 56 + ); + } + + public override void Write(IWriteContext context, object obj) + { + ulong ui = (ulong)obj; + context.WriteBytes( + new byte[] { + (byte)(ui>>56), + (byte)(ui>>48), + (byte)(ui>>40), + (byte)(ui>>32), + (byte)(ui>>24), + (byte)(ui>>16), + (byte)(ui>>8), + (byte)ui, + }); + } + + public override IPreparedComparison InternalPrepareComparison(object obj) + { + return new PreparedComparisonFor(((ulong)obj)); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Handlers/UShortHandler.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Handlers/UShortHandler.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Handlers/UShortHandler.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Handlers/UShortHandler.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,57 @@ +/* Copyright (C) 2004 - 2007 Versant Inc. http://www.db4o.com */ + +using System; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Marshall; + + +namespace Db4objects.Db4o.Internal.Handlers +{ + public class UShortHandler : IntegralTypeHandler + { + public override Object DefaultValue(){ + return (ushort)0; + } + + public override Object Read(byte[] bytes, int offset){ + offset += 1; + return (ushort) (bytes[offset] & 255 | (bytes[--offset] & 255) << 8); + } + + public override int TypeID(){ + return 24; + } + + public override void Write(Object obj, byte[] bytes, int offset){ + ushort us = (ushort)obj; + offset += 2; + bytes[--offset] = (byte)us; + bytes[--offset] = (byte)(us >>= 8); + } + + public override object Read(IReadContext context) + { + byte[] bytes = new byte[2]; + context.ReadBytes(bytes); + return (ushort)( + bytes[1] & 255 | + (bytes[0] & 255) << 8 + ); + } + + public override void Write(IWriteContext context, object obj) + { + ushort us = (ushort)obj; + context.WriteBytes( + new byte[] { + (byte)(us>>8), + (byte)us, + }); + } + + public override IPreparedComparison InternalPrepareComparison(object obj) + { + return new PreparedComparisonFor(((ushort)obj)); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Handlers/WeakReferenceHandler.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Handlers/WeakReferenceHandler.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Handlers/WeakReferenceHandler.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Handlers/WeakReferenceHandler.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,29 @@ +/* Copyright (C) 2004 - 2007 Versant Inc. http://www.db4o.com */ + +using System; + +namespace Db4objects.Db4o.Internal.Handlers +{ + internal class WeakReferenceHandler + { + private readonly WeakReference _reference; + public object ObjectReference; + + internal WeakReferenceHandler(Object queue, Object objectRef, Object obj) + { + _reference = new WeakReference(obj, false); + ObjectReference = objectRef; + ((WeakReferenceHandlerQueue)queue).Add(this); + } + + public object Get() + { + return _reference.Target; + } + + public bool IsAlive + { + get { return _reference.IsAlive; } + } + } +} \ No newline at end of file diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Handlers/WeakReferenceHandlerQueue.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Handlers/WeakReferenceHandlerQueue.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Handlers/WeakReferenceHandlerQueue.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Handlers/WeakReferenceHandlerQueue.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,46 @@ +/* Copyright (C) 2004 - 2007 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Ext; +using Db4objects.Db4o.Foundation; + +namespace Db4objects.Db4o.Internal.Handlers +{ + internal class WeakReferenceHandlerQueue + { + private List4 _list; + + internal void Add(WeakReferenceHandler reference) { + lock(this){ + _list = new List4(_list, reference); + } + } + + internal void Poll(ObjectContainerBase objectContainer) { + List4 remove = null; + lock(this){ + System.Collections.IEnumerator i = new Iterator4Impl(_list); + _list = null; + while(i.MoveNext()){ + WeakReferenceHandler refHandler = (WeakReferenceHandler)i.Current; + if(refHandler.IsAlive){ + _list = new List4(_list, refHandler); + }else{ + remove = new List4(remove, refHandler.ObjectReference); + } + } + } + System.Collections.IEnumerator j = new Iterator4Impl(remove); + while (j.MoveNext()) + { + lock (objectContainer.Lock()) + { + if (objectContainer.IsClosed()) + { + return; + } + objectContainer.RemoveFromAllReferenceSystems(j.Current); + } + } + } + } +} \ No newline at end of file diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/IInternalObjectContainer.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/IInternalObjectContainer.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/IInternalObjectContainer.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/IInternalObjectContainer.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,10 @@ +/* Copyright (C) 2009 Versant Inc. http://www.db4o.com */ +using Db4objects.Db4o.Foundation; + +namespace Db4objects.Db4o.Internal +{ + public partial interface IInternalObjectContainer + { + void WithEnvironment(Action4 action); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/LegacyDb4oAssemblyNameMapper.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/LegacyDb4oAssemblyNameMapper.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/LegacyDb4oAssemblyNameMapper.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/LegacyDb4oAssemblyNameMapper.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,90 @@ +/* Copyright (C) 2009 Versant Inc. http://www.db4o.com */ +using System.Text; +using Db4objects.Db4o.Internal.Encoding; + +namespace Db4objects.Db4o.Internal +{ + internal class LegacyDb4oAssemblyNameMapper + { + static LegacyDb4oAssemblyNameMapper() + { + LatinStringIO stringIO = new UnicodeStringIO(); + oldAssemblies = new byte[oldAssemblyNames.Length][]; + for (int i = 0; i < oldAssemblyNames.Length; i++) + { + oldAssemblies[i] = stringIO.Write(oldAssemblyNames[i]); + } + } + + internal byte[] MappedNameFor(byte[] nameBytes) + { + for (int i = 0; i < oldAssemblyNames.Length; i++) + { + byte[] assemblyName = oldAssemblies[i]; + + int j = assemblyName.Length - 1; + for (int k = nameBytes.Length - 1; k >= 0; k--) + { + if (nameBytes[k] != assemblyName[j]) + { + break; + } + j--; + if (j < 0) + { + return UpdateInternalClassName(nameBytes, i); + } + } + } + return nameBytes; + } + + private static byte[] UpdateInternalClassName(byte[] bytes, int candidateMatchingAssemblyIndex) + { + UnicodeStringIO io = new UnicodeStringIO(); + string typeFQN = io.Read(bytes); + + string[] assemblyNameParts = typeFQN.Split(','); + if (assemblyNameParts[1].Trim() != oldAssemblyNames[candidateMatchingAssemblyIndex]) + { + return bytes; + } + + string typeName = assemblyNameParts[0]; + return io.Write(FullyQualifiedNameFor(typeName).ToString()); + } + + private static StringBuilder FullyQualifiedNameFor(string typeName) + { + StringBuilder typeNameBuffer = new StringBuilder(typeName); + ApplyNameSpaceRenamings(typeNameBuffer); + typeNameBuffer.Append(", "); + typeNameBuffer.Append(GetCurrentAssemblyName()); + return typeNameBuffer; + } + + private static void ApplyNameSpaceRenamings(StringBuilder typeNameBuffer) + { + foreach (string[] renaming in NamespaceRenamings) + { + typeNameBuffer.Replace(renaming[0], renaming[1]); + } + } + + private static string GetCurrentAssemblyName() + { + return typeof(Platform4).Assembly.GetName().Name; + } + + private static readonly string[] oldAssemblyNames = new string[] { "db4o-4.0-net1", "db4o-4.0-compact1" }; + private static readonly byte[][] oldAssemblies; + + private static readonly string[][] NamespaceRenamings = new string[][] + { + new string[] { "com.db4o.ext", "Db4objects.Db4o.Ext"}, + new string[] { "com.db4o.inside", "Db4objects.Db4o.Internal"}, + new string[] { "com.db4o", "Db4objects.Db4o"}, + }; + + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Marshall/MarshallingConstants0.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Marshall/MarshallingConstants0.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Marshall/MarshallingConstants0.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Marshall/MarshallingConstants0.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,9 @@ +using System; + +namespace Db4objects.Db4o.Internal.Marshall +{ + public class MarshallingConstants0 + { + public static readonly DateTime NullDate = DateTime.MinValue; + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/ObjectContainerBase.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/ObjectContainerBase.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/ObjectContainerBase.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/ObjectContainerBase.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,206 @@ +/* Copyright (C) 2004 - 2008 Versant Inc. http://www.db4o.com */ + +using System.Collections.Generic; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Query; + +namespace Db4objects.Db4o.Internal +{ + using System; + using Query; + using Query.Result; + using Query.Processor; + using Ext; + + public partial class ObjectContainerBase + { + void IDisposable.Dispose() + { + Close(); + } + + public IObjectSet Query(Predicate match, System.Collections.IComparer comparer) + { + if (null == match) throw new ArgumentNullException("match"); + return Query(null, match, new ComparerAdaptor(comparer)); + } + + class GenericComparerAdaptor : IQueryComparator + { + private readonly IComparer _comparer; + + public GenericComparerAdaptor(IComparer comparer) + { + _comparer = comparer; + } + + public int Compare(object first, object second) + { + return _comparer.Compare((T)first, (T)second); + } + } + + class GenericComparisonAdaptor : DelegateEnvelope, IQueryComparator + { + public GenericComparisonAdaptor(Comparison comparer) : base(comparer) + { + } + + public int Compare(object first, object second) + { + Comparison _comparer = (Comparison)GetContent(); + return _comparer((T)first, (T)second); + } + } + + public IList Query(Predicate match) + { + return Query(null, match); + } + + public IList Query(Transaction trans, Predicate match) + { + return ExecuteNativeQuery(trans, match, null); + } + + public IList Query(Predicate match, IComparer comparer) + { + return Query(null, match, comparer); + } + + + public IList Query(Transaction trans, Predicate match, IComparer comparer) + { + IQueryComparator comparator = null != comparer + ? new GenericComparerAdaptor(comparer) + : null; + return ExecuteNativeQuery(trans, match, comparator); + } + + public IList Query(Predicate match, Comparison comparison) + { + return Query(null, match, comparison); + } + + + public IList Query(Transaction trans, Predicate match, Comparison comparison) + { + IQueryComparator comparator = null != comparison + ? new GenericComparisonAdaptor(comparison) + : null; + return ExecuteNativeQuery(trans, match, comparator); + } + + public IList Query(Type extent) + { + return Query(null, extent, null); + } + + + public IList Query(Transaction trans, Type extent) + { + return Query(trans, extent, null); + } + + public IList Query(Type extent, IComparer comparer) + { + return Query(null, extent, comparer); + } + + + public IList Query(Transaction trans, Type extent, IComparer comparer) + { + lock (Lock()) + { + trans = CheckTransaction(trans); + QQuery query = (QQuery)Query(trans); + query.Constrain(extent); + if (null != comparer) query.SortBy(new GenericComparerAdaptor(comparer)); + IQueryResult queryResult = query.GetQueryResult(); + return new GenericObjectSetFacade(queryResult); + } + } + + public IList Query() + { + return Query(typeof(Extent)); + } + + public IList Query(IComparer comparer) + { + return Query(typeof(Extent), comparer); + } + + private IList ExecuteNativeQuery(Transaction trans, Predicate match, IQueryComparator comparator) + { + if (null == match) throw new ArgumentNullException("match"); + lock (Lock()) + { + IQuery query = Query(CheckTransaction(trans)); + return (IList) ((QQuery)query).TriggeringQueryEvents(Closures4.ForDelegate( + delegate() { + return GetNativeQueryHandler().Execute(query, match, comparator); + })); + } + } + + public delegate R SyncExecClosure(); + + public R SyncExec(SyncExecClosure closure) + { + return (R)SyncExec(new SyncExecClosure4(closure)); + } + + public class SyncExecClosure4 : IClosure4 + { + private readonly SyncExecClosure _closure; + + public SyncExecClosure4(SyncExecClosure closure) + { + _closure = closure; + } + + #region Implementation of IClosure4 + + public object Run() + { + return _closure.Invoke(); + } + + #endregion + } + + private object AsTopLevelCall(IFunction4 block, Transaction trans) + { + trans = CheckTransaction(trans); + BeginTopLevelCall(); + try + { + return block.Apply(trans); + } + catch(Db4oRecoverableException exc) + { + throw; + } + catch(SystemException exc) + { + throw; + } + catch(Exception exc) + { + FatalShutdown(exc); + } + finally + { + EndTopLevelCall(); + } + // should never happen - just to make compiler happy + throw new Db4oException(); + } + + public void WithEnvironment(Action4 action) + { + WithEnvironment(new RunnableAction(action)); + } + } +} \ No newline at end of file diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/ObjectContainerSession.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/ObjectContainerSession.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/ObjectContainerSession.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/ObjectContainerSession.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,66 @@ +/* Copyright (C) 2004 - 2008 Versant Inc. http://www.db4o.com */ + +using System; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal.Query; +using Db4objects.Db4o.Internal.Query.Result; +using Db4objects.Db4o.Internal.Query.Processor; +using Db4objects.Db4o.Ext; +using Db4objects.Db4o.Query; + +namespace Db4objects.Db4o.Internal +{ + /// + public partial class ObjectContainerSession + { + void System.IDisposable.Dispose() + { + Close(); + } + + public IObjectSet Query(Db4objects.Db4o.Query.Predicate match, System.Collections.IComparer comparer) + { + return _server.Query(_transaction, match, new ComparerAdaptor(comparer)); + } + + public System.Collections.Generic.IList Query(Predicate match) + { + return _server.Query(_transaction, match); + } + + public System.Collections.Generic.IList Query(Predicate match, System.Collections.Generic.IComparer comparer) + { + return _server.Query(_transaction, match, comparer); + } + + public System.Collections.Generic.IList Query(Predicate match, System.Comparison comparison) + { + return _server.Query(_transaction, match, comparison); + } + + public System.Collections.Generic.IList Query(System.Type extent) + { + return _server.Query(_transaction, extent, null); + } + + public System.Collections.Generic.IList Query(System.Type extent, System.Collections.Generic.IComparer comparer) + { + return _server.Query(_transaction, extent, comparer); + } + + public System.Collections.Generic.IList Query() + { + return Query(typeof(Extent)); + } + + public System.Collections.Generic.IList Query(System.Collections.Generic.IComparer comparer) + { + return Query(typeof(Extent), comparer); + } + + public void WithEnvironment(Action4 action) + { + _server.WithEnvironment(new RunnableAction(action)); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Platform4.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Platform4.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Platform4.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Platform4.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,726 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Globalization; +using System.IO; +using Db4objects.Db4o.Config; +using Db4objects.Db4o.Config.Attributes; +using Db4objects.Db4o.Ext; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal.Activation; +using Db4objects.Db4o.Internal.Handlers; +using Db4objects.Db4o.Internal.Query; +using Db4objects.Db4o.Internal.Query.Processor; +using Db4objects.Db4o.Query; +using Db4objects.Db4o.Reflect; +using Db4objects.Db4o.Reflect.Generic; +using Db4objects.Db4o.Reflect.Net; +using Db4objects.Db4o.Typehandlers; +using Sharpen.IO; + +namespace Db4objects.Db4o.Internal +{ + /// + public class Platform4 + { + private static readonly LegacyDb4oAssemblyNameMapper _assemlbyNameMapper = new LegacyDb4oAssemblyNameMapper(); + + private static List _containersToBeShutdown; + + private static readonly object _shutdownStreamsLock = new object(); + + public static object[] CollectionToArray(ObjectContainerBase stream, object obj) + { + Collection4 col = FlattenCollection(stream, obj); + object[] ret = new object[col.Size()]; + col.ToArray(ret); + return ret; + } + + internal static void AddShutDownHook(ObjectContainerBase container) + { + lock (_shutdownStreamsLock) + { + if (_containersToBeShutdown == null) + { + _containersToBeShutdown = new List(); +#if !CF && !SILVERLIGHT + AppDomain.CurrentDomain.ProcessExit += OnShutDown; + AppDomain.CurrentDomain.DomainUnload += OnShutDown; +#endif + } + _containersToBeShutdown.Add(container); + } + } + + internal static byte[] Serialize(Object obj) + { + throw new NotSupportedException(); + } + + internal static Object Deserialize(byte[] bytes) + { + throw new NotSupportedException(); + } + + internal static bool CanSetAccessible() + { + return true; + } + + internal static IReflector CreateReflector(Object config) + { +#if USE_FAST_REFLECTOR && !CF && !SILVERLIGHT + return new Db4objects.Db4o.Internal.Reflect.FastNetReflector(); +#else + return new NetReflector(); +#endif + } + + public static IReflector ReflectorForType(Type typeInstance) + { +#if USE_FAST_REFLECTOR && !CF && !SILVERLIGHT + return new Db4objects.Db4o.Internal.Reflect.FastNetReflector(); +#else + return new NetReflector(); +#endif + } + + internal static Object CreateReferenceQueue() + { + return new WeakReferenceHandlerQueue(); + } + + public static Object CreateWeakReference(Object obj) + { + return new WeakReference(obj, false); + } + + internal static Object CreateActiveObjectReference(Object referenceQueue, Object yapObject, Object obj) + { + return new WeakReferenceHandler(referenceQueue, yapObject, obj); + } + + internal static long DoubleToLong(double a_double) + { +#if CF || SILVERLIGHT + byte[] bytes = BitConverter.GetBytes(a_double); + return BitConverter.ToInt64(bytes, 0); +#else + return BitConverter.DoubleToInt64Bits(a_double); +#endif + } + + internal static QConEvaluation EvaluationCreate(Transaction a_trans, Object example) + { + if (example is IEvaluation || example is EvaluationDelegate) + { + return new QConEvaluation(a_trans, example); + } + return null; + } + + internal static void EvaluationEvaluate(Object a_evaluation, ICandidate a_candidate) + { + IEvaluation eval = a_evaluation as IEvaluation; + if (eval != null) + { + eval.Evaluate(a_candidate); + } + else + { + // use starting _ for PascalCase conversion purposes + EvaluationDelegate _ed = a_evaluation as EvaluationDelegate; + if (_ed != null) + { + _ed(a_candidate); + } + } + } + + internal static Config4Class ExtendConfiguration(IReflectClass clazz, IConfiguration config, Config4Class classConfig) + { + Type t = GetNetType(clazz); + if (t == null) + { + return classConfig; + } + ConfigurationIntrospector a = new ConfigurationIntrospector(t, classConfig, config); + a.Apply(); + return a.ClassConfiguration; + } + + internal static Collection4 FlattenCollection(ObjectContainerBase stream, Object obj) + { + Collection4 collection41 = new Collection4(); + FlattenCollection1(stream, obj, collection41); + return collection41; + } + + internal static void FlattenCollection1(ObjectContainerBase stream, Object obj, Collection4 collection4) + { + Array arr = obj as Array; + if (arr != null) + { + IReflectArray reflectArray = stream.Reflector().Array(); + + Object[] flat = new Object[arr.Length]; + + reflectArray.Flatten(obj, reflectArray.Dimensions(obj), 0, flat, 0); + for (int i = 0; i < flat.Length; i++) + { + FlattenCollection1(stream, flat[i], collection4); + } + } + else + { + // If obj implements IEnumerable, add all elements to collection4 + IEnumerator enumerator = GetCollectionEnumerator(obj, true); + + // Add elements to collection if conversion was succesful + if (enumerator != null) + { + if (enumerator is IDictionaryEnumerator) + { + IDictionaryEnumerator dictEnumerator = enumerator as IDictionaryEnumerator; + while (enumerator.MoveNext()) + { + FlattenCollection1(stream, dictEnumerator.Key, collection4); + } + } + else + { + while (enumerator.MoveNext()) + { + // recursive call to flatten Collections in Collections + FlattenCollection1(stream, enumerator.Current, collection4); + } + } + } + else + { + // If obj is not a Collection, it still needs to be collected. + collection4.Add(obj); + } + } + } + + internal static void ForEachCollectionElement(Object obj, IVisitor4 visitor) + { + IEnumerator enumerator = GetCollectionEnumerator(obj, false); + if (enumerator != null) + { + // If obj is a map (IDictionary in .NET speak) call Visit() with the key + // otherwise use the element itself + if (enumerator is IDictionaryEnumerator) + { + IDictionaryEnumerator dictEnumerator = enumerator as IDictionaryEnumerator; + while (enumerator.MoveNext()) + { + visitor.Visit(dictEnumerator.Key); + } + } + else + { + while (enumerator.MoveNext()) + { + visitor.Visit(enumerator.Current); + } + } + } + } + + internal static String Format(DateTime date, bool showSeconds) + { + String fmt = "yyyy-MM-dd"; + if (showSeconds) + { + fmt += " HH:mm:ss"; + } + return date.ToString(fmt); + } + + internal static IEnumerator GetCollectionEnumerator(object obj, bool allowArray) + { + IEnumerable enumerable = obj as IEnumerable; + if (enumerable == null) return null; + if (obj is string) return null; + if (!allowArray && obj is Array) return null; + return enumerable.GetEnumerator(); + } + + internal static void GetDefaultConfiguration(Config4Impl config) + { + if (IsCompact()) + { + config.SingleThreadedClient(true); + } + + Translate(config, typeof(Delegate), new TNull()); + Translate(config, typeof(Type), new TType()); // TODO: unnecessary? + Translate(config, typeof(Type).GetType(), new TType()); + +#if !CF && !SILVERLIGHT + if (IsMono()) + { + + Translate(config, new Exception(), new TSerializable()); + } +#endif + +#if !SILVERLIGHT + Translate(config, new ArrayList(), new TList()); + Translate(config, new Hashtable(), new TDictionary()); + Translate(config, new Queue(), new TQueue()); + Translate(config, new Stack(), new TStack()); +#endif + Translate(config, CultureInfo.InvariantCulture, new TCultureInfo()); + + if (!IsCompact()) + { + Translate(config, "System.Collections.SortedList, mscorlib", new TDictionary()); + } + + new TypeHandlerConfigurationDotNet(config).Apply(); + + config.ObjectClass(typeof (ActivatableBase)).Indexed(false); + } + + public static bool IsCompact() + { +#if CF || SILVERLIGHT + return true; +#else + return false; +#endif + } + + internal static bool IsMono() + { + return null != Type.GetType("System.MonoType, mscorlib"); + } + + public static Object GetTypeForClass(Object obj) + { + return obj; + } + + internal static Object GetYapRefObject(Object obj) + { + WeakReferenceHandler refHandler = obj as WeakReferenceHandler; + if (refHandler != null) + { + return refHandler.Get(); + } + return obj; + } + + internal static bool HasCollections() + { + return true; + } + + public static bool NeedsLockFileThread() + { + return false; + } + + public static bool HasWeakReferences() + { + return true; + } + + internal static bool IgnoreAsConstraint(Object obj) + { + Type t = obj.GetType(); + if (t.IsEnum) + { + if (System.Convert.ToInt32(obj) == 0) + { + return true; + } + } + return false; + } + + internal static bool IsCollectionTranslator(Config4Class config4class) + { + if (config4class != null) + { + IObjectTranslator ot = config4class.GetTranslator(); + if (ot != null) + { +#if SILVERLIGHT + return false; +#else + return ot is TList || ot is TDictionary || ot is TQueue || ot is TStack; +#endif + } + } + return false; + } + + public static bool IsConnected(Sharpen.Net.Socket socket) + { + if (socket == null) + { + return false; + } + return socket.IsConnected(); + } + + internal static bool IsStruct(IReflectClass claxx) + { + if (claxx == null) + { + return false; + } + System.Type netClass = GetNetType(claxx); + if (netClass == null) + { + return false; + } + return netClass.IsValueType; + } + + internal static void KillYapRef(Object obj) + { + WeakReferenceHandler yr = obj as WeakReferenceHandler; + if (yr != null) + { + yr.ObjectReference = null; + } + } + + internal static double LongToDouble(long l) + { +#if CF || SILVERLIGHT + byte[] bytes = BitConverter.GetBytes(l); + return BitConverter.ToDouble(bytes, 0); +#else + return BitConverter.Int64BitsToDouble(l); +#endif + } + + internal static void LockFile(string path, object file) + { +#if !CF && !SILVERLIGHT + try + { + FileStream stream = ((RandomAccessFile) file).Stream; + stream.Lock(0, 1); + } + catch (IOException x) + { + throw new DatabaseFileLockedException(path,x); + } +#endif + } + + internal static void UnlockFile(string path, object file) + { + // do nothing. C# RAF is unlocked automatically upon closing + } + + internal static void MarkTransient(String marker) + { + NetField.MarkTransient(marker); + } + + internal static bool CallConstructor() + { + return false; + } + + internal static void PollReferenceQueue(Object container, Object referenceQueue) + { + ((WeakReferenceHandlerQueue)referenceQueue).Poll((ObjectContainerBase)container); + } + + public static void RegisterCollections(GenericReflector reflector) + { +// reflector.RegisterCollectionUpdateDepth( +// typeof(IDictionary), +// 3); + } + + internal static void RemoveShutDownHook(ObjectContainerBase container) + { + lock (_shutdownStreamsLock) + { + if (_containersToBeShutdown != null) + { + _containersToBeShutdown.Remove(container); + } + } + } + + public static void SetAccessible(Object obj) + { + // do nothing + } + + private static void OnShutDown(object sender, EventArgs args) + { + lock (_shutdownStreamsLock) + { + foreach (ObjectContainerBase container in _containersToBeShutdown.ToArray()) + { + container.ShutdownHook(); // this will remove the stream for the list + } + } + } + + public static bool StoreStaticFieldValues(IReflector reflector, IReflectClass clazz) + { + return false; + } + + private static void Translate(IConfiguration config, object obj, IObjectTranslator translator) + { + config.ObjectClass(obj).Translate(translator); + } + + public static byte[] UpdateClassName(byte[] nameBytes) + { + return _assemlbyNameMapper.MappedNameFor(nameBytes); + } + + public static Object WeakReferenceTarget(Object weakRef) + { + WeakReference wr = weakRef as WeakReference; + if (wr != null) + { + return wr.Target; + } + return weakRef; + } + + internal static object WrapEvaluation(object evaluation) + { +#if CF || SILVERLIGHT + // FIXME: How to better support EvaluationDelegate on the CompactFramework? + return evaluation; +#else + return (evaluation is EvaluationDelegate) + ? new EvaluationDelegateWrapper((EvaluationDelegate)evaluation) + : evaluation; +#endif + } + + public static bool IsTransient(IReflectClass clazz) + { + Type type = GetNetType(clazz); + if (null == type) return false; + return IsTransient(type); + } + + public static bool IsTransient(Type type) + { + return type.IsPointer + || type.IsSubclassOf(typeof(Delegate)) +#if CF || SILVERLIGHT +; +#else + || type == typeof(System.Reflection.Pointer); +#endif + } + + private static Type GetNetType(IReflectClass clazz) + { + if (null == clazz) + { + return null; + } + + NetClass netClass = clazz as NetClass; + if (null != netClass) + { + return netClass.GetNetType(); + } + IReflectClass claxx = clazz.GetDelegate(); + if (claxx == clazz) + { + return null; + } + return GetNetType(claxx); + } + + public static NetTypeHandler[] Types(IReflector reflector) + { + return new NetTypeHandler[] + { + new SByteHandler(), + new DecimalHandler(), + new UIntHandler(), + new ULongHandler(), + new UShortHandler(), + }; + } + + public static bool IsSimple(Type a_class) + { + for (int i1 = 0; i1 < SIMPLE_CLASSES.Length; i1++) + { + if (a_class == SIMPLE_CLASSES[i1]) + { + return true; + } + } + return false; + } + + private static Type[] SIMPLE_CLASSES = { + typeof(Int32), + typeof(Int64), + typeof(Single), + typeof(Boolean), + typeof(Double), + typeof(Byte), + typeof(Char), + typeof(Int16), + typeof(String), + }; + + public static DateTime Now() + { + return DateTime.Now; + } + + internal static bool IsJavaEnum(IReflector genericReflector, IReflectClass iReflectClass) + { + return false; + } + + internal static bool IsEnum(IReflector genericReflector, IReflectClass iReflectClass) + { + Type type = GetNetType(iReflectClass); + if(type == null) + { + return false; + } + return type.IsEnum; + } + + public static bool UseNativeSerialization() + { + return false; + } + + public static void RegisterPlatformHandlers(ObjectContainerBase container) + { + EnumTypeHandler enumTypeHandler = new EnumTypeHandler(); + container.ConfigImpl.RegisterTypeHandler(new EnumTypeHandlerPredicate(), enumTypeHandler); + container.Handlers.RegisterHandlerVersion(enumTypeHandler, 4, new StandardReferenceTypeHandler()); + container.Handlers.RegisterHandlerVersion(enumTypeHandler, 0, new StandardReferenceTypeHandler0()); + + GuidTypeHandler guidTypeHandler = new GuidTypeHandler(); + container.ConfigImpl.RegisterTypeHandler(new SingleClassTypeHandlerPredicate(typeof(Guid)), guidTypeHandler); + container.Handlers.RegisterHandlerVersion(guidTypeHandler, 8, new StandardReferenceTypeHandler()); + + DateTimeHandler dateTimeHandler = new DateTimeHandler(); + container.Handlers.RegisterNetTypeHandler(dateTimeHandler); + container.Handlers.RegisterHandlerVersion(dateTimeHandler, 6, new DateTimeHandler6()); + +#if !CF + DateTimeOffsetTypeHandler dateTimeOffsetHandler = new DateTimeOffsetTypeHandler(); + container.ConfigImpl.RegisterTypeHandler(new SingleClassTypeHandlerPredicate(typeof(DateTimeOffset)), dateTimeOffsetHandler); + container.Handlers.RegisterHandlerVersion(dateTimeOffsetHandler, 9, new StandardReferenceTypeHandler()); +#endif + } + + public static Type[] PrimitiveTypes() + { + return PRIMITIVE_TYPES; + } + + public static object NullValue(Type type) + { + if(_nullValues == null) + { + InitNullValues(); + } + + return _nullValues.Get(type); + } + + private static void InitNullValues() + { + _nullValues = new Hashtable4(); + _nullValues.Put(typeof(int), 0); + _nullValues.Put(typeof(uint), (uint)0); + _nullValues.Put(typeof(byte), (byte)0); + _nullValues.Put(typeof(short), (short)0); + _nullValues.Put(typeof(float), (float)0); + _nullValues.Put(typeof(double), (double)0); + _nullValues.Put(typeof(ulong), (ulong)0); + _nullValues.Put(typeof(long), (long)0); + _nullValues.Put(typeof(bool), false); + _nullValues.Put(typeof(char), (char)0); + _nullValues.Put(typeof(sbyte), (sbyte)0); + _nullValues.Put(typeof(decimal), (decimal)0); + _nullValues.Put(typeof(ushort), (ushort)0); + _nullValues.Put(typeof(DateTime), DateTime.MinValue); + + } + + private static Hashtable4 _nullValues; + + public static Type NullableTypeFor(Type primitiveType) + { + if(_primitive2Wrapper == null) + InitPrimitive2Wrapper(); + Type wrapperClazz = (Type)_primitive2Wrapper.Get(primitiveType); + if(wrapperClazz==null) + throw new NotImplementedException(); + return wrapperClazz; + } + + private static void InitPrimitive2Wrapper() + { + _primitive2Wrapper = new Hashtable4(); + + foreach (Type type in PRIMITIVE_TYPES) + { + _primitive2Wrapper.Put(type, ConcreteNullableTypeFor(type)); + } + } + + private static Type ConcreteNullableTypeFor(Type type) + { + return typeof (Nullable<>).MakeGenericType(type); + } + + private static Hashtable4 _primitive2Wrapper; + + private static readonly Type[] PRIMITIVE_TYPES = new Type[] + { + typeof(int), + typeof(uint), + typeof(byte), + typeof(short), + typeof(float), + typeof(double), + typeof(ulong), + typeof(long), + typeof(bool), + typeof(char), + typeof(sbyte), + typeof(decimal), + typeof(ushort), + typeof(DateTime), + }; + + public static void ThrowUncheckedException(Exception exc) + { + throw exc; + } + + public static sbyte ToSByte(byte b) + { + return (sbyte)b; + } + + } +} \ No newline at end of file diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Query/EvaluationDelegateWrapper.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Query/EvaluationDelegateWrapper.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Query/EvaluationDelegateWrapper.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Query/EvaluationDelegateWrapper.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,81 @@ +/* Copyright (C) 2004 Versant Inc. http://www.db4o.com */ + +using System; +using System.Reflection; +using Db4objects.Db4o; +using Db4objects.Db4o.Query; + +namespace Db4objects.Db4o.Internal.Query +{ + // TODO: Use DelegateEnvelope to build a generic delegate translator + internal class DelegateEnvelope + { + System.Type _delegateType; + object _target; + System.Type _type; + string _method; + + [NonSerialized] + Delegate _content; + + public DelegateEnvelope() + { + } + + public DelegateEnvelope(Delegate content) + { + _content = content; + Marshal(); + } + + protected Delegate GetContent() + { + if (null == _content) + { + _content = Unmarshal(); + } + return _content; + } + + private void Marshal() + { + _delegateType = _content.GetType(); + _target = _content.Target; + _method = _content.Method.Name; + _type = _content.Method.DeclaringType; + } + + private Delegate Unmarshal() + { + if (null == _target) + { + return Delegate.CreateDelegate(_delegateType, null, _type.GetMethod(_method, BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public)); + } + + return Delegate.CreateDelegate(_delegateType, _target, _target.GetType().GetMethod(_method, BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public)); + } + } + + internal class EvaluationDelegateWrapper : DelegateEnvelope, IEvaluation + { + public EvaluationDelegateWrapper() + { + } + + public EvaluationDelegateWrapper(EvaluationDelegate evaluation) : base(evaluation) + { + } + + EvaluationDelegate GetEvaluationDelegate() + { + return (EvaluationDelegate)GetContent(); + } + + public void Evaluate(ICandidate candidate) + { + // use starting _ for PascalCase conversion purposes + EvaluationDelegate _evaluation = GetEvaluationDelegate(); + _evaluation(candidate); + } + } +} \ No newline at end of file diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Query/GenericObjectSetFacade.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Query/GenericObjectSetFacade.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Query/GenericObjectSetFacade.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Query/GenericObjectSetFacade.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,190 @@ +/* Copyright (C) 2004 Versant Inc. http://www.db4o.com */ +using System; +using Db4objects.Db4o.Ext; +using Db4objects.Db4o.Internal.Query.Result; + +namespace Db4objects.Db4o.Internal.Query +{ + /// + /// List based objectSet implementation + /// + /// + public class GenericObjectSetFacade : System.Collections.Generic.IList + { + public readonly StatefulQueryResult _delegate; + + public GenericObjectSetFacade(IQueryResult qr) + { + _delegate = new StatefulQueryResult(qr); + } + + #region IList Members + public bool IsReadOnly + { + get + { + return true; + } + } + + public T this[int index] + { + get + { + return (T)_delegate.Get(index); + } + set + { + throw new NotSupportedException(); + } + } + + public void RemoveAt(int index) + { + throw new NotSupportedException(); + } + + public void Insert(int index, T value) + { + throw new NotSupportedException(); + } + + public bool Remove(T value) + { + throw new NotSupportedException(); + } + + public bool Contains(T value) + { + return IndexOf(value) >= 0; + } + + public void Clear() + { + throw new NotSupportedException(); + } + + public int IndexOf(T value) + { + return _delegate.IndexOf(value); + } + + public void Add(T value) + { + throw new NotSupportedException(); + } + + public bool IsFixedSize + { + get + { + return true; + } + } + + #endregion + + #region ICollection Members + public bool IsSynchronized + { + get + { + return true; + } + } + + public int Count + { + get + { + return _delegate.Size(); + } + } + + public void CopyTo(T[] array, int index) + { + lock (this.SyncRoot) + { + int i = 0; + int s = this.Count; + while (i < s) + { + array[index + i] = this[i]; + i++; + } + } + } + + public object SyncRoot + { + get + { + return _delegate.Lock(); + } + } + + #endregion + + #region IEnumerable Members + + class ObjectSetImplEnumerator : System.Collections.IEnumerator, System.Collections.Generic.IEnumerator + { + System.Collections.Generic.IList _result; + int _next = 0; + + public ObjectSetImplEnumerator(System.Collections.Generic.IList result) + { + _result = result; + } + + public void Reset() + { + _next = 0; + } + + object System.Collections.IEnumerator.Current + { + get + { + return _result[_next - 1]; + } + } + + public bool MoveNext() + { + if (_next < _result.Count) + { + ++_next; + return true; + } + return false; + } + + public T Current + { + get + { + return _result[_next - 1]; + } + } + + public void Dispose() + { + } + } + + System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() + { + return new ObjectSetImplEnumerator(this); + } + #endregion + + #region IEnumerable implementation + public System.Collections.Generic.IEnumerator GetEnumerator() + { + return new ObjectSetImplEnumerator(this); + } + #endregion + } +} + diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Query/INQOptimizer.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Query/INQOptimizer.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Query/INQOptimizer.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Query/INQOptimizer.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,10 @@ +using System.Reflection; +using Db4objects.Db4o.Query; + +namespace Db4objects.Db4o.Internal.Query +{ + public interface INQOptimizer + { + void Optimize(IQuery q, object predicate, MethodBase method); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Query/NativeQueryHandler.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Query/NativeQueryHandler.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Query/NativeQueryHandler.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Query/NativeQueryHandler.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,230 @@ +/* Copyright (C) 2004 Versant Inc. http://www.db4o.com */ +using System; +using System.IO; +using System.Reflection; +using Db4objects.Db4o.Diagnostic; +using Db4objects.Db4o.Query; +using Db4objects.Db4o.Internal.Query.Result; +using Db4objects.Db4o.Internal.Query.Processor; +using Db4objects.Db4o.Internal.Diagnostic; + +namespace Db4objects.Db4o.Internal.Query +{ + public class NativeQueryHandler + { + private IObjectContainer _container; + + private INQOptimizer _builder; + + public event QueryExecutionHandler QueryExecution; + + public event QueryOptimizationFailureHandler QueryOptimizationFailure; + + public NativeQueryHandler(IObjectContainer container) + { + _container = container; + } + + public virtual Db4objects.Db4o.IObjectSet Execute(Db4objects.Db4o.Query.IQuery query, Db4objects.Db4o.Query.Predicate predicate, Db4objects.Db4o.Query.IQueryComparator comparator) + { + Db4objects.Db4o.Query.IQuery q = ConfigureQuery(query, predicate); + q.SortBy(comparator); + return q.Execute(); + } + + public virtual System.Collections.Generic.IList Execute(Db4objects.Db4o.Query.IQuery query, System.Predicate match, + Db4objects.Db4o.Query.IQueryComparator comparator) + { +#if CF + return ExecuteUnoptimized(QueryForExtent(query, comparator), match); +#else + // XXX: check GetDelegateList().Length + // only 1 delegate must be allowed + // although we could use it as a filter chain + // (and) + return ExecuteImpl(query, match, match.Target, match.Method, match, comparator); +#endif + } + + public static System.Collections.Generic.IList ExecuteEnhancedFilter(IObjectContainer container, IDb4oEnhancedFilter predicate) + { + return NQHandler(container).ExecuteEnhancedFilter(predicate); + } + + public System.Collections.Generic.IList ExecuteEnhancedFilter(IDb4oEnhancedFilter filter) + { + IQuery query = _container.Query(); + query.Constrain(typeof(T)); + filter.OptimizeQuery(query); + OnQueryExecution(filter, QueryExecutionKind.PreOptimized); + return WrapQueryResult(query); + } + + private static NativeQueryHandler NQHandler(IObjectContainer container) + { + return ((ObjectContainerBase)container).GetNativeQueryHandler(); + } + + private System.Collections.Generic.IList ExecuteImpl( + Db4objects.Db4o.Query.IQuery query, + object originalPredicate, + object matchTarget, + System.Reflection.MethodBase matchMethod, + System.Predicate match, + Db4objects.Db4o.Query.IQueryComparator comparator) + { + Db4objects.Db4o.Query.IQuery q = QueryForExtent(query, comparator); + try + { + if (OptimizeNativeQueries()) + { + OptimizeQuery(q, matchTarget, matchMethod); + OnQueryExecution(originalPredicate, QueryExecutionKind.DynamicallyOptimized); + + return WrapQueryResult(q); + } + } + catch(FileNotFoundException fnfe) + { + NativeQueryOptimizerNotLoaded(fnfe); + } + catch(TargetInvocationException tie) + { + NativeQueryOptimizerNotLoaded(tie); + } + catch(TypeLoadException tle) + { + NativeQueryOptimizerNotLoaded(tle); + } + catch (System.Exception e) + { + OnQueryOptimizationFailure(e); + + NativeQueryUnoptimized(e); + } + + return ExecuteUnoptimized(q, match); + } + + private void NativeQueryUnoptimized(Exception e) + { + DiagnosticProcessor dp = Container()._handlers.DiagnosticProcessor(); + if (dp.Enabled()) dp.NativeQueryUnoptimized(null, e); + } + + private void NativeQueryOptimizerNotLoaded(Exception exception) + { + DiagnosticProcessor dp = Container()._handlers.DiagnosticProcessor(); + if (dp.Enabled()) dp.NativeQueryOptimizerNotLoaded(Db4o.Diagnostic.NativeQueryOptimizerNotLoaded.NqNotPresent, exception); + } + + private System.Collections.Generic.IList ExecuteUnoptimized(IQuery q, Predicate match) + { + q.Constrain(new GenericPredicateEvaluation(match)); + OnQueryExecution(match, QueryExecutionKind.Unoptimized); + return WrapQueryResult(q); + } + + private Db4objects.Db4o.Query.IQuery QueryForExtent(Db4objects.Db4o.Query.IQuery query, Db4objects.Db4o.Query.IQueryComparator comparator) + { + query.Constrain(typeof(Extent)); + query.SortBy(comparator); + return query; + } + + private static System.Collections.Generic.IList WrapQueryResult(Db4objects.Db4o.Query.IQuery query) + { + IQueryResult queryResult = ((QQuery)query).GetQueryResult(); + return new GenericObjectSetFacade(queryResult); + } + + private Db4objects.Db4o.Query.IQuery ConfigureQuery(Db4objects.Db4o.Query.IQuery query, Db4objects.Db4o.Query.Predicate predicate) + { + IDb4oEnhancedFilter filter = predicate as IDb4oEnhancedFilter; + if (null != filter) + { + filter.OptimizeQuery(query); + OnQueryExecution(predicate, QueryExecutionKind.PreOptimized); + return query; + } + + query.Constrain(predicate.ExtentType()); + + try + { + if (OptimizeNativeQueries()) + { + OptimizeQuery(query, predicate, predicate.GetFilterMethod()); + OnQueryExecution(predicate, QueryExecutionKind.DynamicallyOptimized); + return query; + } + } + catch (System.Exception e) + { + OnQueryOptimizationFailure(e); + + if (OptimizeNativeQueries()) + { + DiagnosticProcessor dp = Container()._handlers.DiagnosticProcessor(); + if (dp.Enabled()) dp.NativeQueryUnoptimized(predicate, e); + } + } + + query.Constrain(new Db4objects.Db4o.Internal.Query.PredicateEvaluation(predicate)); + OnQueryExecution(predicate, QueryExecutionKind.Unoptimized); + return query; + } + + private ObjectContainerBase Container() + { + return ((ObjectContainerBase)_container); + } + + private bool OptimizeNativeQueries() + { + return _container.Ext().Configure().OptimizeNativeQueries(); + } + + void OptimizeQuery(Db4objects.Db4o.Query.IQuery q, object predicate, System.Reflection.MethodBase filterMethod) + { + if (_builder == null) + _builder = NQOptimizerFactory.CreateExpressionBuilder(); + + _builder.Optimize(q, predicate, filterMethod); + } + + private void OnQueryExecution(object predicate, QueryExecutionKind kind) + { + if (null == QueryExecution) return; + QueryExecution(this, new QueryExecutionEventArgs(predicate, kind)); + } + + private void OnQueryOptimizationFailure(System.Exception e) + { + if (null == QueryOptimizationFailure) return; + QueryOptimizationFailure(this, new QueryOptimizationFailureEventArgs(e)); + } + } + + class GenericPredicateEvaluation : DelegateEnvelope, Db4objects.Db4o.Query.IEvaluation + { + public GenericPredicateEvaluation() + { + // for db4o c/s when CallConstructors == true + } + + public GenericPredicateEvaluation(System.Predicate predicate) + : base(predicate) + { + } + + public void Evaluate(Db4objects.Db4o.Query.ICandidate candidate) + { + // use starting _ for PascalCase conversion purposes + System.Predicate _predicate = (System.Predicate)GetContent(); + candidate.Include(_predicate((T)candidate.GetObject())); + } + } +} + + diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Query/NQOptimizerFactory.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Query/NQOptimizerFactory.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Query/NQOptimizerFactory.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Query/NQOptimizerFactory.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,15 @@ +/* Copyright (C) 2006 Versant Inc. http://www.db4o.com */ + +namespace Db4objects.Db4o.Internal.Query +{ + using System; + + public class NQOptimizerFactory + { + public static INQOptimizer CreateExpressionBuilder() + { + Type type = Type.GetType("Db4objects.Db4o.NativeQueries.NQOptimizer, Db4objects.Db4o.NativeQueries", true); + return (INQOptimizer)Activator.CreateInstance(type); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Query/ObjectSetFacade.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Query/ObjectSetFacade.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Query/ObjectSetFacade.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Query/ObjectSetFacade.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,235 @@ +/* Copyright (C) 2004 Versant Inc. http://www.db4o.com */ +using System; +using System.Collections; +using Db4objects.Db4o.Ext; +using Db4objects.Db4o.Internal.Query.Result; + +namespace Db4objects.Db4o.Internal.Query +{ + /// + /// List based objectSet implementation + /// + /// + public class ObjectSetFacade : IExtObjectSet, System.Collections.IList + { + public readonly StatefulQueryResult _delegate; + + public ObjectSetFacade(IQueryResult qr) + { + _delegate = new StatefulQueryResult(qr); + } + + #region IObjectSet Members + + public Object Get(int index) + { + return _delegate.Get(index); + } + + public void Sort(Db4objects.Db4o.Query.IQueryComparator cmp) + { + _delegate.Sort(cmp); + } + + public long[] GetIDs() + { + return _delegate.GetIDs(); + } + + public IExtObjectSet Ext() + { + return this; + } + + public bool MoveNext() + { + return Enumerator().MoveNext(); + } + + private IEnumerator _enumerator; + + private IEnumerator Enumerator() + { + if (null == _enumerator) + { + _enumerator = GetEnumerator(); + } + return _enumerator; + } + + public object Current + { + get { return Enumerator().Current; } + } + + public bool HasNext() + { + return _delegate.HasNext(); + } + + public Object Next() + { + return _delegate.Next(); + } + + public void Reset() + { + _delegate.Reset(); + } + + public int Size() + { + return _delegate.Size(); + } + + private Object Lock() + { + return _delegate.Lock(); + } + + private IObjectContainer ObjectContainer() + { + return _delegate.ObjectContainer(); + } + + public StatefulQueryResult Delegate_() + { + return _delegate; + } + #endregion + + #region IList Members + + public bool IsReadOnly + { + get + { + return true; + } + } + + public object this[int index] + { + get + { + return _delegate.Get(index); + } + set + { + throw new NotSupportedException(); + } + } + + public void RemoveAt(int index) + { + throw new NotSupportedException(); + } + + public void Insert(int index, object value) + { + throw new NotSupportedException(); + } + + public void Remove(object value) + { + throw new NotSupportedException(); + } + + public bool Contains(object value) + { + return IndexOf(value) >= 0; + } + + public void Clear() + { + throw new NotSupportedException(); + } + + public int IndexOf(object value) + { + return _delegate.IndexOf(value); + } + + public int Add(object value) + { + throw new NotSupportedException(); + } + + public bool IsFixedSize + { + get + { + return true; + } + } + + #endregion + + #region ICollection Members + public bool IsSynchronized + { + get + { + return true; + } + } + + public int Count + { + get + { + return Size(); + } + } + + public void CopyTo(Array array, int index) + { + lock (Lock()) + { + int i = 0; + int s = _delegate.Size(); + while (i < s) + { + array.SetValue(_delegate.Get(i), index + i); + i++; + } + } + } + + public object SyncRoot + { + get + { + return Lock(); + } + } + + #endregion + + public System.Collections.IEnumerator GetEnumerator() + { + IEnumerator enumerator = _delegate.GetEnumerator(); + object current; + while (MoveNext(enumerator, out current)) + { + yield return current; + } + } + + private bool MoveNext(IEnumerator enumerator, out object current) + { + lock (_delegate.Lock()) + { + if (enumerator.MoveNext()) + { + current = enumerator.Current; + return true; + } + } + current = null; + return false; + } + } +} + + diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Query/QueryExecutionHandler.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Query/QueryExecutionHandler.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Query/QueryExecutionHandler.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Query/QueryExecutionHandler.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,34 @@ +/* Copyright (C) 2007 Versant Inc. http://www.db4o.com */ +namespace Db4objects.Db4o.Internal.Query +{ + public enum QueryExecutionKind + { + Unoptimized, + DynamicallyOptimized, + PreOptimized + } + + public class QueryExecutionEventArgs : System.EventArgs + { + private object _predicate; + private QueryExecutionKind _kind; + + public QueryExecutionEventArgs(object predicate, QueryExecutionKind kind) + { + _predicate = predicate; + _kind = kind; + } + + public object Predicate + { + get { return _predicate; } + } + + public QueryExecutionKind ExecutionKind + { + get { return _kind; } + } + } + + public delegate void QueryExecutionHandler(object sender, QueryExecutionEventArgs args); +} \ No newline at end of file diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Query/QueryOptimizationFailureHandler.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Query/QueryOptimizationFailureHandler.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Query/QueryOptimizationFailureHandler.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Query/QueryOptimizationFailureHandler.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,20 @@ +/* Copyright (C) 2007 Versant Inc. http://www.db4o.com */ +namespace Db4objects.Db4o.Internal.Query +{ + public class QueryOptimizationFailureEventArgs : System.EventArgs + { + System.Exception _reason; + + public QueryOptimizationFailureEventArgs(System.Exception e) + { + _reason = e; + } + + public System.Exception Reason + { + get { return _reason; } + } + } + + public delegate void QueryOptimizationFailureHandler(object sender, QueryOptimizationFailureEventArgs args); +} \ No newline at end of file diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Query/SilverlightArrayListExtensions.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Query/SilverlightArrayListExtensions.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Query/SilverlightArrayListExtensions.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Query/SilverlightArrayListExtensions.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,14 @@ +using System.Collections; + +namespace Db4objects.Db4o.Internal.Query +{ +#if SILVERLIGHT + public static class SilverlightArrayListExtensions + { + public static void Sort(this ArrayList self, IComparer comparer) + { + self.Sort(comparer.Compare); + } + } +#endif +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Reflect/Emitters/AccessorFactory.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Reflect/Emitters/AccessorFactory.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Reflect/Emitters/AccessorFactory.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Reflect/Emitters/AccessorFactory.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,67 @@ +using System; +using System.Collections.Generic; +using System.Reflection; + +namespace Db4objects.Db4o.Internal.Reflect.Emitters +{ +#if !CF + public delegate void Setter(object o, object value); + public delegate object Getter(object o); + + public static class AccessorFactory + { + private static readonly Dictionary _getters = new Dictionary(); + private static readonly Dictionary _setters = new Dictionary(); + + public static Setter SetterFor(FieldInfo field) + { + return Produce(_setters, field, EmitSetter); + } + + public static Getter GetterFor(FieldInfo field) + { + return Produce(_getters, field, EmitGetter); + } + + private delegate TEmitter Producer(FieldInfo field); + + private static TEmitter Produce(Dictionary cache, FieldInfo field, Producer producer) + { + TEmitter emitter; + lock (cache) + { + if (!cache.TryGetValue(field, out emitter)) + { + emitter = producer(field); + cache[field] = emitter; + } + } + return emitter; + } + + private static Setter EmitSetter(FieldInfo field) + { + try + { + return new SetFieldEmitter(field).Emit(); + } + catch + { + return delegate { }; + } + } + + private static Getter EmitGetter(FieldInfo field) + { + try + { + return new GetFieldEmitter(field).Emit(); + } + catch + { + return delegate { return null; }; + } + } + } +#endif +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Reflect/Emitters/Emitter.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Reflect/Emitters/Emitter.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Reflect/Emitters/Emitter.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Reflect/Emitters/Emitter.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,50 @@ +/* Copyright (C) 2004 - 2008 Versant Inc. http://www.db4o.com */ + +using System; +using System.Reflection; +#if !CF +using System.Reflection.Emit; +#endif + +namespace Db4objects.Db4o.Internal.Reflect.Emitters +{ +#if !CF + internal class Emitter + { + private readonly DynamicMethod _dynamicMethod; + protected readonly FieldInfo _field; + protected readonly ILGenerator _il; + + public Emitter(FieldInfo field, Type returnType, Type[] paramTypes) + { + _field = field; + _dynamicMethod = new DynamicMethod(_field.DeclaringType.Name + "$" + _field.Name, returnType, paramTypes, _field.DeclaringType); + _il = _dynamicMethod.GetILGenerator(); + } + + protected void BoxIfNeeded(Type type) + { + if (!type.IsValueType) return; + _il.Emit(OpCodes.Box, type); + } + + protected void EmitLoadTargetObject(Type expectedType) + { + _il.Emit(OpCodes.Ldarg_0); // target object is the first argument + if (expectedType.IsValueType) + { + _il.Emit(OpCodes.Unbox, expectedType); + } + else + { + _il.Emit(OpCodes.Castclass, expectedType); + } + } + + protected Delegate CreateDelegate() + { + return _dynamicMethod.CreateDelegate(typeof(T)); + } + } +#endif +} \ No newline at end of file diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Reflect/Emitters/GetFieldEmitter.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Reflect/Emitters/GetFieldEmitter.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Reflect/Emitters/GetFieldEmitter.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Reflect/Emitters/GetFieldEmitter.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,50 @@ +/* Copyright (C) 2004 - 2008 Versant Inc. http://www.db4o.com */ + +using System; +using System.Reflection; +#if !CF +using System.Reflection.Emit; +#endif +using System.Runtime.CompilerServices; + +namespace Db4objects.Db4o.Internal.Reflect.Emitters +{ +#if !CF + class GetFieldEmitter : Emitter + { + public GetFieldEmitter(FieldInfo field) : base(field, typeof(object), new Type[] { typeof(object) }) + { + } + + public Getter Emit() + { + EmitMethodBody(); + return (Getter)CreateDelegate (); + } + + private void EmitMethodBody() + { + if (_field.IsStatic) + { + // make sure type is initialized before + // accessing any static fields + RuntimeHelpers.RunClassConstructor(_field.DeclaringType.TypeHandle); + _il.Emit(OpCodes.Ldsfld, _field); + } + else + { + EmitLoadTargetObject(_field.DeclaringType); + _il.Emit(OpCodes.Ldfld, _field); + } + + EmitReturn(); + } + + protected void EmitReturn() + { + BoxIfNeeded(_field.FieldType); + _il.Emit(OpCodes.Ret); + } + } +#endif +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Reflect/Emitters/SetFieldEmitter.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Reflect/Emitters/SetFieldEmitter.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Reflect/Emitters/SetFieldEmitter.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Reflect/Emitters/SetFieldEmitter.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,79 @@ +/* Copyright (C) 2004 - 2008 Versant Inc. http://www.db4o.com */ + +using System; +using System.Reflection; +#if !CF +using System.Reflection.Emit; +#endif + +namespace Db4objects.Db4o.Internal.Reflect.Emitters +{ +#if !CF + class SetFieldEmitter : Emitter + { + public SetFieldEmitter(FieldInfo field) : base(field, typeof(void), new Type[] { typeof(object), typeof(object) }) + { + } + + public Setter Emit() + { + EmitMethodBody(); + return (Setter) CreateDelegate(); + } + + private void EmitMethodBody() + { + if (_field.IsStatic) + { + EmitLoadValue(); + _il.Emit(OpCodes.Stsfld, _field); + } + else + { + EmitLoadTargetObject(_field.DeclaringType); + EmitLoadValue(); + _il.Emit(OpCodes.Stfld, _field); + } + _il.Emit(OpCodes.Ret); + } + + private void EmitLoadValue() + { + if (_field.FieldType.IsValueType) + { + EmitLoadValueType(); + } + else + { + EmitLoadReferenceType(); + } + + } + + private void EmitLoadReferenceType() + { + _il.Emit(OpCodes.Ldarg_1); + _il.Emit(OpCodes.Castclass, _field.FieldType); + } + + private void EmitLoadValueType() + { + Type fieldType = _field.FieldType; + + _il.Emit(OpCodes.Ldarg_1); + Label nonNull = _il.DefineLabel(); + _il.Emit(OpCodes.Brtrue_S, nonNull); + + _il.DeclareLocal(fieldType); + _il.Emit(OpCodes.Ldloc_0); + Label end = _il.DefineLabel(); + _il.Emit(OpCodes.Br_S, end); + _il.MarkLabel(nonNull); + _il.Emit(OpCodes.Ldarg_1); + _il.Emit(OpCodes.Unbox, fieldType); + _il.Emit(OpCodes.Ldobj, fieldType); + _il.MarkLabel(end); + } + } +#endif +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Reflect/FastNetReflector.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Reflect/FastNetReflector.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Reflect/FastNetReflector.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/Reflect/FastNetReflector.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,84 @@ +/* Copyright (C) 2004 - 2008 Versant Inc. http://www.db4o.com */ + +using System; +using System.Reflection; +using Db4objects.Db4o.Ext; +using Db4objects.Db4o.Internal.Reflect.Emitters; +using Db4objects.Db4o.Reflect; +using Db4objects.Db4o.Reflect.Net; + +namespace Db4objects.Db4o.Internal.Reflect +{ +#if !CF + public class FastNetReflector : NetReflector + { + override protected IReflectClass CreateClass(Type forType) + { + return new FastNetClass(Parent(), this, forType); + } + + public override object DeepClone(object obj) + { + return new FastNetReflector(); + } + } + + class FastNetClass : NetClass + { + public FastNetClass(IReflector reflector, NetReflector netReflector, Type clazz) : base(reflector, netReflector, clazz) + { + } + + protected override IReflectField CreateField(FieldInfo field) + { + return new FastNetField(_reflector, field); + } + } + + class FastNetField : NetField + { + private Getter _getter; + private Setter _setter; + + public FastNetField(IReflector reflector, FieldInfo field) : base(reflector, field) + { + } + + public override object Get(object onObject) + { + if (null == _getter) _getter = AccessorFactory.GetterFor(_field); + try + { + return _getter(onObject); + } + catch (FieldAccessException) + { + _getter = _field.GetValue; + return _getter(onObject); + } + catch (Exception e) + { + throw new Db4oException(e); + } + } + + public override void Set(object onObject, object attribute) + { + if (null == _setter) _setter = AccessorFactory.SetterFor(_field); + try + { + _setter(onObject, attribute); + } + catch (FieldAccessException) + { + _setter = _field.SetValue; + _setter(onObject, attribute); + } + catch (Exception e) + { + throw new Db4oException(e); + } + } + } +#endif +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/ReflectPlatform.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/ReflectPlatform.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/ReflectPlatform.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/ReflectPlatform.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,54 @@ +/* Copyright (C) 2007 Versant Inc. http://www.db4o.com */ + +using System; +using Sharpen.Lang; + +namespace Db4objects.Db4o.Internal +{ + public class ReflectPlatform + { + public static Type ForName(string typeName) + { + try + { + return TypeReference.FromString(typeName).Resolve(); + } + catch + { + return null; + } + } + + public static object CreateInstance(string typeName) + { + return ReflectPlatform.CreateInstance(ForName(typeName)); + } + + public static object CreateInstance(Type type) + { + try + { + return Activator.CreateInstance(type); + } + catch + { + return null; + } + } + + public static string FullyQualifiedName(Type type) + { + return TypeReference.FromType(type).GetUnversionedName(); + } + + public static bool IsNamedClass(Type type) + { + return true; + } + + public static string SimpleName(Type type) + { + return type.Name; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/TagAttribute.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/TagAttribute.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/TagAttribute.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/TagAttribute.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,21 @@ +/* Copyright (C) 2007 Versant Inc. http://www.db4o.com */ +using System; + +namespace Db4objects.Db4o.Internal +{ + [AttributeUsage(AttributeTargets.All, AllowMultiple = true)] + public class TagAttribute : Attribute + { + public TagAttribute(string tag) + { + this.tag = tag; + } + + public string Tag + { + get { return tag; } + } + + private string tag; + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/TypeHandlerConfigurationDotNet.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/TypeHandlerConfigurationDotNet.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/TypeHandlerConfigurationDotNet.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Internal/TypeHandlerConfigurationDotNet.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,129 @@ +/* Copyright (C) 2009 Versant Inc. http://www.db4o.com */ + +using System; +using System.Collections.Generic; +using Db4objects.Db4o.Collections; +using Db4objects.Db4o.Internal.Collections; +using Db4objects.Db4o.Reflect; +using Db4objects.Db4o.Reflect.Net; +using Db4objects.Db4o.Typehandlers; + +namespace Db4objects.Db4o.Internal +{ + class TypeHandlerConfigurationDotNet : TypeHandlerConfiguration + { + public TypeHandlerConfigurationDotNet(Config4Impl config) : base(config) + { + ListTypeHandler(new CollectionTypeHandler()); + MapTypeHandler(new MapTypeHandler()); + } + + public override void Apply() + { +#if !SILVERLIGHT + RegisterCollection(typeof(System.Collections.ArrayList)); + RegisterCollection(typeof (System.Collections.CollectionBase)); + RegisterMap(typeof (System.Collections.Hashtable)); + RegisterMap(typeof (System.Collections.Specialized.HybridDictionary)); +#if !CF + RegisterMap(typeof (System.Collections.DictionaryBase)); +#endif +#endif + RegisterGenericTypeHandlers(); + RegisterBigSetTypeHandler(); + RegisterSystemArrayTypeHandler(); + } + + private void RegisterBigSetTypeHandler() + { + RegisterGenericTypeHandler(typeof(BigSet<>), new BigSetTypeHandler()); + } + + private void RegisterGenericTypeHandlers() + { + GenericCollectionTypeHandler handler = new GenericCollectionTypeHandler(); + handler.RegisterSupportedTypesWith(delegate(Type type) + { + RegisterGenericTypeHandler(type, handler); + }); + +#if NET_3_5 && ! CF + _config.Reflector().RegisterCollection(new GenericCollectionTypePredicate(typeof(HashSet<>))); +#endif + + Type[] dictionaryTypes = new Type[] { + typeof(ActivatableDictionary<,>), + typeof(Dictionary<,>), +#if !SILVERLIGHT + typeof(SortedList<,>), +#if !CF + typeof(SortedDictionary<,>), +#endif +#endif + }; + _config.RegisterTypeHandler(new GenericTypeHandlerPredicate(dictionaryTypes), new MapTypeHandler()); + + } + + private void RegisterGenericTypeHandler(Type genericTypeDefinition, ITypeHandler4 handler) + { + _config.RegisterTypeHandler(new GenericTypeHandlerPredicate(genericTypeDefinition), handler); + } + + internal class GenericTypeHandlerPredicate : ITypeHandlerPredicate + { + private readonly Type[] _genericTypes; + + internal GenericTypeHandlerPredicate(params Type[] genericType) + { + _genericTypes = genericType; + } + + public bool Match(IReflectClass classReflector) + { + Type type = NetReflector.ToNative(classReflector); + if (type == null) + { + return false; + } + + if (!type.IsGenericType) + { + return false; + } + return ((IList) _genericTypes).Contains(type.GetGenericTypeDefinition()); + } + } + + private void RegisterSystemArrayTypeHandler() + { + _config.RegisterTypeHandler(new SystemArrayPredicate(), new SystemArrayTypeHandler()); + } + + internal class GenericCollectionTypePredicate : IReflectClassPredicate + { + private readonly Type _type; + + internal GenericCollectionTypePredicate(Type t) + { + _type = t; + } + + + public bool Match(IReflectClass classReflector) + { + Type type = NetReflector.ToNative(classReflector); + if (type == null) + { + return false; + } + if (!type.IsGenericType) + { + return false; + } + return _type == type.GetGenericTypeDefinition(); + } + } + + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/IO/RandomAccessFileFactory.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/IO/RandomAccessFileFactory.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/IO/RandomAccessFileFactory.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/IO/RandomAccessFileFactory.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,43 @@ +using System; +using System.IO; +using Db4objects.Db4o.Ext; +using Db4objects.Db4o.Internal; +using Sharpen.IO; +using File=Sharpen.IO.File; + +namespace Db4objects.Db4o.IO +{ + public class RandomAccessFileFactory + { + public static RandomAccessFile NewRandomAccessFile(String path, bool readOnly, bool lockFile) + { + RandomAccessFile raf = null; + bool ok = false; + try + { + raf = new RandomAccessFile(path, readOnly, lockFile); + if (lockFile) + { + Platform4.LockFile(path, raf); + } + ok = true; + return raf; + } + catch (IOException x) + { + if (new File(path).Exists()) + { + throw new DatabaseFileLockedException(path, x); + } + throw new Db4oIOException(x); + } + finally + { + if(!ok && raf != null) + { + raf.Close(); + } + } + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/IObjectContainer.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/IObjectContainer.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/IObjectContainer.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/IObjectContainer.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,496 @@ +/* Copyright (C) 2004 - 1010 Versant Inc. http://www.db4o.com */ +using Db4objects.Db4o.Qlin; +using Db4objects.Db4o.Query; + +namespace Db4objects.Db4o +{ + /// the interface to a db4o database, stand-alone or client/server. + /// + /// the interface to a db4o database, stand-alone or client/server. + ///

The IObjectContainer interface provides methods + /// to store, query and delete objects and to commit and rollback + /// transactions.

+ /// An IObjectContainer can either represent a stand-alone database + /// or a connection to a + /// db4o server + /// . + ///

An IObjectContainer also represents a transaction. All work + /// with db4o always is transactional. Both + /// Db4objects.Db4o.IObjectContainer.Commit + /// and + /// Db4objects.Db4o.IObjectContainer.Rollback + /// start new transactions immediately. For working + /// against the same database with multiple transactions, open a db4o server + /// with + /// Db4objects.Db4o.Db4o.OpenServer + /// and + /// connect locally + /// or + /// over TCP + /// . + ///
+ /// IExtObjectContainer for extended functionality. + /// + public interface IObjectContainer : System.IDisposable, ISodaQueryFactory + { + /// activates all members on a stored object to the specified depth. + /// + /// activates all members on a stored object to the specified depth. + ///

+ /// See + /// "Why activation" + /// for an explanation why activation is necessary.

+ /// The activate method activates a graph of persistent objects in memory. + /// Only deactivated objects in the graph will be touched: their + /// fields will be loaded from the database. + /// The activate methods starts from a + /// root object and traverses all member objects to the depth specified by the + /// depth parameter. The depth parameter is the distance in "field hops" + /// (object.field.field) away from the root object. The nodes at 'depth' level + /// away from the root (for a depth of 3: object.member.member) will be instantiated + /// but deactivated, their fields will be null. + /// The activation depth of individual classes can be overruled + /// with the methods + /// MaximumActivationDepth() + /// + /// and + /// MinimumActivationDepth() + /// + /// in the + /// ObjectClass interface + /// .

+ /// A successful call to activate triggers Activating and Activated callback methods, + /// which can be used for cascaded activation.

+ ///
+ /// Why activation? + /// Using callbacks + /// the object to be activated. + /// + /// the member + /// depth + /// to which activate is to cascade. + /// + void Activate(object obj, int depth); + + /// closes this IObjectContainer. + /// + /// closes this IObjectContainer. + ///

A call to Close() automatically performs a + /// Commit() + /// . + ///

Note that every session opened with Db4oFactory.OpenFile() requires one + /// Close()call, even if the same filename was used multiple times.

+ /// Use while(!Close()){} to kill all sessions using this container.

+ ///
+ /// + /// success - true denotes that the last used instance of this container + /// and the database file were closed. + /// + bool Close(); + + /// commits the running transaction. + /// + /// commits the running transaction. + ///

Transactions are back-to-back. A call to commit will starts + /// a new transaction immedidately. + ///
+ void Commit(); + + /// deactivates a stored object by setting all members to NULL. + /// + /// + /// deactivates a stored object by setting all members to NULL. + ///
Primitive types will be set to their default values. + /// Calls to this method save memory. + /// The method has no effect, if the passed object is not stored in the + /// IObjectContainer.

+ /// Deactivate() triggers Deactivating and Deactivated callbacks. + ///

+ /// Be aware that calling this method with a depth parameter greater than + /// 1 sets members on member objects to null. This may have side effects + /// in other places of the application.

+ ///
+ /// Using callbacks + /// Why activation? + /// the object to be deactivated. + /// + /// the member + /// depth + /// + /// to which deactivate is to cascade. + /// + void Deactivate(object obj, int depth); + + /// deletes a stored object permanently. + /// + /// deletes a stored object permanently. + ///

Note that this method has to be called for every single object + /// individually. Delete does not recurse to object members. Simple + /// and array member types are destroyed. + ///

Object members of the passed object remain untouched, unless + /// cascaded deletes are + /// configured for the class + /// or for + /// one of the member fields + /// . + ///

The method has no effect, if + /// the passed object is not stored in the IObjectContainer. + ///

A subsequent call to + /// Store() with the same object newly stores the object + /// to the IObjectContainer.

+ /// Delete() triggers Deleting and Deleted callbacks, + /// which can be also used for cascaded deletes.

+ ///
+ /// Db4objects.Db4o.Config.IObjectClass.CascadeOnDelete + /// + /// Db4objects.Db4o.Config.IObjectField.CascadeOnDelete + /// + /// Using callbacks + /// + /// the object to be deleted from the + /// IObjectContainer.
+ /// + void Delete(object obj); + + /// returns an IObjectContainer with extended functionality. + /// + /// returns an IObjectContainer with extended functionality. + ///

Every IObjectContainer that db4o provides can be casted to + /// an IExtObjectContainer. This method is supplied for your convenience + /// to work without a cast. + ///

The IObjectContainer functionality is split to two interfaces + /// to allow newcomers to focus on the essential methods.

+ ///
+ /// this, casted to IExtObjectContainer + Db4objects.Db4o.Ext.IExtObjectContainer Ext(); + + /// Query-By-Example interface to retrieve objects. + /// + /// Query-By-Example interface to retrieve objects. + ///

QueryByExample() creates an + /// IObjectSet + /// containing + /// all objects in the IObjectContainer that match the passed + /// template object.

+ /// Calling QueryByExample(null) returns all objects stored in the + /// IObjectContainer.


+ /// Query Evaluation + ///
All non-null members of the template object are compared against + /// all stored objects of the same class. + /// Primitive type members are ignored if they are 0 or false respectively. + ///

Arrays and all supported Collection classes are + /// evaluated for containment. Differences in Length/Count/Size() are + /// ignored. + ///

Consult the documentation of the IConfiguration package to + /// configure class-specific behaviour.


+ /// Returned Objects
+ /// The objects returned in the + /// IObjectSet + /// are instantiated + /// and activated to the preconfigured depth of 5. The + /// activation depth + /// may be configured + /// globally + /// or + /// individually for classes + /// . + ///

+ /// db4o keeps track of all instantiatied objects. Queries will return + /// references to these objects instead of instantiating them a second time. + ///

+ /// Objects newly activated by QueryByExample() can respond to the Activating callback + /// method. + ///

+ ///
+ /// object to be used as an example to find all matching objects.

+ /// + /// + /// + /// IObjectSet + /// containing all found objects.

+ ///
+ /// Why activation? + /// Using callbacks + Db4objects.Db4o.IObjectSet QueryByExample(object template); + + + /// + /// creates a new SODA + /// Query + /// . + ///

+ /// Linq queries are the recommended main db4o query interface. + ///

+ /// Use + /// QueryByExample(Object template) + /// for simple Query-By-Example.

+ ///
+ /// a new IQuery object + Db4objects.Db4o.Query.IQuery Query(); + + /// queries for all instances of a class. + /// queries for all instances of a class. + /// the class to query for. + /// + /// the + /// Db4objects.Db4o.IObjectSet + /// returned by the query. + /// + Db4objects.Db4o.IObjectSet Query(System.Type clazz); + + /// Native Query Interface. + /// + /// Native Query Interface. + ///

Native Queries allow typesafe, compile-time checked and refactorable + /// querying, following object-oriented principles. Native Queries expressions + /// are written as if one or more lines of code would be run against all + /// instances of a class. A Native Query expression should return true to mark + /// specific instances as part of the result set. + /// db4o will attempt to optimize native query expressions and execute them + /// against indexes and without instantiating actual objects, where this is + /// possible.

+ /// Example:

+ /// + ///
+ /// IList <Cat> cats = db.Query <Cat> (delegate(Cat cat) {
+ ///    return cat.Name == "Occam";
+ /// });
+ ///
+ /// Summing up the above:
+ /// In order to run a Native Query, you can use the delegate notation + /// with a delegate method taking the extend type as a parameter and + /// returning bool. True is returned for the objects that are to be included in the result.
+ ///

+ ///
+ /// + /// the + /// Db4objects.Db4o.Query.Predicate + /// containing the native query expression. + /// + /// + /// the + /// Db4objects.Db4o.IObjectSet + /// returned by the query. + /// + Db4objects.Db4o.IObjectSet Query(Db4objects.Db4o.Query.Predicate predicate); + + /// Native Query Interface. + /// + /// Native Query Interface. Queries as with + /// Db4objects.Db4o.IObjectContainer.Query(Predicate) + /// , + /// but will sort the resulting + /// Db4objects.Db4o.IObjectSet + /// according to the given + /// Db4objects.Db4o.Query.IQueryComparator + /// . + /// + /// + /// the + /// Db4objects.Db4o.Query.Predicate + /// containing the native query expression. + /// + /// + /// the + /// Db4objects.Db4o.Query.IQueryComparator + /// specifiying the sort order of the result + /// + /// + /// the + /// Db4objects.Db4o.IObjectSet + /// returned by the query. + /// + Db4objects.Db4o.IObjectSet Query(Db4objects.Db4o.Query.Predicate predicate, Db4objects.Db4o.Query.IQueryComparator + comparator); + + /// Native Query Interface. + /// + /// Native Query Interface. Queries as with + /// Db4objects.Db4o.IObjectContainer.Query(Predicate) + /// , + /// but will sort the resulting + /// Db4objects.Db4o.IObjectSet + /// according to the given + /// System.Collections.IComparer + /// . + /// + /// + /// the + /// Db4objects.Db4o.Query.Predicate + /// containing the native query expression. + /// + /// + /// the + /// System.Collections.IComparer + /// specifiying the sort order of the result + /// + /// + /// the + /// Db4objects.Db4o.IObjectSet + /// returned by the query. + /// + Db4objects.Db4o.IObjectSet Query(Db4objects.Db4o.Query.Predicate predicate, System.Collections.IComparer comparer); + + /// rolls back the running transaction. + /// + /// rolls back the running transaction. + ///

Transactions are back-to-back. A call to rollback will starts + /// a new transaction immedidately. + ///

rollback will not restore modified objects in memory. They + /// can be refreshed from the database by calling + /// Db4objects.Db4o.Ext.IExtObjectContainer.Refresh + /// + /// . + ///
+ void Rollback(); + + /// newly stores objects or updates stored objects. + /// + /// newly stores objects or updates stored objects. + ///

An object not yet stored in the IObjectContainer will be + /// stored when it is passed to Store(). An object already stored + /// in the IObjectContainer will be updated. + ///

Updates
+ /// - will affect all simple type object members.
+ /// - links to object members that are already stored will be updated.
+ /// - new object members will be newly stored. The algorithm traverses down + /// new members, as long as further new members are found.
+ /// - object members that are already stored will not be updated + /// themselves.
Every object member needs to be updated individually with a + /// call to Store() unless a deep + /// global + /// or + /// class-specific + /// update depth was configured or cascaded updates were + /// defined in the class + /// or in + /// one of the member fields + /// . + /// Depending if the passed object is newly stored or updated, Creating/Created or + /// Updaing/Updated callback method is triggered. + /// Callbacks + /// might also be used for cascaded updates.

+ ///
+ /// the object to be stored or updated. + /// IExtObjectContainer#Store(object, depth) + /// + /// Db4objects.Db4o.Config.IConfiguration.UpdateDepth + /// + /// Db4objects.Db4o.Config.IObjectClass.UpdateDepth + /// + /// Db4objects.Db4o.Config.IObjectClass.CascadeOnUpdate + /// + /// Db4objects.Db4o.Config.IObjectField.CascadeOnUpdate + /// + /// Using callbacks + void Store(object obj); + + /// .NET 2.0 Native Query interface. + /// + /// Native Query Interface. + ///

Native Queries allow typesafe, compile-time checked and refactorable + /// querying, following object-oriented principles. Native Queries expressions + /// are written as if one or more lines of code would be run against all + /// instances of a class. A Native Query expression should return true to mark + /// specific instances as part of the result set. + /// db4o will attempt to optimize native query expressions and execute them + /// against indexes and without instantiating actual objects, where this is + /// possible.

+ /// Example:

+ /// + ///
+ /// IList <Cat> cats = db.Query <Cat> (delegate(Cat cat) {
+ ///    return cat.Name == "Occam";
+ /// });
+ ///
+ /// Summing up the above:
+ /// In order to run a Native Query, you can use the delegate notation + /// with a delegate method taking the extend type as a parameter and + /// returning bool. True is returned for the objects that are to be included in the result.
+ ///

+ ///
+ /// + /// use an anonymous delegate that takes a single paramter and returns + /// a bool value, see the syntax example above + /// + /// + /// the + /// Db4objects.Db4o.IObjectSet + /// returned by the query. + /// + System.Collections.Generic.IList Query(System.Predicate match); + + /// Native Query Interface. + /// + /// Native Query Interface. Queries as with + /// Db4objects.Db4o.IObjectContainer.Query(Predicate) + /// , + /// but will sort the resulting + /// Db4objects.Db4o.IObjectSet + /// according to the given + /// System.Collections.Generic.IComparer + /// . + /// + /// + /// the + /// Db4objects.Db4o.Query.Predicate + /// containing the native query expression. + /// + /// + /// the + /// System.Collections.Generic.IComparer + /// specifiying the sort order of the result + /// + /// + /// the + /// Db4objects.Db4o.IObjectSet + /// returned by the query. + /// + System.Collections.Generic.IList Query(System.Predicate match, System.Collections.Generic.IComparer comparer); + + /// Native Query Interface. + /// + /// Native Query Interface. Queries as with + /// Db4objects.Db4o.IObjectContainer.Query(Predicate) + /// , + /// but will sort the resulting + /// Db4objects.Db4o.IObjectSet + /// according to the given + /// System.Comparison + /// . + /// + /// + /// the + /// Db4objects.Db4o.Query.Predicate + /// containing the native query expression. + /// + /// + /// the + /// System.Comparison + /// specifiying the sort order of the result + /// + /// + /// the + /// Db4objects.Db4o.IObjectSet + /// returned by the query. + /// + System.Collections.Generic.IList Query(System.Predicate match, System.Comparison comparison); + + /// + /// queries for all instances of the type extent, returning + /// a IList of ElementType which must be assignable from + /// extent. + /// + System.Collections.Generic.IList Query(System.Type extent); + + /// + /// queries for all instances of the type extent. + /// + System.Collections.Generic.IList Query(); + + /// + /// queries for all instances of the type extent sorting with the specified comparer. + /// + System.Collections.Generic.IList Query(System.Collections.Generic.IComparer comparer); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Query/EvaluationDelegate.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Query/EvaluationDelegate.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Query/EvaluationDelegate.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Query/EvaluationDelegate.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,8 @@ +/* Copyright (C) 2004 Versant Inc. http://www.db4o.com */ + +using System; + +namespace Db4objects.Db4o.Query +{ + public delegate void EvaluationDelegate(ICandidate candidate); +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Query/ISodaQueryFactory.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Query/ISodaQueryFactory.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Query/ISodaQueryFactory.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Query/ISodaQueryFactory.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,21 @@ +using Db4objects.Db4o.Query; + +namespace Db4objects.Db4o.Query +{ + public interface ISodaQueryFactory + { + /// + /// creates a new SODA + /// Query + /// . + ///

+ /// Linq queries are the recommended main db4o query interface. + ///

+ /// Use + /// QueryByExample(Object template) + /// for simple Query-By-Example.

+ ///
+ /// a new IQuery object + IQuery Query(); + } +} \ No newline at end of file diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Query/PredicatePlatform.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Query/PredicatePlatform.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Query/PredicatePlatform.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Query/PredicatePlatform.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,22 @@ +using System; + +namespace Db4objects.Db4o.Query +{ + using System.Reflection; + + public sealed class PredicatePlatform + { + public static readonly string PredicatemethodName = "Match"; + + public static bool IsFilterMethod(MethodInfo method) + { + if (method.GetParameters().Length != 1) return false; + return method.Name == PredicatemethodName; + } + + public static T GetField(Object obj, string fieldName) + { + return (T) obj.GetType().GetField(fieldName, BindingFlags.NonPublic | BindingFlags.Instance).GetValue(obj); + } + } +} \ No newline at end of file diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Reflect/Net/NetArray.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Reflect/Net/NetArray.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Reflect/Net/NetArray.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Reflect/Net/NetArray.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,111 @@ +/* Copyright (C) 2007 Versant Inc. http://www.db4o.com */ +using System; + +namespace Db4objects.Db4o.Reflect.Net +{ + public class NetArray : Db4objects.Db4o.Reflect.Core.AbstractReflectArray + { + public NetArray(IReflector reflector) : base(reflector) + { + } + + private static Type GetNetType(IReflectClass clazz) + { + return ((NetClass)clazz).GetNetType(); + } + + public override void Analyze(object obj, ArrayInfo info) + { + info.Nullable(IsNullableType(obj.GetType())); + } + + private bool IsNullableType(Type type) + { + if (type.IsArray) + { + return IsNullableType(type.GetElementType()); + } + + Type underlyingType = Nullable.GetUnderlyingType(type); + return underlyingType != null; + } + + public override object NewInstance(IReflectClass componentType, ArrayInfo info) + { + Type type = GetNetType(componentType); + if (info.Nullable()) + { + type = NullableType(type); + } + MultidimensionalArrayInfo multiDimensionalInfo = info as MultidimensionalArrayInfo; + if (multiDimensionalInfo == null) + { + return System.Array.CreateInstance(type, info.ElementCount()); + } + int[] dimensions = multiDimensionalInfo.Dimensions(); + if (dimensions.Length == 1) + { + return UnfoldArrayCreation(type, dimensions, 0); + } + return UnfoldArrayCreation(GetArrayType(type, dimensions.Length - 1), dimensions, 0); + } + + private Type NullableType(Type type) + { + if(IsNullableType(type)) + { + return type; + } + return typeof(Nullable<>).MakeGenericType(new Type[] { type }); + } + + public override object NewInstance(IReflectClass componentType, int[] dimensions) + { + Type type = GetNetType(componentType); + if (dimensions.Length == 1) + { + return UnfoldArrayCreation(type, dimensions, 0); + } + + return UnfoldArrayCreation(GetArrayType(type, dimensions.Length - 1), dimensions, 0); + } + + private static object UnfoldArrayCreation(Type type, int[] dimensions, int dimensionIndex) + { + int length = dimensions[dimensionIndex]; + Array array = Array.CreateInstance(type, length); + if (dimensionIndex == dimensions.Length - 1) + { + return array; + } + for (int i=0; iReflection implementation for Class to map to .NET reflection. + /// Reflection implementation for Class to map to .NET reflection. + public class NetClass : IConstructorAwareReflectClass + { + protected readonly IReflector _reflector; + + private readonly NetReflector _netReflector; + + private readonly Type _type; + + private ReflectConstructorSpec _constructor; + + private string _name; + + private IReflectField[] _fields; + + public NetClass(IReflector reflector, NetReflector netReflector, Type clazz) + { + if(reflector == null) + { + throw new ArgumentNullException("reflector"); + } + + if(netReflector == null) + { + throw new ArgumentNullException("netReflector"); + } + + _reflector = reflector; + _netReflector = netReflector; + _type = clazz; + _constructor = ReflectConstructorSpec.UnspecifiedConstructor; + } + + public virtual IReflectClass GetComponentType() + { + return _reflector.ForClass(_type.GetElementType()); + } + + private IReflectConstructor[] GetDeclaredConstructors() + { + ConstructorInfo[] constructors = _type.GetConstructors(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public); + IReflectConstructor[] reflectors = new IReflectConstructor[constructors.Length]; + for (int i = 0; i < constructors.Length; i++) + { + reflectors[i] = new NetConstructor(_reflector, constructors[i]); + } + return reflectors; + } + + public virtual IReflectField GetDeclaredField(string name) + { + foreach (IReflectField field in GetDeclaredFields()) + { + if (field.GetName() == name) return field; + } + return null; + } + + public virtual IReflectField[] GetDeclaredFields() + { + if (_fields == null) + { + _fields = CreateDeclaredFieldsArray(); + } + return _fields; + } + + private IReflectField[] CreateDeclaredFieldsArray() + { + FieldInfo[] fields = Sharpen.Runtime.GetDeclaredFields(_type); + IReflectField[] reflectors = new IReflectField[fields.Length]; + for (int i = 0; i < reflectors.Length; i++) + { + reflectors[i] = CreateField(fields[i]); + } + return reflectors; + } + + protected virtual IReflectField CreateField(FieldInfo field) + { + return new NetField(_reflector, field); + } + + public virtual IReflectClass GetDelegate() + { + return this; + } + + public virtual IReflectMethod GetMethod(string methodName, IReflectClass[] paramClasses) + { + try + { + Type[] parameterTypes = NetReflector.ToNative(paramClasses); + MethodInfo method = GetMethod(_type, methodName, parameterTypes); + if (method == null) + { + return null; + } + return new NetMethod(_reflector, method); + } + catch + { + return null; + } + } + + private static MethodInfo GetMethod(Type type, string methodName, Type[] parameterTypes) + { + MethodInfo found = Sharpen.Runtime.GetDeclaredMethod(type, methodName, parameterTypes); + if (found != null) return found; + + Type baseType = type.BaseType; + if (null == baseType) return null; + return GetMethod(baseType, methodName, parameterTypes); + } + + public virtual string GetName() + { + if (_name == null) + { + _name = TypeReference.FromType(_type).GetUnversionedName(); + } + return _name; + } + + public virtual IReflectClass GetSuperclass() + { + return _reflector.ForClass(_type.BaseType); + } + + public virtual bool IsAbstract() + { + return _type.IsAbstract; + } + + public virtual bool IsArray() + { + return _type.IsArray; + } + + public virtual bool IsAssignableFrom(IReflectClass type) + { + if (!(type is NetClass)) + { + return false; + } + return _type.IsAssignableFrom(((NetClass)type).GetNetType()); + } + + public virtual bool IsInstance(object obj) + { + return _type.IsInstanceOfType(obj); + } + + public virtual bool IsInterface() + { + return _type.IsInterface; + } + + public virtual bool IsCollection() + { + return _reflector.IsCollection(this); + } + + public virtual bool IsPrimitive() + { + return _type.IsPrimitive + || _type == typeof(DateTime) + || _type == typeof(decimal); + } + + public virtual object NewInstance() + { + CreateConstructor(); + return _constructor.NewInstance(); + } + + public virtual Type GetNetType() + { + return _type; + } + + public virtual IReflector Reflector() + { + return _reflector; + } + + public virtual IReflectConstructor GetSerializableConstructor() + { +#if !CF && !SILVERLIGHT + return new SerializationConstructor(GetNetType()); +#else + return null; +#endif + } + + public override string ToString() + { + return "NetClass(" + _type + ")"; + } + + public virtual object NullValue() + { + return _netReflector.NullValue(this); + } + + private void CreateConstructor() + { + if(!_constructor.CanBeInstantiated().IsUnspecified()) + { + return; + } + _constructor = ConstructorSupport.CreateConstructor(this, _type, _netReflector.Configuration(), GetDeclaredConstructors()); + } + + public virtual bool EnsureCanBeInstantiated() { + CreateConstructor(); + return _constructor.CanBeInstantiated().DefiniteYes(); + } + + public bool IsImmutable() + { + return IsPrimitive() || Platform4.IsSimple(_type); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Reflect/Net/NetConstructor.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Reflect/Net/NetConstructor.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Reflect/Net/NetConstructor.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Reflect/Net/NetConstructor.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,37 @@ +/* Copyright (C) 2007 Versant Inc. http://www.db4o.com */ +namespace Db4objects.Db4o.Reflect.Net +{ + + /// Reflection implementation for Constructor to map to .NET reflection. + public class NetConstructor : Db4objects.Db4o.Reflect.Core.IReflectConstructor + { + private readonly Db4objects.Db4o.Reflect.IReflector reflector; + + private readonly System.Reflection.ConstructorInfo constructor; + + public NetConstructor(Db4objects.Db4o.Reflect.IReflector reflector, System.Reflection.ConstructorInfo + constructor) + { + this.reflector = reflector; + this.constructor = constructor; + Db4objects.Db4o.Internal.Platform4.SetAccessible(constructor); + } + + public virtual Db4objects.Db4o.Reflect.IReflectClass[] GetParameterTypes() + { + return Db4objects.Db4o.Reflect.Net.NetReflector.ToMeta(reflector, Sharpen.Runtime.GetParameterTypes(constructor)); + } + + public virtual object NewInstance(object[] parameters) + { + try + { + return constructor.Invoke(parameters); + } + catch + { + return null; + } + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Reflect/Net/NetField.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Reflect/Net/NetField.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Reflect/Net/NetField.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Reflect/Net/NetField.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,135 @@ +/* Copyright (C) 2007 Versant Inc. http://www.db4o.com */ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Reflection; +using Db4objects.Db4o.Ext; + +namespace Db4objects.Db4o.Reflect.Net +{ + public class NetField : IReflectField + { + private readonly IReflector _reflector; + + protected readonly FieldInfo _field; + + private static IList _transientMarkers; + + public NetField(IReflector reflector, FieldInfo field) + { + _reflector = reflector; + _field = field; + } + + public override string ToString() + { + return string.Format("NetField({0})", _field); + } + + public virtual string GetName() + { + return _field.Name; + } + + public virtual IReflectClass GetFieldType() + { + return _reflector.ForClass(_field.FieldType); + } + + public virtual bool IsPublic() + { + return _field.IsPublic; + } + + public virtual bool IsStatic() + { + return _field.IsStatic; + } + + public virtual bool IsTransient() + { + return IsTransient(_field); + } + + public virtual void SetAccessible() + { + } + + public virtual object Get(object onObject) + { + try + { + return _field.GetValue(onObject); + } + catch(Exception e) + { + throw new Db4oException(e); + } + } + + public virtual void Set(object onObject, object attribute) + { + try + { + _field.SetValue(onObject, attribute); + } + catch(Exception e) + { + throw new Db4oException(e); + } + } + + public object IndexEntry(object orig) + { + return orig; + } + + public IReflectClass IndexType() + { + return GetFieldType(); + } + + public static bool IsTransient(FieldInfo field) + { + if (field.IsNotSerialized) return true; + if (field.IsDefined(typeof(TransientAttribute), true)) return true; + if (_transientMarkers == null) return false; + return CheckForTransient(field.GetCustomAttributes(true)); + } + + private static bool CheckForTransient(object[] attributes) + { + if (attributes == null) return false; + + foreach (object attribute in attributes) + { + string attributeName = attribute.GetType().FullName; + if (_transientMarkers.Contains(attributeName)) return true; + } + return false; + } + + public static void MarkTransient(Type attributeType) + { + MarkTransient(attributeType.FullName); + } + + public static void MarkTransient(string attributeName) + { + if (_transientMarkers == null) + { + _transientMarkers = new List(); + } + else if (_transientMarkers.Contains(attributeName)) + { + return; + } + _transientMarkers.Add(attributeName); + } + + public static void ResetTransientMarkers() + { + _transientMarkers = null; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Reflect/Net/NetMethod.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Reflect/Net/NetMethod.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Reflect/Net/NetMethod.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Reflect/Net/NetMethod.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,39 @@ +/* Copyright (C) 2007 Versant Inc. http://www.db4o.com */ +namespace Db4objects.Db4o.Reflect.Net +{ + public class NetMethod : Db4objects.Db4o.Reflect.IReflectMethod + { + private readonly System.Reflection.MethodInfo method; + + private readonly Db4objects.Db4o.Reflect.IReflector _reflector; + + public NetMethod(Db4objects.Db4o.Reflect.IReflector reflector, System.Reflection.MethodInfo method) + { + _reflector = reflector; + this.method = method; + } + + public Db4objects.Db4o.Reflect.IReflectClass GetReturnType() + { + return _reflector.ForClass(method.ReturnType); + } + + public virtual object Invoke(object onObject, object[] parameters) + { + try + { + return method.Invoke(onObject, parameters); + } + catch (System.Reflection.TargetInvocationException e) + { + throw new Db4objects.Db4o.Internal.ReflectException(e.InnerException); + } +#if CF + catch (System.Exception e) + { + throw new Db4objects.Db4o.Internal.ReflectException(e); + } +#endif + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Reflect/Net/NetReflector.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Reflect/Net/NetReflector.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Reflect/Net/NetReflector.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Reflect/Net/NetReflector.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,210 @@ +/* Copyright (C) 2007 Versant Inc. http://www.db4o.com */ +using System; + +using Db4objects.Db4o.Internal; + +namespace Db4objects.Db4o.Reflect.Net +{ + public class NetReflector : IReflector + { + + protected IReflector _parent; + + private IReflectArray _array; + + private IReflectorConfiguration _config; + + public NetReflector(IReflectorConfiguration config) + { + _config = config; + } + + public NetReflector() : this(new DefaultConfiguration()) + { + + } + + + public virtual IReflectArray Array() + { + if(_array == null) + { + _array = new NetArray(Parent()); + } + return _array; + } + + public virtual object DeepClone(object obj) + { + return new NetReflector(_config); + } + + public virtual IReflectClass ForClass(Type forType) + { + if(forType == null) + { + return null; + } + Type underlyingType = GetUnderlyingType(forType); + if (underlyingType.IsPrimitive) + { + return CreateClass(forType); + } + return CreateClass(underlyingType); + } + + protected virtual IReflectClass CreateClass(Type type) + { + if(type == null) + { + return null; + } + return new NetClass(Parent(), this, type); + } + + private static Type GetUnderlyingType(Type type) + { + if(type == null) + { + return null; + } + Type underlyingType = Nullable.GetUnderlyingType(type); + if (underlyingType != null) + { + return underlyingType; + } + return type; + } + + public virtual IReflectClass ForName(string className) + { + try + { + Type type = ReflectPlatform.ForName(className); + if (type == null) return null; + return ForClass(type); + } + catch + { + } + return null; + } + + public virtual IReflectClass ForObject(object a_object) + { + if (a_object == null) + { + return null; + } + return Parent().ForClass(a_object.GetType()); + } + + public virtual bool IsCollection(IReflectClass candidate) + { + if (candidate.IsArray()) + { + return false; + } + NetClass netClass = candidate as NetClass; + if (null == netClass) + { + return false; + } + return typeof(System.Collections.ICollection).IsAssignableFrom(netClass.GetNetType()); + } + + public virtual bool MethodCallsSupported() + { + return true; + } + + public static IReflectClass[] ToMeta(IReflector reflector, Type[] clazz) + { + IReflectClass[] claxx = null; + if (clazz != null) + { + claxx = new IReflectClass[clazz.Length]; + for (int i = 0; i < clazz.Length; i++) + { + if (clazz[i] != null) + { + claxx[i] = reflector.ForClass(clazz[i]); + } + } + } + return claxx; + } + + public static Type[] ToNative(IReflectClass[] claxx) + { + Type[] clazz = null; + if (claxx != null) + { + clazz = new Type[claxx.Length]; + for (int i = 0; i < claxx.Length; i++) + { + if (claxx[i] != null) + { + IReflectClass reflectClass = claxx[i]; + clazz[i] = ToNative(reflectClass); + } + } + } + return clazz; + } + + public static Type ToNative(IReflectClass reflectClass) + { + NetClass netClass = reflectClass.GetDelegate() as NetClass; + if(netClass == null) + { + return null; + } + return netClass.GetNetType(); + } + + public virtual void SetParent(IReflector reflector) + { + _parent = reflector; + } + + public virtual void Configuration(IReflectorConfiguration config) + { + _config = config; + } + + public virtual IReflectorConfiguration Configuration() + { + return _config; + } + + public virtual object NullValue(IReflectClass clazz) + { + return Platform4.NullValue(ToNative(clazz)); + } + + protected IReflector Parent() + { + if(_parent == null) + { + return this; + } + + return _parent; + } + + private class DefaultConfiguration : IReflectorConfiguration + { + public bool TestConstructors() + { + return false; + } + + public bool CallConstructor(IReflectClass clazz) + { + return false; + } + } + + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/TransientAttribute.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/TransientAttribute.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/TransientAttribute.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/TransientAttribute.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,24 @@ +/* Copyright (C) 2004 Versant Inc. http://www.db4o.com */ + +using System; + +namespace Db4objects.Db4o +{ + /// + /// Marks a field or event as transient. + /// + /// + /// Transient fields are not stored by db4o. + ///
+ /// If you don't want a field to be stored by db4o, + /// simply mark it with this attribute. + ///
+ /// + [AttributeUsage(AttributeTargets.Field | AttributeTargets.Event)] + public class TransientAttribute : Attribute + { + public TransientAttribute() + { + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Typehandlers/CollectionTypeHandler.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Typehandlers/CollectionTypeHandler.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Typehandlers/CollectionTypeHandler.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Typehandlers/CollectionTypeHandler.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,19 @@ +/* Copyright (C) 2010 Versant Inc. http://www.db4o.com */ + +using System.Collections; + +namespace Db4objects.Db4o.Typehandlers +{ + public partial class CollectionTypeHandler + { + private void AddToCollection(ICollection collection, object element) + { + ((IList)collection).Add(element); + } + + private void ClearCollection(ICollection collection) + { + ((IList)collection).Clear(); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Typehandlers/ComparablePreparedComparison.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Typehandlers/ComparablePreparedComparison.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Typehandlers/ComparablePreparedComparison.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Typehandlers/ComparablePreparedComparison.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,27 @@ +/* Copyright (C) 2009 Versant Inc. http://www.db4o.com */ +using System; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal; + +namespace Db4objects.Db4o.native.Db4objects.Db4o.Typehandlers +{ + sealed internal class ComparablePreparedComparison : IPreparedComparison where T : IComparable + { + public ComparablePreparedComparison(object source) + { + if (source is TransactionContext) + { + source = ((TransactionContext)source)._object; + } + + _source = (IComparable)source; + } + + public int CompareTo(object obj) + { + return _source.CompareTo(obj); + } + + private readonly IComparable _source; + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Typehandlers/DateTimeOffsetTypeHandler.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Typehandlers/DateTimeOffsetTypeHandler.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Typehandlers/DateTimeOffsetTypeHandler.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Typehandlers/DateTimeOffsetTypeHandler.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,129 @@ +/* Copyright (C) 2009 Versant Inc. http://www.db4o.com */ +#if !CF +using System; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Delete; +using Db4objects.Db4o.Internal.Marshall; +using Db4objects.Db4o.Marshall; +using Db4objects.Db4o.native.Db4objects.Db4o.Typehandlers; + +namespace Db4objects.Db4o.Typehandlers +{ + public class DateTimeOffsetTypeHandler : IValueTypeHandler, IQueryableTypeHandler, IIndexableTypeHandler + { + #region Implementation of ITypeHandler4 + + void ITypeHandler4.Delete(IDeleteContext context) + { + context.Seek(context.Offset() + LinkLength()); + } + + void ITypeHandler4.Defragment(IDefragmentContext context) + { + IncrementOffset(context); + } + + void ITypeHandler4.Write(IWriteContext context, object obj) + { + Write(context, (DateTimeOffset)obj); + } + + bool IQueryableTypeHandler.DescendsIntoMembers() + { + return false; + } + + object IValueTypeHandler.Read(IReadContext context) + { + return ReadFrom(context); + } + + #endregion + + #region Implementation of IComparable4 + + IPreparedComparison IComparable4.PrepareComparison(IContext context, object obj) + { + return new ComparablePreparedComparison(obj); + } + + #endregion + + #region Implementation of ILinkLengthAware + + int ILinkLengthAware.LinkLength() + { + return LinkLength(); + } + + #endregion + + #region Implementation of IIndexable4 + + object IIndexable4.ReadIndexEntry(IContext context, ByteArrayBuffer reader) + { + return ReadFrom(reader); + } + + void IIndexable4.WriteIndexEntry(IContext context, ByteArrayBuffer writer, object obj) + { + Write(writer, (DateTimeOffset) obj); + } + + void IIndexable4.DefragIndexEntry(DefragmentContextImpl context) + { + IncrementOffset(context); + } + + #endregion + + #region Implementation of IIndexableTypeHandler + + object IIndexableTypeHandler.IndexEntryToObject(IContext context, object indexEntry) + { + if (indexEntry.GetType() != typeof(DateTimeOffset)) + { + throw new InvalidOperationException(); + } + + return indexEntry; + } + + object IIndexableTypeHandler.ReadIndexEntryFromObjectSlot(MarshallerFamily mf, StatefulBuffer buffer) + { + return ReadFrom(buffer); + } + + object IIndexableTypeHandler.ReadIndexEntry(IObjectIdContext context) + { + return ReadFrom(context); + } + + #endregion + + private static void Write(IWriteBuffer context, DateTimeOffset dateTimeOffset) + { + context.WriteLong(dateTimeOffset.Ticks); + context.WriteLong(dateTimeOffset.Offset.Ticks); + } + + private static DateTimeOffset ReadFrom(IReadBuffer buffer) + { + long ticks = buffer.ReadLong(); + long timeSpanTicks = buffer.ReadLong(); + return new DateTimeOffset(ticks, new TimeSpan(timeSpanTicks)); + } + + private static void IncrementOffset(IDefragmentContext context) + { + context.IncrementOffset(LinkLength()); + } + + private static int LinkLength() + { + return Const4.LongLength + Const4.LongLength; + } + } +} +#endif \ No newline at end of file diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Typehandlers/EnumTypeHandler.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Typehandlers/EnumTypeHandler.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Typehandlers/EnumTypeHandler.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Typehandlers/EnumTypeHandler.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,201 @@ +/* Copyright (C) 2004 - 2008 Versant Inc. http://www.db4o.com */ + +using System; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Delete; +using Db4objects.Db4o.Internal.Marshall; +using Db4objects.Db4o.Marshall; +using Db4objects.Db4o.Reflect; +using Db4objects.Db4o.Reflect.Net; + +namespace Db4objects.Db4o.Typehandlers +{ + public class EnumTypeHandler : IValueTypeHandler, ITypeFamilyTypeHandler, IIndexableTypeHandler + { + private class PreparedEnumComparison : IPreparedComparison + { + private readonly long _enumValue; + public PreparedEnumComparison(object obj) + { + if (obj is TransactionContext) + { + obj = ((TransactionContext)obj)._object; + } + + if (obj == null) return; + + _enumValue = ToLong(obj); + } + + public int CompareTo(object obj) + { + if (obj is TransactionContext) + { + obj = ((TransactionContext)obj)._object; + } + + if (obj == null) return 1; + + long other = ToLong(obj); + if (_enumValue == other) return 0; + if (_enumValue < other) return -1; + + return 1; + } + + private static long ToLong(object obj) + { + if (obj is IndexEntry) + { + return ((IndexEntry)obj).EnumValue; + } + + return Convert.ToInt64(obj); + } + } + + public IPreparedComparison PrepareComparison(IContext context, object obj) + { + return new PreparedEnumComparison(obj); + } + + public void Delete(IDeleteContext context) + { + int offset = context.Offset() + Const4.IdLength + Const4.LongLength; + context.Seek(offset); + } + + public void Defragment(IDefragmentContext context) + { + context.CopyID(); + context.IncrementOffset(Const4.LongLength); + } + + public object Read(IReadContext context) + { + int classId = context.ReadInt(); + long enumValue = context.ReadLong(); + + return ToEnum(context, classId, enumValue); + } + + public void Write(IWriteContext context, object obj) + { + int classId = ClassMetadataIdFor(context, obj); + + context.WriteInt(classId); + context.WriteLong(Convert.ToInt64(obj)); + } + + public bool DescendsIntoMembers() + { + return false; + } + + public int LinkLength() + { + return Const4.IdLength + Const4.LongLength; + } + + public object ReadIndexEntry(IContext context, ByteArrayBuffer reader) + { + return new IndexEntry(reader.ReadInt(), reader.ReadLong()); + } + + public void WriteIndexEntry(IContext context, ByteArrayBuffer writer, object obj) + { + IndexEntry indexEntry = obj as IndexEntry; + if (indexEntry == null) + { + indexEntry = new IndexEntry(ClassMetadataIdFor(context, obj), Convert.ToInt64(obj)); + } + writer.WriteInt(indexEntry.ClassMetadataId); + writer.WriteLong(indexEntry.EnumValue); + } + + public void DefragIndexEntry(DefragmentContextImpl context) + { + context.IncrementOffset(Const4.LongLength); + } + + private static int ClassMetadataIdFor(IContext context, object obj) + { + IReflectClass claxx = Container(context).Reflector().ForObject(obj); + ClassMetadata clazz = Container(context).ProduceClassMetadata(claxx); + + //TODO: Handle clazz == null!! Must not happen! + + return clazz.GetID(); + } + + private static ITypeHandler4 StringTypeHandler(IContext context) + { + return Container(context).Handlers.TypeHandlerForClass(Container(context).Ext().Reflector().ForClass(typeof(string))); + } + + private static ObjectContainerBase Container(IContext context) + { + return ((IInternalObjectContainer)context.ObjectContainer()).Container; + } + + public object IndexEntryToObject(IContext context, object indexEntry) + { + IndexEntry entry = (IndexEntry) indexEntry; + return ToEnum(context, entry.ClassMetadataId, entry.EnumValue); + } + + public object ReadIndexEntryFromObjectSlot(MarshallerFamily mf, StatefulBuffer statefulBuffer) + { + return new IndexEntry(statefulBuffer.ReadInt(), statefulBuffer.ReadLong()); + } + + public object ReadIndexEntry(IObjectIdContext context) + { + return new IndexEntry(context.ReadInt(), context.ReadLong()); + } + + private static object ToEnum(IContext context, int classId, long enumValue) + { + ClassMetadata clazz = Container(context).ClassMetadataForID(classId); + + Type enumType = NetReflector.ToNative(clazz.ClassReflector()); + return Enum.ToObject(enumType, enumValue); + } + + private class IndexEntry + { + private readonly long _enumValue; + private readonly int _classMetadataId; + + internal IndexEntry(int classMetadataId, long enumValue) + { + _classMetadataId = classMetadataId; + _enumValue = enumValue; + } + + internal long EnumValue + { + get { return _enumValue; } + } + + internal int ClassMetadataId + { + get { return _classMetadataId; } + } + } + } + + public class EnumTypeHandlerPredicate : ITypeHandlerPredicate + { + public bool Match(IReflectClass classReflector) + { + Type type = NetReflector.ToNative(classReflector); + if(type == null) + { + return false; + } + return type.IsEnum; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Typehandlers/GenericCollectionTypeHandler.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Typehandlers/GenericCollectionTypeHandler.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Typehandlers/GenericCollectionTypeHandler.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Typehandlers/GenericCollectionTypeHandler.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,218 @@ +/* Copyright (C) 2004 - 2008 Versant Inc. http://www.db4o.com */ + +using System; +using System.Collections; +using System.Collections.Generic; +using Db4objects.Db4o.Collections; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Foundation.Collections; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Delete; +using Db4objects.Db4o.Internal.Handlers; +using Db4objects.Db4o.Internal.Marshall; +using Db4objects.Db4o.Marshall; + +namespace Db4objects.Db4o.Typehandlers +{ + public class GenericCollectionTypeHandler : IReferenceTypeHandler, ICascadingTypeHandler, IVariableLengthTypeHandler, IQueryableTypeHandler + { + public virtual IPreparedComparison PrepareComparison(IContext context, object obj) + { + return null; + } + + public virtual void Write(IWriteContext context, object obj) + { + ICollectionInitializer initializer = CollectionInitializer.For(obj); + IEnumerable enumerable = (IEnumerable)obj; + ClassMetadata elementType = DetectElementTypeErasingNullables(Container(context), enumerable); + WriteElementTypeHandlerId(context, elementType); + WriteElementCount(context, initializer); + WriteElements(context, enumerable, elementType.TypeHandler()); + } + + public virtual void Activate(IReferenceActivationContext context) + { + object collection = context.PersistentObject(); + ICollectionInitializer initializer = CollectionInitializer.For(collection); + initializer.Clear(); + + ReadElements(context, initializer, ReadElementTypeHandler(context, context)); + + initializer.FinishAdding(); + } + + public virtual void Delete(IDeleteContext context) + { + if (!context.CascadeDelete()) return; + + ITypeHandler4 handler = ReadElementTypeHandler(context, context); + int elementCount = context.ReadInt(); + for (int i = elementCount; i > 0; i--) + { + handler.Delete(context); + } + } + + public virtual void Defragment(IDefragmentContext context) + { + DefragmentElementHandlerId(context); + ITypeHandler4 handler = ReadElementTypeHandler(context, context); + int elementCount = context.ReadInt(); + for (int i = 0; i < elementCount; i++) + { + context.Defragment(handler); + } + } + + public void CascadeActivation(IActivationContext context) + { + IEnumerable collection = ((IEnumerable)context.TargetObject()); + + // TODO: detect the element type + // and return immediately when it's a primitive + + foreach (object item in collection) + { + context.CascadeActivationToChild(item); + } + } + + public virtual ITypeHandler4 ReadCandidateHandler(QueryingReadContext context) + { + return this; + } + + public virtual void CollectIDs(QueryingReadContext context) + { + ITypeHandler4 elementHandler = ReadElementTypeHandler(context, context); + int elementCount = context.ReadInt(); + for (int i = 0; i < elementCount; i++) + { + context.ReadId(elementHandler); + } + } + + private static void DefragmentElementHandlerId(IDefragmentContext context) + { + int offset = context.Offset(); + context.CopyID(); + context.Seek(offset); + } + + private static ITypeHandler4 OpenTypeHandlerFrom(IContext context) + { + return context.Transaction().Container().Handlers.OpenTypeHandler(); + } + + private static void ReadElements(IReadContext context, ICollectionInitializer initializer, ITypeHandler4 elementHandler) + { + int elementCount = context.ReadInt(); + for (int i = 0; i < elementCount; i++) + { + initializer.Add(context.ReadObject(elementHandler)); + } + } + + private static void WriteElementTypeHandlerId(IWriteContext context, ClassMetadata type) + { + context.WriteInt(type.GetID()); + } + + private static void WriteElementCount(IWriteBuffer context, ICollectionInitializer initializer) + { + context.WriteInt(initializer.Count()); + } + + private static void WriteElements(IWriteContext context, IEnumerable enumerable, ITypeHandler4 elementHandler) + { + IEnumerator elements = enumerable.GetEnumerator(); + while (elements.MoveNext()) + { + context.WriteObject(elementHandler, elements.Current); + } + } + + private static ObjectContainerBase Container(IContext context) + { + return ((IInternalObjectContainer)context.ObjectContainer()).Container; + } + + private static ITypeHandler4 ReadElementTypeHandler(IReadBuffer buffer, IContext context) + { + int elementTypeId = buffer.ReadInt(); + if (elementTypeId == 0) return OpenTypeHandlerFrom(context); + + ITypeHandler4 elementHandler = Container(context).TypeHandlerForClassMetadataID(elementTypeId); + return elementHandler ?? OpenTypeHandlerFrom(context); + } + + private static ClassMetadata DetectElementTypeErasingNullables(ObjectContainerBase container, IEnumerable collection) + { + Type elementType = ElementTypeOf(collection); + if (IsNullableInstance(elementType)) + { + return container.ClassMetadataForReflectClass(container.Handlers.IclassObject); + } + return container.ProduceClassMetadata(container.Reflector().ForClass(elementType)); + } + + private static bool IsNullableInstance(Type elementType) + { + return elementType.IsGenericType && (elementType.GetGenericTypeDefinition() == typeof(Nullable<>)); + } + + private static Type ElementTypeOf(IEnumerable collection) + { + Type genericCollectionType = GenericCollectionTypeFor(collection.GetType()); + return genericCollectionType.GetGenericArguments()[0]; + } + + private static Type GenericCollectionTypeFor(Type type) + { + if (type == null) + { + throw new InvalidOperationException(); + } + + if (IsGenericCollectionType(type)) + { + return type; + } + + return GenericCollectionTypeFor(type.BaseType); + } + + private static bool IsGenericCollectionType(Type type) + { + return type.IsGenericType && Array.IndexOf(_supportedCollections, type.GetGenericTypeDefinition()) >= 0; + } + + public bool DescendsIntoMembers() + { + return true; + } + + public void RegisterSupportedTypesWith(Action registrationAction) + { + foreach (Type collectionType in _supportedCollections) + { + registrationAction(collectionType); + } + } + + private static readonly Type[] _supportedCollections = new Type[] + { + typeof(List<>), + typeof(LinkedList<>), + typeof(Stack<>), + typeof(Queue<>), + typeof(System.Collections.ObjectModel.Collection<>), + typeof(ActivatableList<>), +#if NET_3_5 && ! CF + typeof(HashSet<>), +#endif + }; + } + +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Typehandlers/GuidTypeHandler.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Typehandlers/GuidTypeHandler.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Typehandlers/GuidTypeHandler.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Typehandlers/GuidTypeHandler.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,137 @@ +/* Copyright (C) 2009 Versant Inc. http://www.db4o.com */ + +/* Copyright (C) 2009 Judah Himango */ + +using System; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Marshall; +using Db4objects.Db4o.native.Db4objects.Db4o.Typehandlers; +using Db4objects.Db4o.Reflect; +using Db4objects.Db4o.Marshall; +using Db4objects.Db4o.Internal.Delete; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Reflect.Net; + +namespace Db4objects.Db4o.Typehandlers +{ + /// + /// DB4O type handler for efficiently storing and activating System.Guid values. + /// + /// Judah Himango + public class GuidTypeHandler: IValueTypeHandler, IQueryableTypeHandler, IIndexableTypeHandler + { + private const int GuidSize = 16; + + #region IValueTypeHandler Members + + public object Read(IReadContext context) + { + return ReadFrom(context); + } + + #endregion + + #region ITypeHandler4 Members + + public bool CanHold(IReflectClass type) + { + return NetReflector.ToNative(type).Equals(typeof (Guid)); + } + + public void Defragment(IDefragmentContext context) + { + IncrementOffset(context); + } + + public void Delete(IDeleteContext context) + { + context.Seek(context.Offset() + GuidSize); + } + + public void Write(IWriteContext context, object obj) + { + WriteGuid(obj, context); + } + + #endregion + + #region IComparable4 Members + + public IPreparedComparison PrepareComparison(IContext context, object obj) + { + return new ComparablePreparedComparison(obj); + } + + #endregion + + #region IQueryableTypeHandler Members + + public bool DescendsIntoMembers() + { + return false; + } + + #endregion + + #region IIndexableTypeHandler Members + + public int LinkLength() + { + return GuidSize; + } + + public object ReadIndexEntry(IContext context, ByteArrayBuffer reader) + { + return ReadFrom(reader); + } + + public void WriteIndexEntry(IContext context, ByteArrayBuffer writer, object obj) + { + WriteGuid(obj, writer); + } + + public void DefragIndexEntry(DefragmentContextImpl context) + { + IncrementOffset(context); + } + + public object IndexEntryToObject(IContext context, object indexEntry) + { + if (indexEntry.GetType() != typeof(Guid)) + { + throw new InvalidOperationException(); + } + return indexEntry; + } + + public object ReadIndexEntryFromObjectSlot(MarshallerFamily mf, StatefulBuffer buffer) + { + return ReadFrom(buffer); + } + + public object ReadIndexEntry(IObjectIdContext context) + { + return ReadFrom(context); + } + + #endregion + + private static Guid ReadFrom(IReadBuffer buffer) + { + byte[] guidBytes = new byte[GuidSize]; + buffer.ReadBytes(guidBytes); + return new Guid(guidBytes); + } + + private static void WriteGuid(object obj, IWriteBuffer context) + { + Guid id = (Guid)obj; + context.WriteBytes(id.ToByteArray()); + } + + private static void IncrementOffset(IDefragmentContext context) + { + context.IncrementOffset(GuidSize); + } + } +} \ No newline at end of file diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Typehandlers/SystemArrayTypeHandler.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Typehandlers/SystemArrayTypeHandler.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Typehandlers/SystemArrayTypeHandler.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Db4objects.Db4o/Typehandlers/SystemArrayTypeHandler.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,137 @@ +/* Copyright (C) 2009 Versant Inc. http://www.db4o.com */ + +using System; +using System.Collections; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.Internal.Activation; +using Db4objects.Db4o.Internal.Delete; +using Db4objects.Db4o.Internal.Handlers; +using Db4objects.Db4o.Internal.Marshall; +using Db4objects.Db4o.Marshall; +using Db4objects.Db4o.Reflect; +using Db4objects.Db4o.Reflect.Net; +using Db4objects.Db4o.Internal.Handlers.Array; + + +namespace Db4objects.Db4o.Typehandlers +{ + public class SystemArrayTypeHandler : ICascadingTypeHandler, IVariableLengthTypeHandler, IValueTypeHandler + { + public virtual IPreparedComparison PrepareComparison(IContext context, object obj) + { + return ReadArrayHandler(context).PrepareComparison(context, obj); + } + + public virtual void Write(IWriteContext context, object obj) + { + Array collection = (Array) obj; + ClassMetadata elementType = DetectElementTypeHandler(Container(context), collection); + WriteElementTypeId(context, elementType); + new ArrayHandler(elementType.TypeHandler(), false).Write(context, obj); + } + + public virtual object Read(IReadContext context) + { + return ReadArrayHandler(context).Read(context); + } + + private static ArrayHandler ReadArrayHandler(IContext context) + { + ITypeHandler4 handler = ReadElementTypeHandler((IReadBuffer)context, context); + return new ArrayHandler(handler, false); + } + + public virtual void Delete(IDeleteContext context) + { + ReadArrayHandler(context).Delete(context); + } + + public virtual void Defragment(IDefragmentContext context) + { + DefragmentElementHandlerId(context); + ReadArrayHandler(context).Defragment(context); + } + + public void CascadeActivation(IActivationContext context) + { + ICollection collection = ((ICollection)context.TargetObject()); + foreach (object item in collection) + { + context.CascadeActivationToChild(item); + } + } + + public virtual ITypeHandler4 ReadCandidateHandler(QueryingReadContext context) + { + return this; + } + + public virtual void CollectIDs(QueryingReadContext context) + { + ReadArrayHandler(context).CollectIDs(context); + } + + private static void DefragmentElementHandlerId(IDefragmentContext context) + { + int offset = context.Offset(); + context.CopyID(); + context.Seek(offset); + } + + private static ITypeHandler4 OpenTypeHandlerFrom(IContext context) + { + return context.Transaction().Container().Handlers.OpenTypeHandler(); + } + + private static void WriteElementTypeId(IWriteContext context, ClassMetadata elementType) + { + context.WriteInt(elementType.GetID()); + } + + private static ObjectContainerBase Container(IContext context) + { + return ((IInternalObjectContainer)context.ObjectContainer()).Container; + } + + private static ITypeHandler4 ReadElementTypeHandler(IReadBuffer buffer, IContext context) + { + int elementHandlerId = buffer.ReadInt(); + if (elementHandlerId == 0) return OpenTypeHandlerFrom(context); + + ITypeHandler4 elementHandler = Container(context).TypeHandlerForClassMetadataID(elementHandlerId); + return elementHandler ?? OpenTypeHandlerFrom(context); + } + + private static ClassMetadata DetectElementTypeHandler(ObjectContainerBase container, Array collection) + { + Type elementType = ElementTypeOf(collection); + return container.ProduceClassMetadata(container.Reflector().ForClass(elementType)); + } + + private static bool IsNullableInstance(Type elementType) + { + return elementType.IsGenericType && (elementType.GetGenericTypeDefinition() == typeof(Nullable<>)); + } + + private static Type ElementTypeOf(Array array) + { + return array.GetType().GetElementType(); + } + + } + + internal class SystemArrayPredicate : ITypeHandlerPredicate + { + public bool Match(IReflectClass classReflector) + { + if(classReflector == null) + { + return false; + } + Type type = NetReflector.ToNative(classReflector); + return type == typeof(System.Array); + } + } + +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/net/Compat.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/net/Compat.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/net/Compat.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/net/Compat.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,10 @@ +/* Copyright (C) 2005 Versant Inc. http://www.db4o.com */ +namespace Db4objects.Db4o +{ +#if !CF + /// + public class Compat + { + } +#endif +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/net/Lock4.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/net/Lock4.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/net/Lock4.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/net/Lock4.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,30 @@ +/* Copyright (C) 2004 Versant Inc. http://www.db4o.com */ + +using System; +using System.Threading; + +#if !CF +namespace Db4objects.Db4o.Foundation +{ + public class Lock4 + { + public void Awake() + { + Monitor.Pulse(this); + } + + public Object Run(IClosure4 closure) + { + lock (this) + { + return closure.Run(); + } + } + + public void Snooze(long timeout) + { + Monitor.Wait(this, (int)timeout); + } + } +} +#endif diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/net/SerializationConstructor.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/net/SerializationConstructor.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/net/SerializationConstructor.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/net/SerializationConstructor.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,32 @@ +/* Copyright (C) 2007 Versant Inc. http://www.db4o.com */ +using System; +using Db4objects.Db4o.Reflect.Core; + +namespace Db4objects.Db4o.Reflect.Net +{ +#if !CF && !SILVERLIGHT + /// Constructs objects by using System.Runtime.Serialization.FormatterServices.GetUninitializedObject + /// and bypasses calls to user contructors this way. Not available on CompactFramework + /// + public class SerializationConstructor : IReflectConstructor + { + private Type _type; + + public SerializationConstructor(Type type){ + _type = type; + } + + public virtual IReflectClass[] GetParameterTypes() { + return null; + } + +#if NET_4_0 + [System.Security.SecurityCritical] +#endif + public virtual object NewInstance(object[] parameters) { + return System.Runtime.Serialization.FormatterServices.GetUninitializedObject(_type); + } + } +#endif +} + diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/net/TSerializable.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/net/TSerializable.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/net/TSerializable.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/net/TSerializable.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,48 @@ +/* Copyright (C) 2004 Versant Inc. http://www.db4o.com */ +using System; +using System.IO; + +using Sharpen.Lang; +using Db4objects.Db4o.Config; + +namespace Db4objects.Db4o.Config +{ +#if !CF && !SILVERLIGHT + using System.Runtime.Serialization; + using System.Runtime.Serialization.Formatters.Binary; + + /// + /// translator for types that are marked with the Serializable attribute. + /// The Serializable translator is provided to allow persisting objects that + /// do not supply a convenient constructor. The use of this translator is + /// recommended only if:
+ /// - the persistent type will never be refactored
+ /// - querying for type members is not necessary
+ ///
+ public class TSerializable : IObjectConstructor + { + public Object OnStore(IObjectContainer objectContainer, Object obj) + { + MemoryStream memoryStream = new MemoryStream(); + new BinaryFormatter().Serialize(memoryStream, obj); + return memoryStream.GetBuffer(); + } + + public void OnActivate(IObjectContainer objectContainer, Object obj, Object members) + { + } + + public Object OnInstantiate(IObjectContainer objectContainer, Object obj) + { + MemoryStream memoryStream = new MemoryStream((byte[])obj); + return new BinaryFormatter().Deserialize(memoryStream); + } + + public System.Type StoredClass() + { + return typeof(byte[]); + } + + } +#endif +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Sharpen/Collections.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Sharpen/Collections.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Sharpen/Collections.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Sharpen/Collections.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,52 @@ + +using System.Collections; +using System.Collections.Generic; + +namespace Sharpen +{ + public class Collections + { + public static void AddAll(System.Collections.IList list, System.Collections.IEnumerable added) + { + foreach (object o in added) + { + list.Add(o); + } + } + + public static bool AddAll(ICollection list, System.Collections.Generic.IEnumerable added) + { + foreach (T o in added) + { + list.Add(o); + } + return true; + } + + public static object Remove(IDictionary dictionary, object key) + { + object removed = dictionary[key]; + dictionary.Remove(key); + return removed; + } + + public static object[] ToArray(ICollection collection) + { + object[] result = new object[collection.Count]; + collection.CopyTo(result, 0); + return result; + } + + public static T[] ToArray(ICollection collection, T[] result) + { + collection.CopyTo(result, 0); + return result; + } + + public static T[] ToArray(ICollection collection, T[] result) + { + collection.CopyTo(result, 0); + return result; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Sharpen/IO/BufferedInputStream.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Sharpen/IO/BufferedInputStream.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Sharpen/IO/BufferedInputStream.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Sharpen/IO/BufferedInputStream.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,41 @@ +/* Copyright (C) 2004 Versant Inc. http://www.db4o.com */ + +using System; + +namespace Sharpen.IO +{ + public class BufferedInputStream : IInputStream + { + private IInputStream _stream; + + public BufferedInputStream(IInputStream stream) + { + _stream = stream; + } + + public BufferedInputStream(IInputStream stream, int bufferSize) + { + _stream = stream; + } + + public int Read() + { + return _stream.Read(); + } + + public int Read(byte[] bytes) + { + return _stream.Read(bytes); + } + + public int Read(byte[] bytes, int offset, int length) + { + return _stream.Read(bytes, offset, length); + } + + public void Close() + { + _stream.Close(); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Sharpen/IO/BufferedOutputStream.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Sharpen/IO/BufferedOutputStream.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Sharpen/IO/BufferedOutputStream.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Sharpen/IO/BufferedOutputStream.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,46 @@ +/* Copyright (C) 2004 Versant Inc. http://www.db4o.com */ + +using System; + +namespace Sharpen.IO +{ + public class BufferedOutputStream : IOutputStream + { + private IOutputStream _stream; + + public BufferedOutputStream(IOutputStream stream) + { + _stream = stream; + } + + public BufferedOutputStream(IOutputStream stream, int bufferSize) + { + _stream = stream; + } + + public void Write(int i) + { + _stream.Write(i); + } + + public void Write(byte[] bytes) + { + _stream.Write(bytes); + } + + public void Write(byte[] bytes, int offset, int length) + { + _stream.Write(bytes, offset, length); + } + + public void Flush() + { + _stream.Flush(); + } + + public void Close() + { + _stream.Close(); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Sharpen/IO/ByteArrayInputStream.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Sharpen/IO/ByteArrayInputStream.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Sharpen/IO/ByteArrayInputStream.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Sharpen/IO/ByteArrayInputStream.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,14 @@ +/* Copyright (C) 2007 Versant Inc. http://www.db4o.com */ + +using System; +using System.IO; + +namespace Sharpen.IO +{ + public class ByteArrayInputStream : InputStream + { + public ByteArrayInputStream(byte[] initial) : base(new MemoryStream(initial)) + { + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Sharpen/IO/ByteArrayOutputStream.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Sharpen/IO/ByteArrayOutputStream.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Sharpen/IO/ByteArrayOutputStream.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Sharpen/IO/ByteArrayOutputStream.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,38 @@ +/* Copyright (C) 2007 Versant Inc. http://www.db4o.com */ + +using System; +using System.IO; + +namespace Sharpen.IO +{ + public class ByteArrayOutputStream : OutputStream + { + public ByteArrayOutputStream() : base(new MemoryStream()) + { + } + + public ByteArrayOutputStream(int size) : base(new MemoryStream(size)) + { + } + + public int Size() + { + return (int)Stream.Length; + } + + public void WriteTo(OutputStream stream) + { + Stream.WriteTo(stream.UnderlyingStream); + } + + public byte[] ToByteArray() + { + return Stream.ToArray(); + } + + private MemoryStream Stream + { + get { return (MemoryStream)UnderlyingStream; } + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Sharpen/IO/File.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Sharpen/IO/File.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Sharpen/IO/File.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Sharpen/IO/File.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,170 @@ +/* Copyright (C) 2004 Versant Inc. http://www.db4o.com */ + +using System; +using System.Collections.Generic; +using System.IO; +using Db4objects.Db4o.IO; + +namespace Sharpen.IO +{ + public class File + { + public static readonly char separatorChar = Path.DirectorySeparatorChar; + public static readonly string separator = separatorChar.ToString(); + + private readonly string _path; + + public File(string path) + { + _path = path; + } + + public static implicit operator string(File file) + { + return file.GetAbsolutePath(); + } + + public File(string dir, string file) + { + _path = dir == null ? file : Path.Combine(dir, file); + } + + public virtual bool Delete() + { +#if SILVERLIGHT + return SilverlightIO.Delete(_path); +#else + if (Exists()) + { + System.IO.File.Delete(_path); + return !Exists(); + } + return false; +#endif + } + + public bool Exists() + { +#if CF + string path = RemoveTrailingSlash(_path); +#elif SILVERLIGHT + string path = _path; + return SilverlightIO.Exists(path); +#else + string path = _path; +#endif + return System.IO.File.Exists(path) || Directory.Exists(path); + } + + private static string RemoveTrailingSlash(string path) + { + return (path.EndsWith("\\") || path.EndsWith("/")) ? path.Remove(path.Length - 1, 1) : path; + } + + public string GetCanonicalPath() + { + return Path.GetFullPath(_path); + } + + public File GetCanonicalFile() + { + return new File(GetCanonicalPath()); + } + + public string GetAbsolutePath() + { +#if SILVERLIGHT + return _path; +#else + return Path.GetFullPath(_path); +#endif + } + + public string GetName() + { + int index = _path.LastIndexOf(separator); + return _path.Substring(index + 1); + } + + public string GetPath() + { + return _path; + } + + public bool IsDirectory() + { +#if CF || SILVERLIGHT + return Exists(); +#else + return (System.IO.File.GetAttributes(_path) & FileAttributes.Directory) != 0; +#endif + } + + public long Length() + { +#if SILVERLIGHT + return SilverlightIO.Length(_path); +#else + return new FileInfo(_path).Length; +#endif + } + + public string[] List() + { +#if SILVERLIGHT + throw new NotImplementedException(); +#else + return Directory.GetFiles(_path); +#endif + } + + public bool Mkdir() + { + if (Exists()) + { + return false; + } + Directory.CreateDirectory(_path); + return Exists(); + } + + public bool Mkdirs() + { + if (Exists()) + { + return false; + } + int pos = _path.LastIndexOf(separator); + if (pos > 0) + { + new File(_path.Substring(0, pos)).Mkdirs(); + } + return Mkdir(); + } + + public void RenameTo(File file) + { + new FileInfo(_path).MoveTo(file.GetPath()); + } + + public File[] ListFiles(IFilenameFilter filter) + { + String[] ss = List(); + if (ss == null) return null; + List v = new List(); + for (int i = 0; i < ss.Length; i++) + { + if ((filter == null) || filter.Accept(this, ss[i])) + { + v.Add(new File(ss[i], this)); + } + } + return v.ToArray(); + } + + public override string ToString() + { + return _path; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Sharpen/IO/FileInputStream.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Sharpen/IO/FileInputStream.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Sharpen/IO/FileInputStream.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Sharpen/IO/FileInputStream.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,14 @@ +/* Copyright (C) 2004 Versant Inc. http://www.db4o.com */ + +using System; +using System.IO; + +namespace Sharpen.IO { + + public class FileInputStream : InputStream { + + public FileInputStream(File file) : base(new FileStream(file.GetPath(), FileMode.Open, FileAccess.Read)) { + } + + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Sharpen/IO/FileOutputStream.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Sharpen/IO/FileOutputStream.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Sharpen/IO/FileOutputStream.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Sharpen/IO/FileOutputStream.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,14 @@ +/* Copyright (C) 2004 Versant Inc. http://www.db4o.com */ + +using System; +using System.IO; + +namespace Sharpen.IO { + + public class FileOutputStream : OutputStream { + + public FileOutputStream(File file) : base(new FileStream(file.GetPath(), FileMode.Create, FileAccess.Write)) { + } + + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Sharpen/IO/IFilenameFilter.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Sharpen/IO/IFilenameFilter.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Sharpen/IO/IFilenameFilter.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Sharpen/IO/IFilenameFilter.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,10 @@ +using System; + +namespace Sharpen.IO +{ + public interface IFilenameFilter + { + bool Accept(Sharpen.IO.File dir, String name); + } +} + diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Sharpen/IO/IInputStream.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Sharpen/IO/IInputStream.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Sharpen/IO/IInputStream.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Sharpen/IO/IInputStream.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,13 @@ +namespace Sharpen.IO +{ + public interface IInputStream + { + int Read(); + + int Read(byte[] bytes); + + int Read(byte[] bytes, int offset, int length); + + void Close(); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Sharpen/IO/InputStream.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Sharpen/IO/InputStream.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Sharpen/IO/InputStream.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Sharpen/IO/InputStream.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,34 @@ +/* Copyright (C) 2004 Versant Inc. http://www.db4o.com */ + +using System.IO; + +namespace Sharpen.IO +{ + public class InputStream : StreamAdaptor, IInputStream + { + public InputStream(Stream stream) + : base(stream) + { + } + + public int Read() + { + return _stream.ReadByte(); + } + + public int Read(byte[] bytes) + { + return Read(bytes, 0, bytes.Length); + } + + public int Read(byte[] bytes, int offset, int length) + { + return TranslateReadReturnValue(_stream.Read(bytes, offset, length)); + } + + internal static int TranslateReadReturnValue(int read) + { + return (0 == read) ? -1 : read; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Sharpen/IO/IOutputStream.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Sharpen/IO/IOutputStream.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Sharpen/IO/IOutputStream.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Sharpen/IO/IOutputStream.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,15 @@ +namespace Sharpen.IO +{ + public interface IOutputStream + { + void Write(int i); + + void Write(byte[] bytes); + + void Write(byte[] bytes, int offset, int length); + + void Flush(); + + void Close(); + } +} \ No newline at end of file diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Sharpen/IO/OutputStream.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Sharpen/IO/OutputStream.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Sharpen/IO/OutputStream.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Sharpen/IO/OutputStream.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,34 @@ +/* Copyright (C) 2004 Versant Inc. http://www.db4o.com */ + +using System.IO; + +namespace Sharpen.IO +{ + public class OutputStream : StreamAdaptor, IOutputStream + { + public OutputStream(Stream stream) + : base(stream) + { + } + + public void Write(int i) + { + _stream.WriteByte((byte)i); + } + + public void Write(byte[] bytes) + { + _stream.Write(bytes, 0, bytes.Length); + } + + public void Write(byte[] bytes, int offset, int length) + { + _stream.Write(bytes, offset, length); + } + + public void Flush() + { + _stream.Flush(); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Sharpen/IO/RandomAccessFile.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Sharpen/IO/RandomAccessFile.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Sharpen/IO/RandomAccessFile.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Sharpen/IO/RandomAccessFile.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,97 @@ +/* Copyright (C) 2004 - 2007 Versant Inc. http://www.db4o.com */ + +using System; +using System.IO; +using System.Runtime.InteropServices; + +namespace Sharpen.IO +{ + public class RandomAccessFile + { + private readonly FileStream _stream; + +#if !CF && !MONO && !SILVERLIGHT +#if NET_4_0 + [System.Security.SecuritySafeCritical] +#endif + [DllImport("kernel32.dll", SetLastError = true)] + static extern int FlushFileBuffers(Microsoft.Win32.SafeHandles.SafeFileHandle fileHandle); +#endif + public RandomAccessFile(String file, bool readOnly, bool lockFile) + { + _stream = new FileStream(file, FileMode.OpenOrCreate, + readOnly ? FileAccess.Read : FileAccess.ReadWrite, + lockFile ? FileShare.None : FileShare.ReadWrite + ); + } + + public RandomAccessFile(String file, String fileMode) + : this(file, fileMode.Equals("r"), true) + { + } + + public FileStream Stream + { + get { return _stream; } + } + + public void Close() + { + _stream.Close(); + } + + public long Length() + { + return _stream.Length; + } + + public int Read(byte[] bytes, int offset, int length) + { + return _stream.Read(bytes, offset, length); + } + + public void Read(byte[] bytes) + { + _stream.Read(bytes, 0, bytes.Length); + } + + public void Seek(long pos) + { + _stream.Seek(pos, SeekOrigin.Begin); + } + +#if NET_4_0 + [System.Security.SecuritySafeCritical] +#endif + public void Sync() + { + _stream.Flush(); + +#if !CF && !MONO && !SILVERLIGHT + FlushFileBuffers(_stream.SafeFileHandle); +#endif + } + + public RandomAccessFile GetFD() + { + return this; + } + + public void Write(byte[] bytes) + { + Write(bytes, 0, bytes.Length); + } + + public void Write(byte[] bytes, int offset, int length) + { + try + { + _stream.Write(bytes, offset, length); + } + catch (NotSupportedException e) + { + throw new IOException("Not supported", e); + } + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Sharpen/IO/StreamAdaptor.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Sharpen/IO/StreamAdaptor.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Sharpen/IO/StreamAdaptor.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Sharpen/IO/StreamAdaptor.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,26 @@ +/* Copyright (C) 2004 Versant Inc. http://www.db4o.com */ + +using System.IO; + +namespace Sharpen.IO +{ + public abstract class StreamAdaptor + { + protected readonly Stream _stream; + + public StreamAdaptor(Stream stream) + { + _stream = stream; + } + + public Stream UnderlyingStream + { + get { return _stream; } + } + + public void Close() + { + _stream.Close(); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Sharpen/Lang/IdentityHashCodeProvider.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Sharpen/Lang/IdentityHashCodeProvider.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Sharpen/Lang/IdentityHashCodeProvider.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Sharpen/Lang/IdentityHashCodeProvider.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,57 @@ +/* Copyright (C) 2005 Versant Inc. http://www.db4o.com */ + +using System; +using System.Reflection; + +namespace Sharpen.Lang +{ + public class IdentityHashCodeProvider + { +#if !CF + public static int IdentityHashCode(object obj) + { + return System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(obj); + } +#else + public static int IdentityHashCode(object obj) + { + if (obj == null) return 0; + return (int) _hashMethod.Invoke(null, new object[] { obj }); + } + + private static MethodInfo _hashMethod = GetIdentityHashCodeMethod(); + + private static MethodInfo GetIdentityHashCodeMethod() + { + Assembly assembly = typeof(object).Assembly; + try + { + Type t = assembly.GetType("System.PInvoke.EE"); + return t.GetMethod( + "Object_GetHashCode", + BindingFlags.Public | + BindingFlags.NonPublic | + BindingFlags.Static); + } + catch (Exception e) + { + } + // We may be running the CF app on .NET Framework 1.1 + // for profiling, let's give that a chance + try + { + Type t = assembly.GetType( + "System.Runtime.CompilerServices.RuntimeHelpers"); + return t.GetMethod( + "GetHashCode", + BindingFlags.Public | + BindingFlags.Static); + } + catch + { + } + return null; + } +#endif + } +} \ No newline at end of file diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Sharpen/Lang/Reflect.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Sharpen/Lang/Reflect.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Sharpen/Lang/Reflect.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Sharpen/Lang/Reflect.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,10 @@ +namespace Sharpen.Lang.Reflect +{ + // this namespace just exists because of a bug + // in sharpen that makes it fail to realize that + // a mapped namespace is not being used + class __fixme__ + { + + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Sharpen/Lang/Runnable.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Sharpen/Lang/Runnable.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Sharpen/Lang/Runnable.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Sharpen/Lang/Runnable.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,8 @@ +/* Copyright (C) 2004 Versant Inc. http://www.db4o.com */ +namespace Sharpen.Lang +{ + public interface IRunnable + { + void Run(); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Sharpen/Lang/SimpleTypeReference.Silverlight.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Sharpen/Lang/SimpleTypeReference.Silverlight.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Sharpen/Lang/SimpleTypeReference.Silverlight.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Sharpen/Lang/SimpleTypeReference.Silverlight.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,94 @@ +/* Copyright (C) 2009 Versant Inc. http://www.db4o.com */ + +#if SILVERLIGHT + +using System; +using System.Collections.Generic; +using System.Reflection; +using System.Threading; +using System.Windows; +using System.Windows.Resources; + +#endif + +namespace Sharpen.Lang +{ + public partial class SimpleTypeReference + { +#if SILVERLIGHT + private Assembly ResolveAssemblySilverlight() + { + if (!_assemblyCache.Contains(_assemblyName.Name)) + { + Assembly assembly = IsInUIThread() + ? LoadAssembly(_assemblyName.Name) + : LoadAssemblyInUIThread(_assemblyName.Name); + + _assemblyCache[_assemblyName.Name] = assembly; + return assembly; + } + + return _assemblyCache[_assemblyName.Name]; + } + + private static bool IsInUIThread() + { + return Deployment.Current.CheckAccess(); + } + + private static Assembly LoadAssemblyInUIThread(string assemblyName) + { + Assembly assembly = null; + using (EventWaitHandle wait = new ManualResetEvent(false)) + { + Deployment.Current.Dispatcher.BeginInvoke(delegate + { + assembly = LoadAssembly(assemblyName); + wait.Set(); + }); + + wait.WaitOne(); + } + return assembly; + } + + private static Assembly LoadAssembly(string assemblyName) + { + StreamResourceInfo resourceInfo = Application.GetResourceStream(AssemblyUriFor(assemblyName)); + return new AssemblyPart().Load(resourceInfo.Stream); + } + + private static Uri AssemblyUriFor(string assemblyName) + { + return new Uri(assemblyName + ".dll", UriKind.Relative); + } + + private static readonly AssemblyCache _assemblyCache = new AssemblyCache(typeof(Type).Assembly); + + } + + sealed class AssemblyCache + { + public AssemblyCache(params Assembly[] preCachedAssemblies) + { + foreach (var assembly in preCachedAssemblies) + { + _cache[new AssemblyName(assembly.FullName).Name] = assembly; + } + } + + public Assembly this[string assemblyName] + { + get { return _cache[assemblyName]; } + set { _cache[assemblyName] = value; } + } + + public bool Contains(string assemblyName) + { + return _cache.ContainsKey(assemblyName); + } + + private IDictionary _cache = new Dictionary(); +#endif + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Sharpen/Lang/Thread.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Sharpen/Lang/Thread.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Sharpen/Lang/Thread.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Sharpen/Lang/Thread.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,147 @@ +/* Copyright (C) 2004 Versant Inc. http://www.db4o.com */ + +using System; +using System.Threading; + +namespace Sharpen.Lang +{ + public class Thread : IRunnable + { + private IRunnable _target; + + private string _name; + + private System.Threading.Thread _thread; + + private bool _isDaemon; + + public Thread() + { + _target = this; + } + + public Thread(IRunnable target, string name) + { + _target = target; + SetName(name); + } + + public Thread(IRunnable target) + { + _target = target; + } + + public Thread(System.Threading.Thread thread) + { + _thread = thread; + } + + public static Thread CurrentThread() + { + return new Thread(System.Threading.Thread.CurrentThread); + } + + public virtual void Run() + { + } + + public void SetName(string name) + { + _name = name; +#if !CF + if (_thread != null && name != null) + { + try + { + _thread.Name = _name; + } + catch + { + } + } +#endif + } + + public string GetName() + { +#if !CF + return _thread != null ? _thread.Name : _name; +#else + return ""; +#endif + } + + public static void Sleep(long milliseconds) + { + System.Threading.Thread.Sleep((int)milliseconds); + } + + public void Start() + { + _thread = new System.Threading.Thread(EntryPoint); + _thread.IsBackground = _isDaemon; + if (_name != null) + { + SetName(_name); + } + _thread.Start(); + } + + public void Join() + { + if (_thread == null) + return; + _thread.Join(); + } + + public void Join(int millisecondsTimeout) + { + if (_thread == null) + return; + _thread.Join(millisecondsTimeout); + } + + public void SetDaemon(bool isDaemon) + { + _isDaemon = isDaemon; + } + + public override bool Equals(object obj) + { + Thread other = (obj as Thread); + if (other == null) + return false; + if (other == this) + return true; + if (_thread == null) + return false; + return _thread == other._thread; + } + + public override int GetHashCode() + { + return _thread == null ? 37 : _thread.GetHashCode(); + } + + private void EntryPoint() + { + try + { + _target.Run(); + } + catch (Exception e) + { + // don't let an unhandled exception bring + // the process down + Runtime.PrintStackTrace(e); + } + } + + public bool IsDaemon() + { + return _thread != null + ? _thread.IsBackground + : _isDaemon; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Sharpen/Lang/ThreadLocal.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Sharpen/Lang/ThreadLocal.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Sharpen/Lang/ThreadLocal.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Sharpen/Lang/ThreadLocal.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,49 @@ +using System; +using System.Collections.Generic; + +namespace Sharpen.Lang +{ +#if CF + + class ThreadLocal : Db4objects.Db4o.Foundation.ThreadLocal4 + { + } + +#else + + class ThreadLocal + { + [ThreadStatic] + private static Dictionary _locals; + + public object Get() + { + object value; + if (Locals.TryGetValue(this, out value)) + return value; + return null; + } + + public void Set(object value) + { + if (value == null) + Locals.Remove(this); + else + Locals[this] = value; + } + + private static Dictionary Locals + { + get + { + Dictionary value = _locals; + if (value == null) + _locals = value = new Dictionary(); + return value; + } + } + + } +#endif +} + diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Sharpen/Lang/TypeReference.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Sharpen/Lang/TypeReference.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Sharpen/Lang/TypeReference.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Sharpen/Lang/TypeReference.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,303 @@ +/* Copyright (C) 2005 Versant Inc. http://www.db4o.com */ +using System; +using System.Reflection; +using System.Text; + +namespace Sharpen.Lang +{ + public abstract class TypeReference + { + public static TypeReference FromString(string s) + { + if (null == s) throw new ArgumentNullException("s"); + return new TypeReferenceParser(s).Parse(); + } + + public static TypeReference FromType(Type type) + { + if (null == type) throw new ArgumentNullException("type"); + return FromString(type.AssemblyQualifiedName); + } + + public abstract string SimpleName + { + get; + } + + public abstract AssemblyName AssemblyName + { + get; + } + + public abstract Type Resolve(); + + public abstract void AppendTypeName(StringBuilder builder); + + public override string ToString() + { + return GetUnversionedName(); + } + + public string GetUnversionedName() + { + StringBuilder builder = new StringBuilder(); + AppendUnversionedName(builder); + return builder.ToString(); + } + + internal virtual void AppendUnversionedName(StringBuilder builder) + { + AppendTypeName(builder); + AppendUnversionedAssemblyName(builder); + } + + protected void AppendUnversionedAssemblyName(StringBuilder builder) + { + AssemblyName assemblyName = AssemblyName; + if (null == assemblyName) return; + + builder.Append(", "); + builder.Append(assemblyName.Name); + } + } + + public partial class SimpleTypeReference : TypeReference + { + protected string _simpleName; + + protected AssemblyName _assemblyName; + + internal SimpleTypeReference(string simpleName) + { + _simpleName = simpleName; + } + + public override string SimpleName + { + get { return _simpleName; } + } + + public override AssemblyName AssemblyName + { + get { return _assemblyName; } + } + + public override Type Resolve() + { + return _assemblyName == null + ? Type.GetType(SimpleName) + : ResolveAssembly().GetType(SimpleName); + } + + public override void AppendTypeName(StringBuilder builder) + { + builder.Append(SimpleName); + } + + public override bool Equals(object obj) + { + SimpleTypeReference other = obj as SimpleTypeReference; + if (null == other) return false; + return _simpleName == other._simpleName; + } + + internal void SetSimpleName(string simpleName) + { + _simpleName = simpleName; + } + + internal void SetAssemblyName(AssemblyName assemblyName) + { + _assemblyName = assemblyName; + } + + private Assembly ResolveAssembly() + { +#if SILVERLIGHT + return ResolveAssemblySilverlight(); +#else + if (null == _assemblyName.Version) + { + return LoadUnversionedAssembly(_assemblyName); + } + + Assembly found; + try + { + found = Assembly.Load(_assemblyName); + } + catch (Exception) + { + AssemblyName unversioned = (AssemblyName)_assemblyName.Clone(); + unversioned.Version = null; + found = LoadUnversionedAssembly(unversioned); + } + return found; +#endif + } + + private Assembly LoadUnversionedAssembly(AssemblyName unversioned) + { +#if CF || SILVERLIGHT + return Assembly.Load(unversioned); +#else + Assembly found = Assembly.LoadWithPartialName(unversioned.FullName); + return found == null + ? Assembly.Load(unversioned) + : found; +#endif + } + } + + public abstract class QualifiedTypeReference : TypeReference + { + protected TypeReference _elementType; + + protected QualifiedTypeReference(TypeReference elementType) + { + _elementType = elementType; + } + + public override string SimpleName + { + get + { + return _elementType.SimpleName; + } + } + + public override AssemblyName AssemblyName + { + get { return _elementType.AssemblyName; } + } + + public override void AppendTypeName(StringBuilder builder) + { + _elementType.AppendTypeName(builder); + AppendQualifier(builder); + } + + protected abstract void AppendQualifier(StringBuilder builder); + } + + public class PointerTypeReference : QualifiedTypeReference + { + public PointerTypeReference(TypeReference elementType) + : base(elementType) + { + } + + protected override void AppendQualifier(StringBuilder builder) + { + builder.Append('*'); + } + + public override Type Resolve() + { +#if !CF + return _elementType.Resolve().MakePointerType(); +#else + StringBuilder builder = new StringBuilder(); + AppendTypeName(builder); + return _elementType.Resolve().Assembly.GetType(builder.ToString(), true); +#endif + } + } + + public class ArrayTypeReference : QualifiedTypeReference + { + public static Type MakeArrayType(Type elementType, int rank) + { +#if !CF + if (rank == 1) return elementType.MakeArrayType(); + return elementType.MakeArrayType(rank); +#else + if (rank == 1) return Array.CreateInstance(elementType, 0).GetType(); + return Array.CreateInstance(elementType, new int[rank]).GetType(); +#endif + } + + + private readonly int _rank; + + internal ArrayTypeReference(TypeReference elementType, int rank) : base(elementType) + { + _rank = rank; + } + + public int Rank + { + get { return _rank; } + } + + public override Type Resolve() + { + return MakeArrayType(_elementType.Resolve(), _rank); + } + + protected override void AppendQualifier(StringBuilder builder) + { + builder.Append('['); + for (int i = 1; i < _rank; ++i) + { + builder.Append(','); + } + builder.Append(']'); + } + } + + public class GenericTypeReference : SimpleTypeReference + { + private readonly TypeReference[] _genericArguments; + + internal GenericTypeReference(string simpleName, TypeReference[] genericArguments) + : base(simpleName) + { + _genericArguments = genericArguments; + } + + public TypeReference[] GenericArguments + { + get { return _genericArguments; } + } + + public override Type Resolve() + { + Type baseType = base.Resolve(); + return _genericArguments.Length > 0 + ? baseType.MakeGenericType(Resolve(_genericArguments)) + : baseType; + } + + static Type[] Resolve(TypeReference[] typeRefs) + { + Type[] types = new Type[typeRefs.Length]; + for (int i = 0; i < types.Length; ++i) + { + types[i] = typeRefs[i].Resolve(); + } + return types; + } + + public override void AppendTypeName(StringBuilder builder) + { + builder.Append(_simpleName); + AppendUnversionedGenericArguments(builder); + } + + private void AppendUnversionedGenericArguments(StringBuilder builder) + { + if (_genericArguments.Length == 0) return; + + builder.Append("["); + for (int i = 0; i < _genericArguments.Length; ++i) + { + if (i > 0) builder.Append(", "); + builder.Append("["); + _genericArguments[i].AppendUnversionedName(builder); + builder.Append("]"); + } + builder.Append("]"); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Sharpen/Lang/TypeReferenceLexer.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Sharpen/Lang/TypeReferenceLexer.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Sharpen/Lang/TypeReferenceLexer.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Sharpen/Lang/TypeReferenceLexer.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,186 @@ +/* Copyright (C) 2005 Versant Inc. http://www.db4o.com */ +using System; +using System.Text; + +namespace Sharpen.Lang +{ + internal enum TokenKind + { + Comma, + Equals, + Id, + Number, + VersionNumber, + GenericQualifier, + NestedQualifier, + LBrack, + RBrack, + PointerQualifier + } + + internal class Token + { + public TokenKind Kind; + public string Value; + + public Token(TokenKind kind, string value) + { + this.Kind = kind; + this.Value = value; + //Console.WriteLine(this); + } + + public override string ToString() + { + return string.Format("Token(Kind: {0}, Value: '{1}')", Kind, Value); + } + } + + internal class TypeReferenceLexer + { + string _input; + int _index; + StringBuilder _buffer; // TODO: get rid of StringBuilder and use string.Substring + + public TypeReferenceLexer(string input) + { + if (null == input) throw new ArgumentNullException("input"); + _input = input; + _index = 0; + _buffer = new StringBuilder(input.Length); + } + + bool AtEOF + { + get { return _index == _input.Length; } + } + + public Token NextToken() + { + if (AtEOF) return null; + + char ch = Peek(); + switch (ch) + { + case '*': + return ConsumeSingleCharToken(ch, TokenKind.PointerQualifier); + case '+': + return ConsumeSingleCharToken(ch, TokenKind.NestedQualifier); + case '[': + return ConsumeSingleCharToken(ch, TokenKind.LBrack); + case ']': + return ConsumeSingleCharToken(ch, TokenKind.RBrack); + case '=': + return ConsumeSingleCharToken(ch, TokenKind.Equals); + case ',': + return ConsumeSingleCharToken(ch, TokenKind.Comma); + case '`': + return ConsumeSingleCharToken(ch, TokenKind.GenericQualifier); + case ' ': + Consume(); + return NextToken(); + default: + if (IsIdStart(ch)) return Id(); + if (char.IsDigit(ch)) return NumberOrVersion(); + break; + } + throw new Exception(string.Format("Unexpected char '{0}'", ch)); + } + + private static bool IsIdStart(char ch) + { + switch (ch) + { + case '_': + case '<': // c# compiler generated classes + return true; + } + return char.IsLetter(ch); + } + + private Token Id() + { + do + { + char ch = Peek(); + if (!char.IsLetterOrDigit(ch) + && '.' != ch + && '-' != ch + && '_' != ch + && '<' != ch + && '>' != ch + && ':' != ch + && ' ' != ch) // assembly names can contain spaces + { + break; + } + ConsumeAndBuffer(ch); + } + while (!AtEOF); + return TokenFromBuffer(TokenKind.Id); + } + + private Token NumberOrVersion() + { + TokenKind kind = TokenKind.Number; + + do + { + char ch = Peek(); + if ('.' == ch) + { + kind = TokenKind.VersionNumber; + } + else + { + if (!IsHexDigit(ch)) + { + break; + } + } + ConsumeAndBuffer(ch); + } + while (!AtEOF); + return TokenFromBuffer(kind); + } + + private static bool IsHexDigit(char ch) + { + return char.IsDigit(ch) || IsHexLetter(ch); + } + + private static bool IsHexLetter(char ch) + { + return (ch >= 'A' && ch <= 'F') || (ch >= 'a' && ch <= 'f'); + } + + private void ConsumeAndBuffer(char ch) + { + Consume(); + _buffer.Append(ch); + } + + private Token TokenFromBuffer(TokenKind kind) + { + Token token = new Token(kind, _buffer.ToString()); + _buffer.Length = 0; + return token; + } + + private Token ConsumeSingleCharToken(char ch, TokenKind kind) + { + Consume(); + return new Token(kind, new string(ch, 1)); + } + + void Consume() + { + ++_index; + } + + char Peek() + { + return _input[_index]; + } + } +} \ No newline at end of file diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Sharpen/Lang/TypeReferenceParser.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Sharpen/Lang/TypeReferenceParser.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Sharpen/Lang/TypeReferenceParser.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Sharpen/Lang/TypeReferenceParser.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,259 @@ +/* Copyright (C) 2005 Versant Inc. http://www.db4o.com */ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Reflection; + +namespace Sharpen.Lang +{ + internal class TypeReferenceParser + { + private readonly TypeReferenceLexer _lexer; + private readonly Stack _stack = new Stack(); + + public TypeReferenceParser(string input) + { + _lexer = new TypeReferenceLexer(input); + } + + public TypeReference Parse() + { + SimpleTypeReference str = ParseSimpleTypeReference(); + TypeReference returnValue = ParseQualifiedTypeReference(str); + Token token = NextToken(); + if (null != token) + { + switch (token.Kind) + { + case TokenKind.Comma: + str.SetAssemblyName(ParseAssemblyName()); + break; + default: + UnexpectedToken(TokenKind.Comma, token); + break; + } + } + return returnValue; + } + + private TypeReference ParseQualifiedTypeReference(TypeReference elementType) + { + TypeReference returnValue = elementType; + + Token token; + while (null != (token = NextToken())) + { + switch (token.Kind) + { + case TokenKind.LBrack: + returnValue = ParseArrayTypeReference(returnValue); + break; + case TokenKind.PointerQualifier: + returnValue = new PointerTypeReference(returnValue); + break; + default: + Push(token); + return returnValue; + } + } + + return returnValue; + } + + private TypeReference ParseArrayTypeReference(TypeReference str) + { + int rank = 1; + Token token = NextToken(); + while (null != token && token.Kind == TokenKind.Comma) + { + ++rank; + token = NextToken(); + } + AssertTokenKind(TokenKind.RBrack, token); + + return new ArrayTypeReference(str, rank); + } + + private SimpleTypeReference ParseSimpleTypeReference() + { + Token id = Expect(TokenKind.Id); + + Token t = NextToken(); + if (null == t) return new SimpleTypeReference(id.Value); + + while (TokenKind.NestedQualifier == t.Kind) + { + Token nestedId = Expect(TokenKind.Id); + id.Value += "+" + nestedId.Value; + + t = NextToken(); + if (null == t) return new SimpleTypeReference(id.Value); + } + + if (t.Kind == TokenKind.GenericQualifier) + { + return ParseGenericTypeReference(id); + } + + Push(t); + return new SimpleTypeReference(id.Value); + } + + private SimpleTypeReference ParseGenericTypeReference(Token id) + { + return InternalParseGenericTypeReference(id, 0); + } + + private SimpleTypeReference InternalParseGenericTypeReference(Token id, int count) + { + Token argcToken = Expect(TokenKind.Number); + id.Value += "`" + argcToken.Value; + + int argc = int.Parse(argcToken.Value); + + Token t = NextToken(); + while (TokenKind.NestedQualifier == t.Kind) + { + Token nestedId = Expect(TokenKind.Id); + id.Value += "+" + nestedId.Value; + + t = NextToken(); + } + + if (IsInnerGenericTypeReference(t)) + { + return InternalParseGenericTypeReference(id, argc + count); + } + + TypeReference[] args = new TypeReference[0]; + if (!IsOpenGenericTypeDefinition(t)) + { + args = new TypeReference[argc + count]; + AssertTokenKind(TokenKind.LBrack, t); + for (int i = 0; i < args.Length; ++i) + { + if (i > 0) Expect(TokenKind.Comma); + Expect(TokenKind.LBrack); + args[i] = Parse(); + Expect(TokenKind.RBrack); + } + Expect(TokenKind.RBrack); + } + else + { + Push(t); + } + + return new GenericTypeReference(id.Value, args); + } + + private static bool IsOpenGenericTypeDefinition(Token t) + { + return t.Kind != TokenKind.LBrack; + } + + private static bool IsInnerGenericTypeReference(Token t) + { + return TokenKind.GenericQualifier == t.Kind; + } + + public AssemblyName ParseAssemblyName() + { + Token simpleName = Expect(TokenKind.Id); + + AssemblyName assemblyName = new AssemblyName(); + assemblyName.Name = simpleName.Value; + + if (!CommaIdEquals()) return assemblyName; + + Token version = Expect(TokenKind.VersionNumber); + assemblyName.Version = new Version(version.Value); + + if (!CommaIdEquals()) return assemblyName; + + Token culture = Expect(TokenKind.Id); + if ("neutral" == culture.Value) + { + assemblyName.CultureInfo = CultureInfo.InvariantCulture; + } + else + { +#if SILVERLIGHT + assemblyName.CultureInfo = CultureInfo.InvariantCulture; +#else + assemblyName.CultureInfo = CultureInfo.CreateSpecificCulture(culture.Value); +#endif + } + + if (!CommaIdEquals()) return assemblyName; + + Token token = NextToken(); + if ("null" != token.Value) + { + assemblyName.SetPublicKeyToken(ParsePublicKeyToken(token.Value)); + } + + return assemblyName; + } + + static byte[] ParsePublicKeyToken(string token) + { + int len = token.Length / 2; + byte[] bytes = new byte[len]; + for (int i = 0; i < len; ++i) + { + bytes[i] = byte.Parse(token.Substring(i * 2, 2), NumberStyles.HexNumber); + } + return bytes; + } + + private bool CommaIdEquals() + { + Token token = NextToken(); + if (null == token) return false; + if (token.Kind != TokenKind.Comma) + { + Push(token); + return false; + } + + AssertTokenKind(TokenKind.Comma, token); + Expect(TokenKind.Id); + Expect(TokenKind.Equals); + return true; + } + + Token Expect(TokenKind expected) + { + Token actual = NextToken(); + AssertTokenKind(expected, actual); + return actual; + } + + private static void AssertTokenKind(TokenKind expected, Token actual) + { + if (null == actual || actual.Kind != expected) + { + UnexpectedToken(expected, actual); + } + } + + private static void UnexpectedToken(TokenKind expectedKind, Token actual) + { + throw new ArgumentException(string.Format("Unexpected Token: '{0}' (Expected kind: '{1}')", actual, expectedKind)); + } + + private void Push(Token token) + { + _stack.Push(token); + } + + private Token NextToken() + { + return _stack.Count > 0 + ? _stack.Pop() + : _lexer.NextToken(); + } + + } +} \ No newline at end of file diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Sharpen/Net/ServerSocket.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Sharpen/Net/ServerSocket.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Sharpen/Net/ServerSocket.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Sharpen/Net/ServerSocket.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,42 @@ +/* Copyright (C) 2007 Versant Inc. http://www.db4o.com */ +using System; +using System.Net; +using System.Net.Sockets; +using NativeSocket=System.Net.Sockets.Socket; + +namespace Sharpen.Net +{ + public class ServerSocket : SocketWrapper + { + public ServerSocket(int port) + { +#if !SILVERLIGHT + try + { + NativeSocket socket = new NativeSocket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); + socket.Bind(new IPEndPoint(IPAddress.Any, port)); + + int maxPendingConnections = 42; + socket.Listen(maxPendingConnections); + Initialize(socket); + } + catch (SocketException e) + { + throw new System.IO.IOException(e.Message); + } +#endif + } + +#if !SILVERLIGHT + public Socket Accept() + { + return new Socket(_delegate.Accept()); + } + + public int GetLocalPort() + { + return ((IPEndPoint)_delegate.LocalEndPoint).Port; + } +#endif + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Sharpen/Net/Socket.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Sharpen/Net/Socket.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Sharpen/Net/Socket.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Sharpen/Net/Socket.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,149 @@ +/* Copyright (C) 2007 Versant Inc. http://www.db4o.com */ +using System; +using System.IO; +using System.Net; +using Sharpen.IO; +using NativeSocket=System.Net.Sockets.Socket; +using System.Net.Sockets; + +namespace Sharpen.Net +{ + public class Socket : SocketWrapper + { +#if SILVERLIGHT + public Socket(string hostName, int port) + { + } + } +#else + public Socket(string hostName, int port) + { + NativeSocket socket = new NativeSocket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); + socket.Connect(new IPEndPoint(Resolve(hostName), port)); + Initialize(socket); + _toString = StringRepresentation(); + } + + private static IPAddress Resolve(string hostName) + { + IPHostEntry found = Dns.GetHostEntry(hostName); + foreach (IPAddress address in found.AddressList) + { + if (address.AddressFamily == AddressFamily.InterNetwork) + { + return address; + } + } + throw new IOException("couldn't find suitable address for name '" + hostName + "'"); + } + + public Socket(NativeSocket socket) + { + Initialize(socket); + } + + public IInputStream GetInputStream() + { + return _in; + } + + public IOutputStream GetOutputStream() + { + return _out; + } + + public int GetPort() + { + return ((IPEndPoint) _delegate.RemoteEndPoint).Port; + } + + override protected void Initialize(NativeSocket socket) + { + base.Initialize(socket); + + NetworkStream stream = new NetworkStream(_delegate); + +#if CF + _in = new SocketInputStream(this); +#else + _in = new InputStream(stream); +#endif + _out = new OutputStream(stream); + } + + public override string ToString() + { + return _toString; + } + + private string StringRepresentation() + { + return ((IPEndPoint)_delegate.LocalEndPoint).Port + " => "+ UnderlyingSocket.RemoteEndPoint; + } + + private IInputStream _in; + private IOutputStream _out; + private readonly string _toString; + } +#if CF + internal class SocketInputStream : IInputStream + { + private readonly Socket _socket; + + public SocketInputStream(Socket socket) + { + _socket = socket; + } + + public int Read() + { + byte[] buffer = new byte[1]; + if (1 != Read(buffer)) + { + return -1; + } + return (int) buffer[0]; + } + + public int Read(byte[] bytes) + { + return Read(bytes, 0, bytes.Length); + } + + public int Read(byte[] bytes, int offset, int length) + { + try + { + if (_socket.SoTimeout > 0) + { + if (!UnderlyingSocket.Poll(_socket.SoTimeout*1000, SelectMode.SelectRead)) + { + throw new IOException("read timeout"); + } + } + return InputStream.TranslateReadReturnValue( + UnderlyingSocket.Receive(bytes, offset, length, SocketFlags.None)); + } + catch (ObjectDisposedException x) + { + throw new IOException(x.Message, x); + } + catch (SocketException x) + { + throw new IOException(x.Message, x); + } + } + + public void Close() + { + // nothing to do + } + + private System.Net.Sockets.Socket UnderlyingSocket + { + get { return _socket.UnderlyingSocket; } + } + } +#endif // CF +#endif // SILVERLIGHT +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Sharpen/Net/SocketWrapper.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Sharpen/Net/SocketWrapper.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Sharpen/Net/SocketWrapper.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Sharpen/Net/SocketWrapper.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,61 @@ +/* Copyright (C) 2007 Versant Inc. http://www.db4o.com */ +using System; +using System.Net.Sockets; +using NativeSocket=System.Net.Sockets.Socket; + +namespace Sharpen.Net +{ + public class SocketWrapper + { + protected NativeSocket _delegate; + +#if CF || SILVERLIGHT + private int _soTimeout = 0; + + public int SoTimeout + { + get { return _soTimeout; } + } +#endif + + public NativeSocket UnderlyingSocket + { + get { return _delegate; } + } + + protected virtual void Initialize(NativeSocket socket) + { + _delegate = socket; + } + + public void SetSoTimeout(int timeout) + { +#if !CF && !SILVERLIGHT + _delegate.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReceiveTimeout, timeout); + _delegate.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.SendTimeout, timeout); +#else + _soTimeout = timeout; +#endif + } + + public void Close() + { + if (_delegate.Connected) + { + try + { + _delegate.Shutdown(SocketShutdown.Both); + } + catch (Exception) + { + } + } + _delegate.Close(); + } + + public bool IsConnected() + { + return _delegate.Connected; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Sharpen/Runtime.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Sharpen/Runtime.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Sharpen/Runtime.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Sharpen/Runtime.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,287 @@ +/* Copyright (C) 2004 Versant Inc. http://www.db4o.com */ + +using System; +using System.IO; +using System.Reflection; +using System.Threading; +using Sharpen.Lang; + +namespace Sharpen +{ + public class Runtime + { + private static long DIFFERENCE_IN_TICKS = 62135604000000; + private static long RATIO = 10000; + + public static TextWriter Out + { + get + { + return Console.Out; + } + } + + public static TextWriter Err + { + get + { + return Console.Error; + } + } + + public static object GetArrayValue(object array, int i) + { + return ((Array)array).GetValue(i); + } + + public static int GetArrayLength(object array) + { + return ((Array) array).Length; + } + + public static void SetArrayValue(object array, int index, object value) + { + ((Array)array).SetValue(value, index); + } + + private const BindingFlags AllMembers = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance; + + private const BindingFlags DeclaredMembers = BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance; + + private const BindingFlags DeclaredMembersIncludingStatic = DeclaredMembers | BindingFlags.Static; + + public static FieldInfo GetDeclaredField(Type type, string name) + { + return type.GetField(name, DeclaredMembersIncludingStatic); + } + + public static FieldInfo[] GetDeclaredFields(Type type) + { + return type.GetFields(DeclaredMembersIncludingStatic); + } + + public static MethodInfo GetDeclaredMethod(Type type, string name, Type[] parameterTypes) + { + return type.GetMethod(name, DeclaredMembers, null, parameterTypes, null); + } + + public static MethodInfo GetMethod(Type type, string name, Type[] parameterTypes) + { + return type.GetMethod(name, AllMembers, null, parameterTypes, null); + } + + public static Type[] GetParameterTypes(MethodBase method) + { + ParameterInfo[] parameters = method.GetParameters(); + Type[] types = new Type[parameters.Length]; + for (int i=0; i(T[] array, T value) + { + for (int i=0; i(T[] array, int fromIndex, int toIndex, T value) + { + for (int i = fromIndex; i < toIndex; ++i) + { + array[i] = value; + } + } + + public static bool Equals(T[] x, T[] y) + { + if (x == null) return y == null; + if (y == null) return false; + if (x.Length != y.Length) return false; + for (int i = 0; i < x.Length; ++i) + { + if (!object.Equals(x[i], y[i])) return false; + } + return true; + } + + public static List AsList(T[] array) + { + return new List(array); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Sharpen/Util/HashSet.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Sharpen/Util/HashSet.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Sharpen/Util/HashSet.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Sharpen/Util/HashSet.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,175 @@ +/* Copyright (C) 2004 - 2008 Versant Inc. http://www.db4o.com */ +using System; +using System.Collections; +using System.Collections.Generic; + +namespace Sharpen.Util +{ + public class HashSet : ISet, /* IList required for dRS */ IList + { + private readonly static object _object = new object(); + + // FIXME: dRS doesn't like using a dictionary here +#if SILVERLIGHT + private readonly List _elements = new List(); +#else + private readonly ArrayList _elements = new ArrayList(); +#endif + + public HashSet() + { + } + + public HashSet(ICollection initialValues) + { + AddAll(initialValues); + } + + public bool Add(object o) + { + if (Contains(o)) return false; + + _elements.Add(o); + return true; + } + + public bool AddAll(ICollection c) + { + bool changed = false; + foreach (object o in c) + { + changed |= Add(o); + } + return changed; + } + + public void Clear() + { + _elements.Clear(); + } + + public bool Contains(object o) + { + return _elements.Contains(o); + } + + public bool ContainsAll(ICollection c) + { + foreach (object o in c) + { + if (!Contains(o)) + { + return false; + } + } + return true; + } + + public bool IsEmpty + { + get { return _elements.Count == 0; } + } + + public bool Remove(object o) + { + if (!Contains(o)) return false; + + _elements.Remove(o); + return true; + } + + public bool RemoveAll(ICollection c) + { + bool changed = false; + foreach (object o in c) + { + changed |= Remove(o); + } + return changed; + } + + public void CopyTo(Array array, int index) + { +#if SILVERLIGHT + object[] objectArray = new object[array.Length]; + int idx = 0; + foreach (var a in array) + { + objectArray[idx++] = a; + } + _elements.CopyTo(objectArray, index); +#else + _elements.CopyTo(array, index); +#endif + } + + public int Count + { + get { return _elements.Count; } + } + + public bool IsSynchronized + { + get { return false; } + } + + public object SyncRoot + { + get + { +#if SILVERLIGHT + throw new InvalidOperationException(); +#else + return _elements.SyncRoot; +#endif + } + } + + public IEnumerator GetEnumerator() + { + return _elements.GetEnumerator(); + } + + int IList.Add(object value) + { + ((ISet) this).Add(value); + return 0; + } + + void IList.Remove(object value) + { + ((ISet)this).Remove(value); + } + + int IList.IndexOf(object value) + { + throw new NotImplementedException(); + } + + void IList.Insert(int index, object value) + { + throw new NotImplementedException(); + } + + void IList.RemoveAt(int index) + { + throw new NotImplementedException(); + } + + object IList.this[int index] + { + get { throw new NotImplementedException(); } + set { throw new NotImplementedException(); } + } + + bool IList.IsReadOnly + { + get { return false; } + } + + bool IList.IsFixedSize + { + get { return false; } + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Sharpen/Util/ISet.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Sharpen/Util/ISet.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Sharpen/Util/ISet.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Sharpen/Util/ISet.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,13 @@ +using System; +using System.Collections; +using System.Text; + +namespace Sharpen.Util +{ + public interface ISet: ICollection + { + bool Add(object element); + bool Remove(object element); + bool Contains(object element); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Sharpen/Util/Random.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Sharpen/Util/Random.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Sharpen/Util/Random.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Sharpen/Util/Random.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,30 @@ +/* Copyright (C) 2004 Versant Inc. http://www.db4o.com */ + +using System.Collections; + +namespace Sharpen.Util +{ + public class Random + { + readonly System.Random _random = new System.Random(); + + public Random() + { + } + + public long NextLong() + { + return _random.Next(); + } + + public int NextInt() + { + return _random.Next(int.MinValue, int.MaxValue); + } + + public object NextInt(int ceiling) + { + return _random.Next(ceiling); + } + } +} \ No newline at end of file diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Silverlight/Db4objects.Db4o/Config/SilverlightSupport.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Silverlight/Db4objects.Db4o/Config/SilverlightSupport.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Silverlight/Db4objects.Db4o/Config/SilverlightSupport.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Silverlight/Db4objects.Db4o/Config/SilverlightSupport.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,26 @@ +/* Copyright (C) 2010 Versant Inc. http://www.db4o.com */ +#if SILVERLIGHT +using Db4objects.Db4o.IO; + +namespace Db4objects.Db4o.Config +{ + /// + /// Configures the database to be used in a Silverlight application. + /// + /// + /// This configuration item basically configures db4o to use Silverlight isolatad storage. + /// If your Silverlight application may run "out of browser" you may want to not add this. + /// + public class SilverlightSupport : IEmbeddedConfigurationItem + { + public void Prepare(IEmbeddedConfiguration configuration) + { + configuration.File.Storage = new IsolatedStorageStorage(); + } + + public void Apply(IEmbeddedObjectContainer db) + { + } + } +} +#endif \ No newline at end of file diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Silverlight/Db4objects.Db4o/Foundation/IO/File4.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Silverlight/Db4objects.Db4o/Foundation/IO/File4.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Silverlight/Db4objects.Db4o/Foundation/IO/File4.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Silverlight/Db4objects.Db4o/Foundation/IO/File4.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,45 @@ +/* Copyright (C) 2009 Versant Inc. http://www.db4o.com */ + +#if SILVERLIGHT +using System; +using System.IO; +using System.IO.IsolatedStorage; + +namespace Db4objects.Db4o.Foundation.IO +{ + public class File4 + { + + public static void Delete(string file) + { + IsolatedStorageFile storageFile = IsolatedStorageFile.GetUserStoreForApplication(); + if (storageFile.FileExists(file)) + { + storageFile.DeleteFile(file); + } + } + + public static void Copy(string from, string to) + { + throw new NotImplementedException(); + } + + public static bool Exists(string file) + { + IsolatedStorageFile storageFile = IsolatedStorageFile.GetUserStoreForApplication(); + return storageFile.FileExists(file); + } + + public static long Size(string filePath) + { + using (IsolatedStorageFile storageFile = IsolatedStorageFile.GetUserStoreForApplication()) + { + using (IsolatedStorageFileStream fileStream = storageFile.OpenFile(filePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) + { + return fileStream.Length; + } + } + } + } + } +#endif diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Silverlight/Db4objects.Db4o/Internal/BlobImpl.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Silverlight/Db4objects.Db4o/Internal/BlobImpl.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Silverlight/Db4objects.Db4o/Internal/BlobImpl.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Silverlight/Db4objects.Db4o/Internal/BlobImpl.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,46 @@ +/* Copyright (C) 2009 Versant Inc. http://www.db4o.com */ + +#if SILVERLIGHT + +namespace Db4objects.Db4o.Internal +{ + public class BlobImpl : IDb4oTypeImpl + { + public void SetTrans(Transaction a_trans) + { + throw new System.NotImplementedException(); + } + + public bool CanBind() + { + throw new System.NotImplementedException(); + } + + public object CreateDefault(Transaction trans) + { + throw new System.NotImplementedException(); + } + + public bool HasClassIndex() + { + throw new System.NotImplementedException(); + } + + public void SetObjectReference(ObjectReference @ref) + { + throw new System.NotImplementedException(); + } + + public object StoredTo(Transaction trans) + { + throw new System.NotImplementedException(); + } + + public void PreDeactivate() + { + throw new System.NotImplementedException(); + } + } +} + +#endif \ No newline at end of file diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Silverlight/Db4objects.Db4o/IO/IsolatedStorageFileBin.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Silverlight/Db4objects.Db4o/IO/IsolatedStorageFileBin.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Silverlight/Db4objects.Db4o/IO/IsolatedStorageFileBin.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Silverlight/Db4objects.Db4o/IO/IsolatedStorageFileBin.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,169 @@ +/* Copyright (C) 2009 Versant Inc. http://www.db4o.com */ + +#if SILVERLIGHT + +using System; +using System.IO; +using System.IO.IsolatedStorage; +using Db4objects.Db4o.Ext; +using Sharpen.Lang; +using Sharpen.Util; + +namespace Db4objects.Db4o.IO +{ + class IsolatedStorageFileBin : IBin + { + private readonly IsolatedStorageFileStream _fileStream; + private string _fullPath; + + internal IsolatedStorageFileBin(BinConfiguration config, IsolatedStorageFile store) + { + Action cleanUp = Close; + try + { + _fileStream = OpenFile(config, store); + cleanUp = () => {}; + } + catch (IsolatedStorageException e) + { + ThrowMappedException(e, config.Uri(), store); + } + finally + { + cleanUp(); + } + } + + internal string Path + { + get { return _fullPath; } + } + + private static void ThrowMappedException(Exception e, string path, IsolatedStorageFile store) + { + if (store.FileExists(path)) + { + throw new DatabaseFileLockedException(path, e); + } + throw new Db4oIOException(e); + } + + private IsolatedStorageFileStream OpenFile(BinConfiguration config, IsolatedStorageFile store) + { + _fullPath = config.Uri(); + string path = config.Uri(); + IsolatedStorageFileStream stream = new IsolatedStorageFileStream(path, FileModeFor(store, path), FileAccessFor(config), FileShareFor(config), store); + Fill(stream, config.InitialLength(), 0); + + return stream; + } + + private static FileMode FileModeFor(IsolatedStorageFile store, string path) + { + return store.FileExists(path) ? FileMode.Open : FileMode.CreateNew; + } + + private static void Fill(Stream stream, long length, byte value) + { + if (length > 0) + { + byte[] bytes = new byte[length]; + Arrays.Fill(bytes, value); + stream.Write(bytes, 0, bytes.Length); + } + } + + private static FileShare FileShareFor(BinConfiguration config) + { + return config.LockFile() ? FileShare.None : FileShare.ReadWrite; + } + + private static FileAccess FileAccessFor(BinConfiguration config) + { + return config.ReadOnly() ? FileAccess.Read : FileAccess.ReadWrite; + } + + #region IBin Members + + public long Length() + { + return _fileStream.Length; + } + + public int Read(long position, byte[] bytes, int bytesToRead) + { + try + { + Seek(position); + return _fileStream.Read(bytes, 0, bytesToRead); + } + catch (IOException e) + { + throw new Db4oIOException(e); + } + } + + public void Write(long position, byte[] bytes, int bytesToWrite) + { + try + { + Seek(position); + _fileStream.Write(bytes, 0, bytesToWrite); + } + catch (NotSupportedException e) + { + throw new Db4oIOException(e); + } + } + + public void Sync() + { + _fileStream.Flush(); + } + + public void Sync(IRunnable runnable) + { + Sync(); + runnable.Run(); + Sync(); + } + + public int SyncRead(long position, byte[] bytes, int bytesToRead) + { + return Read(position, bytes, bytesToRead); + } + + public void Close() + { + if (_fileStream != null) + { + _fileStream.Close(); + RaiseOnCloseEvent(); + } + } + + #endregion + + private void Seek(long position) + { + if (DTrace.enabled) + { + DTrace.RegularSeek.Log(position); + } + _fileStream.Seek(position, SeekOrigin.Begin); + } + + private void RaiseOnCloseEvent() + { + Action onClose = OnClose; + if (onClose != null) + { + onClose(this, EventArgs.Empty); + } + } + + internal event Action OnClose; + } +} + +#endif diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Silverlight/Db4objects.Db4o/IO/IsolatedStorageStorage.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Silverlight/Db4objects.Db4o/IO/IsolatedStorageStorage.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Silverlight/Db4objects.Db4o/IO/IsolatedStorageStorage.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Silverlight/Db4objects.Db4o/IO/IsolatedStorageStorage.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,113 @@ +/* Copyright (C) 2009 Versant Inc. http://www.db4o.com */ + +#if SILVERLIGHT + +using System.Collections.Generic; +using System.IO.IsolatedStorage; +using System.IO; + +namespace Db4objects.Db4o.IO +{ + public class IsolatedStorageStorage : IStorage + { + private static readonly IsolatedStorageFile _store = IsolatedStorageFile.GetUserStoreForApplication(); + private static readonly IDictionary _openBins = new Dictionary(); + + #region IStorage Members + + public IBin Open(BinConfiguration config) + { + IsolatedStorageFileBin bin = new IsolatedStorageFileBin(config, _store); + AddToOpenBinsCollection(bin); + RegisterForOnCloseEvent(bin); + + return bin; + } + + public bool Exists(string uri) + { + return _store.FileExists(uri) && FileSize(uri) > 0; + } + + public void Delete(string uri) + { + if (_store.FileExists(uri)) + { + _store.DeleteFile(uri); + } + } + + public void Rename(string oldUri, string newUri) + { + if (_store.FileExists(oldUri)) + { + Copy(oldUri, newUri); + Delete(oldUri); + } + } + + private static void Copy(string from, string to) + { + using (IsolatedStorageFileStream fromStream = _store.OpenFile(from, FileMode.Open, FileAccess.Read, FileShare.None)) + { + using(IsolatedStorageFileStream toStream = _store.OpenFile(to, FileMode.CreateNew, FileAccess.Write, FileShare.None)) + { + byte []buffer = new byte[1024 * 1024]; + int count = fromStream.Read(buffer, 0, buffer.Length); + while (count > 0) + { + toStream.Write(buffer, 0, count); + count = fromStream.Read(buffer, 0, buffer.Length); + } + } + } + } + + #endregion + + public static long FileSize(string uri) + { + lock (_openBins) + { + if (IsBinAlreadyOpen(uri)) + { + IsolatedStorageFileBin bin = _openBins[uri]; + return bin.Length(); + } + + using (IsolatedStorageFileStream fileStream = _store.OpenFile(uri, FileMode.Open, FileAccess.Read, FileShare.None)) + { + return fileStream.Length; + } + } + } + + private static bool IsBinAlreadyOpen(string uri) + { + return _openBins.ContainsKey(uri); + } + + private static void RegisterForOnCloseEvent(IsolatedStorageFileBin bin) + { + bin.OnClose += (sender, arg) => RemoveFromOpenBinCollection(((IsolatedStorageFileBin)sender).Path); + } + + private static void RemoveFromOpenBinCollection(string path) + { + lock (_openBins) + { + if (_openBins.ContainsKey(path)) + { + _openBins.Remove(path); + } + } + } + + private static void AddToOpenBinsCollection(IsolatedStorageFileBin bin) + { + _openBins[bin.Path] = bin; + } + } +} + +#endif diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Silverlight/Db4objects.Db4o/IO/SilverlightIO.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Silverlight/Db4objects.Db4o/IO/SilverlightIO.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Silverlight/Db4objects.Db4o/IO/SilverlightIO.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Silverlight/Db4objects.Db4o/IO/SilverlightIO.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,42 @@ +/* Copyright (C) 2009 Versant Inc. http://www.db4o.com */ +#if SILVERLIGHT +using System; +using System.IO; +using System.IO.IsolatedStorage; + +namespace Db4objects.Db4o.IO +{ + public static class SilverlightIO + { + public static bool Exists(string path) + { + return ExistsIn(IsolatedStorageFile.GetUserStoreForApplication(), path); + } + + private static bool ExistsIn(IsolatedStorageFile storage, string path) + { + return storage.FileExists(path); + } + + public static bool Delete(string path) + { + IsolatedStorageFile storage = IsolatedStorageFile.GetUserStoreForApplication(); + if (ExistsIn(storage, path)) + { + storage.DeleteFile(path); + return !ExistsIn(storage, path); + } + return false; + } + + public static long Length(string path) + { + IsolatedStorageFile storage = IsolatedStorageFile.GetUserStoreForApplication(); + using (IsolatedStorageFileStream fileStream = storage.OpenFile(path, FileMode.Open, FileAccess.Read, FileShare.Read)) + { + return fileStream.Length; + } + } + } +} +#endif \ No newline at end of file diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Silverlight/System/Collections/ArrayList.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Silverlight/System/Collections/ArrayList.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Silverlight/System/Collections/ArrayList.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Silverlight/System/Collections/ArrayList.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,20 @@ +/* Copyright (C) 2009 Versant Inc. http://www.db4o.com */ +#if SILVERLIGHT + +using System.Collections.Generic; + +namespace System.Collections +{ + public class ArrayList : List + { + public ArrayList(int capacity) : base(capacity) + { + } + + public ArrayList() + { + } + } +} + +#endif \ No newline at end of file diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Silverlight/System/Collections/Hashtable.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Silverlight/System/Collections/Hashtable.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Silverlight/System/Collections/Hashtable.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Silverlight/System/Collections/Hashtable.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,25 @@ +/* Copyright (C) 2009 Versant Inc. http://www.db4o.com */ +#if SILVERLIGHT + +using System.Collections.Generic; + +namespace System.Collections +{ + public class Hashtable : Dictionary + { + public Hashtable() + { + } + + public Hashtable(int capacity) : base(capacity) + { + } + + public bool Contains(object key) + { + return ContainsKey(key); + } + } +} + +#endif \ No newline at end of file diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Silverlight/System/NonSerialized.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Silverlight/System/NonSerialized.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Silverlight/System/NonSerialized.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Silverlight/System/NonSerialized.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,12 @@ +/* Copyright (C) 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o; + +#if SILVERLIGHT +namespace System +{ + public class NonSerialized : TransientAttribute + { + } +} +#endif \ No newline at end of file diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Silverlight/System/Serializable.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Silverlight/System/Serializable.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/native/Silverlight/System/Serializable.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/native/Silverlight/System/Serializable.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,10 @@ +/* Copyright (C) 2009 Versant Inc. http://www.db4o.com */ + +#if SILVERLIGHT +namespace System +{ + public class Serializable : Attribute + { + } +} +#endif \ No newline at end of file diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Properties/AssemblyInfo.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Properties/AssemblyInfo.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o/Properties/AssemblyInfo.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o/Properties/AssemblyInfo.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,29 @@ +/* Copyright (C) 2009 Versant Inc. http://www.db4o.com */ +using System; +using System.Reflection; +using System.Security; + +[assembly: AssemblyTitle("db4o - database for objects")] +[assembly: AssemblyCompany("Versant Corp., Redwood City, CA, USA")] +[assembly: AssemblyProduct("db4o - database for objects")] +[assembly: AssemblyCopyright("Versant Corp. 2000 - 2011")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] +[assembly: AssemblyDelaySign(false)] +[assembly: AssemblyKeyName("")] + +// attributes are automatically set by the build +[assembly: AssemblyVersion("8.0.183.14430")] +[assembly: AssemblyKeyFile("")] +[assembly: AssemblyConfiguration(".NET")] +[assembly: AssemblyDescription("Db4objects.Db4o 8.0.183.14430 (.NET)")] + +#if !CF && !SILVERLIGHT +[assembly: AllowPartiallyTrustedCallers] +#endif + +#if NET_4_0 +[assembly: SecurityRules(SecurityRuleSet.Level1)] +#endif + +[assembly: CLSCompliant(true)] \ No newline at end of file diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o.Instrumentation/Db4objects.Db4o.Instrumentation/Api/CallingConvention.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o.Instrumentation/Db4objects.Db4o.Instrumentation/Api/CallingConvention.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o.Instrumentation/Db4objects.Db4o.Instrumentation/Api/CallingConvention.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o.Instrumentation/Db4objects.Db4o.Instrumentation/Api/CallingConvention.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,20 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +namespace Db4objects.Db4o.Instrumentation.Api +{ + public sealed class CallingConvention + { + public static readonly Db4objects.Db4o.Instrumentation.Api.CallingConvention Static + = new Db4objects.Db4o.Instrumentation.Api.CallingConvention(); + + public static readonly Db4objects.Db4o.Instrumentation.Api.CallingConvention Virtual + = new Db4objects.Db4o.Instrumentation.Api.CallingConvention(); + + public static readonly Db4objects.Db4o.Instrumentation.Api.CallingConvention Interface + = new Db4objects.Db4o.Instrumentation.Api.CallingConvention(); + + private CallingConvention() + { + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o.Instrumentation/Db4objects.Db4o.Instrumentation/Api/IFieldRef.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o.Instrumentation/Db4objects.Db4o.Instrumentation/Api/IFieldRef.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o.Instrumentation/Db4objects.Db4o.Instrumentation/Api/IFieldRef.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o.Instrumentation/Db4objects.Db4o.Instrumentation/Api/IFieldRef.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,21 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Instrumentation.Api; + +namespace Db4objects.Db4o.Instrumentation.Api +{ + /// A reference to a field.. + /// A reference to a field.. + public interface IFieldRef + { + ITypeRef Type + { + get; + } + + string Name + { + get; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o.Instrumentation/Db4objects.Db4o.Instrumentation/Api/IMethodBuilder.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o.Instrumentation/Db4objects.Db4o.Instrumentation/Api/IMethodBuilder.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o.Instrumentation/Db4objects.Db4o.Instrumentation/Api/IMethodBuilder.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o.Instrumentation/Db4objects.Db4o.Instrumentation/Api/IMethodBuilder.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,48 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System.IO; +using System.Reflection; +using Db4objects.Db4o.Instrumentation.Api; + +namespace Db4objects.Db4o.Instrumentation.Api +{ + /// Cross platform interface for bytecode emission. + /// Cross platform interface for bytecode emission. + public interface IMethodBuilder + { + IReferenceProvider References + { + get; + } + + void Ldc(object value); + + void LoadArgument(int index); + + void Pop(); + + void LoadArrayElement(ITypeRef elementType); + + void Add(ITypeRef operandType); + + void Subtract(ITypeRef operandType); + + void Multiply(ITypeRef operandType); + + void Divide(ITypeRef operandType); + + void Invoke(IMethodRef method, CallingConvention convention); + + void Invoke(MethodInfo method); + + void LoadField(IFieldRef fieldRef); + + void LoadStaticField(IFieldRef fieldRef); + + void Box(ITypeRef boxedType); + + void EndMethod(); + + void Print(TextWriter @out); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o.Instrumentation/Db4objects.Db4o.Instrumentation/Api/IMethodRef.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o.Instrumentation/Db4objects.Db4o.Instrumentation/Api/IMethodRef.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o.Instrumentation/Db4objects.Db4o.Instrumentation/Api/IMethodRef.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o.Instrumentation/Db4objects.Db4o.Instrumentation/Api/IMethodRef.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,29 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Instrumentation.Api; + +namespace Db4objects.Db4o.Instrumentation.Api +{ + public interface IMethodRef + { + string Name + { + get; + } + + ITypeRef ReturnType + { + get; + } + + ITypeRef[] ParamTypes + { + get; + } + + ITypeRef DeclaringType + { + get; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o.Instrumentation/Db4objects.Db4o.Instrumentation/Api/INativeClassFactory.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o.Instrumentation/Db4objects.Db4o.Instrumentation/Api/INativeClassFactory.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o.Instrumentation/Db4objects.Db4o.Instrumentation/Api/INativeClassFactory.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o.Instrumentation/Db4objects.Db4o.Instrumentation/Api/INativeClassFactory.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,13 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; + +namespace Db4objects.Db4o.Instrumentation.Api +{ + /// + public interface INativeClassFactory + { + /// + Type ForName(string className); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o.Instrumentation/Db4objects.Db4o.Instrumentation/Api/InstrumentationException.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o.Instrumentation/Db4objects.Db4o.Instrumentation/Api/InstrumentationException.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o.Instrumentation/Db4objects.Db4o.Instrumentation/Api/InstrumentationException.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o.Instrumentation/Db4objects.Db4o.Instrumentation/Api/InstrumentationException.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,14 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; + +namespace Db4objects.Db4o.Instrumentation.Api +{ + [System.Serializable] + public class InstrumentationException : Exception + { + public InstrumentationException(Exception cause) : base(cause.Message, cause) + { + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o.Instrumentation/Db4objects.Db4o.Instrumentation/Api/IReferenceProvider.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o.Instrumentation/Db4objects.Db4o.Instrumentation/Api/IReferenceProvider.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o.Instrumentation/Db4objects.Db4o.Instrumentation/Api/IReferenceProvider.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o.Instrumentation/Db4objects.Db4o.Instrumentation/Api/IReferenceProvider.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,18 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using System.Reflection; +using Db4objects.Db4o.Instrumentation.Api; + +namespace Db4objects.Db4o.Instrumentation.Api +{ + public interface IReferenceProvider + { + ITypeRef ForType(Type type); + + IMethodRef ForMethod(MethodInfo method); + + IMethodRef ForMethod(ITypeRef declaringType, string methodName, ITypeRef[] parameterTypes + , ITypeRef returnType); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o.Instrumentation/Db4objects.Db4o.Instrumentation/Api/IReferenceResolver.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o.Instrumentation/Db4objects.Db4o.Instrumentation/Api/IReferenceResolver.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o.Instrumentation/Db4objects.Db4o.Instrumentation/Api/IReferenceResolver.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o.Instrumentation/Db4objects.Db4o.Instrumentation/Api/IReferenceResolver.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,13 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System.Reflection; +using Db4objects.Db4o.Instrumentation.Api; + +namespace Db4objects.Db4o.Instrumentation.Api +{ + public interface IReferenceResolver + { + /// + MethodInfo Resolve(IMethodRef methodRef); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o.Instrumentation/Db4objects.Db4o.Instrumentation/Api/ITypeEditor.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o.Instrumentation/Db4objects.Db4o.Instrumentation/Api/ITypeEditor.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o.Instrumentation/Db4objects.Db4o.Instrumentation/Api/ITypeEditor.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o.Instrumentation/Db4objects.Db4o.Instrumentation/Api/ITypeEditor.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,26 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Instrumentation.Api; + +namespace Db4objects.Db4o.Instrumentation.Api +{ + /// Cross platform interface for type instrumentation. + /// Cross platform interface for type instrumentation. + public interface ITypeEditor + { + ITypeRef Type + { + get; + } + + IReferenceProvider References + { + get; + } + + void AddInterface(ITypeRef type); + + IMethodBuilder NewPublicMethod(string methodName, ITypeRef returnType, ITypeRef[] + parameterTypes); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o.Instrumentation/Db4objects.Db4o.Instrumentation/Api/ITypeRef.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o.Instrumentation/Db4objects.Db4o.Instrumentation/Api/ITypeRef.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o.Instrumentation/Db4objects.Db4o.Instrumentation/Api/ITypeRef.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o.Instrumentation/Db4objects.Db4o.Instrumentation/Api/ITypeRef.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,24 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Instrumentation.Api; + +namespace Db4objects.Db4o.Instrumentation.Api +{ + public interface ITypeRef + { + bool IsPrimitive + { + get; + } + + ITypeRef ElementType + { + get; + } + + string Name + { + get; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o.Instrumentation/Db4objects.Db4o.Instrumentation/Core/DefaultNativeClassFactory.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o.Instrumentation/Db4objects.Db4o.Instrumentation/Core/DefaultNativeClassFactory.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o.Instrumentation/Db4objects.Db4o.Instrumentation/Core/DefaultNativeClassFactory.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o.Instrumentation/Db4objects.Db4o.Instrumentation/Core/DefaultNativeClassFactory.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,17 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using Db4objects.Db4o.Instrumentation.Api; + +namespace Db4objects.Db4o.Instrumentation.Core +{ + /// + public class DefaultNativeClassFactory : INativeClassFactory + { + /// + public virtual Type ForName(string className) + { + return Sharpen.Runtime.GetType(className); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o.Instrumentation/Db4objects.Db4o.Instrumentation-2008.csproj smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o.Instrumentation/Db4objects.Db4o.Instrumentation-2008.csproj --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o.Instrumentation/Db4objects.Db4o.Instrumentation-2008.csproj 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o.Instrumentation/Db4objects.Db4o.Instrumentation-2008.csproj 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,117 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {FFA59708-14D1-4C22-B9A4-1A389EE796D5} + Library + Properties + Db4objects.Db4o.Instrumentation + Db4objects.Db4o.Instrumentation + + + 2.0 + + + v3.5 + + + + + + + + + + + + + + + + + + + + + + +true +../db4objects.snk + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + bin\Debug\Db4objects.Db4o.Instrumentation.xml + 1591;1572;1573;1574;0419; + + + pdbonly + true + bin\Release\ + TRACE;NET_3_5 + prompt + 4 + bin\Release\Db4objects.Db4o.Instrumentation.xml + 1591;1572;1573;1574;0419; + + + + False + ..\Libs\net-2.0\Cecil.FlowAnalysis.dll + + + False + ..\Libs\net-2.0\Mono.Cecil.dll + + + + 3.5 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {600CD3BF-2ED2-4183-87F7-ADD78A968AE0} + Db4objects.Db4o-2008 + + + + + diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o.Instrumentation/native/Db4objects.Db4o.Instrumentation/Cecil/CecilFieldRef.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o.Instrumentation/native/Db4objects.Db4o.Instrumentation/Cecil/CecilFieldRef.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o.Instrumentation/native/Db4objects.Db4o.Instrumentation/Cecil/CecilFieldRef.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o.Instrumentation/native/Db4objects.Db4o.Instrumentation/Cecil/CecilFieldRef.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,28 @@ +using System; +using Db4objects.Db4o.Instrumentation.Api; +using Mono.Cecil; + +namespace Db4objects.Db4o.Instrumentation.Cecil +{ + public class CecilFieldRef : CecilRef, IFieldRef + { + public CecilFieldRef(CecilReferenceProvider provider, FieldReference field) : base(provider, field) + { + } + + public FieldReference Field + { + get { return _reference; } + } + + public TypeReference FieldType + { + get { return _reference.FieldType; } + } + + public ITypeRef Type + { + get { return TypeRef(FieldType); } + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o.Instrumentation/native/Db4objects.Db4o.Instrumentation/Cecil/CecilMethodBuilder.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o.Instrumentation/native/Db4objects.Db4o.Instrumentation/Cecil/CecilMethodBuilder.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o.Instrumentation/native/Db4objects.Db4o.Instrumentation/Cecil/CecilMethodBuilder.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o.Instrumentation/native/Db4objects.Db4o.Instrumentation/Cecil/CecilMethodBuilder.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,147 @@ +using System; +using System.IO; +using System.Reflection; +using Cecil.FlowAnalysis.Utilities; +using Db4objects.Db4o.Instrumentation.Api; +using Mono.Cecil; +using Mono.Cecil.Cil; + +namespace Db4objects.Db4o.Instrumentation.Cecil +{ + internal class CecilMethodBuilder : IMethodBuilder + { + private readonly MethodDefinition _method; + private readonly ILProcessor _il; + + public CecilMethodBuilder(MethodDefinition method) + { + _method = method; + _il = method.Body.GetILProcessor(); + } + + public IReferenceProvider References + { + get { return CecilReferenceProvider.ForModule(_method.DeclaringType.Module.Assembly.MainModule); } + } + + public void Ldc(object value) + { + Type type = value.GetType(); + TypeCode code = Type.GetTypeCode(type); + switch (code) + { + case TypeCode.SByte: + _il.Emit(OpCodes.Ldc_I4_S, (SByte)value); + break; + case TypeCode.Int32: + _il.Emit(OpCodes.Ldc_I4, (Int32)value); + break; + case TypeCode.Int64: + _il.Emit(OpCodes.Ldc_I8, (Int64)value); + break; + case TypeCode.String: + _il.Emit(OpCodes.Ldstr, (String)value); + break; + default: + throw new NotImplementedException(code.ToString()); + } + } + + public void LoadArgument(int index) + { + switch (index) + { + case 0: + _il.Emit(OpCodes.Ldarg_0); + break; + case 1: + _il.Emit(OpCodes.Ldarg_1); + break; + default: + // TODO: This is wrong. Emit expects an VariableDefinition for a Ldarg . + // But actually no code passes idexes other than 0 and 1 + _il.Emit(OpCodes.Ldarg, index); + break; + } + } + + public void Pop() + { + _il.Emit(OpCodes.Pop); + } + + public void LoadArrayElement(ITypeRef elementType) + { + throw new NotImplementedException(); + } + + public void Add(ITypeRef operandType) + { + throw new NotImplementedException(); + } + + public void Subtract(ITypeRef operandType) + { + throw new NotImplementedException(); + } + + public void Multiply(ITypeRef operandType) + { + throw new NotImplementedException(); + } + + public void Divide(ITypeRef operandType) + { + throw new NotImplementedException(); + } + + public void Invoke(IMethodRef method, CallingConvention convention) + { + _il.Emit(OpCodeForConvention(convention), CecilMethodRef.GetReference(method)); + } + + private static OpCode OpCodeForConvention(CallingConvention convention) + { + return convention == CallingConvention.Static + ? OpCodes.Call + : OpCodes.Callvirt; + } + + public void Invoke(MethodInfo method) + { + throw new NotImplementedException(); + } + + public void LoadField(IFieldRef fieldRef) + { + _il.Emit(OpCodes.Ldfld, GetReference(fieldRef)); + } + + private static FieldReference GetReference(IFieldRef fieldRef) + { + return CecilFieldRef.GetReference(fieldRef); + } + + public void LoadStaticField(IFieldRef fieldRef) + { + _il.Emit(OpCodes.Ldsfld, GetReference(fieldRef)); + } + + public void Box(ITypeRef boxedType) + { + TypeReference type = CecilTypeRef.GetReference(boxedType); + if (!type.IsValueType) return; + _il.Emit(OpCodes.Box, type); + } + + public void EndMethod() + { + _il.Emit(OpCodes.Ret); + } + + public void Print(TextWriter @out) + { + Formatter.WriteMethodBody(@out, _method); + } + } +} \ No newline at end of file diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o.Instrumentation/native/Db4objects.Db4o.Instrumentation/Cecil/CecilMethodRef.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o.Instrumentation/native/Db4objects.Db4o.Instrumentation/Cecil/CecilMethodRef.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o.Instrumentation/native/Db4objects.Db4o.Instrumentation/Cecil/CecilMethodRef.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o.Instrumentation/native/Db4objects.Db4o.Instrumentation/Cecil/CecilMethodRef.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,28 @@ +using System; +using Db4objects.Db4o.Instrumentation.Api; +using Mono.Cecil; + +namespace Db4objects.Db4o.Instrumentation.Cecil +{ + internal class CecilMethodRef : CecilRef, IMethodRef + { + public CecilMethodRef(CecilReferenceProvider provider, MethodReference method) : base(provider, method) + { + } + + public ITypeRef ReturnType + { + get { return TypeRef(_reference.ReturnType); } + } + + public ITypeRef[] ParamTypes + { + get { throw new NotImplementedException(); } + } + + public ITypeRef DeclaringType + { + get { throw new NotImplementedException(); } + } + } +} \ No newline at end of file diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o.Instrumentation/native/Db4objects.Db4o.Instrumentation/Cecil/CecilRef.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o.Instrumentation/native/Db4objects.Db4o.Instrumentation/Cecil/CecilRef.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o.Instrumentation/native/Db4objects.Db4o.Instrumentation/Cecil/CecilRef.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o.Instrumentation/native/Db4objects.Db4o.Instrumentation/Cecil/CecilRef.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,43 @@ +using Db4objects.Db4o.Instrumentation.Api; +using Mono.Cecil; + +namespace Db4objects.Db4o.Instrumentation.Cecil +{ + public class CecilRef where T : MemberReference + { + public static T GetReference(object type) + { + return ((CecilRef)type).Reference; + } + + private readonly CecilReferenceProvider _provider; + protected T _reference; + + public CecilRef(CecilReferenceProvider provider, T reference) + { + _provider = provider; + _reference = reference; + } + + protected ITypeRef TypeRef(TypeReference type) + { + return _provider.ForCecilType(type); + } + + public T Reference + { + get { return _reference; } + set { _reference = value; } + } + + public virtual string Name + { + get { return _reference.Name; } + } + + public override string ToString() + { + return Name; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o.Instrumentation/native/Db4objects.Db4o.Instrumentation/Cecil/CecilReferenceProvider.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o.Instrumentation/native/Db4objects.Db4o.Instrumentation/Cecil/CecilReferenceProvider.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o.Instrumentation/native/Db4objects.Db4o.Instrumentation/Cecil/CecilReferenceProvider.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o.Instrumentation/native/Db4objects.Db4o.Instrumentation/Cecil/CecilReferenceProvider.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,72 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Reflection; +using Db4objects.Db4o.Instrumentation.Api; +using Mono.Cecil; + +namespace Db4objects.Db4o.Instrumentation.Cecil +{ + public class CecilReferenceProvider : IReferenceProvider + { + public static CecilReferenceProvider ForModule(ModuleDefinition module) + { + return new CecilReferenceProvider(module); + } + + private readonly ModuleDefinition _module; + private readonly Dictionary _typeCache = new Dictionary(); + + private CecilReferenceProvider(ModuleDefinition module) + { + if (null == module) throw new ArgumentNullException(); + _module = module; + } + + public ITypeRef ForType(Type type) + { +#if CF + return ForCecilType(ImportType(type)); +#else + return ForCecilType(_module.Import(type)); +#endif + } + + public ITypeRef ForCecilType(TypeReference type) + { + ITypeRef typeRef; + if (!_typeCache.TryGetValue(type, out typeRef)) + { + typeRef = new CecilTypeRef(this, type); + _typeCache.Add(type, typeRef); + } + return typeRef; + } + + public IMethodRef ForMethod(MethodInfo method) + { +#if CF + return new CecilMethodRef(this, _module.Import(new MethodReference(method.Name, ImportType(method.ReturnType)))); +#else + return new CecilMethodRef(this, _module.Import(method)); +#endif + } + +#if CF + private TypeReference ImportType(Type type) + { + return _module.Import(new TypeReference(type.Namespace, type.Name, _module)); + } +#endif + + public IMethodRef ForMethod(ITypeRef declaringType, string methodName, ITypeRef[] parameterTypes, ITypeRef returnType) + { + throw new NotImplementedException(); + } + + public IFieldRef ForCecilField(FieldReference field) + { + return new CecilFieldRef(this, field); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o.Instrumentation/native/Db4objects.Db4o.Instrumentation/Cecil/CecilReferenceResolver.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o.Instrumentation/native/Db4objects.Db4o.Instrumentation/Cecil/CecilReferenceResolver.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o.Instrumentation/native/Db4objects.Db4o.Instrumentation/Cecil/CecilReferenceResolver.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o.Instrumentation/native/Db4objects.Db4o.Instrumentation/Cecil/CecilReferenceResolver.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,14 @@ +using System; +using System.Reflection; +using Db4objects.Db4o.Instrumentation.Api; + +namespace Db4objects.Db4o.Instrumentation.Cecil +{ + public class CecilReferenceResolver : IReferenceResolver + { + public MethodInfo Resolve(IMethodRef methodRef) + { + throw new NotImplementedException(); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o.Instrumentation/native/Db4objects.Db4o.Instrumentation/Cecil/CecilTypeEditor.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o.Instrumentation/native/Db4objects.Db4o.Instrumentation/Cecil/CecilTypeEditor.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o.Instrumentation/native/Db4objects.Db4o.Instrumentation/Cecil/CecilTypeEditor.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o.Instrumentation/native/Db4objects.Db4o.Instrumentation/Cecil/CecilTypeEditor.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,60 @@ +using System; +using System.IO; +using System.Reflection; +using Db4objects.Db4o.Instrumentation.Api; +using Mono.Cecil; +using MethodAttributes=Mono.Cecil.MethodAttributes; + +namespace Db4objects.Db4o.Instrumentation.Cecil +{ + public class CecilTypeEditor : ITypeEditor + { + private readonly TypeDefinition _type; + private readonly CecilReferenceProvider _references; + + public CecilTypeEditor(TypeDefinition type) + { + _type = type; + _references = CecilReferenceProvider.ForModule(type.Module.Assembly.MainModule); + } + + public ITypeRef Type + { + get { return _references.ForCecilType(_type); } + } + + public IReferenceProvider References + { + get { return _references; } + } + + public void AddInterface(ITypeRef type) + { + _type.Interfaces.Add(GetTypeReference(type)); + } + + public IMethodBuilder NewPublicMethod(string methodName, ITypeRef returnType, ITypeRef[] parameterTypes) + { + MethodDefinition method = NewMethod(methodName, parameterTypes, returnType); + _type.Methods.Add(method); + return new CecilMethodBuilder(method); + } + + private static MethodDefinition NewMethod(string methodName, ITypeRef[] parameterTypes, ITypeRef returnType) + { + MethodDefinition method = new MethodDefinition(methodName, + MethodAttributes.Virtual | MethodAttributes.Public, + GetTypeReference(returnType)); + foreach (ITypeRef paramType in parameterTypes) + { + method.Parameters.Add(new ParameterDefinition(GetTypeReference(paramType))); + } + return method; + } + + private static TypeReference GetTypeReference(ITypeRef type) + { + return CecilTypeRef.GetReference(type); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o.Instrumentation/native/Db4objects.Db4o.Instrumentation/Cecil/CecilTypeRef.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o.Instrumentation/native/Db4objects.Db4o.Instrumentation/Cecil/CecilTypeRef.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o.Instrumentation/native/Db4objects.Db4o.Instrumentation/Cecil/CecilTypeRef.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o.Instrumentation/native/Db4objects.Db4o.Instrumentation/Cecil/CecilTypeRef.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,42 @@ +using System; +using Db4objects.Db4o.Instrumentation.Api; +using Mono.Cecil; + +namespace Db4objects.Db4o.Instrumentation.Cecil +{ + public class CecilTypeRef : CecilRef, ITypeRef + { + public CecilTypeRef(CecilReferenceProvider provider, TypeReference type) : base(provider, type) + { + } + + public bool IsPrimitive + { + get + { + switch (_reference.FullName) + { + case "System.Int32": + case "System.Boolean": + return true; + } + return false; + } + } + + public ITypeRef ElementType + { + get { throw new NotImplementedException(); } + } + + public override string Name + { + get { return NormalizeNestedTypeNotation(_reference.FullName); } + } + + private static string NormalizeNestedTypeNotation(string fullName) + { + return fullName.Replace('/', '+'); + } + } +} \ No newline at end of file diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o.Instrumentation/Properties/AssemblyInfo.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o.Instrumentation/Properties/AssemblyInfo.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o.Instrumentation/Properties/AssemblyInfo.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o.Instrumentation/Properties/AssemblyInfo.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,24 @@ +/* Copyright (C) 2009 Versant Inc. http://www.db4o.com */ + +using System; +using System.Reflection; +using System.Security; + +[assembly: AssemblyTitle("db4o - instrumentation layer")] +[assembly: AssemblyCompany("Versant Corp., Redwood City, CA, USA")] +[assembly: AssemblyProduct("db4o - database for objects")] +[assembly: AssemblyCopyright("Versant Corp. 2000 - 2011")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// attributes are automatically set by the build +[assembly: AssemblyVersion("8.0.183.14430")] +[assembly: AssemblyKeyFile("")] +[assembly: AssemblyConfiguration(".NET")] +[assembly: AssemblyDescription("Db4objects.Db4o.Instrumentation 8.0.183.14430 (.NET)")] + +#if !CF +[assembly: AllowPartiallyTrustedCallers] +#endif + +[assembly: CLSCompliant(true)] \ No newline at end of file diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Expr/AndExpression.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Expr/AndExpression.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Expr/AndExpression.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Expr/AndExpression.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,23 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.NativeQueries.Expr; + +namespace Db4objects.Db4o.NativeQueries.Expr +{ + public class AndExpression : BinaryExpression + { + public AndExpression(IExpression left, IExpression right) : base(left, right) + { + } + + public override string ToString() + { + return "(" + _left + ")&&(" + _right + ")"; + } + + public override void Accept(IExpressionVisitor visitor) + { + visitor.Visit(this); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Expr/BinaryExpression.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Expr/BinaryExpression.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Expr/BinaryExpression.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Expr/BinaryExpression.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,52 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.NativeQueries.Expr; + +namespace Db4objects.Db4o.NativeQueries.Expr +{ + public abstract class BinaryExpression : IExpression + { + protected IExpression _left; + + protected IExpression _right; + + public BinaryExpression(IExpression left, IExpression right) + { + this._left = left; + this._right = right; + } + + public virtual IExpression Left() + { + return _left; + } + + public virtual IExpression Right() + { + return _right; + } + + public override bool Equals(object other) + { + if (this == other) + { + return true; + } + if (other == null || GetType() != other.GetType()) + { + return false; + } + Db4objects.Db4o.NativeQueries.Expr.BinaryExpression casted = (Db4objects.Db4o.NativeQueries.Expr.BinaryExpression + )other; + return _left.Equals(casted._left) && (_right.Equals(casted._right)) || _left.Equals + (casted._right) && (_right.Equals(casted._left)); + } + + public override int GetHashCode() + { + return _left.GetHashCode() + _right.GetHashCode(); + } + + public abstract void Accept(IExpressionVisitor arg1); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Expr/BoolConstExpression.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Expr/BoolConstExpression.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Expr/BoolConstExpression.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Expr/BoolConstExpression.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,48 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.NativeQueries.Expr; + +namespace Db4objects.Db4o.NativeQueries.Expr +{ + public class BoolConstExpression : IExpression + { + public static readonly Db4objects.Db4o.NativeQueries.Expr.BoolConstExpression True + = new Db4objects.Db4o.NativeQueries.Expr.BoolConstExpression(true); + + public static readonly Db4objects.Db4o.NativeQueries.Expr.BoolConstExpression False + = new Db4objects.Db4o.NativeQueries.Expr.BoolConstExpression(false); + + private bool _value; + + private BoolConstExpression(bool value) + { + this._value = value; + } + + public virtual bool Value() + { + return _value; + } + + public override string ToString() + { + return _value.ToString(); + } + + public static Db4objects.Db4o.NativeQueries.Expr.BoolConstExpression Expr(bool value + ) + { + return (value ? True : False); + } + + public virtual void Accept(IExpressionVisitor visitor) + { + visitor.Visit(this); + } + + public virtual IExpression Negate() + { + return (_value ? False : True); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Expr/Build/ExpressionBuilder.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Expr/Build/ExpressionBuilder.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Expr/Build/ExpressionBuilder.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Expr/Build/ExpressionBuilder.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,198 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.NativeQueries.Expr; +using Db4objects.Db4o.NativeQueries.Expr.Cmp.Operand; + +namespace Db4objects.Db4o.NativeQueries.Expr.Build +{ + public class ExpressionBuilder + { + /// Optimizations: !(Bool)->(!Bool), !!X->X, !(X==Bool)->(X==!Bool) + /// + public virtual IExpression Not(IExpression expr) + { + if (expr.Equals(BoolConstExpression.True)) + { + return BoolConstExpression.False; + } + if (expr.Equals(BoolConstExpression.False)) + { + return BoolConstExpression.True; + } + if (expr is NotExpression) + { + return ((NotExpression)expr).Expr(); + } + if (expr is ComparisonExpression) + { + ComparisonExpression cmpExpr = (ComparisonExpression)expr; + if (cmpExpr.Right() is ConstValue) + { + ConstValue rightConst = (ConstValue)cmpExpr.Right(); + if (rightConst.Value() is bool) + { + bool boolVal = (bool)rightConst.Value(); + // new Boolean() instead of Boolean.valueOf() for .NET conversion + return new ComparisonExpression(cmpExpr.Left(), new ConstValue(!boolVal), cmpExpr + .Op()); + } + } + } + return new NotExpression(expr); + } + + /// Optimizations: f&&X->f, t&&X->X, X&&X->X, X&&!X->f + public virtual IExpression And(IExpression left, IExpression right) + { + if (left.Equals(BoolConstExpression.False) || right.Equals(BoolConstExpression.False + )) + { + return BoolConstExpression.False; + } + if (left.Equals(BoolConstExpression.True)) + { + return right; + } + if (right.Equals(BoolConstExpression.True)) + { + return left; + } + if (left.Equals(right)) + { + return left; + } + if (Negatives(left, right)) + { + return BoolConstExpression.False; + } + return new AndExpression(left, right); + } + + /// Optimizations: X||t->t, f||X->X, X||X->X, X||!X->t + public virtual IExpression Or(IExpression left, IExpression right) + { + if (left.Equals(BoolConstExpression.True) || right.Equals(BoolConstExpression.True + )) + { + return BoolConstExpression.True; + } + if (left.Equals(BoolConstExpression.False)) + { + return right; + } + if (right.Equals(BoolConstExpression.False)) + { + return left; + } + if (left.Equals(right)) + { + return left; + } + if (Negatives(left, right)) + { + return BoolConstExpression.True; + } + return new OrExpression(left, right); + } + + /// Optimizations: static bool roots + public virtual BoolConstExpression Constant(bool value) + { + return BoolConstExpression.Expr(value); + } + + public virtual IExpression IfThenElse(IExpression cond, IExpression truePath, IExpression + falsePath) + { + IExpression expr = CheckBoolean(cond, truePath, falsePath); + if (expr != null) + { + return expr; + } + return Or(And(cond, truePath), And(Not(cond), falsePath)); + } + + private IExpression CheckBoolean(IExpression cmp, IExpression trueExpr, IExpression + falseExpr) + { + if (cmp is BoolConstExpression) + { + return null; + } + if (trueExpr is BoolConstExpression) + { + bool leftNegative = trueExpr.Equals(BoolConstExpression.False); + if (!leftNegative) + { + return Or(cmp, falseExpr); + } + else + { + return And(Not(cmp), falseExpr); + } + } + if (falseExpr is BoolConstExpression) + { + bool rightNegative = falseExpr.Equals(BoolConstExpression.False); + if (!rightNegative) + { + return And(cmp, trueExpr); + } + else + { + return Or(Not(cmp), falseExpr); + } + } + if (cmp is NotExpression) + { + cmp = ((NotExpression)cmp).Expr(); + IExpression swap = trueExpr; + trueExpr = falseExpr; + falseExpr = swap; + } + if (trueExpr is OrExpression) + { + OrExpression orExpr = (OrExpression)trueExpr; + IExpression orLeft = orExpr.Left(); + IExpression orRight = orExpr.Right(); + if (falseExpr.Equals(orRight)) + { + IExpression swap = orRight; + orRight = orLeft; + orLeft = swap; + } + if (falseExpr.Equals(orLeft)) + { + return Or(orLeft, And(cmp, orRight)); + } + } + if (falseExpr is AndExpression) + { + AndExpression andExpr = (AndExpression)falseExpr; + IExpression andLeft = andExpr.Left(); + IExpression andRight = andExpr.Right(); + if (trueExpr.Equals(andRight)) + { + IExpression swap = andRight; + andRight = andLeft; + andLeft = swap; + } + if (trueExpr.Equals(andLeft)) + { + return And(andLeft, Or(cmp, andRight)); + } + } + return null; + } + + private bool Negatives(IExpression left, IExpression right) + { + return NegativeOf(left, right) || NegativeOf(right, left); + } + + private bool NegativeOf(IExpression right, IExpression left) + { + return (right is NotExpression) && ((NotExpression)right).Expr().Equals(left); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Expr/Cmp/ArithmeticOperator.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Expr/Cmp/ArithmeticOperator.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Expr/Cmp/ArithmeticOperator.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Expr/Cmp/ArithmeticOperator.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,50 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +namespace Db4objects.Db4o.NativeQueries.Expr.Cmp +{ + public sealed class ArithmeticOperator + { + public const int AddId = 0; + + public const int SubtractId = 1; + + public const int MultiplyId = 2; + + public const int DivideId = 3; + + public static readonly Db4objects.Db4o.NativeQueries.Expr.Cmp.ArithmeticOperator + Add = new Db4objects.Db4o.NativeQueries.Expr.Cmp.ArithmeticOperator(AddId, "+"); + + public static readonly Db4objects.Db4o.NativeQueries.Expr.Cmp.ArithmeticOperator + Subtract = new Db4objects.Db4o.NativeQueries.Expr.Cmp.ArithmeticOperator(SubtractId + , "-"); + + public static readonly Db4objects.Db4o.NativeQueries.Expr.Cmp.ArithmeticOperator + Multiply = new Db4objects.Db4o.NativeQueries.Expr.Cmp.ArithmeticOperator(MultiplyId + , "*"); + + public static readonly Db4objects.Db4o.NativeQueries.Expr.Cmp.ArithmeticOperator + Divide = new Db4objects.Db4o.NativeQueries.Expr.Cmp.ArithmeticOperator(DivideId, + "/"); + + private string _op; + + private int _id; + + private ArithmeticOperator(int id, string op) + { + _id = id; + _op = op; + } + + public int Id() + { + return _id; + } + + public override string ToString() + { + return _op; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Expr/Cmp/ComparisonOperator.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Expr/Cmp/ComparisonOperator.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Expr/Cmp/ComparisonOperator.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Expr/Cmp/ComparisonOperator.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,78 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +namespace Db4objects.Db4o.NativeQueries.Expr.Cmp +{ + public sealed class ComparisonOperator + { + public const int EqualsId = 0; + + public const int SmallerId = 1; + + public const int GreaterId = 2; + + public const int ContainsId = 3; + + public const int StartswithId = 4; + + public const int EndswithId = 5; + + public const int IdentityId = 6; + + public static readonly Db4objects.Db4o.NativeQueries.Expr.Cmp.ComparisonOperator + ValueEquality = new Db4objects.Db4o.NativeQueries.Expr.Cmp.ComparisonOperator(EqualsId + , "==", true); + + public static readonly Db4objects.Db4o.NativeQueries.Expr.Cmp.ComparisonOperator + Smaller = new Db4objects.Db4o.NativeQueries.Expr.Cmp.ComparisonOperator(SmallerId + , "<", false); + + public static readonly Db4objects.Db4o.NativeQueries.Expr.Cmp.ComparisonOperator + Greater = new Db4objects.Db4o.NativeQueries.Expr.Cmp.ComparisonOperator(GreaterId + , ">", false); + + public static readonly Db4objects.Db4o.NativeQueries.Expr.Cmp.ComparisonOperator + Contains = new Db4objects.Db4o.NativeQueries.Expr.Cmp.ComparisonOperator(ContainsId + , "", false); + + public static readonly Db4objects.Db4o.NativeQueries.Expr.Cmp.ComparisonOperator + StartsWith = new Db4objects.Db4o.NativeQueries.Expr.Cmp.ComparisonOperator(StartswithId + , "", false); + + public static readonly Db4objects.Db4o.NativeQueries.Expr.Cmp.ComparisonOperator + EndsWith = new Db4objects.Db4o.NativeQueries.Expr.Cmp.ComparisonOperator(EndswithId + , "", false); + + public static readonly Db4objects.Db4o.NativeQueries.Expr.Cmp.ComparisonOperator + ReferenceEquality = new Db4objects.Db4o.NativeQueries.Expr.Cmp.ComparisonOperator + (IdentityId, "===", true); + + private int _id; + + private string _op; + + private bool _symmetric; + + private ComparisonOperator(int id, string op, bool symmetric) + { + // TODO: switch to individual classes and visitor dispatch? + _id = id; + _op = op; + _symmetric = symmetric; + } + + public int Id() + { + return _id; + } + + public override string ToString() + { + return _op; + } + + public bool IsSymmetric() + { + return _symmetric; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Expr/Cmp/Operand/ArithmeticExpression.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Expr/Cmp/Operand/ArithmeticExpression.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Expr/Cmp/Operand/ArithmeticExpression.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Expr/Cmp/Operand/ArithmeticExpression.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,73 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.NativeQueries.Expr.Cmp; +using Db4objects.Db4o.NativeQueries.Expr.Cmp.Operand; + +namespace Db4objects.Db4o.NativeQueries.Expr.Cmp.Operand +{ + public class ArithmeticExpression : IComparisonOperand + { + private ArithmeticOperator _op; + + private IComparisonOperand _left; + + private IComparisonOperand _right; + + public ArithmeticExpression(IComparisonOperand left, IComparisonOperand right, ArithmeticOperator + op) + { + this._op = op; + this._left = left; + this._right = right; + } + + public virtual IComparisonOperand Left() + { + return _left; + } + + public virtual IComparisonOperand Right() + { + return _right; + } + + public virtual ArithmeticOperator Op() + { + return _op; + } + + public override string ToString() + { + return "(" + _left + _op + _right + ")"; + } + + public override bool Equals(object obj) + { + if (this == obj) + { + return true; + } + if (obj == null || obj.GetType() != GetType()) + { + return false; + } + Db4objects.Db4o.NativeQueries.Expr.Cmp.Operand.ArithmeticExpression casted = (Db4objects.Db4o.NativeQueries.Expr.Cmp.Operand.ArithmeticExpression + )obj; + return _left.Equals(casted._left) && _right.Equals(casted._right) && _op.Equals(casted + ._op); + } + + public override int GetHashCode() + { + int hc = _left.GetHashCode(); + hc *= 29 + _right.GetHashCode(); + hc *= 29 + _op.GetHashCode(); + return hc; + } + + public virtual void Accept(IComparisonOperandVisitor visitor) + { + visitor.Visit(this); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Expr/Cmp/Operand/ArrayAccessValue.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Expr/Cmp/Operand/ArrayAccessValue.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Expr/Cmp/Operand/ArrayAccessValue.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Expr/Cmp/Operand/ArrayAccessValue.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,57 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Instrumentation.Api; +using Db4objects.Db4o.NativeQueries.Expr.Cmp.Operand; + +namespace Db4objects.Db4o.NativeQueries.Expr.Cmp.Operand +{ + public class ArrayAccessValue : ComparisonOperandDescendant + { + private IComparisonOperand _index; + + public ArrayAccessValue(ComparisonOperandDescendant parent, IComparisonOperand index + ) : base(parent) + { + _index = index; + } + + public override void Accept(IComparisonOperandVisitor visitor) + { + visitor.Visit(this); + } + + public virtual IComparisonOperand Index() + { + return _index; + } + + public override bool Equals(object obj) + { + if (!base.Equals(obj)) + { + return false; + } + Db4objects.Db4o.NativeQueries.Expr.Cmp.Operand.ArrayAccessValue casted = (Db4objects.Db4o.NativeQueries.Expr.Cmp.Operand.ArrayAccessValue + )obj; + return _index.Equals(casted._index); + } + + public override int GetHashCode() + { + return base.GetHashCode() * 29 + _index.GetHashCode(); + } + + public override string ToString() + { + return base.ToString() + "[" + _index + "]"; + } + + public override ITypeRef Type + { + get + { + return ((ComparisonOperandDescendant)Parent()).Type.ElementType; + } + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Expr/Cmp/Operand/CandidateFieldRoot.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Expr/Cmp/Operand/CandidateFieldRoot.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Expr/Cmp/Operand/CandidateFieldRoot.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Expr/Cmp/Operand/CandidateFieldRoot.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,27 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.NativeQueries.Expr.Cmp.Operand; + +namespace Db4objects.Db4o.NativeQueries.Expr.Cmp.Operand +{ + public class CandidateFieldRoot : ComparisonOperandRoot + { + public static readonly Db4objects.Db4o.NativeQueries.Expr.Cmp.Operand.CandidateFieldRoot + Instance = new Db4objects.Db4o.NativeQueries.Expr.Cmp.Operand.CandidateFieldRoot + (); + + private CandidateFieldRoot() + { + } + + public override string ToString() + { + return "CANDIDATE"; + } + + public override void Accept(IComparisonOperandVisitor visitor) + { + visitor.Visit(this); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Expr/Cmp/Operand/ComparisonOperandDescendant.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Expr/Cmp/Operand/ComparisonOperandDescendant.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Expr/Cmp/Operand/ComparisonOperandDescendant.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Expr/Cmp/Operand/ComparisonOperandDescendant.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,59 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Instrumentation.Api; +using Db4objects.Db4o.NativeQueries.Expr.Cmp.Operand; + +namespace Db4objects.Db4o.NativeQueries.Expr.Cmp.Operand +{ + public abstract class ComparisonOperandDescendant : IComparisonOperandAnchor + { + private IComparisonOperandAnchor _parent; + + protected ComparisonOperandDescendant(IComparisonOperandAnchor _parent) + { + this._parent = _parent; + } + + public IComparisonOperandAnchor Parent() + { + return _parent; + } + + public IComparisonOperandAnchor Root() + { + return _parent.Root(); + } + + public abstract ITypeRef Type + { + get; + } + + public override bool Equals(object obj) + { + if (this == obj) + { + return true; + } + if (obj == null || GetType() != obj.GetType()) + { + return false; + } + Db4objects.Db4o.NativeQueries.Expr.Cmp.Operand.ComparisonOperandDescendant casted + = (Db4objects.Db4o.NativeQueries.Expr.Cmp.Operand.ComparisonOperandDescendant)obj; + return _parent.Equals(casted._parent); + } + + public override int GetHashCode() + { + return _parent.GetHashCode(); + } + + public override string ToString() + { + return _parent.ToString(); + } + + public abstract void Accept(IComparisonOperandVisitor arg1); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Expr/Cmp/Operand/ComparisonOperandRoot.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Expr/Cmp/Operand/ComparisonOperandRoot.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Expr/Cmp/Operand/ComparisonOperandRoot.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Expr/Cmp/Operand/ComparisonOperandRoot.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,21 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.NativeQueries.Expr.Cmp.Operand; + +namespace Db4objects.Db4o.NativeQueries.Expr.Cmp.Operand +{ + public abstract class ComparisonOperandRoot : IComparisonOperandAnchor + { + public virtual IComparisonOperandAnchor Parent() + { + return null; + } + + public IComparisonOperandAnchor Root() + { + return this; + } + + public abstract void Accept(IComparisonOperandVisitor arg1); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Expr/Cmp/Operand/ConstValue.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Expr/Cmp/Operand/ConstValue.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Expr/Cmp/Operand/ConstValue.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Expr/Cmp/Operand/ConstValue.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,72 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.NativeQueries.Expr.Cmp.Operand; + +namespace Db4objects.Db4o.NativeQueries.Expr.Cmp.Operand +{ + public class ConstValue : IComparisonOperand + { + private object _value; + + public ConstValue(object value) + { + this._value = value; + } + + public virtual object Value() + { + return _value; + } + + public virtual void Value(object value) + { + _value = value; + } + + public override string ToString() + { + if (_value == null) + { + return "null"; + } + if (_value is string) + { + return "\"" + _value + "\""; + } + return _value.ToString(); + } + + public override bool Equals(object other) + { + if (this == other) + { + return true; + } + if (other == null || GetType() != other.GetType()) + { + return false; + } + object otherValue = ((Db4objects.Db4o.NativeQueries.Expr.Cmp.Operand.ConstValue)other + )._value; + if (otherValue == _value) + { + return true; + } + if (otherValue == null || _value == null) + { + return false; + } + return _value.Equals(otherValue); + } + + public override int GetHashCode() + { + return _value.GetHashCode(); + } + + public virtual void Accept(IComparisonOperandVisitor visitor) + { + visitor.Visit(this); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Expr/Cmp/Operand/FieldValue.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Expr/Cmp/Operand/FieldValue.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Expr/Cmp/Operand/FieldValue.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Expr/Cmp/Operand/FieldValue.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,64 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Instrumentation.Api; +using Db4objects.Db4o.NativeQueries.Expr.Cmp.Operand; + +namespace Db4objects.Db4o.NativeQueries.Expr.Cmp.Operand +{ + public class FieldValue : ComparisonOperandDescendant + { + private readonly IFieldRef _field; + + public FieldValue(IComparisonOperandAnchor root, IFieldRef field) : base(root) + { + _field = field; + } + + public virtual string FieldName() + { + return _field.Name; + } + + public override bool Equals(object other) + { + if (!base.Equals(other)) + { + return false; + } + Db4objects.Db4o.NativeQueries.Expr.Cmp.Operand.FieldValue casted = (Db4objects.Db4o.NativeQueries.Expr.Cmp.Operand.FieldValue + )other; + return _field.Equals(casted._field); + } + + public override int GetHashCode() + { + return base.GetHashCode() * 29 + _field.GetHashCode(); + } + + public override string ToString() + { + return base.ToString() + "." + _field; + } + + public override void Accept(IComparisonOperandVisitor visitor) + { + visitor.Visit(this); + } + + public virtual IFieldRef Field + { + get + { + return _field; + } + } + + public override ITypeRef Type + { + get + { + return _field.Type; + } + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Expr/Cmp/Operand/IComparisonOperandAnchor.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Expr/Cmp/Operand/IComparisonOperandAnchor.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Expr/Cmp/Operand/IComparisonOperandAnchor.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Expr/Cmp/Operand/IComparisonOperandAnchor.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,13 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.NativeQueries.Expr.Cmp.Operand; + +namespace Db4objects.Db4o.NativeQueries.Expr.Cmp.Operand +{ + public interface IComparisonOperandAnchor : IComparisonOperand + { + IComparisonOperandAnchor Parent(); + + IComparisonOperandAnchor Root(); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Expr/Cmp/Operand/IComparisonOperand.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Expr/Cmp/Operand/IComparisonOperand.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Expr/Cmp/Operand/IComparisonOperand.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Expr/Cmp/Operand/IComparisonOperand.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,12 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.NativeQueries.Expr; +using Db4objects.Db4o.NativeQueries.Expr.Cmp.Operand; + +namespace Db4objects.Db4o.NativeQueries.Expr.Cmp.Operand +{ + public interface IComparisonOperand : IExpressionPart + { + void Accept(IComparisonOperandVisitor visitor); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Expr/Cmp/Operand/IComparisonOperandVisitor.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Expr/Cmp/Operand/IComparisonOperandVisitor.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Expr/Cmp/Operand/IComparisonOperandVisitor.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Expr/Cmp/Operand/IComparisonOperandVisitor.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,25 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.NativeQueries.Expr.Cmp.Operand; + +namespace Db4objects.Db4o.NativeQueries.Expr.Cmp.Operand +{ + public interface IComparisonOperandVisitor + { + void Visit(ArithmeticExpression operand); + + void Visit(ConstValue operand); + + void Visit(FieldValue operand); + + void Visit(CandidateFieldRoot root); + + void Visit(PredicateFieldRoot root); + + void Visit(StaticFieldRoot root); + + void Visit(ArrayAccessValue operand); + + void Visit(MethodCallValue value); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Expr/Cmp/Operand/MethodCallValue.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Expr/Cmp/Operand/MethodCallValue.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Expr/Cmp/Operand/MethodCallValue.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Expr/Cmp/Operand/MethodCallValue.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,89 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Instrumentation.Api; +using Db4objects.Db4o.NativeQueries.Expr.Cmp.Operand; + +namespace Db4objects.Db4o.NativeQueries.Expr.Cmp.Operand +{ + public class MethodCallValue : ComparisonOperandDescendant + { + private readonly IMethodRef _method; + + private readonly IComparisonOperand[] _args; + + private readonly Db4objects.Db4o.Instrumentation.Api.CallingConvention _callingConvention; + + public MethodCallValue(IMethodRef method, Db4objects.Db4o.Instrumentation.Api.CallingConvention + callingConvention, IComparisonOperandAnchor parent, IComparisonOperand[] args) : + base(parent) + { + _method = method; + _args = args; + _callingConvention = callingConvention; + } + + public override void Accept(IComparisonOperandVisitor visitor) + { + visitor.Visit(this); + } + + public virtual IComparisonOperand[] Args + { + get + { + return _args; + } + } + + public override bool Equals(object obj) + { + if (!base.Equals(obj)) + { + return false; + } + Db4objects.Db4o.NativeQueries.Expr.Cmp.Operand.MethodCallValue casted = (Db4objects.Db4o.NativeQueries.Expr.Cmp.Operand.MethodCallValue + )obj; + return _method.Equals(casted._method) && _callingConvention == casted._callingConvention; + } + + public override int GetHashCode() + { + int hc = base.GetHashCode(); + hc *= 29 + _method.GetHashCode(); + hc *= 29 + _args.GetHashCode(); + hc *= 29 + _callingConvention.GetHashCode(); + return hc; + } + + public override string ToString() + { + return base.ToString() + "." + _method.Name + Iterators.Join(Iterators.Iterate(_args + ), "(", ")", ", "); + } + + public virtual IMethodRef Method + { + get + { + return _method; + } + } + + public virtual Db4objects.Db4o.Instrumentation.Api.CallingConvention CallingConvention + { + get + { + return _callingConvention; + } + } + + public override ITypeRef Type + { + get + { + return _method.ReturnType; + } + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Expr/Cmp/Operand/PredicateFieldRoot.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Expr/Cmp/Operand/PredicateFieldRoot.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Expr/Cmp/Operand/PredicateFieldRoot.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Expr/Cmp/Operand/PredicateFieldRoot.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,27 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.NativeQueries.Expr.Cmp.Operand; + +namespace Db4objects.Db4o.NativeQueries.Expr.Cmp.Operand +{ + public class PredicateFieldRoot : ComparisonOperandRoot + { + public static readonly Db4objects.Db4o.NativeQueries.Expr.Cmp.Operand.PredicateFieldRoot + Instance = new Db4objects.Db4o.NativeQueries.Expr.Cmp.Operand.PredicateFieldRoot + (); + + private PredicateFieldRoot() + { + } + + public override string ToString() + { + return "PREDICATE"; + } + + public override void Accept(IComparisonOperandVisitor visitor) + { + visitor.Visit(this); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Expr/Cmp/Operand/StaticFieldRoot.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Expr/Cmp/Operand/StaticFieldRoot.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Expr/Cmp/Operand/StaticFieldRoot.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Expr/Cmp/Operand/StaticFieldRoot.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,60 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using Db4objects.Db4o.Instrumentation.Api; +using Db4objects.Db4o.NativeQueries.Expr.Cmp.Operand; + +namespace Db4objects.Db4o.NativeQueries.Expr.Cmp.Operand +{ + public class StaticFieldRoot : ComparisonOperandRoot + { + private ITypeRef _type; + + public StaticFieldRoot(ITypeRef type) + { + if (null == type) + { + throw new ArgumentNullException(); + } + _type = type; + } + + public virtual ITypeRef Type + { + get + { + return _type; + } + } + + public override bool Equals(object obj) + { + if (obj == this) + { + return true; + } + if (obj == null || GetType() != obj.GetType()) + { + return false; + } + Db4objects.Db4o.NativeQueries.Expr.Cmp.Operand.StaticFieldRoot casted = (Db4objects.Db4o.NativeQueries.Expr.Cmp.Operand.StaticFieldRoot + )obj; + return _type.Equals(casted._type); + } + + public override int GetHashCode() + { + return _type.GetHashCode(); + } + + public override string ToString() + { + return _type.ToString(); + } + + public override void Accept(IComparisonOperandVisitor visitor) + { + visitor.Visit(this); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Expr/Cmp/Operand/ThreeWayComparison.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Expr/Cmp/Operand/ThreeWayComparison.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Expr/Cmp/Operand/ThreeWayComparison.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Expr/Cmp/Operand/ThreeWayComparison.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,39 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.NativeQueries.Expr; +using Db4objects.Db4o.NativeQueries.Expr.Cmp.Operand; + +namespace Db4objects.Db4o.NativeQueries.Expr.Cmp.Operand +{ + public class ThreeWayComparison : IExpressionPart + { + private FieldValue _left; + + private IComparisonOperand _right; + + private bool _swapped; + + public ThreeWayComparison(FieldValue left, IComparisonOperand right, bool swapped + ) + { + this._left = left; + this._right = right; + _swapped = swapped; + } + + public virtual FieldValue Left() + { + return _left; + } + + public virtual IComparisonOperand Right() + { + return _right; + } + + public virtual bool Swapped() + { + return _swapped; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Expr/ComparisonExpression.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Expr/ComparisonExpression.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Expr/ComparisonExpression.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Expr/ComparisonExpression.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,76 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using Db4objects.Db4o.NativeQueries.Expr; +using Db4objects.Db4o.NativeQueries.Expr.Cmp; +using Db4objects.Db4o.NativeQueries.Expr.Cmp.Operand; + +namespace Db4objects.Db4o.NativeQueries.Expr +{ + public class ComparisonExpression : IExpression + { + private FieldValue _left; + + private IComparisonOperand _right; + + private ComparisonOperator _op; + + public ComparisonExpression(FieldValue left, IComparisonOperand right, ComparisonOperator + op) + { + if (left == null || right == null || op == null) + { + throw new ArgumentNullException(); + } + this._left = left; + this._right = right; + this._op = op; + } + + public virtual FieldValue Left() + { + return _left; + } + + public virtual IComparisonOperand Right() + { + return _right; + } + + public virtual ComparisonOperator Op() + { + return _op; + } + + public override string ToString() + { + return _left + " " + _op + " " + _right; + } + + public override bool Equals(object other) + { + if (this == other) + { + return true; + } + if (other == null || GetType() != other.GetType()) + { + return false; + } + Db4objects.Db4o.NativeQueries.Expr.ComparisonExpression casted = (Db4objects.Db4o.NativeQueries.Expr.ComparisonExpression + )other; + return _left.Equals(casted._left) && _right.Equals(casted._right) && _op.Equals(casted + ._op); + } + + public override int GetHashCode() + { + return (_left.GetHashCode() * 29 + _right.GetHashCode()) * 29 + _op.GetHashCode(); + } + + public virtual void Accept(IExpressionVisitor visitor) + { + visitor.Visit(this); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Expr/IExpression.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Expr/IExpression.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Expr/IExpression.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Expr/IExpression.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,15 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.NativeQueries.Expr; + +namespace Db4objects.Db4o.NativeQueries.Expr +{ + public interface IExpression : IExpressionPart + { + /// + /// must implement the visitor interface required + /// by the concrete Expression implementation. + /// + void Accept(IExpressionVisitor visitor); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Expr/IExpressionPart.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Expr/IExpressionPart.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Expr/IExpressionPart.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Expr/IExpressionPart.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,8 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +namespace Db4objects.Db4o.NativeQueries.Expr +{ + public interface IExpressionPart + { + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Expr/IExpressionVisitor.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Expr/IExpressionVisitor.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Expr/IExpressionVisitor.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Expr/IExpressionVisitor.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,19 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.NativeQueries.Expr; + +namespace Db4objects.Db4o.NativeQueries.Expr +{ + public interface IExpressionVisitor + { + void Visit(AndExpression expression); + + void Visit(OrExpression expression); + + void Visit(NotExpression expression); + + void Visit(ComparisonExpression expression); + + void Visit(BoolConstExpression expression); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Expr/IgnoredExpression.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Expr/IgnoredExpression.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Expr/IgnoredExpression.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Expr/IgnoredExpression.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,20 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.NativeQueries.Expr; + +namespace Db4objects.Db4o.NativeQueries.Expr +{ + public sealed class IgnoredExpression : IExpression + { + public static Db4objects.Db4o.NativeQueries.Expr.IgnoredExpression Instance = new + Db4objects.Db4o.NativeQueries.Expr.IgnoredExpression(); + + private IgnoredExpression() + { + } + + public void Accept(IExpressionVisitor visitor) + { + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Expr/NotExpression.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Expr/NotExpression.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Expr/NotExpression.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Expr/NotExpression.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,51 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.NativeQueries.Expr; + +namespace Db4objects.Db4o.NativeQueries.Expr +{ + public class NotExpression : IExpression + { + private IExpression _expr; + + public NotExpression(IExpression expr) + { + this._expr = expr; + } + + public override string ToString() + { + return "!(" + _expr + ")"; + } + + public virtual IExpression Expr() + { + return _expr; + } + + public override bool Equals(object other) + { + if (this == other) + { + return true; + } + if (other == null || GetType() != other.GetType()) + { + return false; + } + Db4objects.Db4o.NativeQueries.Expr.NotExpression casted = (Db4objects.Db4o.NativeQueries.Expr.NotExpression + )other; + return _expr.Equals(casted._expr); + } + + public override int GetHashCode() + { + return -_expr.GetHashCode(); + } + + public virtual void Accept(IExpressionVisitor visitor) + { + visitor.Visit(this); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Expr/OrExpression.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Expr/OrExpression.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Expr/OrExpression.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Expr/OrExpression.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,23 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.NativeQueries.Expr; + +namespace Db4objects.Db4o.NativeQueries.Expr +{ + public class OrExpression : BinaryExpression + { + public OrExpression(IExpression left, IExpression right) : base(left, right) + { + } + + public override string ToString() + { + return "(" + _left + ")||(" + _right + ")"; + } + + public override void Accept(IExpressionVisitor visitor) + { + visitor.Visit(this); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Expr/TraversingExpressionVisitor.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Expr/TraversingExpressionVisitor.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Expr/TraversingExpressionVisitor.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Expr/TraversingExpressionVisitor.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,85 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.NativeQueries.Expr; +using Db4objects.Db4o.NativeQueries.Expr.Cmp.Operand; + +namespace Db4objects.Db4o.NativeQueries.Expr +{ + public class TraversingExpressionVisitor : IExpressionVisitor, IComparisonOperandVisitor + { + public virtual void Visit(AndExpression expression) + { + expression.Left().Accept(this); + expression.Right().Accept(this); + } + + public virtual void Visit(BoolConstExpression expression) + { + } + + public virtual void Visit(OrExpression expression) + { + expression.Left().Accept(this); + expression.Right().Accept(this); + } + + public virtual void Visit(ComparisonExpression expression) + { + expression.Left().Accept(this); + expression.Right().Accept(this); + } + + public virtual void Visit(NotExpression expression) + { + expression.Expr().Accept(this); + } + + public virtual void Visit(ArithmeticExpression operand) + { + operand.Left().Accept(this); + operand.Right().Accept(this); + } + + public virtual void Visit(ConstValue operand) + { + } + + public virtual void Visit(FieldValue operand) + { + operand.Parent().Accept(this); + } + + public virtual void Visit(CandidateFieldRoot root) + { + } + + public virtual void Visit(PredicateFieldRoot root) + { + } + + public virtual void Visit(StaticFieldRoot root) + { + } + + public virtual void Visit(ArrayAccessValue operand) + { + operand.Parent().Accept(this); + operand.Index().Accept(this); + } + + public virtual void Visit(MethodCallValue value) + { + value.Parent().Accept(this); + VisitArgs(value); + } + + protected virtual void VisitArgs(MethodCallValue value) + { + IComparisonOperand[] args = value.Args; + for (int i = 0; i < args.Length; ++i) + { + args[i].Accept(this); + } + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Instrumentation/ComparisonBytecodeGeneratingVisitor.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Instrumentation/ComparisonBytecodeGeneratingVisitor.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Instrumentation/ComparisonBytecodeGeneratingVisitor.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Instrumentation/ComparisonBytecodeGeneratingVisitor.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,243 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using Db4objects.Db4o.Instrumentation.Api; +using Db4objects.Db4o.NativeQueries.Expr.Cmp; +using Db4objects.Db4o.NativeQueries.Expr.Cmp.Operand; +using Db4objects.Db4o.NativeQueries.Instrumentation; + +namespace Db4objects.Db4o.NativeQueries.Instrumentation +{ + internal class ComparisonBytecodeGeneratingVisitor : IComparisonOperandVisitor + { + private IMethodBuilder _methodBuilder; + + private ITypeRef _predicateClass; + + private bool _inArithmetic = false; + + private ITypeRef _opClass = null; + + private ITypeRef _staticRoot = null; + + public ComparisonBytecodeGeneratingVisitor(IMethodBuilder methodBuilder, ITypeRef + predicateClass) + { + this._methodBuilder = methodBuilder; + this._predicateClass = predicateClass; + } + + public virtual void Visit(ConstValue operand) + { + object value = operand.Value(); + if (value != null) + { + _opClass = TypeRef(value.GetType()); + } + _methodBuilder.Ldc(value); + if (value != null) + { + Box(_opClass, !_inArithmetic); + } + } + + private ITypeRef TypeRef(Type type) + { + return _methodBuilder.References.ForType(type); + } + + public virtual void Visit(FieldValue fieldValue) + { + ITypeRef lastFieldClass = fieldValue.Field.Type; + bool needConversion = lastFieldClass.IsPrimitive; + fieldValue.Parent().Accept(this); + if (_staticRoot != null) + { + _methodBuilder.LoadStaticField(fieldValue.Field); + _staticRoot = null; + return; + } + _methodBuilder.LoadField(fieldValue.Field); + Box(lastFieldClass, !_inArithmetic && needConversion); + } + + public virtual void Visit(CandidateFieldRoot root) + { + _methodBuilder.LoadArgument(1); + } + + public virtual void Visit(PredicateFieldRoot root) + { + _methodBuilder.LoadArgument(0); + } + + public virtual void Visit(StaticFieldRoot root) + { + _staticRoot = root.Type; + } + + public virtual void Visit(ArrayAccessValue operand) + { + ITypeRef cmpType = DeduceFieldClass(operand.Parent()).ElementType; + operand.Parent().Accept(this); + bool outerInArithmetic = _inArithmetic; + _inArithmetic = true; + operand.Index().Accept(this); + _inArithmetic = outerInArithmetic; + _methodBuilder.LoadArrayElement(cmpType); + Box(cmpType, !_inArithmetic); + } + + public virtual void Visit(MethodCallValue operand) + { + IMethodRef method = operand.Method; + ITypeRef retType = method.ReturnType; + // FIXME: this should be handled within conversions + bool needConversion = retType.IsPrimitive; + operand.Parent().Accept(this); + bool oldInArithmetic = _inArithmetic; + for (int paramIdx = 0; paramIdx < operand.Args.Length; paramIdx++) + { + _inArithmetic = operand.Method.ParamTypes[paramIdx].IsPrimitive; + operand.Args[paramIdx].Accept(this); + } + _inArithmetic = oldInArithmetic; + _methodBuilder.Invoke(method, operand.CallingConvention); + Box(retType, !_inArithmetic && needConversion); + } + + public virtual void Visit(ArithmeticExpression operand) + { + bool oldInArithmetic = _inArithmetic; + _inArithmetic = true; + operand.Left().Accept(this); + operand.Right().Accept(this); + ITypeRef operandType = ArithmeticType(operand); + switch (operand.Op().Id()) + { + case ArithmeticOperator.AddId: + { + _methodBuilder.Add(operandType); + break; + } + + case ArithmeticOperator.SubtractId: + { + _methodBuilder.Subtract(operandType); + break; + } + + case ArithmeticOperator.MultiplyId: + { + _methodBuilder.Multiply(operandType); + break; + } + + case ArithmeticOperator.DivideId: + { + _methodBuilder.Divide(operandType); + break; + } + + default: + { + throw new Exception("Unknown operand: " + operand.Op()); + } + } + Box(_opClass, !oldInArithmetic); + _inArithmetic = oldInArithmetic; + } + + // FIXME: need to map dX,fX,... + private void Box(ITypeRef boxedType, bool canApply) + { + if (!canApply) + { + return; + } + _methodBuilder.Box(boxedType); + } + + private ITypeRef DeduceFieldClass(IComparisonOperand fieldValue) + { + TypeDeducingVisitor visitor = new TypeDeducingVisitor(_methodBuilder.References, + _predicateClass); + fieldValue.Accept(visitor); + return visitor.OperandClass(); + } + + private ITypeRef ArithmeticType(IComparisonOperand operand) + { + if (operand is ConstValue) + { + return PrimitiveType(((ConstValue)operand).Value().GetType()); + } + if (operand is FieldValue) + { + return ((FieldValue)operand).Field.Type; + } + if (operand is ArithmeticExpression) + { + ArithmeticExpression expr = (ArithmeticExpression)operand; + ITypeRef left = ArithmeticType(expr.Left()); + ITypeRef right = ArithmeticType(expr.Right()); + if (left == DoubleType() || right == DoubleType()) + { + return DoubleType(); + } + if (left == FloatType() || right == FloatType()) + { + return FloatType(); + } + if (left == LongType() || right == LongType()) + { + return LongType(); + } + return IntType(); + } + return null; + } + + private ITypeRef PrimitiveType(Type klass) + { + if (klass == typeof(int) || klass == typeof(short) || klass == typeof(bool) || klass + == typeof(byte)) + { + return IntType(); + } + if (klass == typeof(double)) + { + return DoubleType(); + } + if (klass == typeof(float)) + { + return FloatType(); + } + if (klass == typeof(long)) + { + return LongType(); + } + return TypeRef(klass); + } + + private ITypeRef IntType() + { + return TypeRef(typeof(int)); + } + + private ITypeRef LongType() + { + return TypeRef(typeof(long)); + } + + private ITypeRef FloatType() + { + return TypeRef(typeof(float)); + } + + private ITypeRef DoubleType() + { + return TypeRef(typeof(double)); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Instrumentation/SODAMethodBuilder.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Instrumentation/SODAMethodBuilder.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Instrumentation/SODAMethodBuilder.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Instrumentation/SODAMethodBuilder.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,250 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using System.Collections; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Instrumentation.Api; +using Db4objects.Db4o.Internal.Query; +using Db4objects.Db4o.NativeQueries.Expr; +using Db4objects.Db4o.NativeQueries.Expr.Cmp; +using Db4objects.Db4o.NativeQueries.Expr.Cmp.Operand; +using Db4objects.Db4o.NativeQueries.Instrumentation; +using Db4objects.Db4o.NativeQueries.Optimization; +using Db4objects.Db4o.Query; + +namespace Db4objects.Db4o.NativeQueries.Instrumentation +{ + public class SODAMethodBuilder + { + private const bool LogBytecode = false; + + private IMethodRef descendRef; + + private IMethodRef constrainRef; + + private IMethodRef greaterRef; + + private IMethodRef smallerRef; + + private IMethodRef containsRef; + + private IMethodRef startsWithRef; + + private IMethodRef endsWithRef; + + private IMethodRef notRef; + + private IMethodRef andRef; + + private IMethodRef orRef; + + private IMethodRef identityRef; + + private readonly ITypeEditor _editor; + + private IMethodBuilder _builder; + + public static readonly string OptimizeQueryMethodName = "optimizeQuery"; + + private class SODAExpressionBuilder : IExpressionVisitor + { + private ITypeRef predicateClass; + + public SODAExpressionBuilder(SODAMethodBuilder _enclosing, ITypeRef predicateClass + ) + { + this._enclosing = _enclosing; + this.predicateClass = predicateClass; + } + + public virtual void Visit(AndExpression expression) + { + expression.Left().Accept(this); + expression.Right().Accept(this); + this._enclosing.Invoke(this._enclosing.andRef); + } + + public virtual void Visit(BoolConstExpression expression) + { + this.LoadQuery(); + } + + //throw new RuntimeException("No boolean constants expected in parsed expression tree"); + private void LoadQuery() + { + this._enclosing.LoadArgument(1); + } + + public virtual void Visit(OrExpression expression) + { + expression.Left().Accept(this); + expression.Right().Accept(this); + this._enclosing.Invoke(this._enclosing.orRef); + } + + public virtual void Visit(ComparisonExpression expression) + { + this.LoadQuery(); + this.Descend(this.FieldNames(expression.Left())); + expression.Right().Accept(this.ComparisonEmitter()); + this.Constrain(expression.Op()); + } + + private void Descend(IEnumerator fieldNames) + { + while (fieldNames.MoveNext()) + { + this.Descend(fieldNames.Current); + } + } + + private ComparisonBytecodeGeneratingVisitor ComparisonEmitter() + { + return new ComparisonBytecodeGeneratingVisitor(this._enclosing._builder, this.predicateClass + ); + } + + private void Constrain(ComparisonOperator op) + { + this._enclosing.Invoke(this._enclosing.constrainRef); + if (op.Equals(ComparisonOperator.ValueEquality)) + { + return; + } + if (op.Equals(ComparisonOperator.ReferenceEquality)) + { + this._enclosing.Invoke(this._enclosing.identityRef); + return; + } + if (op.Equals(ComparisonOperator.Greater)) + { + this._enclosing.Invoke(this._enclosing.greaterRef); + return; + } + if (op.Equals(ComparisonOperator.Smaller)) + { + this._enclosing.Invoke(this._enclosing.smallerRef); + return; + } + if (op.Equals(ComparisonOperator.Contains)) + { + this._enclosing.Invoke(this._enclosing.containsRef); + return; + } + if (op.Equals(ComparisonOperator.StartsWith)) + { + this._enclosing.Ldc(1); + this._enclosing.Invoke(this._enclosing.startsWithRef); + return; + } + if (op.Equals(ComparisonOperator.EndsWith)) + { + this._enclosing.Ldc(1); + this._enclosing.Invoke(this._enclosing.endsWithRef); + return; + } + throw new Exception("Cannot interpret constraint: " + op); + } + + private void Descend(object fieldName) + { + this._enclosing.Ldc(fieldName); + this._enclosing.Invoke(this._enclosing.descendRef); + } + + public virtual void Visit(NotExpression expression) + { + expression.Expr().Accept(this); + this._enclosing.Invoke(this._enclosing.notRef); + } + + private IEnumerator FieldNames(FieldValue fieldValue) + { + Collection4 coll = new Collection4(); + IComparisonOperand curOp = fieldValue; + while (curOp is FieldValue) + { + FieldValue curField = (FieldValue)curOp; + coll.Prepend(curField.FieldName()); + curOp = curField.Parent(); + } + return coll.GetEnumerator(); + } + + private readonly SODAMethodBuilder _enclosing; + } + + public SODAMethodBuilder(ITypeEditor editor) + { + _editor = editor; + BuildMethodReferences(); + } + + public virtual void InjectOptimization(IExpression expr) + { + _editor.AddInterface(TypeRef(typeof(IDb4oEnhancedFilter))); + _builder = _editor.NewPublicMethod(PlatformName(OptimizeQueryMethodName), TypeRef + (typeof(void)), new ITypeRef[] { TypeRef(typeof(IQuery)) }); + ITypeRef predicateClass = _editor.Type; + expr.Accept(new SODAMethodBuilder.SODAExpressionBuilder(this, predicateClass)); + _builder.Pop(); + _builder.EndMethod(); + } + + private ITypeRef TypeRef(Type type) + { + return _editor.References.ForType(type); + } + + private string PlatformName(string name) + { + return NativeQueriesPlatform.ToPlatformName(name); + } + + private void LoadArgument(int index) + { + _builder.LoadArgument(index); + } + + private void Invoke(IMethodRef method) + { + _builder.Invoke(method, CallingConvention.Interface); + } + + private void Ldc(object value) + { + _builder.Ldc(value); + } + + private void BuildMethodReferences() + { + descendRef = MethodRef(typeof(IQuery), "descend", new Type[] { typeof(string) }); + constrainRef = MethodRef(typeof(IQuery), "constrain", new Type[] { typeof(object) + }); + greaterRef = MethodRef(typeof(IConstraint), "greater", new Type[] { }); + smallerRef = MethodRef(typeof(IConstraint), "smaller", new Type[] { }); + containsRef = MethodRef(typeof(IConstraint), "contains", new Type[] { }); + startsWithRef = MethodRef(typeof(IConstraint), "startsWith", new Type[] { typeof( + bool) }); + endsWithRef = MethodRef(typeof(IConstraint), "endsWith", new Type[] { typeof(bool + ) }); + notRef = MethodRef(typeof(IConstraint), "not", new Type[] { }); + andRef = MethodRef(typeof(IConstraint), "and", new Type[] { typeof(IConstraint) } + ); + orRef = MethodRef(typeof(IConstraint), "or", new Type[] { typeof(IConstraint) }); + identityRef = MethodRef(typeof(IConstraint), "identity", new Type[] { }); + } + + private IMethodRef MethodRef(Type parent, string name, Type[] args) + { + try + { + return _editor.References.ForMethod(parent.GetMethod(PlatformName(name), args)); + } + catch (Exception e) + { + throw new InstrumentationException(e); + } + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Instrumentation/TypeDeducingVisitor.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Instrumentation/TypeDeducingVisitor.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Instrumentation/TypeDeducingVisitor.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Instrumentation/TypeDeducingVisitor.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,68 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using Db4objects.Db4o.Instrumentation.Api; +using Db4objects.Db4o.NativeQueries.Expr.Cmp.Operand; + +namespace Db4objects.Db4o.NativeQueries.Instrumentation +{ + internal class TypeDeducingVisitor : IComparisonOperandVisitor + { + private ITypeRef _predicateClass; + + private ITypeRef _clazz; + + private IReferenceProvider _referenceProvider; + + public TypeDeducingVisitor(IReferenceProvider provider, ITypeRef predicateClass) + { + this._predicateClass = predicateClass; + this._referenceProvider = provider; + _clazz = null; + } + + public virtual void Visit(PredicateFieldRoot root) + { + _clazz = _predicateClass; + } + + public virtual void Visit(CandidateFieldRoot root) + { + } + + // _clazz=_candidateClass; + public virtual void Visit(StaticFieldRoot root) + { + _clazz = root.Type; + } + + public virtual ITypeRef OperandClass() + { + return _clazz; + } + + public virtual void Visit(ArithmeticExpression operand) + { + } + + public virtual void Visit(ConstValue operand) + { + _clazz = _referenceProvider.ForType(operand.Value().GetType()); + } + + public virtual void Visit(FieldValue operand) + { + _clazz = operand.Field.Type; + } + + public virtual void Visit(ArrayAccessValue operand) + { + operand.Parent().Accept(this); + _clazz = _clazz.ElementType; + } + + public virtual void Visit(MethodCallValue operand) + { + _clazz = operand.Method.ReturnType; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Optimization/ComparisonQueryGeneratingVisitor.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Optimization/ComparisonQueryGeneratingVisitor.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Optimization/ComparisonQueryGeneratingVisitor.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Optimization/ComparisonQueryGeneratingVisitor.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,224 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using System.Reflection; +using Db4objects.Db4o.Instrumentation.Api; +using Db4objects.Db4o.Internal; +using Db4objects.Db4o.NativeQueries.Expr.Cmp; +using Db4objects.Db4o.NativeQueries.Expr.Cmp.Operand; +using Db4objects.Db4o.NativeQueries.Optimization; +using Sharpen.Lang.Reflect; + +namespace Db4objects.Db4o.NativeQueries.Optimization +{ + internal sealed class ComparisonQueryGeneratingVisitor : IComparisonOperandVisitor + { + private object _predicate; + + private object _value = null; + + private readonly INativeClassFactory _classSource; + + private readonly IReferenceResolver _resolver; + + public object Value() + { + return _value; + } + + public void Visit(ConstValue operand) + { + _value = operand.Value(); + } + + public void Visit(FieldValue operand) + { + operand.Parent().Accept(this); + Type clazz = ((operand.Parent() is StaticFieldRoot) ? (Type)_value : _value.GetType + ()); + try + { + FieldInfo field = Reflection4.GetField(clazz, operand.FieldName()); + _value = field.GetValue(_value); + } + catch (Exception exc) + { + // arg is ignored for static + Sharpen.Runtime.PrintStackTrace(exc); + } + } + + internal object Add(object a, object b) + { + if (a is double || b is double) + { + return ((double)a) + ((double)b); + } + if (a is float || b is float) + { + return ((float)a) + ((float)b); + } + if (a is long || b is long) + { + return ((long)a) + ((long)b); + } + return ((int)a) + ((int)b); + } + + internal object Subtract(object a, object b) + { + if (a is double || b is double) + { + return ((double)a) - ((double)b); + } + if (a is float || b is float) + { + return ((float)a) - ((float)b); + } + if (a is long || b is long) + { + return ((long)a) - ((long)b); + } + return ((int)a) - ((int)b); + } + + internal object Multiply(object a, object b) + { + if (a is double || b is double) + { + return ((double)a) * ((double)b); + } + if (a is float || b is float) + { + return ((float)a) * ((float)b); + } + if (a is long || b is long) + { + return ((long)a) * ((long)b); + } + return ((int)a) * ((int)b); + } + + internal object Divide(object a, object b) + { + if (a is double || b is double) + { + return ((double)a) / ((double)b); + } + if (a is float || b is float) + { + return ((float)a) / ((float)b); + } + if (a is long || b is long) + { + return ((long)a) / ((long)b); + } + return ((int)a) / ((int)b); + } + + public void Visit(ArithmeticExpression operand) + { + operand.Left().Accept(this); + object left = _value; + operand.Right().Accept(this); + object right = _value; + switch (operand.Op().Id()) + { + case ArithmeticOperator.AddId: + { + _value = Add(left, right); + break; + } + + case ArithmeticOperator.SubtractId: + { + _value = Subtract(left, right); + break; + } + + case ArithmeticOperator.MultiplyId: + { + _value = Multiply(left, right); + break; + } + + case ArithmeticOperator.DivideId: + { + _value = Divide(left, right); + break; + } + } + } + + public void Visit(CandidateFieldRoot root) + { + } + + public void Visit(PredicateFieldRoot root) + { + _value = _predicate; + } + + public void Visit(StaticFieldRoot root) + { + try + { + _value = _classSource.ForName(root.Type.Name); + } + catch (TypeLoadException e) + { + Sharpen.Runtime.PrintStackTrace(e); + } + } + + public void Visit(ArrayAccessValue operand) + { + operand.Parent().Accept(this); + object parent = _value; + operand.Index().Accept(this); + int index = (int)_value; + _value = Sharpen.Runtime.GetArrayValue(parent, index); + } + + public void Visit(MethodCallValue operand) + { + operand.Parent().Accept(this); + object receiver = _value; + MethodInfo method = _resolver.Resolve(operand.Method); + try + { + _value = method.Invoke(IsStatic(method) ? null : receiver, Args(operand)); + } + catch (Exception exc) + { + Sharpen.Runtime.PrintStackTrace(exc); + _value = null; + } + } + + private object[] Args(MethodCallValue operand) + { + IComparisonOperand[] args = operand.Args; + object[] @params = new object[args.Length]; + for (int paramIdx = 0; paramIdx < args.Length; paramIdx++) + { + args[paramIdx].Accept(this); + @params[paramIdx] = _value; + } + return @params; + } + + private bool IsStatic(MethodInfo method) + { + return NativeQueriesPlatform.IsStatic(method); + } + + public ComparisonQueryGeneratingVisitor(object predicate, INativeClassFactory classSource + , IReferenceResolver resolver) : base() + { + _predicate = predicate; + _classSource = classSource; + _resolver = resolver; + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Optimization/SODAQueryBuilder.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Optimization/SODAQueryBuilder.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Optimization/SODAQueryBuilder.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries/Optimization/SODAQueryBuilder.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,143 @@ +/* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ + +using System; +using System.Collections; +using Db4objects.Db4o.Foundation; +using Db4objects.Db4o.Instrumentation.Api; +using Db4objects.Db4o.NativeQueries.Expr; +using Db4objects.Db4o.NativeQueries.Expr.Cmp; +using Db4objects.Db4o.NativeQueries.Expr.Cmp.Operand; +using Db4objects.Db4o.NativeQueries.Optimization; +using Db4objects.Db4o.Query; + +namespace Db4objects.Db4o.NativeQueries.Optimization +{ + public class SODAQueryBuilder + { + private class SODAQueryVisitor : IExpressionVisitor + { + private object _predicate; + + private IQuery _query; + + private IConstraint _constraint; + + private INativeClassFactory _classSource; + + private IReferenceResolver _referenceResolver; + + internal SODAQueryVisitor(IQuery query, object predicate, INativeClassFactory classSource + , IReferenceResolver referenceResolver) + { + _query = query; + _predicate = predicate; + _classSource = classSource; + _referenceResolver = referenceResolver; + } + + public virtual void Visit(AndExpression expression) + { + expression.Left().Accept(this); + IConstraint left = _constraint; + expression.Right().Accept(this); + left.And(_constraint); + _constraint = left; + } + + public virtual void Visit(BoolConstExpression expression) + { + } + + public virtual void Visit(OrExpression expression) + { + expression.Left().Accept(this); + IConstraint left = _constraint; + expression.Right().Accept(this); + left.Or(_constraint); + _constraint = left; + } + + public virtual void Visit(ComparisonExpression expression) + { + IQuery subQuery = Descend(expression.Left()); + ComparisonQueryGeneratingVisitor visitor = new ComparisonQueryGeneratingVisitor(_predicate + , _classSource, _referenceResolver); + expression.Right().Accept(visitor); + _constraint = subQuery.Constrain(visitor.Value()); + ComparisonOperator op = expression.Op(); + if (op.Equals(ComparisonOperator.ValueEquality)) + { + return; + } + if (op.Equals(ComparisonOperator.ReferenceEquality)) + { + _constraint.Identity(); + return; + } + if (op.Equals(ComparisonOperator.Greater)) + { + _constraint.Greater(); + return; + } + if (op.Equals(ComparisonOperator.Smaller)) + { + _constraint.Smaller(); + return; + } + if (op.Equals(ComparisonOperator.Contains)) + { + _constraint.Contains(); + return; + } + if (op.Equals(ComparisonOperator.StartsWith)) + { + _constraint.StartsWith(true); + return; + } + if (op.Equals(ComparisonOperator.EndsWith)) + { + _constraint.EndsWith(true); + return; + } + throw new Exception("Can't handle constraint: " + op); + } + + private IQuery Descend(FieldValue left) + { + IQuery subQuery = _query; + IEnumerator fieldNameIterator = FieldNames(left); + while (fieldNameIterator.MoveNext()) + { + subQuery = subQuery.Descend((string)fieldNameIterator.Current); + } + return subQuery; + } + + public virtual void Visit(NotExpression expression) + { + expression.Expr().Accept(this); + _constraint.Not(); + } + + private IEnumerator FieldNames(FieldValue fieldValue) + { + Collection4 coll = new Collection4(); + IComparisonOperand curOp = fieldValue; + while (curOp is FieldValue) + { + FieldValue curField = (FieldValue)curOp; + coll.Prepend(curField.FieldName()); + curOp = curField.Parent(); + } + return coll.GetEnumerator(); + } + } + + public virtual void OptimizeQuery(IExpression expr, IQuery query, object predicate + , INativeClassFactory classSource, IReferenceResolver referenceResolver) + { + expr.Accept(new SODAQueryBuilder.SODAQueryVisitor(query, predicate, classSource, + referenceResolver)); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries-2008.csproj smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries-2008.csproj --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries-2008.csproj 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o.NativeQueries/Db4objects.Db4o.NativeQueries-2008.csproj 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,142 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {AB1BF369-A9C4-4876-9797-178DB8AD437F} + Library + Properties + Db4objects.Db4o.NativeQueries + Db4objects.Db4o.NativeQueries + + + 2.0 + + + v3.5 + + + + + + + + + + + + + + + + + + + + + + +true +../db4objects.snk + + + true + full + false + bin\Debug\ + DEBUG;TRACE;NET_3_5 + prompt + 4 + bin\Debug\Db4objects.Db4o.NativeQueries.xml + 1591;1572;1573;1574;0419; + + + pdbonly + true + bin\Release\ + TRACE;NET_3_5 + prompt + 4 + bin\Release\Db4objects.Db4o.NativeQueries.xml + 1591;1572;1573;1574;0419; + + + + False + ..\Libs\net-2.0\Cecil.FlowAnalysis.dll + + + False + ..\Libs\net-2.0\Mono.Cecil.dll + + + + 3.5 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {FFA59708-14D1-4C22-B9A4-1A389EE796D5} + Db4objects.Db4o.Instrumentation-2008 + + + {600CD3BF-2ED2-4183-87F7-ADD78A968AE0} + Db4objects.Db4o-2008 + + + + + diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o.NativeQueries/native/Db4objects.Db4o.NativeQueries/AssemblyResolver.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o.NativeQueries/native/Db4objects.Db4o.NativeQueries/AssemblyResolver.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o.NativeQueries/native/Db4objects.Db4o.NativeQueries/AssemblyResolver.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o.NativeQueries/native/Db4objects.Db4o.NativeQueries/AssemblyResolver.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,57 @@ +/* Copyright (C) 2009 Versant Inc. http://www.db4o.com */ +using System.Collections.Generic; +using System.Reflection; +using Db4objects.Db4o.Internal.Query; +using Mono.Cecil; + +namespace Db4objects.Db4o.NativeQueries +{ + internal class AssemblyResolver + { + public AssemblyResolver(ICachingStrategy assemblyCache) + { + _assemblyCachingStrategy = assemblyCache; + } + + public AssemblyDefinition ForTypeReference(TypeReference type) + { + AssemblyNameReference scope = (AssemblyNameReference)type.Scope; + string assemblyName = scope.FullName; + AssemblyDefinition definition = LookupAssembly(assemblyName); + if (null == definition) + { + Assembly assembly = Assembly.Load(assemblyName); + string location = assembly.GetType(type.FullName, true).Module.FullyQualifiedName; + definition = _assemblyCachingStrategy.Get(location); + RegisterAssembly(definition); + } + return definition; + } + + private AssemblyDefinition LookupAssembly(string fullName) + { + return _assemblies.ContainsKey(fullName) ? _assemblies[fullName] : null; + } + + /// + /// Registers an assembly so it can be looked up by its assembly name + /// string later. + /// + /// + private void RegisterAssembly(AssemblyDefinition assembly) + { + _assemblies.Add(assembly.Name.FullName, assembly); + } + + public AssemblyDefinition ForType(TypeDefinition type) + { + AssemblyDefinition assembly = type.Module.Assembly; + RegisterAssembly(assembly); + + return assembly; + } + + private readonly ICachingStrategy _assemblyCachingStrategy; + readonly IDictionary _assemblies = new Dictionary(); + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o.NativeQueries/native/Db4objects.Db4o.NativeQueries/ICachingStrategy.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o.NativeQueries/native/Db4objects.Db4o.NativeQueries/ICachingStrategy.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o.NativeQueries/native/Db4objects.Db4o.NativeQueries/ICachingStrategy.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o.NativeQueries/native/Db4objects.Db4o.NativeQueries/ICachingStrategy.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,9 @@ +/* Copyright (C) 2007 Versant Inc. http://www.db4o.com */ +namespace Db4objects.Db4o.Internal.Query +{ + public interface ICachingStrategy + { + void Add(K key, V item); + V Get(K key); + } +} \ No newline at end of file diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o.NativeQueries/native/Db4objects.Db4o.NativeQueries/NQOptimizer.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o.NativeQueries/native/Db4objects.Db4o.NativeQueries/NQOptimizer.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o.NativeQueries/native/Db4objects.Db4o.NativeQueries/NQOptimizer.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o.NativeQueries/native/Db4objects.Db4o.NativeQueries/NQOptimizer.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,24 @@ +using System.Reflection; +using Db4objects.Db4o.Instrumentation.Api; +using Db4objects.Db4o.Instrumentation.Cecil; +using Db4objects.Db4o.Instrumentation.Core; +using Db4objects.Db4o.Internal.Query; +using Db4objects.Db4o.NativeQueries.Expr; +using Db4objects.Db4o.NativeQueries.Optimization; +using Db4objects.Db4o.Query; + +namespace Db4objects.Db4o.NativeQueries +{ + public class NQOptimizer : INQOptimizer + { + private readonly INativeClassFactory _classFactory = new DefaultNativeClassFactory(); + + public void Optimize(IQuery q, object predicate, MethodBase filterMethod) + { + // TODO: cache predicate expressions here + QueryExpressionBuilder builder = new QueryExpressionBuilder(); + IExpression expression = builder.FromMethod(filterMethod); + new SODAQueryBuilder().OptimizeQuery(expression, q, predicate, _classFactory, new CecilReferenceResolver()); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o.NativeQueries/native/Db4objects.Db4o.NativeQueries/Optimization/NativeQueriesPlatform.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o.NativeQueries/native/Db4objects.Db4o.NativeQueries/Optimization/NativeQueriesPlatform.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o.NativeQueries/native/Db4objects.Db4o.NativeQueries/Optimization/NativeQueriesPlatform.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o.NativeQueries/native/Db4objects.Db4o.NativeQueries/Optimization/NativeQueriesPlatform.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,17 @@ +using System.Reflection; + +namespace Db4objects.Db4o.NativeQueries.Optimization +{ + class NativeQueriesPlatform + { + public static bool IsStatic(MethodInfo method) + { + return method.IsStatic; + } + + public static string ToPlatformName(string name) + { + return char.ToUpper(name[0]) + name.Substring(1); + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o.NativeQueries/native/Db4objects.Db4o.NativeQueries/QueryExpressionBuilder.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o.NativeQueries/native/Db4objects.Db4o.NativeQueries/QueryExpressionBuilder.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o.NativeQueries/native/Db4objects.Db4o.NativeQueries/QueryExpressionBuilder.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o.NativeQueries/native/Db4objects.Db4o.NativeQueries/QueryExpressionBuilder.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,916 @@ +/* Copyright (C) 2004-2006 Versant Inc. http://www.db4o.com */ + +using System.Collections.Generic; +using Db4objects.Db4o.Activation; +using Db4objects.Db4o.Instrumentation.Cecil; +using Db4objects.Db4o.TA; +using Mono.Collections.Generic; + +namespace Db4objects.Db4o.NativeQueries +{ + using System; + using System.Collections; + using System.Reflection; + + using Mono.Cecil; + + using Cecil.FlowAnalysis; + using Cecil.FlowAnalysis.ActionFlow; + using Cecil.FlowAnalysis.CodeStructure; + using Ast = Cecil.FlowAnalysis.CodeStructure; + + using Expr; + using Expr.Cmp; + using Expr.Cmp.Operand; + using NQExpression = Expr.IExpression; + using Internal.Query; + + /// + /// Build a Db4objects.Db4o.Nativequery.Expr tree out of a predicate method definition. + /// + public class QueryExpressionBuilder + { + protected static ICachingStrategy _assemblyCachingStrategy = + new SingleItemCachingStrategy( delegate(string location) + { + return AssemblyDefinition.ReadAssembly(location); + }); + + protected static ICachingStrategy _expressionCachingStrategy = + new SingleItemCachingStrategy( + delegate(MethodBase method) + { + MethodDefinition methodDef = GetMethodDefinition(method); + return AdjustBoxedValueTypes(FromMethodDefinition(methodDef)); + } + ); + + public NQExpression FromMethod(MethodBase method) + { + if (method == null) throw new ArgumentNullException("method"); + + return GetCachedExpression(method); + } + + private static NQExpression GetCachedExpression(MethodBase method) + { + return _expressionCachingStrategy.Get(method); + } + + private static MethodDefinition GetMethodDefinition(MethodBase method) + { + string location = GetAssemblyLocation(method); +#if CF + MethodDefinition methodDef = MethodDefinitionFor(method); +#else + AssemblyDefinition assembly = _assemblyCachingStrategy.Get(location); + + MethodDefinition methodDef = (MethodDefinition)assembly.MainModule.LookupToken(method.MetadataToken); +#endif + if (null == methodDef) UnsupportedPredicate(string.Format("Unable to load the definition of '{0}' from assembly '{1}'", method, location)); + + return methodDef; + } + + private static MethodDefinition MethodDefinitionFor(MethodBase method) + { + string location = GetAssemblyLocation(method); + AssemblyDefinition assembly = _assemblyCachingStrategy.Get(location); + +#if CF + TypeDefinition declaringType = FindTypeDefinition(assembly.MainModule, method.DeclaringType); + if (declaringType == null) + { + return null; + } + + foreach (MethodDefinition candidate in declaringType.Methods) + { + if (candidate.Name != method.Name) continue; + if (candidate.Parameters.Count != method.GetParameters().Length) continue; + if (!ParametersMatch(candidate.Parameters, GetParameterTypes(method, assembly.MainModule))) continue; + { + return candidate; + } + } + + return null; + +#else + return (MethodDefinition) assembly.MainModule.LookupToken(method.MetadataToken); +#endif + } + + private static NQExpression AdjustBoxedValueTypes(NQExpression expression) + { + expression.Accept(new BoxedValueTypeProcessor()); + return expression; + } + + private static IList GetParameterTypes(MethodBase method, ModuleDefinition module) + { + IList types = new List(); + foreach (ParameterInfo parameter in ParametersFor(method)) + { + types.Add(FindTypeDefinition(module, parameter.ParameterType)); + } + + return types; + } + + private static ParameterInfo[] ParametersFor(MethodBase method) + { + if (method.IsGenericMethod) + { + MethodInfo methodInfo = (MethodInfo) method; + return methodInfo.GetGenericMethodDefinition().GetParameters(); + } + + return method.DeclaringType.IsGenericType + ? method.DeclaringType.GetGenericTypeDefinition().GetMethod(method.Name).GetParameters() + : method.GetParameters(); + } + + private static TypeDefinition FindTypeDefinition(ModuleDefinition module, Type type) + { + return IsNested(type) + ? FindNestedTypeDefinition(module, type) + : FindTypeDefinition(module, type.IsGenericType ? type.Name : type.FullName); + } + + private static bool IsNested(Type type) + { + return type.IsNestedPublic || type.IsNestedPrivate || type.IsNestedAssembly; + } + + private static TypeDefinition FindNestedTypeDefinition(ModuleDefinition module, Type type) + { + foreach (TypeDefinition td in FindTypeDefinition(module, type.DeclaringType).NestedTypes) + { + if (td.Name == type.Name) return td; + } + return null; + } + + private static TypeDefinition FindTypeDefinition(ModuleDefinition module, string name) + { + return module.GetType(name); + } + + private static string GetAssemblyLocation(MethodBase method) + { + return method.DeclaringType.Module.FullyQualifiedName; + } + + public static NQExpression FromMethodDefinition(MethodDefinition method) + { + ValidatePredicateMethodDefinition(method); + + Expression expression = GetQueryExpression(method); + if (null == expression) UnsupportedPredicate("No expression found."); + + Visitor visitor = new Visitor(method, new AssemblyResolver(_assemblyCachingStrategy)); + expression.Accept(visitor); + return visitor.Expression; + } + + private static void ValidatePredicateMethodDefinition(MethodDefinition method) + { + if (method == null) + throw new ArgumentNullException("method"); + if (1 != method.Parameters.Count) + UnsupportedPredicate("A predicate must take a single argument."); + if (0 != method.Body.ExceptionHandlers.Count) + UnsupportedPredicate("A predicate can not contain exception handlers."); + if (method.ReturnType.FullName != typeof(bool).FullName) + UnsupportedPredicate("A predicate must have a boolean return type."); + } + + private static Expression GetQueryExpression(MethodDefinition method) + { + ActionFlowGraph afg = FlowGraphFactory.CreateActionFlowGraph(FlowGraphFactory.CreateControlFlowGraph(method)); + return GetQueryExpression(afg); + } + + private static void UnsupportedPredicate(string reason) + { + throw new UnsupportedPredicateException(reason); + } + + private static void UnsupportedExpression(Expression node) + { + UnsupportedPredicate("Unsupported expression: " + ExpressionPrinter.ToString(node)); + } + + private static Expression GetQueryExpression(ActionFlowGraph afg) + { + IDictionary variables = new Dictionary(); + ActionBlock block = afg.Blocks[0]; + while (block != null) + { + switch (block.ActionType) + { + case ActionType.Invoke: + InvokeActionBlock invokeBlock = (InvokeActionBlock)block; + MethodInvocationExpression invocation = invokeBlock.Expression; + if (IsActivateInvocation(invocation) + || IsNoSideEffectIndirectActivationInvocation(invocation)) + { + block = invokeBlock.Next; + break; + } + + UnsupportedExpression(invocation); + break; + + case ActionType.ConditionalBranch: + UnsupportedPredicate("Conditional blocks are not supported."); + break; + + case ActionType.Branch: + block = ((BranchActionBlock)block).Target; + break; + + case ActionType.Assign: + { + AssignActionBlock assignBlock = (AssignActionBlock)block; + AssignExpression assign = assignBlock.AssignExpression; + VariableReferenceExpression variable = assign.Target as VariableReferenceExpression; + if (null == variable) + { + UnsupportedExpression(assign); + } + else + { + if (variables.ContainsKey(variable.Variable.Index)) + UnsupportedExpression(assign.Expression); + + variables.Add(variable.Variable.Index, assign.Expression); + block = assignBlock.Next; + } + break; + } + + case ActionType.Return: + { + Expression expression = ((ReturnActionBlock)block).Expression; + VariableReferenceExpression variable = expression as VariableReferenceExpression; + return null == variable + ? expression + : variables[variable.Variable.Index]; + } + } + } + return null; + } + + private static bool IsNoSideEffectIndirectActivationInvocation(MethodInvocationExpression invocation) + { + MethodDefinition methodDefinition = MethodDefinitionFor(invocation); + if (null == methodDefinition) return false; + ActionFlowGraph afg = FlowGraphFactory.CreateActionFlowGraph(FlowGraphFactory.CreateControlFlowGraph(methodDefinition)); + + if (afg.Blocks.Count == 2 && afg.Blocks[0].ActionType == ActionType.Invoke) + { + InvokeActionBlock invocationBlock = (InvokeActionBlock) afg.Blocks[0]; + return IsActivateInvocation(invocationBlock.Expression); + } + + return false; + } + + private static MethodDefinition MethodDefinitionFor(MethodInvocationExpression invocation) + { + MethodReferenceExpression methodRef = invocation.Target as MethodReferenceExpression; + if (null == methodRef) return null; + + return GetMethodDefinition(methodRef); + } + + private static bool IsActivateInvocation(MethodInvocationExpression invocation) + { + MethodReferenceExpression methodRef = invocation.Target as MethodReferenceExpression; + if (null == methodRef) return false; + return IsActivateMethod(methodRef.Method); + } + + private static bool IsActivateMethod(MethodReference method) + { + if (method.Name != "Activate") return false; + return method.DeclaringType.FullName == typeof(IActivatable).FullName || + IsOverridenActivateMethod(method); + } + + private static bool IsOverridenActivateMethod(MethodReference method) + { + TypeDefinition declaringType = FindTypeDefinition(method.DeclaringType.Module, method.DeclaringType.FullName); + if (!DeclaringTypeImplementsIActivatable(declaringType)) return false; + if (method.Parameters.Count != 1 || + method.Parameters[0].ParameterType.FullName != typeof(ActivationPurpose).FullName) return false; + + return true; + } + + private static bool DeclaringTypeImplementsIActivatable(TypeDefinition type) + { + foreach (TypeReference itf in type.Interfaces) + { + if (itf.FullName == typeof (IActivatable).FullName) + { + return true; + } + } + + return false; + } + + private static MethodDefinition GetMethodDefinition(MethodReferenceExpression methodRef) + { + MethodDefinition definition = methodRef.Method as MethodDefinition; + return definition ?? LoadExternalMethodDefinition(methodRef); + } + + private static MethodDefinition LoadExternalMethodDefinition(MethodReferenceExpression methodRef) + { + MethodReference method = methodRef.Method; + AssemblyDefinition assemblyDef = new AssemblyResolver(_assemblyCachingStrategy).ForTypeReference(method.DeclaringType); + TypeDefinition type = assemblyDef.MainModule.GetType(method.DeclaringType.FullName); + return GetMethod(type, method); + } + + private static MethodDefinition GetMethod(TypeDefinition type, MethodReference template) + { + foreach (MethodDefinition method in type.Methods) + { + if (method.Name != template.Name) continue; + if (method.Parameters.Count != template.Parameters.Count) continue; + if (!ParametersMatch(method.Parameters, template.Parameters)) continue; + + return method; + } + + return null; + } + +#if CF + private static bool ParametersMatch(Collection parameters, IList templates) + { + return ParametersMatch(parameters, templates, delegate(ParameterDefinition candidate, TypeReference template) + { + return candidate.ParameterType.FullName == template.FullName; + }); + } +#endif + + private static bool ParametersMatch(IList parameters, IList templates) + { + return ParametersMatch(parameters, templates, delegate(ParameterDefinition candidate, ParameterDefinition template) + { + return candidate.ParameterType.FullName == template.ParameterType.FullName; + }); + } + + private static bool ParametersMatch(IList parameters, IList templates, ParameterMatch predicate) + { + if (parameters.Count != templates.Count) return false; + + for (int i = 0; i < parameters.Count; i++) + { + ParameterDefinition parameter = parameters[i]; + if (!predicate(parameter, templates[i])) return false; + } + + return true; + } + + private delegate bool ParameterMatch(ParameterDefinition candidate, T template); + + class Visitor : AbstractCodeStructureVisitor + { + private object _current; + private int _insideCandidate; + readonly IList _methodDefinitionStack = new ArrayList(); + private readonly CecilReferenceProvider _referenceProvider; + + public Visitor(MethodDefinition topLevelMethod, AssemblyResolver resolver) + { + EnterMethodDefinition(topLevelMethod); + AssemblyDefinition assembly = resolver.ForType(topLevelMethod.DeclaringType); + _referenceProvider = CecilReferenceProvider.ForModule(assembly.MainModule); + } + + private void EnterMethodDefinition(MethodDefinition method) + { + _methodDefinitionStack.Add(method); + } + + private void LeaveMethodDefinition(MethodDefinition method) + { + int lastIndex = _methodDefinitionStack.Count - 1; + object popped = _methodDefinitionStack[lastIndex]; + System.Diagnostics.Debug.Assert(method == popped); + _methodDefinitionStack.RemoveAt(lastIndex); + } + + public NQExpression Expression + { + get + { + ConstValue value = _current as ConstValue; + if (null != value) + { + return ToNQExpression(value); + } + return (NQExpression)_current; + } + } + + private static NQExpression ToNQExpression(ConstValue value) + { + if (IsTrue(value.Value())) return BoolConstExpression.True; + return BoolConstExpression.False; + } + + private static bool IsTrue(object o) + { + return ((IConvertible) o).ToBoolean(null); + } + + private bool InsideCandidate + { + get { return _insideCandidate > 0; } + } + + public override void Visit(CastExpression node) + { + node.Target.Accept(this); + } + + public override void Visit(AssignExpression node) + { + UnsupportedExpression(node); + } + + public override void Visit(VariableReferenceExpression node) + { + UnsupportedExpression(node); + } + + public override void Visit(ArgumentReferenceExpression node) + { + UnsupportedExpression(node); + } + + public override void Visit(UnaryExpression node) + { + switch (node.Operator) + { + case UnaryOperator.Not: + Visit(node.Operand); + Negate(); + break; + + default: + UnsupportedExpression(node); + break; + } + } + + public override void Visit(Ast.BinaryExpression node) + { + switch (node.Operator) + { + case BinaryOperator.ValueEquality: + PushComparison(node.Left, node.Right, ComparisonOperator.ValueEquality); + break; + + case BinaryOperator.ValueInequality: + PushComparison(node.Left, node.Right, ComparisonOperator.ValueEquality); + Negate(); + break; + + case BinaryOperator.LessThan: + PushComparison(node.Left, node.Right, ComparisonOperator.Smaller); + break; + + case BinaryOperator.GreaterThan: + PushComparison(node.Left, node.Right, ComparisonOperator.Greater); + break; + + case BinaryOperator.GreaterThanOrEqual: + PushComparison(node.Left, node.Right, ComparisonOperator.Smaller); + Negate(); + break; + + case BinaryOperator.LessThanOrEqual: + PushComparison(node.Left, node.Right, ComparisonOperator.Greater); + Negate(); + break; + + case BinaryOperator.LogicalOr: + Push(new OrExpression(Convert(node.Left), Convert(node.Right))); + break; + + case BinaryOperator.LogicalAnd: + Push(new AndExpression(Convert(node.Left), Convert(node.Right))); + break; + + default: + UnsupportedExpression(node); + break; + } + } + + private void Negate() + { + NQExpression top = (NQExpression)Pop(); + NotExpression topNot = top as NotExpression; + if (topNot != null) + { + Push(topNot.Expr()); + return; + } + Push(new NotExpression(top)); + } + + private void PushComparison(Expression lhs, Expression rhs, ComparisonOperator op) + { + Visit(lhs); + object left = Pop(); + Visit(rhs); + object right = Pop(); + + bool areOperandsSwapped = IsCandidateFieldValue(right); + if (areOperandsSwapped) + { + object temp = left; + left = right; + right = temp; + } + + AssertType(left, typeof(FieldValue), lhs); + AssertType(right, typeof(IComparisonOperand), rhs); + + Push(new ComparisonExpression((FieldValue)left, (IComparisonOperand)right, op)); + + if (areOperandsSwapped && !op.IsSymmetric()) + { + Negate(); + } + } + + private static bool IsCandidateFieldValue(object o) + { + FieldValue value = o as FieldValue; + if (value == null) return false; + return value.Root() is CandidateFieldRoot; + } + + public override void Visit(MethodInvocationExpression node) + { + MethodReferenceExpression methodRef = node.Target as MethodReferenceExpression; + if (null == methodRef) + UnsupportedExpression(node); + + MethodReference method = methodRef.Method; + if (IsOperator(method)) + { + ProcessOperatorMethodInvocation(node, method); + return; + } + + if (IsSystemString(method.DeclaringType)) + { + ProcessStringMethod(node, methodRef); + return; + } + + ProcessRegularMethodInvocation(node, methodRef); + } + + private static bool IsSystemString(TypeReference type) + { + return type.FullName == "System.String"; + } + + private void ProcessStringMethod(MethodInvocationExpression node, MethodReferenceExpression methodRef) + { + MethodReference method = methodRef.Method; + + if (method.Parameters.Count != 1 + || !IsSystemString(method.Parameters[0].ParameterType)) + { + UnsupportedExpression(methodRef); + } + + switch (method.Name) + { + case "Contains": + PushComparison(methodRef.Target, node.Arguments[0], ComparisonOperator.Contains); + break; + + case "StartsWith": + PushComparison(methodRef.Target, node.Arguments[0], ComparisonOperator.StartsWith); + break; + + case "EndsWith": + PushComparison(methodRef.Target, node.Arguments[0], ComparisonOperator.EndsWith); + break; + + case "Equals": + PushComparison(methodRef.Target, node.Arguments[0], ComparisonOperator.ValueEquality); + break; + + default: + UnsupportedExpression(methodRef); + break; + } + } + + private void ProcessRegularMethodInvocation(MethodInvocationExpression node, MethodReferenceExpression methodRef) + { + if (node.Arguments.Count != 0) + UnsupportedExpression(node); + + Expression target = methodRef.Target; + switch (target.CodeElementType) + { + case CodeElementType.ThisReferenceExpression: + if (!InsideCandidate) + UnsupportedExpression(node); + ProcessCandidateMethodInvocation(node, methodRef); + break; + + case CodeElementType.ArgumentReferenceExpression: + ProcessCandidateMethodInvocation(node, methodRef); + break; + + default: + Push(ToFieldValue(target)); + ProcessCandidateMethodInvocation(node, methodRef); + break; + } + } + + private void ProcessOperatorMethodInvocation(MethodInvocationExpression node, MemberReference methodReference) + { + switch (methodReference.Name) + { + case "op_Equality": + PushComparison(node.Arguments[0], node.Arguments[1], ComparisonOperator.ValueEquality); + break; + + case "op_Inequality": + PushComparison(node.Arguments[0], node.Arguments[1], ComparisonOperator.ValueEquality); + Negate(); + break; + + // XXX: check if the operations below are really supported for the + // data types in question + case "op_GreaterThanOrEqual": + PushComparison(node.Arguments[0], node.Arguments[1], ComparisonOperator.Smaller); + Negate(); + break; + + case "op_LessThanOrEqual": + PushComparison(node.Arguments[0], node.Arguments[1], ComparisonOperator.Greater); + Negate(); + break; + + case "op_LessThan": + PushComparison(node.Arguments[0], node.Arguments[1], ComparisonOperator.Smaller); + break; + + case "op_GreaterThan": + PushComparison(node.Arguments[0], node.Arguments[1], ComparisonOperator.Greater); + break; + + default: + UnsupportedExpression(node); + break; + } + } + + private void ProcessCandidateMethodInvocation(Expression methodInvocationExpression, MethodReferenceExpression methodRef) + { + MethodDefinition method = GetMethodDefinition(methodRef); + if (null == method) + UnsupportedExpression(methodInvocationExpression); + + AssertMethodCanBeVisited(methodInvocationExpression, method); + + Expression expression = GetQueryExpression(method); + if (null == expression) + UnsupportedExpression(methodInvocationExpression); + + EnterCandidateMethod(method); + try + { + Visit(expression); + } + finally + { + LeaveCandidateMethod(method); + } + } + + private void AssertMethodCanBeVisited(Expression methodInvocationExpression, MethodDefinition method) + { + if (_methodDefinitionStack.Contains(method)) + UnsupportedExpression(methodInvocationExpression); + } + + private void EnterCandidateMethod(MethodDefinition method) + { + EnterMethodDefinition(method); + ++_insideCandidate; + } + + private void LeaveCandidateMethod(MethodDefinition method) + { + --_insideCandidate; + LeaveMethodDefinition(method); + } + + private static bool IsOperator(MethodReference method) + { + return !method.HasThis && method.Name.StartsWith("op_") && 2 == method.Parameters.Count; + } + + public override void Visit(FieldReferenceExpression node) + { + PushFieldValueForTarget(node, node.Target); + } + + private void PushFieldValueForTarget(FieldReferenceExpression node, Expression target) + { + switch (target.CodeElementType) + { + case CodeElementType.ArgumentReferenceExpression: + PushFieldValue(CandidateFieldRoot.Instance, node.Field); + break; + + case CodeElementType.ThisReferenceExpression: + if (InsideCandidate) + { + if (_current != null) + { + FieldValue current = PopFieldValue(node); + PushFieldValue(current, node.Field); + } + else + { + PushFieldValue(CandidateFieldRoot.Instance, node.Field); + } + } + else + { + PushFieldValue(PredicateFieldRoot.Instance, node.Field); + } + break; + + case CodeElementType.MethodInvocationExpression: + case CodeElementType.FieldReferenceExpression: + FieldValue value = ToFieldValue(target); + PushFieldValue(value, node.Field); + break; + + case CodeElementType.CastExpression: + PushFieldValueForTarget(node, ((CastExpression)node.Target).Target); + break; + + default: + UnsupportedExpression(node); + break; + } + } + + private void PushFieldValue(IComparisonOperandAnchor value, FieldReference field) + { + Push(new FieldValue(value, _referenceProvider.ForCecilField(field))); + } + + public override void Visit(LiteralExpression node) + { + Push(new ConstValue(node.Value)); + } + + NQExpression Convert(Expression node) + { + return ReconstructNullComparisonIfNecessary(node); + } + + private NQExpression ReconstructNullComparisonIfNecessary(Expression node) + { + Visit(node); + + object top = Pop(); + FieldValue fieldValue = top as FieldValue; + if (fieldValue == null) + { + AssertType(top, typeof(NQExpression), node); + return (NQExpression)top; + } + + return + new NotExpression( + new ComparisonExpression( + fieldValue, + new ConstValue(null), + ComparisonOperator.ValueEquality)); + } + + FieldValue ToFieldValue(Expression node) + { + Visit(node); + return PopFieldValue(node); + } + + private FieldValue PopFieldValue(Expression node) + { + return (FieldValue)Pop(node, typeof(FieldValue)); + } + + void Push(object value) + { + Assert(_current == null, "expression stack must be empty before Push"); + _current = value; + } + + object Pop(Expression node, Type expectedType) + { + object value = Pop(); + AssertType(value, expectedType, node); + return value; + } + + private static void AssertType(object value, Type expectedType, Expression sourceExpression) + { + Type actualType = value.GetType(); + if (!expectedType.IsAssignableFrom(actualType)) + { + UnsupportedPredicate( + string.Format("Unsupported expression: {0}. Unexpected type on stack. Expected: {1}, Got: {2}.", + ExpressionPrinter.ToString(sourceExpression), expectedType, actualType)); + } + } + + object Pop() + { + Assert(_current != null, "expression stack is empty"); + object value = _current; + _current = null; + return value; + } + + private static void Assert(bool condition, string message) + { + System.Diagnostics.Debug.Assert(condition, message); + } + } + } + + internal class BoxedValueTypeProcessor : TraversingExpressionVisitor + { + override public void Visit(ComparisonExpression expression) + { + TypeReference fieldType = GetFieldType(expression.Left()); + if (!fieldType.IsValueType) return; + + ConstValue constValue = expression.Right() as ConstValue; + if (constValue == null) return; + + AdjustConstValue(fieldType, constValue); + } + + private static TypeReference GetFieldType(FieldValue field) + { + return ((CecilFieldRef) field.Field).FieldType; + } + + private static void AdjustConstValue(TypeReference typeRef, ConstValue constValue) + { + object value = constValue.Value(); + if (!value.GetType().IsValueType) return; + + System.Type type = ResolveTypeReference(typeRef); + if (!type.IsEnum || value.GetType() == type) return; + + constValue.Value(Enum.ToObject(type, value)); + } + + private static Type ResolveTypeReference(TypeReference typeRef) + { + Assembly assembly = LoadAssembly(typeRef.Scope); + return assembly.GetType(typeRef.FullName.Replace('/', '+'), true); + } + + private static Assembly LoadAssembly(IMetadataScope scope) + { + AssemblyNameReference nameRef = scope as AssemblyNameReference; + if (null != nameRef) return Assembly.Load(nameRef.FullName); + ModuleDefinition moduleDef = scope as ModuleDefinition; + return LoadAssembly(moduleDef.Assembly.Name); + } + } +} \ No newline at end of file diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o.NativeQueries/native/Db4objects.Db4o.NativeQueries/SingleItemCachingStrategy.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o.NativeQueries/native/Db4objects.Db4o.NativeQueries/SingleItemCachingStrategy.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o.NativeQueries/native/Db4objects.Db4o.NativeQueries/SingleItemCachingStrategy.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o.NativeQueries/native/Db4objects.Db4o.NativeQueries/SingleItemCachingStrategy.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,66 @@ +/* Copyright (C) 2007 Versant Inc. http://www.db4o.com */ +using System; + +namespace Db4objects.Db4o.Internal.Query +{ + public delegate R Producer(T arg); + + /// + /// A very simple caching strategy that caches only the last added item. + /// + public class SingleItemCachingStrategy : ICachingStrategy + { + + private K _lastKey; + private V _lastItem; + private object _monitor = new object(); + private readonly Producer _producer; + + public SingleItemCachingStrategy(Producer producer) + { + _producer = producer; + } + + #region ICachingStrategy Members + public void Add(K key, V item) + { + if (!typeof(K).IsValueType && null == key) throw new ArgumentNullException("key"); + lock (_monitor) + { + _lastKey = key; + _lastItem = item; + } + } + + public V Get(K key) + { + if (null == key) throw new ArgumentNullException("key"); + lock (_monitor) + { + if (!key.Equals(_lastKey)) + { + Add(key, _producer(key)); + } + + return _lastItem; + } + } + #endregion + } + + public class NullCachingStrategy : ICachingStrategy + { + public static readonly ICachingStrategy Default = new NullCachingStrategy(); + + #region ICachingStrategy Members + public void Add(object key, object item) + { + } + + public object Get(object key) + { + return null; + } + #endregion + } +} \ No newline at end of file diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o.NativeQueries/native/Db4objects.Db4o.NativeQueries/UnsupportedPredicateException.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o.NativeQueries/native/Db4objects.Db4o.NativeQueries/UnsupportedPredicateException.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o.NativeQueries/native/Db4objects.Db4o.NativeQueries/UnsupportedPredicateException.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o.NativeQueries/native/Db4objects.Db4o.NativeQueries/UnsupportedPredicateException.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,14 @@ +/* Copyright (C) 2006 Versant Inc. http://www.db4o.com */ + +namespace Db4objects.Db4o.NativeQueries +{ + using System; + + public class UnsupportedPredicateException : Exception + { + public UnsupportedPredicateException(string reason) + : base(reason) + { + } + } +} diff -Nru smuxi-0.8/lib/db4o-net/Db4objects.Db4o.NativeQueries/Properties/AssemblyInfo.cs smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o.NativeQueries/Properties/AssemblyInfo.cs --- smuxi-0.8/lib/db4o-net/Db4objects.Db4o.NativeQueries/Properties/AssemblyInfo.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/db4o-net/Db4objects.Db4o.NativeQueries/Properties/AssemblyInfo.cs 2012-01-03 07:52:06.000000000 +0000 @@ -0,0 +1,24 @@ +/* Copyright (C) 2009 Versant Inc. http://www.db4o.com */ + +using System.Reflection; +using System.Runtime.InteropServices; +using System.Security; + +[assembly: AssemblyTitle("db4o - native query handling")] +[assembly: AssemblyCompany("Versant Corp., Redwood City, CA, USA")] +[assembly: AssemblyProduct("db4o - database for objects")] +[assembly: AssemblyCopyright("Versant Corp. 2000 - 2011")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// attributes are automatically set by the build +[assembly: AssemblyVersion("8.0.183.14430")] +[assembly: AssemblyKeyFile("")] +[assembly: AssemblyConfiguration(".NET")] +[assembly: AssemblyDescription("Db4objects.Db4o.NativeQueries 8.0.183.14430 (.NET)")] + +#if !CF +[assembly: AllowPartiallyTrustedCallers] +#endif + +[assembly: ComVisible(false)] diff -Nru smuxi-0.8/lib/jabber-net/2005-jabber-net.csproj smuxi-0.8.9.1/lib/jabber-net/2005-jabber-net.csproj --- smuxi-0.8/lib/jabber-net/2005-jabber-net.csproj 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/jabber-net/2005-jabber-net.csproj 2012-01-03 07:52:11.000000000 +0000 @@ -0,0 +1,481 @@ + + + Local + 8.0.50727 + 2.0 + {6CAE854A-F202-4D2B-B10E-E8D8E81E5EF5} + Debug + AnyCPU + + + + + jabber-net + jabbernet.key + JScript + Grid + IE50 + false + Library + + + OnBuildSuccess + + + + + + + true + v3.5 + + + bin5\Debug\ + obj5\ + obj5\Debug\ + false + 285212672 + false + + + TRACE;DEBUG;NET20 NO_SRV + TRACE;DEBUG;NO_SRV + 2005-jabber-net.xml + true + 4096 + false + + + false + false + false + false + 4 + full + prompt + + + bin5\Release\ + obj5\ + obj5\Debug\ + false + 285212672 + false + + + TRACE;NET20 NO_SRV + TRACE;NO_SRV + 2005-jabber-net.xml + false + 4096 + false + + + true + false + false + false + 4 + none + prompt + + + + System + + + + + + System.XML + + + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + + Code + + + Code + + + Code + + + Code + + + Code + + + Component + + + + Code + + + + Code + + + Code + + + Code + + + + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + + + Code + + + Code + + + Component + + + Code + + + + Component + + + Form + + + Component + + + Component + + + Component + + + Component + + + Component + + + + + Code + + + + Component + + + + + Code + + + Code + + + Code + + + Component + + + Component + + + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + + Code + + + Code + + + + Code + + + Code + + + Code + + + Code + + + Code + + + + + Code + + + + + + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + + Code + + + Code + + + Code + + + + Code + + + Code + + + Code + + + Code + + + Code + + + + Code + + + Code + + + Code + + + Code + + + Component + + + Code + + + + + + + + + + + + + + + + + + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + + JabberClient.cs + + + + + RosterManager.cs + + + XmppStream.cs + Designer + + + + JabberService.cs + + + + + + + + + + + + + + + + + Designer + CertificatePrompt.cs + + + + + + {40AC7A7C-D3E5-46DF-B740-06BD9D2A00E1} + netlib.Dns + + + + + + + + + + + + false + + diff -Nru smuxi-0.8/lib/jabber-net/AssemblyInfo.cs smuxi-0.8.9.1/lib/jabber-net/AssemblyInfo.cs --- smuxi-0.8/lib/jabber-net/AssemblyInfo.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/jabber-net/AssemblyInfo.cs 2012-01-03 07:52:11.000000000 +0000 @@ -0,0 +1,24 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:2.0.50727.1433 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +using System; +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +[assembly: AssemblyTitle("Jabber-Net library")] +[assembly: AssemblyDescription("Connect to Jabber (http://www.jabber.org/) from .Net")] +[assembly: AssemblyCompany("Cursive Systems, Inc.")] +[assembly: AssemblyProduct("jabber-net")] +[assembly: AssemblyCopyright("Copyright (c) Cursive, Inc. 2000-2008")] +[assembly: AssemblyVersion("2.0.0.613")] +[assembly: AssemblyDelaySign(false)] +[assembly: CLSCompliant(true)] + diff -Nru smuxi-0.8/lib/jabber-net/bedrock/collections/ByteStack.cs smuxi-0.8.9.1/lib/jabber-net/bedrock/collections/ByteStack.cs --- smuxi-0.8/lib/jabber-net/bedrock/collections/ByteStack.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/jabber-net/bedrock/collections/ByteStack.cs 2012-01-03 07:52:11.000000000 +0000 @@ -0,0 +1,160 @@ +/* -------------------------------------------------------------------------- + * Copyrights + * + * Portions created by or assigned to Cursive Systems, Inc. are + * Copyright (c) 2002-2008 Cursive Systems, Inc. All Rights Reserved. Contact + * information for Cursive Systems, Inc. is available at + * http://www.cursive.net/. + * + * License + * + * Jabber-Net is licensed under the LGPL. + * See LICENSE.txt for details. + * --------------------------------------------------------------------------*/ +using System; + +using bedrock.util; +namespace bedrock.collections +{ + /// + /// A type-safe stack for bytes, implemented as a growable + /// buffer. + /// + [SVN(@"$Id$")] + public class ByteStack + { + private const double GROWTH_FACTOR = 1.5d; + private const int DEFAULT_SIZE = 16; + private const int MIN_SIZE = 2; + private static readonly System.Text.Encoding ENCODING = System.Text.Encoding.Default; + private int m_count = 0; + private int m_capacity = 0; + private byte[] m_buffer; + /// + /// Creates an instance with the default initial capacity. + /// + public ByteStack() : this(DEFAULT_SIZE) + { + } + /// + /// Create an instance with the given initial capacity. + /// + /// The initial capacity + public ByteStack(int initialSize) + { + if (initialSize < MIN_SIZE) + { + initialSize = DEFAULT_SIZE; + } + m_capacity = initialSize; + m_buffer = new byte[m_capacity]; + } + /// + /// Create an instance with the given initial value. The initial size + /// will be grown from the size of the given bytes. A copy is made of + /// the given bytes. + /// + /// byte array copied into this ByteStack + public ByteStack(byte[] start) + { + m_count = m_capacity = start.Length; + m_buffer = start; + IncreaseSize(); + } + /// + /// Increase the size of the stack by GROWTH_FACTOR times. + /// + private void IncreaseSize() + { + m_capacity = (int) (m_capacity * GROWTH_FACTOR); + // if the size is 1, we'll never get bigger. + if (m_capacity < MIN_SIZE) + { + m_capacity = DEFAULT_SIZE; + } + byte[] newBuf = new byte[m_capacity]; + Buffer.BlockCopy(m_buffer, 0, newBuf, 0, m_count); + m_buffer = newBuf; + } + /// + /// Gets the number of bytes that are currently in the stack. + /// + public int Count + { + get + { + return m_count; + } + } + /// + /// Gets the number of bytes that the stack can hold. + /// + public int Capacity + { + get + { + return m_capacity; + } + } + /// + /// Push a byte onto the stack. + /// + /// + public void Push(byte b) + { + if (m_count >= m_capacity) + { + IncreaseSize(); + } + m_buffer[m_count] = b; + m_count++; + } + /// + /// Pop a byte off of the stack. + /// + public byte Pop() + { + if (m_count <= 0) + { + throw new InvalidOperationException("Empty stack"); + } + m_count--; + byte b = m_buffer[m_count]; + return b; + } + /// + /// Non-destructively read the byte on the top of the stack. + /// + public byte Peek() + { + if (m_count <= 0) + { + throw new InvalidOperationException("Empty stack"); + } + return m_buffer[m_count - 1]; + } + /// + /// Converts to byte[] by making a trimmed copy. + /// + /// The ByteStack to convert to a byte array. + /// The byte array containing a copy of the passed in ByteStack. + public static implicit operator byte[](ByteStack bs) + { + if (bs.m_count == 0) + { + return new byte[0]; + } + byte[] newBuf = new byte[bs.m_count]; + Buffer.BlockCopy(bs.m_buffer, 0, newBuf, 0, bs.m_count); + return newBuf; + } + /// + /// Convert to a string, using the default encoding. This is probably not + /// right, but it's really nice for debugging and testing. + /// + public override string ToString() + { + return ENCODING.GetString(m_buffer, 0, m_count); + } + } +} diff -Nru smuxi-0.8/lib/jabber-net/bedrock/collections/GraphNode.cs smuxi-0.8.9.1/lib/jabber-net/bedrock/collections/GraphNode.cs --- smuxi-0.8/lib/jabber-net/bedrock/collections/GraphNode.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/jabber-net/bedrock/collections/GraphNode.cs 2012-01-03 07:52:11.000000000 +0000 @@ -0,0 +1,150 @@ +/* -------------------------------------------------------------------------- + * Copyrights + * + * Portions created by or assigned to Cursive Systems, Inc. are + * Copyright (c) 2002-2008 Cursive Systems, Inc. All Rights Reserved. Contact + * information for Cursive Systems, Inc. is available at + * http://www.cursive.net/. + * + * License + * + * Jabber-Net is licensed under the LGPL. + * See LICENSE.txt for details. + * --------------------------------------------------------------------------*/ +using System; + +using System.Collections; +using bedrock.util; +namespace bedrock.collections +{ + /// + /// A node in a Graph, such as a Tree + /// + [SVN(@"$Id$")] + public class GraphNode : IEnumerable + { + private object m_key = null; + private object m_data = null; + private GraphNode m_parent = null; + private IDictionary m_children = null; + private bool m_sorted = true; + /// + /// Creates a new node, with key and data. + /// + /// The key used to retrieve the data + /// The data in the node + public GraphNode(object key, object data) : this(key, data, true) + { + } + /// + /// Creates a new node, with key and data, possibly having + /// sorted children. + /// + /// The key used to retrieve the data + /// The data in the node + /// Should the children be sorted? + public GraphNode(object key, object data, bool sorted) + { + m_key = key; + m_data = data; + m_sorted = sorted; + if (m_sorted) + { + m_children = new SortedList(); + } + else + { + m_children = new Hashtable(); + } + } + + /// + /// The key for this node. + /// + public object Key + { + get { return m_key; } + } + + /// + /// The data associated with this node. + /// + public object Data + { + get { return m_data; } + set { m_data = value; } + } + + /// + /// Adds a new child node + /// + /// The key for the child + /// The data for the child + /// The child node added to the graph. + public GraphNode Add(object key, object data) + { + GraphNode n = new GraphNode(key, data, m_sorted); + n.m_parent = this; + m_children.Add(key, n); + return n; + } + /// + /// Retrieves a child node, based on the key. + /// + public object this[object key] + { + get + { + return ((GraphNode)m_children[key]).m_data; + } + } + /// + /// Determines whether this is a root node. + /// + public bool IsRoot + { + get + { + return m_parent == null; + } + } + #region IEnumerable + + /// + /// Iterate over the child nodes + /// + /// + public IEnumerator GetEnumerator() + { + return new GraphNodeEnumerator(this); + } + + private class GraphNodeEnumerator : IEnumerator + { + private IEnumerator m_arrayEnumerator; + public GraphNodeEnumerator(GraphNode n) + { + m_arrayEnumerator = n.m_children.GetEnumerator(); + } + + public object Current + { + get + { + return ((GraphNode)m_arrayEnumerator.Current).m_data; + } + } + + public bool MoveNext() + { + return m_arrayEnumerator.MoveNext(); + } + + public void Reset() + { + m_arrayEnumerator.Reset(); + } + } + #endregion + } +} diff -Nru smuxi-0.8/lib/jabber-net/bedrock/collections/IndexedTrie.cs smuxi-0.8.9.1/lib/jabber-net/bedrock/collections/IndexedTrie.cs --- smuxi-0.8/lib/jabber-net/bedrock/collections/IndexedTrie.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/jabber-net/bedrock/collections/IndexedTrie.cs 2012-01-03 07:52:11.000000000 +0000 @@ -0,0 +1,146 @@ +/* -------------------------------------------------------------------------- + * Copyrights + * + * Portions created by or assigned to Cursive Systems, Inc. are + * Copyright (c) 2002-2008 Cursive Systems, Inc. All Rights Reserved. Contact + * information for Cursive Systems, Inc. is available at + * http://www.cursive.net/. + * + * License + * + * Jabber-Net is licensed under the LGPL. + * See LICENSE.txt for details. + * --------------------------------------------------------------------------*/ +using System; + +using System.Collections; +using bedrock.util; +namespace bedrock.collections +{ + /// + /// A Trie that is searchable for substrings. Uses a separate set of indexes + /// to allow entry into the Trie at any point. Yes, this + /// + [SVN(@"$Id$")] + public class IndexedTrie : Trie + { + private Tree m_indexes = new Tree(); + private int m_maxResults = 100; + + /// + /// Creates the indexed trie. + /// + public IndexedTrie() {} + + /// + /// Creates the indexed trie and sets the maximum number of query results returned. + /// + /// Maximum number of query results returned. + public IndexedTrie(int maxResults) + { + m_maxResults = maxResults; + } + + /// + /// The maximum number of results to return from any query. This is an approximate number. + /// + public int MaxResults + { + get + { + return m_maxResults; + } + set + { + m_maxResults = value; + } + } + /// + /// Finds the index for the given byte. + /// + protected ArrayList this[byte b] + { + get + { + return (ArrayList) m_indexes[b]; + } + } + /// + /// Traverse the trie, computing indexes. + /// + /// + /// + private bool IndexWalker(TrieNode n, object data) + { + if (n.Parent != null) + { + this[n.Byte].Add(new WeakReference(n)); + } + return true; + } + /// + /// Computes the index. + /// + public void Index() + { + Traverse(new TrieWalker(IndexWalker), null); + foreach (ArrayList al in m_indexes) + { + al.TrimToSize(); + } + } + /// + /// Copy the keys from the sub-tree into an ArrayList. + /// + /// + /// + /// + private bool CopyWalker(TrieNode n, object data, ByteStack key) + { + if (n.Value != null) + { + ArrayList al = (ArrayList) data; + al.Add((byte[]) key); + if (al.Count >= m_maxResults) + { + return false; + } + } + return true; + } + /// + /// Return a list of keys that contain the given substring. + /// + /// The substring to search for. + public ArrayList SubString(byte[] lookFor) + { + ArrayList starts = (ArrayList) m_indexes[lookFor[0]]; + ArrayList finds = new ArrayList(); + byte[] nBuf = new byte[lookFor.Length - 1]; + Buffer.BlockCopy(lookFor, 1, nBuf, 0, lookFor.Length - 1); + TrieKeyWalker w = new TrieKeyWalker(CopyWalker); + foreach (WeakReference wref in starts) + { + if (finds.Count >= m_maxResults) + { + break; + } + TrieNode first = (TrieNode) wref.Target; + if (first == null) + { + // node got removed out from underneath. + starts.Remove(wref); + } + else + { + TrieNode last = FindNode(nBuf, first, false); + if (last != null) + { + Traverse(w, finds, last, new ByteStack(last.Key)); + } + } + } + return finds; + } + } +} diff -Nru smuxi-0.8/lib/jabber-net/bedrock/collections/ISet.cs smuxi-0.8.9.1/lib/jabber-net/bedrock/collections/ISet.cs --- smuxi-0.8/lib/jabber-net/bedrock/collections/ISet.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/jabber-net/bedrock/collections/ISet.cs 2012-01-03 07:52:11.000000000 +0000 @@ -0,0 +1,66 @@ +/* -------------------------------------------------------------------------- + * Copyrights + * + * Portions created by or assigned to Cursive Systems, Inc. are + * Copyright (c) 2002-2008 Cursive Systems, Inc. All Rights Reserved. Contact + * information for Cursive Systems, Inc. is available at + * http://www.cursive.net/. + * + * License + * + * Jabber-Net is licensed under the LGPL. + * See LICENSE.txt for details. + * --------------------------------------------------------------------------*/ +using System; + +using System.Collections; +using bedrock.util; + +namespace bedrock.collections +{ + /// + /// Set operations. + /// + [SVN(@"$Id$")] + public interface ISet : ICollection + { + /// + /// Add an object to the set + /// + /// The object to add + /// object was already in the set. + void Add(object o); + + /// + /// Remove the given object from the set. If the object is not in the set, this is a no-op. + /// + /// The object to remove. + void Remove(object o); + + /// + /// Removes all items from the set. + /// + void Clear(); + + /// + /// Is the given object in the set? + /// + /// The object to search for. + /// True if the object is in the set. + bool Contains(object o); + + /// + /// Returns a new collection that contains all of the items that + /// are in this set or the other set. + /// + /// Second set to combine with this one. + /// Combined set. + ISet Union(ISet other); + + /// + /// Return a new collection that contains all of the items that + /// are in this list *and* the other set. + /// + ISet Intersection(ISet other); + } +} diff -Nru smuxi-0.8/lib/jabber-net/bedrock/collections/LinkedList.cs smuxi-0.8.9.1/lib/jabber-net/bedrock/collections/LinkedList.cs --- smuxi-0.8/lib/jabber-net/bedrock/collections/LinkedList.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/jabber-net/bedrock/collections/LinkedList.cs 2012-01-03 07:52:11.000000000 +0000 @@ -0,0 +1,565 @@ +/* -------------------------------------------------------------------------- + * Copyrights + * + * Portions created by or assigned to Cursive Systems, Inc. are + * Copyright (c) 2002-2008 Cursive Systems, Inc. All Rights Reserved. Contact + * information for Cursive Systems, Inc. is available at + * http://www.cursive.net/. + * + * License + * + * Jabber-Net is licensed under the LGPL. + * See LICENSE.txt for details. + * --------------------------------------------------------------------------*/ +using System; + +using System.Collections; +using bedrock.util; +namespace bedrock.collections +{ + /// + /// A doubly-linked list implementation, with a sentinal wrap-around + /// m_header. Yes, it does seem like this should have been included + /// in System.Collections. This may be a nicer implementation of Queue + /// than the one in System.Collections, which uses an array. YMMV. + /// + [SVN(@"$Id$")] + public class LinkedList : IList + { + private Node m_header = new Node(null, null, null); + private int m_size = 0; + private int m_modCount = 0; + private IComparer m_comparator = null; + private bool m_readOnly = false; + private bool m_synch = false; + /// + /// Creates an empty list. + /// + public LinkedList() + { + m_header.next = m_header.previous = m_header; + } + /// + /// Create a list with the targets of the given + /// enumeration copied into it. + /// + /// + public LinkedList(IEnumerable e) : this() + { + foreach (object o in e) + { + Add(o); + } + } + #region IEnumerable + /// + /// Iterate over the list. + /// + /// + public IEnumerator GetEnumerator() + { + return new ListEnumerator(this); + } + #endregion + #region ICollection + /// + /// How many elements in the list? + /// + public int Count + { + get + { + return m_size; + } + } + + /// + /// Determines if the list is read-only (Can the user add or remove an item from this list). + /// + public bool IsReadOnly + { + get + { + return m_readOnly; + } + set + { + m_readOnly = value; + } + } + + /// + /// Is the list thread-safe? + /// TODO: implement thread-safe + /// + public bool IsSynchronized + { + get + { + return m_synch; + } + set + { + m_synch = value; + } + } + + /// + /// The object to synchronize on. + /// TODO: implement settable SyncRoot + /// + public object SyncRoot + { + get + { + return this; + } + } + + /// + /// Copy this list to the given array. + /// + /// Array to copy into + /// Index to start copying at + public void CopyTo(Array array, int index) + { + int i = index; + foreach (object o in this) + { + array.SetValue(o, i++); + } + } + #endregion + #region IList + /// + /// Gets the indexth element by walking the list. + /// + public object this[int index] + { + get + { + return GetNode(index).element; + } + set + { + GetNode(index).element = value; + } + } + + /// + /// Insert an element at the end of the list + /// + /// + /// + public int Add(object value) + { + AddBefore(value, m_header); + return m_size-1; + } + + /// + /// Remove all of the elements. + /// + public void Clear() + { + m_modCount++; + m_header.next = m_header.previous = m_header; + m_size = 0; + } + + /// + /// Is the given object in the list? + /// + /// The object to find + /// True if the object is in the list + public bool Contains(object value) + { + return IndexOf(value) != -1; + } + + /// + /// Determines where in the index the specified object exists. + /// + /// The object to find + /// The position of the object in the list, or -1 if not found + public int IndexOf(object value) + { + int index = 0; + if (value == null) + { + for (Node e = m_header.next; e != m_header; e = e.next) + { + if (e.element == null) + return index; + index++; + } + } + else + { + for (Node e = m_header.next; e != m_header; e = e.next) + { + if (value.Equals(e.element)) + return index; + index++; + } + } + return -1; + } + + /// + /// Inserts an item into the list at the given index. + /// + /// The position to insert before + /// The object to insert + public void Insert(int index, object value) + { + if (index >= m_size) + { + AddBefore(value, m_header); + } + else + { + Node n = GetNode(index); + AddBefore(value, n); + } + } + + /// + /// Always returns "false" for now. + /// TODO: implement fixed size + /// + public bool IsFixedSize + { + get { return false; } + } + + /// + /// Finds the first matching object, and removes it from the list. + /// + /// The object to remove + /// Object not found + public void Remove(object value) + { + if (value == null) + { + for (Node e = m_header.next; e != m_header; e = e.next) + { + if (e.element == null) + { + Remove(e); + return; + } + } + } + else + { + for (Node e = m_header.next; e != m_header; e = e.next) + { + if (value.Equals(e.element)) + { + Remove(e); + return; + } + } + } + throw new ArgumentException("Object not found", "value"); + } + + /// + /// Removes the indexth element from the list. + /// + /// The index of the element to delete + public void RemoveAt(int index) + { + Node e = GetNode(index); + Remove(e); + } + #endregion + + #region Queue + /// + /// Inserts an element at the end of the list. + /// + /// Element to insert. + public void Enqueue(object value) + { + AddBefore(value, m_header); + } + + /// + /// Remove and return the element at the front of the list + /// + /// The element at the end of the list + public object Dequeue() + { + object value = m_header.next.element; + Remove(m_header.next); + return value; + } + + /// + /// Retrieve the element at the front of the list, without removing it. + /// + /// + public object Peek() + { + return m_header.next.element; + } + #endregion + #region Stack + /// + /// Add an element to the front of the list. + /// + /// + public void Push(object value) + { + AddBefore(value, m_header.next); + } + + /// + /// Retrieve and remove the element at the front of the list. + /// + /// + public object Pop() + { + return Dequeue(); + } + #endregion Stack + #region private + private Node GetNode(int index) + { + if ((index < 0) || (index >= m_size)) + { + throw new IndexOutOfRangeException("Must choose index between 0 and " + + (m_size-1)); + } + + Node e = m_header; + // start from end if closer + if (index < m_size/2) + { + for (int i = 0; i <= index; i++) + e = e.next; + } + else + { + for (int i = m_size; i > index; i--) + e = e.previous; + } + return e; + } + + private Node AddBefore(object value, Node n) + { + if (m_readOnly) + { + throw new InvalidOperationException("Cannot add to a read-only list"); + } + + if (m_synch) + { + lock (this) + { + return UncheckedAdd(value, n); + } + } + else + { + return UncheckedAdd(value, n); + } + } + + private Node UncheckedAdd(object value, Node n) + { + Node newNode = new Node(value, n, n.previous); + newNode.previous.next = newNode; + newNode.next.previous = newNode; + m_size++; + m_modCount++; + return newNode; + } + + private void Remove(Node n) + { + if (n == m_header) + throw new InvalidOperationException("Deleting from an empty list"); + if (m_readOnly) + { + throw new InvalidOperationException("Cannot remove from a read-only list"); + } + + if (m_synch) + { + lock (this) + { + UncheckedRemove(n); + } + } + else + { + UncheckedRemove(n); + } + } + + private void UncheckedRemove(Node n) + { + n.previous.next = n.next; + n.next.previous = n.previous; + m_size--; + m_modCount++; + } + #endregion + #region Object + /// + /// Comma-separated list of element.ToString()'s. + /// + /// + public override string ToString() + { + System.Text.StringBuilder sb = new System.Text.StringBuilder(); + bool first = true; + foreach (object o in this) + { + if (!first) + { + sb.Append(", "); + } + else + { + first = false; + } + + if (o == null) + sb.Append("null"); + else + sb.Append(o.ToString()); + } + return sb.ToString(); + } + #endregion + #region newstuff + /// + /// Insert in order. + /// + /// Value to insert. + /// The position of the insertion point. + public int Insert(object value) + { + if (m_comparator == null) + { + m_comparator = Comparer.Default; + } + + // null less than anything + if (value == null) + { + AddBefore(null, m_header.next); + return 0; + } + + int index=0; + int c; + for (Node n = m_header.next; n != m_header; n = n.next, index++) + { + c = m_comparator.Compare(value, n.element); + if (c < 0) + { + AddBefore(value, n); + return index; + } + else if (c == 0) // equal. replace + { + n.element = value; + return index; + } + } + + // got to the end without inserting. Put it on the end. + AddBefore(value, m_header); + return m_size-1; + } + + /// + /// The object to use for comparisons. + /// + public IComparer Comparator + { + get + { + return m_comparator; + } + + set + { + m_comparator = value; + } + } + + /// + /// Returns a read-only linked list from the given enumeration. + /// + /// Collection to be copied over to the read-only list. + /// The new read-only list. + public static LinkedList ReadOnly(IEnumerable e) + { + LinkedList ll = new LinkedList(e); + ll.m_readOnly = true; + return ll; + } + #endregion + #region enumerator + private class ListEnumerator : IEnumerator + { + private LinkedList list = null; + private Node current = null; + private int mods = -1; + + public ListEnumerator(LinkedList ll) + { + list = ll; + current = list.m_header; + mods = list.m_modCount; + } + + public object Current + { + get + { + if (list.m_modCount != mods) + { + throw new InvalidOperationException("Changed list during iterator"); + } + return current.element; + } + } + + public bool MoveNext() + { + current = current.next; + return current != list.m_header; + } + + public void Reset() + { + current = list.m_header; + mods = list.m_modCount; + } + } + #endregion + #region Node + private class Node + { + public object element; + public Node next; + public Node previous; + + public Node(object element, Node next, Node previous) + { + this.element = element; + this.next = next; + this.previous = previous; + } + } + #endregion + } +} diff -Nru smuxi-0.8/lib/jabber-net/bedrock/collections/Set.cs smuxi-0.8.9.1/lib/jabber-net/bedrock/collections/Set.cs --- smuxi-0.8/lib/jabber-net/bedrock/collections/Set.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/jabber-net/bedrock/collections/Set.cs 2012-01-03 07:52:11.000000000 +0000 @@ -0,0 +1,229 @@ +/* -------------------------------------------------------------------------- + * Copyrights + * + * Portions created by or assigned to Cursive Systems, Inc. are + * Copyright (c) 2002-2008 Cursive Systems, Inc. All Rights Reserved. Contact + * information for Cursive Systems, Inc. is available at + * http://www.cursive.net/. + * + * License + * + * Jabber-Net is licensed under the LGPL. + * See LICENSE.txt for details. + * --------------------------------------------------------------------------*/ +using System; + +using System.Collections; +using bedrock.util; + +namespace bedrock.collections +{ + /// + /// The different ways a set can be implemented. + /// + [SVN(@"$Id$")] + public enum SetImplementation + { + /// + /// Hash table. + /// + Hashtable, + /// + /// Red/Black tree. + /// + Tree, + /// + /// Skip List. + /// + SkipList + } + + /// + /// Set backed into a Tree. + /// + [SVN(@"$Id$")] + public class Set : ISet + { + private static readonly object s_nothing = new object(); + + private IDictionary m_dict; + + /// + /// Creates a new, empty Set backed into a hash table. + /// + public Set() + { + m_dict = new Hashtable(); + } + + /// + /// Creates a set with the given back-end implementation. + /// + /// How to implement the set. + public Set(SetImplementation impl) + { + switch (impl) + { + case SetImplementation.Hashtable: + m_dict = new Hashtable(); + break; + case SetImplementation.Tree: + m_dict = new Tree(); + break; + case SetImplementation.SkipList: + m_dict = new SkipList(); + break; + default: + throw new NotImplementedException("Unknown SetImplementation"); + } + } + + #region Implementation of ISet + /// + /// Adds an object to the set. + /// + /// The object to add + /// object was already in the set. + public void Add(object o) + { + if (!m_dict.Contains(o)) + m_dict.Add(o, s_nothing); + } + + /// + /// Removes the given object from the set. + /// There is no exception thrown if the object is not in the set. + /// + /// The object to remove. + public void Remove(object o) + { + m_dict.Remove(o); + } + + /// + /// Removes all items from the set. + /// + public void Clear() + { + m_dict.Clear(); + } + + /// + /// Determines if the given object is in the set. + /// + /// The object to search for. + /// True if the object is in the set. + public bool Contains(object o) + { + return m_dict.Contains(o); + } + + /// + /// Returns a new collection that contains all of the items that + /// are in this set or the other set. + /// + /// Second set to combine. + /// Combined set. + public bedrock.collections.ISet Union(bedrock.collections.ISet other) + { + throw new NotImplementedException(); + } + + /// + /// Returns a new collection that contains all of the items that + /// are in this list *and* the other set. + /// + /// + /// Other set to intersect with. + /// + /// Combined set. + public bedrock.collections.ISet Intersection(bedrock.collections.ISet other) + { + throw new NotImplementedException(); + } + #endregion + + #region Implementation of ICollection + /// + /// Copies the elements of the ICollection to an Array, starting at a particular Array index. + /// + /// The array to copy. + /// The index to start at. + public void CopyTo(System.Array array, int index) + { + int count = index; + foreach (object o in this) + { + array.SetValue(o, count); + count++; + } + } + + /// + /// Gets a value indicating whether access to the ICollection is synchronized (thread-safe). + /// + public bool IsSynchronized + { + get { return m_dict.IsSynchronized; } + } + + /// + /// Gets the number of items in the set. + /// + public int Count + { + get { return m_dict.Count; } + } + + /// + /// Gets an object that can be used to synchronize access to the ICollection. + /// + public object SyncRoot + { + get { return m_dict.SyncRoot; } + } + #endregion + + #region Implementation of IEnumerable + /// + /// Returns an enumerator that iterates through all items in the set. + /// + /// An IEnumerator for the entire set. + public System.Collections.IEnumerator GetEnumerator() + { + return new TreeSetEnumerator(m_dict); + } + #endregion + + private class TreeSetEnumerator : IEnumerator + { + private IEnumerator m_enum; + + public TreeSetEnumerator(IDictionary e) + { + m_enum = e.GetEnumerator(); + } + + #region Implementation of IEnumerator + public void Reset() + { + m_enum.Reset(); + } + + public bool MoveNext() + { + return m_enum.MoveNext(); + } + + public object Current + { + get + { + DictionaryEntry entry = (DictionaryEntry) m_enum.Current; + return entry.Key; + } + } + #endregion + } + } +} diff -Nru smuxi-0.8/lib/jabber-net/bedrock/collections/SkipList.cs smuxi-0.8.9.1/lib/jabber-net/bedrock/collections/SkipList.cs --- smuxi-0.8/lib/jabber-net/bedrock/collections/SkipList.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/jabber-net/bedrock/collections/SkipList.cs 2012-01-03 07:52:11.000000000 +0000 @@ -0,0 +1,519 @@ +/* -------------------------------------------------------------------------- + * Copyrights + * + * Portions created by or assigned to Cursive Systems, Inc. are + * Copyright (c) 2002-2008 Cursive Systems, Inc. All Rights Reserved. Contact + * information for Cursive Systems, Inc. is available at + * http://www.cursive.net/. + * + * License + * + * Jabber-Net is licensed under the LGPL. + * See LICENSE.txt for details. + * --------------------------------------------------------------------------*/ +using System; + +using System.Collections; +using System.Diagnostics; + +using bedrock.util; + +namespace bedrock.collections +{ + /// + /// Summary description for SkipList. + /// + [SVN(@"$Id$")] + public class SkipList : IEnumerable, IDictionary + { + /// + /// The default probability for adding new node levels. + /// .25 provides a good balance of speed and size. + /// .5 will be slightly less variable in run time, + /// and take up more space + /// + private const float DEFAULT_PROBABILITY = 0.25F; + + /// + /// The maximum depth for searching. + /// log(1/p, n), where n is the max number of + /// expected nodes. For the defaults, n = 4096. + /// The list will continue to work for larger lists, + /// but performance will start to degrade toward + /// that of a linear search to further you get + /// above n. + /// TODO: automatically reset max_level when Length + /// goes above n. + /// + private const int DEFAULT_MAX_LEVEL = 6; + + private float m_probability; + private int m_max_level = DEFAULT_MAX_LEVEL; + private SkipListNode m_header; + private Random m_rand = new Random(); + private IComparer m_comparator = System.Collections.Comparer.Default; + private int m_count = 0; + + /// + /// Creates a skiplist with the default probability (0.25). + /// + public SkipList() : this(DEFAULT_PROBABILITY, DEFAULT_MAX_LEVEL) + { + } + + /// + /// Create a skiplist with the default max_level. + /// + /// Probability of adding a new level + public SkipList(float probability) : this(probability, DEFAULT_MAX_LEVEL) + { + } + + /// + /// Create a skiplist. + /// + /// Probability of adding a new level + /// Highest level in the list + public SkipList(float probability, int maxLevel) + { + m_probability = probability; + m_max_level = maxLevel; + m_header = new SkipListNode(1, new Ali(), null); + } + + /// + /// Gets the current number of elements in the list. + /// + public int Count + { + get { return m_count; } + } + + /// + /// Add an item to the list. + /// + /// Key for later retrieval. + /// Must implement IComparable. + /// The value to store + /// Thrown if the same key is added twice + /// Thrown if key is null + public void Add(object key, object val) + { + if (key == null) + throw new ArgumentNullException("key"); + + SkipListNode update = new SkipListNode(m_max_level); + SkipListNode n = m_header; + SkipListNode next; + + for (int i=m_header.Level-1; i>=0; i--) + { + next = n[i]; + while ((next != null) && + (m_comparator.Compare(next.Key, key) < 0)) + { + n = next; + next = n[i]; + } + update[i] = n; + } + if ((n.Level > 0) && + (n[0] != null) && + (m_comparator.Compare(n[0].Key, key) == 0)) + { // already here + //n.Value = val; + throw new ArgumentException("Can't add the same key twice", "key"); + } + else + { // need to insert + int level = RandomLevel(); + int s = m_header.Level; + if (level > s) + { + // this shouldn't happen any more. + //Debug.Assert(false); + m_header.Level = level; + for (int i=s; i + /// Is the given key found in the tree? + /// + /// The key to search for + /// + public bool Contains(object key) + { + return GetNode(key) != null; + } + + /// + /// Looks up the key, and returns the corresponding value, or null if not found. + /// + public object this[object key] + { + get + { + SkipListNode n = GetNode(key); + if (n == null) + return null; + return n.Value; + } + set + { + Add(key, value); + } + } + + /// + /// Remove all of the items from the list. + /// + public void Clear() + { + m_header = new SkipListNode(1, new Ali(), null); + m_count = 0; + } + + /// + /// Removes the item associated with this key from the list. + /// + /// Object that implements IComparable + public void Remove(object key) + { + if (key == null) + throw new ArgumentNullException("key"); + + SkipListNode update = new SkipListNode(m_max_level); + SkipListNode n = m_header; + SkipListNode next; + + for (int i=m_header.Level-1; i>=0; i--) + { + next = n[i]; + while ((next != null) && + (m_comparator.Compare(next.Key, key) < 0)) + { + n = next; + next = n[i]; + } + update[i] = n; + } + if (n.Level == 0) + return; // or assert + + n = n[0]; + if ((n == null) || + (m_comparator.Compare(n.Key, key) != 0)) + { // not found + return; // or assert + } + + for (int i=0; i + /// Returns true if the list will not accept more items than constructed with. + /// + public bool IsFixedSize + { + get + { + return false; + } + } + + /// + /// Returns true if one is unable to add or removed an item from this list. + /// + public bool IsReadOnly + { + get + { + return false; + } + } + + /// + /// Gets all of the keys in the list. + /// + public System.Collections.ICollection Keys + { + get + { + object[] keys = new object[m_count]; + int count = 0; + foreach (DictionaryEntry e in this) + { + keys[count++] = e.Key; + } + return keys; + } + } + + /// + /// Gets all of the values in the list. + /// + public System.Collections.ICollection Values + { + get + { + object[] vals = new object[m_count]; + CopyTo(vals, 0); + return vals; + } + } + + /// + /// Iterate over the list + /// + /// + public IDictionaryEnumerator GetEnumerator() + { + return new SkipListEnumerator(this); + } + + #region IEnumerable + /// + /// Iterate over the list + /// + /// + IEnumerator IEnumerable.GetEnumerator() + { + return new SkipListEnumerator(this); + } + #endregion + + /// + /// Copy the *values* from this list to the given array. + /// It's not clear from the .Net docs wether this should be + /// entries or values, so I chose values. + /// + /// The array to copy into + /// The index to start at + public void CopyTo(System.Array array, int arrayIndex) + { + if (array == null) + throw new ArgumentNullException("array"); + if (array.Rank != 1) + throw new ArgumentException("Array must be single dimensional", "array"); + if (arrayIndex < 0) + throw new ArgumentOutOfRangeException("arrayIndex", "starting index may not be negative"); + if (array.Length - arrayIndex < m_count) + throw new ArgumentException("Array too small", "array"); + + int count = arrayIndex; + foreach (DictionaryEntry e in this) + { + array.SetValue(e.Value, count++); + } + } + + /// + /// Returns false, for now + /// + public bool IsSynchronized + { + get + { + return false; + } + } + + /// + /// Gets an object that can be used to synchronize access to ICollection. + /// + /// Currently this Property is not implemented. + public object SyncRoot + { + get + { + throw new NotImplementedException(); + } + } + + private SkipListNode GetNode(object key) + { + if (key == null) + throw new ArgumentNullException("key"); + + if (m_count == 0) + return null; + + SkipListNode n = m_header; + SkipListNode next; + + for(int i=m_header.Level-1; i>=0; i--) + { + next = n[i]; + while((next != null) && + (m_comparator.Compare(next.Key, key) < 0)) + { + n = next; + next = n[i]; + } + } + + // n should always be level > 0, now. + n = n[0]; + + if( (n != null) && (m_comparator.Compare(n.Key, key) == 0)) + return n; + else + return null; + } + + private int RandomLevel() + { + int level = 1; + while ((level < m_max_level-1) && (m_rand.NextDouble() < m_probability)) + { + level++; + } + + return level; + } + + private class SkipListNode + { + private SkipListNode[] m_next; + private object m_key; + private object m_value; + + public SkipListNode(int level) : this(level, null, null) + { + } + + public SkipListNode(int level, object key, object val) + { + m_next = new SkipListNode[level]; + for (int i=0; i m_next.Length); + SkipListNode[] n = new SkipListNode[value]; + Array.Copy(m_next, 0, n, 0, m_next.Length); + for (int i=m_next.Length; i + /// An object that is the greatest. + /// + private class Ali : IComparable + { + int IComparable.CompareTo(object obj) + { + return 1; + } + } + + private class SkipListEnumerator : IDictionaryEnumerator + { + private SkipList m_list; + private SkipListNode m_node; + + public SkipListEnumerator(SkipList list) + { + m_list = list; + m_node = m_list.m_header; + } + + public bool MoveNext() + { + Debug.Assert(m_node != null); + + m_node = m_node[0]; + return m_node != null; + } + + public void Reset() + { + m_node = m_list.m_header; + } + + public object Current + { + get + { + if (m_node == m_list.m_header) + throw new InvalidOperationException("Call MoveNext, first"); + return Entry; + } + } + + public System.Collections.DictionaryEntry Entry + { + get + { + return new System.Collections.DictionaryEntry(m_node.Key, m_node.Value); + } + } + + public object Key + { + get + { + return m_node.Key; + } + } + + public object Value + { + get + { + return m_node.Value; + } + } + } + } +} diff -Nru smuxi-0.8/lib/jabber-net/bedrock/collections/StringSet.cs smuxi-0.8.9.1/lib/jabber-net/bedrock/collections/StringSet.cs --- smuxi-0.8/lib/jabber-net/bedrock/collections/StringSet.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/jabber-net/bedrock/collections/StringSet.cs 2012-01-03 07:52:11.000000000 +0000 @@ -0,0 +1,440 @@ +/* -------------------------------------------------------------------------- + * Copyrights + * + * Portions created by or assigned to Cursive Systems, Inc. are + * Copyright (c) 2002-2008 Cursive Systems, Inc. All Rights Reserved. Contact + * information for Cursive Systems, Inc. is available at + * http://www.cursive.net/. + * + * License + * + * Jabber-Net is licensed under the LGPL. + * See LICENSE.txt for details. + * --------------------------------------------------------------------------*/ +using System; +using System.Collections; +using System.Collections.Generic; + +using bedrock.util; + +namespace bedrock.collections +{ + /// + /// A set of strings, backed into a BitArray. Any given string that is inserted + /// into any instance of a StringSet increases the size of all StringSets over time. + /// + [SVN(@"$Id$")] + public class StringSet : IEnumerable, IEnumerable, ICloneable + { + private BitArray m_bits = null; + + // List.Add doesn't return an int. + private static ArrayList s_strings = new ArrayList(); + private static Dictionary s_bits = new Dictionary(); + + /// + /// Create a new StringSet, which is empty, but sized for all strings seen so far. + /// + public StringSet() + { + m_bits = new BitArray(s_strings.Count); + } + + /// + /// Create a new set with the contents of another set. + /// + /// + public StringSet(StringSet other) + { + if (other != null) + m_bits = (BitArray)other.m_bits.Clone(); + } + + /// + /// Create a set with one string in it. + /// + /// + public StringSet(string str) : this() + { + if (str != null) + this.Add(str); + } + + /// + /// Create a set containing all of the strings from the specified array. + /// + /// + public StringSet(string[] arr) : this() + { + if (arr != null) + Add(arr); + } + + private static int GetStringValue(string s) + { + int val = -1; + + lock (s_bits) + { + if (!s_bits.TryGetValue(s, out val)) + { + s_bits[s] = val = s_strings.Add(s); + } + } + return val; + } + + /// + /// Add a string to this set. If it is already in the set, this is a no-op. + /// + /// + public void Add(string s) + { + int val = GetStringValue(s); + if (val >= m_bits.Length) + m_bits.Length = s_strings.Count; + m_bits[val] = true; + } + + /// + /// Add all of the strings from the given set to this set. + /// + /// + public void Add(StringSet set) + { + // Lengthen this one to be able to hold everything in the other set, as well. + m_bits.Length = set.m_bits.Length = Math.Max(m_bits.Length, set.m_bits.Length); + m_bits.Or(set.m_bits); + } + + /// + /// Add all of the strings from the given array to this set. + /// + /// + public void Add(string[] arr) + { + foreach (string s in arr) + Add(s); + } + + /// + /// Remove the given string from this set. + /// + /// + public void Remove(string s) + { + int val = GetStringValue(s); + if (val >= m_bits.Length) + return; + m_bits[val] = false; + } + + /// + /// Remove all of the strings from the given set from this set. + /// + /// + public void Remove(StringSet set) + { + m_bits.Length = set.m_bits.Length = Math.Max(m_bits.Length, set.m_bits.Length); + // Not is destructive. Stupid. + BitArray os = (BitArray)set.m_bits.Clone(); + os.Not(); + m_bits.And(os); + } + + /// + /// Clear all of the strings from this set. + /// + public void Clear() + { + m_bits.SetAll(false); + } + + /// + /// Is this string in the set? + /// + /// + /// + public bool Contains(string s) + { + int val = GetStringValue(s); + if (val >= m_bits.Length) + return false; + return m_bits[val]; + } + + /// + /// Gets or sets whether this string is in the set. + /// + /// + /// + public bool this[string s] + { + get { return Contains(s); } + set + { + if (value) + Add(s); + else + Remove(s); + } + } + + /// + /// How many strings are in the set? + /// May be slower than you expect, at the moment. + /// + public int Count + { + get + { + int c = 0; + foreach (bool b in m_bits) + { + if (b) + c++; + } + return c; + } + } + + #region operators + /// + /// Add two StringSets together, returning a new set. + /// + /// + /// + /// + public static StringSet operator +(StringSet one, StringSet two) + { + StringSet n = new StringSet(one); + n.Add(two); + return n; + } + + /// + /// Returns a new set containing the contents of the first set as well as the + /// other string. + /// + /// + /// + /// + public static StringSet operator +(StringSet set, string str) + { + StringSet n = new StringSet(set); + n.Add(str); + return n; + } + + /// + /// Returns a new set containing everything from the first set that isn't in + /// the second set. + /// + /// + /// + /// + public static StringSet operator -(StringSet one, StringSet two) + { + StringSet n = new StringSet(one); + n.Remove(two); + return n; + } + + /// + /// Returns a new set containing everything from the first except the specified + /// string. + /// + /// + /// + /// + public static StringSet operator -(StringSet set, string str) + { + StringSet n = new StringSet(set); + n.Remove(str); + return n; + } + + /// + /// Is this set equal to another one? + /// Warning: this is about 32x slower than it should be. + /// + /// + /// + public override bool Equals(object obj) + { + if ((object)this == obj) + return true; + StringSet set = obj as StringSet; + if (set == null) + return false; + + // BitArray.Equals is useless. + // You'd also like to just compare the internal ints, + // but BitArray is sealed. Thx, MS. + + // it's easiest to just stretch everythin out to the longest. + int max = Math.Max(this.m_bits.Length, set.m_bits.Length); + if (this.m_bits.Length != max) + this.m_bits.Length = max; + if (set.m_bits.Length != max) + set.m_bits.Length = max; + + for (int i = 0; i < max; i++) + { + if (this.m_bits[i] != set.m_bits[i]) + return false; + } + + return true; + } + + /// + /// Hashcode for the current contents of the list. + /// SLOW! + /// + /// + public override int GetHashCode() + { + // Again, if I wrote a BitArray, it's GetHashCode would work, probably by + // adding and rotating the ints. + int hash = 0; + foreach (string s in this) + { + hash ^= s.GetHashCode(); + } + return hash; + } + #endregion + + /// + /// Get all of the strings that are currently in the set. + /// No guarantee of order. + /// + /// + public string[] GetStrings() + { + string[] ret = new string[this.Count]; + int i = 0; + foreach (string s in this) + { + ret[i++] = s; + } + return ret; + } + + /// + /// All of the strings from the set, newline-separated. + /// + /// + public override string ToString() + { + System.IO.StringWriter sw = new System.IO.StringWriter(); + for (int i = 0; i < m_bits.Length; i++) + { + if (m_bits[i]) + sw.WriteLine(s_strings[i]); + } + return sw.ToString(); + } + + #region IEnumerable Members + + /// + /// Enumerate over the strings in the set. + /// + /// + public IEnumerator GetEnumerator() + { + return new StringSetEnumerator(this); + } + + #endregion + + #region IEnumerable Members + + /// + /// Enumerate over the strings in the set. + /// + /// + IEnumerator IEnumerable.GetEnumerator() + { + return new StringSetEnumerator(this); + } + + #endregion + + #region ICloneable Members + + /// + /// Return a copy of this set. + /// + /// + public object Clone() + { + return new StringSet(this); + } + + #endregion + + private class StringSetEnumerator : IEnumerator + { + StringSet m_set; + int m_cur = -1; + + public StringSetEnumerator(StringSet set) + { + m_set = set; + } + + #region IEnumerator Members + + public string Current + { + get + { + if ((m_cur < 0) || (m_cur >= m_set.m_bits.Length)) + throw new InvalidOperationException("Call to current outside of MoveNext"); + return (string)StringSet.s_strings[m_cur]; + } + } + + #endregion + + #region IDisposable Members + + public void Dispose() + { + m_set = null; + } + + #endregion + + #region IEnumerator Members + + object IEnumerator.Current + { + get + { + return this.Current; + } + } + + public bool MoveNext() + { + while (++m_cur < m_set.m_bits.Length) + { + if (m_set.m_bits[m_cur]) + return true; + } + return false; + } + + public void Reset() + { + m_cur = -1; + } + + #endregion + } + } +} diff -Nru smuxi-0.8/lib/jabber-net/bedrock/collections/Tree.cs smuxi-0.8.9.1/lib/jabber-net/bedrock/collections/Tree.cs --- smuxi-0.8/lib/jabber-net/bedrock/collections/Tree.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/jabber-net/bedrock/collections/Tree.cs 2012-01-03 07:52:11.000000000 +0000 @@ -0,0 +1,839 @@ +/* -------------------------------------------------------------------------- + * Copyrights + * + * Portions created by or assigned to Cursive Systems, Inc. are + * Copyright (c) 2002-2008 Cursive Systems, Inc. All Rights Reserved. Contact + * information for Cursive Systems, Inc. is available at + * http://www.cursive.net/. + * + * License + * + * Jabber-Net is licensed under the LGPL. + * See LICENSE.txt for details. + * --------------------------------------------------------------------------*/ +using System; + +using System.Collections; +using bedrock.util; +namespace bedrock.collections +{ + /// + /// A basic balanced tree implementation. + /// + [SVN(@"$Id$")] + public class Tree : IEnumerable, IDictionary + { + private Node root = null; + private int size = 0; + private int modCount = 0; + private IComparer comparator = System.Collections.Comparer.Default; + //private bool readOnly = false; + //private bool synch = false; + /// + /// Construct an empty tree + /// + public Tree() + { + // + // TODO: Add Constructor Logic here + // + } + #region IEnumerable + /// + /// Iterate over the tree + /// + /// + IEnumerator IEnumerable.GetEnumerator() + { + return new TreeEnumerator(this); + } + #endregion + #region ICollection + /// + /// The number of items in the tree. + /// + public int Count + { + get + { + return size; + } + } + + /// + /// Gets a value indicating whether access to the tree is synchronized in thread-safe mode. + /// Currently, it only returns false. + /// + public bool IsSynchronized + { + get + { + return false; + } + } + + /// + /// Copies the values from the tree to the specified array in the order of the keys. + /// + /// The array to copy into + /// The index to start at + public void CopyTo(System.Array array, int index) + { + int i = index; + foreach (DictionaryEntry o in this) + { + array.SetValue(o.Value, i++); + } + } + + /// + /// Gets an object that can be used to sychronize access to the tree. For now, it returns null. + /// + public object SyncRoot + { + get + { + return null; + } + } + + #endregion + #region IDictionary + /// + /// Add an item to the tree + /// + /// The key for the item + /// The data to store with this key + /// Thrown if the same key is added twice + /// Thrown if key is null + public void Add(object key,object value) + { + if (key == null) + throw new ArgumentNullException("key"); + + Node n = root; + + if (n == null) + { + sizeUp(); + root = new Node(key, value, null); + return; + } + + while (true) + { + int cmp = comparator.Compare(key, n.key); + if (cmp == 0) + { + //n.value = value; + //return; + throw new ArgumentException("Can't add the same key twice", "key"); + } + else if (cmp < 0) + { + if (n.left != null) + { + n = n.left; + } + else + { + sizeUp(); + n.left = new Node(key, value, n); + fixAfterInsertion(n.left); + return; + } + } + else // cmp > 0 + { + if (n.right != null) { + n = n.right; + } + else + { + sizeUp(); + n.right = new Node(key, value, n); + fixAfterInsertion(n.right); + return; + } + } + } + + } + + /// + /// Remove all values from the tree. + /// + public void Clear() + { + modCount++; + size = 0; + root = null; + } + + /// + /// Determines if the specified key exists in the tree. + /// + /// The key to search for + /// True if the key exists in the tree; otherwise false. + public bool Contains(object key) + { + return getNode(key) != null; + } + + /// + /// Returns a dictionary enumerator. + /// + /// A dictionary enumerator + public IDictionaryEnumerator GetEnumerator() + { + return new TreeEnumerator(this); + } + + /// + /// Remove the element from the tree associated + /// with this key, possibly rebalancing. + /// + /// + public void Remove(object key) + { + Node n = getNode(key); + if (n == null) + { + return; + } + sizeDown(); + + // If strictly internal, first swap position with successor. + if ((n.left != null) && (n.right != null)) + { + Node s = successor(n); + swapPosition(s, n); + } + + // Start fixup at replacement node, if it exists. + Node replacement = ((n.left != null) ? n.left : n.right); + + if (replacement != null) + { + // Link replacement to parent + replacement.parent = n.parent; + if (n.parent == null) + root = replacement; + else if (n == n.parent.left) + n.parent.left = replacement; + else + n.parent.right = replacement; + + // Null out links so they are OK to use by fixAfterDeletion. + n.left = n.right = n.parent = null; + + // Fix replacement + if (n.color == NodeColor.BLACK) + fixAfterDeletion(replacement); + } + else if (n.parent == null) + { + root = null; + } + else + { + if (n.color == NodeColor.BLACK) + fixAfterDeletion(n); + + if (n.parent != null) + { + if (n == n.parent.left) + n.parent.left = null; + else if (n == n.parent.right) + n.parent.right = null; + n.parent = null; + } + } + } + + /// + /// Retrieves the value associated with the given key. + /// + public object this[object key] + { + get + { + Node n = getNode(key); + if (n == null) + return null; + return n.value; + } + set + { + Add(key, value); + } + } + + /// + /// Retrieve a list of keys. + /// + public ICollection Keys + { + get + { + object[] keys = new object[Count]; + int i=0; + if (root == null) + return keys; + Node n = first(root); + while (n != null) + { + keys[i++] = n.key; + n = successor(n); + } + return keys; + } + } + + /// + /// Retrieves a list of values. + /// + public ICollection Values + { + get + { + object[] vals = new object[Count]; + int i=0; + Node n = first(root); + while (n != null) + { + vals[i++] = n.value; + n = successor(n); + } + return vals; + } + } + + /// + /// Always returns false for now. + /// + public bool IsFixedSize + { + get + { + return false; + } + } + + /// + /// Always returns false for now. + /// + public bool IsReadOnly + { + get + { + return false; + } + } + #endregion + #region Object + /// + /// Retrieves a string representation of the tree. + /// + /// string in the format '{key1}={value1}, {key2}={value2}, ...' + public override string ToString() + { + System.Text.StringBuilder sb = new System.Text.StringBuilder(); + bool f = true; + for (Node n = first(root); n != null; n = successor(n)) + { + if (!f) + { + sb.Append(", "); + } + else + { + f = false; + } + + sb.AppendFormat("{0}={1}", n.key, n.value); + } + return sb.ToString(); + } + + #endregion + /// + /// Retrieve a string representation of the tree. + /// Nice for debugging, but otherwise useless. + /// + /// + public string Structure() + { + return root.ToString(); + } + #region hidden + private static Node first(Node n) + { + if (n != null) + { + while (n.left != null) + n = n.left; + } + return n; + } + + private static Node successor(Node t) + { + if (t == null) + return null; + + if (t.right != null) + { + Node n = t.right; + while (n.left != null) + n = n.left; + return n; + } + + Node p = t.parent; + Node ch = t; + while (p != null && ch == p.right) + { + ch = p; + p = p.parent; + } + return p; + } + + private Node getNode(object key) + { + Node n = root; + while (n != null) + { + int cmp = comparator.Compare(key, n.key); + if (cmp == 0) + return n; + else if (cmp < 0) + n = n.left; + else + n = n.right; + } + return null; + } + + private void swapPosition(Node x, Node y) + { + Node px = x.parent; + Node lx = x.left; + Node rx = x.right; + Node py = y.parent; + Node ly = y.left; + Node ry = y.right; + bool xWasLeftChild = (px != null) && (x == px.left); + bool yWasLeftChild = (py != null) && (y == py.left); + + if (x == py) + { + x.parent = y; + if (yWasLeftChild) + { + y.left = x; + y.right = rx; + } + else + { + y.right = x; + y.left = lx; + } + } + else + { + x.parent = py; + if (py != null) + { + if (yWasLeftChild) + py.left = x; + else + py.right = x; + } + y.left = lx; + y.right = rx; + } + + if (y == px) + { + y.parent = x; + if (xWasLeftChild) + { + x.left = y; + x.right = ry; + } + else + { + x.right = y; + x.left = ly; + } + } + else + { + y.parent = px; + if (px != null) + { + if (xWasLeftChild) + px.left = y; + else + px.right = y; + } + x.left = ly; + x.right = ry; + } + + if (x.left != null) + x.left.parent = x; + if (x.right != null) + x.right.parent = x; + if (y.left != null) + y.left.parent = y; + if (y.right != null) + y.right.parent = y; + + NodeColor c = x.color; + x.color = y.color; + y.color = c; + + if (root == x) + root = y; + else if (root == y) + root = x; + } + + private static NodeColor colorOf(Node n) + { + return (n == null ? NodeColor.BLACK : n.color); + } + + private static Node parentOf(Node n) + { + return (n == null ? null: n.parent); + } + + private static void setColor(Node n, NodeColor c) + { + if (n != null) + n.color = c; + } + + private static Node leftOf(Node n) + { + return (n == null)? null: n.left; + } + + private static Node rightOf(Node n) + { + return (n == null)? null: n.right; + } + + private void rotateLeft(Node n) + { + Node r = n.right; + n.right = r.left; + if (r.left != null) + r.left.parent = n; + r.parent = n.parent; + + if (n.parent == null) + root = r; + else if (n.parent.left == n) + n.parent.left = r; + else + n.parent.right = r; + + r.left = n; + n.parent = r; + } + + private void rotateRight(Node n) + { + Node l = n.left; + n.left = l.right; + if (l.right != null) + l.right.parent = n; + l.parent = n.parent; + + if (n.parent == null) + root = l; + else if (n.parent.right == n) + n.parent.right = l; + else + n.parent.left = l; + + l.right = n; + n.parent = l; + } + + + private void fixAfterInsertion(Node n) + { + n.color = NodeColor.RED; + + while ((n != null) && + (n != root) && + (n.parent.color == NodeColor.RED)) + { + if (parentOf(n) == leftOf(parentOf(parentOf(n)))) + { + Node y = rightOf(parentOf(parentOf(n))); + if (colorOf(y) == NodeColor.RED) + { + setColor(parentOf(n), NodeColor.BLACK); + setColor(y, NodeColor.BLACK); + setColor(parentOf(parentOf(n)), NodeColor.RED); + n = parentOf(parentOf(n)); + } + else + { + if (n == rightOf(parentOf(n))) + { + n = parentOf(n); + rotateLeft(n); + } + + setColor(parentOf(n), NodeColor.BLACK); + setColor(parentOf(parentOf(n)), NodeColor.RED); + if (parentOf(parentOf(n)) != null) + rotateRight(parentOf(parentOf(n))); + } + } + else + { + Node y = leftOf(parentOf(parentOf(n))); + if (colorOf(y) == NodeColor.RED) + { + setColor(parentOf(n), NodeColor.BLACK); + setColor(y, NodeColor.BLACK); + setColor(parentOf(parentOf(n)), NodeColor.RED); + n = parentOf(parentOf(n)); + } + else + { + if (n == leftOf(parentOf(n))) + { + n = parentOf(n); + rotateRight(n); + } + setColor(parentOf(n), NodeColor.BLACK); + setColor(parentOf(parentOf(n)), NodeColor.RED); + if (parentOf(parentOf(n)) != null) + rotateLeft(parentOf(parentOf(n))); + } + } + } + root.color = NodeColor.BLACK; + } + + private void fixAfterDeletion(Node x) + { + while ((x != root) && (colorOf(x) == NodeColor.BLACK)) + { + if (x == leftOf(parentOf(x))) + { + Node sib = rightOf(parentOf(x)); + + if (colorOf(sib) == NodeColor.RED) + { + setColor(sib, NodeColor.BLACK); + setColor(parentOf(x), NodeColor.RED); + rotateLeft(parentOf(x)); + sib = rightOf(parentOf(x)); + } + + if ((colorOf(leftOf(sib)) == NodeColor.BLACK) && + (colorOf(rightOf(sib)) == NodeColor.BLACK)) + { + setColor(sib, NodeColor.RED); + x = parentOf(x); + } + else + { + if (colorOf(rightOf(sib)) == NodeColor.BLACK) + { + setColor(leftOf(sib), NodeColor.BLACK); + setColor(sib, NodeColor.RED); + rotateRight(sib); + sib = rightOf(parentOf(x)); + } + setColor(sib, colorOf(parentOf(x))); + setColor(parentOf(x), NodeColor.BLACK); + setColor(rightOf(sib), NodeColor.BLACK); + rotateLeft(parentOf(x)); + x = root; + } + } + else + { + Node sib = leftOf(parentOf(x)); + + if (colorOf(sib) == NodeColor.RED) + { + setColor(sib, NodeColor.BLACK); + setColor(parentOf(x), NodeColor.RED); + rotateRight(parentOf(x)); + sib = leftOf(parentOf(x)); + } + + if (colorOf(rightOf(sib)) == NodeColor.BLACK && + colorOf(leftOf(sib)) == NodeColor.BLACK) + { + setColor(sib, NodeColor.RED); + x = parentOf(x); + } + else + { + if (colorOf(leftOf(sib)) == NodeColor.BLACK) { + setColor(rightOf(sib), NodeColor.BLACK); + setColor(sib, NodeColor.RED); + rotateLeft(sib); + sib = leftOf(parentOf(x)); + } + setColor(sib, colorOf(parentOf(x))); + setColor(parentOf(x), NodeColor.BLACK); + setColor(leftOf(sib), NodeColor.BLACK); + rotateRight(parentOf(x)); + x = root; + } + } + } + + setColor(x, NodeColor.BLACK); + } + + private void sizeUp() { modCount++; size++; } + private void sizeDown() { modCount++; size--; } + #endregion + #region node + private enum NodeColor : byte + { + RED, + BLACK + } + + private class Node + { + public object key; + public object value; + public Node left = null; + public Node right = null; + public Node parent; + public NodeColor color = NodeColor.BLACK; + + public Node(object key, object value, Node parent) + { + this.key = key; + this.value = value; + this.parent = parent; + } + + public override bool Equals(object o) + { + Node n = o as Node; + if (n == null) + { + return false; + } + return (key == n.key) && (value == n.value); + } + + public override int GetHashCode() + { + return key.GetHashCode(); + } + + public override string ToString() + { + //return key + "=" + value + " (" + color + ")"; + if ((left==null) && (right==null)) + { + return key.ToString(); + } + return key + " (" + + ((left == null) ? "null" : left.ToString()) + "," + + ((right == null) ? "null" : right.ToString()) + ")"; + } + + } + #endregion + #region enumerator + private class TreeEnumerator : IDictionaryEnumerator + { + private Tree tree = null; + private Node current = null; + private int mods = -1; + + public TreeEnumerator(Tree t) : this(t, t.root) + { + } + + public TreeEnumerator(Tree t, Node n) + { + tree = t; + mods = t.modCount; + + // foreach calls MoveNext before starting. Create a dummy node before the first one. + current = new Node(null, null, null); + current.right = first(n); + } + + public object Current + { + get + { + if (tree.modCount != mods) + { + throw new InvalidOperationException("Changed list during iterator"); + } + return Entry; + } + } + + public bool MoveNext() + { + current = successor(current); + return current != null; + } + + public void Reset() + { + current = first(tree.root); + mods = tree.modCount; + } + + public object Key + { + get + { + if (tree.modCount != mods) + { + throw new InvalidOperationException("Changed list during iterator"); + } + return current.key; + } + } + + public object Value + { + get + { + if (tree.modCount != mods) + { + throw new InvalidOperationException("Changed list during iterator"); + } + return current.value; + } + } + + public DictionaryEntry Entry + { + get + { + return new DictionaryEntry(current.key, current.value); + } + } + } + #endregion + } +} diff -Nru smuxi-0.8/lib/jabber-net/bedrock/collections/Trie.cs smuxi-0.8.9.1/lib/jabber-net/bedrock/collections/Trie.cs --- smuxi-0.8/lib/jabber-net/bedrock/collections/Trie.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/jabber-net/bedrock/collections/Trie.cs 2012-01-03 07:52:11.000000000 +0000 @@ -0,0 +1,466 @@ +/* -------------------------------------------------------------------------- + * Copyrights + * + * Portions created by or assigned to Cursive Systems, Inc. are + * Copyright (c) 2002-2008 Cursive Systems, Inc. All Rights Reserved. Contact + * information for Cursive Systems, Inc. is available at + * http://www.cursive.net/. + * + * License + * + * Jabber-Net is licensed under the LGPL. + * See LICENSE.txt for details. + * --------------------------------------------------------------------------*/ +using System; + +using System.Collections; +using bedrock.util; + +namespace bedrock.collections +{ + /// + /// The method signature used by when it encounters a key. + /// + public delegate bool TrieKeyWalker(TrieNode e, object data, ByteStack key); + /// + /// The method signature used by when it encounters a node. + /// + public delegate bool TrieWalker(TrieNode e, object data); + /// + /// A trie is a tree structure that implements a radix search. Each node of the tree has a + /// sub-node for each possible next byte. + /// + [SVN(@"$Id$")] + public class Trie : IDictionary + { + private static readonly System.Text.Encoding ENCODING = System.Text.Encoding.Default; + + /// + /// The root node of the trie. + /// + private TrieNode m_root = new TrieNode(null, 0); + + /// + /// The number of nodes are in the trie + /// + private int m_count = 0; + + /// + /// Creates an empty trie. + /// + public Trie() {} + + /// + /// Find a node for a given key, somewhere under the root. + /// + /// The bytes to search for, where key[0] corresponds to a child + /// node of the root. + /// Create nodes that don't exist, while searching. + /// The node if found. If the node doesn't exist and create is true, the node created; otherwise null. + protected virtual TrieNode FindNode(byte[] key, bool create) + { + return FindNode(key, m_root, create); + } + /// + /// Finds a node in the given sub-tree. + /// + /// The key to search on, where key[0] corresponds to a child of startAt. + /// The node to search under + /// Create nodes that don't exist, while searching. + /// The node if found. If the node doesn't exist and create is true, the node created; otherwise null. + protected virtual TrieNode FindNode(byte[] key, TrieNode startAt, bool create) + { + TrieNode current = startAt; + byte b; + + for (int i=0; (i + /// Compute the byte array corresping to the given object. + /// This is likely to cause problems for non 7-bit ASCII text. + /// + /// + protected static byte[] KeyBytes(object key) + { + if (key is byte[]) + { + return (byte[]) key; + } + + return ENCODING.GetBytes(key.ToString()); + } + /// + /// Extra functionality for trie's whose values are integers. + /// Increment the value corresponding to the key. If + /// the key doesn't exist, put in a value of '1'. + /// + /// + public virtual void Increment(object key) + { + TrieNode e = FindNode(KeyBytes(key), true); + if (e.Value == null) + { + e.Value = 1; + } + else + { + e.Value = ((int) e.Value) + 1; + } + } + /// + /// Performs the given function on every element of the trie. This is equivalent to Perl's map() operator. + /// + /// The function to call + /// Extra data to pass along to the function. + public void Traverse(TrieKeyWalker w, object data) + { + Traverse(w, data, m_root, new ByteStack()); + } + + /// + /// Perform the given function on every element of the trie. Perl's map() operator. + /// + /// The function to call + /// Extra data to pass along to the function. + /// What node are we currently on? + /// A stack holding the current key value + protected void Traverse(TrieKeyWalker w, object data, TrieNode current, ByteStack key) + { + if (!w(current, data, key)) + { + return; + } + foreach (TrieNode e in current) + { + key.Push(e.Byte); + Traverse(w, data, e, key); + key.Pop(); + } + } + /// + /// Perform the given function on every element of the trie. Perl's map() operator. + /// Don't keep track of the keys (slightly faster than the other Traverse() method). + /// + /// The function to call + /// Extra data to pass along to the function. + public void Traverse(TrieWalker w, object data) + { + Traverse(w, data, m_root); + } + /// + /// Perform the given function on every element of the trie. Perl's map() operator. + /// + /// The function to call + /// Extra data to pass along to the function. + /// What node are we currently on? + protected void Traverse(TrieWalker w, object data, TrieNode current) + { + if (! w(current, data)) + { + return; + } + foreach (TrieNode e in current) + { + Traverse(w, data, e); + } + } + #region System.Collections.IDictionary + + /// + /// Retrieve the value associated with the given key. + /// + public virtual object this[object key] + { + get + { + TrieNode e = FindNode(KeyBytes(key), false); + return (e == null) ? null : e.Value; + } + set + { + TrieNode e = FindNode(KeyBytes(key), true); + e.Value = value; + m_count++; + } + } + + /// + /// Always "false" for now. + /// + public bool IsFixedSize + { + get { return false; } + } + + + /// + /// Find all of the keys. + /// + /// + /// + /// + private bool KeyWalker(TrieNode n, object data, ByteStack key) + { + if (n.Value != null) + { + ArrayList al = (ArrayList) data; + al.Add((byte[]) key); + } + return true; + } + + /// + /// Get a list of all of the keys. Hope this doesn't get called often, since it has to make copies + /// of all of the possible keys. + /// + public ICollection Keys + { + get + { + ArrayList al = new ArrayList(m_count); + Traverse(new TrieKeyWalker(KeyWalker), al); + al.TrimToSize(); + return al; + } + } + + /// + /// Returns a collection containing all of the values. + /// + public ICollection Values + { + get + { + // pretty easy, since we implement ICollection. + return new ArrayList(this); + } + } + + /// + /// Removes the node associated with the given key, along with all newly empty ancestors. + /// + /// Key to remove. + public void Remove(object key) + { + TrieNode current = FindNode(KeyBytes(key), false); + if (current == null) + { + return; + } + + current.Value = null; + m_count--; + + if (m_count == 0) + { + Clear(); + return; + } + + // prune + byte last; + while (current.IsEmpty) + { + last = current.Byte; + current = current.Parent; + if (current == null) + { + // all the way empty. + break; + } + current.Remove(last); + } + } + + /// + /// Iterate the dictionary way. + /// + IDictionaryEnumerator IDictionary.GetEnumerator() + { + return new TrieEnumerator(this); + } + + /// + /// Deletes all nodes. + /// + public void Clear() + { + m_root = new TrieNode(null, 0); + m_count = 0; + } + + /// + /// Add a new key/value pair. + /// + /// + /// + public void Add(object key, object value) + { + this[key] = value; + } + + /// + /// Is the given key in the trie? + /// + /// + public bool Contains(object key) + { + TrieNode current = FindNode(KeyBytes(key), false); + return current != null; + } + + #endregion + #region System.Collections.ICollection + + /// + /// How many values are stored? Note: NOT how many nodes. + /// + public int Count + { + get + { + return m_count; + } + } + + /// + /// Object to synchronize on, if in thread-safe mode. + /// TODO: implement settable SyncRoot + /// + public object SyncRoot + { + get + { + return this; + } + } + + /// + /// Always "false" for now + /// + public bool IsReadOnly + { + get + { + return false; + } + } + + /// + /// Gets a value indicating whether access to the trie is synchronized in thread-safe mode. + /// Only returns false now. + /// + public bool IsSynchronized + { + get + { + return false; + } + } + + /// + /// Copy into an array. + /// + /// + /// + public void CopyTo(Array array, int index) + { + int i = index; + foreach (object o in this) + { + array.SetValue(o, i); + i++; + } + } + + #endregion + #region System.Collections.IEnumerable + + /// + /// Iterate over the keys. Each key will be a byte[]. + /// + public IEnumerator GetEnumerator() + { + return new TrieEnumerator(this); + } + + #endregion + + private class TrieEnumerator : IDictionaryEnumerator + { + protected Trie m_trie; + protected Stack m_pos = new Stack(); + protected TrieNode m_current = null; + public TrieEnumerator(Trie t) + { + m_trie = t; + m_pos.Push(m_trie.m_root); + } + + public object Current + { + get + { + return Entry; + } + } + + public void Reset() + { + m_pos.Clear(); + m_pos.Push(m_trie.m_root); + } + + public bool MoveNext() + { + if (m_pos.Count <= 0) + { + return false; + } + + m_current = (TrieNode) m_pos.Pop(); + + foreach (TrieNode e in m_current) + { + m_pos.Push(e); + } + + if (m_current.Value != null) + { + return true; + } + + return MoveNext(); + } + + public object Key + { + get + { + return m_current.Key; + } + } + + public object Value + { + get + { + return m_current.Value; + } + } + + public DictionaryEntry Entry + { + get + { + return new DictionaryEntry(m_current.Key, m_current.Value); + } + } + } + } +} diff -Nru smuxi-0.8/lib/jabber-net/bedrock/collections/TrieNode.cs smuxi-0.8.9.1/lib/jabber-net/bedrock/collections/TrieNode.cs --- smuxi-0.8/lib/jabber-net/bedrock/collections/TrieNode.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/jabber-net/bedrock/collections/TrieNode.cs 2012-01-03 07:52:11.000000000 +0000 @@ -0,0 +1,267 @@ +/* -------------------------------------------------------------------------- + * Copyrights + * + * Portions created by or assigned to Cursive Systems, Inc. are + * Copyright (c) 2002-2008 Cursive Systems, Inc. All Rights Reserved. Contact + * information for Cursive Systems, Inc. is available at + * http://www.cursive.net/. + * + * License + * + * Jabber-Net is licensed under the LGPL. + * See LICENSE.txt for details. + * --------------------------------------------------------------------------*/ +using System; + +using System.IO; +using System.Collections; +using bedrock.util; +namespace bedrock.collections +{ + /// + /// A node in a Trie. This class is public to support traversal via Trie.Traverse(). + /// + [SVN(@"$Id$")] + public class TrieNode : IEnumerable + { + // Warning: Assumption of 7-bit ASCII encoding! + // TODO: replace with GraphNode + //public const byte MIN_CHAR = (byte) ' '; + //public const byte MAX_CHAR = (byte) '~'; + //public const byte NUM_CHARS = MAX_CHAR - MIN_CHAR + 1; + + //private TrieNode[] m_children = new TrieNode[NUM_CHARS]; + private Tree m_children = new Tree(); + private TrieNode m_parent = null; + private Object m_value = null; + private byte m_key = 0; + + /// + /// Create a new node + /// + /// The parent of the new node + /// The byte for this node + public TrieNode(TrieNode parent, byte key) + { + m_parent = parent; + m_key = key; + } + + /// + /// Adds a child to this node. + /// + /// The key for the child. + /// The child noded added to this node. + public virtual TrieNode Add(byte key) + { + TrieNode e = new TrieNode(this, key); + this[key] = e; + return e; + } + /// + /// Are there children of this node? + /// + public bool IsEmpty + { + get + { + if (m_value != null) + return false; + foreach (object key in m_children) + { + if (m_children[key] != null) + return false; + } + return true; + } + } + + /// + /// Get the parent of this node + /// + public TrieNode Parent + { + get + { + return m_parent; + } + } + /// + /// Gets the byte associated with this node. + /// + public byte Byte + { + get + { + return m_key; + } + } + + /// + /// Retrive the full key for this node, traversing parent-ward toward the root. + /// + public byte[] Key + { + get + { + MemoryStream ms = new MemoryStream(); + TrieNode current = this; + while (current.Parent != null) + { + ms.WriteByte(current.Byte); + current = current.Parent; + } + byte[] buf = ms.ToArray(); + Array.Reverse(buf); + return buf; + } + } + /// + /// The value associated with this node + /// + public Object Value + { + get + { + return m_value; + } + set + { + m_value = value;; + } + } + /// + /// Gets the child associated with the specified byte, or null if one does not exist. + /// + public TrieNode this[byte key] + { + get + { + return (TrieNode) m_children[key]; + } + set + { + m_children[key] = value; + } + } + /// + /// Gets the child associated with the specified byte, or null if one does not exist. + /// If create is true, a node will be added with a null value + /// if a node does not already exist, so that this can be used + /// as an lvalue. + /// + public TrieNode this[byte key, bool create] + { + get + { + TrieNode e = this[key]; + if (e != null) + { + return e; + } + if (create) + { + return Add(key); + } + return null; + } + } + /// + /// Is there a child at the given byte? + /// + /// + /// + public bool HasChild(byte key) + { + return this[key] != null; + } + /// + /// Remove the child at the given byte + /// + /// + public void Remove(byte key) + { + this[key] = null; + } + /// + /// Compares the specified object with this entry for equality. + /// Returns true if the given object is also a map entry and + /// the two entries represent the same mapping. More formally, two + /// entries e1 and e2 represent the same mapping + /// if:
+        ///     (e1.getKey()==null ?
+        ///      e2.getKey()==null : e1.getKey().equals(e2.getKey()))  &&
+        ///     (e1.getValue()==null ?
+        ///      e2.getValue()==null : e1.getValue().equals(e2.getValue()))
+        /// 
+ /// This ensures that the equals method works properly across + /// different implementations of the Map.Entry interface. + ///
+ /// Object to be compared for equality with this map entry. + /// True if the specified object is equal to this map + /// entry; otherwise false. + public override bool Equals(Object o) + { + if (o == null) + return false; + if (o == this) + return true; + + if (! (o is TrieNode)) + return false; + TrieNode e = (TrieNode) o; + + return ((Key == null) ? (e.Key == null) : Key.Equals(e.Key)) && + ((Value == null) ? (e.Value == null) : Value.Equals(e.Value)); + } + /// + /// Returns the hash code value for this map entry. + /// + /// Hash code. + public override int GetHashCode() + { + return ((Key==null) ? 0 : Key.GetHashCode()) ^ + ((Value==null) ? 0 : Value.GetHashCode()); + } + #region Implementation of IEnumerable + /// + /// Iterates over the child nodes. + /// + /// An IEnumerator to parse over the child nodes. + public System.Collections.IEnumerator GetEnumerator() + { + return new TrieNodeEnumerator(this); + } + #endregion + private class TrieNodeEnumerator : IEnumerator + { + private TrieNode m_node; + private IEnumerator m_enum; + public TrieNodeEnumerator(TrieNode n) + { + m_node = n; + Reset(); + } + #region Implementation of IEnumerator + public void Reset() + { + // yeah, I know. but I want to go to bed. + m_enum = m_node.m_children.Values.GetEnumerator(); + } + + public bool MoveNext() + { + return m_enum.MoveNext(); + } + + public object Current + { + get + { + return m_enum.Current; + } + } + #endregion + } + } +} diff -Nru smuxi-0.8/lib/jabber-net/bedrock/Delegates.cs smuxi-0.8.9.1/lib/jabber-net/bedrock/Delegates.cs --- smuxi-0.8/lib/jabber-net/bedrock/Delegates.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/jabber-net/bedrock/Delegates.cs 2012-01-03 07:52:11.000000000 +0000 @@ -0,0 +1,42 @@ +/* -------------------------------------------------------------------------- + * Copyrights + * + * Portions created by or assigned to Cursive Systems, Inc. are + * Copyright (c) 2002-2008 Cursive Systems, Inc. All Rights Reserved. Contact + * information for Cursive Systems, Inc. is available at + * http://www.cursive.net/. + * + * License + * + * Jabber-Net is licensed under the LGPL. + * See LICENSE.txt for details. + * --------------------------------------------------------------------------*/ +using System; + +namespace bedrock +{ + /// + /// Delegate for memebers that just have a sender + /// + public delegate void ObjectHandler(object sender); + + /// + /// Delegate for members that receive a string + /// + public delegate void TextHandler(object sender, string txt); + + /// + /// Delegate for methods that get a block of bytes + /// + public delegate void ByteHandler(object sender, byte[] buf); + + /// + /// Delegate for members that receive partial blocks of bytes. + /// + public delegate void ByteOffsetHandler(object sender, byte[] buf, int offset, int length); + + /// + /// Delegate for members that receive an exception + /// + public delegate void ExceptionHandler(object sender, Exception ex); +} diff -Nru smuxi-0.8/lib/jabber-net/bedrock/io/BufferAggregate.cs smuxi-0.8.9.1/lib/jabber-net/bedrock/io/BufferAggregate.cs --- smuxi-0.8/lib/jabber-net/bedrock/io/BufferAggregate.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/jabber-net/bedrock/io/BufferAggregate.cs 2012-01-03 07:52:11.000000000 +0000 @@ -0,0 +1,133 @@ +/* -------------------------------------------------------------------------- + * Copyrights + * + * Portions created by or assigned to Cursive Systems, Inc. are + * Copyright (c) 2002-2008 Cursive Systems, Inc. All Rights Reserved. Contact + * information for Cursive Systems, Inc. is available at + * http://www.cursive.net/. + * + * License + * + * Jabber-Net is licensed under the LGPL. + * See LICENSE.txt for details. + * --------------------------------------------------------------------------*/ +using System.Collections; +using System.IO; + +using bedrock.util; + +namespace bedrock.io +{ + /// Aggregate byte arrays together, so we can parse + /// across IP packet boundaries + /// + [SVN(@"$Id$")] + public class BufferAggregate + { // RingBuffer of the Nieblung + private class BufNode + { + public byte[] buf; + public BufNode next = null; + } + + private MemoryStream m_stream = new MemoryStream(); + private BufNode m_head = null; + private BufNode m_tail = null; + + /// + /// Create an empty buffer + /// + public BufferAggregate() + { + } + + /// + /// Write to the buffer. Please make sure that you won't use this memory any more after you hand it in. + /// It will get mangled. + /// + /// + public void Write(byte[] buf) + { + m_stream.Write(buf, 0, buf.Length); + if (m_tail == null) + { + m_head = m_tail = new BufNode(); + m_head.buf = buf; + } + else + { + BufNode n = new BufNode(); + n.buf = buf; + m_tail.next = n; + m_tail = n; + } + } + + /// + /// Get the current aggregate contents of the buffer. + /// + /// + public byte[] GetBuffer() + { + return m_stream.ToArray(); + } + + /// + /// Clear the first "offset" bytes of the buffer, so they won't be parsed again. + /// + /// + public void Clear(int offset) + { + int s = 0; + int save = -1; + + BufNode bn = null; + for (bn = m_head; bn != null; bn = bn.next) + { + if (s + bn.buf.Length <= offset) + { + if (s + bn.buf.Length == offset) + { + bn = bn.next; + break; + } + s += bn.buf.Length; + } + else + { + save = s + bn.buf.Length - offset; + break; + } + } + + m_head = bn; + if (m_head == null) + m_tail = null; + + if (save > 0) + { + byte[] buf = new byte[save]; + System.Buffer.BlockCopy(m_head.buf, + m_head.buf.Length - save, + buf, 0, save); + m_head.buf = buf; + } + + m_stream.SetLength(0); + for (bn = m_head; bn != null; bn = bn.next) + { + m_stream.Write(bn.buf, 0, bn.buf.Length); + } + } + + /// + /// UTF8 encode the current contents of the buffer. Just for prettiness in the debugger. + /// + /// + public override string ToString() + { + byte[] b = GetBuffer(); + return System.Text.Encoding.UTF8.GetString(b, 0, b.Length); + } + } +} diff -Nru smuxi-0.8/lib/jabber-net/bedrock/io/ReadEventStream.cs smuxi-0.8.9.1/lib/jabber-net/bedrock/io/ReadEventStream.cs --- smuxi-0.8/lib/jabber-net/bedrock/io/ReadEventStream.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/jabber-net/bedrock/io/ReadEventStream.cs 2012-01-03 07:52:11.000000000 +0000 @@ -0,0 +1,236 @@ +/* -------------------------------------------------------------------------- + * Copyrights + * + * Portions created by or assigned to Cursive Systems, Inc. are + * Copyright (c) 2002-2008 Cursive Systems, Inc. All Rights Reserved. Contact + * information for Cursive Systems, Inc. is available at + * http://www.cursive.net/. + * + * License + * + * Jabber-Net is licensed under the LGPL. + * See LICENSE.txt for details. + * --------------------------------------------------------------------------*/ +using System; + +using System.IO; +using bedrock.util; + +namespace bedrock.io +{ + /// + /// Wrap a stream, so that OnRead events can be fired. + /// + [SVN(@"$Id$")] + public class ReadEventStream : Stream + { + private Stream m_stream; + + /// + /// Create a new stream. + /// + /// + public ReadEventStream(Stream s) + { + m_stream = s; + } + + /// + /// Bytes have been read from the underlying stream. + /// + public event ByteOffsetHandler OnRead; + + /// + /// Gets a value indicating whether the current stream supports reading. + /// + public override bool CanRead + { + get { return m_stream.CanRead; } + } + + /// + /// Gets a value indicating whether the current stream supports seeking. + /// + public override bool CanSeek + { + get { return m_stream.CanSeek; } + } + + /// + /// Gets a value indicating whether the current stream supports writing. + /// + public override bool CanWrite + { + get { return m_stream.CanWrite; } + } + + /// + /// Gets the length in bytes of the stream. + /// + public override long Length + { + get { return m_stream.Length; } + } + + /// + /// Gets or sets the position within the current stream. + /// + public override long Position + { + get { return m_stream.Position; } + set { m_stream.Position = value; } + } + + /// + /// Begins an asynchronous read operation. + /// + /// + /// + /// + /// + /// + /// + public override IAsyncResult BeginRead(byte[] buffer, int offset, int count, AsyncCallback callback, object state) + { + return m_stream.BeginRead (buffer, offset, count, callback, state); + } + + /// + /// Begins an asynchronous write operation. + /// + /// + /// + /// + /// + /// + /// + public override IAsyncResult BeginWrite(byte[] buffer, int offset, int count, AsyncCallback callback, object state) + { + return m_stream.BeginWrite (buffer, offset, count, callback, state); + } + + /// + /// Closes the current stream and releases any resources (such as sockets and file handles) associated with the current stream. + /// + public override void Close() + { + m_stream.Close (); + } + + /// + /// Waits for the pending asynchronous read to complete. + /// + /// + /// + public override int EndRead(IAsyncResult asyncResult) + { + int count = m_stream.EndRead(asyncResult); + byte[] buf = System.Text.Encoding.UTF8.GetBytes("Read " + count + " bytes from async stream"); + FireOnRead(buf, 0, buf.Length); + return count; + } + + /// + /// Ends an asynchronous write operation. + /// + /// + public override void EndWrite(IAsyncResult asyncResult) + { + m_stream.EndWrite (asyncResult); + } + + /// + /// Clears all buffers for this stream and causes any buffered data to be written to + /// the underlying device. + /// + public override void Flush() + { + m_stream.Flush(); + } + + /// + /// Reads a sequence of bytes from the current stream and advances the position within the stream + /// by the number of bytes read. + /// + /// + /// + /// + /// + public override int Read(byte[] buffer, int offset, int count) + { + int rcount = m_stream.Read(buffer, offset, count); + FireOnRead(buffer, offset, rcount); + return rcount; + } + + /// + /// Reads a byte from the stream and advances the position within the stream by one byte, + /// or returns -1 if at the end of the stream. + /// + /// + public override int ReadByte() + { + return m_stream.ReadByte(); + } + + /// + /// Sets the position within the current stream. + /// + /// + /// + /// + public override long Seek(long offset, SeekOrigin origin) + { + return m_stream.Seek(offset, origin); + } + + /// + /// Sets the length of the current stream. + /// + /// + public override void SetLength(long value) + { + m_stream.SetLength(value); + } + + /// + /// writes a sequence of bytes to the current stream and advances + /// the current position within this stream by the number of bytes written. + /// + /// + /// + /// + public override void Write(byte[] buffer, int offset, int count) + { + m_stream.Write(buffer, offset, count); + } + + /// + /// Writes a byte to the current position in the stream and advances + /// the position within the stream by one byte. + /// + /// + public override void WriteByte(byte val) + { + m_stream.WriteByte(val); + } + + /// + /// Serves as a hash function for a particular type, suitable for use + /// in hashing algorithms and data structures like a hash table. + /// + /// + public override int GetHashCode() + { + return m_stream.GetHashCode(); + } + + private void FireOnRead(byte[] buf, int offset, int length) + { + if ((OnRead != null) && (length > 0)) + { + OnRead(this, buf, offset, length); + } + } + } +} diff -Nru smuxi-0.8/lib/jabber-net/bedrock/io/ZlibStream.cs smuxi-0.8.9.1/lib/jabber-net/bedrock/io/ZlibStream.cs --- smuxi-0.8/lib/jabber-net/bedrock/io/ZlibStream.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/jabber-net/bedrock/io/ZlibStream.cs 2012-01-03 07:52:11.000000000 +0000 @@ -0,0 +1,444 @@ +/* -------------------------------------------------------------------------- + * Copyrights + * + * Portions created by or assigned to Cursive Systems, Inc. are + * Copyright (c) 2002-2008 Cursive Systems, Inc. All Rights Reserved. Contact + * information for Cursive Systems, Inc. is available at + * http://www.cursive.net/. + * + * License + * + * Jabber-Net is licensed under the LGPL. + * See LICENSE.txt for details. + * --------------------------------------------------------------------------*/ +#if ZLIB_NET +using System; +using System.IO; +using System.Diagnostics; + +using bedrock.util; +using ComponentAce.Compression.Libs.zlib; + +namespace bedrock.io +{ + /// + /// Compression failed. + /// + [SVN(@"$Id$")] + public class CompressionFailedException : ApplicationException + { + /// + /// + /// + /// + public CompressionFailedException(string message) : base(message) { } + + /// + /// + /// + public CompressionFailedException() : base() { } + } + + + /// + /// Wrap two ComponentAce.Compression.Libs.zlib.ZStream's, one in and one out. + /// The existing wrappers in the project are uni-directional. + /// + /// No, System.IO.Compression.GZipStream won't work, because they didn't expose + /// compression levels or flush types. + /// + [SVN(@"$Id$")] + public class ZlibStream : Stream + { + /// + /// Is zlib supported? Note, this will throw an exception if the library is missing. + /// + public static bool Supported + { + get + { + return zlibConst.version() != ""; + } + } + + private Stream m_stream = null; + private ZStream m_in; + private ZStream m_out; + private int m_flush = zlibConst.Z_PARTIAL_FLUSH; + + private const int bufsize = 1024; + private byte[] m_inbuf; + private byte[] m_outbuf; + + /// + /// Wrap a bi-directional stream in a compression stream. + /// + /// The stream to wrap. + public ZlibStream(Stream innerStream) + { + init(innerStream); + } + + /// + /// Wrap a bi-directional stream in a compression stream. + /// + /// The stream to wrap. + /// The flush type. TODO: doc these. + public ZlibStream(Stream innerStream, int flush) + { + m_flush = flush; + init(innerStream); + } + + + private void init(Stream innerStream) + { + m_stream = innerStream; + if (m_stream.CanRead) + { + m_in = new ZStream(); + int ret = m_in.inflateInit(); + if (ret != zlibConst.Z_OK) + throw new CompressionFailedException("Unable to initialize zlib for deflate: " + ret); + m_inbuf = new byte[bufsize]; + m_in.avail_in = 0; + m_in.next_in = m_inbuf; + m_in.next_in_index = 0; + } + + if (m_stream.CanWrite) + { + m_out = new ZStream(); + int ret = m_out.deflateInit(zlibConst.Z_DEFAULT_COMPRESSION); + if (ret != zlibConst.Z_OK) + throw new CompressionFailedException("Unable to initialize zlib for inflate: " + ret); + m_outbuf = new byte[bufsize]; + m_out.next_out = m_outbuf; + } + } + + /// + /// Is the underlying stream readable? + /// + public override bool CanRead + { + get { return m_stream.CanRead; } + } + + /// + /// No seeking on compressed streams. That sounds hard. + /// + public override bool CanSeek + { + get { return false; } + } + + /// + /// Is the underlying stream writable? + /// + public override bool CanWrite + { + get { return m_stream.CanWrite; } + } + + /// + /// This just flushes the stream, but doesn't perform zlib flushing. + /// + public override void Flush() + { + m_stream.Flush(); + } + + /// + /// Not implemented. + /// + public override long Length + { + get { throw new NotImplementedException("The method or operation is not implemented."); } + } + + /// + /// Not implemented. + /// + public override long Position + { + get { throw new NotImplementedException("The method or operation is not implemented."); } + set { throw new NotImplementedException("The method or operation is not implemented."); } + } + + /// + /// Start an async read. Implemented locally, since Stream.BeginRead() isn't really asynch. + /// + /// + /// + /// + /// + /// + /// + public override IAsyncResult BeginRead(byte[] buffer, int offset, int count, AsyncCallback callback, object state) + { + if (count <= 0) + throw new ArgumentException("Can't read 0 bytes", "count"); + + m_in.next_out = buffer; + m_in.next_out_index = offset; + m_in.avail_out = count; + if (m_in.avail_in == 0) + { + m_in.next_in_index = 0; + return m_stream.BeginRead(m_inbuf, 0, bufsize, callback, state); + } + ZlibStreamAsyncResult ar = new ZlibStreamAsyncResult(state); + callback(ar); + return ar; + } + + /// + /// Complete a pending read, when the callback passed to BeginRead fires. + /// + /// + /// + public override int EndRead(IAsyncResult asyncResult) + { + if (!(asyncResult is ZlibStreamAsyncResult)) + m_in.avail_in = m_stream.EndRead(asyncResult); + return Inflate(); + } + + /// + /// Synchronous read. Decompresses. + /// + /// + /// + /// + /// + public override int Read(byte[] buffer, int offset, int count) + { + if (count <= 0) + return 0; + + m_in.next_out = buffer; + m_in.next_out_index = offset; + m_in.avail_out = count; + + if (m_in.avail_in == 0) + { + m_in.next_in_index = 0; + m_in.avail_in = m_stream.Read(m_inbuf, 0, bufsize); + if (m_in.avail_in == 0) + return 0; + } + return Inflate(); + } + + private int Inflate() + { + int count = m_in.avail_out; + int err = m_in.inflate(m_flush); + if ((err != zlibConst.Z_OK) && (err != zlibConst.Z_STREAM_END)) + { + if (err == zlibConst.Z_BUF_ERROR) + return 0; + if (err != zlibConst.Z_OK) + throw new CompressionFailedException("Decompress failed: " + err); + } + return (count - m_in.avail_out); + } + + /// + /// Not implemented. + /// + /// + /// + /// + public override long Seek(long offset, SeekOrigin origin) + { + throw new NotImplementedException("The method or operation is not implemented."); + } + + /// + /// Not implemented. + /// + /// + public override void SetLength(long value) + { + throw new NotImplementedException("The method or operation is not implemented."); + } + + /// + /// Begin an asynch write, compressing first. Implemented locally, since Stream.BeginWrite isn't asynch. + /// Note: may call Write() on the underlying stream more than once. + /// + /// + /// + /// + /// + /// + /// + public override IAsyncResult BeginWrite(byte[] buffer, int offset, int count, AsyncCallback callback, object state) + { + if (count <= 0) + throw new ArgumentException("Can't write 0 bytes", "count"); + + m_out.next_in = buffer; + m_out.next_in_index = offset; + m_out.avail_in = count; + + m_out.next_out_index = 0; + m_out.avail_out = bufsize; + int err = m_out.deflate(m_flush); + if (err != zlibConst.Z_STREAM_END) + { + if (err != zlibConst.Z_OK) + { + ZlibStreamAsyncResult res = new ZlibStreamAsyncResult(state, new CompressionFailedException("Compress failed: " + err)); + callback(res); + return res; + } + } + if (m_out.avail_in == 0) + return m_stream.BeginWrite(m_outbuf, 0, bufsize - m_out.avail_out, callback, state); + else + return m_stream.BeginWrite(m_outbuf, 0, bufsize - m_out.avail_out, new AsyncCallback(IntermediateWrite), new ZlibState(callback, state)); + } + + private void IntermediateWrite(IAsyncResult asyncResult) + { + ZlibState state = (ZlibState)asyncResult.AsyncState; + try + { + m_stream.EndWrite(asyncResult); + } + catch (Exception e) + { + ZlibStreamAsyncResult res = new ZlibStreamAsyncResult(state.state, e); + state.callback(res); + return; + } + + m_out.next_out_index = 0; + m_out.avail_out = bufsize; + int err = m_out.deflate(m_flush); + if (err != zlibConst.Z_STREAM_END) + { + if (err != zlibConst.Z_OK) + { + ZlibStreamAsyncResult res = new ZlibStreamAsyncResult(state.state, new CompressionFailedException("Compress failed: " + err)); + state.callback(res); + return; + } + } + if (m_out.avail_in == 0) + m_stream.BeginWrite(m_outbuf, 0, bufsize - m_out.avail_out, state.callback, state.state); + else + m_stream.BeginWrite(m_outbuf, 0, bufsize - m_out.avail_out, new AsyncCallback(IntermediateWrite), state); + } + + /// + /// Complete a pending write, when the callback given to BeginWrite is called. + /// + /// + public override void EndWrite(IAsyncResult asyncResult) + { + if (asyncResult is ZlibStreamAsyncResult) + { + ZlibStreamAsyncResult ar = (ZlibStreamAsyncResult)asyncResult; + if (ar.Exception != null) + throw ar.Exception; + } + else + m_stream.EndWrite(asyncResult); + return; + } + + /// + /// Synchronous write, after compressing. + /// + /// + /// + /// + public override void Write(byte[] buffer, int offset, int count) + { + if (count <= 0) + return; + m_out.next_in = buffer; + m_out.next_in_index = offset; + m_out.avail_in = count; + + while (m_out.avail_in > 0) + { + m_out.next_out_index = 0; + m_out.avail_out = bufsize; + int err = m_out.deflate(m_flush); + if (err != zlibConst.Z_STREAM_END) + { + if (err != zlibConst.Z_OK) + throw new CompressionFailedException("Compress failed: " + err); + } + m_stream.Write(m_outbuf, 0, bufsize - m_out.avail_out); + } + } + + private class ZlibStreamAsyncResult : IAsyncResult + { + private object m_state = null; + private Exception m_exception; + + public ZlibStreamAsyncResult(object state) + { + m_state = state; + } + + public ZlibStreamAsyncResult(object state, Exception except) + { + m_state = state; + m_exception = except; + } + + public Exception Exception + { + get { return m_exception; } + } + + #region IAsyncResult Members + + public object AsyncState + { + get { return m_state; } + } + + public System.Threading.WaitHandle AsyncWaitHandle + { + get + { + throw new Exception("The method or operation is not implemented."); + } + } + + public bool CompletedSynchronously + { + get { return true; } + } + + public bool IsCompleted + { + get { return true; } + } + + #endregion + } + + private class ZlibState + { + public AsyncCallback callback; + public object state; + + public ZlibState(AsyncCallback callback, object state) + { + this.callback = callback; + this.state = state; + } + } + } +} +#endif diff -Nru smuxi-0.8/lib/jabber-net/bedrock/net/Address.cs smuxi-0.8.9.1/lib/jabber-net/bedrock/net/Address.cs --- smuxi-0.8/lib/jabber-net/bedrock/net/Address.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/jabber-net/bedrock/net/Address.cs 2012-01-03 07:52:11.000000000 +0000 @@ -0,0 +1,354 @@ +/* -------------------------------------------------------------------------- + * Copyrights + * + * Portions created by or assigned to Cursive Systems, Inc. are + * Copyright (c) 2002-2008 Cursive Systems, Inc. All Rights Reserved. Contact + * information for Cursive Systems, Inc. is available at + * http://www.cursive.net/. + * + * License + * + * Jabber-Net is licensed under the LGPL. + * See LICENSE.txt for details. + * --------------------------------------------------------------------------*/ +using System; + +using System.Diagnostics; +using System.Net; +using System.Net.Sockets; +using System.ComponentModel; +using System.Globalization; + +using bedrock.util; + +#if !__MonoCS__ +using netlib.Dns; +using netlib.Dns.Records; +#endif + +namespace bedrock.net +{ + /// + /// Callback for async DNS lookups. + /// + public delegate void AddressResolved(Address addr); + /// + /// Encapsulation and caching of IP address information. Very similar to System.Net.IPEndPoint, + /// but adds async DNS lookups. + /// TODO: add SRV? + /// + [SVN(@"$Id$")] + public class Address + { + private string m_hostname = null; + private int m_port = -1; + private IPAddress m_ip = IPAddress.Any; + /// + /// Address for a server, corresponding to IPAddress.Any. + /// + /// + public Address(int port) + { + m_port = port; + } + /// + /// New connection endpoint. + /// + /// Host name or dotted-quad IP address + /// Port number + public Address(string hostname, int port) : this(port) + { + Debug.Assert(hostname != null, "must supply a host name"); + this.Hostname = hostname; + } + /// + /// Create a new connection endpoint, where the IP address is already known. + /// + /// + /// + public Address(IPAddress ip, int port) : this(port) + { + this.IP = ip; + } + + +#if !__MonoCS__ + private static SRVRecord PickSRV(SRVRecord[] srv) + { + // TODO: keep track of connection failures, and try the next priority down. + + if ((srv == null) || (srv.Length == 0)) + throw new ArgumentException(); + if (srv.Length == 1) + return srv[0]; + + // randomize order. One might wish that the OS would have done this for us. + // cf. Bob Schriter's Grandfather. + Random rnd = new Random(); + byte[] keys = new byte[srv.Length]; + rnd.NextBytes(keys); + Array.Sort(keys, srv); // Permute me, Knuth! (I wish I had a good anagram for that) + + int minpri = int.MaxValue; + foreach (SRVRecord rec in srv) + { + if (rec.Priority < minpri) + { + minpri = rec.Priority; + } + } + + int weight = 0; + foreach (SRVRecord rec in srv) + { + if (rec.Priority == minpri) + { + weight += rec.Weight; + } + } + + int pos = rnd.Next(weight); + weight = 0; + foreach (SRVRecord rec in srv) + { + if (rec.Priority == minpri) + { + weight += rec.Weight; + if ((pos < weight) || (weight == 0)) + { + return rec; + } + } + } + + throw new DnsException("No matching SRV"); + } + + /// + /// Look up a DNS SRV record, returning the best host and port number to connect to. + /// + /// The SRV prefix, ending with a dot. Example: "_xmpp-client._tcp." + /// The domain to check + /// The host name to connect to + /// The port number to connect to + public static void LookupSRV(string prefix, string domain, ref string host, ref int port) + { + if (prefix == null) + throw new ArgumentNullException("prefix"); + if (domain == null) + throw new ArgumentNullException("domain"); + if (!prefix.EndsWith(".")) + throw new ArgumentOutOfRangeException("Prefix must end in '.'", "prefix"); + try + { + DnsRequest request = new DnsRequest(prefix + domain); + DnsResponse response = request.GetResponse(DnsRecordType.SRV); + + SRVRecord record = PickSRV(response.SRVRecords); + host = record.NameNext; + port = record.Port; + Debug.WriteLine(string.Format("SRV found: {0}:{1}", host, port)); + } + catch + { + host = domain; + } + } + + /// + /// Look up a DNS TXT record. + /// + /// The prefix, ending in '.'. Example: "_xmppconnect." + /// The domain to search + /// The attribute name to look for. Example: "_xmpp-client-xbosh" + /// + public static string LookupTXT(string prefix, string domain, string attribute) + { + if (prefix == null) + throw new ArgumentNullException("prefix"); + if (domain == null) + throw new ArgumentNullException("domain"); + if (attribute == null) + throw new ArgumentNullException("attribute"); + if (!prefix.EndsWith(".")) + throw new ArgumentOutOfRangeException("Prefix must end in '.'", "prefix"); + + try + { + DnsRequest request = new DnsRequest(prefix + domain); + DnsResponse response = request.GetResponse(DnsRecordType.TEXT); + string attr = attribute + "="; + foreach (TXTRecord txt in response.TXTRecords) + { + if (txt.StringArray.StartsWith(attr)) + { + Debug.WriteLine(string.Format("TXT found: {0}", txt.StringArray)); + return txt.StringArray.Substring(attr.Length); + } + } + } + catch + { + } + return null; + } +#endif + + /// + /// The host name. When set, checks for dotted-quad representation, to avoid + /// async DNS call when possible. + /// + public string Hostname + { + get { return m_hostname; } + set + { + if ((value == null) || (value == "")) + { + m_hostname = null; + m_ip = IPAddress.Any; + return; + } + if (m_hostname != value) + { + m_hostname = value; + + try + { + m_ip = IPAddress.Parse(m_hostname); + } + catch (FormatException) + { + m_ip = null; + } + } + } + } + + /// + /// Port number. + /// TODO: add string version that looks in /etc/services (or equiv)? + /// + public int Port + { + get { return m_port; } + set + { + Debug.Assert(value > 0); + m_port = value; + } + } + /// + /// The binary IP address. Gives IPAddress.Any if resolution hasn't occured, and + /// null if resolution failed. + /// + public IPAddress IP + { + get { return m_ip; } + set + { + m_ip = value; + m_hostname = m_ip.ToString(); + } + } + /// + /// Not implemented yet. + /// + public string Service + { + get { throw new NotImplementedException(); } + set { throw new NotImplementedException(); } + } + /// + /// An IPEndPoint for making socket connections with. + /// + public IPEndPoint Endpoint + { + get + { + if (m_ip == null) + return null; + return new IPEndPoint(m_ip, Port); + } + set + { + m_ip = value.Address; + Port = value.Port; + } + } + /// + /// Async DNS lookup. IP will be null in callback on failure. Callback will + /// be called immediately if IP is already known (e.g. dotted-quad). + /// + /// Called when resolution complete. + public void Resolve(AddressResolved callback) + { + if ((m_ip != null) && (m_ip != IPAddress.Any) + && (m_ip != IPAddress.IPv6Any) + ) + { + callback(this); + } + else + Dns.BeginGetHostEntry(m_hostname, new AsyncCallback(OnResolved), callback); + } + + /// + /// Synchronous DNS lookup. + /// + public void Resolve() + { + if ((m_ip != null) && + (m_ip != IPAddress.Any) && + (m_ip != IPAddress.IPv6Any)) + { + return; + } + Debug.Assert(m_hostname != null, "Must set hostname first"); + IPHostEntry iph = Dns.GetHostEntry(m_hostname); + + // TODO: what happens here on error? + m_ip = iph.AddressList[0]; + } + + /// + /// Handle the async DNS response. + /// + /// + private void OnResolved(IAsyncResult ar) + { + try + { + IPHostEntry ent = Dns.EndGetHostEntry(ar); + if (ent.AddressList.Length <= 0) + { + m_ip = null; + } + else + { + // From docs: + // When hostName is a DNS-style host name associated with multiple IP addresses, + // only the first IP address that resolves to that host name is returned. + m_ip = ent.AddressList[0]; + } + } + catch (Exception e) + { + Debug.WriteLine(e.ToString()); + m_ip = null; + } + AddressResolved callback = (AddressResolved) ar.AsyncState; + if (callback != null) + callback(this); + } + /// + /// Readable representation of the address. + /// Host (IP):port + /// + /// + public override string ToString() + { + return string.Format("{0}({1}):{2}", m_hostname, m_ip, m_port); + } + } +} diff -Nru smuxi-0.8/lib/jabber-net/bedrock/net/AsyncSocket.cs smuxi-0.8.9.1/lib/jabber-net/bedrock/net/AsyncSocket.cs --- smuxi-0.8/lib/jabber-net/bedrock/net/AsyncSocket.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/jabber-net/bedrock/net/AsyncSocket.cs 2012-01-03 07:52:11.000000000 +0000 @@ -0,0 +1,1314 @@ +/* -------------------------------------------------------------------------- + * Copyrights + * + * Portions created by or assigned to Cursive Systems, Inc. are + * Copyright (c) 2002-2008 Cursive Systems, Inc. All Rights Reserved. Contact + * information for Cursive Systems, Inc. is available at + * http://www.cursive.net/. + * + * License + * + * Jabber-Net is licensed under the LGPL. + * See LICENSE.txt for details. + * --------------------------------------------------------------------------*/ +using System; + +using System.ComponentModel; +using System.Diagnostics; +using System.IO; +using System.Net; +using System.Net.Sockets; +using System.Threading; +using bedrock.util; + +using System.Security.Authentication; +using System.Net.Security; +using System.Security.Cryptography.X509Certificates; + +namespace bedrock.net +{ + /// + /// Delegate for members that receive a socket. + /// + public delegate void AsyncSocketHandler(object sender, BaseSocket sock); + + /// + /// An asynchronous socket, which calls a listener class when + /// interesting things happen. + /// + [SVN(@"$Id$")] + public class AsyncSocket : BaseSocket, IComparable + { + /// + /// Socket states. + /// + [SVN(@"$Id$")] + private enum SocketState + { + /// + /// Socket has been created. + /// + Created, + /// + /// Socket is listening for new connections + /// + Listening, + /// + /// Doing DNS lookup + /// + Resolving, + /// + /// Attempting to connect + /// + Connecting, + /// + /// Connected to a peer. The running state. + /// + Connected, + /// + /// Shutting down the socket. + /// + Closing, + /// + /// Closed down. + /// + Closed, + /// + /// An error ocurred. + /// + Error + } + + private const int BUFSIZE = 4096; + + /// The set of allowable errors in SSL certificates + /// if UntrustedRootOK is set to true. + [Obsolete("Catch OnInvalidCertificate, instead")] + public const SslPolicyErrors DefaultUntrustedPolicy = + SslPolicyErrors.RemoteCertificateChainErrors; + + /// The allowable SSL certificate errors. If you + /// modify UntrustedRootOK to true, the side effect will be to + /// set this to DefaultUntrustedPolicy. False, the default, + /// sets this to None. + private static SslPolicyErrors AllowedSSLErrors = SslPolicyErrors.None; + + /// + /// Are untrusted root certificates OK when connecting using + /// SSL? Setting this to true is insecure, but it's unlikely + /// that you trust jabbber.org or jabber.com's relatively + /// bogus certificate roots. + /// + /// Setting this modifies AllowedSSLErrors by side-effect. + /// + [DefaultValue(false)] + [Obsolete("Catch OnInvalidCertificate, instead")] + public static bool UntrustedRootOK + { + get + { + return (AllowedSSLErrors != SslPolicyErrors.None); + } + set + { + if (value) + { + AllowedSSLErrors = DefaultUntrustedPolicy; + } + else + { + AllowedSSLErrors = SslPolicyErrors.None; + } + } + } + + /// + /// The types of SSL to support. SSL3 and TLS1 by default. + /// That should be good enough for most apps, and was + /// hard-coded to start with. Note: when doing start-tls, + /// this is overridden to just be TLS. + /// + public static SslProtocols SSLProtocols = SslProtocols.Ssl3 | SslProtocols.Tls; + private SslProtocols m_secureProtocol = SslProtocols.None; + private Socket m_sock = null; + private X509Certificate2 m_cert = null; + private Stream m_stream = null; + private SslStream m_sslStream = null; // hold on to the SSL stream as it goes by, since compression might happen later. + private MemoryStream m_pending = new MemoryStream(); + private bool m_writing = false; + private bool m_requireClientCert = false; + private bool m_cert_gui = true; + private bool m_server = false; + private byte[] m_buf = new byte[BUFSIZE]; + private SocketState m_state = SocketState.Created; + private SocketWatcher m_watcher = null; + private Guid m_id = Guid.NewGuid(); + private bool m_reading = false; + private bool m_synch = false; + private Address m_addr; + + + /// + /// Called from SocketWatcher. + /// + /// + /// The listener for this socket + public AsyncSocket(SocketWatcher w, ISocketEventListener listener) : base(listener) + { + m_watcher = w; + } + + /// + /// Called from SocketWatcher. + /// + /// + /// The listener for this socket + /// Do SSL3 and TLS1 on startup (call + /// StartTLS later if this is false, and TLS only is needed + /// later) + /// Synchronous operation + public AsyncSocket(SocketWatcher w, + ISocketEventListener listener, + bool SSL, + bool synch) : + base(listener) + { + m_watcher = w; + m_synch = synch; + + if (SSL) + m_secureProtocol = SSLProtocols; + } + + private AsyncSocket(SocketWatcher w) : base() + { + m_watcher = w; + } + + /* + /// + /// Return the state of the socket. WARNING: don't use this. + /// + public State Socket_State + { + get + { + return m_state; + } + } + */ + private SocketState State + { + get { return m_state; } + set + { +// useful for finding unexpected socket closes. +// Debug.WriteLine("socket state: " + m_state.ToString() + "->" + value.ToString()); + m_state = value; + } + } + + /// + /// For connect sockets, the remote address. For Accept sockets, the local address. + /// + public Address Address + { + get + { + return m_addr; + } + } + + /// + /// Get the certificate of the remote endpoint of the socket. + /// + public X509Certificate RemoteCertificate + { + get + { + if (m_sslStream == null) + return null; + return m_sslStream.RemoteCertificate; + } + } + + /// + /// Choose a certificate from the local store. If there are + /// none available, returns right away. + /// If there is exactly one, uses it. + /// Otherwise, prompts. + /// + [Obsolete("Pass in a list of acceptable issuers")] + public void ChooseClientCertificate() + { + ChooseClientCertificate(null); + } + + /// + /// Choose a certificate from the local store. If there are + /// none available, returns right away. + /// If there is exactly one, uses it. + /// Otherwise, prompts. + /// TODO: figure out something for server certs, too. + /// + /// A list of DNs of CAs that are trusted by the other party + public void ChooseClientCertificate(string[] acceptableIssuers) + { + X509Store store = new X509Store(StoreName.My, StoreLocation.CurrentUser); + store.Open(OpenFlags.ReadOnly); + X509Certificate2Collection coll = new X509Certificate2Collection(); + if (acceptableIssuers == null) + { + coll.AddRange(store.Certificates); + } + else + { + foreach (X509Certificate2 cert in store.Certificates) + { + foreach (string issuer in acceptableIssuers) + { + if (cert.Issuer == issuer) + { + coll.Add(cert); + } + } + } + } + + switch (coll.Count) + { + case 0: + return; + case 1: + m_cert = coll[0]; + return; + default: + #if __MonoCS__ + m_cert = null; + #else + X509Certificate2Collection certs = X509Certificate2UI.SelectFromCollection( + coll, + "Select certificate", + "Use this certificate to log in", + X509SelectionFlag.SingleSelection); + if (certs.Count > 0) + m_cert = certs[0]; + #endif + break; + } + } + + /// + /// Callback to choose client cert. + /// TODO: this should surface an event of some kind. + /// + public X509Certificate ChooseClientCertificate(Object sender, + string targetHost, + X509CertificateCollection localCertificates, + X509Certificate remoteCertificate, + string[] acceptableIssuers) + { + // this will be called twice if the server requires a client cert. + // Ignore the callback the first time; I think this is a .Net bug. + if (acceptableIssuers.Length == 0) + return m_cert; + + if (CertificateGui) + { + if (m_cert != null) + return m_cert; + + ChooseClientCertificate(acceptableIssuers); + } + return m_cert; + } + + /// + /// If true the certificate selection dialog is called. + /// + public bool CertificateGui + { + get { return m_cert_gui; } + set { m_cert_gui = value; } + } + + /// + /// The local certificate of the socket. + /// + public X509Certificate2 LocalCertificate + { + get { return m_cert; } + set { m_cert = value; } + } + + /// + /// Are we using SSL/TLS? + /// + public bool SSL + { + get + { + if (m_sslStream == null) + return false; + return m_sslStream.IsEncrypted; + } + } + + /// + /// Is the socket connected? + /// + public override bool Connected + { + get + { + if (m_sock == null) + return false; + return m_sock.Connected; + } + } + + /// + /// Sets the specified option to the specified value. + /// + /// + /// + /// + public void SetSocketOption(SocketOptionLevel optionLevel, + SocketOptionName optionName, + byte[] optionValue) + { + m_sock.SetSocketOption(optionLevel, optionName, optionValue); + } + + /// + /// Sets the specified option to the specified value. + /// + /// + /// + /// + public void SetSocketOption(SocketOptionLevel optionLevel, + SocketOptionName optionName, + int optionValue) + { + m_sock.SetSocketOption(optionLevel, optionName, optionValue); + } + + /// + /// Sets the specified option to the specified value. + /// + /// + /// + /// + public void SetSocketOption(SocketOptionLevel optionLevel, + SocketOptionName optionName, + object optionValue) + { + m_sock.SetSocketOption(optionLevel, optionName, optionValue); + } + + /// + /// Prepare to start accepting inbound requests. Call + /// RequestAccept() to start the async process. + /// + /// Address to listen on + /// The Maximum length of the queue of + /// pending connections + public override void Accept(Address addr, int backlog) + { + lock (this) + { + m_addr = addr; + + m_sock = new Socket(AddressFamily.InterNetwork, + SocketType.Stream, + ProtocolType.Tcp); + + // Always reuse address. + m_sock.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, 1); + m_sock.Bind(m_addr.Endpoint); + m_sock.Listen(backlog); + State = SocketState.Listening; + + if (m_watcher != null) + m_watcher.RegisterSocket(this); + } + } + + /// + /// Start the flow of async accepts. Flow will continue while + /// Listener.OnAccept() returns true. Otherwise, call + /// RequestAccept() again to continue. + /// + public override void RequestAccept() + { + lock (this) + { + if (State != SocketState.Listening) + { + throw new InvalidOperationException("Not a listen socket"); + } + } + if (m_synch) + { + Socket cli; + try + { + cli = m_sock.Accept(); + } + catch (SocketException) + { + Debug.WriteLine("A cancel call was sent to the accepting socket."); + return; + } + + AsyncSocket cliCon = new AsyncSocket(m_watcher); + cliCon.m_sock = cli; + cliCon.m_synch = true; + AcceptDone(cliCon); + } + else + { + m_sock.BeginAccept(new AsyncCallback(ExecuteAccept), null); + } + } + + /// + /// We got a connection from outside. Add it to the SocketWatcher. + /// + /// + private void ExecuteAccept(IAsyncResult ar) + { + Socket cli = (Socket) m_sock.EndAccept(ar); + AsyncSocket cliCon = new AsyncSocket(m_watcher); + cliCon.m_sock = cli; + AcceptDone(cliCon); + } + + private void AcceptDone(AsyncSocket cliCon) + { + cliCon.m_addr = m_addr; + cliCon.Address.IP = ((IPEndPoint) cliCon.m_sock.RemoteEndPoint).Address; + cliCon.State = SocketState.Connected; + + cliCon.m_stream = new NetworkStream(cliCon.m_sock); + cliCon.m_server = true; + cliCon.LocalCertificate = m_cert; + cliCon.RequireClientCert = m_requireClientCert; + + ISocketEventListener l = m_listener.GetListener(cliCon); + if (l == null) + { + // if the listener returns null, close the socket and + // quit, instead of asserting. + cliCon.m_sock.Close(); + RequestAccept(); + return; + } + + cliCon.m_listener = l; + + try + { + if (m_watcher != null) + m_watcher.RegisterSocket(cliCon); + } + catch (InvalidOperationException) + { + // m_watcher out of slots. + cliCon.AsyncClose(); + + // don't set state + // they really don't need this error, we don't think. + // Error(e); + + // tell the watcher that when it gets its act together, + // we'd appreciate it if it would restart the RequestAccept(). + m_watcher.PendingAccept(this); + return; + } + + if (m_secureProtocol != SslProtocols.None) + cliCon.StartTLS(); + + if (l.OnAccept(cliCon)) + { + RequestAccept(); + } + } + + /// + /// Outbound connection. Eventually calls Listener.OnConnect() when + /// the connection comes up. Don't forget to call RequestRead() in + /// OnConnect()! + /// + /// + public override void Connect(Address addr) + { + // Debug.WriteLine("starting connect to " + addr.ToString()); + State = SocketState.Resolving; + if (m_synch) + { + addr.Resolve(); + OnConnectResolved(addr); + } + else + { + addr.Resolve(new AddressResolved(OnConnectResolved)); + } + } + + /// + /// Address resolution finished. Try connecting. + /// + /// + private void OnConnectResolved(Address addr) + { + // Debug.WriteLine("connectresolved: " + addr.ToString()); + lock (this) + { + if (State != SocketState.Resolving) + { + // closed in the mean time. Probably not an error. + return; + } + if ((addr == null) || (addr.IP == null) || (addr.Endpoint == null)) + { + FireError(new AsyncSocketConnectionException("Bad host: " + addr.Hostname)); + return; + } + + + if (m_watcher != null) + m_watcher.RegisterSocket(this); + + m_addr = addr; + State = SocketState.Connecting; + + if (Socket.OSSupportsIPv6 && (m_addr.Endpoint.AddressFamily == AddressFamily.InterNetworkV6)) + { + // Debug.WriteLine("ipv6"); + m_sock = new Socket(AddressFamily.InterNetworkV6, + SocketType.Stream, + ProtocolType.Tcp); + } + else + { + // Debug.WriteLine("ipv4"); + m_sock = new Socket(AddressFamily.InterNetwork, + SocketType.Stream, + ProtocolType.Tcp); + } + + // well, of course this isn't right. + m_sock.SetSocketOption(SocketOptionLevel.Socket, + SocketOptionName.ReceiveBuffer, + 4 * m_buf.Length); + } + + if (m_synch) + { + try + { + m_sock.Connect(m_addr.Endpoint); + } + catch (SocketException ex) + { + FireError(ex); + return; + } + + if (m_sock.Connected) + { + // TODO: check to see if this Mono bug is still valid +#if __MonoCS__ + m_sock.Blocking = true; + m_stream = new NetworkStream(m_sock); + m_sock.Blocking = false; +#else + m_stream = new NetworkStream(m_sock); +#endif + if (m_secureProtocol != SslProtocols.None) + StartTLS(); + + lock (this) + { + State = SocketState.Connected; + } + m_listener.OnConnect(this); + } + else + { + AsyncClose(); + FireError(new AsyncSocketConnectionException("could not connect")); + } + } + else + { +#if __MonoCS__ + m_sock.Blocking = false; +#endif + m_sock.BeginConnect(m_addr.Endpoint, new AsyncCallback(ExecuteConnect), null); + } + } + + /// + /// Validate the server cert. SSLPolicyErrors will be + /// pre-filled with the errors you got. + /// + /// If there is an error in the cert, OnIvalidCertificate will be called. + /// + /// + /// + /// + /// + /// + protected bool ValidateServerCertificate(object sender, + X509Certificate certificate, + X509Chain chain, + SslPolicyErrors sslPolicyErrors) + { + // Note: Don't write servers with Jabber-Net, please. :) + if (m_server) + { + return true; + } + + if (sslPolicyErrors == SslPolicyErrors.None) + return true; + + if ((sslPolicyErrors & (sslPolicyErrors ^ AllowedSSLErrors)) == SslPolicyErrors.None) + { + // Huh. Maybe there should be a listener method for this. + return true; + } + + if (m_listener.OnInvalidCertificate(this, certificate, chain, sslPolicyErrors)) + return true; + + Debug.WriteLine("Certificate error: {0}", sslPolicyErrors.ToString()); + + // Do not allow this client to communicate with unauthenticated servers. + return false; + } + + /// + /// Start TLS processing on an open socket. + /// + public override void StartTLS() + { + // we're really doing start-tls. + if (m_secureProtocol == SslProtocols.None) + m_secureProtocol = SslProtocols.Tls; + + m_stream = m_sslStream = new SslStream(m_stream, false, ValidateServerCertificate, ChooseClientCertificate); + + if (m_server) + { + if (m_cert == null) + { + FireError(new InvalidOperationException("Must set Certificate for server SSL")); + Close(); + return; + } + // TODO: surface these as params + m_sslStream.AuthenticateAsServer(m_cert, m_requireClientCert, m_secureProtocol, false); + } + else + { + if ((m_watcher != null) && (m_watcher.LocalCertificate != null)) + m_cert = m_watcher.LocalCertificate; + + X509CertificateCollection certs = null; + if (m_cert != null) + { + certs = new X509Certificate2Collection(); + certs.Add(m_cert); + } + try + { + m_sslStream.AuthenticateAsClient(m_hostid, certs, m_secureProtocol, false); + } + catch (Exception ex) + { + FireError(ex); + //Close(); + //throw; + } + } + } + + /// + /// Is the connection mutually authenticated? (was there a good client cert, etc.) + /// + public bool IsMutuallyAuthenticated + { + get + { + if (m_sslStream == null) + return false; + return m_sslStream.IsMutuallyAuthenticated; + } + } + + /// + /// Does the server require a client cert? If not, the client cert won't be sent. + /// + public bool RequireClientCert + { + get { return m_requireClientCert; } + set { m_requireClientCert = value; } + } + + /// + /// Start XEP-138 compression on this socket. + /// + public override void StartCompression() + { +#if ZLIB_NET + m_stream = new bedrock.io.ZlibStream(m_stream, ComponentAce.Compression.Libs.zlib.zlibConst.Z_FULL_FLUSH); +#else + throw new NotSupportedException(); +#endif + } + + /// + /// Connection complete. + /// + /// This is called solely by an async socket thread + /// + private void ExecuteConnect(IAsyncResult ar) + { + Debug.WriteLine("ExecuteConnect"); + lock (this) + { + try + { + m_sock.EndConnect(ar); + } + catch (SocketException e) + { + if (State != SocketState.Connecting) + { + // closed in the mean time. Probably not an error. + return; + } + FireError(e); + return; + } + if (m_sock.Connected) + { + // TODO: Check to see if this Mono bug is still valid. + // TODO: check to see if blocking should be turned back on after StartTLS. +#if __MonoCS__ + m_sock.Blocking = true; + m_stream = new NetworkStream(m_sock); + m_sock.Blocking = false; +#else + m_stream = new NetworkStream(m_sock); +#endif + + if (m_secureProtocol != SslProtocols.None) + { + try + { + StartTLS(); + } + catch (Exception e) + { + FireError(e); + AsyncClose(); + return; + } + } + + State = SocketState.Connected; + m_listener.OnConnect(this); + } + else + { + FireError(new AsyncSocketConnectionException("could not connect")); + AsyncClose(); + } + } + } + + private bool SyncRead() + { + int count = m_stream.Read(m_buf, 0, m_buf.Length); + + if (count > 0) + { + return m_listener.OnRead(this, m_buf, 0, count); + } + Close(); + return false; + } + + /// + /// Start an async read from the socket. Listener.OnRead() is + /// eventually called when data arrives. + /// + public override void RequestRead() + { + try + { + if (m_synch) + { + lock (this) + { + if (State != SocketState.Connected) + { + throw new InvalidOperationException("Socket not connected."); + } + } + + while (SyncRead()) + { + ; + } + return; + } + + lock (this) + { + if (m_reading) + { + throw new InvalidOperationException("Cannot call RequestRead while another read is pending."); + } + if (State != SocketState.Connected) + { + throw new InvalidOperationException("Socket not connected."); + } + + m_reading = true; + } + m_stream.BeginRead(m_buf, 0, m_buf.Length, new AsyncCallback(GotData), null); + } + catch (AuthenticationException) + { + Close(); + // don't throw. this gets caught elsewhere. + } + catch (SocketException e) + { + Close(); + + // 10053 = An established connection was aborted by the + // software in your host machine. + // 10054 = An existing connection was forcibly closed + // by the remote host. + if ((e.ErrorCode != 10053) && + (e.ErrorCode != 10054)) + { + throw; + } + } + catch (IOException) + { + Close(); + } + catch (Exception e) + { + Debug.WriteLine("Exception in RequestRead: " + e.ToString()); + Close(); + throw e; + } + } + + /// + /// Some data arrived. + /// + /// + protected virtual void GotData(IAsyncResult ar) + { + lock (this) + { + m_reading = false; + } + + int count; + try + { + count = m_stream.EndRead(ar); + } + catch (SocketException e) + { + AsyncClose(); + + // closed in middle of read + if (e.ErrorCode != 64) + { + FireError(e); + } + return; + } + catch(ObjectDisposedException) + { + //object already disposed, just exit + return; + } + catch (Exception e) + { + AsyncClose(); + FireError(e); + return; + } + if (count > 0) + { + //byte[] ret = new byte[count]; + //Buffer.BlockCopy(m_buf, 0, ret, 0, count); + + if (m_listener.OnRead(this, m_buf, 0, count) && + (m_state == SocketState.Connected)) + { + RequestRead(); + } + } + else + { + AsyncClose(); + } + } + + /// + /// Async write to the socket. Listener.OnWrite will be + /// called eventually when the data has been written. A + /// trimmed copy is made of the data, internally. + /// + /// Buffer to output + /// Offset into buffer + /// Number of bytes to output + public override void Write(byte[] buf, int offset, int len) + { + lock (this) + { + if (State != SocketState.Connected) + { + return; + //throw new InvalidOperationException("Socket must be connected before writing. Current state: " + State.ToString()); + } + + try + { + if (m_synch) + { + m_stream.Write(buf, offset, len); + m_listener.OnWrite(this, buf, offset, len); + } + else + { + + if (m_writing) + { + // already writing. save this for later. + m_pending.Write(buf, offset, len); + } + else + { + m_writing = true; + // make copy, since we might be a while in async-land + byte[] ret = new byte[len]; + Buffer.BlockCopy(buf, offset, ret, 0, len); + + m_stream.BeginWrite(ret, 0, ret.Length, + new AsyncCallback(WroteData), + ret); + } + } + } + catch (SocketException e) + { + Close(); + + // closed in middle of write + if (e.ErrorCode != 10054) + { + FireError(e); + } + return; + } + catch (Exception e) + { + Close(); + FireError(e); + return; + } + } + } + + /// + /// Data was written. + /// + /// + private void WroteData(IAsyncResult ar) + { + try + { + m_stream.EndWrite(ar); + } + catch (SocketException) + { + AsyncClose(); + return; + } + catch (ObjectDisposedException) + { + AsyncClose(); + return; + } + catch (Exception e) + { + AsyncClose(); + FireError(e); + return; + } + + lock (this) + { + m_writing = false; + } + byte[] buf = (byte[])ar.AsyncState; + m_listener.OnWrite(this, buf, 0, buf.Length); + + if (m_pending.Length > 0) + { + buf = m_pending.ToArray(); + m_pending.SetLength(0L); + Write(buf); + } + } + + /// + /// Close the socket. This is NOT async. .Net doesn't have + /// async closes. But, it can be *called* async, particularly + /// from GotData. Attempts to do a shutdown() first. + /// + public override void Close() + { + Debug.WriteLine("Close"); + lock (this) + { + /* + switch (State) + { + case State.Closed: + throw new InvalidOperationException("Socket already closed"); + case State.Closing: + throw new InvalidOperationException("Socket already closing"); + } + */ + + SocketState oldState = State; + + if (m_sock.Connected) + { + State = SocketState.Closing; + } + + if (m_stream != null) + m_stream.Close(); + else + { + try + { + m_sock.Close(); + } + catch { } + } + + if (oldState <= SocketState.Connected) + m_listener.OnClose(this); + + if (m_watcher != null) + m_watcher.CleanupSocket(this); + + State = SocketState.Closed; + } + } + + + /// + /// Close, called from async places, so that Errors get fired, + /// appropriately. + /// + protected void AsyncClose() + { + try + { + Close(); + } + catch(Exception e) + { + FireError(e); + } + } + + /// + /// Error occurred in the class. Send to Listener. + /// + /// + protected void FireError(Exception e) + { + lock (this) + { + State = SocketState.Error; + } + if (e is SocketException) + { + Debug.WriteLine("Sock errno: " + ((SocketException) e).ErrorCode); + } + if (m_watcher != null) + m_watcher.CleanupSocket(this); + m_listener.OnError(this, e); + } + + + /// + /// Return a string representation of this socket + /// + /// + public override string ToString() + { + return "AsyncSocket " + m_sock.LocalEndPoint + "->" + + m_sock.RemoteEndPoint; + } + + /// + /// In case SocketWatcher wants to use a HashTable. + /// + /// + public override int GetHashCode() + { + return m_id.GetHashCode(); + } + + #region IComparable + int IComparable.CompareTo(object val) + { + if (val == null) + return 1; + + AsyncSocket sock = val as AsyncSocket; + if ((object)sock == null) + throw new ArgumentException("value compared to is not an AsyncSocket", "val"); + + return this.m_id.CompareTo(sock.m_id); + } + + /// + /// IComparable's need to implement Equals(). This checks the + /// guid's for each socket to see if they are the same. + /// + /// The AsyncSocket to check against. + /// + public override bool Equals(object val) + { + AsyncSocket sock = val as AsyncSocket; + if (sock == null) + return false; + return (this.m_id == sock.m_id); + } + + /// + /// IComparable's need to implement ==. Checks for guid equality. + /// + /// First socket to compare + /// Second socket to compare + /// + public static bool operator==(AsyncSocket one, AsyncSocket two) + { + if ((object)one == null) + return ((object)two == null); + if ((object)two == null) + return false; + + return (one.m_id == two.m_id); + } + + /// + /// IComparable's need to implement comparison operators. + /// Checks compares guids. + /// + /// First socket to compare + /// Second socket to compare + /// + public static bool operator!=(AsyncSocket one, AsyncSocket two) + { + if ((object)one == null) + return ((object)two != null); + if ((object)two == null) + return true; + + return (one.m_id != two.m_id); + } + + /// + /// IComparable's need to implement comparison operators. Checks compares guids. + /// + /// First socket to compare + /// Second socket to compare + /// + public static bool operator<(AsyncSocket one, AsyncSocket two) + { + if ((object)one == null) + { + return ((object)two != null); + } + return (((IComparable)one).CompareTo(two) < 0); + } + /// + /// IComparable's need to implement comparison operators. + /// Checks compares guids. + /// + /// First socket to compare + /// Second socket to compare + /// + public static bool operator<=(AsyncSocket one, AsyncSocket two) + { + if ((object)one == null) + return true; + + return (((IComparable)one).CompareTo(two) <= 0); + } + /// + /// IComparable's need to implement comparison operators. + /// Checks compares guids. + /// + /// First socket to compare + /// Second socket to compare + /// + public static bool operator>(AsyncSocket one, AsyncSocket two) + { + if ((object)one == null) + return false; + return (((IComparable)one).CompareTo(two) > 0); + } + /// + /// IComparable's need to implement comparison operators. Checks compares guids. + /// + /// First socket to compare + /// Second socket to compare + /// + public static bool operator>=(AsyncSocket one, AsyncSocket two) + { + if ((object)one == null) + { + return (two == null); + } + return (((IComparable)one).CompareTo(two) >= 0); + } + + #endregion + + /// + /// Retrieve the socketwatcher used by this instance of AsyncSocket + /// + public SocketWatcher SocketWatcher + { + get + { + return m_watcher; + } + } + } +} diff -Nru smuxi-0.8/lib/jabber-net/bedrock/net/BaseSocket.cs smuxi-0.8.9.1/lib/jabber-net/bedrock/net/BaseSocket.cs --- smuxi-0.8/lib/jabber-net/bedrock/net/BaseSocket.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/jabber-net/bedrock/net/BaseSocket.cs 2012-01-03 07:52:11.000000000 +0000 @@ -0,0 +1,180 @@ +/* -------------------------------------------------------------------------- + * Copyrights + * + * Portions created by or assigned to Cursive Systems, Inc. are + * Copyright (c) 2002-2008 Cursive Systems, Inc. All Rights Reserved. Contact + * information for Cursive Systems, Inc. is available at + * http://www.cursive.net/. + * + * License + * + * Jabber-Net is licensed under the LGPL. + * See LICENSE.txt for details. + * --------------------------------------------------------------------------*/ +using System; + +using System.Diagnostics; + +namespace bedrock.net +{ + /// + /// Base class for AsyncSocket and proxies for AsyncSocket + /// + public abstract class BaseSocket + { + /// + /// Identity of the host we're connecting to. Used for SSL + /// validation, this is the name of the SRV we looked up, for + /// example. + /// + protected string m_hostid = null; + + /// + /// Call through this interface when events happen. WARNING: + /// AsyncSocket assumes this is not NULL. + /// + protected ISocketEventListener m_listener = null; + + /// + /// Only to be called by things that immediately set m_listener! + /// + protected BaseSocket() + { + } + + /// + /// Construct a BaseSocket. + /// + /// + protected BaseSocket(ISocketEventListener listener) + { + Debug.Assert(listener != null); + m_listener = listener; + } + + /// + /// Where to send notifications of interesting things. + /// WARNING! Only assign to this if you are Tom Waters. + /// + public virtual ISocketEventListener Listener + { + get + { + return m_listener; + } + set + { + lock (this) + { + //if (m_reading) + // throw new InvalidOperationException("Don't set listener while reading, Tom."); + m_listener = value; + } + } + } + + /// + /// Prepare to start accepting inbound requests. Call + /// RequestAccept() to start the async process. + /// Default the listen queue size to 5. + /// + /// Address to listen on + public void Accept(Address addr) + { + Accept(addr, 5); + } + + /// + /// Prepare to start accepting inbound requests. Call + /// RequestAccept() to start the async process. + /// + /// Address to listen on + /// The Maximum length of the queue of + /// pending connections + public abstract void Accept(Address addr, int backlog); + + /// + /// Start the flow of async accepts. Flow will continue while + /// Listener.OnAccept() returns true. Otherwise, call RequestAccept() again + /// to continue. + /// + public abstract void RequestAccept(); + + /// + /// Outbound connection. Eventually calls Listener.OnConnect() when + /// the connection comes up. Don't forget to call RequestRead() in + /// OnConnect()! + /// + /// Address/hostname to connect to + /// Identity of the host we're + /// connecting to. Used for SSL validation, this is the name + /// of the SRV we looked up, for example. + public void Connect(Address addr, string hostIdentity) + { + m_hostid = hostIdentity; + Connect(addr); + } + + /// + /// Outbound connection. Eventually calls Listener.OnConnect() when + /// the connection comes up. Don't forget to call RequestRead() in + /// OnConnect()! + /// + /// + public abstract void Connect(Address addr); + + /// + /// Returns true if the socket is connected. + /// + public abstract bool Connected + { + get; + } + +#if !NO_SSL + /// + /// Start TLS processing on an open socket. + /// + public abstract void StartTLS(); +#endif + + /// + /// Start XEP-138 compression on this socket. + /// + public abstract void StartCompression(); + + /// + /// Start an async read from the socket. Listener.OnRead() is + /// eventually called when data arrives. + /// + public abstract void RequestRead(); + + /// + /// Async write to the socket. Listener.OnWrite will be + /// called eventually when the data has been written. A copy + /// is made of the data, internally. + /// + /// Data to write + public void Write(byte[] buf) + { + Write(buf, 0, buf.Length); + } + + /// + /// Async write to the socket. Listener.OnWrite will be + /// called eventually when the data has been written. A + /// trimmed copy is made of the data, internally. + /// + /// Buffer to output + /// Offset into buffer + /// Number of bytes to output + public abstract void Write(byte[] buf, int offset, int len); + + /// + /// Close the socket. This is NOT async. .Net doesn't have + /// async closes. But, it can be *called* async, particularly + /// from GotData. Attempts to do a shutdown() first. + /// + public abstract void Close(); + } +} diff -Nru smuxi-0.8/lib/jabber-net/bedrock/net/CertUtil.cs smuxi-0.8.9.1/lib/jabber-net/bedrock/net/CertUtil.cs --- smuxi-0.8/lib/jabber-net/bedrock/net/CertUtil.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/jabber-net/bedrock/net/CertUtil.cs 2012-01-03 07:52:11.000000000 +0000 @@ -0,0 +1,60 @@ +/* -------------------------------------------------------------------------- + * Copyrights + * + * Portions created by or assigned to Cursive Systems, Inc. are + * Copyright (c) 2002-2008 Cursive Systems, Inc. All Rights Reserved. Contact + * information for Cursive Systems, Inc. is available at + * http://www.cursive.net/. + * + * License + * + * Jabber-Net can be used under either JOSL or the GPL. + * See LICENSE.txt for details. + * --------------------------------------------------------------------------*/ +using System; + +#if !NO_SSL && !NET20 && !__MonoCS__ +using Org.Mentalis.Security.Certificates; +using bedrock.util; + +namespace bedrock.net +{ + /// + /// Utilities for creating certificates + /// + [SVN(@"$Id$")] + public class CertUtil + { + /// + /// Can this cert be used for server authentication? + /// + private const string OID_PKIX_KP_SERVER_AUTH = "1.3.6.1.5.5.7.3.1"; + /// + /// Can this cert be used for client authentication? + /// + private const string OID_PKIX_KP_CLIENT_AUTH = "1.3.6.1.5.5.7.3.2"; + + /// + /// Find a server certificate in the given store. + /// + /// + /// + public static Certificate FindServerCert(CertificateStore store) + { + // return store.FindCertificate(new string[] {OID_PKIX_KP_SERVER_AUTH}); + return store.FindCertificateByUsage(new string[] {OID_PKIX_KP_SERVER_AUTH}); + } + + /// + /// Find a client certificate in the given store. + /// + /// + /// + public static Certificate FindClientCert(CertificateStore store) + { + //return store.FindCertificate(new string[] {OID_PKIX_KP_CLIENT_AUTH}); + return store.FindCertificateByUsage(new string[] {OID_PKIX_KP_CLIENT_AUTH}); + } + } +} +#endif diff -Nru smuxi-0.8/lib/jabber-net/bedrock/net/Exceptions.cs smuxi-0.8.9.1/lib/jabber-net/bedrock/net/Exceptions.cs --- smuxi-0.8/lib/jabber-net/bedrock/net/Exceptions.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/jabber-net/bedrock/net/Exceptions.cs 2012-01-03 07:52:11.000000000 +0000 @@ -0,0 +1,69 @@ +/* -------------------------------------------------------------------------- + * Copyrights + * + * Portions created by or assigned to Cursive Systems, Inc. are + * Copyright (c) 2002-2008 Cursive Systems, Inc. All Rights Reserved. Contact + * information for Cursive Systems, Inc. is available at + * http://www.cursive.net/. + * + * License + * + * Jabber-Net is licensed under the LGPL. + * See LICENSE.txt for details. + * --------------------------------------------------------------------------*/ +using System; +using bedrock.util; + +namespace bedrock.net +{ + /// + /// Lame exception, since I couldn't find one I liked. + /// + [SVN(@"$Id$")] + [Serializable] + public class AsyncSocketConnectionException : System.SystemException + { + /// + /// Create a new exception instance. + /// + /// + public AsyncSocketConnectionException(string description) + : base(description) + { + } + + /// + /// Create a new exception instance. + /// + public AsyncSocketConnectionException() + : base() + { + } + + /// + /// Create a new exception instance, wrapping another exception. + /// + /// Desecription of the exception + /// Inner exception + public AsyncSocketConnectionException(string description, Exception e) + : base(description, e) + { + } + + /// + /// Initializes a new instance of the + /// AsyncSocketConnectionException class with serialized + /// data. + /// + /// The object that holds the serialized + /// object data. + /// The contextual information about the + /// source or destination. + protected AsyncSocketConnectionException(System.Runtime.Serialization.SerializationInfo info, + System.Runtime.Serialization.StreamingContext ctx) + : + base(info, ctx) + { + } + } +} diff -Nru smuxi-0.8/lib/jabber-net/bedrock/net/HttpSocket.cs smuxi-0.8.9.1/lib/jabber-net/bedrock/net/HttpSocket.cs --- smuxi-0.8/lib/jabber-net/bedrock/net/HttpSocket.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/jabber-net/bedrock/net/HttpSocket.cs 2012-01-03 07:52:11.000000000 +0000 @@ -0,0 +1,647 @@ +/* -------------------------------------------------------------------------- + * Copyrights + * + * Portions created by or assigned to Cursive Systems, Inc. are + * Copyright (c) 2002-2008 Cursive Systems, Inc. All Rights Reserved. Contact + * information for Cursive Systems, Inc. is available at + * http://www.cursive.net/. + * + * License + * + * Jabber-Net is licensed under the LGPL. + * See LICENSE.txt for details. + * --------------------------------------------------------------------------*/ + +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Diagnostics; +using System.IO; +using System.Net; +using System.Text; +using System.Threading; + +using bedrock.util; + +namespace bedrock.net +{ + /// + /// Do basic HTTP processing, with a long-lived socket. + /// TODO: the BaseSocket parameter in the listener events will always be null for now. + /// TODO: change HttpSocket to be a is-a of AsyncSocket, not has-a. + /// + [SVN(@"$Id$")] + public class HttpSocket : BaseSocket, ISocketEventListener + { + private class PendingRequest + { + public string Method; + public Uri URI; + public byte[] Body; + public string ContentType; + public int Offset; + public int Length; + + public WebHeaderCollection Headers = new WebHeaderCollection(); + public int Code = -1; + public string ResponseText = null; + public MemoryStream Response; + + public PendingRequest(string method, Uri URL, byte[] body, int offset, int len, string contentType) + { + this.Method = method; + this.URI = URL; + this.Body = (body == null) ? new byte[] { } : body; + this.Offset = offset; + this.Length = len; + this.ContentType = contentType; + } + + public int ContentLength + { + get + { + string slen = this.Headers[HttpResponseHeader.ContentLength]; + if (slen == null) + { + Debug.WriteLine("No Content-Length header"); + return -1; + } + try + { + return int.Parse(slen); + } + catch (Exception) + { + Debug.WriteLine("Invalid Content-Length"); + return -1; + } + } + } + } + + private static readonly Encoding ENC = Encoding.UTF8; + private string m_host = null; + private Address m_addr = null; + private bool m_ssl = false; + + private AsyncSocket m_sock = null; + private ParseState m_state = ParseState.START; + private PendingRequest m_current = null; + private bool m_keepRunning = true; + private Uri m_proxyURI = null; + private NetworkCredential m_proxyCredentials = null; + private float m_connectRetrySec = 10.0F; + private int m_maxErrors = 5; + private int m_errorCount = 0; + private object m_lock = new Object(); + + private static readonly byte[] SPACE = ENC.GetBytes(" "); + private static readonly byte[] CRLF = ENC.GetBytes("\r\n"); + private static readonly byte[] COL_SP = ENC.GetBytes(": "); + private static readonly byte[] SP_HTTP11_CRLF = ENC.GetBytes(" HTTP/1.1\r\n"); + private static readonly byte[] HTTP11_SP = ENC.GetBytes("HTTP/1.1 "); + + /// + /// Create a socket. This starts a thread for background processing, but the thread is mostly paused + /// waiting for new requests. + /// + public HttpSocket(ISocketEventListener listener) : base(listener) + { + } + + /// + /// The URI of the HTTP proxy. Note: HTTPS connections through a proxy are not yet supported. + /// + [DefaultValue(null)] + public Uri ProxyURI + { + get { return m_proxyURI; } + set { m_proxyURI = value; } + } + + /// + /// Username/password for the proxy. + /// + [DefaultValue(null)] + public NetworkCredential ProxyCredentials + { + get { return m_proxyCredentials; } + set { m_proxyCredentials = value; } + } + + /// + /// How long to wait before attempting to reconnect, in seconds. + /// + [DefaultValue(10.0f)] + public float ReconnectTimeout + { + get { return m_connectRetrySec; } + set { m_connectRetrySec = value; } + } + + /// + /// The maximum number of reconnect attempts before giving up. + /// + [DefaultValue(5)] + public int MaxErrors + { + get { return m_maxErrors; } + set { m_maxErrors = value; } + } + + private string m_name; + + /// + /// The name of the socket, for debugging purposes + /// + public string Name + { + get { return m_name; } + set { m_name = value; } + } + + /// + /// Execute an HTTP request. + /// + /// The HTTP method verb. E.g. "GET", "POST", etc. + /// The URL to request. MUST be for the same host as the first request. + /// Any data to post with the request + /// The offset into body from which to start + /// The number of bytes to read from body, starting at offset + /// The MIME type of the supplied body + public void Execute(string method, Uri URL, byte[] body, int offset, int len, string contentType) + { + Debug.Assert(!this.IsPending); + + PendingRequest req = new PendingRequest(method, URL, body, offset, len, contentType); + if (m_host == null) + m_host = req.URI.Host; + else if (m_host != req.URI.Host) + throw new InvalidOperationException("All requests must got to same host: " + m_host); + + // connect if not yet connected + if (req.Method != null) + { + lock (m_lock) + { + if (!Connected) + { + Connect(req.URI); + + Monitor.Wait(m_lock, (int)(m_connectRetrySec * 1000)); + if (!m_keepRunning) + return; + + Debug.Assert(Connected); + Debug.Assert(!IsPending); + } + } + } + Send(req); + } + + /// + /// Is there an outstanding request that has not been responded to? + /// + public bool IsPending + { + get { return (m_current != null); } + } + + /// + /// Generally should not be used. + /// + /// + internal void Connect(Uri uri) + { + m_keepRunning = true; + + if (Connected) + return; + + m_ssl = (uri != null) && (uri.Scheme == "https"); + m_host = uri.Host; + if (m_proxyURI != null) + { + // TODO: add CONNECT support here. ShttpProxy? + if (m_ssl) + throw new InvalidOperationException("Can't do SSL through proxies yet."); + uri = m_proxyURI; + } + m_addr = new Address(uri.Host, uri.Port); + Connect(); + } + + private void Connect() + { + m_errorCount = 0; + + if (!m_keepRunning) + return; + m_state = ParseState.START; + m_sock = new AsyncSocket(null, this, m_ssl, false); + m_sock.Connect(m_addr, m_host); + } + + /// + /// Shut down the socket, abandoning any outstainding requests + /// + public override void Close() + { + lock (m_lock) + { + m_keepRunning = false; + // in case we closed while waiting for connect + Monitor.Pulse(m_lock); + } + + if (Connected) + m_sock.Close(); + m_sock = null; + } + + /// + /// Close the socket after any pending request is completed. + /// + public void EnqueueClose() + { + lock (m_lock) + { + if (!m_keepRunning) + return; + + m_keepRunning = false; + if (!IsPending) + Close(); + // otherwise, we'll close after the current pending request completes + } + } + + #region ISocketEventListener Members + + void ISocketEventListener.OnInit(BaseSocket newSock) + { + // This is the one listener event with a good socket, but it might not be the one that anyone expects. + // The important thing is that if someone wants to set the TCP buffer sizes downstream, it + // will work. + m_listener.OnInit(newSock); + } + + ISocketEventListener ISocketEventListener.GetListener(BaseSocket newSock) + { + throw new Exception("The method or operation is not implemented."); + } + + bool ISocketEventListener.OnAccept(BaseSocket newsocket) + { + throw new Exception("The method or operation is not implemented."); + } + + private static void WriteString(Stream s, string str) + { + byte[] buf = ENC.GetBytes(str); + s.Write(buf, 0, buf.Length); + } + + private void Send(PendingRequest req) + { + m_current = req; + + // Try to get it big enough that we don't have to allocate, without going overboard. + MemoryStream ms = new MemoryStream(req.Length + 256); + WriteString(ms, req.Method); + WriteString(ms, " "); + if (m_proxyURI == null) + WriteString(ms, req.URI.PathAndQuery); + else + WriteString(ms, req.URI.ToString()); + ms.Write(SP_HTTP11_CRLF, 0, SP_HTTP11_CRLF.Length); + + WebHeaderCollection coll = new WebHeaderCollection(); + coll.Add(HttpRequestHeader.Host, req.URI.Host); + if (req.ContentType != null) + coll.Add(HttpRequestHeader.ContentType, req.ContentType); + if (m_proxyCredentials != null) + { + byte[] creds = Encoding.ASCII.GetBytes(m_proxyCredentials.UserName + ":" + m_proxyCredentials.Password); + coll.Add("Proxy-Authorization", "Basic " + Convert.ToBase64String(creds)); + } + coll.Add("X-JN-Name", m_name); + coll.Add(HttpRequestHeader.Date, string.Format("{0:r}", DateTime.Now)); + coll.Add(HttpRequestHeader.ContentLength, req.Length.ToString()); + + byte[] headers = coll.ToByteArray(); + ms.Write(headers, 0, headers.Length); + + ms.Write(req.Body, req.Offset, req.Length); + + byte[] buf = ms.ToArray(); + + m_sock.Write(buf); + m_sock.RequestRead(); + } + + void ISocketEventListener.OnConnect(BaseSocket sock) + { + m_listener.OnConnect(null); + lock (m_lock) + { + Monitor.Pulse(m_lock); + } + } + + void ISocketEventListener.OnClose(BaseSocket sock) + { + m_sock = null; + lock (m_lock) + { + Monitor.Pulse(m_lock); + } + } + + void ISocketEventListener.OnError(BaseSocket sock, Exception ex) + { + if (Interlocked.Increment(ref m_errorCount) > m_maxErrors) + { + m_keepRunning = false; + m_listener.OnError(null, ex); + } + + lock (m_lock) + { + Monitor.Pulse(m_lock); + } + } + + private bool ParseAt(byte[] buf, ref int i, int last, byte[] check, int checkoffset) + { + int start = i; + for (int j = checkoffset; j < check.Length; j++) + { + if (i >= last) + { + i = start; + return false; + } + + if (buf[i++] != check[j]) + { + i = start; + return false; + } + } + return true; + } + + private string ParseTo(byte[] buf, ref int i, int last, byte[] check) + { + int start = i; + + // IndexOf should be in asm. + int j; + while (i < last) + { + j = Array.IndexOf(buf, check[0], i); + if (j == -1) + return null; + i = j; + if (check.Length > 1) + { + i++; + if (ParseAt(buf, ref i, last, check, 1)) + return ENC.GetString(buf, start, j - start); + } + else + return ENC.GetString(buf, start, j - start); + } + return null; + } + + private enum ParseState + { + START, + RESPONSE, + RESPONSE_TEXT, + HEADER_NAME, + HEADER_VALUE, + BODY_START, + BODY_CONTINUE + } + + private void Done() + { + m_state = ParseState.START; + m_current = null; + Debug.WriteLine("HTTP Socket " + m_name + " done"); + } + + bool ISocketEventListener.OnRead(BaseSocket sock, byte[] buf, int offset, int length) + { + Debug.WriteLine("IN HTTP(" + m_name + "): " + ENC.GetString(buf, offset, length)); + int i = offset; + string header = null; + int last = offset + length; + + while (i < last) + { + // HTTP/1.1 200 OK + // Header: value + // Header: value + // + // Content + switch (m_state) + { + case ParseState.START: + if (!ParseAt(buf, ref i, last, HTTP11_SP, 0)) + goto ERROR; + m_state = ParseState.RESPONSE; + break; + case ParseState.RESPONSE: + string code = ParseTo(buf, ref i, last, SPACE); + if (code == null) + goto ERROR; + + if (code != "200") + { + Debug.WriteLine("Non-OK response from server (" + code + "). STOP!"); + goto ERROR; + } + + try + { + // I know this can never fail. it's here for when we + // implement redirects and the like. + m_current.Code = int.Parse(code); + } + catch (Exception) + { + Debug.WriteLine("invalid response code"); + goto ERROR; + } + + m_state = ParseState.RESPONSE_TEXT; + break; + case ParseState.RESPONSE_TEXT: + m_current.ResponseText = ParseTo(buf, ref i, last, CRLF); + if (m_current.ResponseText == null) + goto ERROR; + m_state = ParseState.HEADER_NAME; + break; + case ParseState.HEADER_NAME: + if (ParseAt(buf, ref i, last, CRLF, 0)) + { + m_state = ParseState.BODY_START; + break; + } + header = ParseTo(buf, ref i, last, COL_SP); + if (header == null) + goto ERROR; + m_state = ParseState.HEADER_VALUE; + break; + case ParseState.HEADER_VALUE: + string val = ParseTo(buf, ref i, last, CRLF); + if (val == null) + goto ERROR; + m_current.Headers.Add(header, val); + m_state = ParseState.HEADER_NAME; + break; + case ParseState.BODY_START: + // if we have the whole response, which is typical in XEP-124, then return it all at + // once, without creating a MemoryStream. + int len = m_current.ContentLength; + if (len == -1) + goto ERROR; + if (i + len <= last) + { + Done(); + if (!m_listener.OnRead(this, buf, i, len) || !m_keepRunning) + { + Close(); + return false; + } + return false; + } + + // We got a partial response. We're going to have to wait until OnRead is called + // again before we can pass a full response upstream. Hold on to the pieces in a + // MemoryStream. + m_current.Response = new MemoryStream(len); + m_current.Response.Write(buf, i, last - i); + m_state = ParseState.BODY_CONTINUE; + return true; + case ParseState.BODY_CONTINUE: + m_current.Response.Write(buf, i, last - i); + if (m_current.Response.Length == m_current.Response.Capacity) + { + PendingRequest req = m_current; + Done(); + + byte[] resp = req.Response.ToArray(); + if (!m_listener.OnRead(this, resp, 0, resp.Length) || !m_keepRunning) + { + Close(); + return false; + } + + return false; + } + return true; + default: + break; + } + } + return true; + + ERROR: + m_listener.OnError(null, new ProtocolViolationException("Error parsing HTTP response")); + Close(); + return false; + } + + void ISocketEventListener.OnWrite(BaseSocket sock, byte[] buf, int offset, int length) + { + m_listener.OnWrite(null, buf, offset, length); + } + + bool ISocketEventListener.OnInvalidCertificate(BaseSocket sock, System.Security.Cryptography.X509Certificates.X509Certificate certificate, System.Security.Cryptography.X509Certificates.X509Chain chain, System.Net.Security.SslPolicyErrors sslPolicyErrors) + { + // TODO: pass up the chain + return m_listener.OnInvalidCertificate(null, certificate, chain, sslPolicyErrors); + } + + #endregion + + /// + /// Not implemented. + /// + /// + /// + public override void Accept(Address addr, int backlog) + { + throw new Exception("The method or operation is not implemented."); + } + + /// + /// Not implemented. + /// + public override void RequestAccept() + { + throw new Exception("The method or operation is not implemented."); + } + + /// + /// Not implemented. + /// + /// + public override void Connect(Address addr) + { + throw new Exception("The method or operation is not implemented."); + } + + /// + /// Are we currently connected? + /// + public override bool Connected + { + get { return (m_sock != null) && (m_sock.Connected); } + } + +#if !NO_SSL + /// + /// Not implemented. + /// + public override void StartTLS() + { + throw new Exception("The method or operation is not implemented."); + } +#endif + + /// + /// Not implemented. + /// + public override void StartCompression() + { + throw new Exception("The method or operation is not implemented."); + } + + /// + /// Not implemented. + /// + public override void RequestRead() + { + throw new Exception("The method or operation is not implemented."); + } + + /// + /// Not implemented. + /// + /// + /// + /// + public override void Write(byte[] buf, int offset, int len) + { + throw new Exception("The method or operation is not implemented."); + } + } +} diff -Nru smuxi-0.8/lib/jabber-net/bedrock/net/IHttpSocket.cs smuxi-0.8.9.1/lib/jabber-net/bedrock/net/IHttpSocket.cs --- smuxi-0.8/lib/jabber-net/bedrock/net/IHttpSocket.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/jabber-net/bedrock/net/IHttpSocket.cs 2012-01-03 07:52:11.000000000 +0000 @@ -0,0 +1,19 @@ +namespace bedrock.net +{ + interface IHttpSocket + { + string URL { get; set; } + } + + /// + /// This socket has special support for writing XML elements. + /// + public interface IElementSocket + { + /// + /// Write an XML element to the socket. + /// + /// + void Write(System.Xml.XmlElement elem); + } +} diff -Nru smuxi-0.8/lib/jabber-net/bedrock/net/ProxySocket.cs smuxi-0.8.9.1/lib/jabber-net/bedrock/net/ProxySocket.cs --- smuxi-0.8/lib/jabber-net/bedrock/net/ProxySocket.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/jabber-net/bedrock/net/ProxySocket.cs 2012-01-03 07:52:11.000000000 +0000 @@ -0,0 +1,318 @@ +/* -------------------------------------------------------------------------- + * Copyrights + * + * Portions created by or assigned to Cursive Systems, Inc. are + * Copyright (c) 2002-2008 Cursive Systems, Inc. All Rights Reserved. Contact + * information for Cursive Systems, Inc. is available at + * http://www.cursive.net/. + * + * License + * + * Jabber-Net is licensed under the LGPL. + * See LICENSE.txt for details. + * --------------------------------------------------------------------------*/ +using System; + +using System.Diagnostics; +using System.Text; +using bedrock.util; + +namespace bedrock.net +{ + /// + /// Proxy object for sockets. + /// + [SVN(@"$Id$")] + public class ProxySocket : BaseSocket, ISocketEventListener + { + private BaseSocket m_sock = null; + private string m_host = null; + private int m_port = 0; + private string m_username = null; + private string m_password = null; + private Address m_remote_addr = null; + private bool m_ssl = false; + + /// + /// Wrap an existing socket event listener with a proxy. Make SURE to set Socket after this. + /// + /// Event listener to pass events through to. + public ProxySocket(ISocketEventListener chain) : base(chain) + { + } + + /// + /// The address that the proxy should connect to. + /// + public Address RemoteAddress + { + get { return m_remote_addr; } + set { m_remote_addr = value; } + } + + /// + /// The lower level socket + /// + public BaseSocket Socket + { + get { return m_sock; } + set { m_sock = value; } + } + + /// + /// the host running the proxy + /// + public string Host + { + get { return m_host; } + set { m_host = value; } + } + + /// + /// the port to talk to the proxy host on + /// + public int Port + { + get { return m_port; } + set { m_port = value; } + } + + /// + /// Do SSL **after** connected through the proxy. + /// + public bool SSL + { + get { return m_ssl; } + set { m_ssl = value; } + } + + /// + /// the auth username for the proxy + /// + public string Username + { + get { return m_username; } + set { m_username = value; } + } + + /// + /// the auth password for the proxy + /// + public string Password + { + get { return m_password; } + set { m_password = value; } + } + + /// + /// Are we currently connected? + /// + public override bool Connected + { + get { return false; } + } + + /// + /// Prepare to start accepting inbound requests. Call RequestAccept() to start the async process. + /// + /// Address to listen on + /// The Maximum length of the queue of pending connections + public override void Accept(bedrock.net.Address addr, int backlog) + { + m_sock.Accept(addr, backlog); + } + + /// + /// Close the socket. This is NOT async. .Net doesn't have async closes. + /// But, it can be *called* async, particularly from GotData. + /// Attempts to do a shutdown() first. + /// + public override void Close() + { + m_sock.Close(); + } + + /// + /// Saves the address passed in, and really connects to m_host:m_port. + /// + /// + public override void Connect(bedrock.net.Address addr) + { + m_remote_addr = addr; // save this till we are ready for it... + Debug.Assert(m_host != null); + Debug.Assert(m_port != 0); + // connect to the proxy. + Address proxy_addr = new Address(m_host, m_port); + m_sock.Connect(proxy_addr, m_hostid); + // we'll end up in OnConnected below. + } + +#if !NO_SSL + /// + /// Start TLS processing on an open socket. + /// + public override void StartTLS() + { + m_sock.StartTLS(); + } +#endif + + /// + /// Start compression processing on an open socket. + /// + public override void StartCompression() + { + m_sock.StartCompression(); + } + + /// + /// Start the flow of async accepts. Flow will continue while + /// Listener.OnAccept() returns true. Otherwise, call RequestAccept() again + /// to continue. + /// + public override void RequestAccept() + { + m_sock.RequestAccept(); + } + + /// + /// Start an async read from the socket. Listener.OnRead() is eventually called + /// when data arrives. + /// + public override void RequestRead() + { + m_sock.RequestRead(); + } + + /// + /// Async write to the socket. Listener.OnWrite will be called eventually + /// when the data has been written. A trimmed copy is made of the data, internally. + /// + /// Buffer to output + /// Offset into buffer + /// Number of bytes to output + public override void Write(byte[] buf, int offset, int len) + { + m_sock.Write(buf, offset, len); + } + + #region Implementation of ISocketEventListener + + /// + /// + /// + /// + public virtual void OnInit(BaseSocket newSock) + { + m_listener.OnInit(newSock); + } + + /// + /// + /// + /// + /// + public virtual ISocketEventListener GetListener(BaseSocket newSock) + { + return m_listener.GetListener(newSock); + } + + /// + /// + /// + /// + /// + public virtual bool OnAccept(BaseSocket newsocket) + { + return m_listener.OnAccept(newsocket); + } + + /// + /// + /// + /// + public virtual void OnConnect(BaseSocket sock) + { + if (m_ssl) + { +#if !NO_SSL + m_sock.StartTLS(); +#else + throw new NotImplementedException("SSL not compiled in"); +#endif + } + m_listener.OnConnect(sock); + } + + /// + /// + /// + /// + public virtual void OnClose(BaseSocket sock) + { + m_listener.OnClose(sock); + } + + /// + /// + /// + /// + /// + public virtual void OnError(BaseSocket sock, System.Exception ex) + { + m_listener.OnError(sock, ex); + } + + /// + /// + /// + /// + /// + /// + /// + /// + public virtual bool OnRead(BaseSocket sock, byte[] buf, int offset, int length) + { + return m_listener.OnRead(sock, buf, offset, length); + } + + /// + /// + /// + /// + /// + /// + /// + public virtual void OnWrite(BaseSocket sock, byte[] buf, int offset, int length) + { + m_listener.OnWrite(sock, buf, offset, length); + } + + /// + /// An invalid peer certificate was sent during SSL/TLS neogtiation. + /// + /// The socket that experienced the error + /// The bad certificate + /// The chain of CAs for the cert + /// A bitfield for the erorrs in the certificate. + /// True if the cert should be accepted anyway. + public virtual bool OnInvalidCertificate(BaseSocket sock, + System.Security.Cryptography.X509Certificates.X509Certificate certificate, + System.Security.Cryptography.X509Certificates.X509Chain chain, + System.Net.Security.SslPolicyErrors sslPolicyErrors) + { + return m_listener.OnInvalidCertificate(sock, certificate, chain, sslPolicyErrors); + } + #endregion + + /// + /// String representation of the proxy socket. + /// + /// + public override string ToString() + { + return "Proxy connection to: " + RemoteAddress.ToString(); + } + + } +} diff -Nru smuxi-0.8/lib/jabber-net/bedrock/net/ShttpProxy.cs smuxi-0.8.9.1/lib/jabber-net/bedrock/net/ShttpProxy.cs --- smuxi-0.8/lib/jabber-net/bedrock/net/ShttpProxy.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/jabber-net/bedrock/net/ShttpProxy.cs 2012-01-03 07:52:11.000000000 +0000 @@ -0,0 +1,173 @@ +/* -------------------------------------------------------------------------- + * Copyrights + * + * Portions created by or assigned to Cursive Systems, Inc. are + * Copyright (c) 2002-2008 Cursive Systems, Inc. All Rights Reserved. Contact + * information for Cursive Systems, Inc. is available at + * http://www.cursive.net/. + * + * License + * + * Jabber-Net is licensed under the LGPL. + * See LICENSE.txt for details. + * --------------------------------------------------------------------------*/ +using System; + +using System.Diagnostics; +using System.Text; +using bedrock.util; + +namespace bedrock.net +{ + /// + /// Proxy object for sockets that want to do SHTTP proxying. + /// + [SVN(@"$Id$")] + public class ShttpProxy : ProxySocket + { + private enum States { None, Connecting, WaitingForAuth, Running, Closed, Error } + private States m_state = States.None; + private System.IO.MemoryStream m_headerstream = new System.IO.MemoryStream(); + private System.Collections.ArrayList m_headers = new System.Collections.ArrayList(); + + /// + /// Wrap an existing socket event listener with a ShttpProxy proxy. Make SURE to set Socket after this. + /// + /// Event listener to pass events through to. + public ShttpProxy(ISocketEventListener chain) : base(chain) + { + } + + /// + /// Remember that we're in the connecting state, let base connect to proxy, resumes in OnConnect. + /// + /// + public override void Connect(bedrock.net.Address addr) + { + m_state = States.Connecting; + base.Connect(addr); + } + + #region Implementation of ISocketEventListener + + /// + /// overridden OnConnect to start off SHTTP protocol. + /// + /// + public override void OnConnect(bedrock.net.BaseSocket sock) + { + if (m_state == States.Connecting) + { // CONNECT users.instapix.com:5222 HTTP/1.0 + m_state = States.WaitingForAuth; + string cmd = string.Format(@"CONNECT {0}:{1} HTTP/1.1 +Host: {0} +", RemoteAddress.Hostname, RemoteAddress.Port); + + // if authinfo is set, send it. + if (Username != null && Username.Length > 0 && Password != null && Password.Length > 0) + { + string auth = Convert.ToBase64String(Encoding.ASCII.GetBytes(Username + ":" + Password)); + cmd += "Proxy-Authorization: Basic " + auth + "\r\n"; + } + cmd += "\r\n"; + Debug.WriteLine("PSEND:" + cmd); + Write(Encoding.ASCII.GetBytes(cmd)); + RequestRead(); + } + } + + /// + /// Overridden OnRead to handle 4 Socks5 states... + /// + /// + /// + /// + /// + /// + public override bool OnRead(bedrock.net.BaseSocket sock, byte[] buf, int offset, int length) + { + switch (m_state) + { + case States.WaitingForAuth: + m_headerstream.Write(buf, offset, length); + int state = 0; + int line = 0; + foreach (byte b in buf) + { + // Look for \r\n\r\n for end of response header + switch (state) + { + case 0: + if (b == '\r') + state++; + break; + case 1: + if (b == '\n') + { + byte[] hs = m_headerstream.ToArray(); + string s = System.Text.Encoding.UTF8.GetString(hs); + Debug.Write("PRECV: " + s); + m_headers.Add(s); + m_headerstream.SetLength(0); + state++; + line++; + } + else + state = 0; + break; + case 2: + if (b == '\r') + state++; + else + state = 0; + break; + case 3: + if (b == '\n') + { + Debug.WriteLine("End of proxy headers"); + string line0 = (string)m_headers[0]; + if (line0.IndexOf("200") == -1) + { + Debug.WriteLine("200 response not detected. Closing."); + m_state = States.Error; + this.Close(); + } + else + { + Debug.WriteLine("Proxy connected"); + m_listener.OnConnect(sock); // tell the real listener that we're connected. + m_state = States.Running; + } + // they'll call RequestRead(), so we can return false here. + return false; + } + else + state = 0; + break; + } + } + return true; + case States.Error: + throw new InvalidOperationException("Cannot read after error"); + default: + return base.OnRead(sock, buf, offset, length); + } + } + + /// + /// Overridden OnWrite to ensure that the base only gets called when in running state. + /// + /// + /// + /// + /// + public override void OnWrite(bedrock.net.BaseSocket sock, byte[] buf, int offset, int length) + { + if (m_state == States.Running) + { + base.OnWrite(sock, buf, offset, length); + } + } + #endregion + } +} diff -Nru smuxi-0.8/lib/jabber-net/bedrock/net/SocketEventListener.cs smuxi-0.8.9.1/lib/jabber-net/bedrock/net/SocketEventListener.cs --- smuxi-0.8/lib/jabber-net/bedrock/net/SocketEventListener.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/jabber-net/bedrock/net/SocketEventListener.cs 2012-01-03 07:52:11.000000000 +0000 @@ -0,0 +1,203 @@ +/* -------------------------------------------------------------------------- + * Copyrights + * + * Portions created by or assigned to Cursive Systems, Inc. are + * Copyright (c) 2002-2008 Cursive Systems, Inc. All Rights Reserved. Contact + * information for Cursive Systems, Inc. is available at + * http://www.cursive.net/. + * + * License + * + * Jabber-Net is licensed under the LGPL. + * See LICENSE.txt for details. + * --------------------------------------------------------------------------*/ +using System; + +using bedrock.util; +namespace bedrock.net +{ + /// + /// Interface class for Socket events. Any object which + /// implements these interfaces is eligible to recieve Socket + /// events. This is an interface instead of events in order + /// to preserve symmetry with libbedrock. + /// + [SVN(@"$Id$")] + public interface ISocketEventListener + { + /// + /// An accept socket is about to be bound, or a connect socket is about to connect, + /// or an incoming socket just came in. Use this as an opportunity to + /// + /// The new socket that is about to be connected. + void OnInit(BaseSocket newSock); + + /// + /// We accepted a socket, and need to get a listener. + /// If the return value is null, then the socket will be closed, + /// and RequestAccept will ALWAYS be called. + /// + /// The new socket. + /// The listener for the *new* socket, as compared to + /// the listener for the *listen* socket + ISocketEventListener GetListener(BaseSocket newSock); + + /// + /// A new incoming connection was accepted. + /// + /// Socket for new connection. + /// true if RequestAccept() should be called automatically again + bool OnAccept(BaseSocket newsocket); + /// + /// Outbound connection was connected. + /// + /// Connected socket. + void OnConnect(BaseSocket sock); + /// + /// Connection was closed. + /// + /// Closed socket. Already closed! + void OnClose(BaseSocket sock); + /// + /// An error happened in processing. The socket is no longer open. + /// + /// Socket in error + /// Exception that caused the error + void OnError(BaseSocket sock, Exception ex); + /// + /// Bytes were read from the socket. + /// + /// The socket that was read from. + /// The bytes that were read. + /// Offset into the buffer to start at + /// Number of bytes to use out of the buffer + /// true if RequestRead() should be called automatically again + bool OnRead (BaseSocket sock, byte[] buf, int offset, int length); + /// + /// Bytes were written to the socket. + /// + /// The socket that was written to. + /// The bytes that were written. + /// Offset into the buffer to start at + /// Number of bytes to use out of the buffer + void OnWrite(BaseSocket sock, byte[] buf, int offset, int length); + + /// + /// An invalid peer certificate was sent during SSL/TLS neogtiation. + /// + /// The socket that experienced the error + /// The bad certificate + /// The chain of CAs for the cert + /// A bitfield for the erorrs in the certificate. + /// True if the cert should be accepted anyway. + bool OnInvalidCertificate(BaseSocket sock, + System.Security.Cryptography.X509Certificates.X509Certificate certificate, + System.Security.Cryptography.X509Certificates.X509Chain chain, + System.Net.Security.SslPolicyErrors sslPolicyErrors); + } + /// + /// Default, empty implementation of ISocketEventListener + /// + [SVN(@"$Id$")] + public class SocketEventListener : ISocketEventListener + { + #region Implementation of ISocketEventListener + /// + /// An accept socket is about to be bound, or a connect socket is about to connect, + /// or an incoming socket just came in. Use this as an opportunity to + /// + /// The new socket that is about to be connected. + public virtual void OnInit(BaseSocket newSock) + { + } + + /// + /// We accepted a socket, and need to get a listener. + /// If the return value is null, then the socket will be closed, + /// and RequestAccept will ALWAYS be called. + /// + /// The new socket. + /// The listener for the *new* socket, as compared to + /// the listener for the *listen* socket + public virtual ISocketEventListener GetListener(BaseSocket newSock) + { + return this; + } + + /// + /// A new incoming connection was accepted. + /// + /// Socket for new connection. + /// true if RequestAccept() should be called automatically again + public virtual bool OnAccept(BaseSocket newsocket) + { + return true; + } + + /// + /// Outbound connection was connected. + /// + /// Connected socket. + public virtual void OnConnect(BaseSocket sock) + { + } + + /// + /// Connection was closed. + /// + /// Closed socket. Already closed! + public virtual void OnClose(BaseSocket sock) + { + } + + /// + /// An error happened in processing. The socket is no longer open. + /// + /// Socket in error + /// Exception that caused the error + public virtual void OnError(BaseSocket sock, System.Exception ec) + { + } + + /// + /// Bytes were read from the socket. + /// + /// The socket that was read from. + /// The bytes that were read. + /// true if RequestRead() should be called automatically again + /// Offset into the buffer to start at + /// Number of bytes to use out of the buffer + public virtual bool OnRead(BaseSocket sock, byte[] buf, int offset, int length) + { + return true; + } + + /// + /// Bytes were written to the socket. + /// + /// The socket that was written to. + /// The bytes that were written. + /// Offset into the buffer to start at + /// Number of bytes to use out of the buffer + public virtual void OnWrite(BaseSocket sock, byte[] buf, int offset, int length) + { + } + + /// + /// An invalid peer certificate was sent during SSL/TLS neogtiation. + /// + /// The socket that experienced the error + /// The bad certificate + /// The chain of CAs for the cert + /// A bitfield for the erorrs in the certificate. + /// True if the cert should be accepted anyway. + public virtual bool OnInvalidCertificate(BaseSocket sock, + System.Security.Cryptography.X509Certificates.X509Certificate certificate, + System.Security.Cryptography.X509Certificates.X509Chain chain, + System.Net.Security.SslPolicyErrors sslPolicyErrors) + { + return false; + } + #endregion + } +} diff -Nru smuxi-0.8/lib/jabber-net/bedrock/net/SocketWatcher.cs smuxi-0.8.9.1/lib/jabber-net/bedrock/net/SocketWatcher.cs --- smuxi-0.8/lib/jabber-net/bedrock/net/SocketWatcher.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/jabber-net/bedrock/net/SocketWatcher.cs 2012-01-03 07:52:11.000000000 +0000 @@ -0,0 +1,318 @@ +/* -------------------------------------------------------------------------- + * Copyrights + * + * Portions created by or assigned to Cursive Systems, Inc. are + * Copyright (c) 2002-2008 Cursive Systems, Inc. All Rights Reserved. Contact + * information for Cursive Systems, Inc. is available at + * http://www.cursive.net/. + * + * License + * + * Jabber-Net is licensed under the LGPL. + * See LICENSE.txt for details. + * --------------------------------------------------------------------------*/ +using System; + +using System.Collections; +using System.Diagnostics; +using System.IO; + +using bedrock.util; +using bedrock.collections; + +using System.Security.Cryptography.X509Certificates; + +namespace bedrock.net +{ + /// + /// A collection of sockets. This makes a lot more sense in the poll() version (Unix/C) since + /// you need to have a place to collect all of the sockets and call poll(). Here, it's just + /// convenience functions. + /// + [SVN(@"$Id$")] + public class SocketWatcher : IDisposable + { + private enum State + { + Running, + Shutdown, + Stopped + }; + + private ISet m_pending = new Set(SetImplementation.SkipList); + private ISet m_socks = new Set(SetImplementation.SkipList); + private object m_lock = new object(); + private int m_maxSocks; + private bool m_synch = false; + + private X509Certificate2 m_cert = null; + private bool m_requireClientCert = false; + + /// + /// Create a new instance, which will manage an unlimited number of sockets. + /// + public SocketWatcher() + { + m_maxSocks = -1; + } + + /// + /// Create a new instance. + /// + /// Maximum number of sockets to watch. In this version, + /// this is mostly for rate-limiting purposes. + public SocketWatcher(int maxsockets) + { + m_maxSocks = maxsockets; + } + + /// + /// Synchronous operation + /// + public bool Synchronous + { + get { return m_synch; } + set { m_synch = value; } + } + + /// + /// The maximum number of sockets watched. Throws + /// InvalidOperationException if the new value is fewer than the number + /// currently open. -1 means no limit. + /// + public int MaxSockets + { + get { return m_maxSocks; } + set + { + lock(m_lock) + { + if ((value >= 0) && (m_socks.Count >= value)) + throw new InvalidOperationException("Too many sockets: " + m_socks.Count); + + m_maxSocks = value; + } + } + } + + /// + /// The certificate to be used for the local side of sockets, with SSL on. + /// + public X509Certificate2 LocalCertificate + { + get { return m_cert; } + set { m_cert = value; } + } + + /// + /// Does the server require a client cert? If not, the client cert won't be sent. + /// + public bool RequireClientCert + { + get { return m_requireClientCert; } + set { m_requireClientCert = value; } + } + + /// + /// Set the certificate to be used for accept sockets. To generate a test .pfx file using openssl, + /// add this to openssl.conf: + ///
+ /// [ serverex ] + /// extendedKeyUsage=1.3.6.1.5.5.7.3.1 + ///
+ /// and run the following commands: + ///
+ /// openssl req -new -x509 -newkey rsa:1024 -keyout privkey.pem -out key.pem -extensions serverex + /// openssl pkcs12 -export -in key.pem -inkey privkey.pem -name localhost -out localhost.pfx + ///
+ /// If you leave the certificate null, and you are doing Accept, the SSL class will try to find a + /// default server cert on your box. If you have IIS installed with a cert, this might just go... + ///
+ /// A .pfx or .cer file + /// The password, if this is a .pfx file, null if .cer file. + public void SetCertificateFile(string filename, + string password) + { + m_cert = new X509Certificate2(filename, password); + // TODO: check cert for validity + } + + /// + /// Set the certificate from a system store. Try "MY" for the ones listed in IE. + /// + /// + public void SetCertificateStore(StoreName storeName) + { + throw new NotImplementedException("Not implemented yet. Need to figure out how to search for 'server' certs."); + } + + /// + /// Create a socket that is listening for inbound connections. + /// + /// Where to send notifications + /// Address to connect to + /// The maximum length of the queue of pending connections + /// Do SSL3/TLS1 on connect + /// A socket that is ready for calling RequestAccept() + public AsyncSocket CreateListenSocket(ISocketEventListener listener, + Address addr, + int backlog, + bool SSL) + { + //Debug.Assert(m_maxSocks > 1); + AsyncSocket result = new AsyncSocket(this, listener, SSL, m_synch); + if (SSL) + { + result.LocalCertificate = m_cert; + result.RequireClientCert = m_requireClientCert; + } + result.Accept(addr, backlog); + return result; + } + + /// + /// Create a socket that is listening for inbound connections. + /// + /// Where to send notifications + /// Address to connect to + /// Do SSL3/TLS1 on connect + /// A socket that is ready for calling RequestAccept() + public AsyncSocket CreateListenSocket(ISocketEventListener listener, + Address addr, + bool SSL) + { + return CreateListenSocket(listener, addr, 5, SSL); + } + + /// + /// Create a socket that is listening for inbound connections, with no SSL/TLS. + /// + /// Where to send notifications + /// Address to connect to + /// A socket that is ready for calling RequestAccept() + public AsyncSocket CreateListenSocket(ISocketEventListener listener, + Address addr) + { + return CreateListenSocket(listener, addr, 5, false); + } + + /// + /// Create a socket that is listening for inbound connections, with no SSL/TLS. + /// + /// Where to send notifications + /// Address to connect to + /// The maximum length of the queue of pending connections + /// A socket that is ready for calling RequestAccept() + public AsyncSocket CreateListenSocket(ISocketEventListener listener, + Address addr, + int backlog) + { + return CreateListenSocket(listener, addr, backlog, false); + } + + /// + /// Create an outbound socket. + /// + /// Where to send notifications + /// Address to connect to + /// Socket that is in the process of connecting + public AsyncSocket CreateConnectSocket(ISocketEventListener listener, + Address addr) + { + return CreateConnectSocket(listener, addr, false, null); + } + + /// + /// Create an outbound socket. + /// + /// Where to send notifications + /// Address to connect to + /// Do SSL3/TLS1 on startup + /// The logical name of the host to connect to, for SSL/TLS purposes. + /// Socket that is in the process of connecting + public AsyncSocket CreateConnectSocket(ISocketEventListener listener, + Address addr, + bool SSL, + string hostId) + { + AsyncSocket result; + + // Create the socket: + result = new AsyncSocket(this, listener, SSL, m_synch); + if (SSL) + result.LocalCertificate = m_cert; + + // Start the connect process: + result.Connect(addr, hostId); + return result; + } + + /// + /// Called by AsyncSocket when a new connection is received on a listen socket. + /// + /// New socket connection + public void RegisterSocket(AsyncSocket s) + { + lock (m_lock) + { + if ((m_maxSocks >= 0) && (m_socks.Count >= m_maxSocks)) + throw new InvalidOperationException("Too many sockets: " + m_socks.Count); + m_socks.Add(s); + } + } + + /// + /// Called by AsyncSocket when a socket is closed. + /// + /// Closed socket + public void CleanupSocket(AsyncSocket s) + { + lock (m_lock) + { + m_socks.Remove(s); + + if (m_pending.Contains(s)) + { + m_pending.Remove(s); + } + else + { + foreach (AsyncSocket sock in m_pending) + { + sock.RequestAccept(); + } + m_pending.Clear(); + } + } + } + + /// + /// Called by AsyncSocket when this class is full, and the listening AsyncSocket + /// socket would like to be restarted when there are slots free. + /// + /// Listening socket + public void PendingAccept(AsyncSocket s) + { + lock (m_lock) + { + m_pending.Add(s); + } + } + + /// + /// Or close. Potato, tomato. This is useful if you want to use using(). + /// + public void Dispose() + { + lock (m_lock) + { + m_pending.Clear(); + foreach (AsyncSocket s in m_socks) + { + s.Close(); + } + m_socks.Clear(); + } + } + } +} diff -Nru smuxi-0.8/lib/jabber-net/bedrock/net/Socks4Proxy.cs smuxi-0.8.9.1/lib/jabber-net/bedrock/net/Socks4Proxy.cs --- smuxi-0.8/lib/jabber-net/bedrock/net/Socks4Proxy.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/jabber-net/bedrock/net/Socks4Proxy.cs 2012-01-03 07:52:11.000000000 +0000 @@ -0,0 +1,176 @@ +/* -------------------------------------------------------------------------- + * Copyrights + * + * Portions created by or assigned to Cursive Systems, Inc. are + * Copyright (c) 2002-2008 Cursive Systems, Inc. All Rights Reserved. Contact + * information for Cursive Systems, Inc. is available at + * http://www.cursive.net/. + * + * License + * + * Jabber-Net is licensed under the LGPL. + * See LICENSE.txt for details. + * --------------------------------------------------------------------------*/ +using System; + +using System.Diagnostics; +using System.Text; +using System.Net; +using bedrock.util; + +namespace bedrock.net +{ + /// + /// Proxy object for sockets that want to do SOCKS4 proxying. + /// + [SVN(@"$Id$")] + public class Socks4Proxy : ProxySocket + { + private enum States { None, Connecting, RequestingProxy, Running, Closed } + private States m_state = States.None; + + /// + /// Wrap an existing socket event listener with a Socks5 proxy. Make SURE to set Socket after this. + /// + /// Event listener to pass events through to. + public Socks4Proxy(ISocketEventListener chain) : base(chain) + { + } + + /// + /// Saves the address passed in, and really connects to ProxyHost:ProxyPort to begin SOCKS5 handshake. + /// + /// + public override void Connect(bedrock.net.Address addr) + { + m_state = States.Connecting; + base.Connect(addr); + } + + #region Socks4 private methods. + + /* + +----+----+----+----+----+----+----+----+ + | VN | CD | DSTPORT | DSTIP | + +----+----+----+----+----+----+----+----+ + # of bytes: 1 1 2 4 + + VN is the version of the reply code and should be 0. CD is the result + code with one of the following values: + + 90: request granted + 91: request rejected or failed + 92: request rejected becasue SOCKS server cannot connect to + identd on the client + 93: request rejected because the client program and identd + report different user-ids + + */ + private bool HandleRequestResponse(int ver, int reply) + { + if (ver != 0) + { + Debug.WriteLine("bogus version in reply from proxy: " + ver); + return false; + } + if (reply != 90) + { + Debug.WriteLine("request failed on proxy: " + reply); + return false; + } + Debug.WriteLine("proxy complete"); + m_state = States.Running; + return true; + } + + #endregion + + #region Implementation of ISocketEventListener + + /// + /// overridden OnConnect to start off Socks5 protocol. + /// + /// + public override void OnConnect(bedrock.net.BaseSocket sock) + { + if (m_state == States.Connecting) + { + IPHostEntry server = Dns.GetHostEntry(RemoteAddress.Hostname); + IPAddress ip_addr = server.AddressList[0]; + + byte[] addr = ip_addr.GetAddressBytes(); + + int port = RemoteAddress.Port; + byte [] buffer = new Byte[14]; + buffer[0] = 4; // protocol version. + buffer[1] = 1; // connect. + buffer[2] = (byte)(port >> 8); + buffer[3] = (byte)port; + // TODO: test byte order! + buffer[4] = addr[3]; + buffer[5] = addr[2]; + buffer[6] = addr[1]; + buffer[7] = addr[0]; + buffer[8] = (byte)'i'; + buffer[9] = (byte)'d'; + buffer[10] = (byte)'e'; + buffer[11] = (byte)'n'; + buffer[12] = (byte)'t'; + buffer[13] = 0; + + /* + +----+----+----+----+----+----+----+----+----+----+....+----+ + | VN | CD | DSTPORT | DSTIP | USERID |NULL| + +----+----+----+----+----+----+----+----+----+----+....+----+ + # of bytes: 1 1 2 4 variable 1 + */ + + + Write(buffer); + RequestRead(); + m_state = States.RequestingProxy; + } + } + + /// + /// Overridden OnRead to handle 4 Socks5 states... + /// + /// + /// + /// + /// + /// + public override bool OnRead(bedrock.net.BaseSocket sock, byte[] buf, int offset, int length) + { + switch (m_state) + { + case States.RequestingProxy: + bool ret = HandleRequestResponse(buf[offset], buf[offset + 1]); + if (ret) + { + m_listener.OnConnect(sock); // tell the real listener that we're connected. + // they'll call RequestRead(), so we can return false here. + } + return false; + default: + return base.OnRead(sock, buf, offset, length); + } + } + + /// + /// Overridden OnWrite to ensure that the base only gets called when in running state. + /// + /// + /// + /// + /// + public override void OnWrite(bedrock.net.BaseSocket sock, byte[] buf, int offset, int length) + { + if (m_state == States.Running) + { + base.OnWrite(sock, buf, offset, length); + } + } + #endregion + } +} diff -Nru smuxi-0.8/lib/jabber-net/bedrock/net/Socks5Proxy.cs smuxi-0.8.9.1/lib/jabber-net/bedrock/net/Socks5Proxy.cs --- smuxi-0.8/lib/jabber-net/bedrock/net/Socks5Proxy.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/jabber-net/bedrock/net/Socks5Proxy.cs 2012-01-03 07:52:11.000000000 +0000 @@ -0,0 +1,265 @@ +/* -------------------------------------------------------------------------- + * Copyrights + * + * Portions created by or assigned to Cursive Systems, Inc. are + * Copyright (c) 2002-2008 Cursive Systems, Inc. All Rights Reserved. Contact + * information for Cursive Systems, Inc. is available at + * http://www.cursive.net/. + * + * License + * + * Jabber-Net is licensed under the LGPL. + * See LICENSE.txt for details. + * --------------------------------------------------------------------------*/ +using System; + +using System.Diagnostics; +using System.Text; +using bedrock.util; + +namespace bedrock.net +{ + /// + /// Proxy object for sockets that want to do SOCKS proxying. + /// + [SVN(@"$Id$")] + public class Socks5Proxy : ProxySocket + { + private enum States { None, Connecting, GettingMethods, WaitingForAuth, RequestingProxy, Running, Closed } + private States m_state = States.None; + + /// + /// Wrap an existing socket event listener with a Socks5 proxy. Make SURE to set Socket after this. + /// + /// Event listener to pass events through to. + public Socks5Proxy(ISocketEventListener chain) : base(chain) + { + } + + /// + /// Saves the address passed in, and really connects to ProxyHost:ProxyPort to begin SOCKS5 handshake. + /// + /// + public override void Connect(bedrock.net.Address addr) + { + m_state = States.Connecting; + base.Connect(addr); + } + + #region Socks5 private methods. + + /* + * The SOCKS request is formed as follows: + * + * +----+-----+-------+------+----------+----------+ + * |VER | CMD | RSV | ATYP | DST.ADDR | DST.PORT | + * +----+-----+-------+------+----------+----------+ + * | 1 | 1 | X'00' | 1 | Variable | 2 | + * +----+-----+-------+------+----------+----------+ + * + * Where: + * + * o VER protocol version: X'05' + * o CMD + * o CONNECT X'01' + * o BIND X'02' + * o UDP ASSOCIATE X'03' + * o RSV RESERVED + * o ATYP address type of following address + * o IP V4 address: X'01' + * o DOMAINNAME: X'03' + * o IP V6 address: X'04' + * o DST.ADDR desired destination address + * o DST.PORT desired destination port in network octet order + */ + private void RequestProxyConnection() + { + m_state = States.RequestingProxy; + + byte[] host = Encoding.ASCII.GetBytes(RemoteAddress.Hostname); + int n = host.Length; + byte [] buffer = new Byte[7 + n]; + buffer[0] = 5; // protocol version. + buffer[1] = 1; // connect + buffer[2] = 0; // reserved. + buffer[3] = 3; // DOMAINNAME + buffer[4] = (byte)n; + host.CopyTo(buffer, 5); + buffer[5+n] = (byte)(RemoteAddress.Port >> 8); + buffer[6+n] = (byte)RemoteAddress.Port; + Debug.WriteLine("sending request to proxy to " + RemoteAddress); + Write(buffer); + } + + private bool HandleGetMethodsResponse(int ver, int method) + { + if (ver != 5) + { + Debug.WriteLine("bogus version from proxy: " + ver); + return false; + } + if (method == 0xff) + { + Debug.WriteLine("no valid method returned from proxy"); + return false; + } + + Debug.WriteLine("proxy accepted our connection: " + method); + switch (method) + { + case 2: + /* + * +----+------+----------+------+----------+ + * |VER | ULEN | UNAME | PLEN | PASSWD | + * +----+------+----------+------+----------+ + * | 1 | 1 | 1 to 255 | 1 | 1 to 255 | + * +----+------+----------+------+----------+ + */ + m_state = States.WaitingForAuth; + byte [] buffer = new Byte[3 + Username.Length + Password.Length]; + buffer[0] = 1; // version of this subnegotiation. + buffer[1] = (byte)Username.Length; + Encoding.ASCII.GetBytes(Username, 0, Username.Length, buffer, 2); + int pw_offset = 2 + Username.Length; + buffer[pw_offset] = (byte)Password.Length; + Encoding.ASCII.GetBytes(Password, 0, Password.Length, buffer, pw_offset + 1); + Debug.WriteLine("sending plain auth to proxy"); + Write(buffer); + return true; + case 0: + RequestProxyConnection(); + return true; + default: + Debug.WriteLine("bogus auth method: " + method); + return false; + } + } + + private bool HandleAuthResponse(int ver, int status) + { + if (ver != 1) + { + Debug.WriteLine("bogus subnegotiation version from proxy: " + ver); + return false; + } + if (status != 0) + { + Debug.WriteLine("username/password auth failed on proxy"); + return false; + } + + Debug.WriteLine("proxy accepted our auth handshake"); + RequestProxyConnection(); + return true; + } + + /* + * +----+-----+-------+------+----------+----------+ + * |VER | REP | RSV | ATYP | BND.ADDR | BND.PORT | + * +----+-----+-------+------+----------+----------+ + * | 1 | 1 | X'00' | 1 | Variable | 2 | + * +----+-----+-------+------+----------+----------+ + * + * Where: + * + * o VER protocol version: X'05' + * o REP Reply field: + * o X'00' succeeded + * o X'01' general SOCKS server failure + * o X'02' connection not allowed by ruleset + * o X'03' Network unreachable + * o X'04' Host unreachable + * o X'05' Connection refused + * o X'06' TTL expired + * o X'07' Command not supported + * o X'08' Address type not supported + * o X'09' to X'FF' unassigned + */ + private bool HandleRequestResponse(int ver, int reply) + { + if (ver != 5) + { + Debug.WriteLine("bogus version in reply from proxy: " + ver); + return false; + } + if (reply != 0) + { + Debug.WriteLine("request failed on proxy: " + reply); + return false; + } + + Debug.WriteLine("proxy complete"); + m_state = States.Running; + return true; + } + + #endregion + + #region Implementation of ISocketEventListener + + /// + /// overridden OnConnect to start off Socks5 protocol. + /// + /// + public override void OnConnect(bedrock.net.BaseSocket sock) + { + if (m_state == States.Connecting) + { + byte [] buffer = new Byte[4]; + buffer[0] = 5; // protocol version. + buffer[1] = 2; // number of methods. + buffer[2] = 0; // no auth. + buffer[3] = 2; // username password. + Debug.WriteLine("sending auth methods to proxy..."); + Write(buffer); + RequestRead(); + m_state = States.GettingMethods; + } + } + + /// + /// Overridden OnRead to handle 4 Socks5 states... + /// + /// + /// + /// + /// + /// + public override bool OnRead(bedrock.net.BaseSocket sock, byte[] buf, int offset, int length) + { + switch (m_state) + { + case States.GettingMethods: + return HandleGetMethodsResponse(buf[offset], buf[offset + 1]); + case States.WaitingForAuth: + return HandleAuthResponse(buf[offset], buf[offset + 1]); + case States.RequestingProxy: + bool ret = HandleRequestResponse(buf[offset], buf[offset + 1]); + if (ret) + { + m_listener.OnConnect(sock); // tell the real listener that we're connected. + // they'll call RequestRead(), so we can return false here. + } + return false; + default: + return base.OnRead(sock, buf, offset, length); + } + } + + /// + /// Overridden OnWrite to ensure that the base only gets called when in running state. + /// + /// + /// + /// + /// + public override void OnWrite(bedrock.net.BaseSocket sock, byte[] buf, int offset, int length) + { + if (m_state == States.Running) + { + base.OnWrite(sock, buf, offset, length); + } + } + #endregion + } +} diff -Nru smuxi-0.8/lib/jabber-net/bedrock/net/XEP124Socket.cs smuxi-0.8.9.1/lib/jabber-net/bedrock/net/XEP124Socket.cs --- smuxi-0.8/lib/jabber-net/bedrock/net/XEP124Socket.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/jabber-net/bedrock/net/XEP124Socket.cs 2012-01-03 07:52:11.000000000 +0000 @@ -0,0 +1,673 @@ +/* -------------------------------------------------------------------------- + * Copyrights + * + * Portions created by or assigned to Cursive Systems, Inc. are + * Copyright (c) 2002-2008 Cursive Systems, Inc. All Rights Reserved. Contact + * information for Cursive Systems, Inc. is available at + * http://www.cursive.net/. + * + * License + * + * Jabber-Net is licensed under the LGPL. + * See LICENSE.txt for details. + * --------------------------------------------------------------------------*/ + +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Diagnostics; +using System.IO; +using System.Net; +using System.Security.Cryptography; +using System.Security.Cryptography.X509Certificates; +using System.Text; +using System.Threading; +using System.Xml; +using bedrock.util; + +using jabber.protocol.stream; +using jabber.connection; +using jabber.protocol; + +namespace bedrock.net +{ + /// + /// XEP-0124 Error conditions + /// + [SVN(@"$Id$")] + public class XEP124Exception : WebException + { + /// + /// + /// + /// + public XEP124Exception(string reason) + : base(reason) + { + } + } + + /// + /// Make a XEP-124 (http://www.xmpp.org/extensions/xep-0124.html) polling "connection" look like a socket. + /// TODO: get rid of the PipeStream, if possible. + /// + [SVN(@"$Id$")] + public class XEP124Socket : BaseSocket, IHttpSocket, IElementSocket, ISocketEventListener + { + /// + /// Text encoding. Always UTF-8 for XMPP. + /// + protected static readonly Encoding ENC = Encoding.UTF8; + + private const string CONTENT_TYPE = "text/xml; charset=utf-8"; + private const string METHOD = "POST"; + + private readonly int m_hold = 1; + private int m_wait = 60; + private int m_maxPoll = 30; + private int m_minPoll = 1; + private Uri m_uri = null; + private bool m_running = false; + private long m_rid = -1L; + private string m_sid = null; + private string m_authID = null; + private X509Certificate m_remote_cert = null; + private bool m_StartStream = false; + private string m_NS; + private string m_lang = System.Globalization.CultureInfo.CurrentCulture.IetfLanguageTag; + private XmlDocument m_doc = new XmlDocument(); + + private Uri m_proxyURI = null; + private NetworkCredential m_proxyCredentials = null; + + private Thread m_thread = null; + private LinkedList m_queue = new LinkedList(); + + private HttpSocket m_sockA = null; + private HttpSocket m_sockB = null; + private HttpSocket m_lastSock = null; + + /// + /// Create an instance + /// + /// + public XEP124Socket(ISocketEventListener listener) : base(listener) + { + } + + /// + /// The xml:lang for all requests. Defaults to the current culture's language tag. + /// + public string Lang + { + get { return m_lang; } + set { m_lang = value; } + } + + /// + /// Informs the socket that we are dealing with the start tag. + /// + public bool StartStream + { + get { return m_StartStream; } + set { m_StartStream = value; } + } + + /// + /// Gets or sets the NS used by the stream:stream tag. + /// + public string NS + { + get { return m_NS; } + set { m_NS = value; } + } + + /// + /// Maximum time between polls, in seconds + /// + public int MaxPoll + { + get { return m_maxPoll; } + set { m_maxPoll = value; } + } + + /// + /// Minimum time between polls, in seconds + /// + public int MinPoll + { + get { return m_minPoll; } + set { m_minPoll = value; } + } + + /// + /// The URL to poll + /// + public string URL + { + get { return m_uri.ToString(); } + set { m_uri = new Uri(value); } + } + + /// + /// The URI of the HTTP proxy. Note: HTTPS connections through a proxy are not yet supported. + /// + public Uri ProxyURI + { + get { return m_proxyURI; } + set { m_proxyURI = value; } + } + + /// + /// Username/password for the proxy. + /// + public NetworkCredential ProxyCredentials + { + get { return m_proxyCredentials; } + set { m_proxyCredentials = value; } + } + + /// + /// Accept a socket. Not implemented. + /// + /// + /// + public override void Accept(Address addr, int backlog) + { + throw new NotImplementedException("HTTP binding server not implemented"); + } + + private void Enqueue(XmlElement elem) + { + lock (m_queue) + { + m_queue.AddLast(elem); + Monitor.Pulse(m_queue); + } + } + + // Must hold lock first. + private HttpSocket GetSocket() + { + // Debug.Assert(!BothPending); + + // Switch to the other socket than the last one, assuming the other socket isn't pending. + // If the other socket is pending, use the last one. + HttpSocket other = (m_lastSock == m_sockA) ? m_sockB : m_sockA; + if (!other.IsPending) + m_lastSock = other; + + Debug.WriteLine("Socket: " + m_lastSock.Name); + return m_lastSock; + } + + private bool BothPending + { + get { return (m_sockA != null) && (m_sockB != null) && + m_sockA.IsPending && m_sockB.IsPending; } + } + + private bool NeitherPending + { + get { return !m_sockA.IsPending && !m_sockB.IsPending; } + } + + private bool BothConnected + { + get + { + return (m_sockA != null) && (m_sockB != null) && + m_sockA.Connected && m_sockB.Connected; + } + } + + private void ProcessThread() + { + Body body = null; + int children = 0; + + while (m_running) + { + lock (m_queue) + { + //if (NeitherPending) + // m_queue.AddFirst((XmlElement)null); + + Debug.WriteLine("A: " + m_sockA.IsPending); + Debug.WriteLine("b: " + m_sockB.IsPending); + while ((m_queue.First == null) || BothPending) + { + Monitor.Wait(m_queue); + if (!m_running) + return; + } + + // We'll enq nulls to get a poll. + // We'll enq a body in order to terminate. + + Debug.Assert(m_queue.First != null); + body = m_queue.First.Value as Body; + children = 0; + if (body != null) + // TODO: what to do with leftover stanzas!? + m_queue.RemoveFirst(); + else + { + body = CreateOpenBodyTag(); + while (m_queue.First != null) + { + XmlElement elem = m_queue.First.Value; + // ignore nulls. we're going munge together all pending poll requests. + if (elem != null) + { + // if we get to a body in the queue, stop inserting, and wait for the body + // to come around again next time. + if (elem is Body) + break; + body.AddChild(elem); + children++; + } + m_queue.RemoveFirst(); + } + } + } + + if (NeitherPending || (children > 0) || (body.Type == BodyType.terminate)) + { + if (body.RID == -1) + body.RID = Interlocked.Increment(ref m_rid); + + byte[] buf = ENC.GetBytes(body.OuterXml); + GetSocket().Execute(METHOD, m_uri, buf, 0, buf.Length, CONTENT_TYPE); + } + + if (body.Type == BodyType.terminate) + { + // shutting down. + m_sockA.EnqueueClose(); + m_sockB.EnqueueClose(); + return; + } + } + } + + /// + /// Stop polling. + /// + public override void Close() + { + Body body = CreateOpenBodyTag(); + body.Type = BodyType.terminate; + + Enqueue(body); + + if (m_thread != null) + m_thread.Join(); + + lock (m_queue) + { + m_running = false; + m_thread = null; + m_sockA = m_sockB = m_lastSock = null; + } + m_listener.OnClose(this); + } + + /// + /// Start polling + /// + /// Ignored in this case. Set URL. + public override void Connect(Address addr) + { + Debug.Assert(m_uri != null); + + m_rid = -1L; + m_lastSock = null; + m_running = false; + + // Create new ones each time, in case the URL has changed or something. + m_sockA = new HttpSocket(this); + m_sockB = new HttpSocket(this); + + m_sockA.Name = "A"; + m_sockB.Name = "B"; + + m_sockA.ProxyURI = m_sockB.ProxyURI = m_proxyURI; + m_sockA.ProxyCredentials = m_sockB.ProxyCredentials = m_proxyCredentials; + + m_sockA.Connect(m_uri); + m_sockB.Connect(m_uri); + } + + /// + /// Not implemented + /// + public override void RequestAccept() + { + throw new NotImplementedException(); + } + + /// + /// Start reading. + /// + public override void RequestRead() + { + // shutdown race, likely. + if (!m_running) + //throw new InvalidOperationException("Call Connect() first"); + return; + if (m_sockA.IsPending || m_sockB.IsPending) + { + Debug.WriteLine("Skipping request, already pending"); + return; + } + + Enqueue(null); + } + + /// + /// Start TLS over this connection. Not implemented. + /// + public override void StartTLS() + { + throw new NotImplementedException(); + } + + /// + /// Start compression over this connection. Not implemented. + /// + public override void StartCompression() + { + throw new NotImplementedException(); + } + + private void FakeTimer(object state) + { + // HACK: stream restart is null for older versions of XEP-124. + if (!FakeReceivedStream()) + return; + + Features f = new Features(m_doc); + f.AddChild(new Bind(m_doc)); + f.AddChild(new Session(m_doc)); + byte[] p = ENC.GetBytes(f.OuterXml); + if (!m_listener.OnRead(this, p, 0, p.Length)) + { + Close(); + return; + } + } + + /// + /// Send bytes to the jabber server + /// + /// + /// + /// + public override void Write(byte[] buf, int offset, int len) + { + if (buf != null) + throw new NotImplementedException("Call Write(XmlElement)"); + + // HACK + byte[] p = ENC.GetBytes("Psuedo-stream body"); + m_listener.OnWrite(this, p, 0, p.Length); + if (m_sid == null) + { + StartStream = true; + return; + } + + // HACK: upper levels need this to come in after the + // return from write. Double-hack: hope this doesn't get + // gc's before the timer fires.... :) + + //Timer t = + new Timer(new TimerCallback(FakeTimer), null, 0, Timeout.Infinite); + } + + /// + /// Write an XML element to the socket. + /// In this case, the element is queued, so that the write + /// thread can pick it up. + /// + /// + public void Write(XmlElement elem) + { + Enqueue(elem); + } + + private Body CreateOpenBodyTag() + { + Body body = new Body(m_doc); + + if (m_rid == -1L) + { + Random rnd = new Random(); + long r = m_rid = (long)rnd.Next(); + body.Content = CONTENT_TYPE; + + body.To = m_hostid; + body.Wait = m_wait; + body.Hold = m_hold; + body.Lang = m_lang; + body.RID = r; + } + else + { + body.SID = m_sid; + } + + return body; + } + + /// + /// Descripton, including URL. + /// + /// + public override string ToString() + { + return "XEP-0124 socket: " + m_uri.ToString(); + } + + /// + /// Are we connected? + /// + public override bool Connected + { + get + { return m_running; } + } + + /// + /// The certificate from the server. + /// + public X509Certificate RemoteCertificate + { + get { return m_remote_cert; } + set { m_remote_cert = value; } + } + + #region ISocketEventListener Members + + void ISocketEventListener.OnInit(BaseSocket newSock) + { + m_listener.OnInit(newSock); + } + + ISocketEventListener ISocketEventListener.GetListener(BaseSocket newSock) + { + throw new Exception("The method or operation is not implemented."); + } + + bool ISocketEventListener.OnAccept(BaseSocket newsocket) + { + throw new Exception("The method or operation is not implemented."); + } + + void ISocketEventListener.OnConnect(BaseSocket sock) + { + lock (m_queue) + { + if (!m_running && + (m_sockA != null) && m_sockA.Connected && + (m_sockB != null) && m_sockB.Connected) + { + m_running = true; + m_lastSock = m_sockB; + + m_thread = new Thread(ProcessThread); + m_thread.IsBackground = true; + m_thread.Name = "XEP 124 processing thread"; + m_thread.Start(); + + m_listener.OnConnect(this); + } + } + } + + void ISocketEventListener.OnClose(BaseSocket sock) + { + throw new Exception("The method or operation is not implemented."); + } + + void ISocketEventListener.OnError(BaseSocket sock, Exception ex) + { + // shutdown race. + if (!m_running) + return; + + m_listener.OnError(this, ex); + } + + private bool FakeReceivedStream() + { + jabber.protocol.stream.Stream stream = + new jabber.protocol.stream.Stream(m_doc, NS); + stream.Version = "1.0"; + stream.ID = m_authID; + + byte[] sbuf = ENC.GetBytes(stream.StartTag()); + if (!m_listener.OnRead(this, sbuf, 0, sbuf.Length)) + { + Close(); + return false; + } + return true; + } + + bool ISocketEventListener.OnRead(BaseSocket sock, byte[] buf, int offset, int length) + { + if (!m_running) + { + Debug.WriteLine("shutting down. extra bytes received."); + return false; + } + + Debug.WriteLine("OnRead: " + ((HttpSocket)sock).Name); + + // Parse out the first start tag or empty element, which will be + // . + xpnet.UTF8Encoding e = new xpnet.UTF8Encoding(); + xpnet.ContentToken ct = new xpnet.ContentToken(); + xpnet.TOK tok = e.tokenizeContent(buf, offset, offset + length, ct); + + if ((tok != xpnet.TOK.START_TAG_WITH_ATTS) && + (tok != xpnet.TOK.EMPTY_ELEMENT_WITH_ATTS)) + { + m_listener.OnError(this, new ProtocolViolationException("Invalid HTTP binding XML. Token type: " + tok.ToString())); + return false; + } + + string name = ENC.GetString(buf, + offset + e.MinBytesPerChar, + ct.NameEnd - offset - e.MinBytesPerChar); + Debug.Assert(name == "body"); + Body b = new Body(m_doc); + string val; + int start; + int end; + for (int i = 0; i < ct.getAttributeSpecifiedCount(); i++) + { + start = ct.getAttributeNameStart(i); + end = ct.getAttributeNameEnd(i); + name = ENC.GetString(buf, start, end - start); + + start = ct.getAttributeValueStart(i); + end = ct.getAttributeValueEnd(i); + val = ENC.GetString(buf, start, end - start); + + if (!name.StartsWith("xmlns")) + b.SetAttribute(name, val); + } + + if (b.SID != null) + m_sid = b.SID; + + if (m_sid == null) + { + m_listener.OnError(this, new ProtocolViolationException("Invalid HTTP binding. No SID.")); + return false; + } + + if (b.Wait != -1) + m_wait = b.Wait; + + if (StartStream) + { + StartStream = false; + m_authID = b.AuthID; + if (!FakeReceivedStream()) + return false; + } + + lock (m_queue) + { + if (!m_running) + return false; + + if (b.Type == BodyType.terminate) + { + m_running = false; + Error err = new Error(m_doc); + err.AppendChild(m_doc.CreateElement(b.GetAttribute("condition"), URI.STREAM_ERROR)); + byte[] sbuf = ENC.GetBytes(err.OuterXml); + m_listener.OnRead(this, sbuf, 0, sbuf.Length); + sbuf = ENC.GetBytes(""); + m_listener.OnRead(this, sbuf, 0, sbuf.Length); + Close(); + return false; + } + } + + + if (tok == xpnet.TOK.START_TAG_WITH_ATTS) + { + // len() = 7 + start = ct.TokenEnd; + if (m_listener.OnRead(this, buf, start, offset + length - start - 7)) + RequestRead(); + } + else + RequestRead(); + + lock (m_queue) + { + Monitor.Pulse(m_queue); + } + return true; + } + + void ISocketEventListener.OnWrite(BaseSocket sock, byte[] buf, int offset, int length) + { + m_listener.OnWrite(this, buf, offset, length); + } + + bool ISocketEventListener.OnInvalidCertificate(BaseSocket sock, X509Certificate certificate, X509Chain chain, System.Net.Security.SslPolicyErrors sslPolicyErrors) + { + return m_listener.OnInvalidCertificate(this, certificate, chain, sslPolicyErrors); + } + + #endregion + } +} diff -Nru smuxi-0.8/lib/jabber-net/bedrock/net/XEP25Socket.cs smuxi-0.8.9.1/lib/jabber-net/bedrock/net/XEP25Socket.cs --- smuxi-0.8/lib/jabber-net/bedrock/net/XEP25Socket.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/jabber-net/bedrock/net/XEP25Socket.cs 2012-01-03 07:52:11.000000000 +0000 @@ -0,0 +1,518 @@ +/* -------------------------------------------------------------------------- + * Copyrights + * + * Portions created by or assigned to Cursive Systems, Inc. are + * Copyright (c) 2002-2008 Cursive Systems, Inc. All Rights Reserved. Contact + * information for Cursive Systems, Inc. is available at + * http://www.cursive.net/. + * + * License + * + * Jabber-Net is licensed under the LGPL. + * See LICENSE.txt for details. + * --------------------------------------------------------------------------*/ + +using System; +using System.Collections; +using System.Diagnostics; +using System.IO; +using System.Net; +using System.Security.Cryptography; +using System.Security.Cryptography.X509Certificates; +using System.Text; +using System.Threading; +using bedrock.util; + +namespace bedrock.net +{ + /// + /// XEP25 Error conditions + /// + [SVN(@"$Id$")] + public class XEP25Exception : WebException + { + /// + /// + /// + /// + public XEP25Exception(string reason) : base(reason) + { + } + } + + /// + /// Make a XEP-25 (http://www.xmpp.org/extensions/xep-0025.html) polling "connection" look like a socket. + /// TODO: get rid of the PipeStream, if possible. + /// + [SVN(@"$Id$")] + public class XEP25Socket : BaseSocket, IHttpSocket + { + private const string CONTENT_TYPE = "application/x-www-form-urlencoded"; + private const string METHOD = "POST"; + + private readonly RandomNumberGenerator s_rng = RNGCryptoServiceProvider.Create(); + + private readonly Queue m_writeQ = new Queue(); + private readonly Object m_lock = new Object(); + private Thread m_thread = null; + private int m_maxPoll = 30; + private int m_minPoll = 1; + private double m_curPoll = 1.0; + private string m_url = null; + private string[] m_keys = null; + private int m_numKeys = 512; + private int m_curKey = 511; + private bool m_running = false; + private string m_id = null; + private WebProxy m_proxy = null; + private X509Certificate m_cert = null; + private X509Certificate m_remote_cert = null; + + /// + /// Do trust all server sertificates? + /// + public static bool UntrustedRootOK = false; + + /// + /// Create an instance + /// + /// + public XEP25Socket(ISocketEventListener listener) + { + Debug.Assert(listener != null); + m_listener = listener; + } + + /// + /// Maximum time between polls, in seconds + /// + public int MaxPoll + { + get { return m_maxPoll; } + set { m_maxPoll = value; } + } + + /// + /// Minimum time between polls, in seconds + /// + public int MinPoll + { + get { return m_minPoll; } + set { m_minPoll = value; } + } + + /// + /// The URL to poll + /// + public string URL + { + get { return m_url; } + set { m_url = value; } + } + + + /// + /// The number of keys to generate at a time. Higher numbers use more memory, + /// and more CPU to generate keys, less often. Defaults to 512. + /// + public int NumKeys + { + get { return m_numKeys; } + set { m_numKeys = value; } + } + + /// + /// Proxy information. My guess is if you leave this null, the IE proxy + /// info may be used. Not tested. + /// + public WebProxy Proxy + { + get { return m_proxy; } + set { m_proxy = value; } + } + + /// + /// The local certificate of the socket. + /// + public X509Certificate LocalCertificate + { + get { return m_cert; } + set { m_cert = value; } + } + + /// + /// The remote certificate. + /// + public X509Certificate RemoteCertificate + { + get { return m_remote_cert; } + set { m_remote_cert = value; } + } + + /// + /// Accept a socket. Not implemented. + /// + /// + /// + public override void Accept(Address addr, int backlog) + { + throw new NotImplementedException("HTTP polling server not implemented yet"); + } + + /// + /// Stop polling. + /// + public override void Close() + { + lock (m_lock) + { + m_running = false; + Monitor.Pulse(m_lock); + } + m_listener.OnClose(this); + } + + + + /// + /// Start polling + /// + /// + public override void Connect(Address addr) + { + Debug.Assert(m_url != null); + m_running = true; + m_curKey = -1; + + if (m_thread == null) + { + m_thread = new Thread(PollThread); + m_thread.IsBackground = true; + m_thread.Start(); + } + + m_listener.OnConnect(this); + } + + /// + /// Not implemented + /// + public override void RequestAccept() + { + throw new NotImplementedException(); + } + + /// + /// Start reading. + /// + public override void RequestRead() + { + if (!m_running) + throw new InvalidOperationException("Call Connect() first"); + } + +#if !NO_SSL + + /// + /// Start TLS over this connection. Not implemented. + /// + public override void StartTLS() + { + throw new NotImplementedException(); + } +#endif + + /// + /// Start TLS over this connection. Not implemented. + /// + public override void StartCompression() + { + throw new NotImplementedException(); + } + + /// + /// Send bytes to the jabber server + /// + /// + /// + /// + public override void Write(byte[] buf, int offset, int len) + { + if (!m_running) + throw new InvalidOperationException("Call Connect() first"); + + lock (m_lock) + { + //if (m_thread == null) + //{ + // // first write + // m_thread = new Thread(new ThreadStart(PollThread)); + // m_thread.IsBackground = true; + // m_thread.Start(); + //} + m_writeQ.Enqueue(new WriteBuf(buf, offset, len)); + Monitor.Pulse(m_lock); + } + } + + private void GenKeys() + { + byte[] seed = new byte[32]; + SHA1 sha = SHA1.Create(); + Encoding ENC = Encoding.ASCII; // All US-ASCII. No need for UTF8. + string prev; + + // K(n, seed) = Base64Encode(SHA1(K(n - 1, seed))), for n > 0 + // K(0, seed) = seed, which is client-determined + + s_rng.GetBytes(seed); + prev = Convert.ToBase64String(seed); + m_keys = new string[m_numKeys]; + for (int i=0; i + /// Keep polling until + /// + private void PollThread() + { + m_curPoll = m_minPoll; + m_id = null; + + MemoryStream ms = new MemoryStream(); + CookieContainer cookies = new CookieContainer(5); + byte[] readbuf = new byte[1024]; + + Stream rs; + byte[] buf; + HttpWebResponse resp; + HttpWebRequest req; + Stream s; + WriteBuf start; + + while (m_running) + { + lock (m_lock) + { + if (m_writeQ.Count == 0) + { + Monitor.Wait(m_lock, (int)(m_curPoll * 1000.0)); + } + } + // did we get closed? + if (!m_running) + break; + + + if (m_id == null) + { + GenKeys(); + start = new WriteBuf(string.Format("0;{0},", m_keys[m_curKey])); + } + else + { + if (m_curKey == 0) + { + string k = m_keys[0]; + GenKeys(); + start = new WriteBuf(string.Format("{0};{1};{2},", m_id, k, m_keys[m_curKey])); + } + else + { + start = new WriteBuf(string.Format("{0};{1},", m_id, m_keys[m_curKey])); + } + } + m_curKey--; + + ms.SetLength(0); + int count = start.len; + while (m_writeQ.Count > 0) + { + WriteBuf b = (WriteBuf) m_writeQ.Dequeue(); + count += b.len; + ms.Write(b.buf, b.offset, b.len); + } + + POLL: + req = (HttpWebRequest)WebRequest.Create(m_url); + req.CookieContainer = cookies; + req.ContentType = CONTENT_TYPE; + req.Method = METHOD; + + if (m_cert != null) + req.ClientCertificates.Add(m_cert); + + req.KeepAlive = false; + + req.CachePolicy = new System.Net.Cache.HttpRequestCachePolicy(System.Net.Cache.HttpRequestCacheLevel.NoCacheNoStore); + req.CachePolicy = new System.Net.Cache.HttpRequestCachePolicy(System.Net.Cache.HttpRequestCacheLevel.NoCacheNoStore); + + if (m_proxy != null) + req.Proxy = m_proxy; + req.ContentLength = count; + + + try + { + ServicePointManager.ServerCertificateValidationCallback = + ValidateRemoteCertificate; + + s = req.GetRequestStream(); + s.Write(start.buf, start.offset, start.len); + + m_remote_cert = req.ServicePoint.Certificate; + + buf = ms.ToArray(); + s.Write(buf, 0, buf.Length); + s.Close(); + + resp = (HttpWebResponse) req.GetResponse(); + } + catch (WebException ex) + { + if (ex.Status != WebExceptionStatus.KeepAliveFailure) + { + m_listener.OnError(this, ex); + return; + } + goto POLL; + } + + + + if (resp.StatusCode != HttpStatusCode.OK) + { + m_listener.OnError(this, new WebException("Invalid HTTP return code: " + resp.StatusCode)); + return; + } + + CookieCollection cc = resp.Cookies; + Debug.Assert(cc != null); + + Cookie c = cc["ID"]; + if ((c == null) || (c.Value == null)) + { + m_listener.OnError(this, new WebException("No ID cookie returned")); + return; + } + + if (m_id == null) + { + // if ID ends in :0, it's an error + if (!c.Value.EndsWith(":0")) + m_id = c.Value; + } + + if (m_id != c.Value) + { + switch (c.Value) + { + case "0:0": + m_listener.OnError(this, new XEP25Exception("Unknown XEP25 error")); + return; + case "-1:0": + m_listener.OnError(this, new XEP25Exception("Server error")); + return; + case "-2:0": + m_listener.OnError(this, new XEP25Exception("Bad request")); + return; + case "-3:0": + m_listener.OnError(this, new XEP25Exception("Key sequence error")); + return; + default: + m_listener.OnError(this, new WebException("ID cookie changed")); + return; + } + } + + if (ms.Length > 0) + { + m_listener.OnWrite(this, buf, 0, buf.Length); + } + + ms.SetLength(0); + rs = resp.GetResponseStream(); + + + int readlen; + while ((readlen = rs.Read(readbuf, 0, readbuf.Length)) > 0) + { + ms.Write(readbuf, 0, readlen); + } + rs.Close(); + if (ms.Length > 0) + { + buf = ms.ToArray(); + + try + { + if (!m_listener.OnRead(this, buf, 0, buf.Length)) + { + Close(); + return; + } + } catch (NullReferenceException) + {} + m_curPoll = m_minPoll; + } + else + { + m_curPoll *= 1.25; + if (m_curPoll > m_maxPoll) + m_curPoll = m_maxPoll; + } + } + } + + /// + /// Is socket connected. + /// + public override bool Connected + { + get + { return m_running; } + } + + /// + /// Descripton, including poll URL. + /// + /// + public override string ToString() + { + return "XEP-0025 Polling socket: " + m_url; + } + + private class WriteBuf + { + public readonly byte[] buf; + public readonly int offset; + public readonly int len; + + public WriteBuf(byte[] buf, int offset, int len) + { + this.buf = buf; + this.offset = offset; + this.len = len; + } + + public WriteBuf(string b) + { + buf = Encoding.UTF8.GetBytes(b); + offset = 0; + len = buf.Length; + } + } + }} diff -Nru smuxi-0.8/lib/jabber-net/bedrock/util/ConfigFile.cs smuxi-0.8.9.1/lib/jabber-net/bedrock/util/ConfigFile.cs --- smuxi-0.8/lib/jabber-net/bedrock/util/ConfigFile.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/jabber-net/bedrock/util/ConfigFile.cs 2012-01-03 07:52:11.000000000 +0000 @@ -0,0 +1,163 @@ +/* -------------------------------------------------------------------------- + * Copyrights + * + * Portions created by or assigned to Cursive Systems, Inc. are + * Copyright (c) 2002-2008 Cursive Systems, Inc. All Rights Reserved. Contact + * information for Cursive Systems, Inc. is available at + * http://www.cursive.net/. + * + * License + * + * Jabber-Net is licensed under the LGPL. + * See LICENSE.txt for details. + * --------------------------------------------------------------------------*/ +using System; + +using System.Xml; +using System.IO; +using System.Diagnostics; +using System.Collections; +using bedrock.util; +namespace bedrock.util +{ + /// + /// XML configuration file manager. + /// + [SVN(@"$Id$")] + public class ConfigFile + { + private string m_file; + private XmlDocument m_doc; + private static Hashtable s_instances = new Hashtable(); + private FileSystemWatcher m_watcher; + + /// + /// Singleton factory + /// + /// + /// + public static ConfigFile GetInstance(string name) + { + ConfigFile inst = (ConfigFile) s_instances[name]; + if (inst == null) + { + lock (s_instances.SyncRoot) + { + if (inst == null) + { + inst = new ConfigFile(name); + s_instances[name] = inst; + } + } + } + return inst; + } + + /// + /// The config file has been modified, and reloaded. + /// + public event FileSystemEventHandler OnFileChange; + + private ConfigFile(string name) + { + // Don't call Tracer from here! + m_doc = new XmlDocument(); + string d = Path.GetDirectoryName(System.Environment.GetCommandLineArgs()[0]); + DirectoryInfo p; + while (d != null) + { + FileInfo fi = new FileInfo(Path.Combine(d, name)); + if (fi.Exists) + { + Load(fi); + return; + } + p = fi.Directory.Parent; + if (p == null) + break; + d = p.FullName; + } + + throw new FileNotFoundException(name); + } + + private void Load(FileInfo info) + { + m_file = info.FullName; + m_doc.Load(m_file); + m_watcher = new FileSystemWatcher(info.DirectoryName, info.Name); + m_watcher.NotifyFilter = NotifyFilters.LastWrite | NotifyFilters.Size | NotifyFilters.CreationTime; + m_watcher.Changed += new FileSystemEventHandler(m_watcher_Changed); + m_watcher.EnableRaisingEvents = true; + } + + private void m_watcher_Changed(object sender, FileSystemEventArgs e) + { + m_doc = new XmlDocument(); + m_doc.Load(m_file); + if (OnFileChange != null) + OnFileChange(this, e); + } + + /// + /// The full path of the filename being used. + /// + public string Filename + { + get { return m_file; } + } + + /// + /// Get the configuration file XML node associated + /// with a given XPath query. + /// + /// + /// + public XmlNode GetNode(string xpath) + { + return m_doc.SelectSingleNode(xpath); + //ConfigFile f; + } + /// + /// Get the configuration file XML nodes associated with a give XPath query + /// + /// + /// + public XmlNodeList GetNodes(string xpath) + { + return m_doc.SelectNodes(xpath); + } + /// + /// Get the configuration file string associated + /// with a given XPath query, or null if not found. + /// + public string this[string xpath] + { + get + { + return this[xpath, null]; + } + } + /// + /// Get the configuration file string associated + /// with a given XPath query, or defaultValue if not found. + /// + public string this[string xpath, string defaultValue] + { + get + { + string val; + XmlNode n = m_doc.SelectSingleNode(xpath); + if (n != null) + { + val = n.InnerText; + } + else + { + val = defaultValue; + } + return val; + } + } + } +} diff -Nru smuxi-0.8/lib/jabber-net/bedrock/util/GetOptBase.cs smuxi-0.8.9.1/lib/jabber-net/bedrock/util/GetOptBase.cs --- smuxi-0.8/lib/jabber-net/bedrock/util/GetOptBase.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/jabber-net/bedrock/util/GetOptBase.cs 2012-01-03 07:52:11.000000000 +0000 @@ -0,0 +1,553 @@ +/* -------------------------------------------------------------------------- + * Copyrights + * + * Portions created by or assigned to Cursive Systems, Inc. are + * Copyright (c) 2002-2008 Cursive Systems, Inc. All Rights Reserved. Contact + * information for Cursive Systems, Inc. is available at + * http://www.cursive.net/. + * + * License + * + * Jabber-Net is licensed under the LGPL. + * See LICENSE.txt for details. + * --------------------------------------------------------------------------*/ +namespace bedrock.util + +{ + using System; + using System.Collections; + using System.Diagnostics; + using System.Reflection; + using System.Text; + using System.Text.RegularExpressions; + + /// + /// GetOpt should be subclassed to create a class that handles + /// command-line parameters. The subclass should use fields or properties + /// that have the CommandLine attribute set on them. Fields and properties + /// of type bool will be toggle flags, other types will take a value as + /// either the next command-line parameter or following a colon. + /// Also, now, you can create an instance of GetOpt, and pass in + /// TODO: Give examples of sublcass and calling example. + /// + [SVN(@"$Id$")] + public class GetOpt + { + private object m_obj = null; + private string[] m_args = null; + private Hashtable m_flags = + new Hashtable(StringComparer.InvariantCultureIgnoreCase); + + // Regular expression to parse these: + // /a + // /a:foo + // -a + // -a:foo + private static readonly Regex FLAG_REGEX = + new Regex("[/-]([a-z0-9_]+)([:=](.*))?", RegexOptions.IgnoreCase); + /// + /// Really only useful for subclasses, I think. + /// + public GetOpt() + { + // Debug.Assert(this.GetType() != typeof(GetOpt)); + m_obj = this; + } + /// + /// Get ready to process command line parameters for the given target object. + /// + /// Object to set parameters on + public GetOpt(object target) + { + m_obj = (target == null) ? this : target; + } + /// + /// Process command line parameters for the given target object, with the + /// given arguments. + /// + /// Object to set parameters on + /// An array of arguments. If null, use the environment's command line. + public GetOpt(object target, string[] args) : this(target) + { + Process(args); + } + /// + /// Subclass interface, processing immediately. + /// + /// An array of arguments. If null, use the environment's command line. + public GetOpt(string[] args) : this(null, args) + { + } + /// + /// Process the given command line parameters. + /// + /// An array of arguments. If null, use the environment's command line. + public void Process(string[] args) + { + int i; + MemberInfo mi; + Match rm; + Type mit; + + SetFlags(); + if (args == null) + { + string[] e = Environment.GetCommandLineArgs(); + args = new string[e.Length - 1]; + Array.Copy(e, 1, args, 0, e.Length-1); + } + + for (i=0; i= args.Length) + { + throw new IndexOutOfRangeException("Not enough parameters for: " + old_flag); + } + parms[j] = ConvertValue(args[++i], pi[j].ParameterType); + } + + meth.Invoke(m_obj, parms); + } + + // bool flags act as toggles + else if (mit == typeof(bool)) + { + SetValue(mi, ! (bool) GetValue(mi)); + } + else + { + // use the value after the colon, if it exists + if (rm.Groups[3].Success) + { + SetValue(mi, rm.Groups[3].ToString()); + } + else + { + if (i+1 >= args.Length) + { + throw new IndexOutOfRangeException("Not enough parameters for: " + args[i]); + } + SetValue(mi, args[++i]); + } + } + } + // copy the rest of the argument array (those after the flags) + // into an array for later use. + m_args = new string[args.Length - i]; + Array.Copy(args, i, m_args, 0, args.Length - i); + CheckRequired(); + } + /// + /// Look at myself, to see if there are any command line + /// parameter fields or properties. + /// + private void SetFlags() + { + if (m_flags.Count != 0) + return; + MemberInfo[] mis = GetCommandLineMembers(); + foreach (MemberInfo mi in mis) + { + CommandLineAttribute cla = GetOption(mi); + string cf = cla.CommandFlag; + // If no CommandFlag specified, use the member name. + if (cf == null) + { + cf = mi.Name; + } + // make sure required parameters are initialized to null. + if (cla.Required && (GetValue(mi) != null)) + { + throw new ArgumentException("Must provide null initial value for required parameters: ", mi.Name); + } + m_flags[cf] = mi; + } + } + /// + /// Make sure all required fields got hit. + /// + private void CheckRequired() + { + MemberInfo[] mis = GetCommandLineMembers(); + foreach (MemberInfo mi in mis) + { + CommandLineAttribute cla = GetOption(mi); + if (cla.Required && (GetValue(mi) == null)) + { + throw new ArgumentException("Did not provide required parameter: ", mi.Name); + } + } + } + /// + /// Set the value of a field or property, depending on the kind of member. + /// Coerce the type of the value passed in, as possible + /// + /// The member to set + /// The value to set + private void SetValue(MemberInfo mi, object val) + { + switch (mi.MemberType) + { + case MemberTypes.Field: + FieldInfo fi = (FieldInfo) mi; + fi.SetValue(m_obj, ConvertValue(val, fi.FieldType)); + break; + case MemberTypes.Property: + PropertyInfo pi = (PropertyInfo) mi; + pi.SetValue(m_obj, ConvertValue(val, pi.PropertyType), null); + break; + default: + throw new ArgumentException("Invalid member type", "mi"); + } + } + /// + /// Convert a field value representation to a value of the correct type. + /// Enums need special handling, at least for now. + /// + /// The value to convert + /// The type to convert it to + private object ConvertValue(object val, Type TargetType) + { + if (TargetType.IsEnum) + { + return Enum.Parse(TargetType, (string) val, true); + } + return Convert.ChangeType(val, TargetType); + } + /// + /// Get the value from a field or property, depending on the type of member. + /// + /// + private object GetValue(MemberInfo mi) + { + object ret = null; + switch (mi.MemberType) + { + case MemberTypes.Field: + FieldInfo fi = (FieldInfo) mi; + ret = fi.GetValue(m_obj); + break; + case MemberTypes.Property: + PropertyInfo pi = (PropertyInfo) mi; + ret = pi.GetValue(m_obj, null); + break; + default: + throw new ArgumentException("Invalid member type", "mi"); + } + return ret; + } + /// + /// Get the type contained in the given member. + /// + /// The member to check + private static Type GetMemberType(MemberInfo mi) + { + Type ret = null; + switch (mi.MemberType) + { + case MemberTypes.Field: + FieldInfo fi = (FieldInfo) mi; + ret = fi.FieldType; + break; + case MemberTypes.Property: + PropertyInfo pi = (PropertyInfo) mi; + ret = pi.PropertyType; + break; + case MemberTypes.Method: + ret = null; + break; + default: + throw new ArgumentException("Invalid member type", "mi"); + } + return ret; + } + /// + /// Get all of the members that are tagged with the CommandLineAttribute. + /// NOTE: this currently returns private members as well, but setting the + /// BindingFlags to public doesn't return anything. Could be a bug in the BCL? + /// + private MemberInfo[] GetCommandLineMembers() + { + Type t = m_obj.GetType(); + MemberInfo[] mis = t.FindMembers(MemberTypes.All, + BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance, + new MemberFilter(AttrMemberFilter), + typeof(CommandLineAttribute)); + Debug.Assert(mis.Length > 0, "Must have at least one CommandLine attribute on class: " + t.FullName); + return mis; + } + + /// + /// Filter proc for GetCommandLineMembers. Returns true if the member + /// implements a given attribute. + /// + /// The member to evaluate + /// The attribute type to check for + private static bool AttrMemberFilter(MemberInfo m, object filterCriteria) + { + return m.GetCustomAttributes((Type)filterCriteria, true).Length > 0; + } + /// + /// Get the CommandLineAttribute off of a member. Assumes that the member implements + ///exactly one instance of the attribute. + /// + /// The member to retrieve from + private CommandLineAttribute GetOption(MemberInfo mi) + { + object[] o = mi.GetCustomAttributes(typeof(CommandLineAttribute), true); + Debug.Assert(o.Length == 1); + return ((CommandLineAttribute[]) o)[0]; + } + /// + /// The list of command-line arguments that were not associated with flags. + /// + public virtual string[] Args + { + get { return m_args; } + } + /// + /// Get/Set a parameter on the managed object, using the flag. + /// Warning: this will do an implicit conversion to the type of the + /// field associated with the flag. + /// If you're using this, you've probably got a design problem. + /// + public object this[string flag] + { + get + { + SetFlags(); + MemberInfo mi = (MemberInfo) m_flags[flag]; + return GetValue(mi); + } + set + { + SetFlags(); + MemberInfo mi = (MemberInfo) m_flags[flag]; + SetValue(mi, value); + } + } + /// + /// Get a usage description string from the object. + /// Use the CommandLineAttribute descriptions wherever possible. + /// + public virtual string Usage + { + get + { + SetFlags(); + StringBuilder sb = new StringBuilder(); + // Gr. this used to work, and I can't find the new API. + //sb.Append(System.IO.File.GetFileNameFromPath(Environment.GetCommandLineArgs()[0])); + sb.Append(Environment.GetCommandLineArgs()[0]); + string[] keys = new string[m_flags.Count]; + m_flags.Keys.CopyTo(keys, 0); + Array.Sort(keys); + foreach (object key in keys) + { + MemberInfo mi = (MemberInfo) m_flags[key]; + CommandLineAttribute cla = GetOption(mi); + Type mit = GetMemberType(mi); + sb.Append(" "); + if (!cla.Required) + { + sb.Append("["); + } + + // method + if (mit == null) + { + MethodInfo meth = (MethodInfo) mi; + ParameterInfo[] pis = meth.GetParameters(); + sb.AppendFormat("/{0}", key); + foreach (ParameterInfo pi in pis) + { + sb.Append(" "); + sb.Append(pi.ParameterType.Name); + } + } + else if (mit == typeof(bool)) + { + sb.AppendFormat("/{0}", key); + } + else if (mit.IsEnum) + { + sb.AppendFormat("/{0} (", key); + string val = GetValue(mi).ToString(); + string[] names = Enum.GetNames(mit); + bool first = true; + foreach (string n in names) + { + if (first) + { + first = false; + } + else + { + sb.Append("|"); + } + if (val == n) + { + sb.AppendFormat("*{0}*", n); + } + else + { + sb.Append(n); + } + } + sb.Append(")"); + } + else + { + sb.AppendFormat("/{0} {1}", key, GetValue(mi)); + } + if (!cla.Required) + { + sb.Append("]"); + } + } + sb.Append(Environment.NewLine); + foreach (object key in keys) + { + sb.AppendFormat("\t/{0}: \t{1}", key, GetOption((MemberInfo)m_flags[key]).Description); + sb.Append(Environment.NewLine); + } + return sb.ToString(); + } + } + /// + /// Print out the usage information on StdErr, and exit with code 64. + /// + public virtual void UsageExit() + { + Console.Error.WriteLine(Usage); + Environment.Exit(64); + } + + /// + /// Echo Command-Line requirements for a GUI app via a MessageBox + /// (since we do not have user-visible stdout) + /// + public virtual void UsageGUIExit() + { + /* + MessageBox.Show + (Usage, "Command-line argument usage", + MessageBoxButtons.OK, MessageBoxIcon.Error); + Environment.Exit(64); + */ + throw new NotImplementedException("This is the only thing that requires Windows.Forms. Removed."); + } + } + /// + /// Attribute to annotate subclasses of GetOpt. Any field or property + /// that gets this attribute is a possible command-line argument for the + /// program containing the GetOpt subclass. + /// + [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property | AttributeTargets.Method, + AllowMultiple=false)] + [SVN(@"$Id$")] + public class CommandLineAttribute : Attribute + { + private string m_commandFlag = null; + private string m_description = null; + private bool m_required = false; + /// + /// Use the member name for the command-line parameter. + /// + public CommandLineAttribute() + { + } + /// + /// Use the given string as the command-line parameter. + /// + /// + public CommandLineAttribute(string commandFlag) + { + m_commandFlag = commandFlag; + } + /// + /// Use the given string as the command-line parameter. + /// + /// + /// + public CommandLineAttribute(string commandFlag, string description) + { + m_commandFlag = commandFlag; + m_description = description; + } + /// + /// Use the given string as the command-line parameter. + /// + /// + /// + /// + public CommandLineAttribute(string commandFlag, string description, bool required) + { + m_commandFlag = commandFlag; + m_description = description; + m_required = required; + } + /// + /// Get the command-line flag. If none was specified, returns null. + /// + public string CommandFlag + { + get + { + return m_commandFlag; + } + } + /// + /// Get the command-line description. If none was specified, returns null. + /// + public string Description + { + get + { + return m_description; + } + set + { + m_description = value; + } + } + /// + /// Is the option required? Defaults to false. + /// + public bool Required + { + get + { + return m_required; + } + set + { + m_required = value; + } + } + } +} diff -Nru smuxi-0.8/lib/jabber-net/bedrock/util/IdleTime.cs smuxi-0.8.9.1/lib/jabber-net/bedrock/util/IdleTime.cs --- smuxi-0.8/lib/jabber-net/bedrock/util/IdleTime.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/jabber-net/bedrock/util/IdleTime.cs 2012-01-03 07:52:11.000000000 +0000 @@ -0,0 +1,217 @@ +/* -------------------------------------------------------------------------- + * Copyrights + * + * Portions created by or assigned to Cursive Systems, Inc. are + * Copyright (c) 2002-2008 Cursive Systems, Inc. All Rights Reserved. Contact + * information for Cursive Systems, Inc. is available at + * http://www.cursive.net/. + * + * License + * + * Jabber-Net is licensed under the LGPL. + * See LICENSE.txt for details. + * --------------------------------------------------------------------------*/ +using System; +using System.ComponentModel; +using System.Text; +using System.Runtime.InteropServices; +using System.ComponentModel.Design; + +namespace bedrock.util +{ + /// + /// TimeSpan event. + /// + /// + /// + public delegate void SpanEventHandler(object sender, TimeSpan span); + + /// + /// Idle time calculations and notifications. + /// + [SVN(@"$Id$")] + public class IdleTime : System.ComponentModel.Component + { + [StructLayout(LayoutKind.Sequential)] + private struct LASTINPUTINFO + { + public int cbSize; + public int dwTime; + } + + [DllImport("User32.dll")] + private static extern bool GetLastInputInfo(ref LASTINPUTINFO plii); + + /// + /// Get the lapse time between user input (mouse or keyboard) system-wide. + /// + /// Lapse time in seconds. + public static double GetIdleTime() + { + LASTINPUTINFO lii = new LASTINPUTINFO(); + lii.cbSize = Marshal.SizeOf(lii.GetType()); + if (!GetLastInputInfo(ref lii)) + throw new ApplicationException("Error executing GetLastInputInfo"); + return (Environment.TickCount - lii.dwTime) / 1000.0; + } + + /// + /// Fired when user has been idle (mouse, keyboard) for the configured number of seconds. + /// + public event SpanEventHandler OnIdle; + + /// + /// Fired when the user comes back. + /// + public event SpanEventHandler OnUnIdle; + + private const double DEFAULT_POLL = 5; // 5s in s. + private const double DEFAULT_IDLE = 5 * 60; // 5m in s. + + private System.Timers.Timer m_timer = null; + private double m_notifySecs = DEFAULT_IDLE; + private bool m_idle = false; + private DateTime m_idleStart = DateTime.MinValue; + private ISynchronizeInvoke m_invoker = null; + + /// + /// Create an idle timer with the default timouts. + /// + public IdleTime() + { + m_timer = new System.Timers.Timer(DEFAULT_POLL * 1000.0); + m_timer.Elapsed += new System.Timers.ElapsedEventHandler(m_timer_Elapsed); + } + + /// + /// Create an idle timer. Make sure to set Enabled = true to start. + /// + /// Every pollSecs seconds, poll to see how long we've been away. + /// If we've been away notifySecs seconds, fire notification. + public IdleTime(int pollSecs, int notifySecs) : this() + { + if (pollSecs > notifySecs) + throw new ArgumentException("Poll more often than you notify."); + PollInterval = pollSecs; + IdleLength = notifySecs; + } + + /// + /// Is the timer running? + /// + [Category("Logic")] + [DefaultValue(false)] + public bool Enabled + { + get { return m_timer.Enabled; } + set { m_timer.Enabled = value; } + } + + /// + /// Time, in seconds, between checking for + /// + [Category("Time")] + [DefaultValue(DEFAULT_POLL)] + public double PollInterval + { + get { return m_timer.Interval / 1000.0; } + set { m_timer.Interval = value * 1000.0; } + } + + /// + /// The amount of time (in seconds) the computer can be idle before OnIdle is fired. + /// + [Category("Time")] + [DefaultValue(DEFAULT_IDLE)] + public double IdleLength + { + get { return m_notifySecs; } + set { m_notifySecs = value; } + } + + /// + /// Are we currently idle? + /// + [Category("Logic")] + public bool IsIdle + { + get { return m_idle; } + } + + /// + /// Invoke() all callbacks on this control. + /// + [Description("Invoke all callbacks on this control")] + [DefaultValue(null)] + [Category("Logic")] + public ISynchronizeInvoke InvokeControl + { + get + { + // If we are running in the designer, let's try to get + // an invoke control from the environment. VB + // programmers can't seem to follow directions. + if ((this.m_invoker == null) && DesignMode) + { + IDesignerHost host = (IDesignerHost)base.GetService(typeof(IDesignerHost)); + if (host != null) + { + object root = host.RootComponent; + if ((root != null) && (root is ISynchronizeInvoke)) + { + m_invoker = (ISynchronizeInvoke)root; + // TODO: fire some sort of propertyChanged event, + // so that old code gets cleaned up correctly. + } + } + } + return m_invoker; + } + set { m_invoker = value; } + } + + + private void m_timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e) + { + double idle = GetIdleTime(); + if (m_idle) + { + if (idle < PollInterval) + { + m_idle = false; + if (OnUnIdle != null) + { + TimeSpan span = DateTime.Now - m_idleStart; + if ((m_invoker != null) && + (m_invoker.InvokeRequired)) + { + m_invoker.Invoke(OnUnIdle, new object[] { this, span }); + } + else + OnUnIdle(this, span); + } + m_idleStart = DateTime.MinValue; + } + } + else + { + if (idle > m_notifySecs) + { + m_idle = true; + m_idleStart = DateTime.Now; + if (OnIdle != null) + { + TimeSpan span = new TimeSpan((long)(idle * 1000L)); + if ((m_invoker != null) && + (m_invoker.InvokeRequired)) + { + m_invoker.Invoke(OnIdle, new object[] { this, span }); + } + else + OnIdle(this, span); + } + } + } + } + } +} diff -Nru smuxi-0.8/lib/jabber-net/bedrock/util/Version.cs smuxi-0.8.9.1/lib/jabber-net/bedrock/util/Version.cs --- smuxi-0.8/lib/jabber-net/bedrock/util/Version.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/jabber-net/bedrock/util/Version.cs 2012-01-03 07:52:11.000000000 +0000 @@ -0,0 +1,632 @@ +/* -------------------------------------------------------------------------- + * Copyrights + * + * Portions created by or assigned to Cursive Systems, Inc. are + * Copyright (c) 2002-2008 Cursive Systems, Inc. All Rights Reserved. Contact + * information for Cursive Systems, Inc. is available at + * http://www.cursive.net/. + * + * License + * + * Jabber-Net is licensed under the LGPL. + * See LICENSE.txt for details. + * --------------------------------------------------------------------------*/ +using System; + +using System.Collections; +using System.Collections.Specialized; +using System.Reflection; +using System.Text; +using System.Text.RegularExpressions; +namespace bedrock.util +{ + /// + /// Make source code versions available at runtime. Use the appropriate + /// subclass for your CM system. + /// + /// + /// + /// + // [SVN(@"$Id$")] + [AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface | AttributeTargets.Enum | AttributeTargets.Struct, + AllowMultiple = false, + Inherited = false)] + public abstract class SourceVersionAttribute : Attribute + { + /// + /// The entire header + /// + protected string m_header = null; + /// + /// The directory it's stored in + /// + protected string m_archive = null; + /// + /// Last check-in author + /// + protected string m_author = null; + /// + /// Last check-in version + /// + protected string m_version = null; + /// + /// Last check-in date + /// + protected DateTime m_date = DateTime.MinValue; + /// + /// Have we parsed the header, yet? + /// + private bool m_parsed = false; + // TODO: replace all of the subclasses with a single, uber-regex. + private static readonly Regex REGEX = + new Regex(@"^(\$(?[a-z]+): *(?.+) *\$)|( *(?.+) *)$", + RegexOptions.IgnoreCase | RegexOptions.Compiled); + /// + /// Construct the attribute. Parsing is delayed until needed. + /// + /// the Header keyword for your CM system. + /// Usually $Header$ + public SourceVersionAttribute(string header) + { + m_header = header; + } + /// + /// You could use this one, and pass the keywords in individually. + /// + public SourceVersionAttribute() + { + + } + /// + /// Give back the header string. + /// + public override string ToString() + { + return m_header; + } + /// + /// Have we parsed yet? + /// + protected void CheckParse() + { + if (m_parsed) + { + return; + } + lock(this) + { + if (m_parsed) + { + return; + } + Parse(); + m_parsed = true; + } + } + /// + /// We have done a parse, now + /// + protected void SetParse() + { + if (!m_parsed) + { + lock(this) + { + m_parsed = true; + } + } + } + /// + /// Parse data into internal fields + /// + protected abstract void Parse(); + /// + /// Do a regex match on src + /// + /// + /// + protected string GetField(string src) + { + Match m = REGEX.Match(src); + if (!m.Success) + { + throw new FormatException("Bad header format: " + src + " != " + REGEX.ToString()); + } + if (!m.Groups["value"].Success) + { + throw new FormatException("Value not found in: " + src); + } + return m.Groups["value"].ToString(); + } + /// + /// The last checked-in version + /// + public string Revision + { + get + { + CheckParse(); + return m_version; + } + set + { + SetParse(); + m_version = GetField(value); + } + } + /// + /// The last checked-in version, in perhaps more useful format + /// + public Version Version + { + get + { + CheckParse(); + if (m_version == null) + { + return null; + } + if (m_version.IndexOf('.') == -1) + { + return new Version(1, Int32.Parse(m_version)); + } + return new Version(m_version); + } + } + /// + /// Retrive the binary date/time of last check-in + /// + public DateTime Date + { + get + { + CheckParse(); + return m_date; + } + set + { + SetParse(); + m_date = value; + } + } + /// + /// Retrieve the string representation of the date of last check-in. + /// + public string DateString + { + get + { + CheckParse(); + return m_date.ToString(); + } + set + { + SetParse(); + m_date = DateTime.Parse(GetField(value)); + } + } + /// + /// Retrive the name of the last person to check in + /// + public string Author + { + get + { + CheckParse(); + return m_author; + } + set + { + SetParse(); + m_author = GetField(value); + } + } + /// + /// Retrieve the archive name from the header + /// + public string Archive + { + get + { + CheckParse(); + return m_archive; + } + set + { + SetParse(); + m_archive = GetField(value); + } + } + /// + /// Get the version information for the given type. + /// + /// + /// + public static SourceVersionAttribute GetVersion(Type t) + { + object[] sta = t.GetCustomAttributes(typeof(SourceVersionAttribute), true); + if (sta.Length == 0) + { + // throw exception? Null seems nicer. + return null; + } + return (SourceVersionAttribute) sta[0]; + } + /// + /// Get the version information for the class of the given object. + /// + /// + /// + public static SourceVersionAttribute GetVersion(object o) + { + // Well, someone used it wrong, but who am I to complain? + if (o is Type) + { + return GetVersion((Type) o); + } + return GetVersion(o.GetType()); + } + /// + /// Get all of the versioned classes currently in the working set. + /// + /// + public static SourceVersionCollection GetVersion() + { + SourceVersionCollection tv = new SourceVersionCollection(); + Assembly[] assems = AppDomain.CurrentDomain.GetAssemblies(); + SourceVersionAttribute sta; + foreach (Assembly a in assems) + { + Type[] ts = a.GetTypes(); + foreach (Type t in ts) + { + sta = GetVersion(t); + if (sta != null) + { + tv.Add(t.FullName, sta); + } + } + } + return tv; + } + } + /// + /// Make StarTeam versoning available at run-time. + /// + /// + /// + /// [StarTeam(@"$Header$")] + /// public class foo {} + /// + /// SourceVersionAttribute sta = SourceVersionAttribute.GetVersion(typeof(foo)); + /// + [SVN(@"$Id$")] + [AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface | AttributeTargets.Enum | AttributeTargets.Struct, + AllowMultiple=false, Inherited=false)] + public class StarTeamAttribute : SourceVersionAttribute + { + // Dammit gumby. Don't mess up my regex. + private static readonly Regex REGEX = + new Regex(@"^\$" + @"Header(: (?[^,]+), (?[0-9.]+), (?[^,]+), (?[^$]+))?" + @"\$$"); + /// + /// Normal usage + /// + /// + public StarTeamAttribute(string header) : base(header) + { + } + /// + /// Not useful + /// + public StarTeamAttribute() : base() + { + } + + /// + /// Return normalized header + /// + /// + public override string ToString() + { + string s = base.ToString(); + if (s != null) + { + return s; + } + + return String.Format("{0}Header: {1}, {2}, {3:MM/dd/yyyy h:mm:ss tt}, {4}{5}", + new object[] {"$", m_archive, m_version, m_date, m_author, "$"}); + } + /// + /// Parse the header + /// + protected override void Parse() + { + Match m = REGEX.Match(m_header); + if (!m.Success) + { + throw new FormatException("Bad header format: " + m_header + " != " + REGEX.ToString()); + } + if (m.Groups["archive"].Success) + { + m_archive = m.Groups["archive"].ToString(); + m_version = m.Groups["version"].ToString(); + m_date = DateTime.Parse(m.Groups["date"].ToString()); + m_author = m.Groups["author"].ToString(); + } + } + } + /// + /// Version control attribute for RCS and CVS. + /// + [SVN(@"$Id$")] + [AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface | AttributeTargets.Enum | AttributeTargets.Struct, + AllowMultiple=false, Inherited=false)] + public class RCSAttribute : SourceVersionAttribute + { + // Header: /u1/html/cvsroot/www.cyclic.com/RCS-html/info-ref.html,v 1.1 1999/04/14 19:04:02 kingdon Exp + private static readonly Regex REGEX = + new Regex(@"^\$" + @"Header(: +(?[^ ]+) +(?[0-9.]+) +(?[0-9/]+ [0-9:]+) +(?[^ ]+) +(?[^ ]+) *)?" + @"\$$"); + private string m_state = null; + /// + /// The most common. Pass in @"$ Header $" (without the spaces). + /// + /// + public RCSAttribute(string header) : base(header) + { + } + /// + /// Null constructor. This is rarely right. + /// + public RCSAttribute() : base() + { + } + /// + /// Parse the header string. + /// + protected override void Parse() + { + Match m = REGEX.Match(m_header); + if (!m.Success) + { + throw new FormatException("Bad header format: " + m_header + " != " + REGEX.ToString()); + } + if (m.Groups["archive"].Success) + { + m_archive = m.Groups["archive"].ToString(); + m_version = m.Groups["version"].ToString(); + m_date = DateTime.Parse(m.Groups["date"].ToString()); + m_author = m.Groups["author"].ToString(); + m_state = m.Groups["state"].ToString(); + } + } + /// + /// Hm. Wish I remembered what this was for. :) + /// + public string State + { + get + { + CheckParse(); + return m_state; + } + set + { + SetParse(); + m_state = GetField(value); + } + } + } + /// + /// Version control attribute for SourceSafe. + /// I don't use this any more, so someone tell me if it breaks with + /// some new release. + /// + [SVN(@"$Id$")] + [AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface | AttributeTargets.Enum | AttributeTargets.Struct, + AllowMultiple=false, Inherited=false)] + public class SourceSafeAttribute : SourceVersionAttribute + { + // Header: /t.cs 1 2/14/01 3:57p Hildebzj + private static readonly Regex REGEX = + new Regex(@"^\$" + @"Header(: +(?[^ ]+) +(?[0-9.]+) +(?[0-9/]+ [0-9:]+)(?[ap]) +(?[^ ]+) *)?" + @"\$$"); + //private string m_state = null; + /// + /// The normal use. Pass in @"$ Header $" (without the spaces). + /// + /// + public SourceSafeAttribute(string header) : base(header) + { + } + /// + /// Not usually useful. + /// + public SourceSafeAttribute() : base() + { + } + /// + /// Parse the header. + /// + protected override void Parse() + { + Match m = REGEX.Match(m_header); + if (!m.Success) + { + throw new FormatException("Bad header format: " + m_header + " != " + REGEX.ToString()); + } + if (m.Groups["archive"].Success) + { + m_archive = m.Groups["archive"].ToString(); + m_version = m.Groups["version"].ToString(); + m_date = DateTime.Parse(m.Groups["date"].ToString()); + if (m.Groups["ampm"].ToString() == "p") + { + m_date = m_date.AddHours(12); + } + m_author = m.Groups["author"].ToString(); + } + } + } + /// + /// A collection of SourceVersionAttributes, so that we can + /// return a list of all of the versioned classes in the + /// current working set. + /// + [SVN(@"$Id$")] + public class SourceVersionCollection : NameObjectCollectionBase + { + /// + /// Add an attribute to the list + /// + /// + /// + public void Add(string type, SourceVersionAttribute value) + { + BaseAdd(type, value); + } + /// + /// Remove all of the attributes from the list + /// + public void Clear() + { + BaseClear(); + } + /// + /// Get the index'th attribute + /// + /// + /// + public SourceVersionAttribute Get(int index) + { + return (SourceVersionAttribute) BaseGet(index); + } + /// + /// Get the attribute associated with a give type name + /// + /// + /// + public SourceVersionAttribute Get(string type) + { + return (SourceVersionAttribute) BaseGet(type); + } + /// + /// Set the attribute associated with a given type name + /// + /// + /// + public void Set(string type, SourceVersionAttribute value) + { + BaseSet(type, value); + } + /// + /// Set the index'th attribute + /// + /// + /// + public void Set(int index, SourceVersionAttribute value) + { + BaseSet(index, value); + } + /// + /// Remove the index'th attribute + /// + /// + public void Remove(int index) + { + BaseRemoveAt(index); + } + /// + /// Remove the attribute associated with the given type name + /// + /// + public void Remove(string type) + { + BaseRemove(type); + } + /// + /// Retrieve the index'th attribute + /// + public string this[int index] + { + get + { + return BaseGetKey(index); + } + } + /// + /// Retrieve/set the attriubute associated with the given type name. + /// + public SourceVersionAttribute this[string type] + { + get + { + return Get(type); + } + set + { + Set(type, value); + } + } + /// + /// Retrieve/set the attribute associated with the given type. + /// + public SourceVersionAttribute this[Type type] + { + get + { + return Get(type.FullName); + } + set + { + Set(type.FullName, value); + } + } + } + + /// + /// Version control attribute for Subversion. + /// + [SVN(@"$Id$")] + [AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface | AttributeTargets.Enum | AttributeTargets.Struct, + AllowMultiple=false, Inherited=false)] + public class SVNAttribute : SourceVersionAttribute + { + // Header: /u1/html/cvsroot/www.cyclic.com/RCS-html/info-ref.html,v 1.1 1999/04/14 19:04:02 kingdon Exp + // Id: calc.c 148 2002-07-28 21:30:43Z sally + private static readonly Regex REGEX = + new Regex(@"^\$" + @"Id(: +(?[^ ]+) +(?[0-9.]+) +(?[0-9-]+ [0-9:]+)Z +(?[^ ]+) *)?\$$"); + /// + /// The most common. Pass in @"$ Id $" (without the spaces). + /// + /// + public SVNAttribute(string header) + : base(header) + { + } + /// + /// Null constructor. This is rarely right. + /// + public SVNAttribute() + : base() + { + } + /// + /// Parse the header string. + /// + protected override void Parse() + { + Match m = REGEX.Match(m_header); + if (!m.Success) + { + throw new FormatException("Bad header format: " + m_header + " != " + REGEX.ToString()); + } + if (m.Groups["archive"].Success) + { + m_archive = m.Groups["archive"].ToString(); + m_version = m.Groups["version"].ToString(); + m_date = DateTime.Parse(m.Groups["date"].ToString()); + m_author = m.Groups["author"].ToString(); + } + } + } +} diff -Nru smuxi-0.8/lib/jabber-net/ConsoleClient/AssemblyInfo.cs smuxi-0.8.9.1/lib/jabber-net/ConsoleClient/AssemblyInfo.cs --- smuxi-0.8/lib/jabber-net/ConsoleClient/AssemblyInfo.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/jabber-net/ConsoleClient/AssemblyInfo.cs 2012-01-03 07:52:11.000000000 +0000 @@ -0,0 +1,71 @@ +/* -------------------------------------------------------------------------- + * Copyrights + * + * Portions created by or assigned to Cursive Systems, Inc. are + * Copyright (c) 2002-2008 Cursive Systems, Inc. All Rights Reserved. Contact + * information for Cursive Systems, Inc. is available at + * http://www.cursive.net/. + * + * License + * + * Jabber-Net is licensed under the LGPL. + * See LICENSE.txt for details. + * --------------------------------------------------------------------------*/ +using System.Reflection; +using System.Runtime.CompilerServices; + +// +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +// +[assembly: AssemblyTitle("ConsoleClient")] +[assembly: AssemblyDescription("Jabber-net console client example")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Cursive Systems, Inc.")] +[assembly: AssemblyProduct("jnExample")] +[assembly: AssemblyCopyright("Copyright (c) Cursive Systems, 2000-2008")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Revision and Build Numbers +// by using the '*' as shown below: + +[assembly: AssemblyVersion("1.0.*")] + +// +// In order to sign your assembly you must specify a key to use. Refer to the +// Microsoft .NET Framework documentation for more information on assembly signing. +// +// Use the attributes below to control which key is used for signing. +// +// Notes: +// (*) If no key is specified, the assembly is not signed. +// (*) KeyName refers to a key that has been installed in the Crypto Service +// Provider (CSP) on your machine. KeyFile refers to a file which contains +// a key. +// (*) If the KeyFile and the KeyName values are both specified, the +// following processing occurs: +// (1) If the KeyName can be found in the CSP, that key is used. +// (2) If the KeyName does not exist and the KeyFile does exist, the key +// in the KeyFile is installed into the CSP and used. +// (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility. +// When specifying the KeyFile, the location of the KeyFile should be +// relative to the project output directory which is +// %Project Directory%\obj\. For example, if your KeyFile is +// located in the project directory, you would specify the AssemblyKeyFile +// attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")] +// (*) Delay Signing is an advanced option - see the Microsoft .NET Framework +// documentation for more information on this. +// +[assembly: AssemblyDelaySign(false)] +[assembly: AssemblyKeyFile("")] +[assembly: AssemblyKeyName("")] diff -Nru smuxi-0.8/lib/jabber-net/ConsoleClient/Main.cs smuxi-0.8.9.1/lib/jabber-net/ConsoleClient/Main.cs --- smuxi-0.8/lib/jabber-net/ConsoleClient/Main.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/jabber-net/ConsoleClient/Main.cs 2012-01-03 07:52:11.000000000 +0000 @@ -0,0 +1,229 @@ +/* -------------------------------------------------------------------------- + * Copyrights + * + * Portions created by or assigned to Cursive Systems, Inc. are + * Copyright (c) 2002-2008 Cursive Systems, Inc. All Rights Reserved. Contact + * information for Cursive Systems, Inc. is available at + * http://www.cursive.net/. + * + * License + * + * Jabber-Net is licensed under the LGPL. + * See LICENSE.txt for details. + * --------------------------------------------------------------------------*/ +using System; +using System.Threading; +using System.Xml; + +using bedrock.util; +using jabber; +using jabber.client; +using jabber.protocol.client; +using jabber.protocol.iq; +using jabber.connection; + +namespace ConsoleClient +{ + /// + /// Summary description for Class1. + /// + [SVN(@"$Id$")] + class Class1 + { + [CommandLine("j", "user@host Jabber ID", true)] + public string jid = null; + + [CommandLine("p", "Password", false)] + public string pass = null; + + [CommandLine("n", "Network Host", false)] + public string networkHost = null; + + [CommandLine("o", "Port", false)] + public int port = 5222; + + [CommandLine("t", "TLS auto-start", false)] + public bool TLS = true; + + [CommandLine("r", "Register user", false)] + public bool register = false; + + [CommandLine("c", "Certificate file", false)] + public string certificateFile = null; + + [CommandLine("w", "Certificate password", false)] + public string certificatePass = ""; + + [CommandLine("u", "Untrusted certificates OK", false)] + public bool untrustedOK = false; + + [CommandLine("i", "Do not send initial presence", false)] + public bool initialPresence = true; + + [CommandLine("b", "HTTP Binding (BOSH) URL", false)] + public string boshURL = null; + + public Class1(string[] args) + { + JabberClient jc = new JabberClient(); + jc.OnReadText += new bedrock.TextHandler(jc_OnReadText); + jc.OnWriteText += new bedrock.TextHandler(jc_OnWriteText); + jc.OnError +=new bedrock.ExceptionHandler(jc_OnError); + jc.OnStreamError += new jabber.protocol.ProtocolHandler(jc_OnStreamError); + + jc.AutoReconnect = 3f; + + GetOpt go = new GetOpt(this); + try + { + go.Process(args); + } + catch (ArgumentException) + { + go.UsageExit(); + } + + if (untrustedOK) + jc.OnInvalidCertificate += new System.Net.Security.RemoteCertificateValidationCallback(jc_OnInvalidCertificate); + + JID j = new JID(jid); + jc.User = j.User; + jc.Server = j.Server; + jc.NetworkHost = networkHost; + jc.Port = port; + jc.Resource = "Jabber.Net Console Client"; + jc.Password = pass; + jc.AutoStartTLS = TLS; + jc.AutoPresence = initialPresence; + + if (certificateFile != null) + { + jc.SetCertificateFile(certificateFile, certificatePass); + Console.WriteLine(jc.LocalCertificate.ToString(true)); + } + + if (boshURL != null) + { + jc[Options.POLL_URL] = boshURL; + jc[Options.CONNECTION_TYPE] = ConnectionType.HTTP_Binding; + } + + if (register) + { + jc.AutoLogin = false; + jc.OnLoginRequired += + new bedrock.ObjectHandler(jc_OnLoginRequired); + jc.OnRegisterInfo += new RegisterInfoHandler(this.jc_OnRegisterInfo); + jc.OnRegistered += new IQHandler(jc_OnRegistered); + } + + CapsManager cm = new CapsManager(); + cm.Stream = jc; + cm.Node = "http://cursive.net/clients/ConsoleClient"; + + Console.WriteLine("Connecting"); + jc.Connect(); + Console.WriteLine("Connected"); + + string line; + while ((line = Console.ReadLine()) != null) + { + if (line == "/clear") + { + // Hm.... I wonder if this works on windows. + Console.Write("\x1b[H\x1b[2J"); + continue; + } + if ((line == "/q") || (line == "/quit")) + { + jc.Close(); + break; + } + if (line.Trim() == "") + { + continue; + } + try + { + if (line == "") + { + jc.Write(line); + } + else + { + // TODO: deal with stanzas that span lines... keep + // parsing until we have a full "doc". + XmlDocument doc = new XmlDocument(); + doc.LoadXml(line); + XmlElement elem = doc.DocumentElement; + if (elem != null) + jc.Write(elem); + } + } + catch (XmlException ex) + { + Console.WriteLine("Invalid XML: " + ex.Message); + } + } + } + + bool jc_OnInvalidCertificate(object sender, System.Security.Cryptography.X509Certificates.X509Certificate certificate, System.Security.Cryptography.X509Certificates.X509Chain chain, System.Net.Security.SslPolicyErrors sslPolicyErrors) + { + Console.WriteLine("Invalid certificate ({0}):\n{1}", sslPolicyErrors.ToString(), certificate.ToString(true)); + return true; + } + + /// + /// The main entry point for the application. + /// + [STAThread] + static void Main(string[] args) + { + new Class1(args); + } + + private void jc_OnReadText(object sender, string txt) + { + if (txt != " ") + Console.WriteLine("RECV: " + txt); + } + + private void jc_OnWriteText(object sender, string txt) + { + if (txt != " ") + Console.WriteLine("SENT: " + txt); + } + + private void jc_OnError(object sender, Exception ex) + { + Console.WriteLine("ERROR: " + ex.ToString()); + Environment.Exit(1); + } + + private void jc_OnStreamError(object sender, System.Xml.XmlElement rp) + { + Console.WriteLine("Stream ERROR: " + rp.OuterXml); + Environment.Exit(1); + } + + private void jc_OnLoginRequired(object sender) + { + Console.WriteLine("Registering"); + JabberClient jc = (JabberClient) sender; + jc.Register(new JID(jc.User, jc.Server, null)); + } + + private void jc_OnRegistered(object sender, + IQ iq) + { + JabberClient jc = (JabberClient) sender; + if (iq.Type == IQType.result) + jc.Login(); + } + + private bool jc_OnRegisterInfo(object sender, Register r) + { + return true; + } + } +} diff -Nru smuxi-0.8/lib/jabber-net/Example/AddContact.cs smuxi-0.8.9.1/lib/jabber-net/Example/AddContact.cs --- smuxi-0.8/lib/jabber-net/Example/AddContact.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/jabber-net/Example/AddContact.cs 2012-01-03 07:52:11.000000000 +0000 @@ -0,0 +1,325 @@ +/* -------------------------------------------------------------------------- + * Copyrights + * + * Portions created by or assigned to Cursive Systems, Inc. are + * Copyright (c) 2002-2008 Cursive Systems, Inc. All Rights Reserved. Contact + * information for Cursive Systems, Inc. is available at + * http://www.cursive.net/. + * + * License + * + * Jabber-Net is licensed under the LGPL. + * See LICENSE.txt for details. + * --------------------------------------------------------------------------*/ +using System; +using System.ComponentModel; +using System.Drawing; +using System.Text; +using System.Windows.Forms; + +using bedrock.util; +using jabber; + +namespace Example +{ + [SVN(@"$Id$")] + public class AddContact : Form + { + + private Label label1; + private TextBox txtJID; + private Label label2; + private TextBox txtNickname; + private Label label3; + private CheckedListBox lbGroups; + private Button btnOK; + private Button btnCancel; + private TextBox txtGroup; + private Button btnAdd; + + private string m_domain = null; + + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + public AddContact() + { + InitializeComponent(); + } + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + /// + /// The Jabber ID to subscribe to. + /// + public JID JID + { + get + { + return new JID(txtJID.Text); + } + set + { + txtJID.Text = value.ToString(); + } + } + + public string Nickname + { + get + { + return txtNickname.Text; + } + set + { + txtNickname.Text = value; + } + } + + /// + /// All of the groups, checked or not. + /// + public string[] AllGroups + { + get + { + string[] items = new string[lbGroups.Items.Count]; + lbGroups.Items.CopyTo(items, 0); + return items; + } + set + { + lbGroups.BeginUpdate(); + lbGroups.Items.Clear(); + lbGroups.Items.AddRange(value); + lbGroups.EndUpdate(); + } + } + + /// + /// The groups that have been selected + /// + public string[] SelectedGroups + { + get + { + string[] items = new string[lbGroups.CheckedItems.Count]; + lbGroups.CheckedItems.CopyTo(items, 0); + return items; + } + set + { + lbGroups.BeginUpdate(); + lbGroups.ClearSelected(); + for (int i=0; i + /// Use this domain, if one isn't provided in the JID. + /// + public string DefaultDomain + { + get { return m_domain; } + set { m_domain = value; } + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.label1 = new System.Windows.Forms.Label(); + this.txtJID = new System.Windows.Forms.TextBox(); + this.label2 = new System.Windows.Forms.Label(); + this.txtNickname = new System.Windows.Forms.TextBox(); + this.label3 = new System.Windows.Forms.Label(); + this.lbGroups = new System.Windows.Forms.CheckedListBox(); + this.btnOK = new System.Windows.Forms.Button(); + this.btnCancel = new System.Windows.Forms.Button(); + this.txtGroup = new System.Windows.Forms.TextBox(); + this.btnAdd = new System.Windows.Forms.Button(); + this.SuspendLayout(); + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(54, 9); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(26, 13); + this.label1.TabIndex = 0; + this.label1.Text = "JID:"; + // + // txtJID + // + this.txtJID.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.txtJID.Location = new System.Drawing.Point(86, 6); + this.txtJID.Name = "txtJID"; + this.txtJID.Size = new System.Drawing.Size(269, 20); + this.txtJID.TabIndex = 1; + this.txtJID.Leave += new System.EventHandler(this.txtJID_Leave); + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(22, 35); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(58, 13); + this.label2.TabIndex = 2; + this.label2.Text = "Nickname:"; + // + // txtNickname + // + this.txtNickname.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.txtNickname.Location = new System.Drawing.Point(86, 32); + this.txtNickname.Name = "txtNickname"; + this.txtNickname.Size = new System.Drawing.Size(269, 20); + this.txtNickname.TabIndex = 3; + // + // label3 + // + this.label3.AutoSize = true; + this.label3.Location = new System.Drawing.Point(36, 58); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(44, 13); + this.label3.TabIndex = 4; + this.label3.Text = "Groups:"; + // + // lbGroups + // + this.lbGroups.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.lbGroups.Location = new System.Drawing.Point(86, 58); + this.lbGroups.Name = "lbGroups"; + this.lbGroups.Size = new System.Drawing.Size(269, 124); + this.lbGroups.Sorted = true; + this.lbGroups.TabIndex = 5; + // + // btnOK + // + this.btnOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.btnOK.DialogResult = System.Windows.Forms.DialogResult.OK; + this.btnOK.Location = new System.Drawing.Point(199, 215); + this.btnOK.Name = "btnOK"; + this.btnOK.Size = new System.Drawing.Size(75, 23); + this.btnOK.TabIndex = 8; + this.btnOK.Text = "OK"; + // + // btnCancel + // + this.btnCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.btnCancel.Location = new System.Drawing.Point(280, 216); + this.btnCancel.Name = "btnCancel"; + this.btnCancel.Size = new System.Drawing.Size(75, 23); + this.btnCancel.TabIndex = 9; + this.btnCancel.Text = "Cancel"; + // + // txtGroup + // + this.txtGroup.Location = new System.Drawing.Point(86, 190); + this.txtGroup.Name = "txtGroup"; + this.txtGroup.Size = new System.Drawing.Size(269, 20); + this.txtGroup.TabIndex = 6; + this.txtGroup.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txtGroup_KeyDown); + // + // btnAdd + // + this.btnAdd.Location = new System.Drawing.Point(12, 188); + this.btnAdd.Name = "btnAdd"; + this.btnAdd.Size = new System.Drawing.Size(68, 23); + this.btnAdd.TabIndex = 7; + this.btnAdd.Text = "Add Group"; + this.btnAdd.Click += new System.EventHandler(this.btnAdd_Click); + // + // AddContact + // + this.AcceptButton = this.btnOK; + this.CancelButton = this.btnCancel; + this.ClientSize = new System.Drawing.Size(367, 250); + this.Controls.Add(this.btnAdd); + this.Controls.Add(this.txtGroup); + this.Controls.Add(this.btnCancel); + this.Controls.Add(this.btnOK); + this.Controls.Add(this.lbGroups); + this.Controls.Add(this.label3); + this.Controls.Add(this.txtNickname); + this.Controls.Add(this.label2); + this.Controls.Add(this.txtJID); + this.Controls.Add(this.label1); + this.Name = "AddContact"; + this.Text = "Add Contact"; + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private void btnAdd_Click(object sender, EventArgs e) + { + string g = txtGroup.Text.Trim(); + if (g != "") + { + int item = lbGroups.Items.Add(g, true); + lbGroups.TopIndex = item; + txtGroup.Clear(); + } + } + + private void txtGroup_KeyDown(object sender, KeyEventArgs e) + { + // TODO: this doesn't actually work. + if (e.KeyCode == Keys.Return) + { + btnAdd_Click(null, null); +#if NET_20 + e.SuppressKeyPress = true; +#endif + } + } + + private void txtJID_Leave(object sender, EventArgs e) + { + if (!txtJID.Text.Contains("@") && (m_domain != null)) + { + txtJID.Text = txtJID.Text + "@" + m_domain; + } + if (txtNickname.Text == "") + { + JID jid = new JID(txtJID.Text); + txtNickname.Text = jid.User; + } + } + + } +} diff -Nru smuxi-0.8/lib/jabber-net/Example/AddGroup.cs smuxi-0.8.9.1/lib/jabber-net/Example/AddGroup.cs --- smuxi-0.8/lib/jabber-net/Example/AddGroup.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/jabber-net/Example/AddGroup.cs 2012-01-03 07:52:11.000000000 +0000 @@ -0,0 +1,128 @@ +/* -------------------------------------------------------------------------- + * Copyrights + * + * Portions created by or assigned to Cursive Systems, Inc. are + * Copyright (c) 2002-2008 Cursive Systems, Inc. All Rights Reserved. Contact + * information for Cursive Systems, Inc. is available at + * http://www.cursive.net/. + * + * License + * + * Jabber-Net is licensed under the LGPL. + * See LICENSE.txt for details. + * --------------------------------------------------------------------------*/ +using System; +using System.ComponentModel; +using System.Drawing; +using System.Text; +using System.Windows.Forms; + +using bedrock.util; + +namespace Example +{ + [SVN(@"$Id$")] + public class AddGroup : Form + { + private System.Windows.Forms.TextBox textBox1; + private System.Windows.Forms.Button btnOK; + private System.Windows.Forms.Button btnCancel; + + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + public AddGroup() + { + InitializeComponent(); + } + + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + + /// + /// Get the new group name. + /// + public string GroupName + { + get { return textBox1.Text; } + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.textBox1 = new System.Windows.Forms.TextBox(); + this.btnOK = new System.Windows.Forms.Button(); + this.btnCancel = new System.Windows.Forms.Button(); + this.SuspendLayout(); + // + // textBox1 + // + this.textBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.textBox1.Location = new System.Drawing.Point(12, 12); + this.textBox1.Name = "textBox1"; + this.textBox1.Size = new System.Drawing.Size(176, 20); + this.textBox1.TabIndex = 0; + // + // btnOK + // + this.btnOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.btnOK.DialogResult = System.Windows.Forms.DialogResult.OK; + this.btnOK.Location = new System.Drawing.Point(32, 38); + this.btnOK.Name = "btnOK"; + this.btnOK.Size = new System.Drawing.Size(75, 23); + this.btnOK.TabIndex = 1; + this.btnOK.Text = "OK"; + this.btnOK.UseVisualStyleBackColor = true; + // + // btnCancel + // + this.btnCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.btnCancel.Location = new System.Drawing.Point(113, 38); + this.btnCancel.Name = "btnCancel"; + this.btnCancel.Size = new System.Drawing.Size(75, 23); + this.btnCancel.TabIndex = 2; + this.btnCancel.Text = "Cancel"; + this.btnCancel.UseVisualStyleBackColor = true; + // + // AddGroup + // + this.AcceptButton = this.btnOK; + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.CancelButton = this.btnCancel; + this.ClientSize = new System.Drawing.Size(200, 70); + this.Controls.Add(this.btnCancel); + this.Controls.Add(this.btnOK); + this.Controls.Add(this.textBox1); + this.Name = "AddGroup"; + this.Text = "Add Group"; + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + } +} diff -Nru smuxi-0.8/lib/jabber-net/Example/AssemblyInfo.cs smuxi-0.8.9.1/lib/jabber-net/Example/AssemblyInfo.cs --- smuxi-0.8/lib/jabber-net/Example/AssemblyInfo.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/jabber-net/Example/AssemblyInfo.cs 2012-01-03 07:52:11.000000000 +0000 @@ -0,0 +1,72 @@ +/* -------------------------------------------------------------------------- + * Copyrights + * + * Portions created by or assigned to Cursive Systems, Inc. are + * Copyright (c) 2002-2008 Cursive Systems, Inc. All Rights Reserved. Contact + * information for Cursive Systems, Inc. is available at + * http://www.cursive.net/. + * + * License + * + * Jabber-Net is licensed under the LGPL. + * See LICENSE.txt for details. + * --------------------------------------------------------------------------*/ +using System.Reflection; + +using System.Runtime.CompilerServices; + +// +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +// +[assembly: AssemblyTitle("Example")] +[assembly: AssemblyDescription("Jabber-net examples")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Cursive Systems, Inc.")] +[assembly: AssemblyProduct("jnExample")] +[assembly: AssemblyCopyright("Copyright (c) Cursive Systems, 2000-2008")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Revision and Build Numbers +// by using the '*' as shown below: + +[assembly: AssemblyVersion("1.0.*")] + +// +// In order to sign your assembly you must specify a key to use. Refer to the +// Microsoft .NET Framework documentation for more information on assembly signing. +// +// Use the attributes below to control which key is used for signing. +// +// Notes: +// (*) If no key is specified, the assembly is not signed. +// (*) KeyName refers to a key that has been installed in the Crypto Service +// Provider (CSP) on your machine. KeyFile refers to a file which contains +// a key. +// (*) If the KeyFile and the KeyName values are both specified, the +// following processing occurs: +// (1) If the KeyName can be found in the CSP, that key is used. +// (2) If the KeyName does not exist and the KeyFile does exist, the key +// in the KeyFile is installed into the CSP and used. +// (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility. +// When specifying the KeyFile, the location of the KeyFile should be +// relative to the project output directory which is +// %Project Directory%\obj\. For example, if your KeyFile is +// located in the project directory, you would specify the AssemblyKeyFile +// attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")] +// (*) Delay Signing is an advanced option - see the Microsoft .NET Framework +// documentation for more information on this. +// +[assembly: AssemblyDelaySign(false)] +[assembly: AssemblyKeyFile("")] +[assembly: AssemblyKeyName("")] diff -Nru smuxi-0.8/lib/jabber-net/Example/ConferenceForm.cs smuxi-0.8.9.1/lib/jabber-net/Example/ConferenceForm.cs --- smuxi-0.8/lib/jabber-net/Example/ConferenceForm.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/jabber-net/Example/ConferenceForm.cs 2012-01-03 07:52:11.000000000 +0000 @@ -0,0 +1,253 @@ +/* -------------------------------------------------------------------------- + * Copyrights + * + * Portions created by or assigned to Cursive Systems, Inc. are + * Copyright (c) 2002-2008 Cursive Systems, Inc. All Rights Reserved. Contact + * information for Cursive Systems, Inc. is available at + * http://www.cursive.net/. + * + * License + * + * Jabber-Net is licensed under the LGPL. + * See LICENSE.txt for details. + * --------------------------------------------------------------------------*/ +using System; +using System.ComponentModel; +using System.ComponentModel.Design; +using System.Drawing; +using System.Text; +using System.Windows.Forms; + +using bedrock.util; +using jabber; +using jabber.connection; + +namespace Example +{ + [SVN(@"$Id$")] + public class ConferenceForm : Form + { + private Label label1; + private Label label2; + private ComboBox cmbJID; + private TextBox txtRoom; + private Button btnOK; + private Button btnCancel; + + private DiscoManager m_disco = null; + private TextBox txtNick; + private Label label3; + + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + public ConferenceForm() + { + InitializeComponent(); + } + + public DiscoManager DiscoManager + { + get { return m_disco; } + set { m_disco = value; } + } + + public JID RoomJID + { + get + { + return new JID(txtRoom.Text, cmbJID.Text, null); + } + } + + public JID RoomAndNick + { + get + { + return new JID(txtRoom.Text, cmbJID.Text, txtNick.Text); + } + set + { + if (value == null) + { + cmbJID.Text = txtRoom.Text = txtNick.Text = ""; + } + else + { + cmbJID.Text = value.Server; + txtRoom.Text = value.User; + txtNick.Text = value.Resource; + } + } + } + + public string Nick + { + get { return txtNick.Text; } + set { txtNick.Text = value; } + } + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.label1 = new System.Windows.Forms.Label(); + this.label2 = new System.Windows.Forms.Label(); + this.cmbJID = new System.Windows.Forms.ComboBox(); + this.txtRoom = new System.Windows.Forms.TextBox(); + this.btnOK = new System.Windows.Forms.Button(); + this.btnCancel = new System.Windows.Forms.Button(); + this.txtNick = new System.Windows.Forms.TextBox(); + this.label3 = new System.Windows.Forms.Label(); + this.SuspendLayout(); + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(12, 9); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(99, 13); + this.label1.TabIndex = 0; + this.label1.Text = "Conference Server:"; + this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleRight; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(73, 35); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(38, 13); + this.label2.TabIndex = 2; + this.label2.Text = "Room:"; + this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleRight; + // + // cmbJID + // + this.cmbJID.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.cmbJID.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.Suggest; + this.cmbJID.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.ListItems; + this.cmbJID.Location = new System.Drawing.Point(118, 5); + this.cmbJID.Name = "cmbJID"; + this.cmbJID.Size = new System.Drawing.Size(156, 21); + this.cmbJID.TabIndex = 1; + // + // txtRoom + // + this.txtRoom.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.txtRoom.Location = new System.Drawing.Point(118, 32); + this.txtRoom.Name = "txtRoom"; + this.txtRoom.Size = new System.Drawing.Size(156, 20); + this.txtRoom.TabIndex = 3; + // + // btnOK + // + this.btnOK.DialogResult = System.Windows.Forms.DialogResult.OK; + this.btnOK.Location = new System.Drawing.Point(118, 84); + this.btnOK.Name = "btnOK"; + this.btnOK.Size = new System.Drawing.Size(75, 23); + this.btnOK.TabIndex = 6; + this.btnOK.Text = "OK"; + this.btnOK.UseVisualStyleBackColor = true; + // + // btnCancel + // + this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.btnCancel.Location = new System.Drawing.Point(199, 84); + this.btnCancel.Name = "btnCancel"; + this.btnCancel.Size = new System.Drawing.Size(75, 23); + this.btnCancel.TabIndex = 7; + this.btnCancel.Text = "Cancel"; + this.btnCancel.UseVisualStyleBackColor = true; + // + // txtNick + // + this.txtNick.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.txtNick.Location = new System.Drawing.Point(118, 58); + this.txtNick.Name = "txtNick"; + this.txtNick.Size = new System.Drawing.Size(156, 20); + this.txtNick.TabIndex = 5; + // + // label3 + // + this.label3.AutoSize = true; + this.label3.Location = new System.Drawing.Point(53, 61); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(58, 13); + this.label3.TabIndex = 4; + this.label3.Text = "Nickname:"; + this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleRight; + // + // ConferenceForm + // + this.AcceptButton = this.btnOK; + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.CancelButton = this.btnCancel; + this.ClientSize = new System.Drawing.Size(286, 117); + this.Controls.Add(this.txtNick); + this.Controls.Add(this.label3); + this.Controls.Add(this.btnCancel); + this.Controls.Add(this.btnOK); + this.Controls.Add(this.txtRoom); + this.Controls.Add(this.cmbJID); + this.Controls.Add(this.label2); + this.Controls.Add(this.label1); + this.Name = "ConferenceForm"; + this.Text = "Join/Create room"; + this.Shown += new System.EventHandler(this.ConferenceForm_Shown); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + + private void ConferenceForm_Shown(object sender, EventArgs e) + { + cmbJID.BeginUpdate(); + cmbJID.Items.Clear(); + if (m_disco != null) + m_disco.BeginGetItems(null, GotRoot, null); + else + cmbJID.EndUpdate(); + } + + private void GotRoot(DiscoManager sender, DiscoNode node, object state) + { + if (node.Children != null) + { + foreach (DiscoNode component in node.Children) + { + if (component.HasFeature(jabber.protocol.URI.MUC)) + cmbJID.Items.Add(component.JID); + } + if (cmbJID.Items.Count > 0) + cmbJID.SelectedIndex = 0; + } + cmbJID.EndUpdate(); + } + } +} diff -Nru smuxi-0.8/lib/jabber-net/Example/MainForm.cs smuxi-0.8.9.1/lib/jabber-net/Example/MainForm.cs --- smuxi-0.8/lib/jabber-net/Example/MainForm.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/jabber-net/Example/MainForm.cs 2012-01-03 07:52:11.000000000 +0000 @@ -0,0 +1,1224 @@ +/* -------------------------------------------------------------------------- + * Copyrights + * + * Portions created by or assigned to Cursive Systems, Inc. are + * Copyright (c) 2002-2008 Cursive Systems, Inc. All Rights Reserved. Contact + * information for Cursive Systems, Inc. is available at + * http://www.cursive.net/. + * + * License + * + * Jabber-Net is licensed under the LGPL. + * See LICENSE.txt for details. + * --------------------------------------------------------------------------*/ + +using System; +using System.ComponentModel; +using System.Diagnostics; +using System.Drawing; +using System.Windows.Forms; +using System.Xml; +using bedrock.util; +using jabber; +using jabber.connection; +using jabber.protocol; +using jabber.protocol.client; +using jabber.protocol.iq; + +namespace Example +{ + /// + /// Summary description for MainForm. + /// + [SVN(@"$Id$")] + public class MainForm : Form + { + #region Private Members + + private StatusBar sb; + private jabber.client.JabberClient jc; + private jabber.client.RosterManager rm; + private jabber.client.PresenceManager pm; + private TabControl tabControl1; + private TabPage tpDebug; + private TabPage tpRoster; + private StatusBarPanel pnlCon; + private StatusBarPanel pnlPresence; + private ContextMenu mnuPresence; + private MenuItem mnuAvailable; + private MenuItem mnuAway; + private IContainer components; + private muzzle.RosterTree roster; + private StatusBarPanel pnlSSL; + private DiscoManager dm; + private TabPage tpServices; + private CapsManager cm; + private muzzle.XmppDebugger debug; + private PubSubManager psm; + private MenuStrip menuStrip1; + private ToolStripMenuItem fileToolStripMenuItem; + private ToolStripMenuItem connectToolStripMenuItem; + private ToolStripSeparator toolStripMenuItem1; + private ToolStripMenuItem exitToolStripMenuItem; + private ToolStripMenuItem viewToolStripMenuItem; + private ToolStripMenuItem servicesToolStripMenuItem; + private ToolStripMenuItem debugToolStripMenuItem; + private ToolStripMenuItem rosterToolStripMenuItem; + private ToolStripMenuItem addContactToolStripMenuItem; + private ToolStripMenuItem removeContactToolStripMenuItem; + private ToolStripMenuItem addGroupToolStripMenuItem; + private IdleTime idler; + private ServiceDisplay services; + private ToolStripMenuItem windowToolStripMenuItem; + private ToolStripMenuItem closeTabToolStripMenuItem; + private ToolStripMenuItem deletePubSubToolStripMenuItem; + private ToolStripMenuItem subscribePubSubToolStripMenuItem; + private ToolStripMenuItem pubSubToolStripMenuItem; + private ConferenceManager muc; + private ToolStripMenuItem joinConferenceToolStripMenuItem; + + private bool m_err = false; + private jabber.client.BookmarkManager bmm; + private TabPage tpBookmarks; + private ListView lvBookmarks; + private ColumnHeader chName; + private ColumnHeader chNick; + private ColumnHeader chAutoJoin; + private ToolStripMenuItem bookmarkToolStripMenuItem; + private ToolStripMenuItem addToolStripMenuItem; + private ToolStripMenuItem removeToolStripMenuItem; + private bool m_connected = false; + + #endregion + + public MainForm() + { + // + // Required for Windows Form Designer support + // + InitializeComponent(); + + services.ImageList = roster.ImageList; + cm.AddFeature(URI.TIME); + cm.AddFeature(URI.VERSION); + cm.AddFeature(URI.LAST); + cm.AddFeature(URI.DISCO_INFO); + + tabControl1.TabPages.Remove(tpServices); + tabControl1.TabPages.Remove(tpDebug); + AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; + } + + + void idler_OnUnIdle(object sender, TimeSpan span) + { + jc.Presence(PresenceType.available, "Available", null, 0); + pnlPresence.Text = "Available"; + } + + private void idler_OnIdle(object sender, TimeSpan span) + { + jc.Presence(PresenceType.available, "Auto-away", "away", 0); + pnlPresence.Text = "Away"; + } + + /// + /// Clean up any resources being used. + /// + protected override void Dispose( bool disposing ) + { + idler.Enabled = false; + + if( disposing ) + { + if (components != null) + { + components.Dispose(); + } + } + base.Dispose( disposing ); + } + +#region Windows Form Designer generated code + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + jabber.connection.Ident ident2 = new jabber.connection.Ident(); + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm)); + this.sb = new System.Windows.Forms.StatusBar(); + this.pnlCon = new System.Windows.Forms.StatusBarPanel(); + this.pnlSSL = new System.Windows.Forms.StatusBarPanel(); + this.pnlPresence = new System.Windows.Forms.StatusBarPanel(); + this.tabControl1 = new System.Windows.Forms.TabControl(); + this.tpRoster = new System.Windows.Forms.TabPage(); + this.roster = new muzzle.RosterTree(); + this.jc = new jabber.client.JabberClient(this.components); + this.pm = new jabber.client.PresenceManager(this.components); + this.cm = new jabber.connection.CapsManager(this.components); + this.dm = new jabber.connection.DiscoManager(this.components); + this.rm = new jabber.client.RosterManager(this.components); + this.tpServices = new System.Windows.Forms.TabPage(); + this.services = new Example.ServiceDisplay(); + this.tpBookmarks = new System.Windows.Forms.TabPage(); + this.lvBookmarks = new System.Windows.Forms.ListView(); + this.chName = new System.Windows.Forms.ColumnHeader(); + this.chNick = new System.Windows.Forms.ColumnHeader(); + this.chAutoJoin = new System.Windows.Forms.ColumnHeader(); + this.tpDebug = new System.Windows.Forms.TabPage(); + this.debug = new muzzle.XmppDebugger(); + this.mnuPresence = new System.Windows.Forms.ContextMenu(); + this.mnuAvailable = new System.Windows.Forms.MenuItem(); + this.mnuAway = new System.Windows.Forms.MenuItem(); + this.menuStrip1 = new System.Windows.Forms.MenuStrip(); + this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.connectToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.joinConferenceToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripSeparator(); + this.exitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.viewToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.servicesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.debugToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.rosterToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.addContactToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.removeContactToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.addGroupToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.bookmarkToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.addToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.removeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.windowToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.closeTabToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.pubSubToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.subscribePubSubToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.deletePubSubToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.psm = new jabber.connection.PubSubManager(this.components); + this.idler = new bedrock.util.IdleTime(); + this.muc = new jabber.connection.ConferenceManager(this.components); + this.bmm = new jabber.client.BookmarkManager(this.components); + ((System.ComponentModel.ISupportInitialize)(this.pnlCon)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.pnlSSL)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.pnlPresence)).BeginInit(); + this.tabControl1.SuspendLayout(); + this.tpRoster.SuspendLayout(); + this.tpServices.SuspendLayout(); + this.tpBookmarks.SuspendLayout(); + this.tpDebug.SuspendLayout(); + this.menuStrip1.SuspendLayout(); + this.SuspendLayout(); + // + // sb + // + this.sb.Location = new System.Drawing.Point(0, 416); + this.sb.Name = "sb"; + this.sb.Panels.AddRange(new System.Windows.Forms.StatusBarPanel[] { + this.pnlCon, + this.pnlSSL, + this.pnlPresence}); + this.sb.ShowPanels = true; + this.sb.Size = new System.Drawing.Size(632, 22); + this.sb.TabIndex = 0; + this.sb.PanelClick += new System.Windows.Forms.StatusBarPanelClickEventHandler(this.sb_PanelClick); + // + // pnlCon + // + this.pnlCon.AutoSize = System.Windows.Forms.StatusBarPanelAutoSize.Spring; + this.pnlCon.Name = "pnlCon"; + this.pnlCon.Text = "Click on \"Offline\", and select a presence to log in."; + this.pnlCon.Width = 538; + // + // pnlSSL + // + this.pnlSSL.Alignment = System.Windows.Forms.HorizontalAlignment.Center; + this.pnlSSL.Name = "pnlSSL"; + this.pnlSSL.Width = 30; + // + // pnlPresence + // + this.pnlPresence.Alignment = System.Windows.Forms.HorizontalAlignment.Right; + this.pnlPresence.AutoSize = System.Windows.Forms.StatusBarPanelAutoSize.Contents; + this.pnlPresence.Name = "pnlPresence"; + this.pnlPresence.Text = "Offline"; + this.pnlPresence.Width = 47; + // + // tabControl1 + // + this.tabControl1.Controls.Add(this.tpRoster); + this.tabControl1.Controls.Add(this.tpServices); + this.tabControl1.Controls.Add(this.tpBookmarks); + this.tabControl1.Controls.Add(this.tpDebug); + this.tabControl1.Dock = System.Windows.Forms.DockStyle.Fill; + this.tabControl1.Location = new System.Drawing.Point(0, 24); + this.tabControl1.Name = "tabControl1"; + this.tabControl1.SelectedIndex = 0; + this.tabControl1.Size = new System.Drawing.Size(632, 392); + this.tabControl1.TabIndex = 2; + // + // tpRoster + // + this.tpRoster.Controls.Add(this.roster); + this.tpRoster.Location = new System.Drawing.Point(4, 22); + this.tpRoster.Name = "tpRoster"; + this.tpRoster.Size = new System.Drawing.Size(624, 366); + this.tpRoster.TabIndex = 1; + this.tpRoster.Text = "Roster"; + this.tpRoster.UseVisualStyleBackColor = true; + // + // roster + // + this.roster.AllowDrop = true; + this.roster.Client = this.jc; + this.roster.Dock = System.Windows.Forms.DockStyle.Fill; + this.roster.DrawMode = System.Windows.Forms.TreeViewDrawMode.OwnerDrawText; + this.roster.ImageIndex = 1; + this.roster.Location = new System.Drawing.Point(0, 0); + this.roster.Name = "roster"; + this.roster.PresenceManager = this.pm; + this.roster.RosterManager = this.rm; + this.roster.SelectedImageIndex = 0; + this.roster.ShowLines = false; + this.roster.ShowRootLines = false; + this.roster.Size = new System.Drawing.Size(624, 366); + this.roster.Sorted = true; + this.roster.StatusColor = System.Drawing.Color.Teal; + this.roster.TabIndex = 0; + this.roster.DoubleClick += new System.EventHandler(this.roster_DoubleClick); + // + // jc + // + this.jc.AutoReconnect = 3F; + this.jc.AutoStartCompression = true; + this.jc.AutoStartTLS = true; + this.jc.InvokeControl = this; + this.jc.KeepAlive = 30F; + this.jc.LocalCertificate = null; + this.jc.Password = null; + this.jc.User = null; + this.jc.OnRegisterInfo += new jabber.client.RegisterInfoHandler(this.jc_OnRegisterInfo); + this.jc.OnError += new bedrock.ExceptionHandler(this.jc_OnError); + this.jc.OnIQ += new jabber.client.IQHandler(this.jc_OnIQ); + this.jc.OnAuthenticate += new bedrock.ObjectHandler(this.jc_OnAuthenticate); + this.jc.OnStreamError += new jabber.protocol.ProtocolHandler(this.jc_OnStreamError); + this.jc.OnConnect += new jabber.connection.StanzaStreamHandler(this.jc_OnConnect); + this.jc.OnDisconnect += new bedrock.ObjectHandler(this.jc_OnDisconnect); + this.jc.OnAuthError += new jabber.protocol.ProtocolHandler(this.jc_OnAuthError); + this.jc.OnRegistered += new jabber.client.IQHandler(this.jc_OnRegistered); + this.jc.OnMessage += new jabber.client.MessageHandler(this.jc_OnMessage); + // + // pm + // + this.pm.CapsManager = this.cm; + this.pm.OverrideFrom = null; + this.pm.Stream = this.jc; + // + // cm + // + this.cm.DiscoManager = this.dm; + this.cm.Features = new string[0]; + this.cm.FileName = "caps.xml"; + ident2.Category = "client"; + ident2.Lang = "en"; + ident2.Name = "Jabber-Net Test Client"; + ident2.Type = "pc"; + this.cm.Identities = new jabber.connection.Ident[] { + ident2}; + this.cm.Node = "http://cursive.net/clients/csharp-example"; + this.cm.OverrideFrom = null; + this.cm.Stream = this.jc; + // + // dm + // + this.dm.OverrideFrom = null; + this.dm.Stream = this.jc; + // + // rm + // + this.rm.AutoAllow = jabber.client.AutoSubscriptionHanding.AllowIfSubscribed; + this.rm.AutoSubscribe = true; + this.rm.OverrideFrom = null; + this.rm.Stream = this.jc; + this.rm.OnRosterEnd += new bedrock.ObjectHandler(this.rm_OnRosterEnd); + this.rm.OnSubscription += new jabber.client.SubscriptionHandler(this.rm_OnSubscription); + this.rm.OnUnsubscription += new jabber.client.UnsubscriptionHandler(this.rm_OnUnsubscription); + // + // tpServices + // + this.tpServices.Controls.Add(this.services); + this.tpServices.Location = new System.Drawing.Point(4, 22); + this.tpServices.Name = "tpServices"; + this.tpServices.Size = new System.Drawing.Size(624, 366); + this.tpServices.TabIndex = 2; + this.tpServices.Text = "Services"; + this.tpServices.UseVisualStyleBackColor = true; + // + // services + // + this.services.DiscoManager = this.dm; + this.services.Dock = System.Windows.Forms.DockStyle.Fill; + this.services.ImageList = null; + this.services.Location = new System.Drawing.Point(0, 0); + this.services.Name = "services"; + this.services.Size = new System.Drawing.Size(624, 366); + this.services.Stream = this.jc; + this.services.TabIndex = 0; + // + // tpBookmarks + // + this.tpBookmarks.Controls.Add(this.lvBookmarks); + this.tpBookmarks.Location = new System.Drawing.Point(4, 22); + this.tpBookmarks.Name = "tpBookmarks"; + this.tpBookmarks.Size = new System.Drawing.Size(624, 366); + this.tpBookmarks.TabIndex = 3; + this.tpBookmarks.Text = "Bookmarks"; + this.tpBookmarks.UseVisualStyleBackColor = true; + // + // lvBookmarks + // + this.lvBookmarks.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { + this.chName, + this.chNick, + this.chAutoJoin}); + this.lvBookmarks.Dock = System.Windows.Forms.DockStyle.Fill; + this.lvBookmarks.Location = new System.Drawing.Point(0, 0); + this.lvBookmarks.Name = "lvBookmarks"; + this.lvBookmarks.Size = new System.Drawing.Size(624, 366); + this.lvBookmarks.Sorting = System.Windows.Forms.SortOrder.Ascending; + this.lvBookmarks.TabIndex = 0; + this.lvBookmarks.UseCompatibleStateImageBehavior = false; + this.lvBookmarks.View = System.Windows.Forms.View.Details; + this.lvBookmarks.DoubleClick += new System.EventHandler(this.lvBookmarks_DoubleClick); + this.lvBookmarks.KeyUp += new System.Windows.Forms.KeyEventHandler(this.lvBookmarks_KeyUp); + // + // chName + // + this.chName.Text = "Room"; + this.chName.Width = 198; + // + // chNick + // + this.chNick.Text = "Nick"; + this.chNick.Width = 88; + // + // chAutoJoin + // + this.chAutoJoin.Text = "AutoJoin"; + // + // tpDebug + // + this.tpDebug.Controls.Add(this.debug); + this.tpDebug.Location = new System.Drawing.Point(4, 22); + this.tpDebug.Name = "tpDebug"; + this.tpDebug.Size = new System.Drawing.Size(624, 366); + this.tpDebug.TabIndex = 0; + this.tpDebug.Text = "Debug"; + this.tpDebug.UseVisualStyleBackColor = true; + // + // debug + // + this.debug.Dock = System.Windows.Forms.DockStyle.Fill; + this.debug.ErrorColor = System.Drawing.Color.Red; + this.debug.Location = new System.Drawing.Point(0, 0); + this.debug.Name = "debug"; + this.debug.OtherColor = System.Drawing.Color.Green; + this.debug.OverrideFrom = null; + this.debug.ReceiveColor = System.Drawing.Color.Orange; + this.debug.SendColor = System.Drawing.Color.Blue; + this.debug.Size = new System.Drawing.Size(624, 366); + this.debug.Stream = this.jc; + this.debug.TabIndex = 0; + this.debug.TextColor = System.Drawing.Color.Black; + // + // mnuPresence + // + this.mnuPresence.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { + this.mnuAvailable, + this.mnuAway}); + // + // mnuAvailable + // + this.mnuAvailable.Enabled = false; + this.mnuAvailable.Index = 0; + this.mnuAvailable.Shortcut = System.Windows.Forms.Shortcut.CtrlO; + this.mnuAvailable.Text = "&Available"; + this.mnuAvailable.Click += new System.EventHandler(this.mnuAvailable_Click); + // + // mnuAway + // + this.mnuAway.Enabled = false; + this.mnuAway.Index = 1; + this.mnuAway.Shortcut = System.Windows.Forms.Shortcut.CtrlA; + this.mnuAway.Text = "A&way"; + this.mnuAway.Click += new System.EventHandler(this.mnuAway_Click); + // + // menuStrip1 + // + this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.fileToolStripMenuItem, + this.viewToolStripMenuItem, + this.rosterToolStripMenuItem, + this.bookmarkToolStripMenuItem, + this.windowToolStripMenuItem, + this.pubSubToolStripMenuItem}); + this.menuStrip1.Location = new System.Drawing.Point(0, 0); + this.menuStrip1.Name = "menuStrip1"; + this.menuStrip1.Size = new System.Drawing.Size(632, 24); + this.menuStrip1.TabIndex = 3; + this.menuStrip1.Text = "menuStrip1"; + // + // fileToolStripMenuItem + // + this.fileToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.connectToolStripMenuItem, + this.joinConferenceToolStripMenuItem, + this.toolStripMenuItem1, + this.exitToolStripMenuItem}); + this.fileToolStripMenuItem.Name = "fileToolStripMenuItem"; + this.fileToolStripMenuItem.Size = new System.Drawing.Size(35, 20); + this.fileToolStripMenuItem.Text = "&File"; + // + // connectToolStripMenuItem + // + this.connectToolStripMenuItem.Name = "connectToolStripMenuItem"; + this.connectToolStripMenuItem.ShortcutKeys = System.Windows.Forms.Keys.F9; + this.connectToolStripMenuItem.Size = new System.Drawing.Size(200, 22); + this.connectToolStripMenuItem.Text = "&Connect"; + this.connectToolStripMenuItem.Click += new System.EventHandler(this.connectToolStripMenuItem_Click); + // + // joinConferenceToolStripMenuItem + // + this.joinConferenceToolStripMenuItem.Name = "joinConferenceToolStripMenuItem"; + this.joinConferenceToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.J))); + this.joinConferenceToolStripMenuItem.Size = new System.Drawing.Size(200, 22); + this.joinConferenceToolStripMenuItem.Text = "&Join Conference"; + this.joinConferenceToolStripMenuItem.Click += new System.EventHandler(this.joinConferenceToolStripMenuItem_Click); + // + // toolStripMenuItem1 + // + this.toolStripMenuItem1.Name = "toolStripMenuItem1"; + this.toolStripMenuItem1.Size = new System.Drawing.Size(197, 6); + // + // exitToolStripMenuItem + // + this.exitToolStripMenuItem.Name = "exitToolStripMenuItem"; + this.exitToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Q))); + this.exitToolStripMenuItem.Size = new System.Drawing.Size(200, 22); + this.exitToolStripMenuItem.Text = "E&xit"; + this.exitToolStripMenuItem.Click += new System.EventHandler(this.exitToolStripMenuItem_Click); + // + // viewToolStripMenuItem + // + this.viewToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.servicesToolStripMenuItem, + this.debugToolStripMenuItem}); + this.viewToolStripMenuItem.Name = "viewToolStripMenuItem"; + this.viewToolStripMenuItem.Size = new System.Drawing.Size(41, 20); + this.viewToolStripMenuItem.Text = "&View"; + // + // servicesToolStripMenuItem + // + this.servicesToolStripMenuItem.Name = "servicesToolStripMenuItem"; + this.servicesToolStripMenuItem.ShortcutKeys = System.Windows.Forms.Keys.F8; + this.servicesToolStripMenuItem.Size = new System.Drawing.Size(144, 22); + this.servicesToolStripMenuItem.Text = "&Services"; + this.servicesToolStripMenuItem.Click += new System.EventHandler(this.servicesToolStripMenuItem_Click); + // + // debugToolStripMenuItem + // + this.debugToolStripMenuItem.Name = "debugToolStripMenuItem"; + this.debugToolStripMenuItem.ShortcutKeys = System.Windows.Forms.Keys.F12; + this.debugToolStripMenuItem.Size = new System.Drawing.Size(144, 22); + this.debugToolStripMenuItem.Text = "&Debug"; + this.debugToolStripMenuItem.Click += new System.EventHandler(this.debugToolStripMenuItem_Click); + // + // rosterToolStripMenuItem + // + this.rosterToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.addContactToolStripMenuItem, + this.removeContactToolStripMenuItem, + this.addGroupToolStripMenuItem}); + this.rosterToolStripMenuItem.Name = "rosterToolStripMenuItem"; + this.rosterToolStripMenuItem.Size = new System.Drawing.Size(51, 20); + this.rosterToolStripMenuItem.Text = "&Roster"; + // + // addContactToolStripMenuItem + // + this.addContactToolStripMenuItem.Name = "addContactToolStripMenuItem"; + this.addContactToolStripMenuItem.ShortcutKeys = System.Windows.Forms.Keys.Insert; + this.addContactToolStripMenuItem.Size = new System.Drawing.Size(187, 22); + this.addContactToolStripMenuItem.Text = "&Add Contact"; + this.addContactToolStripMenuItem.Click += new System.EventHandler(this.menuItem3_Click); + // + // removeContactToolStripMenuItem + // + this.removeContactToolStripMenuItem.Name = "removeContactToolStripMenuItem"; + this.removeContactToolStripMenuItem.ShortcutKeys = System.Windows.Forms.Keys.Delete; + this.removeContactToolStripMenuItem.Size = new System.Drawing.Size(187, 22); + this.removeContactToolStripMenuItem.Text = "&Remove Contact"; + this.removeContactToolStripMenuItem.Click += new System.EventHandler(this.menuItem5_Click); + // + // addGroupToolStripMenuItem + // + this.addGroupToolStripMenuItem.Name = "addGroupToolStripMenuItem"; + this.addGroupToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.G))); + this.addGroupToolStripMenuItem.Size = new System.Drawing.Size(187, 22); + this.addGroupToolStripMenuItem.Text = "&Add Group"; + this.addGroupToolStripMenuItem.Click += new System.EventHandler(this.addGroupToolStripMenuItem_Click); + // + // bookmarkToolStripMenuItem + // + this.bookmarkToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.addToolStripMenuItem, + this.removeToolStripMenuItem}); + this.bookmarkToolStripMenuItem.Name = "bookmarkToolStripMenuItem"; + this.bookmarkToolStripMenuItem.Size = new System.Drawing.Size(65, 20); + this.bookmarkToolStripMenuItem.Text = "Bookmark"; + // + // addToolStripMenuItem + // + this.addToolStripMenuItem.Name = "addToolStripMenuItem"; + this.addToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.B))); + this.addToolStripMenuItem.Size = new System.Drawing.Size(192, 22); + this.addToolStripMenuItem.Text = "Add"; + this.addToolStripMenuItem.Click += new System.EventHandler(this.addToolStripMenuItem_Click); + // + // removeToolStripMenuItem + // + this.removeToolStripMenuItem.Name = "removeToolStripMenuItem"; + this.removeToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)(((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Shift) + | System.Windows.Forms.Keys.B))); + this.removeToolStripMenuItem.Size = new System.Drawing.Size(192, 22); + this.removeToolStripMenuItem.Text = "Remove"; + this.removeToolStripMenuItem.Click += new System.EventHandler(this.removeToolStripMenuItem_Click); + // + // windowToolStripMenuItem + // + this.windowToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.closeTabToolStripMenuItem}); + this.windowToolStripMenuItem.Name = "windowToolStripMenuItem"; + this.windowToolStripMenuItem.Size = new System.Drawing.Size(57, 20); + this.windowToolStripMenuItem.Text = "&Window"; + // + // closeTabToolStripMenuItem + // + this.closeTabToolStripMenuItem.Name = "closeTabToolStripMenuItem"; + this.closeTabToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.W))); + this.closeTabToolStripMenuItem.Size = new System.Drawing.Size(174, 22); + this.closeTabToolStripMenuItem.Text = "&Close Tab"; + this.closeTabToolStripMenuItem.Click += new System.EventHandler(this.closeTabToolStripMenuItem_Click); + // + // pubSubToolStripMenuItem + // + this.pubSubToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.subscribePubSubToolStripMenuItem, + this.deletePubSubToolStripMenuItem}); + this.pubSubToolStripMenuItem.Name = "pubSubToolStripMenuItem"; + this.pubSubToolStripMenuItem.Size = new System.Drawing.Size(55, 20); + this.pubSubToolStripMenuItem.Text = "PubSub"; + // + // subscribePubSubToolStripMenuItem + // + this.subscribePubSubToolStripMenuItem.Name = "subscribePubSubToolStripMenuItem"; + this.subscribePubSubToolStripMenuItem.ShortcutKeys = System.Windows.Forms.Keys.F10; + this.subscribePubSubToolStripMenuItem.Size = new System.Drawing.Size(156, 22); + this.subscribePubSubToolStripMenuItem.Text = "&Subscribe"; + this.subscribePubSubToolStripMenuItem.Click += new System.EventHandler(this.subscribeToPubSubToolStripMenuItem_Click); + // + // deletePubSubToolStripMenuItem + // + this.deletePubSubToolStripMenuItem.Name = "deletePubSubToolStripMenuItem"; + this.deletePubSubToolStripMenuItem.ShortcutKeys = System.Windows.Forms.Keys.F11; + this.deletePubSubToolStripMenuItem.Size = new System.Drawing.Size(156, 22); + this.deletePubSubToolStripMenuItem.Text = "&Delete"; + this.deletePubSubToolStripMenuItem.Click += new System.EventHandler(this.deletePubSubToolStripMenuItem_Click); + // + // psm + // + this.psm.OverrideFrom = null; + this.psm.Stream = this.jc; + // + // idler + // + this.idler.InvokeControl = this; + this.idler.OnIdle += new bedrock.util.SpanEventHandler(this.idler_OnIdle); + this.idler.OnUnIdle += new bedrock.util.SpanEventHandler(this.idler_OnUnIdle); + // + // muc + // + this.muc.OverrideFrom = null; + this.muc.Stream = this.jc; + // + // bmm + // + this.bmm.ConferenceManager = this.muc; + this.bmm.OverrideFrom = null; + this.bmm.Stream = this.jc; + this.bmm.OnConferenceAdd += new jabber.client.BookmarkConferenceDelegate(this.bmm_OnConferenceAdd); + this.bmm.OnConferenceRemove += new jabber.client.BookmarkConferenceDelegate(this.bmm_OnConferenceRemove); + // + // MainForm + // + this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); + this.ClientSize = new System.Drawing.Size(632, 438); + this.ContextMenu = this.mnuPresence; + this.Controls.Add(this.tabControl1); + this.Controls.Add(this.sb); + this.Controls.Add(this.menuStrip1); + this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); + this.MainMenuStrip = this.menuStrip1; + this.Name = "MainForm"; + this.Text = "MainForm"; + this.Closing += new System.ComponentModel.CancelEventHandler(this.MainForm_Closing); + ((System.ComponentModel.ISupportInitialize)(this.pnlCon)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.pnlSSL)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.pnlPresence)).EndInit(); + this.tabControl1.ResumeLayout(false); + this.tpRoster.ResumeLayout(false); + this.tpServices.ResumeLayout(false); + this.tpBookmarks.ResumeLayout(false); + this.tpDebug.ResumeLayout(false); + this.menuStrip1.ResumeLayout(false); + this.menuStrip1.PerformLayout(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + +#endregion + + /// + /// The MainForm entry point for the application. + /// + [STAThread] + static void Main() + { + Application.Run(new MainForm()); + } + + private void Connect() + { + muzzle.ClientLogin.Login(jc, "login.xml"); + } + + private void jc_OnAuthenticate(object sender) + { + pnlPresence.Text = "Available"; + pnlCon.Text = "Connected"; + mnuAway.Enabled = mnuAvailable.Enabled = true; + + if (jc.SSLon) + { + + pnlSSL.Text = "SSL"; + System.Security.Cryptography.X509Certificates.X509Certificate cert2 = + (System.Security.Cryptography.X509Certificates.X509Certificate) + jc[Options.REMOTE_CERTIFICATE]; + + string cert_str = cert2.ToString(true); + debug.Write("CERT:", cert_str); + pnlSSL.ToolTipText = cert_str; + } + idler.Enabled = true; + } + + private void jc_OnDisconnect(object sender) + { + m_connected = false; + mnuAway.Enabled = mnuAvailable.Enabled = false; + idler.Enabled = false; + pnlPresence.Text = "Offline"; + pnlSSL.Text = ""; + pnlSSL.ToolTipText = ""; + connectToolStripMenuItem.Text = "&Connect"; + lvBookmarks.Items.Clear(); + + if (!m_err) + pnlCon.Text = "Disconnected"; + } + + private void jc_OnError(object sender, Exception ex) + { + m_connected = false; + mnuAway.Enabled = mnuAvailable.Enabled = false; + connectToolStripMenuItem.Text = "&Connect"; + idler.Enabled = false; + lvBookmarks.Items.Clear(); + + pnlCon.Text = "Error: " + ex.Message; + } + + private void jc_OnAuthError(object sender, XmlElement elem) + { + if (MessageBox.Show(this, + "Create new account?", + "Authentication error", + MessageBoxButtons.OKCancel, + MessageBoxIcon.Warning) == DialogResult.OK) + { + if (!m_connected) + { + MessageBox.Show("You have been disconnected by the server. Registration is not enabled.", "Disconnected", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + jc.Register(new JID(jc.User, jc.Server, null)); + } + else + { + jc.Close(false); + } + } + + private void jc_OnRegistered(object sender, IQ iq) + { + if (iq.Type == IQType.result) + jc.Login(); + else + pnlCon.Text = "Registration error"; + } + + private bool jc_OnRegisterInfo(object sender, Register r) + { + if (r.Form == null) + return true; + muzzle.XDataForm f = new muzzle.XDataForm(r.Form); + if (f.ShowDialog() != DialogResult.OK) + return false; + f.FillInResponse(r.Form); + return true; + } + + private void jc_OnMessage(object sender, jabber.protocol.client.Message msg) + { + jabber.protocol.x.Data x = msg["x", URI.XDATA] as jabber.protocol.x.Data; + if (x != null) + { + muzzle.XDataForm f = new muzzle.XDataForm(msg); + f.ShowDialog(this); + jc.Write(f.GetResponse()); + } + else + MessageBox.Show(this, msg.Body, msg.From, MessageBoxButtons.OK); + } + + private void jc_OnIQ(object sender, IQ iq) + { + if (iq.Type != IQType.get) + return; + + XmlElement query = iq.Query; + if (query == null) + return; + + // + if (query is jabber.protocol.iq.Version) + { + iq = iq.GetResponse(jc.Document); + jabber.protocol.iq.Version ver = iq.Query as jabber.protocol.iq.Version; + if (ver != null) + { + ver.OS = Environment.OSVersion.ToString(); + ver.EntityName = Application.ProductName; + ver.Ver = Application.ProductVersion; + } + jc.Write(iq); + return; + } + + if (query is Time) + { + iq = iq.GetResponse(jc.Document); + Time tim = iq.Query as Time; + if (tim != null) tim.SetCurrentTime(); + jc.Write(iq); + return; + } + + if (query is Last) + { + iq = iq.GetResponse(jc.Document); + Last last = iq.Query as Last; + if (last != null) last.Seconds = (int)IdleTime.GetIdleTime(); + jc.Write(iq); + return; + } + } + + private void roster_DoubleClick(object sender, EventArgs e) + { + muzzle.RosterTree.ItemNode n = roster.SelectedNode as muzzle.RosterTree.ItemNode; + if (n == null) + return; + new SendMessage(jc, n.JID).Show(); + } + + private void sb_PanelClick(object sender, StatusBarPanelClickEventArgs e) + { + if (e.StatusBarPanel != pnlPresence) + return; + mnuPresence.Show(sb, new Point(e.X, e.Y)); + } + + private void connectToolStripMenuItem_Click(object sender, EventArgs e) + { + if (jc.IsAuthenticated) + { + jc.Close(true); + connectToolStripMenuItem.Text = "&Connect"; + } + else + { + Connect(); + connectToolStripMenuItem.Text = "Dis&connect"; + } + } + + private void mnuAvailable_Click(object sender, EventArgs e) + { + if (jc.IsAuthenticated) + { + jc.Presence(PresenceType.available, "Available", null, 0); + pnlPresence.Text = "Available"; + } + else + Connect(); + } + + private void mnuAway_Click(object sender, EventArgs e) + { + if (jc.IsAuthenticated) + { + jc.Presence(PresenceType.available, "Away", "away", 0); + pnlPresence.Text = "Away"; + } + else + Connect(); + } + + /* + private void mnuOffline_Click(object sender, EventArgs e) + { + if (jc.IsAuthenticated) + jc.Close(); + } + */ + + void jc_OnConnect(object sender, StanzaStream stream) + { + m_err = false; + m_connected = true; + } + + private void jc_OnStreamError(object sender, XmlElement rp) + { + m_err = true; + pnlCon.Text = "Stream error: " + rp.InnerText; + } + + /* + private void txtDebugInput_KeyUp(object sender, System.Windows.Forms.KeyEventArgs e) + { + if ((e.KeyCode == Keys.Enter) && e.Control) + { + try + { + XmlDocument doc = new XmlDocument(); + doc.LoadXml(txtDebugInput.Text); + XmlElement elem = doc.DocumentElement; + if (elem != null) + jc.Write(elem); + txtDebugInput.Clear(); + } + catch (XmlException ex) + { + MessageBox.Show("Invalid XML: " + ex.Message); + } + } + + } +*/ + private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) + { + MessageBox.Show(e.ExceptionObject.ToString(), "Unhandled exception: " + e.GetType()); + } + + private void rm_OnRosterEnd(object sender) + { + roster.ExpandAll(); + } + + private void MainForm_Closing(object sender, CancelEventArgs e) + { + if (jc.IsAuthenticated) + jc.Close(); + } + + private void exitToolStripMenuItem_Click(object sender, EventArgs e) + { + jc.Close(); + Close(); + } + + private void menuItem3_Click(object sender, EventArgs e) + { + AddContact ac = new AddContact(); + ac.AllGroups = roster.Groups; + ac.DefaultDomain = jc.Server; + if (ac.ShowDialog() != DialogResult.OK) + return; + + jc.Subscribe(ac.JID, ac.Nickname, ac.SelectedGroups); + } + + private void menuItem5_Click(object sender, EventArgs e) + { + muzzle.RosterTree.ItemNode n = roster.SelectedNode as muzzle.RosterTree.ItemNode; + if (n == null) + return; + jc.RemoveRosterItem(n.JID); + } + + + // add group + private void addGroupToolStripMenuItem_Click(object sender, EventArgs e) + { + AddGroup ag = new AddGroup(); + if (ag.ShowDialog() == DialogResult.Cancel) + return; + + if (ag.GroupName == "") + return; + + roster.AddGroup(ag.GroupName).EnsureVisible(); + } + + private void servicesToolStripMenuItem_Click(object sender, EventArgs e) + { + if (tabControl1.TabPages.Contains(tpServices)) + { + tabControl1.TabPages.Remove(tpServices); + servicesToolStripMenuItem.Checked = false; + } + else + { + tabControl1.TabPages.Add(tpServices); + tabControl1.SelectedTab = tpServices; + servicesToolStripMenuItem.Checked = true; + } + } + + private void debugToolStripMenuItem_Click(object sender, EventArgs e) + { + if (tabControl1.TabPages.Contains(tpDebug)) + { + tabControl1.TabPages.Remove(tpDebug); + debugToolStripMenuItem.Checked = false; + } + else + { + tabControl1.TabPages.Add(tpDebug); + tabControl1.SelectedTab = tpDebug; + debugToolStripMenuItem.Checked = true; + } + } + + private void subscribeToPubSubToolStripMenuItem_Click(object sender, EventArgs e) + { + PubSubSubcribeForm ps = new PubSubSubcribeForm(); + // this is a small race. to do it right, I should call dm.BeginFindServiceWithFeature, + // and modify that to call back on all of the found services. The idea is that + // by the the time the user has a chance to click on the menu item, the DiscoManager + // will be populated. + ps.DiscoManager = dm; + if (ps.ShowDialog() != DialogResult.OK) + return; + JID jid = ps.JID; + string node = ps.Node; + string text = string.Format("{0}/{1}", jid, node); + + TabPage tp = new TabPage(text); + tp.Name = text; + + PubSubDisplay disp = new PubSubDisplay(); + disp.Node = psm.GetNode(jid, node, 10); + tp.Controls.Add(disp); + disp.Dock = DockStyle.Fill; + + tabControl1.TabPages.Add(tp); + tabControl1.SelectedTab = tp; + } + + private void rm_OnSubscription(jabber.client.RosterManager manager, Item ri, Presence pres) + { + DialogResult res = MessageBox.Show("Allow incoming presence subscription request from: " + pres.From, + "Subscription Request", + MessageBoxButtons.YesNoCancel); + switch (res) + { + case DialogResult.Yes: + manager.ReplyAllow(pres); + break; + case DialogResult.No: + manager.ReplyDeny(pres); + break; + case DialogResult.Cancel: + // do nothing; + break; + } + } + + private void rm_OnUnsubscription(jabber.client.RosterManager manager, Presence pres, ref bool remove) + { + MessageBox.Show(pres.From + " has removed you from their roster.", "Unsubscription notification", MessageBoxButtons.OK); + } + + private void closeTabToolStripMenuItem_Click(object sender, EventArgs e) + { + TabPage tp = tabControl1.SelectedTab; + if (tp == tpRoster) + return; + else if (tp == tpDebug) + debugToolStripMenuItem.Checked = false; + else if (tp == tpServices) + servicesToolStripMenuItem.Checked = false; + tabControl1.TabPages.Remove(tp); + } + + private void deletePubSubToolStripMenuItem_Click(object sender, EventArgs e) + { + PubSubSubcribeForm fm = setupPubSubForm(); + if (fm.ShowDialog() != DialogResult.OK) + return; + + JID jid = fm.JID; + string node = fm.Node; + + psm.RemoveNode(jid, node, + delegate { + MessageBox.Show("Remove Node unsuccessful."); + }); + + tabControl1.TabPages.RemoveByKey(string.Format("{0}/{1}", jid, node)); + } + + private PubSubSubcribeForm setupPubSubForm() + { + string JID = null; + string node = null; + if (tabControl1.SelectedTab.Name != null && tabControl1.SelectedTab.Name.Contains("/")) + { + string value = tabControl1.SelectedTab.Name; + int index = value.IndexOf("/"); + + JID = value.Substring(0, index); + node = value.Substring(index + 1); + } + + PubSubSubcribeForm fm = new PubSubSubcribeForm(); + fm.Text = "Delete PubSub"; + if (JID != null) fm.JID = JID; + if (node != null) fm.Node = node; + fm.DiscoManager = dm; + + return fm; + } + + private void joinConferenceToolStripMenuItem_Click(object sender, EventArgs e) + { + ConferenceForm cf = new ConferenceForm(); + cf.DiscoManager = dm; + cf.Nick = muc.DefaultNick; + if (cf.ShowDialog() != DialogResult.OK) + return; + + muc.GetRoom(cf.RoomAndNick).Join(); + } + + private IQ muc_OnRoomConfig(Room room, IQ parent) + { + muzzle.XDataForm form = new muzzle.XDataForm(parent); + if (form.ShowDialog() != DialogResult.OK) + return null; + + return (IQ)form.GetResponse(); + } + + private void muc_OnPresenceError(Room room, Presence pres) + { + m_err = true; + pnlCon.Text = "Groupchat error: " + pres.Error.OuterXml; + } + + private void muc_OnInvite(object sender, jabber.protocol.client.Message msg) + { + Room r = sender as Room; + r.Join(); + } + + private void bmm_OnConferenceAdd(jabber.client.BookmarkManager manager, BookmarkConference conference) + { + string jid = conference.JID; + string name = conference.ConferenceName; + if (name == null) + name = jid; + if (lvBookmarks.Items.ContainsKey(jid)) + lvBookmarks.Items.RemoveByKey(jid); + ListViewItem item = lvBookmarks.Items.Add(jid, name, -1); + item.SubItems.Add(conference.Nick); + item.SubItems.Add(conference.AutoJoin.ToString()); + item.Tag = conference.JID; + } + + private void bmm_OnConferenceRemove(jabber.client.BookmarkManager manager, BookmarkConference conference) + { + string jid = conference.JID; + if (lvBookmarks.Items.ContainsKey(jid)) + lvBookmarks.Items.RemoveByKey(jid); + } + + private void lvBookmarks_KeyUp(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Delete) + removeToolStripMenuItem_Click(null, null); + } + + private void addToolStripMenuItem_Click(object sender, EventArgs e) + { + // pop up AddBookmark dialog + ConferenceForm cf = new ConferenceForm(); + cf.DiscoManager = dm; + cf.Nick = muc.DefaultNick; + if (cf.ShowDialog() != DialogResult.OK) + return; + // TODO: add autojoin and name. + bmm.AddConference(cf.RoomJID, null, false, cf.Nick); + } + + private void removeToolStripMenuItem_Click(object sender, EventArgs e) + { + foreach (ListViewItem lvi in lvBookmarks.SelectedItems) + { + bmm[(JID)lvi.Tag] = null; + } + } + + private void lvBookmarks_DoubleClick(object sender, EventArgs e) + { + if (lvBookmarks.SelectedItems.Count == 0) + return; + ListViewItem lvi = lvBookmarks.SelectedItems[0]; + + JID jid = (JID)lvi.Tag; + BookmarkConference conf = bmm[jid]; + Debug.Assert(conf != null); + + ConferenceForm cf = new ConferenceForm(); + cf.DiscoManager = dm; + cf.RoomAndNick = new JID(jid.User, jid.Server, conf.Nick); + + if (cf.ShowDialog() != DialogResult.OK) + return; + bmm.AddConference(cf.RoomJID, null, false, cf.Nick); + } + } +} diff -Nru smuxi-0.8/lib/jabber-net/Example/PubSubDisplay.cs smuxi-0.8.9.1/lib/jabber-net/Example/PubSubDisplay.cs --- smuxi-0.8/lib/jabber-net/Example/PubSubDisplay.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/jabber-net/Example/PubSubDisplay.cs 2012-01-03 07:52:11.000000000 +0000 @@ -0,0 +1,155 @@ +/* -------------------------------------------------------------------------- + * Copyrights + * + * Portions created by or assigned to Cursive Systems, Inc. are + * Copyright (c) 2002-2008 Cursive Systems, Inc. All Rights Reserved. Contact + * information for Cursive Systems, Inc. is available at + * http://www.cursive.net/. + * + * License + * + * Jabber-Net is licensed under the LGPL. + * See LICENSE.txt for details. + * --------------------------------------------------------------------------*/ + +using System; +using System.Diagnostics; +using System.Windows.Forms; +using jabber.connection; + +using bedrock.util; + +namespace Example +{ + [SVN(@"$Id$")] + public class PubSubDisplay : UserControl + { + private ListBox lbID; + private Splitter splitter1; + private RichTextBox rtItem; + + private PubSubNode m_node = null; + + /// + /// Required designer variable. + /// + private readonly System.ComponentModel.IContainer components = null; + + public PubSubDisplay() + { + InitializeComponent(); + } + + public PubSubNode Node + { + get { return m_node; } + set + { + if (m_node == value) + return; + if (m_node != null) + { + m_node.OnItemAdd -= m_node_OnItemAdd; + m_node.OnItemRemove -= m_node_OnItemRemove; + } + m_node = value; + m_node.OnItemAdd += m_node_OnItemAdd; + m_node.OnItemRemove += m_node_OnItemRemove; + m_node.AutomatedSubscribe(); + } + } + + private void m_node_OnItemAdd(PubSubNode node, jabber.protocol.iq.PubSubItem item) + { + // OnItemRemove should have fired first, so no reason to remove it here. + // Hopefully. + Debug.Assert(lbID.Items.IndexOf(item.ID) == -1); + lbID.Items.Add(item.ID); + } + + private void m_node_OnItemRemove(PubSubNode node, jabber.protocol.iq.PubSubItem item) + { + int index = lbID.Items.IndexOf(item.ID); + if (lbID.SelectedIndex == index) + rtItem.Clear(); + if (index >= 0) + lbID.Items.RemoveAt(index); + } + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Component Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.lbID = new System.Windows.Forms.ListBox(); + this.splitter1 = new System.Windows.Forms.Splitter(); + this.rtItem = new System.Windows.Forms.RichTextBox(); + this.SuspendLayout(); + // + // lbID + // + this.lbID.Dock = System.Windows.Forms.DockStyle.Left; + this.lbID.FormattingEnabled = true; + this.lbID.IntegralHeight = false; + this.lbID.Location = new System.Drawing.Point(0, 0); + this.lbID.Name = "lbID"; + this.lbID.Size = new System.Drawing.Size(120, 170); + this.lbID.TabIndex = 0; + this.lbID.SelectedIndexChanged += new System.EventHandler(this.lbID_SelectedIndexChanged); + // + // splitter1 + // + this.splitter1.Location = new System.Drawing.Point(120, 0); + this.splitter1.Name = "splitter1"; + this.splitter1.Size = new System.Drawing.Size(3, 170); + this.splitter1.TabIndex = 1; + this.splitter1.TabStop = false; + // + // rtItem + // + this.rtItem.Dock = System.Windows.Forms.DockStyle.Fill; + this.rtItem.Location = new System.Drawing.Point(123, 0); + this.rtItem.Name = "rtItem"; + this.rtItem.Size = new System.Drawing.Size(236, 170); + this.rtItem.TabIndex = 2; + this.rtItem.Text = ""; + // + // PubSubDisplay + // + this.Controls.Add(this.rtItem); + this.Controls.Add(this.splitter1); + this.Controls.Add(this.lbID); + this.Name = "PubSubDisplay"; + this.Size = new System.Drawing.Size(359, 170); + this.ResumeLayout(false); + + } + + #endregion + + private void lbID_SelectedIndexChanged(object sender, EventArgs e) + { + rtItem.Clear(); + if (lbID.SelectedIndex == -1) + return; + // TODO: XML2RTF + rtItem.Text = m_node[(string)lbID.SelectedItem].OuterXml; + } + } +} diff -Nru smuxi-0.8/lib/jabber-net/Example/PubSubSubscribeForm.cs smuxi-0.8.9.1/lib/jabber-net/Example/PubSubSubscribeForm.cs --- smuxi-0.8/lib/jabber-net/Example/PubSubSubscribeForm.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/jabber-net/Example/PubSubSubscribeForm.cs 2012-01-03 07:52:11.000000000 +0000 @@ -0,0 +1,191 @@ +/* -------------------------------------------------------------------------- + * Copyrights + * + * Portions created by or assigned to Cursive Systems, Inc. are + * Copyright (c) 2002-2008 Cursive Systems, Inc. All Rights Reserved. Contact + * information for Cursive Systems, Inc. is available at + * http://www.cursive.net/. + * + * License + * + * Jabber-Net is licensed under the LGPL. + * See LICENSE.txt for details. + * --------------------------------------------------------------------------*/ + +using System; +using System.ComponentModel; +using System.Windows.Forms; +using bedrock.util; +using jabber; +using jabber.connection; + +namespace Example +{ + [SVN(@"$Id$")] + public class PubSubSubcribeForm : Form + { + private Label label1; + private Label label2; + private ComboBox cmbJID; + private TextBox txtNode; + private Button btnOK; + private Button btnCancel; + + private DiscoManager m_disco = null; + + /// + /// Required designer variable. + /// + private readonly IContainer components = null; + + public PubSubSubcribeForm() + { + InitializeComponent(); + } + + public DiscoManager DiscoManager + { + get { return m_disco; } + set { m_disco = value; } + } + + public JID JID + { + get { return cmbJID.Text; } + set { cmbJID.Text = value.ToString(); } + } + + public string Node + { + get { return txtNode.Text; } + set { txtNode.Text = value; } + } + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.label1 = new System.Windows.Forms.Label(); + this.label2 = new System.Windows.Forms.Label(); + this.cmbJID = new System.Windows.Forms.ComboBox(); + this.txtNode = new System.Windows.Forms.TextBox(); + this.btnOK = new System.Windows.Forms.Button(); + this.btnCancel = new System.Windows.Forms.Button(); + this.SuspendLayout(); + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(12, 9); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(106, 13); + this.label1.TabIndex = 0; + this.label1.Text = "PubSub Service JID:"; + this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleRight; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(82, 35); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(36, 13); + this.label2.TabIndex = 2; + this.label2.Text = "Node:"; + this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleRight; + // + // cmbJID + // + this.cmbJID.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.cmbJID.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.Suggest; + this.cmbJID.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.ListItems; + this.cmbJID.Location = new System.Drawing.Point(124, 6); + this.cmbJID.Name = "cmbJID"; + this.cmbJID.Size = new System.Drawing.Size(141, 21); + this.cmbJID.TabIndex = 4; + // + // txtNode + // + this.txtNode.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.txtNode.Location = new System.Drawing.Point(124, 32); + this.txtNode.Name = "txtNode"; + this.txtNode.Size = new System.Drawing.Size(141, 20); + this.txtNode.TabIndex = 5; + // + // btnOK + // + this.btnOK.DialogResult = System.Windows.Forms.DialogResult.OK; + this.btnOK.Location = new System.Drawing.Point(109, 58); + this.btnOK.Name = "btnOK"; + this.btnOK.Size = new System.Drawing.Size(75, 23); + this.btnOK.TabIndex = 6; + this.btnOK.Text = "OK"; + this.btnOK.UseVisualStyleBackColor = true; + // + // btnCancel + // + this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.btnCancel.Location = new System.Drawing.Point(190, 58); + this.btnCancel.Name = "btnCancel"; + this.btnCancel.Size = new System.Drawing.Size(75, 23); + this.btnCancel.TabIndex = 7; + this.btnCancel.Text = "Cancel"; + this.btnCancel.UseVisualStyleBackColor = true; + // + // PubSubSubcribeForm + // + this.AcceptButton = this.btnOK; + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.CancelButton = this.btnCancel; + this.ClientSize = new System.Drawing.Size(277, 90); + this.Controls.Add(this.btnCancel); + this.Controls.Add(this.btnOK); + this.Controls.Add(this.txtNode); + this.Controls.Add(this.cmbJID); + this.Controls.Add(this.label2); + this.Controls.Add(this.label1); + this.Name = "PubSubSubcribeForm"; + this.Text = "Subscribe to PubSub Node"; + this.Shown += new System.EventHandler(this.PubSub_Shown); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private void PubSub_Shown(object sender, EventArgs e) + { + cmbJID.BeginUpdate(); + cmbJID.Items.Clear(); + foreach (DiscoNode component in m_disco.Root.Children) + { + if (component.HasFeature(jabber.protocol.URI.PUBSUB)) + cmbJID.Items.Add(component.JID); + } + if (cmbJID.Items.Count > 0) + cmbJID.SelectedIndex = 0; + cmbJID.EndUpdate(); + } + + } +} diff -Nru smuxi-0.8/lib/jabber-net/Example/SendMessage.cs smuxi-0.8.9.1/lib/jabber-net/Example/SendMessage.cs --- smuxi-0.8/lib/jabber-net/Example/SendMessage.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/jabber-net/Example/SendMessage.cs 2012-01-03 07:52:11.000000000 +0000 @@ -0,0 +1,209 @@ +/* -------------------------------------------------------------------------- + * Copyrights + * + * Portions created by or assigned to Cursive Systems, Inc. are + * Copyright (c) 2002-2008 Cursive Systems, Inc. All Rights Reserved. Contact + * information for Cursive Systems, Inc. is available at + * http://www.cursive.net/. + * + * License + * + * Jabber-Net is licensed under the LGPL. + * See LICENSE.txt for details. + * --------------------------------------------------------------------------*/ +using System; + +using System.Drawing; +using System.Collections; +using System.ComponentModel; +using System.Windows.Forms; + +namespace Example +{ + using bedrock.util; + + /// + /// Summary description for SendMessage. + /// + [SVN(@"$Id$")] + public class SendMessage : System.Windows.Forms.Form + { + private jabber.client.JabberClient m_jc; + private System.Windows.Forms.Panel panel1; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.TextBox txtTo; + private System.Windows.Forms.TextBox txtSubject; + private System.Windows.Forms.Button btnSend; + private System.Windows.Forms.Button btnCancel; + private System.Windows.Forms.TextBox txtBody; + /// + /// Required designer variable. + /// + private System.ComponentModel.Container components = null; + + public SendMessage(jabber.client.JabberClient jc, string toJid) : this(jc) + { + txtTo.Text = toJid; + } + + public SendMessage(jabber.client.JabberClient jc) + { + // + // Required for Windows Form Designer support + // + InitializeComponent(); + + m_jc = jc; + } + + /// + /// Clean up any resources being used. + /// + protected override void Dispose( bool disposing ) + { + if( disposing ) + { + if(components != null) + { + components.Dispose(); + } + } + base.Dispose( disposing ); + } + + #region Windows Form Designer generated code + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(SendMessage)); + this.panel1 = new System.Windows.Forms.Panel(); + this.btnCancel = new System.Windows.Forms.Button(); + this.btnSend = new System.Windows.Forms.Button(); + this.txtSubject = new System.Windows.Forms.TextBox(); + this.txtTo = new System.Windows.Forms.TextBox(); + this.label2 = new System.Windows.Forms.Label(); + this.label1 = new System.Windows.Forms.Label(); + this.txtBody = new System.Windows.Forms.TextBox(); + this.panel1.SuspendLayout(); + this.SuspendLayout(); + // + // panel1 + // + this.panel1.Controls.Add(this.btnCancel); + this.panel1.Controls.Add(this.btnSend); + this.panel1.Controls.Add(this.txtSubject); + this.panel1.Controls.Add(this.txtTo); + this.panel1.Controls.Add(this.label2); + this.panel1.Controls.Add(this.label1); + this.panel1.Dock = System.Windows.Forms.DockStyle.Top; + this.panel1.Location = new System.Drawing.Point(0, 0); + this.panel1.Name = "panel1"; + this.panel1.Size = new System.Drawing.Size(312, 72); + this.panel1.TabIndex = 1; + // + // btnCancel + // + this.btnCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.btnCancel.Location = new System.Drawing.Point(256, 40); + this.btnCancel.Name = "btnCancel"; + this.btnCancel.Size = new System.Drawing.Size(48, 23); + this.btnCancel.TabIndex = 2; + this.btnCancel.Text = "Cancel"; + this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click); + // + // btnSend + // + this.btnSend.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.btnSend.Location = new System.Drawing.Point(256, 8); + this.btnSend.Name = "btnSend"; + this.btnSend.Size = new System.Drawing.Size(48, 23); + this.btnSend.TabIndex = 1; + this.btnSend.Text = "Send"; + this.btnSend.Click += new System.EventHandler(this.btnSend_Click); + // + // txtSubject + // + this.txtSubject.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.txtSubject.Location = new System.Drawing.Point(64, 41); + this.txtSubject.Name = "txtSubject"; + this.txtSubject.Size = new System.Drawing.Size(184, 20); + this.txtSubject.TabIndex = 0; + this.txtSubject.Text = ""; + // + // txtTo + // + this.txtTo.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.txtTo.Location = new System.Drawing.Point(64, 9); + this.txtTo.Name = "txtTo"; + this.txtTo.Size = new System.Drawing.Size(184, 20); + this.txtTo.TabIndex = 3; + this.txtTo.Text = ""; + // + // label2 + // + this.label2.Location = new System.Drawing.Point(8, 40); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(48, 23); + this.label2.TabIndex = 2; + this.label2.Text = "Subject:"; + // + // label1 + // + this.label1.Location = new System.Drawing.Point(8, 8); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(48, 23); + this.label1.TabIndex = 0; + this.label1.Text = "To:"; + // + // txtBody + // + this.txtBody.Dock = System.Windows.Forms.DockStyle.Fill; + this.txtBody.Location = new System.Drawing.Point(0, 72); + this.txtBody.Multiline = true; + this.txtBody.Name = "txtBody"; + this.txtBody.ScrollBars = System.Windows.Forms.ScrollBars.Both; + this.txtBody.Size = new System.Drawing.Size(312, 194); + this.txtBody.TabIndex = 0; + this.txtBody.Text = ""; + // + // SendMessage + // + this.AcceptButton = this.btnSend; + this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); + this.CancelButton = this.btnCancel; + this.ClientSize = new System.Drawing.Size(312, 266); + this.Controls.Add(this.txtBody); + this.Controls.Add(this.panel1); + this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); + this.Name = "SendMessage"; + this.Text = "SendMessage"; + this.panel1.ResumeLayout(false); + this.ResumeLayout(false); + + } + #endregion + + private void btnSend_Click(object sender, System.EventArgs e) + { + jabber.protocol.client.Message msg = new jabber.protocol.client.Message(m_jc.Document); + msg.To = txtTo.Text; + if (txtSubject.Text != "") + msg.Subject = txtSubject.Text; + msg.Body = txtBody.Text; + m_jc.Write(msg); + this.Close(); + } + + private void btnCancel_Click(object sender, System.EventArgs e) + { + this.Close(); + } + } +} diff -Nru smuxi-0.8/lib/jabber-net/Example/ServiceDisplay.cs smuxi-0.8.9.1/lib/jabber-net/Example/ServiceDisplay.cs --- smuxi-0.8/lib/jabber-net/Example/ServiceDisplay.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/jabber-net/Example/ServiceDisplay.cs 2012-01-03 07:52:11.000000000 +0000 @@ -0,0 +1,248 @@ +/* -------------------------------------------------------------------------- + * Copyrights + * + * Portions created by or assigned to Cursive Systems, Inc. are + * Copyright (c) 2002-2008 Cursive Systems, Inc. All Rights Reserved. Contact + * information for Cursive Systems, Inc. is available at + * http://www.cursive.net/. + * + * License + * + * Jabber-Net is licensed under the LGPL. + * See LICENSE.txt for details. + * --------------------------------------------------------------------------*/ +using System; +using System.ComponentModel; +using System.ComponentModel.Design; +using System.Windows.Forms; + +using bedrock.util; + +using jabber.client; +using jabber.connection; + +namespace Example +{ + [SVN(@"$Id$")] + public class ServiceDisplay : UserControl + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + private TreeView tvServices; + private Splitter splitter2; + private PropertyGrid pgServices; + private DiscoManager m_disco = null; + private JabberClient m_stream = null; + + public ServiceDisplay() + { + InitializeComponent(); + tvServices.ShowNodeToolTips = true; + tvServices.NodeMouseDoubleClick += new TreeNodeMouseClickEventHandler(tvServices_NodeMouseDoubleClick); + tvServices.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.tvServices_AfterSelect); + } + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Component Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.tvServices = new System.Windows.Forms.TreeView(); + this.splitter2 = new System.Windows.Forms.Splitter(); + this.pgServices = new System.Windows.Forms.PropertyGrid(); + this.SuspendLayout(); + // + // tvServices + // + this.tvServices.Dock = System.Windows.Forms.DockStyle.Left; + this.tvServices.Location = new System.Drawing.Point(0, 0); + this.tvServices.Name = "tvServices"; + this.tvServices.ShowLines = false; + this.tvServices.ShowPlusMinus = false; + this.tvServices.ShowRootLines = false; + this.tvServices.Size = new System.Drawing.Size(175, 281); + this.tvServices.TabIndex = 1; + this.tvServices.AfterCollapse += new System.Windows.Forms.TreeViewEventHandler(this.tvServices_AfterCollapse); + this.tvServices.AfterExpand += new System.Windows.Forms.TreeViewEventHandler(this.tvServices_AfterExpand); + // + // splitter2 + // + this.splitter2.Location = new System.Drawing.Point(175, 0); + this.splitter2.Name = "splitter2"; + this.splitter2.Size = new System.Drawing.Size(3, 281); + this.splitter2.TabIndex = 2; + this.splitter2.TabStop = false; + // + // pgServices + // + this.pgServices.Dock = System.Windows.Forms.DockStyle.Fill; + this.pgServices.Location = new System.Drawing.Point(178, 0); + this.pgServices.Name = "pgServices"; + this.pgServices.Size = new System.Drawing.Size(366, 281); + this.pgServices.TabIndex = 3; + // + // ServiceDisplay + // + this.Controls.Add(this.pgServices); + this.Controls.Add(this.splitter2); + this.Controls.Add(this.tvServices); + this.Name = "ServiceDisplay"; + this.Size = new System.Drawing.Size(544, 281); + this.ResumeLayout(false); + + } + + #endregion + + + /// + /// The JabberClient or JabberService to hook up to. + /// + [Description("The JabberClient to hook up to.")] + [Category("Jabber")] + public virtual JabberClient Stream + { + get + { + // If we are running in the designer, let's try to get an XmppStream control + // from the environment. + if ((this.m_stream == null) && DesignMode) + { + IDesignerHost host = (IDesignerHost)base.GetService(typeof(IDesignerHost)); + this.Stream = (JabberClient)jabber.connection.StreamComponent.GetComponentFromHost(host, typeof(JabberClient)); + } + return m_stream; + } + set + { + if ((object)m_stream != (object)value) + { + m_stream = value; + m_stream.OnAuthenticate += new bedrock.ObjectHandler(m_stream_OnAuthenticate); + m_stream.OnDisconnect += new bedrock.ObjectHandler(m_stream_OnDisconnect); + } + } + } + + [Category("Jabber")] + public DiscoManager DiscoManager + { + get + { + // If we are running in the designer, let's try to get a DiscoManager control + // from the environment. + if ((this.m_disco == null) && DesignMode) + { + IDesignerHost host = (IDesignerHost)base.GetService(typeof(IDesignerHost)); + this.m_disco = (DiscoManager)StreamComponent.GetComponentFromHost(host, typeof(DiscoManager)); + } + return m_disco; + } + set + { + if ((object)m_disco != (object)value) + m_disco = value; + } + } + + [Category("Appearance")] + public ImageList ImageList + { + get { return tvServices.ImageList; } + set { tvServices.ImageList = value; } + } + + private void m_stream_OnAuthenticate(object sender) + { + // TODO: some of this will break in 2003. + jabber.connection.DiscoNode dn = m_disco.GetNode(m_stream.Server, null); + TreeNode tn = tvServices.Nodes.Add(dn.Key, dn.Name); + tn.ToolTipText = dn.Key.Replace('\u0000', '\n'); + tn.Tag = dn; + tn.ImageIndex = 8; + tn.SelectedImageIndex = 8; + m_disco.BeginGetFeatures(dn, new jabber.connection.DiscoNodeHandler(GotInitialFeatures), null); + } + + private void m_stream_OnDisconnect(object sender) + { + pgServices.SelectedObject = null; + tvServices.Nodes.Clear(); + } + + + private void tvServices_AfterExpand(object sender, TreeViewEventArgs e) + { + e.Node.ImageIndex = 6; + e.Node.SelectedImageIndex = 6; + } + + private void tvServices_AfterCollapse(object sender, TreeViewEventArgs e) + { + e.Node.ImageIndex = 7; + e.Node.SelectedImageIndex = 7; + } + + private void tvServices_NodeMouseDoubleClick(object sender, + TreeNodeMouseClickEventArgs e) + { + jabber.connection.DiscoNode dn = (jabber.connection.DiscoNode)e.Node.Tag; + if (dn.Children == null) + m_disco.BeginGetItems(dn.JID, dn.Node, new jabber.connection.DiscoNodeHandler(GotItems), null); + } + + private void tvServices_AfterSelect(object sender, TreeViewEventArgs e) + { + jabber.connection.DiscoNode dn = (jabber.connection.DiscoNode)e.Node.Tag; + m_disco.BeginGetFeatures(dn, new jabber.connection.DiscoNodeHandler(GotInfo), null); + } + + private void GotInitialFeatures(DiscoManager sender, jabber.connection.DiscoNode node, object state) + { + m_disco.BeginGetItems(node, new jabber.connection.DiscoNodeHandler(GotItems), state); + } + + private void GotItems(DiscoManager sender, jabber.connection.DiscoNode node, object state) + { + // TODO: some of this will break in 2003. + TreeNode[] nodes = tvServices.Nodes.Find(node.Key, true); + foreach (TreeNode n in nodes) + { + n.ImageIndex = 7; + n.SelectedImageIndex = 7; + foreach (jabber.connection.DiscoNode dn in node.Children) + { + TreeNode tn = n.Nodes.Add(dn.Key, dn.Name); + tn.ToolTipText = dn.Key.Replace('\u0000', '\n'); + tn.Tag = dn; + tn.ImageIndex = 8; + tn.SelectedImageIndex = 8; + } + } + pgServices.Refresh(); + } + + private void GotInfo(DiscoManager sender, jabber.connection.DiscoNode node, object state) + { + pgServices.SelectedObject = node; + } + } +} diff -Nru smuxi-0.8/lib/jabber-net/jabber/client/BookmarkManager.cs smuxi-0.8.9.1/lib/jabber-net/jabber/client/BookmarkManager.cs --- smuxi-0.8/lib/jabber-net/jabber/client/BookmarkManager.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/jabber-net/jabber/client/BookmarkManager.cs 2012-01-03 07:52:11.000000000 +0000 @@ -0,0 +1,293 @@ +/* -------------------------------------------------------------------------- + * Copyrights + * + * Portions created by or assigned to Cursive Systems, Inc. are + * Copyright (c) 2002-2008 Cursive Systems, Inc. All Rights Reserved. Contact + * information for Cursive Systems, Inc. is available at + * http://www.cursive.net/. + * + * License + * + * Jabber-Net is licensed under the LGPL. + * See LICENSE.txt for details. + * --------------------------------------------------------------------------*/ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.ComponentModel.Design; + +using bedrock.util; +using jabber.connection; +using jabber.protocol.client; +using jabber.protocol.iq; +using System.Xml; + +namespace jabber.client +{ + /// + /// A new conference bookmark. + /// + /// + /// + public delegate void BookmarkConferenceDelegate(BookmarkManager manager, BookmarkConference conference); + + /// + /// Manager bookmarks on the server, with the old-style iq:private. + /// TODO: add support for new-style PEP. + /// + [SVN(@"$Id$")] + public class BookmarkManager : jabber.connection.StreamComponent + { + private bool m_autoPrivate = true; + private ConferenceManager m_confManager; + private Dictionary m_conferences = new Dictionary(); + + /// + /// Create + /// + public BookmarkManager() + { + InitializeComponent(); + this.OnStreamChanged += new bedrock.ObjectHandler(BookmarkManager_OnStreamChanged); + } + + /// + /// Create + /// + /// + public BookmarkManager(IContainer container) : this() + { + container.Add(this); + } + + /// + /// Automatically request bookmarks using iq:private on login. + /// + [Category("Bookmarks")] + [Description("Automatically request bookmarks using iq:private on login.")] + [DefaultValue(true)] + public bool AutoPrivate + { + get { return m_autoPrivate; } + set { m_autoPrivate = value; } + } + + /// + /// A conference bookmark has been . + /// + [Category("Bookmarks")] + [Description("A conference bookmark has been added to the list.")] + public event BookmarkConferenceDelegate OnConferenceAdd; + + /// + /// A conference bookmark has been removed from the list. + /// + [Category("Bookmarks")] + [Description("A conference bookmark has been removed from the list.")] + public event BookmarkConferenceDelegate OnConferenceRemove; + + /// + /// A ConferenceManager into which to auto-join conference rooms. + /// + [Category("Jabber")] + public ConferenceManager ConferenceManager + { + get + { + // If we are running in the designer, let's try to auto-hook a ConferenceManager + if ((m_confManager == null) && DesignMode) + { + IDesignerHost host = (IDesignerHost)base.GetService(typeof(IDesignerHost)); + this.ConferenceManager = (ConferenceManager)jabber.connection.StreamComponent.GetComponentFromHost(host, typeof(ConferenceManager)); + } + return m_confManager; + } + set + { + if ((object)m_confManager == (object)value) + return; + m_confManager = value; + } + } + + private void BookmarkManager_OnStreamChanged(object sender) + { + m_stream.OnDisconnect += new bedrock.ObjectHandler(m_stream_OnDisconnect); + m_stream.OnError += new bedrock.ExceptionHandler(m_stream_OnError); + JabberClient cli = m_stream as JabberClient; + if (cli == null) + return; + + cli.OnAuthenticate += new bedrock.ObjectHandler(cli_OnAuthenticate); + } + + private void m_stream_OnError(object sender, Exception ex) + { + m_conferences.Clear(); + } + + private void m_stream_OnDisconnect(object sender) + { + m_conferences.Clear(); + } + + private void cli_OnAuthenticate(object sender) + { + if (AutoPrivate) + { + BookmarksIQ biq = new BookmarksIQ(m_stream.Document); + biq.Type = IQType.get; + m_stream.Tracker.BeginIQ(biq, GotBookmarks, null); + } + } + + private void GotBookmarks(object sender, IQ iq, object state) + { + if ((iq == null) || (iq.Type != IQType.result)) + return; + + Private priv = iq.Query as Private; + if (priv == null) + return; + + Bookmarks bm = priv.GetChildElement(); + if (bm == null) + return; + + foreach (BookmarkConference conf in bm.GetConferences()) + { + if (conf.JID == null) + continue; + + m_conferences[conf.JID] = conf; + if (OnConferenceAdd != null) + OnConferenceAdd(this, conf); + if (conf.AutoJoin && (m_confManager != null)) + { + JID rJID = conf.JID; + JID roomAndNick = new JID(rJID.User, rJID.Server, conf.Nick); + Room r = m_confManager.GetRoom(roomAndNick); + r.Join(conf.Password); + } + } + } + + /// + /// Get the details for the given conference bookmark. + /// + /// + /// + public BookmarkConference this[JID jid] + { + get { return m_conferences[jid]; } + set + { + BookmarkConference prev = null; + if (value == null) + { + if (m_conferences.TryGetValue(jid, out prev)) + { + m_conferences.Remove(jid); + prev.SetAttribute("remove", "true"); + } + else + { + // no-op. Setting null on a non-existing JID. + return; + } + } + else + { + m_conferences[jid] = prev = value; + } + + BookmarksIQ biq = new BookmarksIQ(m_stream.Document); + biq.Type = IQType.set; + Bookmarks bm = biq.Bookmarks; + foreach (BookmarkConference conf in m_conferences.Values) + { + bm.AddChild((XmlElement)conf.CloneNode(true, m_stream.Document)); + } + m_stream.Tracker.BeginIQ(biq, BookmarksSet, prev); + } + } + + private void BookmarksSet(object sender, IQ iq, object state) + { + if ((iq == null) || (iq.Type != IQType.result)) + return; + + BookmarkConference prev = state as BookmarkConference; + if (prev == null) + return; + + if (prev.GetAttribute("remove") == "true") + { + if (OnConferenceRemove != null) + { + prev.RemoveAttribute("remove"); + OnConferenceRemove(this, prev); + } + } + else + { + if (OnConferenceAdd != null) + OnConferenceAdd(this, prev); + } + } + + /// + /// Add a conference room to the bookmark list + /// + /// The room@service JID of the room + /// Human-readable text + /// Join on login + /// Room nickname. May be null. + /// + public BookmarkConference AddConference(JID jid, string name, bool autoJoin, string nick) + { + BookmarkConference c = new BookmarkConference(m_stream.Document); + if (jid == null) + throw new ArgumentNullException("jid", "JID must not be null in a conference bookmark"); + c.JID = jid; + if ((name != null) && (name != "")) + c.ConferenceName = name; + c.AutoJoin = autoJoin; + if ((nick != null) && (nick != "")) + c.Nick = nick; + this[jid] = c; + return c; + } + + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Component Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + components = new System.ComponentModel.Container(); + } + + #endregion + } +} Binary files /tmp/l3kVLF4iNE/smuxi-0.8/lib/jabber-net/jabber/client/JabberClient.bmp and /tmp/jEQ8aotOZY/smuxi-0.8.9.1/lib/jabber-net/jabber/client/JabberClient.bmp differ diff -Nru smuxi-0.8/lib/jabber-net/jabber/client/JabberClient.cs smuxi-0.8.9.1/lib/jabber-net/jabber/client/JabberClient.cs --- smuxi-0.8/lib/jabber-net/jabber/client/JabberClient.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/jabber-net/jabber/client/JabberClient.cs 2012-01-03 07:52:11.000000000 +0000 @@ -0,0 +1,1031 @@ +/* -------------------------------------------------------------------------- + * Copyrights + * + * Portions created by or assigned to Cursive Systems, Inc. are + * Copyright (c) 2002-2008 Cursive Systems, Inc. All Rights Reserved. Contact + * information for Cursive Systems, Inc. is available at + * http://www.cursive.net/. + * + * License + * + * Jabber-Net is licensed under the LGPL. + * See LICENSE.txt for details. + * --------------------------------------------------------------------------*/ +using System; + +using System.ComponentModel; +using System.Collections; +using System.Diagnostics; +using System.Xml; + +using bedrock.util; +using bedrock.net; + +using jabber.connection; +using jabber.protocol; +using jabber.protocol.client; +using jabber.protocol.iq; +using jabber.connection.sasl; + +namespace jabber.client +{ + /// + /// Informs the client that a presence packet has been received. + /// + public delegate void PresenceHandler(Object sender, Presence pres); + /// + /// Informst the client that a message has been received. + /// + public delegate void MessageHandler(Object sender, Message msg); + /// + /// Informs the client that an IQ has been received. + /// + public delegate void IQHandler(Object sender, IQ iq); + /// + /// Need more information for registration. Return false to cancel. + /// + public delegate bool RegisterInfoHandler(Object sender, Register register); + + /// + /// Provides a component for clients to use to access the XMPP server. + /// You can install this in your Toolbox, drop onto a form, a service, and so on. + /// This class hooks into the OnProtocol event and calls the Connect() method. + /// + [SVN(@"$Id$")] + public class JabberClient : XmppStream + { + private static readonly object[][] DEFAULTS = new object[][] { + new object[] {Options.RESOURCE, "Jabber.Net"}, + new object[] {Options.PRIORITY, 0}, + new object[] {Options.AUTO_LOGIN, true}, + new object[] {Options.AUTO_ROSTER, true}, + new object[] {Options.AUTO_IQ_ERRORS, true}, + new object[] {Options.AUTO_PRESENCE, true}, + new object[] {Options.PROXY_PORT, 1080}, + new object[] {Options.SRV_PREFIX, "_xmpp-client._tcp."}, + }; + + private void init() + { + SetDefaults(DEFAULTS); + + this.OnSASLStart += new jabber.connection.sasl.SASLProcessorHandler(JabberClient_OnSASLStart); + this.OnSASLEnd += new jabber.protocol.stream.FeaturesHandler(JabberClient_OnSASLEnd); + this.OnSASLError += new ProtocolHandler(JabberClient_OnSASLError); + this.OnStreamInit += new StreamHandler(JabberClient_OnStreamInit); + } + + /// + /// Creates a new Jabber client and associates it with the parent window. + /// Required for Windows.Forms Class Composition Designer support + /// + /// Parent container. + public JabberClient(System.ComponentModel.IContainer container) : + base(container) + { + init(); + } + + /// + /// Creates a new JabberClient. + /// Required for Windows.Forms Class Composition Designer support. + /// + public JabberClient() : base() + { + init(); + } + + /* + /// + /// Create a new JabberClient, reusing an existing SocketWatcher. + /// + /// SocketWatcher to use. + public JabberClient(SocketWatcher watcher) : base(watcher) + { + init(); + } + */ + + /// + /// Informs the client that it received a presence packet. + /// + [Category("Protocol")] + [Description("We received a presence packet.")] + public event PresenceHandler OnPresence; + + /// + /// Informs the client that it received a message packet. + /// + [Category("Protocol")] + [Description("We received a message packet.")] + public event MessageHandler OnMessage; + + /// + /// Informs the client that it received an IQ packet. + /// + [Category("Protocol")] + [Description("We received an IQ packet.")] + public event IQHandler OnIQ; + + /// + /// Informs the client that the authentication has failed. The connection is not + /// terminated if there is an authentication error, and there + /// is at least one event handler for this event. + /// + [Category("Protocol")] + [Description("Authentication failed.")] + public event ProtocolHandler OnAuthError; + + /// + /// Informs the client that the presence is about to be sent. + /// This gives a chance to modify outbound presence (fore example, entity caps). + /// + [Category("Protocol")] + [Description("Presence is about to be sent. This gives a chance to modify outbound presence (e.g. entity caps)")] + public event PresenceHandler OnBeforePresenceOut; + + /// + /// Informs the client that the presence has been sent. + /// This gives a chance to send presence to other things, such as chat rooms. + /// + [Category("Protocol")] + [Description("Informs the client that the presence has been sent. This gives a chance to send presence to other things, such as chat rooms.")] + public event PresenceHandler OnAfterPresenceOut; + + /// + /// Determines if SutoLogin is false, and if it is time to log in. + /// This callback will receive the results of the IQ type=get + /// in the jabber:iq:auth namespace. When login is completed, + /// IsConnected property is set to true. If there is a login error, the + /// FireAuthError() method is called. + /// + [Category("Protocol")] + [Description("AutoLogin is false, and it's time to log in.")] + public event bedrock.ObjectHandler OnLoginRequired; + + /// + /// Informs the client if the registration succeeded or failed. + /// + [Category("Protocol")] + [Description("After calling Register(), the registration succeeded or failed.")] + public event IQHandler OnRegistered; + + /// + /// Allows the user to enter registration requested information before sending to the XMPP server. + /// + /// WARNING: Make sure you do not return from this handler until the IQ is filled in. + /// It is now safe to call UI elements, since this callback is now on the GUI thread if + /// the InvokeControl is set. + /// + [Category("Protocol")] + [Description("After calling Register, information about the user is required.")] + public event RegisterInfoHandler OnRegisterInfo; + + /// + /// Retrieves/Sets the username to connect as. + /// + [Description("The username to connect as.")] + [Category("Jabber")] + public string User + { + get { return this[Options.USER] as string; } + set { this[Options.USER] = value; } + } + + /// + /// Gets the priority for this connection. + /// + [Description("Priority for this connection.")] + [Category("Jabber")] + [DefaultValue(0)] + public int Priority + { + get { return (int)this[Options.PRIORITY]; } + set { this[Options.PRIORITY] = value; } + } + + /// + /// Gets or sets the password to use for connecting to the XMPP server. + /// This may be sent across the wire plaintext if the XMPP + /// server doesn't support digest and PlaintextAuth is set to true. + /// + [Description("The password to use for connecting. " + + "This may be sent across the wire plaintext, " + + "if the server doesn't support digest, " + + "and PlaintextAuth is true")] + [Category("Jabber")] + [PasswordPropertyText] + public string Password + { + get { return this[Options.PASSWORD] as string; } + set { this[Options.PASSWORD] = value; } + } + + /// + /// Allows auto-login to be used for the connection to the XMPP server if set to true. + /// + [Description("Automatically log in on connection.")] + [DefaultValue(true)] + [Category("Automation")] + public bool AutoLogin + { + get { return (bool)this[Options.AUTO_LOGIN]; } + set { this[Options.AUTO_LOGIN] = value; } + } + + /// + /// Retrieves the roster on connection. + /// + [Description("Retrieves the roster on connection.")] + [DefaultValue(true)] + [Category("Automation")] + public bool AutoRoster + { + get { return (bool)this[Options.AUTO_ROSTER]; } + set { this[Options.AUTO_ROSTER] = value; } + } + + /// + /// Sends 501/feature-not-implemented back to the client when an IQ + /// has not been handled if set to true. + /// + [Description("Automatically send back 501/feature-not-implemented to IQs that have not been handled.")] + [DefaultValue(true)] + [Category("Automation")] + public bool AutoIQErrors + { + get { return (bool)this[Options.AUTO_IQ_ERRORS]; } + set { this[Options.AUTO_IQ_ERRORS] = value; } + } + + /// + /// Sends presence information when the connection has been established + /// if set to true. + /// + [Description("Automatically send presence on connection.")] + [DefaultValue(true)] + [Category("Automation")] + public bool AutoPresence + { + get { return (bool)this[Options.AUTO_PRESENCE]; } + set { this[Options.AUTO_PRESENCE] = value; } + } + + /// + /// Gets or sets the connecting resource. + /// Used to identify a unique connection. + /// + [Description("Gets or sets the connecting resource. " + + "Used to identify a unique connection.")] + [DefaultValue("Jabber.Net")] + [Category("Jabber")] + public string Resource + { + get { return this[Options.RESOURCE] as string; } + set { this[Options.RESOURCE] = value; } + } + + /// + /// Gets the stream namespace for this connection. + /// + [Browsable(false)] + protected override string NS + { + get { return URI.CLIENT; } + } + + /// + /// Are we currently connected? + /// + [Browsable(false)] + [DefaultValue(false)] + public override bool IsAuthenticated + { + get { return base.IsAuthenticated; } + set + { + base.IsAuthenticated = value; + if (value) + { + if (AutoRoster) + GetRoster(); + if (AutoPresence) + Presence(PresenceType.available, + "online", null, Priority); + } + } + } + + /// + /// Connects to the XMPP server. This happens asynchronously, and + /// could take a couple of seconds to get the full handshake + /// completed. This will authenticate, send presence, and request + /// roster info, if the Auto* properties are set. + /// + public override void Connect() + { + this[Options.AUTO_LOGIN_THISPASS] = this[Options.AUTO_LOGIN]; + this[Options.SERVER_ID] = this[Options.TO]; + base.Connect(); + } + + /// + /// Closes down the connection. + /// + public override void Close() + { + if (IsAuthenticated) + { + Presence p = new Presence(Document); + p.Type = PresenceType.unavailable; + p.Status = "offline"; + Write(p); + } + base.Close(); + } + + /// + /// Initiates the authentication process. + /// + public void Login() + { + Debug.Assert(User != null, "Username must not be null for XEP-78 authentication"); + Debug.Assert(Password != null, "Password must not be null for XEP-78 authentication"); + Debug.Assert(Resource != null, "Resource must not be null for XEP-78 authentication"); + + this[Options.AUTO_LOGIN_THISPASS] = true; + + if (State == ManualSASLLoginState.Instance) + { + ProcessFeatures(); + return; + } + + this[Options.JID] = new JID(User, Server, Resource); + + AuthIQ aiq = new AuthIQ(Document); + aiq.Type = IQType.get; + Auth a = aiq.Instruction; + a.Username = User; + + lock (StateLock) + { + State = GetAuthState.Instance; + } + Tracker.BeginIQ(aiq, new IqCB(OnGetAuth), null); + } + + /// + /// Sends a presence packet to the XMPP server. + /// + /// The type of presence. + /// Determines the status of the presence. + /// Shows the available, away, dnd and so on status. + /// Prioritizes this connection. + /// Higher number mean higher priority. 0 minumum, 127 max. + /// -1 means this is a presence-only connection. + public void Presence(PresenceType t, + string status, + string show, + int priority) + { + if (IsAuthenticated) + { + if ((priority < -128) || (priority > 127)) + { + throw new ArgumentException("Priority must be -128 to 127", "priority"); + } + + Presence p = new Presence(Document); + if (status != null) + p.Status = status; + if (t != PresenceType.available) + { + p.Type = t; + } + if (show != null) + p.Show = show; + p.Priority = priority.ToString(); + + if (OnBeforePresenceOut != null) + OnBeforePresenceOut(this, p); + Write(p); + if (OnAfterPresenceOut != null) + OnAfterPresenceOut(this, p); + } + else + { + throw new InvalidOperationException("Client must be authenticated before sending presence."); + } + } + + /// + /// Sends a certain type of message packet to another user. + /// + /// The type of message. + /// The JID to send the message to. + /// The body of the message. + public void Message(MessageType t, + string to, + string body) + { + if (IsAuthenticated) + { + Message msg = new Message(Document); + msg.Type = t; + msg.To = to; + msg.Body = body; + Write(msg); + } + else + { + throw new InvalidOperationException("Client must be authenticated before sending messages."); + } + } + + /// + /// Sends a message packet to another user + /// + /// The JID to send the message to. + /// The body of the message. + public void Message( + string to, + string body) + { + Message(MessageType.chat, to, body); + } + + /// + /// Requests a new copy of the roster. + /// + public void GetRoster() + { + if (IsAuthenticated) + { + RosterIQ riq = new RosterIQ(Document); + riq.Type = IQType.get; + Write(riq); + } + else + { + throw new InvalidOperationException("Client must be authenticated before getting roster."); + } + } + + + /// + /// Sends a presence subscription request and updates the roster + /// for a new roster contact. + /// + /// The JID of the contact (required) + /// The nickname to show for the contact. + /// A list of groups to put the contact in. May be null. Hint: new string[] {"foo", "bar"} + public void Subscribe(JID to, string nickname, string[] groups) + { + Debug.Assert(to != null); + + RosterIQ riq = new RosterIQ(Document); + riq.Type = IQType.set; + Roster r = riq.Instruction; + Item i = r.AddItem(); + i.JID = to; + if (nickname != null) + i.Nickname = nickname; + if (groups != null) + { + foreach (string g in groups) + i.AddGroup(g); + } + Write(riq); // don't care about result. we should get a iq/response and a roster push. + + Presence pres = new Presence(Document); + pres.To = to; + pres.Type = PresenceType.subscribe; + Write(pres); + } + + /// + /// Removes a contact from the roster. + /// This will also remove the subscription for that contact being removed. + /// + /// The JID to remove + public void RemoveRosterItem(JID to) + { + Debug.Assert(to != null); + +/* + + + + + + */ + RosterIQ riq = new RosterIQ(Document); + riq.Type = IQType.set; + Roster r = riq.Instruction; + Item i = r.AddItem(); + i.JID = to; + i.Subscription = Subscription.remove; + Write(riq); // don't care about result. we should get a iq/response and a roster push. + } + + /// + /// Requests a list of agents from the XMPP server. + /// + public void GetAgents() + { + DiscoInfoIQ diq = new DiscoInfoIQ(Document); + diq.Type = IQType.get; + diq.To = this.Server; + Tracker.BeginIQ(diq, new IqCB(GotDiscoInfo), null); + } + + private void GotDiscoInfo(object sender, IQ iq, object state) + { + bool error = false; + if (iq.Type == IQType.error) + error = true; + else + { + DiscoInfo info = iq.Query as DiscoInfo; + if (info == null) + error = true; + else + { + if (!info.HasFeature(URI.DISCO_ITEMS)) + error = true; // wow. weird server. + + // TODO: stash away features for this node in discomanager? + } + } + + if (error) + { + // TODO: check the error type that jabberd1.4 or XCP 2.x return + } + } + + + /// + /// Attempts to register a new user. This will fire + /// OnRegisterInfo to retrieve information about the + /// new user, and OnRegistered when the registration + /// is completed or failed. + /// + /// The user to register. + public void Register(JID jid) + { + RegisterIQ iq = new RegisterIQ(Document); + Register reg = iq.Instruction; + iq.Type = IQType.get; + iq.To = jid.Server; + + reg.Username = jid.User; + Tracker.BeginIQ(iq, new IqCB(OnGetRegister), jid); + } + + private void OnGetRegister(object sender, IQ iq, object data) + { + if (iq == null) + { + FireOnError(new IQTimeoutException((JID) data)); + return; + } + + if (iq.Type == IQType.error) + { + if (OnRegistered != null) + { + if (InvokeRequired) + CheckedInvoke(OnRegistered, new object[] {this, iq}); + else + OnRegistered(this, iq); + } + } + else if (iq.Type == IQType.result) + { + JID jid = (JID) data; + iq.Type = IQType.set; + iq.From = null; + iq.To = jid.Server; + iq.ID = Element.NextID(); + Register r = iq.Query as Register; + if (r == null) + throw new BadProtocolException(iq, "Expected a register response"); + + jabber.protocol.x.Data xdata = r["x", URI.XDATA] as jabber.protocol.x.Data; + jabber.protocol.x.Field f; + if (xdata != null) + { + f = xdata.GetField("username"); + if (f != null) + f.Val = jid.User; + f = xdata.GetField("password"); + if (f != null) + f.Val = this.Password; + } + else + { + r.Username = jid.User; + r.Password = this.Password; + } + + bool res = true; + if (OnRegisterInfo != null) + { + if (InvokeRequired) + // Don't use CheckedInvoke, since we want this to be synchronous + res = (bool)this.InvokeControl.Invoke(OnRegisterInfo, new object[] { this, r }); + else + res = OnRegisterInfo(this, r); + if (xdata != null) + { + f = xdata.GetField("username"); + if (f != null) + { + this.User = f.Val; + } + f = xdata.GetField("password"); + if (f != null) + this.Password = f.Val; + } + else + { + this.User = r.Username; + this.Password = r.Password; + } + } + if (!res) + { + this.Close(); + return; + } + if (xdata != null) + xdata.Type = jabber.protocol.x.XDataType.result; + Tracker.BeginIQ(iq, new IqCB(OnSetRegister), jid); + } + } + + private void OnSetRegister(object sender, IQ iq, object data) + { + if (OnRegistered == null) + return; + + if (InvokeRequired) + CheckedInvoke(OnRegistered, new object[] {this, iq}); + else + OnRegistered(this, iq); + } + + private void OnGetAuth(object sender, IQ i, object data) + { + if ((i == null) || (i.Type != IQType.result)) + { + FireAuthError(i); + return; + } + + Auth res = i.Query as Auth; + if (res == null) + { + FireOnError(new InvalidOperationException("Invalid IQ result type")); + return; + } + + AuthIQ aiq = new AuthIQ(Document); + aiq.Type = IQType.set; + Auth a = aiq.Instruction; + + if ((res["sequence"] != null) && (res["token"] != null)) + { + a.SetZeroK(User, Password, res.Token, res.Sequence); + } + else if (res["digest"] != null) + { + a.SetDigest(User, Password, StreamID); + } + else if (res["password"] != null) + { + if (!SSLon && !this.PlaintextAuth) + { + FireOnError(new AuthenticationFailedException("Plaintext authentication forbidden.")); + return; + } + a.SetAuth(User, Password); + } + else + { + FireOnError(new NotImplementedException("Authentication method not implemented for:\n" + i)); + return; + } + if (res["resource"] != null) + a.Resource = Resource; + a.Username = User; + + lock (StateLock) + { + State = SetAuthState.Instance; + } + Tracker.BeginIQ(aiq, new IqCB(OnSetAuth), null); + } + + private void OnSetAuth(object sender, IQ i, object data) + { + if ((i == null) || (i.Type != IQType.result)) + FireAuthError(i); + else + IsAuthenticated = true; + } + + /// + /// Sorts the XML element looking for Presence, Message, and IQ packets. + /// + /// The object calling this method. + /// The XML element containing a stanza. + protected override void OnElement(object sender, System.Xml.XmlElement tag) + { + base.OnElement(sender, tag); + + if (OnPresence != null) + { + Presence p = tag as Presence; + if (p != null) + { + if (InvokeRequired) + CheckedInvoke(OnPresence, new object[] {this, p}); + else + OnPresence(this, p); + return; + } + } + if (OnMessage != null) + { + Message m = tag as Message; + if (m != null) + { + if (InvokeRequired) + CheckedInvoke(OnMessage, new object[] {this, m}); + else + OnMessage(this, m); + return; + } + } + + IQ i = tag as IQ; + if (i != null) + { + if (InvokeRequired) + CheckedInvoke(new IQHandler(FireOnIQ) , new object[] { this, i }); + else + FireOnIQ(this, i); + return; + } + } + + private void FireOnIQ(object sender, IQ iq) + { + // We know we're on the GUI thread. + if (OnIQ != null) + OnIQ(this, iq); + + if (AutoIQErrors) + { + if (!iq.Handled && + iq.HasAttribute("from") && // Belt. Suspenders. Don't respond to roster pushes. + ((iq.Type == IQType.get) || (iq.Type == IQType.set))) + { + Write(iq.GetErrorResponse(this.Document, Error.FEATURE_NOT_IMPLEMENTED)); + } + } + } + + /// + /// Informs the client that an error occurred during authentication. + /// This is public so that manual authenticators + /// can fire errors using the same events. + /// + /// Xml element containing the error message. + public void FireAuthError(XmlElement i) + { + if (OnAuthError != null) + { + if (InvokeRequired) + CheckedInvoke(OnAuthError, new object[] { this, i }); + else + OnAuthError(this, i); + } + else + { + IQ iq = i as IQ; + if (iq != null) + FireOnError(new IQException(iq)); + else + FireOnError(new AuthenticationFailedException(i.OuterXml)); + } + } + + void JabberClient_OnSASLError(object sender, XmlElement rp) + { + FireAuthError(rp); + } + + private void LoginRequired(BaseState newState) + { + lock (StateLock) + { + State = newState; + } + + if (OnLoginRequired != null) + { + if (InvokeRequired) + CheckedInvoke(OnLoginRequired, new object[] { this }); + else + OnLoginRequired(this); + } + else + { + FireOnError(new InvalidOperationException("If AutoLogin is false, you must supply a OnLoginRequired event handler")); + } + } + + private void JabberClient_OnSASLStart(Object sender, jabber.connection.sasl.SASLProcessor proc) + { + BaseState s = null; + lock (StateLock) + { + s = State; + } + + // HACK: fire OnSASLStart with state of NonSASLAuthState to initiate old-style auth. + if (s == NonSASLAuthState.Instance) + { + if ((bool)this[Options.AUTO_LOGIN_THISPASS]) + Login(); + else + LoginRequired(ManualLoginState.Instance); + } + else + { + if ((bool)this[Options.AUTO_LOGIN_THISPASS]) + { + // TODO: integrate SASL params into XmppStream params + proc[SASLProcessor.USERNAME] = User; + proc[SASLProcessor.PASSWORD] = Password; + proc[MD5Processor.REALM] = this.Server; + object creds = this[KerbProcessor.USE_WINDOWS_CREDS]; + if (creds == null) + creds = false; + proc[KerbProcessor.USE_WINDOWS_CREDS] = creds.ToString(); + } + else + { + LoginRequired(ManualSASLLoginState.Instance); + } + } + } + + private void JabberClient_OnSASLEnd(Object sender, jabber.protocol.stream.Features feat) + { + lock (StateLock) + { + State = BindState.Instance; + } + if (feat["bind", URI.BIND] != null) + { + IQ iq = new IQ(this.Document); + iq.Type = IQType.set; + + jabber.protocol.stream.Bind bind = new jabber.protocol.stream.Bind(this.Document); + if ((Resource != null) && (Resource != "")) + bind.Resource = Resource; + + iq.AddChild(bind); + this.Tracker.BeginIQ(iq, new IqCB(GotResource), feat); + } + else if (feat["session", URI.SESSION] != null) + { + IQ iq = new IQ(this.Document); + iq.Type = IQType.set; + iq.AddChild(new jabber.protocol.stream.Session(this.Document)); + this.Tracker.BeginIQ(iq, new IqCB(GotSession), feat); + } + else + IsAuthenticated = true; + } + + private void GotResource(object sender, IQ iq, object state) + { + + jabber.protocol.stream.Features feat = + state as jabber.protocol.stream.Features; + + if (iq == null) + { + FireOnError(new AuthenticationFailedException("Timeout authenticating")); + return; + } + if (iq.Type != IQType.result) + { + Error err = iq.Error; + if (err == null) + FireOnError(new AuthenticationFailedException("Unknown error binding resource")); + else + FireOnError(new AuthenticationFailedException("Error binding resource: " + err.OuterXml)); + return; + } + + XmlElement bind = iq["bind", URI.BIND]; + if (bind == null) + { + FireOnError(new AuthenticationFailedException("No binding returned. Server implementation error.")); + return; + } + XmlElement jid = bind["jid"]; + if (jid == null) + { + FireOnError(new AuthenticationFailedException("No jid returned from binding. Server implementation error.")); + return; + } + this[Options.JID] = new JID(jid.InnerText); + + if (feat["session", URI.SESSION] != null) + { + IQ iqs = new IQ(this.Document); + iqs.Type = IQType.set; + iqs.AddChild(new jabber.protocol.stream.Session(this.Document)); + this.Tracker.BeginIQ(iqs, new IqCB(GotSession), feat); + } + else + IsAuthenticated = true; + } + + private void GotSession(object sender, IQ iq, object state) + { + if ((iq != null) && (iq.Type == IQType.result)) + IsAuthenticated = true; + else + FireOnError(new AuthenticationFailedException()); + } + + private void JabberClient_OnStreamInit(Object sender, ElementStream stream) + { + stream.AddFactory(new jabber.protocol.client.Factory()); + stream.AddFactory(new jabber.protocol.iq.Factory()); + stream.AddFactory(new jabber.protocol.x.Factory()); + + } + } + + /// + /// Contains the "Getting authorization" information. + /// + [SVN(@"$Id$")] + public class GetAuthState : jabber.connection.BaseState + { + /// + /// Gets the instance that is always used. + /// + public static readonly jabber.connection.BaseState Instance = new GetAuthState(); + } + + /// + /// Contains the "Setting authorization" information. + /// + [SVN(@"$Id$")] + public class SetAuthState : jabber.connection.BaseState + { + /// + /// Gets the instance that is always used. + /// + public static readonly jabber.connection.BaseState Instance = new SetAuthState(); + } + + /// + /// Informs the client that the JabberClient is in + /// the "Waiting for manual login" state. + /// + [SVN(@"$Id$")] + public class ManualLoginState : jabber.connection.BaseState + { + /// + /// Gets the instance that is always used. + /// + public static readonly jabber.connection.BaseState Instance = new ManualLoginState(); + } + + /// + /// Informs the client that the JabberClient is in + /// the "Waiting for manual login" state, but when Login() + /// happens, it should try SASL. + /// + [SVN(@"$Id$")] + public class ManualSASLLoginState : jabber.connection.BaseState + { + /// + /// Gets the instance that is always used. + /// + public static readonly jabber.connection.BaseState Instance = new ManualSASLLoginState(); + } + +} diff -Nru smuxi-0.8/lib/jabber-net/jabber/client/JabberClient.resx smuxi-0.8.9.1/lib/jabber-net/jabber/client/JabberClient.resx --- smuxi-0.8/lib/jabber-net/jabber/client/JabberClient.resx 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/jabber-net/jabber/client/JabberClient.resx 2012-01-03 07:52:11.000000000 +0000 @@ -0,0 +1,105 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 1.3 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + JabberClient + + + False + + \ No newline at end of file Binary files /tmp/l3kVLF4iNE/smuxi-0.8/lib/jabber-net/jabber/client/PresenceManager.bmp and /tmp/jEQ8aotOZY/smuxi-0.8.9.1/lib/jabber-net/jabber/client/PresenceManager.bmp differ diff -Nru smuxi-0.8/lib/jabber-net/jabber/client/PresenceManager.cs smuxi-0.8.9.1/lib/jabber-net/jabber/client/PresenceManager.cs --- smuxi-0.8/lib/jabber-net/jabber/client/PresenceManager.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/jabber-net/jabber/client/PresenceManager.cs 2012-01-03 07:52:11.000000000 +0000 @@ -0,0 +1,566 @@ +/* -------------------------------------------------------------------------- + * Copyrights + * + * Portions created by or assigned to Cursive Systems, Inc. are + * Copyright (c) 2002-2008 Cursive Systems, Inc. All Rights Reserved. Contact + * information for Cursive Systems, Inc. is available at + * http://www.cursive.net/. + * + * License + * + * Jabber-Net is licensed under the LGPL. + * See LICENSE.txt for details. + * --------------------------------------------------------------------------*/ +using System; + +using System.ComponentModel; +using System.ComponentModel.Design; +using System.Collections; +using gen = System.Collections.Generic; +using System.Diagnostics; + +using bedrock.util; +using bedrock.collections; + +using jabber.protocol.client; +using jabber.protocol.x; +using jabber.protocol.iq; +using jabber.connection; + +namespace jabber.client +{ + + /// + /// Informs the client of a change of derived primary session for a user. + /// + /// The PresenceManager object that sent the update + /// The bare JID (node@domain) of the user whose presence changed + public delegate void PrimarySessionHandler(object sender, JID bare); + + /// + /// Specifies the presence proxy database. + /// + [SVN(@"$Id$")] + public class PresenceManager : jabber.connection.StreamComponent, IEnumerable + { + /// + /// Required designer variable. + /// +#pragma warning disable 0414 + private System.ComponentModel.Container components = null; +#pragma warning restore 0414 + + private Tree m_items = new Tree(); + private CapsManager m_caps = null; + + /// + /// Constructs a PresenceManager object and adds it to a container. + /// + /// Parent container. + public PresenceManager(System.ComponentModel.IContainer container) : this() + { + container.Add(this); + } + + /// + /// Constructs a new PresenceManager object. + /// + public PresenceManager() + { + InitializeComponent(); + + this.OnStreamChanged += new bedrock.ObjectHandler(PresenceManager_OnStreamChanged); + } + + private void PresenceManager_OnStreamChanged(object sender) + { + JabberClient cli = m_stream as JabberClient; + if (cli == null) + return; + + cli.OnPresence += new PresenceHandler(GotPresence); + cli.OnDisconnect += new bedrock.ObjectHandler(GotDisconnect); + } + + /// + /// Gets or sets the JabberClient associated with the Presence Manager. + /// + [Description("Gets or sets the JabberClient associated with the Presence Manager.")] + [Category("Jabber")] + [Browsable(false)] + [Obsolete("Use the Stream property instead")] + [ReadOnly(true)] + public JabberClient Client + { + get { return (JabberClient)this.Stream; } + set { this.Stream = value; } + } + + /// + /// The CapsManager for this view + /// + [Category("Jabber")] + public CapsManager CapsManager + { + get + { + // If we are running in the designer, let's try to auto-hook a CapsManager + if ((m_caps == null) && DesignMode) + { + IDesignerHost host = (IDesignerHost)base.GetService(typeof(IDesignerHost)); + this.CapsManager = (CapsManager)jabber.connection.StreamComponent.GetComponentFromHost(host, typeof(CapsManager)); + } + return m_caps; + } + set + { + if ((object)m_caps == (object)value) + return; + m_caps = value; + } + } + + /// + /// Gets the current presence state as a string. + /// + /// string in the format '{bare JID}={list of presence stanzas}, ...' + public override string ToString() + { + return m_items.ToString(); + } + + /// + /// Informs the client that the primary session has changed for a user. + /// + public event PrimarySessionHandler OnPrimarySessionChange; + + private void GotDisconnect(object sender) + { + lock(this) + m_items.Clear(); + } + + /// + /// Adds a new available or unavailable presence packet to the database. + /// + /// Presence stanza to add. + public void AddPresence(Presence p) + { + // can't use .From, since that will cause a JID parse. + Debug.Assert(p.GetAttribute("from") != "", + "Do not call AddPresence by hand. I can tell you are doing that because you didn't put a from address on your presence packet, and all presences from the server have a from address."); + GotPresence(this, p); + } + + private void GotPresence(object sender, Presence p) + { + PresenceType t = p.Type; + if ((t != PresenceType.available) && + (t != PresenceType.unavailable)) + return; + + JID f = p.From; + lock (this) + { + UserPresenceManager upm = (UserPresenceManager)m_items[f.Bare]; + + if (t == PresenceType.available) + { + if (upm == null) + { + upm = new UserPresenceManager(f.Bare); + m_items[f.Bare] = upm; + } + + upm.AddPresence(p, this); + } + else + { + if (upm != null) + { + upm.RemovePresence(p, this); + if (upm.Count == 0) + { + m_items.Remove(f.Bare); + } + } + } + } + } + + private void FireOnPrimarySessionChange(JID from) + { + if (OnPrimarySessionChange != null) + OnPrimarySessionChange(this, from); + } + + /// + /// Determines if a specified JID is online with any resources. + /// This performs better than retrieving the particular associated presence packet. + /// + /// The JID to look up. + /// If true, the user is online; otherwise the user is offline + public bool IsAvailable(JID jid) + { + lock (this) + { + return (m_items[jid.Bare] != null); + } + } + + /// + /// Gets the primary presence if given a bare JID. + /// If given a FQJ, returns the associated presence. + /// + public Presence this[JID jid] + { + get + { + lock (this) + { + UserPresenceManager upm = (UserPresenceManager)m_items[jid.Bare]; + if (upm == null) + return null; + return upm[jid.Resource]; + } + } + } + + /// + /// Get the features associated with the JID. If a bare JID is passed in, this will be + /// a union of all of the features for all of the resources of this user. Otherwise, + /// it will be the features for the given resource. + /// + /// Requires a CapsManager to be set before use. + /// + /// + /// Null if no features are known. + public StringSet GetFeatures(JID jid) + { + if (m_caps == null) + return null; + + lock (this) + { + UserPresenceManager upm = (UserPresenceManager)m_items[jid.Bare]; + if (upm == null) + return null; + return upm.GetFeatures(m_caps, jid.Resource); + } + } + + /// + /// Does the given JID implement the given feature? Bare JID asks if any + /// resource of that user implements that feature. Full JID asks if the + /// given resource implements that feature. + /// + /// Requires a CapsManager to be set before use. + /// + /// + /// + /// True if the feaure is implemented + public bool HasFeature(JID jid, string featureURI) + { + StringSet feats = GetFeatures(jid); + if (feats == null) + return false; + return feats[featureURI]; + } + + /// + /// Get the most available full JID that implements the given feature. Unlike + /// most routines in PresenceManager, may also return JIDs that have negative + /// presence. If a full JID is specified, this is effectively the same as + /// HasFeature, but null will be returned if the feature isn't implemented. + /// + /// + /// + /// + /// null if none found + public JID GetFeatureJID(JID jid, string featureURI) + { + if (jid.Resource != null) + { + if (HasFeature(jid, featureURI)) + return jid; + return null; + } + + lock (this) + { + UserPresenceManager upm = (UserPresenceManager)m_items[jid.Bare]; + if (upm == null) + return null; + return upm.GetFeatureJID(m_caps, featureURI); + } + } + + /// + /// Gets all of the current presence stanzas for the given user. + /// + /// User who's presence stanzas you want. + /// Array of presence stanzas for the given user. + public Presence[] GetAll(JID jid) + { + UserPresenceManager upm = (UserPresenceManager)m_items[jid.Bare]; + if (upm == null) + return new Presence[0]; + return upm.GetAll(); + } + + + #region Component Designer generated code + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + components = new System.ComponentModel.Container(); + } + #endregion + + /// + /// Iterate over all of the JIDs we have not-unavilable presence from. + /// + /// + IEnumerator IEnumerable.GetEnumerator() + { + return new UserPresenceManagerEnumerator(m_items.Values); + } + + private class UserPresenceManagerEnumerator : IEnumerator + { + private IEnumerator m_enum; + + public UserPresenceManagerEnumerator(ICollection values) + { + m_enum = values.GetEnumerator(); + } + + #region IEnumerator Members + public object Current + { + get + { + UserPresenceManager m = (UserPresenceManager)m_enum.Current; + if (m == null) + return null; + return m.JID; + } + } + + public bool MoveNext() + { + return m_enum.MoveNext(); + } + + public void Reset() + { + m_enum.Reset(); + } + + #endregion + } + + /// + /// Manage the presence for all of the resources of a user. No locking is performed, + /// since PresenceManager is already doing locking. + /// + /// The intent of this class is to be able to deliver the last presence stanza + /// from the "most available" resource. + /// Note that negative priority sessions are never the most available. + /// + private class UserPresenceManager + { + // List sorted by presence availability, in ascending order. + // most-available is always last. + private gen.LinkedList m_all = new gen.LinkedList(); + private JID m_jid = null; + + public UserPresenceManager(JID jid) + { + Debug.Assert(jid.Resource == null); + m_jid = jid; + } + + public JID JID + { + get { return m_jid; } + } + + public override string ToString() + { + System.IO.StringWriter sw = new System.IO.StringWriter(); + sw.WriteLine("{"); + foreach (Presence p in m_all) + sw.WriteLine(p.OuterXml); + sw.WriteLine("}"); + return sw.ToString(); + } + + private void Primary(Presence p, PresenceManager handler) + { + Debug.Assert((p == null) ? true : (p.IntPriority >= 0), "Primary presence is always positive priority"); + handler.FireOnPrimarySessionChange(m_jid); + } + + private gen.LinkedListNode Find(string resource) + { + for (gen.LinkedListNode n = m_all.First; n != null; n = n.Next) + { + if (n.Value.From.Resource == resource) + return n; + } + return null; + } + + public void AddPresence(Presence p, PresenceManager handler) + { + JID from = p.From; + string res = from.Resource; + Debug.Assert(p.Type == PresenceType.available); + + // If this is an update, remove the existing one. + // we'll add the new one back in, in the correct place. + gen.LinkedListNode n = Find(res); + if (n != null) + m_all.Remove(n); + + + gen.LinkedListNode inserted = new gen.LinkedListNode(p); + for (n = m_all.First; n != null; n = n.Next) + { + if (p < n.Value) + { + m_all.AddBefore(n, inserted); + break; + } + } + + // This is the highest one. + if (inserted.List == null) + { + m_all.AddLast(inserted); + if (p.IntPriority >= 0) + Primary(p, handler); + } + } + + public void RemovePresence(Presence p, PresenceManager handler) + { + JID from = p.From; + string res = from.Resource; + Debug.Assert(p.Type == PresenceType.unavailable); + + gen.LinkedListNode n = Find(res); + + // unavail for a resource we haven't gotten presence from. + if (n == null) + return; + + gen.LinkedListNode last = m_all.Last; + m_all.Remove(n); + + if (last == n) + { + // current high-pri. + if ((m_all.Last != null) && (m_all.Last.Value.IntPriority >= 0)) + Primary(m_all.Last.Value, handler); + else + { + // last non-negative presence went away + if (n.Value.IntPriority >= 0) + Primary(null, handler); + } + } + } + + public int Count + { + get { return m_all.Count; } + } + + public Presence this[string Resource] + { + get + { + gen.LinkedListNode n; + if (Resource == null) + { + // get highest non-negative for this bare JID. + n = m_all.Last; + + if ((n != null) && (n.Value.IntPriority >= 0)) + return n.Value; + } + else + { + n = Find(Resource); + if (n != null) + return n.Value; + } + return null; + } + } + + public Presence[] GetAll() + { + Presence[] all = new Presence[m_all.Count]; + m_all.CopyTo(all, 0); + return all; + } + + private StringSet GetFeatures(CapsManager caps, Presence p) + { + if (p == null) + return null; + + Caps c = p.GetChildElement(); + if (c == null) + return null; + + DiscoInfo di = caps[c.Version]; + if (di == null) + return null; + + return di.FeatureSet; + } + + public StringSet GetFeatures(CapsManager caps, string resource) + { + if (resource == null) + return GetAllFeatures(caps); + + return GetFeatures(caps, this[resource]); + } + + public StringSet GetAllFeatures(CapsManager caps) + { + if (caps == null) + throw new ArgumentNullException("caps"); + + StringSet features = new StringSet(); + foreach (Presence p in m_all) + { + StringSet f = GetFeatures(caps, p); + if (f != null) + features.Add(f); + } + return features; + } + + public JID GetFeatureJID(CapsManager caps, string featureURI) + { + gen.LinkedListNode n; + for (n = m_all.Last; n != null; n = n.Previous) + { + StringSet f = GetFeatures(caps, n.Value); + if ((f != null) && f.Contains(featureURI)) + return n.Value.From; + } + return null; + } + } + } +} diff -Nru smuxi-0.8/lib/jabber-net/jabber/client/PresenceManager.resx smuxi-0.8.9.1/lib/jabber-net/jabber/client/PresenceManager.resx --- smuxi-0.8/lib/jabber-net/jabber/client/PresenceManager.resx 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/jabber-net/jabber/client/PresenceManager.resx 2012-01-03 07:52:11.000000000 +0000 @@ -0,0 +1,105 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 1.3 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + PresenceManager + + + False + + \ No newline at end of file Binary files /tmp/l3kVLF4iNE/smuxi-0.8/lib/jabber-net/jabber/client/RosterManager.bmp and /tmp/jEQ8aotOZY/smuxi-0.8.9.1/lib/jabber-net/jabber/client/RosterManager.bmp differ diff -Nru smuxi-0.8/lib/jabber-net/jabber/client/RosterManager.cs smuxi-0.8.9.1/lib/jabber-net/jabber/client/RosterManager.cs --- smuxi-0.8/lib/jabber-net/jabber/client/RosterManager.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/jabber-net/jabber/client/RosterManager.cs 2012-01-03 07:52:11.000000000 +0000 @@ -0,0 +1,450 @@ +/* -------------------------------------------------------------------------- + * Copyrights + * + * Portions created by or assigned to Cursive Systems, Inc. are + * Copyright (c) 2002-2008 Cursive Systems, Inc. All Rights Reserved. Contact + * information for Cursive Systems, Inc. is available at + * http://www.cursive.net/. + * + * License + * + * Jabber-Net is licensed under the LGPL. + * See LICENSE.txt for details. + * --------------------------------------------------------------------------*/ +using System; + +using System.ComponentModel; +using System.ComponentModel.Design; +using System.Collections; +using System.Diagnostics; + +using bedrock.collections; +using bedrock.util; + +using jabber.protocol.client; +using jabber.protocol.iq; + +namespace jabber.client +{ + /// + /// Informs the client of roster items. + /// + public delegate void RosterItemHandler(object sender, Item ri); + + /// + /// Informs the client of a subscription requests. + /// + /// The RosterManager than detected the subscription + /// The affected roster item, in its current state. Null if not found. + /// The inbound presence stanza + public delegate void SubscriptionHandler(RosterManager manager, Item ri, Presence pres); + + /// + /// Manages unsubscription notifications. + /// + /// The RosterManager than detected the subscription + /// Set this to false to prevent the user being removed from the roster. + /// The inbound presence stanza + public delegate void UnsubscriptionHandler(RosterManager manager, Presence pres, ref bool remove); + + /// + /// Determines how the RosterManager deals with incoming subscriptions. + /// + public enum AutoSubscriptionHanding + { + /// + /// Do not do any automatic processing + /// + NONE = 0, + /// + /// Reply with a subscribed to every subscribe + /// + AllowAll, + /// + /// Reply with an unsubscribed to every subscribe + /// + DenyAll, + /// + /// If the user is either subscribed or trying to subscribe to another user, + /// allow the other user's subscription. + /// Otherwise, treat as NONE, and fire the OnSubscribe event. + /// + AllowIfSubscribed, + } + + /// + /// Manages the roster of the client. + /// + [SVN(@"$Id$")] + public class RosterManager : jabber.connection.StreamComponent, IEnumerable + { + /// + /// Required designer variable. + /// +#pragma warning disable 0414 + private System.ComponentModel.Container components = null; +#pragma warning restore 0414 + private Tree m_items = new Tree(); + private AutoSubscriptionHanding m_autoAllow = AutoSubscriptionHanding.NONE; + private bool m_autoSubscribe = false; + + /// + /// Creates a new roster manager inside a container. + /// + /// Parent container + public RosterManager(System.ComponentModel.IContainer container) : this() + { + // Required for Windows.Forms Class Composition Designer support + container.Add(this); + } + + /// + /// Creates a new roster manager. + /// + public RosterManager() + { + // Required for Windows.Forms Class Composition Designer support + InitializeComponent(); + this.OnStreamChanged += new bedrock.ObjectHandler(RosterManager_OnStreamChanged); + } + + private void RosterManager_OnStreamChanged(object sender) + { + JabberClient cli = m_stream as JabberClient; + if (cli == null) + return; + cli.OnIQ += new IQHandler(GotIQ); + cli.OnPresence += new PresenceHandler(cli_OnPresence); + cli.OnDisconnect += new bedrock.ObjectHandler(GotDisconnect); + } + + + /// + /// Gets or sets the Jabber client associated with the Roster Manager. + /// + [Description("The JabberClient to hook up to.")] + [Category("Jabber")] + [Browsable(false)] + [Obsolete("Use the Stream property instead")] + [ReadOnly(true)] + public JabberClient Client + { + get { return (JabberClient) this.Stream; } + set { this.Stream = value; } + } + + /// + /// Gets the AutoSubscription Handling value for inbound subscriptions. + /// + [Description("How to handle inbound subscriptions")] + [Category("Jabber")] + [DefaultValue(AutoSubscriptionHanding.NONE)] + public AutoSubscriptionHanding AutoAllow + { + get { return m_autoAllow; } + set { m_autoAllow = value; } + } + + /// + /// Determines whether auto-subscribe is enabled or disabled for a user. + /// + [Description("Should we subscribe to a user whenever we allow a subscription from them?")] + [Category("Jabber")] + [DefaultValue(false)] + public bool AutoSubscribe + { + get { return m_autoSubscribe; } + set { m_autoSubscribe = value; } + } + + /// + /// Informs the client that is has new roster items. + /// + [Description("Convenience event for new roster items.")] + [Category("Jabber")] + public event RosterItemHandler OnRosterItem; + + /// + /// Informs the client when a roster result starts, before any OnRosterItem events fire. + /// This will not fire for type='set'. + /// + [Description("Roster result about to start being processed.")] + [Category("Jabber")] + public event bedrock.ObjectHandler OnRosterBegin; + + /// + /// Informs the client that the roster has been retrieved from the XMPP server. + /// + [Description("Roster result finished being processed.")] + [Category("Jabber")] + public event bedrock.ObjectHandler OnRosterEnd; + + /// + /// Informs the client that a subscription request was received that cannot be auto-handled. + /// + [Description("Subscription request received that cannot be auto-handled")] + [Category("Jabber")] + public event SubscriptionHandler OnSubscription; + + /// + /// Informs the client that an Unsubscribe/Unsubscribed notification from another + /// user. By default, the user will be removed from the roster after this event + /// fires. To prevent this, you need to set the remove property to false. + /// + [Description("Unsubscribe/Unsubscribed notification from other user")] + [Category("Jabber")] + public event UnsubscriptionHandler OnUnsubscription; + + /// + /// Returns a string that represents the current object. + /// + public override string ToString() + { + return m_items.ToString(); + } + + /// + /// Gets the currently-known version of a roster item for this JID. + /// + public Item this[JID jid] + { + get + { + lock (this) + return (Item) m_items[jid]; + } + } + + /// + /// Gets the number of items currently in the roster. + /// + public int Count + { + get + { + lock (this) + return m_items.Count; + } + } + + private void GotDisconnect(object sender) + { + lock (this) + m_items.Clear(); + } + + private void cli_OnPresence(object sender, Presence pres) + { + PresenceType typ = pres.Type; + switch (typ) + { + case PresenceType.available: + case PresenceType.unavailable: + case PresenceType.error: + case PresenceType.probe: + return; + case PresenceType.subscribe: + switch (m_autoAllow) + { + case AutoSubscriptionHanding.AllowAll: + ReplyAllow(pres); + return; + case AutoSubscriptionHanding.DenyAll: + ReplyDeny(pres); + return; + case AutoSubscriptionHanding.NONE: + if (OnSubscription != null) + OnSubscription(this, this[pres.From], pres); + return; + case AutoSubscriptionHanding.AllowIfSubscribed: + Item ri = this[pres.From]; + if (ri != null) + { + switch (ri.Subscription) + { + case Subscription.to: + ReplyAllow(pres); + return; + case Subscription.from: + case Subscription.both: + // Almost an assert + throw new InvalidOperationException("Server sent a presence subscribe for an already-subscribed contact"); + case Subscription.none: + if (ri.Ask == Ask.subscribe) + { + ReplyAllow(pres); + return; + } + break; + } + } + if (OnSubscription != null) + OnSubscription(this, ri, pres); + break; + } + break; + case PresenceType.subscribed: + // This is the new ack case. + Presence sub_ack = new Presence(m_stream.Document); + sub_ack.To = pres.From; + sub_ack.Type = PresenceType.subscribe; + Write(sub_ack); + break; + case PresenceType.unsubscribe: + // ack. we'll likely get an unsubscribed soon, anyway. + Presence un_ack = new Presence(m_stream.Document); + un_ack.To = pres.From; + un_ack.Type = PresenceType.unsubscribed; + Write(un_ack); + break; + case PresenceType.unsubscribed: + bool remove = true; + if (OnUnsubscription != null) + OnUnsubscription(this, pres, ref remove); + + if (remove) + Remove(pres.From); + break; + } + } + + /// + /// Adds a new roster item to the database. + /// + /// An IQ containing a roster query. + public void AddRoster(IQ iq) + { + GotIQ(this, iq); + } + + private void GotIQ(object sender, IQ iq) + { + if ((iq.Query == null) || + (iq.Query.NamespaceURI != jabber.protocol.URI.ROSTER) || + ((iq.Type != IQType.result) && (iq.Type != IQType.set))) + return; + + iq.Handled = true; + Roster r = (Roster) iq.Query; + if ((iq.Type == IQType.result) && (OnRosterBegin != null)) + OnRosterBegin(this); + + foreach (Item i in r.GetItems()) + { + lock (this) + { + if (i.Subscription == Subscription.remove) + { + m_items.Remove(i.JID); + } + else + { + if (m_items.Contains(i.JID)) + m_items.Remove(i.JID); + m_items[i.JID] = i; + } + } + if (OnRosterItem != null) + OnRosterItem(this, i); + } + + if ((iq.Type == IQType.result) && (OnRosterEnd != null)) + OnRosterEnd(this); + } + + /// + /// Allows the subscription request and sends a subscribed to the user. + /// + /// + /// The presence packet containing the subscription request. + /// + public void ReplyAllow(Presence pres) + { + Debug.Assert(pres.Type == PresenceType.subscribe); + Presence reply = new Presence(m_stream.Document); + reply.To = pres.From; + reply.Type = PresenceType.subscribed; + Write(reply); + + if (m_autoSubscribe) + { + Presence sub = new Presence(m_stream.Document); + sub.To = pres.From; + sub.Type = PresenceType.subscribe; + Write(sub); + } + } + + /// + /// Denies the subscription request. + /// + /// + /// The presence packet containing the subscription request. + /// + public void ReplyDeny(Presence pres) + { + Debug.Assert(pres.Type == PresenceType.subscribe); + Presence reply = new Presence(m_stream.Document); + reply.To = pres.From; + reply.Type = PresenceType.unsubscribed; + Write(reply); + } + + /// + /// Remove a contact from the roster + /// + /// Typically just a user@host JID + public void Remove(JID jid) + { +/* +C: + + + + + */ + RosterIQ iq = new RosterIQ(m_stream.Document); + iq.Type = IQType.set; + Roster r = iq.Instruction; + Item item = r.AddItem(); + item.JID = jid; + item.Subscription = Subscription.remove; + Write(iq); // ignore response + } + + /// + /// Modifies the roster item to look like the given roster item. + /// This does not modify the model, + /// but waits for roster pushes from the XMPP server. + /// + /// Roster item that will appear in the roster. + public void Modify(Item item) + { + RosterIQ iq = new RosterIQ(m_stream.Document); + iq.Type = IQType.set; + Roster r = iq.Instruction; + r.AppendChild(item); + Write(iq); // ignore response + } + + #region Component Designer generated code + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + components = new System.ComponentModel.Container(); + } + #endregion + + #region IEnumerable Members + + IEnumerator IEnumerable.GetEnumerator() + { + return m_items.Keys.GetEnumerator(); + } + + #endregion + } +} diff -Nru smuxi-0.8/lib/jabber-net/jabber/client/RosterManager.resx smuxi-0.8.9.1/lib/jabber-net/jabber/client/RosterManager.resx --- smuxi-0.8/lib/jabber-net/jabber/client/RosterManager.resx 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/jabber-net/jabber/client/RosterManager.resx 2012-01-03 07:52:11.000000000 +0000 @@ -0,0 +1,105 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 1.3 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + RosterManager + + + False + + \ No newline at end of file diff -Nru smuxi-0.8/lib/jabber-net/jabber/connection/BindingStanzaStream.cs smuxi-0.8.9.1/lib/jabber-net/jabber/connection/BindingStanzaStream.cs --- smuxi-0.8/lib/jabber-net/jabber/connection/BindingStanzaStream.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/jabber-net/jabber/connection/BindingStanzaStream.cs 2012-01-03 07:52:11.000000000 +0000 @@ -0,0 +1,48 @@ +using bedrock.net; +using jabber.protocol.stream; + +namespace jabber.connection +{ + class BindingStanzaStream : HttpStanzaStream + { + public BindingStanzaStream(IStanzaEventListener listener) : base(listener) + { + } + + protected override BaseSocket CreateSocket() + { + XEP124Socket sock = new XEP124Socket(this); + ProxyType pt = (ProxyType)m_listener[Options.PROXY_TYPE]; + if (pt == ProxyType.HTTP) + { + string host = m_listener[Options.PROXY_HOST] as string; + int port = (int)m_listener[Options.PROXY_PORT]; + if (port == -1) + port = 80; + string proxy_uri = string.Format("http://{0}:{1}/", host, port); + sock.ProxyURI = new System.Uri(proxy_uri); + string user = m_listener[Options.PROXY_USER] as string; + if ((user != null) && (user != "")) + { + sock.ProxyCredentials = new System.Net.NetworkCredential(user, + m_listener[Options.PROXY_PW] as string); + } + } + return sock; + } + + public override void WriteStartTag(Stream stream) + { + // We don't send the tag in XEP 124. + XEP124Socket mySock = ((XEP124Socket) Socket); + mySock.NS = stream.NS; + mySock.Write(null, 0, 0); + } + + public override void Close(bool clean) + { + // We don't send the tag in XEP 124. + base.Close(false); + } + } +} Binary files /tmp/l3kVLF4iNE/smuxi-0.8/lib/jabber-net/jabber/connection/CapsManager.bmp and /tmp/jEQ8aotOZY/smuxi-0.8.9.1/lib/jabber-net/jabber/connection/CapsManager.bmp differ diff -Nru smuxi-0.8/lib/jabber-net/jabber/connection/CapsManager.cs smuxi-0.8.9.1/lib/jabber-net/jabber/connection/CapsManager.cs --- smuxi-0.8/lib/jabber-net/jabber/connection/CapsManager.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/jabber-net/jabber/connection/CapsManager.cs 2012-01-03 07:52:11.000000000 +0000 @@ -0,0 +1,573 @@ +/* -------------------------------------------------------------------------- + * Copyrights + * + * Portions created by or assigned to Cursive Systems, Inc. are + * Copyright (c) 2002-2008 Cursive Systems, Inc. All Rights Reserved. Contact + * information for Cursive Systems, Inc. is available at + * http://www.cursive.net/. + * + * License + * + * Jabber-Net is licensed under the LGPL. + * See LICENSE.txt for details. + * --------------------------------------------------------------------------*/ +using System; +using System.Collections; +using System.ComponentModel; +using System.ComponentModel.Design; +using System.Diagnostics; +using System.Security.Cryptography; +using System.Text; +using System.Xml; + +using jabber.protocol; +using jabber.protocol.client; +using jabber.protocol.iq; +using jabber.protocol.x; + +using bedrock.util; +using bedrock.io; + +namespace jabber.connection +{ + /// + /// Manages the entity capabilities information for the local connection as well as remote ones. + /// See XEP-0115, version 1.5 for details. + /// + [SVN("$Id$")] + public class CapsManager: StreamComponent + { + /// + /// Defines the default hash function to use for calculating ver attributes. + /// + public const string DEFAULT_HASH = "sha-1"; + private const string SEP = "<"; + + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + private DiscoNode m_disco; + private string m_hash = DEFAULT_HASH; + private string m_ver = null; + + private FileMap m_cache = null; + private DiscoManager m_discoManager = null; + + /// + /// Creates a new capability manager. + /// + public CapsManager() : this((DiscoNode)null) + { + } + + /// + /// Creates a new capability manager and associates it with a container. + /// + /// Parent container. + public CapsManager(IContainer container) : this((DiscoNode)null) + { + container.Add(this); + } + + /// + /// Create a CapsManager from an existing Disco Node. Pass in null + /// to use a placeholder. + /// + /// + public CapsManager(DiscoNode node) + { + InitializeComponent(); + this.OnStreamChanged += new bedrock.ObjectHandler(CapsManager_OnStreamChanged); + + if (node == null) + m_disco = new DiscoNode(new JID(null, "placeholder", null), null); + else + m_disco = node; + } + + /// + /// Performs tasks associated with freeing, releasing, or resetting resources. + /// + /// + /// True if managed resources should be disposed; otherwise, false. + /// + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + /// + /// The RosterManager for this view + /// + [Category("Cache")] + public DiscoManager DiscoManager + { + get + { + // If we are running in the designer, let's try to auto-hook a RosterManager + if ((m_discoManager == null) && DesignMode) + { + IDesignerHost host = (IDesignerHost)base.GetService(typeof(IDesignerHost)); + this.DiscoManager = (DiscoManager)jabber.connection.StreamComponent.GetComponentFromHost(host, typeof(DiscoManager)); + } + return m_discoManager; + } + set + { + if ((object)m_discoManager == (object)value) + return; + m_discoManager = value; + } + } + + /// + /// The file to store a cache of all received caps into. If no cache file is supplied, + /// caps queries will not be generated. + /// + [Category("Cache")] + public string FileName + { + get + { + if (m_cache == null) + return null; + return m_cache.FileName; + } + set + { + if (m_cache == null) + { + ElementFactory ef = new ElementFactory(); + ef.AddType(new jabber.protocol.iq.Factory()); + + m_cache = new FileMap(value, ef); + } + else + m_cache.FileName = value; + } + } + + /// + /// Adds a feature to the feature list + /// + /// + public void AddFeature(string feature) + { + m_ver = null; + m_disco.AddFeature(feature); + } + + /// + /// Removes a feature from the feature list + /// + /// + public void RemoveFeature(string feature) + { + m_ver = null; + m_disco.RemoveFeature(feature); + } + + /// + /// Gets or sets the current features enabled by this entity. + /// + [Category("Capabilities")] + [DefaultValue(null)] + public string[] Features + { + get + { + if (m_disco.Features == null) + return new string[0]; + return m_disco.FeatureNames; + } + set + { + m_ver = null; + m_disco.ClearFeatures(); + if (value != null) + foreach (string feature in value) + m_disco.AddFeature(feature); + } + } + + private static HashAlgorithm GetHasher(string name) + { + switch (name) + { + case null: + return null; + case "sha-1": + return SHA1.Create(); + case "sha-256": + return SHA256.Create(); + case "sha-512": + return SHA512.Create(); + case "sha-384": + return SHA384.Create(); + case "md5": + return MD5.Create(); + } + throw new ArgumentException("Invalid hash method: " + name, "Hash"); + } + + /// + /// Gets or sets the hash algorithm to use. + /// + [Category("Capabilities")] + [DefaultValue(DEFAULT_HASH)] + public string Hash + { + get { return m_hash; } + set + { + GetHasher(value); // throws if bad. + m_hash = value; + } + } + + private string CalculateVer(DiscoNode n) + { + if (m_hash == null) + return null; + + // 1. Initialize an empty string S. + StringBuilder S = new StringBuilder(); + + // 2. Sort the service discovery identities [16] by category and then by type + // (if it exists) and then by xml:lang (if it exists), formatted as + // CATEGORY '/' [TYPE] '/' [LANG] '/' [NAME]. Note that each slash is + // included even if the TYPE, LANG, or NAME is not included. + Ident[] ids = n.GetIdentities(); + Array.Sort(ids); + + // 3. For each identity, append the 'category/type/lang/name' to S, followed by + // the '<' character. + foreach (Ident id in ids) + { + S.Append(id.Key); + S.Append(SEP); + } + + // 4. Sort the supported service discovery features. + string[] features = n.FeatureNames; + Array.Sort(features); + + // 5. For each feature, append the feature to S, followed by the '<' character. + foreach (string feature in features) + { + S.Append(feature); + S.Append(SEP); + } + + // 6. If the service discovery information response includes XEP-0128 data forms, + // sort the forms by the FORM_TYPE (i.e., by the XML character + // data of the element). + Data[] ext = n.Extensions; + if (ext != null) + { + Array.Sort(ext, new FormTypeComparer()); + foreach (Data x in ext) + { + // For each extended service discovery information form: + + // 1. Append the XML character data of the FORM_TYPE field's + // element, followed by the '<' character. + S.Append(x.FormType); + S.Append(SEP); + + // 2. Sort the fields by the value of the "var" attribute. + bedrock.collections.Tree fields = new bedrock.collections.Tree(); + foreach (Field f in x.GetFields()) + fields[f.Var] = f; + + // 3. For each field: + foreach (System.Collections.DictionaryEntry entry in fields) + { + Field f = (Field)entry.Value; + if (f.Var == "FORM_TYPE") + continue; + + // 1. Append the value of the "var" attribute, followed by the '<' character. + S.Append(f.Var); + S.Append(SEP); + + // 2. Sort values by the XML character data of the element. + string[] values = f.Vals; + Array.Sort(values); + foreach (string v in values) + { + // 3. For each element, append the XML character data, followed by the '<' character. + S.Append(v); + S.Append(SEP); + } + } + } + } + + // Ensure that S is encoded according to the UTF-8 encoding (RFC 3269 [16]). + byte[] input = Encoding.UTF8.GetBytes(S.ToString()); + + // Compute the verification string by hashing S using the algorithm specified + // in the 'hash' attribute (e.g., SHA-1 as defined in RFC 3174 [17]). The hashed + // data MUST be generated with binary output and encoded using Base64 as specified + // in Section 4 of RFC 4648 [18] (note: the Base64 output MUST NOT include + // whitespace and MUST set padding bits to zero). [19] + HashAlgorithm hasher = GetHasher(m_hash); + byte[] hash = hasher.ComputeHash(input, 0, input.Length); + return Convert.ToBase64String(hash); + } + + /// + /// Returns the calculated hash over all of the caps information. + /// + [Category("Capabilities")] + public string Ver + { + get + { + if (m_ver == null) + m_ver = CalculateVer(m_disco); + return m_ver; + } + } + + /// + /// Gets or sets the node URI for this client. + /// + [Category("Capabilities")] + [DefaultValue(null)] + public string Node + { + get { return m_disco.Node; } + set { m_disco.Node = value; } + } + + /// + /// Retrieves the node#ver to look for in queries. + /// + [Category("Capabilities")] + public string NodeVer + { + get { return Node + "#" + Ver; } + } + + /// + /// Adds a new identity. + /// + /// + /// + /// + /// + public void AddIdentity(string category, string type, string lang, string name) + { + m_ver = null; + m_disco.AddIdentity(new Ident(name, category, type, lang)); + } + + /// + /// Adds a new identity + /// + /// + public void AddIdentity(Ident id) + { + m_ver = null; + m_disco.AddIdentity(id); + } + + /// + /// Gets or sets all of the identities currently supported by this manager. + /// + [Category("Capabilities")] + [DefaultValue(null)] + public Ident[] Identities + { + get + { + if (m_disco.Identity == null) + return new Ident[0]; + return m_disco.GetIdentities(); + } + set + { + m_ver = null; + m_disco.ClearIdentity(); + if (value != null) + foreach (Ident id in value) + m_disco.AddIdentity(id); + } + } + + private void CapsManager_OnStreamChanged(object sender) + { + m_disco.JID = m_stream.JID; + + jabber.client.JabberClient jc = m_stream as jabber.client.JabberClient; + if (jc == null) + return; + + jc.OnBeforePresenceOut += new jabber.client.PresenceHandler(jc_OnBeforePresenceOut); + jc.OnIQ += new jabber.client.IQHandler(jc_OnIQ); + jc.OnPresence += new jabber.client.PresenceHandler(jc_OnPresence); + } + + private void jc_OnPresence(object sender, Presence pres) + { + if ((m_cache == null) || (m_discoManager == null)) + return; + Caps c = pres["c", URI.CAPS] as Caps; + if (c == null) + return; + + // TODO: ignoring old-style caps for now. + if (!c.NewStyle) + return; + string ver = c.Version; + if ((ver == null) || (ver == "")) + return; + string node = c.Node; + if ((node == null) || (node == "")) + return; + + if (m_cache.Contains(ver)) + return; + + m_discoManager.BeginGetFeatures(pres.From, c.Node + "#" + ver, GotCaps, ver); + } + + private void GotCaps(DiscoManager m, DiscoNode node, object state) + { + // timeout + if (node == null) + return; + + string ver = (string)state; + string calc = CalculateVer(node); + if (ver != calc) + { + Debug.WriteLine("WARNING: invalid caps ver hash: '" + ver + "' != '" + calc + "'"); + if (node.Info != null) + Debug.WriteLine(node.Info.OuterXml); + return; + } + m_cache[ver] = node.Info; + } + + /// + /// Get a DiscoNode that has all of the info associated with the + /// given ver hash, or null if there is none cached. + /// + /// + /// + /// + public DiscoInfo this[string ver] + { + get + { + if (m_cache == null) + return null; + return m_cache[ver]; + } + set + { + // mostly for test. + if (m_cache == null) + return; + m_cache[ver] = value; + } + } + + /// + /// Determines whether or not this is a capabilities request. + /// Answers true for a bare no-node disco request, as well as + /// for requests to the correct hash. + /// + /// XML to look through for capabilities. + /// True if this is a capabilities request. + public bool IsCaps(IQ iq) + { + if (iq.Type != IQType.get) + return false; + + DiscoInfo info = iq.Query as DiscoInfo; + if (info == null) + return false; + + string node = info.Node; + if (node == null) + return true; + + if (node == NodeVer) + return true; + + return false; + } + + /// + /// Take the info for this entity, and fill it in to the given DiscoInfo protocol element. + /// Node, identities, and features get filled in. + /// + /// The empty info element to fill in. + public void FillInInfo(DiscoInfo info) + { + foreach (Ident id in Identities) + info.AddIdentity(id.Category, id.Type, id.Name, id.Lang); + foreach (string uri in Features) + info.AddFeature(uri); + } + + private void jc_OnIQ(object sender, IQ iq) + { + if (!IsCaps(iq)) + return; + + DiscoInfo info = iq.Query as DiscoInfo; + if (info == null) + return; + + IQ resp = iq.GetResponse(m_stream.Document); + info = (DiscoInfo)resp.Query; + FillInInfo(info); + + Write(resp); + } + + /// + /// Get a caps element that describes the current version, etc. + /// + /// + /// + public Caps GetCaps(XmlDocument doc) + { + Caps caps = new Caps(doc); + caps.Version = Ver; + caps.Node = Node; + caps.Hash = m_hash; + return caps; + } + + private void jc_OnBeforePresenceOut(object sender, Presence pres) + { + Debug.Assert(Node != null, "Node is required"); + pres.AppendChild(GetCaps(pres.OwnerDocument)); + } + + #region Component Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + components = new System.ComponentModel.Container(); + } + + #endregion + } +} diff -Nru smuxi-0.8/lib/jabber-net/jabber/connection/CertificatePrompt.cs smuxi-0.8.9.1/lib/jabber-net/jabber/connection/CertificatePrompt.cs --- smuxi-0.8/lib/jabber-net/jabber/connection/CertificatePrompt.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/jabber-net/jabber/connection/CertificatePrompt.cs 2012-01-03 07:52:11.000000000 +0000 @@ -0,0 +1,240 @@ +/* -------------------------------------------------------------------------- + * Copyrights + * + * Portions created by or assigned to Cursive Systems, Inc. are + * Copyright (c) 2002-2008 Cursive Systems, Inc. All Rights Reserved. Contact + * information for Cursive Systems, Inc. is available at + * http://www.cursive.net/. + * + * License + * + * Jabber-Net is licensed under the LGPL. + * See LICENSE.txt for details. + * --------------------------------------------------------------------------*/ + +#if !__MonoCS__ + #define UI_OK +#endif + +namespace jabber.connection +{ + using System; + using bedrock.util; + +#if UI_OK + using System.Security.Cryptography.X509Certificates; + using System.Net.Security; + using System.Windows.Forms; + using System.Drawing; +#endif + + /// + /// Intentionally-ugly form to deal with bad certificates. Because you don't like it, you should catch XmppStream.OnInvalidCertificate, + /// and do something better. + /// + [SVN(@"$Id$")] + public class CertificatePrompt +#if UI_OK + : Form +#endif + { +#if UI_OK + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + private Label lblSubject; + private Label lblBegin; + private Label lblEnd; + private Button btnCancel; + private Button btnAllow; + private Button btnShow; + private Panel panel2; + + private X509Certificate2 m_cert; + + /// + /// Create an ugly form to prompt the user about an invalid certificate. + /// + /// The invalid certificate + /// The CA chain for the cert + /// The errors associated with the certificate + public CertificatePrompt(X509Certificate2 cert, X509Chain chain, SslPolicyErrors errors) + { + m_cert = cert; + InitializeComponent(); + lblSubject.Text = m_cert.SubjectName.Name; + if ((errors & SslPolicyErrors.RemoteCertificateNameMismatch) == SslPolicyErrors.RemoteCertificateNameMismatch) + lblSubject.ForeColor = Color.Red; + lblBegin.Text = cert.NotBefore.ToString(); + lblEnd.Text = cert.NotAfter.ToString(); + } + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + private void btnShow_Click(object sender, EventArgs e) + { + System.Diagnostics.Debug.Assert(!this.InvokeRequired); + X509Certificate2UI.DisplayCertificate(m_cert); + if (m_cert.Verify()) + this.DialogResult = DialogResult.OK; + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + System.Windows.Forms.Label label1; + System.Windows.Forms.Label label2; + System.Windows.Forms.Label label3; + this.panel2 = new System.Windows.Forms.Panel(); + this.btnCancel = new System.Windows.Forms.Button(); + this.btnAllow = new System.Windows.Forms.Button(); + this.lblSubject = new System.Windows.Forms.Label(); + this.lblBegin = new System.Windows.Forms.Label(); + this.lblEnd = new System.Windows.Forms.Label(); + this.btnShow = new System.Windows.Forms.Button(); + label1 = new System.Windows.Forms.Label(); + label2 = new System.Windows.Forms.Label(); + label3 = new System.Windows.Forms.Label(); + this.panel2.SuspendLayout(); + this.SuspendLayout(); + // + // label1 + // + label1.AutoSize = true; + label1.Location = new System.Drawing.Point(12, 9); + label1.Name = "label1"; + label1.Size = new System.Drawing.Size(77, 13); + label1.TabIndex = 2; + label1.Text = "Subject Name:"; + // + // label2 + // + label2.AutoSize = true; + label2.Location = new System.Drawing.Point(12, 36); + label2.Name = "label2"; + label2.Size = new System.Drawing.Size(63, 13); + label2.TabIndex = 3; + label2.Text = "Begin Date:"; + // + // label3 + // + label3.AutoSize = true; + label3.Location = new System.Drawing.Point(12, 64); + label3.Name = "label3"; + label3.Size = new System.Drawing.Size(55, 13); + label3.TabIndex = 4; + label3.Text = "End Date:"; + // + // panel2 + // + this.panel2.Controls.Add(this.btnCancel); + this.panel2.Controls.Add(this.btnAllow); + this.panel2.Dock = System.Windows.Forms.DockStyle.Bottom; + this.panel2.Location = new System.Drawing.Point(0, 134); + this.panel2.Name = "panel2"; + this.panel2.Size = new System.Drawing.Size(500, 44); + this.panel2.TabIndex = 1; + // + // btnCancel + // + this.btnCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.btnCancel.Location = new System.Drawing.Point(413, 9); + this.btnCancel.Name = "btnCancel"; + this.btnCancel.Size = new System.Drawing.Size(75, 23); + this.btnCancel.TabIndex = 2; + this.btnCancel.Text = "Cancel"; + this.btnCancel.UseVisualStyleBackColor = true; + // + // btnAllow + // + this.btnAllow.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.btnAllow.DialogResult = System.Windows.Forms.DialogResult.OK; + this.btnAllow.Location = new System.Drawing.Point(332, 9); + this.btnAllow.Name = "btnAllow"; + this.btnAllow.Size = new System.Drawing.Size(75, 23); + this.btnAllow.TabIndex = 1; + this.btnAllow.Text = "Allow Once"; + this.btnAllow.UseVisualStyleBackColor = true; + // + // lblSubject + // + this.lblSubject.AutoSize = true; + this.lblSubject.Location = new System.Drawing.Point(126, 9); + this.lblSubject.Name = "lblSubject"; + this.lblSubject.Size = new System.Drawing.Size(43, 13); + this.lblSubject.TabIndex = 5; + this.lblSubject.Text = "Subject"; + // + // lblBegin + // + this.lblBegin.AutoSize = true; + this.lblBegin.Location = new System.Drawing.Point(126, 36); + this.lblBegin.Name = "lblBegin"; + this.lblBegin.Size = new System.Drawing.Size(34, 13); + this.lblBegin.TabIndex = 6; + this.lblBegin.Text = "Begin"; + // + // lblEnd + // + this.lblEnd.AutoSize = true; + this.lblEnd.Location = new System.Drawing.Point(126, 64); + this.lblEnd.Name = "lblEnd"; + this.lblEnd.Size = new System.Drawing.Size(26, 13); + this.lblEnd.TabIndex = 7; + this.lblEnd.Text = "End"; + // + // btnShow + // + this.btnShow.Location = new System.Drawing.Point(14, 90); + this.btnShow.Name = "btnShow"; + this.btnShow.Size = new System.Drawing.Size(75, 23); + this.btnShow.TabIndex = 8; + this.btnShow.Text = "Trust..."; + this.btnShow.UseVisualStyleBackColor = true; + this.btnShow.Click += new System.EventHandler(this.btnShow_Click); + // + // CertificatePrompt + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.CancelButton = this.btnCancel; + this.ClientSize = new System.Drawing.Size(500, 178); + this.Controls.Add(this.btnShow); + this.Controls.Add(this.lblEnd); + this.Controls.Add(this.lblBegin); + this.Controls.Add(this.lblSubject); + this.Controls.Add(label3); + this.Controls.Add(label2); + this.Controls.Add(label1); + this.Controls.Add(this.panel2); + this.Name = "CertificatePrompt"; + this.Text = "Invalid Certificate"; + this.panel2.ResumeLayout(false); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion +#endif + + } +} diff -Nru smuxi-0.8/lib/jabber-net/jabber/connection/CertificatePrompt.resx smuxi-0.8.9.1/lib/jabber-net/jabber/connection/CertificatePrompt.resx --- smuxi-0.8/lib/jabber-net/jabber/connection/CertificatePrompt.resx 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/jabber-net/jabber/connection/CertificatePrompt.resx 2012-01-03 07:52:11.000000000 +0000 @@ -0,0 +1,129 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + False + + + False + + + False + + \ No newline at end of file Binary files /tmp/l3kVLF4iNE/smuxi-0.8/lib/jabber-net/jabber/connection/ConferenceManager.bmp and /tmp/jEQ8aotOZY/smuxi-0.8.9.1/lib/jabber-net/jabber/connection/ConferenceManager.bmp differ diff -Nru smuxi-0.8/lib/jabber-net/jabber/connection/ConferenceManager.cs smuxi-0.8.9.1/lib/jabber-net/jabber/connection/ConferenceManager.cs --- smuxi-0.8/lib/jabber-net/jabber/connection/ConferenceManager.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/jabber-net/jabber/connection/ConferenceManager.cs 2012-01-03 07:52:11.000000000 +0000 @@ -0,0 +1,1658 @@ +/* -------------------------------------------------------------------------- + * Copyrights + * + * Portions created by or assigned to Cursive Systems, Inc. are + * Copyright (c) 2002-2008 Cursive Systems, Inc. All Rights Reserved. Contact + * information for Cursive Systems, Inc. is available at + * http://www.cursive.net/. + * + * License + * + * Jabber-Net is licensed under the LGPL. + * See LICENSE.txt for details. + * --------------------------------------------------------------------------*/ +using System; +using System.Collections; +using System.ComponentModel; +using System.Diagnostics; + +using bedrock.util; +using jabber.protocol; +using jabber.protocol.client; +using jabber.protocol.iq; +using jabber.client; +using jabber.protocol.x; +using System.ComponentModel.Design; + +namespace jabber.connection +{ + + /// + /// An error occurred with a presence sent to a room. + /// + /// + /// + public delegate void RoomPresenceHandler(Room room, Presence pres); + + /// + /// Notifies the client that a room configuration form has been received. + /// + /// Room associated with the configuration. + /// Contains an x:data child with the form. + /// null to take the defaults, otherwise the IQ response + public delegate IQ ConfigureRoom(Room room, IQ parent); + + /// + /// An event, like join or leave, has happened to a room. + /// + /// The room the event is for + public delegate void RoomEvent(Room room); + + /// + /// An event, like join or leave, has happened to a room. + /// + /// The room the event is for + /// State passed in by the caller, or null if none. + public delegate void RoomStateEvent(Room room, object state); + + /// + /// A participant-related callback. + /// + /// The room the event is for + /// The participant in the room + public delegate void RoomParticipantEvent(Room room, RoomParticipant participant); + + /// + /// A participantCollection-related callback. + /// + /// The room the event is for + /// The participants in the response + /// State passed in by the caller, or null if none. + public delegate void RoomParticipantsEvent(Room room, ParticipantCollection participants, object state); + + /// + /// Manages a set of conference rooms + /// + [SVN(@"$Id$")] + public class ConferenceManager : StreamComponent + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + private Hashtable m_rooms = new Hashtable(); + private string m_nick = null; + + /// + /// Creates a new conference manager. + /// + public ConferenceManager() + { + this.OnStreamChanged += new bedrock.ObjectHandler(ConferenceManager_OnStreamChanged); + InitializeComponent(); + } + + private void ConferenceManager_OnStreamChanged(object sender) + { + Stream.OnProtocol += new ProtocolHandler(Stream_OnProtocol); + } + + private void Stream_OnProtocol(object sender, System.Xml.XmlElement rp) + { + if (OnInvite == null) + return; + + Message msg = rp as Message; + if (msg == null) + return; +/* + + + + + Hey Hecate, this is the place for all good witches! + + + cauldronburn + + + */ + UserX x = msg["x", URI.MUC_USER] as UserX; + if (x == null) + return; + + Invite inv = x["invite", URI.MUC_USER] as Invite; + if (inv == null) + return; + + Room r = GetRoom(msg.From); + OnInvite(r, msg); + } + + /// + /// Creates a new conference manager in a container + /// + /// Parent container. + public ConferenceManager(IContainer container) : this() + { + container.Add(this); + } + + /// + /// Performs tasks associated with freeing, releasing, or resetting resources. + /// + /// True if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Component Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + components = new System.ComponentModel.Container(); + } + + #endregion + + /// + /// Finished joining the room, including all potential configuration. + /// If set, will be added to each room created through the manager. + /// + [Category("Room")] + public event RoomEvent OnJoin; + + /// + /// Finished leaving the room, or was kicked/banned, or the room server went down cleanly. + /// If set, will be added to each room created through the manager. + /// + [Category("Room")] + public event RoomPresenceHandler OnLeave; + + /// + /// Error in response to a room join, nick change, or presence update. + /// If set, will be added to each room created through the manager. + /// + [Category("Room")] + public event RoomPresenceHandler OnPresenceError; + + /// + /// Room configuration form received. It is up to the listener call FinishConfig(). + /// The IQ in the callback is the parent of the x:data element. + /// If set, will be added to each room created through the manager. + /// + [Category("Room")] + public event ConfigureRoom OnRoomConfig; + + /// + /// A message broadcast to all in the room + /// If set, will be added to each room created through the manager. + /// + [Category("Room")] + public event MessageHandler OnRoomMessage; + + /// + /// A side-chat message. + /// If set, will be added to each room created through the manager. + /// + [Category("Room")] + public event MessageHandler OnPrivateMessage; + + /// + /// An admin message from the room itself. Typically status change sorts of things + /// like kick/ban. + /// If set, will be added to each room created through the manager. + /// + [Category("Room")] + public event MessageHandler OnAdminMessage; + + /// + /// A message that was sent by this user to the room, echo'd back. + /// If set, will be added to each room created through the manager. + /// + [Category("Room")] + public event MessageHandler OnSelfMessage; + + /// + /// The subject of the room has been changed + /// If set, will be added to each room created through the manager. + /// + [Category("Room")] + public event MessageHandler OnSubjectChange; + + /// + /// A participant has joined the room. This will not fire for yourself. + /// If set, will be added to each room created through the manager. + /// + [Category("Room")] + public event RoomParticipantEvent OnParticipantJoin; + + /// + /// A participant has left the room. This will not fire for yourself. + /// If set, will be added to each room created through the manager. + /// + [Category("Room")] + public event RoomParticipantEvent OnParticipantLeave; + + /// + /// A participant has changed presence, without joining or leaving the room. This will not fire for yourself. + /// If set, will be added to each room created through the manager. + /// + [Category("Room")] + public event RoomParticipantEvent OnParticipantPresenceChange; + + /// + /// An invite was received. A room object will be passed in as the sender. + /// + [Category("Manager")] + public event MessageHandler OnInvite; + + /// + /// The default room nickname, if one is not specified. If none + /// specified, the user name from the stream JID is used. + /// + [Category("Manager")] + [DefaultValue(null)] + public string DefaultNick + { + get + { + if (m_nick != null) + return m_nick; + if ((m_stream == null) || m_stream.JID == null) + return null; + return m_stream.JID.User; + } + set { m_nick = value; } + } + + /// + /// Joins a conference room. + /// + /// room@conference/nick, where "nick" is the desred nickname in the room. + /// + /// If already joined, the existing room will be returned. + /// If not, a Room object will be returned in the joining state. + /// + public Room GetRoom(JID roomAndNick) + { + if (roomAndNick == null) + throw new ArgumentNullException("roomAndNick"); + + if (roomAndNick.Resource == null) + roomAndNick.Resource = DefaultNick; + + Room r = (Room)m_rooms[roomAndNick]; + if (r != null) + return r; + + // If no resource specified, pick up the user's name from their JID + if (roomAndNick.Resource == null) + roomAndNick.Resource = m_stream.JID.User; + + r = new Room(this, roomAndNick); + r.OnJoin += OnJoin; + r.OnLeave += OnLeave; + r.OnPresenceError += OnPresenceError; + r.OnRoomConfig += OnRoomConfig; + r.OnRoomMessage += OnRoomMessage; + r.OnPrivateMessage += OnPrivateMessage; + r.OnAdminMessage += OnAdminMessage; + r.OnSelfMessage += OnSelfMessage; + r.OnSubjectChange += OnSubjectChange; + r.OnParticipantJoin += OnParticipantJoin; + r.OnParticipantLeave += OnParticipantLeave; + r.OnParticipantPresenceChange += OnParticipantPresenceChange; + + m_rooms[roomAndNick] = r; + return r; + } + + /// + /// Determines whether or not the conference room is being managed + /// by this ConferenceManager. + /// + /// Room to look for. + /// True if the room is being managed. + public bool HasRoom(JID roomAndNick) + { + return m_rooms.ContainsKey(roomAndNick); + } + + /// + /// Removes the room from the list. + /// Should most often be called by the Room.Leave() method. + /// If the room does not exist, no exception is thrown. + /// + /// Room to remove. + public void RemoveRoom(JID roomAndNick) + { + m_rooms.Remove(roomAndNick); + } + + private class UniqueState + { + public string Nick; + public RoomStateEvent Callback; + public object State; + + public UniqueState(string nick, RoomStateEvent callback, object state) + { + this.Nick = nick; + this.Callback = callback; + this.State = state; + } + } + + /// + /// Get a unique room name from the given server, and create a Room + /// object for that room with the given nick. You'll be called back on + /// "callback" when complete; the Room will be null if there was an error + /// or timeout. + /// + /// Note: the server should implement the feature http://jabber.org/protocol/muc#unique, + /// or this will return an error. To work around, just create a room with a Guid for + /// a name. + /// + /// The server to send the request to + /// The nickname desired in the new room + /// A callback to be called when the room is created + /// State object to be passed back when the callback fires + public void GetUniqueRoom(string server, string nick, RoomStateEvent callback, object state) + { + if (server == null) + throw new ArgumentNullException("server"); + if (nick == null) + throw new ArgumentNullException("nick"); + if (callback == null) + throw new ArgumentNullException("callback"); + +/* + + + + */ + UniqueIQ iq = new UniqueIQ(m_stream.Document); + iq.To = server; + BeginIQ(iq, new IqCB(GotUnique), new UniqueState(nick, callback, state)); + } + + private void GotUnique(object sender, IQ iq, object state) + { + UniqueState us = (UniqueState)state; + if ((iq == null) || (iq.Type == IQType.error)) + { + us.Callback(null, us.State); + return; + } + +/* + + + 6d9423a55f499b29ad20bf7b2bdea4f4b885ead1 + + + */ + UniqueRoom unique = (UniqueRoom)iq.Query; + Room r = GetRoom(new JID(unique.RoomNode, iq.From.Server, us.Nick)); + us.Callback(r, us.State); + } + } + + /// + /// Manages a multi-user conference room. See XEP-0045 (http://www.xmpp.org/extensions/xep-0045.html). + /// + [SVN(@"$Id$")] + public class Room + { + private enum STATE + { + start, + join, + configGet, + configSet, + running, + leaving, + error + } + + private STATE m_state = STATE.start; + /// + /// Nick JID. room@conference/nick. + /// + private JID m_jid; + /// + /// Bare room JID. room@conference + /// + private JID m_room; + //private XmppStream m_stream; + private bool m_default = false; + private ConferenceManager m_manager; + private Message m_subject; + private ParticipantCollection m_participants = new ParticipantCollection(); + private object m_tag; + + /// + /// Create. + /// + /// The manager for this room. + /// room@conference/nick, where "nick" is the desred nickname in the room. + internal Room(ConferenceManager manager, JID roomAndNick) + { + m_manager = manager; + XmppStream stream = manager.Stream; + m_jid = roomAndNick; + m_room = new JID(m_jid.User, m_jid.Server, null); + stream.OnProtocol += new jabber.protocol.ProtocolHandler(m_stream_OnProtocol); + JabberClient jc = stream as JabberClient; + if (jc != null) + jc.OnAfterPresenceOut += new jabber.client.PresenceHandler(m_stream_OnAfterPresenceOut); + } + + /// + /// Finished joining the room, including all potential configuration. + /// + public event RoomEvent OnJoin; + + /// + /// Finished leaving the room, or was kicked/banned, or the room server went down cleanly. + /// + public event RoomPresenceHandler OnLeave; + + /// + /// Informs the client that an error in response to a room join, + /// nick change, or presence update has occurred. + /// + public event RoomPresenceHandler OnPresenceError; + + /// + /// Informs the client that the room configuration form was received. + /// It is up to the listener to call the FinishConfig() method. + /// The IQ in the callback is the parent of the x:data element. + /// + public event ConfigureRoom OnRoomConfig; + + /// + /// A message broadcast to all in the room + /// + public event MessageHandler OnRoomMessage; + + /// + /// A message that was sent by this user to the room, echo'd back. + /// + public event MessageHandler OnSelfMessage; + + /// + /// A side-chat message. + /// + public event MessageHandler OnPrivateMessage; + + /// + /// An admin message from the room itself. Typically status change sorts of things + /// like kick/ban. + /// + public event MessageHandler OnAdminMessage; + + /// + /// The subject of the room has been changed + /// + public event MessageHandler OnSubjectChange; + + /// + /// A participant has joined the room. This will not fire for yourself. + /// + [Category("Room")] + public event RoomParticipantEvent OnParticipantJoin; + + /// + /// A participant has left the room. This will not fire for yourself. + /// + [Category("Room")] + public event RoomParticipantEvent OnParticipantLeave; + + /// + /// A participant has changed presence, without joining or leaving the room. This will not fire for yourself. + /// + [Category("Room")] + public event RoomParticipantEvent OnParticipantPresenceChange; + + /// + /// Determines whether to use the default conference room configuration + /// or to retrieve the configuration form from the XMPP server. + /// + [DefaultValue(false)] + public bool DefaultConfig + { + get { return m_default; } + set { m_default = value; } + } + + /// + /// The subject of the room. Set has the side-effect of sending to the server. + /// + public string Subject + { + get { return m_subject.Subject; } + set + { + Message m = new Message(m_manager.Stream.Document); + m.To = m_room; + m.Type = MessageType.groupchat; + m.Subject = value; + m.Body = "/me has changed the subject to: " + value; + m_manager.Write(m); + } + } + + /// + /// The full JID of the user in the room. room@service/nick + /// + public JID RoomAndNick + { + get { return m_jid; } + } + + /// + /// The bare JID of the room. room@service + /// + public JID JID + { + get { return m_room; } + } + + /// + /// Have we joined the room successfully? + /// + public bool IsParticipating + { + get { return m_state == STATE.running; } + } + + /// + /// The nickname that others in the room will see for you. + /// Set has the side-effect of changing the nickname on the server. + /// + public string Nickname + { + get { return m_jid.Resource; } + set + { + m_jid = new JID(m_jid.User, m_jid.Server, value); + Presence p = new Presence(m_manager.Stream.Document); + p.To = m_jid; + m_manager.Write(p); + } + } + + /// + /// Current room participants. + /// + /// + public ParticipantCollection Participants + { + get { return m_participants; } + } + + /// + /// Extra data associated with the room. + /// + public object Tag + { + get { return m_tag; } + set { m_tag = value; } + } + + /// + /// Whenver we change presence, send the new presence to the room, including + /// caps etc. + /// + /// + /// + private void m_stream_OnAfterPresenceOut(object sender, Presence pres) + { + Presence p = (Presence)pres.CloneNode(true); + p.To = m_room; + m_manager.Write(p); + } + + private void m_stream_OnProtocol(object sender, System.Xml.XmlElement rp) + { + // There isn't always a from address. iq:roster, for example. + string af = rp.GetAttribute("from"); + if (af == "") + return; + JID from = new JID(af); + if (from.Bare != (string)m_room) + return; // not for this room. + + switch (rp.LocalName) + { + case "presence": + Presence p = (Presence)rp; + if (p.Error != null) + { + m_state = STATE.error; + if (OnPresenceError != null) + OnPresenceError(this, p); + return; + } + + ParticipantCollection.Modification mod = ParticipantCollection.Modification.NONE; + RoomParticipant party = m_participants.Modify(p, out mod); + + // if this is ours + if (p.From == m_jid) + { + switch (m_state) + { + case STATE.join: + OnJoinPresence(p); + break; + case STATE.leaving: + OnLeavePresence(p); + break; + case STATE.running: + if (p.Type == PresenceType.unavailable) + OnLeavePresence(p); + break; + } + } + else + { + switch (mod) + { + case ParticipantCollection.Modification.NONE: + if (OnParticipantPresenceChange != null) + OnParticipantPresenceChange(this, party); + break; + case ParticipantCollection.Modification.JOIN: + if (OnParticipantJoin != null) + OnParticipantJoin(this, party); + break; + case ParticipantCollection.Modification.LEAVE: + if (OnParticipantLeave != null) + OnParticipantLeave(this, party); + break; + } + } + break; + case "message": + Message m = (Message)rp; + if (m.Type == MessageType.groupchat) + { + if (m.Subject != null) + { + if (OnSubjectChange != null) + OnSubjectChange(this, m); + m_subject = m; + } + else if (m.From == m_jid) + { + if (OnSelfMessage != null) + OnSelfMessage(this, m); + } + else + { + if (OnRoomMessage != null) + OnRoomMessage(this, m); + } + } + else + { + if (m.From.Resource == null) + { + // room notification of some kind + if (OnAdminMessage != null) + OnAdminMessage(this, m); + } + else + { + if (OnPrivateMessage != null) + OnPrivateMessage(this, m); + } + } + break; + case "iq": + // TODO: IQs the room sends to us. + break; + } + } + + private void OnJoinPresence(Presence p) + { + // from is always us. +/* + + + + + + + */ + UserX x = p["x", URI.MUC_USER] as UserX; + if (x == null) + { + // Old server. Hope for the best. + if (OnJoin != null) + OnJoin(this); + return; + } + + if (x.HasStatus(RoomStatus.CREATED)) + { + // room was created. this must be me. + if (m_default || (OnRoomConfig == null)) + FinishConfigDefault(); + else + Configure(); + return; + } + + // if it wasn't created, and this is mine, we must be running. + m_state = STATE.running; + if (OnJoin != null) + OnJoin(this); + } + + private void OnLeavePresence(Presence p) + { +/* + + + + + + + */ + // not quite an assert. some sort of race. + if (p.Type != PresenceType.unavailable) + return; + + m_manager.Stream.OnProtocol -= new jabber.protocol.ProtocolHandler(m_stream_OnProtocol); + jabber.client.JabberClient jc = m_manager.Stream as jabber.client.JabberClient; + if (jc != null) + jc.OnAfterPresenceOut -= new jabber.client.PresenceHandler(m_stream_OnAfterPresenceOut); + m_manager.RemoveRoom(m_jid); // should cause this object to GC. + if (OnLeave != null) + OnLeave(this, p); + } + + /// + /// Configures the room. OnRoomConfig MUST be set first. + /// OnRoomConfig will be called back in the GUI thread if there is an + /// InvokeControl on your XmppStream. Make sure that OnRoomConfig does not + /// return until it has the answer, typically by popping up a modal dialog + /// with the x:data form. + /// + public void Configure() + { + if (OnRoomConfig == null) + throw new ArgumentNullException("Must set OnRoomConfig before calling Configure()", "OnRoomConfig"); + +/* + + + + */ + m_state = STATE.configGet; + OwnerIQ iq = new OwnerIQ(m_manager.Stream.Document); + iq.Type = IQType.get; + iq.To = m_room; + m_manager.BeginIQ(iq, new IqCB(ConfigForm), null); + } + + private void ConfigForm(object sender, IQ iq, object context) + { + // We should always be on the GUI thread. + // XmppStream should invoke before calling OnProtocol in the Tracker. + Debug.Assert((m_manager.Stream.InvokeControl == null) || (!m_manager.Stream.InvokeControl.InvokeRequired)); + + IQ resp = OnRoomConfig(this, iq); + if (resp == null) + { + FinishConfigDefault(); + return; + } + + m_state = STATE.configSet; + resp.To = m_room; + resp.Type = IQType.set; + resp.From = null; + m_manager.BeginIQ(resp, new IqCB(Configured), null); + } + + private void Configured(object sender, IQ iq, object context) + { + if (iq.Type != IQType.result) + { + m_state = STATE.error; + // TODO: fire an error + return; + } + + if (m_state != STATE.running) + { + // reconfigs don't call OnJoin + m_state = STATE.running; + if (OnJoin != null) + OnJoin(this); + } + } + + /// + /// Finish up configuration, taking the default room config. Also known as + /// an "Instant Room". Suitable for use if the user cancels the configuration + /// request, perhaps. + /// + private void FinishConfigDefault() + { +/* + + + + + + */ + m_state = STATE.configSet; + OwnerIQ iq = new OwnerIQ(m_manager.Stream.Document); + iq.Type = IQType.set; + iq.To = m_room; + OwnerQuery oq = iq.Instruction; + Data form = oq.Form; + form.Type = XDataType.submit; + m_manager.BeginIQ(iq, new IqCB(Configured), null); + } + + /// + /// Joins the room. If the room is created, Configure() will + /// be called automatically. + /// + public void Join() + { + Join(null); + } + + /// + /// Join a room, using a password. + /// + /// + public void Join(string password) + { + if (m_state == STATE.running) + return; + + m_state = STATE.join; + RoomPresence pres = new RoomPresence(m_manager.Stream.Document, m_jid); + if (password != null) + pres.X.Password = password; + + m_manager.Write(pres); + } + + /// + /// Exits the room. This cleans up the entry in the ConferenceManager, as well. + /// + /// Reason for leaving the room. May be null for no reason. + public void Leave(string reason) + { + m_state = STATE.leaving; + +/* + + gone where the goblins go + + */ + Presence p = new Presence(m_manager.Stream.Document); + p.To = m_jid; + p.Type = PresenceType.unavailable; + if (reason != null) + p.Status = reason; + m_manager.Write(p); + + + // cleanup done when unavailable/110 received. + } + + /// + /// Sends a message to everyone currently in the room. + /// + /// The message text to send. + public void PublicMessage(string body) + { + if (m_state != STATE.running) + throw new InvalidOperationException("Must be in running state to send message: " + m_state.ToString()); +/* + + Harpier cries: 'tis time, 'tis time. + + */ + if (body == null) + throw new ArgumentNullException("body"); + Message m = new Message(m_manager.Stream.Document); + m.To = m_room; + m.Type = MessageType.groupchat; + m.Body = body; + m_manager.Write(m); + } + + /// + /// Sends a private message to a single user in the room. + /// + /// The nickname of the user to send a private message to. + /// The message body to send. + public void PrivateMessage(string nick, string body) + { + if (m_state != STATE.running) + throw new InvalidOperationException("Must be in running state to send message: " + m_state.ToString()); + +/* + + I'll give thee a wind. + + */ + if (nick == null) + throw new ArgumentNullException("nick"); + if (body == null) + throw new ArgumentNullException("body"); + + Message m = new Message(m_manager.Stream.Document); + m.To = new JID(m_room.User, m_room.Server, nick); + m.Type = MessageType.chat; + m.Body = body; + m_manager.Write(m); + } + + /// + /// Invite a user to join the room. + /// + /// The JID of the person to invite + /// The reason for the invite, or null for none. + public void Invite(JID invitee, string reason) + { + if (m_state != STATE.running) + throw new InvalidOperationException("Must be in running state to send invite: " + m_state.ToString()); + + if (invitee == null) + throw new ArgumentNullException("invitee"); +/* + + + + + Hey Hecate, this is the place for all good witches! + + + + + */ + Message m = new Message(m_manager.Stream.Document); + m.To = m_room; + UserX x = new UserX(m_manager.Stream.Document); + x.AddInvite(invitee, reason); + m.AddChild(x); + m_manager.Write(m); + } + +#region Moderator use cases + /// + /// Change the role of a user in the room, by nickname. Must be a moderator. + /// + /// The nickname of the user to modify. + /// The new role + /// The reason for the change + public void ChangeRole(string nick, RoomRole role, string reason) + { + if (m_state != STATE.running) + throw new InvalidOperationException("Must be in running state to change role: " + m_state.ToString()); + + if (nick == null) + throw new ArgumentNullException("nick"); + if (role == RoomRole.UNSPECIFIED) + throw new ArgumentNullException("role"); +/* + + + + Avaunt, you cullion! + + + +*/ + RoomAdminIQ iq = new RoomAdminIQ(m_manager.Stream.Document); + iq.To = m_room; + iq.Type = IQType.set; + AdminQuery query = iq.Instruction; + AdminItem item = query.AddItem(); + item.Nick = nick; + item.Role = role; + item.Reason = reason; + m_manager.BeginIQ(iq, null, null); + } + + /// + /// Kick the given user from the room, based on their nickname. + /// + /// The nickname of the person to kick + /// The reason for kicking, or null for none. + public void Kick(string nick, string reason) + { + ChangeRole(nick, RoomRole.none, reason); + } + + /// + /// Disallow a user from speaking; remove their "voice". + /// + /// The nickname of the person to mute + /// The reason for the muting + public void RevokeVoice(string nick, string reason) + { + ChangeRole(nick, RoomRole.visitor, reason); + } + + /// + /// Un-mute a muted user. Give them "voice". + /// + /// The nicname of the person to unmute + /// The reason for the change + public void GrantVoice(string nick, string reason) + { + ChangeRole(nick, RoomRole.participant, reason); + } + + private class RetrieveParticipantsState + { + public RoomParticipantsEvent Callback; + public object State; + + public RetrieveParticipantsState(RoomParticipantsEvent callback, object state) + { + this.Callback = callback; + this.State = state; + } + } + + /// + /// Retrieve all of the parties with a given role. + /// Modify the affiliations of persons in this list, then call ModifyRoles + /// + /// The role to search for + /// A callback to receive the participant list + /// Caller state information + public void RetrieveListByRole(RoomRole role, RoomParticipantsEvent callback, object state) + { + if (callback == null) + throw new ArgumentNullException("callback"); +/* + + + + + +*/ + RoomAdminIQ iq = new RoomAdminIQ(m_manager.Stream.Document); + iq.To = m_room; + AdminQuery query = iq.Instruction; + query.AddItem().Role = role; + m_manager.BeginIQ(iq, new IqCB(GotList), new RetrieveParticipantsState(callback, state)); + } + + private void GotList(object sender, IQ iq, object state) + { + RetrieveParticipantsState rps = (RetrieveParticipantsState)state; + if (iq.Type == IQType.error) + { + rps.Callback(this, null, rps.State); + return; + } +/* + + + + Treason + + + +*/ + ParticipantCollection parties = new ParticipantCollection(); + AdminQuery query = (AdminQuery)iq.Query; + ParticipantCollection.Modification mod; + foreach (AdminItem item in query.GetItems()) + { + Presence pres = new Presence(m_manager.Stream.Document); + pres.From = new JID(m_jid.User, m_jid.Server, item.Nick); + UserX x = new UserX(m_manager.Stream.Document); + RoomItem xi = x.RoomItem; + xi.Role = item.Role; + xi.Affiliation = item.Affiliation; + xi.Nick = item.Nick; + xi.JID = item.JID; + pres.AppendChild(x); + parties.Modify(pres, out mod); + } + rps.Callback(this, parties, rps.State); + } + + /// + /// Modify the roles of the parties in this list. + /// To use, retrive a ParticipantCollection, change the roles + /// of the parties in that collection, then pass that modified + /// collection in here. + /// + /// The modified participant collection + /// The reason for the change + /// A callback to call when complete. Will have a null IQ if there were no changes to make. + /// Caller's state information + public void ModifyRoles(ParticipantCollection parties, string reason, IqCB callback, object state) + { +/* + + + + + A worthy fellow. + + + A worthy fellow. + + + +*/ + RoomAdminIQ iq = new RoomAdminIQ(m_manager.Stream.Document); + iq.To = m_room; + iq.Type = IQType.set; + AdminQuery query = iq.Instruction; + + int count = 0; + foreach (RoomParticipant party in parties) + { + if (party.Changed) + { + count++; + AdminItem item = query.AddItem(); + item.Nick = party.Nick; + item.Role = party.Role; + item.Reason = reason; + } + } + if (count > 0) + m_manager.BeginIQ(iq, callback, state); + else + callback(this, null, state); + } + +#endregion + +#region Admin use cases + /// + /// Change the affiliation (long-term) with the room of a user, based on their real JID. + /// + /// The bare JID of the user of which to change the affiliation + /// The new affiliation + /// The reason for the change + public void ChangeAffiliation(JID jid, RoomAffiliation affiliation, string reason) + { + if (m_state != STATE.running) + throw new InvalidOperationException("Must be in running state to change affiliation: " + m_state.ToString()); + if (jid == null) + throw new ArgumentNullException("jid"); + if (affiliation == RoomAffiliation.UNSPECIFIED) + throw new ArgumentNullException("affiliation"); +/* + + + + Treason + + + + */ + RoomAdminIQ iq = new RoomAdminIQ(m_manager.Stream.Document); + iq.To = m_room; + iq.Type = IQType.set; + AdminQuery query = iq.Instruction; + AdminItem item = query.AddItem(); + item.JID = jid; + item.Affiliation = affiliation; + item.Reason = reason; + m_manager.BeginIQ(iq, null, null); + } + + /// + /// Ban a user from re-joining the room. Must be an admin. + /// + /// The bare JID of the user to ban + /// The reason for the shunning + public void Ban(JID jid, string reason) + { + ChangeAffiliation(jid, RoomAffiliation.outcast, reason); + } + + /// + /// Make this user a member of the room. + /// + /// The bare jid of the user to grant membership to. + /// + public void GrantMembership(JID jid, string reason) + { + ChangeAffiliation(jid, RoomAffiliation.member, reason); + } + + /// + /// Remove the membership privileges of the given user + /// + /// The bare jid of the user to revoke the membership of. + /// + public void RevokeMembership(JID jid, string reason) + { + // Or "Dismember". + ChangeAffiliation(jid, RoomAffiliation.none, reason); + } + + /// + /// Make this user a moderator of the room. + /// + /// The nickname of the user to change + public void MakeModerator(string nick) + { + ChangeRole(nick, RoomRole.moderator, null); + } + + /// + /// Retrieve all of the parties with a given affiliiation. + /// Modify the affiliations of persons in this list, then call ModifyAffiliations + /// + /// The affiliation to search for + /// A callback to receive the participant list + /// Caller state information + public void RetrieveListByAffiliation(RoomAffiliation affiliation, RoomParticipantsEvent callback, object state) + { + if (callback == null) + throw new ArgumentNullException("callback"); +/* + + + + + +*/ + RoomAdminIQ iq = new RoomAdminIQ(m_manager.Stream.Document); + iq.To = m_room; + AdminQuery query = iq.Instruction; + query.AddItem().Affiliation = affiliation; + m_manager.BeginIQ(iq, new IqCB(GotList), new RetrieveParticipantsState(callback, state)); + } + + /// + /// Modify the roles of the parties in this list. + /// To use, retrive a ParticipantCollection, change the roles + /// of the parties in that collection, then pass that modified + /// collection in here. + /// + /// The modified participant collection + /// The reason for the change + /// A callback to call when complete. Will have a null IQ if there were no changes to make. + /// Caller's state information + public void ModifyAffiliations(ParticipantCollection parties, string reason, IqCB callback, object state) + { +/* + + + + Treason + + + +*/ + RoomAdminIQ iq = new RoomAdminIQ(m_manager.Stream.Document); + iq.To = m_room; + iq.Type = IQType.set; + AdminQuery query = iq.Instruction; + + int count = 0; + foreach (RoomParticipant party in parties) + { + if (party.Changed && (party.RealJID != null)) + { + count++; + AdminItem item = query.AddItem(); + item.JID = party.RealJID; + item.Affiliation = party.Affiliation; + item.Reason = reason; + } + } + if (count > 0) + m_manager.BeginIQ(iq, callback, state); + else + callback(this, null, state); + } +#endregion + } + + /// + /// A list of all of the current participants. + /// + [SVN(@"$Id$")] + public class ParticipantCollection : IEnumerable + { + private Hashtable m_hash = new Hashtable(); + + internal enum Modification + { + NONE = -1, + JOIN, + LEAVE + } + + /// + /// Get a participant by their room@service/nick JID. + /// + /// room@service/nick + /// Participant object + public RoomParticipant this[JID nickJid] + { + get + { + return (RoomParticipant)m_hash[nickJid]; + } + } + + /// + /// Add a participant to the list, indexed by full nick JID. + /// + /// The latest presence + /// Was this a JOIN, a LEAVE, or no change? + /// The associated participant. + internal RoomParticipant Modify(Presence pres, out Modification mod) + { + JID from = pres.From; + mod = Modification.NONE; + RoomParticipant party = (RoomParticipant)m_hash[from]; + if (party != null) + { + party.Presence = pres; + if (pres.Type == PresenceType.unavailable) + { + m_hash.Remove(from); + mod = Modification.LEAVE; + } + } + else + { + party = new RoomParticipant(pres); + // XCP will send unavails from registered users that + // are not currently online. + if (pres.Type != PresenceType.unavailable) + { + m_hash[from] = party; + mod = Modification.JOIN; + } + } + return party; + } + + /// + /// Get all of the participants that are in a given room role. + /// + /// The role to search for + /// + public RoomParticipant[] GetParticipantsByRole(RoomRole role) + { + ArrayList res = new ArrayList(m_hash.Count); + foreach (RoomParticipant party in m_hash.Values) + { + if (party.Role == role) + res.Add(party); + } + return (RoomParticipant[])res.ToArray(typeof(RoomParticipant)); + } + + /// + /// Get all of the participants that are in a given room affiliation. + /// + /// The role to search for + /// + public RoomParticipant[] GetParticipantsByAffiliation(RoomAffiliation affiliation) + { + ArrayList res = new ArrayList(m_hash.Count); + foreach (RoomParticipant party in m_hash.Values) + { + if (party.Affiliation == affiliation) + res.Add(party); + } + return (RoomParticipant[])res.ToArray(typeof(RoomParticipant)); + } + + #region IEnumerable Members + /// + /// Enumerate over all of the participants + /// + /// + public IEnumerator GetEnumerator() + { + return m_hash.Values.GetEnumerator(); + } + + #endregion + } + + /// + /// Someone who is currently in or associated with a room. + /// + [SVN(@"$Id$")] + public class RoomParticipant + { + private Presence m_presence; + private bool m_changed = false; + + /// + /// Create a participant from the last presence received for that user. + /// + /// + public RoomParticipant(Presence pres) + { + if (pres == null) + throw new ArgumentNullException("Presence must nut be null", "pres"); + m_presence = pres; + } + + /// + /// Last presence received for this user. + /// + public Presence Presence + { + get { return m_presence; } + set + { + m_presence = value; + m_changed = false; + } + } + + /// + /// Has this participant's role or affiliation been changed? + /// + public bool Changed + { + get { return m_changed; } + } + + /// + /// The muc#user item in the presence. + /// + protected RoomItem Item + { + get + { + UserX x = (UserX)m_presence["x", URI.MUC_USER]; + if (x == null) + return null; + return x.RoomItem; + } + } + + /// + /// Nickname of the user + /// + public string Nick + { + get { return m_presence.From.Resource; } + } + + /// + /// Affiliation of the user. + /// + public RoomAffiliation Affiliation + { + get + { + RoomItem item = Item; + if (item == null) + return RoomAffiliation.UNSPECIFIED; + return item.Affiliation; + } + set + { + RoomItem item = Item; + if (item == null) + return; + if (item.Affiliation != value) + { + item.Affiliation = value; + m_changed = true; + } + } + } + + /// + /// Role of the user. + /// + public RoomRole Role + { + get + { + RoomItem item = Item; + if (item == null) + return RoomRole.UNSPECIFIED; + return item.Role; + } + set + { + RoomItem item = Item; + if (item == null) + return; + if (item.Role != value) + { + item.Role = value; + m_changed = true; + } + } + } + + /// + /// room@server/nick of the user. + /// + public JID NickJID + { + get { return m_presence.From; } + } + + /// + /// The real JID of the user, if this is a non-anonymous room. + /// + public JID RealJID + { + get + { +/* + + + + + + */ + RoomItem item = Item; + if (item == null) + return null; + return item.JID; + } + } + + /// + /// The nick JID or nick (real). + /// + /// + public override string ToString() + { + JID nick = NickJID; + JID real = RealJID; + if (real != null) + return string.Format("{0} ({1})", nick, real); + return nick; + } + } +} Binary files /tmp/l3kVLF4iNE/smuxi-0.8/lib/jabber-net/jabber/connection/DiscoManager.bmp and /tmp/jEQ8aotOZY/smuxi-0.8.9.1/lib/jabber-net/jabber/connection/DiscoManager.bmp differ diff -Nru smuxi-0.8/lib/jabber-net/jabber/connection/DiscoManager.cs smuxi-0.8.9.1/lib/jabber-net/jabber/connection/DiscoManager.cs --- smuxi-0.8/lib/jabber-net/jabber/connection/DiscoManager.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/jabber-net/jabber/connection/DiscoManager.cs 2012-01-03 07:52:11.000000000 +0000 @@ -0,0 +1,1332 @@ +/* -------------------------------------------------------------------------- + * Copyrights + * + * Portions created by or assigned to Cursive Systems, Inc. are + * Copyright (c) 2002-2008 Cursive Systems, Inc. All Rights Reserved. Contact + * information for Cursive Systems, Inc. is available at + * http://www.cursive.net/. + * + * License + * + * Jabber-Net is licensed under the LGPL. + * See LICENSE.txt for details. + * --------------------------------------------------------------------------*/ +using System; + +using System.ComponentModel; +using System.ComponentModel.Design; +using System.Collections; +using System.Diagnostics; +using System.Xml; +using System.Threading; + +using bedrock.util; +using bedrock.collections; + +using jabber.protocol; +using jabber.protocol.client; +using jabber.protocol.iq; + +namespace jabber.connection +{ + /// + /// Manages a service discovery (disco) identity. See XEP-0030 for more information. + /// + [SVN(@"$Id$")] + public class Ident : IComparable + { + private string m_name; + private string m_category; + private string m_type; + private string m_lang; + + /// + /// Create a new identity from its constituent parts. + /// + /// + /// + /// + /// + public Ident(string name, string category, string type, string lang) + { + m_category = (category == null) ? "" : category; + m_name = (name == null) ? "" : name; + m_type = (type == null) ? "" : type; + m_lang = (lang == null) ? "" : lang; + } + + /// + /// Create a new, empty identity + /// + public Ident() : this("", "", "", "") + { + } + + /// + /// Create an identity from protocol + /// + /// + public Ident(DiscoIdentity id) : this(id.Named, id.Category, id.Type, id.Lang) + { + } + + /// + /// Retrieves the string representation of the Ident (category/type/lang/name). + /// + /// + [Category("Capabilities")] + public string Key + { + get + { + return string.Format("{0}/{1}/{2}/{3}", m_category, m_type, m_lang, m_name); + } + } + + /// + /// Contains the description of the entity. + /// + [Category("Text")] + public string Name + { + get { return m_name; } + set { m_name = value; } + } + + /// + /// Contains the capabilities category, such as server, + /// client, gateway, directory and so on. + /// + [Category("Identity")] + public string Category + { + get { return m_category; } + set { m_category = value; } + } + + /// + /// Contains the entity type. + /// + [Category("Identity")] + public string Type + { + get { return m_type; } + set { m_type = value; } + } + + /// + /// xml:lang language of this identity + /// + [Category("Text")] + public string Lang + { + get { return m_lang; } + set { m_lang = value; } + } + + /// + /// Does this identity have the given category and type? + /// + /// The category to compare + /// The type to compare + /// + public bool Matches(string category, string type) + { + return (m_category == category) && (m_type == type); + } + + #region IComparable Members + /// + /// Compare to another identity, by comparing the string-ified versions + /// of each. + /// + /// + /// + public int CompareTo(object obj) + { + if ((object)this == obj) + return 0; + Ident other = obj as Ident; + if (other == null) + return 1; + return Key.CompareTo(other.Key); + } + #endregion + + /// + /// Is this identity equal to that one? If two are the same except for + /// language, they are different by this method. + /// + /// + /// + public override bool Equals(object obj) + { + return (this.CompareTo(obj) == 0); + } + + /// + /// Hash over the string version of the identity. + /// + /// + public override int GetHashCode() + { + return Key.GetHashCode(); + } + + /// + /// A slash-separated version of the name, with the unset parts omitted. + /// + /// + public override string ToString() + { + System.Text.StringBuilder sb = new System.Text.StringBuilder(); + sb.Append(m_category); + sb.Append("/"); + sb.Append(m_type); + + if ((m_lang != null) && (m_lang != "")) + { + sb.Append("/"); + sb.Append(m_lang); + } + + if ((m_name != null) && (m_name != "")) + { + sb.Append("/"); + sb.Append(m_name); + } + + return sb.ToString(); ; + } + } + + /// + /// Manages a JID and Node combination. + /// + [SVN(@"$Id$")] + public class JIDNode + { + private JID m_jid = null; + private string m_node = null; + + /// + /// Creates a new JID/Node combination. + /// + /// JID to associate with JIDNode. + /// Node to associate with JIDNode. + public JIDNode(JID jid, string node) + { + this.m_jid = jid; + if ((node != null) && (node != "")) + this.m_node = node; + } + + /// + /// Gets the JID. + /// + [Category("Identity")] + public JID JID + { + get { return m_jid; } + set { m_jid = value; } + } + + /// + /// Gets the Node. + /// + [Category("Identity")] + public string Node + { + get { return m_node; } + set { m_node = value; } + } + + /// + /// Retrieves a hash key that combines the JID and the node. + /// + /// JID to use in the hash code. + /// Node to use in the hash code. + /// The hash code. + internal static string GetKey(string jid, string node) + { + if ((node == null) || (node == "")) + { + if (jid == null) + return null; + return jid.ToString(); + } + return jid + '\u0000' + node; + } + + /// + /// Gets the JID/Node key for Hash lookup. + /// + [Browsable(false)] + public string Key + { + get { return GetKey(m_jid, m_node); } + } + + /// + /// Determines if both the jid and the node are equal. + /// + /// JIDNode to compare to. + /// True if both the jid and the node are equal. + public override bool Equals(object obj) + { + JIDNode other = obj as JIDNode; + if (other == null) + { + return false; + } + + return (m_jid == other.m_jid) && (m_node == other.m_node); + } + + /// + /// Serves as a hash function to combine the JID and node together. + /// GetHashCode() is suitable for use in hashing algorithms and + /// data structures like a hash table. + /// + /// The hash code of this JIDNode. + public override int GetHashCode() + { + int code = 0; + if (m_jid != null) + code = m_jid.GetHashCode(); + if (m_node != null) + code ^= m_node.GetHashCode(); + return code; + } + + /// + /// Returns a string representing the JID/Node. + /// + /// String representing the JID/Node. + public override string ToString() + { + return JID + "/" + Node; + } + } + + + /// + /// Manages the information and children of a given JID/Node combination. + /// + /// NOTE: If you have multiple connections in the same process, they all share the same Disco cache. + /// + [SVN(@"$Id$")] + public class DiscoNode : JIDNode, IEnumerable + { + /// + /// Contains the children of this node. + /// + public Set Children = null; + /// + /// Contains the Features of this node. + /// + public StringSet Features = null; + /// + /// Contains the identities of this node. + /// + public Set Identity = null; + private string m_name = null; + private bool m_pendingItems = false; + private bool m_pendingInfo = false; + private jabber.protocol.x.Data[] m_extensions; + private DiscoInfo m_info = null; + + private ArrayList m_featureCallbacks = new ArrayList(); + private ArrayList m_itemCallbacks = new ArrayList(); + private ArrayList m_identCallbacks = new ArrayList(); + + /// + /// Creates a disco node. + /// + /// JID associated with this JIDNode. + /// node associated with this JIDNode. + public DiscoNode(JID jid, string node) + : base(jid, node) + { + } + + private class NodeCallback + { + public DiscoManager manager; + public DiscoNodeHandler callback; + public object state; + + public NodeCallback(DiscoManager m, DiscoNodeHandler h, object s) + { + manager = m; + callback = h; + state = s; + } + + public void Call(DiscoNode node) + { + if (callback != null) + callback(manager, node, state); + } + } + + /// + /// Add a callback for when features are received. + /// + /// Calls the callback immediately if the features have already been retrieved. + /// + /// + /// + /// + /// True if there were no features yet, and the callback was queued. + public bool AddFeatureCallback(DiscoManager manager, DiscoNodeHandler callback, object state) + { + lock (this) + { + if (Features != null) + { + if (callback != null) + callback(manager, this, state); + return false; + } + else + { + if (callback != null) + m_featureCallbacks.Add(new NodeCallback(manager, callback, state)); + return true; + } + } + } + + /// + /// Add a callback for when items are received. + /// + /// Calls the callback immediately if the items have already been retrieved. + /// + /// + /// + /// + /// True if there were no items yet, and the callback was queued. + public bool AddItemsCallback(DiscoManager manager, DiscoNodeHandler callback, object state) + { + lock (this) + { + if (Children != null) + { + if (callback != null) + callback(manager, this, state); + return false; + } + else + { + if (callback != null) + m_itemCallbacks.Add(new NodeCallback(manager, callback, state)); + return true; + } + } + } + + /// + /// Add a callback for when identities are received. + /// + /// Calls the callback immediately if the features have already been retrieved. + /// + /// + /// + /// + /// True if there were no identities yet, and the callback was queued. + public bool AddIdentityCallback(DiscoManager manager, DiscoNodeHandler callback, object state) + { + lock (this) + { + if (Identities != null) + { + if (callback != null) + callback(manager, this, state); + return false; + } + else + { + m_identCallbacks.Add(new NodeCallback(manager, callback, state)); + return true; + } + } + } + + /// + /// Gets or sets the string representation of the first identity. + /// + [Category("Info")] + public string Name + { + set { m_name = value; } + get + { + if (m_name != null) + return m_name; + if (Identity != null) + { + foreach (Ident id in Identity) + { + if ((id.Name != null) && (id.Name != "")) + m_name = id.Name; + } + return m_name; + } + string n = JID; + if (Node != null) + n += "/" + Node; + return n; + } + } + + /// + /// Determines whether or not the disco#info packet has been sent. + /// + [Category("Status")] + public bool PendingInfo + { + get { return m_pendingInfo; } + } + + /// + /// Determines whether or not the disco#items packet has been sent. + /// + [Category("Status")] + public bool PendingItems + { + get { return m_pendingItems; } + } + + /// + /// Retrieves the features associated with this node. + /// + [Category("Info")] + public string[] FeatureNames + { + get + { + if (Features == null) + return new string[0]; + return Features.GetStrings(); + } + } + + /// + /// Retrieves the disco identities of the node. + /// + [Category("Info")] + public string[] Identities + { + get + { + if (Identity == null) + return new string[0]; + string[] names = new string[Identity.Count]; + int count = 0; + foreach (Ident i in Identity) + { + names[count++] = i.Key; + } + return names; + } + } + + /// + /// Retrieves an identity object for each identity of the node. + /// + /// List of identities associated with this node. + public Ident[] GetIdentities() + { + if (Identity == null) + return new Ident[0]; + + Ident[] ret = new Ident[Identity.Count]; + int count = 0; + foreach (Ident i in Identity) + { + ret[count++] = i; + } + return ret; + } + + /// + /// Determines whether or not this node has the given category and type among its identities. + /// + /// Category to look for. + /// Type to look for. + /// The node contains the category and the type if true. + public bool HasIdentity(string category, string type) + { + if (Identity == null) + return false; + foreach (Ident i in Identity) + { + if (i.Matches(category, type)) + return true; + } + return false; + } + + /// + /// Gets or sets the x:data extensions of the disco information. + /// + public jabber.protocol.x.Data[] Extensions + { + get + { + return m_extensions; + } + set + { + m_extensions = value; + } + } + + /// + /// This last info result returned for this JID and node. + /// + public DiscoInfo Info + { + get { return m_info; } + } + + /// + /// Determines if this node has the specified feature. + /// + /// Feature to look for. + /// The node has this feature if true. + public bool HasFeature(string URI) + { + if (Features == null) + return false; + return Features.Contains(URI); + } + + private void DoCallbacks(ArrayList callbacks) + { + lock (this) + { + foreach (NodeCallback cb in callbacks) + cb.Call(this); + callbacks.Clear(); + } + } + + /// + /// Pulls all of the data out of the given protocol response. + /// + /// If null, just calls callbacks + public void AddInfo(DiscoInfo info) + { + m_info = info; + if (info == null) + { + AddIdentities(null); + AddFeatures((StringSet)null); + return; + } + Extensions = info.GetExtensions(); + AddIdentities(info.GetIdentities()); + AddFeatures(info.FeatureSet); + } + + /// + /// Add a single feature to the node. + /// Does not fire OnFeatures, since this should mostly be used by + /// things that are not querying externally. + /// + /// The feature URI to add + public void AddFeature(string feature) + { + if (Features == null) + Features = new StringSet(); + + Features.Add(feature); + } + + /// + /// Remove a single feature from the node. + /// Does not fire OnFeatures, since this should mostly be used by + /// things that are not querying externally. + /// + /// No exception should be thrown if the feature doesn't exist. + /// + /// The feature URI to remove + public void RemoveFeature(string feature) + { + if (Features == null) + return; + Features.Remove(feature); + } + + /// + /// Adds these features to the node. Calls the OnFeatures event. + /// + /// Features to add to this node. + [Obsolete("Use AddFeatures(StringSet)")] + public void AddFeatures(DiscoFeature[] features) + { + if (Features == null) + Features = new StringSet(); + + // features may be null when used from outside. + if (features != null) + { + foreach (DiscoFeature f in features) + Features.Add(f.Var); + } + + DoCallbacks(m_featureCallbacks); + } + + /// + /// Add all of the features from the specified set. + /// + /// + public void AddFeatures(StringSet features) + { + if (features != null) + { + if (Features == null) + Features = new StringSet(features); + else + Features.Add(features); + } + DoCallbacks(m_featureCallbacks); + } + + /// + /// Clear out any features already in the list. + /// + public void ClearFeatures() + { + Features = null; + } + + /// + /// Adds these identities to the node. + /// + /// Identities to add. + public void AddIdentity(Ident id) + { + if (Identity == null) + Identity = new Set(); + Identity.Add(id); + } + + /// + /// Add these identities to the node. + /// Fires OnIdentities + /// + /// Identities to add. + public void AddIdentities(DiscoIdentity[] ids) + { + if (Identity == null) + Identity = new Set(); + + // ids may be null when used from outside. + if (ids != null) + { + foreach (DiscoIdentity id in ids) + Identity.Add(new Ident(id)); + } + + DoCallbacks(m_identCallbacks); + } + + /// + /// Clear out any identities already in the list. + /// + public void ClearIdentity() + { + Identity = null; + } + + internal DiscoNode AddItem(DiscoManager manager, DiscoItem di) + { + DiscoNode dn = manager.GetNode(di.Jid, di.Node); + if ((di.Named != null) && (di.Named != "")) + dn.Name = di.Named; + Children.Add(dn); + return dn; + } + + /// + /// Adds the given items to the cache. + /// + /// The DiscoManager used to create/cache nodes + /// Items to add. + public void AddItems(DiscoManager manager, DiscoItem[] items) + { + if (Children == null) + Children = new Set(); + + // items may be null when used from outside. + if (items != null) + { + foreach (DiscoItem di in items) + AddItem(manager, di); + } + + DoCallbacks(m_itemCallbacks); + } + + /// + /// Creates a disco#info IQ packet. + /// + /// XmlDocument to create the XML elements with. + /// XML representing the disco#info request. + public IQ InfoIQ(System.Xml.XmlDocument doc) + { + m_pendingInfo = true; + DiscoInfoIQ iiq = new DiscoInfoIQ(doc); + iiq.To = JID; + iiq.Type = IQType.get; + if (Node != null) + { + DiscoInfo info = iiq.Instruction; + info.Node = Node; + } + + return iiq; + } + + /// + /// Creates a disco#items IQ packet. + /// + /// XmlDocument used to create the XML Elements. + /// XML element representing the disco#items request. + public IQ ItemsIQ(System.Xml.XmlDocument doc) + { + m_pendingItems = true; + + DiscoItemsIQ iiq = new DiscoItemsIQ(doc); + iiq.To = JID; + iiq.Type = IQType.get; + if (Node != null) + { + DiscoItems items = iiq.Instruction; + items.Node = Node; + } + return iiq; + } + + #region IEnumerable Members + /// + /// Gets an enumerator across all items. + /// + /// Set enumerator to loop over. + public IEnumerator GetEnumerator() + { + return Children.GetEnumerator(); + } + #endregion + } + + /// + /// Represents a callback with a new disco node. + /// + /// The DiscoManager managing this node + /// The node that changed + /// State passed in to the Begin request. + public delegate void DiscoNodeHandler(DiscoManager sender, DiscoNode node, object state); + + /// + /// Manages the discovery (disco) database. + /// + // TODO: once etags are finished, make all of this information cached on disk. + // TODO: cache XEP-115 client caps data to disk + // TODO: add negative caching + [SVN(@"$Id$")] + public class DiscoManager : StreamComponent, IEnumerable + { + /// + /// Required designer variable. + /// +#pragma warning disable 0414 + private System.ComponentModel.Container components = null; +#pragma warning restore 0414 + private DiscoNode m_root = null; + private Tree m_items = new Tree(); + + /// + /// Creates a new DiscoManager and associates it with a parent container. + /// + /// Parent container. + public DiscoManager(System.ComponentModel.IContainer container) : this() + { + container.Add(this); + } + + /// + /// Creates a new DiscoManager. + /// + public DiscoManager() + { + InitializeComponent(); + this.OnStreamChanged +=new bedrock.ObjectHandler(DiscoManager_OnStreamChanged); + } + + + /// + /// Gets the root node. This is probably the server that the client is + /// connected to. If the Children property of this root node is null, + /// the disco#items request has not returned an answer. Register on this + /// node's OnFeatures callback. + /// + public DiscoNode Root + { + get + { + if (m_root != null) + return m_root; + if (m_stream == null) + return null; + // GetNode locks. + m_root = GetNode(m_stream.Server); + return m_root; + } + } + + /// + /// Creates nodes and ensure that they are cached. + /// + /// JID associated with DiscoNode. + /// Node associated with DiscoNode. + /// + /// If DiscoNode exists, returns the found node. + /// Otherwise it creates the node and return it. + /// + public DiscoNode GetNode(JID jid, string node) + { + lock (m_items) + { + string key = DiscoNode.GetKey(jid, node); + DiscoNode n = (DiscoNode)m_items[key]; + if (n == null) + { + n = new DiscoNode(jid, node); + m_items.Add(key, n); + } + return n; + } + } + + /// + /// Creates nodes where only the JID is specified. + /// + /// JID associated with DiscoNode. + /// + /// If DiscoNode exists, returns the found node. + /// Otherwise it creates the node and return it. + /// + public DiscoNode GetNode(JID jid) + { + return GetNode(jid, null); + } + + /// + /// Deletes the cache. + /// + public void Clear() + { + lock (m_items) + { + m_root = null; + m_items.Clear(); + } + } + + /// + /// Gets all of the cached nodes. + /// + /// Tree enumerator to loop over. + IEnumerator IEnumerable.GetEnumerator() + { + return m_items.GetEnumerator(); + } + + private void DiscoManager_OnStreamChanged(object sender) + { + if (m_stream == null) + return; + m_stream.OnAuthenticate += new bedrock.ObjectHandler(m_client_OnAuthenticate); + m_stream.OnDisconnect += new bedrock.ObjectHandler(m_stream_OnDisconnect); + m_stream.OnError += new bedrock.ExceptionHandler(m_stream_OnError); + } + + private void m_client_OnAuthenticate(object sender) + { + RequestInfo(Root); + } + + private void m_stream_OnDisconnect(object sender) + { + Clear(); + } + + private void m_stream_OnError(object sender, Exception ex) + { + Clear(); + } + + + private void RequestInfo(DiscoNode node) + { + lock (node) + { + if (!node.PendingInfo) + { + IQ iq = node.InfoIQ(m_stream.Document); + jabber.server.JabberService js = m_stream as jabber.server.JabberService; + if (js != null) + iq.From = js.ComponentID; + BeginIQ(iq, new jabber.connection.IqCB(GotInfo), node); + } + } + } + + private void RequestItems(DiscoNode node) + { + lock (node) + { + if (!node.PendingItems) + { + IQ iq = node.ItemsIQ(m_stream.Document); + jabber.server.JabberService js = m_stream as jabber.server.JabberService; + if (js != null) + iq.From = js.ComponentID; + BeginIQ(iq, new jabber.connection.IqCB(GotItems), node); + } + } + } + + + private void GotInfo(object sender, IQ iq, object onode) + { + DiscoNode dn = onode as DiscoNode; + Debug.Assert(dn != null); + + if (iq.Type == IQType.error) + { + if (dn == m_root) + { + // root node. + // Try agents. + Error err = iq.Error; + if (err != null) + { + string cond = err.Condition; + if ((cond == Error.FEATURE_NOT_IMPLEMENTED) || + (cond == Error.SERVICE_UNAVAILABLE)) + { + IQ aiq = new AgentsIQ(m_stream.Document); + BeginIQ(aiq, new jabber.connection.IqCB(GotAgents), m_root); + return; + } + } + } + } + if (iq.Type != IQType.result) + { + // protocol error + dn.AddInfo(null); + return; + } + + dn.AddInfo(iq.Query as DiscoInfo); + + if (dn == m_root) + RequestItems(m_root); + } + + private void GotItems(object sender, IQ iq, object onode) + { + DiscoNode dn = onode as DiscoNode; + Debug.Assert(dn != null); + + if (iq.Type != IQType.result) + { + // protocol error + dn.AddItems(this, null); + return; + } + + DiscoItems items = iq.Query as DiscoItems; + if (items == null) + { + // protocol error + dn.AddItems(this, null); + return; + } + + dn.AddItems(this, items.GetItems()); + + // automatically info everything we get an item for. + foreach (DiscoNode n in dn.Children) + { + if (n.Features == null) + { + RequestInfo(n); + } + } + } + + private void GotAgents(object sender, IQ iq, object onode) + { + DiscoNode dn = onode as DiscoNode; + Debug.Assert(dn != null); + + if (iq.Type != IQType.result) + { + dn.AddItems(this, null); + return; + } + + AgentsQuery aq = iq.Query as AgentsQuery; + if (aq == null) + { + dn.AddItems(this, null); + return; + } + + if (dn.Children == null) + dn.Children = new Set(); + + foreach (Agent agent in aq.GetAgents()) + { + DiscoItem di = new DiscoItem(m_stream.Document); + di.Jid = agent.JID; + di.Named = agent.AgentName; + + DiscoNode child = dn.AddItem(this, di); + if (child.Features == null) + child.Features = new StringSet(); + if (child.Identity == null) + child.Identity = new Set(); + + Ident id = new Ident(); + id.Name = agent.Description; + switch (agent.Service) + { + case "groupchat": + id.Category = "conference"; + id.Type = "text"; + child.Identity.Add(id); + break; + case "jud": + id.Category = "directory"; + id.Type = "user"; + child.Identity.Add(id); + break; + case null: + case "": + break; + default: + // guess this is a transport + id.Category = "gateway"; + id.Type = agent.Service; + child.Identity.Add(id); + break; + } + + if (agent.Register) + child.Features.Add(URI.REGISTER); + if (agent.Search) + child.Features.Add(URI.SEARCH); + if (agent.Groupchat) + child.Features.Add(URI.MUC); + if (agent.Transport) + { + if (id.Category != "gateway") + { + Ident tid = new Ident(); + tid.Name = id.Name; + tid.Category = "gateway"; + child.Identity.Add(tid); + } + } + + foreach (XmlElement ns in agent.GetElementsByTagName("ns")) + { + child.Features.Add(ns.InnerText); + } + child.AddItems(this, null); + child.AddIdentities(null); + child.AddFeatures((StringSet)null); + } + dn.AddItems(this, null); + dn.AddIdentities(null); + dn.AddFeatures((StringSet)null); + } + + /// + /// Retrieves the features associated with this node and + /// then calls back on the handler. + /// If the information is in the cache, handler gets called right now. + /// + /// Node to look for. + /// Callback to use afterwards. + /// Context to pass back to caller when complete + public void BeginGetFeatures(DiscoNode node, DiscoNodeHandler handler, object state) + { + if (node == null) + node = Root; + + if (node.AddFeatureCallback(this, handler, state)) + RequestInfo(node); + } + + /// + /// Retrieves the features associated with this node and + /// then calls back on the handler. + /// + /// If caching is specified, items already in the cache call the handler + /// immediately. + /// + /// JID to look for. + /// Node to look for. + /// Callback to use afterwards. + /// Context to pass back to caller when complete + /// Should caching be performed on this request? + public void BeginGetFeatures(JID jid, string node, DiscoNodeHandler handler, object state, bool cache) + { + DiscoNode dn = cache ? GetNode(jid, node) : new DiscoNode(jid, node); + BeginGetFeatures(dn, handler, state); + } + + /// + /// Retrieves the features associated with this JID and node and + /// then calls back on the handler. + /// If the information is in the cache, handler gets called right now. + /// + /// JID to look for. + /// Node to look for. + /// Callback to use afterwards. + /// Context to pass back to caller when complete + public void BeginGetFeatures(JID jid, string node, DiscoNodeHandler handler, object state) + { + BeginGetFeatures(GetNode(jid, node), handler, state); + } + + /// + /// Retrieves the child items associated with this node, + /// and then calls back on the handler. + /// If the information is in the cache, handler gets + /// called right now. + /// + /// Disco node to search. + /// Callback that gets called with the items. + /// Context to pass back to caller when complete + public void BeginGetItems(DiscoNode node, DiscoNodeHandler handler, object state) + { + if (node == null) + node = Root; + + if (node.AddItemsCallback(this, handler, state)) + RequestItems(node); + } + + /// + /// Retrieves the child items associated with this node, + /// and then calls back on the handler. + /// + /// If caching is specified, items already in the cache call the handler + /// immediately. + /// + /// JID of Service to query. + /// Node on the service to interact with. + /// Callback that gets called with the items. + /// Context to pass back to caller when complete + /// Should caching be performed on this request? + public void BeginGetItems(JID jid, string node, DiscoNodeHandler handler, object state, bool cache) + { + DiscoNode dn = cache ? GetNode(jid, node) : new DiscoNode(jid, node); + BeginGetItems(dn, handler, state); + } + + /// + /// Retrieves the child items associated with this node and JID, + /// and then calls back on the handler. + /// If the information is in the cache, handler gets + /// called right now. + /// + /// JID of Service to query. + /// Node on the service to interact with. + /// Callback that gets called with the items. + /// Context to pass back to caller when complete + public void BeginGetItems(JID jid, string node, DiscoNodeHandler handler, object state) + { + BeginGetItems(GetNode(jid, node), handler, state); + } + + private class FindServiceRequest + { + private string m_URI; + private DiscoNodeHandler m_handler; + private int m_outstanding = 0; + + public FindServiceRequest(string featureURI, DiscoNodeHandler handler) + { + m_URI = featureURI; + m_handler = handler; + } + + public void GotFeatures(DiscoManager manager, DiscoNode node, object state) + { + + // yes, yes, this may call the handler more than once in multi-threaded world. Punt for now. + if (m_handler != null) + { + if (node.HasFeature(m_URI)) + { + m_handler(manager, node, state); + m_handler = null; + } + } + + if (Interlocked.Decrement(ref m_outstanding) == 0) + { + if (m_handler != null) + m_handler(manager, null, state); + } + } + + public void GotRootItems(DiscoManager manager, DiscoNode node, object state) + { + m_outstanding = node.Children.Count; + foreach (DiscoNode n in node.Children) + manager.BeginGetFeatures(n, new DiscoNodeHandler(GotFeatures), state); + } + } + + /// + /// Finds a component that implements a given feature, which is a child of + /// the root. This will call back on the first match. It will call back + /// with null if none are found. + /// + /// Feature to look for. + /// Callback to use when finished. + /// Context to pass back to caller when complete + public void BeginFindServiceWithFeature(string featureURI, DiscoNodeHandler handler, object state) + { + if (handler == null) + return; // prove I *didn't* call it. :) + + FindServiceRequest req = new FindServiceRequest(featureURI, handler); + BeginGetItems(Root, new DiscoNodeHandler(req.GotRootItems), state); // hopefully enough to prevent GC. + } + + #region Component Designer generated code + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + components = new System.ComponentModel.Container(); + } + #endregion + } +} diff -Nru smuxi-0.8/lib/jabber-net/jabber/connection/FileMap.cs smuxi-0.8.9.1/lib/jabber-net/jabber/connection/FileMap.cs --- smuxi-0.8/lib/jabber-net/jabber/connection/FileMap.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/jabber-net/jabber/connection/FileMap.cs 2012-01-03 07:52:11.000000000 +0000 @@ -0,0 +1,220 @@ +/* -------------------------------------------------------------------------- + * Copyrights + * + * Portions created by or assigned to Cursive Systems, Inc. are + * Copyright (c) 2002-2008 Cursive Systems, Inc. All Rights Reserved. Contact + * information for Cursive Systems, Inc. is available at + * http://www.cursive.net/. + * + * License + * + * Jabber-Net is licensed under the LGPL. + * See LICENSE.txt for details. + * --------------------------------------------------------------------------*/ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Diagnostics; +using System.Xml; + +using jabber.protocol; +using bedrock.util; + +namespace jabber.connection +{ + /// + /// A dictionary backed into a file. Any modification to the dictionary re-writes the file, so + /// writes are somewhat costly. Reads are cached lazily. + /// + [SVN(@"$Id$")] + public class FileMap + where T : Element + { + private const string NS = "http://cursive.net/xml/FileMap"; + + private string m_fileName = null; + private ElementFactory m_factory = null; + private Dictionary m_cache = null; + + /// + /// Create a file map. + /// + /// Valid file name, either absoulte, or relative + /// to the current working directory. + /// Element factory to create elements of a given type. If null, + /// Elements will always be created, and T MUST be Element. + public FileMap(string fileName, ElementFactory factory) + { + Factory = factory; + FileName = fileName; + } + + /// + /// The ElementFactory that determines the type of the elements being stored. + /// + public ElementFactory Factory + { + get { return m_factory; } + set + { + if (value == null) + { + if (!typeof(T).Equals(typeof(Element))) + throw new ArgumentException("Factory must not be null if type is not XmlElement", "factory"); + m_factory = new ElementFactory(); + } + else + m_factory = value; + } + } + + /// + /// The name of the file to manage. + /// + public string FileName + { + get { return m_fileName; } + set + { + if (value == null) + throw new ArgumentNullException("fileName"); + if (value == "") + throw new ArgumentOutOfRangeException("fileName"); + + lock (this) + { + if (value == null) + throw new ArgumentNullException("FileName"); + if (m_fileName == value) + return; + m_fileName = value; + Read(); + } + } + } + + private void Flush() + { + Debug.Assert(m_cache != null, "m_cache should be initialized in constructor"); + + XmlDocument doc = new XmlDocument(); + XmlElement fm = doc.CreateElement("fm", NS); + doc.AppendChild(fm); + + XmlElement val; + lock (this) + { + foreach (KeyValuePair kv in m_cache) + { + val = doc.CreateElement("val", NS); + val.SetAttribute("name", kv.Key); + if (kv.Value != null) + val.AppendChild(doc.ImportNode(kv.Value, true)); + fm.AppendChild(val); + } + } + XmlWriter xw = new XmlTextWriter(m_fileName, System.Text.Encoding.UTF8); + doc.WriteTo(xw); + xw.Close(); + } + + private void Read() + { + lock (this) + { + m_cache = new Dictionary(); + try + { + XmlDocument doc = new XmlDocument(); + doc.Load(m_fileName); + XmlElement fm = doc.DocumentElement; + foreach (XmlElement val in fm.GetElementsByTagName("val")) + { + string name = val.GetAttribute("name"); + if (name == "") + continue; + foreach (XmlNode child in val.ChildNodes) + { + if (child is XmlElement) + { + m_cache[name] = (T)Element.AddTypes((XmlElement)child, m_factory); + break; + } + } + } + } + catch (Exception ex) + { + Debug.WriteLine("WARNING: " + ex.ToString()); + } + } + } + + /// + /// Remove the specified key and value + /// + /// + /// + public bool Remove(string key) + { + bool ret = m_cache.Remove(key); + if (ret) + Flush(); + return ret; + } + + /// + /// Get or set the XmlElement associated with the given key. + /// If the key already has a value, it WILL NOT be overridden; you + /// MUST call Clear or Remove first. + /// + /// + /// + public T this[string key] + { + get + { + T val = null; + if (m_cache.TryGetValue(key, out val)) + return val; + return null; + } + set + { + if (m_cache.ContainsKey(key)) + return; + m_cache[key] = value; + Flush(); + } + } + + /// + /// How many key/value pairs are stored? + /// + public int Count + { + get { return m_cache.Count; } + } + + /// + /// Clear all stored keys/values. + /// + public void Clear() + { + if (Count == 0) + return; + m_cache.Clear(); + Flush(); + } + + /// + /// Is the given key in the map? + /// + /// + /// + public bool Contains(string key) + { + return m_cache.ContainsKey(key); + } + } +} diff -Nru smuxi-0.8/lib/jabber-net/jabber/connection/HttpStanzaStream.cs smuxi-0.8.9.1/lib/jabber-net/jabber/connection/HttpStanzaStream.cs --- smuxi-0.8/lib/jabber-net/jabber/connection/HttpStanzaStream.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/jabber-net/jabber/connection/HttpStanzaStream.cs 2012-01-03 07:52:11.000000000 +0000 @@ -0,0 +1,302 @@ +/* -------------------------------------------------------------------------- + * Copyrights + * + * Portions created by or assigned to Cursive Systems, Inc. are + * Copyright (c) 2002-2008 Cursive Systems, Inc. All Rights Reserved. Contact + * information for Cursive Systems, Inc. is available at + * http://www.cursive.net/. + * + * License + * + * Jabber-Net is licensed under the LGPL. + * See LICENSE.txt for details. + * --------------------------------------------------------------------------*/ + +using System; +using System.Diagnostics; +using System.Xml; +using bedrock.net; +using bedrock.util; +using jabber.protocol; + +namespace jabber.connection +{ + /// + /// Manages the HTTP Polling XMPP stream. + /// + [SVN(@"$Id$")] + public abstract class HttpStanzaStream : StanzaStream, ISocketEventListener + { + private AsynchElementStream m_elements = null; + private BaseSocket m_sock = null; + + /// + /// The underlying socket + /// + protected BaseSocket Socket + { + get { return m_sock; } + } + + /// + /// Create a new one. + /// + /// + internal HttpStanzaStream(IStanzaEventListener listener) + : base(listener) + { + } + + /// + /// Determines whether or not the client is connected to the XMPP server. + /// + public override bool Connected + { + get { return m_sock.Connected; } + } + + /// + /// Supports Start-TLS if SSL is enabled. + /// + public override bool SupportsTLS + { + get { return false; } + } + + /// + /// Sets up the element stream. This is the place to add factories. + /// + public override void InitializeStream() + { + bool first = (m_elements == null); + m_elements = new AsynchElementStream(); + m_elements.OnDocumentStart += new ProtocolHandler(m_elements_OnDocumentStart); + m_elements.OnDocumentEnd += new bedrock.ObjectHandler(m_elements_OnDocumentEnd); + m_elements.OnElement += new ProtocolHandler(m_elements_OnElement); + m_elements.OnError += new bedrock.ExceptionHandler(m_elements_OnError); + + m_listener.StreamInit(m_elements); + + Debug.Assert(this.Connected); + if (first) + m_sock.RequestRead(); + } + + /// + /// Connects the outbound socket. + /// + public override void Connect() + { + int port = (int)m_listener[Options.PORT]; + Debug.Assert(port > 0); + + m_sock = CreateSocket(); + + + string to = (string)m_listener[Options.TO]; + Debug.Assert(to != null); + + string host = (string)m_listener[Options.NETWORK_HOST]; + if ((host == null) || (host == "")) + host = to; + + string url = (string)m_listener[Options.POLL_URL]; + if ((url == null) || (url == "")) + { +#if !__MonoCS__ + url = Address.LookupTXT("_xmppconnect.", to, "_xmpp-client-xbosh"); + if (url == null) +#endif + throw new ArgumentNullException("URL not found in DNS, and not specified", "URL"); + } + ((IHttpSocket)m_sock).URL = url; + + //Address addr = new Address(host, port); + m_sock.Connect(null, (string)m_listener[Options.SERVER_ID]); + } + + /// + /// Create a socket of the correct type. + /// + /// + protected abstract BaseSocket CreateSocket(); + + /// + /// Listens for an inbound connection. + /// + public override void Accept() + { + AsyncSocket s = new AsyncSocket(null, this, (bool)m_listener[Options.SSL], false); + s.LocalCertificate = m_listener[Options.LOCAL_CERTIFICATE] as + System.Security.Cryptography.X509Certificates.X509Certificate2; + + m_sock = s; + m_sock.Accept(new Address((int)m_listener[Options.PORT])); + m_sock.RequestAccept(); + } + + /// + /// Writes a string to the stream. + /// + /// + /// The string to write; this will be transcoded to UTF-8. + /// + public override void Write(string str) + { + //int keep = (int)m_listener[Options.KEEP_ALIVE]; + m_sock.Write(ENC.GetBytes(str)); + } + + /// + /// Writes a stream:stream start tag. + /// + /// Stream containing the stream:stream packet to send. + public override void WriteStartTag(jabber.protocol.stream.Stream stream) + { + Write(stream.StartTag()); + } + + /// + /// Writes a full stanza. + /// + /// The stanza to write out. + public override void Write(XmlElement elem) + { + if (m_sock is IElementSocket) + ((IElementSocket)m_sock).Write(elem); + else + Write(elem.OuterXml); + } + + /// + /// Closes the socket connection. + /// + /// Sends the stream:stream close packet if true. + public override void Close(bool clean) + { + // TODO: socket should still be connected, excepts for races. Revist. + if (clean) + Write(""); + m_sock.Close(); + } + +#if !NO_SSL + /// + /// Negotiates Start-TLS with the other endpoint. + /// + public override void StartTLS() + { + //m_sock.StartTLS(); + //XEP25Socket s = Sock; + + //Debug.Assert(s != null); + //m_listener[Options.REMOTE_CERTIFICATE] = s.RemoteCertificate; + } +#endif + + #region ElementStream handlers + private void m_elements_OnDocumentStart(object sender, XmlElement rp) + { + m_listener.DocumentStarted(rp); + } + + private void m_elements_OnDocumentEnd(object sender) + { + m_listener.DocumentEnded(); + } + + private void m_elements_OnElement(object sender, XmlElement rp) + { + m_listener.StanzaReceived(rp); + } + + private void m_elements_OnError(object sender, Exception ex) + { + // XML parse error. + m_listener.Errored(ex); + } + #endregion + + #region ISocketEventListener Members + + void ISocketEventListener.OnInit(BaseSocket newSock) + { + } + + ISocketEventListener ISocketEventListener.GetListener(BaseSocket newSock) + { + return this; + } + + bool ISocketEventListener.OnAccept(BaseSocket newsocket) + { + m_sock = newsocket; + InitializeStream(); + m_listener.Accepted(); + + // Don't accept any more connections until this one closes + // yes, it will look like we're still listening until the old sock is free'd by GC. + // don't want OnClose() to fire, though, so we can't close the previous sock. + return false; + } + + void ISocketEventListener.OnConnect(BaseSocket sock) + { +#if !NO_SSL + if ((bool)m_listener[Options.SSL]) + { + XEP25Socket s = sock as XEP25Socket; + + m_listener[Options.REMOTE_CERTIFICATE] = s.RemoteCertificate; + } +#endif + m_listener.Connected(); + } + + void ISocketEventListener.OnClose(BaseSocket sock) + { + m_listener[Options.REMOTE_CERTIFICATE] = null; + m_elements = null; + m_listener.Closed(); + } + + void ISocketEventListener.OnError(BaseSocket sock, Exception ex) + { + m_listener[Options.REMOTE_CERTIFICATE] = null; + m_elements = null; + m_listener.Errored(ex); + } + + bool ISocketEventListener.OnRead(BaseSocket sock, byte[] buf, int offset, int length) + { + Debug.Assert(m_listener != null); + Debug.Assert(m_elements != null); + m_listener.BytesRead(buf, offset, length); + m_elements.Push(buf, offset, length); + return true; + } + + void ISocketEventListener.OnWrite(BaseSocket sock, byte[] buf, int offset, int length) + { + m_listener.BytesWritten(buf, offset, length); + } + + /// + /// An invalid peer certificate was sent during SSL/TLS neogtiation. + /// + /// The socket that experienced the error + /// The bad certificate + /// The chain of CAs for the cert + /// A bitfield for the erorrs in the certificate. + /// True if the cert should be accepted anyway. + bool ISocketEventListener.OnInvalidCertificate(BaseSocket sock, + System.Security.Cryptography.X509Certificates.X509Certificate certificate, + System.Security.Cryptography.X509Certificates.X509Chain chain, + System.Net.Security.SslPolicyErrors sslPolicyErrors) + { + return m_listener.OnInvalidCertificate(sock, certificate, chain, sslPolicyErrors); + } + #endregion + } +} + diff -Nru smuxi-0.8/lib/jabber-net/jabber/connection/HttpUploader.cs smuxi-0.8.9.1/lib/jabber-net/jabber/connection/HttpUploader.cs --- smuxi-0.8/lib/jabber-net/jabber/connection/HttpUploader.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/jabber-net/jabber/connection/HttpUploader.cs 2012-01-03 07:52:11.000000000 +0000 @@ -0,0 +1,78 @@ +/* -------------------------------------------------------------------------- + * Copyrights + * + * Portions created by or assigned to Cursive Systems, Inc. are + * Copyright (c) 2002-2008 Cursive Systems, Inc. All Rights Reserved. Contact + * information for Cursive Systems, Inc. is available at + * http://www.cursive.net/. + * + * License + * + * Jabber-Net is licensed under the LGPL. + * See LICENSE.txt for details. + * --------------------------------------------------------------------------*/ +using System; +using System.Collections.Generic; +using System.Text; + +using System.Net; +using System.IO; +using System.Collections; + +using bedrock.util; + +namespace jabber.connection +{ + /// + /// Manages HTTP Requests via XMPP (XEP-70). + /// + [SVN(@"$Id$")] + public class HttpUploader + { + /// + /// Notifies the client that an upload has finished. + /// + public event bedrock.ObjectHandler OnUpload; + + private void ResponseCallback(IAsyncResult result) + { + HttpWebRequest request = (HttpWebRequest)result.AsyncState; + //request.GetResponse().GetResponseStream(); + if (OnUpload != null) + OnUpload(this); + } + + /// + /// Uploads a file to a given URL and verifies the HTTP request + /// through the XMPP server (XEP-0070). + /// + /// URI to send the file to. + /// JID to send as. + /// File to send. + public void Upload(string uri, string jid, string filename) + { + //try + //{ + StreamReader reader = new StreamReader(filename); + HttpWebRequest request = + (HttpWebRequest)HttpWebRequest.Create(uri); + + request.Method = "POST"; + request.Headers.Add(HttpRequestHeader.Authorization, + "x-xmpp-auth jid=\"" + jid + "\""); + + StreamWriter writer = new StreamWriter(request.GetRequestStream()); + writer.Write(reader.ReadToEnd()); + + reader.Close(); + + request.BeginGetResponse(new AsyncCallback(ResponseCallback), + request); + writer.Close(); + // } + // catch (WebException) + // { + // } + } + } +} diff -Nru smuxi-0.8/lib/jabber-net/jabber/connection/IQTracker.cs smuxi-0.8.9.1/lib/jabber-net/jabber/connection/IQTracker.cs --- smuxi-0.8/lib/jabber-net/jabber/connection/IQTracker.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/jabber-net/jabber/connection/IQTracker.cs 2012-01-03 07:52:11.000000000 +0000 @@ -0,0 +1,230 @@ +/* -------------------------------------------------------------------------- + * Copyrights + * + * Portions created by or assigned to Cursive Systems, Inc. are + * Copyright (c) 2002-2008 Cursive Systems, Inc. All Rights Reserved. Contact + * information for Cursive Systems, Inc. is available at + * http://www.cursive.net/. + * + * License + * + * Jabber-Net is licensed under the LGPL. + * See LICENSE.txt for details. + * --------------------------------------------------------------------------*/ +using System; + +using System.Collections; +using System.Collections.Generic; +using System.Diagnostics; +using System.Threading; +using System.Xml; + +using bedrock.util; +using jabber.protocol.client; + +namespace jabber.connection +{ + /// + /// Informs the client that a response to an IQ request has been received. + /// + public delegate void IqCB(object sender, IQ iq, object data); + + /// + /// Informs the client that an IQ has timed out. + /// + [SVN(@"$Id$")] + public class IQTimeoutException : Exception + { + /// + /// Creates a new timeout exception. + /// + /// Description of the error. + public IQTimeoutException(string message) + : base(message) + { + } + } + + /// + /// Represents the interface for tracking an IQ packet. + /// + [SVN(@"$Id$")] + public interface IIQTracker + { + /// + /// Does an asynchronous IQ call. + /// + ///IQ packet to send. + ///Callback to execute when the result comes back. + ///Arguments to pass to the callback. + void BeginIQ(IQ iq, IqCB cb, object cbArg); + + /// + /// Does a synchronous IQ call. + /// + ///IQ packet to send. + ///Time, in milliseconds, to wait for the response. + ///The IQ packet that was sent back. + IQ IQ(IQ iqp, int millisecondsTimeout); + } + + /// + /// Tracks outstanding IQ requests. + /// + [SVN(@"$Id$")] + public class IQTracker: IIQTracker + { + private Dictionary m_pending = new Dictionary(); + private XmppStream m_cli = null; + + /// + /// Creates a new IQ tracker. + /// + /// The client to send/receive on + public IQTracker(XmppStream stream) + { + m_cli = stream; + m_cli.OnProtocol += new jabber.protocol.ProtocolHandler(OnIQ); + } + + private void OnIQ(object sender, XmlElement elem) + { + IQ iq = elem as IQ; + if (iq == null) + return; + if ((iq.Type != IQType.result) && (iq.Type != IQType.error)) + return; + + string id = iq.ID; + TrackerData td; + + lock (m_pending) + { + if (!m_pending.TryGetValue(id, out td)) + return; + + // this wasn't one that was being tracked. + if (!td.IsMatch(iq)) + return; + + m_pending.Remove(id); + } + + td.Call(this, iq); + } + + /// + /// Starts an IQ request. + /// + /// IQ to send. + /// Callback to use when a response comes back. + /// Arguments to the callback. + public void BeginIQ(IQ iq, IqCB cb, object cbArg) + { + // if no callback, ignore response. + if (cb != null) + { + TrackerData td = new TrackerData(cb, cbArg, iq.To, iq.ID); + lock (m_pending) + { + m_pending[iq.ID] = td; + } + } + m_cli.Write(iq); + } + + /// + /// Sends an IQ request and waits for the response. + /// + /// An IQ packet to send, and wait for. + /// Time to wait for response, in milliseconds + /// An IQ in reponse to the sent IQ. + public IQ IQ(IQ iqp, int millisecondsTimeout) + { + AutoResetEvent are = new AutoResetEvent(false); + TrackerData td = new TrackerData(SignalEvent, are, iqp.To, iqp.ID); + string id = iqp.ID; + lock (m_pending) + { + m_pending[id] = td; + } + m_cli.Write(iqp); + + if (!are.WaitOne(millisecondsTimeout, true)) + { + throw new Exception("Timeout waiting for IQ response"); + } + + lock (m_pending) + { + IQ resp = td.Response; + m_pending.Remove(id); + return resp; + } + } + + private void SignalEvent(object sender, IQ iq, object data) + { + ((AutoResetEvent)data).Set(); + } + + /// + /// Internal state for a pending tracker request + /// + [SVN(@"$Id$")] + public class TrackerData + { + private IqCB cb; + private object data; + private JID jid; + private string id; + private IQ response = null; + + /// + /// Create a tracker data instance. + /// + /// + /// + /// + /// + public TrackerData(IqCB callback, object state, JID to, string iq_id) + { + Debug.Assert(callback != null); + cb = callback; + data = state; + jid = to; + id = iq_id; + } + + /// + /// The response that came in. + /// + public IQ Response + { + get { return response; } + } + + /// + /// Is this IQ the one we're looking for? + /// + /// + /// + public bool IsMatch(IQ iq) + { + JID from = iq.From; + return (iq.ID == id) && ((jid == null) || (from == null) || (from == jid)); + } + + /// + /// Call the callback. + /// + /// + /// + public void Call(object sender, IQ iq) + { + response = iq; + cb(sender, iq, data); + } + } + } +} diff -Nru smuxi-0.8/lib/jabber-net/jabber/connection/PollingStanzaStream.cs smuxi-0.8.9.1/lib/jabber-net/jabber/connection/PollingStanzaStream.cs --- smuxi-0.8/lib/jabber-net/jabber/connection/PollingStanzaStream.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/jabber-net/jabber/connection/PollingStanzaStream.cs 2012-01-03 07:52:11.000000000 +0000 @@ -0,0 +1,50 @@ +/* -------------------------------------------------------------------------- + * Copyrights + * + * Portions created by or assigned to Cursive Systems, Inc. are + * Copyright (c) 2002-2008 Cursive Systems, Inc. All Rights Reserved. Contact + * information for Cursive Systems, Inc. is available at + * http://www.cursive.net/. + * + * License + * + * Jabber-Net is licensed under the LGPL. + * See LICENSE.txt for details. + * --------------------------------------------------------------------------*/ +using System; +using System.Diagnostics; +using System.Threading; +using System.Xml; + +using bedrock.net; +using bedrock.util; +using jabber.protocol; +using System.Security.Cryptography; + +namespace jabber.connection +{ + /// + /// Manages the HTTP Polling XMPP stream. + /// + [SVN(@"$Id$")] + public class PollingStanzaStream : HttpStanzaStream + { + /// + /// Creates a PollingStanzaStream + /// + ///Listener associated with PollingStanzaStream. + public PollingStanzaStream(IStanzaEventListener listener) : base(listener) + { + } + + /// + /// Create a XEP25Socket. + /// + /// + protected override BaseSocket CreateSocket() + { + return new XEP25Socket(this); + } + } +} + Binary files /tmp/l3kVLF4iNE/smuxi-0.8/lib/jabber-net/jabber/connection/PubSubManager.bmp and /tmp/jEQ8aotOZY/smuxi-0.8.9.1/lib/jabber-net/jabber/connection/PubSubManager.bmp differ diff -Nru smuxi-0.8/lib/jabber-net/jabber/connection/PubSubManager.cs smuxi-0.8.9.1/lib/jabber-net/jabber/connection/PubSubManager.cs --- smuxi-0.8/lib/jabber-net/jabber/connection/PubSubManager.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/jabber-net/jabber/connection/PubSubManager.cs 2012-01-03 07:52:11.000000000 +0000 @@ -0,0 +1,1164 @@ +/* -------------------------------------------------------------------------- + * Copyrights + * + * Portions created by or assigned to Cursive Systems, Inc. are + * Copyright (c) 2002-2008 Cursive Systems, Inc. All Rights Reserved. Contact + * information for Cursive Systems, Inc. is available at + * http://www.cursive.net/. + * + * License + * + * Jabber-Net is licensed under the LGPL. + * See LICENSE.txt for details. + * --------------------------------------------------------------------------*/ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.ComponentModel; +using System.Diagnostics; +using System.Xml; +using bedrock.util; +using jabber.protocol; +using jabber.protocol.client; +using jabber.protocol.iq; + +namespace jabber.connection +{ + /// + /// Manages a set of publish-subscribe (XEP-60) subscriptions. + /// The goal is to have a list of jid/node combinations, each of which is a singleton. + /// + /// PubSubNode node = ps.GetNode("infobroker.corp.jabber.com", "test/foo", 10); + /// node.AddItemAddCallback(new ItemCB(node_OnItemAdd)); + /// node.OnItemRemove += new ItemCB(node_OnItemRemove); + /// node.OnError += new bedrock.ExceptionHandler(node_OnError); + /// node.AutomatedSubscribe(); + /// + /// + [SVN(@"$Id$")] + public class PubSubManager : StreamComponent + { + private class CBHolder + { + public string Node = null; + public int Max = 10; + public event ItemCB OnAdd; + public event ItemCB OnRemove; + + public void FireAdd(PubSubNode node, PubSubItem item) + { + if (OnAdd != null) + OnAdd(node, item); + } + public void FireRemove(PubSubNode node, PubSubItem item) + { + if (OnRemove != null) + OnRemove(node, item); + } + } + + /// + /// Required designer variable. + /// + private IContainer components = null; + private Dictionary m_nodes = new Dictionary(); + private Dictionary m_callbacks = new Dictionary(); + + /// + /// Creates a manager. + /// + public PubSubManager() + { + InitializeComponent(); + this.OnStreamChanged += new bedrock.ObjectHandler(PubSubManager_OnStreamChanged); + } + + /// + /// Creates a manager in a container. + /// + /// Parent container. + public PubSubManager(IContainer container) : this() + { + container.Add(this); + } + + private void PubSubManager_OnStreamChanged(object sender) + { + m_stream.OnProtocol += new ProtocolHandler(m_stream_OnProtocol); + } + + private void m_stream_OnProtocol(object sender, XmlElement rp) + { + Message msg = rp as Message; + if (msg == null) + return; + PubSubEvent evt = msg["event", URI.PUBSUB_EVENT] as PubSubEvent; + if (evt == null) + return; + + EventItems items = evt.GetChildElement(); + if (items == null) + return; + + string node = items.Node; + JID from = msg.From.BareJID; + JIDNode jn = new JIDNode(from, node); + PubSubNode psn = null; + if (!m_nodes.TryGetValue(jn, out psn)) + { + CBHolder holder = null; + if (!m_callbacks.TryGetValue(node, out holder)) + { + Console.WriteLine("WARNING: notification received for unknown pubsub node"); + return; + } + psn = new PubSubNode(m_stream, from, node, holder.Max); + psn.OnItemAdd += holder.FireAdd; + psn.OnItemRemove += holder.FireRemove; + m_nodes[jn] = psn; + } + psn.FireItems(items); + } + + /// + /// Performs tasks associated with freeing, releasing, or resetting resources. + /// + /// True if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Component Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + components = new System.ComponentModel.Container(); + } + + #endregion + + /// + /// Notifies the client that an error occurred. If this is set, it will be copied to + /// each node that is created by the manager. + /// + public event bedrock.ExceptionHandler OnError; + + /// + /// Add a handler for all inbound notifications with the given node name. + /// This is handy for PEP implicit subscriptions. + /// + /// PEP node URI + /// Callback when items added + /// Callbacks when items removed + /// Maximum number of items to store per node in this namespace + public void AddNodeHandler(string node, ItemCB addCB, ItemCB removeCB, int maxNumber) + { + CBHolder holder = null; + if (!m_callbacks.TryGetValue(node, out holder)) + { + holder = new CBHolder(); + holder.Node = node; + holder.Max = maxNumber; + m_callbacks[node] = holder; + } + holder.OnAdd += addCB; + holder.OnRemove += removeCB; + } + + /// + /// Remove an existing callback. + /// + /// + /// + public void RemoveNodeHandler(string node, ItemCB cb) + { + CBHolder holder = null; + if (m_callbacks.TryGetValue(node, out holder)) + { + // tests indicate removing from a list that doesn't contain this callback is safe. + holder.OnAdd -= cb; + holder.OnRemove -= cb; + } + } + + /// + /// Subscribes to a publish-subscribe node. + /// + /// Component that handles PubSub requests. + /// The node on the component that the client wants to interact with. + /// Maximum number of items to retain. First one to call Subscribe gets their value, for now. + /// + /// The existing node will be returned if there is already a subscription. + /// If the node does not exist, the PubSubNode object will be returned + /// in a subscribing state. + /// + public PubSubNode GetNode(JID service, string node, int maxItems) + { + JIDNode jn = new JIDNode(service, node); + PubSubNode n = null; + if (m_nodes.TryGetValue(jn, out n)) + return n; + n = new PubSubNode(Stream, service, node, maxItems); + m_nodes[jn] = n; + n.OnError += OnError; + return n; + } + + /// + /// Removes the publish-subscribe node from the manager and sends a delete + /// node to the XMPP server. + /// + /// + /// Component that handles PubSub requests. + /// + /// + /// The node on the component that the client wants to interact with. + /// + /// + /// Callback for any errors with the publish-subscribe node deletion. + /// + public void RemoveNode(JID service, string node, bedrock.ExceptionHandler errorHandler) + { + JIDNode jn = new JIDNode(service, node); + + PubSubNode psNode = null; + if (m_nodes.TryGetValue(jn, out psNode)) + { + m_nodes.Remove(jn); + } + else + { + psNode = new PubSubNode(Stream, service, node, 10); + } + + psNode.OnError += errorHandler; + + psNode.Delete(); + } + + + /// + /// Get the default configuration of the node. + /// + /// JID of the pub/sub service + /// Callback. Must not be null. Will not be called back + /// if there is an error, but instead OnError will be called. + /// State information to be passed back to callback + public void GetDefaults(JID service, IqCB callback, object state) + { + OwnerPubSubCommandIQ iq = new OwnerPubSubCommandIQ(m_stream.Document); + iq.To = service; + iq.Type = IQType.get; + BeginIQ(iq, OnDefaults, new IQTracker.TrackerData(callback, state, null, null)); + } + + private void OnDefaults(object sender, IQ iq, object data) + { + if (iq == null) + { + if (OnError != null) + OnError(this, new PubSubException(Op.DEFAULTS, "IQ timeout", null)); + return; + } + + if (iq.Type != IQType.result) + { + string msg = string.Format("Error configuring pubsub node: {0}", iq.Error.Condition); + Debug.WriteLine(msg); + + if (OnError != null) + OnError(this, new PubSubException(Op.DEFAULTS, msg, iq)); + return; + } + PubSubOwner ow = iq.Query as PubSubOwner; + if (ow == null) + { + if (OnError != null) + OnError(this, new PubSubException(Op.DEFAULTS, "Invalid protocol", iq)); + return; + } + + OwnerDefault conf = ow.Command as OwnerDefault; + if (conf == null) + { + if (OnError != null) + OnError(this, new PubSubException(Op.DEFAULTS, "Invalid protocol", iq)); + return; + } + + IQTracker.TrackerData td = data as IQTracker.TrackerData; + td.Call(this, iq); + } + } + + /// + /// Notifies the client about a publish-subscribe item. + /// + public delegate void ItemCB(PubSubNode node, PubSubItem item); + + /// + /// Manages a list of items with a maximum size. Only one item with a given ID will be in the + /// list at a given time. + /// + [SVN(@"$Id$")] + public class ItemList : ArrayList + { + private Hashtable m_index = new Hashtable(); + private PubSubNode m_node = null; + + /// + /// Creates an item list, which will have at most some number of items. + /// + /// The node to which this item list applies. + /// Maximum size of the list. Delete notifications will be sent if this size is exceeded. + public ItemList(PubSubNode node, int maxItems) : base(maxItems) + { + m_node = node; + } + + /// + /// Makes sure that the underlying ID index is in sync + /// when an item is removed. + /// + /// Index of PubSubItem to remove. + public override void RemoveAt(int index) + { + PubSubItem item = (PubSubItem)this[index]; + string id = item.GetAttribute("id"); + if (id != "") + { + m_index.Remove(id); + } + base.RemoveAt(index); + m_node.ItemRemoved(item); + + // renumber + for (int i=index; i + /// Adds to the end of the list, replacing any item with the same ID, + /// or bumping the oldest item if the list is full. + /// + /// PubSubItem to add to the list. + /// Index where the PubSubItem was inserted. + public override int Add(object value) + { + PubSubItem item = value as PubSubItem; + if (item == null) + throw new ArgumentException("Must be an XmlElement", "value"); + string id = item.ID; + int i; + if (id == null) + { + if (Count == Capacity) + { + RemoveAt(0); + } + i = base.Add(value); + m_node.ItemAdded(item); + return i; + } + + // RemoveId(id); + if (!m_index.Contains(id) && (Count == Capacity)) + RemoveAt(0); + + i = base.Add(value); + m_index[id] = i; + m_node.ItemAdded(item); + return i; + } + + /// + /// Removes the item with the given ID. + /// No exception is thrown if no item is found with that ID. + /// + /// ID of the item to remove + public void RemoveId(string id) + { + object index = m_index[id]; + if (index != null) + RemoveAt((int)index); + } + + /// + /// Gets or sets the contents of the specified item. + /// + /// Id of the PubSubItem. + /// XmlElement representing the contents of the PubSubItem. + public XmlElement this[string id] + { + get + { + object index = m_index[id]; + if (index == null) + return null; + PubSubItem item = this[(int)index] as PubSubItem; + if (item == null) + return null; + return item.Contents; + } + set + { + // wrap an item around the contents. + PubSubItem item = new PubSubItem(value.OwnerDocument); + item.Contents = value; + item.ID = id; + Add(item); + } + } + } + + + /// + /// Contains the different possible operations on a publish-subscribe node. + /// + public enum Op + { + /// + /// Creates a node + /// + CREATE, + /// + /// Subscribes to a node + /// + SUBSCRIBE, + /// + /// Gets the current items in the node + /// + ITEMS, + /// + /// Deletes a node + /// + DELETE, + /// + /// Deletes an item from the node + /// + DELETE_ITEM, + /// + /// Publishes an item to a node + /// + PUBLISH_ITEM, + /// + /// Configure a node + /// + CONFIGURE, + /// + /// Purge all items from a node. + /// + PURGE, + /// + /// Configuration defaults + /// + DEFAULTS + } + + /// + /// Informs the client that a publish-subscribe error occurred. + /// + [SVN(@"$Id$")] + public class PubSubException : Exception + { + /// + /// Contains the stanza that caused the error. + /// + public XmlElement Protocol = null; + /// + /// Contains the operation that failed. + /// + public Op Operation; + + /// + /// Creates a new publish-subscribe exception. + /// + /// The operation that failed. + /// A description of the error. + /// The stanza that caused the error. + public PubSubException(Op op, string error, XmlElement elem) : base(error) + { + Operation = op; + Protocol = elem; + } + + /// + /// Gets the error string. + /// + public override string Message + { + get + { return string.Format("PubSub error on {0}: {1}\r\nAssociated protocol: {2}", Operation, base.Message, Protocol); } + } + } + + /// + /// Some event has occurred on a PubSub node. + /// + /// + public delegate void NodeHandler(PubSubNode node); + + /// + /// Manages a node to be subscribed to. Will keep a maximum number of items. + /// + [SVN(@"$Id$")] + public class PubSubNode : StreamComponent, IEnumerable + { + private enum STATE + { + Start, + Pending, + Asking, + Running, + Error, + } + + // indexed by op. + private STATE[] m_state = new STATE[] { STATE.Start, STATE.Start, STATE.Start, STATE.Start}; + + private JID m_jid = null; + private string m_node = null; + private ItemList m_items = null; + + /// + /// Retrieves the component that handles publish-subscribe requests. + /// + public JID Jid + { + get { return m_jid; } + } + + /// + /// Retrieves the node to interact with as defined by XEP-60. + /// + public string Node + { + get { return m_node; } + } + + /// + /// Create a Node. Next, call Create and/or Subscribe. + /// + /// + /// + /// + /// + internal PubSubNode(XmppStream stream, JID jid, string node, int maxItems) + { + if (stream == null) + throw new ArgumentException("must not be null", "stream"); + if (node == null) + throw new ArgumentException("must not be null", "node"); + if (node == "") + throw new ArgumentException("must not be empty", "node"); + + m_stream = stream; + m_jid = jid; + m_node = node; + m_items = new ItemList(this, maxItems); + } + + /// + /// The document associated with the stream we're attached to. + /// + public XmlDocument Document + { + get { return m_stream.Document; } + } + + /// + /// Determines whether or not this node is fully initialized. + /// + public bool IsInitialized + { + get { return (this[Op.CREATE] == STATE.Running) && (this[Op.SUBSCRIBE] == STATE.Running); } + } + + /// + /// Has the creation request succeeded? + /// + public bool IsCreated + { + get { return this[Op.CREATE] == STATE.Running; } + } + + /// + /// Informs the client that an item has been added to the node, + /// either on initial get or by notification. + /// NOTE: This may fire for the same item more than once. + /// + public event ItemCB OnItemAdd; + + /// + /// Informs the client that an item has been deleted from the node, + /// either by notification or the list being full. + /// + public event ItemCB OnItemRemove; + + + /// + /// Informs the publisher that an item has been published + /// successfully. + /// + public event ItemCB OnItemPublished; + + /// + /// Notifies the client that an error occurred. + /// + public event bedrock.ExceptionHandler OnError; + + /// + /// Node has finished being created, successfully. + /// + public event NodeHandler OnCreate; + + private STATE this[Op op] + { + get { return m_state[(int)op]; } + set { m_state[(int)op] = value; } + } + + private void FireError(Op op, string message, XmlElement protocol) + { + Debug.WriteLine(string.Format("Error {0}ing pubsub node: {1}", op, message)); + this[op] = STATE.Error; + + if (OnError != null) + OnError(this, new PubSubException(op, message, protocol)); + } + + internal void FireItems(EventItems items) + { + // OK, it's for us. Might be a new one or a retraction. + // Shrug, even if we're sent a mix, it shouldn't hurt anything. + + /* + + + + + + + + */ + foreach (string id in items.GetRetractions()) + m_items.RemoveId(id); + + foreach (PubSubItem item in items.GetItems()) + m_items.Add(item); + } + + /// + /// Adds a handler for the OnItemAdd event, and calls the handler for any existing + /// items. To prevent races, use this rather than .OnItemAdd +=. + /// + /// Callback to call with every item. + public void AddItemAddCallback(ItemCB callback) + { + if (callback == null) + throw new ArgumentException("Must not be null", "callback"); + + OnItemAdd += callback; + foreach (PubSubItem item in m_items) + { + callback(this, item); + } + } + + /// + /// Creates the node then subscribes. If the creation succeeded, or if the node + /// already exists, retrieve the items for the node. + /// + /// This is the typical starting point. Please make sure to register callbacks before calling + /// this function. + /// + public void AutomatedSubscribe() + { + lock (this) + { + if ((this[Op.SUBSCRIBE] == STATE.Start) || (this[Op.SUBSCRIBE] == STATE.Error)) + this[Op.SUBSCRIBE] = STATE.Pending; + if ((this[Op.ITEMS] == STATE.Start) || (this[Op.ITEMS] == STATE.Error)) + this[Op.ITEMS] = STATE.Pending; + } + Create(); + } + + /// + /// Creates the node with default configuration. + /// + public void Create() + { + Create(null); + } + + /// + /// Creates the node using the specified configuration form. + /// + /// Null for the default configuration + public void Create(jabber.protocol.x.Data config) + { + lock (this) + { + if (!NeedsAsking(this[Op.CREATE])) + { + SubscribeIfPending(); + return; + } + + this[Op.CREATE] = STATE.Asking; + } +/* + + + + + + + */ + PubSubCommandIQ iq = new PubSubCommandIQ(m_stream.Document, m_node); + iq.To = m_jid; + iq.Type = IQType.set; + iq.Command.CreateConfiguration(config); + BeginIQ(iq, GotCreated, null); + } + + private void GotCreated(object sender, IQ iq, object state) + { + if (iq.Type != IQType.result) + { + // Type=error with conflict is basically a no-op. + if (iq.Type != IQType.error) + { + FireError(Op.CREATE, "Create failed, invalid protocol", iq); + return; + } + Error err = iq.Error; + if (err == null) + { + FireError(Op.CREATE, "Create failed, unknown error", iq); + return; + } + if (err.Condition != Error.CONFLICT) + { + FireError(Op.CREATE, "Error creating node", iq); + return; + } + } + else + { + PubSub ps = iq.Query as PubSub; + if (ps != null) + { + Create c = ps["create", URI.PUBSUB] as Create; + if (c != null) + m_node = c.Node; + } + } + + this[Op.CREATE] = STATE.Running; + + if (OnCreate != null) + OnCreate(this); + + SubscribeIfPending(); + } + + private bool NeedsAsking(STATE state) + { + switch (state) + { + case STATE.Start: + case STATE.Pending: + return true; + case STATE.Asking: + case STATE.Running: + return false; + case STATE.Error: + Debug.WriteLine("Retrying create after error. Hope you've changed perms or something in the mean time."); + return true; + } + return true; + } + + private void SubscribeIfPending() + { + if (this[Op.SUBSCRIBE] == STATE.Pending) + Subscribe(); + } + + /// + /// Sends a subscription request. + /// Items request will be sent automatically on successful subscribe. + /// + public void Subscribe() + { + lock (this) + { + if (!NeedsAsking(this[Op.SUBSCRIBE])) + return; + + this[Op.SUBSCRIBE] = STATE.Asking; + } + + PubSubIQ iq = createCommand(PubSubCommandType.subscribe); + addInfo(iq); + BeginIQ(iq, GotSubscribed, null); + // don't parallelize getItems, in case sub fails. + } + + private PubSubIQ createCommand(PubSubCommandType type) + { + PubSubIQ iq = new PubSubIQ(m_stream.Document, type, m_node); + iq.To = m_jid; + iq.Type = IQType.set; + + return iq; + } + + private void addInfo(PubSubIQ iq) + { + Subscribe sub = (Subscribe) iq.Command; + sub.JID = m_stream.JID; + } + + private void GotSubscribed(object sender, IQ iq, object state) + { + if (iq.Type != IQType.result) + { + FireError(Op.SUBSCRIBE, "Subscription failed", iq); + return; + } + + PubSub ps = iq.Query as PubSub; + if (ps == null) + { + FireError(Op.SUBSCRIBE, "Invalid protocol", iq); + return; + } + + PubSubSubscriptionType subType; + PubSubSubscription sub = ps["subscription", URI.PUBSUB] as PubSubSubscription; + if (sub != null) + subType = sub.Type; + else + { + XmlElement ent = ps["entity", URI.PUBSUB]; + if (ent == null) + { + FireError(Op.SUBSCRIBE, "Invalid protocol", iq); + return; + } + string s = ent.GetAttribute("subscription"); + if (s == "") + subType = PubSubSubscriptionType.NONE_SPECIFIED; + else + subType = (PubSubSubscriptionType)Enum.Parse(typeof(PubSubSubscriptionType), s); + } + + switch (subType) + { + case PubSubSubscriptionType.NONE_SPECIFIED: + case PubSubSubscriptionType.subscribed: + break; + case PubSubSubscriptionType.pending: + FireError(Op.SUBSCRIBE, "Subscription pending authorization", iq); + return; + case PubSubSubscriptionType.unconfigured: + FireError(Op.SUBSCRIBE, "Subscription configuration required. Not implemented yet.", iq); + return; + } + + this[Op.SUBSCRIBE] = STATE.Running; + GetItemsIfPending(); + } + + private void GetItemsIfPending() + { + if (this[Op.ITEMS] == STATE.Pending) + GetItems(); + } + + /// + /// Gets the items from the node on the XMPP server. + /// + public void GetItems() + { + lock (this) + { + if (!NeedsAsking(this[Op.ITEMS])) + return; + this[Op.ITEMS] = STATE.Asking; + } + PubSubIQ piq = new PubSubIQ(m_stream.Document, PubSubCommandType.items, m_node); + piq.To = m_jid; + piq.Type = IQType.get; + BeginIQ(piq, GotItems, null); + } + + private void GotItems(object sender, IQ iq, object state) + { + if (iq.Type != IQType.result) + { + FireError(Op.ITEMS, "Error retrieving items", iq); + return; + } + + PubSub ps = iq["pubsub", URI.PUBSUB] as PubSub; + if (ps == null) + { + FireError(Op.ITEMS, "Invalid pubsub protocol", iq); + return; + } + PubSubItemCommand items = ps["items", URI.PUBSUB] as PubSubItemCommand; + if (items == null) + { + // That doesn't really hurt us, I guess. No items. Keep going. + this[Op.ITEMS] = STATE.Running; + return; + } + + if (items.Node != m_node) + { + FireError(Op.ITEMS, "Non-matching node. Probably a server bug.", iq); + return; + } + + foreach (PubSubItem item in items.GetItems()) + m_items.Add(item); + + this[Op.ITEMS] = STATE.Running; + } + + /// + /// Notifies the client that an item has been add to this PubSubNode. + /// + /// Item that was added. + public void ItemAdded(PubSubItem item) + { + if (OnItemAdd != null) + OnItemAdd(this, item); + } + + /// + /// Notifies the client that an item has been removed from this PubSubNode. + /// + /// Item that was removed. + public void ItemRemoved(PubSubItem item) + { + if (OnItemRemove != null) + OnItemRemove(this, item); + } + + /// + /// Returns the contents of the specified item + /// + /// Index of the element to retrieve. + /// XmlElement contents. + public XmlElement this[string id] + { + get { return m_items[id]; } + set + { + // TODO: publish, and reset ID when it comes back. + m_items[id] = value; + } + } + + /// + /// Unsubscribes from the node. + /// + public void Unsubscribe() + { + PubSubIQ iq = createCommand(PubSubCommandType.unsubscribe); + BeginIQ(iq, GotUnsubsribed, null); + } + + private void GotUnsubsribed(object sender, IQ iq, object data) + { + //TODO: Report back error + } + + /// + /// Deletes the node from the XMPP server. + /// + public void Delete() + { + OwnerPubSubCommandIQ iq = new OwnerPubSubCommandIQ(m_stream.Document); + iq.To = m_jid; + iq.Type = IQType.set; + iq.Command.Node = m_node; + BeginIQ(iq, GotDelete, null); + } + + private void GotDelete(object sender, IQ iq, object data) + { + if (iq.Type != IQType.result) + { + FireError(Op.DELETE, "Delete failed", iq); + return; + } + } + + /// + /// Deletes a single item from the XMPP server. + /// + /// Id of item. + public void DeleteItem(string id) + { + PubSubIQ iq = createCommand(PubSubCommandType.retract); + Retract retract = (Retract)iq.Command; + retract.AddItem(id); + BeginIQ(iq, OnDeleteNode, null); + } + + private void OnDeleteNode(object sender, IQ iq, object data) + { + if (iq.Type != IQType.result) + { + string msg = string.Format("Error deleting pubsub item: {0}", iq.Error.Condition); + Debug.WriteLine(msg); + + if (OnError != null) + OnError(this, new PubSubException(Op.DELETE_ITEM, msg, iq)); + return; + } + } + + /// + /// Delete all items from a node at once. + /// + public void Purge() + { + OwnerPubSubCommandIQ iq = new OwnerPubSubCommandIQ(m_stream.Document); + iq.To = m_jid; + iq.Type = IQType.set; + iq.Command.Node = m_node; + BeginIQ(iq, GotPurge, null); + + } + + private void GotPurge(object sender, IQ iq, object data) + { + if (iq.Type != IQType.result) + { + FireError(Op.PURGE, "Purge failed", iq); + return; + } + } + + /// + /// Publishes an item to the node. + /// + /// If null, the server will assign an item ID. + /// The XML inside the item. Should be in a new namespace. + public void PublishItem(string id, XmlElement contents) + { + PubSubIQ iq = createCommand(PubSubCommandType.publish); + Publish pub = (Publish)iq.Command; + PubSubItem item = new PubSubItem(m_stream.Document); + if (id != null) + item.ID = id; + item.AddChild(contents); + pub.AddChild(item); + BeginIQ(iq, new IqCB(OnPublished), item); + } + + private void OnPublished(object sender, IQ iq, object data) + { + if (iq.Type != IQType.result) + { + string msg = string.Format("Error publishing pubsub item: {0}", iq.Error.Condition); + Debug.WriteLine(msg); + + if (OnError != null) + OnError(this, new PubSubException(Op.PUBLISH_ITEM, msg, iq)); + return; + } + + // TODO: if an item is returned, it will have a new item id. + if (OnItemPublished != null) + OnItemPublished(this, (PubSubItem)data); + } + + /// + /// Request configuration form as the owner + /// + /// Callback. Must not be null. Will not be called back + /// if there is an error, but instead OnError will be called. + /// State information to be passed back to callback + public void Configure(IqCB callback, object state) + { + OwnerPubSubCommandIQ iq = new OwnerPubSubCommandIQ(m_stream.Document); + iq.To = m_jid; + iq.Type = IQType.get; + iq.Command.Node = m_node; + BeginIQ(iq, OnConfigure, new IQTracker.TrackerData(callback, state, null, null)); + } + + private void OnConfigure(object sender, IQ iq, object data) + { + if (iq == null) + { + if (OnError != null) + OnError(this, new PubSubException(Op.CONFIGURE, "IQ timeout", null)); + return; + } + + if (iq.Type != IQType.result) + { + string msg = string.Format("Error configuring pubsub node: {0}", iq.Error.Condition); + Debug.WriteLine(msg); + + if (OnError != null) + OnError(this, new PubSubException(Op.CONFIGURE, msg, iq)); + return; + } + PubSubOwner ow = iq.Query as PubSubOwner; + if (ow == null) + { + if (OnError != null) + OnError(this, new PubSubException(Op.CONFIGURE, "Invalid protocol", iq)); + return; + } + + OwnerConfigure conf = ow.Command as OwnerConfigure; + if (conf == null) + { + if (OnError != null) + OnError(this, new PubSubException(Op.CONFIGURE, "Invalid protocol", iq)); + return; + } + + IQTracker.TrackerData td = data as IQTracker.TrackerData; + td.Call(this, iq); + } + + #region IEnumerable Members + + IEnumerator IEnumerable.GetEnumerator() + { + return m_items.GetEnumerator(); + } + + #endregion + } +} diff -Nru smuxi-0.8/lib/jabber-net/jabber/connection/sasl/ExternalProcessor.cs smuxi-0.8.9.1/lib/jabber-net/jabber/connection/sasl/ExternalProcessor.cs --- smuxi-0.8/lib/jabber-net/jabber/connection/sasl/ExternalProcessor.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/jabber-net/jabber/connection/sasl/ExternalProcessor.cs 2012-01-03 07:52:11.000000000 +0000 @@ -0,0 +1,44 @@ +/* -------------------------------------------------------------------------- + * Copyrights + * + * Portions created by or assigned to Cursive Systems, Inc. are + * Copyright (c) 2002-2008 Cursive Systems, Inc. All Rights Reserved. Contact + * information for Cursive Systems, Inc. is available at + * http://www.cursive.net/. + * + * License + * + * Jabber-Net is licensed under the LGPL. + * See LICENSE.txt for details. + * --------------------------------------------------------------------------*/ +using System; +using System.IO; +using System.Diagnostics; +using System.Xml; + +using bedrock.util; +using jabber.protocol.stream; + +namespace jabber.connection.sasl +{ + /// + /// SASL Mechanism EXTERNAL as specified in XEP-0178. + /// + [SVN(@"$Id$")] + public class ExternalProcessor : SASLProcessor + { + /// + /// Perform the next step + /// + /// Null if it's the initial response + /// Document to create Steps in + /// + public override Step step(Step s, XmlDocument doc) + { + Debug.Assert(s == null); + Auth a = new Auth(doc); + a.Mechanism = MechanismType.EXTERNAL; + return a; + } + } +} diff -Nru smuxi-0.8/lib/jabber-net/jabber/connection/sasl/KerbProcessor.cs smuxi-0.8.9.1/lib/jabber-net/jabber/connection/sasl/KerbProcessor.cs --- smuxi-0.8/lib/jabber-net/jabber/connection/sasl/KerbProcessor.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/jabber-net/jabber/connection/sasl/KerbProcessor.cs 2012-01-03 07:52:11.000000000 +0000 @@ -0,0 +1,798 @@ +/* -------------------------------------------------------------------------- + * Copyrights + * + * Portions created by or assigned to Cursive Systems, Inc. are + * Copyright (c) 2002-2008 Cursive Systems, Inc. All Rights Reserved. Contact + * information for Cursive Systems, Inc. is available at + * http://www.cursive.net/. + * + * License + * + * Jabber-Net is licensed under the LGPL. + * See LICENSE.txt for details. + * --------------------------------------------------------------------------*/ +using System; +using System.Runtime.InteropServices; +using System.Security.Principal; +using System.Xml; +using jabber.protocol.stream; +using HANDLE = System.IntPtr; + +using bedrock.util; + +namespace jabber.connection.sasl +{ + + /// + /// Uses Kerberos authentication ot log into XMPP server. + /// + [SVN(@"$Id$")] + public class KerbProcessor : SASLProcessor + { + /// + /// Should we use the existing Windows (kerberos) credentials? + /// + public const string USE_WINDOWS_CREDS = "USE_WINDOWS_CREDS"; + + private readonly SSPIHelper kerbClient; + /// + /// Creates a new KerbProcessor + /// + ///Remote principal that represents the XMPP server. + public KerbProcessor(string remotePrincipal) + { + kerbClient = new SSPIHelper(remotePrincipal); + } + + /// + /// Perform the next step + /// + /// Null if it's the initial response + /// Document to create Steps in + /// XML to send to the XMPP server. + public override Step step(Step s, XmlDocument doc) + { + byte[] outBytes; + byte[] inBytes = null; + + Step returnStep; + + if (s == null) + { + // First step. + returnStep = new Auth(doc); + ((Auth)returnStep).Mechanism = MechanismType.GSSAPI; + + SetCredentials(); + } + else + { + returnStep = new Response(doc); + inBytes = s.Bytes; + } + + kerbClient.ExecuteKerberos(inBytes, out outBytes); + returnStep.Bytes = outBytes; + + return returnStep; + } + + private void SetCredentials() + { + // Username should be in the form of "DOMAIN\USERNAME" + // If it isn't, we'll assume it is the username and get + // the domain from somewhere else. + string username = this[USERNAME]; + int sepIndex = username.IndexOf('\\'); + kerbClient.Username = username.Substring(sepIndex + 1); + + if (sepIndex != -1) + kerbClient.Domain = username.Substring(0, sepIndex); + else + { + // Domain wasn't specified. Use the current user's domain. + string currentName = WindowsIdentity.GetCurrent().Name; + kerbClient.Domain = currentName.Substring(0, currentName.IndexOf('\\')); + } + kerbClient.Password = this[PASSWORD]; + kerbClient.UseWindowsCreds = Boolean.Parse(this[USE_WINDOWS_CREDS]); + } + } + + internal enum SecBufferType + { + SECBUFFER_VERSION = 0, + SECBUFFER_EMPTY = 0, + SECBUFFER_DATA = 1, + SECBUFFER_TOKEN = 2, + SECBUFFER_PADDING = 9, + SECBUFFER_STREAM = 10 + } + /* + [StructLayout(LayoutKind.Sequential)] + internal struct SecHandle //=PCtxtHandle + { + uint dwLower; + uint dwUpper; + } + */ + [StructLayout(LayoutKind.Sequential)] + internal struct SecBuffer : IDisposable + { + public int cbBuffer; + public int BufferType; + public IntPtr pvBuffer; + + + public SecBuffer(int bufferSize) + { + cbBuffer = bufferSize; + BufferType = (int)SecBufferType.SECBUFFER_TOKEN; + pvBuffer = Marshal.AllocHGlobal(bufferSize); + } + + public SecBuffer(byte[] secBufferBytes) + { + cbBuffer = secBufferBytes.Length; + BufferType = (int)SecBufferType.SECBUFFER_TOKEN; + pvBuffer = Marshal.AllocHGlobal(cbBuffer); + Marshal.Copy(secBufferBytes, 0, pvBuffer, cbBuffer); + } + + public SecBuffer(byte[] secBufferBytes, SecBufferType bufferType) + { + BufferType = (int)bufferType; + + if (secBufferBytes != null && secBufferBytes.Length != 0) + { + cbBuffer = secBufferBytes.Length; + pvBuffer = Marshal.AllocHGlobal(cbBuffer); + Marshal.Copy(secBufferBytes, 0, pvBuffer, cbBuffer); + } + else + { + cbBuffer = 0; + pvBuffer = HANDLE.Zero; + } + } + + public void Dispose() + { + if (pvBuffer != IntPtr.Zero) + { + Marshal.FreeHGlobal(pvBuffer); + pvBuffer = IntPtr.Zero; + } + } + } + + internal struct MultipleSecBufferHelper + { + public byte[] Buffer; + public SecBufferType BufferType; + + public MultipleSecBufferHelper(byte[] buffer, SecBufferType bufferType) + { + Buffer = buffer; + BufferType = bufferType; + } + }; + + [StructLayout(LayoutKind.Sequential)] + internal struct SecBufferDesc : IDisposable + { + + public int ulVersion; + public int cBuffers; + public IntPtr pBuffers; //Point to SecBuffer + + public SecBufferDesc(int bufferSize) + { + ulVersion = (int)SecBufferType.SECBUFFER_VERSION; + cBuffers = 1; + SecBuffer ThisSecBuffer = new SecBuffer(bufferSize); + pBuffers = Marshal.AllocHGlobal(Marshal.SizeOf(ThisSecBuffer)); + Marshal.StructureToPtr(ThisSecBuffer, pBuffers, false); + } + + public SecBufferDesc(byte[] secBufferBytes) + { + ulVersion = (int)SecBufferType.SECBUFFER_VERSION; + cBuffers = 1; + SecBuffer ThisSecBuffer = new SecBuffer(secBufferBytes); + pBuffers = Marshal.AllocHGlobal(Marshal.SizeOf(ThisSecBuffer)); + Marshal.StructureToPtr(ThisSecBuffer, pBuffers, false); + } + + internal SecBufferDesc(MultipleSecBufferHelper[] secBufferBytesArray) + { + if (secBufferBytesArray == null || secBufferBytesArray.Length == 0) + { + throw new ArgumentException("secBufferBytesArray cannot be null or 0 length"); + } + + ulVersion = (int)SecBufferType.SECBUFFER_VERSION; + cBuffers = secBufferBytesArray.Length; + + //Allocate memory for SecBuffer Array.... + pBuffers = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(SecBuffer)) * cBuffers); + + for (int Index = 0; Index < secBufferBytesArray.Length; Index++) + { + //Super hack: Now allocate memory for the individual SecBuffers + //and just copy the bit values to the SecBuffer array!!! + SecBuffer ThisSecBuffer = new SecBuffer(secBufferBytesArray[Index].Buffer, + secBufferBytesArray[Index].BufferType); + + //We will write out bits in the following order: + //int cbBuffer; + //int BufferType; + //pvBuffer; + //Note: that we won't be releasing the memory allocated by ThisSecBuffer until we + //are disposed... + int CurrentOffset = Index * Marshal.SizeOf(typeof(SecBuffer)); + Marshal.WriteInt32(pBuffers, CurrentOffset, ThisSecBuffer.cbBuffer); + + int length = CurrentOffset + Marshal.SizeOf(ThisSecBuffer.cbBuffer); + Marshal.WriteInt32(pBuffers, length, ThisSecBuffer.BufferType); + + length = CurrentOffset + Marshal.SizeOf(ThisSecBuffer.cbBuffer) + + Marshal.SizeOf(ThisSecBuffer.BufferType); + Marshal.WriteIntPtr(pBuffers, length, ThisSecBuffer.pvBuffer); + } + } + + public void Dispose() + { + if (pBuffers != IntPtr.Zero) + { + if (cBuffers == 1) + { + SecBuffer ThisSecBuffer = + (SecBuffer)Marshal.PtrToStructure(pBuffers, typeof(SecBuffer)); + ThisSecBuffer.Dispose(); + } + else + { + // Since we aren't sending any messages using the kerberos encrypt/decrypt. + // The 1st buffer is going to be empty. We can skip it. + for (int Index = 1; Index < cBuffers; Index++) + { + //The bits were written out the following order: + //int cbBuffer; + //int BufferType; + //pvBuffer; + //What we need to do here is to grab a hold of the pvBuffer allocate by the individual + //SecBuffer and release it... + int CurrentOffset = Index * Marshal.SizeOf(typeof(SecBuffer)); + + int totalLength = CurrentOffset + Marshal.SizeOf(typeof(int)) + + Marshal.SizeOf(typeof(int)); + IntPtr SecBufferpvBuffer = Marshal.ReadIntPtr(pBuffers, totalLength); + Marshal.FreeHGlobal(SecBufferpvBuffer); + } + } + + Marshal.FreeHGlobal(pBuffers); + pBuffers = IntPtr.Zero; + } + } + + public byte[] GetSecBufferByteArray() + { + byte[] Buffer = null; + + if (pBuffers == IntPtr.Zero) + { + throw new InvalidOperationException("Object has already been disposed!!!"); + } + + if (cBuffers == 1) + { + SecBuffer ThisSecBuffer = (SecBuffer)Marshal.PtrToStructure(pBuffers, typeof(SecBuffer)); + + if (ThisSecBuffer.cbBuffer > 0) + { + Buffer = new byte[ThisSecBuffer.cbBuffer]; + Marshal.Copy(ThisSecBuffer.pvBuffer, Buffer, 0, ThisSecBuffer.cbBuffer); + } + } + else + { + int BytesToAllocate = 0; + + for (int Index = 0; Index < cBuffers; Index++) + { + //The bits were written out the following order: + //int cbBuffer; + //int BufferType; + //pvBuffer; + //What we need to do here calculate the total number of bytes we need to copy... + int CurrentOffset = Index * Marshal.SizeOf(typeof(SecBuffer)); + BytesToAllocate += Marshal.ReadInt32(pBuffers, CurrentOffset); + } + + Buffer = new byte[BytesToAllocate]; + + for (int Index = 0, BufferIndex = 0; Index < cBuffers; Index++) + { + //The bits were written out the following order: + //int cbBuffer; + //int BufferType; + //pvBuffer; + //Now iterate over the individual buffers and put them together into a + //byte array... + int CurrentOffset = Index * Marshal.SizeOf(typeof(SecBuffer)); + int BytesToCopy = Marshal.ReadInt32(pBuffers, CurrentOffset); + int length = CurrentOffset + Marshal.SizeOf(typeof(int)) + Marshal.SizeOf(typeof(int)); + IntPtr SecBufferpvBuffer = Marshal.ReadIntPtr(pBuffers, length); + Marshal.Copy(SecBufferpvBuffer, Buffer, BufferIndex, BytesToCopy); + BufferIndex += BytesToCopy; + } + } + + return (Buffer); + } + } + + + [StructLayout(LayoutKind.Sequential)] + internal struct SECURITY_INTEGER + { + public uint LowPart; + public int HighPart; + public SECURITY_INTEGER(int dummy) + { + LowPart = 0; + HighPart = 0; + } + }; + + [StructLayout(LayoutKind.Sequential)] + internal struct SECURITY_HANDLE + { + public uint LowPart; + public uint HighPart; + public SECURITY_HANDLE(int dummy) + { + LowPart = HighPart = 0; + } + }; + + [StructLayout(LayoutKind.Sequential)] + internal struct SecPkgContext_Sizes + { + public uint cbMaxToken; + public uint cbMaxSignature; + public uint cbBlockSize; + public uint cbSecurityTrailer; + }; + + [StructLayout(LayoutKind.Sequential)] + internal struct SEC_WINNT_AUTH_IDENTITY + { + public string User; + public int UserLength; + public string Domain; + public int DomainLength; + public string Password; + public int PasswordLength; + public int Flags; + } + + internal class SSPIHelper + { + public const int TOKEN_QUERY = 0x00008; + public const uint SEC_E_OK = 0; + public const uint SEC_E_INVALID_HANDLE = 0x80090301; + public const uint SEC_E_LOGON_DENIED = 0x8009030C; + public const uint SEC_I_CONTINUE_NEEDED = 0x90312; + public const uint SEC_I_COMPLETE_NEEDED = 0x90313; + public const uint SEC_I_COMPLETE_AND_CONTINUE = 0x90314; + + public const uint SECQOP_WRAP_NO_ENCRYPT = 0x80000001; + + const int SECPKG_CRED_OUTBOUND = 2; + private const int SECURITY_NETWORK_DREP = 0x0; + const int MAX_TOKEN_SIZE = 12288; + //For AcquireCredentialsHandle in 3er Parameter "fCredentialUse" + + SECURITY_HANDLE _hOutboundCred = new SECURITY_HANDLE(0); + public SECURITY_HANDLE _hClientContext = new SECURITY_HANDLE(0); + + public const int ISC_REQ_DELEGATE = 0x00000001; + public const int ISC_REQ_MUTUAL_AUTH = 0x00000002; + public const int ISC_REQ_REPLAY_DETECT = 0x00000004; + public const int ISC_REQ_SEQUENCE_DETECT = 0x00000008; + public const int ISC_REQ_CONFIDENTIALITY = 0x00000010; + public const int ISC_REQ_USE_SESSION_KEY = 0x00000020; + public const int ISC_REQ_PROMPT_FOR_CREDS = 0x00000040; + public const int ISC_REQ_USE_SUPPLIED_CREDS = 0x00000080; + public const int ISC_REQ_ALLOCATE_MEMORY = 0x00000100; + public const int ISC_REQ_USE_DCE_STYLE = 0x00000200; + public const int ISC_REQ_DATAGRAM = 0x00000400; + public const int ISC_REQ_CONNECTION = 0x00000800; + public const int ISC_REQ_CALL_LEVEL = 0x00001000; + public const int ISC_REQ_FRAGMENT_SUPPLIED = 0x00002000; + public const int ISC_REQ_EXTENDED_ERROR = 0x00004000; + public const int ISC_REQ_STREAM = 0x00008000; + public const int ISC_REQ_INTEGRITY = 0x00010000; + public const int ISC_REQ_IDENTIFY = 0x00020000; + public const int ISC_REQ_NULL_SESSION = 0x00040000; + public const int ISC_REQ_MANUAL_CRED_VALIDATION = 0x00080000; + public const int ISC_REQ_RESERVED1 = 0x00100000; + public const int ISC_REQ_FRAGMENT_TO_FIT = 0x00200000; + + public const int SECPKG_ATTR_SIZES = 0; + + public const int STANDARD_CONTEXT_ATTRIBUTES = ISC_REQ_MUTUAL_AUTH; + + bool _bGotClientCredentials = false; + + [DllImport("secur32", CharSet = CharSet.Auto)] + static extern uint AcquireCredentialsHandle( + string pszPrincipal, //SEC_CHAR* + string pszPackage, //SEC_CHAR* //"Kerberos","NTLM","Negotiative" + int fCredentialUse, + IntPtr PAuthenticationID,//_LUID AuthenticationID,//pvLogonID, //PLUID + ref SEC_WINNT_AUTH_IDENTITY pAuthData,//PVOID + int pGetKeyFn, //SEC_GET_KEY_FN + IntPtr pvGetKeyArgument, //PVOID + ref SECURITY_HANDLE phCredential, //SecHandle //PCtxtHandle ref + ref SECURITY_INTEGER ptsExpiry); //PTimeStamp //TimeStamp ref + + [DllImport("secur32", CharSet = CharSet.Auto)] + static extern uint AcquireCredentialsHandle( + string pszPrincipal, //SEC_CHAR* + string pszPackage, //SEC_CHAR* //"Kerberos","NTLM","Negotiative" + int fCredentialUse, + IntPtr PAuthenticationID,//_LUID AuthenticationID,//pvLogonID, //PLUID + IntPtr pAuthData,//PVOID + int pGetKeyFn, //SEC_GET_KEY_FN + IntPtr pvGetKeyArgument, //PVOID + ref SECURITY_HANDLE phCredential, //SecHandle //PCtxtHandle ref + ref SECURITY_INTEGER ptsExpiry); //PTimeStamp //TimeStamp ref + + [DllImport("secur32", CharSet = CharSet.Auto, SetLastError = true)] + static extern uint InitializeSecurityContext( + ref SECURITY_HANDLE phCredential,//PCredHandle + IntPtr phContext, //PCtxtHandle + string pszTargetName, + int fContextReq, + int Reserved1, + int TargetDataRep, + IntPtr pInput, //PSecBufferDesc SecBufferDesc + int Reserved2, + out SECURITY_HANDLE phNewContext, //PCtxtHandle + out SecBufferDesc pOutput, //PSecBufferDesc SecBufferDesc + out uint pfContextAttr, //managed ulong == 64 bits!!! + out SECURITY_INTEGER ptsExpiry); //PTimeStamp + + [DllImport("secur32", CharSet = CharSet.Auto, SetLastError = true)] + static extern uint InitializeSecurityContext( + ref SECURITY_HANDLE phCredential,//PCredHandle + ref SECURITY_HANDLE phContext, //PCtxtHandle + string pszTargetName, + int fContextReq, + int Reserved1, + int TargetDataRep, + ref SecBufferDesc SecBufferDesc, //PSecBufferDesc SecBufferDesc + int Reserved2, + out SECURITY_HANDLE phNewContext, //PCtxtHandle + out SecBufferDesc pOutput, //PSecBufferDesc SecBufferDesc + out uint pfContextAttr, //managed ulong == 64 bits!!! + out SECURITY_INTEGER ptsExpiry); //PTimeStamp + + /* + [DllImport("secur32.Dll", CharSet = CharSet.Auto, SetLastError = false)] + static extern int AcceptSecurityContext(ref SECURITY_HANDLE phCredential, + IntPtr phContext, + ref SecBufferDesc pInput, + uint fContextReq, + uint TargetDataRep, + out SECURITY_HANDLE phNewContext, + out SecBufferDesc pOutput, + out uint pfContextAttr, //managed ulong == 64 bits!!! + out SECURITY_INTEGER ptsTimeStamp); + + [DllImport("secur32.Dll", CharSet = CharSet.Auto, SetLastError = false)] + static extern int AcceptSecurityContext(ref SECURITY_HANDLE phCredential, + ref SECURITY_HANDLE phContext, + ref SecBufferDesc pInput, + uint fContextReq, + uint TargetDataRep, + out SECURITY_HANDLE phNewContext, + out SecBufferDesc pOutput, + out uint pfContextAttr, //managed ulong == 64 bits!!! + out SECURITY_INTEGER ptsTimeStamp); + */ + + [DllImport("secur32.Dll", CharSet = CharSet.Auto, SetLastError = false)] + public static extern int ImpersonateSecurityContext(ref SECURITY_HANDLE phContext); + + [DllImport("secur32.Dll", CharSet = CharSet.Auto, SetLastError = false)] + public static extern int QueryContextAttributes(ref SECURITY_HANDLE phContext, + uint ulAttribute, + out SecPkgContext_Sizes pContextAttributes); + + [DllImport("secur32.Dll", CharSet = CharSet.Auto, SetLastError = false)] + public static extern int EncryptMessage(ref SECURITY_HANDLE phContext, + uint fQOP, //managed ulong == 64 bits!!! + ref SecBufferDesc pMessage, + uint MessageSeqNo); //managed ulong == 64 bits!!! + + [DllImport("secur32.Dll", CharSet = CharSet.Auto, SetLastError = false)] + public static extern int DecryptMessage(ref SECURITY_HANDLE phContext, + ref SecBufferDesc pMessage, + uint MessageSeqNo, + out uint pfQOP); + + [DllImport("secur32.Dll", CharSet = CharSet.Auto, SetLastError = false)] + public static extern int MakeSignature(ref SECURITY_HANDLE phContext, // Context to use + uint fQOP, // Quality of Protection + ref SecBufferDesc pMessage, // Message to sign + uint MessageSeqNo); // Message Sequence Num. + + [DllImport("secur32.Dll", CharSet = CharSet.Auto, SetLastError = false)] + public static extern int VerifySignature(ref SECURITY_HANDLE phContext, // Context to use + ref SecBufferDesc pMessage, // Message to sign + uint MessageSeqNo, // Message Sequence Num. + out uint pfQOP); // Quality of Protection + + + readonly string _sAccountName = WindowsIdentity.GetCurrent().Name; + + public SSPIHelper() + { + + } + + public SSPIHelper(string sRemotePrincipal) + { + _sAccountName = sRemotePrincipal; + } + + private string sUsername; + public string Username + { + set { sUsername = value; } + get { return sUsername; } + } + private string sDomain; + public string Domain + { + set { sDomain = value; } + get { return sDomain; } + } + private string sPassword; + public string Password + { + set { sPassword = value; } + get { return sPassword; } + } + + private bool bUseWindowsCreds = false; + public bool UseWindowsCreds + { + set { bUseWindowsCreds = value; } + get { return bUseWindowsCreds; } + } + + public void ExecuteKerberos(byte[] inToken, out byte[] outToken) + { + if (InitializeKerberosStage) + { + InitializeClient(inToken, out outToken); + } + else + { + if (inToken == null) + { + throw new Exception("Kerberos failure: Incoming bytes can't be null."); + } + + DecryptMessage(0, inToken, out outToken); + + inToken = new byte[] { 0x01, 0x00, 0x00, 0x00 }; + EncryptMessage(inToken, out outToken); + } + } + + private void InitializeClient(byte[] serverToken, out byte[] clientToken) + { + clientToken = null; + + SECURITY_INTEGER ClientLifeTime = new SECURITY_INTEGER(0); + + if (!_bGotClientCredentials) + { + uint returnValue; + + if (!UseWindowsCreds) + { + SEC_WINNT_AUTH_IDENTITY ident = new SEC_WINNT_AUTH_IDENTITY(); + ident.User = Username; + ident.UserLength = ident.User.Length; + ident.Domain = Domain; + ident.DomainLength = ident.Domain.Length; + ident.Password = Password; + ident.PasswordLength = ident.Password.Length; + ident.Flags = 0x1; + + returnValue = AcquireCredentialsHandle(null, "Kerberos", SECPKG_CRED_OUTBOUND, + IntPtr.Zero, ref ident, 0, IntPtr.Zero, + ref _hOutboundCred, ref ClientLifeTime); + } + else + { + returnValue = AcquireCredentialsHandle(null, "Kerberos", SECPKG_CRED_OUTBOUND, + HANDLE.Zero, HANDLE.Zero, 0, HANDLE.Zero, + ref _hOutboundCred, ref ClientLifeTime); + } + + if (returnValue != SEC_E_OK) + { + throw new Exception("Couldn't acquire client credentials"); + } + + _bGotClientCredentials = true; + } + + uint ss; + + SecBufferDesc ClientToken = new SecBufferDesc(MAX_TOKEN_SIZE); + + try + { + uint ContextAttributes; + + if (serverToken == null) + { + ss = InitializeSecurityContext(ref _hOutboundCred, + IntPtr.Zero, + _sAccountName,// null string pszTargetName, + STANDARD_CONTEXT_ATTRIBUTES, + 0,//int Reserved1, + SECURITY_NETWORK_DREP, //int TargetDataRep + IntPtr.Zero, //Always zero first time around... + 0, //int Reserved2, + out _hClientContext, //pHandle CtxtHandle = SecHandle + out ClientToken,//ref SecBufferDesc pOutput, //PSecBufferDesc + out ContextAttributes,//ref int pfContextAttr, + out ClientLifeTime); //ref IntPtr ptsExpiry ); //PTimeStamp + + } + else + { + SecBufferDesc ServerToken = new SecBufferDesc(serverToken); + + try + { + ss = InitializeSecurityContext(ref _hOutboundCred, + ref _hClientContext, + _sAccountName,// null string pszTargetName, + STANDARD_CONTEXT_ATTRIBUTES, + 0,//int Reserved1, + SECURITY_NETWORK_DREP,//int TargetDataRep + ref ServerToken, //Always zero first time around... + 0, //int Reserved2, + out _hClientContext, //pHandle CtxtHandle = SecHandle + out ClientToken,//ref SecBufferDesc pOutput, //PSecBufferDesc + out ContextAttributes,//ref int pfContextAttr, + out ClientLifeTime); //ref IntPtr ptsExpiry ); //PTimeStamp + } + finally + { + ServerToken.Dispose(); + } + } + + if (ss == SEC_E_LOGON_DENIED) + { + throw new Exception("Bad username, password or domain."); + } + else if (ss != SEC_E_OK && ss != SEC_I_CONTINUE_NEEDED) + { + throw new Exception("InitializeSecurityContext() failed!!!"); + } + + clientToken = ClientToken.GetSecBufferByteArray(); + } + finally + { + ClientToken.Dispose(); + } + + InitializeKerberosStage = ss != SEC_E_OK; + } + + private bool bInitializeKerberosStage = true; + private bool InitializeKerberosStage + { + get { return bInitializeKerberosStage; } + set { bInitializeKerberosStage = value; } + } + + public void EncryptMessage(byte[] message, out byte[] encryptedBuffer) + { + encryptedBuffer = null; + + SECURITY_HANDLE EncryptionContext = _hClientContext; + + SecPkgContext_Sizes ContextSizes; + + if (QueryContextAttributes(ref EncryptionContext, + SECPKG_ATTR_SIZES, out ContextSizes) != SEC_E_OK) + { + throw new Exception("QueryContextAttribute() failed!!!"); + } + + MultipleSecBufferHelper[] ThisSecHelper = new MultipleSecBufferHelper[] + { + new MultipleSecBufferHelper(new byte[ContextSizes.cbSecurityTrailer], + SecBufferType.SECBUFFER_TOKEN), + new MultipleSecBufferHelper(message, SecBufferType.SECBUFFER_DATA), + new MultipleSecBufferHelper(new byte[ContextSizes.cbBlockSize], + SecBufferType.SECBUFFER_PADDING) + }; + + SecBufferDesc DescBuffer = new SecBufferDesc(ThisSecHelper); + + try + { + if (EncryptMessage(ref EncryptionContext, + SECQOP_WRAP_NO_ENCRYPT, ref DescBuffer, 0) != SEC_E_OK) + { + throw new Exception("EncryptMessage() failed!!!"); + } + + encryptedBuffer = DescBuffer.GetSecBufferByteArray(); + } + finally + { + DescBuffer.Dispose(); + } + } + + public void DecryptMessage(int messageLength, byte[] encryptedBuffer, out byte[] decryptedBuffer) + { + decryptedBuffer = null; + + SECURITY_HANDLE DecryptionContext = _hClientContext; + + byte[] EncryptedMessage = new byte[messageLength]; + Array.Copy(encryptedBuffer, 0, EncryptedMessage, 0, messageLength); + + int SecurityTrailerLength = encryptedBuffer.Length - messageLength; + + byte[] SecurityTrailer = new byte[SecurityTrailerLength]; + Array.Copy(encryptedBuffer, messageLength, SecurityTrailer, 0, SecurityTrailerLength); + + MultipleSecBufferHelper[] ThisSecHelper = new MultipleSecBufferHelper[] + { + new MultipleSecBufferHelper(EncryptedMessage, SecBufferType.SECBUFFER_DATA), + new MultipleSecBufferHelper(SecurityTrailer, SecBufferType.SECBUFFER_STREAM) + }; + + SecBufferDesc DescBuffer = new SecBufferDesc(ThisSecHelper); + try + { + uint EncryptionQuality; + + if (DecryptMessage(ref DecryptionContext, ref DescBuffer, 0, out EncryptionQuality) != SEC_E_OK) + { + throw new Exception("DecryptMessage() failed!!!"); + } + + decryptedBuffer = new byte[messageLength]; + Array.Copy(DescBuffer.GetSecBufferByteArray(), 0, decryptedBuffer, 0, messageLength); + } + finally + { + DescBuffer.Dispose(); + } + } + } +} + + diff -Nru smuxi-0.8/lib/jabber-net/jabber/connection/sasl/MD5Processor.cs smuxi-0.8.9.1/lib/jabber-net/jabber/connection/sasl/MD5Processor.cs --- smuxi-0.8/lib/jabber-net/jabber/connection/sasl/MD5Processor.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/jabber-net/jabber/connection/sasl/MD5Processor.cs 2012-01-03 07:52:11.000000000 +0000 @@ -0,0 +1,339 @@ +/* -------------------------------------------------------------------------- + * Copyrights + * + * Portions created by or assigned to Cursive Systems, Inc. are + * Copyright (c) 2002-2008 Cursive Systems, Inc. All Rights Reserved. Contact + * information for Cursive Systems, Inc. is available at + * http://www.cursive.net/. + * + * License + * + * Jabber-Net is licensed under the LGPL. + * See LICENSE.txt for details. + * --------------------------------------------------------------------------*/ +using System; +using System.Diagnostics; +using System.Collections; +using System.Security.Cryptography; +using System.Text; +using System.Text.RegularExpressions; +using System.IO; +using System.Xml; + +using bedrock.util; +using jabber.protocol.stream; + +namespace jabber.connection.sasl +{ + /// + /// RFC2831 DIGEST-MD5 SASL mechanism + /// + [SVN(@"$Id$")] + public class MD5Processor : SASLProcessor + { + /// + /// Private members + /// + private string m_response; + private string m_realm; + private string m_username; + private string m_password; + private string m_nonce; + private string m_cnonce; + private int m_nc; + private string m_ncString; + private string m_qop; + private string m_charset; + private string m_authzid; + + private readonly MD5CryptoServiceProvider MD5 = new MD5CryptoServiceProvider(); + private readonly Regex CSV = new Regex(@"(?[^= \t\r\n]+)=(?:(?[^,"" \t\r\n]+)|(?:""(?[^""]*)"")),?", + RegexOptions.ExplicitCapture); + + /// + /// DIGEST-MD5 Realm + /// + public const string REALM = "realm"; + /// + /// DIGEST-MD5 nonce + /// + public const string NONCE = "nonce"; + /// + /// DIGEST-MD5 qop + /// + public const string QOP = "qop"; + /// + /// DIGEST-MD5 charset + /// + public const string CHARSET = "charset"; + /// + /// DIGEST-MD5 algorithm + /// + public const string ALGORITHM = "algorithm"; + /// + /// DIGEST-MD5 authorization id + /// + public const string AUTHZID = "authzid"; + + /// + /// The directives that are required to be set on the SASLProcessor in OnSASLStart + /// + public static readonly string[] s_requiredDirectives = {USERNAME, PASSWORD}; + + private static readonly Encoding ENC = System.Text.Encoding.UTF8; + + /// + /// + /// + public MD5Processor() : base() + { + m_nc = 0; + } + + /// + /// Process the next DIGEST-MD5 step. + /// + /// The previous step. Null for the first step + /// Document to create next step in. + /// + /// Thrown if authentication fails + public override Step step(Step s, XmlDocument doc) + { + Step resp = null; + + if (s == null) + { // first step + Auth a = new Auth(doc); + a.Mechanism = MechanismType.DIGEST_MD5; + return a; + } + + Debug.Assert(s is Challenge); + populateDirectives(ENC.GetString(s.Bytes)); + validateStartDirectives(); + + + resp = new Response(doc); + if (this["rspauth"] == null) // we haven't authenticated yet + { + generateResponseString(); + resp.Bytes = generateResponse(); + } + else // we have authenticated + { + // make sure what is in rspauth is correct + if (!validateResponseAuth()) + { + throw new AuthenticationFailedException(); + } + } + return resp; + } + + /// + /// + /// + /// + private void populateDirectives(string decoded) + { + MatchCollection coll = CSV.Matches(decoded); + foreach (Match m in coll) + { + this[m.Groups["tag"].Value] = m.Groups["data"].Value; + } + } + + + /// + /// + /// + /// + private void validateStartDirectives() + { + Object n; + string temp; + if ( (n = this[USERNAME]) != null) + { + temp = n.ToString(); + m_username = ENC.GetString(ENC.GetBytes(temp)); + } + else + { + throw new MissingDirectiveException("Missing SASL username directive"); + } + if ( (n = this[PASSWORD]) != null) + { + temp = n.ToString(); + m_password = ENC.GetString(ENC.GetBytes(temp)); + } + else + { + throw new MissingDirectiveException("Missing SASL password directive"); + } + + if ( (n = this[REALM]) != null) + { + m_realm = n.ToString(); + } + else + { + throw new InvalidServerChallengeException("Missing SASL realm"); + } + if ( (n = this[NONCE]) != null) + { + m_nonce = n.ToString(); + } + else + { + throw new InvalidServerChallengeException("Missing nonce directive"); + } + if ( (n = this[QOP]) != null) + { + m_qop = n.ToString(); + } + else + { + throw new InvalidServerChallengeException("Missing qop directive"); + } + if ( (n = this[CHARSET]) != null) + { + m_charset = n.ToString(); + } + if ( (n = this[AUTHZID]) != null) + { + m_authzid = n.ToString(); + } + } + + /// + /// Generates the entrire response to send to the server + /// + /// + private byte[] generateResponse() + { + StringBuilder sb = new StringBuilder(); + sb.Append("username=\""); + sb.Append(m_username); + sb.Append("\","); + sb.Append("realm=\""); + sb.Append(m_realm); + sb.Append("\","); + sb.Append("nonce=\""); + sb.Append(m_nonce); + sb.Append("\","); + sb.Append("cnonce=\""); + sb.Append(m_cnonce); + sb.Append("\","); + sb.Append("nc="); + sb.Append(m_ncString); + sb.Append(","); + sb.Append("qop="); + sb.Append(m_qop); + sb.Append(","); + sb.Append("digest-uri=\""); + sb.Append("xmpp/"); + sb.Append(m_realm); + sb.Append("\","); + sb.Append("response="); + sb.Append(m_response); + sb.Append(","); + sb.Append("charset="); + sb.Append(m_charset); + return ENC.GetBytes(sb.ToString()); + } + /// + /// Generates the MD5 hash that goes in the response attribute of the + /// response sent to the server. + /// + private void generateResponseString() + { + // here is where we do the md5 foo + ASCIIEncoding AE = new ASCIIEncoding(); + byte[] H1, H2, H3, temp; + string A1, A2, A3, uri, p1, p2; + + uri = "xmpp/" + m_realm; + Random r = new Random(); + int v = r.Next(1024); + + StringBuilder sb = new StringBuilder(); + sb.Append(v.ToString()); + sb.Append(":"); + sb.Append(m_username); + sb.Append(":"); + sb.Append(m_password); + + m_cnonce = HexString(AE.GetBytes(sb.ToString())).ToLower(); + + m_nc++; + m_ncString = m_nc.ToString().PadLeft(8,'0'); + + sb.Remove(0,sb.Length); + sb.Append(m_username); + sb.Append(":"); + sb.Append(m_realm); + sb.Append(":"); + sb.Append(m_password); + H1 = MD5.ComputeHash(AE.GetBytes(sb.ToString())); + + sb.Remove(0, sb.Length); + sb.Append(":"); + sb.Append(m_nonce); + sb.Append(":"); + sb.Append(m_cnonce); + + if (m_authzid != null) + { + sb.Append(":"); + sb.Append(m_authzid); + } + A1 = sb.ToString(); + + MemoryStream ms = new MemoryStream(); + ms.Write(H1,0,16); + temp = AE.GetBytes(A1); + ms.Write(temp,0,temp.Length); + ms.Seek(0,System.IO.SeekOrigin.Begin); + H1 = MD5.ComputeHash(ms); + + sb.Remove(0,sb.Length); + sb.Append("AUTHENTICATE:"); + sb.Append(uri); + if (m_qop.CompareTo("auth") != 0) + { + sb.Append(":00000000000000000000000000000000"); + } + A2 = sb.ToString(); + H2 = AE.GetBytes(A2); + H2 = MD5.ComputeHash(H2); + + // create p1 and p2 as the hex representation of H1 and H2 + p1 = HexString(H1).ToLower(); + p2 = HexString(H2).ToLower(); + + sb.Remove(0, sb.Length); + sb.Append(p1); + sb.Append(":"); + sb.Append(m_nonce); + sb.Append(":"); + sb.Append(m_ncString); + sb.Append(":"); + sb.Append(m_cnonce); + sb.Append(":"); + sb.Append(m_qop); + sb.Append(":"); + sb.Append(p2); + + A3 = sb.ToString(); + H3 = MD5.ComputeHash(AE.GetBytes(A3)); + m_response = HexString(H3).ToLower(); + } + + private bool validateResponseAuth() + { + //TODO: We need to validate the respauth's value by going through the responseString + //function again + return true; + } + } +} diff -Nru smuxi-0.8/lib/jabber-net/jabber/connection/sasl/PlainProcessor.cs smuxi-0.8.9.1/lib/jabber-net/jabber/connection/sasl/PlainProcessor.cs --- smuxi-0.8/lib/jabber-net/jabber/connection/sasl/PlainProcessor.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/jabber-net/jabber/connection/sasl/PlainProcessor.cs 2012-01-03 07:52:11.000000000 +0000 @@ -0,0 +1,63 @@ +/* -------------------------------------------------------------------------- + * Copyrights + * + * Portions created by or assigned to Cursive Systems, Inc. are + * Copyright (c) 2002-2008 Cursive Systems, Inc. All Rights Reserved. Contact + * information for Cursive Systems, Inc. is available at + * http://www.cursive.net/. + * + * License + * + * Jabber-Net is licensed under the LGPL. + * See LICENSE.txt for details. + * --------------------------------------------------------------------------*/ +using System; +using System.IO; +using System.Diagnostics; +using System.Xml; + +using bedrock.util; +using jabber.protocol.stream; + +namespace jabber.connection.sasl +{ + /// + /// SASL Mechanism PLAIN as specified in RFC 2595. + /// + [SVN(@"$Id$")] + public class PlainProcessor : SASLProcessor + { + /// + /// Perform the next step + /// + /// Null if it's the initial response + /// Document to create Steps in + /// + public override Step step(Step s, XmlDocument doc) + { + Debug.Assert(s == null); + Auth a = new Auth(doc); + a.Mechanism = MechanismType.PLAIN; + MemoryStream ms = new MemoryStream(); + + // message = [authorize-id] NUL authenticate-id NUL password + + // Skip authzid. + ms.WriteByte(0); + string u = this[USERNAME]; + if ((u == null) || (u == "")) + throw new SASLException("Username required"); + byte[] bu = System.Text.Encoding.UTF8.GetBytes(u); + ms.Write(bu, 0, bu.Length); + ms.WriteByte(0); + string p = this[PASSWORD]; + if ((p == null) || (p == "")) + throw new SASLException("Password required"); + byte[] pu = System.Text.Encoding.UTF8.GetBytes(p); + ms.Write(pu, 0, pu.Length); + + a.Bytes = ms.ToArray(); + return a; + } + } +} diff -Nru smuxi-0.8/lib/jabber-net/jabber/connection/sasl/SASLProcessor.cs smuxi-0.8.9.1/lib/jabber-net/jabber/connection/sasl/SASLProcessor.cs --- smuxi-0.8/lib/jabber-net/jabber/connection/sasl/SASLProcessor.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/jabber-net/jabber/connection/sasl/SASLProcessor.cs 2012-01-03 07:52:11.000000000 +0000 @@ -0,0 +1,191 @@ +/* -------------------------------------------------------------------------- + * Copyrights + * + * Portions created by or assigned to Cursive Systems, Inc. are + * Copyright (c) 2002-2008 Cursive Systems, Inc. All Rights Reserved. Contact + * information for Cursive Systems, Inc. is available at + * http://www.cursive.net/. + * + * License + * + * Jabber-Net is licensed under the LGPL. + * See LICENSE.txt for details. + * --------------------------------------------------------------------------*/ +using System; +using System.Collections; +using System.Xml; +using System.Text; + +using bedrock.util; +using jabber.protocol.stream; + +namespace jabber.connection.sasl +{ + /// + /// A SASL processor instance has been created. Fill it with information, like USERNAME and PASSWORD. + /// + public delegate void SASLProcessorHandler(Object sender, SASLProcessor proc); + + /// + /// Some sort of SASL error + /// + [SVN(@"$Id$")] + public class SASLException : ApplicationException + { + /// + /// + /// + /// + public SASLException(string message) : base(message){} + + /// + /// + /// + public SASLException() : base(){} + } + + /// + /// Authentication failed. + /// + [SVN(@"$Id$")] + public class AuthenticationFailedException : SASLException + { + /// + /// + /// + public AuthenticationFailedException() : base() + {} + + /// + /// + /// + /// + public AuthenticationFailedException(string message) : base(message) + {} + } + + /// + /// A required directive wasn't supplied. + /// + [SVN(@"$Id$")] + public class MissingDirectiveException : SASLException + { + /// + /// + /// + /// + public MissingDirectiveException(string message) : base(message) + {} + } + + /// + /// Server sent an invalid challenge + /// + [SVN(@"$Id$")] + public class InvalidServerChallengeException : SASLException + { + /// + /// + /// + /// + public InvalidServerChallengeException(string message) : base(message) + {} + } + /// + /// Summary description for SASLProcessor. + /// + [SVN(@"$Id$")] + public abstract class SASLProcessor + { + /// + /// SASL username + /// + public const string USERNAME = "username"; + /// + /// SASL password + /// + public const string PASSWORD = "password"; + + + /// + /// + /// + private Hashtable m_directives = new Hashtable(); + + /// + /// + /// + public SASLProcessor() + { + } + + /// + /// Create a new SASLProcessor, of the best type possible + /// + /// The types the server implements + /// Is it ok to select insecure types? + /// The mechanisms supported by the server + /// + public static SASLProcessor createProcessor(MechanismType mt, bool plaintextOK, Mechanisms mechs) + { + if ((mt & MechanismType.EXTERNAL) == MechanismType.EXTERNAL) + { + return new ExternalProcessor(); + } + if ((mt & MechanismType.GSSAPI) == MechanismType.GSSAPI) + { + string RemotePrincipal = ""; + foreach (Mechanism mechanism in mechs.GetMechanisms()) + { + if (mechanism.MechanismName == "GSSAPI") + { + RemotePrincipal = mechanism.GetAttribute("kerb:principal"); + break; + } + } + return new KerbProcessor(RemotePrincipal); + } + if ((mt & MechanismType.DIGEST_MD5) == MechanismType.DIGEST_MD5) + { + return new MD5Processor(); + } + else if (plaintextOK && ((mt & MechanismType.PLAIN) == MechanismType.PLAIN)) + { + return new PlainProcessor(); + } + return null; + } + + /// + /// Data for performing SASL challenges and responses. + /// + public string this[string directive] + { + get { return (string) m_directives[directive]; } + set { m_directives[directive] = value; } + } + + /// + /// Perform the next step + /// + /// Null if it's the initial response + /// Document to create Steps in + /// + public abstract Step step(Step s, XmlDocument doc); + + /// + /// byte array as a hex string, two chars per byte. + /// + /// Byte array + /// + protected static string HexString(byte[] buf) + { + StringBuilder sb = new StringBuilder(); + foreach (byte b in buf) + { + sb.Append(b.ToString("x2")); + } + return sb.ToString(); + } + } +} diff -Nru smuxi-0.8/lib/jabber-net/jabber/connection/SocketStanzaStream.cs smuxi-0.8.9.1/lib/jabber-net/jabber/connection/SocketStanzaStream.cs --- smuxi-0.8/lib/jabber-net/jabber/connection/SocketStanzaStream.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/jabber-net/jabber/connection/SocketStanzaStream.cs 2012-01-03 07:52:11.000000000 +0000 @@ -0,0 +1,467 @@ +/* -------------------------------------------------------------------------- + * Copyrights + * + * Portions created by or assigned to Cursive Systems, Inc. are + * Copyright (c) 2002-2008 Cursive Systems, Inc. All Rights Reserved. Contact + * information for Cursive Systems, Inc. is available at + * http://www.cursive.net/. + * + * License + * + * Jabber-Net is licensed under the LGPL. + * See LICENSE.txt for details. + * --------------------------------------------------------------------------*/ +using System; +using System.Diagnostics; +using System.Threading; +using System.Xml; + +using bedrock.net; +using bedrock.util; +using jabber.protocol; + +namespace jabber.connection +{ + /// + /// Contains the types of proxies Jabber-Net supports. This is only for socket connections. + /// + [SVN(@"$Id$")] + public enum ProxyType + { + /// + /// no proxy + /// + None, + /// + /// SOCKS4 as in http://archive.socks.permeo.com/protocol/socks4.protocol + /// + Socks4, + /// + /// SOCKS5 as in http://archive.socks.permeo.com/rfc/rfc1928.txt + /// + Socks5, + /// + /// HTTP CONNECT + /// + HTTP, + } + + + /// + /// "Standard" XMPP socket for outbound connections. + /// + [SVN(@"$Id$")] + public class SocketStanzaStream : StanzaStream, ISocketEventListener + { + private AsynchElementStream m_elements = null; + private BaseSocket m_sock = null; + private BaseSocket m_accept = null; + private Timer m_timer = null; + + /// + /// Create a new one. + /// + /// + internal SocketStanzaStream(IStanzaEventListener listener) : base(listener) + { + m_timer = new Timer(new TimerCallback(DoKeepAlive), null, Timeout.Infinite, Timeout.Infinite); + } + + /// + /// Determines if the socket is connected. + /// + public override bool Connected + { + get { return ASock.Connected; } + } + + /// + /// Determines whether or not Jabber-Net supports StartTLS. + /// + public override bool SupportsTLS + { + get + { +#if NO_SSL + return false; +#else + return true; +#endif + } + } + + /// + /// Determines whether or not Jabber-Net supports compression. + /// + public override bool SupportsCompression + { + get + { + try + { +#if ZLIB_NET + return bedrock.io.ZlibStream.Supported; +#else + return false; +#endif + } + catch + { + Debug.WriteLine("WARNING: zlib.net.dll missing!"); + return false; + } + } + } + + private AsyncSocket ASock + { + get + { + if (m_sock is ProxySocket) + return ((ProxySocket)m_sock).Socket as AsyncSocket; + else + return m_sock as AsyncSocket; + } + } + + /// + /// Initializes the element stream. This is the place to add factories. + /// + public override void InitializeStream() + { + bool first = (m_elements == null); + m_elements = new AsynchElementStream(); + m_elements.OnDocumentStart += new ProtocolHandler(m_elements_OnDocumentStart); + m_elements.OnDocumentEnd += new bedrock.ObjectHandler(m_elements_OnDocumentEnd); + m_elements.OnElement += new ProtocolHandler(m_elements_OnElement); + m_elements.OnError += new bedrock.ExceptionHandler(m_elements_OnError); + + m_listener.StreamInit(m_elements); + + Debug.Assert(this.Connected); + if (first) + m_sock.RequestRead(); + + } + + /// + /// Connects to the XMPP server. + /// + public override void Connect() + { + m_elements = null; + int port = (int)m_listener[Options.PORT]; + Debug.Assert(port > 0); + //m_sslOn = m_ssl; + + ProxySocket proxy = null; + ProxyType pt = (ProxyType)m_listener[Options.PROXY_TYPE]; + switch (pt) + { + case ProxyType.Socks4: + proxy = new Socks4Proxy(this); + break; + + case ProxyType.Socks5: + proxy = new Socks5Proxy(this); + break; + + case ProxyType.HTTP: + proxy = new ShttpProxy(this); + break; + + /* + case ProxyType.HTTP_Polling: + XEP25Socket j25s = new XEP25Socket(this); + if (m_ProxyHost != null) + { + System.Net.WebProxy wp = new System.Net.WebProxy(); + wp.Address = new Uri("http://" + m_ProxyHost + ":" + m_ProxyPort); + if (m_ProxyUsername != null) + { + wp.Credentials = new System.Net.NetworkCredential(m_ProxyUsername, m_ProxyPassword); + } + j25s.Proxy = wp; + } + j25s.URL = m_server; + m_sock = j25s; + break; + */ + case ProxyType.None: + m_sock = new AsyncSocket(null, this, (bool)m_listener[Options.SSL], false); + + ((AsyncSocket)m_sock).LocalCertificate = m_listener[Options.LOCAL_CERTIFICATE] as + System.Security.Cryptography.X509Certificates.X509Certificate2; + + ((AsyncSocket)m_sock).CertificateGui = (bool)m_listener[Options.CERTIFICATE_GUI]; + break; + + default: + throw new ArgumentException("no handler for proxy type: " + pt, "ProxyType"); + } + + if (proxy != null) + { + proxy.Socket = new AsyncSocket(null, proxy, (bool)m_listener[Options.SSL], false); + ((AsyncSocket)proxy.Socket).LocalCertificate = m_listener[Options.LOCAL_CERTIFICATE] as + System.Security.Cryptography.X509Certificates.X509Certificate2; + + proxy.Host = m_listener[Options.PROXY_HOST] as string; + proxy.Port = (int)m_listener[Options.PROXY_PORT]; + proxy.Username = m_listener[Options.PROXY_USER] as string; + proxy.Password = m_listener[Options.PROXY_PW] as string; + m_sock = proxy; + } + + string to = (string)m_listener[Options.TO]; + Debug.Assert(to != null); + + string host = (string)m_listener[Options.NETWORK_HOST]; + if ((host == null) || (host == "")) + { +#if __MonoCS__ + host = to; +#else + try + { + Address.LookupSRV((string)m_listener[Options.SRV_PREFIX], to, ref host, ref port); + } + catch + { + Debug.WriteLine("WARNING: netlib.Dns.dll missing"); + host = to; + } +#endif + } + + Address addr = new Address(host, port); + m_sock.Connect(addr, (string)m_listener[Options.SERVER_ID]); + } + + /// + /// Listens for an inbound connection. + /// + public override void Accept() + { + if (m_accept == null) + { + m_accept = new AsyncSocket(null, this, (bool)m_listener[Options.SSL], false); + ((AsyncSocket)m_accept).LocalCertificate = m_listener[Options.LOCAL_CERTIFICATE] as + System.Security.Cryptography.X509Certificates.X509Certificate2; + + Address addr = new Address((string)m_listener[Options.NETWORK_HOST], + (int)m_listener[Options.PORT]); + + m_accept.Accept(addr); + } + m_accept.RequestAccept(); + } + + /// + /// Determines if the method Accept() can be called now. + /// + public override bool Acceptable + { + get + { + return (m_accept != null); + } + } + + /// + /// Writes the given string to the socket after UTF-8 encoding. + /// + /// String to write out. + public override void Write(string str) + { + int keep = (int)m_listener[Options.CURRENT_KEEP_ALIVE]; + if (keep > 0) + m_timer.Change(keep, keep); + m_sock.Write(ENC.GetBytes(str)); + } + + /// + /// Writes a stream:stream. + /// + /// Stream containing the stream:stream packet to send. + public override void WriteStartTag(jabber.protocol.stream.Stream stream) + { + Write(stream.StartTag()); + } + + /// + /// Writes a full stanza. + /// + /// XML stanza to write. + public override void Write(XmlElement elem) + { + if (m_sock is IElementSocket) + ((IElementSocket)m_sock).Write(elem); + else + Write(elem.OuterXml); + } + + /// + /// Closes the session with the XMPP server. + /// + /// Sends the close stanza to the XMPP server if true. + public override void Close(bool clean) + { + // Note: socket should still be connected, excepts for races. Revist. + if (clean) + Write(""); + m_sock.Close(); + } + + private void DoKeepAlive(object state) + { + if ((m_sock != null) && this.Connected && ((int)m_listener[Options.CURRENT_KEEP_ALIVE] > 0)) + m_sock.Write(new byte[] { 32 }); + } + +#if !NO_SSL + /// + /// Negotiates Start-TLS with the other endpoint. + /// + public override void StartTLS() + { + m_sock.StartTLS(); + AsyncSocket s = ASock; + + Debug.Assert(s != null); + m_listener[Options.REMOTE_CERTIFICATE] = s.RemoteCertificate; + } +#endif + + /// + /// Starts compressing outgoing traffic for this connection with the XMPP server. + /// + public override void StartCompression() + { + m_sock.StartCompression(); + } + + #region ElementStream handlers + private void m_elements_OnDocumentStart(object sender, XmlElement rp) + { + m_listener.DocumentStarted(rp); + } + + private void m_elements_OnDocumentEnd(object sender) + { + m_listener.DocumentEnded(); + } + + private void m_elements_OnElement(object sender, XmlElement rp) + { + m_listener.StanzaReceived(rp); + } + + private void m_elements_OnError(object sender, Exception ex) + { + // XML parse error. + m_timer.Change(Timeout.Infinite, Timeout.Infinite); + m_listener.Errored(ex); + } + #endregion + + #region ISocketEventListener Members + + void ISocketEventListener.OnInit(BaseSocket newSock) + { + } + + ISocketEventListener ISocketEventListener.GetListener(BaseSocket newSock) + { + return this; + } + + bool ISocketEventListener.OnAccept(BaseSocket newsocket) + { + m_sock = newsocket; + InitializeStream(); + m_listener.Accepted(); + + // Don't accept any more connections until this one closes + // yes, it will look like we're still listening until the old sock is free'd by GC. + // don't want OnClose() to fire, though, so we can't close the previous sock. + return false; + } + + void ISocketEventListener.OnConnect(BaseSocket sock) + { +#if !NO_SSL + if ((bool)m_listener[Options.SSL]) + { + AsyncSocket s = sock as AsyncSocket; + m_listener[Options.REMOTE_CERTIFICATE] = s.RemoteCertificate; + } +#endif + m_listener.Connected(); + } + + void ISocketEventListener.OnClose(BaseSocket sock) + { + //System.Windows.Forms.Application.DoEvents(); + //System.Threading.Thread.Sleep(1000); + m_listener[Options.REMOTE_CERTIFICATE] = null; + //m_elements = null; + m_timer.Change(Timeout.Infinite, Timeout.Infinite); + m_listener.Closed(); + } + + void ISocketEventListener.OnError(BaseSocket sock, Exception ex) + { + m_listener[Options.REMOTE_CERTIFICATE] = null; + //m_elements = null; + m_timer.Change(Timeout.Infinite, Timeout.Infinite); + m_listener.Errored(ex); + } + + bool ISocketEventListener.OnRead(BaseSocket sock, byte[] buf, int offset, int length) + { + int tim = (int)m_listener[Options.KEEP_ALIVE]; + if (tim > 0) + m_timer.Change(tim, tim); + + m_listener.BytesRead(buf, offset, length); + try + { + m_elements.Push(buf, offset, length); + } + catch (Exception e) + { + ((ISocketEventListener)this).OnError(sock, e); + sock.Close(); + return false; + } + return true; + } + + void ISocketEventListener.OnWrite(BaseSocket sock, byte[] buf, int offset, int length) + { + int tim = (int)m_listener[Options.KEEP_ALIVE]; + if (tim > 0) + m_timer.Change(tim, tim); + + m_listener.BytesWritten(buf, offset, length); + } + + /// + /// An invalid peer certificate was sent during SSL/TLS neogtiation. + /// + /// The socket that experienced the error + /// The bad certificate + /// The chain of CAs for the cert + /// A bitfield for the erorrs in the certificate. + /// True if the cert should be accepted anyway. + bool ISocketEventListener.OnInvalidCertificate(BaseSocket sock, + System.Security.Cryptography.X509Certificates.X509Certificate certificate, + System.Security.Cryptography.X509Certificates.X509Chain chain, + System.Net.Security.SslPolicyErrors sslPolicyErrors) + { + return m_listener.OnInvalidCertificate(sock, certificate, chain, sslPolicyErrors); + } + #endregion + } +} diff -Nru smuxi-0.8/lib/jabber-net/jabber/connection/StanzaStream.cs smuxi-0.8.9.1/lib/jabber-net/jabber/connection/StanzaStream.cs --- smuxi-0.8/lib/jabber-net/jabber/connection/StanzaStream.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/jabber-net/jabber/connection/StanzaStream.cs 2012-01-03 07:52:11.000000000 +0000 @@ -0,0 +1,296 @@ +/* -------------------------------------------------------------------------- + * Copyrights + * + * Portions created by or assigned to Cursive Systems, Inc. are + * Copyright (c) 2002-2008 Cursive Systems, Inc. All Rights Reserved. Contact + * information for Cursive Systems, Inc. is available at + * http://www.cursive.net/. + * + * License + * + * Jabber-Net is licensed under the LGPL. + * See LICENSE.txt for details. + * --------------------------------------------------------------------------*/ +using System; +using System.Diagnostics; +using System.Text; +using System.Xml; + +using bedrock.net; +using bedrock.util; +using jabber.protocol; + +namespace jabber.connection +{ + /// + /// Specifies the connection type, such as socket, polling, and so on. + /// + [SVN(@"$Id$")] + public enum ConnectionType + { + /// + /// Uses "Normal" XMPP socket + /// + Socket, + /// + /// Uses HTTP Polling, as in http://www.xmpp.org/extensions/xep-0025.html + /// + HTTP_Polling, + /// + /// Uses HTTP Binding, as in http://www.xmpp.org/extensions/xep-0124.html + /// + HTTP_Binding + } + + /// + /// Listens for stanza and connection events + /// + [SVN(@"$Id$")] + public interface IStanzaEventListener + { + /// + /// Gets or sets properties on the listener. + /// + /// Property name. Look at the Options class for some ideas. + /// + object this[string prop] + { + get; + set; + } + + /// + /// Notifies the user that one of the properties has changed. + /// + event System.ComponentModel.PropertyChangedEventHandler PropertyChanged; + + /// + /// Informs the client that the connection to the XMPP server has finished. + /// Time to send the stream:stream packet. + /// + void Connected(); + + /// + /// Informs the client that a new connection from the server has been accepted. + /// Wait for a stream:stream. + /// + void Accepted(); + + /// + /// Informs the client that text was read from the XMPP server. + /// Use for debugging only. + /// Will NOT be complete nodes at a time. + /// + /// Buffer containing the data read. + /// Where in the buffer the read data begins. + /// Length of the data read. + void BytesRead(byte[] buf, int offset, int len); + + /// + /// Informs the client that text was written to the server. + /// Use for debugging only. Will NOT be complete nodes at a time. + /// + /// Bytes to write out. + /// The index in the buffer to start getting bytes. + /// The amount of bytes to write out. + void BytesWritten(byte[] buf, int offset, int len); + + /// + /// Informs the client that a new stream was initialized. + /// You can add your packet factories to it. + /// + /// The stream that was initialized. + void StreamInit(ElementStream stream); + + /// + /// Notifies the client that an error has occurred. + /// + /// The exception that caused the error. + void Errored(Exception e); + + /// + /// Notifies the client that the session has been closed. + /// + void Closed(); + + /// + /// Informs the client that a doc start tag has been received. + /// This may be "synthetic" for some backends. + /// + /// XML element containing the start tag. + void DocumentStarted(XmlElement elem); + + /// + /// Receives the closing stream:stream. Probably mostly equivalent to Closed(), + /// except if the stream is still open, you should close it at this point. + /// May not be called for some backends. + /// + void DocumentEnded(); + + /// + /// Receives an XML element such as stream:features and so on. + /// + /// The XML Element received. + void StanzaReceived(XmlElement elem); + + /// + /// An invalid peer certificate was sent during SSL/TLS neogtiation. + /// + /// The socket that experienced the error + /// The bad certificate + /// The chain of CAs for the cert + /// A bitfield for the erorrs in the certificate. + /// True if the cert should be accepted anyway. + bool OnInvalidCertificate(BaseSocket sock, + System.Security.Cryptography.X509Certificates.X509Certificate certificate, + System.Security.Cryptography.X509Certificates.X509Chain chain, + System.Net.Security.SslPolicyErrors sslPolicyErrors); + } + + /// + /// Manages the base stream for reading and writing full stanzas. + /// + [SVN(@"$Id$")] + public abstract class StanzaStream + { + /// + /// Text encoding. Always UTF-8 for XMPP. + /// + protected readonly Encoding ENC = Encoding.UTF8; + + /// + /// Notifies the client that an event has occurred. + /// + protected IStanzaEventListener m_listener = null; + + /// + /// Creates a StanzaStream. + /// + /// Connection type, such as socket, polling, and so on. + /// Connection event listeners. + /// StanzaStream used to connect to an XMPP server and send stanzas. + public static StanzaStream Create(ConnectionType kind, IStanzaEventListener listener) + { + switch (kind) + { + case ConnectionType.Socket: + return new SocketStanzaStream(listener); + case ConnectionType.HTTP_Polling: + return new PollingStanzaStream(listener); + case ConnectionType.HTTP_Binding: + return new BindingStanzaStream(listener); + default: + throw new NotImplementedException("Proxy type not implemented yet: " + kind.ToString()); + } + } + + /// + /// Creates a new stanza stream. + /// + /// Event listener associated with the new stanza stream. + protected StanzaStream(IStanzaEventListener listener) + { + Debug.Assert(listener != null); + m_listener = listener; + } + + /// + /// Starts the outbound connection to the XMPP server. + /// + abstract public void Connect(); + + /// + /// Listens for an inbound connection. Only implemented by socket types for now. + /// + virtual public void Accept() + { + throw new NotImplementedException("Accept not implemented on this stream type"); + } + + /// + /// Determines whether or not the client can call the Accept() method. + /// + virtual public bool Acceptable + { + get { return false; } + } + + /// + /// Starts the TLS handshake. + /// + virtual public void StartTLS() + { + throw new NotImplementedException("Start-TLS not implemented on this stream type"); + } + + /// + /// Starts the compression on the connection. + /// + virtual public void StartCompression() + { + throw new NotImplementedException("Start-TLS not implemented on this stream type"); + } + + /// + /// Initializes a new stream:stream. + /// + virtual public void InitializeStream() + { + } + + /// + /// Writes a stream:stream start tag. + /// Some underlying implementations will ignore this, + /// but may pull out pertinent data. + /// + /// Stream containing the start tag. + abstract public void WriteStartTag(jabber.protocol.stream.Stream stream); + + /// + /// Writes an entire XML element. + /// + /// XML element to write out. + abstract public void Write(XmlElement elem); + + /// + /// Writes a raw string. + /// + /// String to write out. + abstract public void Write(string str); + + /// + /// Closes the session with the XMPP server. + /// + /// If true, send the stream:stream close packet. + abstract public void Close(bool clean); + + /// + /// Determines whether or not the client is connected to the XMPP server. + /// + abstract public bool Connected + { + get; + } + + /// + /// Determines whether or not Jabber-Net supports TLS. + /// + virtual public bool SupportsTLS + { + get { return false; } + } + + /// + /// Determines whether or not this stream supports compression (XEP-0138). + /// + virtual public bool SupportsCompression + { + get { return false; } + } + } + + /// + /// Informs the client that something happened on a StanzaStream. + /// + public delegate void StanzaStreamHandler(object sender, StanzaStream stream); +} diff -Nru smuxi-0.8/lib/jabber-net/jabber/connection/States.cs smuxi-0.8.9.1/lib/jabber-net/jabber/connection/States.cs --- smuxi-0.8/lib/jabber-net/jabber/connection/States.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/jabber-net/jabber/connection/States.cs 2012-01-03 07:52:11.000000000 +0000 @@ -0,0 +1,216 @@ +/* -------------------------------------------------------------------------- + * Copyrights + * + * Portions created by or assigned to Cursive Systems, Inc. are + * Copyright (c) 2002-2008 Cursive Systems, Inc. All Rights Reserved. Contact + * information for Cursive Systems, Inc. is available at + * http://www.cursive.net/. + * + * License + * + * Jabber-Net is licensed under the LGPL. + * See LICENSE.txt for details. + * --------------------------------------------------------------------------*/ +using System; + +using bedrock.util; + +namespace jabber.connection +{ + /// + /// Represents the base class for all states. + /// + [SVN(@"$Id$")] + public abstract class BaseState + { + } + + /// + /// Specifies the state is up and running. If subclasses change the + /// state transition approach, they should end at the RunningState state. + /// + [SVN(@"$Id$")] + public class RunningState : BaseState + { + /// + /// Returns the instance of the running state. + /// + public static readonly BaseState Instance = new RunningState(); + } + + /// + /// Specifies the state is not connected. + /// + [SVN(@"$Id$")] + public class ClosedState : BaseState + { + /// + /// Returns the instance of the closed state. + /// + public static readonly BaseState Instance = new ClosedState(); + } + + /// + /// Specifies the state is in the process of connecting such as + /// DNS lookup, socket setup, and so on. + /// + [SVN(@"$Id$")] + public class ConnectingState : BaseState + { + /// + /// Returns the instance of the connecting state. + /// + public static readonly BaseState Instance = new ConnectingState(); + } + + /// + /// Specifies the state is in the "connected socket" state. + /// + [SVN(@"$Id$")] + public class ConnectedState : BaseState + { + /// + /// The instance that is always used. + /// + public static readonly BaseState Instance = new ConnectedState(); + } + + /// + /// Specifies the state is in the "stream:stream has been received" state. + /// + [SVN(@"$Id$")] + public class StreamState : BaseState + { + /// + /// Returns the instance of the XMPP stream state. + /// + public static readonly BaseState Instance = new StreamState(); + } + + /// + /// Specifies the state is in a closing state. + /// A close was requested, but hasn't yet finalized. + /// + [SVN(@"$Id$")] + public class ClosingState : BaseState + { + /// + /// Returns the instance for the closing state. + /// + public static readonly BaseState Instance = new ClosingState(); + } + + /// + /// Specifies the state is in a paused state waiting for reconnect timeout. + /// + [SVN(@"$Id$")] + public class ReconnectingState : BaseState + { + /// + /// Returns the instance of the reconnecting state. + /// + public static readonly BaseState Instance = new ReconnectingState(); + } + + /// + /// Specifies the state is in the "Accepting incoming socket connections" state. + /// + [SVN(@"$Id$")] + public class AcceptingState : BaseState + { + /// + /// Returns the instance of the accepting state. + /// + public static readonly BaseState Instance = new AcceptingState(); + } + /// + /// Specifies the state is in Old-style auth, iq:auth or handshake. + /// + [SVN(@"$Id$")] + public class NonSASLAuthState : BaseState + { + /// + /// Returns the instance of the non SASL authentication state. + /// + public static readonly BaseState Instance = new NonSASLAuthState(); + } + /// + /// Specifies the state is in waiting for the server to send the features element. + /// + [SVN(@"$Id$")] + public class ServerFeaturesState : BaseState + { + /// + /// Returns the instance of the server features state. + /// + public static readonly BaseState Instance = new ServerFeaturesState(); + } + /// + /// Specifies the state is in Start-TLS. + /// + [SVN(@"$Id$")] + public class StartTLSState : BaseState + { + /// + /// Returns the instance of the Start-TLS state. + /// + public static readonly BaseState Instance = new StartTLSState(); + } + /// + /// Specifies the state is in the compression state. + /// + [SVN(@"$Id$")] + public class CompressionState : BaseState + { + /// + /// The instance that is always used. + /// + public static readonly BaseState Instance = new CompressionState(); + } + /// + /// Specifies the state is in SASL Authentication. + /// + [SVN(@"$Id$")] + public class SASLState : BaseState + { + /// + /// Returns the instance of the SASL state. + /// + public static readonly BaseState Instance = new SASLState(); + } + /// + /// Specifies the state is in the SASL Authentication has finished state. + /// Restarting the stream for the last time. + /// + [SVN(@"$Id$")] + public class SASLAuthedState : BaseState + { + /// + /// Returns the instance for the SASL authentication state. + /// + public static readonly BaseState Instance = new SASLAuthedState(); + } + /// + /// SASL Authentication failed. On some servers you can re-try, or register. + /// + [SVN(@"$Id$")] + public class SASLFailedState : BaseState + { + /// + /// The instance that is always used. + /// + public static readonly BaseState Instance = new SASLFailedState(); + } + /// + /// Specifies the state is in the "Binding session" state. + /// + [SVN(@"$Id$")] + public class BindState : BaseState + { + /// + /// Returns the instance for the Bind state. + /// + public static readonly BaseState Instance = new BindState(); + } + +} diff -Nru smuxi-0.8/lib/jabber-net/jabber/connection/StreamComponent.cs smuxi-0.8.9.1/lib/jabber-net/jabber/connection/StreamComponent.cs --- smuxi-0.8/lib/jabber-net/jabber/connection/StreamComponent.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/jabber-net/jabber/connection/StreamComponent.cs 2012-01-03 07:52:11.000000000 +0000 @@ -0,0 +1,149 @@ +/* -------------------------------------------------------------------------- + * Copyrights + * + * Portions created by or assigned to Cursive Systems, Inc. are + * Copyright (c) 2002-2008 Cursive Systems, Inc. All Rights Reserved. Contact + * information for Cursive Systems, Inc. is available at + * http://www.cursive.net/. + * + * License + * + * Jabber-Net is licensed under the LGPL. + * See LICENSE.txt for details. + * --------------------------------------------------------------------------*/ +using System; +using System.ComponentModel; +using System.ComponentModel.Design; +using System.Xml; + +using bedrock.util; +using System.Diagnostics; +using jabber.protocol.client; + +namespace jabber.connection +{ + /// + /// Manages the XmppStream as a component. + /// + [SVN(@"$Id$")] + public abstract class StreamComponent : System.ComponentModel.Component + { + /// + /// Finds the first component that subclasses XmppStream in Visual Studio + /// during runtime. + /// + /// + /// Calls GetService(typeof(IDesignerHost)) on your control to get this. + /// + /// Null if none found + public static XmppStream GetStreamFromHost(IDesignerHost host) + { + return (XmppStream)GetComponentFromHost(host, typeof(XmppStream)); + } + + /// + /// Finds the first component that subclasses the given type at runtime. + /// + /// Call GetService(typeof(IDesignerHost)) on your control to get this. + /// The type to search for. + /// Null if none found + public static Component GetComponentFromHost(IDesignerHost host, Type type) + { + if (host == null) + return null; + Debug.Assert(type != null); + Component root = host.RootComponent as Component; + if (root == null) + return null; + + foreach (Component c in root.Container.Components) + { + if (type.IsAssignableFrom(c.GetType())) + return c; + } + return null; + } + + /// + /// Retrieves the XmppStream for this control. + /// Set at design time when a subclass control is dragged onto a form. + /// + protected XmppStream m_stream = null; + + /// + /// Informs the client that the XmppStream was changed. + /// Often at design time, the object will be this StreamComponent. + /// + public event bedrock.ObjectHandler OnStreamChanged; + + /// + /// Gets and sets the JabberClient or JabberService XMPP stream value. + /// + [Description("The JabberClient or JabberService to hook up to.")] + [Category("Jabber")] + public virtual XmppStream Stream + { + get + { + // If we are running in the designer, let's try to get an XmppStream control + // from the environment. + if ((this.m_stream == null) && DesignMode) + { + IDesignerHost host = (IDesignerHost)base.GetService(typeof(IDesignerHost)); + this.Stream = GetStreamFromHost(host); + } + return m_stream; + } + set + { + if ((object)m_stream != (object)value) + { + m_stream = value; + if (OnStreamChanged != null) + OnStreamChanged(this); + } + } + } + + private JID m_overrideFrom = null; + + /// + /// Override the from address that will be stamped on outbound packets. + /// Unless your server implemets XEP-193, you shouldn't use this for + /// client connections. + /// + public JID OverrideFrom + { + get { return m_overrideFrom; } + set { m_overrideFrom = value; } + } + + /// + /// Write the specified stanza to the stream. + /// If the from address hasn't been set, and an OverrideFrom has been set, + /// the from address will be set to the value of OverrideFrom. + /// + /// + public void Write(XmlElement elem) + { + if ((m_overrideFrom != null) && (elem.GetAttribute("from") == "")) + elem.SetAttribute("from", m_overrideFrom); + m_stream.Write(elem); + } + + /// + /// Does an asynchronous IQ call. + /// If the from address hasn't been set, and an OverrideFrom has been set, + /// the from address will be set to the value of OverrideFrom. + /// + ///IQ packet to send. + ///Callback to execute when the result comes back. + ///Arguments to pass to the callback. + public void BeginIQ(IQ iq, IqCB cb, object cbArg) + { + if ((m_overrideFrom != null) && (iq.From == null)) + iq.From = m_overrideFrom; + m_stream.Tracker.BeginIQ(iq, cb, cbArg); + } + } +} diff -Nru smuxi-0.8/lib/jabber-net/jabber/connection/XmppStream.cs smuxi-0.8.9.1/lib/jabber-net/jabber/connection/XmppStream.cs --- smuxi-0.8/lib/jabber-net/jabber/connection/XmppStream.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/jabber-net/jabber/connection/XmppStream.cs 2012-01-03 07:52:11.000000000 +0000 @@ -0,0 +1,1774 @@ +/* -------------------------------------------------------------------------- + * Copyrights + * + * Portions created by or assigned to Cursive Systems, Inc. are + * Copyright (c) 2002-2008 Cursive Systems, Inc. All Rights Reserved. Contact + * information for Cursive Systems, Inc. is available at + * http://www.cursive.net/. + * + * License + * + * Jabber-Net is licensed under the LGPL. + * See LICENSE.txt for details. + * --------------------------------------------------------------------------*/ +using System; + +using System.Collections; +using System.ComponentModel; +using System.ComponentModel.Design; +using System.Diagnostics; +using System.IO; +using System.Threading; +using System.Security.Cryptography; +using System.Xml; +using bedrock.util; + +using jabber.protocol; +using jabber.protocol.stream; +using jabber.connection.sasl; + +using System.Security.Cryptography.X509Certificates; + +namespace jabber.connection +{ + /// + /// Informs the client about events that happen on an ElementStream. + /// + public delegate void StreamHandler(Object sender, ElementStream stream); + + /// + /// Manages option names. These must be well-formed XML element names. + /// + [SVN(@"$Id$")] + public abstract class Options + { + /// + /// Contains the default namespace for this connection. + /// + public const string NAMESPACE = "namespace"; + + /// + /// Contains the network hostname or IP address of the XMPP server to connect to. + /// + public const string NETWORK_HOST = "network_host"; + /// + /// Contains the identity of the item that the client is connecting to. + /// For components, the component ID. + /// + public const string TO = "to"; + /// + /// Contains the server identity that is expected on the X.509 certificate + /// from the XMPP server. + /// + public const string SERVER_ID = "tls.cn"; + /// + /// Determines the keep-alive interval in seconds. + /// + public const string KEEP_ALIVE = "keep_alive"; + /// + /// Don't start keep-alives until we're fully authenticated. This is what the SocketStanzaStream actually checks. + /// + public const string CURRENT_KEEP_ALIVE = "current_keep_alive"; + /// + /// Contains the port number to connect to or to listen on. + /// + public const string PORT = "port"; + /// + /// Uses SSL on connection if set to true. + /// + public const string SSL = "ssl"; + /// + /// Uses Start-TLS on connection if set to true and + /// the server supports it. + /// + public const string AUTO_TLS = "tls.auto"; + /// + /// Starts the XMPP stream compression (XEP-138) on connection + /// if set to true. + /// + public const string AUTO_COMPRESS = "compress.auto"; + /// + /// Allows plaintext authentication for connecting to the XMPP server. + /// + public const string PLAINTEXT = "plaintext"; + /// + /// Attempts a SASL connection if set to true and the feature is available + /// from the XMPP server. If the server doesn't support SASL, the connection + /// will move to a fallback mechanism. + /// + public const string SASL = "sasl"; + /// + /// Requires SASL authentication on this connection if set to true. + /// There is no fallback mechanism. If the server doesn't support SASL, + /// the connection attempt will fail. + /// + public const string REQUIRE_SASL = "sasl.require"; + /// + /// Contains the list of SASL Mechanisms such as Digest-MD5, Plain and so on. + /// + public const string SASL_MECHANISMS = "sasl.mechanisms"; + + /// + /// Contains the username to connect as. + /// + public const string USER = "user"; + /// + /// Contains the password for the user, or secret for the component. + /// + public const string PASSWORD = "password"; + /// + /// Contains the connecting resource which is used to identify a unique connection. + /// + public const string RESOURCE = "resource"; + /// + /// Contains the presence default priority for this connection. + /// + public const string PRIORITY = "priority"; + /// + /// Contains the DNS Service/Protocol to prepend to domain. + /// Example: _xmpp-client._tcp. + /// + public const string SRV_PREFIX = "srv.prefix"; + /// + /// Allows auto-login to be used for the connection to the XMPP server + /// if set to true. + /// + public const string AUTO_LOGIN = "auto.login"; + /// + /// This pass through the login process, can we login? + /// This option is set/reset by the framework. + /// + public const string AUTO_LOGIN_THISPASS = "auto.login.thispass"; + /// + /// Retrieves the roster items from the XMPP server on + /// connection if set to true. + /// + public const string AUTO_ROSTER = "auto.roster"; + /// + /// Sends back 501/feature-not-implemented to the XMPP server if + /// there are IQs that have not been handled if set to true. + /// + public const string AUTO_IQ_ERRORS = "auto.iq_errors"; + /// + /// Sends the presence on connection if set to true. + /// + public const string AUTO_PRESENCE = "auto.presence"; + + /// + /// Contains the certificate for our side of the SSL/TLS negotiation. + /// + public const string LOCAL_CERTIFICATE = "certificate.local"; + /// + /// Contains the remote certificate that the XMPP server sent to the client. + /// + public const string REMOTE_CERTIFICATE = "certificate.remote"; + /// + /// Uses x509 selection dialog box when a certificate is requested + /// if set to true. + /// + public const string CERTIFICATE_GUI = "certificate.gui"; + /// + /// Contains the number of seconds to wait before attempting a reconnect. + /// + public const string RECONNECT_TIMEOUT = "reconnect_timeout"; + /// + /// Determines the connection type (sockets, HTTP polling, or HTTP binding). + /// + public const string CONNECTION_TYPE = "connection"; + /// + /// Contains the URL to poll on, or bind to. + /// + public const string POLL_URL = "poll.url"; + /// + /// Connects to the XMPP server or listen for connections. + /// + public const string COMPONENT_DIRECTION = "component.dir"; + /// + /// Contains the logical JID associated with this connection. + /// + public const string JID = "jid"; + + /// + /// Contains the proxy type, such as none, SOCKS5 and so on. + /// + public const string PROXY_TYPE = "proxy.type"; + /// + /// Contains the hostname or IP address of the proxy. + /// + public const string PROXY_HOST = "proxy.host"; + /// + /// Contains the port number for the proxy. + /// + public const string PROXY_PORT = "proxy.port"; + /// + /// Contains the username for the proxy server. + /// + public const string PROXY_USER = "proxy.user"; + /// + /// Contains the password for the proxy server. + /// + public const string PROXY_PW = "proxy.password"; + /// + /// Override the from address, in a component/service connection. + /// + public const string OVERRIDE_FROM = "override_from"; + } + + /// + /// Manages the XMPP stream of the connection. + /// + [SVN(@"$Id$")] + abstract public class XmppStream : + System.ComponentModel.Component, + IStanzaEventListener + { + private static readonly object[][] DEFAULTS = new object[][] { + new object[] {Options.TO, "jabber.com"}, + new object[] {Options.KEEP_ALIVE, 30000}, + new object[] {Options.CURRENT_KEEP_ALIVE, -1}, + new object[] {Options.PORT, 5222}, + new object[] {Options.RECONNECT_TIMEOUT, 30000}, + new object[] {Options.PROXY_PORT, 1080}, + new object[] {Options.SSL, false}, + new object[] {Options.SASL, true}, + new object[] {Options.REQUIRE_SASL, false}, + new object[] {Options.PLAINTEXT, false}, + new object[] {Options.AUTO_TLS, true}, + new object[] {Options.AUTO_COMPRESS, true}, + +#if __MonoCS__ + new object[] {Options.CERTIFICATE_GUI, false}, +#else + new object[] {Options.CERTIFICATE_GUI, true}, +#endif + new object[] {Options.PROXY_TYPE, ProxyType.None}, + new object[] {Options.CONNECTION_TYPE, ConnectionType.Socket}, + }; + + /// + /// Contains the character encoding for the XMPP stream. + /// Currently, it is set to UTF-8. + /// + protected static readonly System.Text.Encoding ENC = System.Text.Encoding.UTF8; + + private StanzaStream m_stanzas = null; + private IQTracker m_tracker = null; + + private XmlDocument m_doc = new XmlDocument(); + private BaseState m_state = ClosedState.Instance; + private IDictionary m_properties = new Hashtable(); + + private string m_streamID = null; + private object m_stateLock = new object(); + private ArrayList m_callbacks = new ArrayList(); + + private Timer m_reconnectTimer = null; + private bool m_reconnect = false; + private bool m_sslOn = false; + private bool m_compressionOn = false; + + private XmlNamespaceManager m_ns; + private ISynchronizeInvoke m_invoker = null; + + // XMPP v1 stuff + private string m_serverVersion = null; + private SASLProcessor m_saslProc = null; + private Features m_features = null; // the last features tag received. + + + /// + /// Required designer variable. + /// +#pragma warning disable 0414 + private System.ComponentModel.Container components = new System.ComponentModel.Container(); +#pragma warning restore 0414 + + /// + /// Creates a new XMPP stream and associates it with the parent control. + /// + /// Parent control. + public XmppStream(System.ComponentModel.IContainer container) : this() + { + container.Add(this); + } + + /// + /// Sets defaults in bulk. + /// + /// Array of objects to replace to defaults with. + protected void SetDefaults(object[][] defaults) + { + foreach (object[] def in defaults) + { + this[(string)def[0]] = def[1]; + } + } + + /// + /// Creates a new SocketElementStream. + /// + public XmppStream() + { + m_ns = new XmlNamespaceManager(m_doc.NameTable); + m_tracker = new IQTracker(this); + + SetDefaults(DEFAULTS); + } + + /// + /// Sets or retrieves a connection property. + /// You have to know the type of the property based on the name. + /// For example, PORT is an integer. + /// + /// The property to get or set. + /// + public object this[string prop] + { + get + { + if (!m_properties.Contains(prop)) + return null; + return m_properties[prop]; + } + set + { + m_properties[prop] = value; + if (PropertyChanged != null) + { + PropertyChanged(this, new PropertyChangedEventArgs(prop)); + } + } + } + + /// + /// Informs the client that a property changed on the instance. + /// + public event PropertyChangedEventHandler PropertyChanged; + + /* + /// + /// Create a SocketElementStream out of an accepted socket. + /// + /// + public XmppStream(BaseSocket aso) + { + m_accept = m_sock = null; + if (aso is AsyncSocket) + { + m_watcher = ((AsyncSocket)aso).SocketWatcher; + } + m_ns = new XmlNamespaceManager(m_doc.NameTable); + m_timer = new Timer(new TimerCallback(DoKeepAlive), null, Timeout.Infinite, Timeout.Infinite); + InitializeStream(); + m_state = jabber.connection.AcceptingState.Instance; + } + + /// + /// Create a SocketElementStream with an existing SocketWatcher, so that you can do + /// lots of concurrent connections. + /// + /// + public XmppStream(SocketWatcher watcher) + { + m_watcher = watcher; + m_ns = new XmlNamespaceManager(m_doc.NameTable); + m_timer = new Timer(new TimerCallback(DoKeepAlive), null, Timeout.Infinite, Timeout.Infinite); + } + */ + + /// + /// Informs the client when text has been written to the XMPP server. + /// Use for debugging only. + /// Will NOT be complete nodes at a time. + /// + [Category("Debug")] + public event bedrock.TextHandler OnWriteText; + + /// + /// Informs the client that text was read from the server. + /// Use for debugging only. Will NOT be complete nodes at a time. + /// + [Category("Debug")] + public event bedrock.TextHandler OnReadText; + + /// + /// Informs the client that a new stream has been inialized. + /// You can add your packet factories to the new stream. + /// NOTE: You may NOT make calls to the GUI in this callback, unless you + /// call Invoke. Make sure you add your packet factories before + /// calling Invoke, however. + /// + [Category("Stream")] + public event StreamHandler OnStreamInit; + + /// + /// Informs the client that an error occurred when processing. + /// The connection has been closed. + /// + [Category("Stream")] + public event bedrock.ExceptionHandler OnError; + + /// + /// Notifies the client about every jabber packet. + /// This is a union of the OnPresence, OnMessage, and OnIQ methods. + /// Use this *or* the other 3 methods, but not both, as a matter of style. + /// + [Category("Stream")] + public event ProtocolHandler OnProtocol; + + /// + /// Notifies the client that the stream header, as a packet, + /// has been received. Can be called multiple times for + /// a single session, with XMPP. + /// + [Category("Stream")] + public event ProtocolHandler OnStreamHeader; + + /// + /// Notifies the client that the SASL handshake has started. + /// + protected event SASLProcessorHandler OnSASLStart; + + /// + /// Gets notified of the end of a SASL handshake. + /// + protected event FeaturesHandler OnSASLEnd; + + /// + /// Gets notified when SASL login fails. + /// + protected event ProtocolHandler OnSASLError; + + /// + /// Informs the client that it received a stream:error packet. + /// + [Category("Stream")] + [Description("We received stream:error packet.")] + public event ProtocolHandler OnStreamError; + + /// + /// Informs the client that the connection is complete and the user is authenticated. + /// + [Category("Stream")] + public event bedrock.ObjectHandler OnAuthenticate; + + /// + /// Informs the client that the connection is connected, + /// but no stream:stream has been sent yet. + /// + [Category("Stream")] + public event StanzaStreamHandler OnConnect; + + /// + /// Informs the client that the connection is disconnected. + /// + [Category("Stream")] + public event bedrock.ObjectHandler OnDisconnect; + + /// + /// An invalid cert was received from the other side. Set this event and return true to + /// use the cert anyway. If the event is not set, an ugly user interface will be displayed. + /// + [Category("Stream")] + public event System.Net.Security.RemoteCertificateValidationCallback OnInvalidCertificate; + + /// + /// Gets the tracker for sending IQ packets. + /// + [Browsable(false)] + public IIQTracker Tracker + { + get { return m_tracker; } + } + + /// + /// Gets or sets the name of the XMPP server to connect to. + /// + [Description("Gets or sets the name of the XMPP server to connect to.")] + [DefaultValue("jabber.com")] + [Category("Jabber")] + public virtual string Server + { + get { return this[Options.TO] as string; } + set { this[Options.TO] = value; } + } + + /// + /// Gets or sets the network host address to use on the "to" attribute + /// of the stream:stream. You can put the network hostname or IP address + /// of the XMPP server to connect to. If none is specified, the Server will + /// be used. Eventually, when SRV is supported, this will be deprecated. + /// + [Description("")] + [DefaultValue(null)] + [Category("Jabber")] + public string NetworkHost + { + get { return this[Options.NETWORK_HOST] as string; } + set { this[Options.NETWORK_HOST] = value; } + } + + /// + /// Specifies the TCP port to connect to. + /// + [Description("Specifies the TCP port to connect to.")] + [DefaultValue(5222)] + [Category("Jabber")] + public int Port + { + get { return (int)this[Options.PORT]; } + set { this[Options.PORT] = value; } + } + + /// + /// Specifies whether plaintext authentication is used for connecting + /// to the XMPP server. + /// + [Description("Allow plaintext authentication?")] + [DefaultValue(false)] + [Category("Jabber")] + public bool PlaintextAuth + { + get { return (bool)this[Options.PLAINTEXT]; } + set { this[Options.PLAINTEXT] = value; } + } + + /// + /// Determines whether or not the current connection is secured with SSL/TLS. + /// + [Browsable(false)] + public bool SSLon + { + get { return m_sslOn; } + } + + /// + /// Gets the JID from the connection. + /// + [Browsable(false)] + public JID JID + { + // Make sure to set this option in subclasses. + get + { + object j = this[Options.JID]; + if (j == null) + return null; + if (j is JID) + return (JID)j; + if (j is string) + return new JID((string)j); + Debug.Assert(false, "Unknown JID type", j.GetType().ToString()); + return null; + } + } + + /// + /// Determines whether or not the current connection uses + /// XMPP stream compression (XEP-138). + /// + [Browsable(false)] + public bool CompressionOn + { + get { return m_compressionOn; } + } + + /// + /// Determines whether SSL3/TLS1 authentication is used when a user + /// connects to the XMPP server. + /// + [Description("Do SSL3/TLS1 on startup.")] + [DefaultValue(false)] + [Category("Jabber")] + public bool SSL + { + get { return (bool)this[Options.SSL]; } + set { this[Options.SSL] = value; } + } + + /// + /// Allows Start-TLS on connection if the server supports it and if set to true. + /// + [Browsable(false)] + public bool AutoStartTLS + { + get { return (bool)this[Options.AUTO_TLS]; } + set { this[Options.AUTO_TLS] = value; } + } + + /// + /// Allows start compression on connection if the server supports it and + /// is set to true. + /// + [Browsable(false)] + public bool AutoStartCompression + { + get { return (bool)this[Options.AUTO_COMPRESS]; } + set { this[Options.AUTO_COMPRESS] = value; } + } + + /// + /// Gets or sets the certificate to be used for the local + /// side of sockets when SSL is enabled. + /// + [Browsable(false)] + public X509Certificate LocalCertificate + { + get { return this[Options.LOCAL_CERTIFICATE] as X509Certificate; } + set { this[Options.LOCAL_CERTIFICATE] = value; } + } + + /// + /// Sets the certificate to be used for accept sockets. To + /// generate a test .pfx file using OpenSSL, add this to + /// openssl.conf: + ///
+ /// [ serverex ] + /// extendedKeyUsage=1.3.6.1.5.5.7.3.1 + ///
+ /// and run the following commands: + ///
+ /// openssl req -new -x509 -newkey rsa:1024 -keyout + /// privkey.pem -out key.pem -extensions serverex + /// openssl pkcs12 -export -in key.pem -inkey privkey.pem + /// -name localhost -out localhost.pfx + ///
+ /// If you leave the certificate null, and you are doing + /// Accept, the SSL class will try to find a default server + /// certificate on your box. + ///
+ /// A .pfx or .cer file. + /// The password, if this is a .pfx + /// file, null if .cer file. + public void SetCertificateFile(string filename, + string password) + { + this[Options.LOCAL_CERTIFICATE] = new X509Certificate2(filename, password); + } + + /// + /// Calls Invoke() for all callbacks on this control. + /// + [Description("Invoke all callbacks on this control")] + [DefaultValue(null)] + [Category("Jabber")] + public ISynchronizeInvoke InvokeControl + { + get + { + // If we are running in the designer, let's try to get + // an invoke control from the environment. VB + // programmers can't seem to follow directions. + if ((this.m_invoker == null) && DesignMode) + { + IDesignerHost host = (IDesignerHost)base.GetService(typeof(IDesignerHost)); + if (host != null) + { + object root = host.RootComponent; + if ((root != null) && (root is ISynchronizeInvoke)) + { + m_invoker = (ISynchronizeInvoke)root; + // TODO: fire some sort of propertyChanged event, + // so that old code gets cleaned up correctly. + } + } + } + return m_invoker; + } + set { m_invoker = value; } + } + + /// + /// Gets or sets the keep-alive interval in seconds. + /// + [Description("Gets or sets the keep-alive interval in seconds")] + [Category("Jabber")] + [DefaultValue(20f)] + public float KeepAlive + { + get { return ((int)this[Options.KEEP_ALIVE]) / 1000f; } + set { this[Options.KEEP_ALIVE] = (int)(value * 1000f); } + } + + /// + /// Gets or sets the number of seconds before automatically + /// reconnecting if the connection drops. + /// -1 to disable, 0 for immediate. + /// + [Description("Automatically reconnect a connection.")] + [DefaultValue(30)] + [Category("Automation")] + public float AutoReconnect + { + get { return ((int)this[Options.RECONNECT_TIMEOUT]) / 1000f; } + set { this[Options.RECONNECT_TIMEOUT] = (int)(value * 1000f); } + } + + /// + /// Gets or sets the proxy type, such as none, SOCKS5 and so on. + /// + [Description("Gets or sets the proxy type, such as none, SOCKS5 and so on.")] + [DefaultValue(ProxyType.None)] + [Category("Proxy")] + public ProxyType Proxy + { + get { return (ProxyType)this[Options.PROXY_TYPE]; } + set { this[Options.PROXY_TYPE] = value; } + } + + /// + /// Gets or sets the connection type, such as Socket, HTTP polling and so on. + /// + [Description("Gets or sets the connection type, such as Socket, HTTP polling and so on.")] + [DefaultValue(ConnectionType.Socket)] + [Category("Proxy")] + public ConnectionType Connection + { + get { return (ConnectionType)this[Options.CONNECTION_TYPE]; } + set { this[Options.CONNECTION_TYPE] = value; } + } + + /// + /// Gets or sets the hostname running the proxy. + /// + [Description("Gets or sets the hostname running the proxy.")] + [DefaultValue(null)] + [Category("Proxy")] + public string ProxyHost + { + get { return this[Options.PROXY_HOST] as string; } + set { this[Options.PROXY_HOST] = value; } + } + + /// + /// Gets or sets the port number of the proxy host. + /// + [Description("Gets or sets the port number of the proxy host.")] + [DefaultValue(1080)] + [Category("Proxy")] + public int ProxyPort + { + get { return (int)this[Options.PROXY_PORT]; } + set { this[Options.PROXY_PORT] = value; } + } + + /// + /// Gets or sets the authentication username for the SOCKS5 proxy. + /// + [Description("Gets or sets the authentication username for the SOCKS5 proxy.")] + [DefaultValue(null)] + [Category("Proxy")] + public string ProxyUsername + { + get { return this[Options.PROXY_USER] as string; } + set { this[Options.PROXY_USER] = value; } + } + + /// + /// Gets or sets the authentication password for the SOCKS5 proxy. + /// + [Description("the auth password for the socks5 proxy")] + [DefaultValue(null)] + [Category("Proxy")] + public string ProxyPassword + { + get { return this[Options.PROXY_PW] as string; } + set { this[Options.PROXY_PW] = value; } + } + + /// + /// Gets or sets the ID attribute from the + /// stream:stream element sent by the XMPP server. + /// + [Browsable(false)] + [DefaultValue(null)] + public string StreamID + { + get { return m_streamID; } + set { m_streamID = value; } + } + + /// + /// Retrieves the outbound document. + /// + [Browsable(false)] + public XmlDocument Document + { + get { return m_doc; } + } + + /// + /// Gets or sets the current state of the connection. + /// Lock on StateLock before accessing. + /// + [Browsable(false)] + protected virtual BaseState State + { + get { return m_state; } + set { m_state = value; + // Debug.WriteLine("New state: " + m_state.ToString()); + } + } + + /// + /// Gets the lock for the state information. + /// + [Browsable(false)] + protected object StateLock + { + get { return m_stateLock; } + } + + /// + /// Gets or sets the state to authenticated. Locks on StateLock + /// + [Browsable(false)] + [DefaultValue(false)] + public virtual bool IsAuthenticated + { + get + { + lock (StateLock) + { + return (State == RunningState.Instance); + } + } + set + { + bool close = false; + lock (StateLock) + { + if (value) + { + State = RunningState.Instance; + } + else + close = true; + } + if (close) + Close(); + if (value && (OnAuthenticate != null)) + { + if (InvokeRequired) + CheckedInvoke(OnAuthenticate, new object[] { this }); + else + OnAuthenticate(this); + } + this[Options.CURRENT_KEEP_ALIVE] = this[Options.KEEP_ALIVE]; + } + } + + /// + /// Returns the namespace for this connection. + /// + [Browsable(false)] + protected abstract string NS + { + get; + } + + /// + /// Determines whether or not SASL is required for connecting to the XMPP server. + /// + [Description("Determines if SASL is required for connecting to the XMPP server.")] + [DefaultValue(false)] + public bool RequiresSASL + { + get { return (bool)this[Options.REQUIRE_SASL]; } + set { this[Options.REQUIRE_SASL] = value; } + } + + /// + /// Gets the version number of the XMPP server. + /// + [Description("Gets the version number of the XMPP server.")] + [DefaultValue(null)] + public string ServerVersion + { + get { return m_serverVersion; } + } + + /// + /// Writes just the start tag of the given XML element. + /// Typically only used for <stream:stream>. + /// + /// <stream:stream%gt; XML element. + public void WriteStartTag(jabber.protocol.stream.Stream elem) + { + m_stanzas.WriteStartTag(elem); + } + + /// + /// Sends the given packet to the server. + /// + /// The XML element to send. + public virtual void Write(XmlElement elem) + { + m_stanzas.Write(elem); + } + + /// + /// Sends a raw string. + /// + /// The string to send. + public void Write(string str) + { + m_stanzas.Write(str); + } + + /// + /// Starts connecting to the XMPP server. This is done asyncronously. + /// + public virtual void Connect() + { + this[Options.CURRENT_KEEP_ALIVE] = -1; + m_stanzas = StanzaStream.Create(this.Connection, this); + lock (StateLock) + { + State = ConnectingState.Instance; + m_reconnect = ((int)this[Options.RECONNECT_TIMEOUT] >= 0); + } + m_stanzas.Connect(); + } + + /// + /// Listens for connections from the XMPP server and is used for components only. + /// + protected virtual void Accept() + { + if ((m_stanzas == null) || (!m_stanzas.Acceptable)) + m_stanzas = StanzaStream.Create(this.Connection, this); + lock (StateLock) + { + this.State = AcceptingState.Instance; + m_reconnect = ((int)this[Options.RECONNECT_TIMEOUT] >= 0); + } + m_stanzas.Accept(); + } + + /// + /// If autoReconnect is on, start the timer for reconnect now. + /// + private void TryReconnect() + { + // close was not requested, or autoreconnect turned on. + if (m_reconnect) + { + if (m_reconnectTimer != null) + m_reconnectTimer.Dispose(); + + m_reconnectTimer = new System.Threading.Timer( + new System.Threading.TimerCallback(Reconnect), + null, + (int)this[Options.RECONNECT_TIMEOUT], + System.Threading.Timeout.Infinite); + } + } + + /// + /// Closes down the connection with the XMPP server with a clean shutdown. + /// + public virtual void Close() + { + Close(true); + } + + /// + /// Closes down the connection. + /// + /// True for graceful shutdown + public virtual void Close(bool clean) + { + bool doClose = false; + bool doStream = false; + + + lock (StateLock) + { + // if close is called, never try to reconnect. + m_reconnect = false; + + if ((State == RunningState.Instance) && (clean)) + { + doStream = true; + } + if (m_state != ClosedState.Instance) + { + State = ClosingState.Instance; + doClose = true; + } + } + + if ((m_stanzas != null) && m_stanzas.Connected && doClose) + { + m_stanzas.Close(doStream); + } + else + { + Debug.WriteLine("Cannot close a socket before it is open"); + //FireOnError(new InvalidOperationException("Cannot close a socket before it is open")); + } + } + + /// + /// Invokes the given method on the Invoker, and does some exception handling. + /// + /// Method to call on the invoker thread. + /// Arguments to pass to the method. + protected void CheckedInvoke(MulticastDelegate method, object[] args) + { + try + { + Debug.Assert(m_invoker != null, "Check for this.InvokeControl == null before calling CheckedInvoke"); + Debug.Assert(m_invoker.InvokeRequired, "Check for InvokeRequired before calling CheckedInvoke"); + + m_invoker.BeginInvoke(method, args); + } + catch (System.Reflection.TargetInvocationException e) + { + Debug.WriteLine("Exception passed along by XmppStream: " + e.ToString()); + throw e.InnerException; + } + catch (Exception e) + { + Debug.WriteLine("Exception in XmppStream: " + e.ToString()); + throw; + } + } + + /// + /// Determines whether or not a callback needs to be on the GUI thread. + /// + /// + /// True if the invoke control is set and the current thread + /// is not the GUI thread. + /// + protected bool InvokeRequired + { + get + { + if (m_invoker == null) + return false; + return m_invoker.InvokeRequired; + } + } + + /// + /// Informs the client that the first tag of the XML document has been received. + /// + /// Caller of this function. + /// The XML element that was received. + protected virtual void OnDocumentStart(object sender, System.Xml.XmlElement elem) + { + bool hack = false; + + if (elem is jabber.protocol.stream.Stream) + { + jabber.protocol.stream.Stream str = elem as jabber.protocol.stream.Stream; + + m_streamID = str.ID; + m_serverVersion = str.Version; + + // See XMPP-core section 4.4.1. We'll accept 1.x + if (m_serverVersion.StartsWith("1.")) + { + lock (m_stateLock) + { + if (State == SASLState.Instance) + // already authed. last stream restart. + State = SASLAuthedState.Instance; + else + State = jabber.connection.ServerFeaturesState.Instance; + } + } + else + { + lock (m_stateLock) + { + State = NonSASLAuthState.Instance; + } + hack = true; + } + if (OnStreamHeader != null) + { + if (InvokeRequired) + CheckedInvoke(OnStreamHeader, new object[] { this, elem }); + else + OnStreamHeader(this, elem); + } + CheckAll(elem); + + if (hack && (OnSASLStart != null)) + { + OnSASLStart(this, null); // Hack. Old-style auth for jabberclient. + } + } + } + + /// + /// Handle the last set of stream:features we have received, + /// based on the current state. + /// + protected virtual void ProcessFeatures() + { + // don't do starttls if we're already on an SSL socket. + // bad server setup, but no skin off our teeth, we're already + // SSL'd. Also, start-tls won't work when polling. + if ((bool)this[Options.AUTO_TLS] && + (m_features.StartTLS != null) && + (!m_sslOn) && + m_stanzas.SupportsTLS) + { + // start-tls + lock (m_stateLock) + { + State = StartTLSState.Instance; + } + this.Write(new StartTLS(m_doc)); + return; + } + + Compression comp = m_features.Compression; + if ((bool)this[Options.AUTO_COMPRESS] && + (comp != null) && + comp.HasMethod("zlib") && + (!m_compressionOn) && + m_stanzas.SupportsCompression) + { + // start compression + lock (m_stateLock) + { + State = CompressionState.Instance; + } + Compress c = new Compress(m_doc); + c.Method = "zlib"; + this.Write(c); + return; + } + + // not authenticated yet. Note: we'll get a stream:features + // after the last sasl restart, so we shouldn't try to iq:auth + // at that point. + if (!IsAuthenticated) + { + Mechanisms ms = m_features.Mechanisms; + m_saslProc = null; + + MechanismType types = MechanismType.NONE; + + if (ms != null) + { + // if SASL_MECHANISMS is set in the options, it is the limited set + // of mechanisms we're willing to try. Mask them off of the offered set. + object smt = this[Options.SASL_MECHANISMS]; + if (smt != null) + types = (MechanismType)smt & ms.Types; + else + types = ms.Types; + } + + // If we're doing SASL, and there are mechanisms implemented by both + // client and server. + if ((types != MechanismType.NONE) && ((bool)this[Options.SASL])) + { + lock (m_stateLock) + { + State = SASLState.Instance; + } + m_saslProc = SASLProcessor.createProcessor(types, m_sslOn || (bool)this[Options.PLAINTEXT], ms); + if (m_saslProc == null) + { + FireOnError(new NotImplementedException("No implemented mechanisms in: " + types.ToString())); + return; + } + if (OnSASLStart != null) + OnSASLStart(this, m_saslProc); + lock (m_stateLock) + { + // probably manual authentication + if (State != SASLState.Instance) + return; + } + + try + { + Step s = m_saslProc.step(null, this.Document); + if (s != null) + this.Write(s); + } + catch (Exception e) + { + FireOnError(new SASLException(e.Message)); + return; + } + } + + if (m_saslProc == null) + { // no SASL mechanisms. Try iq:auth. + if ((bool)this[Options.REQUIRE_SASL]) + { + FireOnError(new SASLException("No SASL mechanisms available")); + return; + } + lock (m_stateLock) + { + State = NonSASLAuthState.Instance; + } + if (OnSASLStart != null) + OnSASLStart(this, null); // HACK: old-style auth for jabberclient. + } + } + } + + /// + /// Informs the client that an XML element was received and + /// invokes the OnProtocol event. + /// + /// The object that called this method. + /// XML element that contains the new tag. + protected virtual void OnElement(object sender, System.Xml.XmlElement tag) + { + //Debug.WriteLine(tag.OuterXml); + + if (tag is jabber.protocol.stream.Error) + { + // Stream error. Race condition! Two cases: + // 1) OnClose has already fired, in which case we are in ClosedState, and the reconnect timer is pending. + // 2) OnClose hasn't fired, in which case we trick it into not starting the reconnect timer. + lock (m_stateLock) + { + if (m_state != ClosedState.Instance) + { + State = ClosingState.Instance; + } + else if (m_reconnectTimer != null) + { + Debug.WriteLine("Disposing of timer"); + m_reconnectTimer.Dispose(); + } + } + + if (OnStreamError != null) + { + if (InvokeRequired) + CheckedInvoke(OnStreamError, new object[] { this, tag }); + else + OnStreamError(this, tag); + } + return; + } + + if (State == ServerFeaturesState.Instance) + { + Features f = tag as Features; + if (f == null) + { + FireOnError(new InvalidOperationException("Expecting stream:features from a version='1.0' server")); + return; + } + m_features = f; + ProcessFeatures(); + return; + } + else if (State == SASLState.Instance) + { + if (tag is Success) + { + // restart the stream again + SendNewStreamHeader(); + } + else if (tag is SASLFailure) + { + m_saslProc = null; + + lock (m_stateLock) + { + State = SASLFailedState.Instance; + } + SASLFailure sf = tag as SASLFailure; + // TODO: I18N + if (OnSASLError != null) + { + m_reconnect = false; + OnSASLError(this, sf); + } + else + FireOnError(new SASLException("SASL failure: " + sf.InnerXml)); + return; + } + else if (tag is Step) + { + try + { + Step s = m_saslProc.step(tag as Step, this.Document); + if (s != null) + Write(s); + } + catch (Exception e) + { + FireOnError(new SASLException(e.Message)); + return; + } + } + else + { + m_saslProc = null; + FireOnError(new SASLException("Invalid SASL protocol")); + return; + } + } + else if (State == StartTLSState.Instance) + { + switch (tag.Name) + { + case "proceed": + if (!StartTLS()) + return; + SendNewStreamHeader(); + break; + case "failure": + FireOnError(new AuthenticationFailedException()); + return; + } + } + else if (State == CompressionState.Instance) + { + switch (tag.Name) + { + case "compressed": + if (!StartCompression()) + return; + SendNewStreamHeader(); + break; + case "failure": + CompressionFailure fail = tag as CompressionFailure; +#if ZLIB_NET + FireOnError(new bedrock.io.CompressionFailedException(fail.Error)); +#else + FireOnError(new IOException(fail.Error)); +#endif + return; + } + + } + else if (State == SASLAuthedState.Instance) + { + Features f = tag as Features; + if (f == null) + { + FireOnError(new InvalidOperationException("Expecting stream:features from a version='1.0' server")); + return; + } + if (OnSASLEnd != null) + OnSASLEnd(this, f); + m_saslProc = null; + } + else + { + if (OnProtocol != null) + { + if (InvokeRequired) + CheckedInvoke(OnProtocol, new object[] { this, tag }); + else + OnProtocol(this, tag); + } + } + CheckAll(tag); + } + + /// + /// Begins the TLS handshake, either client-side or server-side. + /// + /// True if StartTLS worked. + protected bool StartTLS() + { + try + { + m_stanzas.StartTLS(); + } + catch (Exception e) + { + m_reconnect = false; + if (e.InnerException != null) + FireOnError(e.InnerException); + else + FireOnError(e); + return false; + } + m_sslOn = true; + return true; + } + + /// + /// Begins compressing the XMPP stream. + /// + /// If True, compression was successful, otherwise False. + protected bool StartCompression() + { + try + { + m_stanzas.StartCompression(); + } + catch (Exception e) + { + m_reconnect = false; + FireOnError(e); + return false; + } + m_compressionOn = true; + return true; + } + + /// + /// Gets ready for a new stream:stream by starting a new XML document. + /// Needed after Start-TLS or compression, for example. + /// + protected void InitializeStream() + { + try + { + m_stanzas.InitializeStream(); + } + catch (Exception e) + { + FireOnError(e); + } + } + + /// + /// Sends a new XMPP stream header. + /// + protected void SendNewStreamHeader() + { + jabber.protocol.stream.Stream str = new jabber.protocol.stream.Stream(m_doc, NS); + str.To = new JID((string)this[Options.TO]); + str.Version = "1.0"; + m_stanzas.WriteStartTag(str); + InitializeStream(); + } + + /// + /// Informs the client of XMPP stream errors through the OnError event. + /// + /// Error that occurred. + protected void FireOnError(Exception e) + { + m_reconnect = false; + + // ignore spurious IO errors on shutdown. + if (((State == ClosingState.Instance) || (State == ClosedState.Instance)) && + ((e is System.IO.IOException) || (e.InnerException is System.IO.IOException))) + return; + + if (OnError != null) + { + if (InvokeRequired) + CheckedInvoke(OnError, new object[] { this, e }); + else + OnError(this, e); + } + + if ((State != ClosingState.Instance) && (State == ClosedState.Instance)) + Close(false); + } + + private void Reconnect(object state) + { + // prevent double-connects + if (this.State == ClosedState.Instance) + Connect(); + } + + /// + /// Registers a callback, so that if a packet arrives that matches the given xpath expression, + /// the callback fires. Use to add namespace prefixes. + /// + /// jc.AddCallback("self::iq[@type='result']/roster:query", new ProtocolHandler(GotRoster)); + /// The xpath expression to search for + /// The callback to call when the xpath matches + /// A guid that can be used to unregister the callback + public Guid AddCallback(string xpath, ProtocolHandler cb) + { + CallbackData cbd = new CallbackData(xpath, cb); + m_callbacks.Add(cbd); + return cbd.Guid; + } + + /// + /// Removes a callback added with . + /// + /// GUID representing the callback to remove. + public void RemoveCallback(Guid guid) + { + int count = 0; + foreach (CallbackData cbd in m_callbacks) + { + if (cbd.Guid == guid) + { + m_callbacks.RemoveAt(count); + return; + } + count++; + } + throw new ArgumentException("Unknown Guid", "guid"); + } + + /// + /// Adds a namespace prefix, for use with callback xpath expressions added + /// with . + /// + /// The prefix to use. + /// The URI associated with the prefix. + public void AddNamespace(string prefix, string uri) + { + m_ns.AddNamespace(prefix, uri); + } + + private void CheckAll(XmlElement elem) + { + foreach (CallbackData cbd in m_callbacks) + { + cbd.Check(this, elem); + } + } + + private class CallbackData + { + private Guid m_guid = Guid.NewGuid(); + private ProtocolHandler m_cb; + private string m_xpath; + + public CallbackData(string xpath, ProtocolHandler cb) + { + Debug.Assert(cb != null); + m_cb = cb; + m_xpath = xpath; + } + + public Guid Guid + { + get { return m_guid; } + } + + public string XPath + { + get { return m_xpath; } + } + + public void Check(XmppStream sender, XmlElement elem) + { + try + { + XmlNode n = elem.SelectSingleNode(m_xpath, sender.m_ns); + if (n != null) + { + if (sender.InvokeRequired) + sender.CheckedInvoke(m_cb, new object[] { sender, elem }); + else + m_cb(sender, elem); + } + } + catch (Exception e) + { + sender.FireOnError(e); + } + } + } + + #region IStanzaEventListener Members + + void IStanzaEventListener.Connected() + { + lock (m_stateLock) + { + this.State = ConnectedState.Instance; + if ((bool)this[Options.SSL]) + m_sslOn = true; + } + + if (OnConnect != null) + { + if (InvokeRequired) + CheckedInvoke(OnConnect, new Object[] { this, m_stanzas }); + else + OnConnect(this, m_stanzas); + } + + SendNewStreamHeader(); + } + + void IStanzaEventListener.Accepted() + { + lock (StateLock) + { + Debug.Assert(this.State == AcceptingState.Instance, this.State.GetType().ToString()); + + this.State = ConnectedState.Instance; + } + + if (OnConnect != null) + { + if (InvokeRequired) + CheckedInvoke(OnConnect, new object[] { this, m_stanzas }); + else + { + // Um. This cast might not be right, but I don't want to break backward compatibility + // if I don't have to by changing the delegate interface. + OnConnect(this, m_stanzas); + } + } + } + + void IStanzaEventListener.BytesRead(byte[] buf, int offset, int count) + { + if (OnReadText != null) + { + if (InvokeRequired) + CheckedInvoke(OnReadText, new object[] { this, ENC.GetString(buf, offset, count) }); + else + OnReadText(this, ENC.GetString(buf, offset, count)); + } + } + + void IStanzaEventListener.BytesWritten(byte[] buf, int offset, int count) + { + if (OnWriteText != null) + { + if (InvokeRequired) + CheckedInvoke(OnWriteText, new object[] { this, ENC.GetString(buf, offset, count) }); + else + OnWriteText(this, ENC.GetString(buf, offset, count)); + } + } + + void IStanzaEventListener.StreamInit(ElementStream stream) + { + if (OnStreamInit != null) + { + // Race condition. Make sure not to make GUI calls in OnStreamInit + /* + if (InvokeRequired) + CheckedInvoke(OnStreamInit, new object[] { this, stream }); + else + */ + OnStreamInit(this, stream); + } + } + + void IStanzaEventListener.Errored(Exception ex) + { + m_reconnect = false; + + lock (m_stateLock) + { + State = ClosedState.Instance; + if ((m_stanzas != null) && (!m_stanzas.Acceptable)) + m_stanzas = null; + } + + if (OnError != null) + { + if (InvokeRequired) + CheckedInvoke(OnError, new object[] { this, ex }); + else + OnError(this, ex); + } + + // TODO: Figure out what the "good" errors are, and try to + // reconnect. There are too many "bad" errors to just let this fly. + //TryReconnect(); + } + + void IStanzaEventListener.Closed() + { + lock (StateLock) + { + State = ClosedState.Instance; + if ((m_stanzas != null) && (!m_stanzas.Acceptable)) + m_stanzas = null; + m_sslOn = false; + m_compressionOn = false; + } + + if (OnDisconnect != null) + { + if (InvokeRequired) + CheckedInvoke(OnDisconnect, new object[] { this }); + else + OnDisconnect(this); + } + + TryReconnect(); + } + + void IStanzaEventListener.DocumentStarted(XmlElement elem) + { + // The OnDocumentStart logic stays outside the listener, so that it can be + // more easily overriden by subclasses. + OnDocumentStart(m_stanzas, elem); + } + + void IStanzaEventListener.DocumentEnded() + { + lock (StateLock) + { + State = ClosingState.Instance; + // TODO: Validate this, with current parser: + + // No need to close stream any more. AElfred does this for us, even though + // the docs say it doesn't. + + //if (m_sock != null) + //m_sock.Close(); + } + } + + void IStanzaEventListener.StanzaReceived(XmlElement elem) + { + // The OnElement logic stays outside the listener, so that it can be + // more easily overriden by subclasses. + OnElement(m_stanzas, elem); + } + + private bool ShowCertificatePrompt(object sender, + System.Security.Cryptography.X509Certificates.X509Certificate certificate, + System.Security.Cryptography.X509Certificates.X509Chain chain, + System.Net.Security.SslPolicyErrors sslPolicyErrors) + { +#if !__MonoCS__ + CertificatePrompt cp = new CertificatePrompt((X509Certificate2)certificate, chain, sslPolicyErrors); + return (cp.ShowDialog() == System.Windows.Forms.DialogResult.OK); +#else + return false; +#endif + } + + bool IStanzaEventListener.OnInvalidCertificate(bedrock.net.BaseSocket sock, + System.Security.Cryptography.X509Certificates.X509Certificate certificate, + System.Security.Cryptography.X509Certificates.X509Chain chain, + System.Net.Security.SslPolicyErrors sslPolicyErrors) + { + if (OnInvalidCertificate != null) + { + if ((m_invoker == null) || (!m_invoker.InvokeRequired)) + return OnInvalidCertificate(sock, certificate, chain, sslPolicyErrors); + try + { + // Note: can't use CheckedInvoke here, since we need the return value. We'll wait for the response. + return (bool)m_invoker.Invoke(OnInvalidCertificate, new object[] { sock, certificate, chain, sslPolicyErrors }); + } + catch (Exception e) + { + Debug.WriteLine("Exception passed along by XmppStream: " + e.ToString()); + return false; + } + } + if ((m_invoker == null) || (!m_invoker.InvokeRequired)) + return ShowCertificatePrompt(sock, certificate, chain, sslPolicyErrors); + + return (bool)m_invoker.Invoke(new System.Net.Security.RemoteCertificateValidationCallback(ShowCertificatePrompt), new object[]{ sock, certificate, chain, sslPolicyErrors }); + } + + #endregion + } +} diff -Nru smuxi-0.8/lib/jabber-net/jabber/connection/XmppStream.resx smuxi-0.8.9.1/lib/jabber-net/jabber/connection/XmppStream.resx --- smuxi-0.8/lib/jabber-net/jabber/connection/XmppStream.resx 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/jabber-net/jabber/connection/XmppStream.resx 2012-01-03 07:52:11.000000000 +0000 @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 1.0.0.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.3102.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.3102.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + diff -Nru smuxi-0.8/lib/jabber-net/jabber/JID.cs smuxi-0.8.9.1/lib/jabber-net/jabber/JID.cs --- smuxi-0.8/lib/jabber-net/jabber/JID.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/jabber-net/jabber/JID.cs 2012-01-03 07:52:11.000000000 +0000 @@ -0,0 +1,723 @@ +/* -------------------------------------------------------------------------- + * Copyrights + * + * Portions created by or assigned to Cursive Systems, Inc. are + * Copyright (c) 2002-2008 Cursive Systems, Inc. All Rights Reserved. Contact + * information for Cursive Systems, Inc. is available at + * http://www.cursive.net/. + * + * License + * + * Jabber-Net is licensed under the LGPL. + * See LICENSE.txt for details. + * --------------------------------------------------------------------------*/ +using System; + +using System.Text; +using System.Diagnostics; + +using bedrock.util; +using System.Text.RegularExpressions; + +namespace jabber +{ + /// + /// Informs the client that an invalid JID was entered. + /// + [SVN(@"$Id$")] + public class JIDFormatException : ApplicationException + { + /// + /// Creates a new exception for an invalid JID. + /// + /// The invalid JID + public JIDFormatException(string badJid) : base("Bad JID: (" + badJid + ")") + { + } + + /// + /// Creates a new exception instance. + /// + public JIDFormatException() : base() + { + } + + /// + /// Creates a new exception instance, wrapping another exception. + /// + /// Invalid JID. + /// Inner exception. + public JIDFormatException(string badJid, Exception e) : base("Bad JID: (" + badJid + ")", e) + { + } + + /// + /// Initializes a new instance of the AsyncSocketConnectionException class with serialized data. + /// + /// The object that holds the serialized object data. + /// The contextual information about the source or destination. + protected JIDFormatException(System.Runtime.Serialization.SerializationInfo info, + System.Runtime.Serialization.StreamingContext ctx) : + base(info, ctx) + { + } + } + + /// + /// Provides simple JID management. + /// + [SVN(@"$Id$")] + [System.ComponentModel.TypeConverter(typeof(JIDTypeConverter))] + public class JID : IComparable + { +#if !NO_STRINGPREP + private static readonly stringprep.Profile s_nodeprep = new stringprep.XmppNode(); + private static readonly stringprep.Profile s_nameprep = new stringprep.Nameprep(); + private static readonly stringprep.Profile s_resourceprep = new stringprep.XmppResource(); +#endif + + private string m_user = null; + private string m_server = null; + private string m_resource = null; + private string m_JID = null; + + /// + /// Creates a JID from a string. + /// This will parse and perform the stringprep (RFC 3454) process. + /// + /// Jabber ID, in string form + public JID(string jid) + { + Debug.Assert(jid != null, "jid must be non-null"); + m_JID = jid; + parse(); + } + + /// + /// Builds a new JID from the given components. + /// This will parse and perform the stringprep (RFC 3454) process. + /// + /// The username value. + /// The XMPP server domain value. + /// The current resource value. + public JID(string user, string server, string resource) + { + Debug.Assert(server != null, "server must be non-null"); + +#if !NO_STRINGPREP + m_user = (user == null) ? null : s_nodeprep.Prepare(user); + m_server = s_nameprep.Prepare(server); + m_resource = (resource == null) ? null : s_resourceprep.Prepare(resource); +#else + m_user = (user == null) ? null : user.ToLower(); + m_server = server.ToLower(); + m_resource = resource; +#endif + m_JID = build(m_user, m_server, m_resource); + + } + + /// + /// Builds a new JID, from portions that are guaranteed to already be stringprep'd. + /// + /// + /// + /// + /// The full user@server/resource JID, so that it doesn't have to be recreated from the parts + private JID(string user, string server, string resource, string full) + { + m_user = user; + m_server = server; + m_resource = resource; + m_JID = full; + } + + private static string build(string user, string server, string resource) + { + Debug.Assert(server != null, "Server must be non-null"); + StringBuilder sb = new StringBuilder(); + if (user != null) + { + sb.Append(user); + sb.Append("@"); + } + sb.Append(server); + if (resource != null) + { + sb.Append("/"); + sb.Append(resource); + } + return sb.ToString(); + } + + private void parse() + { + if (m_server != null) + return; // already parsed + + string user = null; + string server = null; + string resource = null; + + int at = m_JID.IndexOf('@'); + int slash = m_JID.IndexOf('/'); + + if (at == -1) + { + user = null; + if (slash == -1) + { + server = m_JID; + resource = null; + } + else + { + server = m_JID.Substring(0, slash); + resource = m_JID.Substring(slash+1); + } + } + else + { + if (slash == -1) + { + user = m_JID.Substring(0, at); + server = m_JID.Substring(at + 1); + } + else + { + if (at < slash) + { // normal case + user = m_JID.Substring(0, at); + server = m_JID.Substring(at+1, slash-at-1); + resource = m_JID.Substring(slash+1); + } + else + { // @ in a resource, with no user. bastards. + user = null; + server = m_JID.Substring(0, slash); + resource = m_JID.Substring(slash+1); + } + } + } + if (user != null) + { + if (user.IndexOf('@') != -1) throw new JIDFormatException(m_JID); + if (user.IndexOf('/') != -1) throw new JIDFormatException(m_JID); + } + + if ((server == null) || (server.Length == 0)) throw new JIDFormatException(m_JID); + if (server.IndexOf('@') != -1) throw new JIDFormatException(m_JID); + if (server.IndexOf('/') != -1) throw new JIDFormatException(m_JID); + if ((resource != null) && (resource.Length == 0)) // null is ok, but "" is not. + throw new JIDFormatException(m_JID); + +#if !NO_STRINGPREP + m_user = (user == null) ? null : s_nodeprep.Prepare(user); + m_server = s_nameprep.Prepare(server); + m_resource = (resource == null) ? null : s_resourceprep.Prepare(resource); +#else + m_user = (user == null) ? null : user.ToLower(); + m_server = server.ToLower(); + m_resource = resource; +#endif + // Make the case right, for fast equality comparisons + m_JID = build(m_user, m_server, m_resource); + } + + /// + /// Gets the hash code on the string version of the JID. + /// + /// Hash code. + public override int GetHashCode() + { + return m_JID.GetHashCode(); + } + + /// + /// Returns the string representation. + /// + /// String in the form of "[user]@[server]/[resource] + public override string ToString() + { + return m_JID; + } + + /// + /// Equality of string representations. + /// + /// JID or string to compare against. + /// + public override bool Equals(object other) + { + if (other == null) + return false; + if (other is string) + return m_JID.Equals(other); + if (! (other is JID)) + return false; + + return m_JID.Equals(((JID)other).m_JID); + } + + /// + /// Determines whether two JIDs have the same value. + /// + /// A JID to compare. + /// Another JID to compare to the first one. + /// True if everything (user, host and resource) are the same; otherwise false. + public static bool operator==(JID one, JID two) + { + if ((object)one == null) + return ((object)two == null); + return one.Equals(two); + } + + /// + /// Determines whether the string representation of the specified JID is equal to the current JID. + /// + /// This string is converted to a JID than compared to the second parameter. + /// JID to compare to the first one. + /// True if everything (user, host and resource) are the same; otherwise false. + public static bool operator==(string one, JID two) + { + if ((object)two == null) + return ((object)one == null); + return two.Equals(one); + } + + /// + /// Determines whether the string representation of the specified JID is not equal to the current JID. + /// + /// This string is converted to a JID than compared to the second parameter. + /// JID to compare to the first one. + /// True if one thing (user, host or resource) is different; otherwise false. + public static bool operator!=(string one, JID two) + { + if ((object)two == null) + return ((object)one != null); + return !two.Equals(one); + } + + /// + /// Determines whether two JIDs have different values. + /// + /// A JID to compare. + /// Another JID to compare to the first one. + /// True if one thing (user, host and resource) is different; otherwise false. + public static bool operator!=(JID one, JID two) + { + if ((object)one == null) + return ((object)two != null); + return !one.Equals(two); + } + + /// + /// Converts a string to a JID implicitly (no cast needed). + /// + /// String containing a JID. + /// JID object representing the string passed in. + public static implicit operator JID(string jid) + { + if (jid == null) + return null; + return new JID(jid); + } + + /// + /// Converts a JID to a string implicitly (no cast needed). + /// + /// JID whos string representation we want. + /// String version of the jid. + public static implicit operator string(JID jid) + { + if (jid == null) + return null; + return jid.m_JID; + } + + /// + /// Compares two JIDs. + /// + /// First JID. + /// Second JID. + /// True if the first JID is less to the second; otherwise false. + public static bool operator<(JID left, JID right) + { + return left.CompareTo(right) == -1; + } + + /// + /// Compares two JIDs. + /// + /// First JID. + /// Second JID. + /// True if the first JID is greater than the second; otherwise false. + public static bool operator>(JID left, JID right) + { + return left.CompareTo(right) == 1; + } + + /// + /// Compares two JIDs. + /// + /// First JID. + /// Second JID. + /// True if the first JID is less than or equal to the second; otherwise false. + public static bool operator<=(JID left, JID right) + { + return left.CompareTo(right) != 1; + } + + /// + /// Compares two JIDs. + /// + /// First JID. + /// Second JID. + /// True if the first JID is greater than or equal to the second; otherwise false. + public static bool operator>=(JID left, JID right) + { + return left.CompareTo(right) != -1; + } + + /// + /// Gets and sets the username value of the JID, and returns null if it does not exist. + /// + public string User + { + get + { + parse(); + return m_user; + } + set + { + parse(); + m_user = value; + m_JID = build(m_user, m_server, m_resource); + } + } + + /// + /// Gets and sets the XMPP server domain value. + /// + public string Server + { + get + { + parse(); + return m_server; + } + set + { + parse(); + m_server = value; + m_JID = build(m_user, m_server, m_resource); + } + } + + /// + /// Gets and sets the resource value and returns null if it does not exist. + /// + public string Resource + { + get + { + parse(); + return m_resource; + } + set + { + parse(); + m_resource = value; + m_JID = build(m_user, m_server, m_resource); + } + } + + /// + /// Gets the username and XMPP server domain values of the JID. For example: user@example.com + /// + public string Bare + { + get + { + parse(); + if (m_resource == null) + return m_JID; + return build(m_user, m_server, null); + } + } + + /// + /// Gets the user@server JID associated with this JID, as a JID. + /// Slightly faster than building it yourself, since stringprep + /// is avoided. + /// + public JID BareJID + { + get + { + parse(); + if (m_resource == null) + return this; // already bare + return new JID(m_user, m_server, null, build(m_user, m_server, null)); + } + } + + + /// + /// XEP-0106 escaping. + /// + /// + public static JID Escape(string user, string server, string resource) + { + StringBuilder sb = new StringBuilder(); + int count = 0; + foreach (char c in user) + { + switch (c) + { + case ' ': + if ((count == 0) || (count == (user.Length - 1))) + throw new JIDFormatException(); + sb.Append("\\20"); + break; + case '"': + sb.Append("\\22"); + break; + case '&': + sb.Append("\\26"); + break; + case '\'': + sb.Append("\\27"); + break; + case '/': + sb.Append("\\2f"); + break; + case ':': + sb.Append("\\3a"); + break; + case '<': + sb.Append("\\3c"); + break; + case '>': + sb.Append("\\3e"); + break; + case '@': + sb.Append("\\40"); + break; + case '\\': + sb.Append("\\5c"); + break; + default: + sb.Append(c); + break; + } + count++; + } + string u = sb.ToString(); + return new JID(u, server, resource); + } + + /// + /// Unescape the username portion of a JID, as specified in XEP-106. + /// + /// + public string Unescape() + { + Regex re = new Regex(@"\\([2-5][0267face])"); + string u = re.Replace(m_user, new MatchEvaluator(delegate(Match m) + { + switch (m.Groups[1].Value) + { + case "20": + return " "; + case "22": + return "\""; + case "26": + return "&"; + case "27": + return "'"; + case "2f": + return "/"; + case "3a": + return ":"; + case "3c": + return "<"; + case "3e": + return ">"; + case "40": + return "@"; + case "5c": + return "\\"; + default: + return m.Groups[0].Value; + } + })); + return u; + } + + #region Implementation of IComparable + /// + /// Compares the current instance with another object of the same type. + /// + /// An object to compare with this instance. + /// A 32-bit signed integer that indicates the relative order of the comparands. The return value has these meanings: + /// Less than zero This instance is less than obj. + /// Zero This instance is equal to obj. + /// Greater than zero This instance is greater than obj. + /// + public int CompareTo(object obj) + { + if (obj == null) + return 1; + if (obj == (object)this) + return 0; + + JID oj = obj as JID; + if (oj == null) + throw new ArgumentException("Comparison of JID to non-JID", "obj"); + + // hm. How tricky to get? + // It could be that sorting by domain first is correct... + //return this.m_JID.CompareTo(oj.m_JID); + this.parse(); + oj.parse(); + + int c = this.m_server.ToLower().CompareTo(oj.m_server.ToLower()); + if (c != 0) return c; + + if (this.m_user == null) + { + if (oj.m_user != null) + return -1; + } + else + { + if (oj.m_user == null) + return 1; + + c = this.m_user.ToLower().CompareTo(oj.m_user.ToLower()); + if (c != 0) return c; + } + + if (this.m_resource == null) + { + return (oj.m_resource == null) ? 0 : -1; + } + return this.m_resource.CompareTo(oj.m_resource); + } + #endregion + } + + /// + /// Convert a JID to and from a string, so that JIDs can be used as properties for + /// components, and have those properties set at design time. + /// + public class JIDTypeConverter : System.ComponentModel.TypeConverter + { + /// + /// Returns whether this converter can convert an object of one type to the type of this converter. + /// + /// + /// + /// + public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, Type sourceType) + { + if (sourceType == null) + { + throw new ArgumentNullException("sourceType"); + } + return ((sourceType == typeof(string)) || + (typeof(JID).IsAssignableFrom(sourceType) || + base.CanConvertFrom(context, sourceType))); + } + + /// + /// Returns whether this converter can convert the object to the specified type. + /// + /// + /// + /// + public override bool CanConvertTo(System.ComponentModel.ITypeDescriptorContext context, Type destinationType) + { + return ((destinationType == typeof(string)) || + ((destinationType == typeof(JID)) || + base.CanConvertTo(context, destinationType))); + } + + /// + /// Returns whether the given value object is valid for this type. + /// Empty strings are allowed, since they will map to null. + /// + /// + /// + /// + public override bool IsValid(System.ComponentModel.ITypeDescriptorContext context, object value) + { + string s = value as string; + JID j; + if (s != null) + { + if (s == "") + return true; + + try + { + j = new JID(s); + } + catch (JIDFormatException) + { + return false; + } + return true; + } + j = value as JID; + return (j != null); + } + + /// + /// Converts the given value to the type of this converter. + /// Empty strings are converted to null. + /// + /// + /// + /// + /// + public override object ConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) + { + if (value == null) + return null; + + string s = value as string; + if (s != null) + { + if (s == "") + return null; + return new JID(s); + } + JID j = value as JID; + if (j != null) + return j; + return base.ConvertFrom(context, culture, value); + } + + /// + /// Converts the given value object to the specified type. + /// + /// + /// + /// + /// + /// + public override object ConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType) + { + if (value == null) + return null; + if (destinationType == typeof(string)) + return value.ToString(); + if (destinationType == typeof(JID)) + return value; + return base.ConvertTo(context, culture, value, destinationType); + } + } +} diff -Nru smuxi-0.8/lib/jabber-net/jabber/protocol/accept/Factory.cs smuxi-0.8.9.1/lib/jabber-net/jabber/protocol/accept/Factory.cs --- smuxi-0.8/lib/jabber-net/jabber/protocol/accept/Factory.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/jabber-net/jabber/protocol/accept/Factory.cs 2012-01-03 07:52:11.000000000 +0000 @@ -0,0 +1,41 @@ +/* -------------------------------------------------------------------------- + * Copyrights + * + * Portions created by or assigned to Cursive Systems, Inc. are + * Copyright (c) 2002-2008 Cursive Systems, Inc. All Rights Reserved. Contact + * information for Cursive Systems, Inc. is available at + * http://www.cursive.net/. + * + * License + * + * Jabber-Net is licensed under the LGPL. + * See LICENSE.txt for details. + * --------------------------------------------------------------------------*/ +using System; + + +using bedrock.util; +using jabber.protocol; + +namespace jabber.protocol.accept +{ + /// + /// A packet factory for the jabber:component:accept namespace. + /// + [SVN(@"$Id$")] + public class Factory : IPacketTypes + { + private static QnameType[] s_qnt = new QnameType[] + { + new QnameType("handshake", URI.ACCEPT, typeof(Handshake)), + new QnameType("route", URI.ACCEPT, typeof(Route)), + new QnameType("xdb", URI.ACCEPT, typeof(Xdb)), + new QnameType("log", URI.ACCEPT, typeof(Log)), + new QnameType("handshake", URI.CONNECT, typeof(Handshake)), + new QnameType("route", URI.CONNECT, typeof(Route)), + new QnameType("xdb", URI.CONNECT, typeof(Xdb)), + new QnameType("log", URI.CONNECT, typeof(Log)) + }; + QnameType[] IPacketTypes.Types { get { return s_qnt; } } + } +} diff -Nru smuxi-0.8/lib/jabber-net/jabber/protocol/accept/Handshake.cs smuxi-0.8.9.1/lib/jabber-net/jabber/protocol/accept/Handshake.cs --- smuxi-0.8/lib/jabber-net/jabber/protocol/accept/Handshake.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/jabber-net/jabber/protocol/accept/Handshake.cs 2012-01-03 07:52:11.000000000 +0000 @@ -0,0 +1,67 @@ +/* -------------------------------------------------------------------------- + * Copyrights + * + * Portions created by or assigned to Cursive Systems, Inc. are + * Copyright (c) 2002-2008 Cursive Systems, Inc. All Rights Reserved. Contact + * information for Cursive Systems, Inc. is available at + * http://www.cursive.net/. + * + * License + * + * Jabber-Net is licensed under the LGPL. + * See LICENSE.txt for details. + * --------------------------------------------------------------------------*/ +using System; + +using System.Xml; + +using bedrock.util; + +namespace jabber.protocol.accept +{ + /// + /// The handshake tag, including digest calculation. Call SetAuth() to calculate + /// the SHA1 hash. + /// + [SVN(@"$Id$")] + public class Handshake : jabber.protocol.Element + { + /// + /// + /// + /// + public Handshake(XmlDocument doc) : base("handshake", doc) + { + } + /// + /// + /// + /// + /// + /// + public Handshake(string prefix, XmlQualifiedName qname, XmlDocument doc) : + base(prefix, qname, doc) + { + } + + /// + /// Set the auth information for this handshake tag, + /// performing the digest operation. + /// + /// + /// + public void SetAuth(string secret, string streamID) + { + this.Digest = ShaHash(streamID, secret); + } + + /// + /// The digest. + /// + public string Digest + { + get { return this.InnerText; } + set { this.InnerText = value; } + } + } +} diff -Nru smuxi-0.8/lib/jabber-net/jabber/protocol/accept/Log.cs smuxi-0.8.9.1/lib/jabber-net/jabber/protocol/accept/Log.cs --- smuxi-0.8/lib/jabber-net/jabber/protocol/accept/Log.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/jabber-net/jabber/protocol/accept/Log.cs 2012-01-03 07:52:11.000000000 +0000 @@ -0,0 +1,121 @@ +/* -------------------------------------------------------------------------- + * Copyrights + * + * Portions created by or assigned to Cursive Systems, Inc. are + * Copyright (c) 2002-2008 Cursive Systems, Inc. All Rights Reserved. Contact + * information for Cursive Systems, Inc. is available at + * http://www.cursive.net/. + * + * License + * + * Jabber-Net is licensed under the LGPL. + * See LICENSE.txt for details. + * --------------------------------------------------------------------------*/ +using System; + +using System.Xml; + +using bedrock.util; + +namespace jabber.protocol.accept +{ + /// + /// The type field in a log tag. + /// + [SVN(@"$Id$")] + public enum LogType + { + /// + /// None specified + /// + NONE = -1, + /// + /// type='warn' + /// + warn, + /// + /// type='info' + /// + info, + /// + /// type='verbose' + /// + verbose, + /// + /// type='debug' + /// + debug + } + + /// + /// The log packet. + /// + [SVN(@"$Id$")] + public class Log : jabber.protocol.Packet + { + /// + /// + /// + /// + public Log(XmlDocument doc) : base("log", doc) + { + } + + /// + /// + /// + /// + /// + /// + public Log(string prefix, XmlQualifiedName qname, XmlDocument doc) : + base(prefix, qname, doc) + { + } + + /// + /// The element inside the route tag. + /// + public XmlElement Element + { + get { return this["element"]; } + set { AddChild(value); } + } + + /// + /// The type attribute + /// + public LogType Type + { + get { return GetEnumAttr("type"); } + set { SetEnumAttr("type", value); } + } + + /// + /// The namespace for logging + /// + public string NS + { + get { return GetAttribute("ns"); } + set { SetAttribute("ns", value); } + } + + /// + /// The server thread this came from + /// + public string Thread + { + get { return GetAttribute("thread"); } + set { SetAttribute("thread", value); } + } + + /// + /// Time sent. + /// + public DateTime Timestamp + { + get { return JabberDate(GetAttribute("timestamp")); } + set { SetAttribute("timestamp", JabberDate(value)); } + } + + } +} diff -Nru smuxi-0.8/lib/jabber-net/jabber/protocol/accept/Route.cs smuxi-0.8.9.1/lib/jabber-net/jabber/protocol/accept/Route.cs --- smuxi-0.8/lib/jabber-net/jabber/protocol/accept/Route.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/jabber-net/jabber/protocol/accept/Route.cs 2012-01-03 07:52:11.000000000 +0000 @@ -0,0 +1,93 @@ +/* -------------------------------------------------------------------------- + * Copyrights + * + * Portions created by or assigned to Cursive Systems, Inc. are + * Copyright (c) 2002-2008 Cursive Systems, Inc. All Rights Reserved. Contact + * information for Cursive Systems, Inc. is available at + * http://www.cursive.net/. + * + * License + * + * Jabber-Net is licensed under the LGPL. + * See LICENSE.txt for details. + * --------------------------------------------------------------------------*/ +using System; + +using System.Xml; + +using bedrock.util; + +namespace jabber.protocol.accept +{ + /// + /// The type field in a route tag. + /// + [SVN(@"$Id$")] + public enum RouteType + { + /// + /// None specified + /// + NONE = -1, + /// + /// type='error' + /// + error, + /// + /// type='auth' + /// + auth, + /// + /// type='session' + /// + session + } + + /// + /// The route packet. + /// + [SVN(@"$Id$")] + public class Route : jabber.protocol.Packet + { + /// + /// + /// + /// + public Route(XmlDocument doc) : base("route", doc) + { + } + + /// + /// + /// + /// + /// + /// + public Route(string prefix, XmlQualifiedName qname, XmlDocument doc) : + base(prefix, qname, doc) + { + } + + /// + /// The element inside the route tag. + /// + public XmlElement Contents + { + get { return (XmlElement) this.FirstChild; } + set + { + this.InnerXml = ""; + AddChild(value); + } + } + + /// + /// The type attribute + /// + public RouteType Type + { + get { return GetEnumAttr("type"); } + set { SetEnumAttr("type", value); } + } + } +} diff -Nru smuxi-0.8/lib/jabber-net/jabber/protocol/accept/Xdb.cs smuxi-0.8.9.1/lib/jabber-net/jabber/protocol/accept/Xdb.cs --- smuxi-0.8/lib/jabber-net/jabber/protocol/accept/Xdb.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/jabber-net/jabber/protocol/accept/Xdb.cs 2012-01-03 07:52:11.000000000 +0000 @@ -0,0 +1,136 @@ +/* -------------------------------------------------------------------------- + * Copyrights + * + * Portions created by or assigned to Cursive Systems, Inc. are + * Copyright (c) 2002-2008 Cursive Systems, Inc. All Rights Reserved. Contact + * information for Cursive Systems, Inc. is available at + * http://www.cursive.net/. + * + * License + * + * Jabber-Net is licensed under the LGPL. + * See LICENSE.txt for details. + * --------------------------------------------------------------------------*/ +using System; + +using System.Xml; + +using bedrock.util; + +namespace jabber.protocol.accept +{ + /// + /// The type attribute + /// + [SVN(@"$Id$")] + public enum XdbType + { + /// + /// None specified + /// + NONE = -1, + /// + /// type='get' + /// + get, + /// + /// type='set' + /// + set, + /// + /// type='result' + /// + result, + /// + /// type='error' + /// + error + } + + /// + /// The action attribute. + /// + [SVN(@"$Id$")] + public enum XdbAction + { + /// + /// None specified + /// + NONE = -1, + /// + /// action='check' + /// + check, + /// + /// action='insert' + /// + insert + } + + /// + /// The XDB packet. + /// + [SVN(@"$Id$")] + public class Xdb : jabber.protocol.Packet + { + /// + /// + /// + /// + public Xdb(XmlDocument doc) : base("xdb", doc) + { + ID = NextID(); + } + + /// + /// + /// + /// + /// + /// + public Xdb(string prefix, XmlQualifiedName qname, XmlDocument doc) : + base(prefix, qname, doc) + { + } + + /// + /// The contents of the XDB packet + /// + public XmlElement Contents + { + get { return (XmlElement) this.FirstChild; } + set + { + this.InnerXml = ""; + AddChild(value); + } + } + + /// + /// The type attribute + /// + public XdbType Type + { + get { return GetEnumAttr("type"); } + set { SetEnumAttr("type", value); } + } + + /// + /// The action attribute + /// + public XdbAction Action + { + get { return GetEnumAttr("action"); } + set { SetEnumAttr("action", value); } + } + + /// + /// The namespace to store/retrive from. + /// + public string NS + { + get { return GetAttribute("ns"); } + set { SetAttribute("ns", value); } + } + } +} diff -Nru smuxi-0.8/lib/jabber-net/jabber/protocol/AsynchElementStream.cs smuxi-0.8.9.1/lib/jabber-net/jabber/protocol/AsynchElementStream.cs --- smuxi-0.8/lib/jabber-net/jabber/protocol/AsynchElementStream.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/jabber-net/jabber/protocol/AsynchElementStream.cs 2012-01-03 07:52:11.000000000 +0000 @@ -0,0 +1,398 @@ +/* -------------------------------------------------------------------------- + * Copyrights + * + * Portions created by or assigned to Cursive Systems, Inc. are + * Copyright (c) 2002-2008 Cursive Systems, Inc. All Rights Reserved. Contact + * information for Cursive Systems, Inc. is available at + * http://www.cursive.net/. + * + * License + * + * Jabber-Net is licensed under the LGPL. + * See LICENSE.txt for details. + * --------------------------------------------------------------------------*/ +using System; +using System.Collections; +using System.Diagnostics; +using System.Xml; + +using xpnet; + +using bedrock.io; +using bedrock.util; + +namespace jabber.protocol +{ + /// + /// Summary description for AsynchElementStream. + /// TODO: combine with ElementStream, since there's only one impl now. + /// + [SVN(@"$Id$")] + public class AsynchElementStream : ElementStream + { + private static System.Text.Encoding utf = System.Text.Encoding.UTF8; + + private BufferAggregate m_buf = new BufferAggregate(); + private Encoding m_enc = new UTF8Encoding(); + private NS m_ns = new NS(); + private XmlElement m_elem = null; + private XmlElement m_root = null; + private bool m_cdata = false; + + /// + /// Create an instance. + /// + public AsynchElementStream() + { + } + + /// + /// Put bytes into parser. Used by test routines, only, for convenience. + /// + /// + public void Push(byte[] buf) + { + Push(buf, 0, buf.Length); + } + + /// + /// Put bytes into the parser. + /// + /// The bytes to put into the parse stream + /// Offset into buf to start at + /// Number of bytes to write + public void Push(byte[] buf, int offset, int length) + { + // or assert, really, but this is a little nicer. + if (length == 0) + return; + + // No locking is required. Read() won't get called again + // until this method returns. Keep in mind that we're + // already on a thread in a ThreadPool, which is created + // and managed by System.IO at the end of the day. + + // TODO: only do this copy if we have a partial token at the + // end of parsing. + byte[] copy = new byte[length]; + System.Buffer.BlockCopy(buf, offset, copy, 0, length); + m_buf.Write(copy); + + byte[] b = m_buf.GetBuffer(); + int off = 0; + TOK tok = TOK.END_TAG; + ContentToken ct = new ContentToken(); + + try + { + while (off < b.Length) + { + + + if (m_cdata) + tok = m_enc.tokenizeCdataSection(b, off, b.Length, ct); + else + tok = m_enc.tokenizeContent(b, off, b.Length, ct); + + switch (tok) + { + case TOK.EMPTY_ELEMENT_NO_ATTS: + case TOK.EMPTY_ELEMENT_WITH_ATTS: + StartTag(b, off, ct, tok); + EndTag(b, off, ct, tok); + break; + case TOK.START_TAG_NO_ATTS: + case TOK.START_TAG_WITH_ATTS: + StartTag(b, off, ct, tok); + break; + case TOK.END_TAG: + EndTag(b, off, ct, tok); + break; + case TOK.DATA_CHARS: + case TOK.DATA_NEWLINE: + AddText(utf.GetString(b, off, ct.TokenEnd - off)); + break; + case TOK.CHAR_REF: + case TOK.MAGIC_ENTITY_REF: + AddText(new string(new char[] { ct.RefChar1 })); + break; + case TOK.CHAR_PAIR_REF: + AddText(new string(new char[] {ct.RefChar1, + ct.RefChar2})); + break; + case TOK.COMMENT: + if (m_elem != null) + { + // 3 + int start = off + 4*m_enc.MinBytesPerChar; + int end = ct.TokenEnd - off - + 7*m_enc.MinBytesPerChar; + string text = utf.GetString(b, start, end); + m_elem.AppendChild(m_doc.CreateComment(text)); + } + break; + case TOK.CDATA_SECT_OPEN: + m_cdata = true; + break; + case TOK.CDATA_SECT_CLOSE: + m_cdata = false; + break; + case TOK.XML_DECL: + // thou shalt use UTF8, and XML version 1. + // i shall ignore evidence to the contrary... + + // TODO: Throw an exception if these assuptions are + // wrong + break; + case TOK.ENTITY_REF: + case TOK.PI: + throw new System.NotImplementedException("Token type not implemented: " + tok); + } + off = ct.TokenEnd; + ct.clearAttributes(); + } + } + catch (PartialTokenException) + { + // Console.WriteLine("PartialTokenException: " + System.Text.Encoding.UTF8.GetString(copy)); + // ignored; + } + catch (ExtensibleTokenException) + { + // ignored; + } + catch (xpnet.InvalidTokenException e) + { + throw new XMLParseException(e, this, buf, offset, length); + } + catch (Exception e) + { + throw new Exception("Unexpected exception", e); + } + finally + { + m_buf.Clear(off); + ct.clearAttributes(); + } + } + + private void StartTag(byte[] buf, int offset, + ContentToken ct, TOK tok) + { + int colon; + string name; + string prefix; + Hashtable ht = new Hashtable(); + + m_ns.PushScope(); + + // if i have attributes + if ((tok == TOK.START_TAG_WITH_ATTS) || + (tok == TOK.EMPTY_ELEMENT_WITH_ATTS)) + { + int start; + int end; + string val; + for (int i=0; i + // 0) + { + prefix = name.Substring(0, colon); + name = name.Substring(colon + 1); + ns = m_ns.LookupNamespace(prefix); + } + else + { + ns = m_ns.DefaultNamespace; + } + + XmlQualifiedName q = new XmlQualifiedName(name, ns); + XmlElement elem = m_factory.GetElement(prefix, q, m_doc); + + + foreach (string attrname in ht.Keys) + { + colon = attrname.IndexOf(':'); + if (colon > 0) + { + prefix = attrname.Substring(0, colon); + name = attrname.Substring(colon+1); + + XmlAttribute attr = m_doc.CreateAttribute(prefix, + name, + m_ns.LookupNamespace(prefix)); + attr.InnerXml = (string)ht[attrname]; + elem.SetAttributeNode(attr); + } + else + { + XmlAttribute attr = m_doc.CreateAttribute(attrname); + attr.InnerXml = (string)ht[attrname]; + elem.SetAttributeNode(attr); + } + } + + + if (m_root == null) + { + m_root = elem; + FireOnDocumentStart(m_root); + } + else + { + if (m_elem != null) + m_elem.AppendChild(elem); + m_elem = elem; + } + } + + private void EndTag(byte[] buf, int offset, + ContentToken ct, TOK tok) + { + m_ns.PopScope(); + + if (m_elem == null) + {// end of doc + FireOnDocumentEnd(); + return; + } + + string name = null; + + if ((tok == TOK.EMPTY_ELEMENT_WITH_ATTS) || + (tok == TOK.EMPTY_ELEMENT_NO_ATTS)) + name = utf.GetString(buf, + offset + m_enc.MinBytesPerChar, + ct.NameEnd - offset - + m_enc.MinBytesPerChar); + else + name = utf.GetString(buf, + offset + m_enc.MinBytesPerChar*2, + ct.NameEnd - offset - + m_enc.MinBytesPerChar*2); + + + if (m_elem.Name != name) + throw new XmlException("Invalid end tag: " + name + + " != " + m_elem.Name); + + XmlElement parent = (XmlElement)m_elem.ParentNode; + if (parent == null) + { + FireOnElement(m_elem); + } + m_elem = parent; + } + + private void AddText(string text) + { + if (m_elem != null) + { + m_elem.AppendChild(m_doc.CreateTextNode(text)); + } + } + + /// + /// There was an error parsing XML. What was the context? + /// + [SVN(@"$Id$")] + public class XMLParseException : Exception + { + private string m_context = null; + + /// + /// Some XML parsing error occurred. Wrap it, and generate a little more context, so that we can try + /// to figure out where the actual error happened. + /// + /// + /// + /// + /// + /// + public XMLParseException(Exception innerException, AsynchElementStream stream, byte[] buf, int offset, int length) + : base("Parsing exception", innerException) + { + XmlElement e = stream.m_elem; + XmlElement last = null; + System.Text.StringBuilder sb = new System.Text.StringBuilder(); + + while (e != null) + { + last = e; + e = e.ParentNode as XmlElement; + } + + if (last != null) + { + sb.Append("Outer element: "); + sb.Append(last.OuterXml); + sb.Append("\n"); + } + else + { + sb.Append("Root stanza\n"); + } + + sb.Append("New text (note: it's normal to see what looks like extra close tags here): "); + try + { + sb.Append(AsynchElementStream.utf.GetString(buf, offset, length)); + } + catch (Exception) + { + sb.Append("Error in UTF8 decode: "); + sb.Append(Element.HexString(buf, offset, length)); + } + m_context = sb.ToString(); + } + /// + /// More context of where the error ocurred + /// + public string Context + { + get { return m_context; } + } + + /// + /// String representation. + /// + /// + public override string ToString() + { + return base.ToString() + "\n----------\n\nContext:\n" + m_context; + } + } + } +} diff -Nru smuxi-0.8/lib/jabber-net/jabber/protocol/client/Error.cs smuxi-0.8.9.1/lib/jabber-net/jabber/protocol/client/Error.cs --- smuxi-0.8/lib/jabber-net/jabber/protocol/client/Error.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/jabber-net/jabber/protocol/client/Error.cs 2012-01-03 07:52:11.000000000 +0000 @@ -0,0 +1,428 @@ +/* -------------------------------------------------------------------------- + * Copyrights + * + * Portions created by or assigned to Cursive Systems, Inc. are + * Copyright (c) 2002-2008 Cursive Systems, Inc. All Rights Reserved. Contact + * information for Cursive Systems, Inc. is available at + * http://www.cursive.net/. + * + * License + * + * Jabber-Net is licensed under the LGPL. + * See LICENSE.txt for details. + * --------------------------------------------------------------------------*/ +using System; + +using System.Xml; + +using bedrock.util; + +namespace jabber.protocol.client +{ + /* + /// + /// Error codes for IQ and message + /// + [SVN(@"$Id$")] + public enum ErrorCode + { + /// + /// None specified. + /// + none = -1, + /// + /// Gone (302) + /// + GONE = 302, + /// + /// Bad request (400) + /// + BAD_REQUEST = 400, + /// + /// Unauthorized (401) + /// + UNAUTHORIZED = 401, + /// + /// Payment required (402) + /// + PAYMENT_REQUIRED = 402, + /// + /// Forbidden (403) + /// + FORBIDDEN = 403, + /// + /// Not found (404) + /// + NOT_FOUND = 404, + /// + /// Not allowed (405) + /// + NOT_ALLOWED = 405, + /// + /// Not acceptable (406) + /// + NOT_ACCEPTABLE = 406, + /// + /// Registration required (407) + /// + REGISTRATION_REQUIRED = 407, + /// + /// Request timeout (408) + /// + REQUEST_TIMEOUT = 408, + /// + /// Conflict (409) + /// + CONFLICT = 409, + /// + /// Internal server error (500) + /// + INTERNAL_SERVER_ERROR = 500, + /// + /// Not implemented (501) + /// + NOT_IMPLEMENTED = 501, + /// + /// Remote server error (502) + /// + REMOTE_SERVER_ERROR = 502, + /// + /// Service unavailable (503) + /// + SERVICE_UNAVAILABLE = 503, + /// + /// Remote server timeout (504) + /// + REMOTE_SERVER_TIMEOUT = 504, + /// + /// Disconnected (510) + /// + DISCONNECTED = 510 + } + */ + + /// + /// See RFC 3920, section 9.3.2. These are the possible error types. + /// + public enum ErrorType + { + /// + /// None specified (protocol error) + /// + NONE = -1, + /// + /// do not retry (the error is unrecoverable) + /// + cancel, + /// + /// proceed (the condition was only a warning) + /// + @continue, + /// + /// retry after changing the data sent + /// + modify, + /// + /// retry after providing credentials + /// + auth, + /// + /// retry after waiting (the error is temporary) + /// + wait + } + + + /// + /// Error IQ + /// + [SVN(@"$Id$")] + public class IQError : IQ + { + /// + /// Create an error IQ with the given code and message. + /// + /// + /// + public IQError(XmlDocument doc, string condition) : base(doc) + { + this.Type = IQType.error; + Error e = Error.GetStanzaError(doc, condition); + this.AppendChild(e); + } + } + + /// + /// Error in a message or IQ. + /// + [SVN(@"$Id$")] + public class Error : Element + { + /// + /// modify 400 + /// + public const string BAD_REQUEST = "bad-request"; + /// + /// cancel 409 + /// + public const string CONFLICT = "conflict"; + /// + /// cancel 501 + /// + public const string FEATURE_NOT_IMPLEMENTED = "feature-not-implemented"; + /// + /// auth 403 + /// + public const string FORBIDDEN = "forbidden"; + /// + /// modify 302 (permanent) + /// + public const string GONE = "gone"; + /// + /// wait 500 + /// + public const string INTERNAL_SERVER_ERROR = "internal-server-error"; + /// + /// cancel 404 + /// + public const string ITEM_NOT_FOUND = "item-not-found"; + /// + /// modify 400 + /// + public const string JID_MALFORMED = "jid-malformed"; + /// + /// modify 406 + /// + public const string NOT_ACCEPTABLE = "not-acceptable"; + /// + /// cancel 405 + /// + public const string NOT_ALLOWED = "not-allowed"; + /// + /// auth 401 + /// + public const string NOT_AUTHORIZED = "not-authorized"; + /// + /// auth 402 + /// + public const string PAYMENT_REQUIRED = "payment-required"; + /// + /// wait 404 + /// + public const string RECIPIENT_UNAVAILABLE = "recipient-unavailable"; + /// + /// modify 302 (temporary) + /// + public const string REDIRECT = "redirect"; + /// + /// auth 407 + /// + public const string REGISTRATION_REQUIRED = "registration-required"; + /// + /// cancel 404 + /// + public const string REMOTE_SERVER_NOT_FOUND = "remote-server-not-found"; + /// + /// wait 504 + /// + public const string REMOTE_SERVER_TIMEOUT = "remote-server-timeout"; + /// + /// wait 500 + /// + public const string RESOURCE_CONSTRAINT = "resource-constraint"; + /// + /// cancel 503 + /// + public const string SERVICE_UNAVAILABLE = "service-unavailable"; + /// + /// auth 407 + /// + public const string SUBSCRIPTION_REQUIRED = "subscription-required"; + /// + /// [any] 500 + /// + public const string UNDEFINED_CONDITION = "undefined-condition"; + /// + /// wait 400 + /// + public const string UNEXPECTED_REQUEST = "unexpected-request"; + + private static System.Collections.Hashtable s_errors = new System.Collections.Hashtable(); + private struct CodeType + { + public int Code; + public ErrorType Type; + public CodeType(int code, ErrorType type) + { + Code = code; + Type = type; + } + } + + static Error() + { + // See XEP-86. (http://www.xmpp.org/extensions/xep-0086.html) + s_errors.Add(BAD_REQUEST, new CodeType(400, ErrorType.modify)); + s_errors.Add(CONFLICT, new CodeType(409, ErrorType.cancel)); + s_errors.Add(FEATURE_NOT_IMPLEMENTED, new CodeType(501, ErrorType.cancel)); + s_errors.Add(FORBIDDEN, new CodeType(403, ErrorType.auth)); + s_errors.Add(GONE, new CodeType(302, ErrorType.modify)); + s_errors.Add(INTERNAL_SERVER_ERROR, new CodeType(500, ErrorType.wait)); + s_errors.Add(ITEM_NOT_FOUND, new CodeType(404, ErrorType.cancel)); + s_errors.Add(JID_MALFORMED, new CodeType(400, ErrorType.modify)); + s_errors.Add(NOT_ACCEPTABLE, new CodeType(406, ErrorType.modify)); + s_errors.Add(NOT_ALLOWED, new CodeType(405, ErrorType.cancel)); + s_errors.Add(NOT_AUTHORIZED, new CodeType(401, ErrorType.auth)); + s_errors.Add(PAYMENT_REQUIRED, new CodeType(402, ErrorType.auth)); + s_errors.Add(RECIPIENT_UNAVAILABLE, new CodeType(404, ErrorType.wait)); + s_errors.Add(REDIRECT, new CodeType(302, ErrorType.modify)); + s_errors.Add(REGISTRATION_REQUIRED, new CodeType(407, ErrorType.auth)); + s_errors.Add(REMOTE_SERVER_NOT_FOUND, new CodeType(404, ErrorType.cancel)); + s_errors.Add(REMOTE_SERVER_TIMEOUT, new CodeType(504, ErrorType.wait)); + s_errors.Add(RESOURCE_CONSTRAINT, new CodeType(500, ErrorType.wait)); + s_errors.Add(SERVICE_UNAVAILABLE, new CodeType(503, ErrorType.cancel)); + s_errors.Add(SUBSCRIPTION_REQUIRED, new CodeType(407, ErrorType.auth)); + s_errors.Add(UNDEFINED_CONDITION, new CodeType(500, ErrorType.NONE)); + s_errors.Add(UNEXPECTED_REQUEST, new CodeType(400, ErrorType.wait)); + } + + /// + /// + /// + /// + public Error(XmlDocument doc) : base("error", doc) + { + } + + /// + /// + /// + /// + /// + /// + public Error(string prefix, XmlQualifiedName qname, XmlDocument doc) : + base(prefix, qname, doc) + { + } + + /// + /// Create an error element with the element name of the error condition. + /// + /// + /// + /// + public static Error GetStanzaError(XmlDocument doc, string condition) + { + if (!s_errors.Contains(condition)) + throw new ArgumentException("Unknown condition: " + condition, "condition"); + + CodeType ct = (CodeType) s_errors[condition]; + return GetStanzaError(doc, ct.Type, ct.Code, condition); + } + + /// + /// Get an error element with a urn:ietf:params:xml:ns:xmpp-stanzas condition. + /// Likely, you want the GetStanzaError(doc, condition) instead. + /// + /// + /// + /// + /// + /// + public static Error GetStanzaError(XmlDocument doc, ErrorType type, int code, string condition) + { + Error error = new Error(doc); + error.ErrorType = type; + error.Code = code; + error.AppendChild(doc.CreateElement(condition, URI.STANZA_ERROR)); + return error; + } + + /// + /// Get an error stanza with a urn:ietf:params:xml:ns:xmpp-streams condition. + /// + /// + /// + /// + /// + /// + public static Error GetStreamError(XmlDocument doc, ErrorType type, int code, string condition) + { + Error error = new Error(doc); + error.ErrorType = type; + error.Code = code; + error.AppendChild(doc.CreateElement(condition, URI.STREAM)); + return error; + } + + /// + /// The error code, as an integer. + /// + public int Code + { + get { return GetIntAttr("code"); } + set { this.SetAttribute("code", value.ToString()); } + } + + /// + /// The type of the error + /// + public ErrorType ErrorType + { + get { return this.GetEnumAttr("type"); } + set { this.SetEnumAttr("type", value); } + } + + /// + /// The inner error condition element. + /// + public string Condition + { + get + { + foreach (XmlNode n in this.ChildNodes) + { + if (n.NodeType != XmlNodeType.Element) + continue; + if ((n.NamespaceURI != URI.STANZA_ERROR) && + (n.NamespaceURI != URI.STREAM_ERROR)) + continue; + return n.LocalName; + } + // uh-oh. Old-school error. See section 3 of XEP-86. + switch (this.Code) + { + case 302: return REDIRECT; + case 400: return BAD_REQUEST; + case 401: return NOT_AUTHORIZED; + case 402: return PAYMENT_REQUIRED; + case 403: return FORBIDDEN; + case 404: return ITEM_NOT_FOUND; + case 405: return NOT_ALLOWED; + case 406: return NOT_ACCEPTABLE; + case 407: return REGISTRATION_REQUIRED; + case 408: return REMOTE_SERVER_TIMEOUT; + case 409: return CONFLICT; + case 500: return INTERNAL_SERVER_ERROR; + case 501: return FEATURE_NOT_IMPLEMENTED; + case 502: return SERVICE_UNAVAILABLE; + case 503: return SERVICE_UNAVAILABLE; + case 504: return REMOTE_SERVER_TIMEOUT; + case 510: return SERVICE_UNAVAILABLE; + } + // best we can do. + return UNDEFINED_CONDITION; + } + set { this.InnerXml = ""; this.AddChild(GetStanzaError(this.OwnerDocument, value)); } + } + + /// + /// The error message. Not used anymore (not I18N). + /// + public string Message + { + get { return this.InnerText; } + set { this.InnerText = value; } + } + } +} diff -Nru smuxi-0.8/lib/jabber-net/jabber/protocol/client/Factory.cs smuxi-0.8.9.1/lib/jabber-net/jabber/protocol/client/Factory.cs --- smuxi-0.8/lib/jabber-net/jabber/protocol/client/Factory.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/jabber-net/jabber/protocol/client/Factory.cs 2012-01-03 07:52:11.000000000 +0000 @@ -0,0 +1,41 @@ +/* -------------------------------------------------------------------------- + * Copyrights + * + * Portions created by or assigned to Cursive Systems, Inc. are + * Copyright (c) 2002-2008 Cursive Systems, Inc. All Rights Reserved. Contact + * information for Cursive Systems, Inc. is available at + * http://www.cursive.net/. + * + * License + * + * Jabber-Net is licensed under the LGPL. + * See LICENSE.txt for details. + * --------------------------------------------------------------------------*/ +using System; + +using bedrock.util; +using jabber.protocol; + +namespace jabber.protocol.client +{ + /// + /// ElementFactory for the jabber:client namespace. + /// + [SVN(@"$Id$")] + public class Factory : IPacketTypes + { + private static QnameType[] s_qnt = new QnameType[] + { + new QnameType("presence", URI.CLIENT, typeof(jabber.protocol.client.Presence)), + new QnameType("message", URI.CLIENT, typeof(jabber.protocol.client.Message)), + new QnameType("iq", URI.CLIENT, typeof(jabber.protocol.client.IQ)), + new QnameType("error", URI.CLIENT, typeof(jabber.protocol.client.Error)), + // meh. jabber protocol really isn't right WRT to namespaces. + new QnameType("presence", URI.ACCEPT, typeof(jabber.protocol.client.Presence)), + new QnameType("message", URI.ACCEPT, typeof(jabber.protocol.client.Message)), + new QnameType("iq", URI.ACCEPT, typeof(jabber.protocol.client.IQ)), + new QnameType("error", URI.ACCEPT, typeof(jabber.protocol.client.Error)) + }; + QnameType[] IPacketTypes.Types { get { return s_qnt; } } + } +} diff -Nru smuxi-0.8/lib/jabber-net/jabber/protocol/client/IQ.cs smuxi-0.8.9.1/lib/jabber-net/jabber/protocol/client/IQ.cs --- smuxi-0.8/lib/jabber-net/jabber/protocol/client/IQ.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/jabber-net/jabber/protocol/client/IQ.cs 2012-01-03 07:52:11.000000000 +0000 @@ -0,0 +1,230 @@ +/* -------------------------------------------------------------------------- + * Copyrights + * + * Portions created by or assigned to Cursive Systems, Inc. are + * Copyright (c) 2002-2008 Cursive Systems, Inc. All Rights Reserved. Contact + * information for Cursive Systems, Inc. is available at + * http://www.cursive.net/. + * + * License + * + * Jabber-Net is licensed under the LGPL. + * See LICENSE.txt for details. + * --------------------------------------------------------------------------*/ +using System; + +using System.Xml; + +using bedrock.util; + +namespace jabber.protocol.client +{ + /// + /// IQ type attribute + /// + [SVN(@"$Id$")] + public enum IQType + { + /// + /// type='get' + /// + get, + /// + /// type='set' + /// + set, + /// + /// type='result' + /// + result, + /// + /// type='error' + /// + error + } + + /// + /// All IQ packets start here. The Query property holds the interesting part. + /// There should usually be a convenience class next to the Query type, which + /// creates an IQ with the appropriate type of query inside. + /// + [SVN(@"$Id$")] + public class IQ : Packet + { + private bool m_handled = false; + + /// + /// + /// + /// + public IQ(XmlDocument doc) : base("iq", doc) + { + ID = NextID(); + Type = IQType.get; // get better errors than when there is no type specified. + } + /// + /// + /// + /// + /// + /// + public IQ(string prefix, XmlQualifiedName qname, XmlDocument doc) : + base(qname.Name, doc) // Note: *NOT* base(prefix, qname, doc), so that xpath matches are easier + { + } + + /// + /// Has this IQ been handled? Set automatically by GetResponse and GetErrorResponse. If this is not + /// set to true, Jabber-Net will respond automatically with a 501 error. + /// + public bool Handled + { + get { return m_handled; } + set { m_handled = value; } + } + + /// + /// + /// + public IQType Type + { + get { return GetEnumAttr("type"); } + set + { + IQType cur = this.Type; + if (cur == value) + return; + + if (value == IQType.error) + { + this.InnerXml = ""; + this.GetOrCreateElement(); + } + SetEnumAttr("type", value); + } + } + + /// + /// IQ error. + /// + public Error Error + { + get { return GetChildElement(); } + set + { + this.Type = IQType.error; + ReplaceChild(value); + } + } + + /// + /// The query tag inside, regardless of namespace. + /// If the iq contains something other than query, + /// use normal XmlElement routines. + /// + public XmlElement Query + { + get { return this.GetFirstChildElement(); } + set { this.InnerXml = ""; this.AddChild(value); } + } + +#if __MonoCS__ +#pragma warning disable 0809 +#endif + /// + /// Swap the To and the From addresses. + /// Obsolete: Use GetResponse or GetErrorResponse, now, for IQs. + /// + [Obsolete("Use GetResponse or GetErrorResponse, now.")] + public override void Swap() + { + base.Swap(); + } +#if __MonoCS__ +#pragma warning restore 0809 +#endif + + /// + /// Swap the to and from, set the type to result. + /// + /// + /// + public IQ GetResponse(XmlDocument doc) + { + IQ resp = new IQ(doc); + resp.From = this.To; + resp.To = this.From; + resp.ID = this.ID; + resp.Type = IQType.result; + + XmlElement q = this.Query; + if (q != null) + { + if (q is Element) + resp.AppendChild((XmlElement)((Element)q).CloneNode(true, doc)); + else + resp.AppendChild(doc.ImportNode(q, true)); + } + + this.Handled = true; + return resp; + } + + /// + /// Respond to this IQ with an error. + /// + /// + /// + /// + public IQ GetErrorResponse(XmlDocument doc, string condition) + { + IQ resp = new IQError(doc, condition); + resp.From = this.To; + resp.To = this.From; + resp.ID = this.ID; + resp.Type = IQType.error; + + XmlElement q = this.Query; + if (q != null) + { + if (q is Element) + resp.AppendChild((XmlElement)((Element)q).CloneNode(true, doc)); + else + resp.AppendChild(doc.ImportNode(q, true)); + } + + this.Handled = true; + return resp; + } + } + + /// + /// An IQ subclass that allows typed access to its first child, + /// through the Instruction property. + /// + /// + [SVN(@"$Id$")] + public class TypedIQ : IQ + where T : Element + { + /// + /// Create an IQ to send out, with an instance of the specified + /// type as a child. + /// + /// + public TypedIQ(XmlDocument doc) : base(doc) + { + CreateChildElement(); + } + + /// + /// The child element (often "query") with the command for this IQ. + /// + public T Instruction + { + get { return GetChildElement(); } + set { ReplaceChild(value); } + } + } + +} diff -Nru smuxi-0.8/lib/jabber-net/jabber/protocol/client/Message.cs smuxi-0.8.9.1/lib/jabber-net/jabber/protocol/client/Message.cs --- smuxi-0.8/lib/jabber-net/jabber/protocol/client/Message.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/jabber-net/jabber/protocol/client/Message.cs 2012-01-03 07:52:11.000000000 +0000 @@ -0,0 +1,185 @@ +/* -------------------------------------------------------------------------- + * Copyrights + * + * Portions created by or assigned to Cursive Systems, Inc. are + * Copyright (c) 2002-2008 Cursive Systems, Inc. All Rights Reserved. Contact + * information for Cursive Systems, Inc. is available at + * http://www.cursive.net/. + * + * License + * + * Jabber-Net is licensed under the LGPL. + * See LICENSE.txt for details. + * --------------------------------------------------------------------------*/ +using System; + +using System.Xml; + +using bedrock.util; + +namespace jabber.protocol.client +{ + /// + /// Message type attribute + /// + [SVN(@"$Id$")] + public enum MessageType + { + /// + /// Normal message + /// + normal = -1, + /// + /// Error message + /// + error, + /// + /// Chat (one-to-one) message + /// + chat, + /// + /// Groupchat + /// + groupchat, + /// + /// Headline + /// + headline + } + /// + /// A client-to-client message. + /// TODO: Some XHTML is supported by setting the .Html property, + /// but extra xmlns="" get put everywhere at the moment. + /// + [SVN(@"$Id$")] + public class Message : Packet + { + /// + /// + /// + /// + public Message(XmlDocument doc) : base("message", doc) + { + ID = NextID(); + } + /// + /// + /// + /// + /// + /// + public Message(string prefix, XmlQualifiedName qname, XmlDocument doc) : + base(qname.Name, doc) // Note: *NOT* base(prefix, qname, doc), so that xpath matches are easier + { + } + + /// + /// The message type attribute + /// + public MessageType Type + { + get { return (MessageType) GetEnumAttr("type", typeof(MessageType)); } + set + { + if (value == MessageType.normal) + RemoveAttribute("type"); + else + SetAttribute("type", value.ToString()); + } + } + + private void NormalizeHtml(XmlElement body, string html) + { + XmlDocument d = new XmlDocument(); + d.LoadXml("" + html + ""); + foreach (XmlNode node in d.DocumentElement.ChildNodes) + { + body.AppendChild(this.OwnerDocument.ImportNode(node, true)); + } + } + + /// + /// On set, creates both an html element, and a body element, which will + /// have the de-html'd version of the html element. + /// + public string Html + { + get + { + // Thanks, Mr. Postel. + XmlElement h = this["html"]; + if (h == null) + return ""; + XmlElement b = h["body"]; + if (b == null) + return ""; + string xml = b.InnerXml; + // HACK: yeah, yeah, I know. + return xml.Replace(" xmlns=\"" + URI.XHTML + "\"", ""); + } + set + { + XmlElement html = GetOrCreateElement("html", URI.XHTML_IM, null); + XmlElement body = html["body", URI.XHTML]; + if (body == null) + { + body = this.OwnerDocument.CreateElement(null, "body", URI.XHTML); + html.AppendChild(body); + } + else + body.RemoveAll(); + NormalizeHtml(body, value); + this.Body = body.InnerText; + } + } + + /// + /// The message body + /// + public string Body + { + get { return GetElem("body"); } + set { SetElem("body", value); } + } + + /// + /// The message thread + /// TODO: some help to generate these, please. + /// + public string Thread + { + get { return GetElem("thread"); } + set { SetElem("thread", value); } + } + /// + /// The message subject + /// + public string Subject + { + get { return GetElem("subject"); } + set { SetElem("subject", value); } + } + /// + /// The first x tag, regardless of namespace. + /// + [Obsolete("This almost certainly doesn't do what you want.")] + public XmlElement X + { + get { return this["x"]; } + set { this.AddChild(value); } + } + + /// + /// Message error. + /// + public Error Error + { + get { return GetChildElement(); } + set + { + this.Type = MessageType.error; + ReplaceChild(value); + } + } + } +} diff -Nru smuxi-0.8/lib/jabber-net/jabber/protocol/client/Presence.cs smuxi-0.8.9.1/lib/jabber-net/jabber/protocol/client/Presence.cs --- smuxi-0.8/lib/jabber-net/jabber/protocol/client/Presence.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/jabber-net/jabber/protocol/client/Presence.cs 2012-01-03 07:52:11.000000000 +0000 @@ -0,0 +1,362 @@ +/* -------------------------------------------------------------------------- + * Copyrights + * + * Portions created by or assigned to Cursive Systems, Inc. are + * Copyright (c) 2002-2008 Cursive Systems, Inc. All Rights Reserved. Contact + * information for Cursive Systems, Inc. is available at + * http://www.cursive.net/. + * + * License + * + * Jabber-Net is licensed under the LGPL. + * See LICENSE.txt for details. + * --------------------------------------------------------------------------*/ +using System; + +using System.Xml; + +using bedrock.util; +using jabber.protocol.x; + +namespace jabber.protocol.client +{ + /// + /// Presence type attribute + /// + [SVN(@"$Id$")] + public enum PresenceType + { + /// + /// None specified + /// + available = -1, + /// + /// May I subscribe to you? + /// + subscribe, + /// + /// Yes, you may subscribe. + /// + subscribed, + /// + /// Unsubscribe from this entity. + /// + unsubscribe, + /// + /// No, you may not subscribe. + /// + unsubscribed, + /// + /// Offline + /// + unavailable, + /// + /// server-side only. + /// + probe, + /// + /// A presence error. + /// + error, + /// + /// Invisible presence: we're unavailable to them, but still see + /// theirs. + /// + invisible + } + + /// + /// Client presence packet. + /// + [SVN(@"$Id$")] + public class Presence : Packet, IComparable, IComparable + { + /// + /// + /// + /// + public Presence(XmlDocument doc) : + base("presence", doc) + { + } + + /// + /// + /// + /// + /// + /// + public Presence(string prefix, XmlQualifiedName qname, XmlDocument doc) : + base(qname.Name, doc) // Note: *NOT* base(prefix, qname, doc), so that xpath matches are easier + { + } + + /// + /// Presence type + /// + public PresenceType Type + { + get { return (PresenceType) GetEnumAttr("type", typeof(PresenceType)); } + set + { + if (value == PresenceType.available) + RemoveAttribute("type"); + else + SetAttribute("type", value.ToString()); + } + } + + /// + /// Presence status + /// + public string Status + { + get { return GetElem("status"); } + set { SetElem("status", value); } + } + + /// + /// Presence show + /// + public string Show + { + get { return GetElem("show"); } + set { SetElem("show", value); } + } + + /// + /// Priority for this resource. + /// + public string Priority + { + get { return GetElem("priority"); } + set { SetElem("priority", value); } + } + + /// + /// An integer version of the priority, constrained to -128..127. 0 if there was no priority element or it wasn't an integer. + /// + public int IntPriority + { + get + { + String pri = Priority; + if ((pri == null) || (pri == "")) + return 0; + try + { + int i = int.Parse(pri); + if (i < -128) + return -128; + if (i > 127) + return 127; + return i; + } + catch (Exception) + { + return 0; + } + } + set + { + SetElem("priority", value.ToString()); + } + } + + /// + /// Presence error. + /// + public Error Error + { + get { return (Error) this["error"]; } + set + { + this.Type = PresenceType.error; + ReplaceChild(value); + } + } + + private static int IntShow(string show) + { + switch (show) + { + case "dnd": + return 0; + case "xa": + return 1; + case "away": + return 2; + case "chat": + return 4; + default: + return 3; + } + } + + /// + /// Date/Time stamp that the presence was originially received by the sending + /// server, if this presence is in response to a probe. + /// + public DateTime Stamp + { + get + { + jabber.protocol.x.ModernDelay md = GetChildElement(); + if (md != null) + return md.Stamp; + jabber.protocol.x.Delay delay = GetChildElement(); + if (delay != null) + return delay.Stamp; + return DateTime.MinValue; + } + set + { + jabber.protocol.x.ModernDelay md = GetChildElement(); + if (md != null) + { + md.Stamp = value; + return; + } + jabber.protocol.x.Delay delay = GetChildElement(); + if (delay != null) + { + delay.Stamp = value; + return; + } + md = new jabber.protocol.x.ModernDelay(this.OwnerDocument); + md.Stamp = value; + this.AddChild(md); + } + } + + /// + /// If there is a stamp, returns it, otherwise looks for and adds a new stamp element. + /// This method should never be called for presence that is to be sent out, since it + /// will add non-standard protocol to the presence. + /// + public DateTime ReceivedTime + { + get + { + DateTime dt = this.Stamp; + if (dt != DateTime.MinValue) + return dt; + const string RECEIVED = "http://cursive.net/protocol/received"; + XmlElement el = this["x", RECEIVED]; + if (el != null) + return Element.DateTimeProfile(el.InnerText); + dt = DateTime.Now; + el = OwnerDocument.CreateElement("x", RECEIVED); + el.InnerText = Element.DateTimeProfile(dt); + this.AppendChild(el); + return dt; + } + } + + /// + /// Compare two presences (from the same bare JID, but from + /// different resources), to determine which is "more + /// available". + /// + /// + /// + /// + public static bool operator<(Presence first, Presence second) + { + return (((IComparable)first).CompareTo(second) == -1); + } + + /// + /// Compare two presences (from the same bare JID, but from + /// different resources), to determine which is "more + /// available". + /// + /// + /// + /// + public static bool operator>(Presence first, Presence second) + { + return (((IComparable)first).CompareTo(second) == 1); + } + + #region IComparable Members + + /// + /// Compare this presence element with another, first by priority, + /// then by show, then by time received. + /// + /// + /// + /// Less than zero + /// This object is less than the other parameter. + /// Zero + /// This object is equal to other. + /// Greater than zero + /// This object is greater than other. + /// + public int CompareTo(Presence other) + { + /* + Less than zero + This object is less than the other parameter. + + Zero + This object is equal to other. + + Greater than zero + This object is greater than other. + + */ + if ((object)this == (object)other) + return 0; + + if (other == null) + return 1; + + int tp = this.IntPriority; + int op = other.IntPriority; + if (tp > op) + return 1; + if (tp < op) + return -1; + + // equal priority + int ts = IntShow(this.Show); + int os = IntShow(other.Show); + + if (ts > os) + return 1; + if (ts < os) + return -1; + + // equal show + return this.ReceivedTime.CompareTo(other.ReceivedTime); + } + + #endregion + + #region IComparable Members + + /// + /// Compare this presence element with another, first by priority, + /// then by show, then by time received. + /// + /// + /// + /// Less than zero + /// This object is less than the other parameter. + /// Zero + /// This object is equal to other. + /// Greater than zero + /// This object is greater than other. + /// + public int CompareTo(object other) + { + if (other is Presence) + return CompareTo((Presence)other); + return 1; + } + + #endregion + } +} diff -Nru smuxi-0.8/lib/jabber-net/jabber/protocol/client/ProtocolException.cs smuxi-0.8.9.1/lib/jabber-net/jabber/protocol/client/ProtocolException.cs --- smuxi-0.8/lib/jabber-net/jabber/protocol/client/ProtocolException.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/jabber-net/jabber/protocol/client/ProtocolException.cs 2012-01-03 07:52:11.000000000 +0000 @@ -0,0 +1,112 @@ +/* -------------------------------------------------------------------------- + * Copyrights + * + * Portions created by or assigned to Cursive Systems, Inc. are + * Copyright (c) 2002-2008 Cursive Systems, Inc. All Rights Reserved. Contact + * information for Cursive Systems, Inc. is available at + * http://www.cursive.net/. + * + * License + * + * Jabber-Net is licensed under the LGPL. + * See LICENSE.txt for details. + * --------------------------------------------------------------------------*/ +using System; +using System.Xml; + +using bedrock.util; + +namespace jabber.protocol.client +{ + /// + /// Invalid protocol received. + /// + [SVN(@"$Id$")] + public class BadProtocolException : Exception + { + private XmlElement m_proto = null; + private string m_msg = null; + + /// + /// Create a protocol exception + /// + /// The protocol that was bad. Typically the top-most (stanza) element. + /// An optional message. May be null. + public BadProtocolException(XmlElement badProtocol, string message) + { + m_proto = badProtocol; + m_msg = message; + } + + /// + /// Gets a message that describes the current exception. + /// + public override string Message + { + get + { + if (m_msg == null) + return string.Format("Invalid protocol: {0}", m_proto.OuterXml); + return string.Format("Invalid protocol ({0}): {1}", m_proto.OuterXml, m_msg); + } + } + } + + /// + /// A jabber error, in an IQ. + /// + [SVN(@"$Id$")] + public class IQException : Exception + { + // TODO: fix this up for new error codes. + private int m_code; + private string m_message; + + /// + /// An authorization exception from an IQ. + /// TODO: Add constructor for code/message + /// TODO: understand v1 errors + /// + /// + public IQException(IQ iq) + { + if (iq == null) + { + //timeout + m_code = 504; + m_message = "Request timed out"; + } + else + { + Error e = iq.Error; + m_code = e.Code; + m_message = e.InnerText; + } + } + + /// + /// The Jabber error number + /// + public int Code + { + get { return m_code; } + } + + /// + /// The text description of the message + /// + public string Description + { + get { return m_message; } + } + + /// + /// Return the error code and message. + /// + /// + public override string ToString() + { + return string.Format("Error {0}: {1}", m_code, m_message); + } + } +} diff -Nru smuxi-0.8/lib/jabber-net/jabber/protocol/Element.cs smuxi-0.8.9.1/lib/jabber-net/jabber/protocol/Element.cs --- smuxi-0.8/lib/jabber-net/jabber/protocol/Element.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/jabber-net/jabber/protocol/Element.cs 2012-01-03 07:52:11.000000000 +0000 @@ -0,0 +1,958 @@ +/* -------------------------------------------------------------------------- + * Copyrights + * + * Portions created by or assigned to Cursive Systems, Inc. are + * Copyright (c) 2002-2008 Cursive Systems, Inc. All Rights Reserved. Contact + * information for Cursive Systems, Inc. is available at + * http://www.cursive.net/. + * + * License + * + * Jabber-Net is licensed under the LGPL. + * See LICENSE.txt for details. + * --------------------------------------------------------------------------*/ +using System; +using System.Collections; +using System.Diagnostics; +using System.Reflection; +using System.Security.Cryptography; +using System.Text; +using System.Text.RegularExpressions; +using System.Xml; + +using bedrock.util; + +namespace jabber.protocol +{ + /// + /// An enum that should translate "_" into "-" for use externally. + /// + [SVN(@"$Id$")] + public class DashAttribute : Attribute + { + /// + /// This is just a flag attribute. + /// + public DashAttribute() + { + } + } + + /// + /// An XmlElement with type-safe accessors. This class is not much use by itself, + /// but provides a number of utility functions for its descendants. + /// + [SVN(@"$Id$")] + public class Element : XmlElement + { + /// + /// UTF-8 encoding used throughout. + /// + protected static readonly Encoding ENCODING = Encoding.UTF8; + + /// + /// Fix up bad namespaces that don't need to be sent on XML streams. + /// jabber:client and jabber:component:accept are removed from the root element, + /// and empty namespace declarations are removed throughout. + /// + private static readonly Regex s_RemoveNS = + new Regex("(?:(?<=^[^>]*)( xmlns=\"(?:jabber:client|jabber:component:accept)\")| xmlns=\"\")", + RegexOptions.Compiled); + + /// + /// + /// + /// + /// + /// + public Element(string prefix, XmlQualifiedName qname, XmlDocument doc) : + base(prefix, qname.Name, qname.Namespace, doc) + { + } + /// + /// + /// + /// + /// + public Element(string localName, XmlDocument doc) : + base("", localName, "", doc) + { + } + /// + /// + /// + /// + /// + /// + public Element(string localName, string namespaceURI, XmlDocument doc) : + base("", localName, namespaceURI, doc) + { + } + + /// + /// Returns the first child element with the given type. + /// + /// You might expect this to be slower than this["name", "uri"], but it's + /// probably actually faster, since that code has to check several different + /// things, and this code can just do a type comparison. + /// + /// The type of child to search for + /// The first child with the given type, or null if none found + public T GetChildElement() + where T : XmlElement + { + for (XmlNode node = this.FirstChild; node != null; node = node.NextSibling) + { + if (node is T) + return (T)node; + } + return null; + } + + /// + /// The xml:lang of this element. + /// + public string Lang + { + get + { + if (!HasAttribute("lang", URI.XML)) + return null; + return GetAttribute("lang", URI.XML); + } + set + { + if (HasAttribute("lang", URI.XML)) + RemoveAttribute("lang", URI.XML); + if (value != null) + { + XmlAttribute attr = OwnerDocument.CreateAttribute("xml:lang", URI.XML); + attr.Value = value; + this.Attributes.Append(attr); + } + } + } + + /// + /// Add a child element. The element can be from a different document. + /// + /// + public void AddChild(XmlElement value) + { + if (this.OwnerDocument == value.OwnerDocument) + { + this.AppendChild(value); + } + else + { + this.AppendChild(this.OwnerDocument.ImportNode(value, true)); + } + } + + /// + /// Get a string representation of this element and its children, with the default + /// namespace stripped off if and only if it is jabber:client or jabber:component:accept. + /// + public override string OuterXml + { + get + { + return s_RemoveNS.Replace(base.OuterXml, ""); + } + } + + /// + /// The implementation of OuterXml from XmlElement, without removing the jabber:client + /// namespace. Needed for Stream. + /// + protected string OriginalOuterXml + { + get { return base.OuterXml; } + } + + /// + /// Returns an XmlNodeList containing a list of child elements that match the specified localname and namespace URI. + /// + /// + /// + /// + public override XmlNodeList GetElementsByTagName(string localName, string namespaceURI) + { + return new ElementList(this, localName, namespaceURI); + } + + /// + /// Returns an XmlNodeList containing a list of child elements that match the specified localname. + /// + /// + /// + public override XmlNodeList GetElementsByTagName(string localName) + { + return new ElementList(this, localName); + } + + /// + /// Get a list of child elements that have the specified type. + /// + /// The type of element to search for + /// A typed element list + public TypedElementList GetElements() + where T : XmlElement + { + return new TypedElementList(this); + } + + /// + /// Gett he text contents of the first sub-element with the specified type + /// + /// + /// + protected string GetElem() + where T : Element + { + T e = GetChildElement(); + if (e == null) + return null; + if (!e.HasChildNodes) + return null; + return e.InnerText; + } + + /// + /// Get the text contents of a sub-element. + /// + /// + /// + protected string GetElem(string name) + { + XmlElement e = this[name]; + if (e == null) + return null; + if (!e.HasChildNodes) + return null; + return e.InnerText; + } + + /// + /// Sets the text contents of a sub-element with a specified type. + /// Creates the element if it doesn't exist. + /// + /// + /// + /// + public T SetElem(string value) + where T : Element + { + T result = GetOrCreateElement(); + result.RemoveAll(); + if (value != null) + result.InnerText = value; + return result; + } + + /// + /// Sets the text contents of a sub-element. + /// Note: Do not use this if you want the sub-element to have a type that is not XmlElement. + /// Instead use + /// + /// The element tag. + /// The inner text of the element. + protected void SetElem(string name, string value) + { + XmlElement e = GetOrCreateElement(name, null, null); + e.RemoveAll(); + + if (value != null) + e.InnerText = value; + } + + /// + /// Sets the text contents of a sub-element. + /// + /// The element tag. + /// The inner text of the element. + /// If the element doesn't exist, create it with this type. If null, then just use an XmlElement. + protected void SetElem(string name, string value, Type typeToCreate) + { + XmlElement e = GetOrCreateElement(name, null, typeToCreate); + e.RemoveAll(); + + if (value != null) + e.InnerText = value; + } + + /// + /// Create an element that is a child of this element, of the specified type. + /// + /// + /// + protected T CreateChildElement() + where T : Element + { + // Note: It would be cool to just do new T(OwnerDocument), but you can only call + // parameter-less constructors in generic-land. + ConstructorInfo constructor = typeof(T).GetConstructor(new Type[] { typeof(XmlDocument) }); + Debug.Assert(constructor != null, "Type " + typeof(T).ToString() + " does not have a constructor taking an XmlDocument"); + T c = (T)constructor.Invoke(new object[] { this.OwnerDocument }); + AppendChild(c); + return c; + } + + /// + /// If a child element exists with the given type, return it. Otherwise, + /// gin up a new instance of the given type, add it as a child, + /// and return the result. + /// + /// This should not have the performance impact of GetOrCreateElement. + /// + /// + /// + protected T GetOrCreateElement() + where T : Element + { + T c = GetChildElement(); + if (c == null) + c = CreateChildElement(); + return c; + } + + /// + /// If the named element exists as a child, return it. Otherwise, gin up + /// a new instance of the given class (which must be a subclass of XmlElement) + /// add it as a child, and return the result. Will often be paired with + /// ReplaceChild as the setter. + /// + /// + /// This seems kind of around-the-barn. Wish there was an easier way to do this, + /// rather than having to get the constructor, and whatnot. Hopefully it won't + /// be called all that often, so the speed issue won't be too bad. + /// + /// + /// Namespace URI. Null to use parent's. + /// If the element doesn't exist, create it with this type. If null, then just use an XmlElement. + /// + protected XmlElement GetOrCreateElement(string name, string xmlns, Type typeToCreate) + { + string ns = (xmlns!=null) ? xmlns : NamespaceURI; + XmlElement child = this[name, ns]; + if (child != null) + return child; + + if (typeToCreate == null) + child = this.OwnerDocument.CreateElement(name, ns); + else + { + Debug.Assert(typeToCreate.IsSubclassOf(typeof(XmlElement))); + + ConstructorInfo constructor = typeToCreate.GetConstructor(new Type[] { typeof(XmlDocument) }); + Debug.Assert(constructor != null); + child = constructor.Invoke(new object[] { this.OwnerDocument }) as XmlElement; + Debug.Assert(child != null); + } + + this.AppendChild(child); + return child; + } + + /// + /// Replaces the first element that has the specified type. + /// + /// The type of sub-element to find + /// The element to replace; if this is null, the old element is just deleted + /// The replaced element + protected T ReplaceChild(T elem) + where T : Element + { + T old = GetChildElement(); + if (old != null) + this.RemoveChild(old); + if (elem != null) + AddChild(elem); + return old; + } + + /// + /// Replaces the first element that has the same name + /// with the passed in element. + /// + /// The new element + /// The replaced element + protected XmlElement ReplaceChild(XmlElement elem) + { + XmlElement old = this[elem.Name, elem.NamespaceURI]; + if (old != null) + { + this.RemoveChild(old); + } + if (elem != null) + AddChild(elem); + return old; + } + + /// + /// Remove a child element of the specified type + /// + /// + /// + protected T RemoveElem() + where T : Element + { + T e = GetChildElement(); + if (e != null) + this.RemoveChild(e); + return e; + } + + /// + /// Remove a child element + /// + /// + /// The old element, or null if it didn't exist. + protected XmlElement RemoveElem(string name) + { + XmlElement e = this[name]; + if (e != null) + this.RemoveChild(e); + return e; + } + + /// + /// Remove each of the child elements with the specified type. + /// + /// + protected void RemoveElems() + where T : Element + { + foreach (T child in GetElements()) + this.RemoveChild(child); + } + + /// + /// Removes all of the matching elements from this element. + /// + /// Element local name + protected void RemoveElems(string name) + { + XmlNodeList nl = this.ChildNodes; + foreach (XmlNode n in nl) + { + if (n.NodeType != XmlNodeType.Element) + continue; + if (n.Name == name) + this.RemoveChild(n); + } + } + /// + /// Removes all of the matching elements from this element. + /// + /// Element local name + /// Element namespace URI. + protected void RemoveElems(string name, string namespaceURI) + { + XmlNodeList nl = this.ChildNodes; + foreach (XmlNode n in nl) + { + if (n.NodeType != XmlNodeType.Element) + continue; + if ((n.Name == name) && (n.NamespaceURI == namespaceURI)) + this.RemoveChild(n); + } + } + + /// + /// I think GetAttribute should return null if the attribute is not found. + /// Use carefully, when translating to external semantics. + /// + /// + protected string GetAttr(string name) + { + if (!HasAttribute(name)) + return null; + return GetAttribute(name); + } + + /// + /// I think calling SetAttr with null or "" should remove the attribute. + /// + /// + /// + protected void SetAttr(string name, string value) + { + if ((value == null) || (value == "")) + // testing shows this is safe for non-existing attributes. + RemoveAttribute(name); + else + SetAttribute(name, value); + } + + /// + /// Get the value of an attribute, as a value in the given Enum type. + /// The specified enum should have a member with value -1, which will + /// be returned if the attribute doesn't exist or is in the wrong format. + /// + /// The enum type + /// The attribute name + /// The enum value + protected T GetEnumAttr(string name) + { + string a = this.GetAttribute(name); + return EnumParser.Parse(a); + } + + /// + /// Get the value of an attribute, as a value in the given Enum type. + /// + /// + /// + /// + protected object GetEnumAttr(string name, Type enumType) + { + string a = this.GetAttribute(name); + return EnumParser.Parse(a, enumType); + } + + /// + /// Set the value of an attribute, with the value being a enum instance. + /// The enum in question should have an entry with int value -1, which + /// corresponds to no attribute. + /// + /// + /// + protected void SetEnumAttr(string name, object value) + { + if ((value == null) || ((int)value == -1)) + { + RemoveAttribute(name); + return; + } + SetAttribute(name, EnumParser.ToString(value)); + } + + /// + /// Get the value of a given attribute, as an integer. Returns -1 for + /// most errors. TODO: should this throw exceptions? + /// + /// + /// + protected int GetIntAttr(string name) + { + string a = this.GetAttribute(name); + if ((a == null) || (a.Length == 0)) + return -1; + try + { + return int.Parse(a); + } + catch (FormatException) + { + return -1; + } + catch (OverflowException) + { + return -1; + } + } + /// + /// Set the value of a given attribute, as an integer. Use -1 + /// to remove the attribute. + /// + /// The attribute name + /// The integer to set + /// + protected void SetIntAttr(string name, int val) + { + if (val < 0) + // testing shows this is safe for non-existing attributes. + RemoveAttribute(name); + else + SetAttribute(name, val.ToString()); + } + + /// + /// Get the value of a given attribute, as an unsigned long. Returns -1L for + /// most errors. TODO: should this throw exceptions? + /// + /// + /// + protected long GetLongAttr(string name) + { + string a = this.GetAttribute(name); + if ((a == null) || (a.Length == 0)) + return -1L; + try + { + return long.Parse(a); + } + catch (FormatException) + { + return -1L; + } + catch (OverflowException) + { + return -1L; + } + } + /// + /// Set the value of a given attribute, as a long Use -1L + /// to remove the attribute. + /// + /// The attribute name + /// The integer to set + /// + protected void SetLongAttr(string name, long val) + { + if (val == -1L) + // testing shows this is safe for non-existing attributes. + RemoveAttribute(name); + else + SetAttribute(name, val.ToString()); + } + + /// + /// Get an attribute cast to DateTime, using the DateTime profile + /// of XEP-82. + /// + /// + /// DateTime.MinValue if attribute not found. + /// Invalid format + protected DateTime GetDateTimeAttr(string name) + { + string val = GetAttr(name); + if (val == null) + return DateTime.MinValue; + return DateTimeProfile(val); + } + + /// + /// Set with DateTime.MinValue to remove the attribute + /// + /// + /// + protected void SetDateTimeAttr(string name, DateTime value) + { + if (value == DateTime.MinValue) + // testing shows this is safe for non-existing attributes. + RemoveAttribute(name); + else + SetAttribute(name, DateTimeProfile(value)); + } + + /// + /// Convert the given array of bytes into a string, having two characters + /// for each byte, corresponding to the hex representation of that byte. + /// + /// + /// + public static string HexString(byte[] buf) + { + // it seems like there ought to be a better way to do this. + StringBuilder sb = new StringBuilder(); + foreach (byte b in buf) + { + sb.Append(b.ToString("x2")); + } + return sb.ToString(); + } + /// + /// Convert the given array of bytes into a string, having two characters + /// for each byte, corresponding to the hex representation of that byte. + /// + /// The byte buffer + /// The offset into the buffer for the start + /// The number of bytes to read, starting at the offset. + /// + public static string HexString(byte[] buf, int offset, int length) + { + // it seems like there ought to be a better way to do this. + StringBuilder sb = new StringBuilder(); + for (int i=offset; i < length; i++) + { + sb.Append(buf[i].ToString("x2")); + } + return sb.ToString(); + } + + /// + /// Compute the SHA1 hash of the id and secret concatenated together. + /// + /// UTF8-encoded id + /// UTF8-encoded secret + /// + public static string ShaHash(string id, string secret) + { + Debug.Assert(id != null); + Debug.Assert(secret != null); + SHA1 sha = SHA1.Create(); + byte[] hash = sha.ComputeHash(ENCODING.GetBytes(id + secret)); + return HexString(hash); + } + + /// + /// Compute a 0K hash + /// + /// The secret to hash in + /// The token to permute the hash + /// Number of times to hash + /// + public static string ZeroK(string password, string token, int sequence) + { + Debug.Assert(password != null); + Debug.Assert(token != null); + SHA1 sha = SHA1.Create(); + string hash = HexString(sha.ComputeHash(ENCODING.GetBytes(password))); + hash = HexString(sha.ComputeHash(ENCODING.GetBytes(hash + token))); + for (int i = 0; i < sequence; i++) + { + hash = HexString(sha.ComputeHash(ENCODING.GetBytes(hash))); + } + return hash; + } + + /// + /// Return a DateTime version of the given Jabber date. Example date: 20020504T20:39:42 + /// + /// The pseudo-ISO-8601 formatted date (no milliseconds) + /// A (usually UTC) DateTime + public static DateTime JabberDate(string dt) + { + if ((dt == null) || (dt == "")) + return DateTime.MinValue; + try + { + return new DateTime(int.Parse(dt.Substring(0, 4)), + int.Parse(dt.Substring(4, 2)), + int.Parse(dt.Substring(6, 2)), + int.Parse(dt.Substring(9,2)), + int.Parse(dt.Substring(12,2)), + int.Parse(dt.Substring(15,2))); + } + catch + { + return DateTime.MinValue; + } + } + /// + /// Get a jabber-formated date for the DateTime. Example date: 20020504T20:39:42 + /// + /// The (usually UTC) DateTime to format + /// The pseudo-ISO-8601 formatted date (no milliseconds) + public static string JabberDate(DateTime dt) + { + return string.Format("{0:yyyy}{0:MM}{0:dd}T{0:HH}:{0:mm}:{0:ss}", dt); + } + + /// + /// XEP-82 Date/Time profile: http://www.xmpp.org/extensions/xep-0082.html#sect-id2601974 + /// CCYY-MM-DDThh:mm:ss[.sss]TZD + /// 1969-07-21T02:56:15Z + /// + /// + /// + public static DateTime DateTimeProfile(string dt) + { + string[] fmts = + { + "yyyy-MM-dd", + "yyyy-MM-ddTHH:mm:sszzz", + "yyyy-MM-ddTHH:mm:ss.fffzzz", + "HH:mm:ss", + "HH:mm:ss.fff", + "HH:mm:sszzz", + "HH:mm:ss.fffzzz", + }; + string arg = dt.Replace("Z", "+00:00"); + return DateTime.ParseExact(arg, fmts, null, System.Globalization.DateTimeStyles.AdjustToUniversal); + } + + /// + /// XEP-82 Date/Time profile: http://www.xmpp.org/extensions/xep-0082.html#sect-id2601974 + /// CCYY-MM-DDThh:mm:ss[.sss]TZD + /// 1969-07-21T02:56:15Z + /// + /// + /// + public static string DateTimeProfile(DateTime dt) + { + return dt.ToString("yyyy-MM-ddTHH:mm:ss.fffZ"); + } + + /// + /// The XML for the packet. + /// + /// + public override string ToString() + { + return this.OuterXml; + } + + /// + /// Return just the start tag for the element. + /// + /// + public string StartTag() + { + StringBuilder sb = new StringBuilder("<"); + sb.Append(this.Name); + if (this.NamespaceURI != null) + { + sb.Append(" xmlns"); + if (this.Prefix != null) + { + sb.Append(":"); + sb.Append(this.Prefix); + } + sb.Append("=\""); + sb.Append(this.NamespaceURI); + sb.Append("\""); + } + foreach (XmlAttribute attr in this.Attributes) + { + sb.Append(" "); + sb.Append(attr.Name); + sb.Append("=\""); + sb.Append(attr.Value); + sb.Append("\""); + } + sb.Append(">"); + return sb.ToString(); + } + + /// + /// Get the first child element of this element. + /// + /// null if none found. + public XmlElement GetFirstChildElement() + { + foreach (XmlNode n in this) + { + if (n.NodeType == XmlNodeType.Element) + return (XmlElement) n; + } + return null; + } + + private static readonly Type[] s_constructor_parms = + new Type[] + { + typeof(string), + typeof(XmlQualifiedName), + typeof(XmlDocument) + }; + + /// + /// Clone this node, preserving type information. + /// + /// Clone child nodes too? + /// Cloned node, with type info intact + public override XmlNode CloneNode(bool deep) + { + return CloneNode(deep, this.OwnerDocument); + } + + /// + /// Clone this node into the target document, preserving type information. + /// + /// + /// + /// + public XmlNode CloneNode(bool deep, XmlDocument doc) + { + ConstructorInfo ci = this.GetType().GetConstructor(s_constructor_parms); + if (ci == null) + return doc.ImportNode(this, deep); + if (ci.DeclaringType != this.GetType()) + { + Debug.WriteLine("Bad type: " + ci.DeclaringType.ToString()); + } + XmlElement el = (Element)ci.Invoke(new object[] { this.Prefix, new XmlQualifiedName(this.LocalName, this.NamespaceURI), doc }); + if (el.GetType() != this.GetType()) + { + Debug.Assert(el.GetType() == this.GetType()); + } + + if (el.IsEmpty != this.IsEmpty) + el.IsEmpty = this.IsEmpty; + + + if (this.HasAttributes) + { + foreach (XmlAttribute attr in this.Attributes) + el.Attributes.Append((XmlAttribute)doc.ImportNode(attr, true)); + } + + if (deep) + { + foreach (XmlNode n in this.ChildNodes) + { + if (n is Element) + { + el.AppendChild(((Element)n).CloneNode(deep, doc)); + } + else + { + el.AppendChild(doc.ImportNode(n, deep)); + } + } + } + return el; + } + + /// + /// Convert the given source element to typed subclasses of Element, according + /// to the given ElementFactory. + /// + /// + /// + /// + public static Element AddTypes(XmlElement source, ElementFactory factory) + { + if (source is Element) + return (Element)source; // assume all kids are converted already. + + XmlDocument doc = source.OwnerDocument; + XmlQualifiedName qn = new XmlQualifiedName(source.Name, source.NamespaceURI); + Element el = factory.GetElement(source.Prefix, qn, doc); + + el.IsEmpty = source.IsEmpty; + + if (source.HasAttributes) + { + foreach (XmlAttribute attr in source.Attributes) + el.Attributes.Append((XmlAttribute)attr.CloneNode(true)); + } + + foreach (XmlNode n in source.ChildNodes) + { + if (n is XmlElement) + el.AppendChild(AddTypes((XmlElement)n, factory)); + else + el.AppendChild(n.CloneNode(true)); + } + + return el; + } + + /// + /// System-wide one-up counter, for numbering packets. + /// + static int s_counter = 0; + /// + /// Reset the packet ID counter. This is ONLY to be used for test cases! No locking! + /// + [Conditional("DEBUG")] + public static void ResetID() + { + s_counter = 0; + } + + /// + /// Increment the ID counter, and get the new value. + /// + /// The new ID. + public static string NextID() + { + System.Threading.Interlocked.Increment(ref s_counter); + return "JN_" + s_counter.ToString(); + } + } +} diff -Nru smuxi-0.8/lib/jabber-net/jabber/protocol/ElementFactory.cs smuxi-0.8.9.1/lib/jabber-net/jabber/protocol/ElementFactory.cs --- smuxi-0.8/lib/jabber-net/jabber/protocol/ElementFactory.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/jabber-net/jabber/protocol/ElementFactory.cs 2012-01-03 07:52:11.000000000 +0000 @@ -0,0 +1,198 @@ +/* -------------------------------------------------------------------------- + * Copyrights + * + * Portions created by or assigned to Cursive Systems, Inc. are + * Copyright (c) 2002-2008 Cursive Systems, Inc. All Rights Reserved. Contact + * information for Cursive Systems, Inc. is available at + * http://www.cursive.net/. + * + * License + * + * Jabber-Net is licensed under the LGPL. + * See LICENSE.txt for details. + * --------------------------------------------------------------------------*/ +using System; + +using System.Collections; +using System.Diagnostics; +using System.Reflection; +using System.Xml; + +using bedrock.util; + +namespace jabber.protocol +{ + /// + /// Qname to type mapping. + /// + [SVN(@"$Id$")] + public class QnameType + { + /// + /// Element name + /// + protected internal string Name; + /// + /// Element namespace URI + /// + protected internal string NS; + /// + /// Type to create for NS/Name pair + /// + protected internal Type ElementType; + + /// + /// Create a QnameType + /// + /// + /// + /// + public QnameType(string name, string ns, Type typ) + { + this.Name = name; + this.NS = ns; + this.ElementType = typ; + } + + /// + /// Is this the same qname by element name and namespace? + /// + /// + /// + public override bool Equals(object obj) + { + if (obj == (object)this) + return true; + QnameType other = obj as QnameType; + if (other == null) + return false; + return (other.Name == Name) && (other.NS == NS); + } + + /// + /// Get a hash over the name and namespace. + /// + /// + public override int GetHashCode() + { + return ToString().GetHashCode(); + } + + /// + /// Namespace|Name + /// + /// + public override string ToString() + { + return NS + "|" + Name; + } + } + + /// + /// Interface for packet factories to implement. + /// + [SVN(@"$Id$")] + public interface IPacketTypes + { + /// + /// QName to type mappings. + /// + QnameType[] Types { get; } + } + + /// + /// A ElementFactory is a class that knows how to create packet instances of + /// a wide variety of different types. + /// + [SVN(@"$Id$")] + public class ElementFactory + { + private Hashtable m_types = new Hashtable(); + private static readonly Type[] s_constructorTypes = + new Type[] { typeof(string), + typeof(XmlQualifiedName), + typeof(XmlDocument) }; + /// + /// Add a type to the packet factory. + /// + /// + /// + /// + public void AddType(string localName, string ns, Type t) + { + Debug.Assert(t.IsSubclassOf(typeof(Element))); + ConstructorInfo ci = t.GetConstructor(s_constructorTypes); + Debug.Assert(ci != null); + AddType(new XmlQualifiedName(localName, ns), ci); + } + /// + /// Add a type to the packet factory. + /// + /// + /// + public void AddType(XmlQualifiedName qname, Type t) + { + Debug.Assert(t.IsSubclassOf(typeof(Element))); + ConstructorInfo ci = t.GetConstructor(s_constructorTypes); + Debug.Assert(ci != null); + AddType(qname, ci); + } + /// + /// Add a type to the packet factory. + /// + /// + /// + public void AddType(XmlQualifiedName qname, ConstructorInfo ci) + { + Debug.Assert(ci != null); + if (m_types.Contains(qname)) + Debug.WriteLine("Warning: overriding existing packet factory: " + qname.ToString()); + m_types[qname] = ci; + } + /// + /// Add a type to the packet factory. + /// + /// + public void AddType(IPacketTypes list) + { + foreach (QnameType qn in list.Types) + { + this.AddType(qn.Name, qn.NS, qn.ElementType); + } + } + /* + public void AddType(ElementFactory pf) + { + foreach (DictionaryEntry ent in (IDictionary)pf.m_types) + { + m_types.Add(ent.Key, ent.Value); + } + } +*/ + /// + /// Create an element of the appropriate type, based on the qname of the packet. + /// + /// The namespace prefix for the element + /// The namespaceURI/element name pair + /// The document to create the element in. + /// + public Element GetElement(string prefix, XmlQualifiedName qname, XmlDocument doc) + { + ConstructorInfo ci = (ConstructorInfo) m_types[qname]; + if (ci == null) + { + return new Element(prefix, qname, doc); + } + return (Element) ci.Invoke + (new object[] {prefix, qname, doc}); + } + + /// + /// Get a constructor for the appropriate type for the given qname. + /// + public ConstructorInfo this[XmlQualifiedName qname] + { + get { return (ConstructorInfo) m_types[qname]; } + } + } +} diff -Nru smuxi-0.8/lib/jabber-net/jabber/protocol/ElementList.cs smuxi-0.8.9.1/lib/jabber-net/jabber/protocol/ElementList.cs --- smuxi-0.8/lib/jabber-net/jabber/protocol/ElementList.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/jabber-net/jabber/protocol/ElementList.cs 2012-01-03 07:52:11.000000000 +0000 @@ -0,0 +1,332 @@ +/* -------------------------------------------------------------------------- + * Copyrights + * + * Portions created by or assigned to Cursive Systems, Inc. are + * Copyright (c) 2002-2008 Cursive Systems, Inc. All Rights Reserved. Contact + * information for Cursive Systems, Inc. is available at + * http://www.cursive.net/. + * + * License + * + * Jabber-Net is licensed under the LGPL. + * See LICENSE.txt for details. + * --------------------------------------------------------------------------*/ +using System; + +using System.Collections; +using System.Xml; +using bedrock.util; + +namespace jabber.protocol +{ + /// + /// Replacement for XmlElementList that removes the safety belt of checking for changes during traversal, + /// but removes the big old memory leak in MS's implementation. Also, only returns first-level children, + /// rather than all children below here with the given name. Thanks, MS. + /// + [SVN(@"$Id$")] + public class ElementList : XmlNodeList + { + private XmlElement m_parent = null; + private string m_name = null; + private string m_uri = null; + + /// + /// Create an element list that is for all child elements. + /// + /// Parent to search + public ElementList(XmlElement parent) + { + m_parent = parent; + } + + /// + /// Create an element list that is for all child elements with the given name; + /// + /// + /// + public ElementList(XmlElement parent, string name) + : this(parent) + { + m_name = name; + } + + /// + /// Create an element list that is for all child elements with the given name and namespace URI. + /// + /// + /// + /// + public ElementList(XmlElement parent, string name, string namespaceURI) + : this(parent) + { + m_name = name; + m_uri = namespaceURI; + } + + /// + /// Get the next node in the enumeration. Pass in null to start. + /// + /// Starting point for search. + /// + public XmlNode GetNextNode(XmlNode start) + { + XmlNode n = (start == null) ? m_parent.FirstChild : start.NextSibling; + while ((n != null) && !this.IsMatch(n)) + { + n = n.NextSibling; + } + return n; + } + + private bool IsMatch(XmlNode curNode) + { + if (curNode.NodeType != XmlNodeType.Element) + return false; + + if (m_name == null) + return true; + + if (m_uri == null) + return (curNode.LocalName == m_name); + + return (curNode.LocalName == m_name) && (curNode.NamespaceURI == m_uri); + } + + /// + /// Enumerate over the matching children. + /// + /// + public override System.Collections.IEnumerator GetEnumerator() + { + return new ElementListEnumerator(this); + } + + /// + /// Gets the number of matching children. + /// + public override int Count + { + get + { + int c = 0; + XmlNode n = null; + while ((n = GetNextNode(n)) != null) + { + c++; + } + return c; + } + } + + /* + * This breaks the Mono build, and shouldn't be necessary, since + * the base class implements exactly this. + /// + /// Retrieve a given child. + /// + public override XmlNode this[int i] + { + get { return Item(i); } + } + */ + + /// + /// Retrieve a given child. + /// + /// + /// + public override XmlNode Item(int index) + { + int c = 0; + XmlNode n = m_parent.FirstChild; + while (n != null) + { + if (c == index) + return n; + c++; + n = GetNextNode(n); + } + return null; + } + + private class ElementListEnumerator : IEnumerator + { + private ElementList m_list; + private XmlNode m_cur = null; + + public ElementListEnumerator(ElementList list) + { + m_list = list; + } + + #region IEnumerator Members + + public void Reset() + { + m_cur = null; + } + + public object Current + { + get { return m_cur; } + } + + public bool MoveNext() + { + m_cur = m_list.GetNextNode(m_cur); + return (m_cur != null); + } + + #endregion + } + } + + /// + /// Parameterized version of ElementList. + /// + [SVN(@"$Id$")] + public class TypedElementList : XmlNodeList, System.Collections.Generic.IEnumerable + where T : XmlElement + { + private XmlElement m_parent = null; + + /// + /// Create an element list that is for all child elements with the specified type + /// + /// + public TypedElementList(XmlElement parent) + { + m_parent = parent; + } + + /// + /// Get the next node in the enumeration. Pass in null to start. + /// + /// Starting point for search. + /// + public T GetNextNode(T start) + { + XmlNode n = (start == null) ? m_parent.FirstChild : start.NextSibling; + while ((n != null) && !(n is T)) + { + n = n.NextSibling; + } + return (T)n; + } + + /// + /// Enumerate over the matching children. + /// + /// + public override System.Collections.IEnumerator GetEnumerator() + { + return new TypedElementListEnumerator(this); + } + + System.Collections.Generic.IEnumerator System.Collections.Generic.IEnumerable.GetEnumerator() + { + return new TypedElementListEnumerator(this); + } + + /// + /// Gets the number of matching children. + /// + public override int Count + { + get + { + int c = 0; + T n = null; + while ((n = GetNextNode(n)) != null) + { + c++; + } + return c; + } + } + + /// + /// Retrieve a given child. + /// + /// + /// + public override XmlNode Item(int index) + { + int c = 0; + T n = null; + while ((n = GetNextNode(n)) != null) + { + if (c == index) + return n; + c++; + } + return null; + } + + /// + /// Create an aray from the list. + /// + /// + public T[] ToArray() + { + T[] array = new T[Count]; + int i = 0; + foreach (T item in this) + { + //T item = (T)o; + array[i++] = item; + } + return array; + } + + private class TypedElementListEnumerator : IEnumerator, System.Collections.Generic.IEnumerator + { + private TypedElementList m_list; + private T m_cur = null; + + public TypedElementListEnumerator(TypedElementList list) + { + m_list = list; + } + + #region IEnumerator Members + + public void Reset() + { + m_cur = null; + } + + public object Current + { + get { return m_cur; } + } + + public bool MoveNext() + { + m_cur = m_list.GetNextNode(m_cur); + return (m_cur != null); + } + + #endregion + + #region IEnumerator Members + + T System.Collections.Generic.IEnumerator.Current + { + get { return m_cur; } + } + + #endregion + + #region IDisposable Members + + public void Dispose() + { + + } + + #endregion + } + } +} diff -Nru smuxi-0.8/lib/jabber-net/jabber/protocol/ElementStream.cs smuxi-0.8.9.1/lib/jabber-net/jabber/protocol/ElementStream.cs --- smuxi-0.8/lib/jabber-net/jabber/protocol/ElementStream.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/jabber-net/jabber/protocol/ElementStream.cs 2012-01-03 07:52:11.000000000 +0000 @@ -0,0 +1,166 @@ +/* -------------------------------------------------------------------------- + * Copyrights + * + * Portions created by or assigned to Cursive Systems, Inc. are + * Copyright (c) 2002-2008 Cursive Systems, Inc. All Rights Reserved. Contact + * information for Cursive Systems, Inc. is available at + * http://www.cursive.net/. + * + * License + * + * Jabber-Net is licensed under the LGPL. + * See LICENSE.txt for details. + * --------------------------------------------------------------------------*/ +using System; + +using System.Collections; +using System.Diagnostics; +using System.IO; +using System.Threading; +using System.Xml; + +using bedrock.io; +using bedrock.util; +using jabber.protocol; + +namespace jabber.protocol +{ + /// + /// A packet was received. The specified element will likely be a sub-class + /// of XmlElement, if the packet is found in the packet factory. + /// + public delegate void ProtocolHandler(Object sender, System.Xml.XmlElement rp); + + /// + /// Async XML parsing, according to jabber protocol rules of "interesting". + /// The root node fires IElementStreamListener.OnDocumentStart(), and each + /// direct child of the root fires IElementStreamListener.OnTag(). + /// + /// TODO: Combine with AsyncElementStream, since there's only one impl. + /// + [SVN(@"$Id$")] + public class ElementStream + { + /// + /// The document to create elements in + /// + protected XmlDocument m_doc; + + /// + /// The element factory. + /// + protected ElementFactory m_factory = new ElementFactory(); + + /// + /// The document started. This will have a full element, even + /// though only the start tag has been received. + /// + public event ProtocolHandler OnDocumentStart; + + /// + /// The document has completed. + /// TODO: This isn't fired as often as it needs to be, yet. + /// + public event bedrock.ObjectHandler OnDocumentEnd; + + /// + /// A protocol element (child of the doc root) has been received. + /// + public event ProtocolHandler OnElement; + + /// + /// An XML parsing error occurred. + /// + public event bedrock.ExceptionHandler OnError; + + /// + /// Create a parser that will report events to the listener. + /// + protected ElementStream() + { + m_doc = new XmlDocument(); + m_factory.AddType(new jabber.protocol.stream.Factory()); + } + + /// + /// The document being read into. This document is used for creating nodes, + /// but does not actually contain the nodes. + /// + public XmlDocument Document + { + get { return m_doc; } + } + + /// + /// Add PacketFactories to get XmlElements with type-safe accessors, for + /// all of the namespaces you care about. + /// + /// + public void AddFactory(IPacketTypes pf) + { + m_factory.AddType(pf); + } + + /// + /// Add a type to the packet factory. + /// + /// Local Name (e.g. query) + /// Namespace URI (e.g. jabber:iq:roster) + /// Type to create + public void AddType(string localName, string ns, Type t) + { + m_factory.AddType(localName, ns, t); + } + + /// + /// Fire the OnDocumentStart event + /// + /// + protected void FireOnDocumentStart(XmlElement stream) + { + if (OnDocumentStart != null) + OnDocumentStart(this, stream); + } + + /// + /// Fire the OnElement event + /// + /// + protected void FireOnElement(XmlElement elem) + { + if (OnElement != null) + OnElement(this, elem); + } + + /// + /// Fire the OnDocumentEnd event + /// + protected void FireOnDocumentEnd() + { + if (OnDocumentEnd != null) + OnDocumentEnd(this); + } + + /// + /// Fire the OnError event + /// + /// The exception that was thrown + protected void FireOnError(Exception ex) + { + if (OnError != null) + OnError(this, ex); + } + + /// + /// Get an element by name using the current factory. + /// + /// The element name to use + /// The namespace URI of the element to get + /// + public Element GetElement(string name, string ns) + { + XmlQualifiedName q = new XmlQualifiedName(name, ns); + return m_factory.GetElement("", q, m_doc); + } + } +} diff -Nru smuxi-0.8/lib/jabber-net/jabber/protocol/EnumParser.cs smuxi-0.8.9.1/lib/jabber-net/jabber/protocol/EnumParser.cs --- smuxi-0.8/lib/jabber-net/jabber/protocol/EnumParser.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/jabber-net/jabber/protocol/EnumParser.cs 2012-01-03 07:52:11.000000000 +0000 @@ -0,0 +1,189 @@ +/* -------------------------------------------------------------------------- + * Copyrights + * + * Portions created by or assigned to Cursive Systems, Inc. are + * Copyright (c) 2002-2008 Cursive Systems, Inc. All Rights Reserved. Contact + * information for Cursive Systems, Inc. is available at + * http://www.cursive.net/. + * + * License + * + * Jabber-Net is licensed under the LGPL. + * See LICENSE.txt for details. + * --------------------------------------------------------------------------*/ +using System; +using System.Collections.Generic; +using System.Threading; +using System.Reflection; +using System.Diagnostics; + +using bedrock.util; + +namespace jabber.protocol +{ + /// + /// How should the marked-up entity be rendered in XML? Only used + /// for enums that are going to be put in attributes at the moment. + /// TODO: support namespaces, use for element definitions. + /// + [SVN(@"$Id$")] + [AttributeUsage(AttributeTargets.Field)] + public class XMLAttribute : Attribute + { + private string m_name; + + /// + /// Create + /// + /// + public XMLAttribute(string name) + { + m_name = name; + } + + /// + /// The string to use when converting to and from XML. + /// + public string Name + { + get { return m_name; } + } + } + + /// + /// Parse enums + /// + [SVN(@"$Id$")] + public class EnumParser + { + private static Dictionary> s_vals = + new Dictionary>(); + + private static Dictionary> s_strings = + new Dictionary>(); + + private static bool IsDash(Type t) + { + object[] da = t.GetCustomAttributes(typeof(DashAttribute), false); + return (da.Length > 0); + } + + private static Dictionary GetValHash(Type t) + { + Dictionary map = null; + if (!s_vals.TryGetValue(t, out map)) + { + s_vals[t] = map = new Dictionary(); + bool dash = IsDash(t); + + FieldInfo[] fields = t.GetFields(BindingFlags.Public | BindingFlags.Static); + foreach (FieldInfo fi in fields) + { + object[] attrs = fi.GetCustomAttributes(typeof(XMLAttribute), false); + object val = fi.GetValue(null); + if (attrs.Length > 0) + { + string name = ((XMLAttribute)attrs[0]).Name; + map[name] = val; + } + if (dash) + map[fi.Name.Replace("_", "-")] = val; + else + map[fi.Name] = val; + } + } + return map; + } + + private static Dictionary GetStringHash(Type t) + { + Dictionary map = null; + string name; + + if (!s_strings.TryGetValue(t, out map)) + { + s_strings[t] = map = new Dictionary(); + + bool dash = IsDash(t); + + FieldInfo[] fields = t.GetFields(BindingFlags.Public | BindingFlags.Static); + foreach (FieldInfo fi in fields) + { + object[] attrs = fi.GetCustomAttributes(typeof(XMLAttribute), false); + object val = fi.GetValue(null); + if (attrs.Length > 0) + name = ((XMLAttribute)attrs[0]).Name; + else + { + if (dash) + name = fi.Name.Replace('_', '-'); + else + name = fi.Name; + } + map[val] = name; + } + } + return map; + } + + /// + /// Parse a string into an enum value for the given type T. + /// Any errors map to -1. + /// + /// + /// + /// + public static T Parse(string value) + { + if (!typeof(T).IsEnum) + throw new ArgumentException("Type must be enum"); + + Dictionary map = GetValHash(typeof(T)); + object val = null; + if (!map.TryGetValue(value, out val)) + return (T)(object)(-1); + return (T)val; + } + + /// + /// Parse a string into an enum value for the given type. + /// Any errors map to -1. + /// + /// + /// + /// + public static object Parse(string value, Type t) + { + if (!t.IsEnum) + throw new ArgumentException("Type must be enum"); + + Dictionary map = GetValHash(t); + object val = null; + if (!map.TryGetValue(value, out val)) + return (object)(-1); + return val; + } + + /// + /// Convert an enum value into its string representation. + /// any -1 value gets mapped to null. + /// + /// + /// + public static string ToString(object value) + { + Type t = value.GetType(); + if (!t.IsEnum) + throw new ArgumentException("Type must be enum"); + + if ((int)value == -1) + return null; + + Dictionary map = GetStringHash(t); + string val = null; + bool found = map.TryGetValue(value, out val); + Debug.Assert(found, "Tried to convert an unknown enum value to string"); + return val; + } + } +} diff -Nru smuxi-0.8/lib/jabber-net/jabber/protocol/iq/Agents.cs smuxi-0.8.9.1/lib/jabber-net/jabber/protocol/iq/Agents.cs --- smuxi-0.8/lib/jabber-net/jabber/protocol/iq/Agents.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/jabber-net/jabber/protocol/iq/Agents.cs 2012-01-03 07:52:11.000000000 +0000 @@ -0,0 +1,229 @@ +/* -------------------------------------------------------------------------- + * Copyrights + * + * Portions created by or assigned to Cursive Systems, Inc. are + * Copyright (c) 2002-2008 Cursive Systems, Inc. All Rights Reserved. Contact + * information for Cursive Systems, Inc. is available at + * http://www.cursive.net/. + * + * License + * + * Jabber-Net is licensed under the LGPL. + * See LICENSE.txt for details. + * --------------------------------------------------------------------------*/ +using System; + +using System.Xml; + +using bedrock.util; + +namespace jabber.protocol.iq +{ + //
+    // 
+    //   
+    //     
+    //       Jabber User Directory
+    //       jud
+    //       
+    //       
+    //     
+    //   
+    // 
+    // 
+ /// + /// IQ packet with an agents query element inside. + /// + [SVN(@"$Id$")] + public class AgentsIQ : jabber.protocol.client.TypedIQ + { + /// + /// Create an agents IQ packet. + /// + /// + public AgentsIQ(XmlDocument doc) : base(doc) + { + } + } + + /// + /// An agents query element. + /// + [SVN(@"$Id$")] + public class AgentsQuery : Element + { + /// + /// + /// + /// + public AgentsQuery(XmlDocument doc) : base("query", URI.AGENTS, doc) + { + } + /// + /// + /// + /// + /// + /// + public AgentsQuery(string prefix, XmlQualifiedName qname, XmlDocument doc) : + base(prefix, qname, doc) + { + } + + /// + /// Add an agent to the list + /// + /// + public Agent AddAgent() + { + return CreateChildElement(); + } + + /// + /// Get the list of agents + /// + /// + public Agent[] GetAgents() + { + return GetElements().ToArray(); + } + } + + /// + /// Agent items + /// + [SVN(@"$Id$")] + public class Agent : Element + { + /// + /// + /// + /// + public Agent(XmlDocument doc) : base("agent", URI.AGENTS, doc) + { + } + + /// + /// + /// + /// + /// + /// + public Agent(string prefix, XmlQualifiedName qname, XmlDocument doc) : + base(prefix, qname, doc) + { + } + + /// + /// The agent's JID + /// + public JID JID + { + get { return GetAttr("jid"); } + set { this.SetAttr("jid", value.ToString()); } + } + + /// + /// The agent's name + /// + public string AgentName + { + get { return GetElem("name"); } + set { SetElem("name", value); } + } + + /// + /// The agent's description + /// + public string Description + { + get { return GetElem("description"); } + set { SetElem("description", value); } + } + + /// + /// Is the agent a transport? + /// + public bool Transport + { + get { return this["transport"] != null; } + set + { + if (value) + { + SetElem("transport", null); + } + else + { + RemoveElem("transport"); + } + } + } + + /// + /// Is the agent for groupchat? + /// + public bool Groupchat + { + get { return this["groupchat"] != null; } + set + { + if (value) + { + SetElem("groupchat", null); + } + else + { + RemoveElem("groupchat"); + } + } + } + + /// + /// The agent service name. + /// + public string Service + { + get { return GetElem("service"); } + set { SetElem("service", value); } + } + + /// + /// Is the agent a registrar? + /// + public bool Register + { + get { return this["register"] != null; } + set + { + if (value) + { + SetElem("register", null); + } + else + { + RemoveElem("register"); + } + } + } + + /// + /// Is the agent for JUD? + /// + public bool Search + { + get { return this["search"] != null; } + set + { + if (value) + { + SetElem("search", null); + } + else + { + RemoveElem("search"); + } + } + } + } +} diff -Nru smuxi-0.8/lib/jabber-net/jabber/protocol/iq/Auth.cs smuxi-0.8.9.1/lib/jabber-net/jabber/protocol/iq/Auth.cs --- smuxi-0.8/lib/jabber-net/jabber/protocol/iq/Auth.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/jabber-net/jabber/protocol/iq/Auth.cs 2012-01-03 07:52:11.000000000 +0000 @@ -0,0 +1,175 @@ +/* -------------------------------------------------------------------------- + * Copyrights + * + * Portions created by or assigned to Cursive Systems, Inc. are + * Copyright (c) 2002-2008 Cursive Systems, Inc. All Rights Reserved. Contact + * information for Cursive Systems, Inc. is available at + * http://www.cursive.net/. + * + * License + * + * Jabber-Net is licensed under the LGPL. + * See LICENSE.txt for details. + * --------------------------------------------------------------------------*/ +using System; + +using System.Diagnostics; +using System.Security.Cryptography; +using System.Xml; + +using bedrock.util; + +namespace jabber.protocol.iq +{ + /// + /// An auth IQ. + /// + [SVN(@"$Id$")] + public class AuthIQ : jabber.protocol.client.TypedIQ + { + /// + /// Create an Auth IQ. + /// + /// + public AuthIQ(XmlDocument doc) : base(doc) + { + } + } + + /// + /// Client authentication, with digest support. Call SetAuth() to compute + /// the digest. + /// + [SVN(@"$Id$")] + public class Auth : Element + { + /// + /// + /// + /// + public Auth(XmlDocument doc) : + base("query", URI.AUTH, doc) + { + } + + /// + /// + /// + /// + /// + /// + public Auth(string prefix, XmlQualifiedName qname, XmlDocument doc) : + base(prefix, qname, doc) + { + } + + /// + /// Set the authentication information. + /// TODO: 0k + /// + /// The user name. NOT the JID. + /// The user's password. + /// The id from the stream:stream + /// that the server sent, or null for plaintext. + public void SetDigest(string username, string password, string StreamID) + { + Debug.Assert(username != null); + Debug.Assert(password != null); + Debug.Assert(StreamID != null); + this.Username = username; + this.Digest = ShaHash(StreamID, password); + } + /// + /// Set the authentication information, for plaintext auth. + /// + /// The user name. NOT the JID. + /// The user's password. + public void SetAuth(string username, string password) + { + Debug.Assert(username != null); + Debug.Assert(password != null); + this.Username = username; + this.Password = password; + } + + /// + /// Set the zero-knowledge information for this iq. + /// + /// + /// + /// + /// + public void SetZeroK(string username, + string password, + string token, + int sequence) + { + Debug.Assert(username != null); + this.Username = username; + this.Hash = Element.ZeroK(password, token, sequence); + } + + /// + /// The user's account name. NOT the JID. + /// + public string Username + { + get { return GetElem("username"); } + set { SetElem("username", value); } + } + + /// + /// The plaintext password. + /// + public string Password + { + get { return GetElem("password"); } + set { SetElem("password", value); } + } + + /// + /// SHA1 hash of the StreamID and the password. + /// + public string Digest + { + get { return GetElem("digest"); } + set { SetElem("digest", value); } + } + + /// + /// The resource to connect with. + /// + public string Resource + { + get { return GetElem("resource"); } + set { SetElem("resource", value); } + } + + /// + /// Gets the zero-k token. + /// + public string Token + { + get { return GetElem("token"); } + set { SetElem("token", value); } + } + + /// + /// Zero-k sequence + /// + public int Sequence + { + get { return Int32.Parse(GetElem("sequence")); } + set { SetElem("sequence", value.ToString()); } + } + + /// + /// Zero-k hash. NOT DIGEST! + /// + public string Hash + { + get { return GetElem("hash"); } + set { SetElem("hash", value); } + } + } +} diff -Nru smuxi-0.8/lib/jabber-net/jabber/protocol/iq/Bookmarks.cs smuxi-0.8.9.1/lib/jabber-net/jabber/protocol/iq/Bookmarks.cs --- smuxi-0.8/lib/jabber-net/jabber/protocol/iq/Bookmarks.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/jabber-net/jabber/protocol/iq/Bookmarks.cs 2012-01-03 07:52:11.000000000 +0000 @@ -0,0 +1,344 @@ +/* -------------------------------------------------------------------------- + * Copyrights + * + * Portions created by or assigned to Cursive Systems, Inc. are + * Copyright (c) 2002-2008 Cursive Systems, Inc. All Rights Reserved. Contact + * information for Cursive Systems, Inc. is available at + * http://www.cursive.net/. + * + * License + * + * Jabber-Net is licensed under the LGPL. + * See LICENSE.txt for details. + * --------------------------------------------------------------------------*/ +using System; +using System.Diagnostics; +using System.Xml; + +using bedrock.util; + +namespace jabber.protocol.iq +{ + /// + /// An IQ in jabber:iq:private, with a bookmarks body. + /// + [SVN(@"$Id$")] + public class BookmarksIQ : PrivateIQ + { + /// + /// Create for outbound. + /// + /// + public BookmarksIQ(XmlDocument doc) : base(doc) + { + this.Instruction.AddChild(new Bookmarks(doc)); + } + + /// + /// Get the bookmarks element. + /// + public Bookmarks Bookmarks + { + get { return this.Instruction.GetChildElement(); } + } + } + + /// + /// The bookmarks to be stored. + /// + [SVN(@"$Id$")] + public class Bookmarks : Element + { + /// + /// Create for outbound. + /// + /// + public Bookmarks(XmlDocument doc) : + base("storage", URI.BOOKMARKS, doc) + { + } + + /// + /// Create for inbound. + /// + /// + /// + /// + public Bookmarks(string prefix, XmlQualifiedName qname, XmlDocument doc) : + base(prefix, qname, doc) + { + } + + /// + /// Get all of the URLs contained in the bookmark list. + /// + /// + public BookmarkURL[] GetUrls() + { + return this.GetElements().ToArray(); + } + + /// + /// Add a URL bookmark + /// + /// The URL to add + /// Descriptive text + /// + public BookmarkURL AddURL(string URL, string name) + { + BookmarkURL u = new BookmarkURL(this.OwnerDocument); + u.URL = URL; + u.URLName = name; + this.AddChild(u); + return u; + } + + /// + /// Get all of the conferences contained in the bookmark list. + /// + /// + public BookmarkConference[] GetConferences() + { + return this.GetElements().ToArray(); + } + + /// + /// Add a conference room to the bookmark list + /// + /// + /// + /// + /// + /// + public BookmarkConference AddConference(JID jid, string name, bool autoJoin, string nick) + { + BookmarkConference c = new BookmarkConference(this.OwnerDocument); + c.JID = jid; + c.ConferenceName = name; + c.AutoJoin = autoJoin; + if (nick != null) + c.Nick = nick; + this.AddChild(c); + return c; + } + + /// + /// Get all of the notes contained in the bookmark list. + /// + /// + public BookmarkNote[] GetNotes() + { + return this.GetElements().ToArray(); + } + + /// + /// Add a note to the bookmark list. + /// + /// + /// + /// + public BookmarkNote AddNote(JID jid, string text) + { + BookmarkNote n = new BookmarkNote(this.OwnerDocument); + n.JID = jid; + n.Text = text; + this.AddChild(n); + return n; + } + } + + /// + /// A URL stored in bookmarks. + /// + [SVN(@"$Id$")] + public class BookmarkURL : Element + { + /// + /// Create for outbound. + /// + /// + public BookmarkURL(XmlDocument doc) : + base("url", URI.BOOKMARKS, doc) + { + } + + /// + /// Create for inbound. + /// + /// + /// + /// + public BookmarkURL(string prefix, XmlQualifiedName qname, XmlDocument doc) : + base(prefix, qname, doc) + { + } + + /// + /// The HTTP or HTTPS URL of the web page, according to spec. + /// In practice, any URI. + /// + public string URL + { + get { return GetAttr("url"); } + set { SetAttr("url", value); } + } + + /// + /// A friendly name for the bookmark. + /// + public string URLName + { + get { return GetAttr("name"); } + set { SetAttr("name", value); } + } + } + + /// + /// A conference room name stored in bookmarks + /// + [SVN(@"$Id$")] + public class BookmarkConference : Element + { + /// + /// Create for outbound. + /// + /// + public BookmarkConference(XmlDocument doc) : + base("conference", URI.BOOKMARKS, doc) + { + } + + /// + /// Create for inbound. + /// + /// + /// + /// + public BookmarkConference(string prefix, XmlQualifiedName qname, XmlDocument doc) : + base(prefix, qname, doc) + { + } + + /// + /// Should the room be joined on startup? + /// + public bool AutoJoin + { + get + { + string aj = GetAttr("autojoin"); + return (aj == "true") || (aj == "1"); + } + set + { + if (value) + SetAttr("autojoin", "true"); + else + RemoveAttribute("autojoin"); + } + } + + /// + /// The room@service JID of the room. + /// + public JID JID + { + get { return (JID)GetAttr("jid"); } + set { SetAttr("jid", value); } + } + + /// + /// A friendly name for the bookmark. + /// + public string ConferenceName + { + get { return GetAttr("name"); } + set { SetAttr("name", value); } + } + + /// + /// The user's preferred roomnick for the chatroom. + /// + public string Nick + { + get { return GetElem("nick"); } + set { SetElem("nick", value); } + } + + /// + /// Plain-text string for the password needed to enter a password-protected room. + /// For security reasons, use of this element is NOT RECOMMENDED. + /// + /// TODO: should this be marked Obsolete? + /// + public string Password + { + get { return GetElem("password"); } + set { SetElem("password", value); } + } + } + + /// + /// A note stored in bookmarks. Un-specified, but hinted at in version 1.1 of XEP-48. + /// + [SVN(@"$Id$")] + public class BookmarkNote : Element + { + /// + /// Create for outbound. + /// + /// + public BookmarkNote(XmlDocument doc) : + base("note", URI.BOOKMARKS, doc) + { + Modified = Created = DateTime.UtcNow; + } + + /// + /// Create for inbound. + /// + /// + /// + /// + public BookmarkNote(string prefix, XmlQualifiedName qname, XmlDocument doc) : + base(prefix, qname, doc) + { + } + + /// + /// The JID to which the note pertains. + /// + public JID JID + { + get { return (JID)GetAttr("jid"); } + set { SetAttr("jid", value); } + } + + /// + /// The UTC date/time the note was created. + /// + public DateTime Created + { + get { return GetDateTimeAttr("cdate"); } + set { SetDateTimeAttr("cdate", value); } + } + + /// + /// The UTC date/time the note last modified. + /// + public DateTime Modified + { + get { return GetDateTimeAttr("mdate"); } + set { SetDateTimeAttr("mdate", value); } + } + + /// + /// The text of the note. + /// + public string Text + { + get { return this.InnerText; } + set { this.InnerText = value; } + } + } +} diff -Nru smuxi-0.8/lib/jabber-net/jabber/protocol/iq/Browse.cs smuxi-0.8.9.1/lib/jabber-net/jabber/protocol/iq/Browse.cs --- smuxi-0.8/lib/jabber-net/jabber/protocol/iq/Browse.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/jabber-net/jabber/protocol/iq/Browse.cs 2012-01-03 07:52:11.000000000 +0000 @@ -0,0 +1,158 @@ +/* -------------------------------------------------------------------------- + * Copyrights + * + * Portions created by or assigned to Cursive Systems, Inc. are + * Copyright (c) 2002-2008 Cursive Systems, Inc. All Rights Reserved. Contact + * information for Cursive Systems, Inc. is available at + * http://www.cursive.net/. + * + * License + * + * Jabber-Net is licensed under the LGPL. + * See LICENSE.txt for details. + * --------------------------------------------------------------------------*/ +using System; + +using System.Diagnostics; +using System.Security.Cryptography; +using System.Xml; + +using bedrock.util; + +namespace jabber.protocol.iq +{ + /// + /// An browse IQ. + /// + [SVN(@"$Id$")] + public class BrowseIQ : jabber.protocol.client.TypedIQ + { + /// + /// Create a Browse IQ. + /// + /// + public BrowseIQ(XmlDocument doc) : base(doc) + { + } + } + + /// + /// Browse IQ query. + /// + [SVN(@"$Id$")] + public class Browse : Element + { + /// + /// + /// + /// + public Browse(XmlDocument doc) : + base("query", URI.BROWSE, doc) + { + } + + /// + /// + /// + /// + /// + /// + public Browse(string prefix, XmlQualifiedName qname, XmlDocument doc) : + base(prefix, qname, doc) + { + } + + /// + /// The full JabberID of the entity described. + /// + public JID JID + { + get { return GetAttribute("jid"); } + set { SetAttribute("jid", value.ToString()); } + } + + /// + /// One of the categories from the category list, or a non-standard category prefixed with the string "x-". + /// + public string Category + { + get { return GetAttribute("category"); } + set { SetAttribute("category", value); } + } + + /// + /// One of the official types from the specified category, or a non-standard type prefixed with the string "x-". + /// + public string Type + { + get { return GetAttribute("type"); } + set { SetAttribute("type", value); } + } + + /// + /// A friendly name that may be used in a user interface. + /// + public string BrowseName + { + get { return GetAttribute("name"); } + set { SetAttribute("name", value); } + } + + /// + /// A string containing the version of the node, equivalent to the response provided to a + /// query in the 'jabber:iq:version' namespace. This is useful for servers, especially for lists of services + /// (see the 'service/serverlist' category/type above). + /// + public string Version + { + get { return GetAttribute("version"); } + set { SetAttribute("version", value); } + } + + /// + /// Sub-items of this item + /// + /// + public Browse[] GetItems() + { + return GetElements().ToArray(); + } + + /// + /// Add an item to the sub-item list. + /// + /// + public Browse AddItem() + { + return CreateChildElement(); + } + + /// + /// The namespaces advertised by this item. + /// + /// + public string[] GetNamespaces() + { + XmlNodeList nl = GetElementsByTagName("ns", URI.BROWSE); + string[] items = new string[nl.Count]; + int i=0; + foreach (XmlNode n in nl) + { + items[i] = n.InnerText; + i++; + } + return items; + } + + /// + /// Add a namespace to the namespaces supported by this item. + /// + /// + public void AddNamespace(string ns) + { + XmlElement e = this.OwnerDocument.CreateElement(null, "ns", URI.BROWSE); + e.InnerText = ns; + this.AppendChild(e); + } + } +} diff -Nru smuxi-0.8/lib/jabber-net/jabber/protocol/iq/Disco.cs smuxi-0.8.9.1/lib/jabber-net/jabber/protocol/iq/Disco.cs --- smuxi-0.8/lib/jabber-net/jabber/protocol/iq/Disco.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/jabber-net/jabber/protocol/iq/Disco.cs 2012-01-03 07:52:11.000000000 +0000 @@ -0,0 +1,552 @@ +/* -------------------------------------------------------------------------- + * Copyrights + * + * Portions created by or assigned to Cursive Systems, Inc. are + * Copyright (c) 2002-2008 Cursive Systems, Inc. All Rights Reserved. Contact + * information for Cursive Systems, Inc. is available at + * http://www.cursive.net/. + * + * License + * + * Jabber-Net is licensed under the LGPL. + * See LICENSE.txt for details. + * --------------------------------------------------------------------------*/ +using System; +using System.Xml; + +using bedrock.util; +using jabber.protocol.x; +using bedrock.collections; + +namespace jabber.protocol.iq +{ + /* + * + * + * + * + * + */ + /// + /// IQ packet with a disco#items query element inside. + /// + [SVN(@"$Id$")] + public class DiscoItemsIQ : jabber.protocol.client.TypedIQ + { + /// + /// Create a disco#items IQ + /// + /// + public DiscoItemsIQ(XmlDocument doc) : base(doc) + { + } + + /// + /// The node on the query. + /// + public string Node + { + get { return this.Instruction.Node; } + set { this.Instruction.Node = value; } + } + } + + /// + /// IQ packet with a disco#info query element inside. + /// + [SVN(@"$Id$")] + public class DiscoInfoIQ : jabber.protocol.client.TypedIQ + { + /// + /// Create a disco#items IQ + /// + /// + public DiscoInfoIQ(XmlDocument doc) : base(doc) + { + } + + /// + /// The node on the query. + /// + public string Node + { + get {return this.Instruction.Node; } + set { this.Instruction.Node = value; } + } + } + + /* + * + * + * + * + * + * + * + * + * + * + * + * + * + */ + + + /// + /// A disco#items query element. + /// See XEP-0030 for more information. + /// + [SVN(@"$Id$")] + public class DiscoItems : Element + { + /// + /// + /// + /// + public DiscoItems(XmlDocument doc) : base("query", URI.DISCO_ITEMS, doc) + { + } + + /// + /// + /// + /// + /// + /// + public DiscoItems(string prefix, XmlQualifiedName qname, XmlDocument doc) : + base(prefix, qname, doc) + { + } + + /// + /// The sub-address of the discovered entity. + /// + public string Node + { + get { return GetAttr("node"); } + set { SetAttr("node", value); } + } + + /// + /// Add a disco item + /// + /// + public DiscoItem AddItem() + { + return CreateChildElement(); + } + + /// + /// List of disco items + /// + /// + public DiscoItem[] GetItems() + { + return GetElements().ToArray(); + } + } + + /// + /// Actions for iq/set in the disco#items namespace. + /// + [SVN(@"$Id$")] + public enum DiscoAction + { + /// + /// None specified + /// + NONE = -1, + /// + /// Remove this item + /// + remove, + /// + /// Update this item + /// + update + } + + /// + /// An item inside a disco#items result. + /// + [SVN(@"$Id$")] + public class DiscoItem : Element + { + /// + /// + /// + /// + public DiscoItem(XmlDocument doc) : base("item", URI.DISCO_ITEMS, doc) + { + } + + /// + /// + /// + /// + /// + /// + public DiscoItem(string prefix, XmlQualifiedName qname, XmlDocument doc) : + base(prefix, qname, doc) + { + } + + /// + /// The Jabber ID associated with the item. + /// + public JID Jid + { + get { return GetAttr("jid"); } + set { SetAttr("jid", value.ToString()); } + } + + /// + /// The user-visible name of this node + /// + public string Named + { + get { return GetAttr("name"); } + set { SetAttr("name", value); } + } + + /// + /// The sub-node associated with this item. + /// + public string Node + { + get { return GetAttr("node"); } + set { SetAttr("node", value); } + } + + /// + /// Actions for iq/set in the disco#items namespace. + /// + public DiscoAction Action + { + get { return GetEnumAttr("action"); } + set { SetEnumAttr("action", value); } + } + } + +/* + + + + + + + + + + + + + + + http://jabber.org/network/serverinfo + + + 5222 + + + + +*/ + /// + /// The information associated with a disco node. + /// + [SVN(@"$Id$")] + public class DiscoInfo : Element + { + private StringSet m_features = null; + + /// + /// + /// + /// + public DiscoInfo(XmlDocument doc) : base("query", URI.DISCO_INFO, doc) + { + } + + /// + /// + /// + /// + /// + /// + public DiscoInfo(string prefix, XmlQualifiedName qname, XmlDocument doc) : + base(prefix, qname, doc) + { + } + + /// + /// The sub-node associated with this item. + /// + public string Node + { + get { return GetAttr("node"); } + set { SetAttr("node", value); } + } + + /// + /// Add an identity + /// + /// The category of the identity. Required. + /// The sub-type + /// A human-readable string + /// The xml:lang, or null to take the requestor's default + /// + public DiscoIdentity AddIdentity(string category, string discoType, string name, string language) + { + DiscoIdentity i = CreateChildElement(); + i.Category = category; + i.Type = discoType; + i.Named = name; + i.Lang = language; + return i; + } + + /// + /// List of identities + /// + /// + public DiscoIdentity[] GetIdentities() + { + return GetElements().ToArray(); + } + + /// + /// Add a feature + /// + /// + public DiscoFeature AddFeature(string featureURI) + { + DiscoFeature i = CreateChildElement(); + i.Var = featureURI; + if (m_features != null) + m_features.Add(featureURI); + return i; + } + + /// + /// List of features + /// + /// + public DiscoFeature[] GetFeatures() + { + return GetElements().ToArray(); + } + + /// + /// Is the given feature URI supported by this entity? + /// + /// The URI to check + /// + public bool HasFeature(string featureURI) + { + if (m_features != null) + return m_features.Contains(featureURI); + + foreach (DiscoFeature feat in GetElements()) + { + if (feat.Var == featureURI) + return true; + } + return false; + } + + /// + /// Clear all of the features from the + /// + public void ClearFeatures() + { + this.RemoveElems(); + m_features = null; + } + + /// + /// Get or set a compressed set of features. + /// Setting this has the side-effect of removing all existing features, and + /// replacing them with the specified ones. + /// + public StringSet FeatureSet + { + get + { + if (m_features == null) + { + m_features = new StringSet(); + foreach (DiscoFeature f in GetElements()) + m_features.Add(f.Var); + } + return m_features; + } + set + { + ClearFeatures(); + m_features = new StringSet(); + foreach (string s in value) + AddFeature(s); + } + } + + /// + /// Create a XEP-0128 x:data extension, or return the first existing one. + /// + /// + public Data CreateExtension() + { + Data d = GetOrCreateElement(); + d.Type = XDataType.result; + return d; + } + + /// + /// Get or set the first XEP-0128 x:data extension. + /// + public Data Extension + { + get { return GetChildElement(); } + set { ReplaceChild(value); } + } + + /// + /// In the unlikely event that there are multiple extensions, we need to be able + /// to retrieve all of them. + /// + /// + public Data[] GetExtensions() + { + return GetElements().ToArray(); + } + + /// + /// Get the extension with the given XEP-0068 form type. + /// + /// The value of the FORM_TYPE field to search for. + /// null if none found + public Data GetExtension(string formType) + { + foreach (Data d in GetElements()) + { + if (d.FormType == formType) + return d; + } + return null; + } + } + + /// + /// The identitiy associated with a disco node. + /// + [SVN(@"$Id$")] + public class DiscoIdentity : Element + { + /// + /// + /// + /// + public DiscoIdentity(XmlDocument doc) : base("identity", URI.DISCO_INFO, doc) + { + } + + /// + /// + /// + /// + /// + /// + public DiscoIdentity(string prefix, XmlQualifiedName qname, XmlDocument doc) : + base(prefix, qname, doc) + { + } + + /// + /// The user-visible name of this node + /// + public string Named + { + get { return GetAttr("name"); } + set { SetAttr("name", value); } + } + + /// + /// The category of the node + /// + public string Category + { + get { return GetAttr("category"); } + set { SetAttr("category", value); } + } + + /// + /// The type of the node + /// + public string Type + { + get { return GetAttr("type"); } + set { SetAttr("type", value); } + } + + } + + /// + /// A feature associated with a disco node. + /// + [SVN(@"$Id$")] + public class DiscoFeature : Element + { + /// + /// + /// + /// + public DiscoFeature(XmlDocument doc) : base("feature", URI.DISCO_INFO, doc) + { + } + + /// + /// + /// + /// + /// + /// + public DiscoFeature(string prefix, XmlQualifiedName qname, XmlDocument doc) : + base(prefix, qname, doc) + { + } + + /// + /// The namespace name or feature name. + /// + public string Var + { + get { return GetAttr("var"); } + set { SetAttr("var", value); } + } + } +} diff -Nru smuxi-0.8/lib/jabber-net/jabber/protocol/iq/Factory.cs smuxi-0.8.9.1/lib/jabber-net/jabber/protocol/iq/Factory.cs --- smuxi-0.8/lib/jabber-net/jabber/protocol/iq/Factory.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/jabber-net/jabber/protocol/iq/Factory.cs 2012-01-03 07:52:11.000000000 +0000 @@ -0,0 +1,151 @@ +/* -------------------------------------------------------------------------- + * Copyrights + * + * Portions created by or assigned to Cursive Systems, Inc. are + * Copyright (c) 2002-2008 Cursive Systems, Inc. All Rights Reserved. Contact + * information for Cursive Systems, Inc. is available at + * http://www.cursive.net/. + * + * License + * + * Jabber-Net is licensed under the LGPL. + * See LICENSE.txt for details. + * --------------------------------------------------------------------------*/ +using System; + + +using bedrock.util; +using jabber.protocol; + +namespace jabber.protocol.iq +{ + /// + /// ElementFactory for all currently supported IQ namespaces. + /// + [SVN(@"$Id$")] + public class Factory : IPacketTypes + { + private static QnameType[] s_qnt = new QnameType[] + { + new QnameType("query", URI.AUTH, typeof(jabber.protocol.iq.Auth)), + new QnameType("query", URI.REGISTER, typeof(jabber.protocol.iq.Register)), + new QnameType("query", URI.ROSTER, typeof(jabber.protocol.iq.Roster)), + new QnameType("item", URI.ROSTER, typeof(jabber.protocol.iq.Item)), + new QnameType("group", URI.ROSTER, typeof(jabber.protocol.iq.Group)), + new QnameType("query", URI.AGENTS, typeof(jabber.protocol.iq.AgentsQuery)), + new QnameType("agent", URI.AGENTS, typeof(jabber.protocol.iq.Agent)), + new QnameType("query", URI.OOB, typeof(jabber.protocol.iq.OOB)), + new QnameType("query", URI.TIME, typeof(jabber.protocol.iq.Time)), + new QnameType("query", URI.VERSION, typeof(jabber.protocol.iq.Version)), + new QnameType("query", URI.LAST, typeof(jabber.protocol.iq.Last)), + new QnameType("item", URI.BROWSE, typeof(jabber.protocol.iq.Browse)), + new QnameType("geoloc",URI.GEOLOC, typeof(jabber.protocol.iq.GeoLoc)), + + + new QnameType("query", URI.PRIVATE, typeof(jabber.protocol.iq.Private)), + new QnameType("storage", URI.BOOKMARKS, typeof(jabber.protocol.iq.Bookmarks)), + new QnameType("url", URI.BOOKMARKS, typeof(jabber.protocol.iq.BookmarkURL)), + new QnameType("conference", URI.BOOKMARKS, typeof(jabber.protocol.iq.BookmarkConference)), + new QnameType("note", URI.BOOKMARKS, typeof(jabber.protocol.iq.BookmarkNote)), + + // VCard + new QnameType("vCard", URI.VCARD, typeof(jabber.protocol.iq.VCard)), + new QnameType("N", URI.VCARD, typeof(jabber.protocol.iq.VCard.VName)), + new QnameType("ORG", URI.VCARD, typeof(jabber.protocol.iq.VCard.VOrganization)), + new QnameType("TEL", URI.VCARD, typeof(jabber.protocol.iq.VCard.VTelephone)), + new QnameType("EMAIL", URI.VCARD, typeof(jabber.protocol.iq.VCard.VEmail)), + new QnameType("GEO", URI.VCARD, typeof(jabber.protocol.iq.VCard.VGeo)), + new QnameType("PHOTO", URI.VCARD, typeof(jabber.protocol.iq.VCard.VPhoto)), + new QnameType("ADR", URI.VCARD, typeof(jabber.protocol.iq.VCard.VAddress)), + + // Disco + new QnameType("query", URI.DISCO_ITEMS, typeof(jabber.protocol.iq.DiscoItems)), + new QnameType("item", URI.DISCO_ITEMS, typeof(jabber.protocol.iq.DiscoItem)), + new QnameType("query", URI.DISCO_INFO, typeof(jabber.protocol.iq.DiscoInfo)), + new QnameType("identity", URI.DISCO_INFO, typeof(jabber.protocol.iq.DiscoIdentity)), + new QnameType("feature", URI.DISCO_INFO, typeof(jabber.protocol.iq.DiscoFeature)), + + // PubSub + new QnameType("pubsub", URI.PUBSUB, typeof(jabber.protocol.iq.PubSub)), + new QnameType("affiliations", URI.PUBSUB, typeof(jabber.protocol.iq.Affiliations)), + new QnameType("create", URI.PUBSUB, typeof(jabber.protocol.iq.Create)), + new QnameType("items", URI.PUBSUB, typeof(jabber.protocol.iq.Items)), + new QnameType("publish", URI.PUBSUB, typeof(jabber.protocol.iq.Publish)), + new QnameType("retract", URI.PUBSUB, typeof(jabber.protocol.iq.Retract)), + new QnameType("subscribe", URI.PUBSUB, typeof(jabber.protocol.iq.Subscribe)), + new QnameType("subscriptions", URI.PUBSUB, typeof(jabber.protocol.iq.Subscriptions)), + new QnameType("unsubscribe", URI.PUBSUB, typeof(jabber.protocol.iq.Unsubscribe)), + + new QnameType("configure", URI.PUBSUB, typeof(jabber.protocol.iq.Configure)), + new QnameType("options", URI.PUBSUB, typeof(jabber.protocol.iq.PubSubOptions)), + new QnameType("affiliation", URI.PUBSUB, typeof(jabber.protocol.iq.Affiliation)), + new QnameType("item", URI.PUBSUB, typeof(jabber.protocol.iq.PubSubItem)), + new QnameType("subscription", URI.PUBSUB, typeof(jabber.protocol.iq.PubSubSubscription)), + + // Pubsub event notifications + new QnameType("event", URI.PUBSUB_EVENT, typeof(jabber.protocol.iq.PubSubEvent)), + new QnameType("associate", URI.PUBSUB_EVENT, typeof(jabber.protocol.iq.EventAssociate)), + new QnameType("collection", URI.PUBSUB_EVENT, typeof(jabber.protocol.iq.EventCollection)), + new QnameType("configuration", URI.PUBSUB_EVENT, typeof(jabber.protocol.iq.EventConfiguration)), + new QnameType("disassociate", URI.PUBSUB_EVENT, typeof(jabber.protocol.iq.EventDisassociate)), + new QnameType("items", URI.PUBSUB_EVENT, typeof(jabber.protocol.iq.EventItems)), + new QnameType("item", URI.PUBSUB_EVENT, typeof(jabber.protocol.iq.PubSubItem)), + new QnameType("purge", URI.PUBSUB_EVENT, typeof(jabber.protocol.iq.EventPurge)), + new QnameType("retract", URI.PUBSUB_EVENT, typeof(jabber.protocol.iq.EventRetract)), + new QnameType("subscription", URI.PUBSUB_EVENT, typeof(jabber.protocol.iq.EventSubscription)), + + // Pubsub owner use cases + new QnameType("pubsub", URI.PUBSUB_OWNER, typeof(jabber.protocol.iq.PubSubOwner)), + new QnameType("affiliations", URI.PUBSUB_OWNER, typeof(jabber.protocol.iq.OwnerAffliliations)), + new QnameType("affiliation", URI.PUBSUB_OWNER, typeof(jabber.protocol.iq.OwnerAffiliation)), + new QnameType("configure", URI.PUBSUB_OWNER, typeof(jabber.protocol.iq.OwnerConfigure)), + new QnameType("default", URI.PUBSUB_OWNER, typeof(jabber.protocol.iq.OwnerDefault)), + new QnameType("delete", URI.PUBSUB_OWNER, typeof(jabber.protocol.iq.OwnerDelete)), + new QnameType("purge", URI.PUBSUB_OWNER, typeof(jabber.protocol.iq.OwnerPurge)), + new QnameType("subscriptions", URI.PUBSUB_OWNER, typeof(jabber.protocol.iq.OwnerSubscriptions)), + new QnameType("subscription", URI.PUBSUB_OWNER, typeof(jabber.protocol.iq.PubSubSubscription)), + + // Pubsub errors + new QnameType("closed-node", URI.PUBSUB_ERRORS, typeof(jabber.protocol.iq.ClosedNode)), + new QnameType("configuration-required", URI.PUBSUB_ERRORS, typeof(jabber.protocol.iq.ConfigurationRequired)), + new QnameType("invalid-jid", URI.PUBSUB_ERRORS, typeof(jabber.protocol.iq.InvalidJID)), + new QnameType("invalid-options", URI.PUBSUB_ERRORS, typeof(jabber.protocol.iq.InvalidOptions)), + new QnameType("invalid-payload", URI.PUBSUB_ERRORS, typeof(jabber.protocol.iq.InvalidPayload)), + new QnameType("invalid-subid", URI.PUBSUB_ERRORS, typeof(jabber.protocol.iq.InvalidSubid)), + new QnameType("item-forbidden", URI.PUBSUB_ERRORS, typeof(jabber.protocol.iq.ItemForbidden)), + new QnameType("item-required", URI.PUBSUB_ERRORS, typeof(jabber.protocol.iq.ItemRequired)), + new QnameType("jid-required", URI.PUBSUB_ERRORS, typeof(jabber.protocol.iq.JIDRequired)), + new QnameType("max-items-exceeded", URI.PUBSUB_ERRORS, typeof(jabber.protocol.iq.MaxItemsExceeded)), + new QnameType("max-nodes-exceeded", URI.PUBSUB_ERRORS, typeof(jabber.protocol.iq.MaxNodesExceeded)), + new QnameType("nodeid-required", URI.PUBSUB_ERRORS, typeof(jabber.protocol.iq.NodeIDRequired)), + new QnameType("not-in-roster-group", URI.PUBSUB_ERRORS, typeof(jabber.protocol.iq.NotInRosterGroup)), + new QnameType("not-subscribed", URI.PUBSUB_ERRORS, typeof(jabber.protocol.iq.NotSubscribed)), + new QnameType("payload-too-big", URI.PUBSUB_ERRORS, typeof(jabber.protocol.iq.PayloadTooBig)), + new QnameType("payload-required", URI.PUBSUB_ERRORS, typeof(jabber.protocol.iq.PayloadRequired)), + new QnameType("pending-subscription", URI.PUBSUB_ERRORS, typeof(jabber.protocol.iq.PendingSubscription)), + new QnameType("presence-subscription-required", URI.PUBSUB_ERRORS, typeof(jabber.protocol.iq.PresenceSubscriptionRequired)), + new QnameType("subid-required", URI.PUBSUB_ERRORS, typeof(jabber.protocol.iq.SubidRequired)), + new QnameType("unsupported", URI.PUBSUB_ERRORS, typeof(jabber.protocol.iq.Unsupported)), + new QnameType("unsupported-access-model", URI.PUBSUB_ERRORS, typeof(jabber.protocol.iq.UnsupportedAccessModel)), + + // Multi-user chat + new QnameType("x", URI.MUC, typeof(jabber.protocol.iq.RoomX)), + new QnameType("history", URI.MUC, typeof(jabber.protocol.iq.History)), + + new QnameType("x", URI.MUC_USER, typeof(jabber.protocol.iq.UserX)), + new QnameType("decline", URI.MUC_USER, typeof(jabber.protocol.iq.Decline)), + new QnameType("invite", URI.MUC_USER, typeof(jabber.protocol.iq.Invite)), + new QnameType("destroy", URI.MUC_USER, typeof(jabber.protocol.iq.Destroy)), + new QnameType("item", URI.MUC_USER, typeof(jabber.protocol.iq.RoomItem)), + new QnameType("actor", URI.MUC_USER, typeof(jabber.protocol.iq.RoomActor)), + + new QnameType("query", URI.MUC_ADMIN, typeof(jabber.protocol.iq.AdminQuery)), + new QnameType("item", URI.MUC_ADMIN, typeof(jabber.protocol.iq.AdminItem)), + + new QnameType("query", URI.MUC_OWNER, typeof(jabber.protocol.iq.OwnerQuery)), + new QnameType("destroy", URI.MUC_OWNER, typeof(jabber.protocol.iq.OwnerDestroy)), + }; + + QnameType[] IPacketTypes.Types { get { return s_qnt; } } + } +} diff -Nru smuxi-0.8/lib/jabber-net/jabber/protocol/iq/GeoLoc.cs smuxi-0.8.9.1/lib/jabber-net/jabber/protocol/iq/GeoLoc.cs --- smuxi-0.8/lib/jabber-net/jabber/protocol/iq/GeoLoc.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/jabber-net/jabber/protocol/iq/GeoLoc.cs 2012-01-03 07:52:11.000000000 +0000 @@ -0,0 +1,146 @@ +/* -------------------------------------------------------------------------- + * Copyrights + * + * Portions created by or assigned to Cursive Systems, Inc. are + * Copyright (c) 2002-2008 Cursive Systems, Inc. All Rights Reserved. Contact + * information for Cursive Systems, Inc. is available at + * http://www.cursive.net/. + * + * License + * + * Jabber-Net is licensed under the LGPL. + * See LICENSE.txt for details. + * --------------------------------------------------------------------------*/ +using System; + +using System.Diagnostics; +using System.Security.Cryptography; +using System.Xml; + +using bedrock.util; + +namespace jabber.protocol.iq +{ + /// + /// A GeoLoc IQ. + /// + [SVN(@"$Id$")] + public class GeoLocIQ : jabber.protocol.client.TypedIQ + { + /// + /// Create a GeoLoc IQ. + /// + /// + public GeoLocIQ(XmlDocument doc) : base(doc) + { + } + } + + /// + /// Geographic location. See http://www.xmpp.org/extensions/xep-0080.html. + /// + [SVN(@"$Id$")] + public class GeoLoc : Element + { + /// + /// + /// + /// + public GeoLoc(XmlDocument doc) : + base("geoloc", URI.GEOLOC, doc) + { + } + + /// + /// + /// + /// + /// + /// + public GeoLoc(string prefix, XmlQualifiedName qname, XmlDocument doc) : + base(prefix, qname, doc) + { + } + + /// + /// Altitude above/below sea level, in meters. + /// + public double Altitude + + { + get { return double.Parse(GetElem("alt")); } + set { SetElem("alt", value.ToString()); } + } + + /// + /// Assuming decimal degrees to true north. + /// Note: this is being further specified in the XEP. + /// + public double Bearing + { + get { return double.Parse(GetElem("bearing")); } + set { SetElem("bearing", value.ToString()); } + } + + /// + /// GPS datum, defaults to WGS84. + /// + public string Datum + { + get + { + string datum = GetElem("datum"); + if ((datum == null) || (datum == "")) + datum = "WGS84"; + return datum; + } + set { SetElem("datum", value); } + } + + /// + /// A natural-language description of the location. + /// + public string Description + { + get { return GetElem("description"); } + set { SetElem("description", value); } + } + + /// + /// Horizontal GPS error in arc minutes. + /// + public double Error + { + get { return double.Parse(GetElem("error")); } + set { SetElem("error", value.ToString()); } + } + + /// + /// Latitude in decimal degrees North. + /// + public double Latitude + { + get { return double.Parse(GetElem("lat")); } + set { SetElem("lat", value.ToString()); } + } + + /// + /// Longitude in decimal degrees East. + /// + public double Longitude + { + get { return double.Parse(GetElem("lon")); } + set { SetElem("lon", value.ToString()); } + } + + /// + /// UTC timestamp specifying the moment when the reading was taken. + /// + public DateTime Timestamp + { + get { return DateTimeProfile(GetElem("timestamp")); } + set { SetElem("timestamp", DateTimeProfile(value)); } + } + + } +} diff -Nru smuxi-0.8/lib/jabber-net/jabber/protocol/iq/Last.cs smuxi-0.8.9.1/lib/jabber-net/jabber/protocol/iq/Last.cs --- smuxi-0.8/lib/jabber-net/jabber/protocol/iq/Last.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/jabber-net/jabber/protocol/iq/Last.cs 2012-01-03 07:52:11.000000000 +0000 @@ -0,0 +1,87 @@ +/* -------------------------------------------------------------------------- + * Copyrights + * + * Portions created by or assigned to Cursive Systems, Inc. are + * Copyright (c) 2002-2008 Cursive Systems, Inc. All Rights Reserved. Contact + * information for Cursive Systems, Inc. is available at + * http://www.cursive.net/. + * + * License + * + * Jabber-Net is licensed under the LGPL. + * See LICENSE.txt for details. + * --------------------------------------------------------------------------*/ +using System; + +using System.Xml; + +using bedrock.util; + +namespace jabber.protocol.iq +{ + /* + * + * + * Heading home + * + * + */ + /// + /// IQ packet with an Last query element inside. + /// + [SVN(@"$Id$")] + public class LastIQ : jabber.protocol.client.TypedIQ + { + /// + /// Create a Last IQ + /// + /// + public LastIQ(XmlDocument doc) : base(doc) + { + } + } + + /// + /// A Last query element, which requests the last activity from an entity. + /// + [SVN(@"$Id$")] + public class Last : Element + { + /// + /// + /// + /// + public Last(XmlDocument doc) : base("query", URI.LAST, doc) + { + } + + /// + /// + /// + /// + /// + /// + public Last(string prefix, XmlQualifiedName qname, XmlDocument doc) : + base(prefix, qname, doc) + { + } + + /// + /// The message inside the Last element. + /// + public string Message + { + get { return this.InnerText; } + set { this.InnerText = value; } + } + + /// + /// How many seconds since the last activity. + /// + public int Seconds + { + get { return GetIntAttr("seconds");} + set { SetAttribute("seconds", value.ToString()); } + } + } +} diff -Nru smuxi-0.8/lib/jabber-net/jabber/protocol/iq/MUC.cs smuxi-0.8.9.1/lib/jabber-net/jabber/protocol/iq/MUC.cs --- smuxi-0.8/lib/jabber-net/jabber/protocol/iq/MUC.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/jabber-net/jabber/protocol/iq/MUC.cs 2012-01-03 07:52:11.000000000 +0000 @@ -0,0 +1,1145 @@ +/* -------------------------------------------------------------------------- + * Copyrights + * + * Portions created by or assigned to Cursive Systems, Inc. are + * Copyright (c) 2002-2008 Cursive Systems, Inc. All Rights Reserved. Contact + * information for Cursive Systems, Inc. is available at + * http://www.cursive.net/. + * + * License + * + * Jabber-Net is licensed under the LGPL. + * See LICENSE.txt for details. + * --------------------------------------------------------------------------*/ +using System; +using System.Xml; + +using bedrock.util; +using jabber; +using jabber.protocol; + +namespace jabber.protocol.iq +{ +#region enums + /// + /// Affiliation with a MUC room, per user. + /// + public enum RoomAffiliation + { + /// + /// No attribute specified + /// + UNSPECIFIED = -1, + /// + /// Administrator + /// + admin = 0, + /// + /// Member + /// + member, + /// + /// No affiliation + /// + none, + /// + /// Banned + /// + outcast, + /// + /// Room owner + /// + owner, + } + + /// + /// Current role in the room. Initial role is set by affiliation, if it exits. + /// + public enum RoomRole + { + /// + /// No attribute specified + /// + UNSPECIFIED = -1, + /// + /// Room moderator. Can grant/revoke voice + /// + moderator = 0, + /// + /// No role + /// + none, + /// + /// Can speak + /// + participant, + /// + /// Can listen + /// + visitor, + } + + /// + /// Possible room status values. + /// + public enum RoomStatus + { + /// + /// An invalid or unknown RoomStatus + /// + UNKNOWN = -1, + + /// + /// Inform user that any occupant is allowed to see the user's full JID. + /// + NON_ANONYMOUS_JOIN = 100, + + /// + /// Inform user that his or her affiliation changed while not in the room + /// + AFILLIATION_CHANGE = 101, + + /// + /// Inform occupants that room now shows unavailable members + /// + SHOW_UNAVAILABLE = 102, + + /// + /// Inform occupants that room now does not show unavailable members + /// + NO_SHOW_UNAVAILABLE = 103, + + /// + /// Inform occupants that a non-privacy-related room configuration change has occurred + /// + PRIVACY_CHANGE = 104, + + /// + /// Inform user that presence refers to one of its own room occupants + /// + SELF = 110, + + /// + /// Inform occupants that room logging is now enabled + /// + LOGGING_ENABLED = 170, + + /// + /// Inform occupants that room logging is now disabled + /// + LOGGING_DISABLED = 171, + + /// + /// Inform occupants that the room is now non-anonymous + /// + NON_ANONYMOUS = 172, + + /// + /// Inform occupants that the room is now semi-anonymous + /// + SEMI_ANONYMOUS = 173, + + /// + /// Inform occupants that the room is now fully-anonymous + /// + ANONYMOUS = 174, + + /// + /// Inform user that a new room has been created + /// + CREATED = 201, + + /// + /// Inform user that service has assigned or modified occupant's roomnick + /// + NICK_CHANGED = 210, + + /// + /// Inform user that he or she has been banned from the room + /// + BANNED = 301, + + /// + /// Inform all occupants of new room nickname + /// + NEW_NICK = 303, + + /// + /// Inform user that he or she has been kicked from the room + /// + KICKED = 307, + + /// + /// Inform user that he or she is being removed from the room + /// because of an affiliation change + /// + REMOVED_AFFILIATION = 321, + + /// + /// Inform user that he or she is being removed from the room + /// because the room has been changed to members-only and the user + /// is not a member + /// + REMOVED_NONMEMBER = 322, + + /// + /// Inform user that he or she is being removed from the room + /// because of a system shutdown + /// + REMOVED_SHUTDOWN = 332, + } +#endregion + +#region base protocol + /// + /// Presence to join a multi-user chat. + /// + [SVN(@"$Id$")] + public class RoomPresence : jabber.protocol.client.Presence + { + /// + /// Create, taking default room history, with no password. + /// + /// + /// A jid of the form room@conferenceServer/nick, where nick is the desired + /// room nickname for this user + public RoomPresence(XmlDocument doc, JID roomAndNick) + : base(doc) + { + this.To = roomAndNick; + this.CreateChildElement(); + } + + /// + /// + /// + /// + /// + /// Null for non-password rooms + /// TODO: getHistory? + public RoomPresence(XmlDocument doc, JID roomAndNick, string password) + : base(doc) + { + this.To = roomAndNick; + this.CreateChildElement().Password = password; + } + + /// + /// The X tag denoting MUC-ness. Use this to access passord and history + /// after creation. + /// + public RoomX X + { + get { return GetChildElement(); } + set { ReplaceChild(value); } + } + } + + + /// + /// X tag for presence when joining a room. + /// + [SVN(@"$Id$")] + public class RoomX : Element + { + /// + /// + /// + /// + public RoomX(XmlDocument doc) + : base("x", URI.MUC, doc) + { + } + + /// + /// + /// + /// + /// + /// + public RoomX(string prefix, XmlQualifiedName qname, XmlDocument doc) + : base(prefix, qname, doc) + { + } + + /// + /// Password to join room. Null for no password. + /// + public string Password + { + get { return GetElem("password"); } + set { SetElem("password", value); } + } + + /// + /// Add a history element, or return the existing one. + /// + /// + public History AddHistory() + { + return GetOrCreateElement(); + } + + /// + /// History options + /// + public History History + { + get { return GetChildElement(); } + set { this.ReplaceChild(value); } + } + } + + /// + /// How much history to retrieve upon joining a room. + /// + [SVN(@"$Id$")] + public class History : Element + { + /// + /// + /// + /// + public History(XmlDocument doc) + : base("history", URI.MUC, doc) + { + } + + /// + /// + /// + /// + /// + /// + public History(string prefix, XmlQualifiedName qname, XmlDocument doc) + : base(prefix, qname, doc) + { + } + + /// + /// Maximum number of characters. -1 if not specified. + /// + public int MaxChars + { + get { return GetIntAttr("maxchars"); } + set { SetIntAttr("maxchars", value); } + } + /// + /// Maximum number of stanzas. -1 if not specified. + /// + public int MaxStanzas + { + get { return GetIntAttr("maxstanzas"); } + set { SetIntAttr("maxstanzas", value); } + } + /// + /// Number of seconds of history to retreive. + /// + public int Seconds + { + get { return GetIntAttr("seconds"); } + set { SetIntAttr("seconds", value); } + } + /// + /// Date of earliest history desired. + /// DateTime.MinValue for not specified. + /// + public DateTime since + { + get { return GetDateTimeAttr("since"); } + set { SetDateTimeAttr("since", value); } + } + } +#endregion + + +#region Users + /// + /// Information about users + /// + [SVN(@"$Id$")] + public class UserX : Element + { + /// + /// + /// + /// + public UserX(XmlDocument doc) + : base("x", URI.MUC_USER, doc) + { + } + + /// + /// + /// + /// + /// + /// + public UserX(string prefix, XmlQualifiedName qname, XmlDocument doc) + : base(prefix, qname, doc) + { + } + + /// + /// Add a decline element, or return the existing one. + /// + /// + public Decline AddDecline() + { + return GetOrCreateElement(); + } + + /// + /// Invite was declined + /// + public Decline Decline + { + get { return GetChildElement(); } + set { ReplaceChild(value); } + } + + /// + /// Add a destroy element, or return the existing one. + /// + /// + public Destroy AddDestroy() + { + return GetOrCreateElement(); + } + + /// + /// Room was destroyed + /// + public Destroy Destroy + { + get { return GetChildElement(); } + set { ReplaceChild(value); } + } + + /// + /// The list of invites + /// + public Invite[] GetInvites() + { + return GetElements().ToArray(); + } + + /// + /// Add new invite + /// + /// Who to send the invite to? + /// Why? Null if none. + /// + public Invite AddInvite(JID to, string reason) + { + Invite inv = CreateChildElement(); + inv.To = to; + if (reason != null) + inv.Reason = reason; + return inv; + } + + /// + /// Add a room item element, or return the existing one. + /// + /// + public RoomItem AddRoomItem() + { + return GetOrCreateElement(); + } + + /// + /// The associated item + /// + public RoomItem RoomItem + { + get { return GetChildElement(); } + set { ReplaceChild(value); } + } + + /// + /// The password to join the room. + /// + public string Password + { + get { return GetElem("password"); } + set { SetElem("password", value); } + } + + /// + /// Sorted list of statuses of the request. + /// + /// Invalid code + public RoomStatus[] Status + { + get + { + XmlNodeList nl = this.GetElementsByTagName("status"); + RoomStatus[] ret = new RoomStatus[nl.Count]; + int i = 0; + foreach (XmlElement status in nl) + { + try + { + ret[i] = (RoomStatus)int.Parse(status.GetAttribute("code")); + } + catch + { + ret[i] = RoomStatus.UNKNOWN; + } + i++; + } + Array.Sort(ret); + return ret; + } + set + { + RemoveElems("status"); + foreach (RoomStatus i in value) + { + XmlElement status = this.OwnerDocument.CreateElement("status"); + status.SetAttribute("code", ((int)i).ToString()); + this.AppendChild(status); + } + } + } + + /// + /// Did we receive a given status? + /// + /// + /// + public bool HasStatus(RoomStatus status) + { + string s = ((int)status).ToString(); + XmlNodeList nl = this.GetElementsByTagName("status"); + foreach (XmlElement stat in nl) + { + if (s == stat.GetAttribute("code")) + return true; + } + return false; + } + } + + /// + /// Invitee Declines Invitation + /// + [SVN(@"$Id$")] + public class Decline : Element + { + /// + /// + /// + /// + public Decline(XmlDocument doc) + : base("decline", URI.MUC_USER, doc) + { + } + + /// + /// + /// + /// + /// + /// + public Decline(string prefix, XmlQualifiedName qname, XmlDocument doc) + : base(prefix, qname, doc) + { + } + + /// + /// The From address + /// + public JID From + { + get + { + string from = this.GetAttr("from"); + if (from == null) + return null; + return new JID(from); + } + set { SetAttr("from", (string)value); } + } + + /// + /// The TO address + /// + public JID To + { + get + { + string to = this.GetAttr("to"); + if (to == null) + return null; + return new JID(to); + } + set { SetAttr("to", (string)value); } + } + + /// + /// The reason the invitation was declined. May be null. + /// + public string Reason + { + get { return GetElem("reason"); } + set { SetElem("reason", value); } + } + } + + /// + /// An invite to a room + /// + [SVN(@"$Id$")] + public class Invite : Element + { + /// + /// + /// + /// + public Invite(XmlDocument doc) + : base("invite", URI.MUC_USER, doc) + { + } + + /// + /// + /// + /// + /// + /// + public Invite(string prefix, XmlQualifiedName qname, XmlDocument doc) + : base(prefix, qname, doc) + { + } + + /// + /// The From address + /// + public JID From + { + get + { + string from = this.GetAttr("from"); + if (from == null) + return null; + return new JID(from); + } + set { SetAttr("from", (string)value); } + } + + /// + /// The TO address + /// + public JID To + { + get + { + string to = this.GetAttr("to"); + if (to == null) + return null; + return new JID(to); + } + set { SetAttr("to", (string)value); } + } + + /// + /// The reason the invitation was declined. May be null. + /// + public string Reason + { + get { return GetElem("reason"); } + set { SetElem("reason", value); } + } + } + + /// + /// A room was destroyed + /// + [SVN(@"$Id$")] + public class Destroy : Element + { + /// + /// + /// + /// + public Destroy(XmlDocument doc) + : base("destroy", URI.MUC_USER, doc) + { + } + + /// + /// + /// + /// + /// + /// + public Destroy(string prefix, XmlQualifiedName qname, XmlDocument doc) + : base(prefix, qname, doc) + { + } + + /// + /// The JID of the destroyer + /// + public JID JID + { + get + { + string jid = this.GetAttr("jid"); + if (jid == null) + return null; + return new JID(jid); + } + set { SetAttr("jid", (string)value); } + } + + /// + /// The reason the room was destroyed. May be null. + /// + public string Reason + { + get { return GetElem("reason"); } + set { SetElem("reason", value); } + } + } + + /// + /// Item associated with a room. + /// + [SVN(@"$Id$")] + public class RoomItem : AdminItem + { + /// + /// + /// + /// + public RoomItem(XmlDocument doc) + : base("item", URI.MUC_USER, doc) + { + } + + /// + /// + /// + /// + /// + /// + public RoomItem(string prefix, XmlQualifiedName qname, XmlDocument doc) + : base(prefix, qname, doc) + { + } + + /// + /// This is a continuation from 1-to-1 chat. Not widely implemented yet. + /// + public bool Continue + { + get + { + XmlElement c = this["continue", URI.MUC_USER]; + return (c != null); + } + set + { + if (value) + GetOrCreateElement("continue", URI.MUC_USER, null); + else + RemoveElem("continue"); + } + } + } + + /// + /// The JID associated with an item + /// + [SVN(@"$Id$")] + public class RoomActor : Element + { + /// + /// + /// + /// + public RoomActor(XmlDocument doc) + : base("actor", URI.MUC_USER, doc) + { + } + + /// + /// + /// + /// + /// + /// + public RoomActor(string prefix, XmlQualifiedName qname, XmlDocument doc) + : base(prefix, qname, doc) + { + } + + /// + /// The JID of the destroyer + /// + public JID JID + { + get + { + string jid = this.GetAttr("jid"); + if (jid == null) + return null; + return new JID(jid); + } + set { SetAttr("jid", (string)value); } + } + } +#endregion + +#region admin + /// + /// An IQ with a AdminQuery inside. + /// + [SVN(@"$Id$")] + public class RoomAdminIQ : jabber.protocol.client.TypedIQ + { + /// + /// Create a admin IQ, with a single muc#admin query element. + /// + /// + public RoomAdminIQ(XmlDocument doc) + : base(doc) + { + } + } + + /// + /// Moderator use cases + /// + [SVN(@"$Id$")] + public class AdminQuery : Element + { + /// + /// + /// + /// + public AdminQuery(XmlDocument doc) + : base("query", URI.MUC_ADMIN, doc) + { + } + + /// + /// + /// + /// + /// + /// + public AdminQuery(string prefix, XmlQualifiedName qname, XmlDocument doc) + : base(prefix, qname, doc) + { + } + + /// + /// The list of invites + /// + public AdminItem[] GetItems() + { + XmlNodeList nl = GetElementsByTagName("item", URI.MUC_ADMIN); + AdminItem[] items = new AdminItem[nl.Count]; + int i=0; + foreach (XmlNode n in nl) + { + items[i] = (AdminItem)n; + i++; + } + return items; + } + + /// + /// Add new item + /// + /// + public AdminItem AddItem() + { + AdminItem item = new AdminItem(this.OwnerDocument); + this.AddChild(item); + return item; + } + } + + + /// + /// Item associated with a room. + /// + [SVN(@"$Id$")] + public class AdminItem : Element + { + /// + /// + /// + /// + public AdminItem(XmlDocument doc) + : base("item", URI.MUC_ADMIN, doc) + { + } + + /// + /// + /// + /// + /// + /// + public AdminItem(string prefix, XmlQualifiedName qname, XmlDocument doc) + : base(prefix, qname, doc) + { + } + + /// + /// Pass through. I really wish C# would let me just call grand-superclass constructors. + /// + /// + /// + /// + protected AdminItem(string localName, string namespaceURI, XmlDocument doc) + : base(localName, namespaceURI, doc) + { + } + + /// + /// The JID associated with this item + /// + public RoomActor Actor + { + get { return GetOrCreateElement("actor", null, typeof(RoomActor)) as RoomActor; } + set { ReplaceChild(value); } + } + + /// + /// The reason the room was destroyed. May be null. + /// + public string Reason + { + get { return GetElem("reason"); } + set { SetElem("reason", value); } + } + + /// + /// The affiliation of the item + /// + public RoomAffiliation Affiliation + { + get { return (RoomAffiliation)GetEnumAttr("affiliation", typeof(RoomAffiliation)); } + set { SetEnumAttr("affiliation", value); } + } + + /// + /// The role of the item + /// + public RoomRole Role + { + get { return (RoomRole)GetEnumAttr("role", typeof(RoomRole)); } + set { SetEnumAttr("role", value); } + } + + /// + /// The JID of the item + /// + public JID JID + { + get + { + string jid = this.GetAttr("jid"); + if (jid == null) + return null; + return new JID(jid); + } + set { SetAttr("jid", (string)value); } + } + + /// + /// The nickname of the item + /// + public string Nick + { + get { return GetAttr("nick"); } + set { SetAttr("nick", value); } + } + } +#endregion + +#region owner + /// + /// IQ with an OwnerQuery inside + /// + [SVN(@"$Id$")] + public class OwnerIQ : jabber.protocol.client.TypedIQ + { + /// + /// Create + /// + /// + public OwnerIQ(XmlDocument doc) + : base(doc) + { + } + } + + /// + /// The query element inside an owner IQ. + /// + [SVN(@"$Id$")] + public class OwnerQuery : Element + { + /// + /// + /// + /// + public OwnerQuery(XmlDocument doc) + : base("query", URI.MUC_OWNER, doc) + { + } + + /// + /// + /// + /// + /// + /// + public OwnerQuery(string prefix, XmlQualifiedName qname, XmlDocument doc) + : base(prefix, qname, doc) + { + } + + /// + /// The jabber:x:data form for configuration + /// + public jabber.protocol.x.Data Form + { + get { return GetOrCreateElement("x", URI.XDATA, typeof(jabber.protocol.x.Data)) as jabber.protocol.x.Data; } + set { ReplaceChild(value); } + } + + /// + /// Should we destroy the room? + /// + public OwnerDestroy Destroy + { + get { return GetOrCreateElement("destroy", URI.MUC_OWNER, typeof(OwnerDestroy)) as OwnerDestroy; } + set { ReplaceChild(value); } + } + } + + /// + /// Destroy the room + /// + [SVN(@"$Id$")] + public class OwnerDestroy : Element + { + /// + /// + /// + /// + public OwnerDestroy(XmlDocument doc) + : base("destroy", URI.MUC_OWNER, doc) + { + } + + /// + /// + /// + /// + /// + /// + public OwnerDestroy(string prefix, XmlQualifiedName qname, XmlDocument doc) + : base(prefix, qname, doc) + { + } + + /// + /// Password to destroy room. Null for no password. + /// + public string Password + { + get { return GetElem("password"); } + set { SetElem("password", value); } + } + + /// + /// Reason to destroy room. Null for no reason. + /// + public string Reason + { + get { return GetElem("reason"); } + set { SetElem("reason", value); } + } + + /// + /// The JID of the destroyer. + /// + public JID JID + { + get + { + string jid = this.GetAttr("jid"); + if (jid == null) + return null; + return new JID(jid); + } + set { SetAttr("jid", (string)value); } + } + } +#endregion + + /// + /// Request for a unique room name. Seems like just using a GUID on the + /// create request would be enough, but it's in XEP-45. + /// + [SVN(@"$Id$")] + public class UniqueIQ : jabber.protocol.client.IQ + { + /// + /// Create + /// + /// + public UniqueIQ(XmlDocument doc) + : base(doc) + { + AppendChild(new UniqueRoom(doc)); + } + } + + /// + /// A unique name for a room. + /// + [SVN(@"$Id$")] + public class UniqueRoom : Element + { + /// + /// + /// + /// + public UniqueRoom(XmlDocument doc) + : base("unique", URI.MUC_UNIQUE, doc) + { + } + + /// + /// + /// + /// + /// + /// + public UniqueRoom(string prefix, XmlQualifiedName qname, XmlDocument doc) + : base(prefix, qname, doc) + { + } + + /// + /// The room name returned by the server. Note: must add conference server to this, + /// it is just the node. + /// + public string RoomNode + { + get { return this.InnerText; } + set { this.InnerText = value; } + } + } +} diff -Nru smuxi-0.8/lib/jabber-net/jabber/protocol/iq/OOB.cs smuxi-0.8.9.1/lib/jabber-net/jabber/protocol/iq/OOB.cs --- smuxi-0.8/lib/jabber-net/jabber/protocol/iq/OOB.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/jabber-net/jabber/protocol/iq/OOB.cs 2012-01-03 07:52:11.000000000 +0000 @@ -0,0 +1,87 @@ +/* -------------------------------------------------------------------------- + * Copyrights + * + * Portions created by or assigned to Cursive Systems, Inc. are + * Copyright (c) 2002-2008 Cursive Systems, Inc. All Rights Reserved. Contact + * information for Cursive Systems, Inc. is available at + * http://www.cursive.net/. + * + * License + * + * Jabber-Net is licensed under the LGPL. + * See LICENSE.txt for details. + * --------------------------------------------------------------------------*/ +using System; + +using System.Xml; + +using bedrock.util; + +namespace jabber.protocol.iq +{ + /* + * + * + * http://denmark/act4/letter-1.html + * There's a letter for you sir. + * + * + */ + /// + /// IQ packet with an oob query element inside. + /// + [SVN(@"$Id$")] + public class OobIQ : jabber.protocol.client.TypedIQ + { + /// + /// Create an OOB IQ. + /// + /// + public OobIQ(XmlDocument doc) : base(doc) + { + } + } + + /// + /// An oob query element for file transfer. + /// + [SVN(@"$Id$")] + public class OOB : Element + { + /// + /// + /// + /// + public OOB(XmlDocument doc) : base("query", URI.OOB, doc) + { + } + /// + /// + /// + /// + /// + /// + public OOB(string prefix, XmlQualifiedName qname, XmlDocument doc) : + base(prefix, qname, doc) + { + } + + /// + /// URL to send/receive from + /// + public string Url + { + get { return GetElem("url"); } + set { SetElem("url", value); } + } + + /// + /// File description + /// + public string Desc + { + get { return GetElem("desc"); } + set { SetElem("desc", value); } + } + } +} diff -Nru smuxi-0.8/lib/jabber-net/jabber/protocol/iq/Private.cs smuxi-0.8.9.1/lib/jabber-net/jabber/protocol/iq/Private.cs --- smuxi-0.8/lib/jabber-net/jabber/protocol/iq/Private.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/jabber-net/jabber/protocol/iq/Private.cs 2012-01-03 07:52:11.000000000 +0000 @@ -0,0 +1,66 @@ +/* -------------------------------------------------------------------------- + * Copyrights + * + * Portions created by or assigned to Cursive Systems, Inc. are + * Copyright (c) 2002-2008 Cursive Systems, Inc. All Rights Reserved. Contact + * information for Cursive Systems, Inc. is available at + * http://www.cursive.net/. + * + * License + * + * Jabber-Net is licensed under the LGPL. + * See LICENSE.txt for details. + * --------------------------------------------------------------------------*/ +using System; +using System.Diagnostics; +using System.Xml; + +using bedrock.util; + +namespace jabber.protocol.iq +{ + /// + /// Private storage IQ. + /// See XEP-0049 (http://www.xmpp.org/extensions/xep-0049.html) + /// + [SVN(@"$Id$")] + public class PrivateIQ : jabber.protocol.client.TypedIQ + { + /// + /// Create an IQ for the jabber:iq:private namespace. + /// Make sure to add a body to the query before sending. + /// + /// + public PrivateIQ(XmlDocument doc) : base(doc) + { + } + } + + /// + /// Private storage query. + /// See XEP-0049 (http://www.xmpp.org/extensions/xep-0049.html) + /// + [SVN(@"$Id$")] + public class Private : Element + { + /// + /// Create for outbound + /// + /// + public Private(XmlDocument doc) : + base("query", URI.PRIVATE, doc) + { + } + + /// + /// Create for inbound. + /// + /// + /// + /// + public Private(string prefix, XmlQualifiedName qname, XmlDocument doc) : + base(prefix, qname, doc) + { + } + } +} diff -Nru smuxi-0.8/lib/jabber-net/jabber/protocol/iq/PubSub.cs smuxi-0.8.9.1/lib/jabber-net/jabber/protocol/iq/PubSub.cs --- smuxi-0.8/lib/jabber-net/jabber/protocol/iq/PubSub.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/jabber-net/jabber/protocol/iq/PubSub.cs 2012-01-03 07:52:11.000000000 +0000 @@ -0,0 +1,1278 @@ +/* -------------------------------------------------------------------------- + * Copyrights + * + * Portions created by or assigned to Cursive Systems, Inc. are + * Copyright (c) 2002-2008 Cursive Systems, Inc. All Rights Reserved. Contact + * information for Cursive Systems, Inc. is available at + * http://www.cursive.net/. + * + * License + * + * Jabber-Net is licensed under the LGPL. + * See LICENSE.txt for details. + * --------------------------------------------------------------------------*/ +using System; +using System.Xml; + +using bedrock.util; +using jabber.protocol.x; + +namespace jabber.protocol.iq +{ + /// + /// Different pubsub operations + /// + public enum PubSubCommandType + { + /// + /// Retrieve the affiliations. See: http://www.xmpp.org/extensions/xep-0060.html#entity-affiliations + /// + affiliations, + /// + /// Create a node. See: http://www.xmpp.org/extensions/xep-0060.html#owner-create + /// + create, + /// + /// Retrieve the items for a node. See http://www.xmpp.org/extensions/xep-0060.html#subscriber-retrieve + /// + items, + /// + /// Publish to a node. See http://www.xmpp.org/extensions/xep-0060.html#publisher-publish + /// + publish, + /// + /// Delete an item from a node. See: http://www.xmpp.org/extensions/xep-0060.html#publisher-delete + /// + retract, + /// + /// Subscribe to a node. See: http://www.xmpp.org/extensions/xep-0060.html#subscriber-subscribe + /// + subscribe, + /// + /// Retrieve subscriptions. See: http://www.xmpp.org/extensions/xep-0060.html#entity-subscriptions + /// + subscriptions, + /// + /// Unsubscribe from a node. See: http://www.xmpp.org/extensions/xep-0060.html#subscriber-unsubscribe + /// + unsubscribe, + /// + /// Delete a node. See: http://www.xmpp.org/extensions/xep-0060.html#owner-delete + /// + delete, + + /// + /// Collection modification + /// + collection, + /// + /// Node configuration change + /// + configuration, + /// + /// All items purged + /// + purge, + /// + /// A new subscription + /// + subscription, + + /// + /// Owner configuring the node + /// + configure, + /// + /// Owner-level defaults, in a "default" element. "default" is a C# keyword, though. + /// + defaults + } + + /// + /// A PubSub IQ + /// + [SVN(@"$Id$")] + public class PubSubIQ : jabber.protocol.client.TypedIQ + { + /// + /// Create a pubsub IQ, with a single pubsub query element. + /// + /// + public PubSubIQ(XmlDocument doc) : base(doc) + { + } + + /// + /// Create a pubsub IQ, with a pubusub query element and the given subelement. + /// + /// Document to create in + /// The pubsub command + /// Add this as a node attrbute of the command + public PubSubIQ(XmlDocument doc, PubSubCommandType command, string node) + : base(doc) + { + PubSubCommand cmd = null; + switch (command) + { + case PubSubCommandType.affiliations: + cmd = new Affiliations(doc); + break; + case PubSubCommandType.create: + cmd = new Create(doc); + break; + case PubSubCommandType.items: + cmd = new Items(doc); + break; + case PubSubCommandType.publish: + cmd = new Publish(doc); + break; + case PubSubCommandType.retract: + cmd = new Retract(doc); + break; + case PubSubCommandType.subscribe: + cmd = new Subscribe(doc); + break; + case PubSubCommandType.subscriptions: + cmd = new Subscriptions(doc); + break; + case PubSubCommandType.unsubscribe: + cmd = new Unsubscribe(doc); + break; + default: + throw new ArgumentException("Command not understood: " + command.ToString(), "command"); + } + + if (node != null) + cmd.Node = node; + this.Instruction.AppendChild(cmd); + } + + /// + /// Get the command from the pubsub element. + /// + public PubSubCommand Command + { + get + { + PubSub ps = this.Instruction; + if (ps == null) + return null; + return ps.Command; + } + } + } + + /// + /// A type-safe PubSub IQ. + /// + /// The type of command to create + [SVN(@"$Id$")] + public class PubSubCommandIQ : jabber.protocol.client.TypedIQ> + where T : PubSubCommand + { + /// + /// Create + /// + /// + public PubSubCommandIQ(XmlDocument doc) + : base(doc) + { + } + + /// + /// Create, with node + /// + /// + /// + public PubSubCommandIQ(XmlDocument doc, string node) + : base(doc) + { + Command.Node = node; + } + + /// + /// The command inside the pubsub element. + /// + public T Command + { + get { return Instruction.Command; } + set { Instruction.Command = value; } + } + } + + /// + /// A type-safe pubsub element. + /// + /// + [SVN(@"$Id$")] + public class TypedPubSub : Element + where T : PubSubCommand + { + /// + /// Create + /// + /// + public TypedPubSub(XmlDocument doc) + : base("pubsub", URI.PUBSUB, doc) + { + CreateChildElement(); + } + + /// + /// The pubsub command + /// + public T Command + { + get { return GetChildElement(); } + set { ReplaceChild(value); } + } + + /// + /// The type of pubsub command + /// + public PubSubCommandType CommandType + { + get { return Command.CommandType; } + } + } + + /// + /// Publish/Subscribe. See XEP-60: http://www.xmpp.org/extensions/xep-0060.html + /// + [SVN(@"$Id$")] + public class PubSub : Element + { + /// + /// + /// + /// + public PubSub(XmlDocument doc) : base("pubsub", URI.PUBSUB, doc) + { + } + + /// + /// + /// + /// + /// + /// + public PubSub(string prefix, XmlQualifiedName qname, XmlDocument doc) + : base(prefix, qname, doc) + { + } + + /// + /// The PubSub command associated with this instruction + /// + public PubSubCommand Command + { + get { return GetChildElement(); } + } + } + + /// + /// A PubSub command + /// + [SVN(@"$Id$")] + public abstract class PubSubCommand : Element + { + /// + /// Create a pubsub command. Should not be called directly. + /// + /// + /// + /// + protected PubSubCommand(string prefix, XmlQualifiedName qname, XmlDocument doc) + : base(prefix, qname, doc) + { + } + + /// + /// Create for outbound, in the namespace of the parent element, + /// then attach to the parent element. + /// + /// The name of the element to create + /// The parent element + public PubSubCommand(string elementName, XmlElement parent) + : base(elementName, parent.NamespaceURI, parent.OwnerDocument) + { + parent.AppendChild(this); + } + + /// + /// Create a pubsub command. Should not be called directly. + /// + /// + /// + /// + protected PubSubCommand(string prefix, string ns, XmlDocument doc) + : base(prefix, ns, doc) + { + } + + /// + /// The node this command applies to. + /// + public string Node + { + get { return GetAttr("node"); } + set { SetAttr("node", value); } + } + + /// + /// What type of command? + /// + public abstract PubSubCommandType CommandType + { + get; + } + } + + + /// + /// Retrieve the affiliations. See: http://www.xmpp.org/extensions/xep-0060.html#entity-affiliations + /// + [SVN(@"$Id$")] + public class Affiliations : PubSubCommand + { + /// + /// + /// + /// + public Affiliations(XmlDocument doc) + : base("affiliations", URI.PUBSUB, doc) + { + } + + /// + /// + /// + /// + /// + /// + public Affiliations(string prefix, XmlQualifiedName qname, XmlDocument doc) + : base(prefix, qname, doc) + { + } + + /// + /// What type of command? + /// + public override PubSubCommandType CommandType + { + get { return PubSubCommandType.affiliations; } + } + + /// + /// Retrieve all of the affiliations + /// + /// + public Affiliation[] GetAffiliations() + { + return GetElements().ToArray(); + } + + /// + /// Add a new affiliation to the list. + /// + /// + /// + /// + public Affiliation AddAffiliation(AffiliationType type, string node) + { + Affiliation afil = CreateChildElement(); + afil.Type = type; + afil.Node = node; + return afil; + } + } + + /// + /// What affiliation does an entity have with respect to a node? + /// + [SVN(@"$Id$")] + public enum AffiliationType + { + /// + /// No affiliation specified + /// + NONE_SPECIFIED=-1, + /// + /// Can receive + /// + member=0, + /// + /// No affiliation + /// + none, + /// + /// Can't join + /// + outcast, + /// + /// All permisions + /// + owner, + /// + /// Can publish + /// + publisher, + } + + /// + /// The actual affiliation. + /// + [SVN(@"$Id$")] + public class Affiliation : Element + { + /// + /// + /// + /// + public Affiliation(XmlDocument doc) + : base("affiliation", URI.PUBSUB, doc) + { + } + + /// + /// Create a new instance for output, specifying the namespace. This + /// exists for things in pubsub#owner. + /// + /// + /// + public Affiliation(XmlDocument doc, string namespaceURI) + : base("affiliation", namespaceURI, doc) + { + } + + /// + /// + /// + /// + /// + /// + public Affiliation(string prefix, XmlQualifiedName qname, XmlDocument doc) + : base(prefix, qname, doc) + { + } + + /// + /// The node this affiliation applies to. + /// + public string Node + { + get { return GetAttribute("node"); } + set { SetAttribute("node", value); } + } + + /// + /// Which affiliation? + /// + public AffiliationType Type + { + get { return GetEnumAttr("affiliation"); } + set { SetEnumAttr("affiliation", value); } + } + + } + + /// + /// Create a node. See: http://www.xmpp.org/extensions/xep-0060.html#owner-create + /// + [SVN(@"$Id$")] + public class Create : PubSubCommand + { + /// + /// + /// + /// + public Create(XmlDocument doc) + : base("create", URI.PUBSUB, doc) + { + } + + /// + /// + /// + /// + /// + /// + public Create(string prefix, XmlQualifiedName qname, XmlDocument doc) + : base(prefix, qname, doc) + { + } + + /// + /// What type of command? + /// + public override PubSubCommandType CommandType + { + get { return PubSubCommandType.create; } + } + + /// + /// Does the element have a configure sibling? + /// + public bool HasConfigure + { + get + { + Configure config = GetConfiguration(); + return (config != null); + } + set + { + Configure config = GetConfiguration(); + if (value) + { + if (config != null) + return; + config = new Configure(this.OwnerDocument); + ParentNode.AppendChild(config); + } + else + { + if (config == null) + return; + ParentNode.RemoveChild(config); + } + } + } + + /// + /// Get the configuration. Null if none exists. + /// + public Configure GetConfiguration() + { + return ParentNode["configure", URI.PUBSUB] as Configure; + } + + /// + /// Add a (or return a pre-exisitng) configuration section to the creation request, complete with x:data. + /// + /// The x:data form + public Data CreateConfiguration() + { + return CreateConfiguration(null); + } + + /// + /// Add a configuration section to the creation request, using the given x:data. + /// + /// + /// + public Data CreateConfiguration(Data form) + { + Configure config = GetConfiguration(); + if (config == null) + { + config = new Configure(this.OwnerDocument); + ParentNode.AppendChild(config); + } + return config.CreateForm(form); + } + } + + /// + /// Configuring a pubsub node. If the default is desired, it will be empty. Otherwise it will contain an x:data. + /// + [SVN(@"$Id$")] + public class Configure : PubSubCommand + { + /// + /// + /// + /// + public Configure(XmlDocument doc) : base("configure", URI.PUBSUB, doc) + { + } + + /// + /// + /// + /// + /// + /// + public Configure(string prefix, XmlQualifiedName qname, XmlDocument doc) + : base(prefix, qname, doc) + { + } + + /// + /// What type of command? + /// + public override PubSubCommandType CommandType + { + get { return PubSubCommandType.configuration; } + } + + /// + /// Create or return the existing x:data form, with the appropriate form type. + /// + /// + public Data CreateForm() + { + Data x = GetChildElement(); + if (x == null) + { + x = CreateChildElement(); + x.FormType = URI.PUBSUB_NODE_CONFIG; + } + return x; + } + + /// + /// Add the given form to the configuration, removing any existing form, and ensuring that the + /// form type is correct. + /// + /// + /// + public Data CreateForm(Data form) + { + ReplaceChild(form); + if (form != null) + { + form.FormType = URI.PUBSUB_NODE_CONFIG; + form.Type = XDataType.submit; + } + return form; + } + } + + /// + /// Commands that deal with items. + /// + public abstract class PubSubItemCommand : PubSubCommand + { + /// + /// Create a pubsub command. Should not be called directly. + /// + /// + /// + /// + protected PubSubItemCommand(string prefix, XmlQualifiedName qname, XmlDocument doc) + : base(prefix, qname, doc) + { + } + + /// + /// Create a pubsub command. Should not be called directly. + /// + /// + /// + /// + protected PubSubItemCommand(string prefix, string ns, XmlDocument doc) + : base(prefix, ns, doc) + { + } + + /// + /// Retrieve all of the items + /// + /// + public PubSubItem[] GetItems() + { + return GetElements().ToArray(); + } + + /// + /// Add a new item to the list + /// + /// + /// + public PubSubItem AddItem(string id) + { + PubSubItem item = CreateChildElement(); + item.ID = id; + return item; + } + } + + + /// + /// Retrieve the items for a node. See http://www.xmpp.org/extensions/xep-0060.html#subscriber-retrieve + /// Note: this same type is used for event notifications, in the pubsub#event namespace + /// + [SVN(@"$Id$")] + public class Items : PubSubItemCommand + { + /// + /// + /// + /// + public Items(XmlDocument doc) + : base("items", URI.PUBSUB, doc) + { + } + + /// + /// + /// + /// + /// + /// + public Items(string prefix, XmlQualifiedName qname, XmlDocument doc) + : base(prefix, qname, doc) + { + } + + /// + /// What type of command? + /// + public override PubSubCommandType CommandType + { + get { return PubSubCommandType.items; } + } + + /// + /// The subscription ID these items apply to. + /// + public string SubID + { + get { return GetAttr("subid"); } + set { SetAttr("subid", value); } + } + + /// + /// The maximum number of items to return + /// + public int MaxItems + { + get { return GetIntAttr("max_items"); } + set { SetIntAttr("max_items", value); } + } + } + + + /// + /// The items in a node + /// + [SVN(@"$Id$")] + public class PubSubItem : Element + { + /// + /// + /// + /// + public PubSubItem(XmlDocument doc) + : base("item", URI.PUBSUB, doc) + { + } + + /// + /// Create a new instance for output, specifying the namespace. This + /// exists for things in pubsub#event. + /// + /// + /// + public PubSubItem(XmlDocument doc, string namespaceURI) + : base("item", namespaceURI, doc) + { + } + + /// + /// + /// + /// + /// + /// + public PubSubItem(string prefix, XmlQualifiedName qname, XmlDocument doc) + : base(prefix, qname, doc) + { + } + + /// + /// The node of the published item, when doing hierachical subscribes + /// + public string Node + { + get { return GetAttr("node"); } + set { SetAttr("node", value); } + } + + /// + /// The item id number + /// + public string ID + { + get { return GetAttr("id"); } + set { SetAttr("id", value); } + } + + /// + /// The actual contents to publish. Make sure to set a namespace! + /// + public XmlElement Contents + { + get { return GetFirstChildElement(); } + set { this.InnerXml = ""; this.AddChild(value); } + } + } + + /// + /// Publish to a node. See http://www.xmpp.org/extensions/xep-0060.html#publisher-publish + /// + [SVN(@"$Id$")] + public class Publish : PubSubItemCommand + { + /// + /// + /// + /// + public Publish(XmlDocument doc) + : base("publish", URI.PUBSUB, doc) + { + } + + /// + /// + /// + /// + /// + /// + public Publish(string prefix, XmlQualifiedName qname, XmlDocument doc) + : base(prefix, qname, doc) + { + } + + /// + /// What type of command? + /// + public override PubSubCommandType CommandType + { + get { return PubSubCommandType.publish; } + } + } + + /// + /// Delete an item from a node. See: http://www.xmpp.org/extensions/xep-0060.html#publisher-delete + /// + [SVN(@"$Id$")] + public class Retract : PubSubItemCommand + { + /// + /// + /// + /// + public Retract(XmlDocument doc) + : base("retract", URI.PUBSUB, doc) + { + } + + /// + /// + /// + /// + /// + /// + public Retract(string prefix, XmlQualifiedName qname, XmlDocument doc) + : base(prefix, qname, doc) + { + } + + /// + /// What type of command? + /// + public override PubSubCommandType CommandType + { + get { return PubSubCommandType.retract; } + } + + /// + /// When in an event, there may be an ID as an attribute. + /// + public string ID + { + get { return GetAttr("id"); } + set { SetAttr("id", value); } + } + + /// + /// Don notifications? + /// + public bool Notify + { + get + { + string notify = GetAttribute("notify"); + if (notify == "true") + return true; + if (notify == "1") + return true; + return false; + } + set { SetAttribute("notify", value ? "true": "false"); } + } + } + + /// + /// Subscribe to a node. See: http://www.xmpp.org/extensions/xep-0060.html#subscriber-subscribe + /// + [SVN(@"$Id$")] + public class Subscribe : PubSubCommand + { + /// + /// + /// + /// + public Subscribe(XmlDocument doc) + : base("subscribe", URI.PUBSUB, doc) + { + } + + /// + /// + /// + /// + /// + /// + public Subscribe(string prefix, XmlQualifiedName qname, XmlDocument doc) + : base(prefix, qname, doc) + { + } + + /// + /// What type of command? + /// + public override PubSubCommandType CommandType + { + get { return PubSubCommandType.subscribe; } + } + + /// + /// The Jabber ID for this subscription + /// + public JID JID + { + get { return GetAttr("jid"); } + set { SetAttr("jid", value); } + } + + /// + /// Does the element have a options sibling? + /// + public bool HasOptions + { + get + { + PubSubOptions opts = GetOptions(); + return (opts != null); + } + set + { + PubSubOptions opts = GetOptions(); + if (value) + { + if (opts != null) + return; + opts = new PubSubOptions(this.OwnerDocument); + ParentNode.AppendChild(opts); + } + else + { + if (opts == null) + return; + ParentNode.RemoveChild(opts); + } + } + } + + /// + /// Get the configuration. Null if none exists. + /// + public PubSubOptions GetOptions() + { + return ParentNode["options", URI.PUBSUB] as PubSubOptions; + } + } + + /// + /// PubSub subscription options + /// + [SVN(@"$Id$")] + public class PubSubOptions : Element + { + /// + /// + /// + /// + public PubSubOptions(XmlDocument doc) + : base("options", URI.PUBSUB, doc) + { + } + + /// + /// + /// + /// + /// + /// + public PubSubOptions(string prefix, XmlQualifiedName qname, XmlDocument doc) + : base(prefix, qname, doc) + { + } + + /// + /// The node these options apply to. + /// + public string Node + { + get { return GetAttr("node"); } + set { SetAttr("node", value); } + } + + /// + /// The Jabber ID these options apply to. + /// + public JID JID + { + get { return GetAttr("jid"); } + set { SetAttr("jid", value); } + } + + /// + /// The subscription ID these options apply to. + /// + public string SubID + { + get { return GetAttr("subid"); } + set { SetAttr("subid", value); } + } + + + /// + /// Does the element have an XData child? + /// + public bool HasXData + { + get { return (GetXData() != null); } + set + { + if (value) + GetOrCreateElement().Type = XDataType.submit; + else + RemoveElem(); + } + } + + /// + /// Get the XData child, if it exists. + /// + /// + public Data GetXData() + { + return GetChildElement(); + } + + } + + /// + /// Retrieve subscriptions. See: http://www.xmpp.org/extensions/xep-0060.html#entity-subscriptions + /// + [SVN(@"$Id$")] + public class Subscriptions : PubSubCommand + { + /// + /// + /// + /// + public Subscriptions(XmlDocument doc) + : base("subscriptions", URI.PUBSUB, doc) + { + } + + /// + /// Create a new instance for output, specifying the namespace. This + /// exists for things in pubsub#owner. + /// + /// + /// + public Subscriptions(XmlDocument doc, string namespaceURI) + : base("subscriptions", namespaceURI, doc) + { + } + + /// + /// + /// + /// + /// + /// + public Subscriptions(string prefix, XmlQualifiedName qname, XmlDocument doc) + : base(prefix, qname, doc) + { + } + + /// + /// What type of command? + /// + public override PubSubCommandType CommandType + { + get { return PubSubCommandType.subscriptions; } + } + + /// + /// Retrieve all of the subscriptions + /// + /// + public PubSubSubscription[] GetSubscriptions() + { + return GetElements().ToArray(); + } + + /// + /// Add a new subscription to the list + /// + /// + public PubSubSubscription AddSubscription() + { + return CreateChildElement(); + } + } + + + /// + /// A single subscription + /// + [SVN(@"$Id$")] + public class PubSubSubscription : Element + { + /// + /// + /// + /// + public PubSubSubscription(XmlDocument doc) + : base("subscription", URI.PUBSUB, doc) + { + } + + /// + /// + /// + /// + /// + /// + public PubSubSubscription(string prefix, XmlQualifiedName qname, XmlDocument doc) + : base(prefix, qname, doc) + { + } + + /// + /// The node these options apply to. + /// + public string Node + { + get { return GetAttr("node"); } + set { SetAttr("node", value); } + } + + /// + /// The Jabber ID these options apply to. + /// + public JID JID + { + get { return GetAttr("jid"); } + set { SetAttr("jid", value); } + } + + /// + /// The subscription ID these options apply to. + /// + public string SubID + { + get { return GetAttr("subid"); } + set { SetAttr("subid", value); } + } + + /// + /// The subscription state + /// + public PubSubSubscriptionType Type + { + get { return GetEnumAttr("subscription"); } + set { SetEnumAttr("subscription", value); } + } + } + + /// + /// The subscription state of a given pubsub node. + /// + public enum PubSubSubscriptionType + { + /// + /// No type given + /// + NONE_SPECIFIED = -1, + /// + /// No subscription + /// + none = 0, + /// + /// Sub is pending + /// + pending, + /// + /// Subscribed + /// + subscribed, + /// + /// Subscription needs to be configured + /// + unconfigured + } + + /// + /// Unsubscribe from a node. See: http://www.xmpp.org/extensions/xep-0060.html#subscriber-unsubscribe + /// + [SVN(@"$Id$")] + public class Unsubscribe : PubSubCommand + { + /// + /// + /// + /// + public Unsubscribe(XmlDocument doc) + : base("unsubscribe", URI.PUBSUB, doc) + { + } + + /// + /// + /// + /// + /// + /// + public Unsubscribe(string prefix, XmlQualifiedName qname, XmlDocument doc) + : base(prefix, qname, doc) + { + } + + /// + /// What type of command? + /// + public override PubSubCommandType CommandType + { + get { return PubSubCommandType.unsubscribe; } + } + + /// + /// The Jabber ID these options apply to. + /// + public JID JID + { + get { return GetAttr("jid"); } + set { SetAttr("jid", value); } + } + + /// + /// The subscription ID these options apply to. + /// + public string SubID + { + get { return GetAttr("subid"); } + set { SetAttr("subid", value); } + } + } + + +} diff -Nru smuxi-0.8/lib/jabber-net/jabber/protocol/iq/PubSubErrors.cs smuxi-0.8.9.1/lib/jabber-net/jabber/protocol/iq/PubSubErrors.cs --- smuxi-0.8/lib/jabber-net/jabber/protocol/iq/PubSubErrors.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/jabber-net/jabber/protocol/iq/PubSubErrors.cs 2012-01-03 07:52:11.000000000 +0000 @@ -0,0 +1,779 @@ +/* -------------------------------------------------------------------------- + * Copyrights + * + * Portions created by or assigned to Cursive Systems, Inc. are + * Copyright (c) 2002-2008 Cursive Systems, Inc. All Rights Reserved. Contact + * information for Cursive Systems, Inc. is available at + * http://www.cursive.net/. + * + * License + * + * Jabber-Net is licensed under the LGPL. + * See LICENSE.txt for details. + * --------------------------------------------------------------------------*/ +using System; +using System.Xml; + +using jabber; +using jabber.protocol; + +using bedrock.util; + +namespace jabber.protocol.iq +{ + /// + /// For nodes with a node access model of "whitelist", if the requesting + /// entity is not on the whitelist then the service MUST return a + /// not-allowed error, specifying a pubsub-specific error condition of closed-node. + /// + [SVN(@"$Id$")] + public class ClosedNode : Element + { + /// + /// Create for outbound. + /// + /// + public ClosedNode(XmlDocument doc) + : base("closed-node", URI.PUBSUB_ERRORS, doc) + { + } + + /// + /// Create for inbound + /// + /// + /// + /// + public ClosedNode(string prefix, XmlQualifiedName qname, XmlDocument doc) + : base(prefix, qname, doc) + { + } + } + + /// + /// The node must be configured. + /// + [SVN(@"$Id$")] + public class ConfigurationRequired : Element + { + /// + /// Create for outbound. + /// + /// + public ConfigurationRequired(XmlDocument doc) + : base("configuration-required", URI.PUBSUB_ERRORS, doc) + { + } + + /// + /// Create for inbound + /// + /// + /// + /// + public ConfigurationRequired(string prefix, XmlQualifiedName qname, XmlDocument doc) + : base(prefix, qname, doc) + { + } + } + /// + /// An invalid JID was specified + /// + [SVN(@"$Id$")] + public class InvalidJID : Element + { + /// + /// Create for outbound. + /// + /// + public InvalidJID(XmlDocument doc) + : base("invalid-jid", URI.PUBSUB_ERRORS, doc) + { + } + + /// + /// Create for inbound + /// + /// + /// + /// + public InvalidJID(string prefix, XmlQualifiedName qname, XmlDocument doc) + : base(prefix, qname, doc) + { + } + } + + /// + /// Invalid options were specified + /// + [SVN(@"$Id$")] + public class InvalidOptions : Element + { + /// + /// Create for outbound. + /// + /// + public InvalidOptions(XmlDocument doc) + : base("invalid-options", URI.PUBSUB_ERRORS, doc) + { + } + + /// + /// Create for inbound + /// + /// + /// + /// + public InvalidOptions(string prefix, XmlQualifiedName qname, XmlDocument doc) + : base(prefix, qname, doc) + { + } + } + + /// + /// An invalid item was specified. + /// + [SVN(@"$Id$")] + public class InvalidPayload : Element + { + /// + /// Create for outbound. + /// + /// + public InvalidPayload(XmlDocument doc) + : base("invalid-payload", URI.PUBSUB_ERRORS, doc) + { + + } + + /// + /// Create for inbound + /// + /// + /// + /// + public InvalidPayload(string prefix, XmlQualifiedName qname, XmlDocument doc) + : base(prefix, qname, doc) + { + } + } + + /// + /// An invalid ID was specified. + /// + [SVN(@"$Id$")] + public class InvalidSubid : Element + { + /// + /// Create for outbound. + /// + /// + public InvalidSubid(XmlDocument doc) + : base("invalid-subid", URI.PUBSUB_ERRORS, doc) + { + } + + /// + /// Create for inbound + /// + /// + /// + /// + public InvalidSubid(string prefix, XmlQualifiedName qname, XmlDocument doc) + : base(prefix, qname, doc) + { + } + } + + /// + /// An item was forbidden. + /// + [SVN(@"$Id$")] + public class ItemForbidden : Element + { + /// + /// Create for outbound. + /// + /// + public ItemForbidden(XmlDocument doc) + : base("item-forbidden", URI.PUBSUB_ERRORS, doc) + { + // lambda, the forbidden function + // cf: http://snurl.com/2gduz + } + + /// + /// Create for inbound + /// + /// + /// + /// + public ItemForbidden(string prefix, XmlQualifiedName qname, XmlDocument doc) + : base(prefix, qname, doc) + { + } + } + + /// + /// An item was required, but was not specified. + /// + [SVN(@"$Id$")] + public class ItemRequired : Element + { + /// + /// Create for outbound. + /// + /// + public ItemRequired(XmlDocument doc) + : base("item-required", URI.PUBSUB_ERRORS, doc) + { + } + + /// + /// Create for inbound + /// + /// + /// + /// + public ItemRequired(string prefix, XmlQualifiedName qname, XmlDocument doc) + : base(prefix, qname, doc) + { + } + } + + /// + /// A JID was required, but not specified. + /// + [SVN(@"$Id$")] + public class JIDRequired : Element + { + /// + /// Create for outbound. + /// + /// + public JIDRequired(XmlDocument doc) + : base("jid-required", URI.PUBSUB_ERRORS, doc) + { + } + + /// + /// Create for inbound + /// + /// + /// + /// + public JIDRequired(string prefix, XmlQualifiedName qname, XmlDocument doc) + : base(prefix, qname, doc) + { + } + } + + /// + /// The maximum number of items was exceeded. + /// + [SVN(@"$Id$")] + public class MaxItemsExceeded : Element + { + /// + /// Create for outbound. + /// + /// + public MaxItemsExceeded(XmlDocument doc) + : base("max-items-exceeded", URI.PUBSUB_ERRORS, doc) + { + } + + /// + /// Create for inbound + /// + /// + /// + /// + public MaxItemsExceeded(string prefix, XmlQualifiedName qname, XmlDocument doc) + : base(prefix, qname, doc) + { + } + } + + /// + /// The maximum number of nodes was exceeded. + /// + [SVN(@"$Id$")] + public class MaxNodesExceeded : Element + { + /// + /// Create for outbound. + /// + /// + public MaxNodesExceeded(XmlDocument doc) + : base("max-nodes-exceeded", URI.PUBSUB_ERRORS, doc) + { + } + + /// + /// Create for inbound + /// + /// + /// + /// + public MaxNodesExceeded(string prefix, XmlQualifiedName qname, XmlDocument doc) + : base(prefix, qname, doc) + { + } + } + + /// + /// The node was required, but not specified. + /// + [SVN(@"$Id$")] + public class NodeIDRequired : Element + { + /// + /// Create for outbound. + /// + /// + public NodeIDRequired(XmlDocument doc) + : base("nodeid-required", URI.PUBSUB_ERRORS, doc) + { + } + + /// + /// Create for inbound + /// + /// + /// + /// + public NodeIDRequired(string prefix, XmlQualifiedName qname, XmlDocument doc) + : base(prefix, qname, doc) + { + } + } + /// + /// Not allowed to subscribe, because you aren't in one of the correct roster + /// groups of the publisher. + /// + [SVN(@"$Id$")] + public class NotInRosterGroup : Element + { + /// + /// Create for outbound. + /// + /// + public NotInRosterGroup(XmlDocument doc) + : base("not-in-roster-group", URI.PUBSUB_ERRORS, doc) + { + } + + /// + /// Create for inbound + /// + /// + /// + /// + public NotInRosterGroup(string prefix, XmlQualifiedName qname, XmlDocument doc) + : base(prefix, qname, doc) + { + } + } + + /// + /// You must be subscribed to perform this function. + /// + [SVN(@"$Id$")] + public class NotSubscribed : Element + { + /// + /// Create for outbound. + /// + /// + public NotSubscribed(XmlDocument doc) + : base("not-subscribed", URI.PUBSUB_ERRORS, doc) + { + } + + /// + /// Create for inbound + /// + /// + /// + /// + public NotSubscribed(string prefix, XmlQualifiedName qname, XmlDocument doc) + : base(prefix, qname, doc) + { + } + } + + /// + /// The item is too large. + /// + [SVN(@"$Id$")] + public class PayloadTooBig : Element + { + /// + /// Create for outbound. + /// + /// + public PayloadTooBig(XmlDocument doc) + : base("payload-too-big", URI.PUBSUB_ERRORS, doc) + { + } + + /// + /// Create for inbound + /// + /// + /// + /// + public PayloadTooBig(string prefix, XmlQualifiedName qname, XmlDocument doc) + : base(prefix, qname, doc) + { + } + } + + /// + /// An item is required, but was not specified. + /// + [SVN(@"$Id$")] + public class PayloadRequired : Element + { + /// + /// Create for outbound. + /// + /// + public PayloadRequired(XmlDocument doc) + : base("payload-required", URI.PUBSUB_ERRORS, doc) + { + } + + /// + /// Create for inbound + /// + /// + /// + /// + public PayloadRequired(string prefix, XmlQualifiedName qname, XmlDocument doc) + : base(prefix, qname, doc) + { + } + } + /// + /// The subscription is pending. + /// + [SVN(@"$Id$")] + public class PendingSubscription : Element + { + /// + /// Create for outbound. + /// + /// + public PendingSubscription(XmlDocument doc) + : base("pending-subscription", URI.PUBSUB_ERRORS, doc) + { + } + + /// + /// Create for inbound + /// + /// + /// + /// + public PendingSubscription(string prefix, XmlQualifiedName qname, XmlDocument doc) + : base(prefix, qname, doc) + { + } + } + + /// + /// You must be subscribed first. + /// + [SVN(@"$Id$")] + public class PresenceSubscriptionRequired : Element + { + /// + /// Create for outbound. + /// + /// + public PresenceSubscriptionRequired(XmlDocument doc) + : base("presence-subscription-required", URI.PUBSUB_ERRORS, doc) + { + } + + /// + /// Create for inbound + /// + /// + /// + /// + public PresenceSubscriptionRequired(string prefix, XmlQualifiedName qname, XmlDocument doc) + : base(prefix, qname, doc) + { + } + } + + /// + /// An subscription ID is required, but was not specified. + /// + [SVN(@"$Id$")] + public class SubidRequired : Element + { + /// + /// Create for outbound. + /// + /// + public SubidRequired(XmlDocument doc) + : base("subid-required", URI.PUBSUB_ERRORS, doc) + { + } + + /// + /// Create for inbound + /// + /// + /// + /// + public SubidRequired(string prefix, XmlQualifiedName qname, XmlDocument doc) + : base(prefix, qname, doc) + { + } + } + + /// + /// Supported features + /// + [SVN(@"$Id$")] + [Dash] + public enum PubSubFeature + { + /// + /// None specified + /// + UNSPECIFIED = -1, + /// + /// Access authorizations + /// + access_authorize, + /// + /// Open Access + /// + access_open, + /// + /// Presence-based access control + /// + access_presence, + /// + /// Roster-based access control + /// + access_roster, + /// + /// Whitelist-based access control + /// + access_whitelist, + /// + /// Auto-creation of nodes + /// + auto_create, + /// + /// Auto-subscription to nodes + /// + auto_subscribe, + /// + /// Collection support + /// + collections, + /// + /// Configuration + /// + config_node, + /// + /// Create and configure atomically + /// + create_and_configure, + /// + /// Node creation + /// + create_nodes, + /// + /// Delete items + /// + delete_any, + /// + /// Delete nodes + /// + delete_nodes, + /// + /// Notify on some criteria, only + /// + filtered_notifications, + /// + /// Process pending subscription requests + /// + get_pending, + /// + /// The server can create unused node names + /// + instant_nodes, + /// + /// Items have IDs + /// + item_ids, + /// + /// Geting the last published item + /// + last_published, + /// + /// Time-based subscriptions are supported. + /// + leased_subscription, + /// + /// Node owners may manage subscriptions + /// + manage_subscriptions, + /// + /// The member affiliation is supported + /// + member_affiliation, + /// + /// Node meta-data is supported. + /// + meta_data, + /// + /// Node owners may modify affiliations. + /// + modify_affiliations, + /// + /// A single leaf node may be associated with multiple collections + /// + multi_collection, + /// + /// A single entity may subscribe to a node multiple times. + /// + multi_subscribe, + /// + /// The outcast affiliation is supported + /// + outcast_affiliation, + /// + /// Persistent items are supported. + /// + persistent_items, + /// + /// Presence-based delivery of event notifications is supported + /// + presence_notifications, + /// + /// Authorized contacts are automatically subscribed to a user's virtual pubsub service. + /// + presence_subscribe, + /// + /// Publishing items is supported (note: not valid for collection nodes). + /// + publish, + /// + /// Publishing an item with options is supported. + /// + publish_options, + /// + /// The publisher affiliation is supported. + /// + publisher_affiliation, + /// + /// Purging of nodes is supported. + /// + purge_nodes, + /// + /// Item retraction is supported. + /// + retract_items, + /// + /// Retrieval of current affiliations is supported. + /// + retrieve_affiliations, + /// + /// Retrieval of default node configuration is supported. + /// + retrieve_default, + /// + /// Item retrieval is supported. + /// + retrieve_items, + /// + /// Retrieval of current subscriptions is supported. + /// + retrieve_subscriptions, + /// + /// Subscribing and unsubscribing are supported. + /// + subscribe, + /// + /// Configuration of subscription options is supported. + /// + subscription_options, + /// + /// Notification of subscription state changes is supported. + /// + subscription_notifications, + } + + /// + /// An unsupported protocol was used. + /// + [SVN(@"$Id$")] + public class Unsupported : Element + { + /// + /// Create for outbound. + /// + /// + public Unsupported(XmlDocument doc) + : base("unsupported", URI.PUBSUB_ERRORS, doc) + { + } + + /// + /// Create for inbound + /// + /// + /// + /// + public Unsupported(string prefix, XmlQualifiedName qname, XmlDocument doc) + : base(prefix, qname, doc) + { + } + + /// + /// Which feature was unsupported? + /// + public PubSubFeature Feature + { + get { return GetEnumAttr("feature"); } + set { SetEnumAttr("feature", value); } + } + } + + /// + /// An invalid access model was specified. + /// + [SVN(@"$Id$")] + public class UnsupportedAccessModel : Element + { + /// + /// Create for outbound. + /// + /// + public UnsupportedAccessModel(XmlDocument doc) + : base("unsupported-access-model", URI.PUBSUB_ERRORS, doc) + { + } + + /// + /// Create for inbound + /// + /// + /// + /// + public UnsupportedAccessModel(string prefix, XmlQualifiedName qname, XmlDocument doc) + : base(prefix, qname, doc) + { + } + } +} diff -Nru smuxi-0.8/lib/jabber-net/jabber/protocol/iq/PubSubEvent.cs smuxi-0.8.9.1/lib/jabber-net/jabber/protocol/iq/PubSubEvent.cs --- smuxi-0.8/lib/jabber-net/jabber/protocol/iq/PubSubEvent.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/jabber-net/jabber/protocol/iq/PubSubEvent.cs 2012-01-03 07:52:11.000000000 +0000 @@ -0,0 +1,459 @@ +/* -------------------------------------------------------------------------- + * Copyrights + * + * Portions created by or assigned to Cursive Systems, Inc. are + * Copyright (c) 2002-2008 Cursive Systems, Inc. All Rights Reserved. Contact + * information for Cursive Systems, Inc. is available at + * http://www.cursive.net/. + * + * License + * + * Jabber-Net is licensed under the LGPL. + * See LICENSE.txt for details. + * --------------------------------------------------------------------------*/ +using System; +using System.Xml; + +using bedrock.util; +using jabber; +using jabber.protocol; + +namespace jabber.protocol.iq +{ + /// + /// Publish/Subscribe. See XEP-60: http://www.xmpp.org/extensions/xep-0060.html + /// + [SVN(@"$Id$")] + public class PubSubEvent : Element + { + /// + /// + /// + /// + public PubSubEvent(XmlDocument doc) + : base("event", URI.PUBSUB_EVENT, doc) + { + } + + /// + /// + /// + /// + /// + /// + public PubSubEvent(string prefix, XmlQualifiedName qname, XmlDocument doc) + : base(prefix, qname, doc) + { + } + + /// + /// The PubSub command associated with this instruction + /// + public PubSubCommand Command + { + get { return GetChildElement(); } + } + } + + /// + /// Notification for item deletion. + /// + [SVN(@"$Id$")] + public class EventRetract : Element + { + /// + /// + /// + /// + public EventRetract(XmlDocument doc) + : base("retract", URI.PUBSUB_EVENT, doc) + { + } + + /// + /// + /// + /// + /// + /// + public EventRetract(string prefix, XmlQualifiedName qname, XmlDocument doc) + : base(prefix, qname, doc) + { + } + + /// + /// When in an event, there may be an ID as an attribute. + /// + public string ID + { + get { return GetAttr("id"); } + set { SetAttr("id", value); } + } + } + + /// + /// + /// + [SVN(@"$Id$")] + public class EventCollection : PubSubCommand + { + /// + /// Create for outbound. + /// + /// + public EventCollection(XmlDocument doc) + : base("collection", URI.PUBSUB_EVENT, doc) + { + } + + /// + /// Create for inbound + /// + /// + /// + /// + public EventCollection(string prefix, XmlQualifiedName qname, XmlDocument doc) + : base(prefix, qname, doc) + { + } + + /// + /// A collection notification + /// + public override PubSubCommandType CommandType + { + get { return PubSubCommandType.collection; } + } + + /// + /// The new node associated with the collection + /// + public EventAssociate Associate + { + get { return GetChildElement(); } + set { ReplaceChild(value); } + } + /// + /// The node removed from the collection + /// + public EventDisassociate Disassociate + { + get { return GetChildElement(); } + set { ReplaceChild (value); } + } + } + + /// + /// Nodes added to a collection + /// + [SVN(@"$Id$")] + public class EventAssociate : Element + { + /// + /// Create for outbound. + /// + /// + public EventAssociate(XmlDocument doc) + : base("associate", URI.PUBSUB_EVENT, doc) + { + } + + /// + /// Create for inbound + /// + /// + /// + /// + public EventAssociate(string prefix, XmlQualifiedName qname, XmlDocument doc) + : base(prefix, qname, doc) + { + } + + /// + /// The new node name + /// + public string Node + { + get { return GetAttr("node"); } + set { SetAttr("node", value); } + } + + /// + /// An x:data form that describes the new node + /// + public jabber.protocol.x.Data MetaData + { + get { return GetChildElement(); } + set { ReplaceChild(value); } + } + } + + /// + /// Nodes removed from a collection + /// + [SVN(@"$Id$")] + public class EventDisassociate : Element + { + /// + /// Create for outbound. + /// + /// + public EventDisassociate(XmlDocument doc) + : base("disassociate", URI.PUBSUB_EVENT, doc) + { + } + + /// + /// Create for inbound + /// + /// + /// + /// + public EventDisassociate(string prefix, XmlQualifiedName qname, XmlDocument doc) + : base(prefix, qname, doc) + { + } + + /// + /// The removed node name + /// + public string Node + { + get { return GetAttr("node"); } + set { SetAttr("node", value); } + } + } + + /// + /// Pubsub items notification. This is the main reason for XEP-60 to have been written. + /// + [SVN(@"$Id$")] + public class EventItems : PubSubCommand + { + /// + /// Create for outbound. + /// + /// + public EventItems(XmlDocument doc) + : base("items", URI.PUBSUB_EVENT, doc) + { + } + + /// + /// Create for inbound + /// + /// + /// + /// + public EventItems(string prefix, XmlQualifiedName qname, XmlDocument doc) + : base(prefix, qname, doc) + { + } + + /// + /// Retrieve all of the new items + /// + /// + public PubSubItem[] GetItems() + { + return GetElements().ToArray(); + } + + /// + /// Add a new item to the list + /// + /// + /// + public PubSubItem AddItem(string id) + { + PubSubItem item = new PubSubItem(OwnerDocument, URI.PUBSUB_EVENT); + AddChild(item); + item.ID = id; + return item; + } + + /// + /// Get a list of id's of deleted items. + /// + /// + public string[] GetRetractions() + { + TypedElementList nl = GetElements(); + string[] ids = new string[nl.Count]; + int i = 0; + foreach (EventRetract item in nl) + ids[i++] = item.ID; + return ids; + } + + /// + /// Add a new item to the list + /// + /// + /// + public EventRetract AddRetract(string id) + { + EventRetract item = CreateChildElement(); + item.ID = id; + return item; + } + + /// + /// A configuration event + /// + public override PubSubCommandType CommandType + { + get { return PubSubCommandType.items; } + } + } + + /// + /// New node configuration + /// + [SVN(@"$Id$")] + public class EventConfiguration : PubSubCommand + { + /// + /// Create for outbound. + /// + /// + public EventConfiguration(XmlDocument doc) + : base("configuration", URI.PUBSUB_EVENT, doc) + { + } + + /// + /// Create for inbound + /// + /// + /// + /// + public EventConfiguration(string prefix, XmlQualifiedName qname, XmlDocument doc) + : base(prefix, qname, doc) + { + } + + /// + /// A configuration event + /// + public override PubSubCommandType CommandType + { + get { return PubSubCommandType.configuration; } + } + + /// + /// An x:data form that describes the new configuration + /// + public jabber.protocol.x.Data MetaData + { + get { return GetChildElement(); } + set { ReplaceChild(value); } + } + } + + /// + /// All of the items in a node have been deleted. + /// + [SVN(@"$Id$")] + public class EventPurge : PubSubCommand + { + /// + /// Create for outbound. + /// + /// + public EventPurge(XmlDocument doc) + : base("purge", URI.PUBSUB_EVENT, doc) + { + } + + /// + /// Create for inbound + /// + /// + /// + /// + public EventPurge(string prefix, XmlQualifiedName qname, XmlDocument doc) + : base(prefix, qname, doc) + { + } + + /// + /// A purge event + /// + public override PubSubCommandType CommandType + { + get { return PubSubCommandType.purge; } + } + } + + /// + /// Subscription state has changed + /// + [SVN(@"$Id$")] + public class EventSubscription : PubSubCommand + { + /// + /// Create for outbound. + /// + /// + public EventSubscription(XmlDocument doc) + : base("subscription", URI.PUBSUB_EVENT, doc) + { + } + + /// + /// Create for inbound + /// + /// + /// + /// + public EventSubscription(string prefix, XmlQualifiedName qname, XmlDocument doc) + : base(prefix, qname, doc) + { + } + + /// + /// A subscription event + /// + public override PubSubCommandType CommandType + { + get { return PubSubCommandType.subscription; } + } + + /// + /// When does this subscription expire? DateTime.MIN_VALUE for none. + /// + public DateTime Expiry + { + get { return GetDateTimeAttr("expiry"); } + set { SetDateTimeAttr("expiry", value); } + } + + /// + /// The JID of the subscriber + /// + public JID JID + { + get { return GetAttr("jid"); } + set { SetAttr("jid", value); } + } + + /// + /// The ID of the subscription + /// + public string SubscriptionID + { + get { return GetAttr("subid"); } + set { SetAttr("subid", value); } + } + + /// + /// The subscription state + /// + public PubSubSubscriptionType Subscription + { + get { return GetEnumAttr("subscription"); } + set { SetEnumAttr("subscription", value); } + } + } +} diff -Nru smuxi-0.8/lib/jabber-net/jabber/protocol/iq/PubSubOwner.cs smuxi-0.8.9.1/lib/jabber-net/jabber/protocol/iq/PubSubOwner.cs --- smuxi-0.8/lib/jabber-net/jabber/protocol/iq/PubSubOwner.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/jabber-net/jabber/protocol/iq/PubSubOwner.cs 2012-01-03 07:52:11.000000000 +0000 @@ -0,0 +1,419 @@ +/* -------------------------------------------------------------------------- + * Copyrights + * + * Portions created by or assigned to Cursive Systems, Inc. are + * Copyright (c) 2002-2008 Cursive Systems, Inc. All Rights Reserved. Contact + * information for Cursive Systems, Inc. is available at + * http://www.cursive.net/. + * + * License + * + * Jabber-Net is licensed under the LGPL. + * See LICENSE.txt for details. + * --------------------------------------------------------------------------*/ +using System; +using System.Text; +using System.Xml; + +using bedrock.util; + +namespace jabber.protocol.iq +{ + /// + /// A type-safe PubSub IQ for owner actions. + /// + /// The type of command to create + [SVN(@"$Id$")] + public class OwnerPubSubCommandIQ : jabber.protocol.client.TypedIQ> + where T : PubSubCommand + { + /// + /// Create + /// + /// + public OwnerPubSubCommandIQ(XmlDocument doc) + : base(doc) + { + } + + /// + /// Create, with node + /// + /// + /// + public OwnerPubSubCommandIQ(XmlDocument doc, string node) + : base(doc) + { + Command.Node = node; + } + + /// + /// The command inside the pubsub element. + /// + public T Command + { + get { return Instruction.Command; } + set { Instruction.Command = value; } + } + } + + /// + /// A type-safe pubsub element. + /// + /// + [SVN(@"$Id$")] + public class OwnerPubSub : Element + where T : PubSubCommand + { + /// + /// Create + /// + /// + public OwnerPubSub(XmlDocument doc) + : base("pubsub", URI.PUBSUB_OWNER, doc) + { + CreateChildElement(); + } + + /// + /// The pubsub command + /// + public T Command + { + get { return GetChildElement(); } + set { ReplaceChild(value); } + } + + /// + /// The type of pubsub command + /// + public PubSubCommandType CommandType + { + get { return Command.CommandType; } + } + } + + /// + /// The pubsub container for owner operations. + /// + [SVN(@"$Id$")] + public class PubSubOwner : Element + { + /// + /// Create for outbound. + /// + /// + public PubSubOwner(XmlDocument doc) + : base("pubsub", URI.PUBSUB_OWNER, doc) + { + } + + /// + /// Create for inbound + /// + /// + /// + /// + public PubSubOwner(string prefix, XmlQualifiedName qname, XmlDocument doc) + : base(prefix, qname, doc) + { + } + + /// + /// The command inside. + /// + public PubSubCommand Command + { + get { return GetChildElement(); } + } + + /// + /// The type of the included command + /// + public PubSubCommandType CommandType + { + get { return Command.CommandType; } + } + } + + /// + /// Affiliations of all folks associated with a node + /// + [SVN(@"$Id$")] + public class OwnerAffliliations : PubSubCommand + { + /// + /// Create for outbound. + /// + /// + public OwnerAffliliations(XmlDocument doc) + : base("affiliations", URI.PUBSUB_OWNER, doc) + { + } + + /// + /// Create for inbound + /// + /// + /// + /// + public OwnerAffliliations(string prefix, XmlQualifiedName qname, XmlDocument doc) + : base(prefix, qname, doc) + { + } + + /// + /// Affiliations command + /// + public override PubSubCommandType CommandType + { + get { return PubSubCommandType.affiliations; } + } + + /// + /// Retrieve all of the affiliations + /// + /// + public OwnerAffiliation[] GetAffiliations() + { + return GetElements().ToArray(); + } + + /// + /// Add a new affiliation to the list. + /// + /// + /// + /// + public OwnerAffiliation AddAffiliation(AffiliationType type, string node) + { + OwnerAffiliation afil = CreateChildElement(); + afil.Type = type; + afil.Node = node; + return afil; + } + } + + /// + /// An affiliation for another user, retrieved by the owner. + /// + [SVN(@"$Id$")] + public class OwnerAffiliation : Affiliation + { + /// + /// Create for outbound. + /// + /// + public OwnerAffiliation(XmlDocument doc) + : base(doc, URI.PUBSUB_OWNER) + { + } + + /// + /// Create for inbound + /// + /// + /// + /// + public OwnerAffiliation(string prefix, XmlQualifiedName qname, XmlDocument doc) + : base(prefix, qname, doc) + { + } + + /// + /// The JID of the affiliate. + /// + public JID JID + { + get { return GetAttr("jid"); } + set { SetAttr("jid", value); } + } + } + + /// + /// Owner-level configuration + /// + [SVN(@"$Id$")] + public class OwnerConfigure : PubSubCommand + { + /// + /// Create for outbound. + /// + /// + public OwnerConfigure(XmlDocument doc) + : base("configure", URI.PUBSUB_OWNER, doc) + { + } + + /// + /// Create for inbound + /// + /// + /// + /// + public OwnerConfigure(string prefix, XmlQualifiedName qname, XmlDocument doc) + : base(prefix, qname, doc) + { + } + + /// + /// Configure + /// + public override PubSubCommandType CommandType + { + get { return PubSubCommandType.configure; } + } + + /// + /// An x:data form that describes the node + /// + public jabber.protocol.x.Data MetaData + { + get { return GetChildElement(); } + set { ReplaceChild(value); } + } + } + + /// + /// The default configuration parameters + /// + [SVN(@"$Id$")] + public class OwnerDefault : PubSubCommand + { + /// + /// Create for outbound. + /// + /// + public OwnerDefault(XmlDocument doc) + : base("default", URI.PUBSUB_OWNER, doc) + { + } + + /// + /// Create for inbound + /// + /// + /// + /// + public OwnerDefault(string prefix, XmlQualifiedName qname, XmlDocument doc) + : base(prefix, qname, doc) + { + } + + /// + /// Configure + /// + public override PubSubCommandType CommandType + { + get { return PubSubCommandType.defaults; } + } + + /// + /// An x:data form that describes the node + /// + public jabber.protocol.x.Data MetaData + { + get { return GetChildElement(); } + set { ReplaceChild(value); } + } + } + + /// + /// Delete a node + /// + [SVN(@"$Id$")] + public class OwnerDelete : PubSubCommand + { + /// + /// Create for outbound. + /// + /// + public OwnerDelete(XmlDocument doc) + : base("delete", URI.PUBSUB_OWNER, doc) + { + } + + /// + /// Create for inbound + /// + /// + /// + /// + public OwnerDelete(string prefix, XmlQualifiedName qname, XmlDocument doc) + : base(prefix, qname, doc) + { + } + + /// + /// Delete + /// + public override PubSubCommandType CommandType + { + get { return PubSubCommandType.delete; } + } + } + + /// + /// Purge all items from a node + /// + [SVN(@"$Id$")] + public class OwnerPurge : PubSubCommand + { + /// + /// Create for outbound. + /// + /// + public OwnerPurge(XmlDocument doc) + : base("purge", URI.PUBSUB_OWNER, doc) + { + } + + /// + /// Create for inbound + /// + /// + /// + /// + public OwnerPurge(string prefix, XmlQualifiedName qname, XmlDocument doc) + : base(prefix, qname, doc) + { + } + + /// + /// Purge + /// + public override PubSubCommandType CommandType + { + get { return PubSubCommandType.purge; } + } + } + + /// + /// The subscription list + /// + [SVN(@"$Id$")] + public class OwnerSubscriptions : Subscriptions + { + /// + /// Create for outbound. + /// + /// + public OwnerSubscriptions(XmlDocument doc) + : base(doc, URI.PUBSUB_OWNER) + { + } + + /// + /// Create for inbound + /// + /// + /// + /// + public OwnerSubscriptions(string prefix, XmlQualifiedName qname, XmlDocument doc) + : base(prefix, qname, doc) + { + } + } + +} + \ No newline at end of file diff -Nru smuxi-0.8/lib/jabber-net/jabber/protocol/iq/Register.cs smuxi-0.8.9.1/lib/jabber-net/jabber/protocol/iq/Register.cs --- smuxi-0.8/lib/jabber-net/jabber/protocol/iq/Register.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/jabber-net/jabber/protocol/iq/Register.cs 2012-01-03 07:52:11.000000000 +0000 @@ -0,0 +1,278 @@ +/* -------------------------------------------------------------------------- + * Copyrights + * + * Portions created by or assigned to Cursive Systems, Inc. are + * Copyright (c) 2002-2008 Cursive Systems, Inc. All Rights Reserved. Contact + * information for Cursive Systems, Inc. is available at + * http://www.cursive.net/. + * + * License + * + * Jabber-Net is licensed under the LGPL. + * See LICENSE.txt for details. + * --------------------------------------------------------------------------*/ +using System; + +using System.Xml; + +using bedrock.util; + +namespace jabber.protocol.iq +{ + + /// + /// IQ packet with a register query element inside. + /// + [SVN(@"$Id$")] + public class RegisterIQ : jabber.protocol.client.TypedIQ + { + /// + /// Create a Register IQ. + /// + /// + public RegisterIQ(XmlDocument doc) : base(doc) + { + } + } + + /// + /// User registration + /// + [SVN(@"$Id$")] + public class Register : Element + { + /// + /// + /// + /// + public Register(XmlDocument doc) : + base("query", URI.REGISTER, doc) + { + } + + /// + /// + /// + /// + /// + /// + public Register(string prefix, XmlQualifiedName qname, XmlDocument doc) : + base(prefix, qname, doc) + { + } + + /// + /// Instructions to the user. + /// + public string Instructions + { + get { return GetElem("instructions"); } + set { SetElem("instructions", value); } + } + + /// + /// Username to register + /// + public string Username + { + get { return GetElem("username"); } + set { SetElem("username", value); } + } + + /// + /// User nickname + /// + public string Nick + { + get { return GetElem("nick"); } + set { SetElem("nick", value); } + } + + /// + /// User password + /// + public string Password + { + get { return GetElem("password"); } + set { SetElem("password", value); } + } + + /// + /// The name element.... what's this for? + /// + public string JName + { + get { return GetElem("name"); } + set { SetElem("name", value); } + } + + /// + /// The first name + /// + public string First + { + get { return GetElem("first"); } + set { SetElem("first", value); } + } + + /// + /// Last name + /// + public string Last + { + get { return GetElem("last"); } + set { SetElem("last", value); } + } + + /// + /// E-mail address + /// TODO: add format checking? + /// + public string Email + { + get { return GetElem("email"); } + set { SetElem("email", value); } + } + + /// + /// User's mailing address + /// + public string Address + { + get { return GetElem("address"); } + set { SetElem("address", value); } + } + + /// + /// User's city + /// + public string City + { + get { return GetElem("city"); } + set { SetElem("city", value); } + } + + /// + /// User's state + /// + public string State + { + get { return GetElem("state"); } + set { SetElem("state", value); } + } + + /// + /// User's zip code + /// + public string Zip + { + get { return GetElem("zip"); } + set { SetElem("zip", value); } + } + + /// + /// User's phone number + /// + public string Phone + { + get { return GetElem("phone"); } + set { SetElem("phone", value); } + } + + /// + /// URL for user + /// + public string Url + { + get { return GetElem("url"); } + set { SetElem("url", value); } + } + + /// + /// Current date + /// + public string Date + { + get { return GetElem("date"); } + set { SetElem("date", value); } + } + + /// + /// Miscellaneous information + /// + public string Misc + { + get { return GetElem("misc"); } + set { SetElem("misc", value); } + } + + /// + /// Text... what is this used for? + /// + public string Text + { + get { return GetElem("text"); } + set { SetElem("text", value); } + } + + /// + /// Public key? + /// + public string Key + { + get { return GetElem("key"); } + set { SetElem("key", value); } + } + + /// + /// Is the user already registered? + /// + public bool Registered + { + get { return (this["registered"] != null); } + set + { + if (value) + { + SetElem("registered", null); + } + else + { + XmlNode child = this["registered"]; + if (child != null) + RemoveChild(child); + } + } + } + + /// + /// Remove the current user. + /// + public bool Remove + { + get { return GetElem("remove") != null; } + set + { + if (value) + { + SetElem("remove", null); + } + else + { + XmlNode child = this["remove"]; + if (child != null) + RemoveChild(child); + } + } + } + + /// + /// The x:data form for the registration request. Null if none specified. + /// + public jabber.protocol.x.Data Form + { + get { return GetChildElement(); } + set { ReplaceChild (value); } + } + } +} diff -Nru smuxi-0.8/lib/jabber-net/jabber/protocol/iq/Roster.cs smuxi-0.8.9.1/lib/jabber-net/jabber/protocol/iq/Roster.cs --- smuxi-0.8/lib/jabber-net/jabber/protocol/iq/Roster.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/jabber-net/jabber/protocol/iq/Roster.cs 2012-01-03 07:52:11.000000000 +0000 @@ -0,0 +1,300 @@ +/* -------------------------------------------------------------------------- + * Copyrights + * + * Portions created by or assigned to Cursive Systems, Inc. are + * Copyright (c) 2002-2008 Cursive Systems, Inc. All Rights Reserved. Contact + * information for Cursive Systems, Inc. is available at + * http://www.cursive.net/. + * + * License + * + * Jabber-Net is licensed under the LGPL. + * See LICENSE.txt for details. + * --------------------------------------------------------------------------*/ +using System; + +using System.Xml; + +using bedrock.util; + +namespace jabber.protocol.iq +{ + /// + /// IQ packet with a roster query element inside. + /// + [SVN(@"$Id$")] + public class RosterIQ : jabber.protocol.client.TypedIQ + { + /// + /// Create a roster IQ. + /// + /// + public RosterIQ(XmlDocument doc) : base(doc) + { + } + } + + /// + /// A roster query element. + /// + [SVN(@"$Id$")] + public class Roster : Element + { + /// + /// + /// + /// + public Roster(XmlDocument doc) : base("query", URI.ROSTER, doc) + { + } + + /// + /// + /// + /// + /// + /// + public Roster(string prefix, XmlQualifiedName qname, XmlDocument doc) : + base(prefix, qname, doc) + { + } + + /// + /// Add a roster item + /// + /// + public Item AddItem() + { + return CreateChildElement(); + } + + /// + /// List of roster items + /// + /// + public Item[] GetItems() + { + return GetElements().ToArray(); + } + } + + /// + /// The current status of the subscription related to this item. + /// + [SVN(@"$Id$")] + public enum Subscription + { + /// + /// No subscription state has been specified. + /// + UNSPECIFIED = -1, + /// + /// Subscription to this person. They are a lurkee. + /// + to, + /// + /// Subscription from this person. They are a lurker. + /// + from, + /// + /// subscriptions in both ways. + /// + both, + /// + /// No subscription yet. Often an Ask on this item. + /// + none, + /// + /// Remove this subscription from the local roster. + /// + remove, + } + + /// + /// An optional attribute specifying the current status of a request to this contact. + /// + [SVN(@"$Id$")] + public enum Ask + { + /// + /// No Ask specified. + /// + NONE = -1, + /// + /// this entity is asking to subscribe to that contact's presence + /// + subscribe, + /// + /// this entity is asking unsubscribe from that contact's presence + /// + unsubscribe + } + + /// + /// Roster items. + /// + [SVN(@"$Id$")] + public class Item : Element + { + /// + /// + /// + /// + public Item(XmlDocument doc) : base("item", URI.ROSTER, doc) + { + } + + /// + /// + /// + /// + /// + /// + public Item(string prefix, XmlQualifiedName qname, XmlDocument doc) : + base(prefix, qname, doc) + { + } + + /// + /// Item JID + /// + public JID JID + { + get { return GetAttr("jid"); } + set { this.SetAttr("jid", value); } + } + + /// + /// The user's nick + /// + public string Nickname + { + get { return GetAttr("name"); } + set { SetAttr("name", value); } + } + + /// + /// How are we subscribed? + /// + public Subscription Subscription + { + get { return GetEnumAttr("subscription"); } + set { SetEnumAttr("subscription", value); } + } + + /// + /// Pending? + /// + public Ask Ask + { + get { return GetEnumAttr("ask"); } + set { SetEnumAttr("ask", value); } + } + + /// + /// Add an item group, or return an existing group with the given name + /// + /// + public Group AddGroup(string name) + { + Group g = GetGroup(name); + if (g == null) + { + g = CreateChildElement(); + g.GroupName = name; + } + return g; + } + + /// + /// Remove a group of the given name. Does nothing if that group is not found. + /// + /// + public void RemoveGroup(string name) + { + foreach (Group g in GetElements()) + { + if (g.GroupName == name) + { + this.RemoveChild(g); + return; + } + } + } + + /// + /// List of item groups + /// + /// + public Group[] GetGroups() + { + return GetElements().ToArray(); + } + + /// + /// Is this item in the specified group? + /// + /// The name of the group to check + /// + public bool HasGroup(string name) + { + foreach (Group g in GetElements()) + { + if (g.GroupName == name) + return true; + } + return false; + } + + /// + /// Get the group object of the given name in this item. + /// If there is no group of that name, returns null. + /// + /// The name of the group to return + /// null if none found. + public Group GetGroup(string name) + { + foreach (Group g in GetElements()) + { + if (g.GroupName == name) + return g; + } + return null; + } + } + + /// + /// Roster item groups. <group>GroupName</group> + /// + [SVN(@"$Id$")] + public class Group : Element + { + /// + /// + /// + /// + public Group(XmlDocument doc) : base("group", URI.ROSTER, doc) + { + } + + /// + /// + /// + /// + /// + /// + public Group(string prefix, XmlQualifiedName qname, XmlDocument doc) : + base(prefix, qname, doc) + { + } + + /// + /// Name of the group. + /// + public string GroupName + { + get { return this.InnerText; } + set { this.InnerText = value; } + } + } +} diff -Nru smuxi-0.8/lib/jabber-net/jabber/protocol/iq/Time.cs smuxi-0.8.9.1/lib/jabber-net/jabber/protocol/iq/Time.cs --- smuxi-0.8/lib/jabber-net/jabber/protocol/iq/Time.cs 1970-01-01 00:00:00.000000000 +0000 +++ smuxi-0.8.9.1/lib/jabber-net/jabber/protocol/iq/Time.cs 2012-01-03 07:52:11.000000000 +0000 @@ -0,0 +1,113 @@ +/* -------------------------------------------------------------------------- + * Copyrights + * + * Portions created by or assigned to Cursive Systems, Inc. are + * Copyright (c) 2002-2008 Cursive Systems, Inc. All Rights Reserved. Contact + * information for Cursive Systems, Inc. is available at + * http://www.cursive.net/. + * + * License + * + * Jabber-Net is licensed under the LGPL. + * See LICENSE.txt for details. + * --------------------------------------------------------------------------*/ +using System; + +using System.Xml; + +using bedrock.util; + +namespace jabber.protocol.iq +{ + /* + * + * + * 20020214T23:55:06 + * WET + * 14 Feb 2002 11:55:06 PM + * + * + */ + /// + /// IQ packet with an time query element inside. + /// + [SVN(@"$Id$")] + public class TimeIQ : jabber.protocol.client.TypedIQ