From: <dg...@su...> - 2009-01-19 20:57:19
|
Author: savago Date: Mon Jan 19 21:56:21 2009 New Revision: 5198 URL: http://www.opensync.org/changeset/5198 Log: Starting to implement initialize function for xslt plugin, for while I commented out some code just to make it compile. Modified: format-plugins/xsltformat/src/xsltformat.c Modified: format-plugins/xsltformat/src/xsltformat.c ============================================================================== --- format-plugins/xsltformat/src/xsltformat.c Mon Jan 19 21:45:20 2009 (r5197) +++ format-plugins/xsltformat/src/xsltformat.c Mon Jan 19 21:56:21 2009 (r5198) @@ -64,7 +64,7 @@ return OSYNC_CONV_DATA_MISMATCH; } -static osync_bool conv_format1_to_format2(char *input, unsigned int inpsize, char **output, unsigned int *outpsize, osync_bool *free_input, const char *config, void *userdata, OSyncError **error) +static osync_bool conv_xslt_to_contact(char *input, unsigned int inpsize, char **output, unsigned int *outpsize, osync_bool *free_input, const char *config, void *userdata, OSyncError **error) { /* * This function can be used to convert your format to another format. @@ -104,7 +104,7 @@ return TRUE; } -static osync_bool conv_format2_to_format1(char *input, unsigned int inpsize, char **output, unsigned int *outpsize, osync_bool *free_input, const char *config, void *userdata, OSyncError **error) +static osync_bool conv_contact_to_xslt(char *input, unsigned int inpsize, char **output, unsigned int *outpsize, osync_bool *free_input, const char *config, void *userdata, OSyncError **error) { /* * This function can be used to convert another format to your format. @@ -179,8 +179,9 @@ * If you return the converter specific data, it is passed * to the conversion and detector function as void *userdata */ - format_data *userdata = osync_try_malloc0(sizeof(format_data), error); +/* format_data *userdata = osync_try_malloc0(sizeof(format_data), error); return (void*)userdata; +*/ } void finalize(void *userdata) @@ -188,42 +189,43 @@ /* * Here you can free all your converter specific data. */ - format_data *formatdata =(format_data*)userdata; +/* format_data *formatdata =(format_data*)userdata; g_free(formatdata->data); g_free(formatdata); +*/ } osync_bool get_conversion_info(OSyncFormatEnv *env, OSyncError **error) { - /* - * Here you have to give opensync some information about your format - * This function will be called directly after the plugin has been loaded - * to get converters that convert between different formats - */ - - OSyncObjFormat *format1 = osync_format_env_find_objformat(env, "<your format name>"); - if (!format1) { - osync_error_set(error, OSYNC_ERROR_GENERIC, "Unable to find <your format name> format"); + /* Supported formats */ + OSyncObjFormat *xslt_contact = osync_format_env_find_objformat(env, "xslt-contact"); + if (!xslt_contact) { + osync_error_set(error, OSYNC_ERROR_GENERIC, "Unable to find xslt-contact" + " format"); return FALSE; } - OSyncObjFormat *format2 = osync_format_env_find_objformat(env, "xmlformat-contact"); - if (!format2) { + OSyncObjFormat *xml_contact = osync_format_env_find_objformat(env, "xmlformat-contact"); + if (!xml_contact) { osync_error_set(error, OSYNC_ERROR_GENERIC, "Unable to find xmlformat-contact format"); return FALSE; } - OSyncFormatConverter *conv = osync_converter_new(OSYNC_CONVERTER_CONV, format1, format2, conv_format1_to_format2, error); + /* XSLT to xml-contact */ + OSyncFormatConverter *conv = osync_converter_new(OSYNC_CONVERTER_CONV, + xslt_contact, xml_contact, + conv_xslt_to_contact, error); if (!conv) return FALSE; - /* set init and finalize functions */ osync_converter_set_initialize_func(conv, initialize); osync_converter_set_finalize_func(conv, finalize); - /* register converter */ osync_format_env_register_converter(env, conv); osync_converter_unref(conv); - conv = osync_converter_new(OSYNC_CONVERTER_CONV, format2, format1, conv_format2_to_format1, error); + /* xml-contact to XSLT */ + conv = osync_converter_new(OSYNC_CONVERTER_CONV, + xml_contact, xslt_contact, + conv_contact_to_xslt, error); if (!conv) return FALSE; /* e.g. this converter doesn't need init and finalize functions therefore don't set them */ |