From ee7d97f1b0c2805fcdcc1a8167354d2c5048c7b4 Mon Sep 17 00:00:00 2001 From: Adenilson Cavalcanti Date: Fri, 17 Oct 2008 11:39:05 -0400 Subject: [PATCH] Adding the new init/finalize format plugin functions (r3689) to format plugin. This will make possible to create the XSLT context only once per sync operation (instead of creating for each call of convert function). --- src/gdata_format.c | 39 +++++++++++++++++++++++++++++++-------- 1 file changed, 31 insertions(+), 8 deletions(-) diff --git a/src/gdata_format.c b/src/gdata_format.c index 2f72e16..efc9ce0 100644 --- a/src/gdata_format.c +++ b/src/gdata_format.c @@ -44,7 +44,7 @@ osync_bool xmlcontact_to_gcontact(char *input, unsigned int inpsize, char **output, unsigned int *outpsize, osync_bool *free_input, const char *config, - OSyncError **error) + void *userdata, OSyncError **error) { return FALSE; } @@ -52,7 +52,7 @@ osync_bool xmlcontact_to_gcontact(char *input, unsigned int inpsize, osync_bool xmlevent_to_gevent(char *input, unsigned int inpsize, char **output, unsigned int *outpsize, osync_bool *free_input, const char *config, - OSyncError **error) + void *userdata, OSyncError **error) { return FALSE; } @@ -60,7 +60,7 @@ osync_bool xmlevent_to_gevent(char *input, unsigned int inpsize, osync_bool gcontact_to_xmlcontact(char *input, unsigned int inpsize, char **output, unsigned int *outpsize, osync_bool *free_input, const char *config, - OSyncError **error) + void *userdata, OSyncError **error) { return FALSE; } @@ -68,7 +68,7 @@ osync_bool gcontact_to_xmlcontact(char *input, unsigned int inpsize, osync_bool gevent_to_xmlevent(char *input, unsigned int inpsize, char **output, unsigned int *outpsize, osync_bool *free_input, const char *config, - OSyncError **error) + void *userdata, OSyncError **error) { return FALSE; } @@ -94,6 +94,20 @@ osync_bool get_format_info(OSyncFormatEnv *env, OSyncError **error) osync_objformat_unref(gevent); } +void *initialize(OSyncError **error) +{ + /* TODO: create XSLT context */ + return NULL; + +} + +void finalize(void *userdata) +{ + /* Cleanup XSLT context */ + if (userdata) + free(userdata); +} + osync_bool get_conversion_info(OSyncFormatEnv *env) { OSyncFormatConverter *conv = NULL; @@ -111,27 +125,36 @@ osync_bool get_conversion_info(OSyncFormatEnv *env) /* from xmlformat to gdata */ conv = osync_converter_new(OSYNC_CONVERTER_CONV, xml_contact, gcontact, - xmlcontact_to_gcontact, error); + xmlcontact_to_gcontact, &error); osync_assert(conv); + osync_converter_set_initialize_func(conv, initialize); + osync_converter_set_finalize_func(conv, finalize); osync_format_env_register_converter(env, conv); osync_converter_unref(conv); conv = osync_converter_new(OSYNC_CONVERTER_CONV, xml_event, gevent, - xmlevent_to_gevent, error); + xmlevent_to_gevent, &error); osync_assert(conv); + osync_converter_set_initialize_func(conv, initialize); + osync_converter_set_finalize_func(conv, finalize); osync_format_env_register_converter(env, conv); osync_converter_unref(conv); /* from gdata to xmlformat */ conv = osync_converter_new(OSYNC_CONVERTER_CONV, gcontact, xml_contact, - gcontact_to_xmlcontact, error); + gcontact_to_xmlcontact, &error); osync_assert(conv); + osync_converter_set_initialize_func(conv, initialize); + osync_converter_set_finalize_func(conv, finalize); osync_format_env_register_converter(env, conv); osync_converter_unref(conv); conv = osync_converter_new(OSYNC_CONVERTER_CONV, gevent, xml_event, - gevent_to_xmlevent, error); + gevent_to_xmlevent, &error); osync_assert(conv); + osync_converter_set_initialize_func(conv, initialize); + osync_converter_set_finalize_func(conv, finalize); + osync_format_env_register_converter(env, conv); osync_converter_unref(conv); -- 2.11.4.GIT