From: <svn...@op...> - 2009-10-21 17:56:45
|
Author: cstender Date: Wed Oct 21 19:56:35 2009 New Revision: 5879 URL: http://www.opensync.org/changeset/5879 Log: fixed conversion of name and adress attributes from xmlformat-contact to vcard Modified: format-plugins/vformat/src/xmlformat-common.c Modified: format-plugins/vformat/src/xmlformat-common.c ============================================================================== --- format-plugins/vformat/src/xmlformat-common.c Wed Oct 21 19:39:00 2009 (r5878) +++ format-plugins/vformat/src/xmlformat-common.c Wed Oct 21 19:56:35 2009 (r5879) @@ -227,7 +227,8 @@ vformat_attribute_add_value(attr, tmp); } -void add_value_array(VFormatAttribute *attr, OSyncXMLField *xmlfield, const char *parameterNameArray[], int nParameters, const char *encoding) { +void add_value_array(VFormatAttribute *attr, OSyncXMLField *xmlfield, const char *parameterNameArray[], int nParameters, const char *encoding) +{ const char **parameterValueArray = malloc(nParameters*sizeof(char*)); int n=-1; int i; @@ -235,9 +236,18 @@ parameterValueArray[i]=osync_xmlfield_get_key_value(xmlfield, parameterNameArray[i]); if (parameterValueArray[i]) n=i; } - for (i=0; i<=n; ++i) { + for (i=0; i<=n; ++i) + { const char *tmp = parameterValueArray[i]; - if (!tmp) continue; + + if (!tmp) { + /* If there is no node with the given name, add an empty value to the list. + * This is necessary because some fields (N and ADR, for example) need + * a specific order of the values + */ + tmp = ""; + } + if (needs_charset((unsigned char*)tmp)) if (!vformat_attribute_has_param (attr, "CHARSET")) vformat_attribute_add_param_with_value(attr, "CHARSET", "UTF-8"); |