You can subscribe to this list here.
2005 |
Jan
|
Feb
|
Mar
(56) |
Apr
(109) |
May
(15) |
Jun
(3) |
Jul
(37) |
Aug
(96) |
Sep
(40) |
Oct
(4) |
Nov
(54) |
Dec
|
---|---|---|---|---|---|---|---|---|---|---|---|---|
2006 |
Jan
(47) |
Feb
(30) |
Mar
(102) |
Apr
(120) |
May
(68) |
Jun
(54) |
Jul
(53) |
Aug
(122) |
Sep
(190) |
Oct
(71) |
Nov
(85) |
Dec
(108) |
2007 |
Jan
(72) |
Feb
(190) |
Mar
(53) |
Apr
(101) |
May
(145) |
Jun
(148) |
Jul
(167) |
Aug
(143) |
Sep
(23) |
Oct
(198) |
Nov
(223) |
Dec
(195) |
2008 |
Jan
(100) |
Feb
(129) |
Mar
(79) |
Apr
(77) |
May
(34) |
Jun
(95) |
Jul
(112) |
Aug
(160) |
Sep
(82) |
Oct
(124) |
Nov
(199) |
Dec
(355) |
2009 |
Jan
(436) |
Feb
(89) |
Mar
(298) |
Apr
(189) |
May
(33) |
Jun
(88) |
Jul
(105) |
Aug
(44) |
Sep
(181) |
Oct
(87) |
Nov
(75) |
Dec
(1) |
2010 |
Jan
(63) |
Feb
(21) |
Mar
(3) |
Apr
(1) |
May
(1) |
Jun
(3) |
Jul
(26) |
Aug
(37) |
Sep
(26) |
Oct
(15) |
Nov
(13) |
Dec
|
From: <svn...@op...> - 2005-04-13 14:31:34
|
Author: abauer Date: 2005-04-13 16:33:05 +0200 (Wed, 13 Apr 2005) New Revision: 497 Added: branches/python-swig/src/sample Removed: branches/python-swig/src/opensync.pyx branches/python-swig/src/pywrap.c branches/python-swig/src/pywrap.h branches/python-swig/src/sample.py Log: Deleted some old files Deleted: branches/python-swig/src/opensync.pyx Deleted: branches/python-swig/src/pywrap.c Deleted: branches/python-swig/src/pywrap.h Added: branches/python-swig/src/sample =================================================================== --- branches/python-swig/src/sample 2005-04-13 14:23:04 UTC (rev 496) +++ branches/python-swig/src/sample 2005-04-13 14:33:05 UTC (rev 497) @@ -0,0 +1,44 @@ +from opensync import * + +class A: + def connect(self, ctx): + print "Connect called!!" + ctx.report_success() + + def get_changeinfo(self, ctx): + print "get_changeinfo called!!" + ctx.report_error(0, "Not implemented") + + def commit_change(self, ctx, chg): + print "commit called!!" + ctx.report_success() + + def access(self, ctx, chg): + print "access called!!" + ctx.report_success() + + def finalize(self, ctx): + print "finalize called!" + ctx.report_success() + + def disconnect(self, ctx): + print "disconnect called!" + ctx.report_success() + + def get_data(self, ctx, chg): + print "get_data called!" + +def initialize(): + print "Initialize called!!" + return A() + +def blubbasd(i): + print "juhu" + str(i) + return 2; + +def get_info(info): + info.accept_objtype("contact") + info.accept_objformat("contact", "vcard30") + info.set_name("testmodule", 1) + +# vim: ts=4:sw=4:noet Deleted: branches/python-swig/src/sample.py |
From: <svn...@op...> - 2005-04-13 14:21:34
|
Author: abauer Date: 2005-04-13 16:23:04 +0200 (Wed, 13 Apr 2005) New Revision: 496 Modified: branches/python-swig/Makefile.am branches/python-swig/configure.in branches/python-swig/src/python_module.c Log: Made the python-module load files instead of setting sys.path Modified: branches/python-swig/Makefile.am =================================================================== --- branches/python-swig/Makefile.am 2005-04-13 11:59:14 UTC (rev 495) +++ branches/python-swig/Makefile.am 2005-04-13 14:23:04 UTC (rev 496) @@ -1,38 +1,16 @@ plugindir=@OPENSYNC_PLUGINDIR@ pythonplgdir=@OPENSYNC_PYTHONPLG_DIR@ +INCLUDES = -I$(top_srcdir) + OPENSYNC_LIBS=-lopensync -#FIXME: set EXTRA_DIST - -EXTRA_DIST = \ - src/pywrap.c \ - src/opensync.pyx - plugin_LTLIBRARIES = python_module.la python_module_la_SOURCES = src/python_module.c python_module_la_LDFLAGS = @PYTHON_LDFLAGS@ -avoid-version -export-dynamic -module $(OSYNC_LIBS) python_module_la_CFLAGS = -Wall -Werror $(OSYNC_CFLAGS) -python_module_la_CPPFLAGS = @PYTHON_CFLAGS@ \ - -DOPENSYNC_PYTHONPLG_DIR=\"$(pythonplgdir)\" +python_module_la_CPPFLAGS = @PYTHON_CFLAGS@ -DOPENSYNC_PYTHONPLG_DIR=\"$(pythonplgdir)\" python_module_la_LIBADD = @PYTHON_LIBS@ - - -src/opensync.c: src/opensync.pyx - pyrexc $< - -# opensync python module building rules -# It uses setup.py and distutils to -# make things easier -opensync.so: src/opensync.c setup.py - CFLAGS="$$CFLAGS $(OSYNC_CFLAGS)" python setup.py build_ext - -all-local: opensync.so - -install-exec-local: - python setup.py install - -clean-local: - python setup.py clean +pythonplg_DATA = src/sample Modified: branches/python-swig/configure.in =================================================================== --- branches/python-swig/configure.in 2005-04-13 11:59:14 UTC (rev 495) +++ branches/python-swig/configure.in 2005-04-13 14:23:04 UTC (rev 496) @@ -66,7 +66,8 @@ AC_SUBST(PYTHON_LIBS) os_cv_python_sdk=yes])])]) -PKG_CHECK_MODULES(OSYNC, [opensync-1.0]) +export PKG_CONFIG_PATH=$prefix/lib/pkgconfig:${PKG_CONFIG_PATH} +PKG_CHECK_MODULES(OSYNC, [opensync-1.0 glib-2.0]) OPENSYNC_CONFIGDIR=$(pkg-config --variable=configdir opensync-1.0) OPENSYNC_PLUGINDIR=$(pkg-config --variable=plugindir opensync-1.0) Modified: branches/python-swig/src/python_module.c =================================================================== --- branches/python-swig/src/python_module.c 2005-04-13 11:59:14 UTC (rev 495) +++ branches/python-swig/src/python_module.c 2005-04-13 14:23:04 UTC (rev 496) @@ -9,9 +9,9 @@ #include <opensync/opensync.h> #include <signal.h> +#include <glib.h> +#include "config.h" -#include "pywrap.h" - struct MemberData { PyThreadState *interp_thread; PyObject *module; @@ -19,6 +19,7 @@ PyObject *osync_module; }; +#if 0 /** Insert plugin search path in sys.path * * Isn't there an easier way of setting it? @@ -26,7 +27,7 @@ *FIXME: It would be better if we just load modules from * their filename, not setting the module search path */ -static int change_sys_path() +/*static int change_sys_path() { int rv = -1; PyObject *sys = NULL; @@ -45,7 +46,6 @@ if (PyList_Insert(path, 0, dir) < 0) goto error; - /* Success */ rv = 0; error: @@ -53,7 +53,7 @@ Py_XDECREF(path); Py_XDECREF(sys); return rv; -} +}*/ /** Calls the method initialize function * @@ -293,6 +293,7 @@ { call_module_method(ctx, NULL, "disconnect"); } +#endif /** Register a new plugin from python module called name. * @@ -301,52 +302,92 @@ * plugin information on another place (including * accepted objtypes/formats info) */ -static int register_plugin(OSyncEnv *env, PyObject *osync_module, char *name) +static osync_bool register_plugin(OSyncEnv *env, PyObject *osync_module, char *filename, OSyncError **error) { - PyObject *module = NULL; - PyObject *get_info_result = NULL; - PythonPluginInfo pyinfo; - PyObject *pyinfo_cobject = NULL; - PyObject *get_info_parm = NULL; - OSyncPluginInfo *info; - int ret = -1; + osync_trace(TRACE_ENTRY, "%s(%p. %p, %s, %p)", __func__, env, osync_module, filename, error); + //PyObject *get_info_result = NULL; + //PythonPluginInfo pyinfo; + //PyObject *pyinfo_cobject = NULL; + //PyObject *get_info_parm = NULL; + //OSyncPluginInfo *info; - osync_trace(TRACE_ENTRY, "register_plugin"); - - module = PyImport_ImportModule(name); + osync_trace(TRACE_INTERNAL, "Opening file"); + FILE *fp = fopen(filename, "r"); + osync_trace(TRACE_INTERNAL, "Running file"); + PyImport_AddModule("sys"); + PyRun_SimpleFile(fp, filename); + + PyObject *module = PyImport_AddModule("__main__"); + if (!module) { - osync_debug("python", 1, "Couldn't load testmodule"); + osync_error_set(error, OSYNC_ERROR_GENERIC, "Couldn't load module from file %s", filename); PyErr_Print(); PyErr_Clear(); - goto out; + osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(error)); + return FALSE; } + + + osync_trace(TRACE_INTERNAL, "Calling file"); + osync_trace(TRACE_INTERNAL, "Calling file %i", PyModule_Check(module)); + + PyObject *pyret = PyObject_CallMethod(module, "blubbasd", "i", 1); + if (PyErr_Occurred()) + PyErr_Print(); + if (pyret != NULL) { + printf("Result of call: %ld\n", PyInt_AsLong(pyret)); + Py_DECREF(pyret); + } + + PyObject *pDict = PyModule_GetDict(module); + osync_trace(TRACE_INTERNAL, "Dict is %p", pDict); + /* pDict is a borrowed reference */ + + PyObject *pFunc = PyDict_GetItemString(pDict, "blubbasd"); + osync_trace(TRACE_INTERNAL, "func is %p", pFunc); + /* pFun: Borrowed reference */ + if (pFunc && PyCallable_Check(pFunc)) { + PyObject *pArgs = PyTuple_New(1); + PyObject *pValue = PyInt_FromLong(2); + if (!pValue) { + Py_DECREF(pArgs); + fprintf(stderr, "Cannot convert argument\n"); + return 1; + } + /* pValue reference stolen here: */ + PyTuple_SetItem(pArgs, 0, pValue); + pValue = PyObject_CallObject(pFunc, pArgs); + Py_DECREF(pArgs); + if (pValue != NULL) { + printf("Result of call: %ld\n", PyInt_AsLong(pValue)); + Py_DECREF(pValue); + } + } else { + if (PyErr_Occurred()) + PyErr_Print(); + fprintf(stderr, "Cannot find function \"blubbasd\"\n"); + } + +#if 0 info = osync_plugin_new_info(env); - if (!info) { - osync_debug("python", 1, "Couldn't create a new plugin object"); - goto error; - } - - info->functions.initialize = py_initialize; + /*info->functions.initialize = py_initialize; info->functions.connect = py_connect; info->functions.sync_done = py_sync_done; info->functions.disconnect = py_disconnect; info->functions.finalize = py_finalize; info->functions.get_changeinfo = py_get_changeinfo; - info->functions.get_data = py_get_data; + info->functions.get_data = py_get_data;*/ - /*TODO: let the module get_info function fill the fields below: */ - info->is_threadsafe = 1; - /* The plugin data is just the plugin name, * to be used on py_initialize() */ - info->plugin_data = strdup(name); + info->plugin_data = strdup(filename); /** Build a PluginInfo object for use by get_info */ - pyinfo.commit_fn = py_commit_change; - pyinfo.access_fn = py_access; - pyinfo.osync_info = info; + //pyinfo.commit_fn = py_commit_change; + //pyinfo.access_fn = py_access; + //pyinfo.osync_info = info; pyinfo_cobject = PyCObject_FromVoidPtr(&pyinfo, NULL); if (!pyinfo_cobject) { @@ -377,63 +418,43 @@ osync_debug("python", 1, "The plugin didn't set its name!"); goto error_cancel_register; } - osync_trace(TRACE_EXIT, "register_plugin"); - ret = 0; -out: Py_XDECREF(get_info_result); Py_XDECREF(get_info_parm); Py_XDECREF(pyinfo_cobject); Py_XDECREF(module); +#endif - return ret; - -error_cancel_register: - osync_plugin_free(info->plugin); -error: - osync_trace(TRACE_EXIT_ERROR, "register_plugin"); - goto out; + osync_trace(TRACE_EXIT, "%s", __func__); + return TRUE; } -static int scan_for_plugins(OSyncEnv *env) +static osync_bool scan_for_plugins(OSyncEnv *env, PyObject *osync_module) { - PyObject *osync_module; - int ret = -1; - osync_trace(TRACE_ENTRY, "scan_for_plugins"); + osync_trace(TRACE_ENTRY, "%s(%p)", __func__, env); - if (change_sys_path() < 0) { - osync_debug("python", 1, "Exception when initializing python intepreter"); - PyErr_Print(); - PyErr_Clear(); - goto out; + char *path = OPENSYNC_PYTHONPLG_DIR; + GError *gerror = NULL; + GDir *dir = g_dir_open(path, 0, &gerror); + if (!dir) { + osync_trace(TRACE_EXIT_ERROR, "%s: Unable to open directory %s: %s", __func__, path, gerror ? gerror->message : "None"); + return FALSE; } - osync_module = PyImport_ImportModule("opensync"); - if (!osync_module) { - osync_debug("python", 1, "Couldn't load OpenSync module"); - PyErr_Print(); - PyErr_Clear(); - goto out; - } - /*TODO: do a directory listing */ - char *name = "testmodule"; - { - ret = register_plugin(env, osync_module, name); - if (ret < 0) { - osync_debug("python", 1, "Couldn't register plugin %s", name); - goto out_unload_osync; - } + const char *de = NULL; + while ((de = g_dir_read_name(dir))) { + char *filename = g_build_filename(path, de, NULL); + OSyncError *error = NULL; + if (!register_plugin(env, osync_module, filename, &error)) + osync_debug("python", 1, "Couldn't register plugin \"%s\": %s", filename, osync_error_print(&error)); + + g_free(filename); } + g_dir_close(dir); - ret = 0; - - osync_trace(TRACE_EXIT, "scan_for_plugins: ret = %d", ret); - -out_unload_osync: - Py_DECREF(osync_module); -out: - return ret; + osync_trace(TRACE_EXIT, "%s", __func__); + return TRUE; } void get_info(OSyncEnv *env) @@ -447,5 +468,13 @@ sigaction(SIGINT, &old_sigint, NULL); /* Restore it */ PyEval_InitThreads(); - scan_for_plugins(env); + PyObject *osync_module = PyImport_ImportModule("opensync"); + if (!osync_module) { + osync_debug("python", 1, "Couldn't load OpenSync module"); + PyErr_Print(); + PyErr_Clear(); + return; + } + + scan_for_plugins(env, osync_module); } |
From: <svn...@op...> - 2005-04-13 11:57:39
|
Author: abauer Date: 2005-04-13 13:59:14 +0200 (Wed, 13 Apr 2005) New Revision: 495 Modified: trunk/configure.in trunk/wrapper/Makefile.am trunk/wrapper/opensync.i trunk/wrapper/opensync.py Log: Some changes to the wrapper Linked the python wrapper against python Modified: trunk/configure.in =================================================================== --- trunk/configure.in 2005-04-13 10:47:45 UTC (rev 494) +++ trunk/configure.in 2005-04-13 11:59:14 UTC (rev 495) @@ -121,6 +121,7 @@ AC_MSG_WARN([Python not found]) else AC_PROG_SWIG(1.3.17) + SWIG_PYTHON have_python=yes fi Modified: trunk/wrapper/Makefile.am =================================================================== --- trunk/wrapper/Makefile.am 2005-04-13 10:47:45 UTC (rev 494) +++ trunk/wrapper/Makefile.am 2005-04-13 11:59:14 UTC (rev 495) @@ -1,26 +1,26 @@ -AM_CFLAGS = -Wall -Werror +AM_CFLAGS = -Werror INCLUDES= @PACKAGE_CFLAGS@ $(PYTHON_INCLUDES) -I$(top_srcdir) -I$(top_srcdir)/opensync opensync_wrap.c: opensync.i - $(SWIG) -python -I$(top_srcdir)/opensync $(PYTHON_INCLUDES) opensync.i + $(SWIG) -Werror -python -modern -I$(top_srcdir)/opensync $(PYTHON_INCLUDES) opensync.i EXTRA_DIST = opensync.i CLEANFILES = \ - opensync_impl.py \ + opensync.py \ opensync.pyc \ opensync_wrap.c if HAVE_PYTHON osdir = $(pythondir) -os_PYTHON = opensync_impl.py opensync.py +os_PYTHON = opensync.py osbindingsdir = $(pythondir) -osbindings_LTLIBRARIES = _opensync_impl.la +osbindings_LTLIBRARIES = _opensync.la endif -_opensync_impl_la_SOURCES = opensync_wrap.c -_opensync_impl_la_LDFLAGS = @PACKAGE_LIBS@ @XML_LIBS@ -R $(libdir) -module -_opensync_impl_la_LIBADD = $(top_builddir)/opensync/libopensync.la +_opensync_la_SOURCES = opensync_wrap.c +_opensync_la_LDFLAGS = @PACKAGE_LIBS@ @XML_LIBS@ $(PYTHON_LDFLAGS) -R $(libdir) -module +_opensync_la_LIBADD = $(top_builddir)/opensync/libopensync.la Modified: trunk/wrapper/opensync.i =================================================================== --- trunk/wrapper/opensync.i 2005-04-13 10:47:45 UTC (rev 494) +++ trunk/wrapper/opensync.i 2005-04-13 11:59:14 UTC (rev 495) @@ -1,4 +1,4 @@ -%module opensync_impl +%module opensync %{ #include "opensync.h" @@ -22,8 +22,16 @@ printf("Trying to set it to %i\n", inp); } - int name_get() { - return 5; + %pythoncode %{ + def get_name(self): + return self.name_get() + def set_name(self, name): + self.name_set(name) + name = property(get_name, set_name) + %} + + const char *name_get() { + return osync_plugin_get_name(self); } }; @@ -37,11 +45,11 @@ osync_env_free(self); } - osync_bool initialize() { + int initialize() { return osync_env_initialize(self, NULL); } - osync_bool finalize() { + int finalize() { return osync_env_finalize(self, NULL); } Modified: trunk/wrapper/opensync.py =================================================================== --- trunk/wrapper/opensync.py 2005-04-13 10:47:45 UTC (rev 494) +++ trunk/wrapper/opensync.py 2005-04-13 11:59:14 UTC (rev 495) @@ -1,11 +1,103 @@ -import opensync_impl +# This file was created automatically by SWIG. +# Don't modify this file, modify the SWIG interface instead. -class POSyncEnv(opensync_impl.OSyncEnv, object): - def getx(self): - return self.__x - - def setx(self, x): - if x < 0: x = 0 - self.__x = x - - x = property(getx, setx) +import _opensync + +def _swig_setattr_nondynamic(self,class_type,name,value,static=1): + if (name == "this"): + if isinstance(value, class_type): + self.__dict__[name] = value.this + if hasattr(value,"thisown"): self.__dict__["thisown"] = value.thisown + del value.thisown + return + method = class_type.__swig_setmethods__.get(name,None) + if method: return method(self,value) + if (not static) or hasattr(self,name) or (name == "thisown"): + self.__dict__[name] = value + else: + raise AttributeError("You cannot add attributes to %s" % self) + +def _swig_setattr(self,class_type,name,value): + return _swig_setattr_nondynamic(self,class_type,name,value,0) + +def _swig_getattr(self,class_type,name): + method = class_type.__swig_getmethods__.get(name,None) + if method: return method(self) + raise AttributeError,name + +import types +try: + _object = types.ObjectType + _newclass = 1 +except AttributeError: + class _object : pass + _newclass = 0 +del types + + +def _swig_setattr_nondynamic_method(set): + def set_attr(self,name,value): + if hasattr(self,name) or (name in ("this", "thisown")): + set(self,name,value) + else: + raise AttributeError("You cannot add attributes to %s" % self) + return set_attr + + +TRUE = _opensync.TRUE +FALSE = _opensync.FALSE +class OSyncEnv(object): + def __repr__(self): + return "<%s.%s; proxy of C OSyncEnv instance at %s>" % (self.__class__.__module__, self.__class__.__name__, self.this,) + def __init__(self, *args): + newobj = _opensync.new_OSyncEnv(*args) + self.this = newobj.this + self.thisown = 1 + del newobj.thisown + def __del__(self, destroy=_opensync.delete_OSyncEnv): + try: + if self.thisown: destroy(self) + except: pass + + def initialize(*args): return _opensync.OSyncEnv_initialize(*args) + def finalize(*args): return _opensync.OSyncEnv_finalize(*args) + def num_plugins(*args): return _opensync.OSyncEnv_num_plugins(*args) + def get_nth_plugin(*args): return _opensync.OSyncEnv_get_nth_plugin(*args) + +class OSyncEnvPtr(OSyncEnv): + def __init__(self, this): + self.this = this + if not hasattr(self,"thisown"): self.thisown = 0 + self.__class__ = OSyncEnv +_opensync.OSyncEnv_swigregister(OSyncEnvPtr) + +class OSyncPlugin(object): + def __repr__(self): + return "<%s.%s; proxy of C OSyncPlugin instance at %s>" % (self.__class__.__module__, self.__class__.__name__, self.this,) + def __init__(self, *args): + newobj = _opensync.new_OSyncPlugin(*args) + self.this = newobj.this + self.thisown = 1 + del newobj.thisown + def __del__(self, destroy=_opensync.delete_OSyncPlugin): + try: + if self.thisown: destroy(self) + except: pass + + def name_set(*args): return _opensync.OSyncPlugin_name_set(*args) + def get_name(self): + return self.name_get() + def set_name(self, name): + self.name_set(name) + name = property(get_name, set_name) + + def name_get(*args): return _opensync.OSyncPlugin_name_get(*args) + +class OSyncPluginPtr(OSyncPlugin): + def __init__(self, this): + self.this = this + if not hasattr(self,"thisown"): self.thisown = 0 + self.__class__ = OSyncPlugin +_opensync.OSyncPlugin_swigregister(OSyncPluginPtr) + + |
From: <svn...@op...> - 2005-04-13 10:46:10
|
Author: abauer Date: 2005-04-13 12:47:45 +0200 (Wed, 13 Apr 2005) New Revision: 494 Added: branches/python-swig/ Log: Created a new branch of the python module that will make use of swig Copied: branches/python-swig (from rev 493, plugins/python-module) |
From: <svn...@op...> - 2005-04-12 22:32:31
|
Author: abauer Date: 2005-04-13 00:33:40 +0200 (Wed, 13 Apr 2005) New Revision: 493 Added: trunk/wrapper/opensync.py Modified: trunk/acinclude.m4 trunk/configure.in trunk/formats/vformats-xml/xml-vnote.c trunk/opensync/opensync_env.c trunk/wrapper/ trunk/wrapper/Makefile.am trunk/wrapper/opensync.i Log: Made some changes to the swig wrapper Modified: trunk/acinclude.m4 =================================================================== --- trunk/acinclude.m4 2005-04-12 15:18:43 UTC (rev 492) +++ trunk/acinclude.m4 2005-04-12 22:33:40 UTC (rev 493) @@ -1090,3 +1090,63 @@ AC_SUBST(WADPY) fi ]) + +dnl @synopsis AC_PYTHON_DEVEL +dnl +dnl Checks for Python and tries to get the include path to 'Python.h'. +dnl It provides the $(PYTHON_CPPFLAGS) and $(PYTHON_LDFLAGS) output variable. +dnl +dnl @author Sebastian Huber <seb...@we...>, Alan W. Irwin <ir...@be...>, Rafael Laboissiere <lab...@ps...> and Andrew Collier <col...@nu...>. +dnl +dnl @version $Id: ac_python_devel.m4,v 1.1 2004/12/24 01:03:11 guidod Exp $ +dnl +AC_DEFUN([AC_PYTHON_DEVEL],[ + # + # should allow for checking of python version here... + # + AC_REQUIRE([AM_PATH_PYTHON]) + + # Check for Python include path + AC_MSG_CHECKING([for Python include path]) + python_path=`echo $PYTHON | sed "s,/bin.*$,,"` + for i in "$python_path/include/python$PYTHON_VERSION/" "$python_path/include/python/" "$python_path/" ; do + python_path=`find $i -type f -name Python.h -print | sed "1q"` + if test -n "$python_path" ; then + break + fi + done + python_path=`echo $python_path | sed "s,/Python.h$,,"` + AC_MSG_RESULT([$python_path]) + if test -z "$python_path" ; then + AC_MSG_ERROR([cannot find Python include path]) + fi + AC_SUBST([PYTHON_CPPFLAGS],[-I$python_path]) + + # Check for Python library path + AC_MSG_CHECKING([for Python library path]) + python_path=`echo $PYTHON | sed "s,/bin.*$,,"` + for i in "$python_path/lib/python$PYTHON_VERSION/config/" "$python_path/lib/python$PYTHON_VERSION/" "$python_path/lib/python/config/" "$python_path/lib/python/" "$python_path/" ; do + python_path=`find $i -type f -name libpython$PYTHON_VERSION.* -print | sed "1q"` + if test -n "$python_path" ; then + break + fi + done + python_path=`echo $python_path | sed "s,/libpython.*$,,"` + AC_MSG_RESULT([$python_path]) + if test -z "$python_path" ; then + AC_MSG_ERROR([cannot find Python library path]) + fi + AC_SUBST([PYTHON_LDFLAGS],["-L$python_path -lpython$PYTHON_VERSION"]) + # + python_site=`echo $python_path | sed "s/config/site-packages/"` + AC_SUBST([PYTHON_SITE_PKG],[$python_site]) + # + # libraries which must be linked in when embedding + # + AC_MSG_CHECKING(python extra libraries) + PYTHON_EXTRA_LIBS=`$PYTHON -c "import distutils.sysconfig; \ + conf = distutils.sysconfig.get_config_var; \ + print conf('LOCALMODLIBS')+' '+conf('LIBS')" + AC_MSG_RESULT($PYTHON_EXTRA_LIBS)` + AC_SUBST(PYTHON_EXTRA_LIBS) +]) Modified: trunk/configure.in =================================================================== --- trunk/configure.in 2005-04-12 15:18:43 UTC (rev 492) +++ trunk/configure.in 2005-04-12 22:33:40 UTC (rev 493) @@ -99,13 +99,7 @@ fi AM_CONDITIONAL(ENABLE_TESTS, test x$HAVE_CHECK = x1) -#### Check for BDB (obsolete now) #### -# AX_PATH_BDB([4.2],[LDFLAGS="$LDFLAGS $BDB_LDFLAGS" -# LIBS="$LIBS $BDB_LIBS" -# CPPFLAGS="$CPPFLAGS $BDB_CPPFLAGS"],AC_MSG_ERROR(You must have libdb of version 4.1 or higher installed)) - - -#### Check for Python #### +#### Check for Python and Swig #### #(need python, python headers, and pyrex) AC_ARG_ENABLE(python, AS_HELP_STRING([--enable-python], [build python bindings]), @@ -116,20 +110,26 @@ AC_MSG_NOTICE([Checking to see if we can build Python bindings]) have_python=no AM_PATH_PYTHON(2.2) - AM_CHECK_PYTHON_HEADERS + AM_CHECK_PYTHON_HEADERS([have_python_header=yes], [have_python_header=no]) - if test -z "$PYTHON" ; then - AC_MSG_WARN([Python not found]) - else - AC_PROG_SWIG(1.3.17) - have_python=yes - fi - - if test x$have_python = xno ; then + if test x$have_python_header = xno ; then if test x$enable_python = xyes ; then - AC_MSG_ERROR([Building python explicitly requested, but can't build python bindings]) + AC_MSG_ERROR([Building python explicitly requested, but can't build python bindings]) fi - fi + else + if test -z "$PYTHON" ; then + AC_MSG_WARN([Python not found]) + else + AC_PROG_SWIG(1.3.17) + have_python=yes + fi + + if test x$have_python = xno ; then + if test x$enable_python = xyes ; then + AC_MSG_ERROR([Building python explicitly requested, but can't build python bindings]) + fi + fi + fi fi AM_CONDITIONAL(HAVE_PYTHON, test x$have_python = xyes) Modified: trunk/formats/vformats-xml/xml-vnote.c =================================================================== --- trunk/formats/vformats-xml/xml-vnote.c 2005-04-12 15:18:43 UTC (rev 492) +++ trunk/formats/vformats-xml/xml-vnote.c 2005-04-12 22:33:40 UTC (rev 493) @@ -1,3 +1,4 @@ + /* * xml-vnote - A plugin for parsing vnote objects for the opensync framework * Copyright (C) 2004-2005 Armin Bauer <arm...@op...> Modified: trunk/opensync/opensync_env.c =================================================================== --- trunk/opensync/opensync_env.c 2005-04-12 15:18:43 UTC (rev 492) +++ trunk/opensync/opensync_env.c 2005-04-12 22:33:40 UTC (rev 493) @@ -347,7 +347,7 @@ * @returns Number of plugins * */ -int osync_env_num_plugins (OSyncEnv *env) +int osync_env_num_plugins(OSyncEnv *env) { return g_list_length(env->plugins); } Property changes on: trunk/wrapper ___________________________________________________________________ Name: svn:ignore - Makefile.in opensync.py .libs opensync.pyc opensync_wrap.c .deps Makefile + Makefile.in opensync_impl.py .libs opensync.pyc opensync_wrap.c .deps Makefile Modified: trunk/wrapper/Makefile.am =================================================================== --- trunk/wrapper/Makefile.am 2005-04-12 15:18:43 UTC (rev 492) +++ trunk/wrapper/Makefile.am 2005-04-12 22:33:40 UTC (rev 493) @@ -1,4 +1,6 @@ +AM_CFLAGS = -Wall -Werror + INCLUDES= @PACKAGE_CFLAGS@ $(PYTHON_INCLUDES) -I$(top_srcdir) -I$(top_srcdir)/opensync opensync_wrap.c: opensync.i @@ -7,14 +9,18 @@ EXTRA_DIST = opensync.i CLEANFILES = \ - opensync.py \ + opensync_impl.py \ opensync.pyc \ opensync_wrap.c if HAVE_PYTHON -noinst_LTLIBRARIES = _opensync.la +osdir = $(pythondir) +os_PYTHON = opensync_impl.py opensync.py + +osbindingsdir = $(pythondir) +osbindings_LTLIBRARIES = _opensync_impl.la endif -_opensync_la_SOURCES = opensync_wrap.c -_opensync_la_LDFLAGS = @PACKAGE_LIBS@ @XML_LIBS@ -R $(libdir) -module -_opensync_la_LIBADD = $(top_builddir)/opensync/libopensync.la +_opensync_impl_la_SOURCES = opensync_wrap.c +_opensync_impl_la_LDFLAGS = @PACKAGE_LIBS@ @XML_LIBS@ -R $(libdir) -module +_opensync_impl_la_LIBADD = $(top_builddir)/opensync/libopensync.la Modified: trunk/wrapper/opensync.i =================================================================== --- trunk/wrapper/opensync.i 2005-04-12 15:18:43 UTC (rev 492) +++ trunk/wrapper/opensync.i 2005-04-12 22:33:40 UTC (rev 493) @@ -1,22 +1,56 @@ -%module opensync +%module opensync_impl %{ #include "opensync.h" %} %include "opensync.h" -typedef struct { -} OSyncEnv; +typedef struct {} OSyncEnv; +typedef struct {} OSyncPlugin; +%extend OSyncPlugin { + OSyncPlugin(OSyncEnv *env) { + OSyncPlugin *plugin = osync_plugin_new(env); + return plugin; + } + + ~OSyncPlugin() { + osync_plugin_free(self); + } + + void name_set(int inp) { + printf("Trying to set it to %i\n", inp); + } + + int name_get() { + return 5; + } +}; + %extend OSyncEnv { OSyncEnv() { OSyncEnv *env = osync_env_new(); return env; } + ~OSyncEnv() { osync_env_free(self); } + osync_bool initialize() { return osync_env_initialize(self, NULL); } + + osync_bool finalize() { + return osync_env_finalize(self, NULL); + } + + int num_plugins() { + return osync_env_num_plugins(self); + } + + OSyncPlugin *get_nth_plugin(int nth) { + OSyncPlugin *plugin = osync_env_nth_plugin(self, nth); + return plugin; + } }; Added: trunk/wrapper/opensync.py =================================================================== --- trunk/wrapper/opensync.py 2005-04-12 15:18:43 UTC (rev 492) +++ trunk/wrapper/opensync.py 2005-04-12 22:33:40 UTC (rev 493) @@ -0,0 +1,11 @@ +import opensync_impl + +class POSyncEnv(opensync_impl.OSyncEnv, object): + def getx(self): + return self.__x + + def setx(self, x): + if x < 0: x = 0 + self.__x = x + + x = property(getx, setx) |
From: <svn...@op...> - 2005-04-12 15:17:35
|
Author: abauer Date: 2005-04-12 17:18:43 +0200 (Tue, 12 Apr 2005) New Revision: 492 Added: trunk/wrapper/ trunk/wrapper/Makefile.am trunk/wrapper/opensync.i Modified: trunk/Makefile.am trunk/acinclude.m4 trunk/configure.in Log: Added a new wrapper interface based on swig Modified: trunk/Makefile.am =================================================================== --- trunk/Makefile.am 2005-04-12 12:07:48 UTC (rev 491) +++ trunk/Makefile.am 2005-04-12 15:18:43 UTC (rev 492) @@ -1,6 +1,6 @@ ## Process this file with automake to produce Makefile.in -SUBDIRS = opensync osengine formats tests tools +SUBDIRS = opensync osengine formats tests tools wrapper if BUILD_ENGINE OSENGINE_PC = osengine-1.0.pc Modified: trunk/acinclude.m4 =================================================================== --- trunk/acinclude.m4 2005-04-12 12:07:48 UTC (rev 491) +++ trunk/acinclude.m4 2005-04-12 15:18:43 UTC (rev 492) @@ -934,3 +934,159 @@ ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD (exit $ac_status); }]) + +dnl @synopsis AC_PROG_SWIG([major.minor.micro]) +dnl +dnl This macro searches for a SWIG installation on your system. If +dnl found you should call SWIG via $(SWIG). You can use the optional +dnl first argument to check if the version of the available SWIG is +dnl greater than or equal to the value of the argument. It should have +dnl the format: N[.N[.N]] (N is a number between 0 and 999. Only the +dnl first N is mandatory.) +dnl +dnl If the version argument is given (e.g. 1.3.17), AC_PROG_SWIG checks +dnl that the swig package is this version number or higher. +dnl +dnl In configure.in, use as: +dnl +dnl AC_PROG_SWIG(1.3.17) +dnl SWIG_ENABLE_CXX +dnl SWIG_MULTI_MODULE_SUPPORT +dnl SWIG_PYTHON +dnl +dnl @category InstalledPackages +dnl @author Sebastian Huber <seb...@we...> +dnl @author Alan W. Irwin <ir...@be...> +dnl @author Rafael Laboissiere <ra...@la...> +dnl @author Andrew Collier <abc...@ya...> +dnl @version 2004-09-20 +dnl @license GPLWithACException + +AC_DEFUN([AC_PROG_SWIG],[ + AC_PATH_PROG([SWIG],[swig]) + if test -z "$SWIG" ; then + AC_MSG_WARN([cannot find 'swig' program. You should look at http://www.swig.org]) + SWIG='echo "Error: SWIG is not installed. You should look at http://www.swig.org" ; false' + elif test -n "$1" ; then + AC_MSG_CHECKING([for SWIG version]) + [swig_version=`$SWIG -version 2>&1 | grep 'SWIG Version' | sed 's/.*\([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\).*/\1/g'`] + AC_MSG_RESULT([$swig_version]) + if test -n "$swig_version" ; then + # Calculate the required version number components + [required=$1] + [required_major=`echo $required | sed 's/[^0-9].*//'`] + if test -z "$required_major" ; then + [required_major=0] + fi + [required=`echo $required | sed 's/[0-9]*[^0-9]//'`] + [required_minor=`echo $required | sed 's/[^0-9].*//'`] + if test -z "$required_minor" ; then + [required_minor=0] + fi + [required=`echo $required | sed 's/[0-9]*[^0-9]//'`] + [required_patch=`echo $required | sed 's/[^0-9].*//'`] + if test -z "$required_patch" ; then + [required_patch=0] + fi + # Calculate the available version number components + [available=$swig_version] + [available_major=`echo $available | sed 's/[^0-9].*//'`] + if test -z "$available_major" ; then + [available_major=0] + fi + [available=`echo $available | sed 's/[0-9]*[^0-9]//'`] + [available_minor=`echo $available | sed 's/[^0-9].*//'`] + if test -z "$available_minor" ; then + [available_minor=0] + fi + [available=`echo $available | sed 's/[0-9]*[^0-9]//'`] + [available_patch=`echo $available | sed 's/[^0-9].*//'`] + if test -z "$available_patch" ; then + [available_patch=0] + fi + if test $available_major -ne $required_major \ + -o $available_minor -ne $required_minor \ + -o $available_patch -lt $required_patch ; then + AC_MSG_WARN([SWIG version >= $1 is required. You have $swig_version. You should look at http://www.swig.org]) + SWIG='echo "Error: SWIG version >= $1 is required. You have '"$swig_version"'. You should look at http://www.swig.org" ; false' + else + AC_MSG_NOTICE([SWIG executable is '$SWIG']) + SWIG_LIB=`$SWIG -swiglib` + AC_MSG_NOTICE([SWIG library directory is '$SWIG_LIB']) + fi + else + AC_MSG_WARN([cannot determine SWIG version]) + SWIG='echo "Error: Cannot determine SWIG version. You should look at http://www.swig.org" ; false' + fi + fi + AC_SUBST([SWIG_LIB]) +]) + +# SWIG_ENABLE_CXX() +# +# Enable SWIG C++ support. This affects all invocations of $(SWIG). +AC_DEFUN([SWIG_ENABLE_CXX],[ + AC_REQUIRE([AC_PROG_SWIG]) + AC_REQUIRE([AC_PROG_CXX]) + SWIG="$SWIG -c++" +]) + +# SWIG_MULTI_MODULE_SUPPORT() +# +# Enable support for multiple modules. This effects all invocations +# of $(SWIG). You have to link all generated modules against the +# appropriate SWIG runtime library. If you want to build Python +# modules for example, use the SWIG_PYTHON() macro and link the +# modules against $(SWIG_PYTHON_LIBS). +# +AC_DEFUN([SWIG_MULTI_MODULE_SUPPORT],[ + AC_REQUIRE([AC_PROG_SWIG]) + SWIG="$SWIG -noruntime" +]) + +# SWIG_PYTHON([use-shadow-classes = {no, yes}]) +# +# Checks for Python and provides the $(SWIG_PYTHON_CPPFLAGS), +# and $(SWIG_PYTHON_OPT) output variables. +# +# $(SWIG_PYTHON_OPT) contains all necessary SWIG options to generate +# code for Python. Shadow classes are enabled unless the value of the +# optional first argument is exactly 'no'. If you need multi module +# support (provided by the SWIG_MULTI_MODULE_SUPPORT() macro) use +# $(SWIG_PYTHON_LIBS) to link against the appropriate library. It +# contains the SWIG Python runtime library that is needed by the type +# check system for example. +AC_DEFUN([SWIG_PYTHON],[ + AC_REQUIRE([AC_PROG_SWIG]) + AC_REQUIRE([AC_PYTHON_DEVEL]) + test "x$1" != "xno" || swig_shadow=" -noproxy" + AC_SUBST([SWIG_PYTHON_OPT],[-python$swig_shadow]) + AC_SUBST([SWIG_PYTHON_CPPFLAGS],[$PYTHON_CPPFLAGS]) +]) + + +dnl @synopsis AC_LIB_WAD +dnl +dnl This macro searches for installed WAD library. +dnl +AC_DEFUN([AC_LIB_WAD], +[ + AC_REQUIRE([AC_PYTHON_DEVEL]) + AC_ARG_ENABLE(wad, + AC_HELP_STRING([--enable-wad], [enable wad module]), + [ + case "${enableval}" in + no) ;; + *) if test "x${enableval}" = xyes; + then + check_wad="yes" + fi ;; + esac + ], []) + + if test -n "$check_wad"; + then + AC_CHECK_LIB(wadpy, _init, [WADPY=-lwadpy], [], $PYTHON_LDFLAGS $PYTHON_EXTRA_LIBS) + AC_SUBST(WADPY) + fi +]) Modified: trunk/configure.in =================================================================== --- trunk/configure.in 2005-04-12 12:07:48 UTC (rev 491) +++ trunk/configure.in 2005-04-12 15:18:43 UTC (rev 492) @@ -86,7 +86,6 @@ AC_SUBST(XML_CFLAGS) AC_SUBST(XML_LIBS) - #### Check for unit tests #### AC_ARG_ENABLE(unit-tests, AS_HELP_STRING([--enable-unit-tests], [enable unit tests]), @@ -117,23 +116,13 @@ AC_MSG_NOTICE([Checking to see if we can build Python bindings]) have_python=no AM_PATH_PYTHON(2.2) - + AM_CHECK_PYTHON_HEADERS + if test -z "$PYTHON" ; then AC_MSG_WARN([Python not found]) else - AC_CHECK_PROGS(PYREX, pyrexc) - - if test -z "$PYREX" ; then - have_pyrex=no - else - have_pyrex=yes - fi - - AM_CHECK_PYTHON_HEADERS(have_python_headers=yes,have_python_headers=no) - - if test x$have_pyrex = xyes -a x$have_python_headers = xyes ; then - have_python=yes - fi + AC_PROG_SWIG(1.3.17) + have_python=yes fi if test x$have_python = xno ; then @@ -142,7 +131,6 @@ fi fi fi - AM_CONDITIONAL(HAVE_PYTHON, test x$have_python = xyes) #### Check for glib and sqlite #### @@ -172,6 +160,7 @@ osengine-1.0-uninstalled.pc Doxyfile misc/opensync.spec +wrapper/Makefile ]) @@ -193,7 +182,7 @@ echo "" echo "========================================" -AC_OPENSYNC_ISENABLED([Python Bindings], HAVE_PYTHON, 1) +AC_OPENSYNC_ISENABLED([Python Bindings], have_python) AC_OPENSYNC_ISENABLED([Unit Tests], HAVE_CHECK, 1) AC_OPENSYNC_ISENABLED([Debug messages], WITH_DEBUG) AC_OPENSYNC_ISENABLED([Tracing], WITH_TRACE) Property changes on: trunk/wrapper ___________________________________________________________________ Name: svn:ignore + Makefile.in opensync.py .libs opensync.pyc opensync_wrap.c .deps Makefile Added: trunk/wrapper/Makefile.am =================================================================== --- trunk/wrapper/Makefile.am 2005-04-12 12:07:48 UTC (rev 491) +++ trunk/wrapper/Makefile.am 2005-04-12 15:18:43 UTC (rev 492) @@ -0,0 +1,20 @@ + +INCLUDES= @PACKAGE_CFLAGS@ $(PYTHON_INCLUDES) -I$(top_srcdir) -I$(top_srcdir)/opensync + +opensync_wrap.c: opensync.i + $(SWIG) -python -I$(top_srcdir)/opensync $(PYTHON_INCLUDES) opensync.i + +EXTRA_DIST = opensync.i + +CLEANFILES = \ + opensync.py \ + opensync.pyc \ + opensync_wrap.c + +if HAVE_PYTHON +noinst_LTLIBRARIES = _opensync.la +endif + +_opensync_la_SOURCES = opensync_wrap.c +_opensync_la_LDFLAGS = @PACKAGE_LIBS@ @XML_LIBS@ -R $(libdir) -module +_opensync_la_LIBADD = $(top_builddir)/opensync/libopensync.la Added: trunk/wrapper/opensync.i =================================================================== --- trunk/wrapper/opensync.i 2005-04-12 12:07:48 UTC (rev 491) +++ trunk/wrapper/opensync.i 2005-04-12 15:18:43 UTC (rev 492) @@ -0,0 +1,22 @@ +%module opensync + +%{ +#include "opensync.h" +%} + +%include "opensync.h" +typedef struct { +} OSyncEnv; + +%extend OSyncEnv { + OSyncEnv() { + OSyncEnv *env = osync_env_new(); + return env; + } + ~OSyncEnv() { + osync_env_free(self); + } + osync_bool initialize() { + return osync_env_initialize(self, NULL); + } +}; |
From: <svn...@op...> - 2005-04-12 12:06:50
|
Author: ehabkost Date: 2005-04-12 14:07:48 +0200 (Tue, 12 Apr 2005) New Revision: 491 Modified: plugins/python-module/src/opensync.pyx Log: Added TODO information, so we know what is missing here Modified: plugins/python-module/src/opensync.pyx =================================================================== --- plugins/python-module/src/opensync.pyx 2005-04-12 11:16:19 UTC (rev 490) +++ plugins/python-module/src/opensync.pyx 2005-04-12 12:07:48 UTC (rev 491) @@ -135,6 +135,14 @@ if f: return osync_objformat_get_name(f) else: return None + #TODO: Implement set_data and get_data + #TODO: Write some wrappers to common formats having structs, + # such as fs_info. In the case of known object formats, + # return a python object wrapping the object sotred + # on the change data + + + cdef class PluginInfo: """opensync OSyncPluginInfo object""" |
From: <svn...@op...> - 2005-04-12 11:14:55
|
Author: abauer Date: 2005-04-12 13:16:19 +0200 (Tue, 12 Apr 2005) New Revision: 490 Modified: trunk/opensync/opensync_env.c trunk/opensync/opensync_env_internals.h trunk/opensync/opensync_plugin.c trunk/opensync/opensync_plugin.h trunk/opensync/opensync_plugin_internals.h trunk/tests/check_env.c trunk/tests/mock-plugin/mock_sync.c trunk/tests/support.c trunk/tools/osyncplugin.c Log: Changed the api to unify the plugin and the module loader. The sync module loader gets now a OSyncEnv passed so it can register several plugins at once. Modified: trunk/opensync/opensync_env.c =================================================================== --- trunk/opensync/opensync_env.c 2005-04-12 11:14:21 UTC (rev 489) +++ trunk/opensync/opensync_env.c 2005-04-12 11:16:19 UTC (rev 490) @@ -240,18 +240,17 @@ GList *p; for (p = plugins; p; p = p->next) { OSyncPlugin *plugin = p->data; - osync_plugin_unload(plugin); osync_plugin_free(plugin); } g_list_free(plugins); - plugins = g_list_copy(env->formatplugins); - for (p = plugins; p; p = p->next) { - GModule *gplugin = p->data; - osync_trace(TRACE_INTERNAL, "osync_format_plugin_free %p", gplugin); - g_module_close(gplugin); + //Unload all loaded modules + GList *modules = g_list_copy(env->modules); + for (p = modules; p; p = p->next) { + GModule *module = p->data; + osync_module_unload(env, module); } - g_list_free(plugins); + g_list_free(modules); osync_trace(TRACE_EXIT, "osync_env_finalize"); return TRUE; @@ -269,55 +268,28 @@ * @returns TRUE if successfull, FALSE otherwise * */ -osync_bool osync_env_load_formats(OSyncEnv *env, const char *path, OSyncError **oserror) +osync_bool osync_env_load_formats(OSyncEnv *env, const char *path, OSyncError **error) { - g_assert(env); - osync_bool not_fatal = FALSE; - + osync_trace(TRACE_ENTRY, "%s(%p, %s, %p)", __func__, env, path, error); + osync_bool must_exist = TRUE; + if (!path) { path = OPENSYNC_FORMATSDIR; - not_fatal = TRUE; + must_exist = FALSE; } - if (!g_file_test(path, G_FILE_TEST_IS_DIR)) { - osync_debug("ENV", 1, "directory %s does not exist", path); - return not_fatal; - } - - GDir *dir = NULL; - GError *error = NULL; - dir = g_dir_open(path, 0, &error); - if (!dir) { - osync_debug("OSCONV", 0, "Unable to open format plugin directory %s: %s", path, error->message); - osync_error_set(oserror, OSYNC_ERROR_IO_ERROR, "Unable to open format directory %s: %s", path, error->message); - g_error_free(error); + if (!osync_module_load_dir(env, path, must_exist, error)) { + osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(error)); return FALSE; } - const gchar *de = NULL; - while ((de = g_dir_read_name(dir))) { - char *filename = NULL; - filename = g_strdup_printf ("%s/%s", path, de); - - if (!g_file_test(filename, G_FILE_TEST_IS_REGULAR) || g_file_test(filename, G_FILE_TEST_IS_SYMLINK) || g_pattern_match_simple("*lib.la", filename) || g_pattern_match_simple("*.la", filename)) { - g_free(filename); - continue; - } - - OSyncError *error = NULL; - if (!osync_format_plugin_load(env, filename, &error)) { - osync_debug("OSCONV", 0, "Unable to load format plugin %s: %s", filename, error->message); - osync_error_free(&error); - } - g_free(filename); - } - g_dir_close(dir); + osync_trace(TRACE_EXIT, "%s", __func__); return TRUE; } -/*! @brief Loads the plugins from a given directory +/*! @brief Loads the sync modules from a given directory * - * Loads all plugins from a directory into a osync environment + * Loads all sync modules from a directory into a osync environment * * @param env Pointer to a OSyncEnv environment * @param path The path where to look for plugins @@ -325,49 +297,22 @@ * @returns TRUE on success, FALSE otherwise * */ -osync_bool osync_env_load_plugins(OSyncEnv *env, const char *path, OSyncError **oserror) +osync_bool osync_env_load_plugins(OSyncEnv *env, const char *path, OSyncError **error) { - GDir *dir; - GError *error = NULL; - char *filename = NULL; - osync_bool not_fatal = FALSE; + osync_trace(TRACE_ENTRY, "%s(%p, %s, %p)", __func__, env, path, error); + osync_bool must_exist = TRUE; if (!path) { path = OPENSYNC_PLUGINDIR; - not_fatal = TRUE; + must_exist = FALSE; } - //Load all available shared libraries (plugins) - if (!g_file_test(path, G_FILE_TEST_EXISTS)) { - osync_debug("OSGRP", 3, "%s is no dir", path); - return not_fatal; - } - - dir = g_dir_open(path, 0, &error); - if (!dir) { - osync_debug("OSPLG", 0, "Unable to open plugin directory %s: %s", path, error->message); - osync_error_set(oserror, OSYNC_ERROR_IO_ERROR, "Unable to open directory %s: %s", path, error->message); - g_error_free(error); + if (!osync_module_load_dir(env, path, must_exist, error)) { + osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(error)); return FALSE; } - - const gchar *de = NULL; - while ((de = g_dir_read_name(dir))) { - filename = g_strdup_printf ("%s/%s", path, de); - - if (!g_file_test(filename, G_FILE_TEST_IS_REGULAR) || g_file_test(filename, G_FILE_TEST_IS_SYMLINK) || g_pattern_match_simple("*.la", filename) || g_pattern_match_simple("*lib.so", filename)) { - g_free(filename); - continue; - } - - OSyncError *error = NULL; - if (!osync_plugin_load(env, filename, &error)) { - osync_debug("OSPLG", 0, "Unable to load plugin %s: %s", filename, error->message); - osync_error_free(&error); - } - g_free(filename); - } - g_dir_close(dir); + + osync_trace(TRACE_EXIT, "%s", __func__); return TRUE; } Modified: trunk/opensync/opensync_env_internals.h =================================================================== --- trunk/opensync/opensync_env_internals.h 2005-04-12 11:14:21 UTC (rev 489) +++ trunk/opensync/opensync_env_internals.h 2005-04-12 11:16:19 UTC (rev 490) @@ -7,8 +7,9 @@ char *groupsdir; - GList *plugins; - GList *formatplugins; + GList *plugins; //The registered plugins + GList *formatplugins; //The registered formats + GList *modules; //The loaded modules GList *format_templates; GList *converter_templates; Modified: trunk/opensync/opensync_plugin.c =================================================================== --- trunk/opensync/opensync_plugin.c 2005-04-12 11:14:21 UTC (rev 489) +++ trunk/opensync/opensync_plugin.c 2005-04-12 11:16:19 UTC (rev 490) @@ -189,10 +189,9 @@ return function; } -/*! @brief dlopen()s a plugin and returns the information from it +/*! @brief dlopen()s a format plugin * - * The get_info() function on the plugin gets called and the information is stored - * in the plugin struct + * The get_info() function on the format plugin gets called * * @param env The environment in which to open the plugin * @param path Where to find this plugin @@ -200,137 +199,119 @@ * @return Pointer to the plugin on success, NULL otherwise * */ -osync_bool osync_plugin_load(OSyncEnv *env, const char *path, OSyncError **error) +osync_bool osync_module_load(OSyncEnv *env, const char *path, OSyncError **error) { - GModule *module; - - osync_trace(TRACE_ENTRY, "osync_plugin_load(%p, %s, %p)", env, path, error); - + osync_trace(TRACE_ENTRY, "%s(%p, %s, %p)", __func__, env, path, error); /* Check if this platform supports dynamic * loading of modules */ + if (!g_module_supported()) { - osync_debug("OSPLG", 0, "This platform does not support loading of modules"); osync_error_set(error, OSYNC_ERROR_GENERIC, "This platform does not support loading of modules"); - goto error; + osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(error)); + return FALSE; } /* Try to open the module or fail if an error occurs */ - module = g_module_open(path, 0); //G_MODULE_BIND_LOCAL); - + GModule *module = g_module_open(path, G_MODULE_BIND_LOCAL); if (!module) { - osync_error_set(error, OSYNC_ERROR_GENERIC, "Unable to open plugin %s: %s", path, g_module_error()); - goto error; + osync_error_set(error, OSYNC_ERROR_GENERIC, "Unable to open module %s: %s", path, g_module_error()); + osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(error)); + return FALSE; } - /* There are two type of plugins: simple plugins and multiple plugins. - * - * - Simple plugins register only one plugin object - * - Multiple plugins can register many plugins. Plugins for modules - * in other languages (such as python-module plugin) can use this - * feature - */ - void (* fct_info)(OSyncPluginInfo *info); - void (* fct_register)(OSyncEnv *env); - if (!g_module_symbol(module, "get_info", (void*)&fct_info)) - fct_info = NULL; - if (!g_module_symbol(module, "register_plugins", (void*)&fct_register)) - fct_register = NULL; - if (!fct_info && !fct_register) { - osync_debug("OSPLG", 0, "Unable to open plugin: No get_info or register_plugins symbol"); - osync_error_set(error, OSYNC_ERROR_GENERIC, "Module %s is not a valid OpenSync plugin (no symbol get_info or register_plugins)", path); - goto error_unload; + /* Load the get_info symbol */ + void (* fct_info)(OSyncEnv *env) = NULL; + void (** fct_infop)(OSyncEnv *env) = &fct_info; + if (!g_module_symbol(module, "get_info", (void **)fct_infop)) { + osync_error_set(error, OSYNC_ERROR_GENERIC, "Unable to get symbol from module %s: %s", path, g_module_error()); + osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(error)); + return FALSE; } + env->modules = g_list_append(env->modules, module); - /* Simple plugin: call get_info */ - if (fct_info) { - OSyncPlugin *plugin = osync_plugin_new(env); - plugin->real_plugin = module; - fct_info(&(plugin->info)); - plugin->path = g_strdup(path); - osync_trace(TRACE_INTERNAL, "osync_plugin_load: simple plugin: %p", plugin); - } - - /* Multiple plugin: call register_plugins */ - if (fct_register) { - osync_trace(TRACE_INTERNAL, "osync_plugin_load: multiple plugin"); - fct_register(env); - } + /* Call the get_info function */ + fct_info(env); - osync_trace(TRACE_EXIT, "osync_plugin_load: success"); + osync_trace(TRACE_EXIT, "%s: %p", __func__, module); return TRUE; - -error_unload: - g_module_close(module); -error: - osync_trace(TRACE_EXIT_ERROR, "osync_plugin_load: %s", osync_error_print(error)); - return FALSE; } -/*! @brief unloads a previously loaded plugin +/*! @brief Closes a module * - * This unloads the plugin (but does not free the struct itself) + * @param module The module to unload * - * @param plugin Pointer to the plugin - * */ -void osync_plugin_unload(OSyncPlugin *plugin) +void osync_module_unload(OSyncEnv *env, GModule *module) { - g_assert(plugin); - if (!plugin->real_plugin) { - osync_debug("OSPLG", 0, "You need to load a plugin before unloading it"); - return; - } - + osync_trace(TRACE_INTERNAL, "%s(%p, %p)", __func__, env, module); //FIXME Close the module! This crashes the evo2 plugin at the moment, i have no idea why... //g_module_close(plugin->real_plugin); - g_free(plugin->path); - plugin->path = NULL; + env->modules = g_list_remove(env->modules, module); } -/*! @brief dlopen()s a format plugin +/*! @brief Loads the modules from a given directory * - * The get_info() function on the format plugin gets called + * Loads all modules from a directory into a osync environment * - * @param env The environment in which to open the plugin - * @param path Where to find this plugin - * @param error Pointer to a error struct - * @return Pointer to the plugin on success, NULL otherwise + * @param env Pointer to a OSyncEnv environment + * @param path The path where to look for plugins, NULL for the default sync module directory + * @param must_exist If set to TRUE, this function will return an error if the directory does not exist + * @param error Pointer to a error struct to return a error + * @returns TRUE on success, FALSE otherwise * */ -osync_bool osync_format_plugin_load(OSyncEnv *env, char *path, OSyncError **error) +osync_bool osync_module_load_dir(OSyncEnv *env, const char *path, osync_bool must_exist, OSyncError **error) { - osync_trace(TRACE_ENTRY, "osync_format_plugin_load(%p, %s, %p)", env, path, error); - /* Check if this platform supports dynamic - * loading of modules */ - - if (!g_module_supported()) { - osync_error_set(error, OSYNC_ERROR_GENERIC, "This platform does not support loading of modules"); - osync_debug("OSPLG", 0, "This platform does not support loading of modules"); - osync_trace(TRACE_EXIT_ERROR, "osync_format_plugin_load: %s", osync_error_print(error)); - return FALSE; - } + osync_trace(TRACE_ENTRY, "%s(%p, %s, %p)", __func__, env, path, error); + GDir *dir; + GError *gerror = NULL; + char *filename = NULL; - /* Try to open the module or fail if an error occurs */ - GModule *plugin = g_module_open(path, G_MODULE_BIND_LOCAL); - if (!plugin) { - osync_error_set(error, OSYNC_ERROR_GENERIC, "Unable to open plugin %s: %s", path, g_module_error()); - osync_debug("OSPLG", 0, "Unable to open plugin %s", path); - osync_trace(TRACE_EXIT_ERROR, "osync_format_plugin_load: %s", osync_error_print(error)); + if (!path) { + osync_error_set(error, OSYNC_ERROR_GENERIC, "Not path given to load the modules from"); + osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(error)); return FALSE; } - void (* fct_info)(OSyncEnv *env) = NULL; - void (** fct_infop)(OSyncEnv *env) = &fct_info; - if (!g_module_symbol(plugin, "get_info", (void **)fct_infop)) { - osync_error_set(error, OSYNC_ERROR_GENERIC, "Unable to open format plugin %s: %s", path, g_module_error()); - osync_debug("OSPLG", 0, "Unable to open format plugin %s", path); - osync_trace(TRACE_EXIT_ERROR, "osync_format_plugin_load: %s", osync_error_print(error)); + //Load all available shared libraries (plugins) + if (!g_file_test(path, G_FILE_TEST_IS_DIR)) { + if (must_exist) { + osync_error_set(error, OSYNC_ERROR_GENERIC, "Path is not loadable"); + osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(error)); + return FALSE; + } else { + osync_trace(TRACE_EXIT, "%s: Directory does not exist (non-fatal)", __func__); + return TRUE; + } + } + + dir = g_dir_open(path, 0, &gerror); + if (!dir) { + osync_error_set(error, OSYNC_ERROR_IO_ERROR, "Unable to open directory %s: %s", path, gerror->message); + g_error_free(gerror); + osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(error)); return FALSE; } - env->formatplugins = g_list_append(env->formatplugins, plugin); + + const gchar *de = NULL; + while ((de = g_dir_read_name(dir))) { + filename = g_strdup_printf ("%s/%s", path, de); + + if (!g_file_test(filename, G_FILE_TEST_IS_REGULAR) || g_file_test(filename, G_FILE_TEST_IS_SYMLINK) || !g_pattern_match_simple("*.so", filename)) { + g_free(filename); + continue; + } + + OSyncError *error = NULL; + if (!osync_module_load(env, filename, &error)) { + osync_debug("OSPLG", 0, "Unable to load plugin %s: %s", filename, error->message); + osync_error_free(&error); + } + g_free(filename); + } + g_dir_close(dir); - fct_info(env); - osync_trace(TRACE_EXIT, "osync_format_plugin_load: %p", plugin); + osync_trace(TRACE_EXIT, "%s", __func__); return TRUE; } Modified: trunk/opensync/opensync_plugin.h =================================================================== --- trunk/opensync/opensync_plugin.h 2005-04-12 11:14:21 UTC (rev 489) +++ trunk/opensync/opensync_plugin.h 2005-04-12 11:16:19 UTC (rev 490) @@ -114,9 +114,8 @@ OSyncPluginInfo *osync_plugin_new_info(OSyncEnv *env); void osync_plugin_free(OSyncPlugin *plugin); -osync_bool osync_plugin_load(OSyncEnv *env, const char *path, OSyncError **error); -void osync_plugin_unload(OSyncPlugin *plugin); -osync_bool osync_format_plugin_load(OSyncEnv *env, char *path, OSyncError **error); +osync_bool osync_module_load(OSyncEnv *env, const char *path, OSyncError **error); +osync_bool osync_module_load_dir(OSyncEnv *env, const char *path, osync_bool must_exist, OSyncError **oserror); OSyncPlugin *osync_plugin_from_name(OSyncEnv *osinfo, const char *name); const char *osync_plugin_get_name(OSyncPlugin *plugin); Modified: trunk/opensync/opensync_plugin_internals.h =================================================================== --- trunk/opensync/opensync_plugin_internals.h 2005-04-12 11:14:21 UTC (rev 489) +++ trunk/opensync/opensync_plugin_internals.h 2005-04-12 11:16:19 UTC (rev 490) @@ -18,4 +18,4 @@ OSyncObjFormatTemplate *osync_plugin_find_objformat_template(OSyncObjTypeTemplate *type_template, const char *objformatstr); OSyncObjFormatSink *osync_objtype_find_format_sink(OSyncObjTypeSink *sink, const char *formatstr); -osync_bool osync_format_plugin_load(OSyncEnv *env, char *path, OSyncError **error); +void osync_module_unload(OSyncEnv *env, GModule *module); Modified: trunk/tests/check_env.c =================================================================== --- trunk/tests/check_env.c 2005-04-12 11:14:21 UTC (rev 489) +++ trunk/tests/check_env.c 2005-04-12 11:16:19 UTC (rev 490) @@ -22,6 +22,7 @@ fail_unless(env != NULL, NULL); osync_env_set_option(env, "GROUPS_DIRECTORY", "configs"); + osync_env_set_option(env, "LOAD_PLUGINS", "FALSE"); fail_unless(osync_env_initialize(env, NULL), NULL); @@ -38,6 +39,7 @@ fail_unless(env != NULL, NULL); osync_env_set_option(env, "GROUPS_DIRECTORY", "configs"); + osync_env_set_option(env, "LOAD_PLUGINS", "FALSE"); fail_unless(osync_env_initialize(env, NULL), NULL); fail_unless(!osync_env_initialize(env, NULL), NULL); @@ -67,6 +69,7 @@ char *testbed = setup_testbed("sync_setup_false"); OSyncEnv *osync = osync_env_new(); osync_env_set_option(osync, "GROUPS_DIRECTORY", "configs"); + osync_env_set_option(osync, "LOAD_PLUGINS", "FALSE"); OSyncError *error = NULL; osync_env_initialize(osync, &error); fail_unless(osync_env_num_groups(osync) == 1, NULL); Modified: trunk/tests/mock-plugin/mock_sync.c =================================================================== --- trunk/tests/mock-plugin/mock_sync.c 2005-04-12 11:14:21 UTC (rev 489) +++ trunk/tests/mock-plugin/mock_sync.c 2005-04-12 11:16:19 UTC (rev 490) @@ -442,8 +442,10 @@ osync_trace(TRACE_EXIT, "%s", __func__); } -void get_info(OSyncPluginInfo *info) +void get_info(OSyncEnv *env) { + OSyncPluginInfo *info = osync_plugin_new_info(env); + info->name = "file-sync"; info->longname = "Mock Plugin"; info->description = "Mock Plugin"; Modified: trunk/tests/support.c =================================================================== --- trunk/tests/support.c 2005-04-12 11:14:21 UTC (rev 489) +++ trunk/tests/support.c 2005-04-12 11:16:19 UTC (rev 490) @@ -410,7 +410,7 @@ { OSyncError *error = NULL; char *path = g_strdup_printf("%s/%s", g_get_current_dir(), name); - fail_unless(osync_format_plugin_load(env, path, &error), NULL); + fail_unless(osync_module_load(env, path, &error), NULL); g_free(path); } @@ -428,7 +428,7 @@ fail_unless(!osync_error_is_set(&error), NULL); char *path = g_strdup_printf("%s/%s", g_get_current_dir(), "mock_sync.so"); - fail_unless(osync_plugin_load(osync, path, &error), NULL); + fail_unless(osync_module_load(osync, path, &error), NULL); g_free(path); load_format(osync, "contact.so"); Modified: trunk/tools/osyncplugin.c =================================================================== --- trunk/tools/osyncplugin.c 2005-04-12 11:14:21 UTC (rev 489) +++ trunk/tools/osyncplugin.c 2005-04-12 11:16:19 UTC (rev 490) @@ -376,6 +376,7 @@ if (!objtype) usage (argv[0], 1); } else if (!strcmp (arg, "--plugindir")) { + printf("plugindir %s\n", argv[i + 1]); plugindir = argv[i + 1]; i++; if (!plugindir) @@ -406,7 +407,7 @@ if (plugin) { osync_env_set_option(env, "LOAD_PLUGINS", "FALSE"); - if (!osync_plugin_load(env, plugin, &error)) { + if (!osync_module_load(env, plugin, &error)) { printf("Unable to load plugin: %s\n", osync_error_print(&error)); osync_error_free(&error); return 1; @@ -418,7 +419,7 @@ if (format) { osync_env_set_option(env, "LOAD_FORMATS", "FALSE"); - if (!osync_format_plugin_load(env, format, &error)) { + if (!osync_module_load(env, format, &error)) { printf("Unable to load format: %s\n", osync_error_print(&error)); osync_error_free(&error); return 1; |
From: <svn...@op...> - 2005-04-12 11:13:09
|
Author: abauer Date: 2005-04-12 13:14:21 +0200 (Tue, 12 Apr 2005) New Revision: 489 Modified: plugins/evolution2/src/evolution2_sync.c plugins/file-sync/src/file_sync.c plugins/kdepim/src/kdepim_sync.cpp plugins/kdepim/tests/check_contact plugins/kdepim/tests/check_event plugins/kdepim/tests/check_note plugins/kdepim/tests/check_todo plugins/python-module/src/python_module.c Log: Changed the plugins to the new plugin api. Fixed a bug in the kdepim unit tests, where the unit tests would pick up the currently installed plugin instead of the newly compiled one. Modified: plugins/evolution2/src/evolution2_sync.c =================================================================== --- plugins/evolution2/src/evolution2_sync.c 2005-04-11 16:08:06 UTC (rev 488) +++ plugins/evolution2/src/evolution2_sync.c 2005-04-12 11:14:21 UTC (rev 489) @@ -299,7 +299,9 @@ g_free(env); } -void get_info(OSyncPluginInfo *info) { +void get_info(OSyncEnv *env) +{ + OSyncPluginInfo *info = osync_plugin_new_info(env); info->name = "evo2-sync"; info->version = 1; info->is_threadsafe = TRUE; Modified: plugins/file-sync/src/file_sync.c =================================================================== --- plugins/file-sync/src/file_sync.c 2005-04-11 16:08:06 UTC (rev 488) +++ plugins/file-sync/src/file_sync.c 2005-04-12 11:14:21 UTC (rev 489) @@ -377,8 +377,9 @@ g_free(fsinfo); } -void get_info(OSyncPluginInfo *info) +void get_info(OSyncEnv *env) { + OSyncPluginInfo *info = osync_plugin_new_info(env); info->name = "file-sync"; info->longname = "File Synchronization Plugin"; info->description = "Plugin to synchronize files on the local filesystem"; Modified: plugins/kdepim/src/kdepim_sync.cpp =================================================================== --- plugins/kdepim/src/kdepim_sync.cpp 2005-04-11 16:08:06 UTC (rev 488) +++ plugins/kdepim/src/kdepim_sync.cpp 2005-04-12 11:14:21 UTC (rev 489) @@ -175,8 +175,9 @@ } extern "C" { -void get_info(OSyncPluginInfo *info) +void get_info(OSyncEnv *env) { + OSyncPluginInfo *info = osync_plugin_new_info(env); info->version = 1; info->name = "kdepim"; /*FIXME: i18n */ Modified: plugins/kdepim/tests/check_contact =================================================================== --- plugins/kdepim/tests/check_contact 2005-04-11 16:08:06 UTC (rev 488) +++ plugins/kdepim/tests/check_contact 2005-04-12 11:14:21 UTC (rev 489) @@ -8,4 +8,4 @@ exit 1 fi export KDE_DEBUG=true -osyncplugin kdepim --type contact || exit 1 +osyncplugin kdepim --type contact --plugindir ../.libs || exit 1 Modified: plugins/kdepim/tests/check_event =================================================================== --- plugins/kdepim/tests/check_event 2005-04-11 16:08:06 UTC (rev 488) +++ plugins/kdepim/tests/check_event 2005-04-12 11:14:21 UTC (rev 489) @@ -9,4 +9,4 @@ fi export KDE_DEBUG=true -osyncplugin kdepim --type event || exit 1 +osyncplugin kdepim --type event --plugindir ../.libs || exit 1 Modified: plugins/kdepim/tests/check_note =================================================================== --- plugins/kdepim/tests/check_note 2005-04-11 16:08:06 UTC (rev 488) +++ plugins/kdepim/tests/check_note 2005-04-12 11:14:21 UTC (rev 489) @@ -10,5 +10,5 @@ export KDE_DEBUG=true dcop knotes MainApplication-Interface quit knotes -osyncplugin kdepim --type note || exit 1 +osyncplugin kdepim --type note --plugindir ../.libs || exit 1 dcop knotes MainApplication-Interface quit Modified: plugins/kdepim/tests/check_todo =================================================================== --- plugins/kdepim/tests/check_todo 2005-04-11 16:08:06 UTC (rev 488) +++ plugins/kdepim/tests/check_todo 2005-04-12 11:14:21 UTC (rev 489) @@ -8,4 +8,4 @@ exit 1 fi export KDE_DEBUG=true -osyncplugin kdepim --type todo || exit 1 +osyncplugin kdepim --type todo --plugindir ../.libs || exit 1 Modified: plugins/python-module/src/python_module.c =================================================================== --- plugins/python-module/src/python_module.c 2005-04-11 16:08:06 UTC (rev 488) +++ plugins/python-module/src/python_module.c 2005-04-12 11:14:21 UTC (rev 489) @@ -436,7 +436,7 @@ return ret; } -void register_plugins(OSyncEnv *env) +void get_info(OSyncEnv *env) { /* Python initialization */ struct sigaction old_sigint; |
From: <svn...@op...> - 2005-04-11 16:06:56
|
Author: ehabkost Date: 2005-04-11 18:08:06 +0200 (Mon, 11 Apr 2005) New Revision: 488 Removed: branches/python-plugins/ Log: Removing branch. The changes were already merged to trunk. |
From: <svn...@op...> - 2005-04-11 15:40:23
|
Author: ehabkost Date: 2005-04-11 17:41:43 +0200 (Mon, 11 Apr 2005) New Revision: 487 Added: plugins/python-module/setup.py plugins/python-module/src/pywrap.c plugins/python-module/src/sample.py Modified: plugins/python-module/ plugins/python-module/Makefile.am plugins/python-module/configure.in plugins/python-module/src/opensync.pyx plugins/python-module/src/python_module.c plugins/python-module/src/pywrap.h Log: Getting the changes from the python-plugins branch Property changes on: plugins/python-module ___________________________________________________________________ Name: svn:ignore - configure Makefile.in config.h.in autom4te.cache aclocal.m4 build mkinstalldirs depcomp compile config.guess config.sub ltmain.sh missing install-sh + configure Makefile.in config.h.in autom4te.cache aclocal.m4 build mkinstalldirs depcomp compile config.guess config.sub ltmain.sh missing install-sh config.log config.h .libs .deps Makefile config.status stamp-h1 libtool Modified: plugins/python-module/Makefile.am =================================================================== --- plugins/python-module/Makefile.am 2005-04-11 15:23:15 UTC (rev 486) +++ plugins/python-module/Makefile.am 2005-04-11 15:41:43 UTC (rev 487) @@ -1,33 +1,38 @@ plugindir=@OPENSYNC_PLUGINDIR@ pythonplgdir=@OPENSYNC_PYTHONPLG_DIR@ -pythonlibdir=@OPENSYNC_PYTHONLIB_DIR@ OPENSYNC_LIBS=-lopensync #FIXME: set EXTRA_DIST +EXTRA_DIST = \ + src/pywrap.c \ + src/opensync.pyx plugin_LTLIBRARIES = python_module.la python_module_la_SOURCES = src/python_module.c -python_module_la_LDFLAGS = @PYTHON_LDFLAGS@ -avoid-version -export-dynamic -module -python_module_la_CFLAGS = -Wall -Werror +python_module_la_LDFLAGS = @PYTHON_LDFLAGS@ -avoid-version -export-dynamic -module $(OSYNC_LIBS) +python_module_la_CFLAGS = -Wall -Werror $(OSYNC_CFLAGS) python_module_la_CPPFLAGS = @PYTHON_CFLAGS@ \ - -DOPENSYNC_PYTHONPLG_DIR=\"$(pythonplgdir)\" \ - -DOPENSYNC_PYTHONLIB_DIR=\"$(pythonlibdir)\" + -DOPENSYNC_PYTHONPLG_DIR=\"$(pythonplgdir)\" python_module_la_LIBADD = @PYTHON_LIBS@ -# yes, _PROGRAMS. I am trying to avoid using libtool here -pythonlib_PROGRAMS = opensync.so -#FIXME: the lines below don't work. check why (maybe use distutils?) -# only -Werror. pyrex generated code doesn't support -Wall -opensync_so_CFLAGS = -Werror -fPIC -opensync_so_CPPFLAGS = @PYTHON_CFLAGS@ -Werror -nodist_opensync_so_SOURCES = src/opensync.c -opensync_so_LDFLAGS = @PYTHON_LDFLAGS@ -shared -opensync_so_LDADD = $(OPENSYNC_LIBS) - src/opensync.c: src/opensync.pyx pyrexc $< + +# opensync python module building rules +# It uses setup.py and distutils to +# make things easier +opensync.so: src/opensync.c setup.py + CFLAGS="$$CFLAGS $(OSYNC_CFLAGS)" python setup.py build_ext + +all-local: opensync.so + +install-exec-local: + python setup.py install + +clean-local: + python setup.py clean Modified: plugins/python-module/configure.in =================================================================== --- plugins/python-module/configure.in 2005-04-11 15:23:15 UTC (rev 486) +++ plugins/python-module/configure.in 2005-04-11 15:41:43 UTC (rev 487) @@ -66,14 +66,21 @@ AC_SUBST(PYTHON_LIBS) os_cv_python_sdk=yes])])]) -OPENSYNC_PLUGINDIR=${libdir}/opensync/plugins +PKG_CHECK_MODULES(OSYNC, [opensync-1.0]) + +OPENSYNC_CONFIGDIR=$(pkg-config --variable=configdir opensync-1.0) +OPENSYNC_PLUGINDIR=$(pkg-config --variable=plugindir opensync-1.0) +OPENSYNC_FORMATSDIR=$(pkg-config --variable=formatsdir opensync-1.0) +OPENSYNC_HEADERDIR=$(pkg-config --variable=headerdir opensync-1.0) + +AC_SUBST(OPENSYNC_CONFIGDIR) AC_SUBST(OPENSYNC_PLUGINDIR) +AC_SUBST(OPENSYNC_FORMATSDIR) +AC_SUBST(OPENSYNC_HEADERDIR) +#FIXME: Set the python plugin path using a better method, instead of just +# using libdir OPENSYNC_PYTHONPLG_DIR=${libdir}/opensync/python-plugins AC_SUBST(OPENSYNC_PYTHONPLG_DIR) -#FIXME: install opensync module on python library path, not on opensync directory -OPENSYNC_PYTHONLIB_DIR=${libdir}/opensync/python -AC_SUBST(OPENSYNC_PYTHONLIB_DIR) - AC_OUTPUT([Makefile]) Copied: plugins/python-module/setup.py (from rev 324, branches/python-plugins/plugins/python-module/setup.py) Modified: plugins/python-module/src/opensync.pyx =================================================================== --- plugins/python-module/src/opensync.pyx 2005-04-11 15:23:15 UTC (rev 486) +++ plugins/python-module/src/opensync.pyx 2005-04-11 15:41:43 UTC (rev 487) @@ -28,6 +28,8 @@ void osync_change_set_objformat_string(OSyncChange *change, char *name) OSyncObjFormat *osync_change_get_objformat(OSyncChange *change) void osync_change_set_member(OSyncChange *change, OSyncMember *member) + void osync_change_ref(OSyncChange *change) + void osync_change_decref(OSyncChange *change) #objformat methods char *osync_objformat_get_name(OSyncObjFormat *format) @@ -38,9 +40,21 @@ void osync_context_report_success(OSyncContext *context) cdef extern from "pywrap.h": + ctypedef struct PythonPluginInfo + + # pyrex doesn't handle typecasts gracefully, + # so the functions below are just macros that + # do typecasts OSyncMember *osync_member_from_void(void *m) OSyncContext *osync_context_from_void(void *c) + OSyncChange *osync_change_from_void(void *c) + PythonPluginInfo *osync_plginfo_from_void(void *v) + + void pywrap_accept_objtype(PythonPluginInfo *info, char *objtype) + void pywrap_accept_objformat(PythonPluginInfo *info, char *objtype, char *objformat, char *extension) + void pywrap_set_name_and_version(PythonPluginInfo *info, char *name, int version) + cdef class Member: """opensync OSyncMember object""" cdef OSyncMember *memb @@ -58,25 +72,30 @@ v = PyCObject_AsVoidPtr(m) self.memb = osync_member_from_void(v) +# forward declaration cdef class Change cdef class Context: """opensync OSyncContext object""" cdef OSyncContext *ctx - cdef void *v def __new__(self, c): """Never call this method from python code. Objects of this class are created only internally by OpenSync """ - # Another hack like the OSyncMember hack above, - # to be able to convert a python object - # to OSyncContext * cdef void *v v = PyCObject_AsVoidPtr(c) self.ctx = osync_context_from_void(v) def report_change(self, Change chg): + # call _ref() to avoid the change + # from being free()d after destroying + # the python opensync.Change object + osync_change_ref(chg.chg) + #FIXME: Are we supposed to call ref() here, + # or osync_context_report_change() implies + # on a _ref() call? + osync_context_report_change(self.ctx, chg.chg) def report_success(self): @@ -89,12 +108,23 @@ cdef class Change: cdef OSyncChange *chg - def __new__(self, Member member): - self.chg = osync_change_new() - osync_change_set_member(self.chg, member.memb) + def __new__(self, Member member, chg = None): + """Creates a new change object + The chg parameter can be used only internally + by OpenSync. It is a CObject containing + an existing OSyncChange""" + cdef void *v + if chg is None: + self.chg = osync_change_new() + osync_change_set_member(self.chg, member.memb) + else: + v = PyCObject_AsVoidPtr(chg) + self.chg = osync_change_from_void(v) + osync_change_ref(self.chg) + def __dealloc__(self): - osync_change_free(self.chg) + osync_change_decref(self.chg) def set_objformat(self, name): osync_change_set_objformat_string(self.chg, name) @@ -105,5 +135,35 @@ if f: return osync_objformat_get_name(f) else: return None +cdef class PluginInfo: + """opensync OSyncPluginInfo object""" + # python_module.c should be able to tell, + # somehow, which functions should be registered, + # pyinfo is used for that + cdef PythonPluginInfo *info + + def __new__(self, info): + """Never call this method from python code. + + Objects of this class are created only internally by OpenSync + """ + cdef void *v + v = PyCObject_AsVoidPtr(info) + self.info = osync_plginfo_from_void(v) + + def accept_objtype(self, objtype): + pywrap_accept_objtype(self.info, objtype) + + def accept_objformat(self, objtype, objformat, extension = None): + cdef char *ext + if extension is None: + ext = NULL + else: + ext = extension + pywrap_accept_objformat(self.info, objtype, objformat, ext) + + def set_name(self, name, version): + pywrap_set_name_and_version(self.info, name, version); + # vim:ft=python Modified: plugins/python-module/src/python_module.c =================================================================== --- plugins/python-module/src/python_module.c 2005-04-11 15:23:15 UTC (rev 486) +++ plugins/python-module/src/python_module.c 2005-04-11 15:41:43 UTC (rev 487) @@ -10,6 +10,7 @@ #include <opensync/opensync.h> #include <signal.h> +#include "pywrap.h" struct MemberData { PyThreadState *interp_thread; @@ -18,80 +19,61 @@ PyObject *osync_module; }; -/*FIXME: Provide the opensync plugin API to python modules. - * Probably only a OSyncContext class implementation will suffice +/** Insert plugin search path in sys.path * - * (report_change, report_error, report_success, etc.) + * Isn't there an easier way of setting it? * - * Then, add parameters to the initialize, connect, etc. functions - * of the python module + *FIXME: It would be better if we just load modules from + * their filename, not setting the module search path */ - -/** Insert plugin search path to sys.path - * - * Isn't there an easier way of setting it? - */ static int change_sys_path() { int rv = -1; - PyObject *sys, *path, *dir; + PyObject *sys = NULL; + PyObject *path = NULL; + PyObject *dir = NULL; sys = PyImport_ImportModule("sys"); - if (!sys) goto error_sys; + if (!sys) goto error; path = PyObject_GetAttrString(sys, "path"); - if (!path) goto error_path; + if (!path) goto error; dir = PyString_FromString(OPENSYNC_PYTHONPLG_DIR); - if (!dir) goto error_dir; + if (!dir) goto error; if (PyList_Insert(path, 0, dir) < 0) - goto error_insert; + goto error; - /*FIXME: temporary hack, while the opensync module is not - * installed on the python module path - */ - Py_DECREF(dir); - dir = PyString_FromString(OPENSYNC_PYTHONLIB_DIR); - if (!dir) goto error_dir; - - if (PyList_Insert(path, 0, dir) < 0) - goto error_insert; - /* Success */ rv = 0; -error_insert: - Py_DECREF(dir); -error_dir: - Py_DECREF(path); -error_path: - Py_DECREF(sys); -error_sys: +error: + Py_XDECREF(dir); + Py_XDECREF(path); + Py_XDECREF(sys); return rv; } /** Calls the method initialize function * - * The initialize() function should return an object that + * The python initialize() function should return an object that * has the other plugin methods (get_changeinfo, commit, etc.) */ -static void *py_initialize(OSyncMember *member) +static void *py_initialize(OSyncMember *member, OSyncError **error) { + char *name; struct MemberData *data = malloc(sizeof(struct MemberData)); if (!data) + /*FIXME: set error info */ return NULL; - /*FIXME: the code loading should be on the get_info() function, - * if we support registering many plugins by a single - * loadable module. - * - * Suggestion: on get_info(), use the main interpreter, to avoid - * creating interpreter objects only to get plugin information. - * Then on initialize(), load the plugin using another interpreter - * (or thread state?) to keep the members on separated interpreters (or - * threads) - */ + /* The plugin name was set on register_plugin() on plugin_data */ + name = osync_plugin_get_plugin_data(osync_member_get_plugin(member)); + if (!name) + /*FIXME: set error info */ + return NULL; + data->interp_thread = Py_NewInterpreter(); if (0 && !data->interp_thread) { osync_debug("python", 1, "Couldn't initialize python interpreter"); @@ -99,18 +81,21 @@ } if (change_sys_path() < 0) { osync_debug("python", 1, "Exception when initializing python intepreter"); + PyErr_Print(); PyErr_Clear(); goto error_free_interp; } data->osync_module = PyImport_ImportModule("opensync"); if (!data->module) { osync_debug("python", 1, "Couldn't load OpenSync module"); + PyErr_Print(); PyErr_Clear(); goto error_free_interp; } - data->module = PyImport_ImportModule("testmodule"); + data->module = PyImport_ImportModule(name); if (!data->module) { osync_debug("python", 1, "Couldn't load testmodule"); + PyErr_Print(); PyErr_Clear(); goto error_unload_osync_mod; } @@ -119,6 +104,7 @@ data->object = PyObject_CallMethod(data->module, "initialize", NULL); if (!data->object) { osync_debug("python", 1, "Error during initialize()"); + PyErr_Print(); PyErr_Clear(); goto error_unload_module; } @@ -140,88 +126,207 @@ } static void py_finalize(void *data) -{ /*FIXME: Implement me */ +{ struct MemberData *mydata = data; PyEval_AcquireThread(mydata->interp_thread); { PyObject *ret = PyObject_CallMethod(mydata->object, "finalize", NULL); if (!ret) { osync_debug("python", 1, "Error during finalize()"); + PyErr_Print(); PyErr_Clear(); } else Py_DECREF(ret); } Py_DECREF(mydata->object); Py_DECREF(mydata->module); + Py_DECREF(mydata->osync_module); + free(mydata); + Py_EndInterpreter(mydata->interp_thread); } -static void call_module_method(OSyncContext *ctx, char *name) +/** Create a new opensync.Change object for a given change */ +static PyObject *new_pychange(struct MemberData *mydata, OSyncChange *chg) { + PyObject *cobject = NULL; + PyObject *ret = NULL; + + cobject = PyCObject_FromVoidPtr(chg, NULL); + if (!cobject) + goto error; + + /* ret = opensync.Context(member=None, chg=cobject) */ + ret = PyObject_CallMethod(mydata->osync_module, "Change", "OO", Py_None, cobject); + + /* Done, drop reference even on success (the opensync.Change object + * will hold a reference to the cobject) + */ + Py_XDECREF(cobject); + + return ret; + +error: + Py_XDECREF(ret); + Py_XDECREF(cobject); + return NULL; +} + +/** Create a new opensync.Context object for a given context */ +static PyObject *new_pycontext(struct MemberData *mydata, OSyncContext *ctx) +{ + PyObject *cobject = NULL; + PyObject *ret = NULL; + + cobject = PyCObject_FromVoidPtr(ctx, NULL); + if (!cobject) + goto error; + + /* ret = opensync.Context(cobject) */ + ret = PyObject_CallMethod(mydata->osync_module, "Context", "O", cobject); + + /* Done, drop reference even on success (the opensync.Context object + * will hold a reference to the cobject) + */ + Py_XDECREF(cobject); + + return ret; + +error: + Py_XDECREF(ret); + Py_XDECREF(cobject); + return NULL; +} + +/** Call a python method + * + * Methods called using this function can + * have one of these formats: + * + * - function(context) + * - function(context, change) + */ +static void call_module_method(OSyncContext *ctx, OSyncChange *chg, char *name) +{ + PyObject *context = NULL; + PyObject *ret = NULL; + PyObject *change = NULL; + struct MemberData *data = osync_context_get_plugin_data(ctx); PyEval_AcquireThread(data->interp_thread); - /*FIXME: send parameters */ - { - PyObject *ret = PyObject_CallMethod(data->object, name, NULL); - if (!ret) { - osync_debug("python", 1, "Error during %s() method", name); + + if (chg) { + change = new_pychange(data, chg); + if (!change) { + osync_debug("python", 1, "Can't create a change object"); + PyErr_Print(); + osync_context_report_error(ctx, OSYNC_ERROR_GENERIC, "Couldn't create a opensync.Change object"); PyErr_Clear(); - } else - Py_DECREF(ret); + goto out; + } } + + context = new_pycontext(data, ctx); + if (!context) { + osync_debug("python", 1, "Can't create a context object"); + PyErr_Print(); + osync_context_report_error(ctx, OSYNC_ERROR_GENERIC, "Couldn't create a opensync.Context object"); + PyErr_Clear(); + goto out; + } + + if (change) + ret = PyObject_CallMethod(data->object, name, "OO", context, change); + else + ret = PyObject_CallMethod(data->object, name, "O", context); + + if (!ret) { + osync_debug("python", 1, "Error during %s() method", name); + PyErr_Print(); + osync_context_report_error(ctx, OSYNC_ERROR_GENERIC, "Couldn't call python %s() method", name); + PyErr_Clear(); + goto out; + } + +out: + Py_XDECREF(ret); + Py_XDECREF(change); + Py_XDECREF(context); PyEval_ReleaseThread(data->interp_thread); } static void py_connect(OSyncContext *ctx) { - call_module_method(ctx, "connect"); + call_module_method(ctx, NULL, "connect"); } static void py_get_changeinfo(OSyncContext *ctx) { - call_module_method(ctx, "get_changeinfo"); + call_module_method(ctx, NULL, "get_changeinfo"); } static void py_get_data(OSyncContext *ctx, OSyncChange *change) -{ /*FIXME: Implement me */ +{ + call_module_method(ctx, change, "get_data"); } static osync_bool py_access(OSyncContext *ctx, OSyncChange *change) -{ /*FIXME: Implement me */ - return 0; +{ + call_module_method(ctx, change, "access"); + return TRUE; } static osync_bool py_commit_change(OSyncContext *ctx, OSyncChange *change) -{ /*FIXME: Implement me */ +{ + call_module_method(ctx, change, "commit_change"); return 0; } static void py_sync_done(OSyncContext *ctx) -{ /*FIXME: Implement me */ +{ + call_module_method(ctx, NULL, "sync_done"); } static void py_disconnect(OSyncContext *ctx) -{ /*FIXME: Implement me */ +{ + call_module_method(ctx, NULL, "disconnect"); } -void get_info(OSyncPluginInfo *info) +/** Register a new plugin from python module called name. + * + * @todo We need to avoid the loading of the python runtime + * on get_info() somehow, but then we need to store all + * plugin information on another place (including + * accepted objtypes/formats info) + */ +static int register_plugin(OSyncEnv *env, PyObject *osync_module, char *name) { - /* Python initialization */ - struct sigaction old_sigint; + PyObject *module = NULL; + PyObject *get_info_result = NULL; + PythonPluginInfo pyinfo; + PyObject *pyinfo_cobject = NULL; + PyObject *get_info_parm = NULL; + OSyncPluginInfo *info; + int ret = -1; - /* Hack to make python not overwrite SIGINT */ - sigaction(SIGINT, NULL, &old_sigint); /* Save old handler */ - Py_Initialize(); - sigaction(SIGINT, &old_sigint, NULL); /* Restore it */ - PyEval_InitThreads(); - py_initialize(NULL); + osync_trace(TRACE_ENTRY, "register_plugin"); - info->name = "python_module"; - info->version = 1; - info->is_threadsafe = 1; - + module = PyImport_ImportModule(name); + if (!module) { + osync_debug("python", 1, "Couldn't load testmodule"); + PyErr_Print(); + PyErr_Clear(); + goto out; + } + + info = osync_plugin_new_info(env); + if (!info) { + osync_debug("python", 1, "Couldn't create a new plugin object"); + goto error; + } + info->functions.initialize = py_initialize; info->functions.connect = py_connect; info->functions.sync_done = py_sync_done; @@ -230,31 +335,117 @@ info->functions.get_changeinfo = py_get_changeinfo; info->functions.get_data = py_get_data; - /*FIXME: We can't know all accepted objtypes here. Only after - * loading the python module. This is possible only after loading - * the python module. - * - * There are two approaches to fix this: the first one is - * getting the python module name from the configuration - * data, loading the module and registering the formats on - * initialize() time. Then we need to support registering - * the accepted formats on initialize(). Even if we choose - * the other approach described below, maybe it would be a good thing - * make possible to register the accepted formats on initialize - * (but I am not sure, maybe it is a good thing to force the - * format information to be available after get_info() - * - * Another possible fix: make possible to - * a single loadable module report any number of plugin info, - * so the get_info() function here just - * scans the OSYNC_LIBDIR/python-plugins directory, and reports - * all plugins. I think this is more elegant, and the better approach. - * It has the disadvantage of loading the python interpreter at plugin-listing - * time, but if we have any python plugins available, listing them - * is expected, anyway + /*TODO: let the module get_info function fill the fields below: */ + info->is_threadsafe = 1; + + /* The plugin data is just the plugin name, + * to be used on py_initialize() */ - osync_plugin_accept_objtype(info, "contact"); - osync_plugin_accept_objformat(info, "contact", "vcard30"); - osync_plugin_set_commit_objformat(info, "contact", "vcard30", py_commit_change); - osync_plugin_set_access_objformat(info, "contact", "vcard30", py_access); + info->plugin_data = strdup(name); + + /** Build a PluginInfo object for use by get_info */ + pyinfo.commit_fn = py_commit_change; + pyinfo.access_fn = py_access; + pyinfo.osync_info = info; + + pyinfo_cobject = PyCObject_FromVoidPtr(&pyinfo, NULL); + if (!pyinfo_cobject) { + osync_debug("python", 1, "Can't create pyinfo_cobject"); + PyErr_Print(); + PyErr_Clear(); + goto error_cancel_register; + } + + /* get_info_parm = opensync.PluginInfo(pyinfo_cobject) */ + get_info_parm = PyObject_CallMethod(osync_module, "PluginInfo", "O", pyinfo_cobject); + if (!get_info_parm) { + osync_debug("python", 1, "Can't create get_info_parm"); + PyErr_Print(); + PyErr_Clear(); + goto error_cancel_register; + } + /* Call get_info */ + get_info_result = PyObject_CallMethod(module, "get_info", "O", get_info_parm); + if (!get_info_result) { + osync_debug("python", 1, "Error during initialize()"); + PyErr_Print(); + PyErr_Clear(); + goto error_cancel_register; + } + + if (!info->name) { + osync_debug("python", 1, "The plugin didn't set its name!"); + goto error_cancel_register; + } + + osync_trace(TRACE_EXIT, "register_plugin"); + ret = 0; + +out: + Py_XDECREF(get_info_result); + Py_XDECREF(get_info_parm); + Py_XDECREF(pyinfo_cobject); + Py_XDECREF(module); + + return ret; + +error_cancel_register: + osync_plugin_free(info->plugin); +error: + osync_trace(TRACE_EXIT_ERROR, "register_plugin"); + goto out; } + +static int scan_for_plugins(OSyncEnv *env) +{ + PyObject *osync_module; + int ret = -1; + osync_trace(TRACE_ENTRY, "scan_for_plugins"); + + if (change_sys_path() < 0) { + osync_debug("python", 1, "Exception when initializing python intepreter"); + PyErr_Print(); + PyErr_Clear(); + goto out; + } + osync_module = PyImport_ImportModule("opensync"); + if (!osync_module) { + osync_debug("python", 1, "Couldn't load OpenSync module"); + PyErr_Print(); + PyErr_Clear(); + goto out; + } + + /*TODO: do a directory listing */ + char *name = "testmodule"; + { + ret = register_plugin(env, osync_module, name); + if (ret < 0) { + osync_debug("python", 1, "Couldn't register plugin %s", name); + goto out_unload_osync; + } + } + + ret = 0; + + osync_trace(TRACE_EXIT, "scan_for_plugins: ret = %d", ret); + +out_unload_osync: + Py_DECREF(osync_module); +out: + return ret; +} + +void register_plugins(OSyncEnv *env) +{ + /* Python initialization */ + struct sigaction old_sigint; + + /* Hack to make python not overwrite SIGINT */ + sigaction(SIGINT, NULL, &old_sigint); /* Save old handler */ + Py_Initialize(); + sigaction(SIGINT, &old_sigint, NULL); /* Restore it */ + PyEval_InitThreads(); + + scan_for_plugins(env); +} Copied: plugins/python-module/src/pywrap.c (from rev 324, branches/python-plugins/plugins/python-module/src/pywrap.c) Modified: plugins/python-module/src/pywrap.h =================================================================== --- plugins/python-module/src/pywrap.h 2005-04-11 15:23:15 UTC (rev 486) +++ plugins/python-module/src/pywrap.h 2005-04-11 15:41:43 UTC (rev 487) @@ -1,3 +1,10 @@ +/** @file + * + * Auxiliary functions for opensync.pyx pyrex module + * + * @author Eduardo Pereira Habkost + * + */ #ifndef _OSYNC_PYWRAP_H_ #define _OSYNC_PYWRAP_H_ @@ -2,5 +9,21 @@ #include <opensync/opensync.h> + +/** Plugin information necessary to implement accept_objformat + * correctly + */ +typedef struct PythonPluginInfo { + osync_bool (*commit_fn)(OSyncContext *, OSyncChange *); + osync_bool (*access_fn)(OSyncContext *, OSyncChange *); + OSyncPluginInfo *osync_info; +} PythonPluginInfo; + #define osync_member_from_void(v) ((OSyncMember*)(v)) #define osync_context_from_void(v) ((OSyncContext*)(v)) +#define osync_plginfo_from_void(v) ((PythonPluginInfo *)(v)) +#define osync_change_from_void(v) ((OSyncChange*)(v)) +void pywrap_accept_objtype(PythonPluginInfo *info, const char *objtype); +void pywrap_accept_objformat(PythonPluginInfo *info, const char *objtype, const char *objformat, const char *extension); +void pywrap_set_name_and_version(PythonPluginInfo *info, const char *name, int version); + #endif /* _OSYNC_PYWRAP_H_ */ Copied: plugins/python-module/src/sample.py (from rev 324, branches/python-plugins/plugins/python-module/src/sample.py) |
From: <svn...@op...> - 2005-04-11 15:21:44
|
Author: abauer Date: 2005-04-11 17:23:15 +0200 (Mon, 11 Apr 2005) New Revision: 486 Removed: branches/conversion_fixes/ branches/experimental-branch/ branches/experimental-kdepim/ Log: Removed obsolete branches |
From: <svn...@op...> - 2005-04-11 15:09:35
|
Author: ehabkost Date: 2005-04-11 17:11:01 +0200 (Mon, 11 Apr 2005) New Revision: 485 Modified: trunk/opensync/opensync_plugin.c trunk/opensync/opensync_plugin.h trunk/tests/support.c Log: Getting the module loading changes from the python-plugins branch Modified: trunk/opensync/opensync_plugin.c =================================================================== --- trunk/opensync/opensync_plugin.c 2005-04-11 14:39:47 UTC (rev 484) +++ trunk/opensync/opensync_plugin.c 2005-04-11 15:11:01 UTC (rev 485) @@ -200,8 +200,10 @@ * @return Pointer to the plugin on success, NULL otherwise * */ -OSyncPlugin *osync_plugin_load(OSyncEnv *env, const char *path, OSyncError **error) +osync_bool osync_plugin_load(OSyncEnv *env, const char *path, OSyncError **error) { + GModule *module; + osync_trace(TRACE_ENTRY, "osync_plugin_load(%p, %s, %p)", env, path, error); /* Check if this platform supports dynamic @@ -209,37 +211,59 @@ if (!g_module_supported()) { osync_debug("OSPLG", 0, "This platform does not support loading of modules"); osync_error_set(error, OSYNC_ERROR_GENERIC, "This platform does not support loading of modules"); - osync_trace(TRACE_EXIT_ERROR, "osync_plugin_load: %s", osync_error_print(error)); - return NULL; + goto error; } /* Try to open the module or fail if an error occurs */ - OSyncPlugin *plugin = osync_plugin_new(env); - plugin->real_plugin = g_module_open(path, G_MODULE_BIND_LOCAL); - memset(&(plugin->info.functions), 0, sizeof(OSyncPluginFunctions)); - - if (!plugin->real_plugin) { + module = g_module_open(path, 0); //G_MODULE_BIND_LOCAL); + + if (!module) { osync_error_set(error, OSYNC_ERROR_GENERIC, "Unable to open plugin %s: %s", path, g_module_error()); - osync_plugin_free(plugin); - osync_trace(TRACE_EXIT_ERROR, "osync_plugin_load: %s", osync_error_print(error)); - return NULL; + goto error; } + /* There are two type of plugins: simple plugins and multiple plugins. + * + * - Simple plugins register only one plugin object + * - Multiple plugins can register many plugins. Plugins for modules + * in other languages (such as python-module plugin) can use this + * feature + */ void (* fct_info)(OSyncPluginInfo *info); - if (!(fct_info = osync_plugin_get_function(plugin, "get_info", error))) { - osync_debug("OSPLG", 0, "Unable to open plugin: Missing symbol get_info"); - osync_error_set(error, OSYNC_ERROR_GENERIC, "Unable to open plugin: Missing symbol get_info"); - osync_plugin_unload(plugin); - osync_plugin_free(plugin); - osync_trace(TRACE_EXIT_ERROR, "osync_plugin_load: %s", osync_error_print(error)); - return NULL; + void (* fct_register)(OSyncEnv *env); + if (!g_module_symbol(module, "get_info", (void*)&fct_info)) + fct_info = NULL; + if (!g_module_symbol(module, "register_plugins", (void*)&fct_register)) + fct_register = NULL; + if (!fct_info && !fct_register) { + osync_debug("OSPLG", 0, "Unable to open plugin: No get_info or register_plugins symbol"); + osync_error_set(error, OSYNC_ERROR_GENERIC, "Module %s is not a valid OpenSync plugin (no symbol get_info or register_plugins)", path); + goto error_unload; } - fct_info(&(plugin->info)); - plugin->path = g_strdup(path); + /* Simple plugin: call get_info */ + if (fct_info) { + OSyncPlugin *plugin = osync_plugin_new(env); + plugin->real_plugin = module; + fct_info(&(plugin->info)); + plugin->path = g_strdup(path); + osync_trace(TRACE_INTERNAL, "osync_plugin_load: simple plugin: %p", plugin); + } + + /* Multiple plugin: call register_plugins */ + if (fct_register) { + osync_trace(TRACE_INTERNAL, "osync_plugin_load: multiple plugin"); + fct_register(env); + } - osync_trace(TRACE_EXIT, "osync_plugin_load: %p", plugin); - return plugin; + osync_trace(TRACE_EXIT, "osync_plugin_load: success"); + return TRUE; + +error_unload: + g_module_close(module); +error: + osync_trace(TRACE_EXIT_ERROR, "osync_plugin_load: %s", osync_error_print(error)); + return FALSE; } /*! @brief unloads a previously loaded plugin @@ -358,6 +382,18 @@ return plugin->info.timeouts; } +/*! @brief Returns the plugin_info data, set by the plugin + * + * @param plugin Pointer to the plugin + * @returns The void pointer set on plugin->info.plugin_data + */ +void *osync_plugin_get_plugin_data(OSyncPlugin *plugin) +{ + g_assert(plugin); + return plugin->info.plugin_data; +} + + /*! @brief Sets the commit function of a format * * @param info Pointer to a plugin info struct to fill @@ -443,6 +479,23 @@ format_template->committed_all = committed_all; } +/*! @brief Registers a new plugin + * + * This function creates a new OSyncPluginInfo object, that + * can be used to register a new plugin dynamically. This + * can be used by a module to register multiple plugins, + * instead of using get_info() function, that allows + * registering of only one plugin. + */ +OSyncPluginInfo *osync_plugin_new_info(OSyncEnv *env) +{ + OSyncPlugin *plg = osync_plugin_new(env); + if (!plg) + return NULL; + + return &plg->info; +} + /*! @brief Tells opensync that the plugin can accepts this object * * Tells opensync that the plugin can accepts this object. Used by the plugin Modified: trunk/opensync/opensync_plugin.h =================================================================== --- trunk/opensync/opensync_plugin.h 2005-04-11 14:39:47 UTC (rev 484) +++ trunk/opensync/opensync_plugin.h 2005-04-11 15:11:01 UTC (rev 485) @@ -102,12 +102,19 @@ OSyncConfigurationTypes config_type; /** The pointer to the plugin (for internal use) */ OSyncPlugin *plugin; + /** Plugin-specific data + * + * Can be used when a single module registers many plugins, + * such as the python-module plugin + */ + void *plugin_data; } OSyncPluginInfo; OSyncPlugin *osync_plugin_new(OSyncEnv *env); +OSyncPluginInfo *osync_plugin_new_info(OSyncEnv *env); void osync_plugin_free(OSyncPlugin *plugin); -OSyncPlugin *osync_plugin_load(OSyncEnv *env, const char *path, OSyncError **error); +osync_bool osync_plugin_load(OSyncEnv *env, const char *path, OSyncError **error); void osync_plugin_unload(OSyncPlugin *plugin); osync_bool osync_format_plugin_load(OSyncEnv *env, char *path, OSyncError **error); @@ -116,6 +123,7 @@ const char *osync_plugin_get_longname(OSyncPlugin *plugin); const char *osync_plugin_get_description(OSyncPlugin *plugin); OSyncPluginTimeouts osync_plugin_get_timeouts(OSyncPlugin *plugin); +void *osync_plugin_get_plugin_data(OSyncPlugin *plugin); void *osync_plugin_get_function(OSyncPlugin *plugin, const char *name, OSyncError **error); void osync_plugin_accept_objtype(OSyncPluginInfo *info, const char *objtypestr); Modified: trunk/tests/support.c =================================================================== --- trunk/tests/support.c 2005-04-11 14:39:47 UTC (rev 484) +++ trunk/tests/support.c 2005-04-11 15:11:01 UTC (rev 485) @@ -428,7 +428,7 @@ fail_unless(!osync_error_is_set(&error), NULL); char *path = g_strdup_printf("%s/%s", g_get_current_dir(), "mock_sync.so"); - fail_unless(osync_plugin_load(osync, path, &error) != NULL, NULL); + fail_unless(osync_plugin_load(osync, path, &error), NULL); g_free(path); load_format(osync, "contact.so"); |
From: <svn...@op...> - 2005-04-11 14:38:15
|
Author: abauer Date: 2005-04-11 16:39:47 +0200 (Mon, 11 Apr 2005) New Revision: 484 Modified: trunk/tests/check_vcal.c trunk/tests/check_vcard.c trunk/tests/check_vnote.c Log: Made the get_revision unit tests work in different timezones in the world Modified: trunk/tests/check_vcal.c =================================================================== --- trunk/tests/check_vcal.c 2005-04-11 12:02:34 UTC (rev 483) +++ trunk/tests/check_vcal.c 2005-04-11 14:39:47 UTC (rev 484) @@ -287,19 +287,22 @@ START_TEST (event_get_revision1) { - fail_unless(vcal_get_revision("data/vevents/evolution2/1-hour-alarm.vcf") == 1112090762, NULL); + struct tm testtm = {2, 6, 11, 29, 3 - 1, 2005 - 1900, 0, 0, 0}; + fail_unless(vcal_get_revision("data/vevents/evolution2/1-hour-alarm.vcf") == mktime(&testtm), NULL); } END_TEST START_TEST (event_get_revision2) { - fail_unless(vcal_get_revision("data/vevents/evolution2/1-hour-alarm2.vcf") == 1112090881, NULL); + struct tm testtm = {1, 8, 11, 29, 3 - 1, 2005 - 1900, 0, 0, 0}; + fail_unless(vcal_get_revision("data/vevents/evolution2/1-hour-alarm2.vcf") == mktime(&testtm), NULL); } END_TEST START_TEST (event_get_revision3) { - fail_unless(vcal_get_revision("data/vevents/evolution2/1-hour.vcf") == 1112090713, NULL); + struct tm testtm = {13, 5, 11, 29, 3 - 1, 2005 - 1900, 0, 0, 0}; + fail_unless(vcal_get_revision("data/vevents/evolution2/1-hour.vcf") == mktime(&testtm), NULL); } END_TEST Modified: trunk/tests/check_vcard.c =================================================================== --- trunk/tests/check_vcard.c 2005-04-11 12:02:34 UTC (rev 483) +++ trunk/tests/check_vcard.c 2005-04-11 14:39:47 UTC (rev 484) @@ -1,4 +1,5 @@ #include "support.h" +#include <time.h> static void conv_vcard(const char *filename, const char *extension) { @@ -354,25 +355,29 @@ START_TEST (get_revision1) { - fail_unless(vcard_get_revision("data/vcards/evolution2/evo2-full1.vcf") == 1109410884, NULL); + struct tm testtm = {24, 41, 10, 26, 2 - 1, 2005 - 1900, 0, 0, 0}; + fail_unless(vcard_get_revision("data/vcards/evolution2/evo2-full1.vcf") == mktime(&testtm), NULL); } END_TEST START_TEST (get_revision2) { - fail_unless(vcard_get_revision("data/vcards/evolution2/evo2-full2.vcf") == 1109372400, NULL); + struct tm testtm = {0, 0, 0, 26, 2 - 1, 2005 - 1900, 0, 0, 0}; + fail_unless(vcard_get_revision("data/vcards/evolution2/evo2-full2.vcf") == mktime(&testtm), NULL); } END_TEST START_TEST (get_revision3) { - fail_unless(vcard_get_revision("data/vcards/evolution2/evo2-multiline.vcf") == 1109372400, NULL); + struct tm testtm = {0, 0, 0, 26, 2 - 1, 2005 - 1900, 0, 0, 0}; + fail_unless(vcard_get_revision("data/vcards/evolution2/evo2-multiline.vcf") == mktime(&testtm), NULL); } END_TEST START_TEST (get_revision4) { - fail_unless(vcard_get_revision("data/vcards/evolution2/evo2-photo.vcf") == 1109410884, NULL); + struct tm testtm = {24, 41, 10, 26, 2 - 1, 2005 - 1900, 0, 0, 0}; + fail_unless(vcard_get_revision("data/vcards/evolution2/evo2-photo.vcf") == mktime(&testtm), NULL); } END_TEST Modified: trunk/tests/check_vnote.c =================================================================== --- trunk/tests/check_vnote.c 2005-04-11 12:02:34 UTC (rev 483) +++ trunk/tests/check_vnote.c 2005-04-11 14:39:47 UTC (rev 484) @@ -1,4 +1,5 @@ #include "support.h" +#include <time.h> static void conv_vnote(const char *filename) { @@ -187,19 +188,22 @@ START_TEST (get_revision1) { - fail_unless(vnote_get_revision("data/vnotes/vnote1.vnt") == 1112742000, NULL); + struct tm testtm = {0, 0, 0, 6, 4 - 1, 2005 - 1900, 0, 0, 0}; + fail_unless(vnote_get_revision("data/vnotes/vnote1.vnt") == mktime(&testtm), NULL); } END_TEST START_TEST (get_revision2) { - fail_unless(vnote_get_revision("data/vnotes/vnote2.vnt") == 1112745661, NULL); + struct tm testtm = {1, 1, 1, 6, 4 - 1, 2005 - 1900, 0, 0, 0}; + fail_unless(vnote_get_revision("data/vnotes/vnote2.vnt") == mktime(&testtm), NULL); } END_TEST START_TEST (get_revision3) { - fail_unless(vnote_get_revision("data/vnotes/vnote3.vnt") == 1112742000, NULL); + struct tm testtm = {0, 0, 0, 6, 4 - 1, 2005 - 1900, 0, 0, 0}; + fail_unless(vnote_get_revision("data/vnotes/vnote3.vnt") == mktime(&testtm), NULL); } END_TEST |
From: <svn...@op...> - 2005-04-11 12:01:13
|
Author: abauer Date: 2005-04-11 14:02:34 +0200 (Mon, 11 Apr 2005) New Revision: 483 Modified: trunk/opensync/opensync_change.c trunk/opensync/opensync_changecmds.c trunk/tests/check_vcal.c trunk/tests/check_vcard.c trunk/tests/check_vnote.c Log: Fixed a bug when resetting the format and object type using the _string functions Added the detection checks to the vformat tests Modified: trunk/opensync/opensync_change.c =================================================================== --- trunk/opensync/opensync_change.c 2005-04-11 07:13:09 UTC (rev 482) +++ trunk/opensync/opensync_change.c 2005-04-11 12:02:34 UTC (rev 483) @@ -298,7 +298,11 @@ void osync_change_set_objtype_string(OSyncChange *change, const char *name) { g_assert(change); + if (change->objtype_name) + g_free(change->objtype_name); change->objtype_name = g_strdup(name); + //Invalidate the previous object type + change->objtype = NULL; } /*! @brief Gets the object format of a change @@ -346,7 +350,11 @@ void osync_change_set_objformat_string(OSyncChange *change, const char *name) { g_assert(change); + if (change->format_name) + g_free(change->format_name); change->format_name = g_strdup(name); + //Invalidate the previous format + change->format = NULL; } /*! @brief Gets the changetype of a change Modified: trunk/opensync/opensync_changecmds.c =================================================================== --- trunk/opensync/opensync_changecmds.c 2005-04-11 07:13:09 UTC (rev 482) +++ trunk/opensync/opensync_changecmds.c 2005-04-11 12:02:34 UTC (rev 483) @@ -532,6 +532,7 @@ GList *d = NULL; for (d = env->converters; d; d = d->next) { OSyncFormatConverter *converter = d->data; + osync_trace(TRACE_INTERNAL, "running detector %s for format %s\n", converter->source_format->name, osync_change_get_objformat(change)->name); if (!strcmp(converter->source_format->name, osync_change_get_objformat(change)->name)) { if (converter->detect_func && converter->detect_func(env, change->data, change->size)) { osync_trace(TRACE_EXIT, "osync_change_detect_objformat: %p:%s", converter->target_format, converter->target_format->name); Modified: trunk/tests/check_vcal.c =================================================================== --- trunk/tests/check_vcal.c 2005-04-11 07:13:09 UTC (rev 482) +++ trunk/tests/check_vcal.c 2005-04-11 12:02:34 UTC (rev 483) @@ -54,11 +54,19 @@ //Convert to fail_unless(osync_change_convert(conv_env, change, targetformat, &error), NULL); + //Detect the output + osync_change_set_objformat_string(change, "plain"); + fail_unless(osync_change_detect_objformat(conv_env, change, &error) == targetformat, NULL); + //Compare old to new fail_unless(osync_change_compare(newchange, change) == CONV_DATA_SAME, NULL); //Convert back - fail_unless(osync_change_convert(conv_env, change, targetformat, &error), NULL); + fail_unless(osync_change_convert(conv_env, change, sourceformat, &error), NULL); + + //Detect the output again + osync_change_set_objformat_string(change, "plain"); + fail_unless(osync_change_detect_objformat(conv_env, change, &error) == sourceformat, NULL); //Compare again fail_unless(osync_change_compare(newchange, change) == CONV_DATA_SAME, NULL); @@ -302,8 +310,6 @@ END_TEST - - START_TEST (conv_vtodo_evolution2_simple) { conv_vcal("data/vtodos/evolution2/todo-simple.vcf"); Modified: trunk/tests/check_vcard.c =================================================================== --- trunk/tests/check_vcard.c 2005-04-11 07:13:09 UTC (rev 482) +++ trunk/tests/check_vcard.c 2005-04-11 12:02:34 UTC (rev 483) @@ -48,15 +48,23 @@ //Convert to fail_unless(osync_change_convert_extension(conv_env, change, targetformat, extension, &error), NULL); + //Detect the output + osync_change_set_objformat_string(change, "plain"); + fail_unless(osync_change_detect_objformat(conv_env, change, &error) == targetformat, NULL); + //Compare old to new fail_unless(osync_change_compare(newchange, change) == CONV_DATA_SAME, NULL); //Convert back - fail_unless(osync_change_convert_extension(conv_env, change, targetformat, extension, &error), NULL); + fail_unless(osync_change_convert_extension(conv_env, change, sourceformat, extension, &error), NULL); + //Detect the output again + osync_change_set_objformat_string(change, "plain"); + fail_unless(osync_change_detect_objformat(conv_env, change, &error) == sourceformat, NULL); + //Compare again fail_unless(osync_change_compare(newchange, change) == CONV_DATA_SAME, NULL); - + osync_conv_env_free(conv_env); osync_env_finalize(env, NULL); osync_env_free(env); Modified: trunk/tests/check_vnote.c =================================================================== --- trunk/tests/check_vnote.c 2005-04-11 07:13:09 UTC (rev 482) +++ trunk/tests/check_vnote.c 2005-04-11 12:02:34 UTC (rev 483) @@ -45,7 +45,11 @@ fail_unless(osync_change_compare(newchange, change) == CONV_DATA_SAME, NULL); //Convert back - fail_unless(osync_change_convert(conv_env, change, targetformat, &error), NULL); + fail_unless(osync_change_convert(conv_env, change, sourceformat, &error), NULL); + + //Detect the output again + osync_change_set_objformat_string(change, "plain"); + fail_unless(osync_change_detect_objformat(conv_env, change, &error) == sourceformat, NULL); //Compare again fail_unless(osync_change_compare(newchange, change) == CONV_DATA_SAME, NULL); |
From: <svn...@op...> - 2005-04-11 07:11:42
|
Author: abauer Date: 2005-04-11 09:13:09 +0200 (Mon, 11 Apr 2005) New Revision: 482 Modified: trunk/misc/buildtest.sh Log: Clean the example plugin after building Modified: trunk/misc/buildtest.sh =================================================================== --- trunk/misc/buildtest.sh 2005-04-10 20:28:14 UTC (rev 481) +++ trunk/misc/buildtest.sh 2005-04-11 07:13:09 UTC (rev 482) @@ -46,6 +46,8 @@ echo -n "." make install > /dev/null || exit 1 echo "." +make distclean > /dev/null || exit 1 +echo "." cd $TOP_SRCDIR/libopensync-0.?? || exit 1 |
From: <svn...@op...> - 2005-04-10 20:26:49
|
Author: drzeus Date: 2005-04-10 22:28:14 +0200 (Sun, 10 Apr 2005) New Revision: 481 Added: plugins/kdepim/misc/ plugins/kdepim/misc/kdepim.spec.in Modified: plugins/kdepim/Makefile.am plugins/kdepim/configure.in Log: RPM support Modified: plugins/kdepim/Makefile.am =================================================================== --- plugins/kdepim/Makefile.am 2005-04-10 20:14:57 UTC (rev 480) +++ plugins/kdepim/Makefile.am 2005-04-10 20:28:14 UTC (rev 481) @@ -18,7 +18,9 @@ src/kcal.h \ src/osyncbase.h \ src/knotes.h \ - src/KNotesIface.h + src/KNotesIface.h \ + misc/kdepim.spec \ + misc/kdepim.spec.in CLEANFILES = \ KNotesIface_stub.h \ Modified: plugins/kdepim/configure.in =================================================================== --- plugins/kdepim/configure.in 2005-04-10 20:14:57 UTC (rev 480) +++ plugins/kdepim/configure.in 2005-04-10 20:28:14 UTC (rev 481) @@ -46,7 +46,7 @@ AC_C_BIGENDIAN AC_CHECK_KDEMAXPATHLEN -AC_CONFIG_FILES([ Makefile tests/Makefile]) +AC_CONFIG_FILES([ Makefile tests/Makefile misc/kdepim.spec ]) AC_OUTPUT if test "$all_tests" = "bad"; then Property changes on: plugins/kdepim/misc ___________________________________________________________________ Name: svn:ignore + kdepim.spec Added: plugins/kdepim/misc/kdepim.spec.in =================================================================== --- plugins/kdepim/misc/kdepim.spec.in 2005-04-10 20:14:57 UTC (rev 480) +++ plugins/kdepim/misc/kdepim.spec.in 2005-04-10 20:28:14 UTC (rev 481) @@ -0,0 +1,38 @@ +Summary: KDE PIM sync. plugin for OpenSync +Name: @PACKAGE@ +Version: @VERSION@ +Release: 1 +License: GPL +Group: Development/Libraries +Source: %{name}-%{version}.tar.gz +BuildRoot: %{_tmppath}/%{name}-%{version} +Requires: glib2 libopensync qt >= 3.0.0 kdelibs kdepim +BuildRequires: glib2-devel libopensync-devel qt-devel >= 3.0.0 kdelibs-devel kdepim-devel + +%description +This plugin allows applications using OpenSync to synchronise to and from +files stored on disk. + +%prep +%setup -q + +%build +%configure +make + +%install +rm -rf %{buildroot} +make install DESTDIR=%{buildroot} +rm -f %{buildroot}%{_libdir}/opensync/plugins/*.la + +%clean +rm -rf %{buildroot} + +%files +%defattr(-,root,root) +%{_libdir}/opensync/plugins/kdepim_lib.so +%{_libdir}/opensync/plugins/kdepim_sync.so + +%changelog +* Sun Apr 10 2005 Pierre Ossman <dr...@dr...> 0.16-1 +- Initial package |
From: <svn...@op...> - 2005-04-10 20:13:30
|
Author: drzeus Date: 2005-04-10 22:14:57 +0200 (Sun, 10 Apr 2005) New Revision: 480 Modified: plugins/kdepim/Makefile.am Log: KDE has lots of broken classes and GCC 4 is better at detecting these. There was no easy way to remove the warnings so -Werror has to be removed until KDE is fixed to play nice with GCC 4. Modified: plugins/kdepim/Makefile.am =================================================================== --- plugins/kdepim/Makefile.am 2005-04-10 12:31:34 UTC (rev 479) +++ plugins/kdepim/Makefile.am 2005-04-10 20:14:57 UTC (rev 480) @@ -4,7 +4,9 @@ plugindir=@OPENSYNC_PLUGINDIR@ INCLUDES = $(OSYNC_CFLAGS) $(XML_CFLAGS) $(GLIB_CFLAGS) $(KDE_INCLUDES) $(QT_INCLUDES) -I$(top_srcdir) -AM_CXXFLAGS = -Wall -Werror +# KDE has broken classes so -Werror cannot be used (lots of non-virtual +# destructors in polymorphic classes). +AM_CXXFLAGS = -Wall #FIXME: Is there a KDE macro to set this? LIB_KCAL = -lkcal @@ -25,7 +27,7 @@ KNotesIface.kidl kdepim_sync_la_SOURCES = src/kdepim_sync.cpp -kdepim_sync_la_CXXFLAGS = -DPLUGINDIR=\"$(plugindir)\" -DKDEPIM_LIBDIR=\"$(plugindir)\" -Wall -Werror +kdepim_sync_la_CXXFLAGS = -DPLUGINDIR=\"$(plugindir)\" -DKDEPIM_LIBDIR=\"$(plugindir)\" -Wall kdepim_sync_la_LDFLAGS = -avoid-version -export-dynamic -module # ugly hack to make the c++ library work @@ -43,6 +45,6 @@ src/knotes.cpp \ src/kaddrbook.cpp nodist_kdepim_lib_la_SOURCES = KNotesIface_stub.cpp -kdepim_lib_la_CXXFLAGS = -DPLUGINDIR=\"$(plugindir)\" -DKDEPIM_LIBDIR=\"$(plugindir)\" -Wall -Werror +kdepim_lib_la_CXXFLAGS = -DPLUGINDIR=\"$(plugindir)\" -DKDEPIM_LIBDIR=\"$(plugindir)\" -Wall kdepim_lib_la_LDFLAGS = $(KDE_LDFLAGS) -avoid-version -export-dynamic -module kdepim_lib_la_LIBADD = $(KDE_RPATH) $(LIB_KABC) $(LIB_KCAL) -L$(libdir) -L@OPENSYNC_LIBDIR@ -lopensync-xml |
From: <svn...@op...> - 2005-04-10 12:30:14
|
Author: abauer Date: 2005-04-10 14:31:34 +0200 (Sun, 10 Apr 2005) New Revision: 479 Modified: trunk/formats/vformats-xml/xml-vcal.c trunk/formats/vformats-xml/xml-vcard.c trunk/formats/vformats-xml/xml-vnote.c trunk/opensync/opensync_member.c trunk/opensync/opensync_plugin.h trunk/tools/osyncplugin.c Log: Added some parameters so that you can specify which plugins/formats to load on the osyncplugin tool Fixed a bug when handling unknown attributes Modified: trunk/formats/vformats-xml/xml-vcal.c =================================================================== --- trunk/formats/vformats-xml/xml-vcal.c 2005-04-10 12:07:56 UTC (rev 478) +++ trunk/formats/vformats-xml/xml-vcal.c 2005-04-10 12:31:34 UTC (rev 479) @@ -922,7 +922,7 @@ static VFormatAttribute *xml_handle_unknown_attribute(VFormat *vcard, xmlNode *root, const char *encoding) { osync_trace(TRACE_INTERNAL, "Handling unknown xml attribute %s", root->name); - char *name = osxml_find_node(root, "Name"); + char *name = osxml_find_node(root, "NodeName"); VFormatAttribute *attr = vformat_attribute_new(NULL, name); add_value(attr, root, "Content", encoding); vformat_add_attribute(vcard, attr); Modified: trunk/formats/vformats-xml/xml-vcard.c =================================================================== --- trunk/formats/vformats-xml/xml-vcard.c 2005-04-10 12:07:56 UTC (rev 478) +++ trunk/formats/vformats-xml/xml-vcard.c 2005-04-10 12:31:34 UTC (rev 479) @@ -476,7 +476,7 @@ static VFormatAttribute *xml_handle_unknown_attribute(VFormat *vcard, xmlNode *root, const char *encoding) { osync_trace(TRACE_INTERNAL, "Handling unknown xml attribute %s", root->name); - char *name = osxml_find_node(root, "Name"); + char *name = osxml_find_node(root, "NodeName"); VFormatAttribute *attr = vformat_attribute_new(NULL, name); add_value(attr, root, "Content", encoding); vformat_add_attribute(vcard, attr); Modified: trunk/formats/vformats-xml/xml-vnote.c =================================================================== --- trunk/formats/vformats-xml/xml-vnote.c 2005-04-10 12:07:56 UTC (rev 478) +++ trunk/formats/vformats-xml/xml-vnote.c 2005-04-10 12:31:34 UTC (rev 479) @@ -353,7 +353,7 @@ static VFormatAttribute *xml_handle_unknown_attribute(VFormat *vnote, xmlNode *root, const char *encoding) { osync_trace(TRACE_INTERNAL, "Handling unknown xml attribute %s", root->name); - char *name = osxml_find_node(root, "Name"); + char *name = osxml_find_node(root, "NodeName"); VFormatAttribute *attr = vformat_attribute_new(NULL, name); add_value(attr, root, "Content", encoding); vformat_add_attribute(vnote, attr); Modified: trunk/opensync/opensync_member.c =================================================================== --- trunk/opensync/opensync_member.c 2005-04-10 12:07:56 UTC (rev 478) +++ trunk/opensync/opensync_member.c 2005-04-10 12:31:34 UTC (rev 479) @@ -459,6 +459,7 @@ //FIXME free old data member->configdata = g_strdup(data); member->configsize = size; + osync_trace(TRACE_EXIT, "%s", __func__); } @@ -876,7 +877,7 @@ g_assert(member); g_assert(member->plugin); OSyncPluginFunctions functions = member->plugin->info.functions; - g_assert(functions.finalize); + g_assert(functions.initialize); if (!(member->plugindata = functions.initialize(member, error))) { osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(error)); return FALSE; Modified: trunk/opensync/opensync_plugin.h =================================================================== --- trunk/opensync/opensync_plugin.h 2005-04-10 12:07:56 UTC (rev 478) +++ trunk/opensync/opensync_plugin.h 2005-04-10 12:31:34 UTC (rev 479) @@ -109,6 +109,7 @@ OSyncPlugin *osync_plugin_load(OSyncEnv *env, const char *path, OSyncError **error); void osync_plugin_unload(OSyncPlugin *plugin); +osync_bool osync_format_plugin_load(OSyncEnv *env, char *path, OSyncError **error); OSyncPlugin *osync_plugin_from_name(OSyncEnv *osinfo, const char *name); const char *osync_plugin_get_name(OSyncPlugin *plugin); Modified: trunk/tools/osyncplugin.c =================================================================== --- trunk/tools/osyncplugin.c 2005-04-10 12:07:56 UTC (rev 478) +++ trunk/tools/osyncplugin.c 2005-04-10 12:31:34 UTC (rev 479) @@ -278,6 +278,10 @@ static void empty_all(OSyncMember *member) { connect(member); + sync_done(member); + disconnect(member); + + connect(member); GList *chg = get_changes(member); GList *i = NULL; int num_del = 0; @@ -346,6 +350,9 @@ { int i; char *pluginname = NULL; + char *plugindir = NULL; + char *plugin = NULL; + char *format = NULL; char *configfile = NULL; char *objtype = NULL; char *testname = NULL; @@ -368,6 +375,21 @@ i++; if (!objtype) usage (argv[0], 1); + } else if (!strcmp (arg, "--plugindir")) { + plugindir = argv[i + 1]; + i++; + if (!plugindir) + usage (argv[0], 1); + } else if (!strcmp (arg, "--plugin")) { + plugin = argv[i + 1]; + i++; + if (!plugin) + usage (argv[0], 1); + } else if (!strcmp (arg, "--format")) { + format = argv[i + 1]; + i++; + if (!format) + usage (argv[0], 1); } else if (!strcmp (arg, "--help")) { usage (argv[0], 0); } else if (!strcmp (arg, "--alwaysempty")) { @@ -382,6 +404,27 @@ OSyncEnv *env = osync_env_new(); osync_env_set_option(env, "LOAD_GROUPS", "FALSE"); + if (plugin) { + osync_env_set_option(env, "LOAD_PLUGINS", "FALSE"); + if (!osync_plugin_load(env, plugin, &error)) { + printf("Unable to load plugin: %s\n", osync_error_print(&error)); + osync_error_free(&error); + return 1; + } + } else { + if (plugindir) + osync_env_set_option(env, "PLUGINS_DIRECTORY", plugindir); + } + + if (format) { + osync_env_set_option(env, "LOAD_FORMATS", "FALSE"); + if (!osync_format_plugin_load(env, format, &error)) { + printf("Unable to load format: %s\n", osync_error_print(&error)); + osync_error_free(&error); + return 1; + } + } + if (!osync_env_initialize(env, &error)) { printf("Unable to initialize environment: %s\n", osync_error_print(&error)); osync_error_free(&error); @@ -392,22 +435,20 @@ osync_group_set_name(group, osync_rand_str(8)); OSyncMember *member = osync_member_new(group); - char *config; - int size; + char *testdir = g_strdup_printf("%s/plgtest.XXXXXX", g_get_tmp_dir()); + mkdtemp(testdir); + + char *config = NULL; + int size = 0; if (configfile) { if (!osync_file_read(configfile, &config, &size, &error)) { fprintf(stderr, "Unable to read config: %s\n", osync_error_print(&error)); osync_error_free(&error); return 1; } + osync_member_set_config(member, config, size); } - char *testdir = g_strdup_printf("%s/plgtest.XXXXXX", g_get_tmp_dir()); - mkdtemp(testdir); - - if (configfile) - osync_member_set_config(member, config, size); - osync_member_set_pluginname(member, pluginname); osync_member_set_configdir(member, testdir); OSyncMemberFunctions *functions = osync_member_get_memberfunctions(member); |
From: <svn...@op...> - 2005-04-10 12:18:54
|
Author: abauer Date: 2005-04-10 14:20:24 +0200 (Sun, 10 Apr 2005) New Revision: 119 Modified: trunk/buildtest.sh trunk/configure.in Log: Tagged version 0.16 Modified: trunk/buildtest.sh =================================================================== --- trunk/buildtest.sh 2005-04-06 21:29:37 UTC (rev 118) +++ trunk/buildtest.sh 2005-04-10 12:20:24 UTC (rev 119) @@ -33,9 +33,9 @@ ./configure --prefix=$TOP_SRCDIR/_inst || exit 1 make install || exit 1 -cd $TOP_SRCDIR/multisync* || exit 1 +cd $TOP_SRCDIR/_inst/bin || exit 1 -msynctool --listplugins || exit 1 +./msynctool --listplugins || exit 1 cd $TOP_SRCDIR Modified: trunk/configure.in =================================================================== --- trunk/configure.in 2005-04-06 21:29:37 UTC (rev 118) +++ trunk/configure.in 2005-04-10 12:20:24 UTC (rev 119) @@ -2,7 +2,7 @@ AC_PREREQ(2.58) AC_INIT(configure.in) -AM_INIT_AUTOMAKE(multisync, 0.90.15) +AM_INIT_AUTOMAKE(multisync, 0.90.16) AM_CONFIG_HEADER(config.h) AC_ISC_POSIX |
From: <svn...@op...> - 2005-04-10 12:06:33
|
Author: abauer Date: 2005-04-10 14:07:56 +0200 (Sun, 10 Apr 2005) New Revision: 478 Added: plugins/file-sync/tests/ plugins/file-sync/tests/Makefile.am plugins/file-sync/tests/check_data Modified: plugins/file-sync/ plugins/file-sync/Makefile.am plugins/file-sync/configure.in plugins/file-sync/src/file_sync.c Log: Added unit tests for the file-sync plugin Fixed a bug where the file-sync plugin would free the configdata Property changes on: plugins/file-sync ___________________________________________________________________ Name: svn:ignore - configure mkinstalldirs Makefile.in config.log depcomp config.status config.guess stamp-h1 config.h autom4te.cache missing aclocal.m4 Makefile install-sh libtool config.h.in config.cache config.sub ltmain.sh stamp-h stamp-h.in libopensync-plugin-file* + configure mkinstalldirs Makefile.in config.log depcomp config.status config.guess stamp-h1 config.h autom4te.cache missing aclocal.m4 Makefile install-sh libtool config.h.in config.cache config.sub ltmain.sh stamp-h stamp-h.in libopensync-plugin-file* .project .cdtproject Modified: plugins/file-sync/Makefile.am =================================================================== --- plugins/file-sync/Makefile.am 2005-04-10 10:13:07 UTC (rev 477) +++ plugins/file-sync/Makefile.am 2005-04-10 12:07:56 UTC (rev 478) @@ -1,6 +1,6 @@ ## Process this file with automake to produce Makefile.in -SUBDIRS = src +SUBDIRS = src tests EXTRA_DIST = \ autogen.sh \ Modified: plugins/file-sync/configure.in =================================================================== --- plugins/file-sync/configure.in 2005-04-10 10:13:07 UTC (rev 477) +++ plugins/file-sync/configure.in 2005-04-10 12:07:56 UTC (rev 478) @@ -1,7 +1,7 @@ dnl Process this file with autoconf to produce a configure script. AC_PREREQ(2.58) -AC_INIT([OpenSync File Plugin], 0.15, [], [libopensync-plugin-file]) +AC_INIT([OpenSync File Plugin], 0.16, [], [libopensync-plugin-file]) AM_INIT_AUTOMAKE(foreign) AC_CONFIG_SRCDIR(src/file_sync.c) AC_CONFIG_HEADER(config.h) @@ -47,6 +47,7 @@ AC_OUTPUT([ Makefile src/Makefile +tests/Makefile misc/file-sync.spec ]) Modified: plugins/file-sync/src/file_sync.c =================================================================== --- plugins/file-sync/src/file_sync.c 2005-04-10 10:13:07 UTC (rev 477) +++ plugins/file-sync/src/file_sync.c 2005-04-10 12:07:56 UTC (rev 478) @@ -83,7 +83,6 @@ fsinfo->member = member; fsinfo->hashtable = osync_hashtable_new(); - g_free(configdata); #ifdef HAVE_FAM Property changes on: plugins/file-sync/tests ___________________________________________________________________ Name: svn:ignore + Makefile Makefile.in Added: plugins/file-sync/tests/Makefile.am =================================================================== --- plugins/file-sync/tests/Makefile.am 2005-04-10 10:13:07 UTC (rev 477) +++ plugins/file-sync/tests/Makefile.am 2005-04-10 12:07:56 UTC (rev 478) @@ -0,0 +1,5 @@ +## Process this file with automake to produce Makefile.in + +EXTRA_DIST = check_data + +TESTS = check_data Property changes on: plugins/file-sync/tests/Makefile.am ___________________________________________________________________ Name: svn:executable + * Added: plugins/file-sync/tests/check_data =================================================================== --- plugins/file-sync/tests/check_data 2005-04-10 10:13:07 UTC (rev 477) +++ plugins/file-sync/tests/check_data 2005-04-10 12:07:56 UTC (rev 478) @@ -0,0 +1,8 @@ +#!/bin/bash + +TMPDIR=`mktemp -d /tmp/osplg.XXXXXX` || exit 1 + +TMPCFG=`mktemp /tmp/osplgcfg.XXXXXX` || exit 1 +echo "<config><path>$TMPDIR</path><recursive>FALSE</recursive></config>" > $TMPCFG + +osyncplugin file-sync --config $TMPCFG --type data --plugin ../src/.libs/file_sync.so --format ../src/.libs/file.so || exit 1 |
From: <svn...@op...> - 2005-04-10 10:11:40
|
Author: abauer Date: 2005-04-10 12:13:07 +0200 (Sun, 10 Apr 2005) New Revision: 477 Modified: plugins/kdepim/ Log: Ignored the autogenerated files Property changes on: plugins/kdepim ___________________________________________________________________ Name: svn:ignore - .libs .deps configure Makefile.in config.log config.status stamp-h1 config.h autom4te.cache libtool aclocal.m4 Makefile kdepim_sync.loT mkinstalldirs depcomp config.guess config.sub ltmain.sh missing install-sh configure.files subdirs stamp-h.in config.cache kdepim_impl_la-kcal.loT config.h.in libopensync-plugin-kdepim* .project .cdtproject + .libs .deps configure Makefile.in config.log config.status stamp-h1 config.h autom4te.cache libtool aclocal.m4 Makefile kdepim_sync.loT mkinstalldirs depcomp config.guess config.sub ltmain.sh missing install-sh configure.files subdirs stamp-h.in config.cache kdepim_impl_la-kcal.loT config.h.in libopensync-plugin-kdepim* .project .cdtproject KNotesIface.kidl KNotesIface_stub.h KNotesIface_skel.cpp KNotesIface_stub.cpp |
From: <svn...@op...> - 2005-04-10 09:58:38
|
Author: abauer Date: 2005-04-10 12:00:07 +0200 (Sun, 10 Apr 2005) New Revision: 476 Modified: plugins/kdepim/Makefile.am Log: Fixed the Makefile.am to work correctly for distcheck Modified: plugins/kdepim/Makefile.am =================================================================== --- plugins/kdepim/Makefile.am 2005-04-10 08:53:39 UTC (rev 475) +++ plugins/kdepim/Makefile.am 2005-04-10 10:00:07 UTC (rev 476) @@ -31,22 +31,18 @@ # ugly hack to make the c++ library work kdepim_sync_la_LIBADD = -lstdc++ -L@OPENSYNC_LIBDIR@ +src/kdepim_impl.cpp: KNotesIface_stub.h + +KNotesIface_stub.h: + dcopidl $(top_srcdir)/src/KNotesIface.h > KNotesIface.kidl + dcopidl2cpp KNotesIface.kidl + dist_kdepim_lib_la_SOURCES = \ - KNotesIface_stub.h \ src/kdepim_impl.cpp \ src/kcal.cpp \ - src/KNotesIface_stub.h \ src/knotes.cpp \ - src/kaddrbook.cpp -nodist_kdepim_lib_la_SOURCES = KNotesIface_stub.h KNotesIface_stub.cpp + src/kaddrbook.cpp +nodist_kdepim_lib_la_SOURCES = KNotesIface_stub.cpp kdepim_lib_la_CXXFLAGS = -DPLUGINDIR=\"$(plugindir)\" -DKDEPIM_LIBDIR=\"$(plugindir)\" -Wall -Werror kdepim_lib_la_LDFLAGS = $(KDE_LDFLAGS) -avoid-version -export-dynamic -module kdepim_lib_la_LIBADD = $(KDE_RPATH) $(LIB_KABC) $(LIB_KCAL) -L$(libdir) -L@OPENSYNC_LIBDIR@ -lopensync-xml - -KNotesIface_stub.h: - dcopidl $(top_srcdir)/src/KNotesIface.h > KNotesIface.kidl - dcopidl2cpp KNotesIface.kidl -KNotesIface_stub.cpp: - dcopidl $(top_srcdir)/src/KNotesIface.h > KNotesIface.kidl - dcopidl2cpp KNotesIface.kidl - |
From: <svn...@op...> - 2005-04-10 08:52:14
|
Author: abauer Date: 2005-04-10 10:53:39 +0200 (Sun, 10 Apr 2005) New Revision: 475 Modified: plugins/kdepim/Makefile.am plugins/kdepim/configure.in plugins/kdepim/src/kdepim_impl.cpp plugins/kdepim/src/knotes.cpp plugins/kdepim/tests/ plugins/kdepim/tests/Makefile.am plugins/kdepim/tests/check_contact plugins/kdepim/tests/check_event plugins/kdepim/tests/check_todo Log: svn merge -r 454:474 ../../branches/experimental-kdepim/ . Merged changes to should have gone into the trunk plugin Modified: plugins/kdepim/Makefile.am =================================================================== --- plugins/kdepim/Makefile.am 2005-04-10 08:30:35 UTC (rev 474) +++ plugins/kdepim/Makefile.am 2005-04-10 08:53:39 UTC (rev 475) @@ -3,7 +3,7 @@ plugindir=@OPENSYNC_PLUGINDIR@ -INCLUDES = $(OSYNC_CFLAGS) $(XML_CFLAGS) $(GLIB_CFLAGS) $(KDE_INCLUDES) $(QT_INCLUDES) +INCLUDES = $(OSYNC_CFLAGS) $(XML_CFLAGS) $(GLIB_CFLAGS) $(KDE_INCLUDES) $(QT_INCLUDES) -I$(top_srcdir) AM_CXXFLAGS = -Wall -Werror #FIXME: Is there a KDE macro to set this? @@ -19,10 +19,10 @@ src/KNotesIface.h CLEANFILES = \ - src/KNotesIface_stub.h \ - src/KNotesIface_skel.cpp \ - src/KNotesIface_stub.cpp \ - src/KNotesIface.kidl + KNotesIface_stub.h \ + KNotesIface_skel.cpp \ + KNotesIface_stub.cpp \ + KNotesIface.kidl kdepim_sync_la_SOURCES = src/kdepim_sync.cpp kdepim_sync_la_CXXFLAGS = -DPLUGINDIR=\"$(plugindir)\" -DKDEPIM_LIBDIR=\"$(plugindir)\" -Wall -Werror @@ -32,16 +32,21 @@ kdepim_sync_la_LIBADD = -lstdc++ -L@OPENSYNC_LIBDIR@ dist_kdepim_lib_la_SOURCES = \ + KNotesIface_stub.h \ src/kdepim_impl.cpp \ src/kcal.cpp \ src/KNotesIface_stub.h \ src/knotes.cpp \ src/kaddrbook.cpp -nodist_kdepim_lib_la_SOURCES = src/KNotesIface_stub.h src/KNotesIface_stub.cpp +nodist_kdepim_lib_la_SOURCES = KNotesIface_stub.h KNotesIface_stub.cpp kdepim_lib_la_CXXFLAGS = -DPLUGINDIR=\"$(plugindir)\" -DKDEPIM_LIBDIR=\"$(plugindir)\" -Wall -Werror kdepim_lib_la_LDFLAGS = $(KDE_LDFLAGS) -avoid-version -export-dynamic -module kdepim_lib_la_LIBADD = $(KDE_RPATH) $(LIB_KABC) $(LIB_KCAL) -L$(libdir) -L@OPENSYNC_LIBDIR@ -lopensync-xml -src/KNotesIface_stub.h: - dcopidl src/KNotesIface.h > src/KNotesIface.kidl - dcopidl2cpp src/KNotesIface.kidl +KNotesIface_stub.h: + dcopidl $(top_srcdir)/src/KNotesIface.h > KNotesIface.kidl + dcopidl2cpp KNotesIface.kidl +KNotesIface_stub.cpp: + dcopidl $(top_srcdir)/src/KNotesIface.h > KNotesIface.kidl + dcopidl2cpp KNotesIface.kidl + Modified: plugins/kdepim/configure.in =================================================================== --- plugins/kdepim/configure.in 2005-04-10 08:30:35 UTC (rev 474) +++ plugins/kdepim/configure.in 2005-04-10 08:53:39 UTC (rev 475) @@ -1,7 +1,7 @@ dnl Process this file with autoconf to produce a configure script. AC_PREREQ(2.58) -AC_INIT([OpenSync Kdepim Plugin], 0.15, [], [libopensync-plugin-kdepim]) +AC_INIT([OpenSync Kdepim Plugin], 0.16, [], [libopensync-plugin-kdepim]) AM_INIT_AUTOMAKE(foreign) AC_CONFIG_SRCDIR(src/kdepim_sync.cpp) AC_CONFIG_HEADER(config.h) Modified: plugins/kdepim/src/kdepim_impl.cpp =================================================================== --- plugins/kdepim/src/kdepim_impl.cpp 2005-04-10 08:30:35 UTC (rev 474) +++ plugins/kdepim/src/kdepim_impl.cpp 2005-04-10 08:53:39 UTC (rev 475) @@ -44,6 +44,7 @@ #include "kaddrbook.h" #include "kcal.h" #include "knotes.h" +static bool sentinal = false; class KdePluginImplementation: public KdePluginImplementationBase { @@ -57,31 +58,42 @@ KApplication *application; + public: KdePluginImplementation(OSyncMember *memb) :member(memb) { } + void initKDE() { + if (sentinal) { + return; + } + + KAboutData aboutData( + "libopensync-kdepim-plugin", // internal program name + "OpenSync-KDE-plugin", // displayable program name. + "0.1", // version string + "OpenSync KDEPIM plugin", // short porgram description + KAboutData::License_GPL, // license type + "(c) 2005, Eduardo Pereira Habkost", // copyright statement + 0, // any free form text + "http://www.opensync.org", // program home page address + "http://www.opensync.org/newticket" // bug report email address + ); + + KCmdLineArgs::init(&aboutData); + application = new KApplication(); + + sentinal = true; + } + bool init(OSyncError **error) { osync_trace(TRACE_ENTRY, "%s(%p)", __func__, error); - KAboutData aboutData( - "libopensync-kdepim-plugin", // internal program name - "OpenSync-KDE-plugin", // displayable program name. - "0.1", // version string - "OpenSync KDEPIM plugin", // short porgram description - KAboutData::License_GPL, // license type - "(c) 2005, Eduardo Pereira Habkost", // copyright statement - 0, // any free form text - "http://www.opensync.org", // program home page address - "http://www.opensync.org/newticket" // bug report email address - ); + initKDE(); - KCmdLineArgs::init(&aboutData); - application = new KApplication(); - hashtable = osync_hashtable_new(); kcal = new KCalDataSource(member, hashtable); @@ -104,10 +116,10 @@ knotes = NULL; } - if (application) { + /*if (application) { delete application; application = NULL; - } + }*/ if (hashtable) osync_hashtable_free(hashtable); Modified: plugins/kdepim/src/knotes.cpp =================================================================== --- plugins/kdepim/src/knotes.cpp 2005-04-10 08:30:35 UTC (rev 474) +++ plugins/kdepim/src/knotes.cpp 2005-04-10 08:53:39 UTC (rev 475) @@ -51,11 +51,11 @@ return FALSE; } - if (!kn_dcop->attach()) { + /*if (!kn_dcop->attach()) { osync_context_report_error(ctx, OSYNC_ERROR_INITIALIZATION, "Unable to attach dcop for knotes"); osync_trace(TRACE_EXIT_ERROR, "%s: Unable to attach dcop for knotes", __func__); return FALSE; - } + }*/ QString appId = kn_dcop->registerAs("opensync"); @@ -223,8 +223,7 @@ QString summary = QString(osxml_find_node(root, "Summary")); QString body = osxml_find_node(root, "Body"); - QString hash, uid; - // end of the ugly-format parsing + QString hash; switch (type) { case CHANGE_ADDED: printf("addding new \"%s\" and \"%s\"\n", (const char*)summary.local8Bit(), (const char*)body.local8Bit()); @@ -265,13 +264,16 @@ return false; } } else { + system("dcop knotes KNotesIface hideAllNotes"); + QString asdasd = "dcop knotes KNotesIface killNote " + uid + " true"; + system((const char*)asdasd.local8Bit()); osync_debug("knotes", 4, "Deleting note %s", (const char*)uid.local8Bit()); - kn_iface->killNote(uid, true); + /*kn_iface->killNote(uid, true); if (kn_iface->status() != DCOPStub::CallSucceeded) { osync_context_report_error(ctx, OSYNC_ERROR_GENERIC, "Unable to delete note"); osync_trace(TRACE_EXIT_ERROR, "%s: Unable to delete note", __func__); return false; - } + }*/ } osync_context_report_success(ctx); Property changes on: plugins/kdepim/tests ___________________________________________________________________ Name: svn:ignore + Makefile Makefile.in Modified: plugins/kdepim/tests/Makefile.am =================================================================== --- plugins/kdepim/tests/Makefile.am 2005-04-10 08:30:35 UTC (rev 474) +++ plugins/kdepim/tests/Makefile.am 2005-04-10 08:53:39 UTC (rev 475) @@ -2,4 +2,4 @@ EXTRA_DIST = check_contact check_event check_todo check_note -TESTS = check_contact check_event check_todo +TESTS = check_contact check_event check_todo check_note Modified: plugins/kdepim/tests/check_contact =================================================================== --- plugins/kdepim/tests/check_contact 2005-04-10 08:30:35 UTC (rev 474) +++ plugins/kdepim/tests/check_contact 2005-04-10 08:53:39 UTC (rev 475) @@ -7,4 +7,5 @@ then exit 1 fi +export KDE_DEBUG=true osyncplugin kdepim --type contact || exit 1 Modified: plugins/kdepim/tests/check_event =================================================================== --- plugins/kdepim/tests/check_event 2005-04-10 08:30:35 UTC (rev 474) +++ plugins/kdepim/tests/check_event 2005-04-10 08:53:39 UTC (rev 475) @@ -8,4 +8,5 @@ exit 1 fi +export KDE_DEBUG=true osyncplugin kdepim --type event || exit 1 Modified: plugins/kdepim/tests/check_todo =================================================================== --- plugins/kdepim/tests/check_todo 2005-04-10 08:30:35 UTC (rev 474) +++ plugins/kdepim/tests/check_todo 2005-04-10 08:53:39 UTC (rev 475) @@ -7,4 +7,5 @@ then exit 1 fi +export KDE_DEBUG=true osyncplugin kdepim --type todo || exit 1 |
From: <svn...@op...> - 2005-04-10 08:29:06
|
Author: abauer Date: 2005-04-10 10:30:35 +0200 (Sun, 10 Apr 2005) New Revision: 474 Modified: branches/experimental-kdepim/Makefile.am Log: Modified Makefile.am to work with distcheck Modified: branches/experimental-kdepim/Makefile.am =================================================================== --- branches/experimental-kdepim/Makefile.am 2005-04-09 18:28:58 UTC (rev 473) +++ branches/experimental-kdepim/Makefile.am 2005-04-10 08:30:35 UTC (rev 474) @@ -3,7 +3,7 @@ plugindir=@OPENSYNC_PLUGINDIR@ -INCLUDES = $(OSYNC_CFLAGS) $(XML_CFLAGS) $(GLIB_CFLAGS) $(KDE_INCLUDES) $(QT_INCLUDES) +INCLUDES = $(OSYNC_CFLAGS) $(XML_CFLAGS) $(GLIB_CFLAGS) $(KDE_INCLUDES) $(QT_INCLUDES) -I$(top_srcdir) AM_CXXFLAGS = -Wall -Werror #FIXME: Is there a KDE macro to set this? @@ -19,10 +19,10 @@ src/KNotesIface.h CLEANFILES = \ - src/KNotesIface_stub.h \ - src/KNotesIface_skel.cpp \ - src/KNotesIface_stub.cpp \ - src/KNotesIface.kidl + KNotesIface_stub.h \ + KNotesIface_skel.cpp \ + KNotesIface_stub.cpp \ + KNotesIface.kidl kdepim_sync_la_SOURCES = src/kdepim_sync.cpp kdepim_sync_la_CXXFLAGS = -DPLUGINDIR=\"$(plugindir)\" -DKDEPIM_LIBDIR=\"$(plugindir)\" -Wall -Werror @@ -31,16 +31,21 @@ # ugly hack to make the c++ library work kdepim_sync_la_LIBADD = -lstdc++ -L@OPENSYNC_LIBDIR@ -kdepim_lib_la_SOURCES = \ - src/KNotesIface_stub.cpp \ +dist_kdepim_lib_la_SOURCES = \ + KNotesIface_stub.h \ src/kdepim_impl.cpp \ src/kcal.cpp \ src/knotes.cpp \ src/kaddrbook.cpp +nodist_kdepim_lib_la_SOURCES = KNotesIface_stub.h KNotesIface_stub.cpp kdepim_lib_la_CXXFLAGS = -DPLUGINDIR=\"$(plugindir)\" -DKDEPIM_LIBDIR=\"$(plugindir)\" -Wall -Werror kdepim_lib_la_LDFLAGS = $(KDE_LDFLAGS) -avoid-version -export-dynamic -module kdepim_lib_la_LIBADD = $(KDE_RPATH) $(LIB_KABC) $(LIB_KCAL) -L$(libdir) -L@OPENSYNC_LIBDIR@ -lopensync-xml -src/KNotesIface_stub.cpp: - dcopidl src/KNotesIface.h > src/KNotesIface.kidl - dcopidl2cpp src/KNotesIface.kidl +KNotesIface_stub.h: + dcopidl $(top_srcdir)/src/KNotesIface.h > KNotesIface.kidl + dcopidl2cpp KNotesIface.kidl +KNotesIface_stub.cpp: + dcopidl $(top_srcdir)/src/KNotesIface.h > KNotesIface.kidl + dcopidl2cpp KNotesIface.kidl + |