From: <svn...@op...> - 2009-09-18 08:18:57
|
Author: bricks Date: Fri Sep 18 10:18:41 2009 New Revision: 5804 URL: http://www.opensync.org/changeset/5804 Log: Adapted tomboy-note to latest api changes Modified: format-plugins/tomboy-note/src/tomboy_note.c Modified: format-plugins/tomboy-note/src/tomboy_note.c ============================================================================== --- format-plugins/tomboy-note/src/tomboy_note.c Fri Sep 18 09:49:51 2009 (r5803) +++ format-plugins/tomboy-note/src/tomboy_note.c Fri Sep 18 10:18:41 2009 (r5804) @@ -298,14 +298,14 @@ if ( list_tags != NULL ) { xmlfield = osync_xmlfield_new(xmlformat, "Categories", error); for ( list_tag = g_list_first(list_tags); list_tag != NULL; list_tag = list_tag->next ) { - osync_xmlfield_add_key_value(xmlfield, "Category", list_tag->data); + osync_xmlfield_add_key_value(xmlfield, "Category", list_tag->data, error); } } // parse create-date as created node_data = tomboynote_parse_node(doc, "create-date"); if ( node_data != NULL ) { xmlfield = osync_xmlfield_new(xmlformat, "Created", error); - osync_xmlfield_set_key_value(xmlfield, "Content", node_data); + osync_xmlfield_set_key_value(xmlfield, "Content", node_data, error); osync_xmlfield_set_attr(xmlfield, "Value", "DATE-TIME"); osync_xmlfield_set_attr(xmlfield, "TimezoneID", "UTC" ); //TODO get timezone info } @@ -313,13 +313,13 @@ // parse content as description tomboynote_parse_content(doc, str); xmlfield = osync_xmlfield_new(xmlformat, "Description", error); - osync_xmlfield_set_key_value(xmlfield, "Content", str->str); + osync_xmlfield_set_key_value(xmlfield, "Content", str->str, error); //parse last-change-date as lastmodified node_data = tomboynote_parse_node(doc, "last-change-date"); if ( node_data != NULL ) { xmlfield = osync_xmlfield_new(xmlformat, "LastModified", error); - osync_xmlfield_set_key_value(xmlfield, "Content", node_data); + osync_xmlfield_set_key_value(xmlfield, "Content", node_data, error); osync_xmlfield_set_attr(xmlfield, "Value", "DATE-TIME"); osync_xmlfield_set_attr(xmlfield, "TimezoneID", "UTC" ); //TODO get timezone info } @@ -328,15 +328,15 @@ node_data = tomboynote_parse_node(doc, "title"); if ( node_data != NULL ) { xmlfield = osync_xmlfield_new(xmlformat, "Summary", error); - osync_xmlfield_set_key_value(xmlfield, "Content", node_data); + osync_xmlfield_set_key_value(xmlfield, "Content", node_data, error); } // debug output unsigned int size; char *cstr; - osync_xmlformat_assemble(xmlformat, &cstr, &size); + osync_xmlformat_assemble(xmlformat, &cstr, &size, error); //TODO xmlformat should be sorted automatically - osync_xmlformat_sort(xmlformat); + osync_xmlformat_sort(xmlformat, error); osync_trace(TRACE_SENSITIVE, "... Output XMLFormat is: \n%s", cstr); *free_input = TRUE; *output = (char *)xmlformat; @@ -394,7 +394,7 @@ OSyncXMLFormat *xmlformat = (OSyncXMLFormat *)input; unsigned int size; char *str; - osync_xmlformat_assemble(xmlformat, &str, &size); + osync_xmlformat_assemble(xmlformat, &str, &size, error); osync_trace(TRACE_INTERNAL, "Input XMLFormat is:\n%s", str); // osync_trace(TRACE_SENSITIVE, "Input XMLFormat is:\n%s", str); g_free(str); @@ -499,9 +499,10 @@ // format functions -static void destroy_tomboynote(char *input, unsigned int inpsize, void *user_data) +static osync_bool destroy_tomboynote(char *input, unsigned int inpsize, void *user_data, OSyncError **error) { g_free(input); + return TRUE; } osync_bool validate_tomboynote(const char *data, unsigned int size, void *user_data, OSyncError **error) @@ -547,7 +548,7 @@ return FALSE; } -static void create_tomboynote(char **data, unsigned int *size, void *user_data) { +static osync_bool create_tomboynote(char **data, unsigned int *size, void *user_data, OSyncError **error) { osync_trace(TRACE_ENTRY, "%s (%p,%p)", __func__, data, size); xmlNsPtr ns; @@ -564,13 +565,23 @@ xmlDocDumpFormatMemory(doc, (xmlChar **)data, (int *)size, 1); if (!*data) { - osync_trace(TRACE_ERROR, "%s: Unable to create tomboy-note %s", __func__); + goto error; } xmlFreeDoc(doc); xmlFreeNode(node); xmlFreeNs(ns); osync_trace(TRACE_EXIT, "%s", __func__ ); + return TRUE; +error: + xmlFreeDoc(doc); + xmlFreeNode(node); + xmlFreeNs(ns); + + osync_error_set(error, OSYNC_ERROR_CONVERT, "Unable to create tomboy-note from xmlformat"); + osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(error)); + + return FALSE; } /* @@ -603,7 +614,7 @@ osync_objformat_set_demarshal_func(format, demarshal_xmlformat); */ - osync_format_env_register_objformat(env, format); + osync_format_env_register_objformat(env, format, error); osync_objformat_unref(format); return TRUE; |