diff options
Diffstat (limited to 'debian/opensync/opensync-0.22/osengine')
23 files changed, 0 insertions, 5245 deletions
diff --git a/debian/opensync/opensync-0.22/osengine/Makefile.am b/debian/opensync/opensync-0.22/osengine/Makefile.am deleted file mode 100755 index 115a428a..00000000 --- a/debian/opensync/opensync-0.22/osengine/Makefile.am +++ /dev/null @@ -1,47 +0,0 @@ -## Process this file with automake to produce Makefile.in - -AM_CFLAGS = -Werror -Wall @GCOV_CFLAGS@ @XML_CFLAGS@ - -INCLUDES = -I$(top_srcdir) @PACKAGE_CFLAGS@ - -if BUILD_ENGINE -lib_LTLIBRARIES = libosengine.la -endif - -if BUILD_ENGINE -osengineincludedir = @OPENSYNC_ENGINEHEADERDIR@ -osengineinclude_HEADERS = \ - engine.h \ - osengine_mapping.h \ - osengine_engine.h \ - osengine_status.h \ - osengine_debug.h -endif - -libosengine_la_SOURCES = \ - osengine_client.c \ - osengine_engine.c \ - osengine_status.c \ - osengine_debug.c \ - osengine_mapping.c \ - osengine_mapcmds.c \ - osengine_deciders.c \ - osengine_flags.c - -EXTRA_DIST = \ - engine_internals.h \ - osengine_client_internals.h \ - osengine_engine_internals.h \ - osengine_flags_internals.h \ - osengine_mapping_internals.h \ - osengine_mapcmds_internals.h \ - osengine_deciders_internals.h \ - osengine_debug_internals.h - -CLEANFILES = \ - *.bb \ - *.bbg \ - *.da - -libosengine_la_LDFLAGS = $(PACKAGE_LIBS) -R $(libdir) @GCOV_LDFLAGS@ -libosengine_la_LIBADD = $(top_builddir)/opensync/libopensync.la diff --git a/debian/opensync/opensync-0.22/osengine/Makefile.in b/debian/opensync/opensync-0.22/osengine/Makefile.in deleted file mode 100644 index 4474986f..00000000 --- a/debian/opensync/opensync-0.22/osengine/Makefile.in +++ /dev/null @@ -1,577 +0,0 @@ -# Makefile.in generated by automake 1.9.6 from Makefile.am. -# @configure_input@ - -# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, -# 2003, 2004, 2005 Free Software Foundation, Inc. -# This Makefile.in is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY, to the extent permitted by law; without -# even the implied warranty of MERCHANTABILITY or FITNESS FOR A -# PARTICULAR PURPOSE. - -@SET_MAKE@ - - -srcdir = @srcdir@ -top_srcdir = @top_srcdir@ -VPATH = @srcdir@ -pkgdatadir = $(datadir)/@PACKAGE@ -pkglibdir = $(libdir)/@PACKAGE@ -pkgincludedir = $(includedir)/@PACKAGE@ -top_builddir = .. -am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd -INSTALL = @INSTALL@ -install_sh_DATA = $(install_sh) -c -m 644 -install_sh_PROGRAM = $(install_sh) -c -install_sh_SCRIPT = $(install_sh) -c -INSTALL_HEADER = $(INSTALL_DATA) -transform = $(program_transform_name) -NORMAL_INSTALL = : -PRE_INSTALL = : -POST_INSTALL = : -NORMAL_UNINSTALL = : -PRE_UNINSTALL = : -POST_UNINSTALL = : -build_triplet = @build@ -host_triplet = @host@ -subdir = osengine -DIST_COMMON = $(am__osengineinclude_HEADERS_DIST) \ - $(srcdir)/Makefile.am $(srcdir)/Makefile.in -ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \ - $(top_srcdir)/configure.in -am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ - $(ACLOCAL_M4) -mkinstalldirs = $(install_sh) -d -CONFIG_HEADER = $(top_builddir)/config.h -CONFIG_CLEAN_FILES = -am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; -am__vpath_adj = case $$p in \ - $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ - *) f=$$p;; \ - esac; -am__strip_dir = `echo $$p | sed -e 's|^.*/||'`; -am__installdirs = "$(DESTDIR)$(libdir)" \ - "$(DESTDIR)$(osengineincludedir)" -libLTLIBRARIES_INSTALL = $(INSTALL) -LTLIBRARIES = $(lib_LTLIBRARIES) -libosengine_la_DEPENDENCIES = $(top_builddir)/opensync/libopensync.la -am_libosengine_la_OBJECTS = osengine_client.lo osengine_engine.lo \ - osengine_status.lo osengine_debug.lo osengine_mapping.lo \ - osengine_mapcmds.lo osengine_deciders.lo osengine_flags.lo -libosengine_la_OBJECTS = $(am_libosengine_la_OBJECTS) -@BUILD_ENGINE_TRUE@am_libosengine_la_rpath = -rpath $(libdir) -DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir) -depcomp = $(SHELL) $(top_srcdir)/depcomp -am__depfiles_maybe = depfiles -COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ - $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -LTCOMPILE = $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) \ - $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ - $(AM_CFLAGS) $(CFLAGS) -CCLD = $(CC) -LINK = $(LIBTOOL) --tag=CC --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ - $(AM_LDFLAGS) $(LDFLAGS) -o $@ -SOURCES = $(libosengine_la_SOURCES) -DIST_SOURCES = $(libosengine_la_SOURCES) -am__osengineinclude_HEADERS_DIST = engine.h osengine_mapping.h \ - osengine_engine.h osengine_status.h osengine_debug.h -osengineincludeHEADERS_INSTALL = $(INSTALL_HEADER) -HEADERS = $(osengineinclude_HEADERS) -ETAGS = etags -CTAGS = ctags -DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) -ACLOCAL = @ACLOCAL@ -AMDEP_FALSE = @AMDEP_FALSE@ -AMDEP_TRUE = @AMDEP_TRUE@ -AMTAR = @AMTAR@ -AR = @AR@ -AUTOCONF = @AUTOCONF@ -AUTOHEADER = @AUTOHEADER@ -AUTOMAKE = @AUTOMAKE@ -AWK = @AWK@ -BUILD_ENGINE = @BUILD_ENGINE@ -BUILD_ENGINE_FALSE = @BUILD_ENGINE_FALSE@ -BUILD_ENGINE_TRUE = @BUILD_ENGINE_TRUE@ -CC = @CC@ -CCDEPMODE = @CCDEPMODE@ -CFLAGS = @CFLAGS@ -CHECK_CFLAGS = @CHECK_CFLAGS@ -CHECK_LIBS = @CHECK_LIBS@ -CPP = @CPP@ -CPPFLAGS = @CPPFLAGS@ -CXX = @CXX@ -CXXCPP = @CXXCPP@ -CXXDEPMODE = @CXXDEPMODE@ -CXXFLAGS = @CXXFLAGS@ -CYGPATH_W = @CYGPATH_W@ -DEFS = @DEFS@ -DEPDIR = @DEPDIR@ -ECHO = @ECHO@ -ECHO_C = @ECHO_C@ -ECHO_N = @ECHO_N@ -ECHO_T = @ECHO_T@ -EGREP = @EGREP@ -ENABLE_DEBUG = @ENABLE_DEBUG@ -ENABLE_PROF_FALSE = @ENABLE_PROF_FALSE@ -ENABLE_PROF_TRUE = @ENABLE_PROF_TRUE@ -ENABLE_TESTS_FALSE = @ENABLE_TESTS_FALSE@ -ENABLE_TESTS_TRUE = @ENABLE_TESTS_TRUE@ -ENABLE_TOOLS_FALSE = @ENABLE_TOOLS_FALSE@ -ENABLE_TOOLS_TRUE = @ENABLE_TOOLS_TRUE@ -ENABLE_TRACE = @ENABLE_TRACE@ -EXEEXT = @EXEEXT@ -F77 = @F77@ -FFLAGS = @FFLAGS@ -GCOV_CFLAGS = @GCOV_CFLAGS@ -GCOV_LDFLAGS = @GCOV_LDFLAGS@ -GREP = @GREP@ -HAVE_PYTHON_FALSE = @HAVE_PYTHON_FALSE@ -HAVE_PYTHON_TRUE = @HAVE_PYTHON_TRUE@ -INSTALL_DATA = @INSTALL_DATA@ -INSTALL_PROGRAM = @INSTALL_PROGRAM@ -INSTALL_SCRIPT = @INSTALL_SCRIPT@ -INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ -LDFLAGS = @LDFLAGS@ -LIBOBJS = @LIBOBJS@ -LIBS = @LIBS@ -LIBTOOL = @LIBTOOL@ -LN_S = @LN_S@ -LTLIBOBJS = @LTLIBOBJS@ -MAKEINFO = @MAKEINFO@ -OBJEXT = @OBJEXT@ -OPENSYNC_CONFIGDIR = @OPENSYNC_CONFIGDIR@ -OPENSYNC_ENGINEHEADERDIR = @OPENSYNC_ENGINEHEADERDIR@ -OPENSYNC_FORMATSDIR = @OPENSYNC_FORMATSDIR@ -OPENSYNC_HEADERDIR = @OPENSYNC_HEADERDIR@ -OPENSYNC_PLUGINDIR = @OPENSYNC_PLUGINDIR@ -OSPLUGIN = @OSPLUGIN@ -PACKAGE = @PACKAGE@ -PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ -PACKAGE_CFLAGS = @PACKAGE_CFLAGS@ -PACKAGE_LIBS = @PACKAGE_LIBS@ -PACKAGE_NAME = @PACKAGE_NAME@ -PACKAGE_STRING = @PACKAGE_STRING@ -PACKAGE_TARNAME = @PACKAGE_TARNAME@ -PACKAGE_VERSION = @PACKAGE_VERSION@ -PATH_SEPARATOR = @PATH_SEPARATOR@ -PKG_CONFIG = @PKG_CONFIG@ -PYTHON = @PYTHON@ -PYTHON_CPPFLAGS = @PYTHON_CPPFLAGS@ -PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ -PYTHON_EXTRA_LIBS = @PYTHON_EXTRA_LIBS@ -PYTHON_INCLUDES = @PYTHON_INCLUDES@ -PYTHON_LDFLAGS = @PYTHON_LDFLAGS@ -PYTHON_PLATFORM = @PYTHON_PLATFORM@ -PYTHON_PREFIX = @PYTHON_PREFIX@ -PYTHON_SITE_PKG = @PYTHON_SITE_PKG@ -PYTHON_VERSION = @PYTHON_VERSION@ -RANLIB = @RANLIB@ -SET_MAKE = @SET_MAKE@ -SHELL = @SHELL@ -STRIP = @STRIP@ -SWIG = @SWIG@ -SWIG_LIB = @SWIG_LIB@ -SWIG_PYTHON_CPPFLAGS = @SWIG_PYTHON_CPPFLAGS@ -SWIG_PYTHON_OPT = @SWIG_PYTHON_OPT@ -VERSION = @VERSION@ -XML_CFLAGS = @XML_CFLAGS@ -XML_LIBS = @XML_LIBS@ -YACC = @YACC@ -YFLAGS = @YFLAGS@ -ac_ct_CC = @ac_ct_CC@ -ac_ct_CXX = @ac_ct_CXX@ -ac_ct_F77 = @ac_ct_F77@ -ac_workaround_abs_builddir = @ac_workaround_abs_builddir@ -ac_workaround_abs_srcdir = @ac_workaround_abs_srcdir@ -am__fastdepCC_FALSE = @am__fastdepCC_FALSE@ -am__fastdepCC_TRUE = @am__fastdepCC_TRUE@ -am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@ -am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@ -am__include = @am__include@ -am__leading_dot = @am__leading_dot@ -am__quote = @am__quote@ -am__tar = @am__tar@ -am__untar = @am__untar@ -bindir = @bindir@ -build = @build@ -build_alias = @build_alias@ -build_cpu = @build_cpu@ -build_os = @build_os@ -build_vendor = @build_vendor@ -datadir = @datadir@ -datarootdir = @datarootdir@ -docdir = @docdir@ -dvidir = @dvidir@ -exec_prefix = @exec_prefix@ -host = @host@ -host_alias = @host_alias@ -host_cpu = @host_cpu@ -host_os = @host_os@ -host_vendor = @host_vendor@ -htmldir = @htmldir@ -includedir = @includedir@ -infodir = @infodir@ -install_sh = @install_sh@ -libdir = @libdir@ -libexecdir = @libexecdir@ -localedir = @localedir@ -localstatedir = @localstatedir@ -mandir = @mandir@ -mkdir_p = @mkdir_p@ -oldincludedir = @oldincludedir@ -pdfdir = @pdfdir@ -pkgpyexecdir = @pkgpyexecdir@ -pkgpythondir = @pkgpythondir@ -prefix = @prefix@ -program_transform_name = @program_transform_name@ -psdir = @psdir@ -pyexecdir = @pyexecdir@ -pythondir = @pythondir@ -sbindir = @sbindir@ -sharedstatedir = @sharedstatedir@ -sysconfdir = @sysconfdir@ -target_alias = @target_alias@ -AM_CFLAGS = -Werror -Wall @GCOV_CFLAGS@ @XML_CFLAGS@ -INCLUDES = -I$(top_srcdir) @PACKAGE_CFLAGS@ -@BUILD_ENGINE_TRUE@lib_LTLIBRARIES = libosengine.la -@BUILD_ENGINE_TRUE@osengineincludedir = @OPENSYNC_ENGINEHEADERDIR@ -@BUILD_ENGINE_TRUE@osengineinclude_HEADERS = \ -@BUILD_ENGINE_TRUE@ engine.h \ -@BUILD_ENGINE_TRUE@ osengine_mapping.h \ -@BUILD_ENGINE_TRUE@ osengine_engine.h \ -@BUILD_ENGINE_TRUE@ osengine_status.h \ -@BUILD_ENGINE_TRUE@ osengine_debug.h - -libosengine_la_SOURCES = \ - osengine_client.c \ - osengine_engine.c \ - osengine_status.c \ - osengine_debug.c \ - osengine_mapping.c \ - osengine_mapcmds.c \ - osengine_deciders.c \ - osengine_flags.c - -EXTRA_DIST = \ - engine_internals.h \ - osengine_client_internals.h \ - osengine_engine_internals.h \ - osengine_flags_internals.h \ - osengine_mapping_internals.h \ - osengine_mapcmds_internals.h \ - osengine_deciders_internals.h \ - osengine_debug_internals.h - -CLEANFILES = \ - *.bb \ - *.bbg \ - *.da - -libosengine_la_LDFLAGS = $(PACKAGE_LIBS) -R $(libdir) @GCOV_LDFLAGS@ -libosengine_la_LIBADD = $(top_builddir)/opensync/libopensync.la -all: all-am - -.SUFFIXES: -.SUFFIXES: .c .lo .o .obj -$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) - @for dep in $?; do \ - case '$(am__configure_deps)' in \ - *$$dep*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ - && exit 0; \ - exit 1;; \ - esac; \ - done; \ - echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign osengine/Makefile'; \ - cd $(top_srcdir) && \ - $(AUTOMAKE) --foreign osengine/Makefile -.PRECIOUS: Makefile -Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status - @case '$?' in \ - *config.status*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ - *) \ - echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ - cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ - esac; - -$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh - -$(top_srcdir)/configure: $(am__configure_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(ACLOCAL_M4): $(am__aclocal_m4_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -install-libLTLIBRARIES: $(lib_LTLIBRARIES) - @$(NORMAL_INSTALL) - test -z "$(libdir)" || $(mkdir_p) "$(DESTDIR)$(libdir)" - @list='$(lib_LTLIBRARIES)'; for p in $$list; do \ - if test -f $$p; then \ - f=$(am__strip_dir) \ - echo " $(LIBTOOL) --mode=install $(libLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(libdir)/$$f'"; \ - $(LIBTOOL) --mode=install $(libLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(libdir)/$$f"; \ - else :; fi; \ - done - -uninstall-libLTLIBRARIES: - @$(NORMAL_UNINSTALL) - @set -x; list='$(lib_LTLIBRARIES)'; for p in $$list; do \ - p=$(am__strip_dir) \ - echo " $(LIBTOOL) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$p'"; \ - $(LIBTOOL) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$p"; \ - done - -clean-libLTLIBRARIES: - -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES) - @list='$(lib_LTLIBRARIES)'; for p in $$list; do \ - dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ - test "$$dir" != "$$p" || dir=.; \ - echo "rm -f \"$${dir}/so_locations\""; \ - rm -f "$${dir}/so_locations"; \ - done -libosengine.la: $(libosengine_la_OBJECTS) $(libosengine_la_DEPENDENCIES) - $(LINK) $(am_libosengine_la_rpath) $(libosengine_la_LDFLAGS) $(libosengine_la_OBJECTS) $(libosengine_la_LIBADD) $(LIBS) - -mostlyclean-compile: - -rm -f *.$(OBJEXT) - -distclean-compile: - -rm -f *.tab.c - -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/osengine_client.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/osengine_debug.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/osengine_deciders.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/osengine_engine.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/osengine_flags.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/osengine_mapcmds.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/osengine_mapping.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/osengine_status.Plo@am__quote@ - -.c.o: -@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \ -@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(COMPILE) -c $< - -.c.obj: -@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \ -@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` - -.c.lo: -@am__fastdepCC_TRUE@ if $(LTCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \ -@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Plo"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< - -mostlyclean-libtool: - -rm -f *.lo - -clean-libtool: - -rm -rf .libs _libs - -distclean-libtool: - -rm -f libtool -uninstall-info-am: -install-osengineincludeHEADERS: $(osengineinclude_HEADERS) - @$(NORMAL_INSTALL) - test -z "$(osengineincludedir)" || $(mkdir_p) "$(DESTDIR)$(osengineincludedir)" - @list='$(osengineinclude_HEADERS)'; for p in $$list; do \ - if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ - f=$(am__strip_dir) \ - echo " $(osengineincludeHEADERS_INSTALL) '$$d$$p' '$(DESTDIR)$(osengineincludedir)/$$f'"; \ - $(osengineincludeHEADERS_INSTALL) "$$d$$p" "$(DESTDIR)$(osengineincludedir)/$$f"; \ - done - -uninstall-osengineincludeHEADERS: - @$(NORMAL_UNINSTALL) - @list='$(osengineinclude_HEADERS)'; for p in $$list; do \ - f=$(am__strip_dir) \ - echo " rm -f '$(DESTDIR)$(osengineincludedir)/$$f'"; \ - rm -f "$(DESTDIR)$(osengineincludedir)/$$f"; \ - done - -ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) - list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) ' { files[$$0] = 1; } \ - END { for (i in files) print i; }'`; \ - mkid -fID $$unique -tags: TAGS - -TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ - $(TAGS_FILES) $(LISP) - tags=; \ - here=`pwd`; \ - list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) ' { files[$$0] = 1; } \ - END { for (i in files) print i; }'`; \ - if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ - test -n "$$unique" || unique=$$empty_fix; \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - $$tags $$unique; \ - fi -ctags: CTAGS -CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ - $(TAGS_FILES) $(LISP) - tags=; \ - here=`pwd`; \ - list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) ' { files[$$0] = 1; } \ - END { for (i in files) print i; }'`; \ - test -z "$(CTAGS_ARGS)$$tags$$unique" \ - || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ - $$tags $$unique - -GTAGS: - here=`$(am__cd) $(top_builddir) && pwd` \ - && cd $(top_srcdir) \ - && gtags -i $(GTAGS_ARGS) $$here - -distclean-tags: - -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags - -distdir: $(DISTFILES) - @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ - topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \ - list='$(DISTFILES)'; for file in $$list; do \ - case $$file in \ - $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \ - $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \ - esac; \ - if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ - dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ - if test "$$dir" != "$$file" && test "$$dir" != "."; then \ - dir="/$$dir"; \ - $(mkdir_p) "$(distdir)$$dir"; \ - else \ - dir=''; \ - fi; \ - if test -d $$d/$$file; then \ - if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ - cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ - fi; \ - cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ - else \ - test -f $(distdir)/$$file \ - || cp -p $$d/$$file $(distdir)/$$file \ - || exit 1; \ - fi; \ - done -check-am: all-am -check: check-am -all-am: Makefile $(LTLIBRARIES) $(HEADERS) -installdirs: - for dir in "$(DESTDIR)$(libdir)" "$(DESTDIR)$(osengineincludedir)"; do \ - test -z "$$dir" || $(mkdir_p) "$$dir"; \ - done -install: install-am -install-exec: install-exec-am -install-data: install-data-am -uninstall: uninstall-am - -install-am: all-am - @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am - -installcheck: installcheck-am -install-strip: - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - `test -z '$(STRIP)' || \ - echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install -mostlyclean-generic: - -clean-generic: - -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) - -distclean-generic: - -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) - -maintainer-clean-generic: - @echo "This command is intended for maintainers to use" - @echo "it deletes files that may require special tools to rebuild." -clean: clean-am - -clean-am: clean-generic clean-libLTLIBRARIES clean-libtool \ - mostlyclean-am - -distclean: distclean-am - -rm -rf ./$(DEPDIR) - -rm -f Makefile -distclean-am: clean-am distclean-compile distclean-generic \ - distclean-libtool distclean-tags - -dvi: dvi-am - -dvi-am: - -html: html-am - -info: info-am - -info-am: - -install-data-am: install-osengineincludeHEADERS - -install-exec-am: install-libLTLIBRARIES - -install-info: install-info-am - -install-man: - -installcheck-am: - -maintainer-clean: maintainer-clean-am - -rm -rf ./$(DEPDIR) - -rm -f Makefile -maintainer-clean-am: distclean-am maintainer-clean-generic - -mostlyclean: mostlyclean-am - -mostlyclean-am: mostlyclean-compile mostlyclean-generic \ - mostlyclean-libtool - -pdf: pdf-am - -pdf-am: - -ps: ps-am - -ps-am: - -uninstall-am: uninstall-info-am uninstall-libLTLIBRARIES \ - uninstall-osengineincludeHEADERS - -.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ - clean-libLTLIBRARIES clean-libtool ctags distclean \ - distclean-compile distclean-generic distclean-libtool \ - distclean-tags distdir dvi dvi-am html html-am info info-am \ - install install-am install-data install-data-am install-exec \ - install-exec-am install-info install-info-am \ - install-libLTLIBRARIES install-man \ - install-osengineincludeHEADERS install-strip installcheck \ - installcheck-am installdirs maintainer-clean \ - maintainer-clean-generic mostlyclean mostlyclean-compile \ - mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ - tags uninstall uninstall-am uninstall-info-am \ - uninstall-libLTLIBRARIES uninstall-osengineincludeHEADERS - -# Tell versions [3.59,3.63) of GNU make to not export all variables. -# Otherwise a system limit (for SysV at least) may be exceeded. -.NOEXPORT: diff --git a/debian/opensync/opensync-0.22/osengine/engine.h b/debian/opensync/opensync-0.22/osengine/engine.h deleted file mode 100644 index 30e7262a..00000000 --- a/debian/opensync/opensync-0.22/osengine/engine.h +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef HAVE_ENGINE_H -#define HAVE_ENGINE_H - -#include <opensync/opensync.h> - -#ifdef __cplusplus -extern "C" -{ -#endif - -/************************************************************** - * Structs - *************************************************************/ -typedef struct OSyncEngine OSyncEngine; -typedef struct OSyncClient OSyncClient; -typedef struct OSyncMapping OSyncMapping; - -/************************************************************** - * Includes - *************************************************************/ - -#include "osengine_status.h" -#include "osengine_engine.h" -#include "osengine_mapping.h" -#include "osengine_debug.h" - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/debian/opensync/opensync-0.22/osengine/engine_internals.h b/debian/opensync/opensync-0.22/osengine/engine_internals.h deleted file mode 100644 index d5a0b12f..00000000 --- a/debian/opensync/opensync-0.22/osengine/engine_internals.h +++ /dev/null @@ -1,24 +0,0 @@ -#include <stdlib.h> -#include <stdio.h> -#include <string.h> -#include <glib.h> - -#define segfault_me char **blablabla = NULL; *blablabla = "test"; - -typedef void (* OSyncFlagTriggerFunc) (gpointer user_data1, gpointer user_data2); - -typedef struct OSyncFlag OSyncFlag; -typedef struct OSyncMappingTable OSyncMappingTable; -typedef struct OSyncMappingView OSyncMappingView; -typedef struct OSyncMappingEntry OSyncMappingEntry; - -#include "opensync/opensync_message_internals.h" - -#include "osengine_deciders_internals.h" -#include "osengine_debug.h" -#include "osengine_flags_internals.h" -#include "osengine_engine_internals.h" -#include "osengine_mapping_internals.h" -#include "osengine_mapcmds_internals.h" -#include "osengine_client_internals.h" -#include "osengine_debug_internals.h" diff --git a/debian/opensync/opensync-0.22/osengine/osengine_client.c b/debian/opensync/opensync-0.22/osengine/osengine_client.c deleted file mode 100644 index 76b0b652..00000000 --- a/debian/opensync/opensync-0.22/osengine/osengine_client.c +++ /dev/null @@ -1,891 +0,0 @@ -/* - * libosengine - A synchronization engine for the opensync framework - * Copyright (C) 2004-2005 Armin Bauer <armin.bauer@opensync.org> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -#include "config.h" -#include "engine.h" -#include <glib.h> -#include <opensync/opensync_support.h> -#include "opensync/opensync_format_internals.h" -#include "opensync/opensync_member_internals.h" -#include "opensync/opensync_message_internals.h" -#include "opensync/opensync_queue_internals.h" - -#include "engine_internals.h" -#include <unistd.h> - -#include <sys/types.h> -#include <sys/wait.h> -#include <errno.h> -#include <signal.h> - -/*! @brief This function can be used to receive GET_ENTRY command replies - * - * See OSyncMessageHandler - * - */ -void _get_changes_reply_receiver(OSyncMessage *message, OSyncClient *sender) -{ - osync_trace(TRACE_ENTRY, "%s(%p, %p)", __func__, message, sender); - OSyncEngine *engine = sender->engine; - - if (osync_message_is_error(message)) { - OSyncError *error = NULL; - osync_demarshal_error(message, &error); - osync_error_duplicate(&engine->error, &error); - osync_debug("ENG", 1, "Get changes command reply was a error: %s", osync_error_print(&error)); - osync_status_update_member(engine, sender, MEMBER_GET_CHANGES_ERROR, &error); - osync_error_update(&engine->error, "Unable to read from one of the members"); - osync_flag_unset(sender->fl_sent_changes); - //osync_flag_set(sender->fl_finished); - osync_flag_set(sender->fl_done); - /* - * FIXME: For now we want to stop the engine if - * one of the member didnt connect yet. Later it should - * be that if >= 2 members connect, the sync should continue - */ - osync_flag_set(engine->fl_stop); - - } else { - osync_status_update_member(engine, sender, MEMBER_SENT_CHANGES, NULL); - osync_flag_set(sender->fl_sent_changes); - } - - osengine_client_decider(engine, sender); - osync_trace(TRACE_EXIT, "_get_changes_reply_receiver"); -} - -/*! @brief This function can be used to receive CONNECT command replies - * - * See OSyncMessageHandler - * - */ -void _connect_reply_receiver(OSyncMessage *message, OSyncClient *sender) -{ - osync_trace(TRACE_ENTRY, "_connect_reply_receiver(%p, %p)", message, sender); - - osync_trace(TRACE_INTERNAL, "connect reply %i", osync_message_is_error(message)); - OSyncEngine *engine = sender->engine; - - if (osync_message_is_error(message)) { - OSyncError *error = NULL; - osync_demarshal_error(message, &error); - osync_error_duplicate(&engine->error, &error); - osync_debug("ENG", 1, "Connect command reply was a error: %s", osync_error_print(&error)); - osync_status_update_member(engine, sender, MEMBER_CONNECT_ERROR, &error); - osync_error_update(&engine->error, "Unable to connect one of the members"); - osync_flag_unset(sender->fl_connected); - osync_flag_set(sender->fl_finished); - osync_flag_set(sender->fl_sent_changes); - osync_flag_set(sender->fl_done); - /* - * FIXME: For now we want to stop the engine if - * one of the member didnt connect yet. Later it should - * be that if >= 2 members connect, the sync should continue - */ - osync_flag_set(engine->fl_stop); - - } else { - osync_member_read_sink_info(sender->member, message); - - osync_status_update_member(engine, sender, MEMBER_CONNECTED, NULL); - osync_flag_set(sender->fl_connected); - } - - osengine_client_decider(engine, sender); - osync_trace(TRACE_EXIT, "_connect_reply_receiver"); -} - -void _sync_done_reply_receiver(OSyncMessage *message, OSyncClient *sender) -{ - osync_trace(TRACE_ENTRY, "_sync_done_reply_receiver(%p, %p)", message, sender); - - OSyncEngine *engine = sender->engine; - - if (osync_message_is_error(message)) { - OSyncError *error = NULL; - osync_demarshal_error(message, &error); - osync_error_duplicate(&engine->error, &error); - osync_debug("ENG", 1, "Sync done command reply was a error: %s", osync_error_print(&error)); - osync_status_update_member(engine, sender, MEMBER_SYNC_DONE_ERROR, &error); - osync_error_update(&engine->error, "Unable to finish the sync for one of the members"); - } - - osync_flag_set(sender->fl_done); - osengine_client_decider(engine, sender); - osync_trace(TRACE_EXIT, "_sync_done_reply_receiver"); -} - -void _committed_all_reply_receiver(OSyncMessage *message, OSyncClient *sender) -{ - osync_trace(TRACE_ENTRY, "%s(%p, %p)", __func__, message, sender); - - OSyncEngine *engine = sender->engine; - - if (osync_message_is_error(message)) { - OSyncError *error = NULL; - osync_demarshal_error(message, &error); - osync_error_duplicate(&engine->error, &error); - osync_debug("ENG", 1, "Committed all command reply was a error: %s", osync_error_print(&error)); - osync_status_update_member(engine, sender, MEMBER_COMMITTED_ALL_ERROR, &error); - osync_error_update(&engine->error, "Unable to write changes to one of the members"); - } else - osync_status_update_member(engine, sender, MEMBER_COMMITTED_ALL, NULL); - - osync_flag_set(sender->fl_committed_all); - osengine_client_decider(engine, sender); - osync_trace(TRACE_EXIT, "%s", __func__); -} - -void _disconnect_reply_receiver(OSyncMessage *message, OSyncClient *sender) -{ - osync_trace(TRACE_ENTRY, "_disconnect_reply_receiver(%p, %p)", message, sender); - - OSyncEngine *engine = sender->engine; - - if (osync_message_is_error(message)) { - OSyncError *error = NULL; - osync_demarshal_error(message, &error); - osync_debug("ENG", 1, "Sync done command reply was a error: %s", osync_error_print(&error)); - osync_status_update_member(engine, sender, MEMBER_DISCONNECT_ERROR, &error); - } else - osync_status_update_member(engine, sender, MEMBER_DISCONNECTED, NULL); - - osync_flag_unset(sender->fl_connected); - osync_flag_set(sender->fl_finished); - osengine_client_decider(engine, sender); - osync_trace(TRACE_EXIT, "_disconnect_reply_receiver"); -} - -void _get_change_data_reply_receiver(OSyncMessage *message, OSyncMappingEntry *entry) -{ - osync_trace(TRACE_ENTRY, "_get_change_data_reply_receiver(%p, %p, %p)", message, entry); - OSyncEngine *engine = entry->client->engine; - - if (osync_message_is_error(message)) { - OSyncError *error = NULL; - osync_demarshal_error(message, &error); - osync_error_duplicate(&engine->error, &error); - osync_debug("MAP", 1, "Commit change command reply was a error: %s", osync_error_print(&error)); - osync_status_update_change(engine, entry->change, CHANGE_RECV_ERROR, &error); - osync_error_update(&engine->error, "Unable to read one or more objects"); - - //FIXME Do we need to do anything here? - //osync_flag_unset(entry->fl_has_data); - } else { - - osync_demarshal_changedata(message, entry->change); - - osync_flag_set(entry->fl_has_data); - osync_status_update_change(engine, entry->change, CHANGE_RECEIVED, NULL); - } - - osync_change_save(entry->change, TRUE, NULL); - osengine_mappingentry_decider(engine, entry); - osync_trace(TRACE_EXIT, "_get_change_data_reply_receiver"); -} - -void _read_change_reply_receiver(OSyncClient *sender, OSyncMessage *message, OSyncEngine *engine) -{ - osync_trace(TRACE_ENTRY, "_read_change_reply_receiver(%p, %p, %p)", sender, message, engine); - - /*OSyncMappingEntry *entry = osync_message_get_data(message, "entry"); - - osync_flag_detach(entry->fl_read); - - osync_flag_unset(entry->mapping->fl_solved); - osync_flag_unset(entry->mapping->fl_chkconflict); - osync_flag_unset(entry->mapping->fl_multiplied); - - if (osync_change_get_changetype(entry->change) == CHANGE_DELETED) - osync_flag_set(entry->fl_deleted); - - osync_flag_set(entry->fl_has_info); - osync_flag_unset(entry->fl_synced); - - osync_change_save(entry->change, TRUE, NULL); - - osync_status_update_change(engine, entry->change, CHANGE_RECEIVED, NULL); - - osengine_mappingentry_decider(engine, entry);*/ - osync_trace(TRACE_EXIT, "_read_change_reply_receiver"); -} - -void _commit_change_reply_receiver(OSyncMessage *message, OSyncMappingEntry *entry) -{ - osync_trace(TRACE_ENTRY, "_commit_change_reply_receiver(%p, %p)", message, entry); - OSyncEngine *engine = entry->client->engine; - - if (osync_message_is_error(message)) { - OSyncError *error = NULL; - osync_demarshal_error(message, &error); - osync_error_duplicate(&engine->error, &error); - osync_debug("MAP", 1, "Commit change command reply was a error: %s", osync_error_print(&error)); - osync_status_update_change(engine, entry->change, CHANGE_WRITE_ERROR, &error); - OSyncError *maperror = NULL; - osync_error_duplicate(&maperror, &error); - osync_status_update_mapping(engine, entry->mapping, MAPPING_WRITE_ERROR, &maperror); - osync_error_update(&engine->error, "Unable to write one or more objects"); - - //FIXME Do we need to do anything here? - osync_flag_unset(entry->fl_dirty); - osync_flag_set(entry->fl_synced); - } else { - /* The plugin may have generated a new UID after committing the change. The commit - * change reply will return the new UID of the change - */ - - char *newuid; - osync_message_read_string(message, &newuid); - osync_change_set_uid(entry->change, newuid); - - osync_status_update_change(engine, entry->change, CHANGE_SENT, NULL); - osync_flag_unset(entry->fl_dirty); - osync_flag_set(entry->fl_synced); - } - - if (osync_change_get_changetype(entry->change) == CHANGE_DELETED) - osync_flag_set(entry->fl_deleted); - - osync_change_reset(entry->change); - - OSyncError *error = NULL; - osync_change_save(entry->change, TRUE, &error); - - osengine_mappingentry_decider(engine, entry); - osync_trace(TRACE_EXIT, "_commit_change_reply_receiver"); -} - -OSyncClient *osync_client_new(OSyncEngine *engine, OSyncMember *member, OSyncError **error) -{ - osync_trace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, engine, member, error); - OSyncClient *client = osync_try_malloc0(sizeof(OSyncClient), error); - if (!client) - goto error; - - client->member = member; - osync_member_set_data(member, client); - client->engine = engine; - engine->clients = g_list_append(engine->clients, client); - - char *name = g_strdup_printf("%s/pluginpipe", osync_member_get_configdir(member)); - client->commands_to_osplugin = osync_queue_new(name, error); - g_free(name); - - name = g_strdup_printf("%s/enginepipe", osync_member_get_configdir(member)); - client->commands_from_osplugin = osync_queue_new(name, error); - g_free(name); - - if (!client->commands_to_osplugin || !client->commands_from_osplugin) - goto error_free_client; - - client->fl_connected = osync_flag_new(engine->cmb_connected); - client->fl_sent_changes = osync_flag_new(engine->cmb_sent_changes); - client->fl_done = osync_flag_new(NULL); - client->fl_committed_all = osync_flag_new(engine->cmb_committed_all_sent); - client->fl_finished = osync_flag_new(engine->cmb_finished); - - osync_trace(TRACE_EXIT, "%s: %p", __func__, client); - return client; - -error_free_client: - g_free(client); -error: - osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(error)); - return NULL; -} - -void osync_client_reset(OSyncClient *client) -{ - osync_trace(TRACE_ENTRY, "%s(%p)", __func__, client); - osync_flag_set_state(client->fl_connected, FALSE); - osync_flag_set_state(client->fl_sent_changes, FALSE); - osync_flag_set_state(client->fl_done, FALSE); - osync_flag_set_state(client->fl_finished, FALSE); - osync_flag_set_state(client->fl_committed_all, FALSE); - osync_trace(TRACE_EXIT, "%s", __func__); -} - -void osync_client_free(OSyncClient *client) -{ - osync_trace(TRACE_ENTRY, "%s(%p)", __func__, client); - osync_queue_free(client->commands_to_osplugin); - osync_queue_free(client->commands_from_osplugin); - - osync_flag_free(client->fl_connected); - osync_flag_free(client->fl_sent_changes); - osync_flag_free(client->fl_done); - osync_flag_free(client->fl_finished); - osync_flag_free(client->fl_committed_all); - - g_free(client); - osync_trace(TRACE_EXIT, "%s", __func__); -} - -void *osync_client_message_sink(OSyncMember *member, const char *name, void *data, osync_bool synchronous) -{ - OSyncClient *client = osync_member_get_data(member); - OSyncEngine *engine = client->engine; - if (!synchronous) { - /*OSyncMessage *message = itm_message_new_signal(client, "PLUGIN_MESSAGE"); - osync_debug("CLI", 3, "Sending message %p PLUGIN_MESSAGE for message %s", message, name); - itm_message_set_data(message, "data", data); - itm_message_set_data(message, "name", g_strdup(name)); - itm_queue_send(engine->incoming, message);*/ - return NULL; - } else { - return engine->plgmsg_callback(engine, client, name, data, engine->plgmsg_userdata); - } -} - -OSyncPluginTimeouts osync_client_get_timeouts(OSyncClient *client) -{ - return osync_plugin_get_timeouts(osync_member_get_plugin(client->member)); -} - -void osync_client_call_plugin(OSyncClient *client, char *function, void *data, OSyncPluginReplyHandler replyhandler, void *userdata) -{ - osync_trace(TRACE_ENTRY, "%s(%p, %s, %p, %p, %p)", __func__, client, function, data, replyhandler, userdata); - - /*OSyncEngine *engine = client->engine; - ITMessage *message = itm_message_new_methodcall(engine, "CALL_PLUGIN"); - itm_message_set_data(message, "data", data); - itm_message_set_data(message, "function", g_strdup(function)); - - if (replyhandler) { - OSyncPluginCallContext *ctx = g_malloc0(sizeof(OSyncPluginCallContext)); - ctx->handler = replyhandler; - ctx->userdata = userdata; - itm_message_set_handler(message, engine->incoming, (ITMessageHandler)_recv_plugin_answer, ctx); - - itm_message_set_data(message, "want_reply", GINT_TO_POINTER(1)); - } else - itm_message_set_data(message, "want_reply", GINT_TO_POINTER(0)); - - itm_queue_send(client->incoming, message);*/ - - osync_trace(TRACE_EXIT, "%s", __func__); -} - -osync_bool osync_client_get_changes(OSyncClient *target, OSyncEngine *sender, OSyncError **error) -{ - osync_trace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, target, sender, error); - - osync_flag_changing(target->fl_sent_changes); - - OSyncMessage *message = osync_message_new(OSYNC_MESSAGE_GET_CHANGES, 0, error); - if (!message) - goto error; - - osync_message_set_handler(message, (OSyncMessageHandler)_get_changes_reply_receiver, target); - - osync_member_write_sink_info(target->member, message); - - OSyncPluginTimeouts timeouts = osync_client_get_timeouts(target); - if (!osync_queue_send_message_with_timeout(target->commands_to_osplugin, target->commands_from_osplugin, message, timeouts.get_changeinfo_timeout, error)) - goto error_free_message; - - osync_message_unref(message); - - osync_trace(TRACE_EXIT, "%s", __func__); - return TRUE; - -error_free_message: - osync_message_unref(message); -error: - osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(error)); - return FALSE; -} - -osync_bool osync_client_get_change_data(OSyncClient *target, OSyncEngine *sender, OSyncMappingEntry *entry, OSyncError **error) -{ - osync_flag_changing(entry->fl_has_data); - - OSyncMessage *message = osync_message_new(OSYNC_MESSAGE_GET_CHANGEDATA, 0, error); - if (!message) - goto error; - - osync_message_set_handler(message, (OSyncMessageHandler)_get_change_data_reply_receiver, entry); - - osync_marshal_change(message, entry->change); - - osync_debug("ENG", 3, "Sending get_changedata message %p to client %p", message, entry->client); - - OSyncPluginTimeouts timeouts = osync_client_get_timeouts(target); - if (!osync_queue_send_message_with_timeout(target->commands_to_osplugin, target->commands_from_osplugin, message, timeouts.get_data_timeout, error)) - goto error_free_message; - - osync_message_unref(message); - - osync_trace(TRACE_EXIT, "%s", __func__); - return TRUE; - -error_free_message: - osync_message_unref(message); -error: - osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(error)); - return FALSE; -} - -/*void osync_client_read_change(OSyncEngine *sender, OSyncMappingEntry *entry) -{ - //osync_flag_changing(entry->fl_has_data); - OSyncMessage *message = osync_message_new_methodcall(sender, "READ_CHANGE"); - osync_message_set_handler(message, sender->incoming, (OSyncMessageHandler)_read_change_reply_receiver, sender); - osync_message_set_data(message, "change", entry->change); - osync_message_set_data(message, "entry", entry); - osync_debug("ENG", 3, "Sending read_change message %p to client %p", message, entry->client); - - OSyncPluginTimeouts timeouts = osync_client_get_timeouts(entry->client); - osync_queue_send_with_timeout(entry->client->incoming, message, timeouts.read_change_timeout, sender); -}*/ - -osync_bool osync_client_connect(OSyncClient *target, OSyncEngine *sender, OSyncError **error) -{ - osync_trace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, target, sender, error); - - osync_flag_changing(target->fl_connected); - - OSyncMessage *message = osync_message_new(OSYNC_MESSAGE_CONNECT, 0, error); - if (!message) - goto error; - - osync_member_write_sink_info(target->member, message); - - osync_message_set_handler(message, (OSyncMessageHandler)_connect_reply_receiver, target); - - OSyncPluginTimeouts timeouts = osync_client_get_timeouts(target); - if (!osync_queue_send_message_with_timeout(target->commands_to_osplugin, target->commands_from_osplugin, message, timeouts.connect_timeout, error)) - goto error_free_message; - - osync_message_unref(message); - - osync_trace(TRACE_EXIT, "%s", __func__); - return TRUE; - -error_free_message: - osync_message_unref(message); -error: - osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(error)); - return FALSE; -} - -osync_bool osync_client_commit_change(OSyncClient *target, OSyncEngine *sender, OSyncMappingEntry *entry, OSyncError **error) -{ - osync_trace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, target, sender, entry); - osync_trace(TRACE_INTERNAL, "Committing change with uid %s, changetype %i, data %p, size %i, objtype %s and format %s from member %lli", osync_change_get_uid(entry->change), osync_change_get_changetype(entry->change), osync_change_get_data(entry->change), osync_change_get_datasize(entry->change), osync_change_get_objtype(entry->change) ? osync_objtype_get_name(osync_change_get_objtype(entry->change)) : "None", osync_change_get_objformat(entry->change) ? osync_objformat_get_name(osync_change_get_objformat(entry->change)) : "None", osync_member_get_id(entry->client->member)); - - osync_flag_changing(entry->fl_dirty); - - // convert the data to the format accepted by the member - if (!osync_change_convert_member_sink(osync_group_get_format_env(sender->group), entry->change, target->member, error)) - goto error; - - if (osync_change_get_changetype(entry->change) == CHANGE_ADDED) { - int elevated = 0; - // Generate a new UID, if necessary - OSyncMappingView *view = osengine_mappingtable_find_view(sender->maptable, target->member); - while (!osengine_mappingview_uid_is_unique(view, entry, TRUE)) { - if (!osync_change_elevate(sender, entry->change, 1)) - break; - elevated++; - } - - if (elevated) { - // Save the newly generated UID - if (!osync_change_save(entry->change, TRUE, error)) - goto error; - } - } - - OSyncMessage *message = osync_message_new(OSYNC_MESSAGE_COMMIT_CHANGE, 0, error); - if (!message) - goto error; - - osync_marshal_change(message, entry->change); - - osync_message_set_handler(message, (OSyncMessageHandler)_commit_change_reply_receiver, entry); - OSyncPluginTimeouts timeouts = osync_client_get_timeouts(entry->client); - - if (!osync_queue_send_message_with_timeout(target->commands_to_osplugin, target->commands_from_osplugin, message, timeouts.commit_timeout, error)) - goto error_free_message; - - osync_message_unref(message); - - g_assert(osync_flag_is_attached(entry->fl_committed) == TRUE); - osync_flag_detach(entry->fl_committed); - - osync_trace(TRACE_EXIT, "%s", __func__); - return TRUE; - -error_free_message: - osync_message_unref(message); -error: - osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(error)); - return FALSE; -} - -osync_bool osync_client_sync_done(OSyncClient *target, OSyncEngine *sender, OSyncError **error) -{ - osync_trace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, target, sender, error); - - osync_flag_changing(target->fl_done); - OSyncMessage *message = osync_message_new(OSYNC_MESSAGE_SYNC_DONE, 0, error); - if (!message) - goto error; - - osync_message_set_handler(message, (OSyncMessageHandler)_sync_done_reply_receiver, target); - - OSyncPluginTimeouts timeouts = osync_client_get_timeouts(target); - if (!osync_queue_send_message_with_timeout(target->commands_to_osplugin, target->commands_from_osplugin, message, timeouts.sync_done_timeout, error)) - goto error_free_message; - - osync_message_unref(message); - - osync_trace(TRACE_EXIT, "%s", __func__); - return TRUE; - -error_free_message: - osync_message_unref(message); -error: - osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(error)); - return FALSE; -} - -osync_bool osync_client_committed_all(OSyncClient *target, OSyncEngine *sender, OSyncError **error) -{ - osync_trace(TRACE_ENTRY, "%s(%p, %p)", __func__, target, sender); - - osync_flag_changing(target->fl_committed_all); - - OSyncMessage *message = osync_message_new(OSYNC_MESSAGE_COMMITTED_ALL, 0, error); - if (!message) - goto error; - - osync_message_set_handler(message, (OSyncMessageHandler)_committed_all_reply_receiver, target); - - //OSyncPluginTimeouts timeouts = osync_client_get_timeouts(target); - /*FIXME: Add timeout to committed_all message */ - if (!osync_queue_send_message(target->commands_to_osplugin, target->commands_from_osplugin, message, error)) - goto error_free_message; - - osync_message_unref(message); - - osync_trace(TRACE_EXIT, "%s", __func__); - return TRUE; - -error_free_message: - osync_message_unref(message); -error: - osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(error)); - return FALSE; -} - -osync_bool osync_client_disconnect(OSyncClient *target, OSyncEngine *sender, OSyncError **error) -{ - osync_trace(TRACE_ENTRY, "%s(%p, %p)", __func__, target, sender); - - osync_flag_changing(target->fl_connected); - - OSyncMessage *message = osync_message_new(OSYNC_MESSAGE_DISCONNECT, 0, error); - if (!message) - goto error; - - osync_message_set_handler(message, (OSyncMessageHandler)_disconnect_reply_receiver, target); - - OSyncPluginTimeouts timeouts = osync_client_get_timeouts(target); - if (!osync_queue_send_message_with_timeout(target->commands_to_osplugin, target->commands_from_osplugin, message, timeouts.disconnect_timeout, error)) - goto error_free_message; - - osync_message_unref(message); - - osync_trace(TRACE_EXIT, "%s", __func__); - return TRUE; - -error_free_message: - osync_message_unref(message); -error: - osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(error)); - return FALSE; -} - - -/* -void osync_client_call_plugin_with_reply(OSyncClient *client, char *function, void *data, void ( *replyhandler)(OSyncEngine *, OSyncClient *, void *, OSyncError *), int timeout) -{ - OSyncEngine *engine = client->engine; - ITMessage *message = itm_message_new_signal(engine, "CALL_PLUGIN"); - osync_debug("CLI", 3, "Sending message %p CALL_PLUGIN for function %s", message, function); - itm_message_set_data(message, "data", data); - itm_message_set_data(message, "function", g_strdup(function)); - itm_queue_send_with_reply(client->incoming, message); -}*/ - -char *osync_client_pid_filename(OSyncClient *client) -{ - return g_strdup_printf("%s/osplugin.pid", client->member->configdir); -} - -osync_bool osync_client_remove_pidfile(OSyncClient *client, OSyncError **error) -{ - osync_bool ret = FALSE; - char *pidpath = osync_client_pid_filename(client); - - if (unlink(pidpath) < 0) { - osync_error_set(error, OSYNC_ERROR_GENERIC, "Couldn't remove pid file: %s", strerror(errno)); - goto out_free_path; - } - - /* Success */ - ret = TRUE; - -out_free_path: - g_free(pidpath); -//out: - return ret; -} - -osync_bool osync_client_create_pidfile(OSyncClient *client, OSyncError **error) -{ - osync_bool ret = FALSE; - char *pidpath = osync_client_pid_filename(client); - char *pidstr = g_strdup_printf("%ld", (long)client->child_pid); - - if (!osync_file_write(pidpath, pidstr, strlen(pidstr), 0644, error)) - goto out_free_pidstr; - - /* Success */ - ret = TRUE; - -out_free_pidstr: - g_free(pidstr); -//out_free_path: - g_free(pidpath); -//out: - return ret; -} - -osync_bool osync_client_kill_old_osplugin(OSyncClient *client, OSyncError **error) -{ - osync_bool ret = FALSE; - - char *pidstr; - int pidlen; - pid_t pid; - - char *pidpath = osync_client_pid_filename(client); - - /* Simply returns if there is no PID file */ - if (!g_file_test(pidpath, G_FILE_TEST_EXISTS)) { - ret = TRUE; - goto out_free_path; - } - - if (!osync_file_read(pidpath, &pidstr, &pidlen, error)) - goto out_free_path; - - pid = atol(pidstr); - if (!pid) - goto out_free_str; - - osync_trace(TRACE_INTERNAL, "Killing old osplugin process. PID: %ld", (long)pid); - - if (kill(pid, SIGTERM) < 0) { - osync_trace(TRACE_INTERNAL, "Error killing old osplugin: %s. Stale pid file?", strerror(errno)); - /* Don't return failure if kill() failed, because it may be a stale pid file */ - } - - int count = 0; - while (osync_queue_is_alive(client->commands_to_osplugin)) { - if (count++ > 10) { - osync_trace(TRACE_INTERNAL, "Killing old osplugin process with SIGKILL"); - kill(pid, SIGKILL); - break; - } - osync_trace(TRACE_INTERNAL, "Waiting for other side to terminate"); - /*FIXME: Magic numbers are evil */ - usleep(500000); - } - - if (unlink(pidpath) < 0) { - osync_error_set(error, OSYNC_ERROR_GENERIC, "Couldn't erase PID file: %s", strerror(errno)); - goto out_free_str; - } - - /* Success */ - ret = TRUE; - -out_free_str: - g_free(pidstr); -out_free_path: - g_free(pidpath); -//out: - return ret; -} - - -osync_bool osync_client_spawn(OSyncClient *client, OSyncEngine *engine, OSyncError **error) -{ - osync_trace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, client, engine, error); - - int waiting = 0; - - if (!osync_client_kill_old_osplugin(client, error)) - goto error; - - if (!osync_queue_exists(client->commands_to_osplugin) || !osync_queue_is_alive(client->commands_to_osplugin)) { - pid_t cpid = fork(); - if (cpid == 0) { - osync_trace_reset_indent(); - - /* Export all options to osplugin through environment variables */ - osync_env_export_all_options(osync_group_get_env(engine->group)); - - OSyncMember *member = client->member; - OSyncPlugin *plugin = osync_member_get_plugin(member); - const char *path = osync_plugin_get_path(plugin); - setenv("OSYNC_MODULE_LIST", path, 1); - - osync_env_export_loaded_modules(osync_group_get_env(engine->group)); - - char *memberstring = g_strdup_printf("%lli", osync_member_get_id(client->member)); - execlp(OSPLUGIN, OSPLUGIN, osync_group_get_configdir(engine->group), memberstring, NULL); - - if (errno == ENOENT) { - execlp("./osplugin", "osplugin", osync_group_get_configdir(engine->group), memberstring, NULL); - } - - osync_trace(TRACE_INTERNAL, "unable to exec"); - exit(1); - } - - client->child_pid = cpid; - - /* We are going to wait 5 seconds for plugin */ - while (!osync_queue_exists(client->commands_to_osplugin) && waiting <= 5) { - osync_trace(TRACE_INTERNAL, "Waiting for other side to create fifo"); - - sleep(1); - waiting++; - } - - osync_trace(TRACE_INTERNAL, "Queue was created"); - } - - if (client->child_pid) { - if (!osync_client_create_pidfile(client, error)) - goto error; - } - - if (!osync_queue_connect(client->commands_to_osplugin, OSYNC_QUEUE_SENDER, error)) - goto error; - - OSyncMessage *message = osync_message_new(OSYNC_MESSAGE_INITIALIZE, 0, error); - if (!message) - goto error_disconnect; - - osync_message_write_string(message, client->commands_from_osplugin->name); - - if (!osync_queue_send_message(client->commands_to_osplugin, NULL, message, error)) - goto error_free_message; - - osync_message_unref(message); - - osync_trace(TRACE_EXIT, "%s", __func__); - return TRUE; - -error_free_message: - osync_message_unref(message); -error_disconnect: - osync_queue_disconnect(client->commands_to_osplugin, NULL); -error: - osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(error)); - return FALSE; -} - -osync_bool osync_client_init(OSyncClient *client, OSyncEngine *engine, OSyncError **error) -{ - osync_trace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, client, engine, error); - - OSyncMessage *reply = osync_queue_get_message(client->commands_from_osplugin); - - osync_trace(TRACE_INTERNAL, "reply received %i", reply->cmd); - if (reply->cmd == OSYNC_MESSAGE_ERRORREPLY) { - if (error) - osync_demarshal_error(reply, error); - goto error_free_reply; - } - - if (reply->cmd != OSYNC_MESSAGE_REPLY) { - osync_error_set(error, OSYNC_ERROR_GENERIC, "Invalid answer from plugin process"); - goto error_free_reply; - } - - osync_message_unref(reply); - - osync_trace(TRACE_EXIT, "%s", __func__); - return TRUE; - -error_free_reply: - osync_message_unref(reply); - osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(error)); - return FALSE; -} - -osync_bool osync_client_finalize(OSyncClient *client, OSyncError **error) -{ - osync_trace(TRACE_ENTRY, "%s(%p, %p)", __func__, client, error); - - OSyncMessage *message = osync_message_new(OSYNC_MESSAGE_FINALIZE, 0, error); - if (!message) - goto error; - - if (!osync_queue_send_message(client->commands_to_osplugin, NULL, message, error)) - goto error_free_message; - - osync_message_unref(message); - - if (client->child_pid) { - int status; - if (waitpid(client->child_pid, &status, 0) == -1) { - osync_error_set(error, OSYNC_ERROR_GENERIC, "Error waiting for osplugin process: %s", strerror(errno)); - goto error; - } - - if (!WIFEXITED(status)) - osync_trace(TRACE_INTERNAL, "Child has exited abnormally"); - else if (WEXITSTATUS(status) != 0) - osync_trace(TRACE_INTERNAL, "Child has returned non-zero exit status (%d)", WEXITSTATUS(status)); - - if (!osync_client_remove_pidfile(client, error)) - goto error; - } - - osync_queue_disconnect(client->commands_to_osplugin, NULL); - - - osync_trace(TRACE_EXIT, "%s", __func__); - return TRUE; - -error_free_message: - osync_message_unref(message); -error: - osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(error)); - return FALSE; -} diff --git a/debian/opensync/opensync-0.22/osengine/osengine_client_internals.h b/debian/opensync/opensync-0.22/osengine/osengine_client_internals.h deleted file mode 100644 index 87ffe301..00000000 --- a/debian/opensync/opensync-0.22/osengine/osengine_client_internals.h +++ /dev/null @@ -1,45 +0,0 @@ - -#ifndef DOXYGEN_SHOULD_SKIP_THIS -struct OSyncClient { - OSyncMember *member; - OSyncQueue *commands_to_osplugin; - OSyncQueue *commands_from_osplugin; - OSyncEngine *engine; - - OSyncFlag *fl_connected; - OSyncFlag *fl_sent_changes; - OSyncFlag *fl_done; - OSyncFlag *fl_finished; - OSyncFlag *fl_committed_all; - - pid_t child_pid; - //GList *changes; -}; -#endif - -typedef void (* OSyncPluginReplyHandler) (void *, void *, OSyncError *); - -typedef struct OSyncPluginCallContext { - OSyncPluginReplyHandler handler; - void *userdata; -} OSyncPluginCallContext; - -OSyncClient *osync_client_new(OSyncEngine *engine, OSyncMember *member, OSyncError **error); -void osync_client_free(OSyncClient *client); - -osync_bool osync_client_spawn(OSyncClient *client, OSyncEngine *engine, OSyncError **error); -OSyncEngine *osync_client_get_engine(OSyncClient *client); -void osync_client_call_plugin(OSyncClient *client, char *function, void *data, OSyncPluginReplyHandler replyhandler, void *userdata); - -osync_bool osync_client_init(OSyncClient *client, OSyncEngine *engine, OSyncError **error); -osync_bool osync_client_finalize(OSyncClient *client, OSyncError **error); -OSyncPluginTimeouts osync_client_get_timeouts(OSyncClient *client); -void osync_client_reset(OSyncClient *client); - -osync_bool osync_client_connect(OSyncClient *target, OSyncEngine *sender, OSyncError **error); -osync_bool osync_client_get_changes(OSyncClient *target, OSyncEngine *sender, OSyncError **error); -osync_bool osync_client_committed_all(OSyncClient *target, OSyncEngine *sender, OSyncError **error); -osync_bool osync_client_sync_done(OSyncClient *target, OSyncEngine *sender, OSyncError **error); -osync_bool osync_client_disconnect(OSyncClient *target, OSyncEngine *sender, OSyncError **error); -osync_bool osync_client_commit_change(OSyncClient *target, OSyncEngine *sender, OSyncMappingEntry *entry, OSyncError **error); -osync_bool osync_client_get_change_data(OSyncClient *target, OSyncEngine *sender, OSyncMappingEntry *entry, OSyncError **error); diff --git a/debian/opensync/opensync-0.22/osengine/osengine_debug.c b/debian/opensync/opensync-0.22/osengine/osengine_debug.c deleted file mode 100644 index 7a370bbb..00000000 --- a/debian/opensync/opensync-0.22/osengine/osengine_debug.c +++ /dev/null @@ -1,138 +0,0 @@ -/* - * libosengine - A synchronization engine for the opensync framework - * Copyright (C) 2004-2005 Armin Bauer <armin.bauer@opensync.org> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -#include "engine.h" -#include "engine_internals.h" - -void osengine_print_all(OSyncEngine *engine) -{ - GList *i; - GList *n; - osync_debug("ENG", 2, "ENGINE:"); - osync_debug("ENG", 2, "running: %s", osync_flag_get_state(engine->fl_running) ? "YES" : "NO"); - osync_debug("ENG", 2, "sync: %s", osync_flag_get_state(engine->fl_sync) ? "YES" : "NO"); - osync_debug("ENG", 2, "stop: %s", osync_flag_get_state(engine->fl_stop) ? "YES" : "NO"); - osync_debug("ENG", 2, "sent changes: %s (no: %i, yes: %i)", osync_flag_get_state(engine->cmb_sent_changes) ? "YES" : "NO", engine->cmb_sent_changes->num_not_set, engine->cmb_sent_changes->num_set); - osync_debug("ENG", 2, "all mapped: %s (no: %i, yes: %i)", osync_flag_get_state(engine->cmb_entries_mapped) ? "YES" : "NO", engine->cmb_entries_mapped->num_not_set, engine->cmb_entries_mapped->num_set); - osync_debug("ENG", 2, "synced: %s (no: %i, yes: %i)", osync_flag_get_state(engine->cmb_synced) ? "YES" : "NO", engine->cmb_synced->num_not_set, engine->cmb_synced->num_set); - osync_debug("ENG", 2, "conflicts checked: %s (no: %i, yes: %i)", osync_flag_get_state(engine->cmb_chkconflict) ? "YES" : "NO", engine->cmb_chkconflict->num_not_set, engine->cmb_chkconflict->num_set); - osync_debug("ENG", 2, "finished: %s (no: %i, yes: %i)", osync_flag_get_state(engine->cmb_finished) ? "YES" : "NO", engine->cmb_finished->num_not_set, engine->cmb_finished->num_set); - osync_debug("ENG", 2, "connected: %s (no: %i, yes: %i)", osync_flag_get_state(engine->cmb_connected) ? "YES" : "NO", engine->cmb_connected->num_not_set, engine->cmb_connected->num_set); - osync_debug("ENG", 2, "Multiplied: %s (no: %i, yes: %i)", osync_flag_get_state(engine->cmb_multiplied) ? "YES" : "NO", engine->cmb_multiplied->num_not_set, engine->cmb_multiplied->num_set); - - for (i = engine->clients; i; i = i->next) { - OSyncClient *client = i->data; - osync_debug("ENG", 2, "\tCLIENT %lli %s:", osync_member_get_id(client->member), osync_member_get_pluginname(client->member)); - osync_debug("ENG", 2, "\tconnected: %s", osync_flag_get_state(client->fl_connected) ? "YES" : "NO"); - osync_debug("ENG", 2, "\tsent changes: %s", osync_flag_get_state(client->fl_sent_changes) ? "YES" : "NO"); - osync_debug("ENG", 2, "\tdone: %s", osync_flag_get_state(client->fl_done) ? "YES" : "NO"); - osync_debug("ENG", 2, "\tfinished: %s", osync_flag_get_state(client->fl_finished) ? "YES" : "NO"); - } - - for (i = engine->maptable->mappings; i; i = i->next) { - OSyncMapping *mapping = i->data; - osync_debug("ENG", 2, "MAPPING %p ID: %lli:", mapping, mapping->id); - osync_debug("ENG", 2, "solved: %s", osync_flag_get_state(mapping->fl_solved) ? "YES" : "NO"); - osync_debug("ENG", 2, "synced: %s (no: %i, yes: %i)", osync_flag_get_state(mapping->cmb_synced) ? "YES" : "NO", mapping->cmb_synced->num_not_set, mapping->cmb_synced->num_set); - osync_debug("ENG", 2, "conflict checked: %s", osync_flag_get_state(mapping->fl_chkconflict) ? "YES" : "NO"); - osync_debug("ENG", 2, "muliplied: %s", osync_flag_get_state(mapping->fl_multiplied) ? "YES" : "NO"); - osync_debug("ENG", 2, "has data: %s", osync_flag_get_state(mapping->cmb_has_data) ? "YES" : "NO"); - osync_debug("ENG", 2, "has info: %s (no: %i, yes: %i)", osync_flag_get_state(mapping->cmb_has_info) ? "YES" : "NO", mapping->cmb_has_info->num_not_set, mapping->cmb_has_info->num_set); - osync_debug("ENG", 2, "delete: %s (no: %i, yes: %i)", osync_flag_get_state(mapping->cmb_deleted) ? "YES" : "NO", mapping->cmb_deleted->num_not_set, mapping->cmb_deleted->num_set); - - for (n = mapping->entries; n; n = n->next) { - OSyncMappingEntry *entry = n->data; - osync_debug("ENG", 2, "\tENTRY: %p, CHANGE %p, Member %lli:", entry, entry->change, osync_member_get_id(entry->client->member)); - osync_debug("ENG", 2, "\tuid: %s, changetype: %i", osync_change_get_uid(entry->change), osync_change_get_changetype(entry->change)); - osync_debug("ENG", 2, "\tObjType: %s, Format %s", osync_change_get_objtype(entry->change) ? osync_objtype_get_name(osync_change_get_objtype(entry->change)) : "None", osync_change_get_objformat(entry->change) ? osync_objformat_get_name(osync_change_get_objformat(entry->change)) : "None"); - osync_debug("ENG", 2, "\thas data: %s", osync_flag_get_state(entry->fl_has_data) ? "YES" : "NO"); - osync_debug("ENG", 2, "\tdirty: %s", osync_flag_get_state(entry->fl_dirty) ? "YES" : "NO"); - osync_debug("ENG", 2, "\tmapped: %s", osync_flag_get_state(entry->fl_mapped) ? "YES" : "NO"); - osync_debug("ENG", 2, "\thas info: %s", osync_flag_get_state(entry->fl_has_info) ? "YES" : "NO"); - osync_debug("ENG", 2, "\tsynced: %s", osync_flag_get_state(entry->fl_synced) ? "YES" : "NO"); - osync_debug("ENG", 2, "\tdeleted: %s", osync_flag_get_state(entry->fl_deleted) ? "YES" : "NO"); - } - } - - for (n = engine->maptable->unmapped; n; n = n->next) { - OSyncMappingEntry *entry = n->data; - osync_debug("ENG", 2, "UNMAPPED ENTRY %p with change %p:", entry, entry->change); - osync_debug("ENG", 2, "uid: %s, changetype: %i", osync_change_get_uid(entry->change), osync_change_get_changetype(entry->change)); - osync_debug("ENG", 2, "ObjType: %s, Format %s", osync_change_get_objtype(entry->change) ? osync_objtype_get_name(osync_change_get_objtype(entry->change)) : "None", osync_change_get_objformat(entry->change) ? osync_objformat_get_name(osync_change_get_objformat(entry->change)) : "None"); - osync_debug("ENG", 2, "has data: %s", osync_flag_get_state(entry->fl_has_data) ? "YES" : "NO"); - osync_debug("ENG", 2, "dirty: %s", osync_flag_get_state(entry->fl_dirty) ? "YES" : "NO"); - osync_debug("ENG", 2, "mapped: %s", osync_flag_get_state(entry->fl_mapped) ? "YES" : "NO"); - osync_debug("ENG", 2, "has info: %s", osync_flag_get_state(entry->fl_has_info) ? "YES" : "NO"); - osync_debug("ENG", 2, "synced: %s", osync_flag_get_state(entry->fl_synced) ? "YES" : "NO"); - } -} - -void osengine_print_flags(OSyncEngine *engine) -{ - osync_trace(TRACE_INTERNAL, "ENG(RUN%i,STOP%i,SENT%i,READ%i,MAP%i,CHK%i,MUL%i,SYNC%i,COMMITTED%i)", \ - osync_flag_is_set(engine->fl_running), \ - osync_flag_is_not_set(engine->fl_stop), \ - osync_flag_is_set(engine->cmb_sent_changes), \ - osync_flag_is_set(engine->cmb_read_all), \ - osync_flag_is_set(engine->cmb_entries_mapped), \ - osync_flag_is_set(engine->cmb_chkconflict), \ - osync_flag_is_set(engine->cmb_multiplied), \ - osync_flag_is_set(engine->cmb_synced), \ - osync_flag_is_set(engine->cmb_committed_all)); -} - -void osync_client_print_flags(OSyncClient *client) -{ - osync_trace(TRACE_INTERNAL, "CL(CON%i,SENT%i,DONE%i,FIN%i,COMMITTED%i)", \ - osync_flag_is_set(client->fl_connected), \ - osync_flag_is_set(client->fl_sent_changes), \ - osync_flag_is_set(client->fl_done), \ - osync_flag_is_set(client->fl_finished), \ - osync_flag_is_set(client->fl_committed_all)); -} - -void osengine_mappingentry_print_flags(OSyncMappingEntry *entry) -{ - osync_trace(TRACE_INTERNAL, "ENT(DATA%i,DRY%i,MAP%i,INFO%i,SYNC%i,DEL%i)", \ - osync_flag_is_set(entry->fl_has_data), \ - osync_flag_is_set(entry->fl_dirty), \ - osync_flag_is_set(entry->fl_mapped), \ - osync_flag_is_set(entry->fl_has_info), \ - osync_flag_is_set(entry->fl_synced), \ - osync_flag_is_set(entry->fl_deleted)); -} - -void osengine_mapping_print_flags(OSyncMapping *mapping) -{ - osync_trace(TRACE_INTERNAL, "MAP(SOLV%i,SYNC%i,DATA%i,INFO%i,DEL%i,CHK%i,MUL%i)", \ - osync_flag_is_set(mapping->fl_solved), \ - osync_flag_is_set(mapping->cmb_synced), \ - osync_flag_is_set(mapping->cmb_has_data), \ - osync_flag_is_set(mapping->cmb_has_info), \ - osync_flag_is_set(mapping->cmb_deleted), \ - osync_flag_is_set(mapping->fl_chkconflict), \ - osync_flag_is_set(mapping->fl_multiplied)); -} - -void osengine_get_wasted(OSyncEngine *engine, int *all, int *wasted) -{ - *all = engine->alldeciders; - *wasted = engine->wasted; -} diff --git a/debian/opensync/opensync-0.22/osengine/osengine_debug.h b/debian/opensync/opensync-0.22/osengine/osengine_debug.h deleted file mode 100644 index 45536456..00000000 --- a/debian/opensync/opensync-0.22/osengine/osengine_debug.h +++ /dev/null @@ -1,10 +0,0 @@ -#ifndef _OSENGINE__DEBUG_H -#define _OSENGINE__DEBUG_H - -void osengine_print_all(OSyncEngine *engine); -void osengine_print_flags(OSyncEngine *engine); -void osync_client_print_flags(OSyncClient *client); -void osengine_mapping_print_flags(OSyncMapping *mapping); -void osengine_get_wasted(OSyncEngine *engine, int *all, int *wasted); - -#endif diff --git a/debian/opensync/opensync-0.22/osengine/osengine_debug_internals.h b/debian/opensync/opensync-0.22/osengine/osengine_debug_internals.h deleted file mode 100644 index d3654cdf..00000000 --- a/debian/opensync/opensync-0.22/osengine/osengine_debug_internals.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef _OSENGINE__DEBUG_INTERNALS_H -#define _OSENGINE__DEBUG_INTERNALS_H - -void osengine_mappingentry_print_flags(OSyncMappingEntry *entry); - -#endif diff --git a/debian/opensync/opensync-0.22/osengine/osengine_deciders.c b/debian/opensync/opensync-0.22/osengine/osengine_deciders.c deleted file mode 100644 index d2fdb2c9..00000000 --- a/debian/opensync/opensync-0.22/osengine/osengine_deciders.c +++ /dev/null @@ -1,248 +0,0 @@ -/* - * libosengine - A synchronization engine for the opensync framework - * Copyright (C) 2004-2005 Armin Bauer <armin.bauer@opensync.org> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -#include "engine.h" -#include "engine_internals.h" - -/** - * @defgroup OSEngineDeciders OpenSync Deciders Internals - * @ingroup OSEnginePrivate - * @brief The internals of the engine (communication part) - * - * This gives you an insight in the inner workings of the sync engine - * - * - */ -/*@{*/ - -#ifndef DOXYGEN_SHOULD_SKIP_THIS -void osengine_mappingentry_decider(OSyncEngine *engine, OSyncMappingEntry *entry) -{ - osync_trace(TRACE_ENTRY, "osengine_mappingentry_decider(%p, %p)", engine, entry); - osengine_print_flags(engine); - osengine_mappingentry_print_flags(entry); - - engine->alldeciders++; - - if (osync_flag_is_set(engine->fl_running) \ - && osync_flag_is_set(engine->fl_sync) \ - && osync_flag_is_set(entry->fl_has_info) \ - && osync_flag_is_not_set(entry->fl_has_data)) { - osync_trace(TRACE_INTERNAL, "++++ ENGINE COMMAND: Get data (Entry %p) ++++", entry); - osync_client_get_change_data(entry->client, engine, entry, NULL); - osync_trace(TRACE_EXIT, "osengine_mappingentry_decider"); - return; - } - - if (osync_flag_is_set(engine->fl_running) \ - && osync_flag_is_set(engine->cmb_read_all) \ - && osync_flag_is_set(engine->cmb_sent_changes) \ - && osync_flag_is_set(engine->fl_sync) \ - && osync_flag_is_set(entry->fl_has_info) \ - && osync_flag_is_set(entry->fl_has_data)) { - if (osync_flag_is_not_set(entry->fl_mapped)) { - osync_trace(TRACE_INTERNAL, "++++ ENGINE COMMAND: Mapping entry (Entry %p) ++++", entry); - osengine_change_map(engine, entry); - osync_trace(TRACE_EXIT, "osengine_mappingentry_decider"); - return; - } - if (osync_flag_is_set(entry->fl_dirty)) { - osync_trace(TRACE_INTERNAL, "++++ ENGINE COMMAND: Commiting (Entry %p) ++++", entry); - osync_client_commit_change(entry->client, engine, entry, NULL); - osync_trace(TRACE_EXIT, "osengine_mappingentry_decider"); - return; - } - } - - engine->wasted++; - osync_trace(TRACE_EXIT, "osengine_mappingentry_decider: Waste"); -} - -void osengine_mappingentry_all_deciders(OSyncEngine *engine, OSyncMapping *mapping) -{ - osync_debug("ENG", 3, "Calling all mappingentry deciders (%i) for mapping %p", g_list_length(mapping->entries), mapping); - GList *e; - for (e = mapping->entries; e ; e = e->next) { - OSyncMappingEntry *entry = e->data; - send_mappingentry_changed(engine, entry); - } -} - -void osengine_mapping_decider(OSyncEngine *engine, OSyncMapping *mapping) -{ - osync_trace(TRACE_ENTRY, "osengine_mapping_decider(%p, %p)", engine, mapping); - osengine_print_flags(engine); - osengine_mapping_print_flags(mapping); - - engine->alldeciders++; - - if (osync_flag_is_set(engine->fl_running) \ - && osync_flag_is_set(engine->cmb_sent_changes) \ - && osync_flag_is_set(engine->cmb_read_all) \ - && osync_flag_is_set(engine->cmb_entries_mapped) \ - && osync_flag_is_set(mapping->cmb_has_data) \ - && osync_flag_is_not_set(mapping->cmb_synced) \ - && osync_flag_is_not_set(mapping->fl_solved) \ - && osync_flag_is_not_set(mapping->fl_chkconflict)) { - osync_trace(TRACE_INTERNAL, "++++ ENGINE COMMAND: Check Conflict (Mapping %p) ++++", mapping); - osengine_mapping_check_conflict(engine, mapping); - osync_trace(TRACE_EXIT, "osengine_mapping_decider"); - return; - } - - if (osync_flag_is_set(engine->fl_running) \ - && osync_flag_is_set(engine->cmb_sent_changes) \ - && osync_flag_is_set(engine->cmb_read_all) \ - && osync_flag_is_set(engine->cmb_entries_mapped) \ - && osync_flag_is_set(mapping->cmb_has_data) \ - && osync_flag_is_not_set(mapping->cmb_synced) \ - && osync_flag_is_set(mapping->fl_solved) \ - && osync_flag_is_set(mapping->fl_chkconflict) \ - && osync_flag_is_not_set(mapping->fl_multiplied)) { - osync_trace(TRACE_INTERNAL, "++++ ENGINE COMMAND: Multiply (Mapping %p) ++++", mapping); - osengine_mapping_multiply_master(engine, mapping); - osync_trace(TRACE_EXIT, "osengine_mapping_decider"); - return; - } - - if (osync_flag_is_set(engine->fl_running) \ - && osync_flag_is_set(engine->cmb_synced) \ - && osync_flag_is_set(mapping->cmb_has_info) \ - && osync_flag_is_not_set(mapping->cmb_deleted) \ - && osync_flag_is_set(engine->cmb_multiplied)) { - osync_trace(TRACE_INTERNAL, "++++ ENGINE COMMAND: Reset Mapping (Mapping %p) ++++", mapping); - osengine_mapping_reset(mapping); - osync_trace(TRACE_EXIT, "osengine_mapping_decider"); - return; - } - - if (osync_flag_is_set(engine->fl_running) \ - && osync_flag_is_set(mapping->cmb_synced) \ - && osync_flag_is_set(mapping->cmb_deleted)) { - osync_trace(TRACE_INTERNAL, "++++ ENGINE COMMAND: Deleting Mapping (Mapping %p) ++++", mapping); - osengine_mapping_delete(mapping); - osync_trace(TRACE_EXIT, "osengine_mapping_decider"); - return; - } - - engine->wasted++; - osync_trace(TRACE_EXIT, "osengine_mapping_decider: Waste"); -} - -void osengine_mapping_all_deciders(OSyncEngine *engine) -{ - GList *m; - osync_trace(TRACE_INTERNAL, "Calling all mapping deciders (%i)", g_list_length(engine->maptable->mappings)); - for (m = engine->maptable->mappings; m; m = m->next) { - OSyncMapping *mapping = m->data; - send_mapping_changed(engine, mapping); - } -} - -void osengine_client_decider(OSyncEngine *engine, OSyncClient *client) -{ - osync_trace(TRACE_ENTRY, "osengine_client_decider(%p, %p)", engine, client); - osengine_print_flags(engine); - osync_client_print_flags(client); - - engine->alldeciders++; - - if (osync_flag_is_set(engine->fl_running) \ - && osync_flag_is_not_set(engine->fl_stop) \ - && osync_flag_is_not_set(client->fl_done) \ - && osync_flag_is_not_set(client->fl_connected) \ - && osync_flag_is_not_set(client->fl_finished)) { - osync_trace(TRACE_INTERNAL, "++++ ENGINE COMMAND: Connecting (Client %p) ++++", client); - osync_client_connect(client, engine, NULL); - osync_trace(TRACE_EXIT, "osengine_client_decider"); - return; - } - - if (osync_flag_is_set(engine->fl_running) \ - && osync_flag_is_not_set(engine->fl_stop) \ - && osync_flag_is_not_set(client->fl_done) \ - && osync_flag_is_set(client->fl_connected) \ - && osync_flag_is_not_set(client->fl_sent_changes) \ - && osync_flag_is_set(engine->cmb_connected)) { - osync_trace(TRACE_INTERNAL, "++++ ENGINE COMMAND: Get changes (Client %p) ++++", client); - osync_client_get_changes(client, engine, NULL); - osync_trace(TRACE_EXIT, "osengine_client_decider"); - return; - } - - if (osync_flag_is_set(engine->fl_running) \ - && osync_flag_is_not_set(engine->fl_stop) \ - && osync_flag_is_not_set(client->fl_done) \ - && osync_flag_is_set(client->fl_connected) \ - && osync_flag_is_set(client->fl_sent_changes) \ - && osync_flag_is_not_set(client->fl_committed_all) \ - && osync_flag_is_set(engine->cmb_sent_changes) \ - && osync_flag_is_set(engine->cmb_multiplied) \ - && osync_flag_is_set(engine->cmb_read_all) \ - && osync_flag_is_set(engine->cmb_entries_mapped) \ - && osync_flag_is_set(engine->cmb_committed_all)) { - osync_trace(TRACE_INTERNAL, "++++ ENGINE COMMAND: Committed all (Client %p) ++++", client); - osync_client_committed_all(client, engine, NULL); - osync_trace(TRACE_EXIT, "osengine_client_decider"); - return; - } - - if (osync_flag_is_set(engine->fl_running) \ - && osync_flag_is_not_set(engine->fl_stop) \ - && osync_flag_is_not_set(client->fl_done) \ - && osync_flag_is_set(client->fl_connected) \ - && osync_flag_is_set(client->fl_sent_changes) \ - && osync_flag_is_set(client->fl_committed_all) \ - && osync_flag_is_set(engine->cmb_read_all) \ - && osync_flag_is_set(engine->cmb_sent_changes) \ - && osync_flag_is_set(engine->cmb_synced) \ - && osync_flag_is_set(engine->cmb_entries_mapped)) { - osync_trace(TRACE_INTERNAL, "++++ ENGINE COMMAND: Sync done (Client %p) ++++", client); - osync_client_sync_done(client, engine, NULL); - osync_trace(TRACE_EXIT, "osengine_client_decider"); - return; - } - - if (osync_flag_is_set(engine->fl_running) \ - && (osync_flag_is_set(client->fl_done) \ - || osync_flag_is_set(engine->fl_stop)) \ - && osync_flag_is_set(client->fl_connected)) { - osync_trace(TRACE_INTERNAL, "++++ ENGINE COMMAND: Disconnecting (Client %p) ++++", client); - osync_client_disconnect(client, engine, NULL); - osync_trace(TRACE_EXIT, "osengine_client_decider"); - return; - } - - engine->wasted++; - osync_trace(TRACE_EXIT, "osengine_client_decider: Waste"); -} - -void osengine_client_all_deciders(OSyncEngine *engine) -{ - GList *c; - osync_debug("ENG", 3, "Calling all client deciders (%i)", g_list_length(engine->clients)); - for (c = engine->clients; c; c = c->next) { - OSyncClient *client = c->data; - osengine_client_decider(engine, client); - } -} -#endif - -/** @} */ diff --git a/debian/opensync/opensync-0.22/osengine/osengine_deciders_internals.h b/debian/opensync/opensync-0.22/osengine/osengine_deciders_internals.h deleted file mode 100644 index a4cf00e4..00000000 --- a/debian/opensync/opensync-0.22/osengine/osengine_deciders_internals.h +++ /dev/null @@ -1,5 +0,0 @@ -void osengine_mappingentry_decider(OSyncEngine *engine, OSyncMappingEntry *entry); -void osengine_mappingentry_all_deciders(OSyncEngine *engine, OSyncMapping *mapping); - -void osengine_mapping_decider(OSyncEngine *engine, OSyncMapping *mapping); -void osengine_mapping_all_deciders(OSyncEngine *engine); diff --git a/debian/opensync/opensync-0.22/osengine/osengine_engine.c b/debian/opensync/opensync-0.22/osengine/osengine_engine.c deleted file mode 100644 index c5a98f43..00000000 --- a/debian/opensync/opensync-0.22/osengine/osengine_engine.c +++ /dev/null @@ -1,1233 +0,0 @@ -/* - * libosengine - A synchronization engine for the opensync framework - * Copyright (C) 2004-2005 Armin Bauer <armin.bauer@opensync.org> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -#include "engine.h" - -#include <errno.h> -#include <sys/stat.h> -#include <sys/types.h> - -#include <glib.h> - -#include <opensync/opensync_support.h> -#include "opensync/opensync_message_internals.h" -#include "opensync/opensync_queue_internals.h" -#include "opensync/opensync_format_internals.h" - -#include "engine_internals.h" -#include <opensync/opensync_user_internals.h> - -OSyncMappingEntry *osengine_mappingtable_find_entry(OSyncMappingTable *table, const char *uid, const char *objtype, long long int memberid); -/** - * @defgroup OSEnginePrivate OpenSync Engine Private API - * @ingroup PrivateAPI - * @brief The internals of the multisync engine - * - */ - -/** - * @defgroup OSyncEnginePrivate OpenSync Engine Internals - * @ingroup OSEnginePrivate - * @brief The internals of the engine (communication part) - * - * This gives you an insight in the inner workings of the sync engine, - * especially the communication part. - * - * - */ -/*@{*/ - -void _new_change_receiver(OSyncEngine *engine, OSyncClient *client, OSyncChange *change) -{ - osync_trace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, engine, client, change); - - OSyncError *error = NULL; - OSyncChangeType change_type = osync_change_get_changetype(change); - OSyncFormatEnv *format_env = osync_group_get_format_env(engine->group); - OSyncObjType *objtype = osync_change_get_objtype(change); - const char* uid = osync_change_get_uid(change); - OSyncObjFormat *objformat = osync_change_get_objformat(change); - - osync_change_set_member(change, client->member); - - osync_trace(TRACE_INTERNAL, "Handling new change with uid %s, changetype %i, objtype %s and format %s from member %lli", uid, change_type, - objtype ? osync_objtype_get_name(objtype) : "None", osync_change_get_objformat(change) ? osync_objformat_get_name(osync_change_get_objformat(change)) : "None", - osync_member_get_id(client->member)); - - - /** - * first we need to detect the objtype because we use - * uid + objtype as identifier for an entry. - * Special case is file as objformat... we must not change - * the objtype with format file - **/ - if ( (change_type != CHANGE_DELETED) && - (osync_change_has_data(change))) { - osync_bool is_file_objformat = FALSE; - if(objformat) - is_file_objformat = - ((!strcmp(objformat->name, "file"))?(TRUE):(FALSE)); - if ( (!objtype) || (!objformat) || - (!strcmp(osync_objtype_get_name(objtype), "data")) || - (!strcmp(objformat->name, "plain"))) { - OSyncObjType *objtype_test = osync_change_detect_objtype_full(format_env, change, &error); - objtype = (objtype_test)?(objtype_test):(objtype); - } - if (objtype) { - osync_trace(TRACE_INTERNAL, "Detected the object to be of type %s", osync_objtype_get_name(objtype)); - - osync_change_set_objtype(change, objtype); - - /** - * do not use CHANGE_MODIFIED if slowsync or (change not - * exist before if not filesync) - **/ - if ( ( (osync_group_get_slow_sync(engine->group, - osync_objtype_get_name(objtype))) || - ( (!is_file_objformat) && - (!osengine_mappingtable_find_entry( - engine->maptable, uid, - osync_objtype_get_name(objtype), - osync_member_get_id(client->member))) ) - ) && (change_type == CHANGE_MODIFIED) ){ - osync_change_set_changetype(change, CHANGE_ADDED); - change_type = osync_change_get_changetype(change); - } - } - } else - if (change_type == CHANGE_DELETED){ - /** - * we need to handle the special delete case where objtype - * is data and no uid with objtype data exists from this - * member - **/ - if ( !objtype || - (( !strcmp(osync_objtype_get_name(objtype), "data") ) && - ( !osengine_mappingtable_find_entry( - engine->maptable, uid, - osync_objtype_get_name(objtype), - osync_member_get_id(client->member)) )) ){ - - OSyncMappingEntry *entry = - osengine_mappingtable_find_entry( - engine->maptable, uid, NULL, - osync_member_get_id(client->member) - ); - if (entry) { - osync_change_set_objtype(change, - osync_change_get_objtype( - entry->change)); - objtype=osync_change_get_objtype(change); - } else { - osync_error_set(&error, OSYNC_ERROR_GENERIC, - "Could not find one entry with UID=%s to delete.", uid); - goto error; - } - } - } else { - osync_trace(TRACE_INTERNAL, "Change has no data!"); - } - - osync_trace(TRACE_INTERNAL, "Handling new change with uid %s, changetype %i, data %p, size %i, objtype %s and format %s from member %lli", uid, change_type, osync_change_get_data(change), osync_change_get_datasize(change), objtype ? osync_objtype_get_name(objtype) : "None", osync_change_get_objformat(change) ? osync_objformat_get_name(osync_change_get_objformat(change)) : "None", osync_member_get_id(client->member)); - - if (!objtype){ - osync_error_set(&error, OSYNC_ERROR_GENERIC, - "ObjType not set for uid %s.", uid); - goto error; - } - - - OSyncMappingEntry *entry = osengine_mappingtable_store_change(engine->maptable, change); - change = entry->change; - if (!osync_change_save(change, TRUE, &error)) { - osync_error_duplicate(&engine->error, &error); - osync_status_update_change(engine, change, CHANGE_RECV_ERROR, &error); - osync_error_update(&engine->error, "Unable to receive one or more objects"); - osync_flag_unset(entry->fl_has_data); - goto error; - } - - osync_group_remove_changelog(engine->group, change, &error); - - //We convert to the common format here to make sure we always pass it - osync_change_convert_to_common(change, NULL); - - if (!entry->mapping) { - osync_flag_attach(entry->fl_mapped, engine->cmb_entries_mapped); - osync_flag_unset(entry->fl_mapped); - osync_debug("ENG", 3, "+It has no mapping"); - } else { - osync_debug("ENG", 3, "+It has mapping"); - osync_flag_set(entry->fl_mapped); - osync_flag_unset(entry->mapping->fl_solved); - osync_flag_unset(entry->mapping->fl_chkconflict); - osync_flag_unset(entry->mapping->fl_multiplied); - } - - if (osync_change_has_data(change)) { - osync_debug("ENG", 3, "+It has data"); - osync_flag_set(entry->fl_has_data); - osync_status_update_change(engine, change, CHANGE_RECEIVED, NULL); - } else { - osync_debug("ENG", 3, "+It has no data"); - osync_flag_unset(entry->fl_has_data); - osync_status_update_change(engine, change, CHANGE_RECEIVED_INFO, NULL); - } - - if (osync_change_get_changetype(change) == CHANGE_DELETED) - osync_flag_set(entry->fl_deleted); - - osync_flag_set(entry->fl_has_info); - osync_flag_unset(entry->fl_synced); - - osengine_mappingentry_decider(engine, entry); - - osync_trace(TRACE_EXIT, "%s", __func__); - return; - -error: - osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(&error)); - osync_error_free(&error); - return; -} - -OSyncClient *osengine_get_client(OSyncEngine *engine, long long int memberId) -{ - GList *c = NULL; - for (c = engine->clients; c; c = c->next) { - OSyncClient *client = c->data; - if (osync_member_get_id(client->member) == memberId) - return client; - } - return NULL; -} - - -void send_engine_changed(OSyncEngine *engine) -{ - if (!engine->is_initialized) - return; - - OSyncMessage *message = osync_message_new(OSYNC_MESSAGE_ENGINE_CHANGED, 0, NULL); - /*FIXME: Handle errors here */ - - osync_debug("ENG", 4, "Sending message %p:\"ENGINE_CHANGED\"", message); - osync_queue_send_message(engine->commands_to_self, NULL, message, NULL); -} - -void send_mapping_changed(OSyncEngine *engine, OSyncMapping *mapping) -{ - OSyncMessage *message = osync_message_new(OSYNC_MESSAGE_MAPPING_CHANGED, sizeof(long long), NULL); - osync_message_write_long_long_int(message, mapping->id); - /*FIXME: Handle errors here */ - - osync_queue_send_message(engine->commands_to_self, NULL, message, NULL); - /*FIXME: Handle errors here, too */ -} - -void send_mappingentry_changed(OSyncEngine *engine, OSyncMappingEntry *entry) -{ - OSyncMessage *message = osync_message_new(OSYNC_MESSAGE_MAPPINGENTRY_CHANGED, sizeof(long long)*2, NULL); - - /*FIXME: don't pass a pointer through the messaging system */ - long long ptr = (long long)(long)entry; - osync_message_write_long_long_int(message, ptr); - /*FIXME: Handle errors here */ - - osync_queue_send_message(engine->commands_to_self, NULL, message, NULL); - /*FIXME: Handle errors here, too */ -} - -/*! @brief The queue message handler of the engine - * - * @param sender The Client who sent this message - * @param message The message - * @param engine The engine - * - */ -static void engine_message_handler(OSyncMessage *message, OSyncEngine *engine) -{ - osync_trace(TRACE_ENTRY, "engine_message_handler(%p:%lli-%i, %p)", message, message->id1, message->id2, engine); - - OSyncChange *change = NULL; - - osync_trace(TRACE_INTERNAL, "engine received command %i", osync_message_get_command(message)); - - switch (osync_message_get_command(message)) { - case OSYNC_MESSAGE_SYNCHRONIZE: - osync_trace(TRACE_INTERNAL, "all deciders"); - osengine_client_all_deciders(engine); - break; - case OSYNC_MESSAGE_NEW_CHANGE: - osync_demarshal_change(message, osync_group_get_format_env(engine->group), &change); - - long long int member_id = 0; - osync_message_read_long_long_int(message, &member_id); - OSyncClient *sender = osengine_get_client(engine, member_id); - - _new_change_receiver(engine, sender, change); - break; - case OSYNC_MESSAGE_ENGINE_CHANGED: - osengine_client_all_deciders(engine); - osengine_mapping_all_deciders(engine); - GList *u; - for (u = engine->maptable->unmapped; u; u = u->next) { - OSyncMappingEntry *unmapped = u->data; - send_mappingentry_changed(engine, unmapped); - } - break; - case OSYNC_MESSAGE_MAPPING_CHANGED: - { - long long id; - osync_message_read_long_long_int(message, &id); - /*FIXME: check errors by read_long_long_int */ - OSyncMapping *mapping = osengine_mappingtable_mapping_from_id(engine->maptable, id); - - if (!g_list_find(engine->maptable->mappings, mapping)) { - osync_trace(TRACE_EXIT, "%s: Mapping %p is dead", __func__, mapping); - return; - } - - osengine_mapping_decider(engine, mapping); - } - break; - case OSYNC_MESSAGE_MAPPINGENTRY_CHANGED: - { - long long ptr; - osync_message_read_long_long_int(message, &ptr); - OSyncMappingEntry *entry = (OSyncMappingEntry*)(long)ptr; - - if (!g_list_find(engine->maptable->entries, entry) && !g_list_find(engine->maptable->unmapped, entry)) { - osync_trace(TRACE_EXIT, "%s: Entry %p is dead", __func__, entry); - return; - } - - osengine_mappingentry_decider(engine, entry); - } - break; - case OSYNC_MESSAGE_SYNC_ALERT: - if (engine->allow_sync_alert) - osync_flag_set(engine->fl_running); - else - osync_trace(TRACE_INTERNAL, "Sync Alert not allowed"); - break; - - default: - break; - } - - /*TODO: Implement handling of the messages listed below, on commented code */ - - /* - if (osync_message_is_signal (message, "CLIENT_CHANGED")) { - OSyncClient *client = osync_message_get_data(message, "client"); - - if (!g_list_find(engine->clients, client)) { - osync_trace(TRACE_EXIT, "%s: Client %p is dead", __func__, client); - return; - } - - osengine_client_decider(engine, client); - osync_trace(TRACE_EXIT, "engine_message_handler"); - return; - } - - if (osync_message_is_signal (message, "PLUGIN_MESSAGE")) { - char *name = osync_message_get_data(message, "name"); - void *data = osync_message_get_data(message, "data"); - engine->plgmsg_callback(engine, sender, name, data, engine->plgmsg_userdata); - osync_trace(TRACE_EXIT, "engine_message_handler"); - return; - } - - osync_debug("ENG", 0, "Unknown message \"%s\"", osync_message_get_msgname(message)); - osync_trace(TRACE_EXIT_ERROR, "engine_message_handler: Unknown message"); - g_assert_not_reached();*/ - osync_trace(TRACE_EXIT, "%s", __func__); -} - -static void trigger_clients_sent_changes(OSyncEngine *engine) -{ - osync_trace(TRACE_ENTRY, "%s(%p)", __func__, engine); - osync_status_update_engine(engine, ENG_ENDPHASE_READ, NULL); - - g_mutex_lock(engine->info_received_mutex); - g_cond_signal(engine->info_received); - g_mutex_unlock(engine->info_received_mutex); - - //Load the old mappings - osengine_mappingtable_inject_changes(engine->maptable); - - send_engine_changed(engine); - osync_trace(TRACE_EXIT, "%s", __func__); -} - -static void trigger_clients_read_all(OSyncEngine *engine) -{ - osync_trace(TRACE_ENTRY, "%s(%p)", __func__, engine); - - send_engine_changed(engine); - osync_trace(TRACE_EXIT, "%s", __func__); -} - -static void trigger_status_end_conflicts(OSyncEngine *engine) -{ - osync_trace(TRACE_ENTRY, "%s(%p)", __func__, engine); - osync_status_update_engine(engine, ENG_END_CONFLICTS, NULL); - - osync_trace(TRACE_EXIT, "%s", __func__); -} - -static void trigger_clients_connected(OSyncEngine *engine) -{ - osync_trace(TRACE_ENTRY, "%s(%p)", __func__, engine); - osync_status_update_engine(engine, ENG_ENDPHASE_CON, NULL); - osengine_client_all_deciders(engine); - - osync_trace(TRACE_EXIT, "%s", __func__); -} - -static void trigger_clients_comitted_all(OSyncEngine *engine) -{ - osync_trace(TRACE_ENTRY, "%s(%p)", __func__, engine); - osync_status_update_engine(engine, ENG_ENDPHASE_WRITE, NULL); - - osync_trace(TRACE_EXIT, "%s", __func__); -} - - -/*void send_engine_committed_all(OSyncEngine *engine) -{ - osync_trace(TRACE_ENTRY, "%s(%p)", __func__, engine); - - engine->committed_all_sent = TRUE; - - osync_trace(TRACE_INTERNAL, "++++ ENGINE COMMAND: Committed all ++++"); - - GList *c = NULL; - for (c = engine->clients; c; c = c->next) { - OSyncClient *client = c->data; - if (osync_flag_is_not_set(client->fl_committed_all)) - send_committed_all(client, engine); - } - - osync_trace(TRACE_EXIT, "%s", __func__); -} - -static void trigger_engine_committed_all(OSyncEngine *engine) -{ - osync_trace(TRACE_ENTRY, "%s(%p)", __func__, engine); - - if (osync_flag_is_not_set(engine->cmb_multiplied)) { - osync_trace(TRACE_EXIT, "%s: Not multiplied yet", __func__); - return; - } - - send_engine_committed_all(engine); - - osync_trace(TRACE_EXIT, "%s", __func__); -}*/ - -static gboolean startupfunc(gpointer data) -{ - OSyncEngine *engine = data; - osync_trace(TRACE_INTERNAL, "+++++++++ This is the engine of group \"%s\" +++++++++", osync_group_get_name(engine->group)); - - OSyncError *error = NULL; - if (!osengine_mappingtable_load(engine->maptable, &error)) { - osync_error_duplicate(&engine->error, &error); - osync_status_update_engine(engine, ENG_ERROR, &error); - osync_error_update(&engine->error, "Unable to connect one of the members"); - osync_flag_set(engine->fl_stop); - } - - g_mutex_lock(engine->started_mutex); - g_cond_signal(engine->started); - g_mutex_unlock(engine->started_mutex); - return FALSE; -} - -/*@}*/ - -/** - * @defgroup OSEnginePublic OpenSync Engine API - * @ingroup PublicAPI - * @brief The API of the syncengine available to everyone - * - * This gives you an insight in the public API of the opensync sync engine. - * - */ -/*@{*/ - -/*! @brief This will reset the engine to its initial state - * - * This function will reset the engine to its initial state. The engine - * must not be running at this point. - * - * @param engine A pointer to the engine you want to reset - * @param error A pointer to a error struct - * @returns TRUE if command was succcessfull, FALSE otherwise - * - */ -osync_bool osengine_reset(OSyncEngine *engine, OSyncError **error) -{ - //FIXME Check if engine is running - osync_trace(TRACE_ENTRY, "osengine_reset(%p, %p)", engine, error); - GList *c = NULL; - for (c = engine->clients; c; c = c->next) { - OSyncClient *client = c->data; - osync_client_reset(client); - } - - osync_flag_set_state(engine->fl_running, FALSE); - osync_flag_set_state(engine->fl_stop, FALSE); - osync_flag_set_state(engine->cmb_sent_changes, FALSE); - osync_flag_set_state(engine->cmb_entries_mapped, TRUE); - osync_flag_set_state(engine->cmb_synced, TRUE); - osync_flag_set_state(engine->cmb_chkconflict, TRUE); - osync_flag_set_state(engine->cmb_finished, FALSE); - osync_flag_set_state(engine->cmb_connected, FALSE); - osync_flag_set_state(engine->cmb_read_all, TRUE); - osync_flag_set_state(engine->cmb_committed_all, TRUE); - osync_flag_set_state(engine->cmb_committed_all_sent, FALSE); - - osync_status_update_engine(engine, ENG_ENDPHASE_DISCON, NULL); - - engine->committed_all_sent = FALSE; - - osengine_mappingtable_reset(engine->maptable); - - if (engine->error) { - //FIXME We might be leaking memory here - OSyncError *newerror = NULL; - osync_error_duplicate(&newerror, &engine->error); - osync_status_update_engine(engine, ENG_ERROR, &newerror); - osync_group_set_slow_sync(engine->group, "data", TRUE); - } else { - osync_status_update_engine(engine, ENG_SYNC_SUCCESSFULL, NULL); - osync_group_reset_slow_sync(engine->group, "data"); - } - - osync_trace(TRACE_INTERNAL, "engine error is %p", engine->error); - - g_mutex_lock(engine->syncing_mutex); - g_cond_signal(engine->syncing); - g_mutex_unlock(engine->syncing_mutex); - - osync_trace(TRACE_EXIT, "osengine_reset"); - return TRUE; -} - -/* Implementation of g_mkdir_with_parents() - * - * This function overwrite the contents of the 'dir' parameter - */ -static int __mkdir_with_parents(char *dir, int mode) -{ - if (g_file_test(dir, G_FILE_TEST_IS_DIR)) - return 0; - - char *slash = strrchr(dir, '/'); - if (slash && slash != dir) { - /* Create parent directory if needed */ - - /* This is a trick: I don't want to allocate a new string - * for the parent directory. So, just put a NUL char - * in the last slash, and restore it after creating the - * parent directory - */ - *slash = '\0'; - if (__mkdir_with_parents(dir, mode) < 0) - return -1; - *slash = '/'; - } - - if (mkdir(dir, mode) < 0) - return -1; - - return 0; -} - -static int mkdir_with_parents(const char *dir, int mode) -{ - int r; - char *mydir = strdup(dir); - if (!mydir) - return -1; - - r = __mkdir_with_parents(mydir, mode); - free(mydir); - return r; -} - -/*! @brief This will create a new engine for the given group - * - * This will create a new engine for the given group - * - * @param group A pointer to the group, for which you want to create a new engine - * @param error A pointer to a error struct - * @returns Pointer to a newly allocated OSyncEngine on success, NULL otherwise - * - */ -OSyncEngine *osengine_new(OSyncGroup *group, OSyncError **error) -{ - osync_trace(TRACE_ENTRY, "%s(%p, %p)", __func__, group, error); - - g_assert(group); - OSyncEngine *engine = g_malloc0(sizeof(OSyncEngine)); - osync_group_set_data(group, engine); - - if (!g_thread_supported ()) - g_thread_init (NULL); - - engine->context = g_main_context_new(); - engine->syncloop = g_main_loop_new(engine->context, FALSE); - engine->group = group; - - OSyncUserInfo *user = osync_user_new(error); - if (!user) - goto error; - - char *enginesdir = g_strdup_printf("%s/engines", osync_user_get_confdir(user)); - char *path = g_strdup_printf("%s/enginepipe", enginesdir); - - if (mkdir_with_parents(enginesdir, 0755) < 0) { - osync_error_set(error, OSYNC_ERROR_GENERIC, "Couldn't create engines directory: %s", strerror(errno)); - goto error_free_paths; - } - - engine->syncing_mutex = g_mutex_new(); - engine->info_received_mutex = g_mutex_new(); - engine->syncing = g_cond_new(); - engine->info_received = g_cond_new(); - engine->started_mutex = g_mutex_new(); - engine->started = g_cond_new(); - - //Set the default start flags - engine->fl_running = osync_flag_new(NULL); - osync_flag_set_pos_trigger(engine->fl_running, (OSyncFlagTriggerFunc)osengine_client_all_deciders, engine, NULL); - - engine->fl_sync = osync_flag_new(NULL); - engine->fl_stop = osync_flag_new(NULL); - osync_flag_set_pos_trigger(engine->fl_stop, (OSyncFlagTriggerFunc)osengine_client_all_deciders, engine, NULL); - - //The combined flags - engine->cmb_sent_changes = osync_comb_flag_new(FALSE, FALSE); - osync_flag_set_pos_trigger(engine->cmb_sent_changes, (OSyncFlagTriggerFunc)trigger_clients_sent_changes, engine, NULL); - - engine->cmb_read_all = osync_comb_flag_new(FALSE, TRUE); - osync_flag_set_pos_trigger(engine->cmb_read_all, (OSyncFlagTriggerFunc)trigger_clients_read_all, engine, NULL); - - engine->cmb_entries_mapped = osync_comb_flag_new(FALSE, FALSE); - osync_flag_set_pos_trigger(engine->cmb_entries_mapped, (OSyncFlagTriggerFunc)send_engine_changed, engine, NULL); - - - engine->cmb_synced = osync_comb_flag_new(FALSE, TRUE); - osync_flag_set_pos_trigger(engine->cmb_synced, (OSyncFlagTriggerFunc)send_engine_changed, engine, NULL); - - - engine->cmb_finished = osync_comb_flag_new(FALSE, TRUE); - osync_flag_set_pos_trigger(engine->cmb_finished, (OSyncFlagTriggerFunc)osengine_reset, engine, NULL); - - engine->cmb_connected = osync_comb_flag_new(FALSE, FALSE); - osync_flag_set_pos_trigger(engine->cmb_connected, (OSyncFlagTriggerFunc)trigger_clients_connected, engine, NULL); - - engine->cmb_chkconflict = osync_comb_flag_new(FALSE, TRUE); - osync_flag_set_pos_trigger(engine->cmb_chkconflict, (OSyncFlagTriggerFunc)trigger_status_end_conflicts, engine, NULL); - - engine->cmb_multiplied = osync_comb_flag_new(FALSE, TRUE); - - engine->cmb_committed_all = osync_comb_flag_new(FALSE, TRUE); - osync_flag_set_pos_trigger(engine->cmb_committed_all, (OSyncFlagTriggerFunc)send_engine_changed, engine, NULL); - - - engine->cmb_committed_all_sent = osync_comb_flag_new(FALSE, TRUE); - osync_flag_set_pos_trigger(engine->cmb_committed_all_sent, (OSyncFlagTriggerFunc)trigger_clients_comitted_all, engine, NULL); - - osync_flag_set(engine->fl_sync); - - int i; - for (i = 0; i < osync_group_num_members(group); i++) { - OSyncMember *member = osync_group_nth_member(group, i); - if (!osync_client_new(engine, member, error)) - goto error_free_paths; - } - - engine->maptable = osengine_mappingtable_new(engine); - - osync_trace(TRACE_EXIT, "osengine_new: %p", engine); - return engine; - -error_free_paths: - g_free(path); - g_free(enginesdir); -error: - osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(error)); - return NULL; -} - -/*! @brief This will free a engine and all resources associated - * - * This will free a engine and all resources associated - * - * @param engine A pointer to the engine, which you want to free - * - */ -void osengine_free(OSyncEngine *engine) -{ - osync_trace(TRACE_ENTRY, "osengine_free(%p)", engine); - - GList *c = NULL; - for (c = engine->clients; c; c = c->next) { - OSyncClient *client = c->data; - osync_client_free(client); - } - - osengine_mappingtable_free(engine->maptable); - engine->maptable = NULL; - - osync_flag_free(engine->fl_running); - osync_flag_free(engine->fl_sync); - osync_flag_free(engine->fl_stop); - osync_flag_free(engine->cmb_sent_changes); - osync_flag_free(engine->cmb_entries_mapped); - osync_flag_free(engine->cmb_synced); - osync_flag_free(engine->cmb_chkconflict); - osync_flag_free(engine->cmb_finished); - osync_flag_free(engine->cmb_connected); - osync_flag_free(engine->cmb_read_all); - osync_flag_free(engine->cmb_multiplied); - osync_flag_free(engine->cmb_committed_all); - osync_flag_free(engine->cmb_committed_all_sent); - - g_list_free(engine->clients); - g_main_loop_unref(engine->syncloop); - - g_main_context_unref(engine->context); - - g_mutex_free(engine->syncing_mutex); - g_mutex_free(engine->info_received_mutex); - g_cond_free(engine->syncing); - g_cond_free(engine->info_received); - g_mutex_free(engine->started_mutex); - g_cond_free(engine->started); - - g_free(engine); - osync_trace(TRACE_EXIT, "osengine_free"); -} - -/*! @brief This will set the conflict handler for the given engine - * - * The conflict handler will be called everytime a conflict occurs - * - * @param engine A pointer to the engine, for which to set the callback - * @param function A pointer to a function which will receive the conflict - * @param user_data Pointer to some data that will get passed to the status function as the last argument - * - */ -void osengine_set_conflict_callback(OSyncEngine *engine, void (* function) (OSyncEngine *, OSyncMapping *, void *), void *user_data) -{ - engine->conflict_callback = function; - engine->conflict_userdata = user_data; -} - -/*! @brief This will set the change status handler for the given engine - * - * The change status handler will be called every time a new change is received, written etc - * - * @param engine A pointer to the engine, for which to set the callback - * @param function A pointer to a function which will receive the change status - * @param user_data Pointer to some data that will get passed to the status function as the last argument - * - */ -void osengine_set_changestatus_callback(OSyncEngine *engine, void (* function) (OSyncEngine *, OSyncChangeUpdate *, void *), void *user_data) -{ - engine->changestat_callback = function; - engine->changestat_userdata = user_data; -} - -/*! @brief This will set the mapping status handler for the given engine - * - * The mapping status handler will be called every time a mapping is updated - * - * @param engine A pointer to the engine, for which to set the callback - * @param function A pointer to a function which will receive the mapping status - * @param user_data Pointer to some data that will get passed to the status function as the last argument - * - */ -void osengine_set_mappingstatus_callback(OSyncEngine *engine, void (* function) (OSyncMappingUpdate *, void *), void *user_data) -{ - engine->mapstat_callback = function; - engine->mapstat_userdata = user_data; -} - -/*! @brief This will set the engine status handler for the given engine - * - * The engine status handler will be called every time the engine is updated (started, stoped etc) - * - * @param engine A pointer to the engine, for which to set the callback - * @param function A pointer to a function which will receive the engine status - * @param user_data Pointer to some data that will get passed to the status function as the last argument - * - */ -void osengine_set_enginestatus_callback(OSyncEngine *engine, void (* function) (OSyncEngine *, OSyncEngineUpdate *, void *), void *user_data) -{ - engine->engstat_callback = function; - engine->engstat_userdata = user_data; -} - -/*! @brief This will set the member status handler for the given engine - * - * The member status handler will be called every time a member is updated (connects, disconnects etc) - * - * @param engine A pointer to the engine, for which to set the callback - * @param function A pointer to a function which will receive the member status - * @param user_data Pointer to some data that will get passed to the status function as the last argument - * - */ -void osengine_set_memberstatus_callback(OSyncEngine *engine, void (* function) (OSyncMemberUpdate *, void *), void *user_data) -{ - engine->mebstat_callback = function; - engine->mebstat_userdata = user_data; -} - -/*! @brief This will set the callback handler for a custom message - * - * A custom message can be used to communicate with a plugin directly - * - * @param engine A pointer to the engine, for which to set the callback - * @param function A pointer to a function which will receive the member status - * @param user_data A pointer to some user data that the callback function will get passed - * - */ -void osengine_set_message_callback(OSyncEngine *engine, void *(* function) (OSyncEngine *, OSyncClient *, const char *, void *, void *), void *user_data) -{ - engine->plgmsg_callback = function; - engine->plgmsg_userdata = user_data; -} - -/*! @brief This will initialize a engine - * - * After initialization, the engine will be ready to sync. The threads for the engine, - * the members are started. If one of the members has a listening server, the server will be - * started and listening. - * - * @param engine A pointer to the engine, which will be initialized - * @param error A pointer to a error struct - * @returns TRUE on success, FALSE otherwise. Check the error on FALSE. - * - */ -osync_bool osengine_init(OSyncEngine *engine, OSyncError **error) -{ - osync_trace(TRACE_ENTRY, "osengine_init(%p, %p)", engine, error); - - if (engine->is_initialized) { - osync_error_set(error, OSYNC_ERROR_MISCONFIGURATION, "This engine was already initialized"); - osync_trace(TRACE_EXIT_ERROR, "osengine_init: %s", osync_error_print(error)); - return FALSE; - } - - switch (osync_group_lock(engine->group)) { - case OSYNC_LOCKED: - osync_error_set(error, OSYNC_ERROR_LOCKED, "Group is locked"); - osync_trace(TRACE_EXIT_ERROR, "osengine_init: %s", osync_error_print(error)); - return FALSE; - case OSYNC_LOCK_STALE: - osync_debug("ENG", 1, "Detected stale lock file. Slow-syncing"); - osync_status_update_engine(engine, ENG_PREV_UNCLEAN, NULL); - osync_group_set_slow_sync(engine->group, "data", TRUE); - break; - default: - break; - } - - osync_flag_set(engine->cmb_entries_mapped); - osync_flag_set(engine->cmb_synced); - engine->allow_sync_alert = TRUE; - - //OSyncMember *member = NULL; - OSyncGroup *group = engine->group; - - if (osync_group_num_members(group) < 2) { - //Not enough members! - osync_error_set(error, OSYNC_ERROR_MISCONFIGURATION, "You only configured %i members, but at least 2 are needed", osync_group_num_members(group)); - osync_group_unlock(engine->group, TRUE); - osync_trace(TRACE_EXIT_ERROR, "osengine_init: %s", osync_error_print(error)); - return FALSE; - } - - engine->is_initialized = TRUE; - - osync_trace(TRACE_INTERNAL, "Spawning clients"); - GList *c = NULL; - for (c = engine->clients; c; c = c->next) { - OSyncClient *client = c->data; - osync_queue_create(client->commands_from_osplugin, NULL); - - if (!osync_client_spawn(client, engine, error)) { - osync_group_unlock(engine->group, TRUE); - osync_trace(TRACE_EXIT_ERROR, "osengine_init: %s", osync_error_print(error)); - return FALSE; - } - - osync_queue_set_message_handler(client->commands_from_osplugin, (OSyncMessageHandler)engine_message_handler, engine); - if (!(engine->man_dispatch)) - osync_queue_setup_with_gmainloop(client->commands_from_osplugin, engine->context); - osync_trace(TRACE_INTERNAL, "opening client queue"); - if (!osync_queue_connect(client->commands_from_osplugin, OSYNC_QUEUE_RECEIVER, 0 )) { - osync_group_unlock(engine->group, TRUE); - osync_trace(TRACE_EXIT_ERROR, "osengine_init: %s", osync_error_print(error)); - return FALSE; - } - } - - osync_trace(TRACE_INTERNAL, "opening engine queue"); - if (!osync_queue_new_pipes(&engine->commands_from_self, &engine->commands_to_self, error)) { - osync_group_unlock(engine->group, TRUE); - osync_trace(TRACE_EXIT_ERROR, "osengine_init: %s", osync_error_print(error)); - return FALSE; - } - - if (!osync_queue_connect(engine->commands_from_self, OSYNC_QUEUE_RECEIVER, 0 )) { - osync_group_unlock(engine->group, TRUE); - osync_trace(TRACE_EXIT_ERROR, "osengine_init: %s", osync_error_print(error)); - return FALSE; - } - - if (!osync_queue_connect(engine->commands_to_self, OSYNC_QUEUE_SENDER, 0 )) { - osync_group_unlock(engine->group, TRUE); - osync_trace(TRACE_EXIT_ERROR, "osengine_init: %s", osync_error_print(error)); - return FALSE; - } - - osync_queue_set_message_handler(engine->commands_from_self, (OSyncMessageHandler)engine_message_handler, engine); - if (!(engine->man_dispatch)) - osync_queue_setup_with_gmainloop(engine->commands_from_self, engine->context); - - osync_trace(TRACE_INTERNAL, "initializing clients"); - for (c = engine->clients; c; c = c->next) { - OSyncClient *client = c->data; - if (!osync_client_init(client, engine, error)) { - osengine_finalize(engine); - osync_group_unlock(engine->group, TRUE); - osync_trace(TRACE_EXIT_ERROR, "osengine_init: %s", osync_error_print(error)); - return FALSE; - } - } - - osync_debug("ENG", 3, "Running the main loop"); - - //Now we can run the main loop - //We protect the startup by a g_cond - g_mutex_lock(engine->started_mutex); - GSource *idle = g_idle_source_new(); - g_source_set_priority(idle, G_PRIORITY_HIGH); - g_source_set_callback(idle, startupfunc, engine, NULL); - g_source_attach(idle, engine->context); - engine->thread = g_thread_create ((GThreadFunc)g_main_loop_run, engine->syncloop, TRUE, NULL); - g_cond_wait(engine->started, engine->started_mutex); - g_mutex_unlock(engine->started_mutex); - - osync_trace(TRACE_EXIT, "osengine_init"); - return TRUE; -} - -/*! @brief This will finalize a engine - * - * Finalizing a engine will stop all threads and listening server. - * The engine can be initialized again. - * - * @param engine A pointer to the engine, which will be finalized - * - */ -void osengine_finalize(OSyncEngine *engine) -{ - //FIXME check if engine is running - osync_trace(TRACE_ENTRY, "osengine_finalize(%p)", engine); - - if (!engine->is_initialized) { - osync_trace(TRACE_EXIT_ERROR, "osengine_finalize: Not initialized"); - return; - } - - g_assert(engine); - osync_debug("ENG", 3, "finalizing engine %p", engine); - - if (engine->thread) { - g_main_loop_quit(engine->syncloop); - g_thread_join(engine->thread); - } - - GList *c = NULL; - for (c = engine->clients; c; c = c->next) { - OSyncClient *client = c->data; - osync_queue_disconnect(client->commands_from_osplugin, NULL); - osync_client_finalize(client, NULL); - } - - osync_queue_disconnect(engine->commands_from_self, NULL); - osync_queue_disconnect(engine->commands_to_self, NULL); - - osync_queue_free(engine->commands_from_self); - engine->commands_from_self = NULL; - osync_queue_free(engine->commands_to_self); - engine->commands_to_self = NULL; - - osengine_mappingtable_close(engine->maptable); - - if (engine->error) { - /* If the error occured during connect, we - * dont want to trigger a slow-sync the next - * time. In the case the we have a slow-sync - * right in the beginning, we also dont remove - * the lockfile to trigger a slow-sync again - * next time */ - if (!osync_flag_is_set(engine->cmb_connected) && !engine->slowsync) - osync_group_unlock(engine->group, TRUE); - else - osync_group_unlock(engine->group, FALSE); - } else - osync_group_unlock(engine->group, TRUE); - - engine->is_initialized = FALSE; - osync_trace(TRACE_EXIT, "osengine_finalize"); -} - -/*! @brief Starts to synchronize the given OSyncEngine - * - * This function synchronizes a given engine. The Engine has to be created - * from a OSyncGroup before by using osengine_new(). This function will not block - * - * @param engine A pointer to the engine, which will be used to sync - * @param error A pointer to a error struct - * @returns TRUE on success, FALSE otherwise. Check the error on FALSE. Note that this just says if the sync has been started successfully, not if the sync itself was successfull - * - */ -osync_bool osengine_synchronize(OSyncEngine *engine, OSyncError **error) -{ - osync_trace(TRACE_INTERNAL, "synchronize now"); - osync_trace(TRACE_ENTRY, "%s(%p)", __func__, engine); - g_assert(engine); - - if (!engine->is_initialized) { - osync_error_set(error, OSYNC_ERROR_GENERIC, "osengine_synchronize: Not initialized"); - goto error; - } - - /* We now remember if slow-sync is set right from the start. - * If it is, we dont remove the lock file in the case of - * a error during connect. */ - if (osync_group_get_slow_sync(engine->group, "data")) { - engine->slowsync = TRUE; - } else { - engine->slowsync = FALSE; - } - - engine->wasted = 0; - engine->alldeciders = 0; - - osync_flag_set(engine->fl_running); - - OSyncMessage *message = osync_message_new(OSYNC_MESSAGE_SYNCHRONIZE, 0, error); - if (!message) - goto error; - - if (!osync_queue_send_message(engine->commands_to_self, NULL, message, error)) - goto error_free_message; - - osync_message_unref(message); - - osync_trace(TRACE_EXIT, "%s", __func__); - return TRUE; - -error_free_message: - osync_message_unref(message); -error: - osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(error)); - return FALSE; -} - -/*! @brief Sets a flag on the engine that the engine should only request the info about sync objects - * - * This can be used to see only what has changed. The engine will not request the data itself from - * the members. Note that some members might not support this behaviour and might send the data anyways. - * - * @param engine A pointer to the engine, for which to set the flag - */ -void osengine_flag_only_info(OSyncEngine *engine) -{ - osync_flag_unset(engine->fl_sync); -} - -/*! @brief Sets a flag on the engine that the engine should do single stepping (For debugging) - * - * This flag can be used to set single stepping on the engine. The engine will pause after each iteration. - * Use osengine_one_iteration to initialize the next iteration. This is only for debugging purposes. - * - * @param engine A pointer to the engine, for which to set the flag - */ -void osengine_flag_manual(OSyncEngine *engine) -{ - if (engine->syncloop) { - g_warning("Unable to flag manual since engine is already initialized\n"); - } - engine->man_dispatch = TRUE; -} - -/*! @brief This will pause the engine - * - * This flag can be used to temporarily suspend the engine - * - * @param engine A pointer to the engine, for which to set the flag - */ -void osengine_pause(OSyncEngine *engine) -{ - osync_flag_unset(engine->fl_running); -} - -/*! @brief Sets a flag on the engine that the engine should do single stepping (For debugging) - * - * This flag can be used to set single stepping on the engine. The engine will pause after each iteration. - * Use osengine_one_iteration to initialize the next iteration. This is only for debugging purposes. - * - * @param engine A pointer to the engine, for which to set the flag - */ -void osengine_abort(OSyncEngine *engine) -{ - osync_flag_set(engine->fl_stop); -} - -/*! @brief Allows that the engine can be started by a member - * - * Allow the engine to by started by a member by sending a sync alert. - * - * @param engine The engine - */ -void osengine_allow_sync_alert(OSyncEngine *engine) -{ - engine->allow_sync_alert = TRUE; -} - -/*! @brief Do not allow that the engine can be started by a member - * - * Do not allow the engine to by started by a member by sending a sync alert. - * - * @param engine The engine - */ -void osengine_deny_sync_alert(OSyncEngine *engine) -{ - engine->allow_sync_alert = FALSE; -} - -/*! @brief This function will synchronize once and block until the sync has finished - * - * This can be used to sync a group and wait for the synchronization end. DO NOT USE - * osengine_wait_sync_end for this as this might introduce a race condition. - * - * @param engine A pointer to the engine, which to sync and wait for the sync end - * @param error A pointer to a error struct - * @returns TRUE on success, FALSE otherwise. - * - */ -osync_bool osengine_sync_and_block(OSyncEngine *engine, OSyncError **error) -{ - osync_trace(TRACE_ENTRY, "%s(%p, %p)", __func__, engine, error); - - g_mutex_lock(engine->syncing_mutex); - - if (!osengine_synchronize(engine, error)) { - g_mutex_unlock(engine->syncing_mutex); - goto error; - } - - g_cond_wait(engine->syncing, engine->syncing_mutex); - g_mutex_unlock(engine->syncing_mutex); - - if (engine->error) { - osync_error_duplicate(error, &(engine->error)); - goto error; - } - - osync_trace(TRACE_EXIT, "%s", __func__); - return TRUE; - -error: - osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(error)); - return FALSE; -} - -/*! @brief This function will block until a synchronization has ended - * - * This can be used to wait until the synchronization has ended. Note that this function will always - * block until 1 sync has ended. It can be used before the sync has started, to wait for one auto-sync - * to end - * - * @param engine A pointer to the engine, for which to wait for the sync end - * @param error Return location for the error if the sync was not successfull - * @returns TRUE on success, FALSE otherwise. - */ -osync_bool osengine_wait_sync_end(OSyncEngine *engine, OSyncError **error) -{ - g_mutex_lock(engine->syncing_mutex); - g_cond_wait(engine->syncing, engine->syncing_mutex); - g_mutex_unlock(engine->syncing_mutex); - - if (engine->error) { - osync_error_duplicate(error, &(engine->error)); - return FALSE; - } - return TRUE; -} - -/*! @brief This function will block until all change object information has been received - * - * This will block until the information and not the data has been received. - * - * @param engine A pointer to the engine, for which to wait for the info - */ -void osengine_wait_info_end(OSyncEngine *engine) -{ - g_mutex_lock(engine->info_received_mutex); - g_cond_wait(engine->info_received, engine->info_received_mutex); - g_mutex_unlock(engine->info_received_mutex); -} - -/*! @brief Does one iteration of the engine (For debugging) - * - * @param engine The engine to iterate - */ -void osengine_one_iteration(OSyncEngine *engine) -{ - /*TODO: Reimplement support to stepping mode on engine */ - abort();//osync_queue_dispatch(engine->incoming); -} - -/*! @brief Searches for a mapping by its id - * - * @param engine The engine - * @param id The id of the mapping - * @returns The mapping or NULL if not found - */ -OSyncMapping *osengine_mapping_from_id(OSyncEngine *engine, long long int id) -{ - return osengine_mappingtable_mapping_from_id(engine->maptable, id); -} - -/** @}*/ diff --git a/debian/opensync/opensync-0.22/osengine/osengine_engine.h b/debian/opensync/opensync-0.22/osengine/osengine_engine.h deleted file mode 100644 index 0b8b1ea0..00000000 --- a/debian/opensync/opensync-0.22/osengine/osengine_engine.h +++ /dev/null @@ -1,26 +0,0 @@ -OSyncEngine *osengine_new(OSyncGroup *group, OSyncError **); -void osengine_free(OSyncEngine *engine); - -void osengine_calculate_flags(OSyncEngine *engine); -void osengine_client_all_deciders(OSyncEngine *engine); -void osengine_decider(OSyncEngine *engine); -void osengine_client_decider(OSyncEngine *engine, OSyncClient *client); -void osengine_changes_done(OSyncEngine *engine, OSyncMember *member); -osync_bool osengine_init(OSyncEngine *engine, OSyncError **); -void osengine_finalize(OSyncEngine *engine); -void osengine_flag_only_info(OSyncEngine *engine); -osync_bool osengine_synchronize(OSyncEngine *engine, OSyncError **); -void osengine_pause(OSyncEngine *engine); -void osengine_abort(OSyncEngine *engine); -osync_bool osengine_wait_sync_end(OSyncEngine *engine, OSyncError **error); -void osengine_wait_info_end(OSyncEngine *engine); -void osengine_one_iteration(OSyncEngine *engine); -void osengine_flag_manual(OSyncEngine *engine); -void osengine_set_message_callback(OSyncEngine *engine, void *(* function) (OSyncEngine *, OSyncClient *, const char *, void *, void *), void *user_data); -void osengine_set_conflict_callback(OSyncEngine *engine, void (* function) (OSyncEngine *, OSyncMapping *, void *), void *user_data); -void osengine_set_changestatus_callback(OSyncEngine *engine, void (* function) (OSyncEngine*, OSyncChangeUpdate *, void *), void *user_data); -void osengine_set_mappingstatus_callback(OSyncEngine *engine, void (* function) (OSyncMappingUpdate *, void *), void *user_data); -void osengine_set_enginestatus_callback(OSyncEngine *engine, void (* function) (OSyncEngine *, OSyncEngineUpdate *, void *), void *user_data); -void osengine_set_memberstatus_callback(OSyncEngine *engine, void (* function) (OSyncMemberUpdate *, void *), void *user_data); -osync_bool osengine_sync_and_block(OSyncEngine *engine, OSyncError **error); -OSyncMapping *osengine_mapping_from_id(OSyncEngine *engine, long long id); diff --git a/debian/opensync/opensync-0.22/osengine/osengine_engine_internals.h b/debian/opensync/opensync-0.22/osengine/osengine_engine_internals.h deleted file mode 100644 index 9f4170df..00000000 --- a/debian/opensync/opensync-0.22/osengine/osengine_engine_internals.h +++ /dev/null @@ -1,80 +0,0 @@ - -#ifndef DOXYGEN_SHOULD_SKIP_THIS -struct OSyncEngine { - /** The real opensync group **/ - OSyncGroup *group; - void (* conflict_callback) (OSyncEngine *, OSyncMapping *, void *); - void *conflict_userdata; - void (* changestat_callback) (OSyncEngine *, OSyncChangeUpdate *, void *); - void *changestat_userdata; - void (* mebstat_callback) (OSyncMemberUpdate *, void *); - void *mebstat_userdata; - void (* engstat_callback) (OSyncEngine *, OSyncEngineUpdate *, void *); - void *engstat_userdata; - void (* mapstat_callback) (OSyncMappingUpdate *, void *); - void *mapstat_userdata; - void *(* plgmsg_callback) (OSyncEngine *, OSyncClient *, const char *, void *, void *); - void *plgmsg_userdata; - /** A list of connected clients **/ - GList *clients; - /** The g_main_loop of this engine **/ - GMainLoop *syncloop; - GMainContext *context; - /** The incoming queue of this engine **/ - OSyncQueue *commands_from_self; - OSyncQueue *commands_to_self; - - GCond* syncing; - GMutex* syncing_mutex; - - GCond* info_received; - GMutex* info_received_mutex; - - GCond* started; - GMutex* started_mutex; - - //The normal flags - OSyncFlag *fl_running; //Is the syncengine running? - OSyncFlag *fl_sync; //Do we want to sync data or do we just want info? - OSyncFlag *fl_stop; //Do we want to stop the engine? - - //The combined flags - OSyncFlag *cmb_connected; //Did all client connect or error? - OSyncFlag *cmb_sent_changes; //Did all clients sent changes? - OSyncFlag *cmb_entries_mapped; //Do we have unmapped entries? - OSyncFlag *cmb_synced; //Are all mappings synced? - OSyncFlag *cmb_finished; //Are all clients done and disconnected? - OSyncFlag *cmb_chkconflict; - OSyncFlag *cmb_read_all; - OSyncFlag *cmb_multiplied; - OSyncFlag *cmb_committed_all; - OSyncFlag *cmb_committed_all_sent; - - osync_bool man_dispatch; - osync_bool allow_sync_alert; - OSyncMappingTable *maptable; - osync_bool is_initialized; - osync_bool committed_all_sent; - - OSyncError *error; - GThread *thread; - - int wasted; - int alldeciders; - - osync_bool slowsync; -}; -#endif - -void send_client_changed(OSyncEngine *engine, OSyncClient *client); -void send_mappingentry_changed(OSyncEngine *engine, OSyncMappingEntry *entry); -void send_mapping_changed(OSyncEngine *engine, OSyncMapping *mapping); -void send_get_change_data(OSyncEngine *sender, OSyncMappingEntry *entry); -void send_commit_change(OSyncEngine *sender, OSyncMappingEntry *entry); -void send_connect(OSyncClient *target, OSyncEngine *sender); -void send_get_changes(OSyncClient *target, OSyncEngine *sender, osync_bool data); -void send_sync_done(OSyncClient *target, OSyncEngine *sender); -void send_disconnect(OSyncClient *target, OSyncEngine *sender); -void send_read_change(OSyncEngine *sender, OSyncMappingEntry *entry); -void send_engine_changed(OSyncEngine *engine); -void send_committed_all(OSyncClient *target, OSyncEngine *sender); diff --git a/debian/opensync/opensync-0.22/osengine/osengine_flags.c b/debian/opensync/opensync-0.22/osengine/osengine_flags.c deleted file mode 100644 index 77c7f5df..00000000 --- a/debian/opensync/opensync-0.22/osengine/osengine_flags.c +++ /dev/null @@ -1,221 +0,0 @@ -/* - * libosengine - A synchronization engine for the opensync framework - * Copyright (C) 2004-2005 Armin Bauer <armin.bauer@opensync.org> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -#include "engine.h" -#include "engine_internals.h" - -OSyncFlag *osync_flag_new(OSyncFlag *parent) -{ - OSyncFlag *flag = g_malloc0(sizeof(OSyncFlag)); - flag->is_set = FALSE; - if (parent) { - flag->comb_flag = parent; - parent->num_not_set++; - osync_flag_calculate_comb(parent); - } - return flag; -} - -void osync_flag_free(OSyncFlag *flag) -{ - g_free(flag); -} - -OSyncFlag *osync_comb_flag_new(osync_bool any, osync_bool default_val) -{ - OSyncFlag *flag = osync_flag_new(NULL); - flag->is_comb = TRUE; - flag->is_any = any; - flag->default_val = default_val; - flag->is_set = default_val; - return flag; -} - -void osync_flag_attach(OSyncFlag *flag, OSyncFlag *target) -{ - if (flag->comb_flag) - return; - g_assert(target->is_comb); - flag->comb_flag = target; - if (flag->is_set) { - target->num_set++; - } else { - target->num_not_set++; - } - osync_flag_calculate_comb(target); -} - -osync_bool osync_flag_is_attached(OSyncFlag *flag) -{ - if (flag->comb_flag) - return TRUE; - return FALSE; -} - -void osync_flag_detach(OSyncFlag *flag) -{ - OSyncFlag *target = flag->comb_flag; - if (!target) - return; - if (flag->is_set) { - target->num_set--; - } else { - target->num_not_set--; - } - flag->comb_flag = NULL; - osync_flag_calculate_comb(target); -} - -void osync_flag_set_pos_trigger(OSyncFlag *flag, OSyncFlagTriggerFunc func, void *data1, void *data2) -{ - flag->pos_trigger_func = func; - flag->pos_user_data1 = data1; - flag->pos_user_data2 = data2; -} - -void osync_flag_set_neg_trigger(OSyncFlag *flag, OSyncFlagTriggerFunc func, void *data1, void *data2) -{ - flag->neg_trigger_func = func; - flag->neg_user_data1 = data1; - flag->neg_user_data2 = data2; -} - -void osync_flag_calculate_comb(OSyncFlag *flag) -{ - if (!flag->is_comb) - return; - - if (!flag->num_not_set && !flag->num_set) { - if (flag->default_val) - osync_flag_set(flag); - else - osync_flag_unset(flag); - return; - } - - if (!flag->is_any) { - if (!flag->num_not_set && flag->num_set) { - osync_flag_set(flag); - } else { - osync_flag_unset(flag); - } - } else { - if (flag->num_set) { - osync_flag_set(flag); - } else { - osync_flag_unset(flag); - } - } -} - -osync_bool osync_flag_is_set(OSyncFlag *flag) -{ - if (flag->is_set == TRUE && flag->is_changing == FALSE) - return TRUE; - return FALSE; -} - -osync_bool osync_flag_is_not_set(OSyncFlag *flag) -{ - if (flag->is_set == FALSE && flag->is_changing == FALSE) - return TRUE; - return FALSE; -} - -void osync_comb_flag_update(OSyncFlag *combflag, OSyncFlag *flag, osync_bool prev_state) -{ - if (prev_state == flag->is_set) - return; - if (flag->is_set) { - combflag->num_not_set--; - combflag->num_set++; - } else { - combflag->num_not_set++; - combflag->num_set--; - } -} - -void osync_flag_changing(OSyncFlag *flag) -{ - flag->is_changing = TRUE; -} - -void osync_flag_cancel(OSyncFlag *flag) -{ - flag->is_changing = FALSE; -} - -void osync_flag_unset(OSyncFlag *flag) -{ - osync_bool oldstate = flag->is_set; - flag->is_set = FALSE; - flag->is_changing = FALSE; - osync_flag_calc_trigger(flag, oldstate); - if (flag->comb_flag) { - osync_comb_flag_update(flag->comb_flag, flag, oldstate); - osync_flag_calculate_comb(flag->comb_flag); - } -} - -void osync_flag_set(OSyncFlag *flag) -{ - osync_bool oldstate = flag->is_set; - flag->is_set = TRUE; - flag->is_changing = FALSE; - osync_flag_calc_trigger(flag, oldstate); - if (flag->comb_flag) { - osync_comb_flag_update(flag->comb_flag, flag, oldstate); - osync_flag_calculate_comb(flag->comb_flag); - } -} - -void osync_flag_set_state(OSyncFlag *flag, osync_bool state) -{ - osync_bool oldstate = flag->is_set; - flag->is_set = state; - flag->is_changing = FALSE; - if (flag->comb_flag) { - osync_comb_flag_update(flag->comb_flag, flag, oldstate); - } - if (flag->is_comb) { - //flag->num_not_set = 0; - //flag->num_set = 0; - } -} - -osync_bool osync_flag_get_state(OSyncFlag *flag) -{ - return flag->is_set; -} - -void osync_flag_calc_trigger(OSyncFlag *flag, osync_bool oldstate) -{ - if (flag->is_set != oldstate) { - if (flag->is_set == TRUE) { - if (flag->pos_trigger_func) { - flag->pos_trigger_func(flag->pos_user_data1, flag->pos_user_data2); - } - } else { - if (flag->neg_trigger_func) { - flag->neg_trigger_func(flag->neg_user_data1, flag->neg_user_data2); - } - } - } -} diff --git a/debian/opensync/opensync-0.22/osengine/osengine_flags_internals.h b/debian/opensync/opensync-0.22/osengine/osengine_flags_internals.h deleted file mode 100644 index c42adf5d..00000000 --- a/debian/opensync/opensync-0.22/osengine/osengine_flags_internals.h +++ /dev/null @@ -1,53 +0,0 @@ - -/*! @brief The functions that can be called on a plugin */ -struct OSyncFlag { - /** If this flag is raised */ - osync_bool is_set; - /** If this flag is currently changing its value */ - osync_bool is_changing; - /** The default value of the flag if no children are conencted */ - osync_bool default_val; - /** The parent flag*/ - OSyncFlag *comb_flag; - /** The cached number of unset child flags */ - unsigned int num_not_set; - /** The cached number of set child flags */ - unsigned int num_set; - /** If this flag is a combined flag */ - osync_bool is_comb; - /** The function to be called when the value changes from neq to pos */ - OSyncFlagTriggerFunc pos_trigger_func; - /** To first value to be passed to the pos triger function */ - void *pos_user_data1; - /** To second value to be passed to the pos triger function */ - void *pos_user_data2; - /** The function to be called when the value changes from pos to neq */ - OSyncFlagTriggerFunc neg_trigger_func; - /** To first value to be passed to the neq triger function */ - void *neg_user_data1; - /** To second value to be passed to the neq triger function */ - void *neg_user_data2; - /** Should the combined flag be a OR or a AND flag? */ - osync_bool is_any; -}; - -OSyncFlag *osync_flag_new(OSyncFlag *parent); -OSyncFlag *osync_comb_flag_new(osync_bool any, osync_bool default_val); -void osync_flag_set_pos_trigger(OSyncFlag *flag, OSyncFlagTriggerFunc func, void *data1, void *data2); -void osync_flag_set_neg_trigger(OSyncFlag *flag, OSyncFlagTriggerFunc func, void *data1, void *data2); -void osync_flag_calculate_comb(OSyncFlag *flag); -osync_bool osync_flag_is_set(OSyncFlag *flag); -osync_bool osync_flag_is_not_set(OSyncFlag *flag); -void osync_comb_flag_update(OSyncFlag *combflag, OSyncFlag *flag, osync_bool prev_state); -void osync_flag_changing(OSyncFlag *flag); -void osync_flag_cancel(OSyncFlag *flag); -void osync_flag_unset(OSyncFlag *flag); -void osync_flag_set(OSyncFlag *flag); -void osync_flag_calc_trigger(OSyncFlag *flag, osync_bool oldstate); -void osync_change_flags_detach(OSyncChange *change); -osync_bool osync_flag_get_state(OSyncFlag *flag); -void osync_flag_free(OSyncFlag *flag); -void osync_flag_set_state(OSyncFlag *flag, osync_bool state); -void osync_flag_attach(OSyncFlag *flag, OSyncFlag *target); -void osync_flag_detach(OSyncFlag *flag); -osync_bool osync_flag_is_attached(OSyncFlag *flag); diff --git a/debian/opensync/opensync-0.22/osengine/osengine_mapcmds.c b/debian/opensync/opensync-0.22/osengine/osengine_mapcmds.c deleted file mode 100644 index 045681a7..00000000 --- a/debian/opensync/opensync-0.22/osengine/osengine_mapcmds.c +++ /dev/null @@ -1,616 +0,0 @@ -/* - * libosengine - A synchronization engine for the opensync framework - * Copyright (C) 2004-2005 Armin Bauer <armin.bauer@opensync.org> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -#include "engine.h" -#include "engine_internals.h" - -/** - * @ingroup OSEngineMappingPrivate - */ -/*@{*/ - -static OSyncMappingEntry *_osync_find_next_diff(OSyncMapping *mapping, OSyncMappingEntry *orig_entry) -{ - GList *e; - for (e = mapping->entries; e; e = e->next) { - OSyncMappingEntry *entry = e->data; - if (osync_change_get_changetype(entry->change) == CHANGE_UNKNOWN) - continue; - if ((entry->change != orig_entry->change) && osync_change_compare(orig_entry->change, entry->change) != CONV_DATA_SAME) - return entry; - } - osync_debug("MAP", 3, "Could not find next diff"); - return NULL; -} - -static OSyncMappingEntry *_osync_find_next_same(OSyncMapping *mapping, OSyncMappingEntry *orig_entry) -{ - GList *e; - for (e = mapping->entries; e; e = e->next) { - OSyncMappingEntry *entry = e->data; - if (osync_change_get_changetype(entry->change) == CHANGE_UNKNOWN) - continue; - if ((entry->change != orig_entry->change) && osync_change_compare(orig_entry->change, entry->change) == CONV_DATA_SAME) - return entry; - } - osync_debug("MAP", 3, "Could not find next diff"); - return NULL; -} - -static OSyncMappingEntry *_osync_change_clone(OSyncEngine *engine, OSyncMapping *new_mapping, OSyncMappingEntry *comp_entry) -{ - OSyncMappingEntry *newentry = osengine_mappingentry_new(NULL); - newentry->change = osync_change_new(); - newentry->client = comp_entry->client; - osengine_mapping_add_entry(new_mapping, newentry); - osengine_mappingview_add_entry(comp_entry->view, newentry); - osengine_mappingentry_update(newentry, comp_entry->change); - osync_change_set_uid(newentry->change, osync_change_get_uid(comp_entry->change)); - osync_flag_set(newentry->fl_has_data); - osync_flag_set(newentry->fl_mapped); - osync_flag_set(newentry->fl_has_info); - osync_flag_set(newentry->fl_dirty); - osync_flag_unset(newentry->fl_synced); - osync_change_save(newentry->change, TRUE, NULL); - return newentry; -} - -osync_bool osync_change_elevate(OSyncEngine *engine, OSyncChange *change, int level) -{ - osync_debug("MAP", 3, "elevating change %s (%p) to level %i", osync_change_get_uid(change), change, level); - int i = 0; - for (i = 0; i < level; i++) { - if (!osync_change_duplicate(change)) - return FALSE; - } - osync_debug("MAP", 3, "change after being elevated %s (%p)", osync_change_get_uid(change), change); - osync_change_save(change, TRUE, NULL); - return TRUE; -} - -osync_bool osync_change_check_level(OSyncEngine *engine, OSyncMappingEntry *entry) -{ - GList *c; - osync_debug("MAP", 3, "checking level for change %s (%p)", osync_change_get_uid(entry->change), entry); - for (c = engine->clients; c; c = c->next) { - OSyncClient *client = c->data; - OSyncMappingView *view = osengine_mappingtable_find_view(engine->maptable, client->member); - if (!osengine_mappingview_uid_is_unique(view, entry, TRUE)) - return FALSE; - } - return TRUE; -} - -static int prod(int n) -{ - int ret; - for (ret = 0; n > 0; n--) - ret += n; - return ret; -} - -void osengine_mapping_multiply_master(OSyncEngine *engine, OSyncMapping *mapping) -{ - osync_trace(TRACE_ENTRY, "%s(%p, %p)", __func__, engine, mapping); - g_assert(engine); - - OSyncMappingTable *table = engine->maptable; - OSyncMappingEntry *entry = NULL; - OSyncMappingEntry *master = NULL; - - master = mapping->master; - g_assert(master); - if (osync_flag_is_not_set(master->fl_dirty)) - osync_flag_set(master->fl_synced); - else - osync_flag_attach(master->fl_committed, table->engine->cmb_committed_all); - - //Send the change to every source that is different to the master source and set state to writing in the changes - GList *v; - for (v = table->views; v; v = v->next) { - OSyncMappingView *view = v->data; - //Check if this client is already listed in the mapping - entry = osengine_mapping_find_entry(mapping, NULL, view); - if (entry == master) - continue; - if (entry && (osync_change_compare(entry->change, master->change) == CONV_DATA_SAME)) { - if (osync_flag_is_not_set(entry->fl_dirty)) - osync_flag_set(entry->fl_synced); - continue; - } - if (!entry) { - entry = osengine_mappingentry_new(NULL); - entry->change = osync_change_new(); - entry->client = view->client; - osengine_mappingview_add_entry(view, entry); - osengine_mappingentry_update(entry, master->change); - osync_change_set_uid(entry->change, osync_change_get_uid(master->change)); - osync_change_set_member(entry->change, view->client->member); - osengine_mapping_add_entry(mapping, entry); - } else { - osync_bool had_data = osync_change_has_data(entry->change); - osengine_mappingentry_update(entry, master->change); - if (osync_change_get_changetype(entry->change) == CHANGE_ADDED || osync_change_get_changetype(entry->change) == CHANGE_UNKNOWN) { - osync_change_set_changetype(entry->change, CHANGE_MODIFIED); - } - - if (osync_member_get_slow_sync(view->client->member, osync_objtype_get_name(osync_change_get_objtype(entry->change))) && !had_data) { - osync_change_set_changetype(entry->change, CHANGE_ADDED); - } - } - if (osync_flag_is_set(view->client->fl_sent_changes)) { - //osync_change_flags_attach(change, mapping); - osync_flag_set(entry->fl_dirty); - osync_flag_set(entry->fl_has_data); - osync_flag_set(entry->fl_mapped); - osync_flag_set(entry->fl_has_info); - osync_flag_unset(entry->fl_synced); - OSyncError *error = NULL; - osync_change_save(entry->change, TRUE, &error); - osync_flag_attach(entry->fl_committed, table->engine->cmb_committed_all); - } - } - - OSyncError *error = NULL; - osync_change_save(master->change, TRUE, &error); - - osync_flag_set(mapping->fl_multiplied); - osync_trace(TRACE_EXIT, "%s", __func__); -} - - - -void osengine_mapping_check_conflict(OSyncEngine *engine, OSyncMapping *mapping) -{ - osync_trace(TRACE_ENTRY, "%s(%p, %p)", __func__, engine, mapping); - GList *e; - GList *n; - osync_bool is_conflict = FALSE; - int is_same = 0; - OSyncMappingEntry *leftentry = NULL; - OSyncMappingEntry *rightentry = NULL; - - g_assert(engine != NULL); - g_assert(mapping != NULL); - g_assert(!mapping->master); - - for (e = mapping->entries; e; e = e->next) { - leftentry = e->data; - if (osync_change_get_changetype(leftentry->change) == CHANGE_UNKNOWN) - continue; - mapping->master = leftentry; - for (n = e->next; n; n = n->next) { - rightentry = n->data; - if (osync_change_get_changetype(rightentry->change) == CHANGE_UNKNOWN) - continue; - - if (osync_change_compare(leftentry->change, rightentry->change) != CONV_DATA_SAME) { - is_conflict = TRUE; - goto conflict; - } else { - is_same++; - } - } - } - - conflict: - if (is_conflict) { - //conflict, solve conflict - osync_debug("MAP", 2, "Got conflict for mapping %p", mapping); - osync_status_conflict(engine, mapping); - osync_flag_set(mapping->fl_chkconflict); - osync_trace(TRACE_EXIT, "%s: Got conflict", __func__); - return; - } - g_assert(mapping->master); - osync_flag_set(mapping->fl_chkconflict); - - //Our mapping is already solved since there is no conflict - osync_flag_set(mapping->fl_solved); - - if (is_same == prod(g_list_length(engine->maptable->views) - 1)) { - osync_trace(TRACE_INTERNAL, "No need to sync. All entries are the same"); - osync_flag_set(mapping->cmb_synced); - osync_flag_set(mapping->fl_multiplied); - } - - send_mapping_changed(engine, mapping); - osync_trace(TRACE_EXIT, "%s: No conflict", __func__); -} - -static OSyncMapping *_osengine_mapping_find(OSyncMappingTable *table, OSyncMappingEntry *orig_entry) -{ - GList *i; - GList *n; - osync_bool mapping_found = FALSE; - - for (i = table->mappings; i; i = i->next) { - OSyncMapping *mapping = i->data; - //We only need mapping where our member isnt listed yet. - if (!osengine_mapping_find_entry(mapping, NULL, orig_entry->view)) { - mapping_found = TRUE; - for (n = mapping->entries; n; n = n->next) { - OSyncMappingEntry *entry = n->data; - if (osync_change_compare_data(entry->change, orig_entry->change) == CONV_DATA_MISMATCH) { - mapping_found = FALSE; - continue; - } - } - if (mapping_found) - return mapping; - } - } - return NULL; -} - -void osengine_change_map(OSyncEngine *engine, OSyncMappingEntry *entry) -{ - osync_trace(TRACE_ENTRY, "osengine_change_map(%p, %p)", engine, entry); - OSyncMapping *mapping = NULL; - if (!(mapping = _osengine_mapping_find(engine->maptable, entry))) { - mapping = osengine_mapping_new(engine->maptable); - osync_flag_unset(mapping->fl_chkconflict); - osync_flag_unset(mapping->fl_multiplied); - mapping->id = osengine_mappingtable_get_next_id(engine->maptable); - osync_trace(TRACE_INTERNAL, "No previous mapping found. Creating new one: %p", mapping); - } - osengine_mapping_add_entry(mapping, entry); - osync_flag_set(entry->fl_mapped); - osync_change_save(entry->change, FALSE, NULL); - osync_trace(TRACE_EXIT, "osengine_change_map"); -} - -/*@}*/ - -/** - * @defgroup OSEngineMapping OpenSync Mapping - * @ingroup OSEnginePublic - * @brief The commands to manipulate mappings - * - */ -/*@{*/ - -/** @brief Solves the conflict by duplicating the conflicting entries - * - * @param engine The engine - * @param dupe_mapping The conflicting mapping to duplicate - * - */ -void osengine_mapping_duplicate(OSyncEngine *engine, OSyncMapping *dupe_mapping) -{ - osync_trace(TRACE_ENTRY, "osengine_mapping_duplicate(%p, %p)", engine, dupe_mapping); - g_assert(dupe_mapping); - int elevation = 0; - OSyncMappingEntry *orig_entry = NULL; - OSyncMappingEntry *first_diff_entry = NULL; - OSyncMappingEntry *next_entry = NULL; - OSyncMapping *new_mapping = NULL; - - //Remove all deleted items first. - GList *entries, *e; - entries = g_list_copy(dupe_mapping->entries); - for (e = entries; e; e = e->next) { - OSyncMappingEntry *entry = e->data; - if (osync_change_get_changetype(entry->change) == CHANGE_DELETED) { - osync_change_delete(entry->change, NULL); - osengine_mappingentry_free(entry); - } - } - g_list_free(entries); - - //Choose the first modified change as the master of the mapping to duplicate - GList *i = dupe_mapping->entries; - do { - orig_entry = i->data; - i = i->next; - } while (osync_change_get_changetype(orig_entry->change) != CHANGE_MODIFIED && osync_change_get_changetype(orig_entry->change) != CHANGE_ADDED); - dupe_mapping->master = orig_entry; - osync_change_set_changetype(orig_entry->change, CHANGE_MODIFIED); - - /* Now we go through the list of changes in the mapping to - * duplicate and search for the next entry that is different - * to our choosen master. This entry then has to be moved to a - * new mapping along with all changes to are the same as this next - * different change - */ - while ((first_diff_entry = _osync_find_next_diff(dupe_mapping, orig_entry))) { - //We found a different change - elevation = 0; - new_mapping = osengine_mapping_new(engine->maptable); - new_mapping->id = osengine_mappingtable_get_next_id(engine->maptable); - osync_flag_unset(new_mapping->cmb_synced); - osync_flag_set(new_mapping->fl_chkconflict); - osync_flag_unset(new_mapping->fl_multiplied); - osync_flag_set(new_mapping->fl_solved); - send_mapping_changed(engine, new_mapping); - osync_debug("MAP", 3, "Created new mapping for duplication %p with mappingid %lli", new_mapping, new_mapping->id); - - /* Now we copy the change that differs, and set it as the master of the new - * mapping.*/ - OSyncMappingEntry *newentry = osengine_mappingentry_copy(first_diff_entry); - new_mapping->master = newentry; - osengine_mapping_add_entry(new_mapping, newentry); - osync_change_set_changetype(newentry->change, CHANGE_ADDED); - osync_flag_set(newentry->fl_has_data); - osync_flag_set(newentry->fl_mapped); - osync_flag_set(newentry->fl_has_info); - osync_flag_set(newentry->fl_dirty); - osync_flag_unset(newentry->fl_synced); - - /* Now we elevate the change (which might be done by adding a -dupe - * or a (2) to the change uid. We then check if there is already - * another change on this level and if there is, we elevate again */ - do { - if (!osync_change_elevate(engine, newentry->change, 1)) - break; - elevation += 1; - } while (!osync_change_check_level(engine, newentry)); - OSyncError *error = NULL; - osync_change_save(newentry->change, TRUE, &error); - - /* Now we search for all changes to belong to the new mapping, so - * we are searching for changes to do not differ from the change we found - * to be different from the master of the mapping to duplicate */ - while ((next_entry = _osync_find_next_same(dupe_mapping, first_diff_entry))) { - newentry = _osync_change_clone(engine, new_mapping, first_diff_entry); - osync_change_elevate(engine, newentry->change, elevation); - osengine_mappingentry_update(orig_entry, next_entry->change); - osync_change_save(next_entry->change, TRUE, NULL); - } - - /* Now we can reset the different change and prepare it for - * being overwriten during mulitply_master */ - osync_change_set_changetype(first_diff_entry->change, CHANGE_UNKNOWN); - - //We can now add the new mapping into the queue so it get processed - send_mapping_changed(engine, new_mapping); - } - - //Multiply our original mapping - osync_flag_set(dupe_mapping->fl_solved); - send_mapping_changed(engine, dupe_mapping); - osync_trace(TRACE_EXIT, "osengine_mapping_duplicate"); -} - -/** @brief Solves the mapping by choosing a winner - * - * The winner will overwrite all other entries of this mapping - * - * @param engine The engine - * @param mapping The conflicting mapping - * @param change The winning change - * - */ -void osengine_mapping_solve(OSyncEngine *engine, OSyncMapping *mapping, OSyncChange *change) -{ - osync_trace(TRACE_ENTRY, "osengine_mapping_solve(%p, %p, %p)", engine, mapping, change); - OSyncMappingEntry *entry = osengine_mapping_find_entry(mapping, change, NULL); - mapping->master = entry; - osync_flag_set(mapping->fl_solved); - send_mapping_changed(engine, mapping); - osync_trace(TRACE_EXIT, "osengine_mapping_solve"); -} - -/** @brief Ignores a conflict - * - * This ignores the conflict until the next sync. When the group is synchronized again - * the conflict is brought up again (unless the user solved it already outside of the engine) - * - * @param engine The engine - * @param mapping The mapping to ignore - * - */ -osync_bool osengine_mapping_ignore_conflict(OSyncEngine *engine, OSyncMapping *mapping, OSyncError **error) -{ - osync_trace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, engine, mapping, error); - - if (!osengine_mapping_ignore_supported(engine, mapping)) { - osync_error_set(error, OSYNC_ERROR_GENERIC, "Ignore is not supported for this mapping"); - osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(error)); - return FALSE; - } - - GList *e = NULL; - for (e = mapping->entries; e; e = e->next) { - OSyncMappingEntry *entry = e->data; - osync_trace(TRACE_INTERNAL, "Adding %p to logchanges", entry); - OSyncError *error = NULL; - if (osync_change_get_changetype(entry->change) != CHANGE_UNKNOWN) - osync_group_save_changelog(engine->group, entry->change, &error); - } - - //And make sure we dont synchronize it this time - //osengine_mapping_reset(mapping); - osync_flag_set(mapping->fl_multiplied); - osync_flag_set(mapping->cmb_synced); - osync_flag_set(mapping->cmb_has_info); - osync_trace(TRACE_EXIT, "%s", __func__); - return TRUE; -} - -/** @brief Checks if a conflict can be ignore - * - * To be able to ignore a conflict, you opensync must be able to read - * the changes of the conflict again during the next synchronization. This must be done - * even if they are not reported by the plugin. Therefore, all plugins should provide - * a "read" method. If there is a member in the engine's group that does not have this - * method (either since it is not possible to implement one or since it has not been done - * yet), this function will return FALSE. - * - * @param engine The engine - * @param mapping The mapping to check - * @returns TRUE if conflicts can be ignored, FALSE otherwise - */ -osync_bool osengine_mapping_ignore_supported(OSyncEngine *engine, OSyncMapping *mapping) -{ - osync_trace(TRACE_ENTRY, "%s(%p, %p)", __func__, engine, mapping); - - int i, count = 0; - OSyncChange *change = NULL; - OSyncMember *member = NULL; - OSyncObjType *objtype = NULL; - - count = osengine_mapping_num_changes(mapping); - for (i = 0; i < count; ++i) { - change = osengine_mapping_nth_change(mapping, i); - objtype = osync_change_get_objtype(change); - - member = osync_change_get_member(change); - - if (!osync_member_has_read_function(member, objtype)) { - osync_trace(TRACE_EXIT, "%s: Ignore NOT supported", __func__); - return FALSE; - } - } - - osync_trace(TRACE_EXIT, "%s: Ignore supported", __func__); - return TRUE; -} - -/** @brief Solves a mapping by choosing the entry that was last modified - * - * Solves the mapping by choosing the last modified entry. Note that this can fail - * if one of the entries does not have a timestamp set or of the 2 latest timestamps - * were exactly equal. If it could not be solved you have to solve it with another function! - * - * @param engine The engine - * @param mapping The conflicting mapping - * @param error A pointer to an error - * @returns TRUE if the mapping was solved, FALSE otherwise - * - */ -osync_bool osengine_mapping_solve_latest(OSyncEngine *engine, OSyncMapping *mapping, OSyncError **error) -{ - osync_trace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, engine, mapping, error); - - time_t time = 0; - time_t latesttime = 0; - osync_bool preveq = FALSE; - - GList *e = NULL; - for (e = mapping->entries; e; e = e->next) { - OSyncMappingEntry *entry = e->data; - - if (osync_change_get_changetype(entry->change) != CHANGE_UNKNOWN) { - time = osync_change_get_revision(entry->change, error); - if (time == -1) { - osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(error)); - mapping->master = NULL; - return FALSE; - } - - if (time > latesttime) { - latesttime = time; - mapping->master = entry; - preveq = FALSE; - } else if (time == latesttime) - preveq = TRUE; - } - } - - if (preveq == TRUE) { - osync_error_set(error, OSYNC_ERROR_GENERIC, "Could not decide for one entry. Timestamps where equal"); - mapping->master = NULL; - osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(error)); - return FALSE; - } - - osync_flag_set(mapping->fl_solved); - send_mapping_changed(engine, mapping); - - osync_trace(TRACE_EXIT, "%s: %p", __func__, mapping->master); - return TRUE; -} - -/** @brief Checks if the mapping could be solved with solve_latest - * - * This functions checks all changes to see if they contain valid - * timestamp information and if they could be used to solve but does - * not actually solve the mapping - * - * @param engine The engine - * @param mapping The conflicting mapping - * @param error A pointer to an error - * @returns TRUE if the mapping could be solved, FALSE otherwise - * - */ -osync_bool osengine_mapping_check_timestamps(OSyncEngine *engine, OSyncMapping *mapping, OSyncError **error) -{ - osync_trace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, engine, mapping, error); - - time_t time = 0; - time_t latesttime = 0; - osync_bool preveq = FALSE; - - GList *e = NULL; - for (e = mapping->entries; e; e = e->next) { - OSyncMappingEntry *entry = e->data; - - if (osync_change_get_changetype(entry->change) != CHANGE_UNKNOWN) { - time = osync_change_get_revision(entry->change, error); - if (time == -1) { - osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(error)); - return FALSE; - } - - if (time > latesttime) { - latesttime = time; - preveq = FALSE; - } else if (time == latesttime) - preveq = TRUE; - } - } - - if (preveq == TRUE) { - osync_error_set(error, OSYNC_ERROR_GENERIC, "Could not decide for one entry. Timestamps where equal"); - osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(error)); - return FALSE; - } - - osync_trace(TRACE_EXIT, "%s", __func__); - return TRUE; -} - -/** @brief Solves a mapping by setting an updated change - * - * Solves the mapping by setting an updated change. The change should have been edited by the user. - * This change will then be declared winner. - * - * @param engine The engine - * @param mapping The conflicting mapping - * @param change The updated change - * - */ -void osengine_mapping_solve_updated(OSyncEngine *engine, OSyncMapping *mapping, OSyncChange *change) -{ - osync_trace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, engine, mapping, change); - OSyncMappingEntry *entry = osengine_mapping_find_entry(mapping, change, NULL); - mapping->master = entry; - - osync_flag_set(entry->fl_dirty); - osync_flag_unset(entry->fl_synced); - send_mappingentry_changed(engine, entry); - - osync_flag_set(mapping->fl_solved); - send_mapping_changed(engine, mapping); - osync_trace(TRACE_EXIT, "%s", __func__); -} - -/*@}*/ diff --git a/debian/opensync/opensync-0.22/osengine/osengine_mapcmds_internals.h b/debian/opensync/opensync-0.22/osengine/osengine_mapcmds_internals.h deleted file mode 100644 index 053f4e56..00000000 --- a/debian/opensync/opensync-0.22/osengine/osengine_mapcmds_internals.h +++ /dev/null @@ -1,14 +0,0 @@ -/** - * @ingroup OSEngineMappingPrivate - * - */ -/*@{*/ - -void osengine_change_map(OSyncEngine *engine, OSyncMappingEntry *entry); -void osengine_mapping_check_conflict(OSyncEngine *engine, OSyncMapping *mapping); -void osengine_mapping_multiply_master(OSyncEngine *engine, OSyncMapping *mapping); - -osync_bool osync_change_check_level(OSyncEngine *engine, OSyncMappingEntry *entry); -osync_bool osync_change_elevate(OSyncEngine *engine, OSyncChange *change, int level); - -/*@}*/ diff --git a/debian/opensync/opensync-0.22/osengine/osengine_mapping.c b/debian/opensync/opensync-0.22/osengine/osengine_mapping.c deleted file mode 100644 index 5ff78fb3..00000000 --- a/debian/opensync/opensync-0.22/osengine/osengine_mapping.c +++ /dev/null @@ -1,637 +0,0 @@ -/* - * libopensync - A synchronization framework - * Copyright (C) 2004-2005 Armin Bauer <armin.bauer@opensync.org> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -#include "engine.h" -#include "engine_internals.h" - -/** - * @defgroup OSEngineMappingPrivate OpenSync Mapping Internals - * @ingroup OSEnginePrivate - * @brief The internals the mappings - * - */ -/*@{*/ - -#ifndef DOXYGEN_SHOULD_SKIP_THIS -OSyncMappingTable *osengine_mappingtable_new(OSyncEngine *engine) -{ - osync_trace(TRACE_ENTRY, "osengine_mappingtable_new(%p)", engine); - OSyncMappingTable *table = g_malloc0(sizeof(OSyncMappingTable)); - table->engine = engine; - table->group = engine->group; - - GList *c; - for (c = engine->clients; c; c = c->next) { - OSyncClient *client = c->data; - osengine_mappingview_new(table, client); - } - - osync_trace(TRACE_EXIT, "osengine_mappingtable_new: %p", table); - return table; -} - -void osengine_mappingtable_reset(OSyncMappingTable *table) -{ - GList *v; - for (v = table->views; v; v = v->next) { - OSyncMappingView *view = v->data; - osengine_mappingview_reset(view); - } -} - -void osengine_mappingtable_free(OSyncMappingTable *table) -{ - osync_trace(TRACE_ENTRY, "osengine_mappingtable_free(%p)", table); - GList *c = NULL; - GList *m = NULL; - - GList *mappings = g_list_copy(table->mappings); - GList *unmapped = g_list_copy(table->unmapped); - GList *views = g_list_copy(table->views); - osync_trace(TRACE_INTERNAL, "Free mappings"); - for (m = mappings; m; m = m->next) { - OSyncMapping *mapping = m->data; - osengine_mapping_free(mapping); - } - osync_trace(TRACE_INTERNAL, "Free unmapped"); - for (c = unmapped; c; c = c->next) { - OSyncMappingEntry *entry = c->data; - osengine_mappingentry_free(entry); - } - for (c = views; c; c = c->next) { - OSyncMappingView *view = c->data; - osengine_mappingview_free(view); - } - g_list_free(mappings); - g_list_free(unmapped); - g_list_free(views); - g_free(table); - osync_trace(TRACE_EXIT, "osengine_mappingtable_free"); -} - -OSyncMappingEntry *osengine_mappingtable_find_entry(OSyncMappingTable *table, const char *uid, const char *objtype, long long int memberid) -{ - osync_trace(TRACE_ENTRY, "%s(%p, %s, %s)", __func__, table, uid, objtype ? objtype : "None"); - GList *v; - int count_of_entries = 0; /*must not be more the one for objtype=NULL*/ - OSyncMappingEntry *ret_entry = NULL; - for (v = table->views; v; v = v->next) { - OSyncMappingView *view = v->data; - GList *c; - - if (memberid && memberid != osync_member_get_id(view->client->member)) - continue; - - for (c = view->changes; c; c = c->next) { - OSyncMappingEntry *entry = c->data; - g_assert(entry->change); - if(objtype){ - if ( (!strcmp( - osync_change_get_uid(entry->change), uid)) && - (!strcmp( - osync_objtype_get_name( - osync_change_get_objtype(entry->change)) - , objtype)) - ) { - ret_entry = entry; - count_of_entries++; - } - } else { /**objtype is NULL ... try to find a entry based on uid*/ - if (!strcmp(osync_change_get_uid(entry->change), uid)) { - ret_entry = entry; - count_of_entries++; - } - } - } - } - if(count_of_entries == 1 && ret_entry){ - osync_trace(TRACE_EXIT, "%s: %p", __func__, ret_entry); - return ret_entry; - } - if(count_of_entries >1){ - if (!objtype) - { - osync_trace(TRACE_EXIT_ERROR, "%s: possible dataloss", __func__ ); - } else { - osync_trace(TRACE_EXIT_ERROR, "%s: changes.db corrupted", __func__ ); - } - return NULL; - } - - osync_trace(TRACE_EXIT, "%s: Not Found", __func__); - return NULL; -} - -OSyncMappingEntry *osengine_mappingtable_store_change(OSyncMappingTable *table, OSyncChange *change) -{ - osync_trace(TRACE_ENTRY, "osengine_mappingtable_store_change(%p, %p)", table, change); - OSyncMappingView *view = osengine_mappingtable_find_view(table, osync_change_get_member(change)); - g_assert(view); - OSyncMappingEntry *entry = osengine_mappingview_store_change(view, change); - osync_trace(TRACE_EXIT, "osengine_mappingtable_store_change: %p", entry); - return entry; -} - -OSyncMapping *osengine_mappingtable_find_mapping(OSyncMappingTable *table, OSyncChange *change) -{ - GList *m; - for (m = table->mappings; m; m = m->next) { - OSyncMapping *mapping = m->data; - if (osengine_mapping_find_entry(mapping, change, NULL)) - return mapping; - } - return NULL; -} - -OSyncMapping *osengine_mappingtable_mapping_from_id(OSyncMappingTable *table, long long int id) -{ - GList *m; - for (m = table->mappings; m; m = m->next) { - OSyncMapping *mapping = m->data; - if (mapping->id == id) - return mapping; - } - return NULL; -} - -OSyncMappingView *osengine_mappingtable_find_view(OSyncMappingTable *table, OSyncMember *member) -{ - GList *v; - for (v = table->views; v; v = v->next) { - OSyncMappingView *view = v->data; - if (view->memberid == osync_member_get_id(member)) - return view; - } - return NULL; -} - -void osengine_mappingtable_add_mapping(OSyncMappingTable *table, OSyncMapping *mapping) -{ - table->mappings = g_list_append(table->mappings, mapping); - mapping->table = table; -} - -osync_bool osengine_mappingtable_load(OSyncMappingTable *table, OSyncError **error) -{ - osync_trace(TRACE_ENTRY, "osengine_mappingtable_load(%p, %p)", table, error); - OSyncChange **changes = NULL; - if (!osync_changes_load(table->group, &changes, error)) { - osync_trace(TRACE_EXIT_ERROR, "osengine_mappingtable_load: %s", osync_error_print(error)); - return FALSE; - } - - int i = 0; - OSyncChange *change = NULL; - OSyncMapping *mapping = NULL; - while ((change = changes[i])) { - OSyncMappingEntry *entry = osengine_mappingentry_new(NULL); - entry->change = change; - //entry->orig_change = change; - entry->client = (OSyncClient *)osync_member_get_data(osync_change_get_member(change)); - - if (!osync_change_get_mappingid(change)) { - table->unmapped = g_list_append(table->unmapped, entry); - } else { - if (!mapping || mapping->id != osync_change_get_mappingid(change)) { - mapping = osengine_mapping_new(table); - mapping->id = osync_change_get_mappingid(change); - } - osengine_mapping_add_entry(mapping, entry); - } - - osync_flag_set(entry->fl_has_data); - - OSyncMappingView *view = osengine_mappingtable_find_view(table, osync_change_get_member(change)); - if (view) - osengine_mappingview_add_entry(view, entry); - - i++; - } - - osync_trace(TRACE_EXIT, "osengine_mappingtable_load: TRUE"); - return TRUE; -} - -long long int osengine_mappingtable_get_next_id(OSyncMappingTable *table) -{ - long long int new_id = 1; - GList *m; - for (m = table->mappings; m; m = m->next) { - OSyncMapping *mapping = m->data; - if (new_id <= mapping->id) - new_id = mapping->id + 1; - } - return new_id; -} - -void osengine_mappingtable_inject_changes(OSyncMappingTable *table) -{ - osync_trace(TRACE_ENTRY, "%s(%p)", __func__, table); - //OSyncEngine *engine = table->engine; - - char **uids = NULL; - char **objtypes = NULL; - long long int *memberids = NULL; - int *types = NULL; - char *uid = NULL; - char *objtype = NULL; - int type = 0; - int i = 0; - OSyncError *error = NULL; - osync_group_open_changelog(table->engine->group, &uids, &objtypes, &memberids, &types, &error); - - for (i = 0; (uid = uids[i]) ; i++) { - type = types[i]; - objtype = objtypes[i]; - long long int memberid = memberids[i]; - OSyncMappingEntry *entry = osengine_mappingtable_find_entry(table, uid, objtype, memberid); - - if (!entry) { - osync_trace(TRACE_INTERNAL, "Mappingtable and changelog inconsistent: no entry with uid %s", uid); - /*FIXME: We should be able to return error here. What if entry == NULL? */ - g_assert_not_reached(); - } - - osync_change_set_changetype(entry->change, type); - osync_trace(TRACE_INTERNAL, "Injecting %p with changetype %i", entry, osync_change_get_changetype(entry->change)); - osync_flag_attach(entry->fl_read, table->engine->cmb_read_all); - - /* Set fl_mapped accordingly, if the entry was already mapped previously */ - if (entry->mapping) - osync_flag_set(entry->fl_mapped); - - //send_read_change(engine, entry); - } - - osync_trace(TRACE_EXIT, "%s", __func__); -} - -OSyncMappingTable *_osengine_mappingtable_load_group(OSyncGroup *group) -{ - OSyncMappingTable *table = g_malloc0(sizeof(OSyncMappingTable)); - table->group = group; - - int i; - for (i = 0; i < osync_group_num_members(group); i++) { - OSyncMember *member = osync_group_nth_member(group, i); - OSyncMappingView *view = g_malloc0(sizeof(OSyncMappingView)); - table->views = g_list_append(table->views, view); - view->table = table; - view->memberid = osync_member_get_id(member); - } - - if (!osengine_mappingtable_load(table, NULL)) - return NULL; - return table; -} - -void osengine_mappingtable_close(OSyncMappingTable *table) -{ - osync_changes_close(table->group); - //FIXME Free the changes on the views -} - -OSyncMapping *osengine_mapping_new(OSyncMappingTable *table) -{ - g_assert(table); - OSyncMapping *mapping = g_malloc0(sizeof(OSyncMapping)); - osengine_mappingtable_add_mapping(table, mapping); - if (table->engine) { - mapping->fl_solved = osync_flag_new(NULL); - - mapping->fl_chkconflict = osync_flag_new(NULL); - osync_flag_set(mapping->fl_chkconflict); - - mapping->fl_multiplied = osync_flag_new(NULL); - osync_flag_set(mapping->fl_multiplied); - - mapping->cmb_has_data = osync_comb_flag_new(FALSE, FALSE); - osync_flag_set_pos_trigger(mapping->cmb_has_data, (OSyncFlagTriggerFunc)send_mapping_changed, table->engine, mapping); - - mapping->cmb_has_info = osync_comb_flag_new(FALSE, FALSE); - - mapping->cmb_synced = osync_comb_flag_new(FALSE, TRUE); - - mapping->cmb_deleted = osync_comb_flag_new(FALSE, FALSE); - - osync_flag_attach(mapping->cmb_synced, table->engine->cmb_synced); - osync_flag_attach(mapping->fl_multiplied, table->engine->cmb_multiplied); - osync_flag_attach(mapping->fl_chkconflict, table->engine->cmb_chkconflict); - } - osync_trace(TRACE_INTERNAL, "osengine_mapping_new(%p): %p", table, mapping); - return mapping; -} - -void osengine_mapping_free(OSyncMapping *mapping) -{ - osync_trace(TRACE_ENTRY, "osengine_mapping_free(%p)", mapping); - - while (g_list_nth_data(mapping->entries, 0)) - osengine_mappingentry_free(g_list_nth_data(mapping->entries, 0)); - - osync_flag_detach(mapping->cmb_synced); - osync_flag_detach(mapping->fl_chkconflict); - osync_flag_detach(mapping->fl_multiplied); - - mapping->table->mappings = g_list_remove(mapping->table->mappings, mapping); - osync_flag_free(mapping->fl_solved); - osync_flag_free(mapping->cmb_has_data); - osync_flag_free(mapping->cmb_has_info); - osync_flag_free(mapping->cmb_synced); - osync_flag_free(mapping->fl_chkconflict); - osync_flag_free(mapping->cmb_deleted); - osync_flag_free(mapping->fl_multiplied); - - g_free(mapping); - osync_trace(TRACE_EXIT, "osengine_mapping_free"); -} - -void osengine_mapping_add_entry(OSyncMapping *mapping, OSyncMappingEntry *entry) -{ - osync_trace(TRACE_INTERNAL, "osengine_mapping_add_entry(%p, %p)", mapping, entry); - g_assert(!osengine_mapping_find_entry(mapping, NULL, entry->view)); - mapping->entries = g_list_append(mapping->entries, entry); - entry->mapping = mapping; - - if (mapping->table->engine) { - osync_flag_attach(entry->fl_has_data, mapping->cmb_has_data); - osync_flag_attach(entry->fl_has_info, mapping->cmb_has_info); - osync_flag_attach(entry->fl_synced, mapping->cmb_synced); - osync_flag_attach(entry->fl_deleted, mapping->cmb_deleted); - osync_flag_set_pos_trigger(entry->fl_dirty, (OSyncFlagTriggerFunc)send_mappingentry_changed, mapping->table->engine, entry); - } - osync_change_set_mappingid(entry->change, mapping->id); - - mapping->table->unmapped = g_list_remove(mapping->table->unmapped, entry); - mapping->table->entries = g_list_append(mapping->table->entries, entry); -} - -void osengine_mapping_remove_entry(OSyncMapping *mapping, OSyncMappingEntry *entry) -{ - mapping->entries = g_list_remove(mapping->entries, entry); - mapping->table->entries = g_list_remove(mapping->table->entries, entry); - entry->mapping = NULL; - - osync_flag_detach(entry->fl_has_data); - osync_flag_detach(entry->fl_has_info); - osync_flag_detach(entry->fl_synced); - osync_flag_detach(entry->fl_deleted); -} - -OSyncMappingEntry *osengine_mapping_find_entry(OSyncMapping *mapping, OSyncChange *change, OSyncMappingView *view) -{ - GList *e; - for (e = mapping->entries; e; e = e->next) { - OSyncMappingEntry *entry = e->data; - if (change && entry->change == change) - return entry; - if (view && entry->view == view) - return entry; - } - return NULL; -} - -OSyncMappingEntry *osengine_mapping_nth_entry(OSyncMapping *mapping, int nth) -{ - return (OSyncMappingEntry *)g_list_nth_data(mapping->entries, nth); -} - -int osengine_mapping_num_changes(OSyncMapping *mapping) -{ - return g_list_length(mapping->entries); -} - -OSyncChange *osengine_mapping_nth_change(OSyncMapping *mapping, int nth) -{ - OSyncMappingEntry *entry = g_list_nth_data(mapping->entries, nth); - if (!entry) - return NULL; - return entry->change; -} - -long long osengine_mapping_get_id(OSyncMapping *mapping) -{ - return mapping->id; -} - -void osengine_mapping_reset(OSyncMapping *mapping) -{ - osync_trace(TRACE_ENTRY, "osengine_mapping_reset(%p)", mapping); - GList *e; - for (e = mapping->entries; e; e = e->next) { - OSyncMappingEntry *entry = e->data; - osengine_mappingentry_reset(entry); - } - - osync_flag_set(mapping->fl_multiplied); - osync_flag_set(mapping->fl_chkconflict); - mapping->master = NULL; - osync_trace(TRACE_EXIT, "osengine_mapping_reset"); -} - -void osengine_mapping_delete(OSyncMapping *mapping) -{ - osync_trace(TRACE_ENTRY, "osengine_mapping_delete(%p)", mapping); - GList *entries = g_list_copy(mapping->entries); - GList *c = NULL; - for (c = entries; c; c = c->next) { - OSyncMappingEntry *entry = c->data; - osync_change_delete(entry->change, NULL); - } - g_list_free(entries); - osengine_mapping_free(mapping); - osync_trace(TRACE_EXIT, "osengine_mapping_delete"); -} - -OSyncMappingView *osengine_mappingview_new(OSyncMappingTable *table, OSyncClient *client) -{ - g_assert(table); - OSyncMappingView *view = g_malloc0(sizeof(OSyncMappingView)); - table->views = g_list_append(table->views, view); - view->client = client; - view->table = table; - view->memberid = osync_member_get_id(client->member); - osync_trace(TRACE_INTERNAL, "osengine_mappingview_new(%p)", view); - return view; -} - -void osengine_mappingview_free(OSyncMappingView *view) -{ - osync_trace(TRACE_INTERNAL, "osengine_mappingview_free(%p)", view); - g_list_free(view->changes); - view->changes = NULL; - g_free(view); -} - -void osengine_mappingview_add_entry(OSyncMappingView *view, OSyncMappingEntry *entry) -{ - view->changes = g_list_append(view->changes, entry); - entry->view = view; -} - -OSyncMappingEntry *osengine_mappingview_store_change(OSyncMappingView *view, OSyncChange *change) -{ - osync_trace(TRACE_ENTRY, "osengine_mappingview_store_change(%p, %p)", view, change); - g_assert(change); - GList *c; - for (c = view->changes; c; c = c->next) { - OSyncMappingEntry *entry = c->data; - g_assert(entry->change); - - /** - * not unique UID exception - * UID has to match and objtype has to match - **/ - if (!strcmp(osync_change_get_uid(entry->change), osync_change_get_uid(change))) { - OSyncObjType * entry_objtype = osync_change_get_objtype(entry->change); - OSyncObjType * change_objtype = osync_change_get_objtype(change); - - const char * entry_objtype_name = osync_objtype_get_name(entry_objtype); - const char * change_objtype_name = osync_objtype_get_name(change_objtype); - - if ( - (change_objtype_name == NULL) || - (entry_objtype_name == NULL) || - (!strcmp(change_objtype_name, entry_objtype_name)) || - (!strcmp(change_objtype_name, "data")) || - (!strcmp(entry_objtype_name, "data")) - ) { - osengine_mappingentry_update(entry, change); - osync_trace(TRACE_EXIT, "osengine_mappingview_store_change: %p", entry); - return entry; - } - } - - } - - OSyncMappingEntry *newentry = osengine_mappingentry_new(NULL); - newentry->change = change; - newentry->client = view->client; - view->table->unmapped = g_list_append(view->table->unmapped, newentry); - osengine_mappingview_add_entry(view, newentry); - osync_trace(TRACE_EXIT, "osengine_mappingview_store_change: %p (New MappingEntry)", newentry); - return newentry; -} - -osync_bool osengine_mappingview_uid_is_unique(OSyncMappingView *view, OSyncMappingEntry *entry, osync_bool spare_deleted) -{ - GList *e = NULL; - - for (e = view->changes; e; e = e->next) { - OSyncMappingEntry *exentry = e->data; - if ((exentry != entry) && (!spare_deleted || (osync_change_get_changetype(exentry->change) != CHANGE_DELETED)) && !strcmp(osync_change_get_uid(exentry->change), osync_change_get_uid(entry->change))) - return FALSE; - } - return TRUE; -} - -void osengine_mappingview_reset(OSyncMappingView *view) -{ - //g_list_free(view->changes); - //view->changes = NULL; -} - -OSyncMappingEntry *osengine_mappingentry_new(OSyncMapping *mapping) -{ - OSyncMappingEntry *entry = g_malloc0(sizeof(OSyncMappingEntry)); - osync_trace(TRACE_INTERNAL, "osengine_mappingentry_new(%p): %p", mapping, entry); - entry->fl_has_data = osync_flag_new(NULL); - entry->fl_dirty = osync_flag_new(NULL); - entry->fl_mapped = osync_flag_new(NULL); - entry->fl_has_info = osync_flag_new(NULL); - entry->fl_synced = osync_flag_new(NULL); - entry->fl_deleted = osync_flag_new(NULL); - entry->fl_read = osync_flag_new(NULL); - entry->fl_committed = osync_flag_new(NULL); - osync_flag_set(entry->fl_synced); - - if (mapping) - osengine_mapping_add_entry(mapping, entry); - - return entry; -} - -void osengine_mappingentry_free(OSyncMappingEntry *entry) -{ - osync_trace(TRACE_INTERNAL, "osengine_mappingentry_free(%p)", entry); - - if (entry->mapping) - osengine_mapping_remove_entry(entry->mapping, entry); - - osync_flag_free(entry->fl_has_data); - osync_flag_free(entry->fl_dirty); - osync_flag_free(entry->fl_mapped); - osync_flag_free(entry->fl_has_info); - osync_flag_free(entry->fl_synced); - osync_flag_free(entry->fl_deleted); - osync_flag_free(entry->fl_read); - osync_flag_free(entry->fl_committed); - - entry->view->changes = g_list_remove(entry->view->changes, entry); - entry->view = NULL; - - g_free(entry); -} - -void osengine_mappingentry_update(OSyncMappingEntry *entry, OSyncChange *change) -{ - osync_trace(TRACE_ENTRY, "%s(%p, %p)", __func__, entry, change); - - OSyncObjFormat *format = osync_change_get_objformat(entry->change); - OSyncObjType *type = osync_change_get_objtype(entry->change); - - osync_change_update(change, entry->change); - - if (osync_change_get_changetype(change) == CHANGE_DELETED && format && type) { - osync_change_set_objformat(entry->change, format); - osync_change_set_objtype(entry->change, type); - - osync_trace(TRACE_INTERNAL, "Change was deleted. Old objtype %s and format %s", osync_change_get_objtype(entry->change) ? osync_objtype_get_name(osync_change_get_objtype(entry->change)) : "None", osync_change_get_objformat(entry->change) ? osync_objformat_get_name(osync_change_get_objformat(entry->change)) : "None"); - } - - osync_trace(TRACE_EXIT, "%s", __func__); -} - -OSyncMappingEntry *osengine_mappingentry_copy(OSyncMappingEntry *entry) -{ - OSyncMappingEntry *newentry = osengine_mappingentry_new(NULL); - - OSyncError *error = NULL; - newentry->change = osync_change_copy(entry->change, &error); - newentry->client = entry->client; - osengine_mappingview_add_entry(entry->view, newentry); - return newentry; -} - -void osengine_mappingentry_reset(OSyncMappingEntry *entry) -{ - osync_trace(TRACE_INTERNAL, "osengine_mappingentry_reset(%p)", entry); - - osync_flag_set(entry->fl_has_data); - osync_flag_unset(entry->fl_dirty); - osync_flag_unset(entry->fl_has_info); - osync_flag_unset(entry->fl_deleted); - osync_flag_set(entry->fl_synced); - - osync_change_reset(entry->change); -} -#endif - -/** @} */ diff --git a/debian/opensync/opensync-0.22/osengine/osengine_mapping.h b/debian/opensync/opensync-0.22/osengine/osengine_mapping.h deleted file mode 100644 index c27c82c7..00000000 --- a/debian/opensync/opensync-0.22/osengine/osengine_mapping.h +++ /dev/null @@ -1,12 +0,0 @@ - -void osengine_mapping_duplicate(OSyncEngine *engine, OSyncMapping *dupe_mapping); -void osengine_mapping_solve(OSyncEngine *engine, OSyncMapping *mapping, OSyncChange *change); -int osengine_mapping_num_changes(OSyncMapping *mapping); -OSyncChange *osengine_mapping_nth_change(OSyncMapping *mapping, int nth); -long long osengine_mapping_get_id(OSyncMapping *mapping); -void osengine_mapping_solve_updated(OSyncEngine *engine, OSyncMapping *mapping, OSyncChange *change); -osync_bool osengine_mapping_solve_latest(OSyncEngine *engine, OSyncMapping *mapping, OSyncError **error); - -osync_bool osengine_mapping_ignore_conflict(OSyncEngine *engine, OSyncMapping *mapping, OSyncError **error); -osync_bool osengine_mapping_ignore_supported(OSyncEngine *engine, OSyncMapping *mapping); -osync_bool osengine_mapping_check_timestamps(OSyncEngine *engine, OSyncMapping *mapping, OSyncError **error); diff --git a/debian/opensync/opensync-0.22/osengine/osengine_mapping_internals.h b/debian/opensync/opensync-0.22/osengine/osengine_mapping_internals.h deleted file mode 100644 index 0eecaa42..00000000 --- a/debian/opensync/opensync-0.22/osengine/osengine_mapping_internals.h +++ /dev/null @@ -1,87 +0,0 @@ - -#ifndef DOXYGEN_SHOULD_SKIP_THIS -struct OSyncMappingTable { - GList *mappings; - OSyncEngine *engine; - GList *unmapped; - OSyncGroup *group; - GList *views; - GList *entries; -}; - -struct OSyncMappingView { - OSyncClient *client; - GList *changes; - OSyncMappingTable *table; - long long int memberid; -}; - -struct OSyncMapping { - GList *entries; - OSyncMappingEntry *master; - void *engine_data; - long long int id; - OSyncMappingTable *table; - OSyncFlag *fl_solved; - OSyncFlag *fl_chkconflict; - OSyncFlag *fl_multiplied; - //The combined flags - OSyncFlag *cmb_synced; - OSyncFlag *cmb_has_data; - OSyncFlag *cmb_has_info; - OSyncFlag *cmb_deleted; - OSyncEngine *engine; -}; - -struct OSyncMappingEntry { - OSyncMappingView *view; - OSyncClient *client; - OSyncMapping *mapping; - OSyncChange *change; - OSyncFlag *fl_has_data; - OSyncFlag *fl_dirty; - OSyncFlag *fl_mapped; - OSyncFlag *fl_has_info; - OSyncFlag *fl_synced; - OSyncFlag *fl_deleted; - OSyncFlag *fl_read; - OSyncFlag *fl_committed; -}; -#endif - -OSyncMappingTable *osengine_mappingtable_new(OSyncEngine *engine); -void osengine_mappingtable_free(OSyncMappingTable *table); -OSyncMappingEntry *osengine_mappingtable_store_change(OSyncMappingTable *table, OSyncChange *change); -OSyncMapping *osengine_mappingtable_find_mapping(OSyncMappingTable *table, OSyncChange *change); -OSyncMappingView *osengine_mappingtable_find_view(OSyncMappingTable *table, OSyncMember *member); -void osengine_mappingtable_add_mapping(OSyncMappingTable *table, OSyncMapping *mapping); -osync_bool osengine_mappingtable_load(OSyncMappingTable *table, OSyncError **error); -OSyncMappingTable *_osengine_mappingtable_load_group(OSyncGroup *group); -void osengine_mappingtable_close(OSyncMappingTable *table); -long long int osengine_mappingtable_get_next_id(OSyncMappingTable *table); -void osengine_mappingtable_reset(OSyncMappingTable *table); -void osengine_mappingtable_inject_changes(OSyncMappingTable *table); - -OSyncMapping *osengine_mapping_new(OSyncMappingTable *table); -void osengine_mapping_free(OSyncMapping *mapping); -void osengine_mapping_add_entry(OSyncMapping *mapping, OSyncMappingEntry *entry); -void osengine_mapping_remove_entry(OSyncMapping *mapping, OSyncMappingEntry *entry); -OSyncMappingEntry *osengine_mapping_find_entry(OSyncMapping *mapping, OSyncChange *change, OSyncMappingView *view); -OSyncMappingEntry *osengine_mapping_nth_entry(OSyncMapping *mapping, int nth); -void osengine_mapping_reset(OSyncMapping *mapping); -void osengine_mapping_delete(OSyncMapping *mapping); - -OSyncMappingView *osengine_mappingview_new(OSyncMappingTable *table, OSyncClient *client); -OSyncMappingEntry *osengine_mappingview_store_change(OSyncMappingView *view, OSyncChange *change); -osync_bool osengine_mappingview_uid_is_unique(OSyncMappingView *view, OSyncMappingEntry *entry, osync_bool spare_deleted); -void osengine_mappingview_add_entry(OSyncMappingView *view, OSyncMappingEntry *entry); -void osengine_mappingview_reset(OSyncMappingView *view); -void osengine_mappingview_free(OSyncMappingView *view); - -void osengine_mappingentry_update(OSyncMappingEntry *entry, OSyncChange *change); -OSyncMappingEntry *osengine_mappingentry_new(OSyncMapping *mapping); -void osengine_mappingentry_reset(OSyncMappingEntry *entry); -void osengine_mappingentry_free(OSyncMappingEntry *entry); -OSyncMapping *osengine_mappingtable_mapping_from_id(OSyncMappingTable *table, long long id); -OSyncMappingEntry *osengine_mappingentry_copy(OSyncMappingEntry *entry); - diff --git a/debian/opensync/opensync-0.22/osengine/osengine_status.c b/debian/opensync/opensync-0.22/osengine/osengine_status.c deleted file mode 100644 index bb9ee2bd..00000000 --- a/debian/opensync/opensync-0.22/osengine/osengine_status.c +++ /dev/null @@ -1,110 +0,0 @@ -/* - * libosengine - A synchronization engine for the opensync framework - * Copyright (C) 2004-2005 Armin Bauer <armin.bauer@opensync.org> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -#include "engine.h" -#include "engine_internals.h" - -void osync_status_conflict(OSyncEngine *engine, OSyncMapping *mapping) -{ - osync_trace(TRACE_ENTRY, "%s(%p, %p)", __func__, engine, mapping); - if (engine->conflict_callback) - engine->conflict_callback(engine, mapping, engine->conflict_userdata); - else - osync_trace(TRACE_INTERNAL, "Conflict Ignored"); - - osync_trace(TRACE_EXIT, "%s", __func__); -} - -void osync_status_update_member(OSyncEngine *engine, OSyncClient *client, memberupdatetype type, OSyncError **error) -{ - osync_trace(TRACE_ENTRY, "%s(%p, %p, %i, %p)", __func__, engine, client, type, error); - if (engine->mebstat_callback) { - OSyncMemberUpdate update; - memset(&update, 0, sizeof(OSyncMemberUpdate)); - update.type = type; - update.member = client->member; - if (error) - update.error = *error; - else - update.error = NULL; - engine->mebstat_callback(&update, engine->mebstat_userdata); - } else - osync_trace(TRACE_INTERNAL, "Status Update Ignored"); - - osync_trace(TRACE_EXIT, "%s", __func__); -} - -void osync_status_update_change(OSyncEngine *engine, OSyncChange *change, changeupdatetype type, OSyncError **error) -{ - osync_trace(TRACE_ENTRY, "%s(%p, %p, %i, %p)", __func__, engine, change, type, error); - if (engine->changestat_callback) { - OSyncChangeUpdate update; - update.type = type; - update.member_id = osync_member_get_id(osync_change_get_member(change)); - update.change = change; - update.mapping_id = osync_change_get_mappingid(change); - if (error) - update.error = *error; - else - update.error = NULL; - engine->changestat_callback(engine, &update, engine->changestat_userdata); - } else - osync_trace(TRACE_INTERNAL, "Status Update Ignored"); - - osync_trace(TRACE_EXIT, "%s", __func__); -} - -void osync_status_update_mapping(OSyncEngine *engine, OSyncMapping *mapping, mappingupdatetype type, OSyncError **error) -{ - osync_trace(TRACE_ENTRY, "%s(%p, %p, %i, %p)", __func__, engine, mapping, type, error); - if (engine->mapstat_callback) { - OSyncMappingUpdate update; - update.type = type; - update.mapping = mapping; - if (mapping->master) - update.winner = osync_member_get_id(mapping->master->client->member); - if (error) - update.error = *error; - else - update.error = NULL; - engine->mapstat_callback(&update, engine->mapstat_userdata); - } else - osync_trace(TRACE_INTERNAL, "Status Update Ignored"); - - osync_trace(TRACE_EXIT, "%s", __func__); -} - -void osync_status_update_engine(OSyncEngine *engine, engineupdatetype type, OSyncError **error) -{ - osync_trace(TRACE_ENTRY, "%s(%p, %i, %p)", __func__, engine, type, error); - if (engine->engstat_callback) { - OSyncEngineUpdate update; - memset(&update, 0, sizeof(OSyncEngineUpdate)); - update.type = type; - if (error) - update.error = *error; - else - update.error = NULL; - engine->engstat_callback(engine, &update, engine->engstat_userdata); - } else - osync_trace(TRACE_INTERNAL, "Status Update Ignored"); - - osync_trace(TRACE_EXIT, "%s", __func__); -} diff --git a/debian/opensync/opensync-0.22/osengine/osengine_status.h b/debian/opensync/opensync-0.22/osengine/osengine_status.h deleted file mode 100644 index f78e8d39..00000000 --- a/debian/opensync/opensync-0.22/osengine/osengine_status.h +++ /dev/null @@ -1,134 +0,0 @@ - -/** @brief The types of status updates for members - * @ingroup OSEnginePublic - **/ -typedef enum { - /** The member just connected */ - MEMBER_CONNECTED, - /** The member just sent its changes */ - MEMBER_SENT_CHANGES, - /** The member just wrote its changes */ - MEMBER_COMMITTED_ALL, - /** The member just disconnected */ - MEMBER_DISCONNECTED, - /** The member had problems connecting */ - MEMBER_CONNECT_ERROR, - /** The member had problems getting the changes */ - MEMBER_GET_CHANGES_ERROR, - /** The member had problems getting the changes */ - MEMBER_COMMITTED_ALL_ERROR, - /** The member had problems during sync_done */ - MEMBER_SYNC_DONE_ERROR, - /** There was an error while disconnecting */ - MEMBER_DISCONNECT_ERROR -} memberupdatetype; - -/** @brief The types of status updates for changes - * @ingroup OSEnginePublic - **/ -typedef enum { - /** The change was just received */ - CHANGE_RECEIVED = 1, - /** The change was just received (Only info) */ - CHANGE_RECEIVED_INFO = 2, - /** The change was just written */ - CHANGE_SENT = 3, - /** There was an problem writing */ - CHANGE_WRITE_ERROR = 4, - /** There was an problem receiving the change */ - CHANGE_RECV_ERROR = 5 -} changeupdatetype; - -/** @brief The types of status updates for mappings - * @ingroup OSEnginePublic - **/ -typedef enum { - /** The mapping has just been solved */ - MAPPING_SOLVED = 1, - /** The mapping has just been completely synced */ - MAPPING_SYNCED = 2, - /** There was an error writing on of the changes */ - MAPPING_WRITE_ERROR = 3 -} mappingupdatetype; - -/** @brief The types of status updates for members - * @ingroup OSEnginePublic - **/ -typedef enum { - /** All clients have connected or had an error during connection */ - ENG_ENDPHASE_CON = 1, - /** All clients have sent their changes to the syncengine */ - ENG_ENDPHASE_READ = 2, - /** All clients have written their changes */ - ENG_ENDPHASE_WRITE = 3, - /** All clients have disconnected */ - ENG_ENDPHASE_DISCON = 4, - /** There was an error */ - ENG_ERROR = 5, - /** The sync is done and was successfull (My favorite message) */ - ENG_SYNC_SUCCESSFULL = 6, - /** The previous sync was unclean and the engine will perform a slow-sync now */ - ENG_PREV_UNCLEAN = 7, - /** All conflicts have been reported. */ - ENG_END_CONFLICTS = 8 -} engineupdatetype; - - -/*! @brief Struct for the member status callback - * @ingroup OSEnginePublic - */ -typedef struct OSyncMemberUpdate { - /** The type of the status update */ - memberupdatetype type; - /** The member for which the status update is */ - OSyncMember *member; - /** If the status was a error, this error will be set */ - OSyncError *error; -} OSyncMemberUpdate; - -/*! @brief Struct for the change status callback - * @ingroup OSEnginePublic - */ -typedef struct OSyncChangeUpdate { - /** The type of the status update */ - changeupdatetype type; - /** The change for which the status update is */ - OSyncChange *change; - /** The id of the member which sent this change */ - int member_id; - /** The id of the mapping to which this change belongs if any */ - int mapping_id; - /** If the status was a error, this error will be set */ - OSyncError *error; -} OSyncChangeUpdate; - -/*! @brief Struct for the mapping status callback - * @ingroup OSEnginePublic - */ -typedef struct OSyncMappingUpdate { - /** The type of the status update */ - mappingupdatetype type; - /** If the mapping was already solved, this will have the id if the winning entry */ - long long int winner; - /** The mapping for which the status update is */ - OSyncMapping *mapping; - /** If the status was a error, this error will be set */ - OSyncError *error; -} OSyncMappingUpdate; - -/*! @brief Struct for the engine status callback - * @ingroup OSEnginePublic - */ -typedef struct OSyncEngineUpdate { - /** The type of the status update */ - engineupdatetype type; - /** If the status was a error, this error will be set */ - OSyncError *error; -} OSyncEngineUpdate; - - -void osync_status_conflict(OSyncEngine *engine, OSyncMapping *mapping); -void osync_status_update_member(OSyncEngine *engine, OSyncClient *client, memberupdatetype type, OSyncError **error); -void osync_status_update_change(OSyncEngine *engine, OSyncChange *change, changeupdatetype type, OSyncError **error); -void osync_status_update_mapping(OSyncEngine *engine, OSyncMapping *mapping, mappingupdatetype type, OSyncError **error); -void osync_status_update_engine(OSyncEngine *engine, engineupdatetype type, OSyncError **error); |