From: <dg...@su...> - 2009-01-10 22:29:22
|
Author: dgollub Date: Sat Jan 10 23:06:42 2009 New Revision: 5077 URL: http://www.opensync.org/changeset/5077 Log: Drop xmlformat-note <-> memo conversion. This will be handled by the xmlformat-plugin. Drop obosolate includes. Modified: plugins/file-sync/src/file.c plugins/file-sync/src/plain.c Modified: plugins/file-sync/src/file.c ============================================================================== --- plugins/file-sync/src/file.c Sat Jan 10 23:00:32 2009 (r5076) +++ plugins/file-sync/src/file.c Sat Jan 10 23:06:42 2009 (r5077) @@ -22,7 +22,6 @@ #include <glib.h> #include <opensync/opensync.h> -#include <opensync/opensync-serializer.h> #include <opensync/opensync-format.h> #include "file.h" Modified: plugins/file-sync/src/plain.c ============================================================================== --- plugins/file-sync/src/plain.c Sat Jan 10 23:00:32 2009 (r5076) +++ plugins/file-sync/src/plain.c Sat Jan 10 23:06:42 2009 (r5077) @@ -22,9 +22,7 @@ #include <glib.h> #include <opensync/opensync.h> -#include <opensync/opensync-serializer.h> #include <opensync/opensync-format.h> -#include <opensync/opensync-xmlformat.h> static OSyncConvCmpResult compare_plain(const char *leftdata, unsigned int leftsize, const char *rightdata, unsigned int rightsize, void *user_data) { @@ -55,66 +53,6 @@ return TRUE; } -static osync_bool conv_xmlformatnote_to_memo(char *input, unsigned int inpsize, char **output, unsigned int *outpsize, osync_bool *free_input, const char *config, void *userdata, OSyncError **error) -{ - const char *body = NULL; - OSyncXMLFormat *xmlformat = (OSyncXMLFormat *)input; - OSyncXMLFieldList *xmlfieldlist = osync_xmlformat_search_field(xmlformat, "Description", error, NULL); - OSyncXMLField *xmlfield = osync_xmlfieldlist_item(xmlfieldlist, 0); - - *free_input = TRUE; - if (xmlfield) { - body = osync_xmlfield_get_key_value(xmlfield, "Content"); - } - if (!body) { - body = ""; - } - *output = g_strdup(body); - *outpsize = strlen(body); - return TRUE; -} - -static osync_bool conv_memo_to_xmlformatnote(char *input, unsigned int inpsize, char **output, unsigned int *outpsize, osync_bool *free_input, const char *config, void *userdata, OSyncError **error) -{ - GString *str; - const char *p; - OSyncXMLFormat *ret = NULL; - OSyncXMLField *field = NULL; - - *free_input = TRUE; - - ret = osync_xmlformat_new("note", error); - if (!ret) - return FALSE; - - if (input && *input) { - field = osync_xmlfield_new(ret, "Description", error); - - str = g_string_new(""); - for (p = input; p && *p; p++) { - switch (*p) { - case '\r': - if (*(p+1) == '\n') - p++; - osync_trace(TRACE_INTERNAL, "[%s] escape carriage returns!!", __func__); - str = g_string_append (str, "\n"); - break; - default: - str = g_string_append_c (str, *p); - break; - } - } - osync_trace(TRACE_SENSITIVE, "Input : %s", str->str); - osync_xmlfield_add_key_value(field, "Content", str->str); - } - - osync_xmlformat_sort(ret); - - *output = (char *)ret; - *outpsize = osync_xmlformat_size(); - return TRUE; -} - static void destroy_plain(char *input, unsigned int inpsize, void *user_data) { g_free(input); @@ -148,35 +86,6 @@ return TRUE; } -osync_bool get_conversion_info(OSyncFormatEnv *env, OSyncError **error) -{ - OSyncObjFormat *memo = osync_format_env_find_objformat(env, "memo"); - OSyncObjFormat *xmlformatnote = osync_format_env_find_objformat(env, "xmlformat-note"); - OSyncFormatConverter *conv = NULL; - if (!memo) { - osync_error_set(error, OSYNC_ERROR_GENERIC, "Unable to find memo format"); - return FALSE; - } - if (!xmlformatnote) { - osync_error_set(error, OSYNC_ERROR_GENERIC, "Unable to find xmlformat-note format"); - return FALSE; - } - conv = osync_converter_new(OSYNC_CONVERTER_CONV, xmlformatnote, memo, conv_xmlformatnote_to_memo, error); - if (!conv) - return FALSE; - - osync_format_env_register_converter(env, conv); - osync_converter_unref(conv); - - conv = osync_converter_new(OSYNC_CONVERTER_CONV, memo, xmlformatnote, conv_memo_to_xmlformatnote, error); - if (!conv) - return FALSE; - - osync_format_env_register_converter(env, conv); - osync_converter_unref(conv); - return TRUE; -} - int get_version(void) { return 1; |